ccdeck 3.43.3 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +74 -20
  2. package/THIRD_PARTY_NOTICES.md +43 -7
  3. package/bin/cli/commands.js +613 -0
  4. package/bin/cli/help.js +26 -3
  5. package/bin/cli/one-shot.js +2 -2
  6. package/bin/cli/picker.js +86 -0
  7. package/bin/cli/startup.js +13 -0
  8. package/bin/deck.js +60 -16
  9. package/dist/web/assets/{BrowserWatchModal-DZTMfoGp.js → BrowserWatchModal-DMIUygWz.js} +1 -1
  10. package/dist/web/assets/{RadioPanel-DFqW-MUV.js → RadioPanel-DNB_AHSs.js} +1 -1
  11. package/dist/web/assets/TrafficRadar-Ch0LVdSl.js +8 -0
  12. package/dist/web/assets/UsageHistoryModal-Du0ZkIJ1.js +1 -0
  13. package/dist/web/assets/app-CQIstkMF.js +318 -0
  14. package/dist/web/assets/app-Ch-0CYlK.css +1 -0
  15. package/dist/web/assets/{index-DqxnkNs2.js → index-BQbOfxbL.js} +1 -1
  16. package/dist/web/index.html +3 -3
  17. package/package.json +2 -1
  18. package/release-notes.json +40 -0
  19. package/src/server/account-notify.mjs +206 -9
  20. package/src/server/account-pick.mjs +160 -0
  21. package/src/server/account-projects.mjs +55 -15
  22. package/src/server/account-routes.mjs +47 -4
  23. package/src/server/account-watch.mjs +48 -4
  24. package/src/server/activity.mjs +3 -2
  25. package/src/server/args.mjs +112 -2
  26. package/src/server/autoswitch-failover.mjs +138 -0
  27. package/src/server/claude-accounts.mjs +115 -14
  28. package/src/server/claude-dir.mjs +142 -5
  29. package/src/server/claude-identity.mjs +23 -0
  30. package/src/server/cli-lines.mjs +224 -0
  31. package/src/server/codex-cost-usage.mjs +67 -0
  32. package/src/server/codex-enrichment.mjs +53 -9
  33. package/src/server/codex-review-policy.d.mts +4 -0
  34. package/src/server/codex-review-policy.mjs +11 -0
  35. package/src/server/codex-skills.mjs +146 -0
  36. package/src/server/codex-watch.mjs +5 -2
  37. package/src/server/cswap-auto-choice.mjs +53 -0
  38. package/src/server/cswap-auto-loop.mjs +100 -9
  39. package/src/server/deck-client.mjs +112 -0
  40. package/src/server/deck-prefs.mjs +30 -6
  41. package/src/server/event-pipeline.mjs +19 -3
  42. package/src/server/event-routes.mjs +15 -0
  43. package/src/server/exec.mjs +6 -2
  44. package/src/server/index.mjs +17 -1
  45. package/src/server/installer.mjs +149 -8
  46. package/src/server/lan-copies.mjs +43 -5
  47. package/src/server/lan-deck.mjs +3 -0
  48. package/src/server/lan-engine.mjs +7 -2
  49. package/src/server/lan-manifest.mjs +2 -2
  50. package/src/server/lan-serve.mjs +17 -2
  51. package/src/server/lan-sync.mjs +5 -5
  52. package/src/server/lan-wire.mjs +3 -3
  53. package/src/server/login-guard.mjs +162 -0
  54. package/src/server/login-service.mjs +3 -0
  55. package/src/server/pinned-build.mjs +5 -0
  56. package/src/server/prefs-routes.mjs +4 -0
  57. package/src/server/process-command.mjs +4 -1
  58. package/src/server/reports.mjs +7 -1
  59. package/src/server/request-gates.mjs +7 -0
  60. package/src/server/session-read-gate.mjs +5 -3
  61. package/src/server/session-summary.mjs +281 -0
  62. package/src/server/skill-hook.mjs +162 -0
  63. package/src/server/stop-continue-gate.d.mts +8 -0
  64. package/src/server/stop-continue-gate.mjs +77 -0
  65. package/src/server/stop-continue.mjs +544 -0
  66. package/src/server/stop-failure.d.mts +10 -0
  67. package/src/server/stop-failure.mjs +97 -0
  68. package/src/server/swap-log.mjs +19 -10
  69. package/src/server/tool-audit-report.mjs +5 -3
  70. package/src/server/tool-audit-routes.mjs +5 -3
  71. package/src/server/tool-audit-skills.mjs +82 -0
  72. package/src/server/tool-audit.mjs +53 -11
  73. package/src/server/traffic-radar-capture.mjs +10 -1
  74. package/src/server/traffic-radar-monitor.mjs +4 -2
  75. package/src/server/traffic-radar-routes.mjs +13 -0
  76. package/src/server/traffic-radar-service.mjs +133 -0
  77. package/src/server/traffic-radar-wire.mjs +4 -3
  78. package/src/server/usage-day.mjs +1 -1
  79. package/dist/web/assets/TrafficRadar-CPzsjc2O.js +0 -1
  80. package/dist/web/assets/UsageHistoryModal-CfVS-N_Z.js +0 -1
  81. package/dist/web/assets/app-DsHSufBt.css +0 -1
  82. package/dist/web/assets/app-HpFVXK_g.js +0 -310
@@ -1,310 +0,0 @@
1
- var dF=Object.defineProperty;var hF=(e,t,n)=>t in e?dF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var rg=(e,t,n)=>hF(e,typeof t!="symbol"?t+"":t,n);var Ud=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function H0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ag={exports:{}},hc={},og={exports:{}},Ge={};/**
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 US;function fF(){if(US)return Ge;US=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function m(F){return F===null||typeof F!="object"?null:(F=p&&F[p]||F["@@iterator"],typeof F=="function"?F:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,b={};function k(F,B,Z){this.props=F,this.context=B,this.refs=b,this.updater=Z||w}k.prototype.isReactComponent={},k.prototype.setState=function(F,B){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,B,"setState")},k.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function v(){}v.prototype=k.prototype;function N(F,B,Z){this.props=F,this.context=B,this.refs=b,this.updater=Z||w}var S=N.prototype=new v;S.constructor=N,j(S,k.prototype),S.isPureReactComponent=!0;var E=Array.isArray,C=Object.prototype.hasOwnProperty,I={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function $(F,B,Z){var V,X={},Y=null,J=null;if(B!=null)for(V in B.ref!==void 0&&(J=B.ref),B.key!==void 0&&(Y=""+B.key),B)C.call(B,V)&&!R.hasOwnProperty(V)&&(X[V]=B[V]);var ee=arguments.length-2;if(ee===1)X.children=Z;else if(1<ee){for(var ne=Array(ee),le=0;le<ee;le++)ne[le]=arguments[le+2];X.children=ne}if(F&&F.defaultProps)for(V in ee=F.defaultProps,ee)X[V]===void 0&&(X[V]=ee[V]);return{$$typeof:e,type:F,key:Y,ref:J,props:X,_owner:I.current}}function L(F,B){return{$$typeof:e,type:F.type,key:B,ref:F.ref,props:F.props,_owner:F._owner}}function U(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function O(F){var B={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(Z){return B[Z]})}var M=/\/+/g;function q(F,B){return typeof F=="object"&&F!==null&&F.key!=null?O(""+F.key):B.toString(36)}function A(F,B,Z,V,X){var Y=typeof F;(Y==="undefined"||Y==="boolean")&&(F=null);var J=!1;if(F===null)J=!0;else switch(Y){case"string":case"number":J=!0;break;case"object":switch(F.$$typeof){case e:case t:J=!0}}if(J)return J=F,X=X(J),F=V===""?"."+q(J,0):V,E(X)?(Z="",F!=null&&(Z=F.replace(M,"$&/")+"/"),A(X,B,Z,"",function(le){return le})):X!=null&&(U(X)&&(X=L(X,Z+(!X.key||J&&J.key===X.key?"":(""+X.key).replace(M,"$&/")+"/")+F)),B.push(X)),1;if(J=0,V=V===""?".":V+":",E(F))for(var ee=0;ee<F.length;ee++){Y=F[ee];var ne=V+q(Y,ee);J+=A(Y,B,Z,ne,X)}else if(ne=m(F),typeof ne=="function")for(F=ne.call(F),ee=0;!(Y=F.next()).done;)Y=Y.value,ne=V+q(Y,ee++),J+=A(Y,B,Z,ne,X);else if(Y==="object")throw B=String(F),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.");return J}function D(F,B,Z){if(F==null)return F;var V=[],X=0;return A(F,V,"","",function(Y){return B.call(Z,Y,X++)}),V}function P(F){if(F._status===-1){var B=F._result;B=B(),B.then(function(Z){(F._status===0||F._status===-1)&&(F._status=1,F._result=Z)},function(Z){(F._status===0||F._status===-1)&&(F._status=2,F._result=Z)}),F._status===-1&&(F._status=0,F._result=B)}if(F._status===1)return F._result.default;throw F._result}var K={current:null},G={transition:null},W={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:G,ReactCurrentOwner:I};function H(){throw Error("act(...) is not supported in production builds of React.")}return Ge.Children={map:D,forEach:function(F,B,Z){D(F,function(){B.apply(this,arguments)},Z)},count:function(F){var B=0;return D(F,function(){B++}),B},toArray:function(F){return D(F,function(B){return B})||[]},only:function(F){if(!U(F))throw Error("React.Children.only expected to receive a single React element child.");return F}},Ge.Component=k,Ge.Fragment=n,Ge.Profiler=r,Ge.PureComponent=N,Ge.StrictMode=s,Ge.Suspense=d,Ge.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W,Ge.act=H,Ge.cloneElement=function(F,B,Z){if(F==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+F+".");var V=j({},F.props),X=F.key,Y=F.ref,J=F._owner;if(B!=null){if(B.ref!==void 0&&(Y=B.ref,J=I.current),B.key!==void 0&&(X=""+B.key),F.type&&F.type.defaultProps)var ee=F.type.defaultProps;for(ne in B)C.call(B,ne)&&!R.hasOwnProperty(ne)&&(V[ne]=B[ne]===void 0&&ee!==void 0?ee[ne]:B[ne])}var ne=arguments.length-2;if(ne===1)V.children=Z;else if(1<ne){ee=Array(ne);for(var le=0;le<ne;le++)ee[le]=arguments[le+2];V.children=ee}return{$$typeof:e,type:F.type,key:X,ref:Y,props:V,_owner:J}},Ge.createContext=function(F){return F={$$typeof:i,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},F.Provider={$$typeof:o,_context:F},F.Consumer=F},Ge.createElement=$,Ge.createFactory=function(F){var B=$.bind(null,F);return B.type=F,B},Ge.createRef=function(){return{current:null}},Ge.forwardRef=function(F){return{$$typeof:c,render:F}},Ge.isValidElement=U,Ge.lazy=function(F){return{$$typeof:f,_payload:{_status:-1,_result:F},_init:P}},Ge.memo=function(F,B){return{$$typeof:h,type:F,compare:B===void 0?null:B}},Ge.startTransition=function(F){var B=G.transition;G.transition={};try{F()}finally{G.transition=B}},Ge.unstable_act=H,Ge.useCallback=function(F,B){return K.current.useCallback(F,B)},Ge.useContext=function(F){return K.current.useContext(F)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function(F){return K.current.useDeferredValue(F)},Ge.useEffect=function(F,B){return K.current.useEffect(F,B)},Ge.useId=function(){return K.current.useId()},Ge.useImperativeHandle=function(F,B,Z){return K.current.useImperativeHandle(F,B,Z)},Ge.useInsertionEffect=function(F,B){return K.current.useInsertionEffect(F,B)},Ge.useLayoutEffect=function(F,B){return K.current.useLayoutEffect(F,B)},Ge.useMemo=function(F,B){return K.current.useMemo(F,B)},Ge.useReducer=function(F,B,Z){return K.current.useReducer(F,B,Z)},Ge.useRef=function(F){return K.current.useRef(F)},Ge.useState=function(F){return K.current.useState(F)},Ge.useSyncExternalStore=function(F,B,Z){return K.current.useSyncExternalStore(F,B,Z)},Ge.useTransition=function(){return K.current.useTransition()},Ge.version="18.3.1",Ge}var WS;function gu(){return WS||(WS=1,og.exports=fF()),og.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 HS;function pF(){if(HS)return hc;HS=1;var e=gu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(c,d,h){var f,p={},m=null,w=null;h!==void 0&&(m=""+h),d.key!==void 0&&(m=""+d.key),d.ref!==void 0&&(w=d.ref);for(f in d)s.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(c&&c.defaultProps)for(f in d=c.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:c,key:m,ref:w,props:p,_owner:r.current}}return hc.Fragment=n,hc.jsx=i,hc.jsxs=i,hc}var zS;function mF(){return zS||(zS=1,ag.exports=pF()),ag.exports}var a=mF(),Wd={},ig={exports:{}},_n={},lg={exports:{}},cg={};/**
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 VS;function gF(){return VS||(VS=1,(function(e){function t(G,W){var H=G.length;G.push(W);e:for(;0<H;){var F=H-1>>>1,B=G[F];if(0<r(B,W))G[F]=W,G[H]=B,H=F;else break e}}function n(G){return G.length===0?null:G[0]}function s(G){if(G.length===0)return null;var W=G[0],H=G.pop();if(H!==W){G[0]=H;e:for(var F=0,B=G.length,Z=B>>>1;F<Z;){var V=2*(F+1)-1,X=G[V],Y=V+1,J=G[Y];if(0>r(X,H))Y<B&&0>r(J,X)?(G[F]=J,G[Y]=H,F=Y):(G[F]=X,G[V]=H,F=V);else if(Y<B&&0>r(J,H))G[F]=J,G[Y]=H,F=Y;else break e}}return W}function r(G,W){var H=G.sortIndex-W.sortIndex;return H!==0?H:G.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,c=i.now();e.unstable_now=function(){return i.now()-c}}var d=[],h=[],f=1,p=null,m=3,w=!1,j=!1,b=!1,k=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(G){for(var W=n(h);W!==null;){if(W.callback===null)s(h);else if(W.startTime<=G)s(h),W.sortIndex=W.expirationTime,t(d,W);else break;W=n(h)}}function E(G){if(b=!1,S(G),!j)if(n(d)!==null)j=!0,P(C);else{var W=n(h);W!==null&&K(E,W.startTime-G)}}function C(G,W){j=!1,b&&(b=!1,v($),$=-1),w=!0;var H=m;try{for(S(W),p=n(d);p!==null&&(!(p.expirationTime>W)||G&&!O());){var F=p.callback;if(typeof F=="function"){p.callback=null,m=p.priorityLevel;var B=F(p.expirationTime<=W);W=e.unstable_now(),typeof B=="function"?p.callback=B:p===n(d)&&s(d),S(W)}else s(d);p=n(d)}if(p!==null)var Z=!0;else{var V=n(h);V!==null&&K(E,V.startTime-W),Z=!1}return Z}finally{p=null,m=H,w=!1}}var I=!1,R=null,$=-1,L=5,U=-1;function O(){return!(e.unstable_now()-U<L)}function M(){if(R!==null){var G=e.unstable_now();U=G;var W=!0;try{W=R(!0,G)}finally{W?q():(I=!1,R=null)}}else I=!1}var q;if(typeof N=="function")q=function(){N(M)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,D=A.port2;A.port1.onmessage=M,q=function(){D.postMessage(null)}}else q=function(){k(M,0)};function P(G){R=G,I||(I=!0,q())}function K(G,W){$=k(function(){G(e.unstable_now())},W)}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(G){G.callback=null},e.unstable_continueExecution=function(){j||w||(j=!0,P(C))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(G){switch(m){case 1:case 2:case 3:var W=3;break;default:W=m}var H=m;m=W;try{return G()}finally{m=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,W){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var H=m;m=G;try{return W()}finally{m=H}},e.unstable_scheduleCallback=function(G,W,H){var F=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?F+H:F):H=F,G){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=H+B,G={id:f++,callback:W,priorityLevel:G,startTime:H,expirationTime:B,sortIndex:-1},H>F?(G.sortIndex=H,t(h,G),n(d)===null&&G===n(h)&&(b?(v($),$=-1):b=!0,K(E,H-F))):(G.sortIndex=B,t(d,G),j||w||(j=!0,P(C))),G},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(G){var W=m;return function(){var H=m;m=W;try{return G.apply(this,arguments)}finally{m=H}}}})(cg)),cg}var GS;function yF(){return GS||(GS=1,lg.exports=gF()),lg.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 KS;function wF(){if(KS)return _n;KS=1;var e=gu(),t=yF();function n(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,g=1;g<arguments.length;g++)u+="&args[]="+encodeURIComponent(arguments[g]);return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,r={};function o(l,u){i(l,u),i(l+"Capture",u)}function i(l,u){for(r[l]=u,l=0;l<u.length;l++)s.add(u[l])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function m(l){return d.call(p,l)?!0:d.call(f,l)?!1:h.test(l)?p[l]=!0:(f[l]=!0,!1)}function w(l,u,g,x){if(g!==null&&g.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return x?!1:g!==null?!g.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function j(l,u,g,x){if(u===null||typeof u>"u"||w(l,u,g,x))return!0;if(x)return!1;if(g!==null)switch(g.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function b(l,u,g,x,_,T,z){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=x,this.attributeNamespace=_,this.mustUseProperty=g,this.propertyName=l,this.type=u,this.sanitizeURL=T,this.removeEmptyString=z}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){k[l]=new b(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];k[u]=new b(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){k[l]=new b(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){k[l]=new b(l,2,!1,l,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(l){k[l]=new b(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){k[l]=new b(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){k[l]=new b(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){k[l]=new b(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){k[l]=new b(l,5,!1,l.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function N(l){return l[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(l){var u=l.replace(v,N);k[u]=new b(u,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var u=l.replace(v,N);k[u]=new b(u,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var u=l.replace(v,N);k[u]=new b(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){k[l]=new b(l,1,!1,l.toLowerCase(),null,!1,!1)}),k.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){k[l]=new b(l,1,!1,l.toLowerCase(),null,!0,!0)});function S(l,u,g,x){var _=k.hasOwnProperty(u)?k[u]:null;(_!==null?_.type!==0:x||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(j(u,g,_,x)&&(g=null),x||_===null?m(u)&&(g===null?l.removeAttribute(u):l.setAttribute(u,""+g)):_.mustUseProperty?l[_.propertyName]=g===null?_.type===3?!1:"":g:(u=_.attributeName,x=_.attributeNamespace,g===null?l.removeAttribute(u):(_=_.type,g=_===3||_===4&&g===!0?"":""+g,x?l.setAttributeNS(x,u,g):l.setAttribute(u,g))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),I=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),O=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),G=Symbol.iterator;function W(l){return l===null||typeof l!="object"?null:(l=G&&l[G]||l["@@iterator"],typeof l=="function"?l:null)}var H=Object.assign,F;function B(l){if(F===void 0)try{throw Error()}catch(g){var u=g.stack.trim().match(/\n( *(at )?)/);F=u&&u[1]||""}return`
34
- `+F+l}var Z=!1;function V(l,u){if(!l||Z)return"";Z=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ce){var x=ce}Reflect.construct(l,[],u)}else{try{u.call()}catch(ce){x=ce}l.call(u.prototype)}else{try{throw Error()}catch(ce){x=ce}l()}}catch(ce){if(ce&&x&&typeof ce.stack=="string"){for(var _=ce.stack.split(`
35
- `),T=x.stack.split(`
36
- `),z=_.length-1,Q=T.length-1;1<=z&&0<=Q&&_[z]!==T[Q];)Q--;for(;1<=z&&0<=Q;z--,Q--)if(_[z]!==T[Q]){if(z!==1||Q!==1)do if(z--,Q--,0>Q||_[z]!==T[Q]){var te=`
37
- `+_[z].replace(" at new "," at ");return l.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",l.displayName)),te}while(1<=z&&0<=Q);break}}}finally{Z=!1,Error.prepareStackTrace=g}return(l=l?l.displayName||l.name:"")?B(l):""}function X(l){switch(l.tag){case 5:return B(l.type);case 16:return B("Lazy");case 13:return B("Suspense");case 19:return B("SuspenseList");case 0:case 2:case 15:return l=V(l.type,!1),l;case 11:return l=V(l.type.render,!1),l;case 1:return l=V(l.type,!0),l;default:return""}}function Y(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case R:return"Fragment";case I:return"Portal";case L:return"Profiler";case $:return"StrictMode";case q:return"Suspense";case A:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case O:return(l.displayName||"Context")+".Consumer";case U:return(l._context.displayName||"Context")+".Provider";case M:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case D:return u=l.displayName||null,u!==null?u:Y(l.type)||"Memo";case P:u=l._payload,l=l._init;try{return Y(l(u))}catch{}}return null}function J(l){var u=l.type;switch(l.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=u.render,l=l.displayName||l.name||"",u.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(u);case 8:return u===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ee(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ne(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function le(l){var u=ne(l)?"checked":"value",g=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),x=""+l[u];if(!l.hasOwnProperty(u)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var _=g.get,T=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return _.call(this)},set:function(z){x=""+z,T.call(this,z)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return x},setValue:function(z){x=""+z},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function de(l){l._valueTracker||(l._valueTracker=le(l))}function ue(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var g=u.getValue(),x="";return l&&(x=ne(l)?l.checked?"true":"false":l.value),l=x,l!==g?(u.setValue(l),!0):!1}function re(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function pe(l,u){var g=u.checked;return H({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:g??l._wrapperState.initialChecked})}function ye(l,u){var g=u.defaultValue==null?"":u.defaultValue,x=u.checked!=null?u.checked:u.defaultChecked;g=ee(u.value!=null?u.value:g),l._wrapperState={initialChecked:x,initialValue:g,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function _e(l,u){u=u.checked,u!=null&&S(l,"checked",u,!1)}function he(l,u){_e(l,u);var g=ee(u.value),x=u.type;if(g!=null)x==="number"?(g===0&&l.value===""||l.value!=g)&&(l.value=""+g):l.value!==""+g&&(l.value=""+g);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}u.hasOwnProperty("value")?ge(l,u.type,g):u.hasOwnProperty("defaultValue")&&ge(l,u.type,ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function ae(l,u,g){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var x=u.type;if(!(x!=="submit"&&x!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+l._wrapperState.initialValue,g||u===l.value||(l.value=u),l.defaultValue=u}g=l.name,g!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,g!==""&&(l.name=g)}function ge(l,u,g){(u!=="number"||re(l.ownerDocument)!==l)&&(g==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+g&&(l.defaultValue=""+g))}var Se=Array.isArray;function me(l,u,g,x){if(l=l.options,u){u={};for(var _=0;_<g.length;_++)u["$"+g[_]]=!0;for(g=0;g<l.length;g++)_=u.hasOwnProperty("$"+l[g].value),l[g].selected!==_&&(l[g].selected=_),_&&x&&(l[g].defaultSelected=!0)}else{for(g=""+ee(g),u=null,_=0;_<l.length;_++){if(l[_].value===g){l[_].selected=!0,x&&(l[_].defaultSelected=!0);return}u!==null||l[_].disabled||(u=l[_])}u!==null&&(u.selected=!0)}}function $e(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Pe(l,u){var g=u.value;if(g==null){if(g=u.children,u=u.defaultValue,g!=null){if(u!=null)throw Error(n(92));if(Se(g)){if(1<g.length)throw Error(n(93));g=g[0]}u=g}u==null&&(u=""),g=u}l._wrapperState={initialValue:ee(g)}}function qe(l,u){var g=ee(u.value),x=ee(u.defaultValue);g!=null&&(g=""+g,g!==l.value&&(l.value=g),u.defaultValue==null&&l.defaultValue!==g&&(l.defaultValue=g)),x!=null&&(l.defaultValue=""+x)}function Le(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function Qe(l){switch(l){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 je(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?Qe(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var Ae,De=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,g,x,_){MSApp.execUnsafeLocalFunction(function(){return l(u,g,x,_)})}:l})(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{for(Ae=Ae||document.createElement("div"),Ae.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Ae.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function He(l,u){if(u){var g=l.firstChild;if(g&&g===l.lastChild&&g.nodeType===3){g.nodeValue=u;return}}l.textContent=u}var Ze={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},ft=["Webkit","ms","Moz","O"];Object.keys(Ze).forEach(function(l){ft.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),Ze[u]=Ze[l]})});function ut(l,u,g){return u==null||typeof u=="boolean"||u===""?"":g||typeof u!="number"||u===0||Ze.hasOwnProperty(l)&&Ze[l]?(""+u).trim():u+"px"}function Je(l,u){l=l.style;for(var g in u)if(u.hasOwnProperty(g)){var x=g.indexOf("--")===0,_=ut(g,u[g],x);g==="float"&&(g="cssFloat"),x?l.setProperty(g,_):l[g]=_}}var Dt=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function vt(l,u){if(u){if(Dt[l]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function It(l,u){if(l.indexOf("-")===-1)return typeof u.is=="string";switch(l){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 it=null;function Lt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Ft=null,dt=null,St=null;function rt(l){if(l=Zl(l)){if(typeof Ft!="function")throw Error(n(280));var u=l.stateNode;u&&(u=sd(u),Ft(l.stateNode,l.type,u))}}function ys(l){dt?St?St.push(l):St=[l]:dt=l}function Ws(){if(dt){var l=dt,u=St;if(St=dt=null,rt(l),u)for(l=0;l<u.length;l++)rt(u[l])}}function ws(l,u){return l(u)}function Yn(){}var Xn=!1;function wn(l,u,g){if(Xn)return l(u,g);Xn=!0;try{return ws(l,u,g)}finally{Xn=!1,(dt!==null||St!==null)&&(Yn(),Ws())}}function At(l,u){var g=l.stateNode;if(g===null)return null;var x=sd(g);if(x===null)return null;g=x[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(l=l.type,x=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!x;break e;default:l=!1}if(l)return null;if(g&&typeof g!="function")throw Error(n(231,u,typeof g));return g}var an=!1;if(c)try{var Ne={};Object.defineProperty(Ne,"passive",{get:function(){an=!0}}),window.addEventListener("test",Ne,Ne),window.removeEventListener("test",Ne,Ne)}catch{an=!1}function Te(l,u,g,x,_,T,z,Q,te){var ce=Array.prototype.slice.call(arguments,3);try{u.apply(g,ce)}catch(ve){this.onError(ve)}}var We=!1,pt=null,at=!1,Zn=null,Hs={onError:function(l){We=!0,pt=l}};function zs(l,u,g,x,_,T,z,Q,te){We=!1,pt=null,Te.apply(Hs,arguments)}function On(l,u,g,x,_,T,z,Q,te){if(zs.apply(this,arguments),We){if(We){var ce=pt;We=!1,pt=null}else throw Error(n(198));at||(at=!0,Zn=ce)}}function xn(l){var u=l,g=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(g=u.return),l=u.return;while(l)}return u.tag===3?g:null}function Jr(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function Vs(l){if(xn(l)!==l)throw Error(n(188))}function yr(l){var u=l.alternate;if(!u){if(u=xn(l),u===null)throw Error(n(188));return u!==l?null:l}for(var g=l,x=u;;){var _=g.return;if(_===null)break;var T=_.alternate;if(T===null){if(x=_.return,x!==null){g=x;continue}break}if(_.child===T.child){for(T=_.child;T;){if(T===g)return Vs(_),l;if(T===x)return Vs(_),u;T=T.sibling}throw Error(n(188))}if(g.return!==x.return)g=_,x=T;else{for(var z=!1,Q=_.child;Q;){if(Q===g){z=!0,g=_,x=T;break}if(Q===x){z=!0,x=_,g=T;break}Q=Q.sibling}if(!z){for(Q=T.child;Q;){if(Q===g){z=!0,g=T,x=_;break}if(Q===x){z=!0,x=T,g=_;break}Q=Q.sibling}if(!z)throw Error(n(189))}}if(g.alternate!==x)throw Error(n(190))}if(g.tag!==3)throw Error(n(188));return g.stateNode.current===g?l:u}function wr(l){return l=yr(l),l!==null?xr(l):null}function xr(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=xr(l);if(u!==null)return u;l=l.sibling}return null}var Bt=t.unstable_scheduleCallback,Qr=t.unstable_cancelCallback,Gs=t.unstable_shouldYield,vr=t.unstable_requestPaint,ot=t.unstable_now,Ya=t.unstable_getCurrentPriorityLevel,br=t.unstable_ImmediatePriority,xs=t.unstable_UserBlockingPriority,vs=t.unstable_NormalPriority,ea=t.unstable_LowPriority,kr=t.unstable_IdlePriority,Pn=null,Jt=null;function Ks(l){if(Jt&&typeof Jt.onCommitFiberRoot=="function")try{Jt.onCommitFiberRoot(Pn,l,void 0,(l.current.flags&128)===128)}catch{}}var qt=Math.clz32?Math.clz32:lt,we=Math.log,Ye=Math.LN2;function lt(l){return l>>>=0,l===0?32:31-(we(l)/Ye|0)|0}var ht=64,dn=4194304;function bs(l){switch(l&-l){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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function ta(l,u){var g=l.pendingLanes;if(g===0)return 0;var x=0,_=l.suspendedLanes,T=l.pingedLanes,z=g&268435455;if(z!==0){var Q=z&~_;Q!==0?x=bs(Q):(T&=z,T!==0&&(x=bs(T)))}else z=g&~_,z!==0?x=bs(z):T!==0&&(x=bs(T));if(x===0)return 0;if(u!==0&&u!==x&&(u&_)===0&&(_=x&-x,T=u&-u,_>=T||_===16&&(T&4194240)!==0))return u;if((x&4)!==0&&(x|=g&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=x;0<u;)g=31-qt(u),_=1<<g,x|=l[g],u&=~_;return x}function Nl(l,u){switch(l){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xa(l,u){for(var g=l.suspendedLanes,x=l.pingedLanes,_=l.expirationTimes,T=l.pendingLanes;0<T;){var z=31-qt(T),Q=1<<z,te=_[z];te===-1?((Q&g)===0||(Q&x)!==0)&&(_[z]=Nl(Q,u)):te<=u&&(l.expiredLanes|=Q),T&=~Q}}function Ys(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function Sl(){var l=ht;return ht<<=1,(ht&4194240)===0&&(ht=64),l}function Qo(l){for(var u=[],g=0;31>g;g++)u.push(l);return u}function na(l,u,g){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-qt(u),l[u]=g}function Xs(l,u){var g=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0<g;){var _=31-qt(g),T=1<<_;u[_]=0,x[_]=-1,l[_]=-1,g&=~T}}function _l(l,u){var g=l.entangledLanes|=u;for(l=l.entanglements;g;){var x=31-qt(g),_=1<<x;_&u|l[x]&u&&(l[x]|=u),g&=~_}}var st=0;function El(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var Cl,Za,ei,Zs,Fu,Tl=!1,ti=[],Jn=null,hn=null,Js=null,sa=new Map,ra=new Map,Qs=[],Rl="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 Bu(l,u){switch(l){case"focusin":case"focusout":Jn=null;break;case"dragenter":case"dragleave":hn=null;break;case"mouseover":case"mouseout":Js=null;break;case"pointerover":case"pointerout":sa.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":ra.delete(u.pointerId)}}function Ja(l,u,g,x,_,T){return l===null||l.nativeEvent!==T?(l={blockedOn:u,domEventName:g,eventSystemFlags:x,nativeEvent:T,targetContainers:[_]},u!==null&&(u=Zl(u),u!==null&&Za(u)),l):(l.eventSystemFlags|=x,u=l.targetContainers,_!==null&&u.indexOf(_)===-1&&u.push(_),l)}function Al(l,u,g,x,_){switch(u){case"focusin":return Jn=Ja(Jn,l,u,g,x,_),!0;case"dragenter":return hn=Ja(hn,l,u,g,x,_),!0;case"mouseover":return Js=Ja(Js,l,u,g,x,_),!0;case"pointerover":var T=_.pointerId;return sa.set(T,Ja(sa.get(T)||null,l,u,g,x,_)),!0;case"gotpointercapture":return T=_.pointerId,ra.set(T,Ja(ra.get(T)||null,l,u,g,x,_)),!0}return!1}function Ml(l){var u=ao(l.target);if(u!==null){var g=xn(u);if(g!==null){if(u=g.tag,u===13){if(u=Jr(g),u!==null){l.blockedOn=u,Fu(l.priority,function(){ei(g)});return}}else if(u===3&&g.stateNode.current.memoizedState.isDehydrated){l.blockedOn=g.tag===3?g.stateNode.containerInfo:null;return}}}l.blockedOn=null}function ni(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var g=$l(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(g===null){g=l.nativeEvent;var x=new g.constructor(g.type,g);it=x,g.target.dispatchEvent(x),it=null}else return u=Zl(g),u!==null&&Za(u),l.blockedOn=g,!1;u.shift()}return!0}function qu(l,u,g){ni(l)&&g.delete(u)}function Sp(){Tl=!1,Jn!==null&&ni(Jn)&&(Jn=null),hn!==null&&ni(hn)&&(hn=null),Js!==null&&ni(Js)&&(Js=null),sa.forEach(qu),ra.forEach(qu)}function jr(l,u){l.blockedOn===u&&(l.blockedOn=null,Tl||(Tl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Sp)))}function Qa(l){function u(_){return jr(_,l)}if(0<ti.length){jr(ti[0],l);for(var g=1;g<ti.length;g++){var x=ti[g];x.blockedOn===l&&(x.blockedOn=null)}}for(Jn!==null&&jr(Jn,l),hn!==null&&jr(hn,l),Js!==null&&jr(Js,l),sa.forEach(u),ra.forEach(u),g=0;g<Qs.length;g++)x=Qs[g],x.blockedOn===l&&(x.blockedOn=null);for(;0<Qs.length&&(g=Qs[0],g.blockedOn===null);)Ml(g),g.blockedOn===null&&Qs.shift()}var Nr=E.ReactCurrentBatchConfig,si=!0;function _p(l,u,g,x){var _=st,T=Nr.transition;Nr.transition=null;try{st=1,ri(l,u,g,x)}finally{st=_,Nr.transition=T}}function Ep(l,u,g,x){var _=st,T=Nr.transition;Nr.transition=null;try{st=4,ri(l,u,g,x)}finally{st=_,Nr.transition=T}}function ri(l,u,g,x){if(si){var _=$l(l,u,g,x);if(_===null)Kp(l,u,x,ai,g),Bu(l,x);else if(Al(_,l,u,g,x))x.stopPropagation();else if(Bu(l,x),u&4&&-1<Rl.indexOf(l)){for(;_!==null;){var T=Zl(_);if(T!==null&&Cl(T),T=$l(l,u,g,x),T===null&&Kp(l,u,x,ai,g),T===_)break;_=T}_!==null&&x.stopPropagation()}else Kp(l,u,x,null,g)}}var ai=null;function $l(l,u,g,x){if(ai=null,l=Lt(x),l=ao(l),l!==null)if(u=xn(l),u===null)l=null;else if(g=u.tag,g===13){if(l=Jr(u),l!==null)return l;l=null}else if(g===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null);return ai=l,null}function Il(l){switch(l){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(Ya()){case br:return 1;case xs:return 4;case vs:case ea:return 16;case kr:return 536870912;default:return 16}default:return 16}}var vn=null,eo=null,ks=null;function to(){if(ks)return ks;var l,u=eo,g=u.length,x,_="value"in vn?vn.value:vn.textContent,T=_.length;for(l=0;l<g&&u[l]===_[l];l++);var z=g-l;for(x=1;x<=z&&u[g-x]===_[T-x];x++);return ks=_.slice(l,1<x?1-x:void 0)}function no(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function so(){return!0}function Ll(){return!1}function Qt(l){function u(g,x,_,T,z){this._reactName=g,this._targetInst=_,this.type=x,this.nativeEvent=T,this.target=z,this.currentTarget=null;for(var Q in l)l.hasOwnProperty(Q)&&(g=l[Q],this[Q]=g?g(T):T[Q]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?so:Ll,this.isPropagationStopped=Ll,this}return H(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var g=this.nativeEvent;g&&(g.preventDefault?g.preventDefault():typeof g.returnValue!="unknown"&&(g.returnValue=!1),this.isDefaultPrevented=so)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=so)},persist:function(){},isPersistent:so}),u}var aa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ro=Qt(aa),oa=H({},aa,{view:0,detail:0}),Uu=Qt(oa),Ol,Pl,Sr,_r=H({},oa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:oi,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Sr&&(Sr&&l.type==="mousemove"?(Ol=l.screenX-Sr.screenX,Pl=l.screenY-Sr.screenY):Pl=Ol=0,Sr=l),Ol)},movementY:function(l){return"movementY"in l?l.movementY:Pl}}),Wu=Qt(_r),ia=H({},_r,{dataTransfer:0}),Cp=Qt(ia),Tp=H({},oa,{relatedTarget:0}),Dl=Qt(Tp),Fl=H({},aa,{animationName:0,elapsedTime:0,pseudoElement:0}),Hu=Qt(Fl),Rp=H({},aa,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),zu=Qt(Rp),la=H({},aa,{data:0}),Bl=Qt(la),ql={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ap={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"},Er={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Vu(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=Er[l])?!!u[l]:!1}function oi(){return Vu}var Mp=H({},oa,{key:function(l){if(l.key){var u=ql[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=no(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?Ap[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:oi,charCode:function(l){return l.type==="keypress"?no(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?no(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Gu=Qt(Mp),$p=H({},_r,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ku=Qt($p),er=H({},oa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:oi}),Ip=Qt(er),Lp=H({},aa,{propertyName:0,elapsedTime:0,pseudoElement:0}),Op=Qt(Lp),Pp=H({},_r,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),Yu=Qt(Pp),Qn=[9,13,27,32],Dp=c&&"CompositionEvent"in window,Ul=null;c&&"documentMode"in document&&(Ul=document.documentMode);var i6=c&&"TextEvent"in window&&!Ul,Ij=c&&(!Dp||Ul&&8<Ul&&11>=Ul),Lj=" ",Oj=!1;function Pj(l,u){switch(l){case"keyup":return Qn.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dj(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var ii=!1;function l6(l,u){switch(l){case"compositionend":return Dj(u);case"keypress":return u.which!==32?null:(Oj=!0,Lj);case"textInput":return l=u.data,l===Lj&&Oj?null:l;default:return null}}function c6(l,u){if(ii)return l==="compositionend"||!Dp&&Pj(l,u)?(l=to(),ks=eo=vn=null,ii=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return Ij&&u.locale!=="ko"?null:u.data;default:return null}}var u6={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 Fj(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!u6[l.type]:u==="textarea"}function Bj(l,u,g,x){ys(x),u=ed(u,"onChange"),0<u.length&&(g=new ro("onChange","change",null,g,x),l.push({event:g,listeners:u}))}var Wl=null,Hl=null;function d6(l){rN(l,0)}function Xu(l){var u=hi(l);if(ue(u))return l}function h6(l,u){if(l==="change")return u}var qj=!1;if(c){var Fp;if(c){var Bp="oninput"in document;if(!Bp){var Uj=document.createElement("div");Uj.setAttribute("oninput","return;"),Bp=typeof Uj.oninput=="function"}Fp=Bp}else Fp=!1;qj=Fp&&(!document.documentMode||9<document.documentMode)}function Wj(){Wl&&(Wl.detachEvent("onpropertychange",Hj),Hl=Wl=null)}function Hj(l){if(l.propertyName==="value"&&Xu(Hl)){var u=[];Bj(u,Hl,l,Lt(l)),wn(d6,u)}}function f6(l,u,g){l==="focusin"?(Wj(),Wl=u,Hl=g,Wl.attachEvent("onpropertychange",Hj)):l==="focusout"&&Wj()}function p6(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Xu(Hl)}function m6(l,u){if(l==="click")return Xu(u)}function g6(l,u){if(l==="input"||l==="change")return Xu(u)}function y6(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var js=typeof Object.is=="function"?Object.is:y6;function zl(l,u){if(js(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var g=Object.keys(l),x=Object.keys(u);if(g.length!==x.length)return!1;for(x=0;x<g.length;x++){var _=g[x];if(!d.call(u,_)||!js(l[_],u[_]))return!1}return!0}function zj(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Vj(l,u){var g=zj(l);l=0;for(var x;g;){if(g.nodeType===3){if(x=l+g.textContent.length,l<=u&&x>=u)return{node:g,offset:u-l};l=x}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=zj(g)}}function Gj(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Gj(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Kj(){for(var l=window,u=re();u instanceof l.HTMLIFrameElement;){try{var g=typeof u.contentWindow.location.href=="string"}catch{g=!1}if(g)l=u.contentWindow;else break;u=re(l.document)}return u}function qp(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}function w6(l){var u=Kj(),g=l.focusedElem,x=l.selectionRange;if(u!==g&&g&&g.ownerDocument&&Gj(g.ownerDocument.documentElement,g)){if(x!==null&&qp(g)){if(u=x.start,l=x.end,l===void 0&&(l=u),"selectionStart"in g)g.selectionStart=u,g.selectionEnd=Math.min(l,g.value.length);else if(l=(u=g.ownerDocument||document)&&u.defaultView||window,l.getSelection){l=l.getSelection();var _=g.textContent.length,T=Math.min(x.start,_);x=x.end===void 0?T:Math.min(x.end,_),!l.extend&&T>x&&(_=x,x=T,T=_),_=Vj(g,T);var z=Vj(g,x);_&&z&&(l.rangeCount!==1||l.anchorNode!==_.node||l.anchorOffset!==_.offset||l.focusNode!==z.node||l.focusOffset!==z.offset)&&(u=u.createRange(),u.setStart(_.node,_.offset),l.removeAllRanges(),T>x?(l.addRange(u),l.extend(z.node,z.offset)):(u.setEnd(z.node,z.offset),l.addRange(u)))}}for(u=[],l=g;l=l.parentNode;)l.nodeType===1&&u.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<u.length;g++)l=u[g],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var x6=c&&"documentMode"in document&&11>=document.documentMode,li=null,Up=null,Vl=null,Wp=!1;function Yj(l,u,g){var x=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;Wp||li==null||li!==re(x)||(x=li,"selectionStart"in x&&qp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Vl&&zl(Vl,x)||(Vl=x,x=ed(Up,"onSelect"),0<x.length&&(u=new ro("onSelect","select",null,u,g),l.push({event:u,listeners:x}),u.target=li)))}function Zu(l,u){var g={};return g[l.toLowerCase()]=u.toLowerCase(),g["Webkit"+l]="webkit"+u,g["Moz"+l]="moz"+u,g}var ci={animationend:Zu("Animation","AnimationEnd"),animationiteration:Zu("Animation","AnimationIteration"),animationstart:Zu("Animation","AnimationStart"),transitionend:Zu("Transition","TransitionEnd")},Hp={},Xj={};c&&(Xj=document.createElement("div").style,"AnimationEvent"in window||(delete ci.animationend.animation,delete ci.animationiteration.animation,delete ci.animationstart.animation),"TransitionEvent"in window||delete ci.transitionend.transition);function Ju(l){if(Hp[l])return Hp[l];if(!ci[l])return l;var u=ci[l],g;for(g in u)if(u.hasOwnProperty(g)&&g in Xj)return Hp[l]=u[g];return l}var Zj=Ju("animationend"),Jj=Ju("animationiteration"),Qj=Ju("animationstart"),eN=Ju("transitionend"),tN=new Map,nN="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 ca(l,u){tN.set(l,u),o(u,[l])}for(var zp=0;zp<nN.length;zp++){var Vp=nN[zp],v6=Vp.toLowerCase(),b6=Vp[0].toUpperCase()+Vp.slice(1);ca(v6,"on"+b6)}ca(Zj,"onAnimationEnd"),ca(Jj,"onAnimationIteration"),ca(Qj,"onAnimationStart"),ca("dblclick","onDoubleClick"),ca("focusin","onFocus"),ca("focusout","onBlur"),ca(eN,"onTransitionEnd"),i("onMouseEnter",["mouseout","mouseover"]),i("onMouseLeave",["mouseout","mouseover"]),i("onPointerEnter",["pointerout","pointerover"]),i("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 Gl="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(" "),k6=new Set("cancel close invalid load scroll toggle".split(" ").concat(Gl));function sN(l,u,g){var x=l.type||"unknown-event";l.currentTarget=g,On(x,u,void 0,l),l.currentTarget=null}function rN(l,u){u=(u&4)!==0;for(var g=0;g<l.length;g++){var x=l[g],_=x.event;x=x.listeners;e:{var T=void 0;if(u)for(var z=x.length-1;0<=z;z--){var Q=x[z],te=Q.instance,ce=Q.currentTarget;if(Q=Q.listener,te!==T&&_.isPropagationStopped())break e;sN(_,Q,ce),T=te}else for(z=0;z<x.length;z++){if(Q=x[z],te=Q.instance,ce=Q.currentTarget,Q=Q.listener,te!==T&&_.isPropagationStopped())break e;sN(_,Q,ce),T=te}}}if(at)throw l=Zn,at=!1,Zn=null,l}function bt(l,u){var g=u[em];g===void 0&&(g=u[em]=new Set);var x=l+"__bubble";g.has(x)||(aN(u,l,2,!1),g.add(x))}function Gp(l,u,g){var x=0;u&&(x|=4),aN(g,l,x,u)}var Qu="_reactListening"+Math.random().toString(36).slice(2);function Kl(l){if(!l[Qu]){l[Qu]=!0,s.forEach(function(g){g!=="selectionchange"&&(k6.has(g)||Gp(g,!1,l),Gp(g,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[Qu]||(u[Qu]=!0,Gp("selectionchange",!1,u))}}function aN(l,u,g,x){switch(Il(u)){case 1:var _=_p;break;case 4:_=Ep;break;default:_=ri}g=_.bind(null,u,g,l),_=void 0,!an||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(_=!0),x?_!==void 0?l.addEventListener(u,g,{capture:!0,passive:_}):l.addEventListener(u,g,!0):_!==void 0?l.addEventListener(u,g,{passive:_}):l.addEventListener(u,g,!1)}function Kp(l,u,g,x,_){var T=x;if((u&1)===0&&(u&2)===0&&x!==null)e:for(;;){if(x===null)return;var z=x.tag;if(z===3||z===4){var Q=x.stateNode.containerInfo;if(Q===_||Q.nodeType===8&&Q.parentNode===_)break;if(z===4)for(z=x.return;z!==null;){var te=z.tag;if((te===3||te===4)&&(te=z.stateNode.containerInfo,te===_||te.nodeType===8&&te.parentNode===_))return;z=z.return}for(;Q!==null;){if(z=ao(Q),z===null)return;if(te=z.tag,te===5||te===6){x=T=z;continue e}Q=Q.parentNode}}x=x.return}wn(function(){var ce=T,ve=Lt(g),be=[];e:{var xe=tN.get(l);if(xe!==void 0){var Ee=ro,Re=l;switch(l){case"keypress":if(no(g)===0)break e;case"keydown":case"keyup":Ee=Gu;break;case"focusin":Re="focus",Ee=Dl;break;case"focusout":Re="blur",Ee=Dl;break;case"beforeblur":case"afterblur":Ee=Dl;break;case"click":if(g.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=Wu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=Cp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=Ip;break;case Zj:case Jj:case Qj:Ee=Hu;break;case eN:Ee=Op;break;case"scroll":Ee=Uu;break;case"wheel":Ee=Yu;break;case"copy":case"cut":case"paste":Ee=zu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=Ku}var Me=(u&4)!==0,Mt=!Me&&l==="scroll",oe=Me?xe!==null?xe+"Capture":null:xe;Me=[];for(var se=ce,ie;se!==null;){ie=se;var ke=ie.stateNode;if(ie.tag===5&&ke!==null&&(ie=ke,oe!==null&&(ke=At(se,oe),ke!=null&&Me.push(Yl(se,ke,ie)))),Mt)break;se=se.return}0<Me.length&&(xe=new Ee(xe,Re,null,g,ve),be.push({event:xe,listeners:Me}))}}if((u&7)===0){e:{if(xe=l==="mouseover"||l==="pointerover",Ee=l==="mouseout"||l==="pointerout",xe&&g!==it&&(Re=g.relatedTarget||g.fromElement)&&(ao(Re)||Re[Cr]))break e;if((Ee||xe)&&(xe=ve.window===ve?ve:(xe=ve.ownerDocument)?xe.defaultView||xe.parentWindow:window,Ee?(Re=g.relatedTarget||g.toElement,Ee=ce,Re=Re?ao(Re):null,Re!==null&&(Mt=xn(Re),Re!==Mt||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(Ee=null,Re=ce),Ee!==Re)){if(Me=Wu,ke="onMouseLeave",oe="onMouseEnter",se="mouse",(l==="pointerout"||l==="pointerover")&&(Me=Ku,ke="onPointerLeave",oe="onPointerEnter",se="pointer"),Mt=Ee==null?xe:hi(Ee),ie=Re==null?xe:hi(Re),xe=new Me(ke,se+"leave",Ee,g,ve),xe.target=Mt,xe.relatedTarget=ie,ke=null,ao(ve)===ce&&(Me=new Me(oe,se+"enter",Re,g,ve),Me.target=ie,Me.relatedTarget=Mt,ke=Me),Mt=ke,Ee&&Re)t:{for(Me=Ee,oe=Re,se=0,ie=Me;ie;ie=ui(ie))se++;for(ie=0,ke=oe;ke;ke=ui(ke))ie++;for(;0<se-ie;)Me=ui(Me),se--;for(;0<ie-se;)oe=ui(oe),ie--;for(;se--;){if(Me===oe||oe!==null&&Me===oe.alternate)break t;Me=ui(Me),oe=ui(oe)}Me=null}else Me=null;Ee!==null&&oN(be,xe,Ee,Me,!1),Re!==null&&Mt!==null&&oN(be,Mt,Re,Me,!0)}}e:{if(xe=ce?hi(ce):window,Ee=xe.nodeName&&xe.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&xe.type==="file")var Ie=h6;else if(Fj(xe))if(qj)Ie=g6;else{Ie=p6;var Fe=f6}else(Ee=xe.nodeName)&&Ee.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(Ie=m6);if(Ie&&(Ie=Ie(l,ce))){Bj(be,Ie,g,ve);break e}Fe&&Fe(l,xe,ce),l==="focusout"&&(Fe=xe._wrapperState)&&Fe.controlled&&xe.type==="number"&&ge(xe,"number",xe.value)}switch(Fe=ce?hi(ce):window,l){case"focusin":(Fj(Fe)||Fe.contentEditable==="true")&&(li=Fe,Up=ce,Vl=null);break;case"focusout":Vl=Up=li=null;break;case"mousedown":Wp=!0;break;case"contextmenu":case"mouseup":case"dragend":Wp=!1,Yj(be,g,ve);break;case"selectionchange":if(x6)break;case"keydown":case"keyup":Yj(be,g,ve)}var Be;if(Dp)e:{switch(l){case"compositionstart":var Ue="onCompositionStart";break e;case"compositionend":Ue="onCompositionEnd";break e;case"compositionupdate":Ue="onCompositionUpdate";break e}Ue=void 0}else ii?Pj(l,g)&&(Ue="onCompositionEnd"):l==="keydown"&&g.keyCode===229&&(Ue="onCompositionStart");Ue&&(Ij&&g.locale!=="ko"&&(ii||Ue!=="onCompositionStart"?Ue==="onCompositionEnd"&&ii&&(Be=to()):(vn=ve,eo="value"in vn?vn.value:vn.textContent,ii=!0)),Fe=ed(ce,Ue),0<Fe.length&&(Ue=new Bl(Ue,l,null,g,ve),be.push({event:Ue,listeners:Fe}),Be?Ue.data=Be:(Be=Dj(g),Be!==null&&(Ue.data=Be)))),(Be=i6?l6(l,g):c6(l,g))&&(ce=ed(ce,"onBeforeInput"),0<ce.length&&(ve=new Bl("onBeforeInput","beforeinput",null,g,ve),be.push({event:ve,listeners:ce}),ve.data=Be))}rN(be,u)})}function Yl(l,u,g){return{instance:l,listener:u,currentTarget:g}}function ed(l,u){for(var g=u+"Capture",x=[];l!==null;){var _=l,T=_.stateNode;_.tag===5&&T!==null&&(_=T,T=At(l,g),T!=null&&x.unshift(Yl(l,T,_)),T=At(l,u),T!=null&&x.push(Yl(l,T,_))),l=l.return}return x}function ui(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function oN(l,u,g,x,_){for(var T=u._reactName,z=[];g!==null&&g!==x;){var Q=g,te=Q.alternate,ce=Q.stateNode;if(te!==null&&te===x)break;Q.tag===5&&ce!==null&&(Q=ce,_?(te=At(g,T),te!=null&&z.unshift(Yl(g,te,Q))):_||(te=At(g,T),te!=null&&z.push(Yl(g,te,Q)))),g=g.return}z.length!==0&&l.push({event:u,listeners:z})}var j6=/\r\n?/g,N6=/\u0000|\uFFFD/g;function iN(l){return(typeof l=="string"?l:""+l).replace(j6,`
38
- `).replace(N6,"")}function td(l,u,g){if(u=iN(u),iN(l)!==u&&g)throw Error(n(425))}function nd(){}var Yp=null,Xp=null;function Zp(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var Jp=typeof setTimeout=="function"?setTimeout:void 0,S6=typeof clearTimeout=="function"?clearTimeout:void 0,lN=typeof Promise=="function"?Promise:void 0,_6=typeof queueMicrotask=="function"?queueMicrotask:typeof lN<"u"?function(l){return lN.resolve(null).then(l).catch(E6)}:Jp;function E6(l){setTimeout(function(){throw l})}function Qp(l,u){var g=u,x=0;do{var _=g.nextSibling;if(l.removeChild(g),_&&_.nodeType===8)if(g=_.data,g==="/$"){if(x===0){l.removeChild(_),Qa(u);return}x--}else g!=="$"&&g!=="$?"&&g!=="$!"||x++;g=_}while(g);Qa(u)}function ua(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return l}function cN(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var g=l.data;if(g==="$"||g==="$!"||g==="$?"){if(u===0)return l;u--}else g==="/$"&&u++}l=l.previousSibling}return null}var di=Math.random().toString(36).slice(2),tr="__reactFiber$"+di,Xl="__reactProps$"+di,Cr="__reactContainer$"+di,em="__reactEvents$"+di,C6="__reactListeners$"+di,T6="__reactHandles$"+di;function ao(l){var u=l[tr];if(u)return u;for(var g=l.parentNode;g;){if(u=g[Cr]||g[tr]){if(g=u.alternate,u.child!==null||g!==null&&g.child!==null)for(l=cN(l);l!==null;){if(g=l[tr])return g;l=cN(l)}return u}l=g,g=l.parentNode}return null}function Zl(l){return l=l[tr]||l[Cr],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function hi(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function sd(l){return l[Xl]||null}var tm=[],fi=-1;function da(l){return{current:l}}function kt(l){0>fi||(l.current=tm[fi],tm[fi]=null,fi--)}function mt(l,u){fi++,tm[fi]=l.current,l.current=u}var ha={},on=da(ha),bn=da(!1),oo=ha;function pi(l,u){var g=l.type.contextTypes;if(!g)return ha;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===u)return x.__reactInternalMemoizedMaskedChildContext;var _={},T;for(T in g)_[T]=u[T];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=_),_}function kn(l){return l=l.childContextTypes,l!=null}function rd(){kt(bn),kt(on)}function uN(l,u,g){if(on.current!==ha)throw Error(n(168));mt(on,u),mt(bn,g)}function dN(l,u,g){var x=l.stateNode;if(u=u.childContextTypes,typeof x.getChildContext!="function")return g;x=x.getChildContext();for(var _ in x)if(!(_ in u))throw Error(n(108,J(l)||"Unknown",_));return H({},g,x)}function ad(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ha,oo=on.current,mt(on,l),mt(bn,bn.current),!0}function hN(l,u,g){var x=l.stateNode;if(!x)throw Error(n(169));g?(l=dN(l,u,oo),x.__reactInternalMemoizedMergedChildContext=l,kt(bn),kt(on),mt(on,l)):kt(bn),mt(bn,g)}var Tr=null,od=!1,nm=!1;function fN(l){Tr===null?Tr=[l]:Tr.push(l)}function R6(l){od=!0,fN(l)}function fa(){if(!nm&&Tr!==null){nm=!0;var l=0,u=st;try{var g=Tr;for(st=1;l<g.length;l++){var x=g[l];do x=x(!0);while(x!==null)}Tr=null,od=!1}catch(_){throw Tr!==null&&(Tr=Tr.slice(l+1)),Bt(br,fa),_}finally{st=u,nm=!1}}return null}var mi=[],gi=0,id=null,ld=0,es=[],ts=0,io=null,Rr=1,Ar="";function lo(l,u){mi[gi++]=ld,mi[gi++]=id,id=l,ld=u}function pN(l,u,g){es[ts++]=Rr,es[ts++]=Ar,es[ts++]=io,io=l;var x=Rr;l=Ar;var _=32-qt(x)-1;x&=~(1<<_),g+=1;var T=32-qt(u)+_;if(30<T){var z=_-_%5;T=(x&(1<<z)-1).toString(32),x>>=z,_-=z,Rr=1<<32-qt(u)+_|g<<_|x,Ar=T+l}else Rr=1<<T|g<<_|x,Ar=l}function sm(l){l.return!==null&&(lo(l,1),pN(l,1,0))}function rm(l){for(;l===id;)id=mi[--gi],mi[gi]=null,ld=mi[--gi],mi[gi]=null;for(;l===io;)io=es[--ts],es[ts]=null,Ar=es[--ts],es[ts]=null,Rr=es[--ts],es[ts]=null}var Dn=null,Fn=null,jt=!1,Ns=null;function mN(l,u){var g=as(5,null,null,0);g.elementType="DELETED",g.stateNode=u,g.return=l,u=l.deletions,u===null?(l.deletions=[g],l.flags|=16):u.push(g)}function gN(l,u){switch(l.tag){case 5:var g=l.type;return u=u.nodeType!==1||g.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(l.stateNode=u,Dn=l,Fn=ua(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,Dn=l,Fn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(g=io!==null?{id:Rr,overflow:Ar}:null,l.memoizedState={dehydrated:u,treeContext:g,retryLane:1073741824},g=as(18,null,null,0),g.stateNode=u,g.return=l,l.child=g,Dn=l,Fn=null,!0):!1;default:return!1}}function am(l){return(l.mode&1)!==0&&(l.flags&128)===0}function om(l){if(jt){var u=Fn;if(u){var g=u;if(!gN(l,u)){if(am(l))throw Error(n(418));u=ua(g.nextSibling);var x=Dn;u&&gN(l,u)?mN(x,g):(l.flags=l.flags&-4097|2,jt=!1,Dn=l)}}else{if(am(l))throw Error(n(418));l.flags=l.flags&-4097|2,jt=!1,Dn=l}}}function yN(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;Dn=l}function cd(l){if(l!==Dn)return!1;if(!jt)return yN(l),jt=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!Zp(l.type,l.memoizedProps)),u&&(u=Fn)){if(am(l))throw wN(),Error(n(418));for(;u;)mN(l,u),u=ua(u.nextSibling)}if(yN(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,u=0;l;){if(l.nodeType===8){var g=l.data;if(g==="/$"){if(u===0){Fn=ua(l.nextSibling);break e}u--}else g!=="$"&&g!=="$!"&&g!=="$?"||u++}l=l.nextSibling}Fn=null}}else Fn=Dn?ua(l.stateNode.nextSibling):null;return!0}function wN(){for(var l=Fn;l;)l=ua(l.nextSibling)}function yi(){Fn=Dn=null,jt=!1}function im(l){Ns===null?Ns=[l]:Ns.push(l)}var A6=E.ReactCurrentBatchConfig;function Jl(l,u,g){if(l=g.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(g._owner){if(g=g._owner,g){if(g.tag!==1)throw Error(n(309));var x=g.stateNode}if(!x)throw Error(n(147,l));var _=x,T=""+l;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===T?u.ref:(u=function(z){var Q=_.refs;z===null?delete Q[T]:Q[T]=z},u._stringRef=T,u)}if(typeof l!="string")throw Error(n(284));if(!g._owner)throw Error(n(290,l))}return l}function ud(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function xN(l){var u=l._init;return u(l._payload)}function vN(l){function u(oe,se){if(l){var ie=oe.deletions;ie===null?(oe.deletions=[se],oe.flags|=16):ie.push(se)}}function g(oe,se){if(!l)return null;for(;se!==null;)u(oe,se),se=se.sibling;return null}function x(oe,se){for(oe=new Map;se!==null;)se.key!==null?oe.set(se.key,se):oe.set(se.index,se),se=se.sibling;return oe}function _(oe,se){return oe=ba(oe,se),oe.index=0,oe.sibling=null,oe}function T(oe,se,ie){return oe.index=ie,l?(ie=oe.alternate,ie!==null?(ie=ie.index,ie<se?(oe.flags|=2,se):ie):(oe.flags|=2,se)):(oe.flags|=1048576,se)}function z(oe){return l&&oe.alternate===null&&(oe.flags|=2),oe}function Q(oe,se,ie,ke){return se===null||se.tag!==6?(se=Jm(ie,oe.mode,ke),se.return=oe,se):(se=_(se,ie),se.return=oe,se)}function te(oe,se,ie,ke){var Ie=ie.type;return Ie===R?ve(oe,se,ie.props.children,ke,ie.key):se!==null&&(se.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===P&&xN(Ie)===se.type)?(ke=_(se,ie.props),ke.ref=Jl(oe,se,ie),ke.return=oe,ke):(ke=Id(ie.type,ie.key,ie.props,null,oe.mode,ke),ke.ref=Jl(oe,se,ie),ke.return=oe,ke)}function ce(oe,se,ie,ke){return se===null||se.tag!==4||se.stateNode.containerInfo!==ie.containerInfo||se.stateNode.implementation!==ie.implementation?(se=Qm(ie,oe.mode,ke),se.return=oe,se):(se=_(se,ie.children||[]),se.return=oe,se)}function ve(oe,se,ie,ke,Ie){return se===null||se.tag!==7?(se=yo(ie,oe.mode,ke,Ie),se.return=oe,se):(se=_(se,ie),se.return=oe,se)}function be(oe,se,ie){if(typeof se=="string"&&se!==""||typeof se=="number")return se=Jm(""+se,oe.mode,ie),se.return=oe,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case C:return ie=Id(se.type,se.key,se.props,null,oe.mode,ie),ie.ref=Jl(oe,null,se),ie.return=oe,ie;case I:return se=Qm(se,oe.mode,ie),se.return=oe,se;case P:var ke=se._init;return be(oe,ke(se._payload),ie)}if(Se(se)||W(se))return se=yo(se,oe.mode,ie,null),se.return=oe,se;ud(oe,se)}return null}function xe(oe,se,ie,ke){var Ie=se!==null?se.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Ie!==null?null:Q(oe,se,""+ie,ke);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:return ie.key===Ie?te(oe,se,ie,ke):null;case I:return ie.key===Ie?ce(oe,se,ie,ke):null;case P:return Ie=ie._init,xe(oe,se,Ie(ie._payload),ke)}if(Se(ie)||W(ie))return Ie!==null?null:ve(oe,se,ie,ke,null);ud(oe,ie)}return null}function Ee(oe,se,ie,ke,Ie){if(typeof ke=="string"&&ke!==""||typeof ke=="number")return oe=oe.get(ie)||null,Q(se,oe,""+ke,Ie);if(typeof ke=="object"&&ke!==null){switch(ke.$$typeof){case C:return oe=oe.get(ke.key===null?ie:ke.key)||null,te(se,oe,ke,Ie);case I:return oe=oe.get(ke.key===null?ie:ke.key)||null,ce(se,oe,ke,Ie);case P:var Fe=ke._init;return Ee(oe,se,ie,Fe(ke._payload),Ie)}if(Se(ke)||W(ke))return oe=oe.get(ie)||null,ve(se,oe,ke,Ie,null);ud(se,ke)}return null}function Re(oe,se,ie,ke){for(var Ie=null,Fe=null,Be=se,Ue=se=0,Zt=null;Be!==null&&Ue<ie.length;Ue++){Be.index>Ue?(Zt=Be,Be=null):Zt=Be.sibling;var nt=xe(oe,Be,ie[Ue],ke);if(nt===null){Be===null&&(Be=Zt);break}l&&Be&&nt.alternate===null&&u(oe,Be),se=T(nt,se,Ue),Fe===null?Ie=nt:Fe.sibling=nt,Fe=nt,Be=Zt}if(Ue===ie.length)return g(oe,Be),jt&&lo(oe,Ue),Ie;if(Be===null){for(;Ue<ie.length;Ue++)Be=be(oe,ie[Ue],ke),Be!==null&&(se=T(Be,se,Ue),Fe===null?Ie=Be:Fe.sibling=Be,Fe=Be);return jt&&lo(oe,Ue),Ie}for(Be=x(oe,Be);Ue<ie.length;Ue++)Zt=Ee(Be,oe,Ue,ie[Ue],ke),Zt!==null&&(l&&Zt.alternate!==null&&Be.delete(Zt.key===null?Ue:Zt.key),se=T(Zt,se,Ue),Fe===null?Ie=Zt:Fe.sibling=Zt,Fe=Zt);return l&&Be.forEach(function(ka){return u(oe,ka)}),jt&&lo(oe,Ue),Ie}function Me(oe,se,ie,ke){var Ie=W(ie);if(typeof Ie!="function")throw Error(n(150));if(ie=Ie.call(ie),ie==null)throw Error(n(151));for(var Fe=Ie=null,Be=se,Ue=se=0,Zt=null,nt=ie.next();Be!==null&&!nt.done;Ue++,nt=ie.next()){Be.index>Ue?(Zt=Be,Be=null):Zt=Be.sibling;var ka=xe(oe,Be,nt.value,ke);if(ka===null){Be===null&&(Be=Zt);break}l&&Be&&ka.alternate===null&&u(oe,Be),se=T(ka,se,Ue),Fe===null?Ie=ka:Fe.sibling=ka,Fe=ka,Be=Zt}if(nt.done)return g(oe,Be),jt&&lo(oe,Ue),Ie;if(Be===null){for(;!nt.done;Ue++,nt=ie.next())nt=be(oe,nt.value,ke),nt!==null&&(se=T(nt,se,Ue),Fe===null?Ie=nt:Fe.sibling=nt,Fe=nt);return jt&&lo(oe,Ue),Ie}for(Be=x(oe,Be);!nt.done;Ue++,nt=ie.next())nt=Ee(Be,oe,Ue,nt.value,ke),nt!==null&&(l&&nt.alternate!==null&&Be.delete(nt.key===null?Ue:nt.key),se=T(nt,se,Ue),Fe===null?Ie=nt:Fe.sibling=nt,Fe=nt);return l&&Be.forEach(function(uF){return u(oe,uF)}),jt&&lo(oe,Ue),Ie}function Mt(oe,se,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 C:e:{for(var Ie=ie.key,Fe=se;Fe!==null;){if(Fe.key===Ie){if(Ie=ie.type,Ie===R){if(Fe.tag===7){g(oe,Fe.sibling),se=_(Fe,ie.props.children),se.return=oe,oe=se;break e}}else if(Fe.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===P&&xN(Ie)===Fe.type){g(oe,Fe.sibling),se=_(Fe,ie.props),se.ref=Jl(oe,Fe,ie),se.return=oe,oe=se;break e}g(oe,Fe);break}else u(oe,Fe);Fe=Fe.sibling}ie.type===R?(se=yo(ie.props.children,oe.mode,ke,ie.key),se.return=oe,oe=se):(ke=Id(ie.type,ie.key,ie.props,null,oe.mode,ke),ke.ref=Jl(oe,se,ie),ke.return=oe,oe=ke)}return z(oe);case I:e:{for(Fe=ie.key;se!==null;){if(se.key===Fe)if(se.tag===4&&se.stateNode.containerInfo===ie.containerInfo&&se.stateNode.implementation===ie.implementation){g(oe,se.sibling),se=_(se,ie.children||[]),se.return=oe,oe=se;break e}else{g(oe,se);break}else u(oe,se);se=se.sibling}se=Qm(ie,oe.mode,ke),se.return=oe,oe=se}return z(oe);case P:return Fe=ie._init,Mt(oe,se,Fe(ie._payload),ke)}if(Se(ie))return Re(oe,se,ie,ke);if(W(ie))return Me(oe,se,ie,ke);ud(oe,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,se!==null&&se.tag===6?(g(oe,se.sibling),se=_(se,ie),se.return=oe,oe=se):(g(oe,se),se=Jm(ie,oe.mode,ke),se.return=oe,oe=se),z(oe)):g(oe,se)}return Mt}var wi=vN(!0),bN=vN(!1),dd=da(null),hd=null,xi=null,lm=null;function cm(){lm=xi=hd=null}function um(l){var u=dd.current;kt(dd),l._currentValue=u}function dm(l,u,g){for(;l!==null;){var x=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,x!==null&&(x.childLanes|=u)):x!==null&&(x.childLanes&u)!==u&&(x.childLanes|=u),l===g)break;l=l.return}}function vi(l,u){hd=l,lm=xi=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(jn=!0),l.firstContext=null)}function ns(l){var u=l._currentValue;if(lm!==l)if(l={context:l,memoizedValue:u,next:null},xi===null){if(hd===null)throw Error(n(308));xi=l,hd.dependencies={lanes:0,firstContext:l}}else xi=xi.next=l;return u}var co=null;function hm(l){co===null?co=[l]:co.push(l)}function kN(l,u,g,x){var _=u.interleaved;return _===null?(g.next=g,hm(u)):(g.next=_.next,_.next=g),u.interleaved=g,Mr(l,x)}function Mr(l,u){l.lanes|=u;var g=l.alternate;for(g!==null&&(g.lanes|=u),g=l,l=l.return;l!==null;)l.childLanes|=u,g=l.alternate,g!==null&&(g.childLanes|=u),g=l,l=l.return;return g.tag===3?g.stateNode:null}var pa=!1;function fm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jN(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function $r(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function ma(l,u,g){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(et&2)!==0){var _=x.pending;return _===null?u.next=u:(u.next=_.next,_.next=u),x.pending=u,Mr(l,g)}return _=x.interleaved,_===null?(u.next=u,hm(x)):(u.next=_.next,_.next=u),x.interleaved=u,Mr(l,g)}function fd(l,u,g){if(u=u.updateQueue,u!==null&&(u=u.shared,(g&4194240)!==0)){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,_l(l,g)}}function NN(l,u){var g=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,g===x)){var _=null,T=null;if(g=g.firstBaseUpdate,g!==null){do{var z={eventTime:g.eventTime,lane:g.lane,tag:g.tag,payload:g.payload,callback:g.callback,next:null};T===null?_=T=z:T=T.next=z,g=g.next}while(g!==null);T===null?_=T=u:T=T.next=u}else _=T=u;g={baseState:x.baseState,firstBaseUpdate:_,lastBaseUpdate:T,shared:x.shared,effects:x.effects},l.updateQueue=g;return}l=g.lastBaseUpdate,l===null?g.firstBaseUpdate=u:l.next=u,g.lastBaseUpdate=u}function pd(l,u,g,x){var _=l.updateQueue;pa=!1;var T=_.firstBaseUpdate,z=_.lastBaseUpdate,Q=_.shared.pending;if(Q!==null){_.shared.pending=null;var te=Q,ce=te.next;te.next=null,z===null?T=ce:z.next=ce,z=te;var ve=l.alternate;ve!==null&&(ve=ve.updateQueue,Q=ve.lastBaseUpdate,Q!==z&&(Q===null?ve.firstBaseUpdate=ce:Q.next=ce,ve.lastBaseUpdate=te))}if(T!==null){var be=_.baseState;z=0,ve=ce=te=null,Q=T;do{var xe=Q.lane,Ee=Q.eventTime;if((x&xe)===xe){ve!==null&&(ve=ve.next={eventTime:Ee,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Re=l,Me=Q;switch(xe=u,Ee=g,Me.tag){case 1:if(Re=Me.payload,typeof Re=="function"){be=Re.call(Ee,be,xe);break e}be=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=Me.payload,xe=typeof Re=="function"?Re.call(Ee,be,xe):Re,xe==null)break e;be=H({},be,xe);break e;case 2:pa=!0}}Q.callback!==null&&Q.lane!==0&&(l.flags|=64,xe=_.effects,xe===null?_.effects=[Q]:xe.push(Q))}else Ee={eventTime:Ee,lane:xe,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ve===null?(ce=ve=Ee,te=be):ve=ve.next=Ee,z|=xe;if(Q=Q.next,Q===null){if(Q=_.shared.pending,Q===null)break;xe=Q,Q=xe.next,xe.next=null,_.lastBaseUpdate=xe,_.shared.pending=null}}while(!0);if(ve===null&&(te=be),_.baseState=te,_.firstBaseUpdate=ce,_.lastBaseUpdate=ve,u=_.shared.interleaved,u!==null){_=u;do z|=_.lane,_=_.next;while(_!==u)}else T===null&&(_.shared.lanes=0);fo|=z,l.lanes=z,l.memoizedState=be}}function SN(l,u,g){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var x=l[u],_=x.callback;if(_!==null){if(x.callback=null,x=g,typeof _!="function")throw Error(n(191,_));_.call(x)}}}var Ql={},nr=da(Ql),ec=da(Ql),tc=da(Ql);function uo(l){if(l===Ql)throw Error(n(174));return l}function pm(l,u){switch(mt(tc,u),mt(ec,l),mt(nr,Ql),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:je(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=je(u,l)}kt(nr),mt(nr,u)}function bi(){kt(nr),kt(ec),kt(tc)}function _N(l){uo(tc.current);var u=uo(nr.current),g=je(u,l.type);u!==g&&(mt(ec,l),mt(nr,g))}function mm(l){ec.current===l&&(kt(nr),kt(ec))}var _t=da(0);function md(l){for(var u=l;u!==null;){if(u.tag===13){var g=u.memoizedState;if(g!==null&&(g=g.dehydrated,g===null||g.data==="$?"||g.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var gm=[];function ym(){for(var l=0;l<gm.length;l++)gm[l]._workInProgressVersionPrimary=null;gm.length=0}var gd=E.ReactCurrentDispatcher,wm=E.ReactCurrentBatchConfig,ho=0,Et=null,Ut=null,Yt=null,yd=!1,nc=!1,sc=0,M6=0;function ln(){throw Error(n(321))}function xm(l,u){if(u===null)return!1;for(var g=0;g<u.length&&g<l.length;g++)if(!js(l[g],u[g]))return!1;return!0}function vm(l,u,g,x,_,T){if(ho=T,Et=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,gd.current=l===null||l.memoizedState===null?O6:P6,l=g(x,_),nc){T=0;do{if(nc=!1,sc=0,25<=T)throw Error(n(301));T+=1,Yt=Ut=null,u.updateQueue=null,gd.current=D6,l=g(x,_)}while(nc)}if(gd.current=vd,u=Ut!==null&&Ut.next!==null,ho=0,Yt=Ut=Et=null,yd=!1,u)throw Error(n(300));return l}function bm(){var l=sc!==0;return sc=0,l}function sr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?Et.memoizedState=Yt=l:Yt=Yt.next=l,Yt}function ss(){if(Ut===null){var l=Et.alternate;l=l!==null?l.memoizedState:null}else l=Ut.next;var u=Yt===null?Et.memoizedState:Yt.next;if(u!==null)Yt=u,Ut=l;else{if(l===null)throw Error(n(310));Ut=l,l={memoizedState:Ut.memoizedState,baseState:Ut.baseState,baseQueue:Ut.baseQueue,queue:Ut.queue,next:null},Yt===null?Et.memoizedState=Yt=l:Yt=Yt.next=l}return Yt}function rc(l,u){return typeof u=="function"?u(l):u}function km(l){var u=ss(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=Ut,_=x.baseQueue,T=g.pending;if(T!==null){if(_!==null){var z=_.next;_.next=T.next,T.next=z}x.baseQueue=_=T,g.pending=null}if(_!==null){T=_.next,x=x.baseState;var Q=z=null,te=null,ce=T;do{var ve=ce.lane;if((ho&ve)===ve)te!==null&&(te=te.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),x=ce.hasEagerState?ce.eagerState:l(x,ce.action);else{var be={lane:ve,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};te===null?(Q=te=be,z=x):te=te.next=be,Et.lanes|=ve,fo|=ve}ce=ce.next}while(ce!==null&&ce!==T);te===null?z=x:te.next=Q,js(x,u.memoizedState)||(jn=!0),u.memoizedState=x,u.baseState=z,u.baseQueue=te,g.lastRenderedState=x}if(l=g.interleaved,l!==null){_=l;do T=_.lane,Et.lanes|=T,fo|=T,_=_.next;while(_!==l)}else _===null&&(g.lanes=0);return[u.memoizedState,g.dispatch]}function jm(l){var u=ss(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=g.dispatch,_=g.pending,T=u.memoizedState;if(_!==null){g.pending=null;var z=_=_.next;do T=l(T,z.action),z=z.next;while(z!==_);js(T,u.memoizedState)||(jn=!0),u.memoizedState=T,u.baseQueue===null&&(u.baseState=T),g.lastRenderedState=T}return[T,x]}function EN(){}function CN(l,u){var g=Et,x=ss(),_=u(),T=!js(x.memoizedState,_);if(T&&(x.memoizedState=_,jn=!0),x=x.queue,Nm(AN.bind(null,g,x,l),[l]),x.getSnapshot!==u||T||Yt!==null&&Yt.memoizedState.tag&1){if(g.flags|=2048,ac(9,RN.bind(null,g,x,_,u),void 0,null),Xt===null)throw Error(n(349));(ho&30)!==0||TN(g,u,_)}return _}function TN(l,u,g){l.flags|=16384,l={getSnapshot:u,value:g},u=Et.updateQueue,u===null?(u={lastEffect:null,stores:null},Et.updateQueue=u,u.stores=[l]):(g=u.stores,g===null?u.stores=[l]:g.push(l))}function RN(l,u,g,x){u.value=g,u.getSnapshot=x,MN(u)&&$N(l)}function AN(l,u,g){return g(function(){MN(u)&&$N(l)})}function MN(l){var u=l.getSnapshot;l=l.value;try{var g=u();return!js(l,g)}catch{return!0}}function $N(l){var u=Mr(l,1);u!==null&&Cs(u,l,1,-1)}function IN(l){var u=sr();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:rc,lastRenderedState:l},u.queue=l,l=l.dispatch=L6.bind(null,Et,l),[u.memoizedState,l]}function ac(l,u,g,x){return l={tag:l,create:u,destroy:g,deps:x,next:null},u=Et.updateQueue,u===null?(u={lastEffect:null,stores:null},Et.updateQueue=u,u.lastEffect=l.next=l):(g=u.lastEffect,g===null?u.lastEffect=l.next=l:(x=g.next,g.next=l,l.next=x,u.lastEffect=l)),l}function LN(){return ss().memoizedState}function wd(l,u,g,x){var _=sr();Et.flags|=l,_.memoizedState=ac(1|u,g,void 0,x===void 0?null:x)}function xd(l,u,g,x){var _=ss();x=x===void 0?null:x;var T=void 0;if(Ut!==null){var z=Ut.memoizedState;if(T=z.destroy,x!==null&&xm(x,z.deps)){_.memoizedState=ac(u,g,T,x);return}}Et.flags|=l,_.memoizedState=ac(1|u,g,T,x)}function ON(l,u){return wd(8390656,8,l,u)}function Nm(l,u){return xd(2048,8,l,u)}function PN(l,u){return xd(4,2,l,u)}function DN(l,u){return xd(4,4,l,u)}function FN(l,u){if(typeof u=="function")return l=l(),u(l),function(){u(null)};if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function BN(l,u,g){return g=g!=null?g.concat([l]):null,xd(4,4,FN.bind(null,u,l),g)}function Sm(){}function qN(l,u){var g=ss();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&xm(u,x[1])?x[0]:(g.memoizedState=[l,u],l)}function UN(l,u){var g=ss();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&xm(u,x[1])?x[0]:(l=l(),g.memoizedState=[l,u],l)}function WN(l,u,g){return(ho&21)===0?(l.baseState&&(l.baseState=!1,jn=!0),l.memoizedState=g):(js(g,u)||(g=Sl(),Et.lanes|=g,fo|=g,l.baseState=!0),u)}function $6(l,u){var g=st;st=g!==0&&4>g?g:4,l(!0);var x=wm.transition;wm.transition={};try{l(!1),u()}finally{st=g,wm.transition=x}}function HN(){return ss().memoizedState}function I6(l,u,g){var x=xa(l);if(g={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null},zN(l))VN(u,g);else if(g=kN(l,u,g,x),g!==null){var _=pn();Cs(g,l,x,_),GN(g,u,x)}}function L6(l,u,g){var x=xa(l),_={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null};if(zN(l))VN(u,_);else{var T=l.alternate;if(l.lanes===0&&(T===null||T.lanes===0)&&(T=u.lastRenderedReducer,T!==null))try{var z=u.lastRenderedState,Q=T(z,g);if(_.hasEagerState=!0,_.eagerState=Q,js(Q,z)){var te=u.interleaved;te===null?(_.next=_,hm(u)):(_.next=te.next,te.next=_),u.interleaved=_;return}}catch{}finally{}g=kN(l,u,_,x),g!==null&&(_=pn(),Cs(g,l,x,_),GN(g,u,x))}}function zN(l){var u=l.alternate;return l===Et||u!==null&&u===Et}function VN(l,u){nc=yd=!0;var g=l.pending;g===null?u.next=u:(u.next=g.next,g.next=u),l.pending=u}function GN(l,u,g){if((g&4194240)!==0){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,_l(l,g)}}var vd={readContext:ns,useCallback:ln,useContext:ln,useEffect:ln,useImperativeHandle:ln,useInsertionEffect:ln,useLayoutEffect:ln,useMemo:ln,useReducer:ln,useRef:ln,useState:ln,useDebugValue:ln,useDeferredValue:ln,useTransition:ln,useMutableSource:ln,useSyncExternalStore:ln,useId:ln,unstable_isNewReconciler:!1},O6={readContext:ns,useCallback:function(l,u){return sr().memoizedState=[l,u===void 0?null:u],l},useContext:ns,useEffect:ON,useImperativeHandle:function(l,u,g){return g=g!=null?g.concat([l]):null,wd(4194308,4,FN.bind(null,u,l),g)},useLayoutEffect:function(l,u){return wd(4194308,4,l,u)},useInsertionEffect:function(l,u){return wd(4,2,l,u)},useMemo:function(l,u){var g=sr();return u=u===void 0?null:u,l=l(),g.memoizedState=[l,u],l},useReducer:function(l,u,g){var x=sr();return u=g!==void 0?g(u):u,x.memoizedState=x.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},x.queue=l,l=l.dispatch=I6.bind(null,Et,l),[x.memoizedState,l]},useRef:function(l){var u=sr();return l={current:l},u.memoizedState=l},useState:IN,useDebugValue:Sm,useDeferredValue:function(l){return sr().memoizedState=l},useTransition:function(){var l=IN(!1),u=l[0];return l=$6.bind(null,l[1]),sr().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,g){var x=Et,_=sr();if(jt){if(g===void 0)throw Error(n(407));g=g()}else{if(g=u(),Xt===null)throw Error(n(349));(ho&30)!==0||TN(x,u,g)}_.memoizedState=g;var T={value:g,getSnapshot:u};return _.queue=T,ON(AN.bind(null,x,T,l),[l]),x.flags|=2048,ac(9,RN.bind(null,x,T,g,u),void 0,null),g},useId:function(){var l=sr(),u=Xt.identifierPrefix;if(jt){var g=Ar,x=Rr;g=(x&~(1<<32-qt(x)-1)).toString(32)+g,u=":"+u+"R"+g,g=sc++,0<g&&(u+="H"+g.toString(32)),u+=":"}else g=M6++,u=":"+u+"r"+g.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},P6={readContext:ns,useCallback:qN,useContext:ns,useEffect:Nm,useImperativeHandle:BN,useInsertionEffect:PN,useLayoutEffect:DN,useMemo:UN,useReducer:km,useRef:LN,useState:function(){return km(rc)},useDebugValue:Sm,useDeferredValue:function(l){var u=ss();return WN(u,Ut.memoizedState,l)},useTransition:function(){var l=km(rc)[0],u=ss().memoizedState;return[l,u]},useMutableSource:EN,useSyncExternalStore:CN,useId:HN,unstable_isNewReconciler:!1},D6={readContext:ns,useCallback:qN,useContext:ns,useEffect:Nm,useImperativeHandle:BN,useInsertionEffect:PN,useLayoutEffect:DN,useMemo:UN,useReducer:jm,useRef:LN,useState:function(){return jm(rc)},useDebugValue:Sm,useDeferredValue:function(l){var u=ss();return Ut===null?u.memoizedState=l:WN(u,Ut.memoizedState,l)},useTransition:function(){var l=jm(rc)[0],u=ss().memoizedState;return[l,u]},useMutableSource:EN,useSyncExternalStore:CN,useId:HN,unstable_isNewReconciler:!1};function Ss(l,u){if(l&&l.defaultProps){u=H({},u),l=l.defaultProps;for(var g in l)u[g]===void 0&&(u[g]=l[g]);return u}return u}function _m(l,u,g,x){u=l.memoizedState,g=g(x,u),g=g==null?u:H({},u,g),l.memoizedState=g,l.lanes===0&&(l.updateQueue.baseState=g)}var bd={isMounted:function(l){return(l=l._reactInternals)?xn(l)===l:!1},enqueueSetState:function(l,u,g){l=l._reactInternals;var x=pn(),_=xa(l),T=$r(x,_);T.payload=u,g!=null&&(T.callback=g),u=ma(l,T,_),u!==null&&(Cs(u,l,_,x),fd(u,l,_))},enqueueReplaceState:function(l,u,g){l=l._reactInternals;var x=pn(),_=xa(l),T=$r(x,_);T.tag=1,T.payload=u,g!=null&&(T.callback=g),u=ma(l,T,_),u!==null&&(Cs(u,l,_,x),fd(u,l,_))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var g=pn(),x=xa(l),_=$r(g,x);_.tag=2,u!=null&&(_.callback=u),u=ma(l,_,x),u!==null&&(Cs(u,l,x,g),fd(u,l,x))}};function KN(l,u,g,x,_,T,z){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,T,z):u.prototype&&u.prototype.isPureReactComponent?!zl(g,x)||!zl(_,T):!0}function YN(l,u,g){var x=!1,_=ha,T=u.contextType;return typeof T=="object"&&T!==null?T=ns(T):(_=kn(u)?oo:on.current,x=u.contextTypes,T=(x=x!=null)?pi(l,_):ha),u=new u(g,T),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=bd,l.stateNode=u,u._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=_,l.__reactInternalMemoizedMaskedChildContext=T),u}function XN(l,u,g,x){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(g,x),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(g,x),u.state!==l&&bd.enqueueReplaceState(u,u.state,null)}function Em(l,u,g,x){var _=l.stateNode;_.props=g,_.state=l.memoizedState,_.refs={},fm(l);var T=u.contextType;typeof T=="object"&&T!==null?_.context=ns(T):(T=kn(u)?oo:on.current,_.context=pi(l,T)),_.state=l.memoizedState,T=u.getDerivedStateFromProps,typeof T=="function"&&(_m(l,u,T,g),_.state=l.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(u=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),u!==_.state&&bd.enqueueReplaceState(_,_.state,null),pd(l,g,_,x),_.state=l.memoizedState),typeof _.componentDidMount=="function"&&(l.flags|=4194308)}function ki(l,u){try{var g="",x=u;do g+=X(x),x=x.return;while(x);var _=g}catch(T){_=`
39
- Error generating stack: `+T.message+`
40
- `+T.stack}return{value:l,source:u,stack:_,digest:null}}function Cm(l,u,g){return{value:l,source:null,stack:g??null,digest:u??null}}function Tm(l,u){try{console.error(u.value)}catch(g){setTimeout(function(){throw g})}}var F6=typeof WeakMap=="function"?WeakMap:Map;function ZN(l,u,g){g=$r(-1,g),g.tag=3,g.payload={element:null};var x=u.value;return g.callback=function(){Cd||(Cd=!0,Hm=x),Tm(l,u)},g}function JN(l,u,g){g=$r(-1,g),g.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var _=u.value;g.payload=function(){return x(_)},g.callback=function(){Tm(l,u)}}var T=l.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(g.callback=function(){Tm(l,u),typeof x!="function"&&(ya===null?ya=new Set([this]):ya.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})}),g}function QN(l,u,g){var x=l.pingCache;if(x===null){x=l.pingCache=new F6;var _=new Set;x.set(u,_)}else _=x.get(u),_===void 0&&(_=new Set,x.set(u,_));_.has(g)||(_.add(g),l=Q6.bind(null,l,u,g),u.then(l,l))}function eS(l){do{var u;if((u=l.tag===13)&&(u=l.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return l;l=l.return}while(l!==null);return null}function tS(l,u,g,x,_){return(l.mode&1)===0?(l===u?l.flags|=65536:(l.flags|=128,g.flags|=131072,g.flags&=-52805,g.tag===1&&(g.alternate===null?g.tag=17:(u=$r(-1,1),u.tag=2,ma(g,u,1))),g.lanes|=1),l):(l.flags|=65536,l.lanes=_,l)}var B6=E.ReactCurrentOwner,jn=!1;function fn(l,u,g,x){u.child=l===null?bN(u,null,g,x):wi(u,l.child,g,x)}function nS(l,u,g,x,_){g=g.render;var T=u.ref;return vi(u,_),x=vm(l,u,g,x,T,_),g=bm(),l!==null&&!jn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~_,Ir(l,u,_)):(jt&&g&&sm(u),u.flags|=1,fn(l,u,x,_),u.child)}function sS(l,u,g,x,_){if(l===null){var T=g.type;return typeof T=="function"&&!Zm(T)&&T.defaultProps===void 0&&g.compare===null&&g.defaultProps===void 0?(u.tag=15,u.type=T,rS(l,u,T,x,_)):(l=Id(g.type,null,x,u,u.mode,_),l.ref=u.ref,l.return=u,u.child=l)}if(T=l.child,(l.lanes&_)===0){var z=T.memoizedProps;if(g=g.compare,g=g!==null?g:zl,g(z,x)&&l.ref===u.ref)return Ir(l,u,_)}return u.flags|=1,l=ba(T,x),l.ref=u.ref,l.return=u,u.child=l}function rS(l,u,g,x,_){if(l!==null){var T=l.memoizedProps;if(zl(T,x)&&l.ref===u.ref)if(jn=!1,u.pendingProps=x=T,(l.lanes&_)!==0)(l.flags&131072)!==0&&(jn=!0);else return u.lanes=l.lanes,Ir(l,u,_)}return Rm(l,u,g,x,_)}function aS(l,u,g){var x=u.pendingProps,_=x.children,T=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},mt(Ni,Bn),Bn|=g;else{if((g&1073741824)===0)return l=T!==null?T.baseLanes|g:g,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,mt(Ni,Bn),Bn|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=T!==null?T.baseLanes:g,mt(Ni,Bn),Bn|=x}else T!==null?(x=T.baseLanes|g,u.memoizedState=null):x=g,mt(Ni,Bn),Bn|=x;return fn(l,u,_,g),u.child}function oS(l,u){var g=u.ref;(l===null&&g!==null||l!==null&&l.ref!==g)&&(u.flags|=512,u.flags|=2097152)}function Rm(l,u,g,x,_){var T=kn(g)?oo:on.current;return T=pi(u,T),vi(u,_),g=vm(l,u,g,x,T,_),x=bm(),l!==null&&!jn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~_,Ir(l,u,_)):(jt&&x&&sm(u),u.flags|=1,fn(l,u,g,_),u.child)}function iS(l,u,g,x,_){if(kn(g)){var T=!0;ad(u)}else T=!1;if(vi(u,_),u.stateNode===null)jd(l,u),YN(u,g,x),Em(u,g,x,_),x=!0;else if(l===null){var z=u.stateNode,Q=u.memoizedProps;z.props=Q;var te=z.context,ce=g.contextType;typeof ce=="object"&&ce!==null?ce=ns(ce):(ce=kn(g)?oo:on.current,ce=pi(u,ce));var ve=g.getDerivedStateFromProps,be=typeof ve=="function"||typeof z.getSnapshotBeforeUpdate=="function";be||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==x||te!==ce)&&XN(u,z,x,ce),pa=!1;var xe=u.memoizedState;z.state=xe,pd(u,x,z,_),te=u.memoizedState,Q!==x||xe!==te||bn.current||pa?(typeof ve=="function"&&(_m(u,g,ve,x),te=u.memoizedState),(Q=pa||KN(u,g,Q,x,xe,te,ce))?(be||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(u.flags|=4194308)):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=te),z.props=x,z.state=te,z.context=ce,x=Q):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{z=u.stateNode,jN(l,u),Q=u.memoizedProps,ce=u.type===u.elementType?Q:Ss(u.type,Q),z.props=ce,be=u.pendingProps,xe=z.context,te=g.contextType,typeof te=="object"&&te!==null?te=ns(te):(te=kn(g)?oo:on.current,te=pi(u,te));var Ee=g.getDerivedStateFromProps;(ve=typeof Ee=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==be||xe!==te)&&XN(u,z,x,te),pa=!1,xe=u.memoizedState,z.state=xe,pd(u,x,z,_);var Re=u.memoizedState;Q!==be||xe!==Re||bn.current||pa?(typeof Ee=="function"&&(_m(u,g,Ee,x),Re=u.memoizedState),(ce=pa||KN(u,g,ce,x,xe,Re,te)||!1)?(ve||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(x,Re,te),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(x,Re,te)),typeof z.componentDidUpdate=="function"&&(u.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof z.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Re),z.props=x,z.state=Re,z.context=te,x=ce):(typeof z.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),x=!1)}return Am(l,u,g,x,T,_)}function Am(l,u,g,x,_,T){oS(l,u);var z=(u.flags&128)!==0;if(!x&&!z)return _&&hN(u,g,!1),Ir(l,u,T);x=u.stateNode,B6.current=u;var Q=z&&typeof g.getDerivedStateFromError!="function"?null:x.render();return u.flags|=1,l!==null&&z?(u.child=wi(u,l.child,null,T),u.child=wi(u,null,Q,T)):fn(l,u,Q,T),u.memoizedState=x.state,_&&hN(u,g,!0),u.child}function lS(l){var u=l.stateNode;u.pendingContext?uN(l,u.pendingContext,u.pendingContext!==u.context):u.context&&uN(l,u.context,!1),pm(l,u.containerInfo)}function cS(l,u,g,x,_){return yi(),im(_),u.flags|=256,fn(l,u,g,x),u.child}var Mm={dehydrated:null,treeContext:null,retryLane:0};function $m(l){return{baseLanes:l,cachePool:null,transitions:null}}function uS(l,u,g){var x=u.pendingProps,_=_t.current,T=!1,z=(u.flags&128)!==0,Q;if((Q=z)||(Q=l!==null&&l.memoizedState===null?!1:(_&2)!==0),Q?(T=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(_|=1),mt(_t,_&1),l===null)return om(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((u.mode&1)===0?u.lanes=1:l.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(z=x.children,l=x.fallback,T?(x=u.mode,T=u.child,z={mode:"hidden",children:z},(x&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=z):T=Ld(z,x,0,null),l=yo(l,x,g,null),T.return=u,l.return=u,T.sibling=l,u.child=T,u.child.memoizedState=$m(g),u.memoizedState=Mm,l):Im(u,z));if(_=l.memoizedState,_!==null&&(Q=_.dehydrated,Q!==null))return q6(l,u,z,x,Q,_,g);if(T){T=x.fallback,z=u.mode,_=l.child,Q=_.sibling;var te={mode:"hidden",children:x.children};return(z&1)===0&&u.child!==_?(x=u.child,x.childLanes=0,x.pendingProps=te,u.deletions=null):(x=ba(_,te),x.subtreeFlags=_.subtreeFlags&14680064),Q!==null?T=ba(Q,T):(T=yo(T,z,g,null),T.flags|=2),T.return=u,x.return=u,x.sibling=T,u.child=x,x=T,T=u.child,z=l.child.memoizedState,z=z===null?$m(g):{baseLanes:z.baseLanes|g,cachePool:null,transitions:z.transitions},T.memoizedState=z,T.childLanes=l.childLanes&~g,u.memoizedState=Mm,x}return T=l.child,l=T.sibling,x=ba(T,{mode:"visible",children:x.children}),(u.mode&1)===0&&(x.lanes=g),x.return=u,x.sibling=null,l!==null&&(g=u.deletions,g===null?(u.deletions=[l],u.flags|=16):g.push(l)),u.child=x,u.memoizedState=null,x}function Im(l,u){return u=Ld({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function kd(l,u,g,x){return x!==null&&im(x),wi(u,l.child,null,g),l=Im(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function q6(l,u,g,x,_,T,z){if(g)return u.flags&256?(u.flags&=-257,x=Cm(Error(n(422))),kd(l,u,z,x)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(T=x.fallback,_=u.mode,x=Ld({mode:"visible",children:x.children},_,0,null),T=yo(T,_,z,null),T.flags|=2,x.return=u,T.return=u,x.sibling=T,u.child=x,(u.mode&1)!==0&&wi(u,l.child,null,z),u.child.memoizedState=$m(z),u.memoizedState=Mm,T);if((u.mode&1)===0)return kd(l,u,z,null);if(_.data==="$!"){if(x=_.nextSibling&&_.nextSibling.dataset,x)var Q=x.dgst;return x=Q,T=Error(n(419)),x=Cm(T,x,void 0),kd(l,u,z,x)}if(Q=(z&l.childLanes)!==0,jn||Q){if(x=Xt,x!==null){switch(z&-z){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(x.suspendedLanes|z))!==0?0:_,_!==0&&_!==T.retryLane&&(T.retryLane=_,Mr(l,_),Cs(x,l,_,-1))}return Xm(),x=Cm(Error(n(421))),kd(l,u,z,x)}return _.data==="$?"?(u.flags|=128,u.child=l.child,u=eF.bind(null,l),_._reactRetry=u,null):(l=T.treeContext,Fn=ua(_.nextSibling),Dn=u,jt=!0,Ns=null,l!==null&&(es[ts++]=Rr,es[ts++]=Ar,es[ts++]=io,Rr=l.id,Ar=l.overflow,io=u),u=Im(u,x.children),u.flags|=4096,u)}function dS(l,u,g){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),dm(l.return,u,g)}function Lm(l,u,g,x,_){var T=l.memoizedState;T===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:g,tailMode:_}:(T.isBackwards=u,T.rendering=null,T.renderingStartTime=0,T.last=x,T.tail=g,T.tailMode=_)}function hS(l,u,g){var x=u.pendingProps,_=x.revealOrder,T=x.tail;if(fn(l,u,x.children,g),x=_t.current,(x&2)!==0)x=x&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&dS(l,g,u);else if(l.tag===19)dS(l,g,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(mt(_t,x),(u.mode&1)===0)u.memoizedState=null;else switch(_){case"forwards":for(g=u.child,_=null;g!==null;)l=g.alternate,l!==null&&md(l)===null&&(_=g),g=g.sibling;g=_,g===null?(_=u.child,u.child=null):(_=g.sibling,g.sibling=null),Lm(u,!1,_,g,T);break;case"backwards":for(g=null,_=u.child,u.child=null;_!==null;){if(l=_.alternate,l!==null&&md(l)===null){u.child=_;break}l=_.sibling,_.sibling=g,g=_,_=l}Lm(u,!0,g,null,T);break;case"together":Lm(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function jd(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function Ir(l,u,g){if(l!==null&&(u.dependencies=l.dependencies),fo|=u.lanes,(g&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(n(153));if(u.child!==null){for(l=u.child,g=ba(l,l.pendingProps),u.child=g,g.return=u;l.sibling!==null;)l=l.sibling,g=g.sibling=ba(l,l.pendingProps),g.return=u;g.sibling=null}return u.child}function U6(l,u,g){switch(u.tag){case 3:lS(u),yi();break;case 5:_N(u);break;case 1:kn(u.type)&&ad(u);break;case 4:pm(u,u.stateNode.containerInfo);break;case 10:var x=u.type._context,_=u.memoizedProps.value;mt(dd,x._currentValue),x._currentValue=_;break;case 13:if(x=u.memoizedState,x!==null)return x.dehydrated!==null?(mt(_t,_t.current&1),u.flags|=128,null):(g&u.child.childLanes)!==0?uS(l,u,g):(mt(_t,_t.current&1),l=Ir(l,u,g),l!==null?l.sibling:null);mt(_t,_t.current&1);break;case 19:if(x=(g&u.childLanes)!==0,(l.flags&128)!==0){if(x)return hS(l,u,g);u.flags|=128}if(_=u.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),mt(_t,_t.current),x)break;return null;case 22:case 23:return u.lanes=0,aS(l,u,g)}return Ir(l,u,g)}var fS,Om,pS,mS;fS=function(l,u){for(var g=u.child;g!==null;){if(g.tag===5||g.tag===6)l.appendChild(g.stateNode);else if(g.tag!==4&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===u)break;for(;g.sibling===null;){if(g.return===null||g.return===u)return;g=g.return}g.sibling.return=g.return,g=g.sibling}},Om=function(){},pS=function(l,u,g,x){var _=l.memoizedProps;if(_!==x){l=u.stateNode,uo(nr.current);var T=null;switch(g){case"input":_=pe(l,_),x=pe(l,x),T=[];break;case"select":_=H({},_,{value:void 0}),x=H({},x,{value:void 0}),T=[];break;case"textarea":_=$e(l,_),x=$e(l,x),T=[];break;default:typeof _.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=nd)}vt(g,x);var z;g=null;for(ce in _)if(!x.hasOwnProperty(ce)&&_.hasOwnProperty(ce)&&_[ce]!=null)if(ce==="style"){var Q=_[ce];for(z in Q)Q.hasOwnProperty(z)&&(g||(g={}),g[z]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(r.hasOwnProperty(ce)?T||(T=[]):(T=T||[]).push(ce,null));for(ce in x){var te=x[ce];if(Q=_!=null?_[ce]:void 0,x.hasOwnProperty(ce)&&te!==Q&&(te!=null||Q!=null))if(ce==="style")if(Q){for(z in Q)!Q.hasOwnProperty(z)||te&&te.hasOwnProperty(z)||(g||(g={}),g[z]="");for(z in te)te.hasOwnProperty(z)&&Q[z]!==te[z]&&(g||(g={}),g[z]=te[z])}else g||(T||(T=[]),T.push(ce,g)),g=te;else ce==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(T=T||[]).push(ce,te)):ce==="children"?typeof te!="string"&&typeof te!="number"||(T=T||[]).push(ce,""+te):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(r.hasOwnProperty(ce)?(te!=null&&ce==="onScroll"&&bt("scroll",l),T||Q===te||(T=[])):(T=T||[]).push(ce,te))}g&&(T=T||[]).push("style",g);var ce=T;(u.updateQueue=ce)&&(u.flags|=4)}},mS=function(l,u,g,x){g!==x&&(u.flags|=4)};function oc(l,u){if(!jt)switch(l.tailMode){case"hidden":u=l.tail;for(var g=null;u!==null;)u.alternate!==null&&(g=u),u=u.sibling;g===null?l.tail=null:g.sibling=null;break;case"collapsed":g=l.tail;for(var x=null;g!==null;)g.alternate!==null&&(x=g),g=g.sibling;x===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function cn(l){var u=l.alternate!==null&&l.alternate.child===l.child,g=0,x=0;if(u)for(var _=l.child;_!==null;)g|=_.lanes|_.childLanes,x|=_.subtreeFlags&14680064,x|=_.flags&14680064,_.return=l,_=_.sibling;else for(_=l.child;_!==null;)g|=_.lanes|_.childLanes,x|=_.subtreeFlags,x|=_.flags,_.return=l,_=_.sibling;return l.subtreeFlags|=x,l.childLanes=g,u}function W6(l,u,g){var x=u.pendingProps;switch(rm(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cn(u),null;case 1:return kn(u.type)&&rd(),cn(u),null;case 3:return x=u.stateNode,bi(),kt(bn),kt(on),ym(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(cd(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Ns!==null&&(Gm(Ns),Ns=null))),Om(l,u),cn(u),null;case 5:mm(u);var _=uo(tc.current);if(g=u.type,l!==null&&u.stateNode!=null)pS(l,u,g,x,_),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!x){if(u.stateNode===null)throw Error(n(166));return cn(u),null}if(l=uo(nr.current),cd(u)){x=u.stateNode,g=u.type;var T=u.memoizedProps;switch(x[tr]=u,x[Xl]=T,l=(u.mode&1)!==0,g){case"dialog":bt("cancel",x),bt("close",x);break;case"iframe":case"object":case"embed":bt("load",x);break;case"video":case"audio":for(_=0;_<Gl.length;_++)bt(Gl[_],x);break;case"source":bt("error",x);break;case"img":case"image":case"link":bt("error",x),bt("load",x);break;case"details":bt("toggle",x);break;case"input":ye(x,T),bt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!T.multiple},bt("invalid",x);break;case"textarea":Pe(x,T),bt("invalid",x)}vt(g,T),_=null;for(var z in T)if(T.hasOwnProperty(z)){var Q=T[z];z==="children"?typeof Q=="string"?x.textContent!==Q&&(T.suppressHydrationWarning!==!0&&td(x.textContent,Q,l),_=["children",Q]):typeof Q=="number"&&x.textContent!==""+Q&&(T.suppressHydrationWarning!==!0&&td(x.textContent,Q,l),_=["children",""+Q]):r.hasOwnProperty(z)&&Q!=null&&z==="onScroll"&&bt("scroll",x)}switch(g){case"input":de(x),ae(x,T,!0);break;case"textarea":de(x),Le(x);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(x.onclick=nd)}x=_,u.updateQueue=x,x!==null&&(u.flags|=4)}else{z=_.nodeType===9?_:_.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=Qe(g)),l==="http://www.w3.org/1999/xhtml"?g==="script"?(l=z.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=z.createElement(g,{is:x.is}):(l=z.createElement(g),g==="select"&&(z=l,x.multiple?z.multiple=!0:x.size&&(z.size=x.size))):l=z.createElementNS(l,g),l[tr]=u,l[Xl]=x,fS(l,u,!1,!1),u.stateNode=l;e:{switch(z=It(g,x),g){case"dialog":bt("cancel",l),bt("close",l),_=x;break;case"iframe":case"object":case"embed":bt("load",l),_=x;break;case"video":case"audio":for(_=0;_<Gl.length;_++)bt(Gl[_],l);_=x;break;case"source":bt("error",l),_=x;break;case"img":case"image":case"link":bt("error",l),bt("load",l),_=x;break;case"details":bt("toggle",l),_=x;break;case"input":ye(l,x),_=pe(l,x),bt("invalid",l);break;case"option":_=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},_=H({},x,{value:void 0}),bt("invalid",l);break;case"textarea":Pe(l,x),_=$e(l,x),bt("invalid",l);break;default:_=x}vt(g,_),Q=_;for(T in Q)if(Q.hasOwnProperty(T)){var te=Q[T];T==="style"?Je(l,te):T==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&De(l,te)):T==="children"?typeof te=="string"?(g!=="textarea"||te!=="")&&He(l,te):typeof te=="number"&&He(l,""+te):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(r.hasOwnProperty(T)?te!=null&&T==="onScroll"&&bt("scroll",l):te!=null&&S(l,T,te,z))}switch(g){case"input":de(l),ae(l,x,!1);break;case"textarea":de(l),Le(l);break;case"option":x.value!=null&&l.setAttribute("value",""+ee(x.value));break;case"select":l.multiple=!!x.multiple,T=x.value,T!=null?me(l,!!x.multiple,T,!1):x.defaultValue!=null&&me(l,!!x.multiple,x.defaultValue,!0);break;default:typeof _.onClick=="function"&&(l.onclick=nd)}switch(g){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return cn(u),null;case 6:if(l&&u.stateNode!=null)mS(l,u,l.memoizedProps,x);else{if(typeof x!="string"&&u.stateNode===null)throw Error(n(166));if(g=uo(tc.current),uo(nr.current),cd(u)){if(x=u.stateNode,g=u.memoizedProps,x[tr]=u,(T=x.nodeValue!==g)&&(l=Dn,l!==null))switch(l.tag){case 3:td(x.nodeValue,g,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&td(x.nodeValue,g,(l.mode&1)!==0)}T&&(u.flags|=4)}else x=(g.nodeType===9?g:g.ownerDocument).createTextNode(x),x[tr]=u,u.stateNode=x}return cn(u),null;case 13:if(kt(_t),x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(jt&&Fn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)wN(),yi(),u.flags|=98560,T=!1;else if(T=cd(u),x!==null&&x.dehydrated!==null){if(l===null){if(!T)throw Error(n(318));if(T=u.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(n(317));T[tr]=u}else yi(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;cn(u),T=!1}else Ns!==null&&(Gm(Ns),Ns=null),T=!0;if(!T)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=g,u):(x=x!==null,x!==(l!==null&&l.memoizedState!==null)&&x&&(u.child.flags|=8192,(u.mode&1)!==0&&(l===null||(_t.current&1)!==0?Wt===0&&(Wt=3):Xm())),u.updateQueue!==null&&(u.flags|=4),cn(u),null);case 4:return bi(),Om(l,u),l===null&&Kl(u.stateNode.containerInfo),cn(u),null;case 10:return um(u.type._context),cn(u),null;case 17:return kn(u.type)&&rd(),cn(u),null;case 19:if(kt(_t),T=u.memoizedState,T===null)return cn(u),null;if(x=(u.flags&128)!==0,z=T.rendering,z===null)if(x)oc(T,!1);else{if(Wt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(z=md(l),z!==null){for(u.flags|=128,oc(T,!1),x=z.updateQueue,x!==null&&(u.updateQueue=x,u.flags|=4),u.subtreeFlags=0,x=g,g=u.child;g!==null;)T=g,l=x,T.flags&=14680066,z=T.alternate,z===null?(T.childLanes=0,T.lanes=l,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=z.childLanes,T.lanes=z.lanes,T.child=z.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=z.memoizedProps,T.memoizedState=z.memoizedState,T.updateQueue=z.updateQueue,T.type=z.type,l=z.dependencies,T.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),g=g.sibling;return mt(_t,_t.current&1|2),u.child}l=l.sibling}T.tail!==null&&ot()>Si&&(u.flags|=128,x=!0,oc(T,!1),u.lanes=4194304)}else{if(!x)if(l=md(z),l!==null){if(u.flags|=128,x=!0,g=l.updateQueue,g!==null&&(u.updateQueue=g,u.flags|=4),oc(T,!0),T.tail===null&&T.tailMode==="hidden"&&!z.alternate&&!jt)return cn(u),null}else 2*ot()-T.renderingStartTime>Si&&g!==1073741824&&(u.flags|=128,x=!0,oc(T,!1),u.lanes=4194304);T.isBackwards?(z.sibling=u.child,u.child=z):(g=T.last,g!==null?g.sibling=z:u.child=z,T.last=z)}return T.tail!==null?(u=T.tail,T.rendering=u,T.tail=u.sibling,T.renderingStartTime=ot(),u.sibling=null,g=_t.current,mt(_t,x?g&1|2:g&1),u):(cn(u),null);case 22:case 23:return Ym(),x=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(u.flags|=8192),x&&(u.mode&1)!==0?(Bn&1073741824)!==0&&(cn(u),u.subtreeFlags&6&&(u.flags|=8192)):cn(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function H6(l,u){switch(rm(u),u.tag){case 1:return kn(u.type)&&rd(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return bi(),kt(bn),kt(on),ym(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return mm(u),null;case 13:if(kt(_t),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));yi()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return kt(_t),null;case 4:return bi(),null;case 10:return um(u.type._context),null;case 22:case 23:return Ym(),null;case 24:return null;default:return null}}var Nd=!1,un=!1,z6=typeof WeakSet=="function"?WeakSet:Set,Ce=null;function ji(l,u){var g=l.ref;if(g!==null)if(typeof g=="function")try{g(null)}catch(x){Tt(l,u,x)}else g.current=null}function Pm(l,u,g){try{g()}catch(x){Tt(l,u,x)}}var gS=!1;function V6(l,u){if(Yp=si,l=Kj(),qp(l)){if("selectionStart"in l)var g={start:l.selectionStart,end:l.selectionEnd};else e:{g=(g=l.ownerDocument)&&g.defaultView||window;var x=g.getSelection&&g.getSelection();if(x&&x.rangeCount!==0){g=x.anchorNode;var _=x.anchorOffset,T=x.focusNode;x=x.focusOffset;try{g.nodeType,T.nodeType}catch{g=null;break e}var z=0,Q=-1,te=-1,ce=0,ve=0,be=l,xe=null;t:for(;;){for(var Ee;be!==g||_!==0&&be.nodeType!==3||(Q=z+_),be!==T||x!==0&&be.nodeType!==3||(te=z+x),be.nodeType===3&&(z+=be.nodeValue.length),(Ee=be.firstChild)!==null;)xe=be,be=Ee;for(;;){if(be===l)break t;if(xe===g&&++ce===_&&(Q=z),xe===T&&++ve===x&&(te=z),(Ee=be.nextSibling)!==null)break;be=xe,xe=be.parentNode}be=Ee}g=Q===-1||te===-1?null:{start:Q,end:te}}else g=null}g=g||{start:0,end:0}}else g=null;for(Xp={focusedElem:l,selectionRange:g},si=!1,Ce=u;Ce!==null;)if(u=Ce,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Ce=l;else for(;Ce!==null;){u=Ce;try{var Re=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Re!==null){var Me=Re.memoizedProps,Mt=Re.memoizedState,oe=u.stateNode,se=oe.getSnapshotBeforeUpdate(u.elementType===u.type?Me:Ss(u.type,Me),Mt);oe.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var ie=u.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){Tt(u,u.return,ke)}if(l=u.sibling,l!==null){l.return=u.return,Ce=l;break}Ce=u.return}return Re=gS,gS=!1,Re}function ic(l,u,g){var x=u.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var _=x=x.next;do{if((_.tag&l)===l){var T=_.destroy;_.destroy=void 0,T!==void 0&&Pm(u,g,T)}_=_.next}while(_!==x)}}function Sd(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var g=u=u.next;do{if((g.tag&l)===l){var x=g.create;g.destroy=x()}g=g.next}while(g!==u)}}function Dm(l){var u=l.ref;if(u!==null){var g=l.stateNode;switch(l.tag){case 5:l=g;break;default:l=g}typeof u=="function"?u(l):u.current=l}}function yS(l){var u=l.alternate;u!==null&&(l.alternate=null,yS(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[tr],delete u[Xl],delete u[em],delete u[C6],delete u[T6])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function wS(l){return l.tag===5||l.tag===3||l.tag===4}function xS(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||wS(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Fm(l,u,g){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?g.nodeType===8?g.parentNode.insertBefore(l,u):g.insertBefore(l,u):(g.nodeType===8?(u=g.parentNode,u.insertBefore(l,g)):(u=g,u.appendChild(l)),g=g._reactRootContainer,g!=null||u.onclick!==null||(u.onclick=nd));else if(x!==4&&(l=l.child,l!==null))for(Fm(l,u,g),l=l.sibling;l!==null;)Fm(l,u,g),l=l.sibling}function Bm(l,u,g){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?g.insertBefore(l,u):g.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(Bm(l,u,g),l=l.sibling;l!==null;)Bm(l,u,g),l=l.sibling}var en=null,_s=!1;function ga(l,u,g){for(g=g.child;g!==null;)vS(l,u,g),g=g.sibling}function vS(l,u,g){if(Jt&&typeof Jt.onCommitFiberUnmount=="function")try{Jt.onCommitFiberUnmount(Pn,g)}catch{}switch(g.tag){case 5:un||ji(g,u);case 6:var x=en,_=_s;en=null,ga(l,u,g),en=x,_s=_,en!==null&&(_s?(l=en,g=g.stateNode,l.nodeType===8?l.parentNode.removeChild(g):l.removeChild(g)):en.removeChild(g.stateNode));break;case 18:en!==null&&(_s?(l=en,g=g.stateNode,l.nodeType===8?Qp(l.parentNode,g):l.nodeType===1&&Qp(l,g),Qa(l)):Qp(en,g.stateNode));break;case 4:x=en,_=_s,en=g.stateNode.containerInfo,_s=!0,ga(l,u,g),en=x,_s=_;break;case 0:case 11:case 14:case 15:if(!un&&(x=g.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){_=x=x.next;do{var T=_,z=T.destroy;T=T.tag,z!==void 0&&((T&2)!==0||(T&4)!==0)&&Pm(g,u,z),_=_.next}while(_!==x)}ga(l,u,g);break;case 1:if(!un&&(ji(g,u),x=g.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=g.memoizedProps,x.state=g.memoizedState,x.componentWillUnmount()}catch(Q){Tt(g,u,Q)}ga(l,u,g);break;case 21:ga(l,u,g);break;case 22:g.mode&1?(un=(x=un)||g.memoizedState!==null,ga(l,u,g),un=x):ga(l,u,g);break;default:ga(l,u,g)}}function bS(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var g=l.stateNode;g===null&&(g=l.stateNode=new z6),u.forEach(function(x){var _=tF.bind(null,l,x);g.has(x)||(g.add(x),x.then(_,_))})}}function Es(l,u){var g=u.deletions;if(g!==null)for(var x=0;x<g.length;x++){var _=g[x];try{var T=l,z=u,Q=z;e:for(;Q!==null;){switch(Q.tag){case 5:en=Q.stateNode,_s=!1;break e;case 3:en=Q.stateNode.containerInfo,_s=!0;break e;case 4:en=Q.stateNode.containerInfo,_s=!0;break e}Q=Q.return}if(en===null)throw Error(n(160));vS(T,z,_),en=null,_s=!1;var te=_.alternate;te!==null&&(te.return=null),_.return=null}catch(ce){Tt(_,u,ce)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)kS(u,l),u=u.sibling}function kS(l,u){var g=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Es(u,l),rr(l),x&4){try{ic(3,l,l.return),Sd(3,l)}catch(Me){Tt(l,l.return,Me)}try{ic(5,l,l.return)}catch(Me){Tt(l,l.return,Me)}}break;case 1:Es(u,l),rr(l),x&512&&g!==null&&ji(g,g.return);break;case 5:if(Es(u,l),rr(l),x&512&&g!==null&&ji(g,g.return),l.flags&32){var _=l.stateNode;try{He(_,"")}catch(Me){Tt(l,l.return,Me)}}if(x&4&&(_=l.stateNode,_!=null)){var T=l.memoizedProps,z=g!==null?g.memoizedProps:T,Q=l.type,te=l.updateQueue;if(l.updateQueue=null,te!==null)try{Q==="input"&&T.type==="radio"&&T.name!=null&&_e(_,T),It(Q,z);var ce=It(Q,T);for(z=0;z<te.length;z+=2){var ve=te[z],be=te[z+1];ve==="style"?Je(_,be):ve==="dangerouslySetInnerHTML"?De(_,be):ve==="children"?He(_,be):S(_,ve,be,ce)}switch(Q){case"input":he(_,T);break;case"textarea":qe(_,T);break;case"select":var xe=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!T.multiple;var Ee=T.value;Ee!=null?me(_,!!T.multiple,Ee,!1):xe!==!!T.multiple&&(T.defaultValue!=null?me(_,!!T.multiple,T.defaultValue,!0):me(_,!!T.multiple,T.multiple?[]:"",!1))}_[Xl]=T}catch(Me){Tt(l,l.return,Me)}}break;case 6:if(Es(u,l),rr(l),x&4){if(l.stateNode===null)throw Error(n(162));_=l.stateNode,T=l.memoizedProps;try{_.nodeValue=T}catch(Me){Tt(l,l.return,Me)}}break;case 3:if(Es(u,l),rr(l),x&4&&g!==null&&g.memoizedState.isDehydrated)try{Qa(u.containerInfo)}catch(Me){Tt(l,l.return,Me)}break;case 4:Es(u,l),rr(l);break;case 13:Es(u,l),rr(l),_=l.child,_.flags&8192&&(T=_.memoizedState!==null,_.stateNode.isHidden=T,!T||_.alternate!==null&&_.alternate.memoizedState!==null||(Wm=ot())),x&4&&bS(l);break;case 22:if(ve=g!==null&&g.memoizedState!==null,l.mode&1?(un=(ce=un)||ve,Es(u,l),un=ce):Es(u,l),rr(l),x&8192){if(ce=l.memoizedState!==null,(l.stateNode.isHidden=ce)&&!ve&&(l.mode&1)!==0)for(Ce=l,ve=l.child;ve!==null;){for(be=Ce=ve;Ce!==null;){switch(xe=Ce,Ee=xe.child,xe.tag){case 0:case 11:case 14:case 15:ic(4,xe,xe.return);break;case 1:ji(xe,xe.return);var Re=xe.stateNode;if(typeof Re.componentWillUnmount=="function"){x=xe,g=xe.return;try{u=x,Re.props=u.memoizedProps,Re.state=u.memoizedState,Re.componentWillUnmount()}catch(Me){Tt(x,g,Me)}}break;case 5:ji(xe,xe.return);break;case 22:if(xe.memoizedState!==null){SS(be);continue}}Ee!==null?(Ee.return=xe,Ce=Ee):SS(be)}ve=ve.sibling}e:for(ve=null,be=l;;){if(be.tag===5){if(ve===null){ve=be;try{_=be.stateNode,ce?(T=_.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(Q=be.stateNode,te=be.memoizedProps.style,z=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=ut("display",z))}catch(Me){Tt(l,l.return,Me)}}}else if(be.tag===6){if(ve===null)try{be.stateNode.nodeValue=ce?"":be.memoizedProps}catch(Me){Tt(l,l.return,Me)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===l)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===l)break e;for(;be.sibling===null;){if(be.return===null||be.return===l)break e;ve===be&&(ve=null),be=be.return}ve===be&&(ve=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:Es(u,l),rr(l),x&4&&bS(l);break;case 21:break;default:Es(u,l),rr(l)}}function rr(l){var u=l.flags;if(u&2){try{e:{for(var g=l.return;g!==null;){if(wS(g)){var x=g;break e}g=g.return}throw Error(n(160))}switch(x.tag){case 5:var _=x.stateNode;x.flags&32&&(He(_,""),x.flags&=-33);var T=xS(l);Bm(l,T,_);break;case 3:case 4:var z=x.stateNode.containerInfo,Q=xS(l);Fm(l,Q,z);break;default:throw Error(n(161))}}catch(te){Tt(l,l.return,te)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function G6(l,u,g){Ce=l,jS(l)}function jS(l,u,g){for(var x=(l.mode&1)!==0;Ce!==null;){var _=Ce,T=_.child;if(_.tag===22&&x){var z=_.memoizedState!==null||Nd;if(!z){var Q=_.alternate,te=Q!==null&&Q.memoizedState!==null||un;Q=Nd;var ce=un;if(Nd=z,(un=te)&&!ce)for(Ce=_;Ce!==null;)z=Ce,te=z.child,z.tag===22&&z.memoizedState!==null?_S(_):te!==null?(te.return=z,Ce=te):_S(_);for(;T!==null;)Ce=T,jS(T),T=T.sibling;Ce=_,Nd=Q,un=ce}NS(l)}else(_.subtreeFlags&8772)!==0&&T!==null?(T.return=_,Ce=T):NS(l)}}function NS(l){for(;Ce!==null;){var u=Ce;if((u.flags&8772)!==0){var g=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:un||Sd(5,u);break;case 1:var x=u.stateNode;if(u.flags&4&&!un)if(g===null)x.componentDidMount();else{var _=u.elementType===u.type?g.memoizedProps:Ss(u.type,g.memoizedProps);x.componentDidUpdate(_,g.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var T=u.updateQueue;T!==null&&SN(u,T,x);break;case 3:var z=u.updateQueue;if(z!==null){if(g=null,u.child!==null)switch(u.child.tag){case 5:g=u.child.stateNode;break;case 1:g=u.child.stateNode}SN(u,z,g)}break;case 5:var Q=u.stateNode;if(g===null&&u.flags&4){g=Q;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&g.focus();break;case"img":te.src&&(g.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ce=u.alternate;if(ce!==null){var ve=ce.memoizedState;if(ve!==null){var be=ve.dehydrated;be!==null&&Qa(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}un||u.flags&512&&Dm(u)}catch(xe){Tt(u,u.return,xe)}}if(u===l){Ce=null;break}if(g=u.sibling,g!==null){g.return=u.return,Ce=g;break}Ce=u.return}}function SS(l){for(;Ce!==null;){var u=Ce;if(u===l){Ce=null;break}var g=u.sibling;if(g!==null){g.return=u.return,Ce=g;break}Ce=u.return}}function _S(l){for(;Ce!==null;){var u=Ce;try{switch(u.tag){case 0:case 11:case 15:var g=u.return;try{Sd(4,u)}catch(te){Tt(u,g,te)}break;case 1:var x=u.stateNode;if(typeof x.componentDidMount=="function"){var _=u.return;try{x.componentDidMount()}catch(te){Tt(u,_,te)}}var T=u.return;try{Dm(u)}catch(te){Tt(u,T,te)}break;case 5:var z=u.return;try{Dm(u)}catch(te){Tt(u,z,te)}}}catch(te){Tt(u,u.return,te)}if(u===l){Ce=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,Ce=Q;break}Ce=u.return}}var K6=Math.ceil,_d=E.ReactCurrentDispatcher,qm=E.ReactCurrentOwner,rs=E.ReactCurrentBatchConfig,et=0,Xt=null,Ot=null,tn=0,Bn=0,Ni=da(0),Wt=0,lc=null,fo=0,Ed=0,Um=0,cc=null,Nn=null,Wm=0,Si=1/0,Lr=null,Cd=!1,Hm=null,ya=null,Td=!1,wa=null,Rd=0,uc=0,zm=null,Ad=-1,Md=0;function pn(){return(et&6)!==0?ot():Ad!==-1?Ad:Ad=ot()}function xa(l){return(l.mode&1)===0?1:(et&2)!==0&&tn!==0?tn&-tn:A6.transition!==null?(Md===0&&(Md=Sl()),Md):(l=st,l!==0||(l=window.event,l=l===void 0?16:Il(l.type)),l)}function Cs(l,u,g,x){if(50<uc)throw uc=0,zm=null,Error(n(185));na(l,g,x),((et&2)===0||l!==Xt)&&(l===Xt&&((et&2)===0&&(Ed|=g),Wt===4&&va(l,tn)),Sn(l,x),g===1&&et===0&&(u.mode&1)===0&&(Si=ot()+500,od&&fa()))}function Sn(l,u){var g=l.callbackNode;Xa(l,u);var x=ta(l,l===Xt?tn:0);if(x===0)g!==null&&Qr(g),l.callbackNode=null,l.callbackPriority=0;else if(u=x&-x,l.callbackPriority!==u){if(g!=null&&Qr(g),u===1)l.tag===0?R6(CS.bind(null,l)):fN(CS.bind(null,l)),_6(function(){(et&6)===0&&fa()}),g=null;else{switch(El(x)){case 1:g=br;break;case 4:g=xs;break;case 16:g=vs;break;case 536870912:g=kr;break;default:g=vs}g=OS(g,ES.bind(null,l))}l.callbackPriority=u,l.callbackNode=g}}function ES(l,u){if(Ad=-1,Md=0,(et&6)!==0)throw Error(n(327));var g=l.callbackNode;if(_i()&&l.callbackNode!==g)return null;var x=ta(l,l===Xt?tn:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||u)u=$d(l,x);else{u=x;var _=et;et|=2;var T=RS();(Xt!==l||tn!==u)&&(Lr=null,Si=ot()+500,mo(l,u));do try{Z6();break}catch(Q){TS(l,Q)}while(!0);cm(),_d.current=T,et=_,Ot!==null?u=0:(Xt=null,tn=0,u=Wt)}if(u!==0){if(u===2&&(_=Ys(l),_!==0&&(x=_,u=Vm(l,_))),u===1)throw g=lc,mo(l,0),va(l,x),Sn(l,ot()),g;if(u===6)va(l,x);else{if(_=l.current.alternate,(x&30)===0&&!Y6(_)&&(u=$d(l,x),u===2&&(T=Ys(l),T!==0&&(x=T,u=Vm(l,T))),u===1))throw g=lc,mo(l,0),va(l,x),Sn(l,ot()),g;switch(l.finishedWork=_,l.finishedLanes=x,u){case 0:case 1:throw Error(n(345));case 2:go(l,Nn,Lr);break;case 3:if(va(l,x),(x&130023424)===x&&(u=Wm+500-ot(),10<u)){if(ta(l,0)!==0)break;if(_=l.suspendedLanes,(_&x)!==x){pn(),l.pingedLanes|=l.suspendedLanes&_;break}l.timeoutHandle=Jp(go.bind(null,l,Nn,Lr),u);break}go(l,Nn,Lr);break;case 4:if(va(l,x),(x&4194240)===x)break;for(u=l.eventTimes,_=-1;0<x;){var z=31-qt(x);T=1<<z,z=u[z],z>_&&(_=z),x&=~T}if(x=_,x=ot()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*K6(x/1960))-x,10<x){l.timeoutHandle=Jp(go.bind(null,l,Nn,Lr),x);break}go(l,Nn,Lr);break;case 5:go(l,Nn,Lr);break;default:throw Error(n(329))}}}return Sn(l,ot()),l.callbackNode===g?ES.bind(null,l):null}function Vm(l,u){var g=cc;return l.current.memoizedState.isDehydrated&&(mo(l,u).flags|=256),l=$d(l,u),l!==2&&(u=Nn,Nn=g,u!==null&&Gm(u)),l}function Gm(l){Nn===null?Nn=l:Nn.push.apply(Nn,l)}function Y6(l){for(var u=l;;){if(u.flags&16384){var g=u.updateQueue;if(g!==null&&(g=g.stores,g!==null))for(var x=0;x<g.length;x++){var _=g[x],T=_.getSnapshot;_=_.value;try{if(!js(T(),_))return!1}catch{return!1}}}if(g=u.child,u.subtreeFlags&16384&&g!==null)g.return=u,u=g;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function va(l,u){for(u&=~Um,u&=~Ed,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var g=31-qt(u),x=1<<g;l[g]=-1,u&=~x}}function CS(l){if((et&6)!==0)throw Error(n(327));_i();var u=ta(l,0);if((u&1)===0)return Sn(l,ot()),null;var g=$d(l,u);if(l.tag!==0&&g===2){var x=Ys(l);x!==0&&(u=x,g=Vm(l,x))}if(g===1)throw g=lc,mo(l,0),va(l,u),Sn(l,ot()),g;if(g===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,go(l,Nn,Lr),Sn(l,ot()),null}function Km(l,u){var g=et;et|=1;try{return l(u)}finally{et=g,et===0&&(Si=ot()+500,od&&fa())}}function po(l){wa!==null&&wa.tag===0&&(et&6)===0&&_i();var u=et;et|=1;var g=rs.transition,x=st;try{if(rs.transition=null,st=1,l)return l()}finally{st=x,rs.transition=g,et=u,(et&6)===0&&fa()}}function Ym(){Bn=Ni.current,kt(Ni)}function mo(l,u){l.finishedWork=null,l.finishedLanes=0;var g=l.timeoutHandle;if(g!==-1&&(l.timeoutHandle=-1,S6(g)),Ot!==null)for(g=Ot.return;g!==null;){var x=g;switch(rm(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&rd();break;case 3:bi(),kt(bn),kt(on),ym();break;case 5:mm(x);break;case 4:bi();break;case 13:kt(_t);break;case 19:kt(_t);break;case 10:um(x.type._context);break;case 22:case 23:Ym()}g=g.return}if(Xt=l,Ot=l=ba(l.current,null),tn=Bn=u,Wt=0,lc=null,Um=Ed=fo=0,Nn=cc=null,co!==null){for(u=0;u<co.length;u++)if(g=co[u],x=g.interleaved,x!==null){g.interleaved=null;var _=x.next,T=g.pending;if(T!==null){var z=T.next;T.next=_,x.next=z}g.pending=x}co=null}return l}function TS(l,u){do{var g=Ot;try{if(cm(),gd.current=vd,yd){for(var x=Et.memoizedState;x!==null;){var _=x.queue;_!==null&&(_.pending=null),x=x.next}yd=!1}if(ho=0,Yt=Ut=Et=null,nc=!1,sc=0,qm.current=null,g===null||g.return===null){Wt=1,lc=u,Ot=null;break}e:{var T=l,z=g.return,Q=g,te=u;if(u=tn,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ce=te,ve=Q,be=ve.tag;if((ve.mode&1)===0&&(be===0||be===11||be===15)){var xe=ve.alternate;xe?(ve.updateQueue=xe.updateQueue,ve.memoizedState=xe.memoizedState,ve.lanes=xe.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Ee=eS(z);if(Ee!==null){Ee.flags&=-257,tS(Ee,z,Q,T,u),Ee.mode&1&&QN(T,ce,u),u=Ee,te=ce;var Re=u.updateQueue;if(Re===null){var Me=new Set;Me.add(te),u.updateQueue=Me}else Re.add(te);break e}else{if((u&1)===0){QN(T,ce,u),Xm();break e}te=Error(n(426))}}else if(jt&&Q.mode&1){var Mt=eS(z);if(Mt!==null){(Mt.flags&65536)===0&&(Mt.flags|=256),tS(Mt,z,Q,T,u),im(ki(te,Q));break e}}T=te=ki(te,Q),Wt!==4&&(Wt=2),cc===null?cc=[T]:cc.push(T),T=z;do{switch(T.tag){case 3:T.flags|=65536,u&=-u,T.lanes|=u;var oe=ZN(T,te,u);NN(T,oe);break e;case 1:Q=te;var se=T.type,ie=T.stateNode;if((T.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(ya===null||!ya.has(ie)))){T.flags|=65536,u&=-u,T.lanes|=u;var ke=JN(T,Q,u);NN(T,ke);break e}}T=T.return}while(T!==null)}MS(g)}catch(Ie){u=Ie,Ot===g&&g!==null&&(Ot=g=g.return);continue}break}while(!0)}function RS(){var l=_d.current;return _d.current=vd,l===null?vd:l}function Xm(){(Wt===0||Wt===3||Wt===2)&&(Wt=4),Xt===null||(fo&268435455)===0&&(Ed&268435455)===0||va(Xt,tn)}function $d(l,u){var g=et;et|=2;var x=RS();(Xt!==l||tn!==u)&&(Lr=null,mo(l,u));do try{X6();break}catch(_){TS(l,_)}while(!0);if(cm(),et=g,_d.current=x,Ot!==null)throw Error(n(261));return Xt=null,tn=0,Wt}function X6(){for(;Ot!==null;)AS(Ot)}function Z6(){for(;Ot!==null&&!Gs();)AS(Ot)}function AS(l){var u=LS(l.alternate,l,Bn);l.memoizedProps=l.pendingProps,u===null?MS(l):Ot=u,qm.current=null}function MS(l){var u=l;do{var g=u.alternate;if(l=u.return,(u.flags&32768)===0){if(g=W6(g,u,Bn),g!==null){Ot=g;return}}else{if(g=H6(g,u),g!==null){g.flags&=32767,Ot=g;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{Wt=6,Ot=null;return}}if(u=u.sibling,u!==null){Ot=u;return}Ot=u=l}while(u!==null);Wt===0&&(Wt=5)}function go(l,u,g){var x=st,_=rs.transition;try{rs.transition=null,st=1,J6(l,u,g,x)}finally{rs.transition=_,st=x}return null}function J6(l,u,g,x){do _i();while(wa!==null);if((et&6)!==0)throw Error(n(327));g=l.finishedWork;var _=l.finishedLanes;if(g===null)return null;if(l.finishedWork=null,l.finishedLanes=0,g===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var T=g.lanes|g.childLanes;if(Xs(l,T),l===Xt&&(Ot=Xt=null,tn=0),(g.subtreeFlags&2064)===0&&(g.flags&2064)===0||Td||(Td=!0,OS(vs,function(){return _i(),null})),T=(g.flags&15990)!==0,(g.subtreeFlags&15990)!==0||T){T=rs.transition,rs.transition=null;var z=st;st=1;var Q=et;et|=4,qm.current=null,V6(l,g),kS(g,l),w6(Xp),si=!!Yp,Xp=Yp=null,l.current=g,G6(g),vr(),et=Q,st=z,rs.transition=T}else l.current=g;if(Td&&(Td=!1,wa=l,Rd=_),T=l.pendingLanes,T===0&&(ya=null),Ks(g.stateNode),Sn(l,ot()),u!==null)for(x=l.onRecoverableError,g=0;g<u.length;g++)_=u[g],x(_.value,{componentStack:_.stack,digest:_.digest});if(Cd)throw Cd=!1,l=Hm,Hm=null,l;return(Rd&1)!==0&&l.tag!==0&&_i(),T=l.pendingLanes,(T&1)!==0?l===zm?uc++:(uc=0,zm=l):uc=0,fa(),null}function _i(){if(wa!==null){var l=El(Rd),u=rs.transition,g=st;try{if(rs.transition=null,st=16>l?16:l,wa===null)var x=!1;else{if(l=wa,wa=null,Rd=0,(et&6)!==0)throw Error(n(331));var _=et;for(et|=4,Ce=l.current;Ce!==null;){var T=Ce,z=T.child;if((Ce.flags&16)!==0){var Q=T.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ce=Q[te];for(Ce=ce;Ce!==null;){var ve=Ce;switch(ve.tag){case 0:case 11:case 15:ic(8,ve,T)}var be=ve.child;if(be!==null)be.return=ve,Ce=be;else for(;Ce!==null;){ve=Ce;var xe=ve.sibling,Ee=ve.return;if(yS(ve),ve===ce){Ce=null;break}if(xe!==null){xe.return=Ee,Ce=xe;break}Ce=Ee}}}var Re=T.alternate;if(Re!==null){var Me=Re.child;if(Me!==null){Re.child=null;do{var Mt=Me.sibling;Me.sibling=null,Me=Mt}while(Me!==null)}}Ce=T}}if((T.subtreeFlags&2064)!==0&&z!==null)z.return=T,Ce=z;else e:for(;Ce!==null;){if(T=Ce,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:ic(9,T,T.return)}var oe=T.sibling;if(oe!==null){oe.return=T.return,Ce=oe;break e}Ce=T.return}}var se=l.current;for(Ce=se;Ce!==null;){z=Ce;var ie=z.child;if((z.subtreeFlags&2064)!==0&&ie!==null)ie.return=z,Ce=ie;else e:for(z=se;Ce!==null;){if(Q=Ce,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Sd(9,Q)}}catch(Ie){Tt(Q,Q.return,Ie)}if(Q===z){Ce=null;break e}var ke=Q.sibling;if(ke!==null){ke.return=Q.return,Ce=ke;break e}Ce=Q.return}}if(et=_,fa(),Jt&&typeof Jt.onPostCommitFiberRoot=="function")try{Jt.onPostCommitFiberRoot(Pn,l)}catch{}x=!0}return x}finally{st=g,rs.transition=u}}return!1}function $S(l,u,g){u=ki(g,u),u=ZN(l,u,1),l=ma(l,u,1),u=pn(),l!==null&&(na(l,1,u),Sn(l,u))}function Tt(l,u,g){if(l.tag===3)$S(l,l,g);else for(;u!==null;){if(u.tag===3){$S(u,l,g);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(ya===null||!ya.has(x))){l=ki(g,l),l=JN(u,l,1),u=ma(u,l,1),l=pn(),u!==null&&(na(u,1,l),Sn(u,l));break}}u=u.return}}function Q6(l,u,g){var x=l.pingCache;x!==null&&x.delete(u),u=pn(),l.pingedLanes|=l.suspendedLanes&g,Xt===l&&(tn&g)===g&&(Wt===4||Wt===3&&(tn&130023424)===tn&&500>ot()-Wm?mo(l,0):Um|=g),Sn(l,u)}function IS(l,u){u===0&&((l.mode&1)===0?u=1:(u=dn,dn<<=1,(dn&130023424)===0&&(dn=4194304)));var g=pn();l=Mr(l,u),l!==null&&(na(l,u,g),Sn(l,g))}function eF(l){var u=l.memoizedState,g=0;u!==null&&(g=u.retryLane),IS(l,g)}function tF(l,u){var g=0;switch(l.tag){case 13:var x=l.stateNode,_=l.memoizedState;_!==null&&(g=_.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(u),IS(l,g)}var LS;LS=function(l,u,g){if(l!==null)if(l.memoizedProps!==u.pendingProps||bn.current)jn=!0;else{if((l.lanes&g)===0&&(u.flags&128)===0)return jn=!1,U6(l,u,g);jn=(l.flags&131072)!==0}else jn=!1,jt&&(u.flags&1048576)!==0&&pN(u,ld,u.index);switch(u.lanes=0,u.tag){case 2:var x=u.type;jd(l,u),l=u.pendingProps;var _=pi(u,on.current);vi(u,g),_=vm(null,u,x,l,_,g);var T=bm();return u.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,kn(x)?(T=!0,ad(u)):T=!1,u.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,fm(u),_.updater=bd,u.stateNode=_,_._reactInternals=u,Em(u,x,l,g),u=Am(null,u,x,!0,T,g)):(u.tag=0,jt&&T&&sm(u),fn(null,u,_,g),u=u.child),u;case 16:x=u.elementType;e:{switch(jd(l,u),l=u.pendingProps,_=x._init,x=_(x._payload),u.type=x,_=u.tag=sF(x),l=Ss(x,l),_){case 0:u=Rm(null,u,x,l,g);break e;case 1:u=iS(null,u,x,l,g);break e;case 11:u=nS(null,u,x,l,g);break e;case 14:u=sS(null,u,x,Ss(x.type,l),g);break e}throw Error(n(306,x,""))}return u;case 0:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:Ss(x,_),Rm(l,u,x,_,g);case 1:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:Ss(x,_),iS(l,u,x,_,g);case 3:e:{if(lS(u),l===null)throw Error(n(387));x=u.pendingProps,T=u.memoizedState,_=T.element,jN(l,u),pd(u,x,null,g);var z=u.memoizedState;if(x=z.element,T.isDehydrated)if(T={element:x,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},u.updateQueue.baseState=T,u.memoizedState=T,u.flags&256){_=ki(Error(n(423)),u),u=cS(l,u,x,g,_);break e}else if(x!==_){_=ki(Error(n(424)),u),u=cS(l,u,x,g,_);break e}else for(Fn=ua(u.stateNode.containerInfo.firstChild),Dn=u,jt=!0,Ns=null,g=bN(u,null,x,g),u.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(yi(),x===_){u=Ir(l,u,g);break e}fn(l,u,x,g)}u=u.child}return u;case 5:return _N(u),l===null&&om(u),x=u.type,_=u.pendingProps,T=l!==null?l.memoizedProps:null,z=_.children,Zp(x,_)?z=null:T!==null&&Zp(x,T)&&(u.flags|=32),oS(l,u),fn(l,u,z,g),u.child;case 6:return l===null&&om(u),null;case 13:return uS(l,u,g);case 4:return pm(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=wi(u,null,x,g):fn(l,u,x,g),u.child;case 11:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:Ss(x,_),nS(l,u,x,_,g);case 7:return fn(l,u,u.pendingProps,g),u.child;case 8:return fn(l,u,u.pendingProps.children,g),u.child;case 12:return fn(l,u,u.pendingProps.children,g),u.child;case 10:e:{if(x=u.type._context,_=u.pendingProps,T=u.memoizedProps,z=_.value,mt(dd,x._currentValue),x._currentValue=z,T!==null)if(js(T.value,z)){if(T.children===_.children&&!bn.current){u=Ir(l,u,g);break e}}else for(T=u.child,T!==null&&(T.return=u);T!==null;){var Q=T.dependencies;if(Q!==null){z=T.child;for(var te=Q.firstContext;te!==null;){if(te.context===x){if(T.tag===1){te=$r(-1,g&-g),te.tag=2;var ce=T.updateQueue;if(ce!==null){ce=ce.shared;var ve=ce.pending;ve===null?te.next=te:(te.next=ve.next,ve.next=te),ce.pending=te}}T.lanes|=g,te=T.alternate,te!==null&&(te.lanes|=g),dm(T.return,g,u),Q.lanes|=g;break}te=te.next}}else if(T.tag===10)z=T.type===u.type?null:T.child;else if(T.tag===18){if(z=T.return,z===null)throw Error(n(341));z.lanes|=g,Q=z.alternate,Q!==null&&(Q.lanes|=g),dm(z,g,u),z=T.sibling}else z=T.child;if(z!==null)z.return=T;else for(z=T;z!==null;){if(z===u){z=null;break}if(T=z.sibling,T!==null){T.return=z.return,z=T;break}z=z.return}T=z}fn(l,u,_.children,g),u=u.child}return u;case 9:return _=u.type,x=u.pendingProps.children,vi(u,g),_=ns(_),x=x(_),u.flags|=1,fn(l,u,x,g),u.child;case 14:return x=u.type,_=Ss(x,u.pendingProps),_=Ss(x.type,_),sS(l,u,x,_,g);case 15:return rS(l,u,u.type,u.pendingProps,g);case 17:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:Ss(x,_),jd(l,u),u.tag=1,kn(x)?(l=!0,ad(u)):l=!1,vi(u,g),YN(u,x,_),Em(u,x,_,g),Am(null,u,x,!0,l,g);case 19:return hS(l,u,g);case 22:return aS(l,u,g)}throw Error(n(156,u.tag))};function OS(l,u){return Bt(l,u)}function nF(l,u,g,x){this.tag=l,this.key=g,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function as(l,u,g,x){return new nF(l,u,g,x)}function Zm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function sF(l){if(typeof l=="function")return Zm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===M)return 11;if(l===D)return 14}return 2}function ba(l,u){var g=l.alternate;return g===null?(g=as(l.tag,u,l.key,l.mode),g.elementType=l.elementType,g.type=l.type,g.stateNode=l.stateNode,g.alternate=l,l.alternate=g):(g.pendingProps=u,g.type=l.type,g.flags=0,g.subtreeFlags=0,g.deletions=null),g.flags=l.flags&14680064,g.childLanes=l.childLanes,g.lanes=l.lanes,g.child=l.child,g.memoizedProps=l.memoizedProps,g.memoizedState=l.memoizedState,g.updateQueue=l.updateQueue,u=l.dependencies,g.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},g.sibling=l.sibling,g.index=l.index,g.ref=l.ref,g}function Id(l,u,g,x,_,T){var z=2;if(x=l,typeof l=="function")Zm(l)&&(z=1);else if(typeof l=="string")z=5;else e:switch(l){case R:return yo(g.children,_,T,u);case $:z=8,_|=8;break;case L:return l=as(12,g,u,_|2),l.elementType=L,l.lanes=T,l;case q:return l=as(13,g,u,_),l.elementType=q,l.lanes=T,l;case A:return l=as(19,g,u,_),l.elementType=A,l.lanes=T,l;case K:return Ld(g,_,T,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case U:z=10;break e;case O:z=9;break e;case M:z=11;break e;case D:z=14;break e;case P:z=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=as(z,g,u,_),u.elementType=l,u.type=x,u.lanes=T,u}function yo(l,u,g,x){return l=as(7,l,x,u),l.lanes=g,l}function Ld(l,u,g,x){return l=as(22,l,x,u),l.elementType=K,l.lanes=g,l.stateNode={isHidden:!1},l}function Jm(l,u,g){return l=as(6,l,null,u),l.lanes=g,l}function Qm(l,u,g){return u=as(4,l.children!==null?l.children:[],l.key,u),u.lanes=g,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function rF(l,u,g,x,_){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qo(0),this.expirationTimes=Qo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qo(0),this.identifierPrefix=x,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function eg(l,u,g,x,_,T,z,Q,te){return l=new rF(l,u,g,Q,te),u===1?(u=1,T===!0&&(u|=8)):u=0,T=as(3,null,null,u),l.current=T,T.stateNode=l,T.memoizedState={element:x,isDehydrated:g,cache:null,transitions:null,pendingSuspenseBoundaries:null},fm(T),l}function aF(l,u,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:x==null?null:""+x,children:l,containerInfo:u,implementation:g}}function PS(l){if(!l)return ha;l=l._reactInternals;e:{if(xn(l)!==l||l.tag!==1)throw Error(n(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(kn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(l.tag===1){var g=l.type;if(kn(g))return dN(l,g,u)}return u}function DS(l,u,g,x,_,T,z,Q,te){return l=eg(g,x,!0,l,_,T,z,Q,te),l.context=PS(null),g=l.current,x=pn(),_=xa(g),T=$r(x,_),T.callback=u??null,ma(g,T,_),l.current.lanes=_,na(l,_,x),Sn(l,x),l}function Od(l,u,g,x){var _=u.current,T=pn(),z=xa(_);return g=PS(g),u.context===null?u.context=g:u.pendingContext=g,u=$r(T,z),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=ma(_,u,z),l!==null&&(Cs(l,_,z,T),fd(l,_,z)),z}function Pd(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function FS(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var g=l.retryLane;l.retryLane=g!==0&&g<u?g:u}}function tg(l,u){FS(l,u),(l=l.alternate)&&FS(l,u)}function oF(){return null}var BS=typeof reportError=="function"?reportError:function(l){console.error(l)};function ng(l){this._internalRoot=l}Dd.prototype.render=ng.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));Od(l,u,null,null)},Dd.prototype.unmount=ng.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;po(function(){Od(null,l,null,null)}),u[Cr]=null}};function Dd(l){this._internalRoot=l}Dd.prototype.unstable_scheduleHydration=function(l){if(l){var u=Zs();l={blockedOn:null,target:l,priority:u};for(var g=0;g<Qs.length&&u!==0&&u<Qs[g].priority;g++);Qs.splice(g,0,l),g===0&&Ml(l)}};function sg(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function Fd(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function qS(){}function iF(l,u,g,x,_){if(_){if(typeof x=="function"){var T=x;x=function(){var ce=Pd(z);T.call(ce)}}var z=DS(u,x,l,0,null,!1,!1,"",qS);return l._reactRootContainer=z,l[Cr]=z.current,Kl(l.nodeType===8?l.parentNode:l),po(),z}for(;_=l.lastChild;)l.removeChild(_);if(typeof x=="function"){var Q=x;x=function(){var ce=Pd(te);Q.call(ce)}}var te=eg(l,0,!1,null,null,!1,!1,"",qS);return l._reactRootContainer=te,l[Cr]=te.current,Kl(l.nodeType===8?l.parentNode:l),po(function(){Od(u,te,g,x)}),te}function Bd(l,u,g,x,_){var T=g._reactRootContainer;if(T){var z=T;if(typeof _=="function"){var Q=_;_=function(){var te=Pd(z);Q.call(te)}}Od(u,z,l,_)}else z=iF(g,u,l,_,x);return Pd(z)}Cl=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var g=bs(u.pendingLanes);g!==0&&(_l(u,g|1),Sn(u,ot()),(et&6)===0&&(Si=ot()+500,fa()))}break;case 13:po(function(){var x=Mr(l,1);if(x!==null){var _=pn();Cs(x,l,1,_)}}),tg(l,1)}},Za=function(l){if(l.tag===13){var u=Mr(l,134217728);if(u!==null){var g=pn();Cs(u,l,134217728,g)}tg(l,134217728)}},ei=function(l){if(l.tag===13){var u=xa(l),g=Mr(l,u);if(g!==null){var x=pn();Cs(g,l,u,x)}tg(l,u)}},Zs=function(){return st},Fu=function(l,u){var g=st;try{return st=l,u()}finally{st=g}},Ft=function(l,u,g){switch(u){case"input":if(he(l,g),u=g.name,g.type==="radio"&&u!=null){for(g=l;g.parentNode;)g=g.parentNode;for(g=g.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<g.length;u++){var x=g[u];if(x!==l&&x.form===l.form){var _=sd(x);if(!_)throw Error(n(90));ue(x),he(x,_)}}}break;case"textarea":qe(l,g);break;case"select":u=g.value,u!=null&&me(l,!!g.multiple,u,!1)}},ws=Km,Yn=po;var lF={usingClientEntryPoint:!1,Events:[Zl,hi,sd,ys,Ws,Km]},dc={findFiberByHostInstance:ao,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},cF={bundleType:dc.bundleType,version:dc.version,rendererPackageName:dc.rendererPackageName,rendererConfig:dc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=wr(l),l===null?null:l.stateNode},findFiberByHostInstance:dc.findFiberByHostInstance||oF,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 qd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qd.isDisabled&&qd.supportsFiber)try{Pn=qd.inject(cF),Jt=qd}catch{}}return _n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lF,_n.createPortal=function(l,u){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!sg(u))throw Error(n(200));return aF(l,u,null,g)},_n.createRoot=function(l,u){if(!sg(l))throw Error(n(299));var g=!1,x="",_=BS;return u!=null&&(u.unstable_strictMode===!0&&(g=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(_=u.onRecoverableError)),u=eg(l,1,!1,null,null,g,!1,x,_),l[Cr]=u.current,Kl(l.nodeType===8?l.parentNode:l),new ng(u)},_n.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=wr(u),l=l===null?null:l.stateNode,l},_n.flushSync=function(l){return po(l)},_n.hydrate=function(l,u,g){if(!Fd(u))throw Error(n(200));return Bd(null,l,u,!0,g)},_n.hydrateRoot=function(l,u,g){if(!sg(l))throw Error(n(405));var x=g!=null&&g.hydratedSources||null,_=!1,T="",z=BS;if(g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(T=g.identifierPrefix),g.onRecoverableError!==void 0&&(z=g.onRecoverableError)),u=DS(u,null,l,1,g??null,_,!1,T,z),l[Cr]=u.current,Kl(l),x)for(l=0;l<x.length;l++)g=x[l],_=g._getVersion,_=_(g._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[g,_]:u.mutableSourceEagerHydrationData.push(g,_);return new Dd(u)},_n.render=function(l,u,g){if(!Fd(u))throw Error(n(200));return Bd(null,l,u,!1,g)},_n.unmountComponentAtNode=function(l){if(!Fd(l))throw Error(n(40));return l._reactRootContainer?(po(function(){Bd(null,null,l,!1,function(){l._reactRootContainer=null,l[Cr]=null})}),!0):!1},_n.unstable_batchedUpdates=Km,_n.unstable_renderSubtreeIntoContainer=function(l,u,g,x){if(!Fd(g))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return Bd(l,u,g,!1,x)},_n.version="18.3.1-next-f1338f8080-20240426",_n}var YS;function HI(){if(YS)return ig.exports;YS=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(),ig.exports=wF(),ig.exports}var XS;function xF(){if(XS)return Wd;XS=1;var e=HI();return Wd.createRoot=e.createRoot,Wd.hydrateRoot=e.hydrateRoot,Wd}var vF=xF(),y=gu();const fe=H0(y);function rn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=rn(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var ug={exports:{}},dg={},hg={exports:{}},fg={};/**
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 ZS;function bF(){if(ZS)return fg;ZS=1;var e=gu();function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,r=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function c(p,m){var w=m(),j=s({inst:{value:w,getSnapshot:m}}),b=j[0].inst,k=j[1];return o(function(){b.value=w,b.getSnapshot=m,d(b)&&k({inst:b})},[p,w,m]),r(function(){return d(b)&&k({inst:b}),p(function(){d(b)&&k({inst:b})})},[p]),i(w),w}function d(p){var m=p.getSnapshot;p=p.value;try{var w=m();return!n(p,w)}catch{return!0}}function h(p,m){return m()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return fg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,fg}var JS;function kF(){return JS||(JS=1,hg.exports=bF()),hg.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 QS;function jF(){if(QS)return dg;QS=1;var e=gu(),t=kF();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return dg.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var j=o(null);if(j.current===null){var b={hasValue:!1,value:null};j.current=b}else b=j.current;j=c(function(){function v(I){if(!N){if(N=!0,S=I,I=m(I),w!==void 0&&b.hasValue){var R=b.value;if(w(R,I))return E=R}return E=I}if(R=E,s(S,I))return R;var $=m(I);return w!==void 0&&w(R,$)?(S=I,R):(S=I,E=$)}var N=!1,S,E,C=p===void 0?null:p;return[function(){return v(f())},C===null?void 0:function(){return v(C())}]},[f,p,m,w]);var k=r(h,j[0],j[1]);return i(function(){b.hasValue=!0,b.value=k},[k]),d(k),k},dg}var e_;function NF(){return e_||(e_=1,ug.exports=jF()),ug.exports}var SF=NF();const _F=H0(SF),EF={},t_=e=>{let t;const n=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const w=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(j=>j(t,w))}},r=()=>t,d={setState:s,getState:r,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(EF?"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(s,r,d);return d},CF=e=>e?t_(e):t_,{useDebugValue:TF}=fe,{useSyncExternalStoreWithSelector:RF}=_F,AF=e=>e;function zI(e,t=AF,n){const s=RF(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return TF(s),s}const n_=(e,t)=>{const n=CF(e),s=(r,o=t)=>zI(n,r,o);return Object.assign(s,n),s},MF=(e,t)=>e?n_(e,t):n_;function Kt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,r]of e)if(!Object.is(r,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}var $F={value:()=>{}};function Nf(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new vh(n)}function vh(e){this._=e}function IF(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}vh.prototype=Nf.prototype={constructor:vh,on:function(e,t){var n=this._,s=IF(e+"",n),r,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((r=(e=s[o]).type)&&(r=LF(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(r=(e=s[o]).type)n[r]=s_(n[r],e.name,t);else if(t==null)for(r in n)n[r]=s_(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new vh(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,o;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],s=0,r=o.length;s<r;++s)o[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)}};function LF(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function s_(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=$F,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var bk="http://www.w3.org/1999/xhtml";const r_={svg:"http://www.w3.org/2000/svg",xhtml:bk,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Sf(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),r_.hasOwnProperty(t)?{space:r_[t],local:e}:e}function OF(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===bk&&t.documentElement.namespaceURI===bk?t.createElement(e):t.createElementNS(n,e)}}function PF(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function VI(e){var t=Sf(e);return(t.local?PF:OF)(t)}function DF(){}function z0(e){return e==null?DF:function(){return this.querySelector(e)}}function FF(e){typeof e!="function"&&(e=z0(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var o=t[r],i=o.length,c=s[r]=new Array(i),d,h,f=0;f<i;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),c[f]=h);return new Vn(s,this._parents)}function BF(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qF(){return[]}function GI(e){return e==null?qF:function(){return this.querySelectorAll(e)}}function UF(e){return function(){return BF(e.apply(this,arguments))}}function WF(e){typeof e=="function"?e=UF(e):e=GI(e);for(var t=this._groups,n=t.length,s=[],r=[],o=0;o<n;++o)for(var i=t[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&(s.push(e.call(d,d.__data__,h,i)),r.push(d));return new Vn(s,r)}function KI(e){return function(){return this.matches(e)}}function YI(e){return function(t){return t.matches(e)}}var HF=Array.prototype.find;function zF(e){return function(){return HF.call(this.children,e)}}function VF(){return this.firstElementChild}function GF(e){return this.select(e==null?VF:zF(typeof e=="function"?e:YI(e)))}var KF=Array.prototype.filter;function YF(){return Array.from(this.children)}function XF(e){return function(){return KF.call(this.children,e)}}function ZF(e){return this.selectAll(e==null?YF:XF(typeof e=="function"?e:YI(e)))}function JF(e){typeof e!="function"&&(e=KI(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var o=t[r],i=o.length,c=s[r]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Vn(s,this._parents)}function XI(e){return new Array(e.length)}function QF(){return new Vn(this._enter||this._groups.map(XI),this._parents)}function Lh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Lh.prototype={constructor:Lh,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 e8(e){return function(){return e}}function t8(e,t,n,s,r,o){for(var i=0,c,d=t.length,h=o.length;i<h;++i)(c=t[i])?(c.__data__=o[i],s[i]=c):n[i]=new Lh(e,o[i]);for(;i<d;++i)(c=t[i])&&(r[i]=c)}function n8(e,t,n,s,r,o,i){var c,d,h=new Map,f=t.length,p=o.length,m=new Array(f),w;for(c=0;c<f;++c)(d=t[c])&&(m[c]=w=i.call(d,d.__data__,c,t)+"",h.has(w)?r[c]=d:h.set(w,d));for(c=0;c<p;++c)w=i.call(e,o[c],c,o)+"",(d=h.get(w))?(s[c]=d,d.__data__=o[c],h.delete(w)):n[c]=new Lh(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(m[c])===d&&(r[c]=d)}function s8(e){return e.__data__}function r8(e,t){if(!arguments.length)return Array.from(this,s8);var n=t?n8:t8,s=this._parents,r=this._groups;typeof e!="function"&&(e=e8(e));for(var o=r.length,i=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=s[h],p=r[h],m=p.length,w=a8(e.call(f,f&&f.__data__,h,s)),j=w.length,b=c[h]=new Array(j),k=i[h]=new Array(j),v=d[h]=new Array(m);n(f,p,b,k,v,w,t);for(var N=0,S=0,E,C;N<j;++N)if(E=b[N]){for(N>=S&&(S=N+1);!(C=k[S])&&++S<j;);E._next=C||null}}return i=new Vn(i,s),i._enter=c,i._exit=d,i}function a8(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function o8(){return new Vn(this._exit||this._groups.map(XI),this._parents)}function i8(e,t,n){var s=this.enter(),r=this,o=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?o.remove():n(o),s&&r?s.merge(r).order():r}function l8(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,o=s.length,i=Math.min(r,o),c=new Array(r),d=0;d<i;++d)for(var h=n[d],f=s[d],p=h.length,m=c[d]=new Array(p),w,j=0;j<p;++j)(w=h[j]||f[j])&&(m[j]=w);for(;d<r;++d)c[d]=n[d];return new Vn(c,this._parents)}function c8(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,o=s[r],i;--r>=0;)(i=s[r])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function u8(e){e||(e=d8);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,r=new Array(s),o=0;o<s;++o){for(var i=n[o],c=i.length,d=r[o]=new Array(c),h,f=0;f<c;++f)(h=i[f])&&(d[f]=h);d.sort(t)}return new Vn(r,this._parents).order()}function d8(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function h8(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function f8(){return Array.from(this)}function p8(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,o=s.length;r<o;++r){var i=s[r];if(i)return i}return null}function m8(){let e=0;for(const t of this)++e;return e}function g8(){return!this.node()}function y8(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],o=0,i=r.length,c;o<i;++o)(c=r[o])&&e.call(c,c.__data__,o,r);return this}function w8(e){return function(){this.removeAttribute(e)}}function x8(e){return function(){this.removeAttributeNS(e.space,e.local)}}function v8(e,t){return function(){this.setAttribute(e,t)}}function b8(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function k8(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function j8(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 N8(e,t){var n=Sf(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?x8:w8:typeof t=="function"?n.local?j8:k8:n.local?b8:v8)(n,t))}function ZI(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function S8(e){return function(){this.style.removeProperty(e)}}function _8(e,t,n){return function(){this.style.setProperty(e,t,n)}}function E8(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function C8(e,t,n){return arguments.length>1?this.each((t==null?S8:typeof t=="function"?E8:_8)(e,t,n??"")):sl(this.node(),e)}function sl(e,t){return e.style.getPropertyValue(t)||ZI(e).getComputedStyle(e,null).getPropertyValue(t)}function T8(e){return function(){delete this[e]}}function R8(e,t){return function(){this[e]=t}}function A8(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function M8(e,t){return arguments.length>1?this.each((t==null?T8:typeof t=="function"?A8:R8)(e,t)):this.node()[e]}function JI(e){return e.trim().split(/^|\s+/)}function V0(e){return e.classList||new QI(e)}function QI(e){this._node=e,this._names=JI(e.getAttribute("class")||"")}QI.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 eL(e,t){for(var n=V0(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function tL(e,t){for(var n=V0(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function $8(e){return function(){eL(this,e)}}function I8(e){return function(){tL(this,e)}}function L8(e,t){return function(){(t.apply(this,arguments)?eL:tL)(this,e)}}function O8(e,t){var n=JI(e+"");if(arguments.length<2){for(var s=V0(this.node()),r=-1,o=n.length;++r<o;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?L8:t?$8:I8)(n,t))}function P8(){this.textContent=""}function D8(e){return function(){this.textContent=e}}function F8(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function B8(e){return arguments.length?this.each(e==null?P8:(typeof e=="function"?F8:D8)(e)):this.node().textContent}function q8(){this.innerHTML=""}function U8(e){return function(){this.innerHTML=e}}function W8(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function H8(e){return arguments.length?this.each(e==null?q8:(typeof e=="function"?W8:U8)(e)):this.node().innerHTML}function z8(){this.nextSibling&&this.parentNode.appendChild(this)}function V8(){return this.each(z8)}function G8(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function K8(){return this.each(G8)}function Y8(e){var t=typeof e=="function"?e:VI(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function X8(){return null}function Z8(e,t){var n=typeof e=="function"?e:VI(e),s=t==null?X8:typeof t=="function"?t:z0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function J8(){var e=this.parentNode;e&&e.removeChild(this)}function Q8(){return this.each(J8)}function eB(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tB(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nB(e){return this.select(e?tB:eB)}function sB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rB(e){return function(t){e.call(this,t,this.__data__)}}function aB(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function oB(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,o;n<r;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++s]=o;++s?t.length=s:delete this.__on}}}function iB(e,t,n){return function(){var s=this.__on,r,o=rB(t);if(s){for(var i=0,c=s.length;i<c;++i)if((r=s[i]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=t;return}}this.addEventListener(e.type,o,n),r={type:e.type,name:e.name,value:t,listener:o,options:n},s?s.push(r):this.__on=[r]}}function lB(e,t,n){var s=aB(e+""),r,o=s.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,h=c.length,f;d<h;++d)for(r=0,f=c[d];r<o;++r)if((i=s[r]).type===f.type&&i.name===f.name)return f.value}return}for(c=t?iB:oB,r=0;r<o;++r)this.each(c(s[r],t,n));return this}function nL(e,t,n){var s=ZI(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function cB(e,t){return function(){return nL(this,e,t)}}function uB(e,t){return function(){return nL(this,e,t.apply(this,arguments))}}function dB(e,t){return this.each((typeof t=="function"?uB:cB)(e,t))}function*hB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,o=s.length,i;r<o;++r)(i=s[r])&&(yield i)}var sL=[null];function Vn(e,t){this._groups=e,this._parents=t}function yu(){return new Vn([[document.documentElement]],sL)}function fB(){return this}Vn.prototype=yu.prototype={constructor:Vn,select:FF,selectAll:WF,selectChild:GF,selectChildren:ZF,filter:JF,data:r8,enter:QF,exit:o8,join:i8,merge:l8,selection:fB,order:c8,sort:u8,call:h8,nodes:f8,node:p8,size:m8,empty:g8,each:y8,attr:N8,style:C8,property:M8,classed:O8,text:B8,html:H8,raise:V8,lower:K8,append:Y8,insert:Z8,remove:Q8,clone:nB,datum:sB,on:lB,dispatch:dB,[Symbol.iterator]:hB};function us(e){return typeof e=="string"?new Vn([[document.querySelector(e)]],[document.documentElement]):new Vn([[e]],sL)}function pB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ms(e,t){if(e=pB(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const mB={passive:!1},zc={capture:!0,passive:!1};function pg(e){e.stopImmediatePropagation()}function Yi(e){e.preventDefault(),e.stopImmediatePropagation()}function rL(e){var t=e.document.documentElement,n=us(e).on("dragstart.drag",Yi,zc);"onselectstart"in t?n.on("selectstart.drag",Yi,zc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function aL(e,t){var n=e.document.documentElement,s=us(e).on("dragstart.drag",null);t&&(s.on("click.drag",Yi,zc),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Hd=e=>()=>e;function kk(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:o,x:i,y:c,dx:d,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}kk.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gB(e){return!e.ctrlKey&&!e.button}function yB(){return this.parentNode}function wB(e,t){return t??{x:e.x,y:e.y}}function xB(){return navigator.maxTouchPoints||"ontouchstart"in this}function vB(){var e=gB,t=yB,n=wB,s=xB,r={},o=Nf("start","drag","end"),i=0,c,d,h,f,p=0;function m(E){E.on("mousedown.drag",w).filter(s).on("touchstart.drag",k).on("touchmove.drag",v,mB).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(E,C){if(!(f||!e.call(this,E,C))){var I=S(this,t.call(this,E,C),E,C,"mouse");I&&(us(E.view).on("mousemove.drag",j,zc).on("mouseup.drag",b,zc),rL(E.view),pg(E),h=!1,c=E.clientX,d=E.clientY,I("start",E))}}function j(E){if(Yi(E),!h){var C=E.clientX-c,I=E.clientY-d;h=C*C+I*I>p}r.mouse("drag",E)}function b(E){us(E.view).on("mousemove.drag mouseup.drag",null),aL(E.view,h),Yi(E),r.mouse("end",E)}function k(E,C){if(e.call(this,E,C)){var I=E.changedTouches,R=t.call(this,E,C),$=I.length,L,U;for(L=0;L<$;++L)(U=S(this,R,E,C,I[L].identifier,I[L]))&&(pg(E),U("start",E,I[L]))}}function v(E){var C=E.changedTouches,I=C.length,R,$;for(R=0;R<I;++R)($=r[C[R].identifier])&&(Yi(E),$("drag",E,C[R]))}function N(E){var C=E.changedTouches,I=C.length,R,$;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),R=0;R<I;++R)($=r[C[R].identifier])&&(pg(E),$("end",E,C[R]))}function S(E,C,I,R,$,L){var U=o.copy(),O=Ms(L||I,C),M,q,A;if((A=n.call(E,new kk("beforestart",{sourceEvent:I,target:m,identifier:$,active:i,x:O[0],y:O[1],dx:0,dy:0,dispatch:U}),R))!=null)return M=A.x-O[0]||0,q=A.y-O[1]||0,function D(P,K,G){var W=O,H;switch(P){case"start":r[$]=D,H=i++;break;case"end":delete r[$],--i;case"drag":O=Ms(G||K,C),H=i;break}U.call(P,E,new kk(P,{sourceEvent:K,subject:A,target:m,identifier:$,active:H,x:O[0]+M,y:O[1]+q,dx:O[0]-W[0],dy:O[1]-W[1],dispatch:U}),R)}}return m.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Hd(!!E),m):e},m.container=function(E){return arguments.length?(t=typeof E=="function"?E:Hd(E),m):t},m.subject=function(E){return arguments.length?(n=typeof E=="function"?E:Hd(E),m):n},m.touchable=function(E){return arguments.length?(s=typeof E=="function"?E:Hd(!!E),m):s},m.on=function(){var E=o.on.apply(o,arguments);return E===o?m:E},m.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,m):Math.sqrt(p)},m}function G0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function oL(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function wu(){}var Vc=.7,Oh=1/Vc,Xi="\\s*([+-]?\\d+)\\s*",Gc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bB=/^#([0-9a-f]{3,8})$/,kB=new RegExp(`^rgb\\(${Xi},${Xi},${Xi}\\)$`),jB=new RegExp(`^rgb\\(${dr},${dr},${dr}\\)$`),NB=new RegExp(`^rgba\\(${Xi},${Xi},${Xi},${Gc}\\)$`),SB=new RegExp(`^rgba\\(${dr},${dr},${dr},${Gc}\\)$`),_B=new RegExp(`^hsl\\(${Gc},${dr},${dr}\\)$`),EB=new RegExp(`^hsla\\(${Gc},${dr},${dr},${Gc}\\)$`),a_={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};G0(wu,Kc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:o_,formatHex:o_,formatHex8:CB,formatHsl:TB,formatRgb:i_,toString:i_});function o_(){return this.rgb().formatHex()}function CB(){return this.rgb().formatHex8()}function TB(){return iL(this).formatHsl()}function i_(){return this.rgb().formatRgb()}function Kc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=bB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?l_(t):n===3?new Rn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zd(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=kB.exec(e))?new Rn(t[1],t[2],t[3],1):(t=jB.exec(e))?new Rn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=NB.exec(e))?zd(t[1],t[2],t[3],t[4]):(t=SB.exec(e))?zd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_B.exec(e))?d_(t[1],t[2]/100,t[3]/100,1):(t=EB.exec(e))?d_(t[1],t[2]/100,t[3]/100,t[4]):a_.hasOwnProperty(e)?l_(a_[e]):e==="transparent"?new Rn(NaN,NaN,NaN,0):null}function l_(e){return new Rn(e>>16&255,e>>8&255,e&255,1)}function zd(e,t,n,s){return s<=0&&(e=t=n=NaN),new Rn(e,t,n,s)}function RB(e){return e instanceof wu||(e=Kc(e)),e?(e=e.rgb(),new Rn(e.r,e.g,e.b,e.opacity)):new Rn}function jk(e,t,n,s){return arguments.length===1?RB(e):new Rn(e,t,n,s??1)}function Rn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}G0(Rn,jk,oL(wu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new Rn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vc:Math.pow(Vc,e),new Rn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Rn(Ao(this.r),Ao(this.g),Ao(this.b),Ph(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:c_,formatHex:c_,formatHex8:AB,formatRgb:u_,toString:u_}));function c_(){return`#${Eo(this.r)}${Eo(this.g)}${Eo(this.b)}`}function AB(){return`#${Eo(this.r)}${Eo(this.g)}${Eo(this.b)}${Eo((isNaN(this.opacity)?1:this.opacity)*255)}`}function u_(){const e=Ph(this.opacity);return`${e===1?"rgb(":"rgba("}${Ao(this.r)}, ${Ao(this.g)}, ${Ao(this.b)}${e===1?")":`, ${e})`}`}function Ph(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ao(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Eo(e){return e=Ao(e),(e<16?"0":"")+e.toString(16)}function d_(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $s(e,t,n,s)}function iL(e){if(e instanceof $s)return new $s(e.h,e.s,e.l,e.opacity);if(e instanceof wu||(e=Kc(e)),!e)return new $s;if(e instanceof $s)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,r=Math.min(t,n,s),o=Math.max(t,n,s),i=NaN,c=o-r,d=(o+r)/2;return c?(t===o?i=(n-s)/c+(n<s)*6:n===o?i=(s-t)/c+2:i=(t-n)/c+4,c/=d<.5?o+r:2-o-r,i*=60):c=d>0&&d<1?0:i,new $s(i,c,d,e.opacity)}function MB(e,t,n,s){return arguments.length===1?iL(e):new $s(e,t,n,s??1)}function $s(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}G0($s,MB,oL(wu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new $s(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vc:Math.pow(Vc,e),new $s(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,r=2*n-s;return new Rn(mg(e>=240?e-240:e+120,r,s),mg(e,r,s),mg(e<120?e+240:e-120,r,s),this.opacity)},clamp(){return new $s(h_(this.h),Vd(this.s),Vd(this.l),Ph(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=Ph(this.opacity);return`${e===1?"hsl(":"hsla("}${h_(this.h)}, ${Vd(this.s)*100}%, ${Vd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function h_(e){return e=(e||0)%360,e<0?e+360:e}function Vd(e){return Math.max(0,Math.min(1,e||0))}function mg(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 lL=e=>()=>e;function $B(e,t){return function(n){return e+n*t}}function IB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function LB(e){return(e=+e)==1?cL:function(t,n){return n-t?IB(t,n,e):lL(isNaN(t)?n:t)}}function cL(e,t){var n=t-e;return n?$B(e,n):lL(isNaN(e)?t:e)}const f_=(function e(t){var n=LB(t);function s(r,o){var i=n((r=jk(r)).r,(o=jk(o)).r),c=n(r.g,o.g),d=n(r.b,o.b),h=cL(r.opacity,o.opacity);return function(f){return r.r=i(f),r.g=c(f),r.b=d(f),r.opacity=h(f),r+""}}return s.gamma=e,s})(1);function _a(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Nk=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gg=new RegExp(Nk.source,"g");function OB(e){return function(){return e}}function PB(e){return function(t){return e(t)+""}}function DB(e,t){var n=Nk.lastIndex=gg.lastIndex=0,s,r,o,i=-1,c=[],d=[];for(e=e+"",t=t+"";(s=Nk.exec(e))&&(r=gg.exec(t));)(o=r.index)>n&&(o=t.slice(n,o),c[i]?c[i]+=o:c[++i]=o),(s=s[0])===(r=r[0])?c[i]?c[i]+=r:c[++i]=r:(c[++i]=null,d.push({i,x:_a(s,r)})),n=gg.lastIndex;return n<t.length&&(o=t.slice(n),c[i]?c[i]+=o:c[++i]=o),c.length<2?d[0]?PB(d[0].x):OB(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)c[(p=d[f]).i]=p.x(h);return c.join("")})}var p_=180/Math.PI,Sk={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function uL(e,t,n,s,r,o){var i,c,d;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(d=e*n+t*s)&&(n-=e*d,s-=t*d),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,d/=c),e*s<t*n&&(e=-e,t=-t,d=-d,i=-i),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*p_,skewX:Math.atan(d)*p_,scaleX:i,scaleY:c}}var Gd;function FB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Sk:uL(t.a,t.b,t.c,t.d,t.e,t.f)}function BB(e){return e==null||(Gd||(Gd=document.createElementNS("http://www.w3.org/2000/svg","g")),Gd.setAttribute("transform",e),!(e=Gd.transform.baseVal.consolidate()))?Sk:(e=e.matrix,uL(e.a,e.b,e.c,e.d,e.e,e.f))}function dL(e,t,n,s){function r(h){return h.length?h.pop()+" ":""}function o(h,f,p,m,w,j){if(h!==p||f!==m){var b=w.push("translate(",null,t,null,n);j.push({i:b-4,x:_a(h,p)},{i:b-2,x:_a(f,m)})}else(p||m)&&w.push("translate("+p+t+m+n)}function i(h,f,p,m){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),m.push({i:p.push(r(p)+"rotate(",null,s)-2,x:_a(h,f)})):f&&p.push(r(p)+"rotate("+f+s)}function c(h,f,p,m){h!==f?m.push({i:p.push(r(p)+"skewX(",null,s)-2,x:_a(h,f)}):f&&p.push(r(p)+"skewX("+f+s)}function d(h,f,p,m,w,j){if(h!==p||f!==m){var b=w.push(r(w)+"scale(",null,",",null,")");j.push({i:b-4,x:_a(h,p)},{i:b-2,x:_a(f,m)})}else(p!==1||m!==1)&&w.push(r(w)+"scale("+p+","+m+")")}return function(h,f){var p=[],m=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,m),i(h.rotate,f.rotate,p,m),c(h.skewX,f.skewX,p,m),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,m),h=f=null,function(w){for(var j=-1,b=m.length,k;++j<b;)p[(k=m[j]).i]=k.x(w);return p.join("")}}}var qB=dL(FB,"px, ","px)","deg)"),UB=dL(BB,", ",")",")"),WB=1e-12;function m_(e){return((e=Math.exp(e))+1/e)/2}function HB(e){return((e=Math.exp(e))-1/e)/2}function zB(e){return((e=Math.exp(2*e))-1)/(e+1)}const VB=(function e(t,n,s){function r(o,i){var c=o[0],d=o[1],h=o[2],f=i[0],p=i[1],m=i[2],w=f-c,j=p-d,b=w*w+j*j,k,v;if(b<WB)v=Math.log(m/h)/t,k=function(R){return[c+R*w,d+R*j,h*Math.exp(t*R*v)]};else{var N=Math.sqrt(b),S=(m*m-h*h+s*b)/(2*h*n*N),E=(m*m-h*h-s*b)/(2*m*n*N),C=Math.log(Math.sqrt(S*S+1)-S),I=Math.log(Math.sqrt(E*E+1)-E);v=(I-C)/t,k=function(R){var $=R*v,L=m_(C),U=h/(n*N)*(L*zB(t*$+C)-HB(C));return[c+U*w,d+U*j,h*L/m_(t*$+C)]}}return k.duration=v*1e3*t/Math.SQRT2,k}return r.rho=function(o){var i=Math.max(.001,+o),c=i*i,d=c*c;return e(i,c,d)},r})(Math.SQRT2,2,4);var rl=0,Sc=0,fc=0,hL=1e3,Dh,_c,Fh=0,Do=0,_f=0,Yc=typeof performance=="object"&&performance.now?performance:Date,fL=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function K0(){return Do||(fL(GB),Do=Yc.now()+_f)}function GB(){Do=0}function Bh(){this._call=this._time=this._next=null}Bh.prototype=pL.prototype={constructor:Bh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?K0():+n)+(t==null?0:+t),!this._next&&_c!==this&&(_c?_c._next=this:Dh=this,_c=this),this._call=e,this._time=n,_k()},stop:function(){this._call&&(this._call=null,this._time=1/0,_k())}};function pL(e,t,n){var s=new Bh;return s.restart(e,t,n),s}function KB(){K0(),++rl;for(var e=Dh,t;e;)(t=Do-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rl}function g_(){Do=(Fh=Yc.now())+_f,rl=Sc=0;try{KB()}finally{rl=0,XB(),Do=0}}function YB(){var e=Yc.now(),t=e-Fh;t>hL&&(_f-=t,Fh=e)}function XB(){for(var e,t=Dh,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Dh=n);_c=e,_k(s)}function _k(e){if(!rl){Sc&&(Sc=clearTimeout(Sc));var t=e-Do;t>24?(e<1/0&&(Sc=setTimeout(g_,e-Yc.now()-_f)),fc&&(fc=clearInterval(fc))):(fc||(Fh=Yc.now(),fc=setInterval(YB,hL)),rl=1,fL(g_))}}function y_(e,t,n){var s=new Bh;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var ZB=Nf("start","end","cancel","interrupt"),JB=[],mL=0,w_=1,Ek=2,bh=3,x_=4,Ck=5,kh=6;function Ef(e,t,n,s,r,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;QB(e,n,{name:t,index:s,group:r,on:ZB,tween:JB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:mL})}function Y0(e,t){var n=qs(e,t);if(n.state>mL)throw new Error("too late; already scheduled");return n}function mr(e,t){var n=qs(e,t);if(n.state>bh)throw new Error("too late; already running");return n}function qs(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function QB(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=pL(o,0,n.time);function o(h){n.state=w_,n.timer.restart(i,n.delay,n.time),n.delay<=h&&i(h-n.delay)}function i(h){var f,p,m,w;if(n.state!==w_)return d();for(f in s)if(w=s[f],w.name===n.name){if(w.state===bh)return y_(i);w.state===x_?(w.state=kh,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=kh,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(y_(function(){n.state===bh&&(n.state=x_,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=Ek,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ek){for(n.state=bh,r=new Array(m=n.tween.length),f=0,p=-1;f<m;++f)(w=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=w);r.length=p+1}}function c(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=Ck,1),p=-1,m=r.length;++p<m;)r[p].call(e,f);n.state===Ck&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=kh,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function jh(e,t){var n=e.__transition,s,r,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){o=!1;continue}r=s.state>Ek&&s.state<Ck,s.state=kh,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function eq(e){return this.each(function(){jh(this,e)})}function tq(e,t){var n,s;return function(){var r=mr(this,e),o=r.tween;if(o!==n){s=n=o;for(var i=0,c=s.length;i<c;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}r.tween=s}}function nq(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var o=mr(this,e),i=o.tween;if(i!==s){r=(s=i).slice();for(var c={name:t,value:n},d=0,h=r.length;d<h;++d)if(r[d].name===t){r[d]=c;break}d===h&&r.push(c)}o.tween=r}}function sq(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=qs(this.node(),n).tween,r=0,o=s.length,i;r<o;++r)if((i=s[r]).name===e)return i.value;return null}return this.each((t==null?tq:nq)(n,e,t))}function X0(e,t,n){var s=e._id;return e.each(function(){var r=mr(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return qs(r,s).value[t]}}function gL(e,t){var n;return(typeof t=="number"?_a:t instanceof Kc?f_:(n=Kc(t))?(t=n,f_):DB)(e,t)}function rq(e){return function(){this.removeAttribute(e)}}function aq(e){return function(){this.removeAttributeNS(e.space,e.local)}}function oq(e,t,n){var s,r=n+"",o;return function(){var i=this.getAttribute(e);return i===r?null:i===s?o:o=t(s=i,n)}}function iq(e,t,n){var s,r=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===r?null:i===s?o:o=t(s=i,n)}}function lq(e,t,n){var s,r,o;return function(){var i,c=n(this),d;return c==null?void this.removeAttribute(e):(i=this.getAttribute(e),d=c+"",i===d?null:i===s&&d===r?o:(r=d,o=t(s=i,c)))}}function cq(e,t,n){var s,r,o;return function(){var i,c=n(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),d=c+"",i===d?null:i===s&&d===r?o:(r=d,o=t(s=i,c)))}}function uq(e,t){var n=Sf(e),s=n==="transform"?UB:gL;return this.attrTween(e,typeof t=="function"?(n.local?cq:lq)(n,s,X0(this,"attr."+e,t)):t==null?(n.local?aq:rq)(n):(n.local?iq:oq)(n,s,t))}function dq(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function hq(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fq(e,t){var n,s;function r(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&hq(e,o)),n}return r._value=t,r}function pq(e,t){var n,s;function r(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&dq(e,o)),n}return r._value=t,r}function mq(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=Sf(e);return this.tween(n,(s.local?fq:pq)(s,t))}function gq(e,t){return function(){Y0(this,e).delay=+t.apply(this,arguments)}}function yq(e,t){return t=+t,function(){Y0(this,e).delay=t}}function wq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?gq:yq)(t,e)):qs(this.node(),t).delay}function xq(e,t){return function(){mr(this,e).duration=+t.apply(this,arguments)}}function vq(e,t){return t=+t,function(){mr(this,e).duration=t}}function bq(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xq:vq)(t,e)):qs(this.node(),t).duration}function kq(e,t){if(typeof t!="function")throw new Error;return function(){mr(this,e).ease=t}}function jq(e){var t=this._id;return arguments.length?this.each(kq(t,e)):qs(this.node(),t).ease}function Nq(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;mr(this,e).ease=n}}function Sq(e){if(typeof e!="function")throw new Error;return this.each(Nq(this._id,e))}function _q(e){typeof e!="function"&&(e=KI(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var o=t[r],i=o.length,c=s[r]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Vr(s,this._parents,this._name,this._id)}function Eq(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,o=Math.min(s,r),i=new Array(s),c=0;c<o;++c)for(var d=t[c],h=n[c],f=d.length,p=i[c]=new Array(f),m,w=0;w<f;++w)(m=d[w]||h[w])&&(p[w]=m);for(;c<s;++c)i[c]=t[c];return new Vr(i,this._parents,this._name,this._id)}function Cq(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 Tq(e,t,n){var s,r,o=Cq(t)?Y0:mr;return function(){var i=o(this,e),c=i.on;c!==s&&(r=(s=c).copy()).on(t,n),i.on=r}}function Rq(e,t){var n=this._id;return arguments.length<2?qs(this.node(),n).on.on(e):this.each(Tq(n,e,t))}function Aq(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Mq(){return this.on("end.remove",Aq(this._id))}function $q(e){var t=this._name,n=this._id;typeof e!="function"&&(e=z0(e));for(var s=this._groups,r=s.length,o=new Array(r),i=0;i<r;++i)for(var c=s[i],d=c.length,h=o[i]=new Array(d),f,p,m=0;m<d;++m)(f=c[m])&&(p=e.call(f,f.__data__,m,c))&&("__data__"in f&&(p.__data__=f.__data__),h[m]=p,Ef(h[m],t,n,m,h,qs(f,n)));return new Vr(o,this._parents,t,n)}function Iq(e){var t=this._name,n=this._id;typeof e!="function"&&(e=GI(e));for(var s=this._groups,r=s.length,o=[],i=[],c=0;c<r;++c)for(var d=s[c],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var m=e.call(f,f.__data__,p,d),w,j=qs(f,n),b=0,k=m.length;b<k;++b)(w=m[b])&&Ef(w,t,n,b,m,j);o.push(m),i.push(f)}return new Vr(o,i,t,n)}var Lq=yu.prototype.constructor;function Oq(){return new Lq(this._groups,this._parents)}function Pq(e,t){var n,s,r;return function(){var o=sl(this,e),i=(this.style.removeProperty(e),sl(this,e));return o===i?null:o===n&&i===s?r:r=t(n=o,s=i)}}function yL(e){return function(){this.style.removeProperty(e)}}function Dq(e,t,n){var s,r=n+"",o;return function(){var i=sl(this,e);return i===r?null:i===s?o:o=t(s=i,n)}}function Fq(e,t,n){var s,r,o;return function(){var i=sl(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),sl(this,e))),i===d?null:i===s&&d===r?o:(r=d,o=t(s=i,c))}}function Bq(e,t){var n,s,r,o="style."+t,i="end."+o,c;return function(){var d=mr(this,e),h=d.on,f=d.value[o]==null?c||(c=yL(t)):void 0;(h!==n||r!==f)&&(s=(n=h).copy()).on(i,r=f),d.on=s}}function qq(e,t,n){var s=(e+="")=="transform"?qB:gL;return t==null?this.styleTween(e,Pq(e,s)).on("end.style."+e,yL(e)):typeof t=="function"?this.styleTween(e,Fq(e,s,X0(this,"style."+e,t))).each(Bq(this._id,e)):this.styleTween(e,Dq(e,s,t),n).on("end.style."+e,null)}function Uq(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Wq(e,t,n){var s,r;function o(){var i=t.apply(this,arguments);return i!==r&&(s=(r=i)&&Uq(e,i,n)),s}return o._value=t,o}function Hq(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Wq(e,t,n??""))}function zq(e){return function(){this.textContent=e}}function Vq(e){return function(){var t=e(this);this.textContent=t??""}}function Gq(e){return this.tween("text",typeof e=="function"?Vq(X0(this,"text",e)):zq(e==null?"":e+""))}function Kq(e){return function(t){this.textContent=e.call(this,t)}}function Yq(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Kq(r)),t}return s._value=e,s}function Xq(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,Yq(e))}function Zq(){for(var e=this._name,t=this._id,n=wL(),s=this._groups,r=s.length,o=0;o<r;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)if(d=i[h]){var f=qs(d,t);Ef(d,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Vr(s,this._parents,e,n)}function Jq(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(o,i){var c={value:i},d={value:function(){--r===0&&o()}};n.each(function(){var h=mr(this,s),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),h.on=t}),r===0&&o()})}var Qq=0;function Vr(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function wL(){return++Qq}var Or=yu.prototype;Vr.prototype={constructor:Vr,select:$q,selectAll:Iq,selectChild:Or.selectChild,selectChildren:Or.selectChildren,filter:_q,merge:Eq,selection:Oq,transition:Zq,call:Or.call,nodes:Or.nodes,node:Or.node,size:Or.size,empty:Or.empty,each:Or.each,on:Rq,attr:uq,attrTween:mq,style:qq,styleTween:Hq,text:Gq,textTween:Xq,remove:Mq,tween:sq,delay:wq,duration:bq,ease:jq,easeVarying:Sq,end:Jq,[Symbol.iterator]:Or[Symbol.iterator]};function eU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tU={time:null,delay:0,duration:250,ease:eU};function nU(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 sU(e){var t,n;e instanceof Vr?(t=e._id,e=e._name):(t=wL(),(n=tU).time=K0(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,o=0;o<r;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&Ef(d,e,t,h,i,n||nU(d,t));return new Vr(s,this._parents,e,t)}yu.prototype.interrupt=eq;yu.prototype.transition=sU;const Kd=e=>()=>e;function rU(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:r}})}function Hr(e,t,n){this.k=e,this.x=t,this.y=n}Hr.prototype={constructor:Hr,scale:function(e){return e===1?this:new Hr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Hr(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 zr=new Hr(1,0,0);Hr.prototype;function yg(e){e.stopImmediatePropagation()}function pc(e){e.preventDefault(),e.stopImmediatePropagation()}function aU(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function oU(){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 v_(){return this.__zoom||zr}function iU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lU(){return navigator.maxTouchPoints||"ontouchstart"in this}function cU(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function xL(){var e=aU,t=oU,n=cU,s=iU,r=lU,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,d=VB,h=Nf("start","zoom","end"),f,p,m,w=500,j=150,b=0,k=10;function v(A){A.property("__zoom",v_).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",U).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(A,D,P,K){var G=A.selection?A.selection():A;G.property("__zoom",v_),A!==G?C(A,D,P,K):G.interrupt().each(function(){I(this,arguments).event(K).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},v.scaleBy=function(A,D,P,K){v.scaleTo(A,function(){var G=this.__zoom.k,W=typeof D=="function"?D.apply(this,arguments):D;return G*W},P,K)},v.scaleTo=function(A,D,P,K){v.transform(A,function(){var G=t.apply(this,arguments),W=this.__zoom,H=P==null?E(G):typeof P=="function"?P.apply(this,arguments):P,F=W.invert(H),B=typeof D=="function"?D.apply(this,arguments):D;return n(S(N(W,B),H,F),G,i)},P,K)},v.translateBy=function(A,D,P,K){v.transform(A,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),i)},null,K)},v.translateTo=function(A,D,P,K,G){v.transform(A,function(){var W=t.apply(this,arguments),H=this.__zoom,F=K==null?E(W):typeof K=="function"?K.apply(this,arguments):K;return n(zr.translate(F[0],F[1]).scale(H.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof P=="function"?-P.apply(this,arguments):-P),W,i)},K,G)};function N(A,D){return D=Math.max(o[0],Math.min(o[1],D)),D===A.k?A:new Hr(D,A.x,A.y)}function S(A,D,P){var K=D[0]-P[0]*A.k,G=D[1]-P[1]*A.k;return K===A.x&&G===A.y?A:new Hr(A.k,K,G)}function E(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function C(A,D,P,K){A.on("start.zoom",function(){I(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,W=arguments,H=I(G,W).event(K),F=t.apply(G,W),B=P==null?E(F):typeof P=="function"?P.apply(G,W):P,Z=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),V=G.__zoom,X=typeof D=="function"?D.apply(G,W):D,Y=d(V.invert(B).concat(Z/V.k),X.invert(B).concat(Z/X.k));return function(J){if(J===1)J=X;else{var ee=Y(J),ne=Z/ee[2];J=new Hr(ne,B[0]-ee[0]*ne,B[1]-ee[1]*ne)}H.zoom(null,J)}})}function I(A,D,P){return!P&&A.__zooming||new R(A,D)}function R(A,D){this.that=A,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,D),this.taps=0}R.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,D){return this.mouse&&A!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var D=us(this.that).datum();h.call(A,this.that,new rU(A,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:h}),D)}};function $(A,...D){if(!e.apply(this,arguments))return;var P=I(this,D).event(A),K=this.__zoom,G=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,s.apply(this,arguments)))),W=Ms(A);if(P.wheel)(P.mouse[0][0]!==W[0]||P.mouse[0][1]!==W[1])&&(P.mouse[1]=K.invert(P.mouse[0]=W)),clearTimeout(P.wheel);else{if(K.k===G)return;P.mouse=[W,K.invert(W)],jh(this),P.start()}pc(A),P.wheel=setTimeout(H,j),P.zoom("mouse",n(S(N(K,G),P.mouse[0],P.mouse[1]),P.extent,i));function H(){P.wheel=null,P.end()}}function L(A,...D){if(m||!e.apply(this,arguments))return;var P=A.currentTarget,K=I(this,D,!0).event(A),G=us(A.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",Z,!0),W=Ms(A,P),H=A.clientX,F=A.clientY;rL(A.view),yg(A),K.mouse=[W,this.__zoom.invert(W)],jh(this),K.start();function B(V){if(pc(V),!K.moved){var X=V.clientX-H,Y=V.clientY-F;K.moved=X*X+Y*Y>b}K.event(V).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=Ms(V,P),K.mouse[1]),K.extent,i))}function Z(V){G.on("mousemove.zoom mouseup.zoom",null),aL(V.view,K.moved),pc(V),K.event(V).end()}}function U(A,...D){if(e.apply(this,arguments)){var P=this.__zoom,K=Ms(A.changedTouches?A.changedTouches[0]:A,this),G=P.invert(K),W=P.k*(A.shiftKey?.5:2),H=n(S(N(P,W),K,G),t.apply(this,D),i);pc(A),c>0?us(this).transition().duration(c).call(C,H,K,A):us(this).call(v.transform,H,K,A)}}function O(A,...D){if(e.apply(this,arguments)){var P=A.touches,K=P.length,G=I(this,D,A.changedTouches.length===K).event(A),W,H,F,B;for(yg(A),H=0;H<K;++H)F=P[H],B=Ms(F,this),B=[B,this.__zoom.invert(B),F.identifier],G.touch0?!G.touch1&&G.touch0[2]!==B[2]&&(G.touch1=B,G.taps=0):(G.touch0=B,W=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),W&&(G.taps<2&&(p=B[0],f=setTimeout(function(){f=null},w)),jh(this),G.start())}}function M(A,...D){if(this.__zooming){var P=I(this,D).event(A),K=A.changedTouches,G=K.length,W,H,F,B;for(pc(A),W=0;W<G;++W)H=K[W],F=Ms(H,this),P.touch0&&P.touch0[2]===H.identifier?P.touch0[0]=F:P.touch1&&P.touch1[2]===H.identifier&&(P.touch1[0]=F);if(H=P.that.__zoom,P.touch1){var Z=P.touch0[0],V=P.touch0[1],X=P.touch1[0],Y=P.touch1[1],J=(J=X[0]-Z[0])*J+(J=X[1]-Z[1])*J,ee=(ee=Y[0]-V[0])*ee+(ee=Y[1]-V[1])*ee;H=N(H,Math.sqrt(J/ee)),F=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],B=[(V[0]+Y[0])/2,(V[1]+Y[1])/2]}else if(P.touch0)F=P.touch0[0],B=P.touch0[1];else return;P.zoom("touch",n(S(H,F,B),P.extent,i))}}function q(A,...D){if(this.__zooming){var P=I(this,D).event(A),K=A.changedTouches,G=K.length,W,H;for(yg(A),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),W=0;W<G;++W)H=K[W],P.touch0&&P.touch0[2]===H.identifier?delete P.touch0:P.touch1&&P.touch1[2]===H.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(H=Ms(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<k)){var F=us(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return v.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:Kd(+A),v):s},v.filter=function(A){return arguments.length?(e=typeof A=="function"?A:Kd(!!A),v):e},v.touchable=function(A){return arguments.length?(r=typeof A=="function"?A:Kd(!!A),v):r},v.extent=function(A){return arguments.length?(t=typeof A=="function"?A:Kd([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),v):t},v.scaleExtent=function(A){return arguments.length?(o[0]=+A[0],o[1]=+A[1],v):[o[0],o[1]]},v.translateExtent=function(A){return arguments.length?(i[0][0]=+A[0][0],i[1][0]=+A[1][0],i[0][1]=+A[0][1],i[1][1]=+A[1][1],v):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},v.constrain=function(A){return arguments.length?(n=A,v):n},v.duration=function(A){return arguments.length?(c=+A,v):c},v.interpolate=function(A){return arguments.length?(d=A,v):d},v.on=function(){var A=h.on.apply(h,arguments);return A===h?v:A},v.clickDistance=function(A){return arguments.length?(b=(A=+A)*A,v):Math.sqrt(b)},v.tapDistance=function(A){return arguments.length?(k=+A,v):k},v}var wt=HI();const Cf=y.createContext(null),uU=Cf.Provider,Gr={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.`},vL=Gr.error001();function tt(e,t){const n=y.useContext(Cf);if(n===null)throw new Error(vL);return zI(n,e,t)}const $t=()=>{const e=y.useContext(Cf);if(e===null)throw new Error(vL);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},dU=e=>e.userSelectionActive?"none":"all";function Z0({position:e,children:t,className:n,style:s,...r}){const o=tt(dU),i=`${e}`.split("-");return fe.createElement("div",{className:rn(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...r},t)}function hU({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:fe.createElement(Z0,{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"},fe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const fU=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:r=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...f})=>{const p=y.useRef(null),[m,w]=y.useState({x:0,y:0,width:0,height:0}),j=rn(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const b=p.current.getBBox();w({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:fe.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:j,visibility:m.width?"visible":"hidden",...f},r&&fe.createElement("rect",{width:m.width+2*i[0],x:-i[0],y:-i[1],height:m.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),fe.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:p,style:s},n),d)};var pU=y.memo(fU);const J0=e=>({width:e.offsetWidth,height:e.offsetHeight}),al=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Q0=(e={x:0,y:0},t)=>({x:al(e.x,t[0][0],t[1][0]),y:al(e.y,t[0][1],t[1][1])}),b_=(e,t,n)=>e<t?al(Math.abs(e-t),1,50)/50:e>n?-al(Math.abs(e-n),1,50)/50:0,bL=(e,t)=>{const n=b_(e.x,35,t.width-35)*20,s=b_(e.y,35,t.height-35)*20;return[n,s]},kL=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},jL=(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)}),Xc=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),NL=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),k_=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),mU=(e,t)=>NL(jL(Xc(e),Xc(t))),Tk=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},gU=e=>ds(e.width)&&ds(e.height)&&ds(e.x)&&ds(e.y),ds=e=>!isNaN(e)&&isFinite(e),Rt=Symbol.for("internals"),SL=["Enter"," ","Escape"],yU=(e,t)=>{},wU=e=>"nativeEvent"in e;function Rk(e){var r,o;const t=wU(e)?e.nativeEvent:e,n=((o=(r=t.composedPath)==null?void 0:r.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 _L=e=>"clientX"in e,La=(e,t)=>{var o,i;const n=_L(e),s=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},qh=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},xu=({id:e,path:t,labelX:n,labelY:s,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w=20})=>fe.createElement(fe.Fragment,null,fe.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:m}),w&&fe.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),r&&ds(n)&&ds(s)?fe.createElement(pU,{x:n,y:s,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);xu.displayName="BaseEdge";function mc(e,t,n){return n===void 0?n:s=>{const r=t().edges.find(o=>o.id===e);r&&n(s,{...r})}}function EL({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,i=Math.abs(s-t)/2,c=s<t?s+i:s-i;return[o,c,r,i]}function CL({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:o,targetControlX:i,targetControlY:c}){const d=e*.125+r*.375+i*.375+n*.125,h=t*.125+o*.375+c*.375+s*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Fo;(function(e){e.Strict="strict",e.Loose="loose"})(Fo||(Fo={}));var Co;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Co||(Co={}));var Zc;(function(e){e.Partial="partial",e.Full="full"})(Zc||(Zc={}));var Ca;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ca||(Ca={}));var Uh;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Uh||(Uh={}));var Oe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Oe||(Oe={}));function j_({pos:e,x1:t,y1:n,x2:s,y2:r}){return e===Oe.Left||e===Oe.Right?[.5*(t+s),n]:[t,.5*(n+r)]}function TL({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:r,targetPosition:o=Oe.Top}){const[i,c]=j_({pos:n,x1:e,y1:t,x2:s,y2:r}),[d,h]=j_({pos:o,x1:s,y1:r,x2:e,y2:t}),[f,p,m,w]=CL({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:i,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${i},${c} ${d},${h} ${s},${r}`,f,p,m,w]}const e1=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:r=Oe.Bottom,targetPosition:o=Oe.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:b})=>{const[k,v,N]=TL({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:s,targetPosition:o});return fe.createElement(xu,{path:k,labelX:v,labelY:N,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:b})});e1.displayName="SimpleBezierEdge";const N_={[Oe.Left]:{x:-1,y:0},[Oe.Right]:{x:1,y:0},[Oe.Top]:{x:0,y:-1},[Oe.Bottom]:{x:0,y:1}},xU=({source:e,sourcePosition:t=Oe.Bottom,target:n})=>t===Oe.Left||t===Oe.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},S_=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function vU({source:e,sourcePosition:t=Oe.Bottom,target:n,targetPosition:s=Oe.Top,center:r,offset:o}){const i=N_[t],c=N_[s],d={x:e.x+i.x*o,y:e.y+i.y*o},h={x:n.x+c.x*o,y:n.y+c.y*o},f=xU({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],j,b;const k={x:0,y:0},v={x:0,y:0},[N,S,E,C]=EL({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*c[p]===-1){j=r.x??N,b=r.y??S;const R=[{x:j,y:d.y},{x:j,y:h.y}],$=[{x:d.x,y:b},{x:h.x,y:b}];i[p]===m?w=p==="x"?R:$:w=p==="x"?$:R}else{const R=[{x:d.x,y:h.y}],$=[{x:h.x,y:d.y}];if(p==="x"?w=i.x===m?$:R:w=i.y===m?R:$,t===s){const q=Math.abs(e[p]-n[p]);if(q<=o){const A=Math.min(o-1,o-q);i[p]===m?k[p]=(d[p]>e[p]?-1:1)*A:v[p]=(h[p]>n[p]?-1:1)*A}}if(t!==s){const q=p==="x"?"y":"x",A=i[p]===c[q],D=d[q]>h[q],P=d[q]<h[q];(i[p]===1&&(!A&&D||A&&P)||i[p]!==1&&(!A&&P||A&&D))&&(w=p==="x"?R:$)}const L={x:d.x+k.x,y:d.y+k.y},U={x:h.x+v.x,y:h.y+v.y},O=Math.max(Math.abs(L.x-w[0].x),Math.abs(U.x-w[0].x)),M=Math.max(Math.abs(L.y-w[0].y),Math.abs(U.y-w[0].y));O>=M?(j=(L.x+U.x)/2,b=w[0].y):(j=w[0].x,b=(L.y+U.y)/2)}return[[e,{x:d.x+k.x,y:d.y+k.y},...w,{x:h.x+v.x,y:h.y+v.y},n],j,b,E,C]}function bU(e,t,n,s){const r=Math.min(S_(e,t)/2,S_(t,n)/2,s),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+r*h},${i}Q ${o},${i} ${o},${i+r*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${i+r*d}Q ${o},${i} ${o+r*c},${i}`}function Ak({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:r,targetPosition:o=Oe.Top,borderRadius:i=5,centerX:c,centerY:d,offset:h=20}){const[f,p,m,w,j]=vU({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((k,v,N)=>{let S="";return N>0&&N<f.length-1?S=bU(f[N-1],v,f[N+1],i):S=`${N===0?"M":"L"}${v.x} ${v.y}`,k+=S,k},""),p,m,w,j]}const Tf=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Oe.Bottom,targetPosition:m=Oe.Top,markerEnd:w,markerStart:j,pathOptions:b,interactionWidth:k})=>{const[v,N,S]=Ak({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return fe.createElement(xu,{path:v,labelX:N,labelY:S,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:j,interactionWidth:k})});Tf.displayName="SmoothStepEdge";const t1=y.memo(e=>{var t;return fe.createElement(Tf,{...e,pathOptions:y.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});t1.displayName="StepEdge";function kU({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,o,i,c]=EL({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,o,i,c]}const n1=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[j,b,k]=kU({sourceX:e,sourceY:t,targetX:n,targetY:s});return fe.createElement(xu,{path:j,labelX:b,labelY:k,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});n1.displayName="StraightEdge";function Yd(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function __({pos:e,x1:t,y1:n,x2:s,y2:r,c:o}){switch(e){case Oe.Left:return[t-Yd(t-s,o),n];case Oe.Right:return[t+Yd(s-t,o),n];case Oe.Top:return[t,n-Yd(n-r,o)];case Oe.Bottom:return[t,n+Yd(r-n,o)]}}function s1({sourceX:e,sourceY:t,sourcePosition:n=Oe.Bottom,targetX:s,targetY:r,targetPosition:o=Oe.Top,curvature:i=.25}){const[c,d]=__({pos:n,x1:e,y1:t,x2:s,y2:r,c:i}),[h,f]=__({pos:o,x1:s,y1:r,x2:e,y2:t,c:i}),[p,m,w,j]=CL({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${s},${r}`,p,m,w,j]}const Wh=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:r=Oe.Bottom,targetPosition:o=Oe.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,pathOptions:b,interactionWidth:k})=>{const[v,N,S]=s1({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:s,targetPosition:o,curvature:b==null?void 0:b.curvature});return fe.createElement(xu,{path:v,labelX:N,labelY:S,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:k})});Wh.displayName="BezierEdge";const r1=y.createContext(null),jU=r1.Provider;r1.Consumer;const NU=()=>y.useContext(r1),SU=e=>"id"in e&&"source"in e&&"target"in e,_U=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,Mk=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,EU=(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)),CU=(e,t)=>{if(!e.source||!e.target)return t;let n;return SU(e)?n={...e}:n={...e,id:_U(e)},EU(n,t)?t:t.concat(n)},$k=({x:e,y:t},[n,s,r],o,[i,c])=>{const d={x:(e-n)/r,y:(t-s)/r};return o?{x:i*Math.round(d.x/i),y:c*Math.round(d.y/c)}:d},RL=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s}),Mo=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],s=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-s};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-s}:r}},Rf=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const{x:o,y:i}=Mo(r,t).positionAbsolute;return jL(s,Xc({x:o,y:i,width:r.width||0,height:r.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return NL(n)},AL=(e,t,[n,s,r]=[0,0,1],o=!1,i=!1,c=[0,0])=>{const d={x:(t.x-n)/r,y:(t.y-s)/r,width:t.width/r,height:t.height/r},h=[];return e.forEach(f=>{const{width:p,height:m,selectable:w=!0,hidden:j=!1}=f;if(i&&!w||j)return!1;const{positionAbsolute:b}=Mo(f,c),k={x:b.x,y:b.y,width:p||0,height:m||0},v=Tk(d,k),N=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&v>0,E=(p||0)*(m||0);(N||S||v>=E||f.dragging)&&h.push(f)}),h},ML=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},$L=(e,t,n,s,r,o=.1)=>{const i=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(i,c),h=al(d,s,r),f=e.x+e.width/2,p=e.y+e.height/2,m=t/2-f*h,w=n/2-p*h;return{x:m,y:w,zoom:h}},bo=(e,t=0)=>e.transition().duration(t);function E_(e,t,n,s){return(t[n]||[]).reduce((r,o)=>{var i,c;return`${e.id}-${o.id}-${n}`!==s&&r.push({id:o.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+o.y+o.height/2}),r},[])}function TU(e,t,n,s,r,o){const{x:i,y:c}=La(e),h=t.elementsFromPoint(i,c).find(j=>j.classList.contains("react-flow__handle"));if(h){const j=h.getAttribute("data-nodeid");if(j){const b=a1(void 0,h),k=h.getAttribute("data-handleid"),v=o({nodeId:j,id:k,type:b});if(v){const N=r.find(S=>S.nodeId===j&&S.type===b&&S.id===k);return{handle:{id:k,type:b,nodeId:j,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:v}}}}let f=[],p=1/0;if(r.forEach(j=>{const b=Math.sqrt((j.x-n.x)**2+(j.y-n.y)**2);if(b<=s){const k=o(j);b<=p&&(b<p?f=[{handle:j,validHandleResult:k}]:b===p&&f.push({handle:j,validHandleResult:k}),p=b)}}),!f.length)return{handle:null,validHandleResult:IL()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:j})=>j.isValid),w=f.some(({handle:j})=>j.type==="target");return f.find(({handle:j,validHandleResult:b})=>w?j.type==="target":m?b.isValid:!0)||f[0]}const RU={source:null,target:null,sourceHandle:null,targetHandle:null},IL=()=>({handleDomNode:null,isValid:!1,connection:RU,endHandle:null});function LL(e,t,n,s,r,o,i){const c=r==="target",d=i.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={...IL(),handleDomNode:d};if(d){const f=a1(void 0,d),p=d.getAttribute("data-nodeid"),m=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),j=d.classList.contains("connectableend"),b={source:c?p:n,sourceHandle:c?m:s,target:c?n:p,targetHandle:c?s:m};h.connection=b,w&&j&&(t===Fo.Strict?c&&f==="source"||!c&&f==="target":p!==n||m!==s)&&(h.endHandle={nodeId:p,handleId:m,type:f},h.isValid=o(b))}return h}function AU({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((r,o)=>{if(o[Rt]){const{handleBounds:i}=o[Rt];let c=[],d=[];i&&(c=E_(o,i,"source",`${t}-${n}-${s}`),d=E_(o,i,"target",`${t}-${n}-${s}`)),r.push(...c,...d)}return r},[])}function a1(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function wg(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function MU(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function OL({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:r,getState:o,setState:i,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=kL(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:j,onConnectStart:b,panBy:k,getNodes:v,cancelConnection:N}=o();let S=0,E;const{x:C,y:I}=La(e),R=f==null?void 0:f.elementFromPoint(C,I),$=a1(d,R),L=m==null?void 0:m.getBoundingClientRect();if(!L||!$)return;let U,O=La(e,L),M=!1,q=null,A=!1,D=null;const P=AU({nodes:v(),nodeId:n,handleId:t,handleType:$}),K=()=>{if(!w)return;const[H,F]=bL(O,L);k({x:H,y:F}),S=requestAnimationFrame(K)};i({connectionPosition:O,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:$,connectionStartHandle:{nodeId:n,handleId:t,type:$},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:$});function G(H){const{transform:F}=o();O=La(H,L);const{handle:B,validHandleResult:Z}=TU(H,f,$k(O,F,!1,[1,1]),j,P,V=>LL(V,p,n,t,r?"target":"source",c,f));if(E=B,M||(K(),M=!0),D=Z.handleDomNode,q=Z.connection,A=Z.isValid,i({connectionPosition:E&&A?RL({x:E.x,y:E.y},F):O,connectionStatus:MU(!!E,A),connectionEndHandle:Z.endHandle}),!E&&!A&&!D)return wg(U);q.source!==q.target&&D&&(wg(U),U=D,D.classList.add("connecting","react-flow__handle-connecting"),D.classList.toggle("valid",A),D.classList.toggle("react-flow__handle-valid",A))}function W(H){var F,B;(E||D)&&q&&A&&(s==null||s(q)),(B=(F=o()).onConnectEnd)==null||B.call(F,H),d&&(h==null||h(H)),wg(U),N(),cancelAnimationFrame(S),M=!1,A=!1,q=null,D=null,f.removeEventListener("mousemove",G),f.removeEventListener("mouseup",W),f.removeEventListener("touchmove",G),f.removeEventListener("touchend",W)}f.addEventListener("mousemove",G),f.addEventListener("mouseup",W),f.addEventListener("touchmove",G),f.addEventListener("touchend",W)}const C_=()=>!0,$U=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),IU=(e,t,n)=>s=>{const{connectionStartHandle:r,connectionEndHandle:o,connectionClickStartHandle:i}=s;return{connecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.handleId)===t&&(r==null?void 0:r.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},PL=y.forwardRef(({type:e="source",position:t=Oe.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:i,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...m},w)=>{var L,U;const j=i||null,b=e==="target",k=$t(),v=NU(),{connectOnClick:N,noPanClassName:S}=tt($U,Kt),{connecting:E,clickConnecting:C}=tt(IU(v,j,e),Kt);v||(U=(L=k.getState()).onError)==null||U.call(L,"010",Gr.error010());const I=O=>{const{defaultEdgeOptions:M,onConnect:q,hasDefaultEdges:A}=k.getState(),D={...M,...O};if(A){const{edges:P,setEdges:K}=k.getState();K(CU(D,P))}q==null||q(D),c==null||c(D)},R=O=>{if(!v)return;const M=_L(O);r&&(M&&O.button===0||!M)&&OL({event:O,handleId:j,nodeId:v,onConnect:I,isTarget:b,getState:k.getState,setState:k.setState,isValidConnection:n||k.getState().isValidConnection||C_}),M?f==null||f(O):p==null||p(O)},$=O=>{const{onClickConnectStart:M,onClickConnectEnd:q,connectionClickStartHandle:A,connectionMode:D,isValidConnection:P}=k.getState();if(!v||!A&&!r)return;if(!A){M==null||M(O,{nodeId:v,handleId:j,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:v,type:e,handleId:j}});return}const K=kL(O.target),G=n||P||C_,{connection:W,isValid:H}=LL({nodeId:v,id:j,type:e},D,A.nodeId,A.handleId||null,A.type,G,K);H&&I(W),q==null||q(O),k.setState({connectionClickStartHandle:null})};return fe.createElement("div",{"data-handleid":j,"data-nodeid":v,"data-handlepos":t,"data-id":`${v}-${j}-${e}`,className:rn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!b,target:b,connectable:s,connectablestart:r,connectableend:o,connecting:C,connectionindicator:s&&(r&&!E||o&&E)}]),onMouseDown:R,onTouchStart:R,onClick:N?$:void 0,ref:w,...m},d)});PL.displayName="Handle";var Bo=y.memo(PL);const DL=({data:e,isConnectable:t,targetPosition:n=Oe.Top,sourcePosition:s=Oe.Bottom})=>fe.createElement(fe.Fragment,null,fe.createElement(Bo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,fe.createElement(Bo,{type:"source",position:s,isConnectable:t}));DL.displayName="DefaultNode";var Ik=y.memo(DL);const FL=({data:e,isConnectable:t,sourcePosition:n=Oe.Bottom})=>fe.createElement(fe.Fragment,null,e==null?void 0:e.label,fe.createElement(Bo,{type:"source",position:n,isConnectable:t}));FL.displayName="InputNode";var BL=y.memo(FL);const qL=({data:e,isConnectable:t,targetPosition:n=Oe.Top})=>fe.createElement(fe.Fragment,null,fe.createElement(Bo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);qL.displayName="OutputNode";var UL=y.memo(qL);const o1=()=>null;o1.displayName="GroupNode";const LU=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Xd=e=>e.id;function OU(e,t){return Kt(e.selectedNodes.map(Xd),t.selectedNodes.map(Xd))&&Kt(e.selectedEdges.map(Xd),t.selectedEdges.map(Xd))}const WL=y.memo(({onSelectionChange:e})=>{const t=$t(),{selectedNodes:n,selectedEdges:s}=tt(LU,OU);return y.useEffect(()=>{const r={nodes:n,edges:s};e==null||e(r),t.getState().onSelectionChange.forEach(o=>o(r))},[n,s,e]),null});WL.displayName="SelectionListener";const PU=e=>!!e.onSelectionChange;function DU({onSelectionChange:e}){const t=tt(PU);return e||t?fe.createElement(WL,{onSelectionChange:e}):null}const FU=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 Ei(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Ke(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const BU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:r,onConnectStart:o,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:m,edgesUpdatable:w,elevateNodesOnSelect:j,minZoom:b,maxZoom:k,nodeExtent:v,onNodesChange:N,onEdgesChange:S,elementsSelectable:E,connectionMode:C,snapGrid:I,snapToGrid:R,translateExtent:$,connectOnClick:L,defaultEdgeOptions:U,fitView:O,fitViewOptions:M,onNodesDelete:q,onEdgesDelete:A,onNodeDrag:D,onNodeDragStart:P,onNodeDragStop:K,onSelectionDrag:G,onSelectionDragStart:W,onSelectionDragStop:H,noPanClassName:F,nodeOrigin:B,rfId:Z,autoPanOnConnect:V,autoPanOnNodeDrag:X,onError:Y,connectionRadius:J,isValidConnection:ee,nodeDragThreshold:ne})=>{const{setNodes:le,setEdges:de,setDefaultNodesAndEdges:ue,setMinZoom:re,setMaxZoom:pe,setTranslateExtent:ye,setNodeExtent:_e,reset:he}=tt(FU,Kt),ae=$t();return y.useEffect(()=>{const ge=s==null?void 0:s.map(Se=>({...Se,...U}));return ue(n,ge),()=>{he()}},[]),Ke("defaultEdgeOptions",U,ae.setState),Ke("connectionMode",C,ae.setState),Ke("onConnect",r,ae.setState),Ke("onConnectStart",o,ae.setState),Ke("onConnectEnd",i,ae.setState),Ke("onClickConnectStart",c,ae.setState),Ke("onClickConnectEnd",d,ae.setState),Ke("nodesDraggable",h,ae.setState),Ke("nodesConnectable",f,ae.setState),Ke("nodesFocusable",p,ae.setState),Ke("edgesFocusable",m,ae.setState),Ke("edgesUpdatable",w,ae.setState),Ke("elementsSelectable",E,ae.setState),Ke("elevateNodesOnSelect",j,ae.setState),Ke("snapToGrid",R,ae.setState),Ke("snapGrid",I,ae.setState),Ke("onNodesChange",N,ae.setState),Ke("onEdgesChange",S,ae.setState),Ke("connectOnClick",L,ae.setState),Ke("fitViewOnInit",O,ae.setState),Ke("fitViewOnInitOptions",M,ae.setState),Ke("onNodesDelete",q,ae.setState),Ke("onEdgesDelete",A,ae.setState),Ke("onNodeDrag",D,ae.setState),Ke("onNodeDragStart",P,ae.setState),Ke("onNodeDragStop",K,ae.setState),Ke("onSelectionDrag",G,ae.setState),Ke("onSelectionDragStart",W,ae.setState),Ke("onSelectionDragStop",H,ae.setState),Ke("noPanClassName",F,ae.setState),Ke("nodeOrigin",B,ae.setState),Ke("rfId",Z,ae.setState),Ke("autoPanOnConnect",V,ae.setState),Ke("autoPanOnNodeDrag",X,ae.setState),Ke("onError",Y,ae.setState),Ke("connectionRadius",J,ae.setState),Ke("isValidConnection",ee,ae.setState),Ke("nodeDragThreshold",ne,ae.setState),Ei(e,le),Ei(t,de),Ei(b,re),Ei(k,pe),Ei($,ye),Ei(v,_e),null},T_={display:"none"},qU={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},HL="react-flow__node-desc",zL="react-flow__edge-desc",UU="react-flow__aria-live",WU=e=>e.ariaLiveMessage;function HU({rfId:e}){const t=tt(WU);return fe.createElement("div",{id:`${UU}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:qU},t)}function zU({rfId:e,disableKeyboardA11y:t}){return fe.createElement(fe.Fragment,null,fe.createElement("div",{id:`${HL}-${e}`,style:T_},"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."," "),fe.createElement("div",{id:`${zL}-${e}`,style:T_},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&fe.createElement(HU,{rfId:e}))}var Jc=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=y.useState(!1),r=y.useRef(!1),o=y.useRef(new Set([])),[i,c]=y.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=h.reduce((p,m)=>p.concat(...m),[]);return[h,f]}return[[],[]]},[e]);return y.useEffect(()=>{const d=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||d;if(e!==null){const f=w=>{if(r.current=w.ctrlKey||w.metaKey||w.shiftKey,(!r.current||r.current&&!t.actInsideInputWithModifier)&&Rk(w))return!1;const b=A_(w.code,c);o.current.add(w[b]),R_(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!r.current||r.current&&!t.actInsideInputWithModifier)&&Rk(w))return!1;const b=A_(w.code,c);R_(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[b]),w.key==="Meta"&&o.current.clear(),r.current=!1},m=()=>{o.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",m),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",m)}}},[e,s]),n};function R_(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(r=>t.has(r)))}function A_(e,t){return t.includes(e)?"code":"key"}function VL(e,t,n,s){var c,d;const r=e.parentNode||e.parentId;if(!r)return n;const o=t.get(r),i=Mo(o,s);return VL(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=o[Rt])==null?void 0:c.z)??0)>(n.z??0)?((d=o[Rt])==null?void 0:d.z)??0:n.z??0},s)}function GL(e,t,n){e.forEach(s=>{var o;const r=s.parentNode||s.parentId;if(r&&!e.has(r))throw new Error(`Parent node ${r} not found`);if(r||n!=null&&n[s.id]){const{x:i,y:c,z:d}=VL(s,e,{...s.position,z:((o=s[Rt])==null?void 0:o.z)??0},t);s.positionAbsolute={x:i,y:c},s[Rt].z=d,n!=null&&n[s.id]&&(s[Rt].isParent=!0)}})}function xg(e,t,n,s){const r=new Map,o={},i=s?1e3:0;return e.forEach(c=>{var w;const d=(ds(c.zIndex)?c.zIndex:0)+(c.selected?i:0),h=t.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},p=c.parentNode||c.parentId;p&&(o[p]=!0);const m=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,Rt,{enumerable:!1,value:{handleBounds:m||(w=h==null?void 0:h[Rt])==null?void 0:w.handleBounds,z:d}}),r.set(c.id,f)}),GL(r,n,o),r}function KL(e,t={}){const{getNodes:n,width:s,height:r,minZoom:o,maxZoom:i,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),m=t.initial&&!h&&f;if(c&&d&&(m||!t.initial)){const j=n().filter(k=>{var N;const v=t.includeHiddenNodes?k.width&&k.height:!k.hidden;return(N=t.nodes)!=null&&N.length?v&&t.nodes.some(S=>S.id===k.id):v}),b=j.every(k=>k.width&&k.height);if(j.length>0&&b){const k=Rf(j,p),{x:v,y:N,zoom:S}=$L(k,s,r,t.minZoom??o,t.maxZoom??i,t.padding??.1),E=zr.translate(v,N).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform(bo(d,t.duration),E):c.transform(d,E),!0}}return!1}function VU(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[Rt]:s[Rt],selected:n.selected})}),new Map(t)}function GU(e,t){return t.map(n=>{const s=e.find(r=>r.id===n.id);return s&&(n.selected=s.selected),n})}function Zd({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:r,edges:o,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&s({nodeInternals:VU(e,r)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:GU(t,o)}),c==null||c(t))}const Ci=()=>{},KU={zoomIn:Ci,zoomOut:Ci,zoomTo:Ci,getZoom:()=>1,setViewport:Ci,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ci,fitBounds:Ci,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},YU=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),XU=()=>{const e=$t(),{d3Zoom:t,d3Selection:n}=tt(YU,Kt);return y.useMemo(()=>n&&t?{zoomIn:r=>t.scaleBy(bo(n,r==null?void 0:r.duration),1.2),zoomOut:r=>t.scaleBy(bo(n,r==null?void 0:r.duration),1/1.2),zoomTo:(r,o)=>t.scaleTo(bo(n,o==null?void 0:o.duration),r),getZoom:()=>e.getState().transform[2],setViewport:(r,o)=>{const[i,c,d]=e.getState().transform,h=zr.translate(r.x??i,r.y??c).scale(r.zoom??d);t.transform(bo(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[r,o,i]=e.getState().transform;return{x:r,y:o,zoom:i}},fitView:r=>KL(e.getState,r),setCenter:(r,o,i)=>{const{width:c,height:d,maxZoom:h}=e.getState(),f=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:h,p=c/2-r*f,m=d/2-o*f,w=zr.translate(p,m).scale(f);t.transform(bo(n,i==null?void 0:i.duration),w)},fitBounds:(r,o)=>{const{width:i,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:m}=$L(r,i,c,d,h,(o==null?void 0:o.padding)??.1),w=zr.translate(f,p).scale(m);t.transform(bo(n,o==null?void 0:o.duration),w)},project:r=>{const{transform:o,snapToGrid:i,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),$k(r,o,i,c)},screenToFlowPosition:r=>{const{transform:o,snapToGrid:i,snapGrid:c,domNode:d}=e.getState();if(!d)return r;const{x:h,y:f}=d.getBoundingClientRect(),p={x:r.x-h,y:r.y-f};return $k(p,o,i,c)},flowToScreenPosition:r=>{const{transform:o,domNode:i}=e.getState();if(!i)return r;const{x:c,y:d}=i.getBoundingClientRect(),h=RL(r,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:KU,[t,n])};function ml(){const e=XU(),t=$t(),n=y.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),s=y.useCallback(b=>t.getState().nodeInternals.get(b),[]),r=y.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(k=>({...k}))},[]),o=y.useCallback(b=>{const{edges:k=[]}=t.getState();return k.find(v=>v.id===b)},[]),i=y.useCallback(b=>{const{getNodes:k,setNodes:v,hasDefaultNodes:N,onNodesChange:S}=t.getState(),E=k(),C=typeof b=="function"?b(E):b;if(N)v(C);else if(S){const I=C.length===0?E.map(R=>({type:"remove",id:R.id})):C.map(R=>({item:R,type:"reset"}));S(I)}},[]),c=y.useCallback(b=>{const{edges:k=[],setEdges:v,hasDefaultEdges:N,onEdgesChange:S}=t.getState(),E=typeof b=="function"?b(k):b;if(N)v(E);else if(S){const C=E.length===0?k.map(I=>({type:"remove",id:I.id})):E.map(I=>({item:I,type:"reset"}));S(C)}},[]),d=y.useCallback(b=>{const k=Array.isArray(b)?b:[b],{getNodes:v,setNodes:N,hasDefaultNodes:S,onNodesChange:E}=t.getState();if(S){const I=[...v(),...k];N(I)}else if(E){const C=k.map(I=>({item:I,type:"add"}));E(C)}},[]),h=y.useCallback(b=>{const k=Array.isArray(b)?b:[b],{edges:v=[],setEdges:N,hasDefaultEdges:S,onEdgesChange:E}=t.getState();if(S)N([...v,...k]);else if(E){const C=k.map(I=>({item:I,type:"add"}));E(C)}},[]),f=y.useCallback(()=>{const{getNodes:b,edges:k=[],transform:v}=t.getState(),[N,S,E]=v;return{nodes:b().map(C=>({...C})),edges:k.map(C=>({...C})),viewport:{x:N,y:S,zoom:E}}},[]),p=y.useCallback(({nodes:b,edges:k})=>{const{nodeInternals:v,getNodes:N,edges:S,hasDefaultNodes:E,hasDefaultEdges:C,onNodesDelete:I,onEdgesDelete:R,onNodesChange:$,onEdgesChange:L}=t.getState(),U=(b||[]).map(D=>D.id),O=(k||[]).map(D=>D.id),M=N().reduce((D,P)=>{const K=P.parentNode||P.parentId,G=!U.includes(P.id)&&K&&D.find(H=>H.id===K);return(typeof P.deletable=="boolean"?P.deletable:!0)&&(U.includes(P.id)||G)&&D.push(P),D},[]),q=S.filter(D=>typeof D.deletable=="boolean"?D.deletable:!0),A=q.filter(D=>O.includes(D.id));if(M||A){const D=ML(M,q),P=[...A,...D],K=P.reduce((G,W)=>(G.includes(W.id)||G.push(W.id),G),[]);if((C||E)&&(C&&t.setState({edges:S.filter(G=>!K.includes(G.id))}),E&&(M.forEach(G=>{v.delete(G.id)}),t.setState({nodeInternals:new Map(v)}))),K.length>0&&(R==null||R(P),L&&L(K.map(G=>({id:G,type:"remove"})))),M.length>0&&(I==null||I(M),$)){const G=M.map(W=>({id:W.id,type:"remove"}));$(G)}}},[]),m=y.useCallback(b=>{const k=gU(b),v=k?null:t.getState().nodeInternals.get(b.id);return!k&&!v?[null,null,k]:[k?b:k_(v),v,k]},[]),w=y.useCallback((b,k=!0,v)=>{const[N,S,E]=m(b);return N?(v||t.getState().getNodes()).filter(C=>{if(!E&&(C.id===S.id||!C.positionAbsolute))return!1;const I=k_(C),R=Tk(I,N);return k&&R>0||R>=N.width*N.height}):[]},[]),j=y.useCallback((b,k,v=!0)=>{const[N]=m(b);if(!N)return!1;const S=Tk(N,k);return v&&S>0||S>=N.width*N.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:r,getEdge:o,setNodes:i,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:j}),[e,n,s,r,o,i,c,d,h,f,p,w,j])}const ZU={actInsideInputWithModifier:!1};var JU=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=$t(),{deleteElements:s}=ml(),r=Jc(e,ZU),o=Jc(t);y.useEffect(()=>{if(r){const{edges:i,getNodes:c}=n.getState(),d=c().filter(f=>f.selected),h=i.filter(f=>f.selected);s({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[r]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function QU(e){const t=$t();y.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const r=J0(e.current);(r.height===0||r.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",Gr.error004())),t.setState({width:r.width||500,height:r.height||500})};return s(),window.addEventListener("resize",s),e.current&&(n=new ResizeObserver(()=>s()),n.observe(e.current)),()=>{window.removeEventListener("resize",s),n&&e.current&&n.unobserve(e.current)}},[])}const i1={position:"absolute",width:"100%",height:"100%",top:0,left:0},eW=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Jd=e=>({x:e.x,y:e.y,zoom:e.k}),Ti=(e,t)=>e.target.closest(`.${t}`),M_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$_=e=>{const t=e.ctrlKey&&qh()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},tW=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),nW=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Co.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:j,maxZoom:b,zoomActivationKeyCode:k,preventScrolling:v=!0,children:N,noWheelClassName:S,noPanClassName:E})=>{const C=y.useRef(),I=$t(),R=y.useRef(!1),$=y.useRef(!1),L=y.useRef(null),U=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:M,d3ZoomHandler:q,userSelectionActive:A}=tt(tW,Kt),D=Jc(k),P=y.useRef(0),K=y.useRef(!1),G=y.useRef();return QU(L),y.useEffect(()=>{if(L.current){const W=L.current.getBoundingClientRect(),H=xL().scaleExtent([j,b]).translateExtent(w),F=us(L.current).call(H),B=zr.translate(m.x,m.y).scale(al(m.zoom,j,b)),Z=[[0,0],[W.width,W.height]],V=H.constrain()(B,Z,w);H.transform(F,V),H.wheelDelta($_),I.setState({d3Zoom:H,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:L.current.closest(".react-flow")})}},[]),y.useEffect(()=>{M&&O&&(i&&!D&&!A?M.on("wheel.zoom",W=>{if(Ti(W,S))return!1;W.preventDefault(),W.stopImmediatePropagation();const H=M.property("__zoom").k||1;if(W.ctrlKey&&o){const ee=Ms(W),ne=$_(W),le=H*Math.pow(2,ne);O.scaleTo(M,le,ee,W);return}const F=W.deltaMode===1?20:1;let B=d===Co.Vertical?0:W.deltaX*F,Z=d===Co.Horizontal?0:W.deltaY*F;!qh()&&W.shiftKey&&d!==Co.Vertical&&(B=W.deltaY*F,Z=0),O.translateBy(M,-(B/H)*c,-(Z/H)*c,{internal:!0});const V=Jd(M.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=I.getState();clearTimeout(G.current),K.current||(K.current=!0,t==null||t(W,V),X==null||X(V)),K.current&&(e==null||e(W,V),Y==null||Y(V),G.current=setTimeout(()=>{n==null||n(W,V),J==null||J(V),K.current=!1},150))},{passive:!1}):typeof q<"u"&&M.on("wheel.zoom",function(W,H){if(!v&&W.type==="wheel"&&!W.ctrlKey||Ti(W,S))return null;W.preventDefault(),q.call(this,W,H)},{passive:!1}))},[A,i,d,M,O,q,D,o,v,S,t,e,n]),y.useEffect(()=>{O&&O.on("start",W=>{var B,Z;if(!W.sourceEvent||W.sourceEvent.internal)return null;P.current=(B=W.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:H}=I.getState(),F=Jd(W.transform);R.current=!0,U.current=F,((Z=W.sourceEvent)==null?void 0:Z.type)==="mousedown"&&I.setState({paneDragging:!0}),H==null||H(F),t==null||t(W.sourceEvent,F)})},[O,t]),y.useEffect(()=>{O&&(A&&!R.current?O.on("zoom",null):A||O.on("zoom",W=>{var F;const{onViewportChange:H}=I.getState();if(I.setState({transform:[W.transform.x,W.transform.y,W.transform.k]}),$.current=!!(s&&M_(p,P.current??0)),(e||H)&&!((F=W.sourceEvent)!=null&&F.internal)){const B=Jd(W.transform);H==null||H(B),e==null||e(W.sourceEvent,B)}}))},[A,O,e,p,s]),y.useEffect(()=>{O&&O.on("end",W=>{if(!W.sourceEvent||W.sourceEvent.internal)return null;const{onViewportChangeEnd:H}=I.getState();if(R.current=!1,I.setState({paneDragging:!1}),s&&M_(p,P.current??0)&&!$.current&&s(W.sourceEvent),$.current=!1,(n||H)&&eW(U.current,W.transform)){const F=Jd(W.transform);U.current=F,clearTimeout(C.current),C.current=setTimeout(()=>{H==null||H(F),n==null||n(W.sourceEvent,F)},i?150:0)}})},[O,i,p,n,s]),y.useEffect(()=>{O&&O.filter(W=>{const H=D||r,F=o&&W.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&W.button===1&&W.type==="mousedown"&&(Ti(W,"react-flow__node")||Ti(W,"react-flow__edge")))return!0;if(!p&&!H&&!i&&!h&&!o||A||!h&&W.type==="dblclick"||Ti(W,S)&&W.type==="wheel"||Ti(W,E)&&(W.type!=="wheel"||i&&W.type==="wheel"&&!D)||!o&&W.ctrlKey&&W.type==="wheel"||!H&&!i&&!F&&W.type==="wheel"||!p&&(W.type==="mousedown"||W.type==="touchstart")||Array.isArray(p)&&!p.includes(W.button)&&W.type==="mousedown")return!1;const B=Array.isArray(p)&&p.includes(W.button)||!W.button||W.button<=1;return(!W.ctrlKey||W.type==="wheel")&&B})},[A,O,r,o,i,h,p,f,D]),fe.createElement("div",{className:"react-flow__renderer",ref:L,style:i1},N)},sW=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function rW(){const{userSelectionActive:e,userSelectionRect:t}=tt(sW,Kt);return e&&t?fe.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 I_(e,t){const n=t.parentNode||t.parentId,s=e.find(r=>r.id===n);if(s){const r=t.position.x+t.width-s.width,o=t.position.y+t.height-s.height;if(r>0||o>0||t.position.x<0||t.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,r>0&&(s.style.width+=r),o>0&&(s.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);s.position.x=s.position.x-i,s.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);s.position.y=s.position.y-i,s.style.height+=i,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function aW(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const n=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,r)=>{const o=e.filter(c=>c.id===r.id);if(o.length===0)return s.push(r),s;const i={...r};for(const c of o)if(c)switch(c.type){case"select":{i.selected=c.selected;break}case"position":{typeof c.position<"u"&&(i.position=c.position),typeof c.positionAbsolute<"u"&&(i.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(i.dragging=c.dragging),i.expandParent&&I_(s,i);break}case"dimensions":{typeof c.dimensions<"u"&&(i.width=c.dimensions.width,i.height=c.dimensions.height),typeof c.updateStyle<"u"&&(i.style={...i.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(i.resizing=c.resizing),i.expandParent&&I_(s,i);break}case"remove":return s}return s.push(i),s},n)}function oW(e,t){return aW(e,t)}const Ea=(e,t)=>({id:e,type:"select",selected:t});function Hi(e,t){return e.reduce((n,s)=>{const r=t.includes(s.id);return!s.selected&&r?(s.selected=!0,n.push(Ea(s.id,!0))):s.selected&&!r&&(s.selected=!1,n.push(Ea(s.id,!1))),n},[])}const vg=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},iW=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),YL=y.memo(({isSelecting:e,selectionMode:t=Zc.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:r,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const m=y.useRef(null),w=$t(),j=y.useRef(0),b=y.useRef(0),k=y.useRef(),{userSelectionActive:v,elementsSelectable:N,dragging:S}=tt(iW,Kt),E=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,b.current=0},C=q=>{o==null||o(q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},I=q=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){q.preventDefault();return}i==null||i(q)},R=c?q=>c(q):void 0,$=q=>{const{resetSelectedElements:A,domNode:D}=w.getState();if(k.current=D==null?void 0:D.getBoundingClientRect(),!N||!e||q.button!==0||q.target!==m.current||!k.current)return;const{x:P,y:K}=La(q,k.current);A(),w.setState({userSelectionRect:{width:0,height:0,startX:P,startY:K,x:P,y:K}}),s==null||s(q)},L=q=>{const{userSelectionRect:A,nodeInternals:D,edges:P,transform:K,onNodesChange:G,onEdgesChange:W,nodeOrigin:H,getNodes:F}=w.getState();if(!e||!k.current||!A)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=La(q,k.current),Z=A.startX??0,V=A.startY??0,X={...A,x:B.x<Z?B.x:Z,y:B.y<V?B.y:V,width:Math.abs(B.x-Z),height:Math.abs(B.y-V)},Y=F(),J=AL(D,X,K,t===Zc.Partial,!0,H),ee=ML(J,P).map(le=>le.id),ne=J.map(le=>le.id);if(j.current!==ne.length){j.current=ne.length;const le=Hi(Y,ne);le.length&&(G==null||G(le))}if(b.current!==ee.length){b.current=ee.length;const le=Hi(P,ee);le.length&&(W==null||W(le))}w.setState({userSelectionRect:X})},U=q=>{if(q.button!==0)return;const{userSelectionRect:A}=w.getState();!v&&A&&q.target===m.current&&(C==null||C(q)),w.setState({nodesSelectionActive:j.current>0}),E(),r==null||r(q)},O=q=>{v&&(w.setState({nodesSelectionActive:j.current>0}),r==null||r(q)),E()},M=N&&(e||v);return fe.createElement("div",{className:rn(["react-flow__pane",{dragging:S,selection:e}]),onClick:M?void 0:vg(C,m),onContextMenu:vg(I,m),onWheel:vg(R,m),onMouseEnter:M?void 0:d,onMouseDown:M?$:void 0,onMouseMove:M?L:h,onMouseUp:M?U:void 0,onMouseLeave:M?O:f,ref:m,style:i1},p,fe.createElement(rW,null))});YL.displayName="Pane";function XL(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:XL(s,t):!1}function L_(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n.current)return!1;s=s.parentElement}while(s);return!1}function lW(e,t,n,s){return Array.from(e.values()).filter(r=>(r.selected||r.id===s)&&(!r.parentNode||r.parentId||!XL(r,e))&&(r.draggable||t&&typeof r.draggable>"u")).map(r=>{var o,i;return{id:r.id,position:r.position||{x:0,y:0},positionAbsolute:r.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=r.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=r.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:r.extent,parentNode:r.parentNode||r.parentId,parentId:r.parentNode||r.parentId,width:r.width,height:r.height,expandParent:r.expandParent}})}function cW(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function ZL(e,t,n,s,r=[0,0],o){const i=cW(e,e.extent||s);let c=i;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const p=n.get(d),{x:m,y:w}=Mo(p,r).positionAbsolute;c=p&&ds(m)&&ds(w)&&ds(p.width)&&ds(p.height)?[[m+e.width*r[0],w+e.height*r[1]],[m+p.width-e.width+e.width*r[0],w+p.height-e.height+e.height*r[1]]]:c}else o==null||o("005",Gr.error005()),c=i;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:m,y:w}=Mo(p,r).positionAbsolute;c=[[e.extent[0][0]+m,e.extent[0][1]+w],[e.extent[1][0]+m,e.extent[1][1]+w]]}let h={x:0,y:0};if(d){const p=n.get(d);h=Mo(p,r).positionAbsolute}const f=c&&c!=="parent"?Q0(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function bg({nodeId:e,dragItems:t,nodeInternals:n}){const s=t.map(r=>({...n.get(r.id),position:r.position,positionAbsolute:r.positionAbsolute}));return[e?s.find(r=>r.id===e):s[0],s]}const O_=(e,t,n,s)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const o=Array.from(r),i=t.getBoundingClientRect(),c={x:i.width*s[0],y:i.height*s[1]};return o.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-i.left-c.x)/n,y:(h.top-i.top-c.y)/n,...J0(d)}})};function gc(e,t,n){return n===void 0?n:s=>{const r=t().nodeInternals.get(e);r&&n(s,{...r})}}function Lk({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",Gr.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&i)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):r([e])}function uW(){const e=$t();return y.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:r,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,d={x:(i-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:o?r[0]*Math.round(d.x/r[0]):d.x,ySnapped:o?r[1]*Math.round(d.y/r[1]):d.y,...d}},[])}function kg(e){return(t,n,s)=>e==null?void 0:e(t,s)}function JL({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:r,isSelectable:o,selectNodesOnDrag:i}){const c=$t(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),m=y.useRef(0),w=y.useRef(null),j=y.useRef({x:0,y:0}),b=y.useRef(null),k=y.useRef(!1),v=y.useRef(!1),N=y.useRef(!1),S=uW();return y.useEffect(()=>{if(e!=null&&e.current){const E=us(e.current),C=({x:$,y:L})=>{const{nodeInternals:U,onNodeDrag:O,onSelectionDrag:M,updateNodePositions:q,nodeExtent:A,snapGrid:D,snapToGrid:P,nodeOrigin:K,onError:G}=c.getState();p.current={x:$,y:L};let W=!1,H={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&A){const B=Rf(f.current,K);H=Xc(B)}if(f.current=f.current.map(B=>{const Z={x:$-B.distance.x,y:L-B.distance.y};P&&(Z.x=D[0]*Math.round(Z.x/D[0]),Z.y=D[1]*Math.round(Z.y/D[1]));const V=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];f.current.length>1&&A&&!B.extent&&(V[0][0]=B.positionAbsolute.x-H.x+A[0][0],V[1][0]=B.positionAbsolute.x+(B.width??0)-H.x2+A[1][0],V[0][1]=B.positionAbsolute.y-H.y+A[0][1],V[1][1]=B.positionAbsolute.y+(B.height??0)-H.y2+A[1][1]);const X=ZL(B,Z,U,V,K,G);return W=W||B.position.x!==X.position.x||B.position.y!==X.position.y,B.position=X.position,B.positionAbsolute=X.positionAbsolute,B}),!W)return;q(f.current,!0,!0),h(!0);const F=r?O:kg(M);if(F&&b.current){const[B,Z]=bg({nodeId:r,dragItems:f.current,nodeInternals:U});F(b.current,B,Z)}},I=()=>{if(!w.current)return;const[$,L]=bL(j.current,w.current);if($!==0||L!==0){const{transform:U,panBy:O}=c.getState();p.current.x=(p.current.x??0)-$/U[2],p.current.y=(p.current.y??0)-L/U[2],O({x:$,y:L})&&C(p.current)}m.current=requestAnimationFrame(I)},R=$=>{var K;const{nodeInternals:L,multiSelectionActive:U,nodesDraggable:O,unselectNodesAndEdges:M,onNodeDragStart:q,onSelectionDragStart:A}=c.getState();v.current=!0;const D=r?q:kg(A);(!i||!o)&&!U&&r&&((K=L.get(r))!=null&&K.selected||M()),r&&o&&i&&Lk({id:r,store:c,nodeRef:e});const P=S($);if(p.current=P,f.current=lW(L,O,P,r),D&&f.current){const[G,W]=bg({nodeId:r,dragItems:f.current,nodeInternals:L});D($.sourceEvent,G,W)}};if(t)E.on(".drag",null);else{const $=vB().on("start",L=>{const{domNode:U,nodeDragThreshold:O}=c.getState();O===0&&R(L),N.current=!1;const M=S(L);p.current=M,w.current=(U==null?void 0:U.getBoundingClientRect())||null,j.current=La(L.sourceEvent,w.current)}).on("drag",L=>{var q,A;const U=S(L),{autoPanOnNodeDrag:O,nodeDragThreshold:M}=c.getState();if(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!k.current&&v.current&&O&&(k.current=!0,I()),!v.current){const D=U.xSnapped-(((q=p==null?void 0:p.current)==null?void 0:q.x)??0),P=U.ySnapped-(((A=p==null?void 0:p.current)==null?void 0:A.y)??0);Math.sqrt(D*D+P*P)>M&&R(L)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&v.current&&(b.current=L.sourceEvent,j.current=La(L.sourceEvent,w.current),C(U))}}).on("end",L=>{if(!(!v.current||N.current)&&(h(!1),k.current=!1,v.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:U,nodeInternals:O,onNodeDragStop:M,onSelectionDragStop:q}=c.getState(),A=r?M:kg(q);if(U(f.current,!1,!1),A){const[D,P]=bg({nodeId:r,dragItems:f.current,nodeInternals:O});A(L.sourceEvent,D,P)}}}).filter(L=>{const U=L.target;return!L.button&&(!n||!L_(U,`.${n}`,e))&&(!s||L_(U,s,e))});return E.call($),()=>{E.on(".drag",null)}}}},[e,t,n,s,o,c,r,i,S]),d}function QL(){const e=$t();return y.useCallback(n=>{const{nodeInternals:s,nodeExtent:r,updateNodePositions:o,getNodes:i,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=i().filter(N=>N.selected&&(N.draggable||f&&typeof N.draggable>"u")),m=c?d[0]:5,w=c?d[1]:5,j=n.isShiftPressed?4:1,b=n.x*m*j,k=n.y*w*j,v=p.map(N=>{if(N.positionAbsolute){const S={x:N.positionAbsolute.x+b,y:N.positionAbsolute.y+k};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:E,position:C}=ZL(N,S,s,r,void 0,h);N.position=C,N.positionAbsolute=E}return N});o(v,!0,!1)},[])}const Zi={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var yc=e=>{const t=({id:n,type:s,data:r,xPos:o,yPos:i,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:m,onMouseLeave:w,onContextMenu:j,onDoubleClick:b,style:k,className:v,isDraggable:N,isSelectable:S,isConnectable:E,isFocusable:C,selectNodesOnDrag:I,sourcePosition:R,targetPosition:$,hidden:L,resizeObserver:U,dragHandle:O,zIndex:M,isParent:q,noDragClassName:A,noPanClassName:D,initialized:P,disableKeyboardA11y:K,ariaLabel:G,rfId:W,hasHandleBounds:H})=>{const F=$t(),B=y.useRef(null),Z=y.useRef(null),V=y.useRef(R),X=y.useRef($),Y=y.useRef(s),J=S||N||f||p||m||w,ee=QL(),ne=gc(n,F.getState,p),le=gc(n,F.getState,m),de=gc(n,F.getState,w),ue=gc(n,F.getState,j),re=gc(n,F.getState,b),pe=he=>{const{nodeDragThreshold:ae}=F.getState();if(S&&(!I||!N||ae>0)&&Lk({id:n,store:F,nodeRef:B}),f){const ge=F.getState().nodeInternals.get(n);ge&&f(he,{...ge})}},ye=he=>{if(!Rk(he)&&!K)if(SL.includes(he.key)&&S){const ae=he.key==="Escape";Lk({id:n,store:F,unselect:ae,nodeRef:B})}else N&&h&&Object.prototype.hasOwnProperty.call(Zi,he.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${he.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),ee({x:Zi[he.key].x,y:Zi[he.key].y,isShiftPressed:he.shiftKey}))};y.useEffect(()=>()=>{Z.current&&(U==null||U.unobserve(Z.current),Z.current=null)},[]),y.useEffect(()=>{if(B.current&&!L){const he=B.current;(!P||!H||Z.current!==he)&&(Z.current&&(U==null||U.unobserve(Z.current)),U==null||U.observe(he),Z.current=he)}},[L,P,H]),y.useEffect(()=>{const he=Y.current!==s,ae=V.current!==R,ge=X.current!==$;B.current&&(he||ae||ge)&&(he&&(Y.current=s),ae&&(V.current=R),ge&&(X.current=$),F.getState().updateNodeDimensions([{id:n,nodeElement:B.current,forceUpdate:!0}]))},[n,s,R,$]);const _e=JL({nodeRef:B,disabled:L||!N,noDragClassName:A,handleSelector:O,nodeId:n,isSelectable:S,selectNodesOnDrag:I});return L?null:fe.createElement("div",{className:rn(["react-flow__node",`react-flow__node-${s}`,{[D]:N},v,{selected:h,selectable:S,parent:q,dragging:_e}]),ref:B,style:{zIndex:M,transform:`translate(${c}px,${d}px)`,pointerEvents:J?"all":"none",visibility:P?"visible":"hidden",...k},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ne,onMouseMove:le,onMouseLeave:de,onContextMenu:ue,onClick:pe,onDoubleClick:re,onKeyDown:C?ye:void 0,tabIndex:C?0:void 0,role:C?"button":void 0,"aria-describedby":K?void 0:`${HL}-${W}`,"aria-label":G},fe.createElement(jU,{value:n},fe.createElement(e,{id:n,data:r,type:s,xPos:o,yPos:i,selected:h,isConnectable:E,sourcePosition:R,targetPosition:$,dragging:_e,dragHandle:O,zIndex:M})))};return t.displayName="NodeWrapper",y.memo(t)};const dW=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Rf(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function hW({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=$t(),{width:r,height:o,x:i,y:c,transformString:d,userSelectionActive:h}=tt(dW,Kt),f=QL(),p=y.useRef(null);if(y.useEffect(()=>{var j;n||(j=p.current)==null||j.focus({preventScroll:!0})},[n]),JL({nodeRef:p}),h||!r||!o)return null;const m=e?j=>{const b=s.getState().getNodes().filter(k=>k.selected);e(j,b)}:void 0,w=j=>{Object.prototype.hasOwnProperty.call(Zi,j.key)&&f({x:Zi[j.key].x,y:Zi[j.key].y,isShiftPressed:j.shiftKey})};return fe.createElement("div",{className:rn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},fe.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:r,height:o,top:c,left:i}}))}var fW=y.memo(hW);const pW=e=>e.nodesSelectionActive,eO=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:w,onSelectionStart:j,onSelectionEnd:b,multiSelectionKeyCode:k,panActivationKeyCode:v,zoomActivationKeyCode:N,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:C,panOnScroll:I,panOnScrollSpeed:R,panOnScrollMode:$,zoomOnDoubleClick:L,panOnDrag:U,defaultViewport:O,translateExtent:M,minZoom:q,maxZoom:A,preventScrolling:D,onSelectionContextMenu:P,noWheelClassName:K,noPanClassName:G,disableKeyboardA11y:W})=>{const H=tt(pW),F=Jc(p),B=Jc(v),Z=B||U,V=B||I,X=F||m&&Z!==!0;return JU({deleteKeyCode:c,multiSelectionKeyCode:k}),fe.createElement(nW,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:C,panOnScroll:V,panOnScrollSpeed:R,panOnScrollMode:$,zoomOnDoubleClick:L,panOnDrag:!F&&Z,defaultViewport:O,translateExtent:M,minZoom:q,maxZoom:A,zoomActivationKeyCode:N,preventScrolling:D,noWheelClassName:K,noPanClassName:G},fe.createElement(YL,{onSelectionStart:j,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!X,selectionMode:w},e,H&&fe.createElement(fW,{onSelectionContextMenu:P,noPanClassName:G,disableKeyboardA11y:W})))};eO.displayName="FlowRenderer";var mW=y.memo(eO);function gW(e){return tt(y.useCallback(n=>e?AL(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function yW(e){const t={input:yc(e.input||BL),default:yc(e.default||Ik),output:yc(e.output||UL),group:yc(e.group||o1)},n={},s=Object.keys(e).filter(r=>!["input","default","output","group"].includes(r)).reduce((r,o)=>(r[o]=yc(e[o]||Ik),r),n);return{...t,...s}}const wW=({x:e,y:t,width:n,height:s,origin:r})=>!n||!s?{x:e,y:t}:r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-s*r[1]},xW=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),tO=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:r,updateNodeDimensions:o,onError:i}=tt(xW,Kt),c=gW(e.onlyRenderVisibleElements),d=y.useRef(),h=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const m=p.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));o(m)});return d.current=f,f},[]);return y.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),fe.createElement("div",{className:"react-flow__nodes",style:i1},c.map(f=>{var C,I,R;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",Gr.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),j=!!(f.selectable||r&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),k=!!(f.focusable||s&&typeof f.focusable>"u"),v=e.nodeExtent?Q0(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(v==null?void 0:v.x)??0,S=(v==null?void 0:v.y)??0,E=wW({x:N,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return fe.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Oe.Bottom,targetPosition:f.targetPosition||Oe.Top,hidden:f.hidden,xPos:N,yPos:S,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:w,isSelectable:j,isConnectable:b,isFocusable:k,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((C=f[Rt])==null?void 0:C.z)??0,isParent:!!((I=f[Rt])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((R=f[Rt])!=null&&R.handleBounds)})}))};tO.displayName="NodeRenderer";var vW=y.memo(tO);const bW=(e,t,n)=>n===Oe.Left?e-t:n===Oe.Right?e+t:e,kW=(e,t,n)=>n===Oe.Top?e-t:n===Oe.Bottom?e+t:e,P_="react-flow__edgeupdater",D_=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:r,onMouseEnter:o,onMouseOut:i,type:c})=>fe.createElement("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:i,className:rn([P_,`${P_}-${c}`]),cx:bW(t,s,e),cy:kW(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),jW=()=>!0;var Ri=e=>{const t=({id:n,className:s,type:r,data:o,onClick:i,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:b,style:k,source:v,target:N,sourceX:S,sourceY:E,targetX:C,targetY:I,sourcePosition:R,targetPosition:$,elementsSelectable:L,hidden:U,sourceHandleId:O,targetHandleId:M,onContextMenu:q,onMouseEnter:A,onMouseMove:D,onMouseLeave:P,reconnectRadius:K,onReconnect:G,onReconnectStart:W,onReconnectEnd:H,markerEnd:F,markerStart:B,rfId:Z,ariaLabel:V,isFocusable:X,isReconnectable:Y,pathOptions:J,interactionWidth:ee,disableKeyboardA11y:ne})=>{const le=y.useRef(null),[de,ue]=y.useState(!1),[re,pe]=y.useState(!1),ye=$t(),_e=y.useMemo(()=>`url('#${Mk(B,Z)}')`,[B,Z]),he=y.useMemo(()=>`url('#${Mk(F,Z)}')`,[F,Z]);if(U)return null;const ae=Ze=>{var It;const{edges:ft,addSelectedEdges:ut,unselectNodesAndEdges:Je,multiSelectionActive:Dt}=ye.getState(),vt=ft.find(it=>it.id===n);vt&&(L&&(ye.setState({nodesSelectionActive:!1}),vt.selected&&Dt?(Je({nodes:[],edges:[vt]}),(It=le.current)==null||It.blur()):ut([n])),i&&i(Ze,vt))},ge=mc(n,ye.getState,c),Se=mc(n,ye.getState,q),me=mc(n,ye.getState,A),$e=mc(n,ye.getState,D),Pe=mc(n,ye.getState,P),qe=(Ze,ft)=>{if(Ze.button!==0)return;const{edges:ut,isValidConnection:Je}=ye.getState(),Dt=ft?N:v,vt=(ft?M:O)||null,It=ft?"target":"source",it=Je||jW,Lt=ft,Ft=ut.find(rt=>rt.id===n);pe(!0),W==null||W(Ze,Ft,It);const dt=rt=>{pe(!1),H==null||H(rt,Ft,It)};OL({event:Ze,handleId:vt,nodeId:Dt,onConnect:rt=>G==null?void 0:G(Ft,rt),isTarget:Lt,getState:ye.getState,setState:ye.setState,isValidConnection:it,edgeUpdaterType:It,onReconnectEnd:dt})},Le=Ze=>qe(Ze,!0),Qe=Ze=>qe(Ze,!1),je=()=>ue(!0),Ae=()=>ue(!1),De=!L&&!i,He=Ze=>{var ft;if(!ne&&SL.includes(Ze.key)&&L){const{unselectNodesAndEdges:ut,addSelectedEdges:Je,edges:Dt}=ye.getState();Ze.key==="Escape"?((ft=le.current)==null||ft.blur(),ut({edges:[Dt.find(It=>It.id===n)]})):Je([n])}};return fe.createElement("g",{className:rn(["react-flow__edge",`react-flow__edge-${r}`,s,{selected:d,animated:h,inactive:De,updating:de}]),onClick:ae,onDoubleClick:ge,onContextMenu:Se,onMouseEnter:me,onMouseMove:$e,onMouseLeave:Pe,onKeyDown:X?He:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${v} to ${N}`,"aria-describedby":X?`${zL}-${Z}`:void 0,ref:le},!re&&fe.createElement(e,{id:n,source:v,target:N,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:b,data:o,style:k,sourceX:S,sourceY:E,targetX:C,targetY:I,sourcePosition:R,targetPosition:$,sourceHandleId:O,targetHandleId:M,markerStart:_e,markerEnd:he,pathOptions:J,interactionWidth:ee}),Y&&fe.createElement(fe.Fragment,null,(Y==="source"||Y===!0)&&fe.createElement(D_,{position:R,centerX:S,centerY:E,radius:K,onMouseDown:Le,onMouseEnter:je,onMouseOut:Ae,type:"source"}),(Y==="target"||Y===!0)&&fe.createElement(D_,{position:$,centerX:C,centerY:I,radius:K,onMouseDown:Qe,onMouseEnter:je,onMouseOut:Ae,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function NW(e){const t={default:Ri(e.default||Wh),straight:Ri(e.bezier||n1),step:Ri(e.step||t1),smoothstep:Ri(e.step||Tf),simplebezier:Ri(e.simplebezier||e1)},n={},s=Object.keys(e).filter(r=>!["default","bezier"].includes(r)).reduce((r,o)=>(r[o]=Ri(e[o]||Wh),r),n);return{...t,...s}}function F_(e,t,n=null){const s=((n==null?void 0:n.x)||0)+t.x,r=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case Oe.Top:return{x:s+o/2,y:r};case Oe.Right:return{x:s+o,y:r+i/2};case Oe.Bottom:return{x:s+o/2,y:r+i};case Oe.Left:return{x:s,y:r+i/2}}}function B_(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const SW=(e,t,n,s,r,o)=>{const i=F_(n,e,t),c=F_(o,s,r);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function _W({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:r,targetHeight:o,width:i,height:c,transform:d}){const h={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+r),y2:Math.max(e.y+s,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=Xc({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:i/d[2],height:c/d[2]}),p=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),m=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*m)>0}function q_(e){var s,r,o,i,c;const t=((s=e==null?void 0:e[Rt])==null?void 0:s.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((r=e==null?void 0:e.positionAbsolute)==null?void 0:r.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const EW=[{level:0,isMaxLevel:!0,edges:[]}];function CW(e,t,n=!1){let s=-1;const r=e.reduce((i,c)=>{var f,p;const d=ds(c.zIndex);let h=d?c.zIndex:0;if(n){const m=t.get(c.target),w=t.get(c.source),j=c.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),b=Math.max(((f=w==null?void 0:w[Rt])==null?void 0:f.z)||0,((p=m==null?void 0:m[Rt])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(j?b:0)}return i[h]?i[h].push(c):i[h]=[c],s=h>s?h:s,i},{}),o=Object.entries(r).map(([i,c])=>{const d=+i;return{edges:c,level:d,isMaxLevel:d===s}});return o.length===0?EW:o}function TW(e,t,n){const s=tt(y.useCallback(r=>e?r.edges.filter(o=>{const i=t.get(o.source),c=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&_W({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:c.width,targetHeight:c.height,width:r.width,height:r.height,transform:r.transform})}):r.edges,[e,t]));return CW(s,t,n)}const RW=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),AW=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),U_={[Uh.Arrow]:RW,[Uh.ArrowClosed]:AW};function MW(e){const t=$t();return y.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(U_,e)?U_[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Gr.error009(e)),null)},[e])}const $W=({id:e,type:t,color:n,width:s=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const d=MW(t);return d?fe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},fe.createElement(d,{color:n,strokeWidth:i})):null},IW=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((r,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const c=Mk(i,t);s.includes(c)||(r.push({id:c,color:i.color||e,...i}),s.push(c))}}),r),[]).sort((r,o)=>r.id.localeCompare(o.id))},nO=({defaultColor:e,rfId:t})=>{const n=tt(y.useCallback(IW({defaultColor:e,rfId:t}),[e,t]),(s,r)=>!(s.length!==r.length||s.some((o,i)=>o.id!==r[i].id)));return fe.createElement("defs",null,n.map(s=>fe.createElement($W,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};nO.displayName="MarkerDefinitions";var LW=y.memo(nO);const OW=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}),sO=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:r,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:b,children:k,disableKeyboardA11y:v})=>{const{edgesFocusable:N,edgesUpdatable:S,elementsSelectable:E,width:C,height:I,connectionMode:R,nodeInternals:$,onError:L}=tt(OW,Kt),U=TW(t,$,n);return C?fe.createElement(fe.Fragment,null,U.map(({level:O,edges:M,isMaxLevel:q})=>fe.createElement("svg",{key:O,style:{zIndex:O},width:C,height:I,className:"react-flow__edges react-flow__container"},q&&fe.createElement(LW,{defaultColor:e,rfId:s}),fe.createElement("g",null,M.map(A=>{const[D,P,K]=q_($.get(A.source)),[G,W,H]=q_($.get(A.target));if(!K||!H)return null;let F=A.type||"default";r[F]||(L==null||L("011",Gr.error011(F)),F="default");const B=r[F]||r.default,Z=R===Fo.Strict?W.target:(W.target??[]).concat(W.source??[]),V=B_(P.source,A.sourceHandle),X=B_(Z,A.targetHandle),Y=(V==null?void 0:V.position)||Oe.Bottom,J=(X==null?void 0:X.position)||Oe.Top,ee=!!(A.focusable||N&&typeof A.focusable>"u"),ne=A.reconnectable||A.updatable,le=typeof m<"u"&&(ne||S&&typeof ne>"u");if(!V||!X)return L==null||L("008",Gr.error008(V,A)),null;const{sourceX:de,sourceY:ue,targetX:re,targetY:pe}=SW(D,V,Y,G,X,J);return fe.createElement(B,{key:A.id,id:A.id,className:rn([A.className,o]),type:F,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:de,sourceY:ue,targetX:re,targetY:pe,sourcePosition:Y,targetPosition:J,elementsSelectable:E,onContextMenu:i,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:b,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ee,isReconnectable:le,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:v})})))),k):null};sO.displayName="EdgeRenderer";var PW=y.memo(sO);const DW=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function FW({children:e}){const t=tt(DW);return fe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function BW(e){const t=ml(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const qW={[Oe.Left]:Oe.Right,[Oe.Right]:Oe.Left,[Oe.Top]:Oe.Bottom,[Oe.Bottom]:Oe.Top},rO=({nodeId:e,handleType:t,style:n,type:s=Ca.Bezier,CustomComponent:r,connectionStatus:o})=>{var I,R,$;const{fromNode:i,handleId:c,toX:d,toY:h,connectionMode:f}=tt(y.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),Kt),p=(I=i==null?void 0:i[Rt])==null?void 0:I.handleBounds;let m=p==null?void 0:p[t];if(f===Fo.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=c?m.find(L=>L.id===c):m[0],j=w?w.x+w.width/2:(i.width??0)/2,b=w?w.y+w.height/2:i.height??0,k=(((R=i.positionAbsolute)==null?void 0:R.x)??0)+j,v=((($=i.positionAbsolute)==null?void 0:$.y)??0)+b,N=w==null?void 0:w.position,S=N?qW[N]:null;if(!N||!S)return null;if(r)return fe.createElement(r,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:k,fromY:v,toX:d,toY:h,fromPosition:N,toPosition:S,connectionStatus:o});let E="";const C={sourceX:k,sourceY:v,sourcePosition:N,targetX:d,targetY:h,targetPosition:S};return s===Ca.Bezier?[E]=s1(C):s===Ca.Step?[E]=Ak({...C,borderRadius:0}):s===Ca.SmoothStep?[E]=Ak(C):s===Ca.SimpleBezier?[E]=TL(C):E=`M${k},${v} ${d},${h}`,fe.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};rO.displayName="ConnectionLine";const UW=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function WW({containerStyle:e,style:t,type:n,component:s}){const{nodeId:r,handleType:o,nodesConnectable:i,width:c,height:d,connectionStatus:h}=tt(UW,Kt);return!(r&&o&&c&&i)?null:fe.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},fe.createElement("g",{className:rn(["react-flow__connection",h])},fe.createElement(rO,{nodeId:r,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function W_(e,t){return y.useRef(null),$t(),y.useMemo(()=>t(e),[e])}const aO=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:r,onInit:o,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,onSelectionContextMenu:j,onSelectionStart:b,onSelectionEnd:k,connectionLineType:v,connectionLineStyle:N,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:C,selectionOnDrag:I,selectionMode:R,multiSelectionKeyCode:$,panActivationKeyCode:L,zoomActivationKeyCode:U,deleteKeyCode:O,onlyRenderVisibleElements:M,elementsSelectable:q,selectNodesOnDrag:A,defaultViewport:D,translateExtent:P,minZoom:K,maxZoom:G,preventScrolling:W,defaultMarkerColor:H,zoomOnScroll:F,zoomOnPinch:B,panOnScroll:Z,panOnScrollSpeed:V,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:J,onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneScroll:ue,onPaneContextMenu:re,onEdgeContextMenu:pe,onEdgeMouseEnter:ye,onEdgeMouseMove:_e,onEdgeMouseLeave:he,onReconnect:ae,onReconnectStart:ge,onReconnectEnd:Se,reconnectRadius:me,noDragClassName:$e,noWheelClassName:Pe,noPanClassName:qe,elevateEdgesOnSelect:Le,disableKeyboardA11y:Qe,nodeOrigin:je,nodeExtent:Ae,rfId:De})=>{const He=W_(e,yW),Ze=W_(t,NW);return BW(o),fe.createElement(mW,{onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneContextMenu:re,onPaneScroll:ue,deleteKeyCode:O,selectionKeyCode:C,selectionOnDrag:I,selectionMode:R,onSelectionStart:b,onSelectionEnd:k,multiSelectionKeyCode:$,panActivationKeyCode:L,zoomActivationKeyCode:U,elementsSelectable:q,onMove:n,onMoveStart:s,onMoveEnd:r,zoomOnScroll:F,zoomOnPinch:B,zoomOnDoubleClick:Y,panOnScroll:Z,panOnScrollSpeed:V,panOnScrollMode:X,panOnDrag:J,defaultViewport:D,translateExtent:P,minZoom:K,maxZoom:G,onSelectionContextMenu:j,preventScrolling:W,noDragClassName:$e,noWheelClassName:Pe,noPanClassName:qe,disableKeyboardA11y:Qe},fe.createElement(FW,null,fe.createElement(PW,{edgeTypes:Ze,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:M,onEdgeContextMenu:pe,onEdgeMouseEnter:ye,onEdgeMouseMove:_e,onEdgeMouseLeave:he,onReconnect:ae,onReconnectStart:ge,onReconnectEnd:Se,reconnectRadius:me,defaultMarkerColor:H,noPanClassName:qe,elevateEdgesOnSelect:!!Le,disableKeyboardA11y:Qe,rfId:De},fe.createElement(WW,{style:N,type:v,component:S,containerStyle:E})),fe.createElement("div",{className:"react-flow__edgelabel-renderer"}),fe.createElement(vW,{nodeTypes:He,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:A,onlyRenderVisibleElements:M,noPanClassName:qe,noDragClassName:$e,disableKeyboardA11y:Qe,nodeOrigin:je,nodeExtent:Ae,rfId:De})))};aO.displayName="GraphView";var HW=y.memo(aO);const Ok=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ja={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:Ok,nodeExtent:Ok,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Fo.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:yU,isValidConnection:void 0},zW=()=>MF((e,t)=>({...ja,setNodes:n=>{const{nodeInternals:s,nodeOrigin:r,elevateNodesOnSelect:o}=t();e({nodeInternals:xg(n,s,r,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:s={}}=t();e({edges:n.map(r=>({...s,...r}))})},setDefaultNodesAndEdges:(n,s)=>{const r=typeof n<"u",o=typeof s<"u",i=r?xg(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?s:[],hasDefaultNodes:r,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:r,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:c,domNode:d,nodeOrigin:h}=t(),f=d==null?void 0:d.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:m}=new window.DOMMatrixReadOnly(p.transform),w=n.reduce((b,k)=>{const v=r.get(k.id);if(v!=null&&v.hidden)r.set(v.id,{...v,[Rt]:{...v[Rt],handleBounds:void 0}});else if(v){const N=J0(k.nodeElement);!!(N.width&&N.height&&(v.width!==N.width||v.height!==N.height||k.forceUpdate))&&(r.set(v.id,{...v,[Rt]:{...v[Rt],handleBounds:{source:O_(".source",k.nodeElement,m,h),target:O_(".target",k.nodeElement,m,h)}},...N}),b.push({id:v.id,type:"dimensions",dimensions:N}))}return b},[]);GL(r,h);const j=i||o&&!i&&KL(t,{initial:!0,...c});e({nodeInternals:new Map(r),fitViewOnInitDone:j}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(n,s=!0,r=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(c=>{const d={id:c.id,type:"position",dragging:r};return s&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(i)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:r,hasDefaultNodes:o,nodeOrigin:i,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=oW(n,c()),f=xg(h,r,i,d);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:r,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ea(d,!0)):(i=Hi(o(),n),c=Hi(r,[])),Zd({changedNodes:i,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:r,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ea(d,!0)):(i=Hi(r,n),c=Hi(o(),[])),Zd({changedNodes:c,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:r,getNodes:o}=t(),i=n||o(),c=s||r,d=i.map(f=>(f.selected=!1,Ea(f.id,!1))),h=c.map(f=>Ea(f.id,!1));Zd({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:s,maxZoom:r}=t();s==null||s.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:s,minZoom:r}=t();s==null||s.scaleExtent([r,n]),e({maxZoom:n})},setTranslateExtent:n=>{var s;(s=t().d3Zoom)==null||s.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:s}=t(),o=s().filter(c=>c.selected).map(c=>Ea(c.id,!1)),i=n.filter(c=>c.selected).map(c=>Ea(c.id,!1));Zd({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(r=>{r.positionAbsolute=Q0(r.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:r,height:o,d3Zoom:i,d3Selection:c,translateExtent:d}=t();if(!i||!c||!n.x&&!n.y)return!1;const h=zr.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[r,o]],p=i==null?void 0:i.constrain()(h,f,d);return i.transform(c,p),s[0]!==p.x||s[1]!==p.y||s[2]!==p.k},cancelConnection:()=>e({connectionNodeId:ja.connectionNodeId,connectionHandleId:ja.connectionHandleId,connectionHandleType:ja.connectionHandleType,connectionStatus:ja.connectionStatus,connectionStartHandle:ja.connectionStartHandle,connectionEndHandle:ja.connectionEndHandle}),reset:()=>e({...ja})}),Object.is),l1=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=zW()),fe.createElement(uU,{value:t.current},e)};l1.displayName="ReactFlowProvider";const oO=({children:e})=>y.useContext(Cf)?fe.createElement(fe.Fragment,null,e):fe.createElement(l1,null,e);oO.displayName="ReactFlowWrapper";const VW={input:BL,default:Ik,output:UL,group:o1},GW={default:Wh,straight:n1,step:t1,smoothstep:Tf,simplebezier:e1},KW=[0,0],YW=[15,15],XW={x:0,y:0,zoom:1},ZW={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},iO=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:r,nodeTypes:o=VW,edgeTypes:i=GW,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:j,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:v,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:C,onNodeDoubleClick:I,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:L,onNodesDelete:U,onEdgesDelete:O,onSelectionChange:M,onSelectionDragStart:q,onSelectionDrag:A,onSelectionDragStop:D,onSelectionContextMenu:P,onSelectionStart:K,onSelectionEnd:G,connectionMode:W=Fo.Strict,connectionLineType:H=Ca.Bezier,connectionLineStyle:F,connectionLineComponent:B,connectionLineContainerStyle:Z,deleteKeyCode:V="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=Zc.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ne=qh()?"Meta":"Control",zoomActivationKeyCode:le=qh()?"Meta":"Control",snapToGrid:de=!1,snapGrid:ue=YW,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:pe=!0,nodesDraggable:ye,nodesConnectable:_e,nodesFocusable:he,nodeOrigin:ae=KW,edgesFocusable:ge,edgesUpdatable:Se,elementsSelectable:me,defaultViewport:$e=XW,minZoom:Pe=.5,maxZoom:qe=2,translateExtent:Le=Ok,preventScrolling:Qe=!0,nodeExtent:je,defaultMarkerColor:Ae="#b1b1b7",zoomOnScroll:De=!0,zoomOnPinch:He=!0,panOnScroll:Ze=!1,panOnScrollSpeed:ft=.5,panOnScrollMode:ut=Co.Free,zoomOnDoubleClick:Je=!0,panOnDrag:Dt=!0,onPaneClick:vt,onPaneMouseEnter:It,onPaneMouseMove:it,onPaneMouseLeave:Lt,onPaneScroll:Ft,onPaneContextMenu:dt,children:St,onEdgeContextMenu:rt,onEdgeDoubleClick:ys,onEdgeMouseEnter:Ws,onEdgeMouseMove:ws,onEdgeMouseLeave:Yn,onEdgeUpdate:Xn,onEdgeUpdateStart:wn,onEdgeUpdateEnd:At,onReconnect:an,onReconnectStart:Ne,onReconnectEnd:Te,reconnectRadius:We=10,edgeUpdaterRadius:pt=10,onNodesChange:at,onEdgesChange:Zn,noDragClassName:Hs="nodrag",noWheelClassName:zs="nowheel",noPanClassName:On="nopan",fitView:xn=!1,fitViewOptions:Jr,connectOnClick:Vs=!0,attributionPosition:yr,proOptions:wr,defaultEdgeOptions:xr,elevateNodesOnSelect:Bt=!0,elevateEdgesOnSelect:Qr=!1,disableKeyboardA11y:Gs=!1,autoPanOnConnect:vr=!0,autoPanOnNodeDrag:ot=!0,connectionRadius:Ya=20,isValidConnection:br,onError:xs,style:vs,id:ea,nodeDragThreshold:kr,...Pn},Jt)=>{const Ks=ea||"1";return fe.createElement("div",{...Pn,style:{...vs,...ZW},ref:Jt,className:rn(["react-flow",r]),"data-testid":"rf__wrapper",id:ea},fe.createElement(oO,null,fe.createElement(HW,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:C,onNodeDoubleClick:I,nodeTypes:o,edgeTypes:i,connectionLineType:H,connectionLineStyle:F,connectionLineComponent:B,connectionLineContainerStyle:Z,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:J,deleteKeyCode:V,multiSelectionKeyCode:ne,panActivationKeyCode:ee,zoomActivationKeyCode:le,onlyRenderVisibleElements:re,selectNodesOnDrag:pe,defaultViewport:$e,translateExtent:Le,minZoom:Pe,maxZoom:qe,preventScrolling:Qe,zoomOnScroll:De,zoomOnPinch:He,zoomOnDoubleClick:Je,panOnScroll:Ze,panOnScrollSpeed:ft,panOnScrollMode:ut,panOnDrag:Dt,onPaneClick:vt,onPaneMouseEnter:It,onPaneMouseMove:it,onPaneMouseLeave:Lt,onPaneScroll:Ft,onPaneContextMenu:dt,onSelectionContextMenu:P,onSelectionStart:K,onSelectionEnd:G,onEdgeContextMenu:rt,onEdgeDoubleClick:ys,onEdgeMouseEnter:Ws,onEdgeMouseMove:ws,onEdgeMouseLeave:Yn,onReconnect:an??Xn,onReconnectStart:Ne??wn,onReconnectEnd:Te??At,reconnectRadius:We??pt,defaultMarkerColor:Ae,noDragClassName:Hs,noWheelClassName:zs,noPanClassName:On,elevateEdgesOnSelect:Qr,rfId:Ks,disableKeyboardA11y:Gs,nodeOrigin:ae,nodeExtent:je}),fe.createElement(BU,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:j,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:v,nodesDraggable:ye,nodesConnectable:_e,nodesFocusable:he,edgesFocusable:ge,edgesUpdatable:Se,elementsSelectable:me,elevateNodesOnSelect:Bt,minZoom:Pe,maxZoom:qe,nodeExtent:je,onNodesChange:at,onEdgesChange:Zn,snapToGrid:de,snapGrid:ue,connectionMode:W,translateExtent:Le,connectOnClick:Vs,defaultEdgeOptions:xr,fitView:xn,fitViewOptions:Jr,onNodesDelete:U,onEdgesDelete:O,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:L,onSelectionDrag:A,onSelectionDragStart:q,onSelectionDragStop:D,noPanClassName:On,nodeOrigin:ae,rfId:Ks,autoPanOnConnect:vr,autoPanOnNodeDrag:ot,onError:xs,connectionRadius:Ya,isValidConnection:br,nodeDragThreshold:kr}),fe.createElement(DU,{onSelectionChange:M}),St,fe.createElement(hU,{proOptions:wr,position:yr}),fe.createElement(zU,{rfId:Ks,disableKeyboardA11y:Gs})))});iO.displayName="ReactFlow";const JW=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function lO(){return tt(JW,Kt)}const cO=({id:e,x:t,y:n,width:s,height:r,style:o,color:i,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:m,selected:w})=>{const{background:j,backgroundColor:b}=o||{},k=i||j||b;return fe.createElement("rect",{className:rn(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:r,fill:k,stroke:c,strokeWidth:d,shapeRendering:p,onClick:m?v=>m(v,e):void 0})};cO.displayName="MiniMapNode";var QW=y.memo(cO);const eH=e=>e.nodeOrigin,tH=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),jg=e=>e instanceof Function?e:()=>e;function nH({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:r=2,nodeComponent:o=QW,onClick:i}){const c=tt(tH,Kt),d=tt(eH),h=jg(t),f=jg(e),p=jg(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return fe.createElement(fe.Fragment,null,c.map(w=>{const{x:j,y:b}=Mo(w,d).positionAbsolute;return fe.createElement(o,{key:w.id,x:j,y:b,width:w.width,height:w.height,style:w.style,selected:w.selected,className:p(w),color:h(w),borderRadius:s,strokeColor:f(w),strokeWidth:r,shapeRendering:m,onClick:i,id:w.id})}))}var sH=y.memo(nH);const rH=200,aH=150,oH=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?mU(Rf(t,e.nodeOrigin),n):n,rfId:e.rfId}},iH="react-flow__minimap-desc";function uO({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:m,onNodeClick:w,pannable:j=!1,zoomable:b=!1,ariaLabel:k="React Flow mini map",inversePan:v=!1,zoomStep:N=10,offsetScale:S=5}){const E=$t(),C=y.useRef(null),{boundingRect:I,viewBB:R,rfId:$}=tt(oH,Kt),L=(e==null?void 0:e.width)??rH,U=(e==null?void 0:e.height)??aH,O=I.width/L,M=I.height/U,q=Math.max(O,M),A=q*L,D=q*U,P=S*q,K=I.x-(A-I.width)/2-P,G=I.y-(D-I.height)/2-P,W=A+P*2,H=D+P*2,F=`${iH}-${$}`,B=y.useRef(0);B.current=q,y.useEffect(()=>{if(C.current){const X=us(C.current),Y=ne=>{const{transform:le,d3Selection:de,d3Zoom:ue}=E.getState();if(ne.sourceEvent.type!=="wheel"||!de||!ue)return;const re=-ne.sourceEvent.deltaY*(ne.sourceEvent.deltaMode===1?.05:ne.sourceEvent.deltaMode?1:.002)*N,pe=le[2]*Math.pow(2,re);ue.scaleTo(de,pe)},J=ne=>{const{transform:le,d3Selection:de,d3Zoom:ue,translateExtent:re,width:pe,height:ye}=E.getState();if(ne.sourceEvent.type!=="mousemove"||!de||!ue)return;const _e=B.current*Math.max(1,le[2])*(v?-1:1),he={x:le[0]-ne.sourceEvent.movementX*_e,y:le[1]-ne.sourceEvent.movementY*_e},ae=[[0,0],[pe,ye]],ge=zr.translate(he.x,he.y).scale(le[2]),Se=ue.constrain()(ge,ae,re);ue.transform(de,Se)},ee=xL().on("zoom",j?J:null).on("zoom.wheel",b?Y:null);return X.call(ee),()=>{X.on("zoom",null)}}},[j,b,v,N]);const Z=m?X=>{const Y=Ms(X);m(X,{x:Y[0],y:Y[1]})}:void 0,V=w?(X,Y)=>{const J=E.getState().nodeInternals.get(Y);w(X,J)}:void 0;return fe.createElement(Z0,{position:p,style:e,className:rn(["react-flow__minimap",t]),"data-testid":"rf__minimap"},fe.createElement("svg",{width:L,height:U,viewBox:`${K} ${G} ${W} ${H}`,role:"img","aria-labelledby":F,ref:C,onClick:Z},k&&fe.createElement("title",{id:F},k),fe.createElement(sH,{onClick:V,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:c}),fe.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-P},${G-P}h${W+P*2}v${H+P*2}h${-W-P*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"})))}uO.displayName="MiniMap";var lH=y.memo(uO);function cH(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},fe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function uH(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},fe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function dH(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},fe.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 hH(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.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 fH(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.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 is=({children:e,className:t,...n})=>fe.createElement("button",{type:"button",className:rn(["react-flow__controls-button",t]),...n},e);is.displayName="ControlButton";const pH=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),dO=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:i,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const m=$t(),[w,j]=y.useState(!1),{isInteractive:b,minZoomReached:k,maxZoomReached:v}=tt(pH,Kt),{zoomIn:N,zoomOut:S,fitView:E}=ml();if(y.useEffect(()=>{j(!0)},[]),!w)return null;const C=()=>{N(),o==null||o()},I=()=>{S(),i==null||i()},R=()=>{E(r),c==null||c()},$=()=>{m.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)};return fe.createElement(Z0,{className:rn(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&fe.createElement(fe.Fragment,null,fe.createElement(is,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:v},fe.createElement(cH,null)),fe.createElement(is,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:k},fe.createElement(uH,null))),n&&fe.createElement(is,{className:"react-flow__controls-fitview",onClick:R,title:"fit view","aria-label":"fit view"},fe.createElement(dH,null)),s&&fe.createElement(is,{className:"react-flow__controls-interactive",onClick:$,title:"toggle interactivity","aria-label":"toggle interactivity"},b?fe.createElement(fH,null):fe.createElement(hH,null)),f)};dO.displayName="Controls";var mH=y.memo(dO),Os;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Os||(Os={}));function gH({color:e,dimensions:t,lineWidth:n}){return fe.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function yH({color:e,radius:t}){return fe.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const wH={[Os.Dots]:"#91919a",[Os.Lines]:"#eee",[Os.Cross]:"#e2e2e2"},xH={[Os.Dots]:1,[Os.Lines]:1,[Os.Cross]:6},vH=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hO({id:e,variant:t=Os.Dots,gap:n=20,size:s,lineWidth:r=1,offset:o=2,color:i,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=tt(vH,Kt),m=i||wH[t],w=s||xH[t],j=t===Os.Dots,b=t===Os.Cross,k=Array.isArray(n)?n:[n,n],v=[k[0]*f[2]||1,k[1]*f[2]||1],N=w*f[2],S=b?[N,N]:v,E=j?[N/o,N/o]:[S[0]/o,S[1]/o];return fe.createElement("svg",{className:rn(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},fe.createElement("pattern",{id:p+e,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},j?fe.createElement(yH,{color:m,radius:N/o}):fe.createElement(gH,{dimensions:S,color:m,lineWidth:r})),fe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}hO.displayName="Background";var bH=y.memo(hO);function kH(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ma(e){return e!=="gone"}function H_(e,t){return e||Ma(t)}function z_(e,t){return!e&&Ma(t)}function zi(e,t){const[n,s]=y.useState(()=>e?"here":"gone"),r=y.useRef(null);return y.useEffect(()=>{s(o=>kH(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return r.current=window.setTimeout(()=>s("gone"),t),()=>{r.current!=null&&window.clearTimeout(r.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&s("here")},[n]),n}const fO=.2,pO=1.6;function jH(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:s,zoom:r}=t;return typeof n!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(r)||r<fO||r>pO?null:{x:n,y:s,zoom:r}}function Pk({durationMs:e,documentHidden:t,reducedMotion:n=vu()}){return t||n?!1:Number.isFinite(e)&&e>0}function vu(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function c1(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,parkedEnrichment:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function Yr(e,t){return`${e}::${t}`}function gl(e,t){return`${e}\0${t}`}const NH=/[0-9a-f]{16,}/i,SH=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function mO(e){return NH.test(e)||SH.test(e)}function _H(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!mO(t[n]))return t[n];return t[t.length-1]}function gO(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function yO(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,s=n.ephemeral_1h_input_tokens,r=n.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof r!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(r??0)}}function Af(e){const t=yO(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)),e.longContext&&typeof e.longContext=="object"&&!Array.isArray(e.longContext)&&(n.longContext=Af({...e.longContext,longContext:void 0})),n}function EH(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e)){if(!n||!s||typeof s!="object")continue;const r=s;t[n]=Af(r);const o=CH(r.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function CH(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,s])=>n&&s&&typeof s=="object").map(([n,s])=>[n,Af(s)]);return t.length?Object.fromEntries(t):void 0}function wO(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),...yO(n)};for(const s of Object.values(n)){const r=wO(s,t+1);if(r)return r}return null}function u1(e){return _H(e)}function d1(e){const t=e.agent_type??e.subagent_type;return t&&!mO(t)?t:"subagent"}function yl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function qo(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=u1(t.cwd))}function h1(e,t){e.label==="session"&&t.cwd&&(e.label=u1(t.cwd)??"session")}function xO(e,t){const n=d1(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function za(e,t,n,s){const r=t;let o=e.agents.get(r);return o||(o={id:r,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:gO()},e.agents.set(r,o),o)}function vO(e,t,n,s){const r=Yr(t,n),o=e.agents.get(r);return o?(qo(o,s),xO(o,s),o):null}function TH(e,t,n){var h;const s=t.session_id??"unknown",r=yl(t);if(r){const f=vO(e,s,r,t);if(f)return f}const i=((h=e.agents.get(s))==null?void 0:h.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(s),c=i&&i.length>0?i[i.length-1]:null;if(c){const f=e.agents.get(Yr(s,c));if(f)return qo(f,t),f}const d=za(e,s,n,t.hook_event_name!=="SessionStart");return qo(d,t),h1(d,t),d}function RH(e,t,n,s){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const r=e.agents.get(s);return!r||r.keyedSubagents?!1:(r.keyedSubagents=!0,!0)}function AH(e,t,n,s,r){const o=Yr(t,n),i=za(e,t,r,!0);let c=e.agents.get(o);if(c)return qo(c,s),xO(c,s),c;c={id:o,sessionId:t,label:d1(s),kind:"subagent",parentId:i.id,state:"active",startedAt:r,tools:[],prompts:[],cwd:s.cwd,cwdBasename:u1(s.cwd),toolCount:0,childCount:0,usage:gO()},e.agents.set(o,c);const d=e.pendingSubagentModels.get(o);return d&&(c.model=d,e.pendingSubagentModels.delete(o)),i.childCount+=1,c}function MH(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function bO(e,t,n){const s=e.activeSubagentStack.get(t);if(s){for(let r=s.length-1;r>=0;r--)if(s[r]===n){s.splice(r,1);break}s.length===0&&e.activeSubagentStack.delete(t)}}const $H=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),kO=/^[a-z][a-z0-9_-]{0,23}$/i;function IH(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&kO.test(n)?n:$H.has(e)?null:void 0}function jO(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function f1(e,t,n){if(typeof t.model_context_window=="number"&&t.model_context_window>0){const s=e.agents.get(n);s&&(s.contextWindow=t.model_context_window)}if(typeof t.approval_policy=="string"&&t.approval_policy){const s=e.agents.get(n);s&&(s.approvalPolicy=t.approval_policy)}if(t.reasoning_effort===null||typeof t.reasoning_effort=="string"&&kO.test(t.reasoning_effort)){const s=e.agents.get(n);s&&(s.effort=t.reasoning_effort??void 0)}if(typeof t.context_tokens=="number"&&t.context_tokens>=0){const s=e.agents.get(n);s&&(s.context={...s.context??jO(),currentContextTokens:t.context_tokens})}}const LH=6e4,V_=64;function NO(e,t,n){const s=typeof t.model=="string"?t.model:null;if(s){const o=e.agents.get(n);o&&(o.model=s)}const r=t.subagentModels;if(r&&typeof r=="object")for(const[o,i]of Object.entries(r)){if(typeof i!="string")continue;const c=Yr(n,o),d=e.agents.get(c);if(d)d.model=i,e.pendingSubagentModels.delete(c);else if(e.pendingSubagentModels.delete(c),e.pendingSubagentModels.set(c,i),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function SO(e,t,n){const s=t.context??null;if(s){const r=e.agents.get(n);if(r){const o=r.context??jO(),i=(d,h)=>typeof s[d]=="number"?s[d]:h,c=Array.isArray(s.memoryFiles)?s.memoryFiles:Array.isArray(s.claudeMdFiles)?s.claudeMdFiles:null;r.context={msgsUser:i("msgsUser",o.msgsUser),msgsAssistant:i("msgsAssistant",o.msgsAssistant),toolUses:i("toolUses",o.toolUses),toolResults:i("toolResults",o.toolResults),systemReminders:i("systemReminders",o.systemReminders),currentContextTokens:i("currentContextTokens",o.currentContextTokens),memoryFiles:c??o.memoryFiles}}}}function _O(e,t,n){const s=e.agents.get(n);if(s){const r=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";r&&(s.sessionName=r),o&&(s.sessionTitle=o);const i=s.sessionName??"";s.sessionTitle&&i&&s.sessionTitle.toLowerCase()===i.toLowerCase()&&(s.sessionTitle=void 0)}}function OH(e,t,n){const s=e.agents.get(n);if(s){const r=t.recap;r===null?s.recap=void 0:r&&typeof r.text=="string"&&r.text.trim()&&Number.isFinite(r.at)&&(s.recap={text:r.text.trim(),at:r.at})}}function EO(e,t,n){const s=e.agents.get(n),r=t.activity;!s||!r||typeof r.text!="string"||!r.text.trim()||!Number.isFinite(r.at)||s.activity&&r.at<s.activity.at||(s.activity={text:r.text.trim(),source:r.source==="said"?"said":"tool",at:r.at})}const PH=new Set(["working","blocked","done","failed","stopped"]);function CO(e,t,n){const s=e.agents.get(n);if(!s)return;const r=t.job;if(r===null){s.job=void 0;return}if(!r||typeof r!="object"||!PH.has(r.state))return;const o=i=>typeof i=="string"&&i.trim()?i.trim():void 0;s.job={id:o(r.id)??"",state:r.state,detail:o(r.detail)??"",needs:o(r.needs),suggestedReply:o(r.suggestedReply),result:o(r.result),updatedAt:Number.isFinite(r.updatedAt)?r.updatedAt:0}}function DH(e,t,n,s){const r=t.kind==="thinking"||t.kind==="text"||t.kind==="tool_use"?t.kind:null,o=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:s;if(!r)return;const i=e.agents.get(n);if(i&&!(i.lastOutputAt!=null&&o<=i.lastOutputAt)){if(i.lastOutputAt=o,r!=="tool_use"){const c=(i.outputs??[]).filter(d=>o-d<LH);c.push(o),i.outputs=c.length>V_?c.slice(-V_):c}e.revision+=1}}function p1(e,t,n){const s=t.usage??null;if(s){const r=e.agents.get(n);r&&(Object.assign(r.usage,Af(s)),r.usageByModel=EH(t.usageByModel))}}function Vt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const FH=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function G_(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const BH={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Mf(e){const t=FH.exec(e);if(!t)return null;const n=G_(t[1],"status");return{label:(n?Vt(BH,n):void 0)??"background task update",detail:G_(t[1],"summary")}}function TO(e){return e.filter(t=>!Mf(t.text))}const K_=2e3;function qH(e,t,n){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.at<t-K_)return!1;if(r.text===n&&r.at<=t+K_)return!0}return!1}function UH(e,t,n){if(qH(e,t,n))return!1;let s=e.length;for(;s>0&&e[s-1].at>t;)s--;return e.splice(s,0,{at:t,text:n}),!0}const Hh=2e3;function WH(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const Y_=["B","KB","MB","GB","TB"];function qr(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<Y_.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${Y_[n]}`}const HH=60,zH=6e3,hs=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),qn=e=>typeof e=="string"?e:null;function VH(e){return hs(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function ol(e){const t=VH(e);if(t!=null)return`(too large to show — ${qr(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(ol);return n.some((s,r)=>s!==e[r])?n:e}if(hs(e)){let n=!1;const s={};for(const[r,o]of Object.entries(e))s[r]=ol(o),s[r]!==o&&(n=!0);return n?s:e}return e}function Uo(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),s=n?e.map((o,i)=>[String(i),o]):Object.entries(e);if(s.length===0)return n?"[]":"{}";const r=[];for(const[o,i]of s){const c=n?`${t}-`:`${t}${o}:`;if(typeof i=="string"&&i.includes(`
58
- `)){r.push(c);for(const d of i.split(`
59
- `))r.push(`${t} ${d}`)}else if(i!==null&&typeof i=="object"){const d=Uo(i,`${t} `);d==="[]"||d==="{}"?r.push(`${c} ${d}`):r.push(c,d)}else r.push(`${c} ${i===void 0?"(none)":String(i)}`)}return r.join(`
60
- `)}function GH(e){return e.lines??e.text.split(`
61
- `).map(t=>({text:t}))}function RO(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const r of e){if(n.length===HH)return{shown:n,cut:!0};const o=zH-s;if(r.text.length>o)return n.push({...r,text:`${r.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(r),s+=r.text.length+1}return{shown:n,cut:!1}}function KH(e,t){return RO(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const mn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Un=(e,t)=>({label:e,text:t,inline:!0}),AO=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
- `),lines:t});function YH(e,t){return[...e.split(`
63
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function XH(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!hs(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const s of n.lines){const r=String(s);t.push(r.startsWith("+")?{text:r,tone:"add"}:r.startsWith("-")?{text:r,tone:"del"}:{text:r})}}return t}function X_(e){if(typeof e=="string")return[mn(void 0,e)];if(!hs(e))return[mn(void 0,Uo(e))];const t=[],n=qn(e.type);n==="create"&&t.push(Un("result","created the file"));const s=XH(e.structuredPatch);return s&&t.push(AO("applied",s)),e.userModified===!0&&t.push(Un("note","the user changed it before it was applied")),t.length?t:[Un("result",n==="update"?"updated the file":"done")]}function ZH(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 s=t??1;return n!=null?`${s}–${s+n-1}`:`from ${s}`}function JH(e){if(typeof e=="string")return[mn(void 0,e)];const t=hs(e)&&hs(e.file)?e.file:null,n=qn(t==null?void 0:t.content);if(t&&n!=null){const r=[],o=Number(t.numLines),i=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&r.push(Un("lines",o>=i?`all ${i}`:Number.isFinite(c)?`${c}–${c+o-1} of ${i}`:`${o} of ${i}`)),r.push(mn("content",n)),r}const s=hs(e)?qn(e.type):null;return s&&s!=="text"?[Un("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[mn(void 0,Uo(e))]}function QH(e){if(typeof e=="string")return[mn("output",e)];if(!hs(e))return[mn(void 0,Uo(e))];const t=qn(e.stdout),n=qn(e.stderr);if(t==null&&n==null)return[mn(void 0,Uo(e))];const s=[];return t&&s.push(mn("output",t.replace(/\n$/,""))),n&&s.push(mn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Un("note","interrupted before it finished")),s.length?s:[Un("output","none")]}function ez(e,t,n){const s=ol(t),r=ol(n),o=hs(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=qn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(hs).filter(d=>qn(d.old_string)!=null&&qn(d.new_string)!=null);if(i&&c.length){const d=[Un("file",i)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(AO(c.length>1?`change ${f+1}${p}`:`change${p}`,YH(h.old_string,h.new_string)))}),{input:d,response:X_(r)}}}if(o&&e==="Write"){const i=qn(o.file_path),c=qn(o.content);if(i&&c!=null)return{input:[Un("file",i),mn("content",c)],response:X_(r)}}if(o&&e==="Read"){const i=qn(o.file_path);if(i){const c=ZH(o);return{input:c?[Un("file",i),Un("lines",c)]:[Un("file",i)],response:JH(r)}}}if(o&&e==="Bash"){const i=qn(o.command);if(i!=null){const c=qn(o.description);return{input:c?[mn("command",i),Un("why",c)]:[mn("command",i)],response:QH(r)}}}return{input:[mn(void 0,Uo(s))],response:[mn(void 0,Uo(r))]}}function Z_(e,t,n){const s=ol(n);if(s==null)return"";if(typeof s=="string")return s;if(hs(s)){if(e==="Bash"&&t==="input"&&typeof s.command=="string")return s.command;if(e==="Bash"&&t==="response"&&(typeof s.stdout=="string"||typeof s.stderr=="string"))return[s.stdout,s.stderr].filter(r=>typeof r=="string"&&r!=="").join(`
65
- `);if(e==="Read"&&t==="response"&&hs(s.file)&&typeof s.file.content=="string")return s.file.content}try{return JSON.stringify(s,null,2)??String(s)}catch{return String(s)}}const tz=new Set(["TodoWrite","update_plan"]),nz=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function Ec(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function ls(e){return typeof e=="string"?e.trim():""}function ko(e){if(e&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e=="string")try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}return null}function sz(e,t){const n=ko(t);if(!n)return null;const s=e==="TodoWrite"?n.todos:n.plan;if(!Array.isArray(s))return null;const r=[];for(const i of s){if(!i||typeof i!="object")continue;const c=i,d=ls(e==="TodoWrite"?c.content:c.step),h=Ec(c.status);if(!d||!h)continue;const f=ls(c.activeForm??c.active_form);r.push(f?{text:d,status:h,active:f}:{text:d,status:h})}const o=e==="update_plan"?ls(n.explanation):"";return o?{items:r,note:o}:{items:r}}function Sa(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function rz(e,t,n,s){if(!t||!tz.has(t)||e.plan&&s<e.plan.at)return;const r=sz(t,n);r&&(e.plan=Sa(r.items,s,r.note))}function Ai(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):ls(t)}function az(e,t,n,s,r){var b,k,v,N,S,E,C,I,R,$,L,U,O,M,q;if(!t||!nz.has(t))return;const o=ko(n),i=ko(s),c=((b=e.plan)==null?void 0:b.items)??[],d=A=>c.findIndex(D=>D.id===A);if(t==="TaskCreate"){const A=ko(i==null?void 0:i.task),D=Ai(A),P=ls(A==null?void 0:A.subject)||ls(o==null?void 0:o.subject);if(!D||!P)return;const K=ls((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),G=d(D),W={id:D,text:P,status:G>=0?c[G].status:"pending",...K?{active:K}:{}},H=c.slice();G>=0?H[G]=W:H.push(W),e.plan=Sa(H,Math.max(r,((k=e.plan)==null?void 0:k.at)??r),(v=e.plan)==null?void 0:v.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const A=Ai(i)||Ai(o);if(!A)return;const D=o==null?void 0:o.status,P=d(A);if(D==="deleted"){if(P<0)return;e.plan=Sa(c.filter((Z,V)=>V!==P),Math.max(r,((N=e.plan)==null?void 0:N.at)??r),(S=e.plan)==null?void 0:S.note);return}const K=ls(o==null?void 0:o.subject),G=ls((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),W=Ec(D)??Ec((E=ko(i==null?void 0:i.statusChange))==null?void 0:E.to);if(P<0){if(!K)return;const Z={id:A,text:K,status:W??"pending",...G?{active:G}:{}};e.plan=Sa([...c,Z],Math.max(r,((C=e.plan)==null?void 0:C.at)??r),(I=e.plan)==null?void 0:I.note);return}const F={...c[P],...K?{text:K}:{},...W?{status:W}:{},...G?{active:G}:{}},B=c.slice();B[P]=F,e.plan=Sa(B,Math.max(r,((R=e.plan)==null?void 0:R.at)??r),($=e.plan)==null?void 0:$.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&r<e.plan.at)return;const A=[];for(const D of i.tasks){const P=ko(D),K=Ai(P),G=ls(P==null?void 0:P.subject),W=Ec(P==null?void 0:P.status);if(!K||!G||!W)continue;const H=c.find(F=>F.id===K);A.push(H!=null&&H.active?{id:K,text:G,status:W,active:H.active}:{id:K,text:G,status:W})}e.plan=Sa(A,r,(L=e.plan)==null?void 0:L.note);return}const h=i&&"task"in i?ko(i.task):void 0,f=Ai(h??null)||Ai(o),p=f?d(f):-1;if(p<0)return;if(h===null){e.plan=Sa(c.filter((A,D)=>D!==p),Math.max(r,((U=e.plan)==null?void 0:U.at)??r),(O=e.plan)==null?void 0:O.note);return}const m=ls(h==null?void 0:h.subject),w=Ec(h==null?void 0:h.status);if(!m&&!w)return;const j=c.slice();j[p]={...c[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=Sa(j,Math.max(r,((M=e.plan)==null?void 0:M.at)??r),(q=e.plan)==null?void 0:q.note)}function bu(e){const t=(e==null?void 0:e.items)??[];if(t.length===0)return null;const n=t.filter(i=>i.status==="completed").length,s=t.find(i=>i.status==="in_progress"),r=s?null:t.find(i=>i.status==="pending"),o=s?s.active||s.text:r?r.text:null;return{done:n,total:t.length,current:o,next:!s&&!!r,allDone:n===t.length}}function oz(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function MO(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function $O(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
66
- `)}function Qc(e,t=80){const n=ol(e);if(n==null)return"";if(typeof n=="string")return n.length>t?n.slice(0,t-1)+"…":n;try{const s=JSON.stringify(n);return s.length>t?s.slice(0,t-1)+"…":s}catch{return String(n)}}const J_=200;function IO(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function LO(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Lc(e,t,n){const s=e.toolCountByName??(e.toolCountByName=new Map),r=(s.get(t)??0)+n;r>0?s.set(t,r):s.delete(t)}function iz(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(r=>r.id===n))??null}const OO=25;function PO(e,t){const n=t.tools;if(n.length>J_){const s=n.splice(0,n.length-J_);for(const r of s)FO(e,t,r)}for(let s=n.length-OO-1;s>=0;s--){const r=n[s];if(r.trimmed)break;r.input=void 0,r.response=void 0,r.trimmed=!0}}function lz(e,t,n){const s=e.toolIndex.get(gl(t.sessionId,n));if(s)return s;for(let r=t.tools.length-1;r>=0;r--)if(t.tools[r].id===n)return t.tools[r];return null}function DO(e,t){for(const n of t.tools)FO(e,t,n)}function FO(e,t,n){const s=gl(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function cz(e,t){const n=e.agents.get(t);if(!n)return;let s=!1;for(const r of e.agents.values()){if(r===n||r.sessionId!==t)continue;const o=r.tools.filter(i=>i.explicitSubagentId==null);if(o.length!==0){for(const i of o)r.toolCount-=1,Lc(r,i.name,-1),i.ok===!1&&(r.toolErrorCount=(r.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,Lc(n,i.name,1),i.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);r.tools=r.tools.filter(i=>i.explicitSubagentId!=null),s=!0}}if(s){n.tools.sort((r,o)=>r.startedAt-o.startedAt),PO(e,n);for(let r=0;r<n.tools.length-OO;r++){const o=n.tools[r];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const uz="no result reached the deck — events were dropped while the deck was paused";function BO(e,t,n,s,r){n.endedAt=s,IO(t,n,!1),n.errorPreview=n.outcomeGap?uz:r,e.toolIndex.delete(gl(t.sessionId,n.id))}function dz(e,t){const n=t==null?void 0:t.payload,s=n==null?void 0:n.hook_event_name;if(s!=="PostToolUse"&&s!=="PostToolUseFailure")return!1;const r=n==null?void 0:n.tool_use_id;return typeof r!="string"||r.length===0?!1:e.toolIndex.has(gl((n==null?void 0:n.session_id)??"unknown",r))}function hz(e,t,n,s,r){const o=t.tool_use_id?lz(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=LO(e,o);h&&(Lc(h,"?",-1),Lc(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=Qc(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,c=yl(t),d={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:Qc(t.tool_input),agentId:s.id,explicitSubagentId:c?Yr(n,c):void 0,startedAt:r};s.tools.push(d),s.toolCount+=1,Lc(s,d.name,1),s.state="active",e.toolIndex.set(gl(s.sessionId,i),d),PO(e,s),rz(s,d.name,t.tool_input,r)}function fz(e,t,n,s,r){const o=t.tool_use_id;if(!o)return;const i=gl(s,o);let c=e.toolIndex.get(i),d=!1;if(!c)for(const f of e.agents.values()){if(f.sessionId!==s)continue;const p=f.tools.find(m=>m.id===o);if(p){c=p,d=!0;break}}if(!c||c.outcomeApplied)return;if(c.outcomeApplied=!0,n==="PostToolUse"){const f=e.agents.get(s);f&&az(f,t.tool_name??c.name,t.tool_input??c.input,t.tool_response,r)}c.outcomeGap=void 0,c.endedAt=r,IO(LO(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=Qc(t.tool_response):d&&(c.errorPreview=void 0);const h=wO(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(i)}function pz(e,t,n){const s=e.agents.get(t);s&&n>(s.lastEventAt??0)&&(s.lastEventAt=n,s.reaped&&(s.reaped=!1,s.state="active",s.endedAt=void 0,s.closedAt=void 0))}function mz(e,t,n,s){const r=za(e,n,s,!1);r.synthetic=!1,r.state="active",r.closedAt=void 0,r.endedAt=void 0,r.startedAt=Math.min(r.startedAt??s,s),qo(r,t),h1(r,t)}function gz(e,t,n,s){for(const i of e.agents.values())i.sessionId===n&&i.kind==="subagent"&&i.state==="done"&&i.exitAt==null&&i.endedAt!=null&&i.endedAt<s&&(i.exitAt=s);const r=za(e,n,s,!1);r.state="active",r.endedAt=void 0,r.closedAt=void 0,r.exitAt=void 0;const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&UH(r.prompts,s,o)&&!r.firstPrompt&&!Mf(o)&&(r.firstPrompt=Qc(o,120))}function qO(e,t,n,s){const r=za(e,n,s,!1),o=WH(r);if(s<o)return;const i=r.lastTurnEndAt;if(!(i!=null&&o>i&&s<=i+Hh)){r.state="done",r.endedAt=s,r.lastTurnEndAt=s;for(const c of r.provider==="codex"?[]:e.agents.values())if(c.sessionId===n)for(const d of c.tools)d.endedAt==null&&d.explicitSubagentId==null&&BO(e,c,d,s,"the turn ended before this call returned");t==="SessionEnd"&&(r.closedAt=s),e.activeSubagentStack.delete(n)}}function yz(e,t,n){var i;const s=t.session_id;if(t.provider!=="codex"&&t.provider!=="claude"||typeof s!="string"||!s)return;const r=e.agents.get(s);if(r!=null&&r.provider&&r.provider!==t.provider||r&&Number.isFinite(t.snapshot_observed_at)&&(r.recoveryLiveAt??r.lastEventAt??0)>=t.snapshot_observed_at)return;if(t.recovery_active===!1){r&&(qO(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),r.restoredFromLog=void 0);return}const o=za(e,s,n,!0);o.recoveryLiveAt??(o.recoveryLiveAt=(r==null?void 0:r.lastEventAt)??0),o.provider=t.provider,o.state="active",o.endedAt=o.closedAt=o.exitAt=void 0,o.reaped=!1,o.restoredFromLog=!0,o.lastEventAt=n,qo(o,t),h1(o,t),typeof t.model=="string"&&t.model&&(o.model=t.model),!r&&Number.isFinite(t.turn_started_at)&&t.turn_started_at<=n&&(o.startedAt=t.turn_started_at),typeof t.prompt=="string"&&t.prompt&&(((i=o.prompts.at(-1))==null?void 0:i.text)!==t.prompt&&o.prompts.push({at:n,text:t.prompt}),o.firstPrompt||(o.firstPrompt=Qc(t.prompt,120))),f1(e,t,s),p1(e,t,s)}function wz(e,t,n){const s=t.session_id,r=t.parent_session_id;if(t.provider!=="codex"||typeof s!="string"||!s||typeof r!="string"||!r||s===r)return;const o=e.agents.get(s);if(o!=null&&o.provider&&o.provider!=="codex"||o!=null&&o.parentId&&o.parentId!==r)return;const i=new Set([s]);for(let f=r;f;){if(i.has(f))return;i.add(f);const p=e.agents.get(f);if(p!=null&&p.provider&&p.provider!=="codex")return;f=p==null?void 0:p.parentId}const c=za(e,s,n,!0);c.provider="codex",c.parentId=r,qo(c,t);const d=t.agent_nickname||t.agent_role;typeof d=="string"&&d.trim()&&(c.label=d);const h=e.agents.get(r);h&&(h.childCount=[...e.agents.values()].filter(f=>f.parentId===r).length)}const xz=["us-gov","global","apac","us","eu","jp","au"],vz=new RegExp(`^(?:(?:${xz.join("|")})\\.)?anthropic\\.`,"i");function lr(e){return e.replace(vz,"")}const bz=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,kz=new Set(["tool_input","tool_response"]);function UO(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&bz.test(lr(n.model)))return n.model;for(const[s,r]of Object.entries(n)){if(kz.has(s))continue;const o=UO(r,t+1);if(o)return o}return null}const jz=256,Nh={ModelObserved:NO,UsageObserved:p1,ContextObserved:SO,SessionNamed:_O,ActivityObserved:EO,JobObserved:CO},Br=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Qd=e=>typeof e=="string"&&e.trim()!=="",Nz=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["reasoning_effort",e=>typeof e=="string"&&e!==""||e===null],["context_tokens",e=>typeof e=="number"&&e>=0]],Sz=new Set(["working","blocked","done","failed","stopped"]),Q_=e=>Br(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function _z(e,t){if(!e)return t;const n={...e};for(const[r,o]of Object.entries(t))o!==void 0&&(n[r]=o);const s=r=>{r in e?n[r]=e[r]:delete n[r]};for(const[r,o]of Nz)o(t[r])||s(r);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Br(e.subagentModels)||Br(t.subagentModels))&&(n.subagentModels={...Br(e.subagentModels)?e.subagentModels:{},...Br(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Br(t.context)){s("context");break}const r=Br(e.context)?{...e.context}:{};for(const[o,i]of Object.entries(t.context))(typeof i=="number"||Array.isArray(i))&&(r[o]=i);n.context=r;break}case"SessionNamed":{const r=Qd(t.sessionName)?t.sessionName:e.sessionName??null;let o=Qd(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Qd(r)&&Qd(o)&&o.trim().toLowerCase()===r.trim().toLowerCase()&&(o=null),n.sessionName=r,n.sessionTitle=o;break}case"ActivityObserved":(!Q_(t.activity)||Q_(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Br(t.job)&&Sz.has(t.job.state)||s("job");break;case"UsageObserved":Br(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function Ez(e,t,n,s){if(!(t in Nh)||e.agents.has(s))return!1;const r=e.parkedEnrichment.get(s)??new Map,o=_z(r.get(t),n);for(r.delete(t),r.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,r);e.parkedEnrichment.size>jz;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function Cz(e,t){var s;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[r,o]of n)f1(e,o,t),(s=Nh[r])==null||s.call(Nh,e,o,t)}}function WO(e,t){e.parkedEnrichment.delete(t)}function Tz(e,t,n,s){const r=yl(t);if(!r)return;const o=AH(e,n,r,t,s),i=d1(t);i&&(o.label=i);const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&s-o.endedAt<=Hh,h=c!=null&&s-c<=Hh;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),bO(e,n,r);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,MH(e,n,r)}function Rz(e,t,n,s){const r=yl(t);if(!r)return;const o=vO(e,n,r,t);if(!o){for(const[i,c]of e.subagentTombstones)s-c>Hh&&e.subagentTombstones.delete(i);e.subagentTombstones.set(Yr(n,r),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),bO(e,n,r)}const Az=["command","cmd","file_path","path","url","pattern","notebook_path"],eE=120,Ng=e=>e.length>eE?`${e.slice(0,eE-1)}…`:e;function Mz(e){if(typeof e=="string")return e.trim()?Ng(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of Az){const s=t[n];if(typeof s=="string"&&s.trim())return Ng(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(r=>typeof r=="string")){const r=s.join(" ").trim();if(r)return Ng(r)}}return null}function $z(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const Iz=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function Lz(e,t){let n=null;for(const s of e.toolIndex.values()){const r=s.agentId?e.agents.get(s.agentId):void 0;!r||r.sessionId!==t||(!n||s.startedAt>n.startedAt)&&(n=s)}return n}const Oz=3e4;function Pz(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>Oz)&&!(e.startedAt>t))return{name:e.name,preview:Mz(e.input)??""}}function Dz(e,t,n,s,r){if(n!=="permission")return{kind:n,message:s,since:r};const o=Lz(e,t),i={kind:n,message:s,since:r};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const c=Pz(o,r);return c&&(i.tool=c),i}function Fz(e,t,n){if(e.kind==="idle")return!0;const s=yl(t);return s==null?!0:e.subagentId!=null&&Yr(n,s)===e.subagentId}function Bz(e,t,n,s){if(!Iz.has(t)){const r=e.agents.get(s);r!=null&&r.waiting&&Fz(r.waiting,n,s)&&(r.waiting=null)}}function qz(e,t,n,s){const r=$z(t.notification_type);if(!r)return;const o=za(e,n,s,!1),i=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===r&&c.message===i?{...c,since:Math.min(c.since,s)}:Dz(e,n,r,i,s)}function $f(e){const t=[...e],n=new Map(t.map(r=>[r.id,r])),s=new Map;for(const r of t){let o=r;const i=new Set;for(;o.provider==="codex"&&o.parentId;){if(i.has(o.id)){o=r;break}i.add(o.id);const c=n.get(o.parentId);if(!c||c.provider!=="codex")break;o=c}s.set(r.id,o.sessionId)}return s}function ku(e,t){return t&&(e.revision+=1),t}function Uz(e,t,n,s,r){if(e.agents.size<=n)return!1;const o=w=>w.state==="done"&&w.endedAt!=null&&t-w.endedAt>s,i=$f(e.agents.values()),c=new Set([...e.agents.values()].filter(w=>w.provider==="codex"&&!o(w)).map(w=>i.get(w.id))),d=[],h=new Map;for(const[w,j]of e.agents){if(j.parentId!=null){const b=h.get(j.parentId);b?b.push(w):h.set(j.parentId,[w])}o(j)&&!c.has(i.get(w))&&d.push({id:w,endedAt:j.endedAt})}if(d.length===0)return!1;d.sort((w,j)=>w.endedAt-j.endedAt);let f=0;const p=new Set,m=w=>{const j=e.agents.get(w);j&&(DO(e,j),e.agents.delete(w),j.kind==="root"&&WO(e,j.sessionId),p.add(j.sessionId),f++)};for(const w of d){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const j=[],b=new Set([w.id]),k=[...h.get(w.id)??[]];for(;k.length;){const v=k.pop();if(b.has(v))continue;b.add(v);const N=e.agents.get(v);N&&(j.push(N),k.push(...h.get(v)??[]))}if(!j.some(v=>!o(v))){for(const v of j.reverse())m(v.id);m(w.id)}}if(r&&p.size>0){const w=new Set;for(const j of e.agents.values())w.add(j.sessionId);for(const j of p)w.has(j)||r(j)}return ku(e,f>0)}function Wz(e,t,n,s,r){const o=new Map;for(const[m,w]of e.agents){let j=o.get(w.sessionId);j||(j={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,j)),j.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(j.closed=!0),w.state==="done"&&w.endedAt!=null?j.endedAt=Math.max(j.endedAt,w.endedAt):j.live=!0}const i=$f(e.agents.values()),c=new Set([...e.agents.values()].filter(m=>m.state!=="done"||m.endedAt==null).map(m=>i.get(m.id))),d=[...o].filter(([m,w])=>!c.has(i.get(m))&&!w.live&&w.endedAt>0&&t-w.endedAt>s).sort(([,m],[,w])=>m.closed===w.closed?m.endedAt-w.endedAt:m.closed?-1:1);let f=[...o.values()].filter(m=>!m.live).length-n;if(f<=0)return!1;let p=!1;for(const[m,w]of d){if(f<=0)break;for(const b of w.ids){const k=e.agents.get(b);k&&DO(e,k),e.agents.delete(b)}WO(e,m);const j=Yr(m,"");for(const b of e.pendingSubagentModels.keys())b.startsWith(j)&&e.pendingSubagentModels.delete(b);r==null||r(m),f--,p=!0}return ku(e,p)}function Hz(e){let t=!1;for(const n of e.agents.values())for(const s of n.tools)s.endedAt!=null||s.outcomeGap||(s.outcomeGap=!0,t=!0);return ku(e,t)}function zz(e,t,n){let s=!1;for(const r of e.agents.values()){if(r.provider==="codex")continue;const o=e.agents.get(r.sessionId),i=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of r.tools){const d=Math.max(c.startedAt,i??c.startedAt);c.endedAt==null&&t-d>n&&(BO(e,r,c,d,"session ended before this call returned"),s=!0)}}return ku(e,s)}const tE=90*6e4;function Vz(e,t,n){let s=!1;for(const r of e.agents.values()){if(r.kind!=="root")continue;const o=r.lastEventAt??r.startedAt;if(!(t-o<=n)){r.waiting&&(r.waiting=null,s=!0),r.closedAt==null&&(r.closedAt=o),r.state==="active"&&(r.state="done",r.endedAt=o,r.reaped=!0,s=!0);for(const i of e.agents.values())i.sessionId!==r.sessionId||i.kind==="root"||i.state!=="active"||(i.state="done",i.endedAt=o,s=!0);e.activeSubagentStack.delete(r.sessionId)}}return ku(e,s)}function eu(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function HO(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const s=t.payload??{},r=t.receivedAt,o=s.hook_event_name??"Unknown";if(o==="__clear")return{...c1(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};if(e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1,o==="CodexSessionRecovered"||o==="ClaudeSessionRecovered")return yz(e,s,r),e;if(o==="CodexThreadLinked")return wz(e,s,r),e;const i=s.session_id??"unknown";if(Bz(e,o,s,i),o!=="JobObserved"&&pz(e,i,r),f1(e,s,i),Ez(e,o,s,i))return e;switch(o){case"ModelObserved":return NO(e,s,i),e;case"ContextObserved":return SO(e,s,i),e;case"SessionNamed":return _O(e,s,i),e;case"SessionRecapped":return OH(e,s,i),e;case"ActivityObserved":return EO(e,s,i),e;case"JobObserved":return CO(e,s,i),e;case"OutputObserved":return DH(e,s,i,r),e;case"UsageObserved":return p1(e,s,i),e}const c=TH(e,s,r),d=e.agents.get(i);d&&r>=(d.recoveryLiveAt??0)&&(d.recoveryLiveAt=r,d.restoredFromLog=void 0),Cz(e,i),RH(e,o,s,i)&&cz(e,i),c.provider||(c.provider=s.provider==="codex"?"codex":"claude"),c.provider==="codex"&&(c.childCount=[...e.agents.values()].filter(w=>w.parentId===c.id).length);const h=UO(s),f=yl(s),p=f?Yr(i,f):i;h&&c.id===p&&(c.model=h);const m=IH(o,s);switch(m!==void 0&&c.id===p&&(c.effort=m??void 0),o){case"SessionStart":mz(e,s,i,r);break;case"UserPromptSubmit":gz(e,s,i,r);break;case"PreToolUse":hz(e,s,i,c,r);break;case"PostToolUse":case"PostToolUseFailure":fz(e,s,o,i,r);break;case"SubagentStart":Tz(e,s,i,r);break;case"SubagentStop":Rz(e,s,i,r);break;case"Stop":case"SessionEnd":qO(e,o,i,r);break;case"Notification":qz(e,s,i,r);break}return e}const Gz={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},Kz=[{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:.1,cacheWrite:2.5,cacheWrite1h:4}},{match:/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,cacheWrite1h:.2}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:Gz},{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[-_]6[-_.]1[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.1,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]luna\b(?![-_][A-Za-z])/i,rates:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125}},{match:/^gpt[-_]5[-_.]6[-_]cyber\b(?![-_][A-Za-z])/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:15.625}},{match:/^gpt[-_]5[-_.]6[-_]luna\b(?![-_][A-Za-z])/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra\b(?![-_][A-Za-z])/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[-_]chat[-_]latest$/i,rates:{input:1.75,output:14,cacheRead:.175,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}}],Yz=[{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 Xz(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Va(e,t=Date.now(),n=Pa){if(!e)return null;const s=Zz.get(n);if(!s)return null;const r=lr(e);for(const o of s)if(o.match.test(r))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const Pa="standard",Zz=new Map([[Pa,Kz],["fast",Yz]]);function Oc(e,t){return e*t/1e6}function zO(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),r=Math.max(0,e.cacheCreateTokens-n-s),o=s+r,i=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:Oc(o,t.cacheWrite),usd1h:Oc(n,i)}}function VO(e,t,n=Date.now()){if(!Xz(t))return e.inputTokens;const s=Va(t,n),r=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-r)}function If(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of Lf(e)){const o=tu(r.usage,t,r.speed,n);s.input+=o.input,s.output+=o.output,s.cacheRead+=o.cacheRead,s.cacheWrite+=o.cacheWrite,s.total+=o.total}return s}function tu(e,t,n,s=Date.now()){const r=Va(t,s,n);if(!r)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const i of GO(e,t)){const c=i.usage,d=KO(r,i.long);o.input+=Oc(VO(c,t,s),d.input),o.output+=Oc(c.outputTokens,d.output),o.cacheRead+=Oc(c.cacheReadTokens,d.cacheRead);const h=zO(c,d);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function GO(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(lr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:m1(e,[n]),long:!1},{usage:n,long:!0}]}function KO(e,t){return t?{input:e.input*5,output:e.output*5,cacheRead:e.cacheRead*5,cacheWrite:e.cacheWrite*5,...e.cacheWrite1h===void 0?{}:{cacheWrite1h:e.cacheWrite1h*5}}:e}function Lf(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:Pa,usage:e}]:[{speed:Pa,usage:m1(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function m1(e,t){const n=o=>t.reduce((i,c)=>i+(o(c)??0),0),s=o=>Math.max(0,(o(e)??0)-n(o)),r={inputTokens:s(o=>o.inputTokens),outputTokens:s(o=>o.outputTokens),cacheReadTokens:s(o=>o.cacheReadTokens),cacheCreateTokens:s(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(r.cacheCreate1hTokens=s(o=>o.cacheCreate1hTokens),r.cacheCreate5mTokens=s(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(r.reasoningOutputTokens=e.reasoningOutputTokens),e.longContext&&(r.longContext=m1(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),r}const Kr="not priced";function Pc(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function Xe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Pc(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Pc(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Pc(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function g1(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${Xe(s)}/min`:`${Xe(n*3600)}/hr`}function Dk(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.longContext||t.longContext){const s={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0};n.longContext=Dk(e.longContext??s,t.longContext??s)}if(e.bySpeed||t.bySpeed){const s=new Map(Object.entries(e.bySpeed??{}));for(const[r,o]of Object.entries(t.bySpeed??{})){const i=s.get(r);s.set(r,i?Dk(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function Jz(e,t){let n=0,s=0,r=0,o=0,i=0,c=0;for(const p of t)n+=p.inputTokens,s+=p.outputTokens,r+=p.cacheReadTokens,o+=p.cacheCreateTokens,i+=p.cacheCreate1hTokens??0,c+=p.cacheCreate5mTokens??0;const d=(p,m)=>Math.max(0,p-m),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,s),cacheReadTokens:d(e.cacheReadTokens,r),cacheCreateTokens:d(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,i),h.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,c)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function ju(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const s=n.map(o=>({model:o,usage:t[o]})),r=Jz(e.usage,s.map(o=>o.usage));if(r){const o=s.findIndex(i=>i.model===e.model);o>=0?s[o]={model:s[o].model,usage:Dk(s[o].usage,r)}:s.push({model:e.model,usage:r})}return s}function In(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of ju(e)){const r=If(s.usage,s.model,t);n.input+=r.input,n.output+=r.output,n.cacheRead+=r.cacheRead,n.cacheWrite+=r.cacheWrite,n.total+=r.total}return n}function nu(e,t=Date.now()){let n=0;for(const s of ju(e))for(const r of Lf(s.usage))Va(s.model,t,r.speed)==null&&(n+=r.usage.inputTokens+r.usage.outputTokens);return n}function YO(e){const t=[];for(const n of ju(e)){if(!n.model||t.includes(n.model))continue;const s=n.usage;s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreateTokens<=0||t.push(n.model)}return t}function y1(e){return YO(e).filter(t=>t!==e.model)}function nE(e,t){if(!e.bySpeed)return Sg(e,t,Pa);const n=Lf(e).filter(s=>s.speed!==Pa||XO(s.usage));return n.length===1?Sg(n[0].usage,t,n[0].speed):[...n.map(s=>Sg(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${Xe(If(e,t).total)}`].join(`
67
- `)}function XO(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Sg(e,t,n){const s=GO(e,t).filter(r=>XO(r.usage));return e.longContext&&s.some(r=>r.long)?[...s.map(r=>sE(r.usage,t,n,r.long)),`all context tiers = ${Xe(tu(e,t,n).total)}`].join(`
68
- `):sE(e,t,n,!1)}function sE(e,t,n,s){const r=Va(t,Date.now(),n),o=r?KO(r,s):null,i=s?" · prompt >100K":"",c=(n===Pa?`model: ${t}`:`model: ${t} · ${n}`)+i;if(!o)return`${c}
69
- no published rate in this build — the tokens are counted, the dollars are not`;const d=b=>b.toLocaleString(),h=b=>`$${b}/MTok`,f=tu(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=zO(e,o),m=p.tokens1h>0?[`cache w5m${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${Xe(p.usd5m)}`,`cache w1h${d(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${Xe(p.usd1h)}`]:[`cache w ${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${Xe(p.usd5m)}`],w=VO(e,t),j=w===e.inputTokens?"input":"uncached";return[c,`${j.padEnd(9)}${d(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${Xe(f.input)}`,`output ${d(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${Xe(f.output)}`,`cache r ${d(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${Xe(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${Xe(f.total)}`].join(`
70
- `)}function rE(e){const t=ju(e),[n]=t;return t.length<=1?nE(n.usage,n.model):[...t.map(s=>nE(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${Xe(In(e).total)}`].join(`
71
- `)}function Qz(e){if(!e.model)return null;const t=Va(e.model),n=In(e),s=nu(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:rE(e)};if(n.total<=0)return null;const r=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?g1(n.total,r):null,i=rE(e)+(o?`
72
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const e7=new Set(["untrusted","on-request","on-failure"]);function t7(e){return typeof e!="string"||!e?null:e7.has(e)?!0:e==="never"?!1:null}function ZO(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=t7(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."}
73
-
74
- 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 aE(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Da(e){const t=lr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const r=aE(n[1]),o=n[2].replace(/[-_]/g,".");return`${r} ${o}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const r=s[1].replace(/[-_]/g,"."),o=s[2].split(/[-_]/).filter(Boolean).map(aE);return[`GPT-${r}`,...o].join(" ")}return e}function Of(e){const t=lr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Pf(e,t){return t?`${Da(e)} · ${t}`:Da(e)}function su(e,t){return t?`${e}
75
- effort: ${t}`:e}function n7(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function s7(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function r7(e){return{kind:e<1,effort:e<2}}function Mn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function Fk(e){const t=[];for(const n of e)n.kind==="root"&&Mn(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,s)=>n.waiting.since-s.waiting.since)}function a7(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function o7(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Df(e,t){return`${e}@${t.since}`}function JO(e,t){if(!e.tool)return null;const{name:n,preview:s}=e.tool,r=new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(t);return s?r?s:`${n} · ${s}`:r?null:n}function i7(e){const t=e.message||"Needs your permission",n=JO(e,t);return n?`${t}
76
- Likely on: ${n}`:t}function l7(e,t,n,s=!0){if(!s)return[];if(n)return[];const r=[];for(const o of e){if(!Mn(o.waiting))continue;const i=Df(o.id,o.waiting);t.has(i)||r.push({key:i,title:o.label,body:i7(o.waiting),sessionId:o.id})}return r}function c7(e,t,n){const s=new Set;for(const o of e)s.add(Df(o.id,o.waiting));const r=new Set;for(const o of n)s.has(o)&&r.add(o);for(const o of t)r.add(o.key);return r}function eh(e){return new Set(e.map(t=>Df(t.id,t.waiting)))}function u7(e,t){return e!==t}function d7(e,t){return!e&&t!=null}function h7(e,t){return e!==null&&t!=null}function Ff(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function il(e){return e==="active"?"live":e==="done"?"done":"err"}function ll(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function f7(e){return`${e} subagent${e===1?"":"s"} spawned`}function p7(e){const t=[Ff(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=y1(e).length;t.push(`${Da(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function m7(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,r=In(e,t).total;return[e.label,Ff(e),il(e.state),Mn(e.waiting)?ll(e.waiting):null,e.model?Da(e.model):null,(()=>{const o=bu(e.plan);return o?MO(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,r>0?`${Xe(r)}${nu(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function QO(e,t){const n=JO(e,t);return n?`Likely on: ${n}`:null}function zh(e){return e.kind==="idle"?"Your turn":ll(e)}function gt(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Pc(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Pc(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function cl(e,t,n){const s=(t??n)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const r=Math.floor(s/1e3);if(r<60)return`${r}s`;const o=Math.floor(r/60);if(o>=100)return`${Math.floor(o/60)}h ${o%60}m`;const i=r%60;return`${o}m ${String(i).padStart(2,"0")}s`}function e3(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 w1(e,t){const n=typeof e=="string"?e.trim():"",s=typeof t=="string"?t.trim():"";return{face:n||s||void 0,tooltip:s||n||void 0}}const oE=2e5,g7=1e6,y7=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/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],w7=[{match:/^gpt[-_]6[-_]astra/i,window:105e4},{match:/^gpt[-_]6[-_.]1[-_]sol/i,window:105e4},{match:/^gpt[-_]6[-_](?:sol|luna)/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[-_]chat[-_]latest$/i,window:128e3},{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 x7(e){if(!e)return oE;const t=lr(e);for(const n of y7)if(n.test(t))return g7;for(const n of w7)if(n.match.test(t))return n.window;return oE}function t3(e,t){return typeof e=="number"&&e>0?e:x7(t)}const v7=1;function b7(){const e=[];let t=0;function n(){let s;for(const r of e)(!s||r.layer>s.layer||r.layer===s.layer&&r.seq>s.seq)&&(s=r);return s}return{push(s,r=0,o="dialog"){const i={dismiss:s,layer:r,kind:o,seq:t++};return e.push(i),()=>{const c=e.indexOf(i);c!==-1&&e.splice(c,1)}},dismissTop(){const s=n();return s?(s.dismiss(),!0):!1},isTop(s){const r=n();return r!=null&&r.dismiss===s},depth(){return e.length},dialogDepth(){return e.filter(s=>s.kind==="dialog").length}}}const Cn=b7(),n3=e=>e==="Escape";function k7(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function iE(e){return String(e.tagName??"").toUpperCase()==="BODY"}function lE(e,t){return!e||!e.isConnected||iE(e)?!1:t==null||iE(t)}const Vh="a[href], button, input, select, textarea, summary, [tabindex]";function s3(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function j7(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function N7({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 Bf(e){return e.ctrlKey||e.metaKey||e.altKey}function S7(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const _7=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),E7=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),C7=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function x1(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function T7(e){return x1(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function $o(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=x1(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!_7.has(String(e.type??"text").toLowerCase())}function R7(e,t){if(!e)return!1;if($o(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&T7(e))return!1;if(E7.has(x1(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>C7.has(s))}function A7({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function M7({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!$o(n)}function Sh({appModal:e,dialogDepth:t}){return e||t>0}function r3(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Vh))return s3({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.checkVisibility?t.checkVisibility():t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n?(t.checkVisibility?t.checkVisibility():t.getClientRects().length>0)&&j7({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Vh)!=null}):!1}):[]}function $7(e,t){const n=r3(e);if(!t||!e.contains(t)||n.includes(t))return n;const s=n.findIndex(r=>(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return s===-1?[...n,t]:[...n.slice(0,s),t,...n.slice(s)]}function ct(e,t={}){const{focusRef:n,restoreFocusFallback:s,layer:r,popover:o}=t,i=o?"popover":"dialog",c=y.useRef(null),d=y.useRef(e);d.current=e;const h=y.useRef(null);h.current===null&&(h.current=()=>d.current());const f=h.current;return y.useEffect(()=>Cn.push(f,r,i),[f,r,i]),y.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??r3(c.current)[0])==null||m.focus(),()=>{if(lE(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();lE(w,document.activeElement)&&w.focus()}}},[]),y.useEffect(()=>{const p=m=>{var N;if(m.key!=="Tab"||Bf(m))return;const w=c.current;if(!w)return;const j=document.activeElement;if(!(j!=null&&w.contains(j))&&!Cn.isTop(f))return;const k=$7(w,j),v=N7({count:k.length,index:j?k.indexOf(j):-1,shiftKey:m.shiftKey});v.kind!=="allow"&&(m.preventDefault(),v.kind==="focus"&&((N=k[v.index])==null||N.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),c}function xt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const s=t.current&&n.target===n.currentTarget;t.current=!1,s&&e()}}}function I7(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 os(e){return e.toLocaleString()}const L7=60;function O7(e,t=L7){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),s=n.search(/[/\\]/);return"…"+(s===-1?n:n.slice(s))}function P7({agent:e,onClose:t}){var w;const n=y.useRef(null),s=ct(t,{focusRef:n}),r=xt(t),o=e.context,i=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=t3(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=In(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=I7(e.provider);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:j=>j.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:m.subtitle})]}),a.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"ctx-window-row",children:[a.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),a.jsxs("span",{children:[os(c)," / ",os(d)," tok (",m.windowScope,")"]})]})]}),a.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),a.jsxs("div",{className:"ctx-grid",children:[a.jsx(Ts,{label:"input tokens",val:os(i.inputTokens)}),a.jsx(Ts,{label:"output tokens",val:os(i.outputTokens)}),a.jsx(Ts,{label:"cache reads",val:os(i.cacheReadTokens)}),a.jsx(Ts,{label:"cache writes",val:os(i.cacheCreateTokens)}),a.jsx(Ts,{label:"cumulative total",val:os(p)}),a.jsx(Ts,{label:"estimated cost",val:Xe(f.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(Ts,{label:"user messages",val:os((o==null?void 0:o.msgsUser)??0)}),a.jsx(Ts,{label:"assistant messages",val:os((o==null?void 0:o.msgsAssistant)??0)}),a.jsx(Ts,{label:"tool uses",val:os((o==null?void 0:o.toolUses)??0)}),a.jsx(Ts,{label:"tool results",val:os((o==null?void 0:o.toolResults)??0)}),a.jsx(Ts,{label:"system-reminders",val:os((o==null?void 0:o.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((w=o==null?void 0:o.memoryFiles)==null?void 0:w.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(j=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:j.path,children:O7(j.path)}),a.jsx("span",{className:"ctx-md-size",children:qr(j.bytes)})]},j.path))})]})})}function Ts({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 D7({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:r}){const o=t3(n,t),i=Math.min(1,e/o),c=s/2-3,d=s/2,h=2*Math.PI*c,f=h*i,p=i>.9?"var(--err)":i>.7?"var(--warn)":"var(--accent)";return a.jsx("button",{type:"button",className:"ctx-donut",onClick:m=>{m.stopPropagation(),r==null||r()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(i*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(i*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:a.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,"aria-hidden":"true",children:[a.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:c,stroke:p,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),a.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(i*100)})]})})}const cE=new Map;function a3(e){let t=cE.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},cE.set(e,t)),t}function F7(e,t){const n=a3(e);return n.listeners.add(t),n.timer===null&&(n.now=Date.now(),n.timer=setInterval(()=>{n.now=Date.now();for(const s of n.listeners)s()},e)),()=>{n.listeners.delete(t),n.listeners.size===0&&n.timer!==null&&(clearInterval(n.timer),n.timer=null)}}function B7(e){return a3(e).now}const uE=new Map,dE=new Map;function Go(e=1e3){let t=uE.get(e);t||(t=s=>F7(e,s),uE.set(e,t));let n=dE.get(e);return n||(n=()=>B7(e),dE.set(e,n)),y.useSyncExternalStore(t,n,n)}function q7(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 U7="1",hE="agent-dag.schema",W7=["agent-dag.layout","agent-dag.viewport"];function Ve(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function ze(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function hr(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function cr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function H7(e,t=U7){let n=null;try{n=e.getItem(hE)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const r of W7)try{e.getItem(r)!==null&&(e.removeItem(r),s.push(r))}catch{}try{e.setItem(hE,t)}catch{}return s}const o3="agent-dag.recapsDismissed",fE=200;function z7(){const e=Ve(o3);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let ul=new Set(z7());const Bk=new Set;let i3=0;function l3(e){return Bk.add(e),()=>{Bk.delete(e)}}function c3(e){ul=e,i3++;const t=Array.from(e);ze(o3,JSON.stringify(t.length>fE?t.slice(-fE):t));for(const n of Bk)n()}function V7(e,t){return`${e}@${t}`}function G7(e){return ul.has(e)}function K7(e){if(ul.has(e))return;const t=new Set(ul);t.add(e),c3(t)}function Y7(e){const t=new Set(ul);t.delete(e)||t.add(e),c3(t)}function X7(e){return y.useSyncExternalStore(l3,()=>e!=null&&ul.has(e),()=>!1)}function v1(e){return`recap:${e}`}function Z7(e){return e.startsWith("recap:")}function J7(){return y.useSyncExternalStore(l3,()=>i3,()=>0)}function Oa(e){switch(e){case"recap":return"recap";case"needs":return"needs you";case"done":return"done";case"failed":return"failed";case"last":return"last";default:return"now"}}function Q7(e){let t,n;switch(e.state){case"blocked":t="needs",n=e.needs||e.detail;break;case"done":t="done",n=e.result||e.detail;break;case"failed":t="failed",n=e.detail||e.result||"";break;case"working":t="now",n=e.detail;break;default:return null}if(!n)return null;const s={kind:t,text:n,at:e.updatedAt,source:"job"};return t==="needs"&&e.suggestedReply&&(s.reply=e.suggestedReply),s}function e9(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const pE=160;function t9(e){const t=Mf(e);if(t)return t.detail?`${t.label}: ${t.detail}`:t.label;const s=(e.split(`
77
- `).map(r=>r.trim()).find(Boolean)??"").replace(/\s+/g," ");return s.length>pE?s.slice(0,pE-1).trimEnd()+"…":s}function n9(e){const t=e9(e),n=(t==null?void 0:t.at)??e.startedAt,s=i=>({...i,key:`${e.sessionId}@${i.kind==="last"?"now":i.kind}:${n}`}),r=e.job?Q7(e.job):null;if(r)return s(r);const o=e.activity;if(o&&(!t||t.at<=o.at))return s({kind:e.state==="active"?"now":"last",text:o.text,at:o.at,source:"activity"});if(t&&e.state==="active"){const i=t9(t.text);if(i){const c={kind:"now",text:i,at:t.at,source:"prompt"};return e.provider==="codex"&&(c.codex=!0),s(c)}}return null}function qf(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=n9(e),n=q7(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:V7(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function Uf(e){switch(e.source){case"recap":return"Claude Code's recap";case"job":return"Claude Code's own line for this background session";case"prompt":return e.codex?"The prompt this turn began with — the deck takes no line from a Codex reply":"The prompt this turn began with — the model has not answered yet";default:return e.kind==="last"?"What the session did last, until Claude Code's recap":"From the session's newest reply"}}function s9(e){const t=new Map,n=[...e],s=$f(n);for(const r of n){if(r.kind!=="subagent"&&!(r.provider==="codex"&&r.parentId)||r.exitAt!=null)continue;const o=s.get(r.id)??r.sessionId;if(r.provider==="codex"&&o===r.sessionId)continue;let i=t.get(o);i||(i={total:0,live:0,done:0,err:0,failed:0},t.set(o,i)),i.total+=1,r.state==="active"?i.live+=1:r.state==="err"?i.err+=1:i.done+=1,i.failed+=r.toolErrorCount??0}return t}function u3(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 d3(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function r9(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&Mn(s))return{tone:"warn",long:n.sayWaiting(s),short:s.kind==="permission"?"Needs you":"Asked you"};if(s&&s.kind==="idle"){const o=n.sayWaiting(s);return{tone:"idle",long:o,short:o}}const r=e.toolErrorCount??0;if(r>0)return{tone:"err",long:`${r} tool ${r===1?"call":"calls"} failed`,short:`${r} failed`};if(t&&t.total>0)return{tone:"muted",long:u3(t),short:d3(t)};if(e.state==="active"){const o=bu(e.plan);if(o&&o.current&&!o.allDone)return{tone:"muted",long:oz(o),short:`${o.done}/${o.total} done`}}if(e.state==="active")for(let o=e.tools.length-1;o>=0;o--){const i=e.tools[o];if(i.endedAt!=null)continue;const{name:c,subject:d}=n.describeCall(i);return{tone:"muted",long:d?`${c} · ${d}`:c,short:c}}return null}function a9(e,t){return t?t.includes(e)?t:`${e}
78
- ${t}`:e}function qk(e){return e==="active"?"live":e==="done"?"done":"err"}const Wf={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"}},o9=Object.fromEntries(Object.entries(Wf).map(([e,t])=>[e,t.category])),i9=Object.fromEntries(Object.entries(Wf).map(([e,t])=>[e,t.emoji])),l9=Object.fromEntries(Object.entries(Wf).map(([e,t])=>[e,t.label])),c9=new Set(Object.entries(Wf).filter(([,e])=>e.shell).map(([e])=>e)),u9={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",...o9};function h3(e){return e.startsWith("mcp__")?"mcp":Vt(u9,e)??"other"}const d9=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,h9=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function f9(e){if(typeof e!="string"||!e)return null;const t=d9.exec(e);if(t){const s=p9(t[2]);if(s.trim())return s}const n=h9.exec(e);return n?n[1]:null}function p9(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
79
- `:n==="r"?"\r":n==="t"?" ":n)}const m9={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:"📡",...i9};function mE(e){return e.startsWith("mcp__")?"🔌":Vt(m9,e)??"✨"}const g9={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 f3(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function p3(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=>f3(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return p3(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 s=t.match(/^([^\s|;&<>(]+)/);if(!s)return null;let r=s[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(r.replace(/^.*[/\\]/,""))?(r=r.replace(/^.*[/\\]/,""),r=r.replace(/\.(exe|cmd|bat|ps1)$/i,""),r||null):null}function y9(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=f9(t.script);if(n)return n}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(n=>typeof n=="string")){const n=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(n[0]??"")){const s=n.findIndex(f3);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const w9=new Set(["Bash","PowerShell",...c9]);function x9(e,t){if(!w9.has(e))return null;const n=y9(t);if(!n)return null;const s=p3(n);return s?{emoji:Vt(g9,s)??"⚙️",label:s,category:"shell",detail:n}:null}const v9=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),b9={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:"🗄️"},k9={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 j9(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function N9(e){const t=e.toLowerCase(),n=Vt(k9,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const s=t.lastIndexOf(".");if(s>0&&s<t.length-1){const r=Vt(b9,t.slice(s+1));if(r!==void 0)return r}return"📄"}function S9(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const s=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof n.file_path=="string"?n.file_path:typeof n.notebook_path=="string"?n.notebook_path:typeof n.path=="string"?n.path:e==="Glob"&&typeof n.pattern=="string"?n.pattern:null}function _9(e,t){if(!v9.has(e))return null;const n=S9(e,t);if(!n)return null;const s=j9(n);return s?{emoji:e==="LS"?"📂":N9(s),label:s,category:"file",detail:n}:null}const E9={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 b1(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 C9(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 m3(e){return Vt(E9,e.toLowerCase())}function T9(e,t){const n=b1(e);if(!n)return null;const{server:s,method:r}=n;if(!r)return null;const o=m3(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:r,category:"mcp",detail:o?`${o.name} · ${r}`:`${s} · ${r}`}}function g3(e,t){return x9(e,t)??_9(e,t)??T9(e)}function R9(e,t){var n;return((n=g3(e,t))==null?void 0:n.label)??null}const A9=l9,gE=18;function th(e){const t=[...e];return t.length<=gE?e:t.slice(0,gE-1).join("")+"…"}const _g=13,M9=6;function $9(e,t){const n=[...e];if(n.length<=_g)return e;const s=n.lastIndexOf("."),r=s>0?n.slice(s):[];return t==="file"&&r.length>1&&r.length<=M9?n.slice(0,_g-1-r.length).join("")+"…"+r.join(""):n.slice(0,_g-1).join("")+"…"}function k1(e){const t=b1(e);if(t){const s=m3(t.server);return s?{emoji:s.emoji,label:th(s.name)}:{emoji:"🔌",label:th(t.server),hue:C9(t.server)}}const n=Vt(A9,e)??"";return n?{emoji:mE(e),label:th(n)}:{emoji:mE(e),label:th(e)}}function I9(e){let t=null,n="";for(const s of e){const r=b1(s);if(r){if(!r.server)return null;if(t===null)t=r.server,n=s;else if(r.server!==t)return null}}return t===null?null:k1(n)}const Uk=6e4,Ji=24,yE=Uk/Ji,Eg=132,_h=14;function L9(e,t,n){const s=new Array(Ji).fill(0);let r=0;const o=m=>{const w=n-m;if(w<0||w>=Uk)return;const j=Ji-1-Math.floor(w/yE);j>=0&&j<Ji&&(s[j]+=1,r+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const c=Math.max(0,...s)/(yE/1e3),d=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<Uk).length,h=r-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=r===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:s,title:p}}const O9=2;function P9(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/O9)*_h)}function y3({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 j1(){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 w3(){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 Gh({recap:e}){return e?a.jsx(w3,{}):a.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:a.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}const wE=typeof window>"u"?y.useEffect:y.useLayoutEffect;function D9({data:e}){var L,U;const t=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),n=e.tools.filter(O=>!O.endedAt).length,s=e.toolErrorCount??0,r=eu(e.canvasSessionId??e.sessionId),o=((L=e.context)==null?void 0:L.currentContextTokens)??0,i=e.kind==="root"&&o>0,c=e.sessionTitle?e.cwd?`${e.cwd}
80
- ${e.sessionTitle}`:e.sessionTitle:e.cwd,d=y1(e),h=y.useRef(null),f=y.useRef(null),p=n7(e),[m,w]=y.useState(0),[j,b]=y.useState(null);wE(()=>{w(0)},[e.effort,e.model,d.length,e.cwdBasename,e.childCount,e.kind,p,j]),wE(()=>{const O=h.current;if(!O||m>=p)return;const M=f.current,q=s7(m,{overflowing:O.scrollWidth>O.clientWidth,folderCut:!!M&&M.scrollWidth>M.clientWidth,max:p});q!==m&&w(q)}),y.useEffect(()=>{const O=h.current;if(!O||typeof ResizeObserver>"u")return;let M=O.clientWidth;const q=new ResizeObserver(()=>{O.clientWidth!==M&&(M=O.clientWidth,wt.flushSync(()=>b(M)))});return q.observe(O),()=>q.disconnect()},[]);const k=r7(m),v=e.model&&(d.length>0?`${su(e.model,e.effort)}
81
- spend on this card also covers:
82
- ${d.join(`
83
- `)}`:su(e.model,e.effort)),N=w1(e.sessionName,e.sessionTitle),S=qf(e),E=S?S.key:null,C=X7(E),I=S!=null&&!C,R=(S==null?void 0:S.kind)==="recap",$=Qz(e);return a.jsxs("div",{className:t,style:{"--session-hue":r},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(Bo,{type:"target",position:Oe.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(W9,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.restoredFromLog&&a.jsx("span",{className:"synth-tag",title:e.provider==="claude"?"Restored from Claude’s busy-session registry after verifying the process identity. Earlier tool history is partial.":"Restored from a log with no recorded ending. Process status is not confirmed.",children:"restored"}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),S&&E&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":R?"Claude Code's recap":`Session note: ${Oa(S.kind)}`,"aria-expanded":I,title:R?I?"Hide the recap":"Show Claude Code's recap":I?"Hide this note":"Show what this session is doing",onClick:O=>{O.stopPropagation(),Y7(E)},children:a.jsx(Gh,{recap:R})})]}),a.jsx("div",{className:"head-right",children:i&&e.onOpenContext&&a.jsx(D7,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),a.jsxs("div",{className:"sub",title:p7(e),children:[a.jsxs("span",{className:"sub-details",ref:h,children:[k.kind&&a.jsx("span",{children:Ff(e)}),e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:f7(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&a.jsxs("span",{className:"sub-folder",ref:f,children:[k.kind?"· ":"",e.cwdBasename]}),e.model?a.jsxs("span",{className:"model-chip","data-family":Of(e.model),title:v,children:[Pf(e.model,k.effort?e.effort:void 0),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),a.jsxs("span",{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(U9,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&N.face&&a.jsx("div",{className:"session-name",title:N.tooltip,children:N.face}),e.waiting&&a.jsx(H9,{waiting:e.waiting}),(()=>{const O=ZO(e);return O?a.jsxs("div",{className:"approval-blind-row",title:O.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:O.label})]}):null})(),(()=>{const O=bu(e.plan);return O&&e.plan?a.jsx(B9,{plan:O,items:e.plan.items}):null})(),(e.tools.length>0||(((U=e.outputs)==null?void 0:U.length)??0)>0)&&a.jsx(z9,{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"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:gt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),($==null?void 0:$.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:$.tt,children:Kr}),($==null?void 0:$.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:$.tt,children:a.jsxs("b",{children:[Xe($.total),$.floor?"+":""]})})]}),a.jsx(q9,{data:e,title:e.kind==="root"?N.face:void 0}),a.jsx(Bo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}const F9=y.memo(D9);function B9({plan:e,items:t}){return a.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:$O(t),children:[a.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),a.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),a.jsx("span",{className:"plan-step",children:e.allDone||!e.current?"done":a.jsxs(a.Fragment,{children:[e.next&&a.jsx("span",{className:"plan-next",children:"next: "}),e.current]})})]})}function q9({data:e,title:t}){const n=e.kind==="root"&&Mn(e.waiting),s=r9(e,e.branch,{sayWaiting:zh,describeCall:r=>({name:k1(r.name).label,subject:R9(r.name,r.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":s?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(y3,{kind:qk(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),s&&a.jsx("span",{className:"lod-inline","data-tone":s.tone,children:s.short}),n&&a.jsx(j1,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),s&&a.jsxs("div",{className:"lod-signal","data-tone":s.tone,children:[a.jsx("span",{className:"lod-long",children:s.long}),a.jsx("span",{className:"lod-short",children:s.short})]})]})}function U9({start:e,end:t}){const n=Go(1e3);return a.jsx(a.Fragment,{children:cl(e,t,n)})}function W9({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:il(e)})}function H9({waiting:e}){const t=Go(1e3),n=Mn(e),s=ll(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
84
- Blocked for ${cl(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:zh(e)}),a.jsx("b",{children:cl(e.since,void 0,t)})]})}function z9({tools:e,outputs:t}){const n=Go(1e3),{counts:s,title:r}=L9(e,t,n),o=Eg/Ji;return a.jsxs("div",{className:"tool-spark-row",title:r,children:[a.jsx("svg",{className:"tool-spark",width:Eg,height:_h,viewBox:`0 0 ${Eg} ${_h}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=P9(i),h=c===Ji-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:_h-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function V9({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"})]})}const N1="agent-dag.single-key-shortcuts";function x3(e){return e!=="0"}function v3(e){return e.length===1}function b3(e,t){return!t&&v3(e)}function gn(e,t,n){return n?`${e} (${t})`:e}let Io=null;const Cc=new Set;function k3(){for(const e of Cc)e()}function Wk(){return Io===null&&(Io=x3(Ve(N1))),Io}function G9(e){Io!==e&&(Io=e,ze(N1,e?"1":"0"),k3())}function xE(e){if(e.key!==N1)return;const t=x3(e.newValue);t!==Io&&(Io=t,k3())}function K9(e){var t;return Cc.add(e),Cc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",xE)),()=>{var n;Cc.delete(e),Cc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",xE))}}function Kh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const vE=99;function Y9(e){const t=Math.max(0,Math.floor(e));return t>vE?`${vE}+`:String(t)}const X9="Pause the canvas";function Z9(e){const t=e.singleKeys??!0;if(!e.paused)return gn("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?gn(`The pause is full — ${Kh(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?gn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):gn(`${Kh(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function J9(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 j3="paused · full",Q9=(e,t)=>t>0?j3:e>0?`paused · ${Y9(e)}`:"paused";function eV(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:Q9(e.held,t),widest:j3,title:gn(t>0?`Connected — the pause is full at ${Kh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${Kh(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function Ln(){return y.useSyncExternalStore(K9,Wk,Wk)}const tV=e=>e.transform[2]>=e.maxZoom,nV=e=>e.transform[2]<=e.minZoom;function sV({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:r,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=ml(),h=tt(tV),f=tt(nV),p=Ln();return a.jsxs(mH,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(is,{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(is,{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(is,{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(is,{"data-group-start":"",onClick:r,title:Z9({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":X9,"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(is,{onClick:o,title:gn("Auto-arrange — clear pins","R",p),"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(is,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:gn("Clear the canvas and the server's event log — asks first","C",p),"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(is,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?gn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","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 rV="modulepreload",aV=function(e){return"/"+e},bE={},Nu=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=i(n.map(h=>{if(h=aV(h),h in bE)return;bE[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":rV,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,j)=>{m.addEventListener("load",w),m.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return r.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},kE="agent-dag.fm-custom-stations",jE="agent-dag.fm-muted",Hk="custom:",oV=/^UC[A-Za-z0-9_-]{22}$/,iV=/^[A-Za-z0-9_-]{11}$/,N3=/^[A-Za-z0-9_-]{1,80}$/,lV=/\.(mp3|aac|ogg)$/i,cV=/\.m3u8$/i,uV=2048,S3=80;function dl(e){return`${Hk}${e}`}function Hf(e){if(!e.startsWith(Hk))return null;const t=e.slice(Hk.length);return N3.test(t)?t:null}function NE(e){return Hf(e)??e}function S1(e){var i,c;const t=e.trim();if(t.length>uV)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const s=n.toString(),r=n.hostname.toLowerCase();if(r==="youtube.com"||r==="www.youtube.com"||r==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&oV.test(d))return{kind:"youtube-channel",url:s,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:s,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(iV.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return cV.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:lV.test(n.pathname)?{kind:"direct-audio",url:s,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:s,format:"audio"}}function dV(e){return e==="1"}function hV(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,s=[];for(const r of t){if(!r||typeof r!="object")continue;const o=typeof r.id=="string"?r.id:"",i=typeof r.name=="string"?r.name.trim():"",c=typeof r.url=="string"?r.url.trim():"",d=S1(c);if(!N3.test(o)||n.has(o)||!i||i.length>S3||!d)continue;n.add(o);const h=_3(r.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function fV(e,t,n){const s=Hf(e??"");return s&&t.some(r=>r.id===s)?dl(s):n(e)}function pV(e,t){return e===dl(t)?"claude-fm":e}function _3(e){if(!e||typeof e!="object")return null;const t=e,n=(r,o)=>typeof t[r]=="string"?t[r].slice(0,o):"",s=(r,o)=>typeof t[r]=="number"&&Number.isFinite(t[r])&&Math.abs(t[r])<=o?t[r]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:s("lat",90),lon:s("lon",180)}}const zk="https://www.youtube-nocookie.com";function mV(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${zk}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Mi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function gV(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const yV=[1],wV=[0,2],xV=[2,5,100,101,150,153];function vV(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:s}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const r=typeof s=="number"?s:Number(s==null?void 0:s.errorCode);return Number.isFinite(r)?{kind:"error",code:r}:null}if(n==="onStateChange"||n==="infoDelivery"){const r=typeof s=="number"?s:s==null?void 0:s.playerState;return typeof r!="number"||!Number.isFinite(r)?null:yV.includes(r)?{kind:"playing",playing:!0}:r===3?{kind:"buffering"}:wV.includes(r)?{kind:"playing",playing:!1}:null}return null}const wc=new Set;let SE="";function _E(e){const t=new Date().toISOString().slice(0,10);if(t!==SE&&(wc.clear(),SE=t),!wc.has(e)){wc.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&wc.delete(e)}catch{wc.delete(e)}}}const EE=864e5,bV=6e4;function nn(e,t=!0){y.useEffect(()=>{if(!t)return;_E(e);let n;const s=()=>{n=setTimeout(()=>{_E(e),s()},EE-Date.now()%EE+bV)};return s(),()=>clearTimeout(n)},[e,t])}const kV={"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 jV({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:r,playRequest:o,customStation:i,onAvailabilityChange:c}){var q;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[j,b]=y.useState(!1),[k,v]=y.useState(!1);nn("claude-fm",j);const N=y.useRef(o),S=y.useRef(null),E=y.useRef(null),C=y.useRef(void 0),I=y.useRef(null),R=y.useCallback(()=>{var D;clearTimeout(C.current),(D=E.current)==null||D.destroy(),E.current=null;const A=S.current;A&&(A.pause(),A.removeAttribute("src"),A.load(),S.current=null)},[]),$=y.useCallback(A=>{var D,P;(P=(D=I.current)==null?void 0:D.contentWindow)==null||P.postMessage(A,zk)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(s);U.current=s;const O=y.useCallback((A,D,P)=>{R();const K=new Audio;K.preload="none",K.volume=L.current/100,K.muted=U.current,S.current=K,w(!0),b(!1),v(!1);let G=!1;const W=()=>S.current===K,H=()=>{clearTimeout(C.current),R(),w(!1),b(!1),v(!1)},F=()=>{W()&&(H(),p(!0),c==null||c(P,!0))},B=V=>{if(W()&&!(V instanceof DOMException&&V.name==="AbortError")){if(V instanceof DOMException&&V.name==="NotAllowedError"){H();return}F()}};C.current=setTimeout(()=>{W()&&!G&&F()},15e3),K.addEventListener("playing",()=>{W()&&(clearTimeout(C.current),G=!0,b(!0),v(!1),c==null||c(P,!1))});const Z=()=>{W()&&(b(!1),v(G),clearTimeout(C.current),C.current=setTimeout(()=>{W()&&F()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{W()&&H()}),K.addEventListener("error",F,{once:!0}),D&&!K.canPlayType("application/vnd.apple.mpegurl")?Nu(async()=>{const{default:V}=await import("./hls-BFpXDghs.js");return{default:V}},[]).then(({default:V})=>{if(!W())return;if(!V.isSupported()){F();return}const X=new V;E.current=X,X.on(V.Events.ERROR,(Y,J)=>{J.fatal&&F()}),X.on(V.Events.MEDIA_ATTACHED,()=>X.loadSource(A)),X.on(V.Events.MANIFEST_PARSED,()=>{K.play().catch(B)}),X.attachMedia(K)},F):(K.src=A,K.play().catch(B))},[c,R]);y.useEffect(()=>{m&&($(Mi("setVolume",[n])),$(Mi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,$]),y.useEffect(()=>{var H;let A=!0;const D=e??fetch,P=N.current!==o;if(N.current=o,h(null),p(!1),v(!1),w(P),b(!1),R(),!t){w(!1),b(!1);return}const K=i&&dl(i.id)===r?S1(i.url):null;if(K){if(K.kind==="direct-audio"){const F=K.format==="hls"||((H=i==null?void 0:i.radio)==null?void 0:H.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:F}),c==null||c(r,!1),P&&O(K.url,F,r),()=>{A=!1}}return D(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.channel||F!=null&&F.video?(h({live:!0,channel:F.channel??"",video:F.video??void 0}),c==null||c(r,!1)):(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),v(!1),c==null||c(r,!0))}),()=>{A=!1}}if(Hf(r))return p(!0),c==null||c(r,!0),()=>{A=!1};const G=r,W=kV[G];if(W)D(W).then(F=>F.ok?F.json():null).then(F=>{A&&(F!=null&&F.video&&h({live:!0,channel:"",video:F.video}),F!=null&&F.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(F!=null&&F.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});else if(G!=="claude-fm"){const F=G.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent(F)}`).then(B=>B.ok?B.json():null).then(B=>{A&&(B!=null&&B.video&&h({live:!0,channel:"",video:B.video}),B!=null&&B.video||(p(!0),w(!1),b(!1)),c==null||c(r,!(B!=null&&B.video)))}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))})}else D("/api/claude-fm").then(F=>F.ok?F.json():null).then(F=>{if(!A)return;const B=!!(F!=null&&F.live&&(F!=null&&F.channel));B&&h({live:!0,channel:F.channel}),B||(p(!0),w(!1),b(!1)),c==null||c(r,!B)}).catch(()=>{A&&(p(!0),w(!1),b(!1),c==null||c(r,!0))});return()=>{A=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(q=i==null?void 0:i.radio)==null?void 0:q.hls,t,e,c,o,r,O,R]),y.useEffect(()=>()=>R(),[R]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let A;const D=()=>{clearTimeout(A),A=void 0,w(!1),b(!1),v(!1),p(!0),c==null||c(r,!0)},P=()=>{A??(A=setTimeout(D,15e3))};P();const K=G=>{var H;if(G.origin!==zk||G.source!==((H=I.current)==null?void 0:H.contentWindow))return;const W=vV(G.data);if(W){if(W.kind==="ready"){$(Mi("setVolume",[L.current])),$(Mi(U.current?"mute":"unMute")),$(Mi("playVideo"));return}if(W.kind==="blocked"){clearTimeout(A),A=void 0,w(!1),b(!1),v(!1);return}if(W.kind==="buffering"){b(!1),v(!0),P();return}if(W.kind==="playing"){clearTimeout(A),A=void 0,b(W.playing),v(!1),W.playing||w(!1);return}xV.includes(W.code)&&D()}};return window.addEventListener("message",K),()=>{clearTimeout(A),window.removeEventListener("message",K)}},[m,d==null?void 0:d.audio,o,c,$,r]);const M=y.useCallback(()=>{if(d){if(d.audio){if(m){R(),w(!1),b(!1),v(!1);return}O(d.audio,d.hls===!0,r);return}if(!m){w(!0),b(!1),v(!1);return}$(Mi("pauseVideo")),w(!1),b(!1),v(!1)}},[d,m,j,r,$,O,R]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:j,buffering:k,frame:I,say:$,press:M}),[d,f,m,j,k,$,M])}const CE="agent-dag.radio-favorites",TE="agent-dag.radio-recent",RE="agent-dag.radio-catalogue";function NV(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const s=n,r=typeof s.id=="string"?s.id:"",o=typeof s.name=="string"?s.name.trim().slice(0,80):"",i=typeof s.url=="string"?S1(s.url):null,c=_3(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(r)||!o||!c||!i||i.kind!=="direct-audio"||t.has(r)?[]:(t.add(r),[{id:r,name:o,url:i.url,radio:c}])})}function AE(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function SV(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Cwe(e,t,n=Math.random){const s=e.filter(r=>r.id!==t);return s.length?s[Math.min(s.length-1,Math.floor(Math.max(0,n())*s.length))]:null}function Twe(e,t,n){if(!e.length)return null;const s=e.findIndex(o=>o.id===t),r=e[s<0?n===1?0:e.length-1:(s+n+e.length)%e.length];return r.id===t?null:r}function E3(e,t,n){const s=e.findIndex(r=>r.id===t);for(let r=1;r<=e.length;r++){const o=e[(s+r)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Rwe(e,t){if(!e.length)return null;const n=[...e].sort((r,o)=>r.id.localeCompare(o.id));let s=0;for(const r of t)s=Math.imul(s,31)+r.charCodeAt(0)>>>0;return n[s%n.length]}function Awe(e,t,n,s,r){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!s||e.radio.tags.toLowerCase().includes(s.toLowerCase()))&&(!r||e.radio.language.toLowerCase().includes(r.toLowerCase()))}function _V(){const[e,t]=y.useState(()=>AE(Ve(CE))),[n,s]=y.useState(()=>AE(Ve(TE))),[r,o]=y.useState(()=>{try{return NV(JSON.parse(Ve(RE)??"[]"))}catch{return[]}});y.useEffect(()=>{ze(CE,JSON.stringify(e))},[e]),y.useEffect(()=>{ze(TE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>SV(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),ze(RE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:r,remember:i,toggleFavorite:c,updateCatalogue:d}}function EV(e,t,n,s){const r=E3(e,t,n);if(!r)return()=>{};const o=setTimeout(()=>{n.add(t),s(r)},1e3);return()=>clearTimeout(o)}const zf=148,ME=6e3,CV=16e3,C3=46,$a=34;function TV(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return{to:s,ms:Math.round(Math.abs(s-e)*C3)}}function RV(e){return Math.round(ME+e()*(CV-ME))}const $E=[{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 AV(e){const t=$E.reduce((s,r)=>s+r.weight,0);let n=e()*t;for(const s of $E)if(n-=s.weight,n<0)return s.kind;return"stroll"}const MV=720,$V=260,IV=620,LV=220,IE=520,T3=1600,LE=7e3,OV=15e3,OE=6e3,PV=14e3;function $i(e,t,n=zf){let s=-Math.round(t()*n);if(Math.abs(s-e)<$a){const r=e-$a>=-n?-$a:$a;s=Math.max(-n,Math.min(0,Math.round(e+r)))}return s}const Gt=(e,t)=>Math.round(Math.abs(t-e)*C3),DV=120,nh=0;function FV(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Gt(e,t)},{x:t,prop:n({}),act:"stoop",ms:MV},{x:nh,prop:n({held:!0}),act:"carry",ms:Gt(t,nh)},{x:nh,prop:n({held:!0}),act:"windup",ms:$V},{x:nh,prop:n({held:!0,leaving:!0}),act:"toss",ms:IV}]}function BV(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),r=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:r(),act:"walk",ms:Gt(e,s)},{x:s,prop:r(),act:"windup",ms:LV,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"kick",ms:IE,facing:n>0?"right":"left"},{x:s,prop:r({leaving:!0}),act:"stand",ms:T3-IE}]}const R3=640;function qV(e,t,n){const s=Math.max(-70,Math.min(-20,t)),r={x:s,prop:null,facing:"left"};return[{x:s,prop:null,act:"walk",ms:Gt(e,s)},{...r,act:"sit",ms:600},{...r,act:"cast",ms:900},{...r,act:"fish",ms:6e3+Math.round(n()*4e3)},{...r,act:"reel",ms:1200},{...r,act:"stow",ms:500},{...r,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function UV(e,t,n){const s=Math.max(-110,Math.min(-30,t)),r={x:s,prop:null};return[{...r,act:"walk",ms:Gt(e,s)},{...r,act:"skip-ready",ms:500},{...r,act:"skip",ms:R3*(6+Math.floor(n()*5))},{...r,act:"skip-rest",ms:600},{...r,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Gt(s,0)}]}function WV(e,t,n){return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(OE+n()*(PV-OE))},{x:t,prop:null,act:"stand",ms:400}]}function HV(e,t,n){t=Math.max(-110,Math.min(0,t));const s=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Gt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(LE+n()*(OV-LE))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Cg(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 zV=1500,VV=e=>Math.round(1e3*Math.sqrt(2*e/zV)),GV=115,KV=e=>Math.round(e/GV*1e3),YV=620,XV=200,ZV=760,JV=600,QV=240;function eG(e,t,n){const r=-(t.ledgeSpan??zf),o=VV(t.ledgeH),i=KV(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:r,act:"walk",prop:null,ms:Gt(e,r)},{x:r,act:"peer",prop:null,ms:YV},{x:r,act:"fall",prop:null,ms:o,place:"floor"},{x:r,act:"land",prop:null,ms:XV,place:"floor"},{x:h,act:"walk",prop:null,ms:Gt(r,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Gt(h,f),place:"floor",floorFrac:d},{x:r,act:"walk",prop:null,ms:Gt(f,r),place:"floor"},{x:r,act:"lasso",prop:null,ms:ZV,place:"floor"},{x:r,act:"rope-throw",prop:null,ms:JV,place:"floor"},{x:r,act:"rope-catch",prop:null,ms:QV,place:"floor"},{x:r,act:"climb",prop:null,ms:i},{x:r,act:"pull-up",prop:null,ms:480}]}function tG(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??zf;switch(AV(t)){case"tidy":return FV(e,$i(e,t,s));case"kick":return BV(e,$i(e,t,s));case"sit":return WV(e,$i(e,t,s),t);case"watch":return HV(e,$i(e,t,s),t);case"fish":return qV(e,$i(e,t,s),t);case"skip":return UV(e,$i(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return eG(e,n,t)}}const o=TV(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const nG=420;function sG(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(nG,Math.max(0,s))}const rG=260,aG=200;function oG(e,t,n){const s=(f,p=Gt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[s(t)];const r=Math.min(e,t);if(Math.max(e,t)<=n.left||r>=n.right)return[s(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[s(c,Gt(e,c)),{...h,x:c,act:"mount",ms:rG},{...h,x:d,act:"walk",ms:Gt(c,d)},{x:d,prop:null,act:"dismount",ms:aG,place:"floor"},{x:t,prop:null,act:"walk",ms:Gt(d,t),place:"floor"}]}const A3=["bob","sway","groove"],PE=9e3,iG=16e3,M3=1e3,lG=.08;function cG(e,t){const n=A3.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],r=(t()*2-1)*lG;return{dance:s,beatMs:Math.round(M3*(1+r))}}function uG(e){return Math.round(PE+e()*(iG-PE))}const _1=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],DE=18,dG=_1.length,$3="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",I3="M12 9H14V6H13V3H11V2H9V4H12Z",E1=new Set(["a","c","p"]);function Ga(e=_1){const t=[];return e.forEach((n,s)=>{let r=0;for(;r<n.length;){const o=n[r];if(o==="."){r+=1;continue}let i=1;for(;r+i<n.length&&n[r+i]===o;)i+=1;t.push({x:r,y:s,w:i,cell:o}),r+=i}}),t}const hG=[".xx.","xxxx",".xx."],fG=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],pG=["...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."],Tg={litter:hG,ball:fG,scope:pG},mG=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],gG=3,yG=-1,Vk=11,FE=9;function BE(e){let t=null,n=null,s=0,r=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(r=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},s))},d=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-r)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,s=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function wG(e,t,n){const[s,r]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,m]=y.useState({x:0,drop:0}),[w,j]=y.useState("ledge"),[b,k]=y.useState("left"),[v,N]=y.useState(0),S=y.useRef(null),[E,C]=y.useState(()=>document.hidden);y.useEffect(()=>{const M=new Set,q=()=>{var A;if(document.hidden){for(const D of((A=S.current)==null?void 0:A.getAnimations({subtree:!0}))??[])if(D.playState==="running"||D.pending){const P=D.currentTime;D.pause(),P!==null&&(D.currentTime=P),M.add(D)}}else{for(const D of M)D.playState==="paused"&&D.play();M.clear()}C(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[I,R]=y.useState(null),[$,L]=y.useState(M3),[U,O]=y.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var A;const M=(A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const q=()=>O(M.matches);return q(),M.addEventListener("change",q),()=>M.removeEventListener("change",q)},[]),y.useEffect(()=>{var J;if(!e||t||U)return;const M=BE(document);let q=0;r(ee=>q=ee);let A=null,D=0,P=0;const K=ee=>{var re,pe;const[ne,...le]=ee;if(!ne){A=null,d(null),f(null),V();return}d(ne.act),f(ne.prop),j(ne.place??"ledge"),N(ne.riser??0);const de=q,ue=B(ne);if(ne.act==="kick"){const ye=(pe=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:pe.getBoundingClientRect();ye&&m({x:sG(ye.x,Cg(ne,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ye.y+24)})}P=ne.act==="walk"?Math.max(Gt(de,ue),DV):ne.ms,ne.act==="carry"&&(P=Gt(de,ue)),i(P),k(ye=>Cg({...ne,x:ue},de,ye)),r(ue),q=ue,A=ne,D=Date.now(),M.schedule(()=>K(le),P)},G=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),le=ee==null?void 0:ee.parentElement;if(!ee||!ne||!le)return null;const de=ee.getBoundingClientRect(),ue=le.getBoundingClientRect(),re=ue.right-de.right,pe=ue.width-re*2-ne.offsetWidth;return pe>0?pe:null},W=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},H=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),le=G();if(!ee||!ne||le==null)return;const de=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:le,ledgeSpan:W()}},F=()=>{const ee=S.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const le=ee.getBoundingClientRect(),de=ne.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-le.right,right:de.right-le.right,height:de.height}},B=ee=>{const ne=(ee.place??"ledge")==="floor",le=ne?G()??W():W(),de=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*le):ee.x;return Math.max(-le,Math.min(0,de))},Z=()=>{if(!A)return;const ee=B(A);ee!==q&&(i(Math.max(0,D+P-Date.now())),k(ne=>Cg({...A,x:ee},q,ne)),r(ee),q=ee)},V=()=>{M.schedule(()=>{const ee=tG(q,Math.random,H()),ne=ee.some(ue=>ue.place==="floor")?F():null;let le=q;const de=ee.flatMap(ue=>{const re=le;if(le=ue.x,!(ue.place==="floor"&&ue.act==="walk"))return[ue];const pe=oG(re,ue.x,ne),ye=pe.length-1;return ue.floorFrac==null?pe:pe.map((_e,he)=>he===ye?{..._e,floorFrac:ue.floorFrac}:_e)});K(de)},RV(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),V(),()=>{M.dispose(),Y==null||Y.disconnect(),j("ledge"),r(ee=>Math.max(-W(),Math.min(0,ee))),i(0),d(null),f(null),N(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){R(null);return}const M=BE(document),q=A=>{const D=cG(A,Math.random);R(D.dance),L(D.beatMs),M.schedule(()=>q(D.dance),uG(Math.random))};return q(null),()=>M.dispose()},[n,U]),{scene:S,suspended:E,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:b,riser:v,dance:I,beatMs:$}}const Rg={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Yh=Ga().filter(e=>!E1.has(e.cell)),xG=Ga().filter(e=>E1.has(e.cell)),qE=Yh.filter(e=>e.cell==="e"),vG=Ga(mG),bG=Yh.filter(e=>e.y<Vk&&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),kG={left:Yh.filter(e=>e.y>=Vk&&e.x<FE),right:Yh.filter(e=>e.y>=Vk&&e.x>=FE)},jG=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${DE} ${dG}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:xG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`g${s.y}-${s.x}`))})}),a.jsxs("g",{className:"fm-body",children:[qE.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),bG.map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Rg[s.cell]},`b${s.y}-${s.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"})]}),qE.map(s=>a.jsx("rect",{x:s.x-(s.x>=DE/2?1:0)+(n==="right"?1:0),y:s.y,width:s.w,height:1,className:"fm-eye"},`eye-${s.x}`))]}),a.jsx("g",{className:"fm-hat",children:vG.map(s=>a.jsx("rect",{x:gG+s.x,y:yG+s.y,width:s.w,height:1,className:s.cell==="k"?"fm-hatband":void 0},`h${s.y}-${s.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:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),(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(s=>a.jsx("g",{className:"fm-leg","data-side":s,children:kG[s].map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Rg[r.cell]},`${s}${r.y}-${r.x}`))},s))]})}),NG=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],SG=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],ar={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},_G={p:"fm-pad"},ru=Ga(NG),EG=Ga(SG);function Gk(e,t,n){return e.map(s=>({...s,x:Math.max(t,s.x),w:Math.max(0,Math.min(n,s.x+s.w)-Math.max(t,s.x))})).filter(s=>s.w>0)}const CG=Gk(ru.filter(e=>e.y>=8),12,18),TG=ru.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),UE=ru.filter(e=>e.cell==="e"),RG={left:Gk(ru.filter(e=>e.y>=11),0,9),right:Gk(ru.filter(e=>e.y>=11),9,12)},AG=y.memo(function({act:t,facing:n}){const s=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:CG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:EG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:_G[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[TG.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar[i.cell]},`b${i.y}-${i.x}`)),UE.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ar.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:ar.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),UE.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:ar.n}},`e${i.x}`))]}),s&&a.jsxs("g",{className:"fm-grip",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-grip-left",d:$3}),a.jsx("path",{className:"fm-grip-right",d:I3})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:ar.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:ar.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:ar.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:RG[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:ar[c.cell]},`${c.y}-${c.x}`))},i))]})}),MG=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Pr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},$G={p:"fm-pad"},Xh=Ga(MG),IG=Ga(_1).filter(e=>E1.has(e.cell)),WE=Xh.filter(e=>e.cell==="e"),LG=Xh.filter(e=>e.y<12&&e.cell!=="e"),OG={left:Xh.filter(e=>e.y>=12&&e.x<9),right:Xh.filter(e=>e.y>=12&&e.x>=9)},PG=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",r=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:IG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:$G[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[LG.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr[o.cell]},`b${o.y}-${o.x}`)),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Pr.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:Pr.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),WE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Pr.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:Pr.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Pr.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),r&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Pr.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Pr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:OG[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Pr.b},`${i.y}-${i.x}`))},o))]})});function L3({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(PG,{act:t,facing:n}):e==="fox"?a.jsx(AG,{act:t,facing:n}):a.jsx(jG,{act:t,facing:n})}const DG={"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 O3(e,t){return t&&dl(t.id)===e?t.name:Hf(e)?"Custom FM":DG[e]}function Ag(e,t){var s;const n=((s=e[0])==null?void 0:s.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Ga(e).map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:r.cell==="s"?"var(--fm-prop-shadow, var(--bg))":r.cell==="l"?"var(--fm-prop-light, var(--text))":r.cell==="a"?"var(--accent)":void 0},`${t}${r.y}-${r.x}`))})}const HE={litter:Ag(Tg.litter,"litter"),ball:Ag(Tg.ball,"ball"),scope:Ag(Tg.scope,"scope")};function FG(e){try{return new URL(e).host}catch{return"the station's server"}}const BG=y.memo(function({player:t,source:n,customStation:s,character:r="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:j,ballFlight:b,place:k,facing:v,riser:N,dance:S,beatMs:E}=wG(o,i,c);if(!o||i)return null;const C=O3(n,s),I=o.audio?FG(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":k,style:{"--fm-beat":`${E}ms`},children:[j&&!j.held&&a.jsx("div",{className:"fm-prop","data-prop":j.kind,"data-leaving":j.leaving?"":void 0,style:{"--fm-prop-x":`${j.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${T3}ms`,"--fm-ball-turn":v==="right"?"1080deg":"-1080deg"},children:HE[j.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${m}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":w??void 0,"data-place":k,"data-facing":v,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${N}px`,"--fm-skip-beat":`${R3}ms`},children:[(j==null?void 0:j.held)&&a.jsx("div",{className:"fm-held","data-prop":j.kind,"data-toss":j.leaving?"":void 0,children:HE[j.kind]}),["cast","fish","reel","stow"].includes(w)&&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(w)&&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":c?"":void 0,"data-dance":c?S??A3[0]:void 0,onClick:d,title:c?`Stop ${C}`:`Play ${C} — streams from ${I}`,"aria-label":c?`Stop ${C}`:`Play ${C}`,children:a.jsx(L3,{character:r,act:w,facing:v})})]})]})});function qG({player:e,label:t}){const{probe:n,armed:s,frame:r,say:o}=e;return n?a.jsx(a.Fragment,{children:s&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:r,className:"fm-frame",title:t,src:mV(n.channel,window.location.origin,n.video),onLoad:()=>o(gV()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const UG={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function WG({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:UG[e]})})}function HG({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const s=()=>n(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function zG({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=ct(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:S7,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(WG,{name:"close"})}),a.jsx(HG,{opening:!0})]})}const VG=y.lazy(()=>Nu(()=>import("./RadioPanel-DFqW-MUV.js"),[]));function GG({fm:e,characterEnabled:t,character:n,open:s,onClose:r}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=_V(),[f,p]=y.useState(null),m=y.useRef(new Set);y.useEffect(()=>{const R=new AbortController;return fetch("/api/music-config",{signal:R.signal}).then($=>$.ok?$.json():null).then($=>{R.signal.aborted||(i(($==null?void 0:$.enabled)===!0),d($?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{R.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>R.abort()},[s]);const w=e.customFmStations.find(R=>dl(R.id)===e.fmSource),j=w!=null&&w.radio?w:void 0,b=jV({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),k=O3(e.fmSource,w),v=o&&j&&b.dead&&e.fmPlayRequest>0?E3(f??h.catalogue,j.id,m.current):null,{remember:N}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{b.playing&&N(S)},[S,b.playing,N]);const E=r,C=xt(r),I=y.useCallback((R,$=!1)=>{var M;if(!o)return;$||m.current.clear();const L=dl(R.id),U=L===e.fmSource;if(U&&b.armed&&!b.dead){b.press();return}const O=U&&!!w&&(w.url!==R.url||((M=w.radio)==null?void 0:M.hls)!==R.radio.hls);e.addFmStation(R,!0),U&&!b.dead&&!O?b.press():e.pickFmSource(L,O),fetch(`/api/radio-click?id=${encodeURIComponent(R.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,b.armed,b.dead,b.press]);return y.useEffect(()=>{b.playing&&!b.dead&&m.current.clear()},[b.playing,b.dead]),y.useEffect(()=>{if(!(!o||!j||!b.dead||e.fmPlayRequest===0))return EV(f??h.catalogue,j.id,m.current,R=>I(R,!0))},[o,j==null?void 0:j.id,b.dead,e.fmPlayRequest,f,h.catalogue,I]),a.jsxs(a.Fragment,{children:[t&&a.jsx(BG,{character:n,player:b,source:e.fmSource,customStation:w}),a.jsx(qG,{player:b,label:k}),s&&wt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...C,children:a.jsx(y.Suspense,{fallback:a.jsx(zG,{onClose:E}),children:a.jsx(VG,{fm:e,player:b,library:h,selected:j,label:k,enabled:o,disabledReason:c,autoNext:v==null?void 0:v.name,onPick:I,onQueueChange:p,onClose:E})})}),document.body)]})}function P3(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 Kk(e){return P3(Math.floor(e/1e3))}function Su(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return s>0?`${s}d ${r}h`:r>0?`${r}h ${o}m`:`${o}m`}function KG(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Zh(e,t,n){const s=new Date(e),r=Kk(t-e);return{label:KG(s,new Date(t))?r:`${r} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function YG({data:e}){const t=Go(3e4),n=e.note,s=n.kind==="recap",r=Zh(n.at,t),o=s?"recap-note":`recap-note is-status status-${n.kind}`,i=s?void 0:Uf(n);return a.jsxs("div",{className:o,role:"note","aria-label":s?"Claude Code's recap":`Session note: ${Oa(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:r.title,children:r.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":s?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),K7(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:a9(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),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(Gh,{recap:s}),Oa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:r.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(Bo,{type:"source",position:Oe.Right,style:{background:"transparent",border:"none"}})]})}function _u(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Eu(e){return/mac|iphone|ipad/i.test(e)}const Jh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function XG(e,t,n){return{positions:Jh(e.positions),pinned:Jh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function ZG(e,t){t.positions.clear();for(const[n,s]of Jh(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of Jh(e.pinned))t.pinned.set(n,s);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const zE=7e3,JG=2e3,QG=140,eK="Layout re-arranged",tK="Layout re-arranged. Undo available.",VE="Layout restored.",nK={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function sK(e,t=nK){let n=null,s=null,r=0,o=zE;const i=new Set,c=()=>{s!==null&&t.clear(s),s=null},d=()=>{c(),!(n===null||i.size>0)&&(r=t.now()+o,s=t.set(()=>{s=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=zE,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&s!==null&&(o=Math.max(0,r-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,JG),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function rK(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function aK(e){return Eu(e)?"⌘Z":"Ctrl+Z"}function oK({undo:e}){const{open:t,said:n,undo:s,dismiss:r,hold:o,release:i}=e,c=zi(t,QG),d=y.useRef(null);return y.useEffect(()=>t?Cn.push(r,0,"popover"):void 0,[t,r]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),Ma(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:eK}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:s,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:aK(_u())})]})]})]})}function iK({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:r,targetPosition:o,style:i}){const[c]=s1({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:s,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:s,r:3.5})]})}function Yk(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Qh(e,t){const n=Yk(e);return n?n.slice(-t):e.slice(-t)}function D3(e,t,n=4){const s=Yk(e);if(!s)return Qh(e,n);let r=n;for(const o of t){if(o===e)continue;const i=Yk(o);let c=0;for(;c<s.length&&c<i.length&&s[s.length-1-c]===i[i.length-1-c];)c++;r=Math.max(r,c+1)}return s.slice(-r)}const Dc=" · ",lK=32,cK=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function GE(e){return cK.test(e)?2:1}function KE(e,t=lK){const n=[...e];let s=0;for(const i of n)s+=GE(i);if(s<=t)return e;const r=[];let o=0;for(const i of n){const c=GE(i);if(o+c>t-1)break;r.push(i),o+=c}for(;r.length&&/[\s\-_.:/]/.test(r[r.length-1]);)r.pop();return`${r.join("")}…`}function uK(e,t,n,s,r=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=s?D3(n,r):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Dc);return{label:KE(e),name:c?KE(c):void 0,shortId:d,fullLabel:h.join(Dc),title:`${i?"waiting on you: ":""}${f}
85
- Zoom to this session
86
- drag the wrapper to move the whole session`}}const To=18,Xk=26,C1=12,au=240,F3=130,Zk=To*2+Xk+C1,dK=72,Qi=Zk+dK,Eh=24,B3=To*2+Eh,ef=Qi;function q3(e,t){var s;let n=au;for(const r of e)n=Math.max(n,((s=t.get(r.id))==null?void 0:s.width)??au);return n}const tf=420,U3=1;function hK(e,t,n,s){return Math.min(U3,n/Math.max(1,e),s/Math.max(1,t))}function Gn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function Vf(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const r=Gn(s),o=n.get(r);o?o.push(s):n.set(r,[s])}return n}function fK(e,t){return((t==null?void 0:t.get(e))??0)>0?tf:0}function pK(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function nf(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??au,h:(n==null?void 0:n.height)??F3}}function ou(e,t,n){const s=nf(e,t);return{w:s.w+fK(e,n),h:Math.max(s.h,pK(e,n))}}function mK(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const gK=240,W3=16;function H3(e,t){return(e+gK)*(t||1)}function yK(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 wK(e,t,n,s){return{position:"absolute",left:e.x+W3,top:e.y-C1/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??H3(e.w,t),"--session-hue":n}}function xK(e){const t=new Map;for(const r of e){if(r.type!=="agent"&&r.type!=="recapNote")continue;const o=r.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||r.width==null||r.height==null)continue;const i=r.position.x,c=r.position.y,d=i+r.width,h=c+r.height,f=t.get(Gn(r)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:vK(o);f?(f.minX=Math.min(f.minX,i),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(Gn(r),{minX:i,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[r,o]of t){const i=n.get(o.label);i?i.push(r):n.set(o.label,[r])}const s=[];for(const[r,o]of t){const i=n.get(o.label)??[],c=i.length>1;s.push({sessionId:r,...uK(o.label,o.name,r,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-To,y:o.minY-To-Xk,w:o.maxX-o.minX+To*2,h:o.maxY-o.minY+To*2+Xk,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return s}function vK(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:w1(e.sessionName,e.sessionTitle).face,alarm:Mn(e.waiting),branch:t&&t.total>0?d3(t):void 0}}function bK(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],r=t[n];if(s.sessionId!==r.sessionId||s.label!==r.label||s.name!==r.name||s.shortId!==r.shortId||s.alarm!==r.alarm||s.branch!==r.branch||s.fullLabel!==r.fullLabel||s.title!==r.title||s.x!==r.x||s.y!==r.y||s.w!==r.w||s.h!==r.h)return!1}return!0}const kK=20,Dr=4,jK=64,NK=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function SK(e,t,n,s){const r=t.zoom||1,o=H3(e.w,r);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+W3)*r+t.x,c=e.y*r+t.y-C1,d=c+kK;let h=Math.min(o,n.width-Dr-i),f=i<Dr||c<Dr||d>n.height-Dr;for(const p of s)if(!(p.top-Dr>=d||p.bottom+Dr<=c)&&!(p.right+Dr<=i)){if(p.left-Dr<=i){f=!0;break}h=Math.min(h,p.left-Dr-i)}return h<jK&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function _K(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(NK)){const r=s.getBoundingClientRect(),o=Math.max(r.left,t.left)-t.left,i=Math.max(r.top,t.top)-t.top,c=Math.min(r.right,t.right)-t.left,d=Math.min(r.bottom,t.bottom)-t.top;c-o<1||d-i<1||n.push({left:Math.round(o),top:Math.round(i),right:Math.round(c),bottom:Math.round(d)})}return n}function EK(e,t){return e.length===t.length&&e.every((n,s)=>{const r=t[s];return n.left===r.left&&n.top===r.top&&n.right===r.right&&n.bottom===r.bottom})}const CK=500;function z3({focus:e,setTimeout:t,clearTimeout:n,ms:s=CK}){let r=null;const o=()=>{r!==null&&(n(r),r=null)};return{hold(i){o(),r=t(()=>{r=null;try{e(i)}catch{}},s)},cancel:o}}function TK(e){return xK(e.nodeInternals.values())}const RK=e=>e.width,AK=e=>e.height,MK=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function $K({onFocusSession:e}){const{x:t,y:n,zoom:s}=lO(),r=tt(TK,bK),o=tt(RK),i=tt(AK),c={width:o,height:i},d=y.useRef(null),h=tt(MK),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var I;const S=(I=d.current)==null?void 0:I.parentElement;if(!S)return;const E=_K(S),C=requestAnimationFrame(()=>{p(R=>EK(R,E)?R:E)});return()=>cancelAnimationFrame(C)});const m=y.useRef(e);m.current=e;const[w]=y.useState(()=>z3({focus:S=>{var E;return(E=m.current)==null?void 0:E.call(m,S)},setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),r.length<=1)return null;const j=S=>{try{e==null||e(S)}catch{}},b=(S,E)=>{S.detail>0&&vu()?w.hold(E):j(E)},k={transform:`translate(${t}px, ${n}px) scale(${s})`},v=a.jsx("div",{className:"session-clusters",style:k,ref:d,children:r.map(S=>{const E=eu(S.sessionId),C=yK(S,E);return a.jsx("div",{className:"cluster-card",style:C,"aria-hidden":!0},S.sessionId)})}),N=h&&wt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:r.map(S=>{const E=eu(S.sessionId),C=SK(S,{x:t,y:n,zoom:s},c,f),I=wK(S,s,E,C.maxWidth);return a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":C.hidden?"":void 0,style:I,title:S.title,onClick:R=>b(R,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(j1,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:Dc+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:Dc+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:Dc+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[v,N]})}function IK({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 V3=600,LK=4,OK=36,sf=14,PK=60,DK=6,YE=220,FK=96,BK=28;function qK(e,t){return Math.max(FK,61+[...t].length*6.8)}function UK(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function WK(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/V3)}function HK(e,t){const n=[],s=new Set;for(let r=e.length-1;r>=0&&n.length<t;r--){const o=e[r];s.has(o.id)||(s.add(o.id),n.push(o))}return n.reverse()}function zK(e,t,n,s,r,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>V3)continue;const d=s.get(c.id)??n.get(c.id);if(!d)continue;const h=HK(c.tools,LK);if(h.length===0)continue;const f=c.exitAt??null,p=r.get(c.id),m=Math.max((p==null?void 0:p.width)??YE,YE),w=(p==null?void 0:p.height)??130,j=d.x,b=d.y,k=j+m,v=b+w/2;h.forEach((N,S)=>{const E=S*OK,C=j+m+PK,I=b+DK+E,R=WK(o,f),$=N.inputPreview??"",L=UK(N),U=R<.999,O=k1(N.name);i.push({id:`${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:O.label,emoji:O.emoji,status:L,category:h3(N.name),mcpHue:O.hue,inputPreview:$,fade:R,fading:U,worldX:C,worldY:I,anchorX:k,anchorY:v,spawnDx:k-C,spawnDy:v-(I+sf)});const M=g3(N.name,N.input);if(M){const q=qK(N.name,O.label),A=C+q+BK,D=I,P=C+q,K=I+sf;i.push({id:`sub:${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:$9(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:L,category:M.category,inputPreview:M.detail??$,fade:R,fading:U,worldX:A,worldY:D,anchorX:P,anchorY:K,spawnDx:P-A,spawnDy:0})}})}return i}function VK({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:r,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=zK(e,t,n,s,r,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return a.jsx(GK,{bursts:f,spotlight:o,onOpenTool:d})}function GK({bursts:e,spotlight:t,onOpenTool:n}){const s=e.map(o=>{const i=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+sf,f=Math.max(1,d-i),p=Math.min(1,Math.abs(h-c)/f),m=i+f*(.55-.22*p),w=c+(h-c)*.12,j=d-f*.25,b=t!=null&&!t.has(o.agentId),k=o.fade*(b?.14:1);return a.jsx("path",{d:`M ${i} ${c} C ${m} ${w}, ${j} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:k,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),r=e.map(o=>a.jsx(XK,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(KK,{connectors:s,bubbles:r})}function KK({connectors:e,bubbles:t}){const{x:n,y:s,zoom:r}=lO();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*sf}px`},children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${s}) scale(${r})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${s}px) scale(${r})`},children:t})]})}function YK(e,t){const n=e.b,s=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===s.id&&n.toolId===s.toolId&&n.worldX===s.worldX&&n.worldY===s.worldY&&n.spawnDx===s.spawnDx&&n.spawnDy===s.spawnDy&&n.status===s.status&&n.fading===s.fading&&n.category===s.category&&n.mcpHue===s.mcpHue&&n.isSub===s.isSub&&n.emoji===s.emoji&&n.name===s.name&&n.fullName===s.fullName&&n.toolName===s.toolName&&n.inputPreview===s.inputPreview}const XK=y.memo(function({b:t,dim:n,onOpenTool:s}){const r={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,i=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=s!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:r,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:i,onClick:c?()=>s(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:"×"})]})})},YK),ZK={width:140,height:105},JK={agent:F9,sessionGroup:IK,recapNote:YG},QK={recapTie:iK},XE=400;function eY({graph:e,layout:t,viewport:n,clicks:s,drag:r,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:j,openTool:b,focusAgent:k,requestClear:v,setKeyHelpOpen:N}){const{allNodes:S,edges:E,visibleAgentIds:C,spotlightSet:I}=e,{positionsRef:R,pinnedRef:$,handleRelayout:L,rearrangeUndo:U}=t,{restoredViewport:O,onMoveStart:M,onMove:q}=n,{onNodeClick:A,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:K,onNodeMouseLeave:G}=s,{onNodeDragStart:W,onNodeDrag:H,onNodeDragStop:F}=r,{palette:B,minimapNodeFill:Z,characterEnabled:V}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=h,{paused:J,pauseGate:ee,togglePause:ne}=f;return a.jsxs(iO,{nodes:S,edges:E,nodeTypes:JK,edgesFocusable:!1,edgeTypes:QK,fitView:!O,fitViewOptions:{padding:.25,duration:Pk({durationMs:XE,documentHidden:document.hidden})?XE:0},minZoom:fO,maxZoom:pO,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:A,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:K,onNodeMouseLeave:G,onMoveStart:M,onMove:q,onNodeDragStart:(le,de,ue)=>{U.dismiss(),W(le,de,ue)},onNodeDrag:H,onNodeDragStop:F,children:[a.jsx(bH,{gap:28,size:1,color:B["--grid-line"]}),a.jsx($K,{onFocusSession:k}),a.jsx(VK,{agents:p.current.agents,visibleAgentIds:C,positions:R.current,pinned:$.current,measured:m.current,spotlight:I,hiddenCategories:w,now:j,onOpenTool:b}),a.jsxs("div",{className:"canvas-notices",children:[X&&a.jsx(V9,{enableAutoFitAndRefit:Y}),a.jsx(oK,{undo:U})]}),a.jsx(sV,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:ee,togglePause:ne,handleRelayout:L,requestClear:v,setKeyHelpOpen:N}),a.jsx(lH,{style:ZK,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:B["--minimap-mask"],maskStrokeColor:B["--line"]}),a.jsx(GG,{fm:i,character:o.character,characterEnabled:V,open:c,onClose:d})]})}function tY(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const s=document.querySelector(".topbar");if(!s)return;const r=getComputedStyle(s),o=i=>{var d;const c=(d=i.match(/\d+/g))==null?void 0:d.slice(0,3);return(c==null?void 0:c.length)===3?`#${c.map(h=>Number(h).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};e.colors({color:o(r.backgroundColor),symbolColor:o(r.color)}).catch(()=>{})};t();const n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>n.disconnect()},[e]),!e||e.platform==="darwin"?null:a.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function nY(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,r=0,o=0;for(const i of e){const c=In(i);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=i.usage.inputTokens,s+=i.usage.outputTokens,r+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:r,cacheCreateTokens:o,sum:n+s}}const sY="spend on this board",rY="on this board",G3=`Everything on the board right now, and only that.
87
- 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.
88
- `,aY=G3+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function ZE(e){return e?aY:G3+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const K3="session spend",Jk="__unknown__",oY=12;function iY(e,t=Date.now()){const n=new Map;for(const s of e)for(const r of ju(s)){const o=r.model??Jk,i=If(r.usage,r.model,t),c=n.get(o);c?(c.inputTokens+=r.usage.inputTokens,c.outputTokens+=r.usage.outputTokens,c.cacheReadTokens+=r.usage.cacheReadTokens,c.cacheCreateTokens+=r.usage.cacheCreateTokens,c.cost.total+=i.total,c.cost.input+=i.input,c.cost.output+=i.output,c.cost.cacheRead+=i.cacheRead,c.cost.cacheWrite+=i.cacheWrite,c.agentCount++):n.set(o,{model:o,inputTokens:r.usage.inputTokens,outputTokens:r.usage.outputTokens,cacheReadTokens:r.usage.cacheReadTokens,cacheCreateTokens:r.usage.cacheCreateTokens,cost:{...i},agentCount:1,priced:Va(r.model,t)!=null})}return Array.from(n.values()).sort((s,r)=>r.cost.total-s.cost.total||r.inputTokens+r.outputTokens-(s.inputTokens+s.outputTokens))}function lY(e,t=Date.now()){const n=[...e],s=[];for(const r of n){if(r.kind!=="root")continue;let o=In(r,t).total,i=r.usage.inputTokens,c=r.usage.outputTokens,d=nu(r,t);for(const h of n)h.sessionId!==r.sessionId||h.kind==="root"||(o+=In(h,t).total,i+=h.usage.inputTokens,c+=h.usage.outputTokens,d+=nu(h,t));s.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",state:r.state,cost:o,inputTokens:i,outputTokens:c,unpricedTokens:d})}return s.sort((r,o)=>o.cost-r.cost||o.inputTokens+o.outputTokens-(r.inputTokens+r.outputTokens)).slice(0,oY)}const cY=600;function Gf(e,t){return!(e.exitAt!=null&&t-e.exitAt>cY||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function uY(e,t){const n=new Set;for(const s of e.agents.values())Gf(s,t)&&n.add(s.id);return n}function dY(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 hY(e,t,n=0){if(!e)return!1;for(const s of t)if(dY(e,s,n))return!0;return!1}function JE(e){return e.waiting?Mn(e.waiting)?0:1:e.state==="active"?2:3}function fY(e,t){var s;const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let o=r.toolCount,i=In(r).total,c=r.endedAt??r.startedAt;for(const p of e.agents.values()){if(p.sessionId!==r.sessionId||p.kind==="root")continue;o+=p.toolCount,i+=In(p).total;const m=p.endedAt??p.startedAt;m>c&&(c=m)}const d=qf(r),h=(d==null?void 0:d.kind)==="recap"?{text:d.text,at:d.at}:null,f=d&&d.kind!=="recap"?d:null;n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:h,status:f,modelId:r.model,effort:r.effort,plan:bu(r.plan),planTitle:$O(((s=r.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:r.startedAt,lastActivity:c})}return n.sort((r,o)=>{const i=JE(r),c=JE(o);return i!==c?i-c:r.waiting&&o.waiting?r.waiting.since-o.waiting.since:o.lastActivity-r.lastActivity}),n}function pY(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",Uf(e)].filter(Boolean).join(`
89
- `)}function rf(e,t,n){const s=(t??n)-e;if(s<1e3)return"<1s";const r=Math.floor(s/1e3);if(r<60)return`${r}s`;const o=Math.floor(r/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function mY({state:e,now:t,selectedIds:n,onSelect:s,onClose:r,removedIds:o,onBringBackAll:i,leaving:c=!1}){const d=Ln(),h=y.useMemo(()=>fY(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>Mn(m.waiting)).length;return a.jsxs("aside",{className:`session-list${c?" leaving":""}`,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:h.length})]}),p>0&&a.jsxs("span",{className:"sl-waiting-count",children:[p," waiting"]}),f>0&&a.jsxs("span",{className:"sl-live-count",children:[f," live"]}),a.jsx("button",{className:"glyph-btn sl-close",onClick:r,title:gn("Hide sidebar","L",d),"aria-label":"Hide session list",children:"‹"})]}),a.jsxs("ul",{className:"sl-rows",children:[h.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),h.map(m=>{var b;const w=n.has(m.sessionId),j=(o==null?void 0:o.has(m.sessionId))??!1;return a.jsx("li",{className:"sl-row-item",children:a.jsxs("button",{type:"button",className:`sl-row state-${m.state}${w?" selected":""}${j?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:j?`Bring ${m.label} back to the board`:`Focus ${m.label}`,children:[a.jsx("span",{className:`sl-dot state-${m.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:il(m.state)}),a.jsxs("div",{className:"sl-row-body",children:[a.jsxs("div",{className:"sl-row-head",children:[a.jsx("span",{className:"sl-label",children:m.label}),j&&a.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&a.jsx("span",{className:"model-chip","data-family":Of(m.modelId),title:su(m.modelId,m.effort),children:Pf(m.modelId,m.effort)})]}),a.jsxs("div",{className:"sl-row-meta",children:[a.jsxs("span",{title:"tool calls",children:[a.jsx("b",{children:m.toolCount})," ",m.toolCount===1?"tool":"tools"]}),m.cost>0&&a.jsx("span",{className:"sl-cost",title:K3,children:a.jsx("b",{children:Xe(m.cost)})}),m.waiting?a.jsxs("span",{className:"sl-waiting",title:[ll(m.waiting),QO(m.waiting,ll(m.waiting)),`${Mn(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
90
- `),children:[Mn(m.waiting)?"waiting":"your turn"," ",rf(m.waiting.since,void 0,t),m.waiting.tool&&a.jsxs("span",{className:"sl-waiting-tool",children:[" · ",m.waiting.tool.name]})]}):a.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(m.startedAt).toLocaleString()}`,children:rf(m.startedAt,m.state==="active"?void 0:m.lastActivity,t)})]}),m.plan&&a.jsxs("span",{className:m.plan.allDone?"sl-plan sl-plan-done":"sl-plan",title:m.planTitle,children:[a.jsxs("span",{className:"sl-plan-count","aria-hidden":!0,children:[m.plan.done,"/",m.plan.total]}),a.jsx("span",{className:"vis-hidden",children:MO(m.plan)}),a.jsx("span",{className:"sl-plan-step","aria-hidden":!0,children:m.plan.allDone||!m.plan.current?"done":`${m.plan.next?"next: ":""}${m.plan.current}`})]}),m.recap&&a.jsxs("span",{className:"sl-recap",title:m.recap.text,children:[a.jsx(w3,{}),m.recap.text]}),m.status&&a.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:pY(m.status),children:[a.jsx("span",{className:"sl-status-tag",children:Oa(m.status.kind)})," ",m.status.text]}),((b=m.status)==null?void 0:b.reply)&&a.jsxs("span",{className:"sl-status-reply",title:`suggested reply “${m.status.reply}”`,children:["suggested reply “",m.status.reply,"”"]})]})]})},m.sessionId)})]}),(()=>{let m=0;for(const w of o??[]){const j=e.agents.get(w);j&&Gf(j,t)&&m++}return m===0||!i?null:a.jsx("div",{className:"sl-foot",children:a.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:w=>{const j=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var b;return(b=j==null?void 0:j.querySelector(".sl-row"))==null?void 0:b.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const Wn=e=>{if(e===null)return"—";if(e<1e3)return`${Math.round(e)} ms`;if(e<6e4)return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} s`;if(e<36e5)return`${(e/6e4).toLocaleString(void 0,{maximumFractionDigits:1})} min`;const t=Math.round(e/6e4),n=Math.floor(t/60),s=t%60;return`${n.toLocaleString()} h${s?` ${s} min`:""}`},gY=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,yY=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function QE(e,t){for(let n=0;n<4;n++){const s=await fetch(`/api/tool-audit?${e}`,{signal:t}),r=await s.json();if(s.status===409&&r.reason==="busy"&&n<3){await new Promise((o,i)=>{const c=()=>{window.clearTimeout(d),i(new DOMException("Cancelled","AbortError"))},d=window.setTimeout(()=>{t.removeEventListener("abort",c),o()},300);t.addEventListener("abort",c,{once:!0}),t.aborted&&c()});continue}if(!s.ok||!r.ok||!Array.isArray(r.rows))throw new Error("Could not build the tool report. Try Refresh or reduce history retention in Settings.");return r}throw new Error("A tool report is already running. Try Refresh in a moment.")}const eC={Read:"Reads a file",Edit:"Changes part of a file",MultiEdit:"Makes several changes to one file",Write:"Creates or overwrites a file",NotebookEdit:"Changes a Jupyter notebook cell",Grep:"Searches file contents",Glob:"Finds files by name",LS:"Lists a folder",WebFetch:"Opens a web page",WebSearch:"Searches the web",Agent:"Hands work to a subagent",Task:"Hands work to a subagent",TodoWrite:"Updates the agent’s to-do list",Skill:"Loads a skill",ToolSearch:"Looks up another tool",apply_patch:"Changes files",update_plan:"Updates the agent’s plan",view_image:"Looks at an image file",write_stdin:"Talks to a running command",multi_agent_v1__wait_agent:"Waits for other agents to finish",rg:"Searches file contents",grep:"Searches text",ls:"Lists a folder",cat:"Prints a file",sed:"Prints or edits text",head:"Shows the start of a file",tail:"Shows the end of a file",find:"Finds files",wc:"Counts lines or words",cut:"Picks columns out of text",sort:"Sorts lines",jq:"Reads JSON",curl:"Makes a web request",sleep:"Waits",node:"Runs a Node.js script",python:"Runs a Python script",python3:"Runs a Python script",git:"Runs Git","git status":"Shows what changed","git diff":"Shows the exact changes","git log":"Shows the commit history","git show":"Shows one commit","git add":"Stages changes","git commit":"Saves a commit","git push":"Uploads commits","git pull":"Downloads and merges commits","git fetch":"Downloads commits","git checkout":"Switches branch or restores files","git switch":"Switches branch","git branch":"Lists or changes branches","git merge":"Merges a branch","git rebase":"Replays commits on another base","git stash":"Puts changes aside","git restore":"Restores files","git reset":"Moves the branch or unstages changes","git worktree":"Manages worktrees","npm test":"Runs the project’s tests","npm install":"Installs packages","npm ci":"Installs packages from the lock file","gh pr":"Works with GitHub pull requests","gh issue":"Works with GitHub issues","gh run":"Works with GitHub Actions runs","gh api":"Calls the GitHub API","shell (unclassified)":"A shell command ccdeck could not name","exec (unclassified)":"A Codex script ccdeck could not name","tool (unclassified)":"A tool with an unreadable name"};function iu(e){if(Object.hasOwn(eC,e))return eC[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=Y3(e);return n?`From the ${n.server} MCP server`:null}function Y3(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const lu=e=>{var t;return((t=Y3(e))==null?void 0:t.tool)??e},wY=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function af(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const xY=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(iu(e.operation)??"").toLowerCase().includes(n)};function vY(e,t,n=""){return e.filter(s=>xY(s,n)).sort((s,r)=>{const o=af(s,t),i=af(r,t);return o!==i?o===null?1:i===null?-1:i-o:r.calls-s.calls||s.operation.localeCompare(r.operation)})}const T1=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},Kf=e=>e.failed>0&&e.completed>0?T1(e.failed,e.completed):null;function bY(e,t){const n=[],r=e.filter(c=>c.totalMs!==null&&c.measured>=2).slice().sort((c,d)=>d.totalMs-c.totalMs)[0];r&&t&&r.totalMs>=t*.2&&n.push({kind:"time",operation:r.operation,title:"takes the most time",detail:`${Wn(r.totalMs)} over ${Wo(r.calls,"call")}, ${T1(r.totalMs,t)} of all tool time.`});const o=e.filter(c=>c.completed>=5&&c.failed>=2&&c.failed/c.completed>=.1).sort((c,d)=>d.failed/d.completed-c.failed/c.completed||d.failed-c.failed)[0];o&&n.push({kind:"failing",operation:o.operation,title:"fails often",detail:`${o.failed.toLocaleString()} of ${Wo(o.completed,"call")} failed (${Kf(o)}).`});const i=e.filter(c=>c.medianMs!==null&&c.measured>=3&&c.medianMs>=1e4&&c.operation!==(r==null?void 0:r.operation)).sort((c,d)=>d.medianMs-c.medianMs)[0];return i&&n.push({kind:"slow",operation:i.operation,title:"is the slowest",detail:`Usually ${Wn(i.medianMs)} per call; the longest took ${Wn(i.maxMs)}.`}),n}const Wo=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,Qk={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},kY={all:"your agents",claude:"Claude",codex:"Codex"};function jY(e,t,n){return{lead:`In the last ${Qk[n]??`${n} days`}, ${kY[t]} made`,calls:Wo(e.total,"tool call"),time:e.totalMs?Wn(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?T1(e.failed,e.completed):null}}const tC=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function NY(e,t=Date.now()){const n=r=>new Date(r).toDateString(),s=new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return n(e)===n(t)?`Today ${s}`:n(e)===n(t-864e5)?`Yesterday ${s}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${s}`}const Ta=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function SY(e){return e.status==="outside-history"?`${Ta(e.date)} · before recording started`:e.calls?`${Ta(e.date)} · ${Wo(e.calls,"call")}${e.medianMs!==null?` · usually ${Wn(e.medianMs)}`:""}`:`${Ta(e.date)} · no calls`}function _Y({history:e}){const t=e.days,n=[...t].reverse().find(d=>d.calls>0)??t.at(-1),[s,r]=y.useState(null);if(t.length<3||!n)return null;const o=t.find(d=>d.date===s)??n,i=t.reduce((d,h)=>h.calls>d.calls?h:d,t[0]),c=Math.max(1,i.calls);return a.jsxs("section",{className:"ta-history","aria-labelledby":"ta-history-title",children:[a.jsx("h4",{id:"ta-history-title",children:"Calls per day"}),a.jsx("div",{className:"ta-history-bars",role:"img","aria-label":`Calls per day from ${Ta(t[0].date)} to ${Ta(t.at(-1).date)}. The busiest day was ${Ta(i.date)} with ${Wo(i.calls,"call")}.`,onPointerLeave:()=>r(null),style:{"--ta-days":t.length},children:t.map(d=>a.jsx("span",{"data-shown":d.date===o.date||void 0,"data-outside":d.status==="outside-history"||void 0,onPointerEnter:()=>r(d.date),children:a.jsx("i",{style:{"--ta-height":d.calls/c}})},d.date))}),a.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[a.jsx("span",{children:Ta(t[0].date)}),a.jsx("span",{children:Ta(t.at(-1).date)})]}),a.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:SY(o)})]})}function EY(){return a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const CY={success:"Done",failed:"Failed",unmatched:"No result"},TY=({state:e})=>a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:e==="failed"?"m4 4 8 8m0-8-8 8":e==="success"?"m3 8.5 3 3 7-7":"M4 8h8"})});function RY(e){const{claude:t,codex:n}=e.providers;return t&&n?`${t.toLocaleString()} by Claude, ${n.toLocaleString()} by Codex`:t?"All by Claude":"All by Codex"}function X3({row:e,details:t,loading:n,error:s,kind:r,setKind:o,onClose:i}){const c=iu(e.operation),d=(t==null?void 0:t[r])??[],h=Date.now(),f=Kf(e);return a.jsxs("section",{className:"ta-inspector","aria-label":`${lu(e.operation)} details`,id:"tool-operation-inspector",children:[a.jsxs("header",{className:"ta-inspector-head",children:[a.jsxs("div",{children:[a.jsx("h3",{tabIndex:-1,id:"tool-operation-heading",children:lu(e.operation)}),c&&a.jsx("p",{children:c})]}),a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:a.jsx(EY,{})})]}),a.jsxs("dl",{className:"ta-facts",children:[a.jsxs("div",{children:[a.jsx("dt",{children:"Calls"}),a.jsx("dd",{children:e.calls.toLocaleString()})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Total time"}),a.jsx("dd",{children:Wn(e.totalMs)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Usually"}),a.jsx("dd",{children:Wn(e.medianMs)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Failed"}),a.jsxs("dd",{"data-bad":e.failed>0||void 0,children:[e.failed.toLocaleString(),f&&a.jsx("small",{children:f})]})]})]}),a.jsxs("p",{className:"ta-note",children:[RY(e),e.maxMs!==null&&e.measured>1&&a.jsxs(a.Fragment,{children:[" · longest ",Wn(e.maxMs)]}),e.unmatched>0&&a.jsxs(a.Fragment,{children:[" · ",Wo(e.unmatched,"call")," without a result yet"]})]}),s&&a.jsx("p",{className:"ta-message",role:"alert",children:s}),(t==null?void 0:t.history)&&a.jsx(_Y,{history:t.history},e.operation),a.jsxs("section",{className:"ta-calls-section","aria-labelledby":"ta-calls-title",children:[a.jsxs("div",{className:"ta-calls-head",children:[a.jsx("h4",{id:"ta-calls-title",children:"Calls"}),a.jsxs("div",{className:"uh-range",role:"group","aria-label":"Show calls",children:[a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r==="recent",onClick:()=>o("recent"),children:"Latest"}),a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r==="slowest",onClick:()=>o("slowest"),children:"Slowest"})]})]}),n&&!t&&a.jsx("p",{className:"ta-note",role:"status",children:"Reading calls…"}),t&&a.jsxs(a.Fragment,{children:[a.jsx("ul",{className:"ta-calls",children:d.map(p=>a.jsxs("li",{"data-state":p.state,children:[a.jsx("span",{className:"ta-call-when",children:NY(p.capturedAt,h)}),a.jsx("span",{className:"ta-call-who",children:p.provider==="claude"?"Claude":"Codex"}),a.jsx("span",{className:"ta-call-took",children:Wn(p.durationMs)}),a.jsxs("span",{className:"ta-call-state",children:[a.jsx(TY,{state:p.state}),CY[p.state]]})]},p.id))}),!d.length&&a.jsx("p",{className:"ta-note",children:r==="slowest"?"None of these calls was timed.":"No calls in this period."}),t.total>d.length&&d.length>0&&a.jsxs("p",{className:"ta-note",children:["The ",r==="recent"?"latest":"slowest"," ",d.length," of ",t.total.toLocaleString(),"."]})]})]}),a.jsx("p",{className:"ta-note ta-inspector-foot",children:"Times include any wait for your approval."})]})}function R1(e){const[t,n]=y.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const s=window.matchMedia(e),r=()=>n(s.matches);return r(),s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[e]),t}function AY({keyboard:e,...t}){const n=y.useRef(null),s=ct(t.onClose,{focusRef:n}),r=xt(t.onClose);return y.useEffect(()=>{var o,i;n.current=((o=s.current)==null?void 0:o.querySelector("#tool-operation-heading"))??null,(i=n.current)==null||i.focus({preventScroll:!0})},[s]),wt.createPortal(a.jsx("div",{className:"ta-drawer-backdrop",role:"presentation",...r,children:a.jsx("div",{className:"ta-drawer","data-keyboard":e||void 0,ref:s,role:"dialog","aria-modal":"true","aria-labelledby":"tool-operation-heading",children:a.jsx(X3,{...t})})}),document.body)}function MY({keyboard:e,...t}){const n=y.useRef(null),s=y.useRef(t.onClose);return s.current=t.onClose,y.useEffect(()=>Cn.push(()=>s.current(),0,"popover"),[]),y.useLayoutEffect(()=>{var r,o;n.current&&(n.current.scrollTop=0),(document.activeElement===document.body||e&&document.activeElement instanceof HTMLElement&&document.activeElement.dataset.operation===t.row.operation)&&((o=(r=n.current)==null?void 0:r.querySelector("#tool-operation-heading"))==null||o.focus({preventScroll:!0}))},[t.row.operation,e]),a.jsx("aside",{ref:n,className:"ta-drawer ta-integrated-inspector","data-keyboard":e||void 0,"aria-labelledby":"tool-operation-heading",children:a.jsx(X3,{...t})})}function $Y(e){return R1("(max-width: 700px)")?a.jsx(AY,{...e}):a.jsx(MY,{...e})}const e0="agent-dag.text-size",t0="agent-dag.density",nC=["smallest","smaller","default","larger","largest"],sC=["tightest","tighter","compact","default","comfortable"],A1={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function M1(){var e,t;return $1(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function $1(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function Z3(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const IY=()=>$1(Ve(e0)),LY=()=>Z3(Ve(t0)),ur={min:320,standard:380,max:1600},OY=420,PY=8,J3="agent-dag.tool-activity.details-width";function xc(e,t){const n=Math.max(ur.min,Math.min(ur.max,t-OY-PY));return Math.round(Math.min(n,Math.max(ur.min,Number.isFinite(e)?e:of())))}function of(){return ur.standard+12*Math.max(0,A1[M1()])}function DY(){const e=Number(Ve(J3));return Number.isFinite(e)&&e>=ur.min&&e<=ur.max?Math.round(e):of()}function FY(e){ze(J3,String(Math.round(e)))}function BY({width:e,workspace:t,onCommit:n}){const s=y.useRef(null),r=y.useRef(null),o=()=>{var w;return((w=t.current)==null?void 0:w.clientWidth)??window.innerWidth},i=xc(e,o()),c=w=>{var j,b;(j=t.current)==null||j.style.setProperty("--ta-details-w",`${w}px`),(b=s.current)==null||b.setAttribute("aria-valuenow",String(w))},d=w=>{c(w),n(w)},h=w=>{var j;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),r.current={x:w.clientX,width:i,room:o(),last:i},(j=t.current)==null||j.setAttribute("data-resizing",""))},f=w=>{const j=r.current;j&&(j.last=xc(j.width+j.x-w.clientX,j.room),c(j.last))},p=()=>{var j;const w=r.current;w&&(r.current=null,(j=t.current)==null||j.removeAttribute("data-resizing"),d(w.last))},m=w=>{const j=w.shiftKey?64:16,b=w.key==="ArrowLeft"?i+j:w.key==="ArrowRight"?i-j:w.key==="Home"?ur.min:w.key==="End"?ur.max:w.key==="Enter"?of():null;b!==null&&(w.preventDefault(),d(xc(b,o())))};return a.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":ur.min,"aria-valuemax":xc(ur.max,o()),"aria-valuenow":i,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:h,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onLostPointerCapture:p,onDoubleClick:()=>d(xc(of(),o())),onKeyDown:m})}const rC=12,qY=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],UY=()=>a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"m10 5-7 7 7 7M3 12h18"})}),WY=()=>a.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})}),HY=()=>a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),a.jsx("path",{d:"m16 16 4.5 4.5"})]}),zY={time:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"13",r:"8"}),a.jsx("path",{d:"M12 9v4l2.5 2M9.5 2.5h5"})]}),failing:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"m9 9 6 6m0-6-6 6"})]}),slow:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"M3 17h18M6 17a6 6 0 0 1 12 0M12 17l3.5-4.5"})})};function VY(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${Kf(e)})`:"none failed",n=e.totalMs===null?"not timed":`${Wn(e.totalMs)} in total, usually ${Wn(e.medianMs)}`;return`${lu(e.operation)}${iu(e.operation)?`, ${iu(e.operation)}`:""}: ${Wo(e.calls,"call")}, ${n}, ${t}`}function GY({onClose:e}){const[t,n]=y.useState("all"),[s,r]=y.useState("7"),[o,i]=y.useState("calls"),[c,d]=y.useState(""),[h,f]=y.useState(!1),[p,m]=y.useState(null),[w,j]=y.useState(!1),b=y.useRef(p);b.current=p;const k=y.useRef(null),[v,N]=y.useState(null),[S,E]=y.useState(null),[C,I]=y.useState("recent"),[R,$]=y.useState(!0),[L,U]=y.useState(!1),[O,M]=y.useState(""),[q,A]=y.useState(""),[D,P]=y.useState(0),K=y.useRef(!1),G=y.useRef(null),W=y.useRef(null),H=y.useRef(null),F=R1("(min-width: 960px)"),[B,Z]=y.useState(DY),V=ae=>{Z(ae),FY(ae)},[X]=y.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),Y=()=>{e(),requestAnimationFrame(()=>{var Se;const ae=X,ge=Array.from(document.querySelectorAll('[data-rail-item="tool-activity"], [data-rail-item="more"]')).find(me=>me.checkVisibility());(Se=ae&&ae!==document.body&&ae.isConnected&&ae.checkVisibility()?ae:ge)==null||Se.focus({preventScroll:!0})})},J=ct(Y,{focusRef:W}),ee=new URLSearchParams({provider:t,days:s}).toString();y.useEffect(()=>{const ae=new AbortController;let ge=!0;const Se=window.setTimeout(()=>ae.abort(),65e3);return M(""),G.current!==ee&&(N(null),E(null),f(!1)),K.current=!0,$(!0),(async()=>{try{const me=await QE(ee,ae.signal);ge&&(G.current=ee,N(me),b.current&&!me.rows.some($e=>$e.operation===b.current)&&m(null))}catch(me){ge&&M(me instanceof Error&&me.name!=="AbortError"?me.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Se),ge&&(K.current=!1,$(!1))}})(),()=>{ge=!1,ae.abort(),window.clearTimeout(Se)}},[ee,D]),y.useEffect(()=>{if(E(me=>(me==null?void 0:me.operation)===p&&G.current===ee?me:null),A(""),!p||!v||R){U(!1);return}let ae=!0;const ge=new AbortController,Se=window.setTimeout(()=>ge.abort(),65e3);return U(!0),(async()=>{var me;try{const $e=await QE(`${ee}&operation=${encodeURIComponent(p)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,ge.signal);ae&&(((me=$e.details)==null?void 0:me.measurements)===null?m(null):E($e.details))}catch{ae&&A("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Se),ae&&U(!1)}})(),()=>{ae=!1,ge.abort(),window.clearTimeout(Se)}},[p,v,R,ee]);const ne=y.useMemo(()=>vY((v==null?void 0:v.rows)??[],o,c),[v,o,c]),le=y.useMemo(()=>v?bY(v.rows,v.totalMs):[],[v]),de=h||c?ne:ne.slice(0,rC),ue=ne.length?af(ne[0],o)??0:0,re=v==null?void 0:v.rows.find(ae=>ae.operation===p),pe=ae=>ge=>{k.current=ge.currentTarget,j(ge.detail===0),I("recent"),m(Se=>Se===ae?null:ae)},ye=()=>{const ae=p;m(null),requestAnimationFrame(()=>{var me,$e;const ge=k.current,Se=Array.from(((me=J.current)==null?void 0:me.querySelectorAll(".ta-row[data-operation]"))??[]).find(Pe=>Pe.dataset.operation===ae);($e=ge!=null&&ge.isConnected&&ge.checkVisibility()?ge:Se??W.current)==null||$e.focus({preventScroll:!0})})},_e=()=>{K.current||L||(K.current=!0,P(ae=>ae+1))},he=v&&jY(v,t,s);return wt.createPortal(a.jsx("div",{className:"ta-report-backdrop",role:"presentation",children:a.jsxs("div",{className:"ta-report",ref:J,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title",children:[a.jsxs("header",{className:"ta-report-header",children:[a.jsxs("button",{type:"button",ref:W,className:"ta-back",onClick:Y,"aria-label":"Close tool activity",children:[a.jsx(UY,{}),a.jsx("span",{children:"Back to workspace"})]}),a.jsx("h2",{id:"tool-audit-title",children:"Tool activity"}),a.jsxs("div",{className:"ta-actions",children:[a.jsx("span",{className:"ta-freshness",role:"status",children:R?v?"Updating…":"Reading history…":v?`Updated ${new Date(v.capturedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}),a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh tool activity",title:"Refresh","data-loading":R||void 0,"aria-busy":R||L,onClick:_e,children:a.jsx(WY,{})})]})]}),a.jsxs("div",{className:"ta-workspace",ref:H,"data-inspecting":!!re||void 0,style:{"--ta-details-w":`${B}px`},children:[a.jsx("div",{className:"ta-body",children:a.jsxs("div",{className:"ta-report-content",children:[a.jsxs("div",{className:"ta-filters",children:[a.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(Qk).map(([ae,ge])=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===ae,onClick:()=>r(ae),children:ge},ae))}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:qY.map(ae=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":t===ae.id,onClick:()=>n(ae.id),children:ae.label},ae.id))})]}),R&&!v&&a.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),O&&a.jsxs("div",{className:"ta-message",role:"alert",children:[a.jsxs("p",{children:[v&&"Showing the last numbers. ",O]}),a.jsx("button",{type:"button",className:"btn",onClick:_e,children:"Try again"})]}),v&&he&&(v.total===0?a.jsxs("div",{className:"ta-empty",children:[a.jsxs("h3",{children:["No tool calls in the last ",Qk[s]]}),a.jsxs("p",{children:["ccdeck records each tool ",t==="all"?"Claude Code and Codex use":t==="claude"?"Claude Code uses":"Codex uses"," on this device, starting ",tC(v.startedAt),". Run a session and the calls show up here."]}),s!=="90"&&a.jsx("button",{type:"button",className:"btn",onClick:()=>r("90"),children:"Show the last 90 days"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"ta-summary",children:[he.lead," ",a.jsx("strong",{children:he.calls}),he.time&&a.jsxs(a.Fragment,{children:[" and spent ",a.jsx("strong",{children:he.time})," running them"]}),"."," ",he.failed?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{className:"ta-bad",children:[he.failed.toLocaleString()," failed"]})," (",he.failedShare,")."]}):"None failed."]}),(!v.storageOk||v.dropped>0||v.corrupt>0)&&a.jsxs("p",{className:"ta-warning",role:"status",children:["Some calls could not be saved or read, so these numbers may be a little low.",!v.storageOk&&" Check free disk space."]}),le.length>0&&a.jsxs("section",{className:"ta-highlights","aria-labelledby":"ta-highlights-title",children:[a.jsx("h3",{id:"ta-highlights-title",children:"Worth a look"}),a.jsx("ul",{children:le.map(ae=>a.jsx("li",{children:a.jsxs("button",{type:"button",className:"ta-highlight","data-kind":ae.kind,"data-operation":ae.operation,"aria-expanded":p===ae.operation,"aria-controls":p===ae.operation?"tool-operation-inspector":void 0,onClick:pe(ae.operation),children:[a.jsx("span",{className:"ta-highlight-glyph",children:zY[ae.kind]}),a.jsxs("span",{className:"ta-highlight-text",children:[a.jsxs("span",{children:[a.jsx("code",{children:lu(ae.operation)})," ",ae.title]}),a.jsx("small",{children:ae.detail})]})]})},ae.kind))})]}),a.jsxs("section",{className:"ta-tools","aria-labelledby":"ta-tools-title",children:[a.jsxs("div",{className:"ta-tools-head",children:[a.jsxs("h3",{id:"ta-tools-title",children:["Tools and commands ",a.jsx("span",{className:"ta-count",children:v.rows.length.toLocaleString()})]}),a.jsxs("label",{className:"ta-search",children:[a.jsx(HY,{}),a.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:c,onChange:ae=>d(ae.target.value)})]})]}),a.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:wY.map(ae=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":o===ae.id,onClick:()=>i(ae.id),children:ae.label},ae.id))}),a.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":o,children:[a.jsx("span",{children:"Name"}),a.jsx("span",{"data-col":"calls",children:"Calls"}),a.jsx("span",{"data-col":"time",children:"Total time"}),a.jsx("span",{"data-col":"slowest",children:"Usually"}),a.jsx("span",{"data-col":"failed",children:"Failed"})]}),a.jsx("ul",{className:"ta-list","data-sort":o,children:de.map(ae=>{const ge=af(ae,o),Se=iu(ae.operation);return a.jsx("li",{children:a.jsxs("button",{type:"button",className:"ta-row","data-operation":ae.operation,"data-selected":p===ae.operation||void 0,"aria-expanded":p===ae.operation,"aria-controls":p===ae.operation?"tool-operation-inspector":void 0,"aria-label":VY(ae),onClick:pe(ae.operation),children:[a.jsxs("span",{className:"ta-row-name",children:[a.jsx("span",{className:"ta-op",children:lu(ae.operation)}),Se&&a.jsx("span",{className:"ta-desc",children:Se}),a.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":ue&&ge?Math.max(.015,ge/ue):0}})]}),a.jsxs("span",{className:"ta-cell","data-col":"calls",children:[ae.calls.toLocaleString(),a.jsxs("span",{className:"ta-unit",children:[" ",ae.calls===1?"call":"calls"]})]}),a.jsxs("span",{className:"ta-cell","data-col":"time",children:[Wn(ae.totalMs),a.jsx("span",{className:"ta-unit",children:" total"})]}),a.jsxs("span",{className:"ta-cell","data-col":"slowest",children:[a.jsx("span",{className:"ta-unit",children:"usually "}),Wn(ae.medianMs)]}),a.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":ae.failed>0||void 0,children:ae.failed?a.jsxs(a.Fragment,{children:[ae.failed.toLocaleString(),a.jsx("span",{className:"ta-unit",children:" failed"}),a.jsx("small",{children:Kf(ae)})]}):a.jsxs("span",{className:"ta-zero",children:["0",a.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},ae.operation)})}),!ne.length&&a.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",c.trim(),"”."]}),!c&&!h&&ne.length>rC&&a.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>f(!0),children:["Show all ",ne.length.toLocaleString()]})]}),a.jsxs("details",{className:"ta-explain",children:[a.jsx("summary",{children:"How this is counted"}),a.jsxs("ul",{children:[a.jsx("li",{children:"A call’s time runs from when the agent starts the tool until it reports back, so it can include waiting for your approval."}),a.jsx("li",{children:"Total time adds every call together. Calls that ran at the same time each count, so it can be more than the time that actually passed."}),a.jsx("li",{children:"“Usually” is the middle value: half of the calls were quicker, half took longer."}),a.jsxs("li",{children:["A command line such as ",a.jsx("code",{children:"git add . && git commit"})," counts once for each command in it, and shares its time and result with both."]}),a.jsx("li",{children:"Claude and Codex report times in different ways, so do not compare one with the other."}),a.jsxs("li",{children:["Recorded on this device since ",tC(v.startedAt)," and kept for ",v.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),re&&F&&a.jsx(BY,{width:B,workspace:H,onCommit:V}),re&&a.jsx($Y,{keyboard:w,row:(S==null?void 0:S.operation)===p&&S.measurements?S.measurements:re,details:(S==null?void 0:S.operation)===p?S:null,loading:L,error:q,kind:C,setKind:I,onClose:ye})]})]})}),document.body)}const n0={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function KY(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function s0(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||KY(s))continue;const r=In(s,t);n.set(s.sessionId,{cost:r.total,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens})}return n}function YY(e,t){if(!e)return n0;const n={...n0};for(const[s,r]of t){const o=e.get(s);if(!o)continue;const i={cost:r.cost-o.cost,inputTokens:r.inputTokens-o.inputTokens,outputTokens:r.outputTokens-o.outputTokens,cacheReadTokens:r.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:r.cacheCreateTokens-o.cacheCreateTokens};i.cost<0||i.inputTokens<0||i.outputTokens<0||i.cost===0&&i.inputTokens===0&&i.outputTokens===0&&i.cacheReadTokens===0&&i.cacheCreateTokens===0||(n.cost+=i.cost,n.inputTokens+=Math.max(0,i.inputTokens),n.outputTokens+=Math.max(0,i.outputTokens),n.cacheReadTokens+=Math.max(0,i.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,i.cacheCreateTokens),n.sessions+=1)}return n}function r0(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const Yf=[{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 XY(e,t,n=Yf.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 ZY(e,t=new Date){return e==="today"?r0(1,t):e==="month"?r0(t.getDate(),t):"20200101"}const En=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Ch=e=>typeof e=="string"?e:"";function Q3(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const s of t){const r=Array.isArray(s==null?void 0:s.modelBreakdowns)?s.modelBreakdowns:[];for(const o of r){const i=Ch(o==null?void 0:o.modelName);if(!i)continue;let c=n.get(i);c||(c={model:i,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(i,c)),c.cost+=En(o==null?void 0:o.cost),c.inputTokens+=En(o==null?void 0:o.inputTokens),c.outputTokens+=En(o==null?void 0:o.outputTokens),c.cacheReadTokens+=En(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=En(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,r)=>r.cost-s.cost||r.tokens-s.tokens)}const JY=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function QY(e){var t;return((t=JY.exec(e))==null?void 0:t[0])??e}function eX(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=[];for(const r of n){const o=Ch(r==null?void 0:r.period);if(!o)continue;const i=QY(o),c=r==null?void 0:r.metadata,d=typeof(c==null?void 0:c.lastActivity)=="string"?Date.parse(c.lastActivity):NaN;s.push({sessionId:i,label:t.get(i)??null,agent:Ch(r==null?void 0:r.agent)||"claude",cost:En(r==null?void 0:r.totalCost),tokens:En(r==null?void 0:r.totalTokens),models:Array.isArray(r==null?void 0:r.modelsUsed)?r.modelsUsed.map(Ch).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return s.sort((r,o)=>o.cost-r.cost||o.tokens-r.tokens)}function tX(e,t=I1(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+En(i==null?void 0:i.totalCost),0),r=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+r}}function nX(e,t,n){const s=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${s}
91
- 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.`:s}function I1(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=En(t.cacheReadTokens),h=En(t.cacheCreationTokens),f=En(t.inputTokens),p=En(t.outputTokens);return{cost:En(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:En(t.totalTokens)||f+p+d+h}}const n=Q3(e),s=d=>n.reduce((h,f)=>h+d(f),0),r=s(d=>d.inputTokens),o=s(d=>d.outputTokens),i=s(d=>d.cacheReadTokens),c=s(d=>d.cacheCreateTokens);return{cost:s(d=>d.cost),inputTokens:r,outputTokens:o,cacheReadTokens:i,cacheCreateTokens:c,tokens:r+o+i+c}}function sX(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 eP(e,t){var n;return((n=Yf.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function rX(e,t,n){const s=e!=null,r=I1(e);return{fromRange:s,cost:s?r.cost+n.cost:t.cost.total,inputTokens:s?r.inputTokens+n.inputTokens:t.inputTokens,outputTokens:s?r.outputTokens+n.outputTokens:t.outputTokens,cacheReadTokens:s?r.cacheReadTokens+n.cacheReadTokens:t.cacheReadTokens,cacheCreateTokens:s?r.cacheCreateTokens+n.cacheCreateTokens:t.cacheCreateTokens,hasCost:s?r.cost>0:t.cost.total>0,tokenSum:s?r.tokens:t.sum,showCostBar:!s}}const tP="agent-dag.usagePeriod";function aX(){const e=Ve(tP);return Yf.some(t=>t.key===e)?e:"today"}function oX(e){ze(tP,e)}const nP="agent-dag.usageSessionsOpen";function iX(){return Ve(nP)==="1"}function lX(e){ze(nP,e?"1":"0")}function L1({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(o,i,c)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${i}`,style:{width:`${d}%`},title:`${c}: ${Xe(o)} (${d.toFixed(0)}%)`},i)},r=t==="lg";return a.jsxs("div",{className:r?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[s(e.input,"cb-input","input"),s(e.output,"cb-output","output"),s(e.cacheRead,"cb-cache-r","cache read"),s(e.cacheWrite,"cb-cache-w","cache write")]})}const sh="https://ccdeck.dev/guides",cX={localNetwork:{href:`${sh}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${sh}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${sh}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${sh}/first-run/#film`,subject:"first run"}};function cu({film:e,action:t=!1}){const{href:n,subject:s}=cX[e];return a.jsxs("a",{className:t?"film-link film-action":"film-link",href:n,target:"_blank",rel:"noopener noreferrer",title:`The ${s} video on ccdeck.dev, 30 seconds — opens in your browser`,children:[t?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"m8 5 11 7-11 7V5Z"})}),a.jsx("span",{children:"Watch video"}),a.jsx("span",{className:"film-duration",children:"30 s"})]}):"Watch · 30 s",a.jsxs("span",{className:"vis-hidden",children:[": the ",s," video on ccdeck.dev, opens in your browser"]})]})}const Ct="ccdeck",uX="/brand/ccdeck-mark-gradient-small-optical.svg",dX="/brand/ccdeck-mark-mono-dark-small-optical.svg";function sP(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 rP(){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:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}function aP(){return 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:"M3.3 10.7L10.7 3.3M5.5 3.3h5.2v5.2"})})}function hX({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.jsx(aP,{})}),a.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function oP({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:a.jsx(aP,{})}),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 fX(e,t,n,s,r=!1){const o=Math.max(0,t-s),i=Math.max(0,n-o);if(i<120)return null;const c=Math.min(100,i/n*100),d=e-c;if(r||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:c,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,f=i>0?e/i:0,p=f>0?h/f:1/0,m={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(p<o&&p<86400){const w=Math.floor(p/3600),j=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${j}m`:`${j}m`}return m}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Ra({pct:e,label:t,reset:n,resetAt:s,windowSec:r,limitReached:o,nowSec:i}){const c=!!s&&s<=i,d=e!=null&&!c,h=d?Math.min(100,Math.max(0,e)):0,p=o||h>=90?"var(--err)":h>=70?"var(--warn)":"var(--accent)",m=h<1,w=c?"reset":d?m?"< 1%":`${Math.round(h)}%`:"no reading",j=m?2:h,b=s&&!c?Su(s,i):null,k=d&&s&&r?fX(h,s,r,i,o):null,[v,N]=y.useState(!1),S=y.useId();return a.jsxs("div",{className:"qb-row",children:[a.jsxs("div",{className:"qb-meta",children:[a.jsxs("span",{className:"qb-label",children:[t,o&&!c&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:w})]}),a.jsxs("div",{className:"qb-track",children:[d&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${j/100})`,background:p,opacity:m?.4:1}}),k&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${k.expectedPct}%)`},children:a.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:k.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(k.expectedPct)}% by now`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[c?a.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):b?a.jsxs("span",{className:"qb-reset",children:["resets in ",b]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,k&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:k.color},"aria-expanded":v,"aria-controls":v?S:void 0,onClick:()=>N(E=>!E),children:[a.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:k.isDeficit?"var(--err)":"var(--ok)"}}),k.runsOutIn?`runs out in ${k.runsOutIn}`:k.label]})]}),v&&k&&a.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(k.expectedPct),"% by now."]})]})}function iP(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 pX(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 mX(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 gX(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";case"rate_limited":return"OpenAI asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"ChatGPT API unreachable — click ↻ to retry."}}function yX({quota:e,quotaLoading:t,nowSec:n,incident:s}){const r=iP(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",r&&!t&&a.jsxs("span",{className:"up-section-age",title:pX(e==null?void 0:e.source),children:[r,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),a.jsx(oP,{incident:s}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(Ra,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(Ra,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(Ra,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(Ra,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(Ra,{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 — ${Ct} only reports them`,children:sP("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:mX(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function wX({codexQuota:e,codexLoading:t,nowSec:n,incident:s}){var o,i;const r=iP(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:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&a.jsx("span",{className:"up-plan-badge",children:e.planLabel}),r&&!t&&a.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:r})]}),a.jsx(oP,{incident:s}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[(o=e.windows)==null?void 0:o.map(c=>a.jsx(Ra,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,limitReached:e.limitReached&&c.pct>=100,nowSec:n},c.id)),(i=e.extraWindows)==null?void 0:i.map(c=>a.jsx(Ra,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,nowSec:n},c.id)),e.creditLimit&&a.jsx(Ra,{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:n}),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 — ${Ct} only reports them`,children:sP("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:gX(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function xX({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(s=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:s.model,children:Da(s.model)}),a.jsx("td",{className:"up-num",children:gt(s.tokens)}),s.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:Xe(s.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:Kr})]},s.model)):n.map(s=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:s.model===Jk?"no model reported yet":s.model,children:s.model===Jk?"unknown":Da(s.model)}),a.jsx("td",{className:"up-num",children:gt(s.inputTokens+s.outputTokens)}),s.priced?a.jsx("td",{className:"up-num up-cost-val",children:Xe(s.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:Kr})]},s.model))})]})]})}function vX({period:e,rangePending:t,setPeriod:n}){const s=y.useRef([]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:r=>{var c;const o=s.current.indexOf(r.target);if(o<0)return;const i=XY(r.key,o);i!==null&&(r.preventDefault(),(c=s.current[i])==null||c.focus())},children:Yf.map((r,o)=>a.jsx("button",{type:"button",ref:i=>{s.current[o]=i},tabIndex:e===r.key?0:-1,"aria-pressed":e===r.key,"data-pending":e===r.key&&t?"":void 0,title:e===r.key&&t?`Reading ${r.noun} from the transcripts on this machine…`:r.hint,className:"uh-range-btn",onClick:()=>n(r.key),children:r.label},r.key))}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${eP(e,e)}…`:""})]})}function bX(e,t){return t.includes("..")?!1:e==="codex"?/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i.test(t):e==="claude"&&/^[a-z\d][a-z\d._:-]{0,255}$/i.test(t)}function kX(e){return e.reason==="not_found"?"No usage found in the local logs for this session.":e.reason==="ambiguous"?"More than one local log matches this session ID.":e.reason==="no_install"?"Install ccusage to read this session’s usage.":e.reason==="busy"?"Other usage reports are still loading. Try again in a moment.":e.reason==="timeout"?"The session report took too long. Try again.":/unknown|unrecognized|unexpected|unsupported/i.test(e.error??"")&&/speed|--id|session|claude/i.test(e.error??"")?"This copy of ccusage does not support the report. Update ccusage and try again.":"Could not read this session’s usage. Try again."}function aC({sessionId:e,agent:t,label:n,onOpen:s,children:r}){return s&&bX(t,e)?a.jsxs("button",{type:"button",className:"up-session-row up-session-open",title:`Inspect session usage · ${n}`,onClick:()=>s({sessionId:e,agent:t,label:n}),children:[r,a.jsx("svg",{className:"up-session-inspect",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"m3.5 2 3 3-3 3"})}),a.jsx("span",{className:"vis-hidden",children:"Open session usage"})]}):a.jsx("div",{className:"up-session-row",children:r})}function jX({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:s,sessionsOpen:r,setSessionsOpen:o,periodNoun:i,sessionScale:c,onOpenSession:d,boardProviders:h}){const f=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":r,"aria-controls":"up-sessions",title:r?"Hide the per-session breakdown":`Show the per-session breakdown — ${f} session${f===1?"":"s"}`,onClick:()=>o(p=>!p),children:["By session",e&&a.jsxs("span",{className:"up-section-age",title:nX(i,c,Xe),children:["active ",i]}),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:!r,children:[e&&t.map(p=>{const m=s.get(p.sessionId);return a.jsxs(aC,{sessionId:p.sessionId,agent:p.agent,label:p.label??Qh(p.sessionId,8),onOpen:d,children:[m?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`sl-dot state-${m}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:il(m)})]}):a.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),a.jsx("span",{className:`up-session-label${p.label?"":" up-session-id"}`,title:p.label?`${p.label}
92
- ${p.sessionId}`:p.sessionId,children:p.label??Qh(p.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:gt(p.tokens)}),p.cost>0?a.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:Xe(p.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:Kr})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>a.jsxs(aC,{sessionId:p.sessionId,agent:(h==null?void 0:h.get(p.sessionId))??"claude",label:p.label,onOpen:d,children:[a.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:il(p.state)}),a.jsx("span",{className:"up-session-label",children:p.label}),a.jsx("span",{className:"up-session-tokens",children:gt(p.inputTokens+p.outputTokens)}),p.cost>0?a.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${gt(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Xe(p.cost),p.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:Kr})]},p.sessionId))]})]})}function NX(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const SX={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function lP(e){const t=e.toLowerCase(),n=Vt(SX,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function _X(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Mwe(e,t=[]){const n=t.length?_X(t.map(lP)):NX(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function EX(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]}const rh=e=>e.toLocaleString(),oC=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function CX({session:e,onClose:t}){var k,v;const[n,s]=y.useState("auto"),[r,o]=y.useState(0),[i,c]=y.useState(null),d=y.useRef(r),h=y.useRef(null),f=ct(t,{focusRef:h}),p=xt(t),m=i!=null&&i.ok&&((k=i.detail)==null?void 0:k.speed)===n?i.detail:void 0;y.useEffect(()=>{const N=new AbortController;c(null);const S=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return r!==d.current&&S.set("refresh","1"),d.current=r,fetch(`/api/ccusage/session?${S}`,{signal:N.signal}).then(async E=>{const C=await E.json();N.signal.aborted||c(C)}).catch(()=>{N.signal.aborted||c({ok:!1})}),()=>N.abort()},[e.agent,e.sessionId,n,r]);const w=(m==null?void 0:m.models.filter(N=>N.missingPricing))??[],j=m?[{name:"Input",n:m.inputTokens,color:"var(--usage-blue)"},{name:"Output",n:m.outputTokens,color:"var(--usage-purple)"},{name:"Cache read",n:m.cacheReadTokens,color:"var(--usage-teal)"},{name:"Cache write",n:m.cacheCreationTokens,color:"var(--usage-orange)"}]:[],b=j.reduce((N,S)=>N+S.n,0);return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"su-title",children:[a.jsx("h2",{id:"session-usage-title",children:"Session usage"}),a.jsx("span",{title:e.label,children:e.label})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(N=>N+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:a.jsx(rP,{})}),a.jsx("button",{type:"button",className:"glyph-btn",ref:h,onClick:t,"aria-label":"Close session usage (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body su-body","aria-busy":!i,children:[a.jsxs("div",{className:"su-scope",children:[a.jsx("span",{children:lP(e.agent)}),a.jsx("span",{children:"Whole session"})]}),e.agent==="codex"&&a.jsxs("label",{className:"su-pricing",children:["Estimate using",a.jsxs("select",{value:n,disabled:!i,onChange:N=>{c(null),s(N.target.value)},children:[a.jsx("option",{value:"auto",children:"Session settings / config"}),a.jsx("option",{value:"standard",children:"Standard scenario"}),a.jsx("option",{value:"fast",children:"Fast scenario"}),a.jsx("option",{value:"flex",children:"Flex scenario"})]})]}),!i&&a.jsx("p",{className:"su-message",role:"status",children:"Reading local session usage…"}),i&&!i.ok&&a.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[kX(i)," Use Refresh to try again."]}),m&&a.jsxs(a.Fragment,{children:[a.jsxs("dl",{className:"su-totals",children:[a.jsxs("div",{children:[a.jsxs("dt",{children:[n==="auto"?"Estimated cost":"Scenario estimate",w.length>0?" · partial":""]}),a.jsxs("dd",{children:[m.totalCost>0?Xe(m.totalCost):m.totalTokens>0?"No cost reported":"$0.00",w.length>0&&m.totalCost>0?"+":""]})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Total tokens"}),a.jsx("dd",{title:rh(m.totalTokens),children:gt(m.totalTokens)})]})]}),a.jsxs("section",{"aria-labelledby":"session-tokens-title",children:[a.jsx("div",{className:"su-section-head",children:a.jsx("h3",{id:"session-tokens-title",children:"Token breakdown"})}),a.jsxs("div",{className:"su-cache-reuse",children:[a.jsx("span",{children:"Cached input reuse"}),a.jsx("strong",{children:((v=m.cacheReuse)==null?void 0:v.pct)!=null?`${m.cacheReuse.pct.toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"}),a.jsx("span",{className:"su-note",children:m.cacheReuse&&m.cacheReuse.measured>0?`${m.cacheReuse.measured} of ${m.cacheReuse.total} ${m.cacheReuse.unit} measured${m.cacheReuse.pct==null?" · no input tokens":""}`:"No cache measurements available"})]}),b>0&&a.jsx("div",{className:"su-composition","aria-hidden":"true",children:j.filter(N=>N.n>0).map(N=>a.jsx("span",{style:{width:`${N.n/b*100}%`,background:N.color}},N.name))}),a.jsx("dl",{className:"su-tokens",children:j.map(({name:N,n:S,color:E})=>a.jsxs("div",{children:[a.jsxs("dt",{children:[a.jsx("span",{className:"su-key",style:{background:E},"aria-hidden":"true"}),N]}),a.jsxs("dd",{title:rh(S),children:[gt(S),a.jsx("span",{className:"su-share",children:b>0?`${(S/b*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},N))}),m.reasoningOutputTokens>0&&a.jsxs("p",{className:"su-note su-reasoning",children:[gt(m.reasoningOutputTokens)," reasoning tokens, included in output."]})]}),a.jsxs("section",{className:"su-models","aria-labelledby":"session-models-title",children:[a.jsxs("div",{className:"su-section-head",children:[a.jsx("h3",{id:"session-models-title",children:"Models"}),a.jsxs("span",{children:[m.models.length," used"]})]}),a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{scope:"col",children:"Model"}),a.jsx("th",{scope:"col",children:"Tokens"})]})}),a.jsx("tbody",{children:m.models.map(N=>a.jsxs("tr",{children:[a.jsxs("th",{scope:"row",title:N.model,children:[Da(N.model),N.missingPricing&&a.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),a.jsx("td",{title:rh(N.totalTokens),children:gt(N.totalTokens)})]},N.model))})]}),m.models.length===0&&a.jsx("p",{className:"su-note",children:"No model breakdown was reported."})]}),w.length>0&&a.jsx("p",{className:"su-note",children:"Tokens on unpriced models are included; their cost is missing from the estimate."}),a.jsxs("dl",{className:"su-dates",children:[m.firstActivity&&a.jsxs("div",{children:[a.jsx("dt",{children:"First activity"}),a.jsx("dd",{children:a.jsx("time",{dateTime:m.firstActivity,title:new Date(m.firstActivity).toLocaleString(),children:oC(m.firstActivity)})})]}),m.lastActivity&&a.jsxs("div",{children:[a.jsx("dt",{children:"Last activity"}),a.jsx("dd",{children:a.jsx("time",{dateTime:m.lastActivity,title:new Date(m.lastActivity).toLocaleString(),children:oC(m.lastActivity)})})]}),m.entries!=null&&a.jsxs("div",{children:[a.jsx("dt",{children:"Usage records"}),a.jsx("dd",{children:rh(m.entries)})]})]})]}),a.jsxs("footer",{className:"su-footer",children:[a.jsxs("p",{className:"su-note",children:[n==="auto"?"Estimated from local logs, not an invoice.":"Pricing scenario · does not change settings or billing."," Includes the whole session."]}),a.jsxs("details",{className:"su-id su-assumptions",children:[a.jsx("summary",{children:"Estimate details"}),a.jsxs("p",{className:"su-note",children:[e.agent==="codex"?n==="auto"?"ccusage estimates from recorded Standard, Fast and Flex settings; unmarked usage can use your current Codex config. Requested modes do not confirm billed rates.":"This scenario applies one mode to the whole session. It does not change Codex or your billing. Models without a published multiplier keep standard pricing.":"Cost is the ccusage estimate from local logs, not an invoice."," The whole session can extend beyond the period selected in Usage."]})]}),a.jsxs("details",{className:"su-id",children:[a.jsx("summary",{children:"Session ID"}),a.jsx("code",{children:e.sessionId})]})]})]})]})}),document.body)}const ah=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function TX(e){var o;const t=(e.resetAt-e.windowSec)*1e3,n=i=>36+Math.max(0,Math.min(1,(i-t)/(e.windowSec*1e3)))*516,s=i=>12+Math.max(0,Math.min(100,i))/100*150,r=[];for(const i of e.points){if(!Number.isFinite(i.t)||!Number.isFinite(i.pct)||i.pct<0||i.pct>100)continue;const c=(o=r.at(-1))==null?void 0:o.at(-1);(!c||i.t-c.t>10*6e4||i.t<=c.t)&&r.push([]),r.at(-1).push({...i,x:n(i.t),y:s(i.pct)})}return r}function RX(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));return n<1?"just now":n<60?`${n}m ago`:n<1440?`${Math.floor(n/60)}h ${n%60}m ago`:`${Math.floor(n/1440)}d ago`}function Fa(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Xf(e){return e==null}const a0="self";function Ps(e,t=!1){const n=Fa(e?a0:null,a0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function An(e){return Xf(e?a0:null)}const hl=400;function fl({armedFor:e,target:t,armedAt:n,now:s,gapMs:r}){return e!==t?"arm":s-n<r?"ignore":"fire"}function cP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Kn(e){return e==null||e==="BODY"||e==="HTML"}const el=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),iC=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function AX({series:e}){const t=TX(e),n=(e.resetAt-e.windowSec)*1e3,s=e.resetAt*1e3;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"qh-chart-wrap",children:[a.jsxs("div",{className:"qh-axis","aria-hidden":"true",children:[a.jsx("span",{children:"100%"}),a.jsx("span",{children:"50%"}),a.jsx("span",{children:"0%"})]}),a.jsxs("svg",{className:"qh-chart",viewBox:"36 12 516 150",role:"img","aria-label":`${e.label}: observed remaining quota over time. Dashed line is an even-use guide, not a forecast.`,children:[[0,50,100].map(r=>a.jsx("g",{children:a.jsx("line",{className:"qh-grid",x1:"36",x2:"552",y1:12+r*1.5,y2:12+r*1.5})},r)),a.jsx("path",{className:"qh-guide",d:"M36 12 L552 162"}),t.map((r,o)=>a.jsxs("g",{children:[r.length>1&&a.jsx("path",{className:"qh-observed",d:r.map((i,c)=>`${c?"L":"M"}${i.x} ${i.y}`).join(" ")}),[r[0],...r.length>1?[r.at(-1)]:[]].map(i=>a.jsx("circle",{className:"qh-point",cx:i.x,cy:i.y,r:"2.5",children:a.jsxs("title",{children:[el(i.t)," · ",Math.round(100-i.pct),"% remaining"]})},i.t))]},o))]}),a.jsxs("div",{className:"qh-times","aria-hidden":"true",children:[a.jsx("span",{children:e.windowSec>86400?el(n):iC(n)}),a.jsx("span",{children:e.windowSec>86400?el(s):iC(s)})]})]}),a.jsxs("div",{className:"qh-legend",children:[a.jsxs("span",{children:[a.jsx("i",{className:"qh-key"}),"Observed remaining"]}),a.jsxs("span",{children:[a.jsx("i",{className:"qh-key qh-key-guide"}),"Even-use guide"]})]})]})}function MX({providers:e,accounts:t,onClose:n,instant:s=!1}){const[r,o]=y.useState(e.claude?"claude":"codex"),[i,c]=y.useState(null),[d,h]=y.useState(!0),[f,p]=y.useState(!1),[m,w]=y.useState(""),[j,b]=y.useState(0),[k,v]=y.useState(Date.now),N=y.useRef(!1),S=y.useRef(null),E=ct(n,{focusRef:S}),C=xt(n),I=t[r];y.useEffect(()=>{let O=!1,M=null;c(null),p(!1);const q=async()=>{if(M)return;if(!I){N.current=!1,h(!1);return}const D=new AbortController;M=D,N.current=!0;const P=window.setTimeout(()=>D.abort(),12e3);h(!0);try{const K=await fetch(`/api/quota/history?provider=${r}&account=${encodeURIComponent(I)}`,{signal:D.signal}),G=await K.json();if(!K.ok||!G.ok||!Array.isArray(G.series))throw new Error("History unavailable");O||(c(G.account===I?G:{...G,series:[]}),p(!1))}catch{O||p(!0)}finally{window.clearTimeout(P),M=null,O||(N.current=!1,h(!1))}};q();const A=window.setInterval(()=>{v(Date.now()),document.visibilityState==="visible"&&q()},6e4);return()=>{O=!0,M==null||M.abort(),window.clearInterval(A)}},[r,I,j]);const R=((i==null?void 0:i.series)??[]).slice().sort((O,M)=>M.resetAt-O.resetAt||O.windowSec-M.windowSec),$=R.find(O=>ah(O)===m)??R.find(O=>O.resetAt*1e3>k&&O.windowSec<=6*3600)??R[0],L=$==null?void 0:$.points.at(-1),U=()=>{An(N.current)&&(N.current=!0,b(O=>O+1))};return wt.createPortal(a.jsx("div",{className:"modal-backdrop",role:"presentation",...C,children:a.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":s||void 0,ref:E,role:"dialog","aria-modal":"true","aria-labelledby":"quota-history-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("h2",{id:"quota-history-title",children:"Quota history"}),a.jsxs("div",{className:"qh-header-actions",children:[a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh quota history",title:"Read recorded quota history",...Ps(d),onClick:U,children:d?"…":a.jsx(rP,{})}),a.jsx("button",{type:"button",ref:S,className:"glyph-btn",onClick:n,"aria-label":"Close quota history",children:"×"})]})]}),a.jsxs("div",{className:"modal-body qh-body","aria-busy":d,children:[a.jsxs("div",{className:"qh-controls",children:[a.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(O=>e[O]).map(O=>a.jsx("button",{type:"button",className:"qh-provider","aria-pressed":r===O,onClick:()=>{o(O),w("")},children:O==="claude"?"Claude":"Codex"},O))}),R.length>0&&a.jsxs("label",{className:"qh-window",children:["Window",a.jsx("select",{"aria-label":"Quota window",value:$?ah($):"",onChange:O=>w(O.target.value),children:R.map(O=>a.jsxs("option",{value:ah(O),children:[O.label," · ",el(O.resetAt*1e3)]},ah(O)))})]})]}),f&&a.jsxs("p",{className:"qh-message",role:"status",children:["Could not read saved quota history. Use Refresh to try again.",i&&" Showing the last loaded history."]}),$&&L?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"qh-summary",children:[a.jsxs("strong",{children:[Math.round(100-L.pct),"% remaining"]}),a.jsxs("span",{title:el(L.t),children:["Captured ",RX(L.t,k),$.resetAt*1e3<=k&&" · window ended"]})]}),a.jsx(AX,{series:$}),a.jsx("p",{className:"qh-note",children:"Recorded quota readings. The dashed guide shows even use until reset; it is not a forecast. Gaps are left unconnected."}),a.jsxs("details",{className:"qh-readings",children:[a.jsxs("summary",{children:["Recorded readings (",$.points.length,")"]}),a.jsxs("table",{children:[a.jsx("caption",{children:$.points.length>50?"Latest 50 readings":"Recorded readings"}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{scope:"col",children:"Captured"}),a.jsx("th",{scope:"col",children:"Remaining"})]})}),a.jsx("tbody",{children:$.points.slice(-50).reverse().map(O=>a.jsxs("tr",{children:[a.jsx("td",{children:el(O.t)}),a.jsxs("td",{children:[(100-O.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},O.t))})]})]})]}):!f&&a.jsx("p",{className:"qh-message",role:"status",children:d?"Reading quota history…":I?"No recorded readings yet. History fills in as ccdeck receives quota updates.":"History starts when a quota reading can be matched to your active account."}),(i==null?void 0:i.storageOk)===!1&&a.jsx("p",{className:"qh-note",role:"status",children:"History is available for this run, but could not be saved to disk."}),a.jsx("footer",{className:"qh-note qh-footer",children:"Recorded on this machine from existing quota reads. No extra provider requests. Account changes and resets are kept separate."})]})]})}),document.body)}const $X=6e4,IX=2e4;function LX(e){const[t,n]=y.useState(null),[s,r]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!An(i.current))){h&&(i.current=!0,r(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(IX)});p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,r(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),$X),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&c(!0)}}}const OX=6e4;function PX(e){const[t,n]=y.useState(null),[s,r]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!An(i.current))){h&&(i.current=!0,r(!0));try{const p=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,r(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),OX),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&c(!0)}}}const lC=6e4;function DX(e,t,n){const[s,r]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(0),h=y.useRef(0);y.useEffect(()=>{const p=()=>document.visibilityState==="visible",m=()=>{p()&&d(b=>b+1)},w=window.setInterval(m,lC),j=()=>{p()&&Date.now()-h.current>=lC&&d(b=>b+1)};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",j)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,j=ZY(w);return i(!0),fetch(`/api/ccusage?since=${j}${m?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(h.current=Date.now(),r({period:w,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,c]),{...sX(s,e),loading:o}}const FX=e=>1-Math.pow(1-e,5),uP=420;function BX(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 s=Math.max(Math.abs(e),Math.abs(t));return s===0||n/s>=.005}function qX(e,t,n,s=uP){return n>=s?t:n<=0?e:e+(t-e)*FX(n/s)}function dP(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function cC(e,t,n,s={}){const r=s.now??(()=>performance.now()),o=s.raf??(w=>requestAnimationFrame(w)),i=s.cancel??(w=>cancelAnimationFrame(w)),c=s.reducedMotion??dP,d=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!BX(e,t))return n(t),()=>{};const h=r();let f=0,p=!0;const m=()=>{if(!p)return;const w=r()-h;n(qX(e,t,w)),w<uP&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const UX=typeof window>"u"?y.useEffect:y.useLayoutEffect;function So(e,{countIn:t=!1}={}){const[n,s]=y.useState(e),r=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{r.current=n},[n]),UX(()=>{!t||dP()||(r.current=0,s(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return cC(0,e,c=>{r.current=c,s(c)});r.current=e,s(e);return}return cC(r.current,e,c=>{r.current=c,s(c)})},[e]),n}function hP(e,t,n){const s=HX*Math.max(1,n/pP);let r=0;for(const[o,i]of t){const c=e.get(o);if(c===void 0)continue;const d=i.cost-c.cost;d>0&&d<=s&&(r+=d)}return r}const uC={samples:[],last:new Map,watched:0},fP=10*6e4,WX=6e4,pP=5e3,HX=20;function zX(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<pP)return e;const r=e.watched+hP(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=fP);return o.push({t,watched:r}),{samples:o,last:n,watched:r}}function VX(e,t,n){const s=e.samples[0];if(!s)return null;const r=t-s.t;if(r<WX)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+hP(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:r/1e3,spanMin:Math.min(fP/6e4,Math.ceil(r/6e4))}:null}function GX(e,t,n){const s=y.useRef(uC),r=y.useRef(null);return y.useMemo(()=>{const o=iY(e.agents.values()),i=nY(e.agents.values());r.current!==n&&(r.current=n,s.current=uC);const c=s0(e.agents.values(),t);n!=null&&(s.current=zX(s.current,t,c));const d=n==null?null:VX(s.current,t,c),h=d?{label:g1(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const KX=3e4;function mP(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),KX);return()=>window.clearInterval(n)},[]),e}function dC(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function YX(e,t,n){return e?t.some(s=>s.cost<=0&&s.tokens>0):n.some(s=>!s.priced)}function XX(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function ZX(e){const t=new Map;for(const n of e){if(n.kind!=="root"||!n.sessionId)continue;const s=n.label||n.cwdBasename;s&&t.set(n.sessionId,s)}return t}function JX(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function QX(e){const t=new Map;for(const n of e){if(!n.label)continue;const s=t.get(n.label);s?s.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const s=n.label?t.get(n.label)??[]:[];return s.length>1?{...n,label:`${n.label} ${D3(n.sessionId,s)}`}:n})}function eZ({state:e,now:t,providers:n,incidents:s=[],leaving:r,onClose:o,liveSince:i=null}){const c=Ln(),[d,h]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Map([...e.agents.values()].filter(Le=>Le.kind==="root").map(Le=>[Le.sessionId,Le.provider??"claude"])),[e,e.revision]),{quota:w,loading:j,refresh:b}=LX(n.claude),{data:k,loading:v,refresh:N}=PX(n.codex),S=mP(),{byModel:E,totalCost:C,totalTokens:I}=GX(e,t,i),R=y.useMemo(()=>lY(e.agents.values()),[e,e.revision]),[$,L]=y.useState(aX);y.useEffect(()=>{oX($)},[$]);const[U,O]=y.useState(iX);y.useEffect(()=>{lX(U)},[U]);const[M,q]=y.useState(0),A=y.useRef(()=>new Map);A.current=()=>i==null?null:s0(e.agents.values(),t);const D=y.useCallback(()=>A.current(),[]),{data:P,shown:K,stale:G,loading:W,baseline:H}=DX($,M,D),F=P!=null,B=W&&G,Z=y.useMemo(()=>ZX(e.agents.values()),[e,e.revision]),V=y.useMemo(()=>JX(e.agents.values()),[e,e.revision]),X=y.useMemo(()=>F?Q3(P):[],[P,F]),Y=y.useMemo(()=>F?QX(eX(P,Z).slice(0,12)):[],[P,F,Z]),J=y.useMemo(()=>I1(P),[P]),ee=y.useMemo(()=>tX(P,J.cost),[P,J.cost]),ne=eP(K,$),le=y.useMemo(()=>F?YY(H,s0(e.agents.values(),t)):n0,[e,e.revision,H,F,t]),de=rX(P,{...I,cost:C},le),ue=de.hasCost,re=de.tokenSum,pe=So(de.cost),ye=So(de.inputTokens),_e=So(de.outputTokens),he=So(de.cacheReadTokens),ae=So(de.cacheCreateTokens),ge=E.filter(dC),Se=R.filter(dC),me=YX(F,X,ge),$e=j||v,Pe=()=>{b(),N(),q(Le=>Le+1)},qe=XX(n);return a.jsxs("aside",{className:`usage-panel${r?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[a.jsxs("div",{className:"up-header",children:[a.jsx("h2",{children:"Usage"}),a.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Open quota history",title:"Quota history",onClick:Le=>p(Le.detail===0?"keyboard":"pointer"),children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M4 4v16h16M8 8l4 4 4-3 4 7"})})}),(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Pe,...Ps($e),"aria-label":qe,title:qe,children:$e?"…":a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})})}),a.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:gn("Close","U",c),children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})})]})]}),n.claude&&a.jsx(yX,{quota:w,quotaLoading:j,nowSec:S,incident:s.find(Le=>Le.provider==="claude")}),n.codex&&a.jsx(wX,{codexQuota:k,codexLoading:v,nowSec:S,incident:s.find(Le=>Le.provider==="codex")}),F&&a.jsx(vX,{period:$,rangePending:B,setPeriod:L}),re>0?a.jsxs(a.Fragment,{children:[ue&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:F?void 0:ZE(c),children:[a.jsx("span",{className:"up-total-value",children:Xe(pe)}),a.jsx("span",{className:"up-total-label",children:F?ne:sY})]}),a.jsxs("p",{className:"up-source",children:["Local estimate · ",F?"ccusage":"live sessions"]}),de.showCostBar&&a.jsx(L1,{cost:C})]}),a.jsxs("div",{className:"up-tokens-row",title:F?void 0:ZE(c),children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),gt(ye)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),gt(_e)]}),de.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),gt(he)]}),de.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),gt(ae)]}),!ue&&a.jsx("span",{className:"up-tok up-scope",children:rY})]}),(F?X.length:ge.length)>0&&a.jsx(xX,{fromRange:F,rangeModelRows:X,boardModelRows:ge}),F&&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 ",ne," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(F?Y.length:Se.length)>0&&a.jsx(jX,{fromRange:F,rangeSessionRows:Y,boardSessionRows:Se,boardStates:V,sessionsOpen:U,setSessionsOpen:O,periodNoun:ne,sessionScale:ee,onOpenSession:h,boardProviders:m}),me&&a.jsxs("div",{className:"up-hint",children:["“",Kr,"” 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:F?(K??$)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",ne,".",a.jsx("br",{}),"Try a longer period."]}):a.jsxs(a.Fragment,{children:["No usage data yet.",a.jsx("br",{}),"Start a Claude Code or Codex session."]})}),a.jsx("div",{className:"film-foot",children:a.jsx(cu,{film:"usage"})}),d&&a.jsx(CX,{session:d,onClose:()=>h(null)},`${d.agent}:${d.sessionId}`),f&&a.jsx(MX,{providers:n,instant:f==="keyboard",accounts:{claude:w==null?void 0:w.historyAccount,codex:k==null?void 0:k.historyAccount},onClose:()=>p(null)})]})}function Mg(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function O1(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Mg(t/1e3),unit:"KB/s"}:t<9995e5?{value:Mg(t/1e6),unit:"MB/s"}:{value:Mg(t/1e9),unit:"GB/s"}}function Zf(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 uu(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const tZ="thermal:Throttling";function P1(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function nZ(e){var n,s,r,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),(s=e.loadavg)!=null&&s.length&&(t["load:1m"]=e.loadavg[0]);for(const i of((r=e.thermal)==null?void 0:r.celsius)??[])t[`thermal:${i.label}`]=i.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[tZ]=P1(e.thermal.throttle)),t}function Fc(e,t){return t==="B/s"?uu(O1(e)):t==="ms"?uu(Zf(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function oh(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Fc(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function sZ(e,t){return e==null||!Number.isFinite(e)||!Number.isFinite(t)||t<=0||e<=t?null:`${(e/t).toFixed(1)}× more work queued than cores to run it`}function rZ(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function aZ(e,t,n=Date.now()){const s=P1(e),r="timeHeld"in e;return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?r?`CPU throttled ${s}% of the time to cool down`:`CPU held to ${100-s}% of full speed to cool down`:t?r?`at full speed · ${t.peak}% throttled ${hC(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${hC(t.lastMs,n)}`:"running at full speed, and never held back"}}function hC(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const s=Math.floor(n/60);return s===1?"an hour ago":`${s} hours ago`}function oZ(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${s}m`:`${s}m`}function iZ(e){var s,r;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?P1(t):0;return t&&n>0?"timeHeld"in t?`throttled ${n}% of the time`:`throttled to ${100-n}% of full speed`:e.memory&&e.memory.usedPct>=90?`physical memory ${Math.round(e.memory.usedPct)}% full`:(r=e.network)!=null&&r.api&&e.network.api.ms==null?"the Claude API is not answering":null}function lZ(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 cZ=3e3;function uZ(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let s=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();s&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(r(),n.current=window.setInterval(r,cZ))},i=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){i();return}o(),r()};return o(),document.addEventListener("visibilitychange",c),()=>{s=!1,i(),document.removeEventListener("visibilitychange",c)}},[]),e}function dZ(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function Bi({col:e,label:t,note:n,sort:s,next:r,onSort:o,className:i}){const c=dZ(s,e);return a.jsx("th",{scope:"col","aria-sort":c,className:i,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
93
-
94
- ${n}`:`Sort by ${t}`,onClick:()=>o(r(s,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function $g(e,t){return t==="B/s"?O1(e):t==="ms"?Zf(e):{value:String(e),unit:t==="C"?"°C":t}}const Ht={l:30,r:6,t:6,b:2},Na={l:0,r:0,t:2,b:1},Jf=104,hZ=64;function Is(e,t=100,n=Jf,s=Ht){const r=n-s.t-s.b;return s.t+r*(1-Math.max(0,Math.min(t,e))/t)}function gP(e,t){return t??[e[0].t,e[e.length-1].t]}function D1(e,[t,n],s,r=Ht){const o=s-r.l-r.r,i=n-t;return r.l+(i>0?o*(e-t)/i:o/2)}function yP(e,t,n,s=100,r=Jf,o=Ht,i){if(!e.length)return"";const c=gP(e,i),d=p=>D1(p,c,t,o);let h="",f=null;for(const p of e){const m=f&&p.t-f.t<=n*2?"L":"M";h+=`${m}${d(p.t).toFixed(1)} ${Is(p.v,s,r,o).toFixed(1)}`,f=p}return h}function wP(e,t,n,s=100,r=Jf,o=Ht,i){if(e.length<2)return"";const c=r-o.b,d=gP(e,i),h=w=>D1(w,d,t,o);let f="",p=[];const m=()=>{if(p.length>=2){let w=`M${h(p[0].t).toFixed(1)} ${c}`;for(const j of p)w+=`L${h(j.t).toFixed(1)} ${Is(j.v,s,r,o).toFixed(1)}`;f+=`${w}L${h(p[p.length-1].t).toFixed(1)} ${c}Z`}p=[]};for(const w of e)p.length&&w.t-p[p.length-1].t>n*2&&m(),p.push(w);return m(),f}function fZ(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 xP(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function pZ(e,t,n=s=>_o(s)){const s=e.filter(i=>i.v>0);if(!e.length)return null;if(!s.length)return"never held back";const r=s.length*(t/6e4),o=s[s.length-1];return`held back for ${r===1?"1 minute":`${r} minutes`}, last at ${n(o.t)}`}function _o(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function F1(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const s=Math.floor(n/60),r=n%60;return r?`${s}h ${r}m`:`${s}h`}function mZ({group:e,title:t,liveNote:n,onClose:s}){const r=ct(s),o=xt(s),[i,c]=y.useState(null);y.useEffect(()=>{let m=!0;const w=async()=>{try{const b=await fetch(`/api/system/history?group=${e}`);if(!b.ok)return;const k=await b.json();m&&(k!=null&&k.ok)&&c(k)}catch{}};w();const j=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(j)}},[e]);const d=(i==null?void 0:i.series)??[],[h,f,p]=y.useMemo(()=>{let m=1/0,w=0;for(const j of d)j.points.length&&(m=Math.min(m,j.points[0].t),w=Math.max(w,j.points[j.points.length-1].t));return Number.isFinite(m)?[Math.max(m,(i==null?void 0:i.sinceMs)??0),w,[m,w]]:[(i==null?void 0:i.sinceMs)??0,w,void 0]},[d,i==null?void 0:i.sinceMs]);return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:m=>m.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}),i&&h>0&&a.jsxs("span",{className:"hist-since",children:["since ",_o(h)," · ",F1(h,f||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"hist-body",children:[i==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):d.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):d.map(m=>a.jsx(gZ,{series:m,stepMs:i.stepMs,domain:p},m.label)),e==="load"&&n&&a.jsxs("p",{className:"hist-note hist-load-summary",children:[a.jsx("span",{children:"Current 1-minute load"}),a.jsx("strong",{children:n})]})]})]})}),document.body)}function gZ({series:e,stepMs:t,domain:n}){const s=y.useRef(null),[r,o]=y.useState(560),[i,c]=y.useState(null);y.useEffect(()=>{const O=s.current;if(!O||typeof ResizeObserver>"u")return;const M=new ResizeObserver(([q])=>o(Math.max(160,q.contentRect.width)));return M.observe(O),()=>M.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:m,top:w,restsAtZero:j,changes:b}=e,k=j?hZ:Jf,{now:v,peak:N}=fZ(d),S=v!=null?$g(v,h):null,E=N!=null?$g(N,h):null,C=m==="Throttling"?pZ(d,t):null,I=i!=null?d[i]:null,[R,$]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),L=O=>D1(O,[R,$],r),U=O=>{if(d.length<2)return;const M=O.currentTarget.getBoundingClientRect(),q=(O.clientX-M.left-Ht.l)/Math.max(1,M.width-Ht.l-Ht.r),A=R+($-R)*Math.max(0,Math.min(1,q));let D=0;for(let P=1;P<d.length;P++)Math.abs(d[P].t-A)<Math.abs(d[D].t-A)&&(D=P);c(D)};return a.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:m}),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&&E&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:xP(N,f,p),children:E.value}),a.jsxs("span",{children:[E.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:s,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:k,viewBox:`0 0 ${r} ${k}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||E==null?`${m}: nothing measured yet`:`${m}: ${uu(S)} now, peak ${uu(E)}, over ${F1(d[0].t,d[d.length-1].t)}`,onPointerMove:U,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([O,M])=>M==null||M>w?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${O}`,x1:Ht.l,x2:r-Ht.r,y1:Is(M,w,k),y2:Is(M,w,k)}),a.jsx("text",{className:`hist-rule-tag ${O}`,x:2,y:Is(M,w,k)+3,children:M})]},O)),a.jsx("line",{className:"hist-floor",x1:Ht.l,x2:r-Ht.r,y1:k-Ht.b,y2:k-Ht.b}),(b??[]).filter(O=>O.from!=null&&d.length>1&&O.t>=R&&O.t<=$).map(O=>a.jsx("line",{className:"hist-mark",x1:L(O.t),x2:L(O.t),y1:Ht.t,y2:k-Ht.b},O.t)),a.jsx("path",{className:"hist-area",d:wP(d,r,t,w,k,Ht,[R,$])}),a.jsx("path",{className:"hist-line",d:yP(d,r,t,w,k,Ht,[R,$])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:L(d[0].t),cy:Is(d[0].v,w,k),r:3}),I&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:L(I.t),x2:L(I.t),y1:Ht.t,y2:k-Ht.b}),a.jsx("circle",{className:"hist-dot",cx:L(I.t),cy:Is(I.v,w,k),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:I?a.jsxs("span",{className:"hist-at",children:[_o(I.t)," — ",(()=>{const O=$g(I.v,h);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:O.value}),O.unit==="%"||O.unit==="°C"||!O.unit?O.unit:` ${O.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:d.length?_o(R):""}),a.jsx("span",{children:d.length?_o($):""})]})}),C&&a.jsx("div",{className:"hist-note",children:C}),b==null?void 0:b.slice(-3).map(O=>a.jsx("div",{className:"hist-note hist-route",children:O.from==null?`Since ${_o(O.t)} — ${O.label}`:`${_o(O.t)} — ${O.label.charAt(0).toUpperCase()+O.label.slice(1)}`},O.t))]})}const fC=["cores","memory","load","thermal"],wo=116,or=24,yZ=60,wZ=6e4;function xZ(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function vZ(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function bZ(e,t=yZ){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function kZ({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let i=!0;const c=async()=>{const h=await Promise.all(fC.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]}}));i&&n(f=>{const p={...f};for(const[m,w]of h)w!=null&&w.ok&&(p[m]=w);return p})};c();const d=setInterval(()=>void c(),wZ);return()=>{i=!1,clearInterval(d)}},[]);const s=y.useMemo(()=>nZ(e),[e]),r=y.useMemo(()=>fC.flatMap(i=>{const c=t[i];return c?c.series.filter(xZ).map(d=>({series:bZ(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let i=1/0,c=-1/0;for(const{series:d}of r){const h=d.points;h.length&&(i=Math.min(i,h[0].t),c=Math.max(c,h[h.length-1].t))}return Number.isFinite(i)?F1(i,c):"less than a minute"},[r]);return Object.keys(s).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:r.map(({series:i,stepMs:c})=>a.jsx(jZ,{series:i,stepMs:c,now:s[i.key],span:o},i.key))}):null}function jZ({series:e,stepMs:t,now:n,span:s}){var w;const{points:r,top:o,unit:i,warnAt:c,critAt:d}=e,h=vZ(e),f=n??((w=r[r.length-1])==null?void 0:w.v),p=f==null?"":xP(f,c,d),m=Math.max(...r.map(j=>j.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${Fc(m,i)} over the last ${s}`,c!=null?`over ${oh(c,i)} is uncomfortable`:"",d!=null?`over ${oh(d,i)} 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?"—":Fc(f,i)})]}),a.jsxs("svg",{className:"pl-spark",width:wo,height:or,viewBox:`0 0 ${wo} ${or}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:wo,y1:or-Na.b,y2:or-Na.b}),a.jsx("path",{className:"pl-spark-area",d:wP(r,wo,t,o,or,Na)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:wo,y1:Is(c,o,or,Na),y2:Is(c,o,or,Na)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:wo,y1:Is(d,o,or,Na),y2:Is(d,o,or,Na)}),a.jsx("path",{className:"pl-spark-line",d:yP(r,wo,t,o,or,Na)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",Fc(m,i)," over the last ",s,c!=null&&`, uncomfortable over ${oh(c,i)}`,d!=null&&`, the machine acts over ${oh(d,i)}`]})]})}const vP={key:"cpu",dir:"desc"};function NZ(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function SZ(e,t){const n=t.dir==="asc"?1:-1,s=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,r=(o,i)=>{if(t.key==="name")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=i.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const c=s(o),d=s(i);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>r(o,i)||(i.cpu??-1)-(o.cpu??-1)||i.mem-o.mem||o.pid-i.pid)}const _Z=4e3;function EZ(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 CZ(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const i=await o.json();n&&t(c=>EZ(c,i))}catch{}};s();const r=window.setInterval(s,_Z);return()=>{n=!1,window.clearInterval(r)}},[]),e}function TZ(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 RZ({sys:e,onClose:t}){nn("process-list");const n=ct(t),s=xt(t),[r,o]=y.useState(vP),i=CZ();return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(AZ,{read:i,sort:r,onSort:o,sys:e,onClose:t})})}),document.body)}function AZ({read:e,sort:t,onSort:n,sys:s,onClose:r}){const o=e?SZ(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:r,"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(Ii,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Ii,{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(Ii,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Ii,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Ii,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Ii,{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(i=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:i.cpu==null?"—":i.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${i.mem.toFixed(1)}% of installed memory`,children:qr(i.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:TZ(i.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:i.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:i.pid}),a.jsxs("td",{className:"pl-name",children:[i.name,i.cmd&&a.jsxs("span",{className:"pl-cmd",title:i.cmd,children:[" ",i.cmd]})]})]},i.pid))})]})}),a.jsx(kZ,{sys:s})]})]})}function Ii(e){return a.jsx(Bi,{...e,next:(t,n)=>NZ(t??vP,n)})}function o0({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}const MZ=300;function du({group:e,title:t,action:n,label:s,value:r,hint:o,liveNote:i,children:c}){const[d,h]=y.useState(!1),f=y.useRef(null),p=y.useRef(null),m=()=>{p.current!=null&&window.clearTimeout(p.current),p.current=null};y.useEffect(()=>m,[]);const w=j=>{var b;m(),!(j.detail>1||((b=window.getSelection())==null?void 0:b.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var k,v;p.current=null,((k=window.getSelection())==null?void 0:k.isCollapsed)!==!1&&((v=f.current)==null||v.focus({preventScroll:!0}),h(!0))},MZ))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:w,children:[a.jsx("button",{ref:f,type:"button",className:"sd-open",onClick:j=>{j.stopPropagation(),m(),h(!0)},title:n,"aria-label":r==null?`${s}: show history`:`${s}: show history, now ${r}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[s," ",a.jsx("i",{className:"sd-row-more",children:"›"}),r!=null&&a.jsx("span",{className:"sd-h-val",children:r})]})}),c]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),d&&a.jsx(mZ,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function lf({label:e,value:t,pct:n,tone:s="calm",note:r,mark:o,title:i,trackLabel:c}){return a.jsxs("div",{className:"sd-row",title:i,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[a.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,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})]}),r&&a.jsx("div",{className:"sd-note",children:r})]})}function $Z(e,t,n){if(n<=0||Bf(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:s===-1?0:(s+1)%n};case"ArrowUp":return{kind:"focus",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}const Ia=4,cs=8;function B1(e,t,n){const s=n.width-cs-(e.right+Ia),r=e.left-Ia-cs,o=t.width<=s||s>=r?"right":"left",i=o==="right"?e.right+Ia:e.left-Ia-t.width,c=n.height-cs*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(cs,Math.min(e.top,n.height-cs-h)),p=Math.max(cs,Math.min(i,n.width-cs-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function IZ(e,t,n){const s=n.height-cs-(e.bottom+Ia),r=e.top-Ia-cs,o=t.height<=s||s>=r?"below":"above",i=o==="below"?s:r,c=t.height<=i,d=c?t.height:Math.max(0,i),h=o==="below"?e.bottom+Ia:e.top-Ia-d,f=Math.max(cs,Math.min(e.right-t.width,n.width-cs-t.width));return{top:Math.max(cs,h),left:f,side:o,maxHeight:c?null:d}}function LZ(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function OZ(e,t,n){const s=y.useRef(t);s.current=t;const r=y.useRef(n);r.current=n,y.useEffect(()=>{const o=i=>{LZ(i.target,e.current,s.current())&&r.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const bP='[role="menuitem"]';function pC(e){return e?Array.from(e.querySelectorAll(bP)).filter(t=>!t.disabled):[]}function Qf({anchorId:e,boundaryId:t,portalRootId:n,id:s,className:r,role:o,labelledBy:i,start:c="first",focusRef:d,fallbackFocus:h,onClose:f,children:p}){const m=y.useRef(f);m.current=f;const w=y.useRef(h);w.current=h;const j=ct(()=>{var S;(S=document.getElementById(e))==null||S.focus(),m.current()},{popover:!0,focusRef:d}),b=y.useCallback(()=>{var $,L,U;const S=j.current;if(!S)return;const E=document.getElementById(e);if(!E){m.current();return}if(E.getClientRects().length===0){S.contains(document.activeElement)&&((L=($=w.current)==null?void 0:$.call(w))==null||L.focus()),m.current();return}const C=E.getBoundingClientRect(),I=t?(U=document.getElementById(t))==null?void 0:U.getBoundingClientRect():null;if(I&&(C.bottom<=I.top||C.top>=I.bottom)){S.contains(document.activeElement)&&E.focus({preventScroll:!0}),m.current();return}S.style.maxHeight="";const R=IZ(C,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight});S.style.top=`${R.top}px`,S.style.left=`${R.left}px`,S.style.maxHeight=R.maxHeight==null?"":`${R.maxHeight}px`,S.dataset.side=R.side},[e,t,j]);y.useLayoutEffect(()=>{b()}),y.useEffect(()=>{const S=E=>{var C;(C=j.current)!=null&&C.contains(E.target)||b()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",b)}},[b,j]),OZ(j,()=>document.getElementById(e),f),y.useEffect(()=>{var E;if(o!=="menu")return;const S=pC(j.current);(E=c==="last"?S[S.length-1]:S[0])==null||E.focus()},[]);const k=S=>{var E;if(o==="menu"&&S.key==="Tab"){S.stopPropagation(),(E=document.getElementById(e))==null||E.focus(),S.shiftKey&&S.preventDefault(),m.current();return}if(o==="menu"){const C=pC(j.current),I=$Z(S,C.indexOf(document.activeElement),C.length);I.kind==="focus"&&(S.preventDefault(),C[I.index].focus())}S.key.length===1&&S.stopPropagation()},v=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},N=S=>{if(o!=="menu"||S.pointerType==="touch")return;const E=S.target.closest(bP);E&&!E.disabled&&document.activeElement!==E&&E.focus({preventScroll:!0})};return wt.createPortal(a.jsx("div",{ref:j,id:s,className:`anchored-popover${r?` ${r}`:""}`,role:o,"aria-labelledby":i,onKeyDown:k,onMouseDown:v,onPointerMove:N,children:p}),(n?document.getElementById(n):null)??document.body)}function PZ({network:e}){const{down:t,up:n,api:s,route:r}=e,[o,i]=y.useState(!1),c=s&&s.ms!=null?Zf(s.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(du,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=O1(f);return a.jsx(o0,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(o0,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),s&&s.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),r&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>i(h=>!h),children:["Connection details",r.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(DZ,{route:r,api:s,onClose:()=>i(!1)})]})]})}function DZ({route:e,api:t,onClose:n}){return a.jsxs(Qf,{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 ",lZ(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`:`${uu(Zf(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 mC({usageOpen:e,leaving:t,sub:n,flag:s,onClose:r,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:r,"aria-label":"Close",title:"Close",children:"×"})]}),s&&a.jsx("p",{className:"sd-flag",children:s})]}),o]})}function FZ({usageOpen:e,leaving:t,onClose:n}){const s=uZ();if(!s||s.cpu==null||!s.memory)return a.jsx(mC,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:r,swap:o,perCore:i,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:m,cpu:w}=s;return a.jsxs(mC,{usageOpen:e,leaving:t,sub:`up ${oZ(h)} · ${d} cores`,flag:iZ(s),onClose:n,children:[a.jsx(BZ,{cpu:w,perCore:i,loadavg:c,cores:d}),a.jsx(qZ,{memory:r,swap:o,platform:f}),m&&a.jsx(PZ,{network:m}),a.jsx(UZ,{thermal:p}),a.jsx(WZ,{sys:s})]})}function BZ({cpu:e,perCore:t,loadavg:n,cores:s}){const r=sZ(n==null?void 0:n[0],s),o=!!t&&t.length>0;return!o&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[o&&a.jsx(du,{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((i,c)=>a.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${i}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,i)/100})`}})},c))})}),n&&a.jsxs(du,{group:"load",title:"Load history",action:"Show load history",label:"Load average",liveNote:r,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((i,c)=>a.jsx(o0,{value:i.toFixed(2),cap:["1m","5m","15m"][c]},c))}),r&&a.jsx("div",{className:"sd-note",children:r})]})]})}function qZ({memory:e,swap:t,platform:n}){const s=e.total-e.available,r=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(du,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(lf,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:qr(s)})," of ",qr(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${qr(e.available)} available`}),t&&t.total>0&&a.jsx(lf,{label:r,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:qr(t.used)})," of ",qr(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function UZ({thermal:e}){if(!e)return null;const t=e.throttle?aZ(e.throttle,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(du,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(lf,{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:rZ(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(lf,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function WZ({sys:e}){const[t,n]=y.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(RZ,{sys:e,onClose:()=>n(!1)})]})}function cf(e){const t={inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m};e.l&&(t.longContext=cf(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,r])=>[s,cf(r)]))),t}function gC(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(cf(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,r])=>[s,t(r)]))),n}function kP(e){return e.i+e.o+e.cr+e.cc}function i0(e,t){var n;e.i+=t.i,e.o+=t.o,e.cr+=t.cr,e.cc+=t.cc,e.c1h+=t.c1h,e.c5m+=t.c5m,t.l&&i0(e.l??(e.l={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),t.l);for(const[s,r]of Object.entries(t.s??{}))i0((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),r);return e}function yC(e,t,n){let s=0,r=0,o=0;const i=[];for(const c of Lf(e)){if(!Va(t,n,c.speed)){const d=c.usage,h=d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens;h>0&&(o+=h,i.push(c.speed));continue}s+=tu(c.usage,t,c.speed,n).total,r+=tu({...c.usage,longContext:void 0},t,Pa,n).total}return{atSpeed:s,atStandard:r,unpriced:o,unpricedSpeeds:i}}function wC(e){let t=0;for(const n of Object.values(e))t+=kP(n);return t}function HZ(e){const t=r=>typeof r=="number"&&Number.isFinite(r)?r:0,n=new Map,s=e&&Array.isArray(e.days)?e.days:[];for(const r of s){const o=typeof r.period=="string"?r.period:"",i=Array.isArray(r.modelBreakdowns)?r.modelBreakdowns:[];for(const c of i){const d=typeof c.modelName=="string"?c.modelName:"";if(!o||!/claude/i.test(d)||c.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(c.inputTokens),p.outputTokens+=t(c.outputTokens),p.cacheReadTokens+=t(c.cacheReadTokens),p.cacheCreateTokens+=t(c.cacheCreationTokens),f?f.cost+=t(c.cost):n.set(h,{cost:t(c.cost),usage:p})}}return n}function zZ(e,t,n,s=Date.now()){const r=new Map;for(const R of e){const $={},L=U=>{for(const[O,M]of Object.entries(U))i0($[O]??($[O]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),M)};for(const U of R.projects)L(U.models);R.unattributed&&L(R.unattributed);for(const[U,O]of Object.entries($)){if(!O.s&&!O.l)continue;const{atSpeed:M,atStandard:q}=yC(gC(O),U,s);if(!(M>0&&q>0))continue;let A=r.get(R.day);A||(A=new Map,r.set(R.day,A)),A.set(U,M/q),A.has(lr(U))||A.set(lr(U),M/q)}}const o=(R,$)=>{const L=r.get(R);return(L==null?void 0:L.get($))??(L==null?void 0:L.get(lr($)))??1},i=new Map;let c=0,d=0;for(const[R,$]of n){const L=R.indexOf("|"),U=R.slice(0,L),O=R.slice(L+1),M=If($.usage,O,s).total*o(U,O);if(!(M>0&&$.cost>0))continue;c+=$.cost,d+=M;let q=i.get(U);q||(q=new Map,i.set(U,q)),q.set(O,$.cost/M)}const h=d>0,f=(R,$)=>{const L=i.get(R);return(L==null?void 0:L.get($))??(L==null?void 0:L.get(lr($)))??null},p=new Set,m=(R,$)=>{let L=0,U=0;for(const[O,M]of Object.entries(R)){if(Va(O,s)){const A=$(O),D=yC(A===null?cf(M):gC(M),O,s);L+=A===null?D.atSpeed:D.atSpeed*A,U+=D.unpriced;for(const P of D.unpricedSpeeds)p.add(`${O} (${P})`);continue}const q=kP(M);q>0&&(U+=q,p.add(O))}return{cost:L,unpriced:U}},w=new Map,j=[];for(const R of e){const $=new Map,L=new Map;let U=0;for(const O of R.projects){const{cost:M,unpriced:q}=m(O.models,D=>f(R.day,D));$.set(O.path,($.get(O.path)??0)+M),q>0&&L.set(O.path,(L.get(O.path)??0)+q),U+=M;let A=w.get(O.path);A||(A={path:O.path,cost:0,tokens:0,unpricedTokens:0},w.set(O.path,A)),A.cost+=M,A.tokens+=wC(O.models),A.unpricedTokens+=q}j.push({day:R.day,total:U,byPath:$,unpricedByPath:L})}const b=[...w.values()].sort((R,$)=>$.cost-R.cost||$.tokens-R.tokens),k=b.reduce((R,$)=>R+$.cost,0),v=b.reduce((R,$)=>R+$.tokens,0),N=b.reduce((R,$)=>R+$.unpricedTokens,0),S=h?c/d:null,E=t?wC(t):0,C=t?m(t,()=>S):{cost:0,unpriced:0},I=C.cost>0||E>0?{cost:C.cost,tokens:E,unpricedTokens:C.unpriced}:null;return{projects:b,totalCost:k,totalTokens:v,unpricedTokens:N,perDay:j,unattributed:I,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&N===0}}function ir(e,t,n=Xe){return t>0?e>0?`${n(e)}+`:Kr:n(e)}function Li(e){return e>0?`${gt(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function VZ(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 ${Kr}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${Kr}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const GZ={phase:"running"},KZ={phase:"failed"},YZ={gen:0,report:null,error:null,early:null};function XZ(e,t){var n,s;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 r=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:GZ;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:r},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((s=e.report)==null?void 0:s.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function ZZ(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function JZ(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:KZ}function QZ(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function eJ(e,t,n=Date.now()){const s=t===0?60:t,r=new Date(n),o=r0(s,r),i=QZ(r);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function tJ({num:e,days:t,gen:n,dispatch:s,get:r=(i,c)=>fetch(i,c),now:o=Date.now()}){const i=eJ(e,t,o),c={credentials:"same-origin"};r(i.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>s({type:"report",gen:n,days:t,data:d}),d=>s({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),r(i.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>s({type:"cost",gen:n,cost:JZ(d)}))}async function Ko(e,t=500){var s;if(!e)return!1;let n=!1;try{n=await Promise.race([((s=navigator.clipboard)==null?void 0:s.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(r=>window.setTimeout(()=>r(!1),t))])}catch{n=!1}if(n)return!0;try{const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(r),r.select(),n=document.execCommand("copy"),r.remove()}catch{n=!1}return n}function jP(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Ig(e){const t=jP(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function xC(e){if(!e)return e;const t=jP(e),n=t.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);if(n)return`~${n[1]??""}`;const s=t.replace(/\\/g,"/").match(/^[A-Za-z]:\/Users\/[^/]+(\/.*)?$/i);return s?`~${s[1]??""}`:t.replace(/\\/g,"/")}function nJ(e,t){const n=Ig(e);let s;for(const r of t){const o=Ig(r.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||Ig(s.path).length<o.length)&&(s=r)}return s==null?void 0:s.label}function l0(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function sJ(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${l0(e)}.`}function rJ(e){return e===1?7:e===7?30:e===30?0:null}function aJ(e,t){return e!==1&&t>0}const oJ=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Oi=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],iJ="var(--usage-zinc)",Lg=6,lJ=1600;function cJ(e){const t=Xe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function ih(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 uJ(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function dJ(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Og(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function hJ({num:e,name:t,onClose:n}){var P,K,G,W;nn("account-projects");const[s,r]=y.useState(1),[o,i]=y.useReducer(XZ,YZ),c=((P=o.report)==null?void 0:P.data)??null,d=((K=o.report)==null?void 0:K.days)??s,h=((G=o.report)==null?void 0:G.cost.phase)==="ready"?o.report.cost.range:null,f=((W=o.report)==null?void 0:W.cost.phase)==="running",[p,m]=y.useState(null),[w,j]=y.useState(()=>new Set),b=ZZ(o),k=o.error,[v,N]=y.useState(null),S=y.useRef(void 0),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1,window.clearTimeout(S.current)},[]);const C=y.useRef(null),I=ct(n,{focusRef:C}),R=xt(n),$=y.useRef(0);y.useEffect(()=>{const H=++$.current;i({type:"start",gen:H}),m(null),j(new Set),tJ({num:e,days:s,gen:H,dispatch:i})},[e,s]);const L=y.useMemo(()=>{const H=Date.now();if(!c)return null;const F=zZ(c.daily??[],c.unattributed,HZ(h),H),B=ge=>ge.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||ge||"(unknown)",Z=new Map;for(const ge of F.projects)Z.set(B(ge.path),(Z.get(B(ge.path))??0)+1);const V=ge=>{const Se=B(ge);if((Z.get(Se)??0)<=1)return Se;const me=ge.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return me?`${me}/${Se}`:Se},X=F.projects.map(ge=>({path:ge.path,label:V(ge.path)})),Y=ge=>({path:ge.path,label:V(ge.path),parentLabel:nJ(ge.path,X),cost:ge.cost,tokens:ge.tokens,unpricedTokens:ge.unpricedTokens}),J=Oi[Lg%Oi.length],ee=new Map,ne=[],le=F.projects.slice(0,Lg),de=F.projects.slice(Lg);le.forEach((ge,Se)=>{ee.set(ge.path,Oi[Se%Oi.length]),ne.push({key:ge.path,...Y(ge),color:Oi[Se%Oi.length]})}),de.length&&ne.push({key:"__other__",label:`Other · ${de.length} project${de.length>1?"s":""}`,cost:de.reduce((ge,Se)=>ge+Se.cost,0),tokens:de.reduce((ge,Se)=>ge+Se.tokens,0),unpricedTokens:de.reduce((ge,Se)=>ge+Se.unpricedTokens,0),color:J,muted:!0,members:de.map(Y)});const ue=F.totalCost,re=F.totalTokens,pe=ue>0&&F.unpricedTokens===0?"cost":"tokens",ye=pe==="cost"?ue:re,_e=ne.map(ge=>ge.color),he=F.perDay.map(ge=>{const Se=new Map;for(const[Pe,qe]of ge.byPath){const Le=ee.get(Pe)??J;Se.set(Le,(Se.get(Le)??0)+qe)}const me=new Map;let $e=0;for(const[Pe,qe]of ge.unpricedByPath){const Le=ee.get(Pe)??J;me.set(Le,(me.get(Le)??0)+qe),$e+=qe}return{day:ge.day,total:ge.total,costByColor:Se,unpricedByColor:me,unpriced:$e}}),ae=he.reduce((ge,Se)=>Math.max(ge,Se.total),0);return{projectCount:F.projects.length,rows:ne,totalCost:ue,totalTokens:re,basis:pe,denom:ye,un:F.unattributed,chart:he,maxDay:ae,colorOrder:_e,unpricedTokens:F.unpricedTokens,unpricedNote:VZ(F.unpricedModels),calibrated:F.calibrated,reconciled:F.reconciled}},[c,h]),U=(H,F)=>{Ko(H).then(B=>{E.current&&(window.clearTimeout(S.current),N({path:H,label:F,ok:B}),S.current=window.setTimeout(()=>{E.current&&N(null)},lJ))})},O=H=>v!=null&&v.ok&&v.path===H?"Copied":"Copy",M=c!=null&&c.trackedSince?`Tracked since ${Og(c.trackedSince)}`:"Tracking starts with this version",q=l0(d),A=rJ(d),D=b&&!!c;return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...R,role:"presentation",children:a.jsxs("div",{ref:I,className:"modal ap-proj-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:oJ.map(H=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===H.days,onClick:()=>r(H.days),children:H.label},H.days))}),a.jsx("button",{ref:C,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${D?" refreshing":""}`,"aria-busy":b,children:[b&&!c&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!b&&k&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",k]}),!k&&L&&a.jsx(a.Fragment,{children:L.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[D?"Updating…":sJ(d),A!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>r(A),children:["Show ",l0(A)]})}),a.jsxs("div",{className:"ap-proj-note",children:[M,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${L.basis==="cost"?Xe(L.totalCost):`${gt(L.totalTokens)} tokens`} across ${L.projectCount} project${L.projectCount>1?"s":""}`,children:L.rows.map(H=>{const F=L.basis==="cost"?H.cost:H.tokens,B=L.denom>0?F/L.denom*100:0;if(B<=0)return null;const Z=L.basis==="cost"?ih(H.cost,L.totalCost):`${ih(H.tokens,L.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${B}%`,background:H.color},title:`${H.label} · ${ir(H.cost,H.unpricedTokens)} · ${Z}${H.tokens?` · ${gt(H.tokens)} tokens`:""}`},H.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:Li(L.unpricedTokens),children:ir(L.totalCost,L.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[gt(L.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",D?"updating…":q]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),L.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:L.unpricedNote}),aJ(d,L.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",L.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${L.chart.length} day${L.chart.length>1?"s":""}`,children:L.chart.map(H=>{const F=L.maxDay>0?H.total/L.maxDay*100:0,B=p===H.day,Z=L.rows.map(X=>({label:X.label,c:H.costByColor.get(X.color)??0,u:H.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),V=`${Og(Date.parse(`${H.day}T00:00:00`))}, ${ir(H.total,H.unpriced)}. ${Z.map(X=>`${X.label} ${ir(X.c,X.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${B?" selected":""}`,"aria-pressed":B,"aria-label":V,title:`${H.day} · ${ir(H.total,H.unpriced)}`,onClick:()=>m(X=>X===H.day?null:H.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${F}%`},children:L.colorOrder.map((X,Y)=>{const J=H.costByColor.get(X)??0;return J<=0||H.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/H.total*100}%`,background:X}},Y)})})},H.day)})}),(()=>{const H=dJ(L.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:L.chart.map((F,B)=>a.jsx("div",{className:"ap-proj-axis-cell",children:H(B)?uJ(F.day):""},F.day))})})(),(()=>{const H=p?L.chart.find(B=>B.day===p):null;if(!H)return null;const F=L.rows.map(B=>({r:B,c:H.costByColor.get(B.color)??0,u:H.unpricedByColor.get(B.color)??0})).filter(B=>B.c>0||B.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:Og(Date.parse(`${H.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:Li(H.unpriced),children:ir(H.total,H.unpriced)})]}),F.map(({r:B,c:Z,u:V})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:B.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:B.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:Li(V),children:ir(Z,V)})]},B.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:L.rows.map((H,F)=>{const B=L.basis==="cost"?H.cost:H.tokens,Z=L.denom>0?B/L.denom*100:0,V=w.has(H.key),X=`ap-proj-details-${F}`,Y=V&&(!!H.path||!!H.members),J=H.members?`${V?"Hide":"Show"} the ${H.members.length} project${H.members.length>1?"s":""} folded into Other`:`${V?"Hide":"Show"} location for ${H.label}`;return a.jsxs("li",{className:`ap-proj-row${H.muted?" muted":""}${V?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[H.label,H.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",H.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:L.basis==="cost"?`${ih(H.cost,L.totalCost)} of tracked cost`:`${ih(H.tokens,L.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:H.color}})}),a.jsx("span",{className:"ap-proj-cost",title:Li(H.unpricedTokens),children:ir(H.cost,H.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:gt(H.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":V,"aria-controls":Y?X:void 0,"aria-label":J,onClick:()=>j(ee=>{const ne=new Set(ee);return ne.has(H.key)?ne.delete(H.key):ne.add(H.key),ne}),children:"ⓘ"}),V&&H.path&&a.jsxs("div",{className:"ap-proj-details",id:X,children:[a.jsx("code",{className:"ap-proj-path",children:xC(H.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(H.path)} location for ${H.label}`,onClick:()=>U(H.path,H.label),children:O(H.path)})]}),V&&H.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:H.members.map(ee=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[ee.label,ee.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",ee.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:xC(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:Li(ee.unpricedTokens),children:ir(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:gt(ee.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(ee.path)} location for ${ee.label}`,onClick:()=>U(ee.path,ee.label),children:O(ee.path)})]},ee.path))})]},H.key)})}),L.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:iJ},"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:Li(L.un.unpricedTokens),children:ir(L.un.cost,L.un.unpricedTokens,cJ)}),a.jsx("span",{className:"ap-proj-un-tok",children:gt(L.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:v&&(v.ok?`Copied the location of ${v.label}`:`Could not copy the location of ${v.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":L.reconciled?"Dollars from ccusage · split by activity":L.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",M]})]})})]})]})}),document.body)}function Ba(e,t){return P3(t-Math.floor(e/1e3))}function fJ(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 q1(){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 pJ({anchorId:e,boundaryId:t,issue:n,who:s,fetchedAt:r,nowSec:o,onClose:i,onSignIn:c,onReport:d}){const h=y.useRef(null);return a.jsx(Qf,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:h,onClose:()=>i(),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(q1,{}),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:s})," · ",r?`last collected ${Ba(r,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{i(),d()},children:"Report this"}),a.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>i(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{i(!0),c()},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:n.fix})]})]})})}function Tc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mJ(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 s=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),r=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} ${r} It tries again in ${s}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function gJ(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 yJ(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 vC={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 that shares it; the others repair from it on their next round."};function Ho(e,t,n){const s=xJ(e,t);return!s||!(n!=null&&n.noCopyWorksNearby)||!wJ(e)?s:{...s,text:vC.text,hint:vC.hint}}function wJ(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function xJ(e,t){if(e.staleCopy){const n=mJ(e.repair??null,t);return{text:Tc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=yJ(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 s=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:Tc(n.text),hint:n.hint,fix:n.fix?Tc(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=gJ(e.error);return{text:Tc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function bC(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function kC(e){const t=e.filter(c=>!bC(c)),n=e.filter(c=>bC(c)),s=t.length?t:n,r=t.length?n:[],o=s.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let i=null;for(const c of r)o&&c.pct<=o.pct||(!i||c.pct>i.pct)&&(i=c);return{shown:s,rest:r,fuller:i,peak:i??o}}function hu(e,t){return!!e.resetAt&&e.resetAt<=t}function U1(e,t){return(e.lanes??[]).some(s=>hu(s,t))?null:e.headroom}const vJ="\0";function Ls(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.orgUuid=="string"&&e.orgUuid.trim()?`uuid:${e.orgUuid.trim()}`:typeof e.org=="string"?e.org.trim():"";return`acct:${t}${vJ}${n}`}function bJ(e,t,n=Ls){const s=n(t);return e.includes(s)?e.filter(r=>r!==s):[...e,s]}const ep="slot",W1=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],NP=e=>e.id.startsWith("scoped-");function kJ(e){var t;return((t=W1.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function jJ(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function SP(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(NP).map(r=>r.label)))].sort((s,r)=>s.localeCompare(r)),n=[...W1.map(s=>s.name),...t];return[{id:ep,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function jC(e,t,n){const s=W1.find(o=>o.name===t),r=(e.lanes??[]).find(o=>s?o.id===s.lane:NP(o)&&o.label===t);return r&&n!=null&&hu(r,n)?null:r&&Number.isFinite(r.pct)?r.pct:null}function NJ(e,t,n=()=>!0,s){const r=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>s==null?p.headroom:U1(p,s);return o(NC(r,p=>{const m=f(p);return Number.isFinite(m)?m:null},"desc"))}const i=/^(.+):(full|empty)$/.exec(t);if(!i)return r;const[,c,d]=i;if(!r.some(f=>jC(f,c,s)!=null))return r;const h=NC(r,f=>jC(f,c,s),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function NC(e,t,n){const s=e.filter(o=>t(o)!=null),r=e.filter(o=>t(o)==null);return s.sort((o,i)=>n==="desc"?t(i)-t(o):t(o)-t(i)),[...s,...r]}function SJ(e,t){return SP(t).some(n=>n.id===e)?e:ep}function c0(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(Ls(o))).sort((o,i)=>n.get(Ls(o))-n.get(Ls(i))),r=e.filter(o=>!n.has(Ls(o)));return[...s,...r]}function H1(e){const t=Ls(e);return t.startsWith("slot:")?t:`h:${_J(t)}`}function _J(e){let t=3735928559,n=1103547991;for(let s=0;s<e.length;s++){const r=e.charCodeAt(s);t=Math.imul(t^r,2654435761),n=Math.imul(n^r,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 u0={mode:"some",keys:[]};function _P(e,t){const n=e.keys.includes(H1(t));return e.mode==="all"?!n:n}function EJ(e,t){return{mode:e.mode,keys:bJ(e.keys,t,H1)}}function EP(e,t){return t.length>0&&t.every(n=>_P(e,n))}function CJ(e,t){return EP(e,t)?u0:{mode:"all",keys:[]}}function TJ(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(H1)),s=e.keys.filter(r=>n.has(r));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const Lo=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function SC(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function RJ(e){const t=SC(e.five_hour),n=SC(e.seven_day);if(t==null||n==null)return"stale";const s=+(t>=100)+ +(n>=100);return s===0?"ready":s===1?"limited":"exhausted"}function AJ(e,t){const n=Lo.map(s=>e.cells[s.id]);for(const s of n)if(!s.counted&&(s.why==="login"||s.why==="none"))return{text:s.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(s=>s.counted)?{text:"now",old:!1}:{text:Ba(e.updatedAt,t),old:!0}}const CP=15*6e4;function tp(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const TP=e=>e.alias??e.email??`account ${e.num}`;function Bc(e,t){var s,r;const n=(r=(s=e.lanes)==null?void 0:s.find(o=>o.id===t))==null?void 0:r.resetAt;return n!=null&&n>0&&Number.isFinite(n)&&Number.isFinite(new Date(n*1e3).getTime())?n:null}function d0(e,t,n){const s=Lo.find(w=>w.id===t).label,r=(e.lanes??[]).find(w=>w.id===t),o=r&&Number.isFinite(r.pct)?RP(r.pct):null,i=Ho(e,n),c=Bc(e,t),d=c!=null&&c<=n,h=AP(r,e.fetchedAt,n),f=(w,j)=>({counted:!1,why:w,say:j,last:o,estimate:o,resetAt:d?null:Bc(e,t),reset:h});if(i!=null&&i.blocksSwitch)return f("login",i.text);if(o==null)return f("none",`No ${s} reading`);if(h)return f("reset",h);const p=tp(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>CP?f("stale",p!=null?`Updated ${Ba(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:Bc(e,t)}}const RP=e=>Math.min(100,Math.max(0,e));function AP(e,t,n){if((e==null?void 0:e.resetAt)==null||e.resetAt<=0||!Number.isFinite(e.resetAt)||!Number.isFinite(new Date(e.resetAt*1e3).getTime())||e.resetAt>n||!Number.isFinite(e.pct))return null;const s=tp(t),r=s!=null?`read ${Ba(s,n)}`:"last read";return`Reported reset time passed ${Ba(e.resetAt*1e3,n)}, ${qa(RP(e.pct))}% when ${r}`}function MJ(e,t){const n=Lo.find(h=>h.id===t);let s=0,r=0,o=0;const i=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(s+=p,o++,f.counted&&r++,f.resetAt!=null&&i.push({at:f.resetAt,name:h.name,pct:p}))}const c=i.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=c&&{...c,more:i.filter(h=>h!==c&&h.at-c.at<60).length};return{id:t,label:n.label,long:n.long,reporting:r,included:o,total:e.length,used:o?s/o:null,nextReset:d}}function z1(e,t){const n=e.map(r=>{const o={five_hour:d0(r,"five_hour",t),seven_day:d0(r,"seven_day",t)};return{num:r.num,key:Ls(r),name:TP(r),active:r.active,heldOut:r.disabled===!0,cells:o,resets:{five_hour:Bc(r,"five_hour"),seven_day:Bc(r,"seven_day")},status:RJ(o),updatedAt:tp(r.fetchedAt)}}),s=n.filter(r=>r.status==="ready").length;return{rows:n,windows:Lo.map(r=>MJ(n,r.id)),roomInBoth:s}}function vc(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const $J={ready:0,limited:1,exhausted:2,stale:3};function IJ(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function _C(e,t){return t==="status"?$J[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:t==="five_hour_reset"?e.resets.five_hour:t==="seven_day_reset"?e.resets.seven_day:IJ(e.cells[t])}function LJ(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,s=new Map(e.map((o,i)=>[o.num,i])),r=(o,i)=>{if(t.key==="account")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});const c=_C(o,t.key),d=_C(i,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>r(o,i)||s.get(o.num)-s.get(i.num))}function qa(e){return e>=100?100:Math.min(99,Math.round(e))}function OJ(e){const t=qa(e);return{used:t,available:100-t}}function PJ(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}const MP=new Set(["awaiting_url","awaiting_code","registering"]);function $P(e){return e!=null&&MP.has(e)}function IP(e){return e!=null&&e!=="done"&&!MP.has(e)}const LP="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",DJ="the sign-in did not complete";function FJ({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?LP:DJ)}}function EC({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 CC({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function BJ({login:e,started:t,loginError:n,loginBusy:s}){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":IP(e==null?void 0:e.state)||n&&t&&!s?"ended":s||$P(e==null?void 0:e.state)?"asking":"primer"}function V1(e,t){return t?Vt(e,t):void 0}const qJ={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 ${Ct}`,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"},UJ={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"},G1=`claude-swap could not read the login keychain — start ${Ct} from a Terminal window rather than a background service`,WJ={unreadable_here:{short:"Keychain locked on this Mac",long:`${G1}.`},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 uf(e){return e?Vt(WJ,e)??null:null}const OP={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 h0(e,t,n){const s=n==null?null:OP[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(fu(e)))return G1;const r=V1(UJ,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function fu(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const HJ={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"},zJ="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 VJ(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const GJ="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",KJ="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",YJ=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),XJ=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,ZJ=/[\\/]_npx[\\/]/i,JJ=`the copy of ccusage ${Ct} installed for itself`;function QJ(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function $we(e,t){const n=eQ(e,t),s=QJ(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${bc(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${bc(n)}`;case"managed":return`${JJ} failed to run: ${bc(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${bc(n)}`:`the ccusage this deck found on your PATH failed to run: ${bc(n)}`;default:return n}}const bc=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function eQ(e,t){const n=fu(e);if(YJ(n)){if(ZJ.test(n))return KJ;if(XJ.test(n))return GJ}if(VJ(n))return zJ;const s=V1(HJ,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Vi(e,t,n){const s=n==null?null:OP[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&IP(e.state))return e.error;const r=V1(qJ,e==null?void 0:e.reason);return r||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function fr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const s=Math.round(n/60);if(s<60)return`${s}m ago`;const r=Math.round(s/60);return r<48?`${r}h ago`:`${Math.round(r/24)}d ago`}const tQ={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${G1}. The next round brings it.`}};function f0(e){return e.why?Vt(tQ,e.why)??uf(e.why):null}const K1={"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"}},nQ={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 TC(e){var s;const t=sQ[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&nQ[n]||e}const sQ={"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 np(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=np({...e,error:void 0},t),m=` · ${fr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${TC(e.error)}${m}`,tone:"bad"}}if(e.error)return K1[e.error]??{text:TC(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${fr(e.at,t)}`,tone:"idle"};const s=n.filter(p=>p.ok),r=s.length===1?"login":"logins",o=n.map(p=>({d:p,why:f0(p)})).filter(p=>p.why),i=[...new Set(o.map(p=>p.why.short))],c=i.length?`, ${i.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=fr(e.at,t);return s.length===n.length?{text:`${s.length} ${r} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${s.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const rQ=9e4;function aQ({error:e,host:t,port:n},s,r,o=45317){if(e!=="handshake timed out")return null;const i=(t??"").trim();if(!i)return null;const c=s.filter(h=>h.addr===i&&h.port&&h.at>0&&r-h.at<rQ);if(!c.length)return null;const d=[...new Set(c.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${i} 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 ${i}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function sp(e,t){var n,s;return(n=e.last)!=null&&n.error&&!K1[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<p0||e.lastSeen!=null&&t-e.lastSeen<p0)}const p0=95e3;function oQ(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 s=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!s.length)return{text:"no deck paired yet",tone:"idle"};const r=p=>p.waiting?PP(p.lastSeen,t):sp(p,t),o=p=>{var m;return!p.waiting&&((m=p.last)==null?void 0:m.error)==="waiting for the other deck to accept this one"},i=e.aliases??{};let c=0,d=0,h=0;for(const p of DP(s,m=>X1(m,m.peerFp??m.fp,i).name,m=>m.addr??"")){const m=p.filter(r);if(!m.length){h++;continue}c++,m.every(o)&&d++}if(c&&d===c)return{text:c===1?"1 deck found · waiting for them to accept":`${c} decks found · waiting for them to accept`,tone:"wait"};if(!c)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=c===1?"1 deck ready":`${c} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function iQ(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=fr(e,t);return s==="now"?"checked just now":`checked ${s}`}function Y1(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const s=Math.round(n/60);return s<60?`${s}m ago`:`${Math.round(s/60)}h ago`}function PP(e,t){return e!=null&&t-e<p0}function lQ(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=PP(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${fr(e,t)}`,here:n}}function RC(e,t,n){return t?"online":e.lastSeen!=null?`last online ${fr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function cQ(e,t){if(!e)return[];const n=[],s=new Set,r=(p,m)=>p.name.localeCompare(m.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),n.push(uQ(p,o,t)));const i=[],c=[];for(const p of e.peers??[]){const m=p.peerFp??p.fp;!m||s.has(m)||(s.add(m),!p.paired&&p.manual&&!p.met?c.push(dQ(p,m,t)):i.push(hQ(p,m,o,t)))}n.push(...gQ(i).sort(r),...c.sort(r));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),d.push(pQ(p,o,e.pairingMode)));n.push(...d.sort(r));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),h.push(mQ(p,o)));n.push(...h.sort(r));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 uQ(e,t,n){const s=rp(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${Y1(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...ap(e.via)}}function dQ(e,t,n){var o;const s=np(e.last,n),r=e.addr?`${e.addr}:${e.port}`:"";return{fp:r,name:r||e.name||t,addr:e.addr??"",kind:"dialling",state:s?m0(s):"trying…",tone:s?s.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${r} yet — ${e.last.error}.`:`Dialling ${r} until something answers.`,...ap(e.via)}}function hQ(e,t,n,s){var w,j,b,k;const r=np(e.last,s),o=sp(e,s),i=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?lQ(e.lastSeen,s):null,d=c?c.here:o,h=!c&&r?d?`online · ${m0(r)}`:`${m0(r)} · ${RC(e,d,s)}`:c?c.text:RC(e,d,s),f=(w=e.last)!=null&&w.error?K1[e.last.error]:null,p=!c&&d&&!((j=e.last)!=null&&j.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,m=X1(e,t,n);return{fp:t,...m,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":r?r.tone:d?"ok":"idle",here:c?c.here:o,...ap(e.via),hint:c?`${m.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${fr(e.lastSeen,s)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${m.name}${i?` at ${i}`:""}${(k=e.last)!=null&&k.error?` — ${e.last.error}`:""}${r!=null&&r.hint?` — ${r.hint}`:""}`}}function X1(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:rp(n,t,e.name||t)}function fQ(e,t){return X1(e,e.peerFp??e.fp,t).name}function pQ(e,t,n){const s=rp(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${s.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${s.name} at ${e.addr} is on this network and nothing is shared with it.`,...ap(e.via)}}function mQ(e,t){const n=rp(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 rp(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function ap(e){return e==="tailscale"?{via:"tailscale"}:{}}function m0(e){return e.text.replace(/ · .*$/,"")}function gQ(e){return DP(e,t=>t.name,t=>t.addr).map(yQ)}function DP(e,t,n){const s=new Map;for(const o of e){const i=s.get(t(o));i?i.push(o):s.set(t(o),[o])}const r=[];for(const o of s.values()){const i=[...new Set(o.map(n).filter(Boolean))];if(i.length>1){for(const c of i)r.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||r.push([c])}else r.push(o)}return r}function yQ(e){const[t,...n]=[...e].sort((s,r)=>Number(r.here)-Number(s.here)||+!!r.addr-+!!s.addr);return n.length?{...t,twins:n}:t}function AC(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function pu(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 wQ(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(i=>i.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 s=t.filter(i=>i.kind==="paired");if(!s.length)return{text:"On · none paired yet",tone:"idle",live:!1};const r=s.filter(i=>i.here).length;return r?r===s.length?{text:`${r} online`,tone:"ok",live:!0}:{text:`${r} of ${s.length} online`,tone:"ok",live:!0}:{text:`none of ${s.length} online`,tone:"idle",live:!1}}function xQ(e,t){const n=e.filter(f=>f.kind==="asks"),s=e.filter(f=>f.kind!=="asks"),r=s.filter(f=>f.here),o=s.filter(f=>!f.here),i=o.filter(f=>f.tone==="bad").length,c=t||r.length===0,d=c?[...r,...o]:r,h=s.filter(f=>f.kind==="paired").length;return{asks:n,rest:s,live:r,folded:o,troubled:i,showFolded:c,shown:d,paired:h}}function MC(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 vQ(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(r=>r.paired&&sp(r,n)).map(r=>{var o,i;return(i=(o=r.offers)==null?void 0:o.accounts)==null?void 0:i.find(c=>c.key===e)}).filter(r=>r!=null);return s.length>0&&s.every(r=>!r.alive)}function bQ(e,t,n,s){if(!(n!=null&&n.enabled)||n.running===!1)return!1;const r=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!sp(o,s))return!1;const i=(d=(c=o.offers)==null?void 0:c.accounts)==null?void 0:d.find(p=>p.key===e);return!(i!=null&&i.alive)||i.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===r))})}function kQ(e,t){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return null;const n=(t.peers??[]).filter(s=>s.paired&&!(s.notOffered??[]).includes(e)).map(s=>fQ(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,r)=>s.localeCompare(r))}function $C(e){return e.length?`Shared on Local network: offered to ${e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}.`:"Shared on Local network: offered to every deck you pair with. None is paired yet."}function jQ(e){return e>=90?"hi":e>=70?"mid":void 0}function NQ({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:r}){const o=Math.min(100,Math.max(0,e.pct)),i=hu(e,t),c=s||i,d=c?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!c?Su(e.resetAt,t):null,f=i?AP(e,n,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:!i&&a.jsx("div",{className:"ap-lane-fill",style:{width:`${o===0?1.5:o}%`,background:d,opacity:o===0||c?.4:1}})}),i?a.jsx("span",{className:"ap-lane-pct",style:{color:d},"data-reset":"",title:f??void 0,children:f?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"reset"}),a.jsx("span",{className:"vis-hidden",children:f})]}):"reset"}):a.jsxs("span",{className:"ap-lane-pct",style:{color:d},children:[Math.round(o),"%"]}),a.jsx("span",{className:"ap-lane-reset",title:h?`${e.label} resets in ${h}`:void 0,children:h&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),h]})})]})}function SQ({a:e,nowSec:t,lan:n,opened:s,onToggleLanes:r,busy:o,pressProps:i,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:m,switchedHere:w,swapped:j,displaced:b,issueExpanded:k,onOpenIssue:v,sortKey:N=null,home:S=null}){const E=e.lanes.filter(D=>!hu(D,t)),{shown:C}=kC(e.lanes),{fuller:I}=kC(E),R=N==="room"?E.reduce((D,P)=>D&&D.pct>=P.pct?D:P,null):N?e.lanes.find(D=>kJ(D)===N)??null:null,$=Ho(e,t,n),L=e.active||s,U=e.alias??e.email??`account ${e.num}`,O=e.alias&&e.email?`${e.alias} · ${e.email}`:U,M=e.stale||($==null?void 0:$.blocksSwitch)===!0,q=I?[...C,I]:C,A=e.fetchedAt?Ba(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":L?"":void 0,"data-frozen":M?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:O,"aria-expanded":L,"aria-controls":L?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,S?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!L&&!($!=null&&$.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>r(),children:a.jsxs("span",{className:"vis-hidden",children:[U,", ",L?"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}),S&&a.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:S,children:[a.jsxs("svg",{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:"M2.2 6.6 7 2.6l4.8 4"}),a.jsx("path",{d:"M3.6 5.6v5.8h6.8V5.6"}),a.jsx("path",{d:"M6 11.4V8.6h2v2.8"})]}),a.jsx("span",{className:"vis-hidden",children:S})]}),(n==null?void 0:n.sharedTo)&&a.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:$C(n.sharedTo),children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"10.5",cy:"3.2",r:"1.7"}),a.jsx("circle",{cx:"3.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"10.5",cy:"10.8",r:"1.7"}),a.jsx("path",{d:"M5.2 6.1 8.8 4.1M5.2 7.9l3.6 2"})]}),a.jsx("span",{className:"vis-hidden",children:$C(n.sharedTo)})]}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!($!=null&&$.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>c(e.num,U),"aria-label":`Switch to ${U}`,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:D=>{D.key!=="ArrowDown"&&D.key!=="ArrowUp"||(D.preventDefault(),h(e.num,D.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:()=>m(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&w&&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."}),j&&(()=>{const D=(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 ${j.at} was taken, so the two accounts traded places: ${D} now holds slot ${j.displaced}.`,children:["swapped with slot ",j.displaced]})})(),$&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":$.tone,"aria-haspopup":"dialog","aria-expanded":k,"aria-controls":k?"ap-issue-pop":void 0,onClick:()=>v(e.num,`ap-issue-${e.num}`),children:[$.tone==="warn"&&a.jsx(q1,{}),a.jsx("span",{className:"ap-issue-text",children:$.text})]}),!L&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:A??"never collected"})]}),!L&&!($!=null&&$.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[q.length?q.map(D=>a.jsxs("span",{className:"ap-q","data-sort-key":D.id===(R==null?void 0:R.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:D.label})," ",hu(D,t)?a.jsx("span",{className:"ap-q-pct",title:`${D.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":M?void 0:jQ(D.pct),children:[Math.round(D.pct),"%"]})]},D.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!$&&a.jsx("span",{className:"ap-q-age","data-never":A?void 0:"",title:"When claude-swap last read this account's usage",children:A??"never collected"})]}),L&&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(D=>a.jsx(NQ,{lane:D,nowSec:t,readAt:e.fetchedAt,frozen:M,sortedBy:D.id===(R==null?void 0:R.id)},D.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&&!$?" 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 ",Ba(e.fetchedAt,t),$!=null&&$.blocksSwitch?"":fJ(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function _Q({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 EQ({canShare:e,canReport:t,onAdd:n,onReport:s,onShareSet:r,onReload:o,pressProps:i,reloading:c,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"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:()=>r(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Ct} 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(),...i("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}function yn({children:e,narrow:t}){return a.jsx("svg",{className:t?"glyph glyph-narrow":"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:e})}const CQ=()=>a.jsxs(yn,{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"})]}),TQ=()=>a.jsxs(yn,{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"})]}),RQ=()=>a.jsxs(yn,{narrow:!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"})]}),AQ=()=>a.jsxs(yn,{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"})]}),MQ=()=>a.jsxs(yn,{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"})]}),$Q=()=>a.jsxs(yn,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5"}),a.jsx("path",{d:"M7 2v5l3.5-3.5"}),a.jsx("circle",{cx:"4.5",cy:"8.5",r:".7"})]}),IQ=({watching:e})=>a.jsxs(yn,{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"}),e?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"})]}),LQ=()=>a.jsxs(yn,{children:[a.jsx("path",{d:"M5.4 2.9L5.6 1.1L8.4 1.1L8.6 2.9L9.8 3.6L11.5 2.8L12.8 5.2L11.3 6.3L11.3 7.7L12.8 8.8L11.5 11.2L9.8 10.4L8.6 11.1L8.4 12.9L5.6 12.9L5.4 11.1L4.2 10.4L2.5 11.2L1.2 8.8L2.7 7.7L2.7 6.3L1.2 5.2L2.5 2.8L4.2 3.6Z"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.9"})]}),OQ=()=>a.jsxs(yn,{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"})]}),PQ=()=>a.jsx(yn,{children:a.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),DQ=()=>a.jsxs(yn,{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"})]}),FQ=()=>a.jsxs(yn,{children:[a.jsx("path",{d:"M7 1.6v5"}),a.jsx("path",{d:"M4.2 3.6a4.8 4.8 0 1 0 5.6 0"})]}),BQ=()=>a.jsx(yn,{children:a.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),qQ=()=>a.jsx(yn,{children:a.jsx("path",{d:"M1.4 7.4h2.5l1.7-4 2.8 7.2 1.6-3.2h2.6"})}),UQ=()=>a.jsxs(yn,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5"}),a.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]});function IC(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function WQ(e,t,n=!1){const s=new Date(t*1e3),r=Array.from({length:7},(c,d)=>{const h=new Date(s.getFullYear(),s.getMonth(),s.getDate()+d);return{key:IC(h),date:h,entries:[],scheduled:0,outdated:0}}),o=new Map(r.map(c=>[c.key,c])),i=[];for(const c of e){const d=c.lanes.find(N=>N.id==="seven_day"),h=d==null?void 0:d.resetAt,f=h!=null&&h>0&&Number.isFinite(h)&&Number.isFinite(new Date(h*1e3).getTime())?h:null,p=d0(c,"seven_day",t),m=Ho(c,t),w=tp(c.fetchedAt),j=w==null,b=n||j||c.stale||c.staleCopy===!0||c.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>CP,k=n?"Last saved reading":m!=null&&m.blocksSwitch||c.staleCopy||c.stopped?(m==null?void 0:m.text)??"Not collecting":j?"Never read":b?`${c.stale?"Marked stale · ":""}Read ${Ba(w,t)}`:null,v={key:Ls(c),name:TP(c),active:c.active,heldOut:c.disabled,at:f,used:p.counted?p.pct:p.last,stale:b,note:k};if(f==null)i.push({...v,reason:"unknown"});else if(f<=t)i.push({...v,reason:"passed"});else{const N=o.get(IC(new Date(f*1e3)));N?(N.entries.push(v),b?N.outdated++:N.scheduled++):i.push({...v,reason:"outside"})}}for(const c of r)c.entries.sort((d,h)=>d.at-h.at);return{days:r,unscheduled:i}}const Th=e=>e.toLocaleDateString(void 0,{weekday:"short"}),df=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),qc=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),Z1=(e,t)=>e-t<60?"less than 1m":Su(e,t);function op({at:e}){const t=new Date(e*1e3);return a.jsx("time",{className:"ap-reset-time",dateTime:t.toISOString(),title:`${t.toLocaleString(void 0,{timeZoneName:"shortOffset"})} · ${t.toISOString()} (UTC)`,children:t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})})}function Rh({entry:e}){return a.jsxs("span",{className:"ap-reset-name",children:[a.jsx("span",{children:e.name}),e.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),e.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}function FP({entry:e,row:t,nowSec:n,withReading:s=!1,older:r=!1,context:o}){return a.jsxs("details",{className:"ap-reset-account",children:[a.jsxs("summary",{children:[o?a.jsxs("span",{className:"ap-reset-summary-other",children:[a.jsx(Rh,{entry:e}),o]}):s?a.jsxs("span",{className:"ap-reset-summary-content",children:[a.jsx(Rh,{entry:e}),a.jsx(BP,{entry:e,older:r})]}):a.jsx(Rh,{entry:e}),a.jsx("span",{className:"vis-hidden",children:" · Account details"})]}),a.jsxs("div",{className:"ap-reset-account-body",children:[t&&["five_hour","seven_day"].map(i=>{const c=t.cells[i],d=c.counted?c.pct:c.last,h=t.resets[i];return a.jsxs("p",{children:[a.jsx("strong",{children:i==="five_hour"?"5-hour":"7-day"}),a.jsx("span",{children:d==null?"No usage reading":`${e.stale||!c.counted?"Last read: ":""}${qa(d)}% used`}),a.jsx("span",{children:h==null?"Reset time unknown":h<=n?"Reported time passed · awaiting a new reading":a.jsxs(a.Fragment,{children:[e.stale?"Last reported reset":`Reset in ${Z1(h,n)}`," · ",a.jsx(op,{at:h})]})})]},i)}),a.jsx("p",{children:e.heldOut?"Excluded from automatic rotation.":"A weekly reset does not remove a separate 5-hour limit."})]})]})}function BP({entry:e,past:t=!1,older:n=!1}){return a.jsxs("span",{className:"ap-reset-reading","data-level":e.stale||t?"older":e.used!=null&&e.used>=70?"limited":void 0,children:[a.jsx("span",{className:"ap-reset-usage",children:e.used==null?"Usage unavailable":`${e.stale||t?"Last read: ":""}${qa(e.used)}% used`}),e.used!=null&&!e.stale&&!t&&a.jsx("span",{className:"ap-reset-meter","data-level":e.used>=90?"hi":e.used>=70?"mid":void 0,"aria-hidden":"true",children:a.jsx("span",{style:{"--reset-used":Math.min(100,Math.max(0,e.used))/100}})}),e.stale&&a.jsxs("span",{className:"ap-reset-old",children:[!n&&"Needs a fresh reading · ",e.note]})]})}function HQ({entry:e,row:t,nowSec:n}){const s=e.reason==="unknown"?"Reset time unknown":e.reason==="passed"?"Reported time passed · awaiting a new reading":"Beyond these seven days";return a.jsx("li",{className:"ap-reset-unplaced-row",children:a.jsx(FP,{entry:e,row:t,nowSec:n,context:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"ap-reset-unplaced-detail",children:[a.jsx("span",{children:s}),e.at!=null&&a.jsxs("span",{children:[df(new Date(e.at*1e3))," · ",a.jsx(op,{at:e.at})]})]}),a.jsx(BP,{entry:e,past:e.reason==="passed"})]})})})}function LC({days:e,rows:t,nowSec:n,outdated:s=!1}){return a.jsx("div",{className:"ap-reset-agenda",children:e.map(r=>{const o=r.entries.filter(i=>i.stale===s);return o.length?a.jsxs("section",{className:"ap-reset-day","aria-label":qc(r.date),children:[a.jsxs("h4",{className:"vis-hidden",children:[qc(r.date)," · ",o.length," ",o.length===1?"account":"accounts"]}),a.jsx("ul",{children:Array.from(new Set(o.map(i=>i.at))).map((i,c)=>a.jsxs("li",{className:"ap-reset-event",children:[a.jsxs("div",{className:"ap-reset-when","data-outdated":s?"":void 0,children:[s&&a.jsx("span",{className:"ap-reset-last-reported",children:"Last reported"}),c===0&&a.jsxs("time",{className:"ap-reset-day-label",dateTime:r.key,children:[Th(r.date)," · ",df(r.date)]}),a.jsx(op,{at:i}),!s&&a.jsxs("span",{children:["in ",Z1(i,n)]})]}),a.jsx("ul",{children:o.filter(d=>d.at===i).map(d=>a.jsx("li",{className:"ap-reset-entry","data-outdated":d.stale?"":void 0,children:a.jsx(FP,{entry:d,row:t.get(d.key),nowSec:n,withReading:!0,older:s})},d.key))})]},i))})]},r.key):null})})}function zQ({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:r=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:c,unscheduled:d}=WQ(e,t,n!=null),h=c.find($=>$.key===s)??null,f=h?[h]:c,p=c.reduce(($,L)=>$+L.scheduled,0),m=f.reduce(($,L)=>$+L.outdated,0),w=c.reduce(($,L)=>$+L.outdated,0),j=h?h.scheduled:p,b=c.flatMap($=>$.entries).find($=>!$.stale),k=b?c.flatMap($=>$.entries).filter($=>!$.stale&&$.at===b.at):[],v=y.useRef(null),N=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{var L,U;const $=S.current;$&&!$.isConnected&&document.activeElement===document.body&&((U=(L=N.current)==null?void 0:L.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const E=()=>{v.current&&(v.current.scrollTop=0)},C=$=>{E(),r(null),i($)},I=Intl.DateTimeFormat().resolvedOptions().timeZone,R=new Map(z1(e,t).rows.map($=>[$.key,$]));return a.jsxs("div",{ref:N,onFocusCapture:$=>{S.current=$.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("div",{className:"ap-reset-overview",children:[a.jsxs("div",{className:"ap-reset-command",children:[a.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:b?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ap-reset-next-identity",children:[a.jsxs("h3",{children:[a.jsx(UQ,{}),"Next reported reset ",a.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),k.length>1?a.jsxs("span",{className:"ap-reset-name",children:[k.length," accounts"]}):a.jsxs("details",{className:"ap-reset-next-account",children:[a.jsxs("summary",{title:b.name,children:[a.jsx(Rh,{entry:b}),a.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),a.jsx("p",{className:"ap-reset-full-name",children:b.name})]}),a.jsxs("p",{children:[Th(new Date(b.at*1e3)),", ",df(new Date(b.at*1e3))," · ",a.jsx(op,{at:b.at})]}),a.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",k.length>1?"s":b.used!=null?` · ${qa(b.used)}% weekly used`:""]})]}),a.jsxs("p",{className:"ap-reset-countdown",children:[a.jsx("strong",{children:Z1(b.at,t)}),a.jsxs("span",{children:[a.jsx("span",{className:"vis-hidden",children:"until "}),"reported reset"]})]})]}):a.jsxs("div",{className:"ap-reset-next-identity",children:[a.jsx("h3",{children:"No upcoming weekly resets"}),a.jsx("p",{children:w?"Some schedules need a fresh reading. Check the last reported times below.":"No reported weekly resets in these seven days. Unknown and elapsed times remain below."})]})}),a.jsxs("div",{className:"ap-reset-coverage",role:"group","aria-label":"Schedule data",children:[a.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"upcoming","aria-pressed":o==="upcoming",onClick:()=>C("upcoming"),children:[a.jsx("b",{children:p}),a.jsxs("span",{children:["Upcoming",a.jsx("span",{children:"Recent readings"})]})]}),a.jsxs("button",{type:"button",className:"ap-reset-coverage-link",title:"Schedules in these seven days that need a fresh reading","data-scope":"older","data-attention":w>0?"":void 0,"aria-pressed":o==="older",onClick:()=>C("older"),children:[a.jsx("b",{children:w}),a.jsxs("span",{children:["Needs fresh data",a.jsx("span",{children:"This week · excluded"})]})]}),a.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"other","aria-pressed":o==="other",onClick:()=>C("other"),children:[a.jsx("b",{children:d.length}),a.jsxs("span",{children:["Other reset times",a.jsx("span",{children:"Unknown, elapsed or later"})]})]})]})]}),a.jsxs("section",{className:"ap-reset-navigation","aria-label":"Choose a calendar day",children:[a.jsxs("div",{className:"ap-reset-intro",children:[a.jsxs("h3",{children:["Next 7 days ",a.jsxs("span",{children:[p," weekly ",p===1?"reset":"resets"]})]}),a.jsx("p",{children:I})]}),a.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:c.map(($,L)=>a.jsx("li",{"data-today":L===0?"":void 0,children:a.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":L===0?"date":void 0,"data-active":$.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===$.key,"aria-label":`${qc($.date)}: ${$.scheduled} scheduled resets${$.outdated?`, ${$.outdated} readings need updating`:""}`,onClick:()=>{E(),i("upcoming"),r((h==null?void 0:h.key)===$.key?null:$.key)},children:[a.jsxs("time",{dateTime:$.key,title:qc($.date),children:[a.jsx("span",{className:"ap-reset-weekday",children:L===0?"Today":Th($.date)}),a.jsx("span",{className:"ap-reset-date",children:$.date.getDate()})]}),a.jsxs("span",{className:"ap-reset-count",children:[a.jsx("b",{children:$.scheduled||"—"}),a.jsxs("span",{children:[" ",$.scheduled===1?"reset":"resets"]})]})]})},$.key))})]})]}),a.jsxs("div",{ref:v,className:"ap-reset-results",children:[a.jsxs("section",{className:"ap-reset-scheduled",hidden:o!=="upcoming","aria-label":"Scheduled weekly resets",children:[a.jsxs("div",{className:"ap-reset-list-head",children:[a.jsxs("h3",{children:[h?`${Th(h.date)}, ${df(h.date)}`:"All upcoming resets"," ",a.jsx("span",{children:j})]}),a.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{E(),r(null)},children:"All days"})]}),a.jsx("p",{className:"ap-reset-hint",role:"status",children:h?`Showing only ${qc(h.date)}.`:"All days · select a date to narrow the agenda."}),j>0?a.jsx(LC,{days:f,rows:R,nowSec:t}):a.jsx("p",{className:"ap-reset-empty",children:h?"No upcoming resets on this day. Choose another date or All days.":"The schedule updates with new account readings. No weekly recurrence is assumed."})]}),a.jsxs("section",{className:"ap-reset-disclosure",hidden:o!=="older","aria-label":"Accounts needing fresh readings",children:[a.jsxs("h3",{children:["Needs a fresh reading ",a.jsxs("span",{children:[m," ",m===1?"account":"accounts"," · excluded from counts"]})]}),a.jsx("p",{className:"ap-reset-explain",children:"These weekly schedules need a fresh reading. Other reset times may also contain stale readings. Last reported times and usage remain visible until updated."}),m>0?a.jsx(LC,{days:f,rows:R,nowSec:t,outdated:!0}):a.jsx("p",{className:"ap-reset-empty",children:"No older schedules in these seven days. Unknown or elapsed times are listed in Other reset times."})]}),a.jsxs("section",{className:"ap-reset-disclosure ap-reset-unplaced",hidden:o!=="other","aria-label":"Other reset times",children:[a.jsxs("h3",{children:["Other reset times ",a.jsxs("span",{children:[d.length," ",d.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),d.length>0?a.jsx("ul",{children:d.map($=>a.jsx(HQ,{entry:$,row:R.get($.key),nowSec:t},$.key))}):a.jsx("p",{className:"ap-reset-empty",children:"All reported reset times fall within the upcoming week."})]}),a.jsxs("details",{className:"ap-reset-about",children:[a.jsx("summary",{children:"How to read this schedule"}),a.jsxs("p",{className:"ap-reset-explain",children:["Counts are reported weekly account resets, not token amounts. Zero means no upcoming reset on that day, not zero usage. Held-out accounts still appear in the schedule. A timestamp passing does not confirm renewed capacity. Older readings are excluded from upcoming counts. Times use ",I,"; a separate 5-hour limit may still apply. Usage bars show reported capacity used. The warning tint at 70% or more indicates lower remaining capacity, not an account error."]})]})]})]})}function qP(e){return e>=90?"hi":e>=70?"mid":void 0}const UP=(e,t,n)=>`${e} ${e===1?t:n}`;function OC(e){const t=e.more>0?`, and ${UP(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${qa(e.pct)}% used)${t}`}function VQ({w:e,nowSec:t}){const n=`ap-report-${e.id}`,s=e.total-e.included,r=s>0&&a.jsxs("p",{className:"ap-report-basis",children:[s," never read"]}),{used:o,available:i}=OJ(e.used??0),c=Math.round(So(i,{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."]}),r]});const d=e.nextReset?Su(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[c,"%"]})," average remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":qP(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":i/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:OC(e.nextReset),children:[a.jsxs("span",{children:["Next reported 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:[". ",OC(e.nextReset)]})]}),r]})}function GQ({cell:e,label:t}){if(!e.counted){const n=e.estimate==null?", not counted":", last reading, counted as is";return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",title:e.reset??void 0,children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),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"})]}):`${qa(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:e.reset?`. ${e.reset}. Awaiting a fresh reading${n}.`:n})]})}return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),a.jsxs("span",{className:"ap-report-pct","data-level":qP(e.pct),children:[qa(e.pct),"%"]})]})}function KQ({at:e,nowSec:t,label:n}){if(e==null)return a.jsxs("td",{className:"ap-report-reset-cell",children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"No reset time"})]});const s=new Date(e*1e3),r=Su(e,t);return a.jsxs("td",{className:"ap-report-reset-cell",title:`Recorded reset: ${s.toLocaleString()}`,children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),a.jsxs("time",{dateTime:s.toISOString(),children:[a.jsx("span",{className:"vis-hidden",children:r?"reported reset in ":"reported reset "}),r??"due"]}),!r&&a.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"}),a.jsxs("span",{className:"vis-hidden",children:[" · Recorded reset: ",s.toLocaleString()]})]})}const YQ={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function XQ({row:e}){return a.jsxs("td",{className:"ap-report-state","data-status":e.status,children:[a.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Status"}),a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),YQ[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&a.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function ZQ({row:e,nowSec:t}){const n=AJ(e,t);return a.jsxs("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:[a.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Updated"}),n.text]})}function JQ(){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 QQ({accounts:e,nowSec:t,held:n,sort:s=null,onSort:r=()=>{}}){const o=z1(e,t),i=o.rows.length,c=Math.round(So(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("div",{className:"ap-report-overview",children:[a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:c})," of ",UP(i,"Claude account","Claude accounts")," ready"]}),a.jsxs("p",{className:"ap-report-confidence",children:["Based on last readings",o.rows.some(d=>Object.values(d.cells).some(h=>!h.counted&&h.reset))&&" · elapsed reset times need fresh readings",o.rows.some(d=>d.heldOut)&&` · ${o.rows.filter(d=>d.heldOut).length} held out of rotation`]})]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(VQ,{w:d,nowSec:t},d.id))}),a.jsx("div",{className:"ap-report-table-scroll",role:"region","aria-label":"Account capacity table",children:a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use and reset of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),Lo.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("col",{className:"ap-report-col-win"}),a.jsx("col",{className:"ap-report-col-reset"})]},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(Bi,{col:"account",label:"Account",sort:s,next:vc,onSort:r}),Lo.map(d=>a.jsxs(y.Fragment,{children:[a.jsx(Bi,{col:d.id,label:`${d.label} used`,sort:s,next:vc,onSort:r}),a.jsx(Bi,{col:`${d.id}_reset`,label:`${d.label} reset`,sort:s,next:vc,onSort:r})]},d.id)),a.jsx(Bi,{col:"status",label:"Status",sort:s,next:vc,onSort:r}),a.jsx(Bi,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:vc,onSort:r})]})}),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"})]})}),Lo.map(f=>a.jsxs(y.Fragment,{children:[a.jsx(GQ,{cell:d.cells[f.id],label:f.label}),a.jsx(KQ,{at:d.resets[f.id],nowSec:t,label:f.label})]},f.id)),a.jsx(XQ,{row:d}),a.jsx(ZQ,{row:d,nowSec:t})]},d.num))})]})}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(JQ,{}),"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, not pooled quota. A passed reported reset time does not confirm renewed capacity. Its last usage reading remains until refreshed."]}),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. Ready may be based on an older reading whose reset time has passed; held-out accounts remain included, but are excluded from automatic rotation."]})]})]})]})}function eee({accounts:e,order:t,failed:n,nowSec:s,onClose:r}){const o=y.useRef(null),i=ct(r,{focusRef:o}),c=xt(r),[d,h]=y.useState("accounts"),[f,p]=y.useState("upcoming"),[m,w]=y.useState(null),[j,b]=y.useState(e??[]);y.useEffect(()=>{e!=null&&b(e)},[e]);const k=PJ(n,e==null,j.length>0),[v,N]=y.useState(null),S=c0(j,(v==null?void 0:v.order)??t),E=C=>{const I=z1(c0(j,t),s).rows;N({sort:C,order:LJ(I,C).map(R=>R.key)})};return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:i,className:"modal ap-report-modal","data-view":d,onClick:C=>C.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.jsxs("div",{className:"ap-report-views",role:"group","aria-label":"Capacity view",children:[a.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="accounts",onClick:()=>h("accounts"),children:"Accounts"}),a.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="calendar",onClick:()=>h("calendar"),children:"Reset calendar"})]}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:r,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:k??""}),d==="accounts"?a.jsx(QQ,{accounts:S,nowSec:s,held:k,sort:(v==null?void 0:v.sort)??null,onSort:E}):a.jsx(zQ,{accounts:S,nowSec:s,held:k,selectedDate:m,onSelect:w,scope:f,onScope:p})]})}),document.body)}const tee=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],nee="Uses up quota that resets within 4 days first";function see(e){return e==="room"||e==="weekly"}function Pg(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function ree(e,t){return t?e.disabled?"Home · paused while held out of rotation":e.alive===!1||e.error||e.reauth?"Home · paused until this account is signed in again":"Home · Auto-switch comes back here after its 5-hour window resets":"Home · Auto-switch comes back here while it is on"}const Dg=[70,80,85,90,95],WP="custom",qi=50,Ui=99,aee=`A whole percent from ${qi} to ${Ui}.`;function oee(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Dg.includes(t)?[...Dg,t]:Dg].sort((s,r)=>s-r)}function iee(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${qi} to ${Ui}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${qi} to ${Ui}.`};const n=Number(t);return Number.isInteger(n)?n<qi?{ok:!1,reason:"too_low",message:`The lowest is ${qi}%.`}:n>Ui?{ok:!1,reason:"too_high",message:`The highest is ${Ui}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${qi} to ${Ui}.`}}const g0={pick:null,custom:null,refusal:null};function lee(e,t){switch(t.kind){case"pick":return t.pick===WP?{...e,custom:{from:e.pick},refusal:null}:{pick:t.pick,custom:null,refusal:null};case"type":return{...e,pick:t.text,refusal:null};case"cancel":return e.custom?{pick:e.custom.from,custom:null,refusal:null}:e;case"refuse":return{...e,refusal:t.message};case"settle":return g0;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?g0:e}}async function cee(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=iee(e);if(!s.ok)return{kind:"refused",message:s.message};const r=await n({action:"setting",key:"autoswitch.threshold",value:s.value},"threshold");return{kind:"sent",ok:(r==null?void 0:r.ok)===!0}}function uee({auto:e,threshold:t,thresholdPick:n,thresholdCtl:s,thresholdSaved:r,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:c,thresholdRefusal:d,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:m,leaveThreshold:w,doThreshold:j,nextPick:b,nextCtl:k,nextSaved:v,nextRef:N,nextSaveRef:S,proposeNext:E,doNext:C,pressProps:I,post:R,load:$}){const L=y.useId(),U=y.useId(),O=y.useId();return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",onKeyDown:c?m:void 0,children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),c?a.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:M=>{M.preventDefault(),j(n,s)},children:a.jsxs("span",{className:"ap-threshold-field",title:"Switch once the active account passes this much of its limit",children:[a.jsx("input",{ref:h,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-label":"Switch threshold","aria-describedby":L,"aria-invalid":d?!0:void 0,value:n,...I("threshold"),onChange:M=>p(M.target.value),onBlur:()=>w(),autoComplete:"off",spellCheck:!1}),a.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsxs("select",{ref:o,"aria-label":"Switch threshold",value:n,...I("threshold"),onChange:M=>f(M.target.value),children:[oee(t).map(M=>a.jsxs("option",{value:M,children:[M,"%"]},M)),a.jsx("option",{value:WP,children:"Custom…"})]})}),(s.sends||r)&&a.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...I("threshold"),title:s.title,onClick:()=>j(n,s),children:r&&!s.sends?s.done:s.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...I("enable"),onClick:()=>R({action:"enable",enabled:!e.enabled},"enable").then(()=>$(!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"})})]}),d?a.jsx("p",{id:L,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?a.jsx("p",{id:L,className:"ap-threshold-note",children:aee},"hint"):null,e.enabled&&a.jsxs("div",{className:"ap-policy ap-next",children:[a.jsx("label",{className:"ap-next-label",htmlFor:U,children:"Next account"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:U,ref:N,value:b,"aria-describedby":b==="weekly"?O:void 0,...I("next"),onChange:M=>E(M.target.value),children:tee.map(M=>a.jsx("option",{value:M.value,children:M.label},M.value))})}),(k.sends||v)&&a.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...I("next"),title:k.title,onClick:()=>C(),children:v&&!k.sends?k.done:k.label})]}),e.enabled&&b==="weekly"&&a.jsx("p",{id:O,className:"ap-threshold-note",children:nee}),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 PC=18,dee=1100,Pi=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},hee=Array.from({length:PC},(e,t)=>{const n=-72+144*t/(PC-1)+(Pi(t,1)-.5)*9,s=(n-90)*(Math.PI/180),r=(54+32*Math.cos(n*Math.PI/180))*(.74+Pi(t,2)*.52);return{dx:Math.cos(s)*r,dy:Math.sin(s)*r,rot:(t%2?1:-1)*(100+Pi(t,3)*260),delay:Math.round(Pi(t,4)*90),dur:760+Math.round(Pi(t,5)*260),scale:.8+Pi(t,6)*.45,hue:t%4,round:t%3===0}});function DC({anchor:e}){var r;const[t,n]=y.useState(null),s=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(s)return;const o=e.current;if(!o)return;const i=o.getBoundingClientRect();n({x:i.left+i.width/2,y:i.top+i.height/2});const c=window.setTimeout(()=>n(null),dee);return()=>window.clearTimeout(c)},[e,s]),s||!t?null:wt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:hee.map((o,i)=>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`}},i))}),document.body)}const hf=y.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));hf.displayName="SuccessMark";const fee={done:", done",active:", in progress",failed:", failed",pending:""};function pee({status:e}){return a.jsx("svg",{className:"aa-stage-icon",viewBox:"0 0 16 16","aria-hidden":!0,children:e==="done"?a.jsx("path",{className:"aa-stage-tick",d:"M4 8.5 L7 11.5 L12.5 5"}):e==="failed"?a.jsx("path",{className:"aa-stage-cross",d:"M5 5 L11 11 M11 5 L5 11"}):e==="active"?a.jsx("circle",{className:"aa-stage-now",cx:"8",cy:"8",r:"3.5"}):a.jsx("circle",{className:"aa-stage-later",cx:"8",cy:"8",r:"3"})})}function mee({rows:e,phase:t,detail:n,actions:s}){var o;const r=(o=e.find(i=>i.status==="active"))==null?void 0:o.id;return a.jsxs("div",{className:`aa-progress ${t}`,"data-at":r,children:[a.jsxs("svg",{className:"aa-orbit",viewBox:"0 0 44 44","aria-hidden":!0,children:[a.jsx("circle",{className:"aa-orbit-track",cx:"22",cy:"22",r:"20"}),t==="live"||t==="resolving"?a.jsx("circle",{className:"aa-orbit-arc",cx:"22",cy:"22",r:"20"}):null,t==="resolving"?a.jsx("circle",{className:"aa-orbit-close",cx:"22",cy:"22",r:"20"}):null,t==="failed"?a.jsx("path",{className:"aa-orbit-cross",d:"M17 17 L27 27 M27 17 L17 27"}):null]}),a.jsx("ol",{className:"aa-stages",children:e.map(i=>{const c=i.status==="active"||i.status==="failed";return a.jsxs("li",{className:"aa-stage","data-status":i.status,"aria-current":i.status==="active"?"step":void 0,children:[a.jsx(pee,{status:i.status}),a.jsxs("span",{className:"aa-stage-label",children:[i.label,a.jsx("span",{className:"vis-hidden",children:fee[i.status]})]}),c&&n?a.jsx("div",{className:"aa-stage-more",children:n}):null]},i.id)})}),s?a.jsx("div",{className:"aa-actions aa-progress-actions",children:s}):null]})}const Fg=["link","approve","confirm","save"],FC={confirm:"confirm",save:"save",restore:"save"};function HP(e){return e!=null&&Object.prototype.hasOwnProperty.call(FC,e)?FC[e]:null}function gee({state:e,step:t,starting:n}){return e==="registering"?HP(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function yee({state:e,step:t,url:n,lastLive:s}){return e==="failed"?HP(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const wee={link:{pending:"Open the sign-in page",active:"Opening the sign-in page",done:"Sign-in page opened"},approve:{pending:"Approve in your browser",active:"Waiting for you to approve in the browser",done:"Approved in the browser"},confirm:{pending:"Confirm who signed in",active:"Confirming who signed in",done:"Sign-in confirmed"},save:{pending:"Save the credentials",active:"Saving the credentials",done:"Credentials saved"}};function xee(e,t,n){return t==="failed"?zP(e,n):wee[e][t]}function vee({live:e=null,failed:t=null,done:n=!1,state:s=null}){const r=n?Fg.length:Fg.indexOf(t??e);return Fg.map((o,i)=>{const c=n||i<r?"done":i>r||r<0?"pending":t?"failed":"active";return{id:o,status:c,label:xee(o,c,s)}})}function bee(e,t){switch(e){case"link":return"The claude CLI is preparing a sign-in link, and opens a browser tab with it.";case"approve":return"Approve the sign-in in the tab that opened. This finishes by itself.";case"confirm":return"Asking the claude CLI which account just signed in.";case"save":return t==="restore"?"Switching this machine back to the account you were using.":"claude-swap is recording the account."}}const kee={link:"The sign-in page did not open",approve:"The sign-in did not finish in the browser",confirm:"The sign-in could not be confirmed",save:"claude-swap could not save the account"};function zP(e,t){return t==="idle"?"Sign-in ended":kee[e]}const jee=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function Ah(e){const t=String(e??"").trim();if(!t)return"";const n=jee.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}Ah(LP);const Nee=1e4,See=1e4,_ee=5;function Eee({since:e,now:t,expiresAt:n}){if(e==null||t-e<Nee)return null;const s=n!=null?Math.ceil((n-t)/6e4):NaN,r="Still waiting for the browser. If no tab opened, or you closed it, use the link above";return s>=1&&s<=_ee?`${r} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${r}.`}function Cee({since:e,now:t}){return e==null||t-e<See?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function Tee(e){return e==="registering"?400:1500}const VP=460;function Ree({fromStages:e,reducedMotion:t}){return e&&!t?VP:0}function Aee({added:e,reducedMotion:t}){return e&&!t}function BC({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function Mee(e){switch(e){case"approve":return"Waiting for you to approve the sign-in in your browser.";case"confirm":return"Approved. Confirming who signed in.";case"save":return"Saving the credentials.";default:return null}}const $ee="done";function Iee(){let e=!1;return{shouldAnnounce(t){return t!==$ee?(e=!1,!1):e?!1:(e=!0,!0)}}}function J1(e,t,n,s="horizontal"){if(n<=0||Bf(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1,o=s==="vertical",i=e.key==="ArrowRight"||o&&e.key==="ArrowDown",c=e.key==="ArrowLeft"||o&&e.key==="ArrowUp";if(i)return{kind:"select",index:r===-1?0:(r+1)%n};if(c)return{kind:"select",index:r===-1?n-1:(r-1+n)%n};switch(e.key){case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function GP(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 Lee(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),r=n.alias||s||`account ${n.num}`,o=[];return n.alias&&s&&o.push(s),s&&(t.get(s.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:r,sub:o.length?o.join(" · "):null}})}function Oee(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function Pee(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Dee(e){return e.length?{action:"share",accounts:[...e]}:null}function Fee(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 y0(e){return`${e.email}|${e.org??""}`}function Bee(e,t,n){return e&&e.map(s=>y0(s)===t?n:s)}function qee(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 qC(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,s=[],r=n("imported");r&&s.push(`${r} of ${t} imported`);const o=n("healed");o&&s.push(`${o} had a dead token replaced`);const i=n("updated");i&&s.push(`${i} updated`);const c=n("present");c&&s.push(`${c} already here`);const d=n("failed");d&&s.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=uf(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function Uee(e){try{return e?new URL(e).host:""}catch{return""}}const lh=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],UC="aa-panel",WC=e=>`aa-tab-${e}`;async function xo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function KP({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){nn("add-account");const[r,o]=y.useState("login"),[i,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[m,w]=y.useState(!1),[j,b]=y.useState(!1),[k,v]=y.useState(null),[N,S]=y.useState(null),E=m||j,[C,I]=y.useState(null),[R,$]=y.useState(null),[L,U]=y.useState(null),O=y.useRef(""),M=y.useRef(!1),q=y.useRef(!1),A=y.useRef(null),D=y.useRef(null),P=y.useRef(null),K=y.useRef(null),G=y.useRef([]),W=y.useRef(!1),H=y.useRef(0),F=y.useRef(null),B=y.useRef("primer"),Z=y.useRef(null),V=y.useRef(null),X=y.useRef(null),Y=y.useRef(!1),J=y.useState(vu)[0],[ee,ne]=y.useState(null),[le,de]=y.useState(!1),[ue,re]=y.useState(()=>Date.now()),[pe,ye]=y.useState(null),[_e,he]=y.useState(null),[ae,ge]=y.useState(null),Se=y.useCallback(()=>{const Ne=CC({started:M.current,state:i==null?void 0:i.state});Ne&&xo(Ne).catch(()=>{}),e()},[e,i==null?void 0:i.state]),me=ct(Se,{focusRef:P}),$e=xt(Se),Pe=y.useCallback(async()=>{if(!An(q.current))return;const Ne=++H.current;q.current=!0,w(!0),v(null),ge(null),M.current=!0;let Te=await xo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(Te==null?void 0:Te.reason)==="bad_email"&&Ne===H.current&&(Te=await xo({action:"login"}).catch(()=>null)),Ne===H.current){if(q.current=!1,w(!1),!(Te!=null&&Te.ok)){v(Vi(Te,"could not start the sign-in"));return}c(Te)}},[n]);y.useEffect(()=>{if(!$P(i==null?void 0:i.state))return;const Ne=window.setInterval(async()=>{try{const Te=await fetch("/api/claude-accounts/login");Te.ok&&c(await Te.json())}catch{}},Tee(i==null?void 0:i.state));return()=>window.clearInterval(Ne)},[i]);const qe=y.useCallback(async()=>{const Ne=CC({started:M.current,state:i==null?void 0:i.state});if(H.current+=1,M.current=!1,q.current=!1,w(!1),v(null),c(null),h(""),de(!1),Y.current=!0,!Ne)return;const Te=await xo(Ne).catch(()=>null);ge(EC({restored:Te==null?void 0:Te.restored,activeAccount:Te==null?void 0:Te.activeAccount}))},[i==null?void 0:i.state]),Le=y.useCallback(()=>{M.current=!1,c(null),v(null),h(""),de(!1),Pe()},[Pe]),Qe=y.useRef(t);Qe.current=t;const je=y.useState(Iee)[0];y.useEffect(()=>{je.shouldAnnounce(i==null?void 0:i.state)&&Qe.current()},[i==null?void 0:i.state,je]),y.useEffect(()=>{var Ne;le&&((Ne=A.current)==null||Ne.focus())},[le]);const Ae=y.useRef(s);Ae.current=s;const De=y.useRef(null);y.useEffect(()=>{var We;const Ne=(i==null?void 0:i.state)==="done"?i.account:null,Te=Ne?`${Ne.num??""}|${Ne.email}`:null;!Ne||De.current===Te||(De.current=Te,(We=Ae.current)==null||We.call(Ae,Ne))},[i]),y.useEffect(()=>{var Ne;r==="paste"&&!W.current&&((Ne=D.current)==null||Ne.focus()),W.current=!1},[r]);const He=y.useCallback(Ne=>{var We;const Te=J1(Ne,lh.findIndex(pt=>pt.id===r),lh.length);Te.kind!=="pass"&&(Ne.preventDefault(),W.current=!0,o(lh[Te.index].id),(We=G.current[Te.index])==null||We.focus())},[r]),Ze=y.useCallback(async()=>{var We;if(!An(q.current))return;const Ne=H.current;q.current=!0,w(!0),v(null);const Te=await xo({action:"login-code",code:d}).catch(()=>null);if(Ne===H.current){if(q.current=!1,w(!1),!(Te!=null&&Te.ok)){v(Vi(Te,"the code was not accepted")),Te!=null&&Te.state&&c(Te),(We=A.current)==null||We.select();return}h(""),c(Te)}},[d,i]),ft=y.useCallback(async()=>{if(!An(q.current))return;q.current=!0,b(!0),S(null);const Ne=await xo({action:"import",blob:f}).catch(()=>null);if(q.current=!1,b(!1),!(Ne!=null&&Ne.ok)){S(Vi(Ne,"the import failed"));return}O.current=f,p(""),U(null),I(Ne.results??[]),t()},[f,t]),ut=y.useCallback(async Ne=>{const Te=y0(Ne);if(!An(q.current)||!O.current)return;q.current=!0,b(!0),$(Te),U(null);const We=await xo({action:"import",blob:O.current,force:!0,only:{email:Ne.email,org:Ne.org??""}}).catch(()=>null);if(q.current=!1,b(!1),$(null),!(We!=null&&We.ok)){U({key:Te,text:Vi(We,"that account could not be updated")});return}const pt=(We.results??[])[0];pt&&I(at=>Bee(at,Te,pt)),t()},[t]),Je=(i==null?void 0:i.state)==="done"?i.account:null,Dt=EC({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),vt=BJ({login:i,started:M.current,loginError:k,loginBusy:m}),It=FJ({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:k}),it=vt==="asking"||vt==="code"?gee({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:vt==="asking"})??"link":null,Lt=vt==="ended"?yee({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:F.current}):null,Ft=Je?`${Je.num??""}|${Je.email}`:null,dt=vt==="done"&&Ft!==ee&&Ree({fromStages:B.current==="progress",reducedMotion:J})>0,St=vt==="primer"?"primer":vt==="done"&&Je&&!dt?"done":"progress",rt=Lt?"failed":dt?"resolving":"live",ys=vee(dt?{done:!0}:Lt?{failed:Lt,state:i==null?void 0:i.state}:{live:it}),Ws=Lt?zP(Lt,i==null?void 0:i.state):"",ws=Ah(It.message),Yn=it==="approve"?Eee({since:pe,now:ue,expiresAt:i==null?void 0:i.expiresAt}):null,Xn=j?Cee({since:_e,now:ue}):null,wn=r==="login"?St==="done"&&Je?`${BC(Je)}.`:rt==="failed"?`${Ws}. ${ws}`:St==="progress"&&!dt?Mee(it)??"":"":j?"Importing the share.":N?Ah(N):C?Ah(qC(C)):"";y.useEffect(()=>{it&&(F.current=it)},[it]),y.useEffect(()=>{B.current=St},[St]),y.useEffect(()=>{if(!dt||!Ft)return;const Ne=window.setTimeout(()=>ne(Ft),VP);return()=>window.clearTimeout(Ne)},[dt,Ft]);const At=it==="approve";y.useEffect(()=>{ye(At?Date.now():null)},[At]),y.useEffect(()=>{he(j?Date.now():null)},[j]);const an=At||j;return y.useEffect(()=>{if(!an)return;re(Date.now());const Ne=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Ne)},[an]),y.useEffect(()=>{var Te,We,pt,at;if(r!=="login")return;if(St==="done"){(Te=V.current)==null||Te.focus();return}if(St==="primer"){Y.current&&((We=P.current)==null||We.focus()),Y.current=!1;return}if(rt==="failed"){(pt=X.current)==null||pt.focus();return}const Ne=document.activeElement;it==="approve"&&(!Ne||Ne===document.body)&&((at=Z.current)==null||at.focus())},[r,St,rt,it]),wt.createPortal(a.jsx("div",{className:"modal-backdrop",...$e,role:"presentation",children:a.jsxs("div",{ref:me,className:"modal aa-modal",onClick:Ne=>Ne.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:He,children:lh.map((Ne,Te)=>a.jsx("button",{type:"button",role:"tab",id:WC(Ne.id),ref:We=>{G.current[Te]=We},"aria-selected":r===Ne.id,"aria-controls":UC,tabIndex:r===Ne.id?0:-1,className:`aa-tab${r===Ne.id?" on":""}`,onClick:()=>{W.current=!1,o(Ne.id)},children:Ne.label},Ne.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:Se,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body aa-body",id:UC,role:"tabpanel","aria-labelledby":WC(r),children:[r==="login"?St==="done"&&Je?a.jsxs("div",{className:`aa-done${ee===Ft?" from-orbit":""}`,children:[a.jsx(hf,{ref:K}),Aee({added:Je.added,reducedMotion:J})&&a.jsx(DC,{anchor:K}),a.jsx("h4",{children:BC(Je)}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:Je.email}),Je.added?Dt?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already in the rotation, so its stored login was replaced with this one."]}),Dt?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:Dt}):null,a.jsx("button",{type:"button",ref:V,className:"btn primary",onClick:Se,children:"Done"})]}):St==="progress"?a.jsx(mee,{rows:ys,phase:rt,detail:rt==="failed"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"aa-note aa-reason",children:ws}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:X,className:"btn primary",onClick:Le,children:Lt==="link"?"Try again":"Start over"})})]}):it==="approve"&&i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"aa-note",children:["Approve the sign-in in the tab that opened",n?a.jsxs(a.Fragment,{children:[", with ",a.jsx("strong",{children:n})," filled in"]}):null,". This moves on by itself."]}),a.jsxs("a",{ref:Z,className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:[a.jsx("span",{children:"Open it in this browser"}),a.jsxs("span",{className:"aa-link-host",children:[Uee(i.url),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3 7 7 3M3.6 3H7v3.4"})})]})]}),Yn?a.jsx("p",{className:"aa-note aa-arrive",children:Yn}):null,a.jsxs("details",{className:"aa-code",open:le,onToggle:Ne=>de(Ne.currentTarget.open),children:[a.jsxs("summary",{children:[a.jsx("svg",{className:"aa-code-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:"M3.6 2.2 6.4 5 3.6 7.8"})}),"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:A,type:"text",value:d,onChange:Ne=>h(Ne.target.value),onKeyDown:Ne=>{Ne.key==="Enter"&&d.trim()&&!E&&Ze()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...Ps(E,!d.trim()||i.state==="registering"),onClick:Ze,children:"Continue"})]}),(k||i.error)&&a.jsx("p",{className:"aa-err",children:k??i.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."})]})]}):it?a.jsx("p",{className:"aa-note",children:bee(it,i==null?void 0:i.step)}):null,actions:it==="link"||it==="approve"?a.jsx("button",{type:"button",className:"btn",onClick:qe,children:"Cancel"}):null}):a.jsxs("div",{className:"aa-step aa-primer",children:[ae?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:ae}):null,a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:P,className:"btn primary",...Ps(E),onClick:Pe,children:"Open the sign-in page"})})]}):C?(()=>{const Ne=C.filter(We=>We.state==="imported").length,Te=C.some(We=>uf(We.check));return a.jsxs("div",{className:"aa-done",children:[!Te&&a.jsx(hf,{ref:K}),Ne>0&&!Te&&a.jsx(DC,{anchor:K}),a.jsx("h4",{children:qC(C)}),C.length>0&&a.jsx("ul",{className:"aa-results",children:C.map(We=>{const pt=y0(We),at=uf(We.check);return a.jsxs("li",{className:`aa-result ${We.state}`,children:[a.jsx("span",{className:"aa-result-who",children:We.email||(We.num?`slot ${We.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:qee(We.state)}),We.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":R===pt,title:`Overwrite the stored login for ${We.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ut(We),children:R===pt?"updating…":"update anyway"}),at&&a.jsx("span",{className:"aa-result-err",children:at.long}),(L==null?void 0:L.key)===pt&&a.jsx("span",{className:"aa-result-err",children:L.text})]},pt)})}),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:Se,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{O.current="",U(null),I(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:D,type:"text",value:f,onChange:Ne=>p(Ne.target.value),onKeyDown:Ne=>{Ne.key==="Enter"&&f.trim()&&!E&&ft()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Ps(E,!f.trim()),onClick:ft,children:j?"importing…":"Import"})]}),N&&a.jsx("p",{className:"aa-err",children:N}),j?a.jsxs("p",{className:"aa-live-line",children:[a.jsxs("svg",{className:"aa-spin",viewBox:"0 0 16 16","aria-hidden":!0,children:[a.jsx("circle",{className:"aa-spin-track",cx:"8",cy:"8",r:"6"}),a.jsx("circle",{className:"aa-spin-arc",cx:"8",cy:"8",r:"6"})]}),a.jsx("span",{children:Xn??"claude-swap is adding the accounts in this share. Any already here are left as they are."})]}):null,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."]})]}),a.jsx("p",{className:"vis-hidden",role:"status","aria-live":"polite",children:wn})]})]})}),document.body)}function Wee(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((r,o)=>r-o).map(r=>{const o=r===t?"here":n.has(r)?"swap":"free";return{slot:r,kind:o,label:o==="here"?`slot ${r}`:`slot ${r} · ${o}`}})}function Hee(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const r=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:r&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:r?{at:s,displaced:t}:null}}const zee=64;function Vee(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function Gee(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function Kee(e,t,n){var r;const s=((r=e.find(o=>o.slot===t))==null?void 0:r.kind)??"here";return s==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:s==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function Yee(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:e==="weekly"?"Move to the account whose weekly limit resets soonest, within 4 days.":"Move to the account with the most room left."}}function Xee(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 Zee({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:r,busy:o,pressProps:i,rotating:c,onProjects:d,onRotation:h,home:f,canSetHome:p,onHome:m}){const{menu:w,menuError:j,aliasDraft:b,confirmRemove:k,share:v,shareCopied:N,slotDraft:S,dropMenu:E,closeMenu:C,startRename:I,typeAlias:R,doAlias:$,startMove:L,pickSlot:U,doSlot:O,makeShare:M,copyShare:q,pressRemove:A}=r;if(!w)return null;const D=`ap-pop-title-${e.num}`,P=j&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:j.raw||void 0,children:j.text});return a.jsxs(Qf,{anchorId:`ap-more-${e.num}`,boundaryId:s,id:`ap-menu-${e.num}`,className:"ap-pop",role:w.view==="menu"?"menu":"dialog",labelledBy:w.view==="menu"?`ap-more-${e.num}`:D,start:w.start,onClose:E,children:[w.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>I(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>L(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`share-${e.num}`),title:`Copy this account to another ${Ct}. 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:()=>M(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(c&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`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"}),(f||p&&e.email)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`home-${e.num}`),title:f?"Auto-switch stops coming back to this account":"Auto-switch takes you here, and comes back after this account's 5-hour window resets",onClick:()=>m(),children:f?"Remove home":"Set as home"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${k===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":k===e.num?"Confirm remove":void 0,title:k===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>A(e.num),children:o===`rm-${e.num}`?"Removing…":k===e.num?"Confirm":"Remove"}),P]}),w.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:K=>{K.preventDefault(),$(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:D,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:b,onChange:K=>R(K.target.value),maxLength:zee,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:K=>K.currentTarget.select()}),P,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>C(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...i(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),w.view==="move"&&(()=>{const K=Wee(t,e.num),G=Gee(K,S,e.num),W=Kee(K,G,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:D,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(G),...i(`move-${e.num}`),onChange:H=>U(Number(H.target.value)),autoFocus:!0,children:K.map(H=>a.jsx("option",{value:H.slot,children:H.label},H.slot))})}),P,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>C(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:W.title,onClick:()=>O(e.num,G,W),children:o===`move-${e.num}`?"…":Tc(W.label)})]})]})})(),w.view==="share"&&(v==null?void 0:v.num)===e.num&&(()=>{const K=GP(v.expiresAt,n),G=K.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:D,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:v.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 ${K.tone}`,children:K.text})]}),P,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>C(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(G){await M(e.num);return}await q(v.blob)},children:G?"Make a new share":N?"Copied":"Copy"})]})]})})()]})}const Jee=6;function Qee(e,t){const n=e.filter(c=>c.ready);if(t.armed&&e.length>0&&n.length===0)return{text:"Auto-switch has nowhere to go",tone:"bad",free:null};const s=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`,r=n.length?"ok":"idle",o=t.strained&&!t.armed?ete(n):null,i=[s];return o!=null&&i.push(`${o}% free`),i.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:i.join(" · "),tone:r,free:o}}function ete(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function tte(e){const t=[...e].sort((r,o)=>{if(r.ready!==o.ready)return r.ready?-1:1;if(!r.ready)return r.name.localeCompare(o.name);const i=r.headroom,c=o.headroom;return i==null&&c==null?r.name.localeCompare(o.name):i==null?1:c==null?-1:c-i}),n=t.slice(0,Jee),s=t.length-n.length;return{title:e.some(r=>r.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:s>0?`and ${s} more`:null}}const YP=160,XP=140;function nte(){const[e,t]=y.useState(!1),n=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:c=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),c)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),XP)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function ste(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function As(e,t){return{text:e,giveBack:ste(t),done:!1}}async function rte(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const ate={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 ote(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?ate[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 w0=5e3,ZP=6e4;function zt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?cte(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 ite={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."},lte=new Set(["EACCES","EPERM"]);function cte(e,t){const n=ite[e];if(!n)return;const s=e==="prefs_unreadable"&&t?ute(t):void 0,r=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+r}function ute({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&&!lte.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 Di(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function dte(e,t){const[n,s]=y.useState(null),[r,o]=y.useState([]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(O=>Xf(f.current)?(f.current=O,c(O),!0):!1,[]),m=y.useCallback(()=>{f.current=null,k.current&&c(null)},[]),w=O=>{const M=Fa(i,O);return{disabled:M.disabled,"aria-busy":M.busy}},[j,b]=y.useState(()=>Date.now()),k=y.useRef(!0),v=y.useRef(w0),N=y.useCallback(async()=>{var O,M;try{const[q,A]=await Promise.all([fetch("/api/lan").then(D=>D.json()),fetch("/api/prefs").then(D=>D.json())]);if(!k.current)return;q!=null&&q.ok&&s(q),A!=null&&A.ok&&o(Array.isArray((M=(O=A.prefs)==null?void 0:O.lan)==null?void 0:M.manual)?A.prefs.lan.manual:[]),v.current=(q==null?void 0:q.enabled)===!0?w0:ZP}catch{}},[]);y.useEffect(()=>{k.current=!0;let O=0;const M=async()=>{b(Date.now()),await N(),k.current&&(O=window.setTimeout(M,v.current))};return M(),()=>{k.current=!1,window.clearTimeout(O)}},[N]);const S=y.useCallback(async()=>{const O=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const M=await Di("/api/prefs",{lan:{enabled:!O}});if(!k.current)return;M!=null&&M.ok?(h(null),O||t()):h(As(zt(O?"turn this off":"turn this on",M),M)),await N()}catch{k.current&&h(As(zt(O?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,N,p,m,t]),E=y.useCallback(async(O,M,q)=>{if(!p(`${O}:${M}`))return null;let A=null;try{const D=await Di("/api/lan/peer",{action:O,fp:M});if(!k.current)return null;D!=null&&D.ok?(s(D),h(null)):(A=zt(q,D),h(As(A,D))),await N()}catch{A=zt(q,null),k.current&&h(As(A))}finally{m()}return A},[N,p,m]),C=y.useCallback(async O=>{if(!p(`drop:${O}`))return null;let M=null;try{const q=await Di("/api/prefs",{lan:{manual:r.filter(A=>A!==O)}});if(!k.current)return null;q!=null&&q.ok?(h(null),e()):(M=zt("stop dialling that address",q),h(As(M,q))),await N()}catch{M=zt("stop dialling that address",null),k.current&&h(As(M))}finally{m()}return M},[r,N,e,p,m]),I=y.useCallback(async(O,M)=>{if(!p(`alias:${O}`))return"Something else is still being saved. Try again in a moment.";try{const q=await Di("/api/lan/peer",{action:"alias",fp:O,name:M});return k.current?q!=null&&q.ok?(s(q),null):zt("rename that deck",q):null}catch{return zt("rename that deck",null)}finally{m()}},[p,m]),R=y.useCallback(async O=>{if(!p(`check:${O}`))return null;try{const M=await Di("/api/lan/sync",{fp:O});return k.current?M!=null&&M.ok?(s(M),e(),null):(M==null?void 0:M.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.":zt("check that deck",M):null}catch{return zt("check that deck",null)}finally{m()}},[p,m,e]),$=y.useCallback(async()=>{if(p("check"))try{const O=await Di("/api/lan/sync",{});if(!k.current)return;O!=null&&O.ok?(s(O),h(null)):h(As(zt("check the other decks",O),O)),e()}catch{k.current&&h(As(zt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:r,now:j,busy:i,failure:d,dismissFailure:()=>h(null),answerGiveBack:O=>{h(O),O.done&&(N(),e())},pressProps:w,load:N,toggle:S,answer:E,dropAddress:C,rename:I,checkOne:R,checkNow:$}}function hte(e){const[t,n]=y.useState(null),s=y.useRef(0);return y.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const i=Date.now(),c=fl({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:hl});if(c==="arm"){n(o.fp),s.current=i;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function JP({title:e,steps:t,finish:n,aside:s,onClose:r}){const o=y.useRef(null),i=ct(r,{focusRef:o}),c=xt(r),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],m=b=>h(Math.max(0,Math.min(t.length-1,b)));y.useEffect(()=>{var b,k;Kn(((b=document.activeElement)==null?void 0:b.tagName)??null)&&((k=o.current)==null||k.focus())},[d]);const w=b=>{b.key!=="ArrowRight"&&b.key!=="ArrowLeft"||(b.preventDefault(),b.stopPropagation(),m(b.key==="ArrowRight"?d+1:d-1))},j=()=>{if(!f){m(d+1);return}n?n.act():r()};return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:i,className:"modal guide",onClick:b=>b.stopPropagation(),onKeyDown:w,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:p.art},d),a.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),a.jsx("p",{className:"guide-tip",children:p.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((b,k)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${k+1} of ${t.length}`,"aria-current":k===d?"step":void 0,onClick:()=>m(k)},k))}),f&&s&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),d>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>m(d-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:j,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const x0={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function ps({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function fs({x:e,y:t=34,w:n=176,h:s=132,label:r}){return a.jsxs(a.Fragment,{children:[r&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:r}),a.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function Ds({x:e,y:t,email:n,state:s,tone:r,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:x0[r]}),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 ${x0[r]}`,children:s}),o==null?void 0:o.map((i,c)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96*i/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[i,"%"]})]},c))]})}function QP({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 ch({x:e,y:t,name:n,here:s=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:s?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:s?"ga-t":"ga-s",children:n})]})}function HC({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 zC({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function Q1({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 ej(){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 Gi({x:e,y:t,w:n,title:s,sub:r,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:x0[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:r})]})}function tl({x:e,y:t,label:n,live:s}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function ff({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(QP,{x:e+118,y:t-13,on:!0})]})}function fte(){return a.jsxs(ps,{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 pte(){return a.jsxs(ps,{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(Gi,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Gi,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Gi,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Gi,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(tl,{x:326,y:28,label:"Read"}),a.jsx(tl,{x:380,y:28,label:"Grep",live:!0}),a.jsx(tl,{x:326,y:90,label:"Bash",live:!0})]})}function VC({x:e,y:t,label:n,pct:s,note:r}){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:[s,"%"]}),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*s/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:r})]})}function mte(){return a.jsxs(ps,{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(VC,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(VC,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function gte(){return a.jsxs(ps,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Gi,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(Q1,{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(fs,{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(tl,{x:214,y:122,label:"Read"}),a.jsx(tl,{x:266,y:122,label:"Edit"}),a.jsx(tl,{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 yte(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(ps,{children:[a.jsx(fs,{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 wte(){return a.jsxs(ps,{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(Gi,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function xte(){return a.jsxs(ps,{children:[a.jsx(fs,{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(zC,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(zC,{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(Ds,{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(Ds,{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(Q1,{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(fs,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Ds,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function vte(){return a.jsxs(ps,{children:[a.jsx(fs,{x:14,label:"THIS MACHINE"}),a.jsx(ff,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(Ds,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(Ds,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(fs,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ff,{x:264,y:60}),a.jsx(Ds,{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(ej,{})})]})}const bte=[{art:a.jsx(fte,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. Both behind the topbar gear."},{art:a.jsx(pte,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(gte,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(mte,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(yte,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(xte,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(vte,{}),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(wte,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function kte(){return a.jsxs(ps,{children:[a.jsx(fs,{x:14,label:"THIS MACHINE"}),a.jsx(Ds,{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(fs,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Ds,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function jte(){return a.jsxs(ps,{children:[a.jsx(fs,{x:14,label:"THIS MACHINE"}),a.jsx(ff,{x:28,y:60}),a.jsx(ch,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(ch,{x:28,y:114,name:"Dorin's PC"}),a.jsx(fs,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ff,{x:264,y:60}),a.jsx(ch,{x:264,y:92,name:"Your MacBook"}),a.jsx(ch,{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 Nte(){return a.jsxs(ps,{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(HC,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(HC,{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(QP,{x:304,y:157,on:!0}),a.jsx(Q1,{x:115,y:97})]})}function Ste(){return a.jsxs(ps,{children:[a.jsx(fs,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(Ds,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(Ds,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(fs,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Ds,{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(ej,{})})]})}const _te=[{art:a.jsx(kte,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(jte,{}),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(Nte,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(Ste,{}),line:"An expired login is copied from a paired machine within a minute."}];function Ete(){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(ej,{})})]})}const Cte={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."},Tte=1600;function e4({reach:e,where:t}){const[n,s]=y.useState(!1),r=y.useRef(!0);y.useEffect(()=>()=>{r.current=!1},[]);const o=(e==null?void 0:e.steps)??[],i=y.useCallback(async()=>{await Ko(o.join(`
95
- `))&&r.current&&(s(!0),window.setTimeout(()=>{r.current&&s(!1)},Tte))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:Cte[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[d?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
96
- `)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void i(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function Rte(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const s=t.slice(0,n).trim(),r=Number(t.slice(n+1).trim());return!s||!Number.isInteger(r)||r<1||r>65535||s.includes(":")&&!(s.startsWith("[")&&s.endsWith("]"))?null:{addr:s,port:r}}function Ate(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 Bg(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const Mte={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."},$te={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function GC(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||zt(n,t)}function Ite({status:e,manual:t,startWith:n,onClose:s,onChanged:r}){const o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ct(s,{focusRef:h?i:o}),p=xt(s),[m,w]=y.useState(""),[j,b]=y.useState(""),[k,v]=y.useState(null),[N,S]=y.useState(null),[E,C]=y.useState(null),[I,R]=y.useState(null),[$,L]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const U=y.useRef(!0);y.useEffect(()=>()=>{U.current=!1},[]);const O=y.useRef(null),M=y.useRef(null),q=y.useCallback(Y=>Xf(O.current)?(O.current=Y,C(Y),!0):!1,[]),A=y.useCallback(()=>{O.current=null,U.current&&C(null)},[]),D=Y=>{const J=Fa(E,Y);return{disabled:J.disabled,"aria-busy":J.busy}},P=Y=>(k==null?void 0:k.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>v(J=>J&&J.field===Y?null:J),G=y.useCallback(async()=>{if(h)return;const Y=Rte(m);if(!Y){v({text:Lte(m),field:"addr"});return}const J=`${Y.addr}:${Y.port}`,ee=e.peers.find(ne=>ne.addr===Y.addr&&ne.port===Y.port&&ne.paired);if(ee){v({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(J)){v({text:"This deck already calls that address.",field:"addr"});return}if(q("add"))try{const ne=await Bg("/api/prefs",{lan:{manual:[...t,J]}});if(!U.current)return;ne!=null&&ne.ok?(v(null),w(""),r(),s()):v({text:zt("add that address",ne),field:"addr"})}catch{U.current&&v({text:zt("add that address",null),field:"addr"})}finally{A()}},[m,h,t,e.peers,r,s,q,A]),W=y.useCallback(async Y=>{if(!q(`invite:${Y}`))return;const J=Y==="make"?"make an invite":"cancel that invite";try{const ee=await Bg("/api/lan/invite",{action:Y});if(!U.current)return;ee!=null&&ee.ok?(M.current=Y,v(null),S(null),r()):v({text:GC($te,ee,J)})}catch{U.current&&v({text:zt(J,null)})}finally{A()}},[r,q,A]),H=y.useCallback(async()=>{const Y=j.trim();if(!(!Y||!q("join"))){R(null);try{const J=await Bg("/api/lan/invite",{action:"join",token:Y});if(!U.current)return;J!=null&&J.ok?(b(""),v(null),r(),s()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(R(J.tried),v(null)):(R(null),v({text:GC(Mte,J,"use that invite"),field:"join"}))}catch{U.current&&v({text:zt("use that invite",null),field:"join"})}finally{A()}}},[j,r,s,q,A]),F=y.useCallback(async(Y,J)=>{try{await navigator.clipboard.writeText(Y),S(J),window.setTimeout(()=>{U.current&&S(ee=>ee===J?null:ee)},1600)}catch{v({text:"Could not copy it — select the text and copy it by hand."})}},[]),B=e.invite&&e.invite.expiresAt>$?e.invite:null,Z=y.useRef(!1);y.useEffect(()=>{n!=="invite"||Z.current||B||(Z.current=!0,W("make"))},[n,B,W]);const V=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||V.current||!B||(V.current=!0,(Y=c.current)==null||Y.focus())},[n,B]),y.useEffect(()=>{var J,ee;const Y=M.current;!Y||Y==="make"!=!!B||(M.current=null,Kn(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[B]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[k&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:k.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>v(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(e4,{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:m,placeholder:"192.168.1.5:54340",spellCheck:!1,...P("addr"),onChange:Y=>{w(Y.target.value),K("addr")},onKeyDown:Y=>{Y.key==="Enter"&&G()}}),m.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...D("add"),onClick:()=>void G(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,J)=>a.jsxs("span",{children:[J>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...D("copy:mine"),onClick:()=>void F(X.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",!B&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...D("invite:make"),onClick:()=>void W("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:i,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:j,placeholder:"paste one you were sent",spellCheck:!1,...P("join"),onChange:Y=>{b(Y.target.value),R(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&H()}}),j.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...D("join"),onClick:()=>void H(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),I&&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."}),I.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),B&&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:[Ate(B.expiresAt,$)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:B.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...D("copy:invite"),"aria-label":N==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void F(B.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",...D("invite:withdraw"),onClick:()=>void W("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 Lte(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 Ote({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(s=>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:s.name})," at ",a.jsx("code",{className:"ap-lan-code",children:s.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${s.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:s.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${s.fp}`),"aria-label":`Accept ${s.name}`,"aria-describedby":`lan-ask-fp-${s.fp}`,onClick:()=>void n("accept",s.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${s.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:${s.fp}`),"aria-label":`Decline ${s.name}`,"aria-describedby":`lan-ask-fp-${s.fp}`,onClick:()=>void n("dismiss",s.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},s.fp))})}function Pte({rows:e,pairingMode:t,armed:n,pressProps:s,answer:r,dropAddress:o,onUnpair:i,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`accept:${h.fp}`),onClick:()=>void r("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":""}`,...s(`unpair:${h.fp}`),onClick:()=>i(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",...s(`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",...s(`allow:${h.fp}`),onClick:()=>void r("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 Dte(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 Fte({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(e4,{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:Dte(t)})]})}const KC=["online","offline","loose"],Bte={online:0,offline:1,loose:2};function qte(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const Ute=76,Wte=62,pf=96,Hte={1:[.62],2:[.58,1],3:[.42,.72,1]},zte=.2,Vte=.16,Gte=.05,Kte=20,Yte=17,uh=7,Xte=30,Zte=116,Jte=6.6,Qte=6,ene=e=>tj(e,null),tne=1.5,nne=80,sne=.45,YC=40,rne=64,ane=150,XC=.3,ZC=84,JC=8,one=1.3,mf=6,ine=5.94,QC=7,eT=16,kc=4,tT=.16;function v0(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function t4(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function lne(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function cne(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>KC.indexOf(t.tier)-KC.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 nT(e,t){let n=2166136261^t;for(let s=0;s<e.length;s++)n^=e.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function une(e,t,n){const s=[...Hte[e.length]??[]];for(let r=0;r<s.length;r++){const o=e[r];if(o<2)continue;const i=v0(t*s[r],n*s[r])/o;if(!(i>0)||i>=pf)continue;const c=r+1<s.length?s[r+1]-zte:1;s[r]=Math.max(s[r],Math.min(c,s[r]*(pf/i)*1.02))}return s}const jo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,qg={h:16,ch:6.1,maxW:100};function dne(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 n4(e,t,n,s,r,o){const i=t==="loose"?Yte:Kte,c=!r||e.kind==="asks",d=c?Xte:qg.h,h=r?qg.ch:Jte,f=c?o.length:0,p=Math.min(r?qg.maxW:Zte,Math.max(2*i,r4(e).length*h,f*Qte)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=t4(n,s)==="top"?{x0:n-p/2,y0:s-i-uh-d,x1:n+p/2,y1:s-i-uh}:{x0:n-p/2,y0:s+i+uh,x1:n+p/2,y1:s+i+uh+d};return[m,w]}const b0=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]},dh=(e,t)=>((e-t)%360+540)%360-180;function sT(e,t,n){const s=new Map;for(const f of e)s.has(f.ring)||s.set(f.ring,[]),s.get(f.ring).push(f);const r=()=>e.map(f=>{const[p,m]=b0(f);return n4(f.row,f.tier,p,m,t,f.caption)}),o=(f,p,m=!1)=>{if(f.count<=2&&!m)return!1;const w=f.theta+p*tne,j=s.get(f.ring),b=(f.count>2?360/f.count:f.turn)*sne,k=j[(f.index+1)%f.count],v=j[(f.index-1+f.count)%f.count];return!(k===f||(p>0?dh(k.theta,w)>=b:dh(w,v.theta)>=b))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>jo(p,m)||jo(w,f)||jo(p,w)||jo(f,m),c=([f,p])=>jo(f,n)||jo(p,n);for(let f=0;f<nne;f++){const p=r();let m=!1;for(let w=0;w<e.length;w++){c(p[w])&&(m=o(e[w],dh(e[w].theta,90)>=0?1:-1,!0)||m);for(let j=w+1;j<e.length;j++){if(!i(p[w],p[j]))continue;const b=e[w],k=e[j],v=k.ring.ring>b.ring.ring||k.ring===b.ring&&j>w?k:b,N=v===k?b:k,S=dh(v.theta,N.theta)>=0?1:-1;m=o(v,S)||o(N,-S)||m}}if(!m)break}const d=r();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)i(d[f],d[p])&&h++}return h}const hne={online:0,offline:1,loose:1};function fne(e,t,n,s="",r=ene){const o=[];for(const i of[!0,!1]){const c=rT(e,t,n,s,Bte,r,i);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=rT(e,t,n,s,hne,r,i),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((i,c)=>c.clashes<i.clashes?c:i).named()}function rT(e,t,n,s,r,o,i=!0){const c=new Map;for(const q of e){const A=qte(q);if(!A)continue;const D=r[A];c.has(D)||c.set(D,[]),c.get(D).push({row:q,tier:A})}const d=[...c.keys()].sort((q,A)=>q-A),h=Math.max(0,t/2-Ute),f=Math.max(0,n/2-Wte),p=une(d.map(q=>c.get(q).length),h,f),m=d.map((q,A)=>({ring:q,rx:h*p[A],ry:f*p[A],count:c.get(q).length})),w=m.reduce((q,A)=>q+A.count,0),j=q=>q.row.via==="tailscale",b=[...c.values()].flat().filter(j).length,k=Math.max(0,...m.map(q=>{const A=c.get(q.ring).filter(j).length,D=v0(q.rx,q.ry);return A>0&&D>0?A*pf*one/D*360:0})),v=i&&b>0&&b<w?Math.min(ane,Math.max(rne,b/w*360,k)):0,N=YC-v/2,S=YC+v/2,E=[];let C=!1;m.forEach((q,A)=>{const D=cne(c.get(q.ring)),P=D.length,K=P>1&&v0(q.rx,q.ry)/P<pf;K&&(C=!0);const G=A===m.length-1,W=G?-tT*(p[A]-(p[A-1]??0)):tT*(p[A+1]-p[A]),H=v>0?[{members:D.filter(B=>B.row.via!=="tailscale"),from:S,width:360-v},{members:D.filter(B=>B.row.via==="tailscale"),from:N+360,width:v}]:[{members:D,from:null,width:360}];let F=0;for(const B of H){const Z=B.members.length;if(Z===0)continue;const V=B.width/Z,X=Z>2;B.members.forEach(({row:Y,tier:J},ee)=>{const ne=Rs(Y),le=B.from==null?lne(Z,A)+V*ee:B.from+V*(ee+.5),de=X?nT(ne,1)*Vte*V:0,ue=K&&F%2===1?1+W/p[A]:1,re=X?nT(ne,2)*Gte:0,pe=V*.3;E.push({row:Y,tier:J,ring:q,index:F,count:P,theta:le+de,reach:ue*(1+(G?-Math.abs(re):re)),lo:B.from==null?-1/0:B.from+pe,hi:B.from==null?1/0:B.from+B.width-pe,turn:V,caption:o(Y)}),F++})}});const I=dne(s);let R=sT(E,C,I);R>0&&!C&&(C=!0,R=sT(E,!0,I));const $=E.map((q,A)=>{const[D,P]=b0(q);return{row:q.row,tier:q.tier,ring:q.ring.ring,x:D,y:P,angle:pne(Math.atan2(P,D)*180/Math.PI),dist:Math.hypot(D,P),side:t4(D,P),order:A}}),L=m.reduce((q,A,D)=>c.get(A.ring).some(j)?Math.max(q,p[D]):q,0),U=q=>({from:N,to:S,inner:{rx:h*XC,ry:f*XC},outer:{rx:Math.min(t/2-8,h*L+q),ry:Math.min(n/2-8,f*L+q)},count:b}),O={nodes:$,rings:m,dense:C,zone:v>0?{...U(ZC),labelAt:null}:null};return{layout:O,clashes:R,named:()=>{if(!O.zone)return O;const q=E.flatMap(P=>{const[K,G]=b0(P);return n4(P.row,P.tier,K,G,C,P.caption)});let A={...O.zone,labelAt:aT(O.zone,q)},D=A.outer;for(let P=ZC+JC;A.labelAt==null;P+=JC){const K=U(P);if(K.outer.rx===D.rx&&K.outer.ry===D.ry)break;D=K.outer;const G=aT(K,q);G!=null&&(A={...K,labelAt:G})}return{...O,zone:A}}}}function s4(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function aT(e,t){const n={rx:e.outer.rx-mf,ry:e.outer.ry-mf};if(!(n.rx>0&&n.ry>0))return null;const s=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),r=[];for(let N=e.to;N>=e.from;N-=s){const S=N*Math.PI/180;r.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=QC+kc,i={x0:Math.min(...r.map(N=>N[0]))-o,x1:Math.max(...r.map(N=>N[0]))+o,y0:Math.min(...r.map(N=>N[1]))-o,y1:Math.max(...r.map(N=>N[1]))+o},c=t.map(N=>({x0:N.x0-kc,y0:N.y0-kc,x1:N.x1+kc,y1:N.y1+kc})).filter(N=>jo(N,i)),d=(N,S)=>c.some(E=>N>E.x0&&N<E.x1&&S>E.y0&&S<E.y1),h=[],f=[];let p=0;r.forEach(([N,S],E)=>{E>0&&(p+=Math.hypot(N-r[E-1][0],S-r[E-1][1]));const C=Math.hypot(N,S)||1;let I=!1;for(let R=0;R<=QC&&!I;R+=1.75)I=d(N-N/C*R,S-S/C*R);h.push(p),f.push((f.at(-1)??0)+(I?1:0))});const m=s4(e.count).length*ine/2,w=m+eT,j=p-m-eT;if(!(p>0)||j<w)return null;const b=N=>{let S=0,E=h.length;for(;S<E;){const C=S+E>>1;h[C]<N?S=C+1:E=C}return S},k=N=>{const S=b(N-m),E=b(N+m+1e-9)-1;return E<S||f[E]-(S>0?f[S-1]:0)===0},v=p/2;for(let N=0;v-N>=w;N+=2)for(const S of N===0?[v]:[v-N,v+N])if(k(S))return S/p;return null}function pne(e){return(e%360+360)%360}function mne(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 gne(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 tj(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return a4(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?yne(t):"online";const n=i4(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function r4(e){return a4(e)?e.addr:e.name}function a4(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function o4(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=i4(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 i4(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function yne(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function wne(e){var s;if(!e)return[];const t=(e.addrs??[]).map(r=>`${r}:${e.port}`),n=(s=e.tailscale)==null?void 0:s.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function Rs(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function xne(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function vne(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${l4}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const l4="This deck pairs by invite only. Send one from Add a deck.";function bne(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"?l4:"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 kne(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,s)=>({l:n,i:s})).sort((n,s)=>t[n.l.tone]-t[s.l.tone]||n.i-s.i).map(({l:n})=>n)}function jne(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),s=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!s)return null;for(let r=1;r<=3;r++){const o=Number(n[r])-Number(s[r]);if(o)return Math.sign(o)}return 0}function Nne(e,t){const n=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:n,note:null,tone:"idle"};if(!e.alive){const s=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:n,note:s,tone:s?"bad":"idle"}}return t?t.alive?{there:"works there",here:n,note:null,tone:t.shareable===!1?"idle":"ok"}:{there:"works there",here:n,note:"repairs next round",tone:"wait"}:{there:"works there",here:n,note:"arrives next round",tone:"wait"}}function Sne(e,t,n,s=null){var d;const r=new Map;for(const h of t)(d=r.get(h.key))!=null&&d.alive||r.set(h.key,h);const o=new Set(n),i=[],c=new Set;for(const h of e??[]){if(c.has(h.key))continue;c.add(h.key);const f=r.get(h.key)??null,p=o.has(h.key),m=Nne(h,f),w=f?f.alive?f.shareable===!1?"unavailable":"works":"expired":"missing",j=!h.alive&&f&&!f.alive?m.note:[w==="works"?null:m.here,h.alive&&h.shareable!==!1?null:m.there,m.note].filter(Boolean).join(" · ")||null;i.push({key:h.key,email:h.email,here:w,there:h.alive?h.shareable===!1?"unavailable":"works":"broken",in:!h.alive||h.shareable===!1?"cut":m.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:j,tone:m.tone,usedThere:s===h.key})}for(const h of n){const f=r.get(h);!f||c.has(h)||(c.add(h),i.push({key:h,email:f.email,here:f.alive?f.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return i}const _ne=1e3;function Ene(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=fr(e,t);return`${n} · ${s==="now"?"just now":s}`}function k0(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const c4={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},u4={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function d4(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${c4[e.here]}, ${u4[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function h4({row:e,source:t,status:n,accounts:s,now:r}){var J,ee,ne,le,de;const{peer:o,stranger:i}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":i?i.port?`${i.addr}:${i.port}`:i.addr:e.addr,m=(o==null?void 0:o.about)??null,w=((J=n.about)==null?void 0:J.version)??null,j=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",b=k0(n.about),k=k0(m),v=m!=null&&m.version&&w?jne(m.version,w):null,N=o?np(o.last,r):null,S=o&&((ee=o.last)!=null&&ee.error)?aQ({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ue=>!ue.manual&&ue.addr).map(ue=>({fp:ue.fp,name:ue.name,addr:ue.addr,port:ue.port,at:ue.lastSeen??0}))],r):null,E=(ne=o==null?void 0:o.last)!=null&&ne.error&&N&&N.text!==o.last.error?o.last.error:null,C=((le=o==null?void 0:o.last)==null?void 0:le.done)??[],I=!!N&&!!E&&!e.quiet&&e.state.startsWith(N.text),R=c||e.kind==="dialling",$=((o==null?void 0:o.via)??e.via)==="tailscale",L=o?o.waiting?null:o.manual?$?"added by its Tailscale address":"added by address":$?"over Tailscale":"on this network":e.kind==="nearby"?$?"heard over Tailscale":"heard on this network":$?"asked this deck to pair, over Tailscale":"asked this deck to pair",U=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",O=(o==null?void 0:o.offers)??null,M=U==="up"?(O==null?void 0:O.current)??null:null,q=M&&"key"in M?M.key:null,A=!!M&&"hidden"in M,D=!!M&&"other"in M,P=(n.shared??[]).filter(ue=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(ue))}),K=c?Sne((O==null?void 0:O.accounts)??null,s,P,q):[],G=K.filter(ue=>ue.in==null&&ue.out==="cut"),W=K.some(ue=>ue.in!=null),H=K.some(ue=>ue.out!=null),F=new Set((n.peers??[]).filter(ue=>ue.paired).flatMap(ue=>ue.notOffered??[])),B=K.some(ue=>ue.out!=null&&F.has(ue.key))?"decks you chose":"every paired deck",Z=new Map(C.map(ue=>[ue.email,ue])),V=C.filter(ue=>!K.some(re=>re.email===ue.email)),X=c?O?O.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(de=o==null?void 0:o.last)!=null&&de.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,Y=O&&(o!=null&&o.last)&&o.last.at-O.at>_ne?fr(O.at,r):null;return{peer:o,stranger:i,paired:c,own:d,canRename:h,fp:f,where:p,about:m,unsaid:j,hereRuns:b,thereRuns:k,order:v,line:N,silence:S,raw:E,echoed:I,showRound:R,how:L,link:U,hiddenThere:A,otherThere:D,lanes:K,spent:G,taking:W,giving:H,givenTo:B,told:Z,unplaced:V,unknown:X,stale:Y}}function j0(){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 hh({dir:e}){return a.jsx("svg",{className:"lan-chev","data-dir":e,width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function Cne({view:e,row:t,status:n,asking:s,drawn:r,onSettings:o}){const{peer:i,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:m,order:w,line:j,silence:b,raw:k,echoed:v,showRound:N,how:S,link:E,hiddenThere:C,otherThere:I,lanes:R,spent:$,taking:L,giving:U,givenTo:O,told:M,unplaced:q,unknown:A,stale:D}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":s||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}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[m??(h?"not said":f),w?` · ${w<0?"older":"newer"}`:null]}),C&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),I&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(j0,{}),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(j0,{}),(d&&S||N)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&N&&" · ",N&&(j?v?a.jsx("code",{className:"ap-lan-code",children:k}):a.jsx("span",{className:"lan-round","data-tone":j.tone,children:j.text.replace(/ · now$/," · just now")}):"not asked yet"),N&&k&&!v&&a.jsx("code",{className:"lan-fact-raw",children:k})]}),q.length>0&&a.jsx("ul",{className:"lan-done",children:q.map(P=>{const K=f0(P);return a.jsxs("li",{"data-ok":P.ok&&!K,children:[P.email," ",a.jsxs("span",{className:"lan-done-what",children:[P.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${P.email}:${P.action}`)})}),b&&a.jsx("p",{className:"lan-note lan-link-note",children:b}),(i==null?void 0:i.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(j==null?void 0:j.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:j.hint})]}),R.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:R.map((P,K)=>{const G=M.get(P.email),W=G?f0(G):null,H=P.out==="live"||P.in!=null&&P.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":P.tone,"data-draw":P.in&&P.out?"both":P.in?"in":"out","data-used-there":P.usedThere||void 0,style:{"--i":K},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":P.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":H?"live":"cut","aria-hidden":!0,children:[(P.in==="live"||P.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":P.in}),P.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),P.in&&P.in!=="cut"&&a.jsx(hh,{dir:"in"}),P.out==="live"&&a.jsx(hh,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:P.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":P.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:d4(P)}),(P.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[P.caption,P.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!W,children:[G.ok?"arrived last round":"did not arrive last round",W&&` — ${W.long}`]})]})]},P.key)})},r),c&&a.jsxs(a.Fragment,{children:[$.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",$.length===1?$[0].email:"the expired ones"," until you sign in again here."]}),A&&a.jsx("p",{className:"lan-empty",children:A}),D&&a.jsxs("p",{className:"lan-stale",children:["As of ",D==="now"?"just now":D,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[L&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(hh,{dir:"in"})}),"from ",t.name]}),U?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(hh,{dir:"out"})}),"from this deck, to ",O]}):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 Tne=20,Rne=17,oT=34,Ane=160,Mne=80,$ne=200,Ine=8,Lne=14,One=10,Pne=.61803398875;function Dne({status:e,rows:t,accounts:n,now:s,covered:r,onOpenDeck:o,onClose:i}){const c=y.useRef(null),d=ct(i,{focusRef:c}),h=xt(i),f=y.useRef(null),[p,m]=y.useState(null),[w,j]=y.useState(!1),b=y.useRef(null);y.useLayoutEffect(()=>{const re=f.current;if(!re)return;let pe=null;const ye=()=>{const he=Math.round(re.clientWidth),ae=Math.round(re.clientHeight);pe&&pe.w===he&&pe.h===ae||(pe&&(j(!0),b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>j(!1),$ne)),pe={w:he,h:ae},m(pe))};if(ye(),typeof ResizeObserver>"u")return;const _e=new ResizeObserver(ye);return _e.observe(re),()=>{_e.disconnect(),b.current!=null&&window.clearTimeout(b.current)}},[]);const k=y.useMemo(()=>p?fne(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var pe,ye;return tj(re,(ye=(pe=pu(e,re).peer)==null?void 0:pe.about)==null?void 0:ye.os)}):null,[t,p,e]),v=y.useMemo(()=>mne(t),[t]),N=(k==null?void 0:k.nodes)??[],S=y.useRef(new Map),E=y.useMemo(()=>{const re=new Map;for(const pe of N){const ye=Rs(pe.row);re.set(ye,xne(S.current.get(ye),pe.angle))}return S.current=re,re},[N]),[C,I]=y.useState(null),[R,$]=y.useState(null),[L,U]=y.useState("none"),O=y.useRef(null),M=y.useCallback((re,pe)=>{O.current!==re&&(O.current=re,U(pe),$(re))},[]),q=y.useRef(null),A=y.useRef(null),D=y.useCallback(()=>{A.current!=null&&window.clearTimeout(A.current),A.current=null},[]),P=y.useCallback((re,pe)=>{if(q.current!=null&&window.clearTimeout(q.current),q.current=null,D(),I(re),pe==="keyboard"){M(re,"none");return}A.current=window.setTimeout(()=>M(re,O.current?"swap":"full"),Mne)},[M,D]),K=y.useCallback(()=>{q.current!=null&&window.clearTimeout(q.current),D(),q.current=window.setTimeout(()=>I(null),Ane)},[D]);y.useEffect(()=>()=>{q.current!=null&&window.clearTimeout(q.current),D()},[D]);const G=C&&N.some(re=>Rs(re.row)===C)?C:null,W=R?t.find(re=>Rs(re)===R)??null:null;y.useEffect(()=>{R&&!W&&M(null,"swap")},[R,W,M]);const[H,F]=y.useState(null),B=y.useRef(new Map),Z=N.findIndex(re=>Rs(re.row)===H),V=Z<0?0:Z,X=re=>{var he;if(N.length===0)return;const pe=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,ye=re.key==="Home"?0:re.key==="End"?N.length-1:pe?(V+pe+N.length)%N.length:null;if(ye==null)return;re.preventDefault();const _e=Rs(N[ye].row);F(_e),(he=B.current.get(_e))==null||he.focus()},[Y,J]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const re=()=>J(document.hidden);return document.addEventListener("visibilitychange",re),()=>document.removeEventListener("visibilitychange",re)},[]);const ee=(e==null?void 0:e.enabled)===!0,ne=e?ee?gne(v):"Local network is off":"checking…",le=()=>{D(),M(null,"swap"),I(null)},de=G?N.find(re=>Rs(re.row)===G)??null:null,ue=()=>{var re;R&&((re=B.current.get(R))==null||re.focus()),le()};return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:re=>re.stopPropagation(),"data-paused":r||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":G?"":void 0,"data-focus-via":de==null?void 0:de.row.via,"data-dense":(k==null?void 0:k.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&le()},children:p&&k&&a.jsxs(a.Fragment,{children:[a.jsx(Fne,{layout:k,w:p.w,h:p.h}),N.map(re=>{const pe=Rs(re.row);return a.jsx(Une,{node:re,angle:E.get(pe)??re.angle,lit:G===pe},pe)}),a.jsx(Wne,{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:X,children:N.map((re,pe)=>{var _e,he;const ye=Rs(re.row);return a.jsx(Hne,{node:re,angle:E.get(ye)??re.angle,os:(he=(_e=pu(e,re.row).peer)==null?void 0:_e.about)==null?void 0:he.os,lit:G===ye,shown:R===ye,tabbable:pe===V,register:ae=>{ae?B.current.set(ye,ae):B.current.delete(ye)},onHold:ae=>{F(ye),P(ye,ae)},onRelease:K,onOpen:()=>o(re.row.fp)},ye)})}),N.length===0&&a.jsx(zne,{status:e})]})}),a.jsx(Vne,{slice:(k==null?void 0:k.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:W&&e?a.jsx(Kne,{row:W,status:e,accounts:n,now:s,entrance:L,onOpen:()=>o(W.fp),onBack:ue},Rs(W)):a.jsx(Gne,{status:e,summary:v,entrance:L,slice:(k==null?void 0:k.zone)!=null})})]})]})}),document.body)}function f4(){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 Fne({layout:e,w:t,h:n}){const{zone:s}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[s&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:qne(s,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(s.outer.rx,s.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:Bne(s,t/2,n/2),fill:"url(#nm-zone-fill)"}),s.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(s.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:s4(s.count)})})]}),e.rings.map((r,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":r.ring,"data-folded":e.folded&&r.ring===1||void 0,cx:t/2,cy:n/2,rx:r.rx,ry:r.ry,style:{"--ring":o}},r.ring))]})}function iT(e,t,n,s){const r=s*Math.PI/180;return`${(t+Math.cos(r)*e.rx).toFixed(1)},${(n+Math.sin(r)*e.ry).toFixed(1)}`}function Bne(e,t,n){const s=e.to-e.from>180?1:0,r=(v,N)=>{const S=N*Math.PI/180;return[t+Math.cos(S)*v.rx,n+Math.sin(S)*v.ry]},o=(v,N)=>N/((v.rx+v.ry)/2)*(180/Math.PI),i=(v,N,S)=>{const E=Math.hypot(N[0]-v[0],N[1]-v[1])||1,C=Math.min(.5,S/E);return[v[0]+(N[0]-v[0])*C,v[1]+(N[1]-v[1])*C]},c=([v,N])=>`${v.toFixed(1)},${N.toFixed(1)}`,d=One,h=Lne,f=o(e.inner,d),p=o(e.outer,h),m=r(e.inner,e.from),w=r(e.outer,e.from),j=r(e.outer,e.to),b=r(e.inner,e.to),k=v=>`${v.rx.toFixed(1)},${v.ry.toFixed(1)}`;return[`M${c(r(e.inner,e.from+f))}`,`Q${c(m)} ${c(i(m,w,d))}`,`L${c(i(w,m,h))}`,`Q${c(w)} ${c(r(e.outer,e.from+p))}`,`A${k(e.outer)} 0 ${s} 1 ${c(r(e.outer,e.to-p))}`,`Q${c(j)} ${c(i(j,b,h))}`,`L${c(i(b,j,d))}`,`Q${c(b)} ${c(r(e.inner,e.to-f))}`,`A${k(e.inner)} 0 ${s} 0 ${c(r(e.inner,e.from+f))}`,"Z"].join(" ")}function qne(e,t,n){const s={rx:e.outer.rx-mf,ry:e.outer.ry-mf},r=e.to-e.from>180?1:0;return`M${iT(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${r} 0 ${iT(s,t,n,e.from)}`}function Une({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,r=e.order*Pne%1*Ine;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":`${oT}px`,"--gap":`${oT+(e.tier==="loose"?Rne:Tne)}px`,"--i":e.order,"--phase":`${r.toFixed(2)}s`},children:s&&a.jsx("i",{className:"nm-glint"})})}function Wne({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 Hne({node:e,angle:t,os:n,lit:s,shown:r,tabbable:o,register:i,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${Yne(Rs(f))}`,m=e.angle*Math.PI/180,w=tj(f,n);return a.jsxs("button",{ref:i,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":s||void 0,"data-shown":r||void 0,"aria-label":`${f.name}: ${o4(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(m)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(m)*14).toFixed(1)}px`},onPointerEnter:j=>{j.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:j=>c(j.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(j0,{}),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:r4(f)}),a.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function zne({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 Vne({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function p4({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 Gne({status:e,summary:t,entrance:n,slice:s}){const r=wne(e),o=k0(e==null?void 0:e.about),i=[];o&&i.push({label:"Runs",value:o}),i.push({label:r.length>1?"Addresses":"Address",value:r.length?a.jsx("span",{className:"nm-addrs",children:r.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:r.length===0}),e!=null&&e.pairingMode&&i.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=vne(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",s?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(p4,{facts:i}),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 Kne({row:e,status:t,accounts:n,now:s,entrance:r,onOpen:o,onBack:i}){var k;const c=h4({row:e,source:pu(t,e),status:t,accounts:n,now:s}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=bne(e,t.pairingMode),p=kne(c.lanes),m=p.length,w=p.filter(v=>v.tone==="ok").length,j=m===0?"No shared logins":w===m?`${m} shared login${m===1?", fine":"s, all fine"}`:`${m} shared login${m===1?"":"s"} · ${w} fine`,b=c.unknown&&((k=c.peer)!=null&&k.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":r,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:i,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:o4(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(p4,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:j}),m>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((v,N)=>a.jsxs("li",{className:"nm-lane","data-tone":v.tone,style:{"--k":N},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:v.email}),lT(v)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:lT(v)}),v.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[v.email,": ",d4(v)]})]},v.key))}),b&&a.jsx("p",{className:"nm-panel-hint",children:b})]})]})}function lT(e){return e.caption?e.caption:e.tone==="ok"?null:`${c4[e.here]} · ${u4[e.there]}`}function Yne(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 Xne=6;function Zne({anchorId:e,id:t,rows:n,onHold:s,onLet:r}){const o=y.useRef(null),i=n.filter(m=>m.kind==="paired"),c=i.filter(m=>m.here),d=c.slice(0,Xne),h=i.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const m=o.current,w=document.getElementById(e);if(!m||!w)return;m.style.maxHeight="";const j=B1(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${j.top}px`,m.style.left=`${j.left}px`,m.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,m.dataset.side=j.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),wt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:r,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(m=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{title:m.via==="tailscale"?`${m.name} · Tailscale`:m.name,children:[m.name,m.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${m.kind}:${m.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function Jne({entry:e,rows:t,onOpen:n,onMap:s,peek:r,openPeek:o,shutPeek:i,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":r?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(YP)},onPointerLeave:i,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:i,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"})})]}),s&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),s()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(f4,{})}),r&&a.jsx(Zne,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:i})]})}function Qne({row:e,run:t,onVerb:n,onUnpair:s}){const[r,o]=y.useState(!1),i=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!r)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[r]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:r,armedTwin:c,pressOwn:()=>{const p=Date.now(),m=fl({armedFor:r?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:hl});if(m==="arm"){o(!0),d(null),i.current=p;return}m!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!s)return;const m=Date.now(),w=fl({armedFor:c,target:p,armedAt:i.current,now:m,gapMs:hl});if(w==="arm"){d(p),o(!1),i.current=m;return}w!=="ignore"&&(d(null),t(()=>s(p)))}}}function ese({row:e,paired:t,peer:n,status:s,busy:r,press:o,checkNow:i,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:i,title:"Ask this deck now instead of waiting for the next round",children:r===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:m=>{m.repeat&&m.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:r===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&s.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:r===`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:r===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&s.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:r===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&s.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 tse({instances:e,now:t,busy:n,press:s,armedTwin:r,pressTwin:o,onUnpair:i}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var j,b,k,v;const h=(j=c.peer)!=null&&j.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(b=c.peer)!=null&&b.pairedAt?fr(c.peer.pairedAt,t):null,m=[(v=(k=c.peer)==null?void 0:k.about)!=null&&v.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),w=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:w}),d>0&&i&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${r===w?" armed":""}`,...s(`unpair:${w}`),onKeyDown:N=>{N.repeat&&N.preventDefault()},onClick:()=>o(w),"aria-label":r===w?`Confirm unpairing ${f}`:`Unpair ${f}`,title:r===w?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:n===`unpair:${w}`?"unpairing…":r===w?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${m} · shown above`:m})]},w)})})]})}function nse(){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 sse({row:e,source:t,status:n,accounts:s,now:r,busy:o,onClose:i,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:m=[],onUnpair:w}){const j=y.useRef(null),b=ct(i,{focusRef:j}),k=xt(i),[v,N]=y.useState(null),[S,E]=y.useState(null),[C,I]=y.useState(!1),[R,$]=y.useState(0),L=y.useRef(null),U=y.useRef(null),O=y.useRef(!0);y.useEffect(()=>()=>{O.current=!1},[]);const M=v!=null;y.useEffect(()=>{var re;M&&((re=L.current)==null||re.select())},[M]);const q=y.useRef(!1);y.useEffect(()=>{var re,pe;q.current&&!M&&Kn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((pe=U.current)==null||pe.focus()),q.current=M},[M]);const A=re=>{const pe=Fa(o,re);return{disabled:pe.disabled,"aria-busy":pe.busy}},D=async re=>{const pe=await re();return O.current&&E(pe),pe==null},{armed:P,armedTwin:K,pressOwn:G,pressTwin:W}=Qne({row:e,run:D,onVerb:h,onUnpair:w}),H=h4({row:e,source:t,status:n,accounts:s,now:r}),{peer:F,stranger:B,paired:Z,own:V,canRename:X,fp:Y}=H,J=o===`check:${e.fp}`,ee=async re=>{const pe=re.trim()===V?"":re;await D(()=>c(pe))&&N(null)},ne=()=>void D(d).then(re=>{re&&O.current&&$(pe=>pe+1)}),le=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!O.current)return;I(!0),window.setTimeout(()=>{O.current&&I(!1)},1600)}catch{O.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},de=[];Z&&(F!=null&&F.pairedAt)?de.push({label:"Paired",value:Ene(F.pairedAt,r),tone:"meta"}):e.kind==="declined"&&B&&de.push({label:"Paired",value:`no · you said no ${Y1(B.at,r)}`,tone:"meta"}),de.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void le(),"aria-label":C?"Fingerprint copied":"Copy the fingerprint",children:C?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const ue=m.length?[{row:e,peer:F??null},...m]:[];return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...k,role:"presentation",children:a.jsxs("div",{ref:b,className:"modal lan-peer","data-tone":e.tone,onClick:re=>re.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:[M?a.jsxs("form",{className:"lan-peer-edit",onSubmit:re=>{re.preventDefault(),ee(v??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:L,className:"ap-manage-input lan-peer-input",value:v??"",maxLength:48,placeholder:V,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>N(re.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...A(`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}),X&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:U,onClick:()=>{E(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(nse,{})})]}),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}),M&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...A(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:j,type:"button",className:"glyph-btn",onClick:i,"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:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(Cne,{view:H,row:e,status:n,asking:J,drawn:R,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:de.map(re=>a.jsxs("div",{className:"lan-fact","data-tone":re.tone,children:[a.jsx("dt",{children:re.label}),a.jsx("dd",{children:re.value})]},re.label))}),ue.length>1&&a.jsx(tse,{instances:ue,now:r,busy:o,press:A,armedTwin:K,pressTwin:W,onUnpair:w})]}),a.jsx(ese,{row:e,paired:Z,peer:F,status:n,busy:o,press:A,checkNow:ne,armed:P,pressOwn:G,run:D,onVerb:h,onInvite:p})]})}),document.body)}function Ur(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var s,r;!e||!n.current||(n.current=!1,Kn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(r=t.current)==null||r.focus()))},[e]),()=>{n.current=!0}}function rse(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function ase(e,t,n,s){const r=new Set(e??t);return s?r.add(n):r.delete(n),[...r]}function cT(e,t,n){return e==null||n!=null&&!n.ok||rse(e,t)?null:e}function m4({line:e,onDismiss:t,onAnswer:n}){const[s,r]=y.useState(!1),o=y.useRef(!1),i=y.useRef(!0);y.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,r(!0);const p=await rte();o.current=!1,i.current&&(r(!1),h.current=document.activeElement===c.current,n(ote(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":s,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:s?"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 ose(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 fh="Paused while this deck pairs only by invite. Turn that off above to use it.";function ise({status:e,accounts:t,onClose:n,onChanged:s}){nn("lan-setup");const r=ct(n),o=xt(n),[i,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),j=y.useRef(null),b=W=>{const H=Fa(m,W);return{disabled:H.disabled,"aria-busy":H.busy}},k=y.useRef(null),v=y.useRef(!0);y.useEffect(()=>()=>{v.current=!1},[]),y.useEffect(()=>{k.current=cT(k.current,e.shared??[],null)},[e.shared]);const N=y.useCallback(async(W,H,F="write")=>{j.current=F,w(F);try{const Z=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:W})})).json().catch(()=>null);return v.current?(Z!=null&&Z.ok?h(null):h(As(zt(H,Z),Z)),s(),(Z==null?void 0:Z.ok)===!0):!1}catch{return v.current&&h(As(zt(H,null))),!1}finally{j.current=null,v.current&&w(null)}},[s]),S=y.useCallback(async W=>{const H=await N({name:W},"save the name","name");return H&&v.current&&c(F=>F===W?null:F),H},[N]),E=y.useRef(null),C=i!=null&&i!==(e.name??""),I=Ur(!C,E),R=y.useCallback(async()=>{C&&!await S(i)||n()},[C,i,S,n]),$=async()=>{if(!e.fp)return;const W=await Ko(e.fp);if(v.current){if(!W){h(As("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{v.current&&p(!1)},1600)}},L=new Set(k.current??e.shared??[]),U=e.autoAsk!==!1,O=e.autoAccept!==!1,M=e.pairingMode==="invite",q=W=>{const H=b(W);return{...H,disabled:H.disabled||M}},A=e.shareActive!==!1,D=e.tailscale??null,P=!!(D!=null&&D.on),K=(D==null?void 0:D.ask)!==!1,G=(D==null?void 0:D.accept)!==!1;return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal lan-modal",onClick:W=>W.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(m4,{line:d,onDismiss:()=>h(null),onAnswer:W=>{h(W),W.done&&s()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:W=>c(W.target.value),onKeyDown:W=>{W.key!=="Enter"||i==null||S(i)}}),C&&a.jsx("button",{type:"button",className:"ap-manage-btn",...b("name"),onClick:()=>{I(),S(i)},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 $(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(W=>a.jsxs("label",{className:"ap-lan-pick",title:W.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[a.jsx("input",{type:"checkbox",checked:L.has(W.key),onChange:H=>{const F=ase(k.current,e.shared??[],W.key,H.target.checked);k.current=F,N({shared:F},H.target.checked?"share that account":"stop sharing that account").then(B=>{k.current===F&&(k.current=cT(F,e.shared??[],{ok:B}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:W.email}),!W.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},W.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":A,"aria-label":"Show paired decks which of these this deck is using",...b("current"),onClick:()=>void N({shareActive:!A},A?"stop showing which account this deck is using":"show which account this deck is using","current"),title:A?"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",M&&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":M,"aria-label":"Pair new decks only by invite","aria-describedby":M?"lan-invite-only-detail":void 0,...b("mode"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({pairingMode:M?"automatic":"invite"},M?"let decks pair on their own again":"pair new decks only by invite","mode"),title:M?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children: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",M&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":M||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":U,"aria-label":"Ask every deck this one finds",...q("ask"),onClick:()=>void N({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:M?fh:U?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...q("accept"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({autoAccept:!O},O?"stop accepting automatically":"accept every deck that asks","accept"),title:M?fh:O?"Stop saying yes for you. A deck that asks waits in the panel again, and adds no login here until somebody here accepts it.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here. Each can then add the logins ticked on it to this deck.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),(D==null?void 0:D.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:ose(D)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...b("tailscale"),onClick:()=>void N({tailscale:!P},P?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:P?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:a.jsx("span",{className:"switch-knob"})})]}),P&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",M&&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":M||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":K,"aria-label":"Ask each of my devices it finds over Tailscale",...q("tailscale-ask"),onClick:()=>void N({tailscaleAsk:!K},K?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?fh:K?"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":M||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":G,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...q("tailscale-accept"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({tailscaleAccept:!G},G?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?fh:G?"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",...b("name"),onClick:()=>void R(),children:"Done"})]})]})}),document.body)}function lse({on:e,status:t,paired:n,busy:s,pressProps:r,checkNow:o,setAddOpen:i,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(f4,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>i("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",...r("check"),onClick:()=>void o(),"aria-label":s==="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",...r("setup"),onClick:()=>c(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function cse({accounts:e,onChanged:t,onNoCopy:n,onShared:s,view:r,onOpen:o,onBack:i,closeButton:c}){const[d,h]=y.useState(!1),[f,p]=y.useState(!1),[m,w]=y.useState(!1),j=nte(),[b,k]=y.useState(!1),{status:v,manual:N,now:S,busy:E,failure:C,dismissFailure:I,answerGiveBack:R,pressProps:$,load:L,toggle:U,answer:O,dropAddress:M,rename:q,checkOne:A,checkNow:D}=dte(t,()=>h(!0)),{armed:P,pressUnpair:K}=hte(O),[G,W]=y.useState(null),[H,F]=y.useState(!1),B=y.useMemo(()=>e.filter(he=>vQ(he.key,v??null,S)).map(he=>he.key).sort().join(`
97
- `),[e,v,S]);y.useEffect(()=>{n==null||n(B?B.split(`
98
- `):[])},[B,n]);const Z=y.useMemo(()=>JSON.stringify(e.flatMap(he=>{const ae=kQ(he.key,v??null);return ae?[[he.key,ae]]:[]})),[e,v]);y.useEffect(()=>{s==null||s(new Map(JSON.parse(Z)))},[Z,s]);const V=(v==null?void 0:v.enabled)===!0,X=y.useMemo(()=>cQ((v==null?void 0:v.pairingMode)==="invite"&&v?{...v,pending:[]}:v,S),[v,S]),Y=G?X.find(he=>{var ae;return he.fp===G||((ae=he.twins)==null?void 0:ae.some(ge=>ge.fp===G))})??null:null;y.useEffect(()=>{G&&v&&!Y&&W(null)},[G,v,Y]);const{asks:J,rest:ee,live:ne,folded:le,troubled:de,shown:ue,paired:re}=xQ(X,b),pe=oQ(v,S),ye=wQ(v,X),_e=a.jsxs(a.Fragment,{children:[f&&v&&a.jsx(Ite,{status:v,manual:N,startWith:f==="invite"?"invite":void 0,onClose:()=>p(!1),onChanged:()=>{L(),t()}}),m&&a.jsx(JP,{title:"How Local network works",steps:_te,finish:V?void 0:{label:"Turn it on",act:()=>{w(!1),U()}},onClose:()=>w(!1)}),d&&v&&a.jsx(ise,{status:{...v,manualRows:N},accounts:e,manual:N,onClose:()=>h(!1),onChanged:()=>{L(),t()}}),H&&a.jsx(Dne,{status:v,rows:X,accounts:e,now:S,covered:!!Y||d||!!f||m,onOpenDeck:W,onClose:()=>F(!1)}),Y&&v&&a.jsx(sse,{row:Y,source:pu(v,Y),status:v,accounts:e,now:S,busy:E,onClose:()=>W(null),onRename:he=>q(Y.fp,he),onCheck:()=>A(Y.fp),onVerb:()=>{switch(Y.kind){case"paired":return O("unpair",Y.fp,"unpair that deck");case"nearby":return O("accept",Y.fp,"reach that deck");case"declined":return O("allow",Y.fp,"let that deck ask again");case"dialling":return M(Y.fp);default:return Promise.resolve(null)}},onSettings:()=>{W(null),h(!0)},onInvite:()=>{W(null),p("invite")},twins:(Y.twins??[]).map(he=>({row:he,peer:pu(v,he).peer??null})),onUnpair:he=>O("unpair",he,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(lse,{on:V,status:v,paired:re,busy:E,pressProps:$,checkNow:D,setAddOpen:p,setSetupOpen:h,setMapOpen:F,onBack:i,closeButton:c}),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":V,"aria-label":"Sync with paired decks",...$("switch"),onClick:()=>void U(),title:V?"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(Fte,{on:V,status:v}),!V&&a.jsxs("div",{className:"ap-lan-intro-row",children:[a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>w(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(Ete,{}),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(cu,{film:"localNetwork"})]}),a.jsx("p",{className:`ap-lan-status ${pe.tone}`,role:"status",children:pe.tone==="ok"?"":pe.text}),a.jsx(m4,{line:C,onDismiss:I,onAnswer:R}),V&&a.jsxs(a.Fragment,{children:[J.length>0&&a.jsx(Ote,{asks:J,pressProps:$,answer:O}),ue.length>0&&a.jsx(Pte,{rows:ue,pairingMode:v==null?void 0:v.pairingMode,armed:P,pressProps:$,answer:O,dropAddress:M,onUnpair:K,onOpenPeer:W,onInvite:()=>p("invite")}),(ne.length>0&&le.length>0||V&&re>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[ne.length>0&&le.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":b,onClick:()=>k(he=>!he),title:b?"Show only the decks that are on":`Show the ${le.length} deck${le.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${b?" open":""}`,"aria-hidden":!0,children:"›"}),b?"fewer":`${le.length} more`,!b&&de>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",de," not responding"]})]}),V&&re>0&&a.jsx("span",{className:"ap-lan-checked",children:iQ(v==null?void 0:v.checkedAt,S,E==="check")})]}),ee.length===0&&J.length===0&&!(v!=null&&v.stalled)&&!(v!=null&&v.deaf)&&!(v!=null&&v.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:()=>w(!0),children:"How it works"}),a.jsx(cu,{film:"localNetwork"})]})]})]})}),_e]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(Jne,{entry:ye,rows:X,onOpen:o,onMap:V?()=>F(!0):void 0,...j}),a.jsx("p",{className:"vis-hidden",role:"status",children:pe.tone==="ok"?"":pe.text}),_e]})}function use({anchorId:e,id:t,peers:n,onHold:s,onLet:r}){const o=y.useRef(null),{title:i,shown:c,rest:d}=tte(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=B1(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${m.top}px`,f.style.left=`${m.left}px`,f.style.maxHeight=m.maxHeight==null?"":`${m.maxHeight}px`,f.dataset.side=m.side},[e]);return y.useLayoutEffect(()=>{h()}),y.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),wt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:r,children:[a.jsx("p",{className:"ap-peek-title",children:i}),a.jsx("div",{className:"ap-peek-list",children:c.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",title:f.name,children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${Math.round(f.headroom)}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function dse({peers:e,strained:t,armed:n,threshold:s,open:r,onToggle:o,order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[m,w]=y.useState(!1),j=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(j.current),[]),y.useEffect(()=>{r&&(window.clearTimeout(j.current),w(!1))},[r]);const b=E=>{r||(window.clearTimeout(j.current),j.current=window.setTimeout(()=>w(!0),E))},k=()=>{window.clearTimeout(j.current),j.current=window.setTimeout(()=>w(!1),XP)},v=()=>window.clearTimeout(j.current),N=()=>{window.clearTimeout(j.current),w(!1)},S=Qee(e,{strained:t&&!r,armed:n,threshold:s});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":r,"aria-controls":r?"ap-rest-panel":void 0,"aria-describedby":m?"ap-rest-peek":void 0,onClick:()=>{N(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&b(YP)},onPointerLeave:k,onFocus:E=>{E.target.matches(":focus-visible")&&b(0)},onBlur:k,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":S.tone,children:S.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"})})]}),m&&a.jsx(use,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:v,onLet:k}),r&&a.jsx(hse,{order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function hse({order:e,choices:t,onOrder:n,allOpen:s,onToggleAll:r,held:o}){var d;const i=y.useRef(null);y.useLayoutEffect(()=>{const h=i.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 m=new ResizeObserver(p);return m.observe(h),()=>{m.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:i,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${c} — held where it was while you are in the list`:c,"data-sorted":e===ep?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":s,"aria-controls":"ap-rest-list",title:s?"Collapse every account":"Expand every account",onClick:r,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:s?"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 fse(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const pse=1800;function mse({accounts:e,onClose:t,copyText:n}){nn("share-accounts");const[s,r]=y.useState([]),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,m]=y.useState(!1),[w,j]=y.useState(()=>Math.floor(Date.now()/1e3)),b=y.useRef(null),k=y.useRef(!1),v=ct(t,{focusRef:b}),N=xt(t),S=Ur(o!=null,b),E=Ur(o==null,b);y.useEffect(()=>{if(!o)return;j(Math.floor(Date.now()/1e3));const P=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(P)},[o]);const C=Lee(e),I=Oee(e,s),R=I.length===e.length,$=P=>r(K=>Pee(K,P)),L=y.useCallback(async()=>{const P=Dee(I);if(!An(k.current)||!P)return;k.current=!0,d(!0),f(null),m(!1);const K=await fse(P).catch(()=>null);if(k.current=!1,d(!1),!(K!=null&&K.ok)){f(Vi(K,"the share could not be made"));return}i({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,I]),U=o?GP(o.expiresAt,w):null,O=(U==null?void 0:U.tone)==="gone",M=(o==null?void 0:o.shared.length)??0,q=O?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`,A=M===1?"this is the password":`this is ${M} passwords`,D=o?O?q:`${q} — ${A}`:"";return wt.createPortal(a.jsx("div",{className:"modal-backdrop",...N,role:"presentation",children:a.jsxs("div",{ref:v,className:"modal sa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:D}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:q}),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(O){E(),S(),i(null),L();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),pse))},children:O?"make a new share":p?"copied":`copy ${M===1?"the share":"all "+M}`}),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:A})," · ",a.jsx("span",{className:`ap-share-expiry ${U==null?void 0:U.tone}`,children:U==null?void 0:U.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map(P=>{var G;const K=!!(P.email&&((G=P.detail)!=null&&G.includes(P.email)));return a.jsxs("li",{children:[!K&&a.jsx("span",{className:"sa-who",children:P.email||`account ${P.num}`}),a.jsx("span",{className:"sa-why",children:P.detail||"could not be exported"})]},`${P.num}-${P.email}`)})})]}),a.jsx("p",{className:"sa-note",children:O?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{E(),i(null),m(!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 ",Ct,"?"]}),a.jsx("p",{className:`sa-count${I.length?"":" empty"}`,children:Fee(I.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:C.map(P=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:I.includes(P.num),onChange:()=>$(P.num)}),a.jsx("span",{className:"sa-who",children:P.label}),P.sub&&a.jsx("span",{className:"sa-sub",children:P.sub})]})},P.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>r(R?e.map(P=>P.num):[]),children:R?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:b,...Ps(c,!I.length),onClick:()=>{S(),L()},children:c?"making the share…":I.length===0?"Share":I.length===1?"Share 1 account":`Share ${I.length} accounts`})]})]})]})]})}),document.body)}function g4(e,t){var n;return!e.disabled&&!((n=Ho(e,t))!=null&&n.blocksSwitch)}function gse(e,t,n){return e.map(s=>{const r=Ho(s,t,n==null?void 0:n(s));return{key:Ls(s),name:s.alias??s.email??`account ${s.num}`,ready:g4(s,t),why:s.disabled?"held out":r!=null&&r.blocksSwitch?r.text:null,warn:(r==null?void 0:r.tone)==="warn",headroom:U1(s,t)}})}function yse(e,t,n){const s=Number(t),r=e&&(n==null?e.headroom:U1(e,n));return r!=null&&Number.isFinite(s)&&100-r>=s}function wse(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const y4="agent-dag.otherAccountsOrder",w4="agent-dag.otherAccountsOpen";function xse(){const e=Ve(y4);return typeof e=="string"&&e.length>0&&e.length<=64?e:ep}function vse(e){ze(y4,e)}function bse(){const e=Ve(w4);if(!e)return u0;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 u0}function kse(e){ze(w4,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function jse(){const[e,t]=y.useState(null),n=y.useRef(null),s=y.useCallback(i=>Xf(n.current)?(n.current=i,t(i),!0):!1,[]),r=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:s,release:r,pressProps:(i,c=!1)=>{const d=Fa(e,i);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const Nse=8e3,Sse=1800,_se=4e3;function Ese({claim:e,release:t,load:n,clearFailure:s,rescueFocus:r}){const[o,i]=y.useState(null),c=(o==null?void 0:o.num)??null,d=y.useRef(o);d.current=o;const[h,f]=y.useState(null),[p,m]=y.useState(""),[w,j]=y.useState(null),b=y.useRef(0);y.useEffect(()=>{if(w==null)return;const Z=window.setTimeout(()=>j(null),_se);return()=>window.clearTimeout(Z)},[w]);const[k,v]=y.useState(null),[N,S]=y.useState(!1),[E,C]=y.useState(null),[I,R]=y.useState(null),$=y.useCallback(async(Z,V)=>{if(!e(V))return null;s(),f(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}),Y=await X.json().catch(()=>null);return Y!=null&&Y.ok||f({text:Vi(Y,"command failed",X.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,s]),L=y.useCallback(()=>{i(null),f(null),j(null),v(null),S(!1)},[]),U=(Z,V="first")=>{L(),R(null),i({num:Z,view:"menu",start:V})},O=y.useCallback(Z=>{var Y,J;const V=d.current;if(!V||Z!=null&&V.num!==Z)return;const X=document.getElementById(`ap-menu-${V.num}`);(X!=null&&X.contains(document.activeElement)||Kn(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((J=document.getElementById(`ap-more-${V.num}`))==null||J.focus()),L()},[L]),M=y.useCallback(Z=>f(Z),[]),q=(Z,V)=>{m(V??""),f(null),i({num:Z,view:"rename"})},A=Z=>m(Z),D=Z=>{R(null),f(null),i({num:Z,view:"move"})},P=Z=>R(Z),K=async Z=>{var X;S(!1);const V=await $({action:"share",account:Z},`share-${Z}`);!(V!=null&&V.ok)||((X=d.current)==null?void 0:X.num)!==Z||(v({num:Z,blob:V.blob,expiresAt:V.expiresAt}),i({num:Z,view:"share"}))},G=async Z=>{await Ko(Z)&&(S(!0),window.setTimeout(()=>S(!1),Sse))},W=async(Z,V)=>{const{commit:X,alias:Y}=Vee(p,V);if(X){const J=await $({action:"alias",account:Z,alias:Y},`alias-${Z}`);if(await n(!0),!(J!=null&&J.ok))return}O(Z)},H=async(Z,V)=>{var J,ee,ne;const X=await $({action:"move",account:Z,slot:V},`move-${Z}`),Y=Hee({menuFor:((J=d.current)==null?void 0:J.num)??null,shareFor:(k==null?void 0:k.num)??null},Z,X);if(await n(!0),Y){if(Y.menuFor!=null){const de=document.getElementById(`ap-menu-${Z}`),ue=document.getElementById(`ap-more-${Y.menuFor}`);ue&&(de!=null&&de.contains(document.activeElement)||Kn(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ue.focus()}((ne=d.current)==null?void 0:ne.num)===Z&&L(),j(Y.confirmRemove),Y.shareFor==null&&(v(null),S(!1)),C(Y.swapNote);const le=Y.swapNote;le&&window.setTimeout(()=>C(de=>de===le?null:de),Nse),R(null),r(Y.menuFor)}return X};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:w,share:k,shareCopied:N,slotDraft:I,swapNote:E,showMenu:U,dropMenu:L,closeMenu:O,sayInMenu:M,startRename:q,typeAlias:A,doAlias:W,startMove:D,pickSlot:P,doSlot:async(Z,V,X)=>{if(!X.sends){O(Z);return}await H(Z,V)},makeShare:K,copyShare:G,pressRemove:Z=>{const V=Date.now(),X=fl({armedFor:w,target:Z,armedAt:b.current,now:V,gapMs:hl});if(X==="arm"){j(Z),b.current=V;return}X!=="ignore"&&(j(null),$({action:"remove",account:Z},`rm-${Z}`).then(Y=>{var J;n(!0),Y!=null&&Y.ok&&(((J=d.current)==null?void 0:J.num)===Z&&L(),r(null))}))}}}function Cse(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function Tse({data:e,claim:t,release:n,load:s,sayFailure:r,clearFailure:o,sayInMenu:i,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(m,w,j="panel")=>{if(!t(w))return null;const b=j==="menu"?i:r;b(null);try{const k=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),v=await k.json().catch(()=>null);return v!=null&&v.ok||b({text:h0(v,"command failed",k.status),raw:fu(v)}),v}catch{return b({text:"server unreachable"}),null}finally{n()}},[t,n,i,r]);return y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(m=>Cse(m,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(m,w)=>{if(t(`switch-${m}`)){o(),h(null);try{const b=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:m})})).json().catch(()=>null);b!=null&&b.ok?h({num:m,name:w}):r({text:h0(b,"the switch failed"),raw:fu(b),row:m}),await s(!0)}catch{r({text:"server unreachable",row:m})}finally{n(),c(m)}}}}}const Rse=1800;function Ase({auto:e,post:t,load:n}){var I;const[s,r]=y.useReducer(lee,g0),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=((I=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:I.value)??"90",m=s.pick??p,w=Xee(m,p),j=s.custom!=null,b=s.refusal,k=y.useRef(j);return y.useEffect(()=>{var R,$,L;k.current!==j&&(k.current=j,j?((R=h.current)==null||R.focus(),($=h.current)==null||$.select()):f.current&&((L=c.current)==null||L.focus()),f.current=!1)},[j]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:j,thresholdRefusal:b,thresholdFieldRef:h,proposeThreshold:R=>r({kind:"pick",pick:R}),typeThreshold:R=>r({kind:"type",text:R}),cancelThreshold:R=>{R.key!=="Escape"||R.nativeEvent.isComposing||!s.custom||(R.preventDefault(),R.stopPropagation(),f.current=!0,r({kind:"cancel"}))},leaveThreshold:()=>r({kind:"leave",stored:p}),doThreshold:async(R,$)=>{const L=await cee(R,$,t);if(L.kind==="refused"){r({kind:"refuse",message:L.message});return}L.kind==="sent"&&(await n(!0),!L.ok)||(f.current=document.activeElement===h.current,r({kind:"settle"}),i(!0),window.setTimeout(()=>{var U;document.activeElement===d.current&&((U=c.current)==null||U.focus()),i(!1)},Rse))}}}const Mse=1800;function $se({auto:e,post:t,load:n}){var j;const[s,r]=y.useState(null),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((j=e==null?void 0:e.choice)==null?void 0:j.next)??"room",f=s??h,p=Yee(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:c,nextSaveRef:d,proposeNext:b=>r(see(b)?b:null),doNext:async()=>{if(!p.sends)return;const b=await t({action:"next",value:f},"next");await n(!0),b!=null&&b.ok&&(r(null),i(!0),window.setTimeout(()=>{var k;document.activeElement===d.current&&((k=c.current)==null||k.focus()),i(!1)},Mse))}}}const Ise=Object.freeze({text:"couldn't reach the deck server",reload:!0}),Lse=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function uT(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function Ose(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=fu(t.body);return{text:h0(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function Ug(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 Wg=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Hg=e=>e==null||typeof e=="string",zg=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function Pse(e){if(!Wg(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return Hg(e.reason)&&Hg(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!Wg(n)||typeof n.num!="number"||!Number.isInteger(n.num)||n.num<1||t.has(n.num)||(t.add(n.num),![n.email,n.alias,n.org,n.orgUuid,n.error].every(Hg)||![n.active,n.disabled,n.stale].every(r=>typeof r=="boolean")||!zg(n.fetchedAt)||!zg(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(r=>!Wg(r)||typeof r.id!="string"||!r.id||s.has(r.id)||typeof r.label!="string"||typeof r.pct!="number"||!Number.isFinite(r.pct)||r.pct<0||r.pct>100||!zg(r.resetAt==null?null:typeof r.resetAt=="number"?r.resetAt*1e3:NaN)?!1:(s.add(r.id),!0))})}const x4=15e3,Dse=3e4;function Fse(e){const[t,n]=y.useState(null),[s,r]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(null),h=y.useRef(null),f=y.useRef(0),p=y.useRef(!1),m=y.useRef(new Set),w=y.useCallback(async(k=!1)=>{if(!p.current||!k&&m.current.size>0)return;const v=++f.current;k&&i(!0);const N=new AbortController;m.current.add(N);const S=window.setTimeout(()=>N.abort(),Dse);try{const[E,C]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`,{signal:N.signal}),fetch("/api/cswap-auto",{signal:N.signal})]),[I,R]=await Promise.all([E.ok?E.json():null,C.ok?C.json():null]),$=Ose([await uT(E),await uT(C)]);if(!p.current||v!==f.current)return;if(I&&!Pse(I)){d(L=>Ug(L,{text:"the deck server returned unreadable account data",reload:!0}));return}I&&(n(I),e(I)),R&&r(R),d(L=>Ug(L,$))}catch{p.current&&v===f.current&&d(E=>Ug(E,N.signal.aborted?Lse:Ise))}finally{window.clearTimeout(S),m.current.delete(N),p.current&&v===f.current&&i(!1)}},[e]);y.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),x4),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const k of m.current)k.abort()}),[w]);const j=y.useCallback(k=>d(k),[]),b=y.useCallback(()=>d(null),[]);return{data:t,auto:s,reloading:o,failure:c,load:w,sayFailure:j,clearFailure:b}}const Bse="#ap-rest-entry";function qse(e){return[`#${e}`,Bse,...cP(null)]}function Use(e){const t=y.useRef(null),n=r=>{t.current=r.target.id||null},s=r=>{r.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const r=t.current;if(!(!r||!Kn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of qse(r)){const c=document.querySelector(i);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:s}}function Wse({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:r=!1,onLanShown:o}){var Jt,Ks,qt;nn("accounts-panel");const i=Ln(),{busy:c,claim:d,release:h,pressProps:f}=jse(),[p,m]=y.useState("accounts"),[w,j]=y.useState(!1),[b,k]=y.useState(null),v=y.useRef(b);v.current=b;const[N,S]=y.useState(!1),[E,C]=y.useState(!1),[I,R]=y.useState([]),[$,L]=y.useState(!1),[U,O]=y.useState(null),[M,q]=y.useState(bse),[A,D]=y.useState(xse),[P,K]=y.useState(null),[G,W]=y.useState(!1),H=y.useRef(s);H.current=s;const F=y.useCallback(we=>{var Ye;q(lt=>TJ(lt,we.accounts)),(Ye=H.current)==null||Ye.call(H,we)},[]),{data:B,auto:Z,reloading:V,failure:X,load:Y,sayFailure:J,clearFailure:ee}=Fse(F),ne=Use(B),le=y.useCallback(we=>{window.requestAnimationFrame(()=>{var Ye;if(Kn(((Ye=document.activeElement)==null?void 0:Ye.tagName)??null))for(const lt of cP(we)){const ht=document.querySelector(lt);if(ht){ht.focus();return}}})},[]),de=Ese({claim:d,release:h,load:Y,clearFailure:ee,rescueFocus:le}),{menu:ue,menuFor:re,swapNote:pe,showMenu:ye,dropMenu:_e,closeMenu:he,sayInMenu:ae}=de,{switched:ge,post:Se,doSwitch:me}=Tse({data:B,claim:d,release:h,load:Y,sayFailure:J,clearFailure:ee,sayInMenu:ae,rescueFocus:le}),{threshold:$e,thresholdPick:Pe,thresholdCtl:qe,thresholdSaved:Le,thresholdRef:Qe,thresholdSaveRef:je,thresholdCustom:Ae,thresholdRefusal:De,thresholdFieldRef:He,proposeThreshold:Ze,typeThreshold:ft,cancelThreshold:ut,leaveThreshold:Je,doThreshold:Dt}=Ase({auto:Z,post:Se,load:Y}),{nextPick:vt,nextCtl:It,nextSaved:it,nextRef:Lt,nextSaveRef:Ft,proposeNext:dt,doNext:St}=$se({auto:Z,post:Se,load:Y}),rt=mP();y.useEffect(()=>{kse(M)},[M]),y.useEffect(()=>{vse(A)},[A]);const[ys,Ws]=y.useState(()=>new Set),ws=y.useCallback(we=>Ws(new Set(we)),[]),[Yn,Xn]=y.useState(()=>new Map),wn=we=>{const Ye=MC([we])[0].key;return{noCopyWorksNearby:ys.has(Ye),sharedTo:Yn.get(Ye)??null}},At=(Jt=B==null?void 0:B.accounts)==null?void 0:Jt.find(we=>we.active),an=At?Ho(At,rt,wn(At)):null,Ne=(B==null?void 0:B.accounts)??[],Te=At?Ne.filter(we=>!we.active):[],We=SP(Te),pt=SJ(A,Te),at=c0(NJ(Te,pt,we=>g4(we,rt),rt),P),Zn=y.useRef(!1),Hs=y.useRef(!1),zs=y.useRef(!1),On=y.useCallback(()=>{!Zn.current&&!Hs.current&&!zs.current&&K(null)},[]),xn=()=>K(we=>we??at.map(Ls)),Jr={onPointerEnter:()=>{Zn.current=!0,xn()},onPointerLeave:()=>{Zn.current=!1,On()},onFocus:we=>{we.target.matches(":focus-visible")&&(Hs.current=!0,xn())},onBlur:we=>{we.currentTarget.contains(we.relatedTarget)||(Hs.current=!1,On())}},Vs=re!=null&&Te.some(we=>we.num===re)||b!=null&&Te.some(we=>we.num===b.num);y.useEffect(()=>{zs.current=Vs,Vs||On()},[Vs,On]);const yr=G&&Te.length>0;y.useEffect(()=>{yr||(Zn.current=Hs.current=zs.current=!1,K(null))},[yr]);const wr=y.useRef(!1);y.useEffect(()=>{wr.current&&Te.length===0&&le(null),wr.current=Te.length>0},[Te.length,le]);const xr=at.length?Ne.filter(we=>we.active):Ne,Bt=gse(at,rt,wn),Qr=yse(At,$e,rt),Gs=wse(Z),vr=we=>G&&at.some(Ye=>Ye.num===we)?"ap-rest-list":"ap-scroll",ot=(we,Ye="first")=>{ye(we,Ye),k(null)},Ya=(we,Ye)=>{_e(),k(lt=>(lt==null?void 0:lt.anchor)===Ye?null:{num:we,anchor:Ye})},br=y.useCallback((we=!1)=>{var lt;const Ye=v.current;we&&Ye&&((lt=document.getElementById(Ye.anchor))==null||lt.focus()),k(null)},[]),xs=()=>{_e(),k(null),m("lan")},vs=y.useRef(p);y.useEffect(()=>{vs.current!==p&&(vs.current=p,window.requestAnimationFrame(()=>{var we;(we=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||we.focus()}))},[p]),y.useEffect(()=>{B!=null&&B.ok&&j(!0)},[B==null?void 0:B.ok]),y.useEffect(()=>{!r||!w||(xs(),o==null||o())},[r,w]),y.useEffect(()=>{t&&(_e(),k(null))},[t,_e]),y.useEffect(()=>{ue&&(B!=null&&B.accounts)&&!B.accounts.some(we=>we.num===ue.num)&&_e(),b&&(B!=null&&B.accounts)&&!B.accounts.some(we=>we.num===b.num)&&k(null)},[B,ue,b,_e]),y.useEffect(()=>{U==null||!(B!=null&&B.accounts)||B.accounts.some(we=>we.num===U.num)||(O(null),le(null))},[B,U,le]);const ea=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:gn("Close","A",i),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"})})}),kr=we=>{var Xa;const Ye=_P(M,we),lt=re===we.num,ht=(X==null?void 0:X.row)===we.num?X:null,dn=(ge==null?void 0:ge.num)===we.num,bs=(pe==null?void 0:pe.at)===we.num?pe:null,ta=bs?Ne.find(Ys=>Ys.num===bs.displaced):void 0,Nl=(b==null?void 0:b.anchor)===`ap-issue-${we.num}`;return a.jsx(SQ,{a:we,nowSec:rt,lan:wn(we),opened:Ye,onToggleLanes:()=>q(Ys=>EJ(Ys,we)),busy:c,pressProps:f,onSwitch:me,menuOpen:lt,onOpenMenu:ot,onCloseMenu:he,refusal:ht,onDismissRefusal:()=>ee(),switchedHere:dn,swapped:bs,displaced:ta,issueExpanded:Nl,onOpenIssue:Ya,sortKey:we.active?null:jJ(pt),home:Pg(we,(Xa=Z==null?void 0:Z.choice)==null?void 0:Xa.home)?ree(we,!!(Z!=null&&Z.enabled)):null},we.num)},Pn=B!=null&&B.ok&&(Z!=null&&Z.ok)?a.jsx(uee,{auto:Z,threshold:$e,thresholdPick:Pe,thresholdCtl:qe,thresholdSaved:Le,thresholdRef:Qe,thresholdSaveRef:je,thresholdCustom:Ae,thresholdRefusal:De,thresholdFieldRef:He,proposeThreshold:Ze,typeThreshold:ft,cancelThreshold:ut,leaveThreshold:Je,doThreshold:Dt,nextPick:vt,nextCtl:It,nextSaved:it,nextRef:Lt,nextSaveRef:Ft,proposeNext:dt,doNext:St,pressProps:f,post:Se,load:Y}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:ne.onFocus,onBlur:ne.onBlur,children:[p==="accounts"&&a.jsx(EQ,{canShare:(((Ks=B==null?void 0:B.accounts)==null?void 0:Ks.length)??0)>0,canReport:(((qt=B==null?void 0:B.accounts)==null?void 0:qt.length)??0)>1||E,onAdd:()=>S(!0),onReport:()=>{R([...xr,...at].map(Ls)),C(!0)},onShareSet:()=>L(!0),onReload:()=>Y(!0),pressProps:f,reloading:V,closeButton:ea}),p==="accounts"&&a.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[B==null?X?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:X.raw||void 0,children:X.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",x4/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...f("reload",V),onClick:()=>Y(!0).then(()=>le(null)),children:V?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):B.ok?a.jsxs(a.Fragment,{children:[At&&(an==null?void 0:an.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":(b==null?void 0:b.anchor)==="ap-notice","aria-controls":(b==null?void 0:b.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Ya(At.num,"ap-notice"),children:[a.jsx(q1,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),an.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>S(!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:xr.map(kr)}),at.length>0&&a.jsx(dse,{peers:Bt,strained:Qr,armed:Gs,threshold:Z!=null&&Z.ok?$e:null,open:G,onToggle:()=>W(we=>!we),order:pt,choices:We,onOrder:D,allOpen:EP(M,at),onToggleAll:()=>q(we=>CJ(we,at)),held:P!=null}),at.length>0&&G&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Jr,children:at.map(kr)}),Pn]}),at.length===0&&Pn,X&&X.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:X.raw||void 0,children:X.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>ee(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ue&&(()=>{var Ye,lt;const we=(Ye=B.accounts)==null?void 0:Ye.find(ht=>ht.num===ue.num);return we?a.jsx(Zee,{a:we,accountMenu:de,slots:(B.accounts??[]).map(ht=>ht.num),boundaryId:vr(we.num),nowSec:rt,busy:c,pressProps:f,rotating:!!(Z!=null&&Z.enabled||Z!=null&&Z.external),onProjects:()=>{O({num:we.num,name:we.alias??we.email??`account ${we.num}`}),he(we.num)},onRotation:()=>Se({action:"account",account:we.num,enabled:we.disabled},`rot-${we.num}`,"menu").then(ht=>{Y(!0),ht!=null&&ht.ok&&he(we.num)}),home:Pg(we,(lt=Z==null?void 0:Z.choice)==null?void 0:lt.home),canSetHome:!!(Z!=null&&Z.enabled)&&!(Z!=null&&Z.external),onHome:()=>{var ht;return Se({action:"home",account:Pg(we,(ht=Z==null?void 0:Z.choice)==null?void 0:ht.home)?null:we.num},`home-${we.num}`,"menu").then(dn=>{Y(!0),dn!=null&&dn.ok&&he(we.num)})}}):null})(),b&&(()=>{var lt;const we=(lt=B.accounts)==null?void 0:lt.find(ht=>ht.num===b.num),Ye=we?Ho(we,rt,wn(we)):null;return!we||!Ye?null:a.jsx(pJ,{anchorId:b.anchor,boundaryId:b.anchor==="ap-notice"?"ap-scroll":vr(we.num),issue:Ye,who:we.alias??we.email??`account ${we.num}`,fetchedAt:we.fetchedAt,nowSec:rt,onClose:br,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:Ye.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Ye.text}. ${Ye.hint}`}))})})()]}):a.jsx(_Q,{data:B}),a.jsx("div",{className:"film-foot",children:a.jsx(cu,{film:"claudeAccounts"})})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ge?`Now active: ${ge.name}`:""}),w&&a.jsx(cse,{accounts:MC((B==null?void 0:B.accounts)??[]),onChanged:()=>Y(!0),onNoCopy:ws,onShared:Xn,view:p==="lan",onOpen:xs,onBack:()=>m("accounts"),closeButton:ea}),N&&a.jsx(KP,{onClose:()=>S(!1),onChanged:()=>Y(!0)}),$&&a.jsx(mse,{accounts:((B==null?void 0:B.accounts)??[]).map(we=>({num:we.num,email:we.email,alias:we.alias,org:we.org})),onClose:()=>L(!1),copyText:Ko}),U!=null&&(()=>{var Ye;const we=(Ye=B==null?void 0:B.accounts)==null?void 0:Ye.find(lt=>lt.num===U.num);return B!=null&&B.accounts&&!we?null:a.jsx(hJ,{num:U.num,name:we?we.alias??we.email??`account ${we.num}`:U.name,onClose:()=>O(null)})})(),E&&a.jsx(eee,{accounts:(B==null?void 0:B.accounts)??null,order:I,failed:X!=null&&X.reload?X.text:null,nowSec:rt,onClose:()=>C(!1)})]})}function Hse({width:e,children:t}){const n=y.useRef(null);return y.useLayoutEffect(()=>{var s;for(const r of Array.from(((s=n.current)==null?void 0:s.children)??[]))r.inert=r.classList.contains("leaving")}),a.jsx("div",{ref:n,className:`left-column${e===0?" closing":""}`,style:{"--left-col-w":e===0?"0px":`calc(${e}px + var(--ui-panel-increase, 0px))`},children:t})}const zse=16,Vse=120;function Gse(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 Kse(e,t){const n=Math.max(t.left-e.clientX,0,e.clientX-t.right),s=Math.max(t.top-e.clientY,0,e.clientY-t.bottom);return Math.hypot(n,s)}function Yse(e,t){return Gse(e,t,zse)?"over":Kse(e,t)<=Vse?"near":"far"}function Xse(e){var n,s;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])??((s=e.touches)==null?void 0:s[0]);return t?{clientX:t.clientX,clientY:t.clientY}:null}function Zse(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[r,o]=y.useState("far"),i=y.useRef(null),c=zi(e,140),d=y.useCallback(m=>{var b;const w=(b=i.current)==null?void 0:b.getBoundingClientRect(),j=Xse(m);return w&&j?Yse(j,w):"far"},[]),h=y.useCallback(m=>{m!==null&&(s(m),t(!0)),o("far")},[]),f=y.useCallback(m=>{o(d(m))},[d]),p=y.useCallback((m,w)=>{const j=w&&d(m)==="over";return t(!1),j},[d]);return{trashDragging:e,trashLabel:n,trashState:r,trashZoneRef:i,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const Jse=420;function Qse(){const[e,t]=y.useState(!1),n=y.useRef(null),s=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),r=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),Jse+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:r}}const nj=11;function v4(e=0){return nj+Math.min(0,e)}const b4=7.2,k4=6.6,ere={width:104,height:48},dT={width:96,height:44},j4={width:220,height:103};function tre(e){let t=1/0,n=1/0;for(const s of e)!(s.width>0)||!(s.height>0)||(t=Math.min(t,s.width),n=Math.min(n,s.height));return!Number.isFinite(t)||!Number.isFinite(n)?j4:{width:Math.max(160,t),height:Math.max(72,n)}}function Vg(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function nre(e,t,n=j4,s=nj){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=s*t;return e==="detail"?r>=k4?"detail":Vg(n,t,dT)?"compact":"overview":r>=b4?"detail":e==="compact"?Vg(n,t,dT)?"compact":"overview":Vg(n,t,ere)?"compact":"overview"}function sre(e,t,n=nj){return e>=b4/n?e:Math.max(e,Math.min(t,k4/n-.001))}const rre=.8,are=1;function ore({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:s}){const[r,o]=y.useState("detail"),i=y.useRef(null),c=y.useRef(null),d=y.useCallback(()=>{var w;const f=n.current;if(((w=c.current)==null?void 0:w.version)===f)return c.current.card;const p=[];for(const j of e.current.agents.keys()){const b=t.current.get(j);b&&p.push(b)}const m=tre(p);return c.current={version:f,card:m},m},[]),h=y.useCallback(f=>{var m;const p=nre(i.current,f,d(),v4(A1[M1()]));return p===i.current?null:(i.current=p,(m=s.current)==null||m.setAttribute("data-lod",p),o(p),p)},[d,s]);return{lod:r,lodRef:i,applyZoom:h}}const ire=40,lre=120;function cre(e,t){let n=null,s=0,r=Number.NEGATIVE_INFINITY;const o=()=>{n=null,r=t.now(),e()},i=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(s<=d)return;i()}const p=Math.min(f,Math.max(0,d-h));s=d,n=t.setTimeout(o,p)};return{live(d=ire){const h=t.now(),f=Math.max(r+d,h);if(f<=h){i(),o();return}c(f,h,d)},replay(d=lre){i(),s=t.now()+d,n=t.setTimeout(o,d)},flush(){i(),o()},cancel(){i()}}}const ure=1024*1024,hT=5,N4=.8,N0=24,dre="agent-dag.soundCustom.done",hre="agent-dag.soundCustom.needs-input",Uc={done:dre,"needs-input":hre};function mu(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function fT(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function fre(e){return{done:fT(e(Uc.done)),"needs-input":fT(e(Uc["needs-input"]))}}function pre(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function mre(e){return e.done&&e.done===e["needs-input"]?e.done:null}const gre={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},S4=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function _4(e,t){const n=t.toLowerCase().split(";")[0].trim();if(S4.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return gre[s]??n}function pT(e,t){const n=_4(e.name,e.type);if(!S4.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>ure)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>hT)return`Audio must be ${hT} seconds or shorter.`}return null}function S0(e){return e>=N0?`There are already ${N0} custom sounds. Delete one first.`:null}function yre(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function wre(e){let t=0;for(const n of e)for(let s=0;s<n.length;s++)t=Math.max(t,Math.abs(n[s]));return t<=1e-5?1:Math.min(16,N4/t)}function E4(){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 xre(e,t,n=E4()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",r=pT({name:s,type:e.type,size:e.size});if(r)throw new Error(r);const o=await e.arrayBuffer();let i;try{i=await t(o.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const c=pT({name:s,type:e.type,size:e.size},i.duration);if(c)throw new Error(c);const d=Array.from({length:i.numberOfChannels},(f,p)=>i.getChannelData(p));return{id:n,name:s.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:_4(s,e.type),duration:i.duration,normalizationGain:wre(d),bytes:o}}function vre(e,t=E4()){const n=e.name.trim()||"Custom voice",s=e.text.trim();if(!s)throw new Error("Enter the words this voice should say.");const r=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:s.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,r)),pitch:Math.min(2,Math.max(.5,o))}}const bre="ccdeck-notification-audio",kre=2,Fs="assets",pr="summaries";function Cu(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function jre(){return new Promise((e,t)=>{const n=indexedDB.open(bre,kre);n.onupgradeneeded=s=>{const r=n.result,o=r.objectStoreNames.contains(Fs)?n.transaction.objectStore(Fs):r.createObjectStore(Fs,{keyPath:"id"});if(r.objectStoreNames.contains(pr))return;const i=r.createObjectStore(pr,{keyPath:"id"});if(s.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(i.put(mu(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Tu(e,t,n){const s=await jre();try{return await new Promise((r,o)=>{const i=s.transaction(e,t),c=n(i),d=()=>o(i.error??new Error("Local audio storage failed."));i.oncomplete=()=>r(c?c.result:void 0),i.onerror=d,i.onabort=d})}finally{s.close()}}async function Nre(){const e=Cu();return e?e.list():typeof indexedDB>"u"?[]:await Tu([pr],"readonly",t=>t.objectStore(pr).getAll())??[]}async function Sre(e){const t=Cu();return t?t.get(e):typeof indexedDB>"u"?null:await Tu([Fs],"readonly",n=>n.objectStore(Fs).get(e))??null}async function mT(e){const t=Cu();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Tu([Fs,pr],"readwrite",n=>{n.objectStore(Fs).put(e),n.objectStore(pr).put(mu(e))})}async function _re(e,t){const n=Cu();if(n){const s=await n.get(e);s&&await n.put({...s,name:t});return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Tu([Fs,pr],"readwrite",s=>{const r=s.objectStore(Fs),o=r.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const c={...i,name:t};r.put(c),s.objectStore(pr).put(mu(c))}})}async function Ere(e){const t=Cu();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Tu([Fs,pr],"readwrite",n=>{n.objectStore(Fs).delete(e),n.objectStore(pr).delete(e)})}const Wc=["done","needs-input"],Cre=[{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}]}],Tre=[{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}]}],sj={done:Cre,"needs-input":Tre},Hn="two";function _0(e,t){const n=sj[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Hn)??n[0]}function C4(e,t){return sj[e].some(s=>s.id===t)?t:Hn}_0("done",Hn).notes,_0("needs-input",Hn).notes;const gT=.04,T4=.24,Mh=0,gf=100,rj=5,zo=50;function ip(e,t=rj){if(!Number.isFinite(e))return zo;const n=Math.round(e/t)*t;return Math.min(gf,Math.max(Mh,n))}function R4(e,t=rj){if(e==null)return zo;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?ip(Number(n),t):zo}function aj(e){const t=ip(e),n=gT+(T4-gT)*(t/gf);return Math.round(n*1e4)/1e4}function Rre(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(aj(e)*s*1e4)/1e4}const Are=.012,yT=1e-4;function Mre(e){return Math.min(1,aj(e)/T4)}function $re(e,t){const n=e*(aj(t)/N4);return Math.max(1e-4,n)}const Ire=160,Lre="agent-dag.soundLevel.done",Ore="agent-dag.soundLevel.needs-input",Pre="agent-dag.soundFigure.done",Dre="agent-dag.soundFigure.needs-input",A4={done:Lre,"needs-input":Ore},yf={done:Pre,"needs-input":Dre},wT={done:{level:zo,figure:Hn},"needs-input":{level:zo,figure:Hn}};function Fre(e){const t=n=>({level:R4(e(A4[n])),figure:C4(n,e(yf[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function Bre(e,t){return(e??wT)[t]??wT[t]}const qre={Stop:"done",Notification:"needs-input"};function Ure(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:Vt(qre,n)??null}const Wre=6,Hre="ccdeck-tabs";function zre(e){return e>=Wre}function Vre(e,t,n){const s=r=>{const o=r.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",s),{ask(r,o=(i,c)=>setTimeout(i,c)){return new Promise(i=>{const c=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&c.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),i(c.size)},r)})},leave(){var r;e.removeEventListener("message",s),(r=e.close)==null||r.call(e)}}}function Gre({stateRef:e,rerender:t,pauseGate:n,chimesRef:s,desktopUpdateRef:r}){const[o,i]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[m,w]=y.useState(null);return y.useEffect(()=>{const j=new EventSource("/events"),b=cre(t,{now:()=>Date.now(),setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)});let k=!1;const v=typeof BroadcastChannel=="function"?Vre(new BroadcastChannel(Hre),Math.random().toString(36).slice(2),()=>k):null,N=window.setInterval(()=>{k||!v||v.ask(600).then(S=>{k||d(zre(S))})},3e3);return j.addEventListener("open",()=>{i(!0),f(!0)}),j.addEventListener("error",()=>{i(!1),w(null)}),j.addEventListener("open",()=>{k=!0,d(!1)}),j.addEventListener("error",()=>{k=!1}),j.addEventListener("replay-end",()=>{p.current=!1,b.flush(),w(Date.now())}),j.addEventListener("desktop-update",S=>r.current(S.data)),j.addEventListener("hook",S=>{var E;try{const C=JSON.parse(S.data);if(!n.accept(C))return;e.current=HO(e.current,C);const I=C.replay===!0||p.current||Date.now()-C.receivedAt>3e4;I?b.replay():b.live();const R=Ure(C,I);R&&((E=s.current)==null||E.play(R))}catch{}}),()=>{j.close(),b.cancel(),window.clearInterval(N),v==null||v.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:m}}const Kre=200,Yre=5*6e4,Xre=6,Zre=2*6e4;function ph(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function Jre(e,t){let n=!1;for(const r of e)if(!t.has(r)){n=!0;break}if(!n)return e;const s=new Set;for(const r of e)t.has(r)&&s.add(r);return s}function Qre(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(v1(n.id));return t}function eae(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(v1(n.id));return t}function tae(e,t){let n=zz(e,t,tE);Vz(e,t,tE)&&(n=!0);const s=[],r=o=>{s.push(o)};return Uz(e,t,Kre,Yre,r)&&(n=!0),Wz(e,t,Xre,Zre,r)&&(n=!0),{changed:n,forgotten:s}}function nae(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const s=new Set(e.ids);if(!s.has(t))return s.add(t),{ids:s,primary:t};if(s.delete(t),e.primary!==t)return{ids:s,primary:e.primary};let r=null;for(const o of s)r=o;return{ids:s,primary:r}}function sae(e,t){const[n,s]=y.useState(()=>({ids:new Set,primary:null})),{ids:r,primary:o}=n,i=y.useCallback((h,f,p=!f)=>{s(m=>nae(m,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{s({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{s(h=>{const f=Jre(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:r,primarySelectedId:o,selectAgent:i,clearSelection:c,pruneSelectionToBoard:d}}function rae({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:s,setSummaryFor:r}){const[o,i]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();i(d);const{changed:h,forgotten:f}=tae(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),s(p=>p!=null&&!e.current.agents.has(p)?null:p),r(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function oj(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 Gg,xT;function aae(){if(xT)return Gg;xT=1;function e(){this.__data__=[],this.size=0}return Gg=e,Gg}var Kg,vT;function wl(){if(vT)return Kg;vT=1;function e(t,n){return t===n||t!==t&&n!==n}return Kg=e,Kg}var Yg,bT;function lp(){if(bT)return Yg;bT=1;var e=wl();function t(n,s){for(var r=n.length;r--;)if(e(n[r][0],s))return r;return-1}return Yg=t,Yg}var Xg,kT;function oae(){if(kT)return Xg;kT=1;var e=lp(),t=Array.prototype,n=t.splice;function s(r){var o=this.__data__,i=e(o,r);if(i<0)return!1;var c=o.length-1;return i==c?o.pop():n.call(o,i,1),--this.size,!0}return Xg=s,Xg}var Zg,jT;function iae(){if(jT)return Zg;jT=1;var e=lp();function t(n){var s=this.__data__,r=e(s,n);return r<0?void 0:s[r][1]}return Zg=t,Zg}var Jg,NT;function lae(){if(NT)return Jg;NT=1;var e=lp();function t(n){return e(this.__data__,n)>-1}return Jg=t,Jg}var Qg,ST;function cae(){if(ST)return Qg;ST=1;var e=lp();function t(n,s){var r=this.__data__,o=e(r,n);return o<0?(++this.size,r.push([n,s])):r[o][1]=s,this}return Qg=t,Qg}var ey,_T;function cp(){if(_T)return ey;_T=1;var e=aae(),t=oae(),n=iae(),s=lae(),r=cae();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=r,ey=o,ey}var ty,ET;function uae(){if(ET)return ty;ET=1;var e=cp();function t(){this.__data__=new e,this.size=0}return ty=t,ty}var ny,CT;function dae(){if(CT)return ny;CT=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return ny=e,ny}var sy,TT;function hae(){if(TT)return sy;TT=1;function e(t){return this.__data__.get(t)}return sy=e,sy}var ry,RT;function fae(){if(RT)return ry;RT=1;function e(t){return this.__data__.has(t)}return ry=e,ry}var ay,AT;function M4(){if(AT)return ay;AT=1;var e=typeof Ud=="object"&&Ud&&Ud.Object===Object&&Ud;return ay=e,ay}var oy,MT;function Us(){if(MT)return oy;MT=1;var e=M4(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return oy=n,oy}var iy,$T;function xl(){if($T)return iy;$T=1;var e=Us(),t=e.Symbol;return iy=t,iy}var ly,IT;function pae(){if(IT)return ly;IT=1;var e=xl(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,r=e?e.toStringTag:void 0;function o(i){var c=n.call(i,r),d=i[r];try{i[r]=void 0;var h=!0}catch{}var f=s.call(i);return h&&(c?i[r]=d:delete i[r]),f}return ly=o,ly}var cy,LT;function mae(){if(LT)return cy;LT=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return cy=n,cy}var uy,OT;function Yo(){if(OT)return uy;OT=1;var e=xl(),t=pae(),n=mae(),s="[object Null]",r="[object Undefined]",o=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?r:s:o&&o in Object(c)?t(c):n(c)}return uy=i,uy}var dy,PT;function ms(){if(PT)return dy;PT=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return dy=e,dy}var hy,DT;function Ru(){if(DT)return hy;DT=1;var e=Yo(),t=ms(),n="[object AsyncFunction]",s="[object Function]",r="[object GeneratorFunction]",o="[object Proxy]";function i(c){if(!t(c))return!1;var d=e(c);return d==s||d==r||d==n||d==o}return hy=i,hy}var fy,FT;function gae(){if(FT)return fy;FT=1;var e=Us(),t=e["__core-js_shared__"];return fy=t,fy}var py,BT;function yae(){if(BT)return py;BT=1;var e=gae(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return py=n,py}var my,qT;function $4(){if(qT)return my;qT=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return my=n,my}var gy,UT;function wae(){if(UT)return gy;UT=1;var e=Ru(),t=yae(),n=ms(),s=$4(),r=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,d=i.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(m){if(!n(m)||t(m))return!1;var w=e(m)?f:o;return w.test(s(m))}return gy=p,gy}var yy,WT;function xae(){if(WT)return yy;WT=1;function e(t,n){return t==null?void 0:t[n]}return yy=e,yy}var wy,HT;function Xo(){if(HT)return wy;HT=1;var e=wae(),t=xae();function n(s,r){var o=t(s,r);return e(o)?o:void 0}return wy=n,wy}var xy,zT;function ij(){if(zT)return xy;zT=1;var e=Xo(),t=Us(),n=e(t,"Map");return xy=n,xy}var vy,VT;function up(){if(VT)return vy;VT=1;var e=Xo(),t=e(Object,"create");return vy=t,vy}var by,GT;function vae(){if(GT)return by;GT=1;var e=up();function t(){this.__data__=e?e(null):{},this.size=0}return by=t,by}var ky,KT;function bae(){if(KT)return ky;KT=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return ky=e,ky}var jy,YT;function kae(){if(YT)return jy;YT=1;var e=up(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function r(o){var i=this.__data__;if(e){var c=i[o];return c===t?void 0:c}return s.call(i,o)?i[o]:void 0}return jy=r,jy}var Ny,XT;function jae(){if(XT)return Ny;XT=1;var e=up(),t=Object.prototype,n=t.hasOwnProperty;function s(r){var o=this.__data__;return e?o[r]!==void 0:n.call(o,r)}return Ny=s,Ny}var Sy,ZT;function Nae(){if(ZT)return Sy;ZT=1;var e=up(),t="__lodash_hash_undefined__";function n(s,r){var o=this.__data__;return this.size+=this.has(s)?0:1,o[s]=e&&r===void 0?t:r,this}return Sy=n,Sy}var _y,JT;function Sae(){if(JT)return _y;JT=1;var e=vae(),t=bae(),n=kae(),s=jae(),r=Nae();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=r,_y=o,_y}var Ey,QT;function _ae(){if(QT)return Ey;QT=1;var e=Sae(),t=cp(),n=ij();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Ey=s,Ey}var Cy,eR;function Eae(){if(eR)return Cy;eR=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Cy=e,Cy}var Ty,tR;function dp(){if(tR)return Ty;tR=1;var e=Eae();function t(n,s){var r=n.__data__;return e(s)?r[typeof s=="string"?"string":"hash"]:r.map}return Ty=t,Ty}var Ry,nR;function Cae(){if(nR)return Ry;nR=1;var e=dp();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Ry=t,Ry}var Ay,sR;function Tae(){if(sR)return Ay;sR=1;var e=dp();function t(n){return e(this,n).get(n)}return Ay=t,Ay}var My,rR;function Rae(){if(rR)return My;rR=1;var e=dp();function t(n){return e(this,n).has(n)}return My=t,My}var $y,aR;function Aae(){if(aR)return $y;aR=1;var e=dp();function t(n,s){var r=e(this,n),o=r.size;return r.set(n,s),this.size+=r.size==o?0:1,this}return $y=t,$y}var Iy,oR;function lj(){if(oR)return Iy;oR=1;var e=_ae(),t=Cae(),n=Tae(),s=Rae(),r=Aae();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=r,Iy=o,Iy}var Ly,iR;function Mae(){if(iR)return Ly;iR=1;var e=cp(),t=ij(),n=lj(),s=200;function r(o,i){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<s-1)return d.push([o,i]),this.size=++c.size,this;c=this.__data__=new n(d)}return c.set(o,i),this.size=c.size,this}return Ly=r,Ly}var Oy,lR;function hp(){if(lR)return Oy;lR=1;var e=cp(),t=uae(),n=dae(),s=hae(),r=fae(),o=Mae();function i(c){var d=this.__data__=new e(c);this.size=d.size}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=s,i.prototype.has=r,i.prototype.set=o,Oy=i,Oy}var Py,cR;function cj(){if(cR)return Py;cR=1;function e(t,n){for(var s=-1,r=t==null?0:t.length;++s<r&&n(t[s],s,t)!==!1;);return t}return Py=e,Py}var Dy,uR;function I4(){if(uR)return Dy;uR=1;var e=Xo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Dy=t,Dy}var Fy,dR;function fp(){if(dR)return Fy;dR=1;var e=I4();function t(n,s,r){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):n[s]=r}return Fy=t,Fy}var By,hR;function pp(){if(hR)return By;hR=1;var e=fp(),t=wl(),n=Object.prototype,s=n.hasOwnProperty;function r(o,i,c){var d=o[i];(!(s.call(o,i)&&t(d,c))||c===void 0&&!(i in o))&&e(o,i,c)}return By=r,By}var qy,fR;function Au(){if(fR)return qy;fR=1;var e=pp(),t=fp();function n(s,r,o,i){var c=!o;o||(o={});for(var d=-1,h=r.length;++d<h;){var f=r[d],p=i?i(o[f],s[f],f,o,s):void 0;p===void 0&&(p=s[f]),c?t(o,f,p):e(o,f,p)}return o}return qy=n,qy}var Uy,pR;function $ae(){if(pR)return Uy;pR=1;function e(t,n){for(var s=-1,r=Array(t);++s<t;)r[s]=n(s);return r}return Uy=e,Uy}var Wy,mR;function gr(){if(mR)return Wy;mR=1;function e(t){return t!=null&&typeof t=="object"}return Wy=e,Wy}var Hy,gR;function Iae(){if(gR)return Hy;gR=1;var e=Yo(),t=gr(),n="[object Arguments]";function s(r){return t(r)&&e(r)==n}return Hy=s,Hy}var zy,yR;function Mu(){if(yR)return zy;yR=1;var e=Iae(),t=gr(),n=Object.prototype,s=n.hasOwnProperty,r=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!r.call(i,"callee")};return zy=o,zy}var Vy,wR;function Pt(){if(wR)return Vy;wR=1;var e=Array.isArray;return Vy=e,Vy}var Rc={exports:{}},Gy,xR;function Lae(){if(xR)return Gy;xR=1;function e(){return!1}return Gy=e,Gy}Rc.exports;var vR;function vl(){return vR||(vR=1,(function(e,t){var n=Us(),s=Lae(),r=t&&!t.nodeType&&t,o=r&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===r,c=i?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||s;e.exports=h})(Rc,Rc.exports)),Rc.exports}var Ky,bR;function mp(){if(bR)return Ky;bR=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,r){var o=typeof s;return r=r??e,!!r&&(o=="number"||o!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<r}return Ky=n,Ky}var Yy,kR;function uj(){if(kR)return Yy;kR=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Yy=t,Yy}var Xy,jR;function Oae(){if(jR)return Xy;jR=1;var e=Yo(),t=uj(),n=gr(),s="[object Arguments]",r="[object Array]",o="[object Boolean]",i="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",m="[object RegExp]",w="[object Set]",j="[object String]",b="[object WeakMap]",k="[object ArrayBuffer]",v="[object DataView]",N="[object Float32Array]",S="[object Float64Array]",E="[object Int8Array]",C="[object Int16Array]",I="[object Int32Array]",R="[object Uint8Array]",$="[object Uint8ClampedArray]",L="[object Uint16Array]",U="[object Uint32Array]",O={};O[N]=O[S]=O[E]=O[C]=O[I]=O[R]=O[$]=O[L]=O[U]=!0,O[s]=O[r]=O[k]=O[o]=O[v]=O[i]=O[c]=O[d]=O[h]=O[f]=O[p]=O[m]=O[w]=O[j]=O[b]=!1;function M(q){return n(q)&&t(q.length)&&!!O[e(q)]}return Xy=M,Xy}var Zy,NR;function gp(){if(NR)return Zy;NR=1;function e(t){return function(n){return t(n)}}return Zy=e,Zy}var Ac={exports:{}};Ac.exports;var SR;function dj(){return SR||(SR=1,(function(e,t){var n=M4(),s=t&&!t.nodeType&&t,r=s&&!0&&e&&!e.nodeType&&e,o=r&&r.exports===s,i=o&&n.process,c=(function(){try{var d=r&&r.require&&r.require("util").types;return d||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(Ac,Ac.exports)),Ac.exports}var Jy,_R;function $u(){if(_R)return Jy;_R=1;var e=Oae(),t=gp(),n=dj(),s=n&&n.isTypedArray,r=s?t(s):e;return Jy=r,Jy}var Qy,ER;function L4(){if(ER)return Qy;ER=1;var e=$ae(),t=Mu(),n=Pt(),s=vl(),r=mp(),o=$u(),i=Object.prototype,c=i.hasOwnProperty;function d(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),j=!p&&!m&&!w&&o(h),b=p||m||w||j,k=b?e(h.length,String):[],v=k.length;for(var N in h)(f||c.call(h,N))&&!(b&&(N=="length"||w&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||r(N,v)))&&k.push(N);return k}return Qy=d,Qy}var ew,CR;function yp(){if(CR)return ew;CR=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,r=typeof s=="function"&&s.prototype||e;return n===r}return ew=t,ew}var tw,TR;function O4(){if(TR)return tw;TR=1;function e(t,n){return function(s){return t(n(s))}}return tw=e,tw}var nw,RR;function Pae(){if(RR)return nw;RR=1;var e=O4(),t=e(Object.keys,Object);return nw=t,nw}var sw,AR;function hj(){if(AR)return sw;AR=1;var e=yp(),t=Pae(),n=Object.prototype,s=n.hasOwnProperty;function r(o){if(!e(o))return t(o);var i=[];for(var c in Object(o))s.call(o,c)&&c!="constructor"&&i.push(c);return i}return sw=r,sw}var rw,MR;function Xr(){if(MR)return rw;MR=1;var e=Ru(),t=uj();function n(s){return s!=null&&t(s.length)&&!e(s)}return rw=n,rw}var aw,$R;function Ka(){if($R)return aw;$R=1;var e=L4(),t=hj(),n=Xr();function s(r){return n(r)?e(r):t(r)}return aw=s,aw}var ow,IR;function Dae(){if(IR)return ow;IR=1;var e=Au(),t=Ka();function n(s,r){return s&&e(r,t(r),s)}return ow=n,ow}var iw,LR;function Fae(){if(LR)return iw;LR=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return iw=e,iw}var lw,OR;function Bae(){if(OR)return lw;OR=1;var e=ms(),t=yp(),n=Fae(),s=Object.prototype,r=s.hasOwnProperty;function o(i){if(!e(i))return n(i);var c=t(i),d=[];for(var h in i)h=="constructor"&&(c||!r.call(i,h))||d.push(h);return d}return lw=o,lw}var cw,PR;function Zo(){if(PR)return cw;PR=1;var e=L4(),t=Bae(),n=Xr();function s(r){return n(r)?e(r,!0):t(r)}return cw=s,cw}var uw,DR;function qae(){if(DR)return uw;DR=1;var e=Au(),t=Zo();function n(s,r){return s&&e(r,t(r),s)}return uw=n,uw}var Mc={exports:{}};Mc.exports;var FR;function P4(){return FR||(FR=1,(function(e,t){var n=Us(),s=t&&!t.nodeType&&t,r=s&&!0&&e&&!e.nodeType&&e,o=r&&r.exports===s,i=o?n.Buffer:void 0,c=i?i.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,m=c?c(p):new h.constructor(p);return h.copy(m),m}e.exports=d})(Mc,Mc.exports)),Mc.exports}var dw,BR;function D4(){if(BR)return dw;BR=1;function e(t,n){var s=-1,r=t.length;for(n||(n=Array(r));++s<r;)n[s]=t[s];return n}return dw=e,dw}var hw,qR;function F4(){if(qR)return hw;qR=1;function e(t,n){for(var s=-1,r=t==null?0:t.length,o=0,i=[];++s<r;){var c=t[s];n(c,s,t)&&(i[o++]=c)}return i}return hw=e,hw}var fw,UR;function B4(){if(UR)return fw;UR=1;function e(){return[]}return fw=e,fw}var pw,WR;function fj(){if(WR)return pw;WR=1;var e=F4(),t=B4(),n=Object.prototype,s=n.propertyIsEnumerable,r=Object.getOwnPropertySymbols,o=r?function(i){return i==null?[]:(i=Object(i),e(r(i),function(c){return s.call(i,c)}))}:t;return pw=o,pw}var mw,HR;function Uae(){if(HR)return mw;HR=1;var e=Au(),t=fj();function n(s,r){return e(s,t(s),r)}return mw=n,mw}var gw,zR;function pj(){if(zR)return gw;zR=1;function e(t,n){for(var s=-1,r=n.length,o=t.length;++s<r;)t[o+s]=n[s];return t}return gw=e,gw}var yw,VR;function wp(){if(VR)return yw;VR=1;var e=O4(),t=e(Object.getPrototypeOf,Object);return yw=t,yw}var ww,GR;function q4(){if(GR)return ww;GR=1;var e=pj(),t=wp(),n=fj(),s=B4(),r=Object.getOwnPropertySymbols,o=r?function(i){for(var c=[];i;)e(c,n(i)),i=t(i);return c}:s;return ww=o,ww}var xw,KR;function Wae(){if(KR)return xw;KR=1;var e=Au(),t=q4();function n(s,r){return e(s,t(s),r)}return xw=n,xw}var vw,YR;function U4(){if(YR)return vw;YR=1;var e=pj(),t=Pt();function n(s,r,o){var i=r(s);return t(s)?i:e(i,o(s))}return vw=n,vw}var bw,XR;function W4(){if(XR)return bw;XR=1;var e=U4(),t=fj(),n=Ka();function s(r){return e(r,n,t)}return bw=s,bw}var kw,ZR;function Hae(){if(ZR)return kw;ZR=1;var e=U4(),t=q4(),n=Zo();function s(r){return e(r,n,t)}return kw=s,kw}var jw,JR;function zae(){if(JR)return jw;JR=1;var e=Xo(),t=Us(),n=e(t,"DataView");return jw=n,jw}var Nw,QR;function Vae(){if(QR)return Nw;QR=1;var e=Xo(),t=Us(),n=e(t,"Promise");return Nw=n,Nw}var Sw,eA;function H4(){if(eA)return Sw;eA=1;var e=Xo(),t=Us(),n=e(t,"Set");return Sw=n,Sw}var _w,tA;function Gae(){if(tA)return _w;tA=1;var e=Xo(),t=Us(),n=e(t,"WeakMap");return _w=n,_w}var Ew,nA;function bl(){if(nA)return Ew;nA=1;var e=zae(),t=ij(),n=Vae(),s=H4(),r=Gae(),o=Yo(),i=$4(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),j=i(t),b=i(n),k=i(s),v=i(r),N=o;return(e&&N(new e(new ArrayBuffer(1)))!=m||t&&N(new t)!=c||n&&N(n.resolve())!=h||s&&N(new s)!=f||r&&N(new r)!=p)&&(N=function(S){var E=o(S),C=E==d?S.constructor:void 0,I=C?i(C):"";if(I)switch(I){case w:return m;case j:return c;case b:return h;case k:return f;case v:return p}return E}),Ew=N,Ew}var Cw,sA;function Kae(){if(sA)return Cw;sA=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var r=s.length,o=new s.constructor(r);return r&&typeof s[0]=="string"&&t.call(s,"index")&&(o.index=s.index,o.input=s.input),o}return Cw=n,Cw}var Tw,rA;function z4(){if(rA)return Tw;rA=1;var e=Us(),t=e.Uint8Array;return Tw=t,Tw}var Rw,aA;function mj(){if(aA)return Rw;aA=1;var e=z4();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Rw=t,Rw}var Aw,oA;function Yae(){if(oA)return Aw;oA=1;var e=mj();function t(n,s){var r=s?e(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.byteLength)}return Aw=t,Aw}var Mw,iA;function Xae(){if(iA)return Mw;iA=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Mw=t,Mw}var $w,lA;function Zae(){if(lA)return $w;lA=1;var e=xl(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(r){return n?Object(n.call(r)):{}}return $w=s,$w}var Iw,cA;function V4(){if(cA)return Iw;cA=1;var e=mj();function t(n,s){var r=s?e(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.length)}return Iw=t,Iw}var Lw,uA;function Jae(){if(uA)return Lw;uA=1;var e=mj(),t=Yae(),n=Xae(),s=Zae(),r=V4(),o="[object Boolean]",i="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",m="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",k="[object Float64Array]",v="[object Int8Array]",N="[object Int16Array]",S="[object Int32Array]",E="[object Uint8Array]",C="[object Uint8ClampedArray]",I="[object Uint16Array]",R="[object Uint32Array]";function $(L,U,O){var M=L.constructor;switch(U){case w:return e(L);case o:case i:return new M(+L);case j:return t(L,O);case b:case k:case v:case N:case S:case E:case C:case I:case R:return r(L,O);case c:return new M;case d:case p:return new M(L);case h:return n(L);case f:return new M;case m:return s(L)}}return Lw=$,Lw}var Ow,dA;function G4(){if(dA)return Ow;dA=1;var e=ms(),t=Object.create,n=(function(){function s(){}return function(r){if(!e(r))return{};if(t)return t(r);s.prototype=r;var o=new s;return s.prototype=void 0,o}})();return Ow=n,Ow}var Pw,hA;function K4(){if(hA)return Pw;hA=1;var e=G4(),t=wp(),n=yp();function s(r){return typeof r.constructor=="function"&&!n(r)?e(t(r)):{}}return Pw=s,Pw}var Dw,fA;function Qae(){if(fA)return Dw;fA=1;var e=bl(),t=gr(),n="[object Map]";function s(r){return t(r)&&e(r)==n}return Dw=s,Dw}var Fw,pA;function eoe(){if(pA)return Fw;pA=1;var e=Qae(),t=gp(),n=dj(),s=n&&n.isMap,r=s?t(s):e;return Fw=r,Fw}var Bw,mA;function toe(){if(mA)return Bw;mA=1;var e=bl(),t=gr(),n="[object Set]";function s(r){return t(r)&&e(r)==n}return Bw=s,Bw}var qw,gA;function noe(){if(gA)return qw;gA=1;var e=toe(),t=gp(),n=dj(),s=n&&n.isSet,r=s?t(s):e;return qw=r,qw}var Uw,yA;function Y4(){if(yA)return Uw;yA=1;var e=hp(),t=cj(),n=pp(),s=Dae(),r=qae(),o=P4(),i=D4(),c=Uae(),d=Wae(),h=W4(),f=Hae(),p=bl(),m=Kae(),w=Jae(),j=K4(),b=Pt(),k=vl(),v=eoe(),N=ms(),S=noe(),E=Ka(),C=Zo(),I=1,R=2,$=4,L="[object Arguments]",U="[object Array]",O="[object Boolean]",M="[object Date]",q="[object Error]",A="[object Function]",D="[object GeneratorFunction]",P="[object Map]",K="[object Number]",G="[object Object]",W="[object RegExp]",H="[object Set]",F="[object String]",B="[object Symbol]",Z="[object WeakMap]",V="[object ArrayBuffer]",X="[object DataView]",Y="[object Float32Array]",J="[object Float64Array]",ee="[object Int8Array]",ne="[object Int16Array]",le="[object Int32Array]",de="[object Uint8Array]",ue="[object Uint8ClampedArray]",re="[object Uint16Array]",pe="[object Uint32Array]",ye={};ye[L]=ye[U]=ye[V]=ye[X]=ye[O]=ye[M]=ye[Y]=ye[J]=ye[ee]=ye[ne]=ye[le]=ye[P]=ye[K]=ye[G]=ye[W]=ye[H]=ye[F]=ye[B]=ye[de]=ye[ue]=ye[re]=ye[pe]=!0,ye[q]=ye[A]=ye[Z]=!1;function _e(he,ae,ge,Se,me,$e){var Pe,qe=ae&I,Le=ae&R,Qe=ae&$;if(ge&&(Pe=me?ge(he,Se,me,$e):ge(he)),Pe!==void 0)return Pe;if(!N(he))return he;var je=b(he);if(je){if(Pe=m(he),!qe)return i(he,Pe)}else{var Ae=p(he),De=Ae==A||Ae==D;if(k(he))return o(he,qe);if(Ae==G||Ae==L||De&&!me){if(Pe=Le||De?{}:j(he),!qe)return Le?d(he,r(Pe,he)):c(he,s(Pe,he))}else{if(!ye[Ae])return me?he:{};Pe=w(he,Ae,qe)}}$e||($e=new e);var He=$e.get(he);if(He)return He;$e.set(he,Pe),S(he)?he.forEach(function(ut){Pe.add(_e(ut,ae,ge,ut,he,$e))}):v(he)&&he.forEach(function(ut,Je){Pe.set(Je,_e(ut,ae,ge,Je,he,$e))});var Ze=Qe?Le?f:h:Le?C:E,ft=je?void 0:Ze(he);return t(ft||he,function(ut,Je){ft&&(Je=ut,ut=he[Je]),n(Pe,Je,_e(ut,ae,ge,Je,he,$e))}),Pe}return Uw=_e,Uw}var Ww,wA;function soe(){if(wA)return Ww;wA=1;var e=Y4(),t=4;function n(s){return e(s,t)}return Ww=n,Ww}var Hw,xA;function gj(){if(xA)return Hw;xA=1;function e(t){return function(){return t}}return Hw=e,Hw}var zw,vA;function roe(){if(vA)return zw;vA=1;function e(t){return function(n,s,r){for(var o=-1,i=Object(n),c=r(n),d=c.length;d--;){var h=c[t?d:++o];if(s(i[h],h,i)===!1)break}return n}}return zw=e,zw}var Vw,bA;function yj(){if(bA)return Vw;bA=1;var e=roe(),t=e();return Vw=t,Vw}var Gw,kA;function wj(){if(kA)return Gw;kA=1;var e=yj(),t=Ka();function n(s,r){return s&&e(s,r,t)}return Gw=n,Gw}var Kw,jA;function aoe(){if(jA)return Kw;jA=1;var e=Xr();function t(n,s){return function(r,o){if(r==null)return r;if(!e(r))return n(r,o);for(var i=r.length,c=s?i:-1,d=Object(r);(s?c--:++c<i)&&o(d[c],c,d)!==!1;);return r}}return Kw=t,Kw}var Yw,NA;function xp(){if(NA)return Yw;NA=1;var e=wj(),t=aoe(),n=t(e);return Yw=n,Yw}var Xw,SA;function Jo(){if(SA)return Xw;SA=1;function e(t){return t}return Xw=e,Xw}var Zw,_A;function X4(){if(_A)return Zw;_A=1;var e=Jo();function t(n){return typeof n=="function"?n:e}return Zw=t,Zw}var Jw,EA;function Z4(){if(EA)return Jw;EA=1;var e=cj(),t=xp(),n=X4(),s=Pt();function r(o,i){var c=s(o)?e:t;return c(o,n(i))}return Jw=r,Jw}var Qw,CA;function J4(){return CA||(CA=1,Qw=Z4()),Qw}var ex,TA;function ooe(){if(TA)return ex;TA=1;var e=xp();function t(n,s){var r=[];return e(n,function(o,i,c){s(o,i,c)&&r.push(o)}),r}return ex=t,ex}var tx,RA;function ioe(){if(RA)return tx;RA=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return tx=t,tx}var nx,AA;function loe(){if(AA)return nx;AA=1;function e(t){return this.__data__.has(t)}return nx=e,nx}var sx,MA;function Q4(){if(MA)return sx;MA=1;var e=lj(),t=ioe(),n=loe();function s(r){var o=-1,i=r==null?0:r.length;for(this.__data__=new e;++o<i;)this.add(r[o])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,sx=s,sx}var rx,$A;function coe(){if($A)return rx;$A=1;function e(t,n){for(var s=-1,r=t==null?0:t.length;++s<r;)if(n(t[s],s,t))return!0;return!1}return rx=e,rx}var ax,IA;function eD(){if(IA)return ax;IA=1;function e(t,n){return t.has(n)}return ax=e,ax}var ox,LA;function tD(){if(LA)return ox;LA=1;var e=Q4(),t=coe(),n=eD(),s=1,r=2;function o(i,c,d,h,f,p){var m=d&s,w=i.length,j=c.length;if(w!=j&&!(m&&j>w))return!1;var b=p.get(i),k=p.get(c);if(b&&k)return b==c&&k==i;var v=-1,N=!0,S=d&r?new e:void 0;for(p.set(i,c),p.set(c,i);++v<w;){var E=i[v],C=c[v];if(h)var I=m?h(C,E,v,c,i,p):h(E,C,v,i,c,p);if(I!==void 0){if(I)continue;N=!1;break}if(S){if(!t(c,function(R,$){if(!n(S,$)&&(E===R||f(E,R,d,h,p)))return S.push($)})){N=!1;break}}else if(!(E===C||f(E,C,d,h,p))){N=!1;break}}return p.delete(i),p.delete(c),N}return ox=o,ox}var ix,OA;function uoe(){if(OA)return ix;OA=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r,o){s[++n]=[o,r]}),s}return ix=e,ix}var lx,PA;function xj(){if(PA)return lx;PA=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r){s[++n]=r}),s}return lx=e,lx}var cx,DA;function doe(){if(DA)return cx;DA=1;var e=xl(),t=z4(),n=wl(),s=tD(),r=uoe(),o=xj(),i=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",j="[object Set]",b="[object String]",k="[object Symbol]",v="[object ArrayBuffer]",N="[object DataView]",S=e?e.prototype:void 0,E=S?S.valueOf:void 0;function C(I,R,$,L,U,O,M){switch($){case N:if(I.byteLength!=R.byteLength||I.byteOffset!=R.byteOffset)return!1;I=I.buffer,R=R.buffer;case v:return!(I.byteLength!=R.byteLength||!O(new t(I),new t(R)));case d:case h:case m:return n(+I,+R);case f:return I.name==R.name&&I.message==R.message;case w:case b:return I==R+"";case p:var q=r;case j:var A=L&i;if(q||(q=o),I.size!=R.size&&!A)return!1;var D=M.get(I);if(D)return D==R;L|=c,M.set(I,R);var P=s(q(I),q(R),L,U,O,M);return M.delete(I),P;case k:if(E)return E.call(I)==E.call(R)}return!1}return cx=C,cx}var ux,FA;function hoe(){if(FA)return ux;FA=1;var e=W4(),t=1,n=Object.prototype,s=n.hasOwnProperty;function r(o,i,c,d,h,f){var p=c&t,m=e(o),w=m.length,j=e(i),b=j.length;if(w!=b&&!p)return!1;for(var k=w;k--;){var v=m[k];if(!(p?v in i:s.call(i,v)))return!1}var N=f.get(o),S=f.get(i);if(N&&S)return N==i&&S==o;var E=!0;f.set(o,i),f.set(i,o);for(var C=p;++k<w;){v=m[k];var I=o[v],R=i[v];if(d)var $=p?d(R,I,v,i,o,f):d(I,R,v,o,i,f);if(!($===void 0?I===R||h(I,R,c,d,f):$)){E=!1;break}C||(C=v=="constructor")}if(E&&!C){var L=o.constructor,U=i.constructor;L!=U&&"constructor"in o&&"constructor"in i&&!(typeof L=="function"&&L instanceof L&&typeof U=="function"&&U instanceof U)&&(E=!1)}return f.delete(o),f.delete(i),E}return ux=r,ux}var dx,BA;function foe(){if(BA)return dx;BA=1;var e=hp(),t=tD(),n=doe(),s=hoe(),r=bl(),o=Pt(),i=vl(),c=$u(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function j(b,k,v,N,S,E){var C=o(b),I=o(k),R=C?f:r(b),$=I?f:r(k);R=R==h?p:R,$=$==h?p:$;var L=R==p,U=$==p,O=R==$;if(O&&i(b)){if(!i(k))return!1;C=!0,L=!1}if(O&&!L)return E||(E=new e),C||c(b)?t(b,k,v,N,S,E):n(b,k,R,v,N,S,E);if(!(v&d)){var M=L&&w.call(b,"__wrapped__"),q=U&&w.call(k,"__wrapped__");if(M||q){var A=M?b.value():b,D=q?k.value():k;return E||(E=new e),S(A,D,v,N,E)}}return O?(E||(E=new e),s(b,k,v,N,S,E)):!1}return dx=j,dx}var hx,qA;function nD(){if(qA)return hx;qA=1;var e=foe(),t=gr();function n(s,r,o,i,c){return s===r?!0:s==null||r==null||!t(s)&&!t(r)?s!==s&&r!==r:e(s,r,o,i,n,c)}return hx=n,hx}var fx,UA;function poe(){if(UA)return fx;UA=1;var e=hp(),t=nD(),n=1,s=2;function r(o,i,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var m=c[h];if(p&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++h<f;){m=c[h];var w=m[0],j=o[w],b=m[1];if(p&&m[2]){if(j===void 0&&!(w in o))return!1}else{var k=new e;if(d)var v=d(j,b,w,o,i,k);if(!(v===void 0?t(b,j,n|s,d,k):v))return!1}}return!0}return fx=r,fx}var px,WA;function sD(){if(WA)return px;WA=1;var e=ms();function t(n){return n===n&&!e(n)}return px=t,px}var mx,HA;function moe(){if(HA)return mx;HA=1;var e=sD(),t=Ka();function n(s){for(var r=t(s),o=r.length;o--;){var i=r[o],c=s[i];r[o]=[i,c,e(c)]}return r}return mx=n,mx}var gx,zA;function rD(){if(zA)return gx;zA=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return gx=e,gx}var yx,VA;function goe(){if(VA)return yx;VA=1;var e=poe(),t=moe(),n=rD();function s(r){var o=t(r);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(i){return i===r||e(i,r,o)}}return yx=s,yx}var wx,GA;function kl(){if(GA)return wx;GA=1;var e=Yo(),t=gr(),n="[object Symbol]";function s(r){return typeof r=="symbol"||t(r)&&e(r)==n}return wx=s,wx}var xx,KA;function vj(){if(KA)return xx;KA=1;var e=Pt(),t=kl(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function r(o,i){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:s.test(o)||!n.test(o)||i!=null&&o in Object(i)}return xx=r,xx}var vx,YA;function yoe(){if(YA)return vx;YA=1;var e=lj(),t="Expected a function";function n(s,r){if(typeof s!="function"||r!=null&&typeof r!="function")throw new TypeError(t);var o=function(){var i=arguments,c=r?r.apply(this,i):i[0],d=o.cache;if(d.has(c))return d.get(c);var h=s.apply(this,i);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,vx=n,vx}var bx,XA;function woe(){if(XA)return bx;XA=1;var e=yoe(),t=500;function n(s){var r=e(s,function(i){return o.size===t&&o.clear(),i}),o=r.cache;return r}return bx=n,bx}var kx,ZA;function xoe(){if(ZA)return kx;ZA=1;var e=woe(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(r){var o=[];return r.charCodeAt(0)===46&&o.push(""),r.replace(t,function(i,c,d,h){o.push(d?h.replace(n,"$1"):c||i)}),o});return kx=s,kx}var jx,JA;function vp(){if(JA)return jx;JA=1;function e(t,n){for(var s=-1,r=t==null?0:t.length,o=Array(r);++s<r;)o[s]=n(t[s],s,t);return o}return jx=e,jx}var Nx,QA;function voe(){if(QA)return Nx;QA=1;var e=xl(),t=vp(),n=Pt(),s=kl(),r=e?e.prototype:void 0,o=r?r.toString:void 0;function i(c){if(typeof c=="string")return c;if(n(c))return t(c,i)+"";if(s(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return Nx=i,Nx}var Sx,e2;function aD(){if(e2)return Sx;e2=1;var e=voe();function t(n){return n==null?"":e(n)}return Sx=t,Sx}var _x,t2;function bp(){if(t2)return _x;t2=1;var e=Pt(),t=vj(),n=xoe(),s=aD();function r(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return _x=r,_x}var Ex,n2;function Iu(){if(n2)return Ex;n2=1;var e=kl();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return Ex=t,Ex}var Cx,s2;function kp(){if(s2)return Cx;s2=1;var e=bp(),t=Iu();function n(s,r){r=e(r,s);for(var o=0,i=r.length;s!=null&&o<i;)s=s[t(r[o++])];return o&&o==i?s:void 0}return Cx=n,Cx}var Tx,r2;function boe(){if(r2)return Tx;r2=1;var e=kp();function t(n,s,r){var o=n==null?void 0:e(n,s);return o===void 0?r:o}return Tx=t,Tx}var Rx,a2;function koe(){if(a2)return Rx;a2=1;function e(t,n){return t!=null&&n in Object(t)}return Rx=e,Rx}var Ax,o2;function oD(){if(o2)return Ax;o2=1;var e=bp(),t=Mu(),n=Pt(),s=mp(),r=uj(),o=Iu();function i(c,d,h){d=e(d,c);for(var f=-1,p=d.length,m=!1;++f<p;){var w=o(d[f]);if(!(m=c!=null&&h(c,w)))break;c=c[w]}return m||++f!=p?m:(p=c==null?0:c.length,!!p&&r(p)&&s(w,p)&&(n(c)||t(c)))}return Ax=i,Ax}var Mx,i2;function iD(){if(i2)return Mx;i2=1;var e=koe(),t=oD();function n(s,r){return s!=null&&t(s,r,e)}return Mx=n,Mx}var $x,l2;function joe(){if(l2)return $x;l2=1;var e=nD(),t=boe(),n=iD(),s=vj(),r=sD(),o=rD(),i=Iu(),c=1,d=2;function h(f,p){return s(f)&&r(p)?o(i(f),p):function(m){var w=t(m,f);return w===void 0&&w===p?n(m,f):e(p,w,c|d)}}return $x=h,$x}var Ix,c2;function lD(){if(c2)return Ix;c2=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Ix=e,Ix}var Lx,u2;function Noe(){if(u2)return Lx;u2=1;var e=kp();function t(n){return function(s){return e(s,n)}}return Lx=t,Lx}var Ox,d2;function Soe(){if(d2)return Ox;d2=1;var e=lD(),t=Noe(),n=vj(),s=Iu();function r(o){return n(o)?e(s(o)):t(o)}return Ox=r,Ox}var Px,h2;function Zr(){if(h2)return Px;h2=1;var e=goe(),t=joe(),n=Jo(),s=Pt(),r=Soe();function o(i){return typeof i=="function"?i:i==null?n:typeof i=="object"?s(i)?t(i[0],i[1]):e(i):r(i)}return Px=o,Px}var Dx,f2;function cD(){if(f2)return Dx;f2=1;var e=F4(),t=ooe(),n=Zr(),s=Pt();function r(o,i){var c=s(o)?e:t;return c(o,n(i,3))}return Dx=r,Dx}var Fx,p2;function _oe(){if(p2)return Fx;p2=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,r){return s!=null&&t.call(s,r)}return Fx=n,Fx}var Bx,m2;function uD(){if(m2)return Bx;m2=1;var e=_oe(),t=oD();function n(s,r){return s!=null&&t(s,r,e)}return Bx=n,Bx}var qx,g2;function Eoe(){if(g2)return qx;g2=1;var e=hj(),t=bl(),n=Mu(),s=Pt(),r=Xr(),o=vl(),i=yp(),c=$u(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function m(w){if(w==null)return!0;if(r(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||o(w)||c(w)||n(w)))return!w.length;var j=t(w);if(j==d||j==h)return!w.size;if(i(w))return!e(w).length;for(var b in w)if(p.call(w,b))return!1;return!0}return qx=m,qx}var Ux,y2;function dD(){if(y2)return Ux;y2=1;function e(t){return t===void 0}return Ux=e,Ux}var Wx,w2;function hD(){if(w2)return Wx;w2=1;var e=xp(),t=Xr();function n(s,r){var o=-1,i=t(s)?Array(s.length):[];return e(s,function(c,d,h){i[++o]=r(c,d,h)}),i}return Wx=n,Wx}var Hx,x2;function fD(){if(x2)return Hx;x2=1;var e=vp(),t=Zr(),n=hD(),s=Pt();function r(o,i){var c=s(o)?e:n;return c(o,t(i,3))}return Hx=r,Hx}var zx,v2;function Coe(){if(v2)return zx;v2=1;function e(t,n,s,r){var o=-1,i=t==null?0:t.length;for(r&&i&&(s=t[++o]);++o<i;)s=n(s,t[o],o,t);return s}return zx=e,zx}var Vx,b2;function Toe(){if(b2)return Vx;b2=1;function e(t,n,s,r,o){return o(t,function(i,c,d){s=r?(r=!1,i):n(s,i,c,d)}),s}return Vx=e,Vx}var Gx,k2;function pD(){if(k2)return Gx;k2=1;var e=Coe(),t=xp(),n=Zr(),s=Toe(),r=Pt();function o(i,c,d){var h=r(i)?e:s,f=arguments.length<3;return h(i,n(c,4),d,f,t)}return Gx=o,Gx}var Kx,j2;function Roe(){if(j2)return Kx;j2=1;var e=Yo(),t=Pt(),n=gr(),s="[object String]";function r(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return Kx=r,Kx}var Yx,N2;function Aoe(){if(N2)return Yx;N2=1;var e=lD(),t=e("length");return Yx=t,Yx}var Xx,S2;function Moe(){if(S2)return Xx;S2=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",r=t+n+s,o="\\ufe0e\\ufe0f",i="\\u200d",c=RegExp("["+i+e+r+o+"]");function d(h){return c.test(h)}return Xx=d,Xx}var Zx,_2;function $oe(){if(_2)return Zx;_2=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",r=t+n+s,o="\\ufe0e\\ufe0f",i="["+e+"]",c="["+r+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",b="["+o+"]?",k="(?:"+w+"(?:"+[f,p,m].join("|")+")"+b+j+")*",v=b+j+k,N="(?:"+[f+c+"?",c,p,m,i].join("|")+")",S=RegExp(d+"(?="+d+")|"+N+v,"g");function E(C){for(var I=S.lastIndex=0;S.test(C);)++I;return I}return Zx=E,Zx}var Jx,E2;function Ioe(){if(E2)return Jx;E2=1;var e=Aoe(),t=Moe(),n=$oe();function s(r){return t(r)?n(r):e(r)}return Jx=s,Jx}var Qx,C2;function Loe(){if(C2)return Qx;C2=1;var e=hj(),t=bl(),n=Xr(),s=Roe(),r=Ioe(),o="[object Map]",i="[object Set]";function c(d){if(d==null)return 0;if(n(d))return s(d)?r(d):d.length;var h=t(d);return h==o||h==i?d.size:e(d).length}return Qx=c,Qx}var ev,T2;function Ooe(){if(T2)return ev;T2=1;var e=cj(),t=G4(),n=wj(),s=Zr(),r=wp(),o=Pt(),i=vl(),c=Ru(),d=ms(),h=$u();function f(p,m,w){var j=o(p),b=j||i(p)||h(p);if(m=s(m,4),w==null){var k=p&&p.constructor;b?w=j?new k:[]:d(p)?w=c(k)?t(r(p)):{}:w={}}return(b?e:n)(p,function(v,N,S){return m(w,v,N,S)}),w}return ev=f,ev}var tv,R2;function Poe(){if(R2)return tv;R2=1;var e=xl(),t=Mu(),n=Pt(),s=e?e.isConcatSpreadable:void 0;function r(o){return n(o)||t(o)||!!(s&&o&&o[s])}return tv=r,tv}var nv,A2;function bj(){if(A2)return nv;A2=1;var e=pj(),t=Poe();function n(s,r,o,i,c){var d=-1,h=s.length;for(o||(o=t),c||(c=[]);++d<h;){var f=s[d];r>0&&o(f)?r>1?n(f,r-1,o,i,c):e(c,f):i||(c[c.length]=f)}return c}return nv=n,nv}var sv,M2;function Doe(){if(M2)return sv;M2=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return sv=e,sv}var rv,$2;function mD(){if($2)return rv;$2=1;var e=Doe(),t=Math.max;function n(s,r,o){return r=t(r===void 0?s.length-1:r,0),function(){for(var i=arguments,c=-1,d=t(i.length-r,0),h=Array(d);++c<d;)h[c]=i[r+c];c=-1;for(var f=Array(r+1);++c<r;)f[c]=i[c];return f[r]=o(h),e(s,this,f)}}return rv=n,rv}var av,I2;function Foe(){if(I2)return av;I2=1;var e=gj(),t=I4(),n=Jo(),s=t?function(r,o){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return av=s,av}var ov,L2;function Boe(){if(L2)return ov;L2=1;var e=800,t=16,n=Date.now;function s(r){var o=0,i=0;return function(){var c=n(),d=t-(c-i);if(i=c,d>0){if(++o>=e)return arguments[0]}else o=0;return r.apply(void 0,arguments)}}return ov=s,ov}var iv,O2;function gD(){if(O2)return iv;O2=1;var e=Foe(),t=Boe(),n=t(e);return iv=n,iv}var lv,P2;function jp(){if(P2)return lv;P2=1;var e=Jo(),t=mD(),n=gD();function s(r,o){return n(t(r,o,e),r+"")}return lv=s,lv}var cv,D2;function yD(){if(D2)return cv;D2=1;function e(t,n,s,r){for(var o=t.length,i=s+(r?1:-1);r?i--:++i<o;)if(n(t[i],i,t))return i;return-1}return cv=e,cv}var uv,F2;function qoe(){if(F2)return uv;F2=1;function e(t){return t!==t}return uv=e,uv}var dv,B2;function Uoe(){if(B2)return dv;B2=1;function e(t,n,s){for(var r=s-1,o=t.length;++r<o;)if(t[r]===n)return r;return-1}return dv=e,dv}var hv,q2;function Woe(){if(q2)return hv;q2=1;var e=yD(),t=qoe(),n=Uoe();function s(r,o,i){return o===o?n(r,o,i):e(r,t,i)}return hv=s,hv}var fv,U2;function Hoe(){if(U2)return fv;U2=1;var e=Woe();function t(n,s){var r=n==null?0:n.length;return!!r&&e(n,s,0)>-1}return fv=t,fv}var pv,W2;function zoe(){if(W2)return pv;W2=1;function e(t,n,s){for(var r=-1,o=t==null?0:t.length;++r<o;)if(s(n,t[r]))return!0;return!1}return pv=e,pv}var mv,H2;function Voe(){if(H2)return mv;H2=1;function e(){}return mv=e,mv}var gv,z2;function Goe(){if(z2)return gv;z2=1;var e=H4(),t=Voe(),n=xj(),s=1/0,r=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return gv=r,gv}var yv,V2;function Koe(){if(V2)return yv;V2=1;var e=Q4(),t=Hoe(),n=zoe(),s=eD(),r=Goe(),o=xj(),i=200;function c(d,h,f){var p=-1,m=t,w=d.length,j=!0,b=[],k=b;if(f)j=!1,m=n;else if(w>=i){var v=h?null:r(d);if(v)return o(v);j=!1,m=s,k=new e}else k=h?[]:b;e:for(;++p<w;){var N=d[p],S=h?h(N):N;if(N=f||N!==0?N:0,j&&S===S){for(var E=k.length;E--;)if(k[E]===S)continue e;h&&k.push(S),b.push(N)}else m(k,S,f)||(k!==b&&k.push(S),b.push(N))}return b}return yv=c,yv}var wv,G2;function wD(){if(G2)return wv;G2=1;var e=Xr(),t=gr();function n(s){return t(s)&&e(s)}return wv=n,wv}var xv,K2;function Yoe(){if(K2)return xv;K2=1;var e=bj(),t=jp(),n=Koe(),s=wD(),r=t(function(o){return n(e(o,1,s,!0))});return xv=r,xv}var vv,Y2;function Xoe(){if(Y2)return vv;Y2=1;var e=vp();function t(n,s){return e(s,function(r){return n[r]})}return vv=t,vv}var bv,X2;function xD(){if(X2)return bv;X2=1;var e=Xoe(),t=Ka();function n(s){return s==null?[]:e(s,t(s))}return bv=n,bv}var kv,Z2;function gs(){if(Z2)return kv;Z2=1;var e;if(typeof oj=="function")try{e={clone:soe(),constant:gj(),each:J4(),filter:cD(),has:uD(),isArray:Pt(),isEmpty:Eoe(),isFunction:Ru(),isUndefined:dD(),keys:Ka(),map:fD(),reduce:pD(),size:Loe(),transform:Ooe(),union:Yoe(),values:xD()}}catch{}return e||(e=window._),kv=e,kv}var jv,J2;function kj(){if(J2)return jv;J2=1;var e=gs();jv=r;var t="\0",n="\0",s="";function r(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={}}r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(f){return this._label=f,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return e.keys(this._nodes)},r.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},r.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},r.prototype.setNodes=function(f,p){var m=arguments,w=this;return e.each(f,function(j){m.length>1?w.setNode(j,p):w.setNode(j)}),this},r.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)},r.prototype.node=function(f){return this._nodes[f]},r.prototype.hasNode=function(f){return e.has(this._nodes,f)},r.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var m=function(w){p.removeEdge(p._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){p.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),m),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),m),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},r.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 m=p;!e.isUndefined(m);m=this.parent(m))if(m===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},r.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},r.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},r.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[]}},r.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},r.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},r.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},r.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},r.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var m=this;e.each(this._nodes,function(b,k){f(k)&&p.setNode(k,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,m.edge(b))});var w={};function j(b){var k=m.parent(b);return k===void 0||p.hasNode(k)?(w[b]=k,k):k in w?w[k]:j(k)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,j(b))}),p},r.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return e.values(this._edgeObjs)},r.prototype.setPath=function(f,p){var m=this,w=arguments;return e.reduce(f,function(j,b){return w.length>1?m.setEdge(j,b,p):m.setEdge(j,b),b}),this},r.prototype.setEdge=function(){var f,p,m,w,j=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,p=b.w,m=b.name,arguments.length===2&&(w=arguments[1],j=!0)):(f=b,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var k=c(this._isDirected,f,p,m);if(e.has(this._edgeLabels,k))return j&&(this._edgeLabels[k]=w),this;if(!e.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[k]=j?w:this._defaultEdgeLabelFn(f,p,m);var v=d(this._isDirected,f,p,m);return f=v.v,p=v.w,Object.freeze(v),this._edgeObjs[k]=v,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][k]=v,this._out[f][k]=v,this._edgeCount++,this},r.prototype.edge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m);return this._edgeLabels[w]},r.prototype.hasEdge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m);return e.has(this._edgeLabels,w)},r.prototype.removeEdge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m),j=this._edgeObjs[w];return j&&(f=j.v,p=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],i(this._preds[p],f),i(this._sucs[f],p),delete this._in[p][w],delete this._out[f][w],this._edgeCount--),this},r.prototype.inEdges=function(f,p){var m=this._in[f];if(m){var w=e.values(m);return p?e.filter(w,function(j){return j.v===p}):w}},r.prototype.outEdges=function(f,p){var m=this._out[f];if(m){var w=e.values(m);return p?e.filter(w,function(j){return j.w===p}):w}},r.prototype.nodeEdges=function(f,p){var m=this.inEdges(f,p);if(m)return m.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function i(f,p){--f[p]||delete f[p]}function c(f,p,m,w){var j=""+p,b=""+m;if(!f&&j>b){var k=j;j=b,b=k}return j+s+b+s+(e.isUndefined(w)?t:w)}function d(f,p,m,w){var j=""+p,b=""+m;if(!f&&j>b){var k=j;j=b,b=k}var v={v:j,w:b};return w&&(v.name=w),v}function h(f,p){return c(f,p.v,p.w,p.name)}return jv}var Nv,Q2;function Zoe(){return Q2||(Q2=1,Nv="2.1.8"),Nv}var Sv,eM;function Joe(){return eM||(eM=1,Sv={Graph:kj(),version:Zoe()}),Sv}var _v,tM;function Qoe(){if(tM)return _v;tM=1;var e=gs(),t=kj();_v={write:n,read:o};function n(i){var c={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:s(i),edges:r(i)};return e.isUndefined(i.graph())||(c.value=e.clone(i.graph())),c}function s(i){return e.map(i.nodes(),function(c){var d=i.node(c),h=i.parent(c),f={v:c};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function r(i){return e.map(i.edges(),function(c){var d=i.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function o(i){var c=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(i.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return _v}var Ev,nM;function eie(){if(nM)return Ev;nM=1;var e=gs();Ev=t;function t(n){var s={},r=[],o;function i(c){e.has(s,c)||(s[c]=!0,o.push(c),e.each(n.successors(c),i),e.each(n.predecessors(c),i))}return e.each(n.nodes(),function(c){o=[],i(c),o.length&&r.push(o)}),r}return Ev}var Cv,sM;function vD(){if(sM)return Cv;sM=1;var e=gs();Cv=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var r=this._keyIndices;if(n=String(n),!e.has(r,n)){var o=this._arr,i=o.length;return r[n]=i,o.push({key:n,priority:s}),this._decrease(i),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,s){var r=this._keyIndices[n];if(s>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+s);this._arr[r].priority=s,this._decrease(r)},t.prototype._heapify=function(n){var s=this._arr,r=2*n,o=r+1,i=n;r<s.length&&(i=s[r].priority<s[i].priority?r:i,o<s.length&&(i=s[o].priority<s[i].priority?o:i),i!==n&&(this._swap(n,i),this._heapify(i)))},t.prototype._decrease=function(n){for(var s=this._arr,r=s[n].priority,o;n!==0&&(o=n>>1,!(s[o].priority<r));)this._swap(n,o),n=o},t.prototype._swap=function(n,s){var r=this._arr,o=this._keyIndices,i=r[n],c=r[s];r[n]=c,r[s]=i,o[c.key]=n,o[i.key]=s},Cv}var Tv,rM;function bD(){if(rM)return Tv;rM=1;var e=gs(),t=vD();Tv=s;var n=e.constant(1);function s(o,i,c,d){return r(o,String(i),c||n,d||function(h){return o.outEdges(h)})}function r(o,i,c,d){var h={},f=new t,p,m,w=function(j){var b=j.v!==p?j.v:j.w,k=h[b],v=c(j),N=m.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+v);N<k.distance&&(k.distance=N,k.predecessor=p,f.decrease(b,N))};for(o.nodes().forEach(function(j){var b=j===i?0:Number.POSITIVE_INFINITY;h[j]={distance:b},f.add(j,b)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(w);return h}return Tv}var Rv,aM;function tie(){if(aM)return Rv;aM=1;var e=bD(),t=gs();Rv=n;function n(s,r,o){return t.transform(s.nodes(),function(i,c){i[c]=e(s,c,r,o)},{})}return Rv}var Av,oM;function kD(){if(oM)return Av;oM=1;var e=gs();Av=t;function t(n){var s=0,r=[],o={},i=[];function c(d){var h=o[d]={onStack:!0,lowlink:s,index:s++};if(r.push(d),n.successors(d).forEach(function(m){e.has(o,m)?o[m].onStack&&(h.lowlink=Math.min(h.lowlink,o[m].index)):(c(m),h.lowlink=Math.min(h.lowlink,o[m].lowlink))}),h.lowlink===h.index){var f=[],p;do p=r.pop(),o[p].onStack=!1,f.push(p);while(d!==p);i.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||c(d)}),i}return Av}var Mv,iM;function nie(){if(iM)return Mv;iM=1;var e=gs(),t=kD();Mv=n;function n(s){return e.filter(t(s),function(r){return r.length>1||r.length===1&&s.hasEdge(r[0],r[0])})}return Mv}var $v,lM;function sie(){if(lM)return $v;lM=1;var e=gs();$v=n;var t=e.constant(1);function n(r,o,i){return s(r,o||t,i||function(c){return r.outEdges(c)})}function s(r,o,i){var c={},d=r.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),i(h).forEach(function(f){var p=f.v===h?f.w:f.v,m=o(f);c[h][p]={distance:m,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var m=c[p];d.forEach(function(w){var j=m[h],b=f[w],k=m[w],v=j.distance+b.distance;v<k.distance&&(k.distance=v,k.predecessor=b.predecessor)})})}),c}return $v}var Iv,cM;function jD(){if(cM)return Iv;cM=1;var e=gs();Iv=t,t.CycleException=n;function t(s){var r={},o={},i=[];function c(d){if(e.has(o,d))throw new n;e.has(r,d)||(o[d]=!0,r[d]=!0,e.each(s.predecessors(d),c),delete o[d],i.push(d))}if(e.each(s.sinks(),c),e.size(r)!==s.nodeCount())throw new n;return i}function n(){}return n.prototype=new Error,Iv}var Lv,uM;function rie(){if(uM)return Lv;uM=1;var e=jD();Lv=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Lv}var Ov,dM;function ND(){if(dM)return Ov;dM=1;var e=gs();Ov=t;function t(s,r,o){e.isArray(r)||(r=[r]);var i=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],d={};return e.each(r,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);n(s,h,o==="post",d,i,c)}),c}function n(s,r,o,i,c,d){e.has(i,r)||(i[r]=!0,o||d.push(r),e.each(c(r),function(h){n(s,h,o,i,c,d)}),o&&d.push(r))}return Ov}var Pv,hM;function aie(){if(hM)return Pv;hM=1;var e=ND();Pv=t;function t(n,s){return e(n,s,"post")}return Pv}var Dv,fM;function oie(){if(fM)return Dv;fM=1;var e=ND();Dv=t;function t(n,s){return e(n,s,"pre")}return Dv}var Fv,pM;function iie(){if(pM)return Fv;pM=1;var e=gs(),t=kj(),n=vD();Fv=s;function s(r,o){var i=new t,c={},d=new n,h;function f(m){var w=m.v===h?m.w:m.v,j=d.priority(w);if(j!==void 0){var b=o(m);b<j&&(c[w]=h,d.decrease(w,b))}}if(r.nodeCount()===0)return i;e.each(r.nodes(),function(m){d.add(m,Number.POSITIVE_INFINITY),i.setNode(m)}),d.decrease(r.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))i.setEdge(h,c[h]);else{if(p)throw new Error("Input graph is not connected: "+r);p=!0}r.nodeEdges(h).forEach(f)}return i}return Fv}var Bv,mM;function lie(){return mM||(mM=1,Bv={components:eie(),dijkstra:bD(),dijkstraAll:tie(),findCycles:nie(),floydWarshall:sie(),isAcyclic:rie(),postorder:aie(),preorder:oie(),prim:iie(),tarjan:kD(),topsort:jD()}),Bv}var qv,gM;function cie(){if(gM)return qv;gM=1;var e=Joe();return qv={Graph:e.Graph,json:Qoe(),alg:lie(),version:e.version},qv}var Uv,yM;function Bs(){if(yM)return Uv;yM=1;var e;if(typeof oj=="function")try{e=cie()}catch{}return e||(e=window.graphlib),Uv=e,Uv}var Wv,wM;function uie(){if(wM)return Wv;wM=1;var e=Y4(),t=1,n=4;function s(r){return e(r,t|n)}return Wv=s,Wv}var Hv,xM;function Np(){if(xM)return Hv;xM=1;var e=wl(),t=Xr(),n=mp(),s=ms();function r(o,i,c){if(!s(c))return!1;var d=typeof i;return(d=="number"?t(c)&&n(i,c.length):d=="string"&&i in c)?e(c[i],o):!1}return Hv=r,Hv}var zv,vM;function die(){if(vM)return zv;vM=1;var e=jp(),t=wl(),n=Np(),s=Zo(),r=Object.prototype,o=r.hasOwnProperty,i=e(function(c,d){c=Object(c);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var m=d[h],w=s(m),j=-1,b=w.length;++j<b;){var k=w[j],v=c[k];(v===void 0||t(v,r[k])&&!o.call(c,k))&&(c[k]=m[k])}return c});return zv=i,zv}var Vv,bM;function hie(){if(bM)return Vv;bM=1;var e=Zr(),t=Xr(),n=Ka();function s(r){return function(o,i,c){var d=Object(o);if(!t(o)){var h=e(i,3);o=n(o),i=function(p){return h(d[p],p,d)}}var f=r(o,i,c);return f>-1?d[h?o[f]:f]:void 0}}return Vv=s,Vv}var Gv,kM;function fie(){if(kM)return Gv;kM=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Gv=t,Gv}var Kv,jM;function pie(){if(jM)return Kv;jM=1;var e=fie(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Kv=n,Kv}var Yv,NM;function mie(){if(NM)return Yv;NM=1;var e=pie(),t=ms(),n=kl(),s=NaN,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return s;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||i.test(h)?c(h.slice(2),p?2:8):r.test(h)?s:+h}return Yv=d,Yv}var Xv,SM;function SD(){if(SM)return Xv;SM=1;var e=mie(),t=1/0,n=17976931348623157e292;function s(r){if(!r)return r===0?r:0;if(r=e(r),r===t||r===-t){var o=r<0?-1:1;return o*n}return r===r?r:0}return Xv=s,Xv}var Zv,_M;function gie(){if(_M)return Zv;_M=1;var e=SD();function t(n){var s=e(n),r=s%1;return s===s?r?s-r:s:0}return Zv=t,Zv}var Jv,EM;function yie(){if(EM)return Jv;EM=1;var e=yD(),t=Zr(),n=gie(),s=Math.max;function r(o,i,c){var d=o==null?0:o.length;if(!d)return-1;var h=c==null?0:n(c);return h<0&&(h=s(d+h,0)),e(o,t(i,3),h)}return Jv=r,Jv}var Qv,CM;function wie(){if(CM)return Qv;CM=1;var e=hie(),t=yie(),n=e(t);return Qv=n,Qv}var eb,TM;function _D(){if(TM)return eb;TM=1;var e=bj();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return eb=t,eb}var tb,RM;function xie(){if(RM)return tb;RM=1;var e=yj(),t=X4(),n=Zo();function s(r,o){return r==null?r:e(r,t(o),n)}return tb=s,tb}var nb,AM;function vie(){if(AM)return nb;AM=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return nb=e,nb}var sb,MM;function bie(){if(MM)return sb;MM=1;var e=fp(),t=wj(),n=Zr();function s(r,o){var i={};return o=n(o,3),t(r,function(c,d,h){e(i,d,o(c,d,h))}),i}return sb=s,sb}var rb,$M;function jj(){if($M)return rb;$M=1;var e=kl();function t(n,s,r){for(var o=-1,i=n.length;++o<i;){var c=n[o],d=s(c);if(d!=null&&(h===void 0?d===d&&!e(d):r(d,h)))var h=d,f=c}return f}return rb=t,rb}var ab,IM;function kie(){if(IM)return ab;IM=1;function e(t,n){return t>n}return ab=e,ab}var ob,LM;function jie(){if(LM)return ob;LM=1;var e=jj(),t=kie(),n=Jo();function s(r){return r&&r.length?e(r,n,t):void 0}return ob=s,ob}var ib,OM;function ED(){if(OM)return ib;OM=1;var e=fp(),t=wl();function n(s,r,o){(o!==void 0&&!t(s[r],o)||o===void 0&&!(r in s))&&e(s,r,o)}return ib=n,ib}var lb,PM;function Nie(){if(PM)return lb;PM=1;var e=Yo(),t=wp(),n=gr(),s="[object Object]",r=Function.prototype,o=Object.prototype,i=r.toString,c=o.hasOwnProperty,d=i.call(Object);function h(f){if(!n(f)||e(f)!=s)return!1;var p=t(f);if(p===null)return!0;var m=c.call(p,"constructor")&&p.constructor;return typeof m=="function"&&m instanceof m&&i.call(m)==d}return lb=h,lb}var cb,DM;function CD(){if(DM)return cb;DM=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return cb=e,cb}var ub,FM;function Sie(){if(FM)return ub;FM=1;var e=Au(),t=Zo();function n(s){return e(s,t(s))}return ub=n,ub}var db,BM;function _ie(){if(BM)return db;BM=1;var e=ED(),t=P4(),n=V4(),s=D4(),r=K4(),o=Mu(),i=Pt(),c=wD(),d=vl(),h=Ru(),f=ms(),p=Nie(),m=$u(),w=CD(),j=Sie();function b(k,v,N,S,E,C,I){var R=w(k,N),$=w(v,N),L=I.get($);if(L){e(k,N,L);return}var U=C?C(R,$,N+"",k,v,I):void 0,O=U===void 0;if(O){var M=i($),q=!M&&d($),A=!M&&!q&&m($);U=$,M||q||A?i(R)?U=R:c(R)?U=s(R):q?(O=!1,U=t($,!0)):A?(O=!1,U=n($,!0)):U=[]:p($)||o($)?(U=R,o(R)?U=j(R):(!f(R)||h(R))&&(U=r($))):O=!1}O&&(I.set($,U),E(U,$,S,C,I),I.delete($)),e(k,N,U)}return db=b,db}var hb,qM;function Eie(){if(qM)return hb;qM=1;var e=hp(),t=ED(),n=yj(),s=_ie(),r=ms(),o=Zo(),i=CD();function c(d,h,f,p,m){d!==h&&n(h,function(w,j){if(m||(m=new e),r(w))s(d,h,j,f,c,p,m);else{var b=p?p(i(d,j),w,j+"",d,h,m):void 0;b===void 0&&(b=w),t(d,j,b)}},o)}return hb=c,hb}var fb,UM;function Cie(){if(UM)return fb;UM=1;var e=jp(),t=Np();function n(s){return e(function(r,o){var i=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=s.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),r=Object(r);++i<c;){var f=o[i];f&&s(r,f,i,d)}return r})}return fb=n,fb}var pb,WM;function Tie(){if(WM)return pb;WM=1;var e=Eie(),t=Cie(),n=t(function(s,r,o){e(s,r,o)});return pb=n,pb}var mb,HM;function TD(){if(HM)return mb;HM=1;function e(t,n){return t<n}return mb=e,mb}var gb,zM;function Rie(){if(zM)return gb;zM=1;var e=jj(),t=TD(),n=Jo();function s(r){return r&&r.length?e(r,n,t):void 0}return gb=s,gb}var yb,VM;function Aie(){if(VM)return yb;VM=1;var e=jj(),t=Zr(),n=TD();function s(r,o){return r&&r.length?e(r,t(o,2),n):void 0}return yb=s,yb}var wb,GM;function Mie(){if(GM)return wb;GM=1;var e=Us(),t=function(){return e.Date.now()};return wb=t,wb}var xb,KM;function $ie(){if(KM)return xb;KM=1;var e=pp(),t=bp(),n=mp(),s=ms(),r=Iu();function o(i,c,d,h){if(!s(i))return i;c=t(c,i);for(var f=-1,p=c.length,m=p-1,w=i;w!=null&&++f<p;){var j=r(c[f]),b=d;if(j==="__proto__"||j==="constructor"||j==="prototype")return i;if(f!=m){var k=w[j];b=h?h(k,j,w):void 0,b===void 0&&(b=s(k)?k:n(c[f+1])?[]:{})}e(w,j,b),w=w[j]}return i}return xb=o,xb}var vb,YM;function Iie(){if(YM)return vb;YM=1;var e=kp(),t=$ie(),n=bp();function s(r,o,i){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(r,f);i(p,f)&&t(h,n(f,r),p)}return h}return vb=s,vb}var bb,XM;function Lie(){if(XM)return bb;XM=1;var e=Iie(),t=iD();function n(s,r){return e(s,r,function(o,i){return t(s,i)})}return bb=n,bb}var kb,ZM;function Oie(){if(ZM)return kb;ZM=1;var e=_D(),t=mD(),n=gD();function s(r){return n(t(r,void 0,e),r+"")}return kb=s,kb}var jb,JM;function Pie(){if(JM)return jb;JM=1;var e=Lie(),t=Oie(),n=t(function(s,r){return s==null?{}:e(s,r)});return jb=n,jb}var Nb,QM;function Die(){if(QM)return Nb;QM=1;var e=Math.ceil,t=Math.max;function n(s,r,o,i){for(var c=-1,d=t(e((r-s)/(o||1)),0),h=Array(d);d--;)h[i?d:++c]=s,s+=o;return h}return Nb=n,Nb}var Sb,e$;function Fie(){if(e$)return Sb;e$=1;var e=Die(),t=Np(),n=SD();function s(r){return function(o,i,c){return c&&typeof c!="number"&&t(o,i,c)&&(i=c=void 0),o=n(o),i===void 0?(i=o,o=0):i=n(i),c=c===void 0?o<i?1:-1:n(c),e(o,i,c,r)}}return Sb=s,Sb}var _b,t$;function Bie(){if(t$)return _b;t$=1;var e=Fie(),t=e();return _b=t,_b}var Eb,n$;function qie(){if(n$)return Eb;n$=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return Eb=e,Eb}var Cb,s$;function Uie(){if(s$)return Cb;s$=1;var e=kl();function t(n,s){if(n!==s){var r=n!==void 0,o=n===null,i=n===n,c=e(n),d=s!==void 0,h=s===null,f=s===s,p=e(s);if(!h&&!p&&!c&&n>s||c&&d&&f&&!h&&!p||o&&d&&f||!r&&f||!i)return 1;if(!o&&!c&&!p&&n<s||p&&r&&i&&!o&&!c||h&&r&&i||!d&&i||!f)return-1}return 0}return Cb=t,Cb}var Tb,r$;function Wie(){if(r$)return Tb;r$=1;var e=Uie();function t(n,s,r){for(var o=-1,i=n.criteria,c=s.criteria,d=i.length,h=r.length;++o<d;){var f=e(i[o],c[o]);if(f){if(o>=h)return f;var p=r[o];return f*(p=="desc"?-1:1)}}return n.index-s.index}return Tb=t,Tb}var Rb,a$;function Hie(){if(a$)return Rb;a$=1;var e=vp(),t=kp(),n=Zr(),s=hD(),r=qie(),o=gp(),i=Wie(),c=Jo(),d=Pt();function h(f,p,m){p.length?p=e(p,function(b){return d(b)?function(k){return t(k,b.length===1?b[0]:b)}:b}):p=[c];var w=-1;p=e(p,o(n));var j=s(f,function(b,k,v){var N=e(p,function(S){return S(b)});return{criteria:N,index:++w,value:b}});return r(j,function(b,k){return i(b,k,m)})}return Rb=h,Rb}var Ab,o$;function zie(){if(o$)return Ab;o$=1;var e=bj(),t=Hie(),n=jp(),s=Np(),r=n(function(o,i){if(o==null)return[];var c=i.length;return c>1&&s(o,i[0],i[1])?i=[]:c>2&&s(i[0],i[1],i[2])&&(i=[i[0]]),t(o,e(i,1),[])});return Ab=r,Ab}var Mb,i$;function Vie(){if(i$)return Mb;i$=1;var e=aD(),t=0;function n(s){var r=++t;return e(s)+r}return Mb=n,Mb}var $b,l$;function Gie(){if(l$)return $b;l$=1;function e(t,n,s){for(var r=-1,o=t.length,i=n.length,c={};++r<o;){var d=r<i?n[r]:void 0;s(c,t[r],d)}return c}return $b=e,$b}var Ib,c$;function Kie(){if(c$)return Ib;c$=1;var e=pp(),t=Gie();function n(s,r){return t(s||[],r||[],e)}return Ib=n,Ib}var Lb,u$;function Nt(){if(u$)return Lb;u$=1;var e;if(typeof oj=="function")try{e={cloneDeep:uie(),constant:gj(),defaults:die(),each:J4(),filter:cD(),find:wie(),flatten:_D(),forEach:Z4(),forIn:xie(),has:uD(),isUndefined:dD(),last:vie(),map:fD(),mapValues:bie(),max:jie(),merge:Tie(),min:Rie(),minBy:Aie(),now:Mie(),pick:Pie(),range:Bie(),reduce:pD(),sortBy:zie(),uniqueId:Vie(),values:xD(),zipObject:Kie()}}catch{}return e||(e=window._),Lb=e,Lb}var Ob,d$;function Yie(){if(d$)return Ob;d$=1,Ob=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,r=s._prev;if(r!==s)return t(r),r},e.prototype.enqueue=function(s){var r=this._sentinel;s._prev&&s._next&&t(s),s._next=r._next,r._next._prev=s,r._next=s,s._prev=r},e.prototype.toString=function(){for(var s=[],r=this._sentinel,o=r._prev;o!==r;)s.push(JSON.stringify(o,n)),o=o._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,r){if(s!=="_next"&&s!=="_prev")return r}return Ob}var Pb,h$;function Xie(){if(h$)return Pb;h$=1;var e=Nt(),t=Bs().Graph,n=Yie();Pb=r;var s=e.constant(1);function r(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||s),m=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(m,function(w){return h.outEdges(w.v,w.w)}),!0)}function o(h,f,p){for(var m=[],w=f[f.length-1],j=f[0],b;h.nodeCount();){for(;b=j.dequeue();)i(h,f,p,b);for(;b=w.dequeue();)i(h,f,p,b);if(h.nodeCount()){for(var k=f.length-2;k>0;--k)if(b=f[k].dequeue(),b){m=m.concat(i(h,f,p,b,!0));break}}}return m}function i(h,f,p,m,w){var j=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(b){var k=h.edge(b),v=h.node(b.v);w&&j.push({v:b.v,w:b.w}),v.out-=k,d(f,p,v)}),e.forEach(h.outEdges(m.v),function(b){var k=h.edge(b),v=b.w,N=h.node(v);N.in-=k,d(f,p,N)}),h.removeNode(m.v),j}function c(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(k){p.setNode(k,{v:k,in:0,out:0})}),e.forEach(h.edges(),function(k){var v=p.edge(k.v,k.w)||0,N=f(k),S=v+N;p.setEdge(k.v,k.w,S),w=Math.max(w,p.node(k.v).out+=N),m=Math.max(m,p.node(k.w).in+=N)});var j=e.range(w+m+3).map(function(){return new n}),b=m+1;return e.forEach(p.nodes(),function(k){d(j,b,p.node(k))}),{graph:p,buckets:j,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 Pb}var Db,f$;function Zie(){if(f$)return Db;f$=1;var e=Nt(),t=Xie();Db={run:n,undo:r};function n(o){var i=o.graph().acyclicer==="greedy"?t(o,c(o)):s(o);e.forEach(i,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function s(o){var i=[],c={},d={};function h(f){e.has(d,f)||(d[f]=!0,c[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(c,p.w)?i.push(p):h(p.w)}),delete c[f])}return e.forEach(o.nodes(),h),i}function r(o){e.forEach(o.edges(),function(i){var c=o.edge(i);if(c.reversed){o.removeEdge(i);var d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(i.w,i.v,c,d)}})}return Db}var Fb,p$;function $n(){if(p$)return Fb;p$=1;var e=Nt(),t=Bs().Graph;Fb={addDummyNode:n,simplify:s,asNonCompoundGraph:r,successorWeights:o,predecessorWeights:i,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:w,time:j,notime:b};function n(k,v,N,S){var E;do E=e.uniqueId(S);while(k.hasNode(E));return N.dummy=v,k.setNode(E,N),E}function s(k){var v=new t().setGraph(k.graph());return e.forEach(k.nodes(),function(N){v.setNode(N,k.node(N))}),e.forEach(k.edges(),function(N){var S=v.edge(N.v,N.w)||{weight:0,minlen:1},E=k.edge(N);v.setEdge(N.v,N.w,{weight:S.weight+E.weight,minlen:Math.max(S.minlen,E.minlen)})}),v}function r(k){var v=new t({multigraph:k.isMultigraph()}).setGraph(k.graph());return e.forEach(k.nodes(),function(N){k.children(N).length||v.setNode(N,k.node(N))}),e.forEach(k.edges(),function(N){v.setEdge(N,k.edge(N))}),v}function o(k){var v=e.map(k.nodes(),function(N){var S={};return e.forEach(k.outEdges(N),function(E){S[E.w]=(S[E.w]||0)+k.edge(E).weight}),S});return e.zipObject(k.nodes(),v)}function i(k){var v=e.map(k.nodes(),function(N){var S={};return e.forEach(k.inEdges(N),function(E){S[E.v]=(S[E.v]||0)+k.edge(E).weight}),S});return e.zipObject(k.nodes(),v)}function c(k,v){var N=k.x,S=k.y,E=v.x-N,C=v.y-S,I=k.width/2,R=k.height/2;if(!E&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var $,L;return Math.abs(C)*I>Math.abs(E)*R?(C<0&&(R=-R),$=R*E/C,L=R):(E<0&&(I=-I),$=I,L=I*C/E),{x:N+$,y:S+L}}function d(k){var v=e.map(e.range(m(k)+1),function(){return[]});return e.forEach(k.nodes(),function(N){var S=k.node(N),E=S.rank;e.isUndefined(E)||(v[E][S.order]=N)}),v}function h(k){var v=e.min(e.map(k.nodes(),function(N){return k.node(N).rank}));e.forEach(k.nodes(),function(N){var S=k.node(N);e.has(S,"rank")&&(S.rank-=v)})}function f(k){var v=e.min(e.map(k.nodes(),function(C){return k.node(C).rank})),N=[];e.forEach(k.nodes(),function(C){var I=k.node(C).rank-v;N[I]||(N[I]=[]),N[I].push(C)});var S=0,E=k.graph().nodeRankFactor;e.forEach(N,function(C,I){e.isUndefined(C)&&I%E!==0?--S:S&&e.forEach(C,function(R){k.node(R).rank+=S})})}function p(k,v,N,S){var E={width:0,height:0};return arguments.length>=4&&(E.rank=N,E.order=S),n(k,"border",E,v)}function m(k){return e.max(e.map(k.nodes(),function(v){var N=k.node(v).rank;if(!e.isUndefined(N))return N}))}function w(k,v){var N={lhs:[],rhs:[]};return e.forEach(k,function(S){v(S)?N.lhs.push(S):N.rhs.push(S)}),N}function j(k,v){var N=e.now();try{return v()}finally{console.log(k+" time: "+(e.now()-N)+"ms")}}function b(k,v){return v()}return Fb}var Bb,m$;function Jie(){if(m$)return Bb;m$=1;var e=Nt(),t=$n();Bb={run:n,undo:r};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(i){s(o,i)})}function s(o,i){var c=i.v,d=o.node(c).rank,h=i.w,f=o.node(h).rank,p=i.name,m=o.edge(i),w=m.labelRank;if(f!==d+1){o.removeEdge(i);var j,b,k;for(k=0,++d;d<f;++k,++d)m.points=[],b={width:0,height:0,edgeLabel:m,edgeObj:i,rank:d},j=t.addDummyNode(o,"edge",b,"_d"),d===w&&(b.width=m.width,b.height=m.height,b.dummy="edge-label",b.labelpos=m.labelpos),o.setEdge(c,j,{weight:m.weight},p),k===0&&o.graph().dummyChains.push(j),c=j;o.setEdge(c,h,{weight:m.weight},p)}}function r(o){e.forEach(o.graph().dummyChains,function(i){var c=o.node(i),d=c.edgeLabel,h;for(o.setEdge(c.edgeObj,d);c.dummy;)h=o.successors(i)[0],o.removeNode(i),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),i=h,c=o.node(i)})}return Bb}var qb,g$;function wf(){if(g$)return qb;g$=1;var e=Nt();qb={longestPath:t,slack:n};function t(s){var r={};function o(i){var c=s.node(i);if(e.has(r,i))return c.rank;r[i]=!0;var d=e.min(e.map(s.outEdges(i),function(h){return o(h.w)-s.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(s.sources(),o)}function n(s,r){return s.node(r.w).rank-s.node(r.v).rank-s.edge(r).minlen}return qb}var Ub,y$;function RD(){if(y$)return Ub;y$=1;var e=Nt(),t=Bs().Graph,n=wf().slack;Ub=s;function s(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,m;r(d,c)<f;)p=o(d,c),m=d.hasNode(p.v)?n(c,p):-n(c,p),i(d,c,m);return d}function r(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var m=p.v,w=f===m?p.w:m;!c.hasNode(w)&&!n(d,p)&&(c.setNode(w,{}),c.setEdge(f,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function o(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(d,h)})}function i(c,d,h){e.forEach(c.nodes(),function(f){d.node(f).rank+=h})}return Ub}var Wb,w$;function Qie(){if(w$)return Wb;w$=1;var e=Nt(),t=RD(),n=wf().slack,s=wf().longestPath,r=Bs().alg.preorder,o=Bs().alg.postorder,i=$n().simplify;Wb=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=b;function c(S){S=i(S),s(S);var E=t(S);p(E),d(E,S);for(var C,I;C=w(E);)I=j(E,S,C),b(E,S,C,I)}function d(S,E){var C=o(S,S.nodes());C=C.slice(0,C.length-1),e.forEach(C,function(I){h(S,E,I)})}function h(S,E,C){var I=S.node(C),R=I.parent;S.edge(C,R).cutvalue=f(S,E,C)}function f(S,E,C){var I=S.node(C),R=I.parent,$=!0,L=E.edge(C,R),U=0;return L||($=!1,L=E.edge(R,C)),U=L.weight,e.forEach(E.nodeEdges(C),function(O){var M=O.v===C,q=M?O.w:O.v;if(q!==R){var A=M===$,D=E.edge(O).weight;if(U+=A?D:-D,v(S,C,q)){var P=S.edge(C,q).cutvalue;U+=A?-P:P}}}),U}function p(S,E){arguments.length<2&&(E=S.nodes()[0]),m(S,{},1,E)}function m(S,E,C,I,R){var $=C,L=S.node(I);return E[I]=!0,e.forEach(S.neighbors(I),function(U){e.has(E,U)||(C=m(S,E,C,U,I))}),L.low=$,L.lim=C++,R?L.parent=R:delete L.parent,C}function w(S){return e.find(S.edges(),function(E){return S.edge(E).cutvalue<0})}function j(S,E,C){var I=C.v,R=C.w;E.hasEdge(I,R)||(I=C.w,R=C.v);var $=S.node(I),L=S.node(R),U=$,O=!1;$.lim>L.lim&&(U=L,O=!0);var M=e.filter(E.edges(),function(q){return O===N(S,S.node(q.v),U)&&O!==N(S,S.node(q.w),U)});return e.minBy(M,function(q){return n(E,q)})}function b(S,E,C,I){var R=C.v,$=C.w;S.removeEdge(R,$),S.setEdge(I.v,I.w,{}),p(S),d(S,E),k(S,E)}function k(S,E){var C=e.find(S.nodes(),function(R){return!E.node(R).parent}),I=r(S,C);I=I.slice(1),e.forEach(I,function(R){var $=S.node(R).parent,L=E.edge(R,$),U=!1;L||(L=E.edge($,R),U=!0),E.node(R).rank=E.node($).rank+(U?L.minlen:-L.minlen)})}function v(S,E,C){return S.hasEdge(E,C)}function N(S,E,C){return C.low<=E.lim&&E.lim<=C.lim}return Wb}var Hb,x$;function ele(){if(x$)return Hb;x$=1;var e=wf(),t=e.longestPath,n=RD(),s=Qie();Hb=r;function r(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":i(d);break;case"longest-path":o(d);break;default:c(d)}}var o=t;function i(d){t(d),n(d)}function c(d){s(d)}return Hb}var zb,v$;function tle(){if(v$)return zb;v$=1;var e=Nt();zb=t;function t(r){var o=s(r);e.forEach(r.graph().dummyChains,function(i){for(var c=r.node(i),d=c.edgeObj,h=n(r,o,d.v,d.w),f=h.path,p=h.lca,m=0,w=f[m],j=!0;i!==d.w;){if(c=r.node(i),j){for(;(w=f[m])!==p&&r.node(w).maxRank<c.rank;)m++;w===p&&(j=!1)}if(!j){for(;m<f.length-1&&r.node(w=f[m+1]).minRank<=c.rank;)m++;w=f[m]}r.setParent(i,w),i=r.successors(i)[0]}})}function n(r,o,i,c){var d=[],h=[],f=Math.min(o[i].low,o[c].low),p=Math.max(o[i].lim,o[c].lim),m,w;m=i;do m=r.parent(m),d.push(m);while(m&&(o[m].low>f||p>o[m].lim));for(w=m,m=c;(m=r.parent(m))!==w;)h.push(m);return{path:d.concat(h.reverse()),lca:w}}function s(r){var o={},i=0;function c(d){var h=i;e.forEach(r.children(d),c),o[d]={low:h,lim:i++}}return e.forEach(r.children(),c),o}return zb}var Vb,b$;function nle(){if(b$)return Vb;b$=1;var e=Nt(),t=$n();Vb={run:n,cleanup:i};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=r(c),f=e.max(e.values(h))-1,p=2*f+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(w){c.edge(w).minlen*=p});var m=o(c)+1;e.forEach(c.children(),function(w){s(c,d,p,m,f,h,w)}),c.graph().nodeRankFactor=p}function s(c,d,h,f,p,m,w){var j=c.children(w);if(!j.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:h});return}var b=t.addBorderNode(c,"_bt"),k=t.addBorderNode(c,"_bb"),v=c.node(w);c.setParent(b,w),v.borderTop=b,c.setParent(k,w),v.borderBottom=k,e.forEach(j,function(N){s(c,d,h,f,p,m,N);var S=c.node(N),E=S.borderTop?S.borderTop:N,C=S.borderBottom?S.borderBottom:N,I=S.borderTop?f:2*f,R=E!==C?1:p-m[w]+1;c.setEdge(b,E,{weight:I,minlen:R,nestingEdge:!0}),c.setEdge(C,k,{weight:I,minlen:R,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,b,{weight:0,minlen:p+m[w]})}function r(c){var d={};function h(f,p){var m=c.children(f);m&&m.length&&e.forEach(m,function(w){h(w,p+1)}),d[f]=p}return e.forEach(c.children(),function(f){h(f,1)}),d}function o(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function i(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return Vb}var Gb,k$;function sle(){if(k$)return Gb;k$=1;var e=Nt(),t=$n();Gb=n;function n(r){function o(i){var c=r.children(i),d=r.node(i);if(c.length&&e.forEach(c,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)s(r,"borderLeft","_bl",i,d,h),s(r,"borderRight","_br",i,d,h)}}e.forEach(r.children(),o)}function s(r,o,i,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],m=t.addDummyNode(r,"border",f,i);d[o][h]=m,r.setParent(m,c),p&&r.setEdge(p,m,{weight:1})}return Gb}var Kb,j$;function rle(){if(j$)return Kb;j$=1;var e=Nt();Kb={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){r(h.node(f))}),e.forEach(h.edges(),function(f){r(h.edge(f))})}function r(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){i(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return Kb}var Yb,N$;function ale(){if(N$)return Yb;N$=1;var e=Nt();Yb=t;function t(n){var s={},r=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(r,function(h){return n.node(h).rank})),i=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=n.node(h);i[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(r,function(h){return n.node(h).rank});return e.forEach(d,c),i}return Yb}var Xb,S$;function ole(){if(S$)return Xb;S$=1;var e=Nt();Xb=t;function t(s,r){for(var o=0,i=1;i<r.length;++i)o+=n(s,r[i-1],r[i]);return o}function n(s,r,o){for(var i=e.zipObject(o,e.map(o,function(m,w){return w})),c=e.flatten(e.map(r,function(m){return e.sortBy(e.map(s.outEdges(m),function(w){return{pos:i[w.w],weight:s.edge(w).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(c.forEach(function(m){var w=m.pos+d;f[w]+=m.weight;for(var j=0;w>0;)w%2&&(j+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*j})),p}return Xb}var Zb,_$;function ile(){if(_$)return Zb;_$=1;var e=Nt();Zb=t;function t(n,s){return e.map(s,function(r){var o=n.inEdges(r);if(o.length){var i=e.reduce(o,function(c,d){var h=n.edge(d),f=n.node(d.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return Zb}var Jb,E$;function lle(){if(E$)return Jb;E$=1;var e=Nt();Jb=t;function t(r,o){var i={};e.forEach(r,function(d,h){var f=i[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=i[d.v],f=i[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(i[d.w]))});var c=e.filter(i,function(d){return!d.indegree});return n(c)}function n(r){var o=[];function i(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&r.push(f)}}for(;r.length;){var d=r.pop();o.push(d),e.forEach(d.in.reverse(),i(d)),e.forEach(d.out,c(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(r,o){var i=0,c=0;r.weight&&(i+=r.barycenter*r.weight,c+=r.weight),o.weight&&(i+=o.barycenter*o.weight,c+=o.weight),r.vs=o.vs.concat(r.vs),r.barycenter=i/c,r.weight=c,r.i=Math.min(o.i,r.i),o.merged=!0}return Jb}var Qb,C$;function cle(){if(C$)return Qb;C$=1;var e=Nt(),t=$n();Qb=n;function n(o,i){var c=t.partition(o,function(b){return e.has(b,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(b){return-b.i}),f=[],p=0,m=0,w=0;d.sort(r(!!i)),w=s(f,h,w),e.forEach(d,function(b){w+=b.vs.length,f.push(b.vs),p+=b.barycenter*b.weight,m+=b.weight,w=s(f,h,w)});var j={vs:e.flatten(f,!0)};return m&&(j.barycenter=p/m,j.weight=m),j}function s(o,i,c){for(var d;i.length&&(d=e.last(i)).i<=c;)i.pop(),o.push(d.vs),c++;return c}function r(o){return function(i,c){return i.barycenter<c.barycenter?-1:i.barycenter>c.barycenter?1:o?c.i-i.i:i.i-c.i}}return Qb}var ek,T$;function ule(){if(T$)return ek;T$=1;var e=Nt(),t=ile(),n=lle(),s=cle();ek=r;function r(c,d,h,f){var p=c.children(d),m=c.node(d),w=m?m.borderLeft:void 0,j=m?m.borderRight:void 0,b={};w&&(p=e.filter(p,function(C){return C!==w&&C!==j}));var k=t(c,p);e.forEach(k,function(C){if(c.children(C.v).length){var I=r(c,C.v,h,f);b[C.v]=I,e.has(I,"barycenter")&&i(C,I)}});var v=n(k,h);o(v,b);var N=s(v,f);if(w&&(N.vs=e.flatten([w,N.vs,j],!0),c.predecessors(w).length)){var S=c.node(c.predecessors(w)[0]),E=c.node(c.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+S.order+E.order)/(N.weight+2),N.weight+=2}return N}function o(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function i(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return ek}var tk,R$;function dle(){if(R$)return tk;R$=1;var e=Nt(),t=Bs().Graph;tk=n;function n(r,o,i){var c=s(r),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return r.node(h)});return e.forEach(r.nodes(),function(h){var f=r.node(h),p=r.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(r[i](h),function(m){var w=m.v===h?m.w:m.v,j=d.edge(w,h),b=e.isUndefined(j)?0:j.weight;d.setEdge(w,h,{weight:r.edge(m).weight+b})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function s(r){for(var o;r.hasNode(o=e.uniqueId("_root")););return o}return tk}var nk,A$;function hle(){if(A$)return nk;A$=1;var e=Nt();nk=t;function t(n,s,r){var o={},i;e.forEach(r,function(c){for(var d=n.parent(c),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=i,i=d),f&&f!==d){s.setEdge(f,d);return}d=h}})}return nk}var sk,M$;function fle(){if(M$)return sk;M$=1;var e=Nt(),t=ale(),n=ole(),s=ule(),r=dle(),o=hle(),i=Bs().Graph,c=$n();sk=d;function d(m){var w=c.maxRank(m),j=h(m,e.range(1,w+1),"inEdges"),b=h(m,e.range(w-1,-1,-1),"outEdges"),k=t(m);p(m,k);for(var v=Number.POSITIVE_INFINITY,N,S=0,E=0;E<4;++S,++E){f(S%2?j:b,S%4>=2),k=c.buildLayerMatrix(m);var C=n(m,k);C<v&&(E=0,N=e.cloneDeep(k),v=C)}p(m,N)}function h(m,w,j){return e.map(w,function(b){return r(m,b,j)})}function f(m,w){var j=new i;e.forEach(m,function(b){var k=b.graph().root,v=s(b,k,j,w);e.forEach(v.vs,function(N,S){b.node(N).order=S}),o(b,j,v.vs)})}function p(m,w){e.forEach(w,function(j){e.forEach(j,function(b,k){m.node(b).order=k})})}return sk}var rk,$$;function ple(){if($$)return rk;$$=1;var e=Nt(),t=Bs().Graph,n=$n();rk={positionX:j,findType1Conflicts:s,findType2Conflicts:r,addConflict:i,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(v,N){var S={};function E(C,I){var R=0,$=0,L=C.length,U=e.last(I);return e.forEach(I,function(O,M){var q=o(v,O),A=q?v.node(q).order:L;(q||O===U)&&(e.forEach(I.slice($,M+1),function(D){e.forEach(v.predecessors(D),function(P){var K=v.node(P),G=K.order;(G<R||A<G)&&!(K.dummy&&v.node(D).dummy)&&i(S,P,D)})}),$=M+1,R=A)}),I}return e.reduce(N,E),S}function r(v,N){var S={};function E(I,R,$,L,U){var O;e.forEach(e.range(R,$),function(M){O=I[M],v.node(O).dummy&&e.forEach(v.predecessors(O),function(q){var A=v.node(q);A.dummy&&(A.order<L||A.order>U)&&i(S,q,O)})})}function C(I,R){var $=-1,L,U=0;return e.forEach(R,function(O,M){if(v.node(O).dummy==="border"){var q=v.predecessors(O);q.length&&(L=v.node(q[0]).order,E(R,U,M,$,L),U=M,$=L)}E(R,U,R.length,L,I.length)}),R}return e.reduce(N,C),S}function o(v,N){if(v.node(N).dummy)return e.find(v.predecessors(N),function(S){return v.node(S).dummy})}function i(v,N,S){if(N>S){var E=N;N=S,S=E}var C=v[N];C||(v[N]=C={}),C[S]=!0}function c(v,N,S){if(N>S){var E=N;N=S,S=E}return e.has(v[N],S)}function d(v,N,S,E){var C={},I={},R={};return e.forEach(N,function($){e.forEach($,function(L,U){C[L]=L,I[L]=L,R[L]=U})}),e.forEach(N,function($){var L=-1;e.forEach($,function(U){var O=E(U);if(O.length){O=e.sortBy(O,function(P){return R[P]});for(var M=(O.length-1)/2,q=Math.floor(M),A=Math.ceil(M);q<=A;++q){var D=O[q];I[U]===U&&L<R[D]&&!c(S,U,D)&&(I[D]=U,I[U]=C[U]=C[D],L=R[D])}}})}),{root:C,align:I}}function h(v,N,S,E,C){var I={},R=f(v,N,S,C),$=C?"borderLeft":"borderRight";function L(M,q){for(var A=R.nodes(),D=A.pop(),P={};D;)P[D]?M(D):(P[D]=!0,A.push(D),A=A.concat(q(D))),D=A.pop()}function U(M){I[M]=R.inEdges(M).reduce(function(q,A){return Math.max(q,I[A.v]+R.edge(A))},0)}function O(M){var q=R.outEdges(M).reduce(function(D,P){return Math.min(D,I[P.w]-R.edge(P))},Number.POSITIVE_INFINITY),A=v.node(M);q!==Number.POSITIVE_INFINITY&&A.borderType!==$&&(I[M]=Math.max(I[M],q))}return L(U,R.predecessors.bind(R)),L(O,R.successors.bind(R)),e.forEach(E,function(M){I[M]=I[S[M]]}),I}function f(v,N,S,E){var C=new t,I=v.graph(),R=b(I.nodesep,I.edgesep,E);return e.forEach(N,function($){var L;e.forEach($,function(U){var O=S[U];if(C.setNode(O),L){var M=S[L],q=C.edge(M,O);C.setEdge(M,O,Math.max(R(v,U,L),q||0))}L=U})}),C}function p(v,N){return e.minBy(e.values(N),function(S){var E=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(S,function(I,R){var $=k(v,R)/2;E=Math.max(I+$,E),C=Math.min(I-$,C)}),E-C})}function m(v,N){var S=e.values(N),E=e.min(S),C=e.max(S);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(R){var $=I+R,L=v[$],U;if(L!==N){var O=e.values(L);U=R==="l"?E-e.min(O):C-e.max(O),U&&(v[$]=e.mapValues(L,function(M){return M+U}))}})})}function w(v,N){return e.mapValues(v.ul,function(S,E){if(N)return v[N.toLowerCase()][E];var C=e.sortBy(e.map(v,E));return(C[1]+C[2])/2})}function j(v){var N=n.buildLayerMatrix(v),S=e.merge(s(v,N),r(v,N)),E={},C;e.forEach(["u","d"],function(R){C=R==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function($){$==="r"&&(C=e.map(C,function(M){return e.values(M).reverse()}));var L=(R==="u"?v.predecessors:v.successors).bind(v),U=d(v,C,S,L),O=h(v,C,U.root,U.align,$==="r");$==="r"&&(O=e.mapValues(O,function(M){return-M})),E[R+$]=O})});var I=p(v,E);return m(E,I),w(E,v.graph().align)}function b(v,N,S){return function(E,C,I){var R=E.node(C),$=E.node(I),L=0,U;if(L+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":U=-R.width/2;break;case"r":U=R.width/2;break}if(U&&(L+=S?U:-U),U=0,L+=(R.dummy?N:v)/2,L+=($.dummy?N:v)/2,L+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":U=$.width/2;break;case"r":U=-$.width/2;break}return U&&(L+=S?U:-U),U=0,L}}function k(v,N){return v.node(N).width}return rk}var ak,I$;function mle(){if(I$)return ak;I$=1;var e=Nt(),t=$n(),n=ple().positionX;ak=s;function s(o){o=t.asNonCompoundGraph(o),r(o),e.forEach(n(o),function(i,c){o.node(c).x=i})}function r(o){var i=t.buildLayerMatrix(o),c=o.graph().ranksep,d=0;e.forEach(i,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+c})}return ak}var ok,L$;function gle(){if(L$)return ok;L$=1;var e=Nt(),t=Zie(),n=Jie(),s=ele(),r=$n().normalizeRanks,o=tle(),i=$n().removeEmptyRanks,c=nle(),d=sle(),h=rle(),f=fle(),p=mle(),m=$n(),w=Bs().Graph;ok=j;function j(V,X){var Y=X&&X.debugTiming?m.time:m.notime;Y("layout",function(){var J=Y(" buildLayoutGraph",function(){return L(V)});Y(" runLayout",function(){b(J,Y)}),Y(" updateInputGraph",function(){k(V,J)})})}function b(V,X){X(" makeSpaceForEdgeLabels",function(){U(V)}),X(" removeSelfEdges",function(){W(V)}),X(" acyclic",function(){t.run(V)}),X(" nestingGraph.run",function(){c.run(V)}),X(" rank",function(){s(m.asNonCompoundGraph(V))}),X(" injectEdgeLabelProxies",function(){O(V)}),X(" removeEmptyRanks",function(){i(V)}),X(" nestingGraph.cleanup",function(){c.cleanup(V)}),X(" normalizeRanks",function(){r(V)}),X(" assignRankMinMax",function(){M(V)}),X(" removeEdgeLabelProxies",function(){q(V)}),X(" normalize.run",function(){n.run(V)}),X(" parentDummyChains",function(){o(V)}),X(" addBorderSegments",function(){d(V)}),X(" order",function(){f(V)}),X(" insertSelfEdges",function(){H(V)}),X(" adjustCoordinateSystem",function(){h.adjust(V)}),X(" position",function(){p(V)}),X(" positionSelfEdges",function(){F(V)}),X(" removeBorderNodes",function(){G(V)}),X(" normalize.undo",function(){n.undo(V)}),X(" fixupEdgeLabelCoords",function(){P(V)}),X(" undoCoordinateSystem",function(){h.undo(V)}),X(" translateGraph",function(){A(V)}),X(" assignNodeIntersects",function(){D(V)}),X(" reversePoints",function(){K(V)}),X(" acyclic.undo",function(){t.undo(V)})}function k(V,X){e.forEach(V.nodes(),function(Y){var J=V.node(Y),ee=X.node(Y);J&&(J.x=ee.x,J.y=ee.y,X.children(Y).length&&(J.width=ee.width,J.height=ee.height))}),e.forEach(V.edges(),function(Y){var J=V.edge(Y),ee=X.edge(Y);J.points=ee.points,e.has(ee,"x")&&(J.x=ee.x,J.y=ee.y)}),V.graph().width=X.graph().width,V.graph().height=X.graph().height}var v=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],E=["width","height"],C={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$=["labelpos"];function L(V){var X=new w({multigraph:!0,compound:!0}),Y=Z(V.graph());return X.setGraph(e.merge({},N,B(Y,v),e.pick(Y,S))),e.forEach(V.nodes(),function(J){var ee=Z(V.node(J));X.setNode(J,e.defaults(B(ee,E),C)),X.setParent(J,V.parent(J))}),e.forEach(V.edges(),function(J){var ee=Z(V.edge(J));X.setEdge(J,e.merge({},R,B(ee,I),e.pick(ee,$)))}),X}function U(V){var X=V.graph();X.ranksep/=2,e.forEach(V.edges(),function(Y){var J=V.edge(Y);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function O(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(Y.width&&Y.height){var J=V.node(X.v),ee=V.node(X.w),ne={rank:(ee.rank-J.rank)/2+J.rank,e:X};m.addDummyNode(V,"edge-proxy",ne,"_ep")}})}function M(V){var X=0;e.forEach(V.nodes(),function(Y){var J=V.node(Y);J.borderTop&&(J.minRank=V.node(J.borderTop).rank,J.maxRank=V.node(J.borderBottom).rank,X=e.max(X,J.maxRank))}),V.graph().maxRank=X}function q(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);Y.dummy==="edge-proxy"&&(V.edge(Y.e).labelRank=Y.rank,V.removeNode(X))})}function A(V){var X=Number.POSITIVE_INFINITY,Y=0,J=Number.POSITIVE_INFINITY,ee=0,ne=V.graph(),le=ne.marginx||0,de=ne.marginy||0;function ue(re){var pe=re.x,ye=re.y,_e=re.width,he=re.height;X=Math.min(X,pe-_e/2),Y=Math.max(Y,pe+_e/2),J=Math.min(J,ye-he/2),ee=Math.max(ee,ye+he/2)}e.forEach(V.nodes(),function(re){ue(V.node(re))}),e.forEach(V.edges(),function(re){var pe=V.edge(re);e.has(pe,"x")&&ue(pe)}),X-=le,J-=de,e.forEach(V.nodes(),function(re){var pe=V.node(re);pe.x-=X,pe.y-=J}),e.forEach(V.edges(),function(re){var pe=V.edge(re);e.forEach(pe.points,function(ye){ye.x-=X,ye.y-=J}),e.has(pe,"x")&&(pe.x-=X),e.has(pe,"y")&&(pe.y-=J)}),ne.width=Y-X+le,ne.height=ee-J+de}function D(V){e.forEach(V.edges(),function(X){var Y=V.edge(X),J=V.node(X.v),ee=V.node(X.w),ne,le;Y.points?(ne=Y.points[0],le=Y.points[Y.points.length-1]):(Y.points=[],ne=ee,le=J),Y.points.unshift(m.intersectRect(J,ne)),Y.points.push(m.intersectRect(ee,le))})}function P(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function K(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);Y.reversed&&Y.points.reverse()})}function G(V){e.forEach(V.nodes(),function(X){if(V.children(X).length){var Y=V.node(X),J=V.node(Y.borderTop),ee=V.node(Y.borderBottom),ne=V.node(e.last(Y.borderLeft)),le=V.node(e.last(Y.borderRight));Y.width=Math.abs(le.x-ne.x),Y.height=Math.abs(ee.y-J.y),Y.x=ne.x+Y.width/2,Y.y=J.y+Y.height/2}}),e.forEach(V.nodes(),function(X){V.node(X).dummy==="border"&&V.removeNode(X)})}function W(V){e.forEach(V.edges(),function(X){if(X.v===X.w){var Y=V.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:V.edge(X)}),V.removeEdge(X)}})}function H(V){var X=m.buildLayerMatrix(V);e.forEach(X,function(Y){var J=0;e.forEach(Y,function(ee,ne){var le=V.node(ee);le.order=ne+J,e.forEach(le.selfEdges,function(de){m.addDummyNode(V,"selfedge",{width:de.label.width,height:de.label.height,rank:le.rank,order:ne+ ++J,e:de.e,label:de.label},"_se")}),delete le.selfEdges})})}function F(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);if(Y.dummy==="selfedge"){var J=V.node(Y.e.v),ee=J.x+J.width/2,ne=J.y,le=Y.x-ee,de=J.height/2;V.setEdge(Y.e,Y.label),V.removeNode(X),Y.label.points=[{x:ee+2*le/3,y:ne-de},{x:ee+5*le/6,y:ne-de},{x:ee+le,y:ne},{x:ee+5*le/6,y:ne+de},{x:ee+2*le/3,y:ne+de}],Y.label.x=Y.x,Y.label.y=Y.y}})}function B(V,X){return e.mapValues(e.pick(V,X),Number)}function Z(V){var X={};return e.forEach(V,function(Y,J){X[J.toLowerCase()]=Y}),X}return ok}var ik,O$;function yle(){if(O$)return ik;O$=1;var e=Nt(),t=$n(),n=Bs().Graph;ik={debugOrdering:s};function s(r){var o=t.buildLayerMatrix(r),i=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(r.nodes(),function(c){i.setNode(c,{label:c}),i.setParent(c,"layer"+r.node(c).rank)}),e.forEach(r.edges(),function(c){i.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,d){var h="layer"+d;i.setNode(h,{rank:"same"}),e.reduce(c,function(f,p){return i.setEdge(f,p,{style:"invis"}),p})}),i}return ik}var lk,P$;function wle(){return P$||(P$=1,lk="0.8.5"),lk}var ck,D$;function xle(){return D$||(D$=1,ck={graphlib:Bs(),layout:gle(),debug:yle(),util:{time:$n().time,notime:$n().notime},version:wle()}),ck}var vle=xle();const F$=H0(vle);function ble(e,t,n){const s=Vf(e,r=>!t.has(r.id)&&n(r.id)!=null);if(s.size===0)return e;for(const r of s.values())r.sort((o,i)=>o.id.localeCompare(i.id));return e.map(r=>{var h;if(t.has(r.id)||n(r.id))return r;const o=s.get(Gn(r));if(!o)return r;const i=(h=r.data)==null?void 0:h.parentId,c=o.find(f=>f.id===i)??o[0],d=n(c.id);return{...r,position:{x:r.position.x+d.x-c.position.x,y:r.position.y+d.y-c.position.y}}})}function kle(e,t,n,s,r,o,i){const c=S=>ou(S,s,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:E,h:C}=nf(S,s);return{cw:E,ch:C}},f=i!=null&&i.width>0&&i.height>0,p=Vf(e,S=>d(S.id)!=null),m=new Set;for(const[S,E]of p)E.every(C=>r.has(C.id)&&!n.has(C.id))&&m.add(S);const w=new Map,j=[];for(const S of e){const E=d(S.id);if(!E)continue;const{w:C,h:I}=c(S.id),R=Gn(S);m.has(R)?(w.get(R)??w.set(R,[]).get(R)).push(S):j.push({sid:R,x:E.x,y:E.y,w:C,h:I,...h(S.id)})}if(w.size===0||f&&j.length===0)return[];const b=ef,k=(S,E,C,I)=>j.some(R=>S<R.x+R.w+Zk&&R.x<S+C+Zk&&E<R.y+R.h+b&&R.y<E+I+b),v=q3(e,s),N=[];for(const S of[...w.keys()].sort()){const E=w.get(S);let C=1/0,I=1/0,R=-1/0,$=-1/0,L=-1/0,U=-1/0;for(const G of E){const W=d(G.id),{w:H,h:F}=c(G.id),{cw:B,ch:Z}=h(G.id);C=Math.min(C,W.x),I=Math.min(I,W.y),R=Math.max(R,W.x+H),$=Math.max($,W.y+F),L=Math.max(L,W.x+B),U=Math.max(U,W.y+Z)}const O=R-C,M=$-I,q=new Map;for(const G of j)q.set(G.sid,Math.min(q.get(G.sid)??1/0,G.x));const A=[...new Set([...q.values()].map(G=>Math.round(G)))].sort((G,W)=>G-W),D=A.length?A:[C],P=[0,...j.map(G=>G.y+G.h+b)].sort((G,W)=>G-W);let K=null;if(f){let G=1/0,W=1/0,H=-1/0,F=-1/0;for(const J of j)G=Math.min(G,J.x),W=Math.min(W,J.y),H=Math.max(H,J.x+J.cw),F=Math.max(F,J.y+J.ch);const B=(J,ee)=>{const ne=i.width/(Math.max(H,J+L-C)-Math.min(G,J)+tf),le=i.height/(Math.max(F,ee+U-I)-Math.min(W,ee));return[Math.min(U3,ne,le),Math.min(ne,le),Math.max(ne,le)]},Z=(J,ee)=>{for(let ne=0;ne<J.length;ne++){if(J[ne]>ee[ne]+1e-9)return!0;if(J[ne]<ee[ne]-1e-9)return!1}return!1},V=Math.round(H+tf+v),X=[...new Set([...P,W])].sort((J,ee)=>J-ee);let Y=null;for(const J of[...D,V])for(const ee of X){if(k(J,ee,O,M))continue;const ne=B(J,ee);(Y===null||Z(ne,Y))&&(Y=ne,K={x:J,y:ee})}K&&K.x===C&&K.y===I&&(K=null)}else e:for(const G of D)for(const W of P){if(W>=I)break;if(!k(G,W,O,M)){K={x:G,y:W};break e}}if(K){const G=K.x-C,W=K.y-I;for(const H of E){const F=d(H.id);t.set(H.id,{x:F.x+G,y:F.y+W})}N.push(S)}for(const G of E){const W=d(G.id),{w:H,h:F}=c(G.id);j.push({sid:S,x:W.x,y:W.y,w:H,h:F,...h(G.id)})}}return N}function jle(e,t,n,s,r,o){const i=m=>ou(m,s,r),c=new Map(e.map(m=>[m.id,Gn(m)])),d=[],h=e.map(m=>({id:m.id,pos:n.get(m.id)??t.get(m.id)})).filter(m=>m.pos!=null).sort((m,w)=>m.pos.y-w.pos.y||m.pos.x-w.pos.x||m.id.localeCompare(w.id)),f=m=>(o==null?void 0:o.has(m))===!0&&!n.has(m);for(const{id:m,pos:w}of h){if(!f(m))continue;const{w:j,h:b}=i(m);d.push({x:w.x,y:w.y,w:j,h:b,sid:c.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:j,h:b}=i(m),k=c.get(m)??"_default";if(n.has(m)){d.push({x:w.x,y:w.y,w:j,h:b,sid:k});continue}let v=w.y;for(let N=0;N<d.length+1;N++){const S=d.find(E=>{const C=E.sid===k?Eh:B3,I=E.sid===k?Eh:ef;return w.x<E.x+E.w+C&&E.x<w.x+j+C&&v<E.y+E.h+I&&E.y<v+b+I});if(!S)break;v=S.y+S.h+(S.sid===k?Eh:ef)}v!==w.y&&(t.set(m,{x:w.x,y:v}),p.push(m)),d.push({x:w.x,y:v,w:j,h:b,sid:k})}return p}function Nle(e,t,n,s,r,o=!1,i){const d=B3+1,h=ef+1,f=8,p=1.75,m=200,w=.7,j=.01,b=M=>ou(M,s,i),k=M=>n.get(M)??t.get(M),v=Vf(e,M=>k(M.id)!=null),N=[],S=new Set,E=new Set,C=r.size===0;for(const M of[...v.keys()].sort()){const q=v.get(M);let A=1/0,D=1/0,P=-1/0,K=-1/0,G=!1;for(const B of q){const Z=k(B.id),{w:V,h:X}=b(B.id);A=Math.min(A,Z.x),D=Math.min(D,Z.y),P=Math.max(P,Z.x+V),K=Math.max(K,Z.y+X),n.has(B.id)&&(G=!0)}const W=P-A,H=K-D;E.add(M);const F=r.get(M);F&&(W>F.w+f||H>F.h+f)&&S.add(M),r.set(M,{w:W,h:H}),N.push({sid:M,members:q.map(B=>B.id),x:A,y:D,w:W,h:H,anchored:G,mass:1})}for(const M of[...r.keys()])E.has(M)||r.delete(M);if(o||C)return[];let I=!1;for(let M=0;M<N.length&&!I;M++)for(let q=M+1;q<N.length;q++){const A=N[M],D=N[q];if(!(A.anchored&&D.anchored)&&Math.abs(A.x+A.w/2-(D.x+D.w/2))<(A.w+D.w)/2+d&&Math.abs(A.y+A.h/2-(D.y+D.h/2))<(A.h+D.h)/2+h){I=!0;break}}if(S.size===0&&!I)return[];if(S.size>0)for(const M of N)S.has(M.sid)&&(M.mass=8);else for(const M of N)M.mass=Math.max(1,M.w*M.h/(au*F3));const R=new Map(N.map(M=>[M.sid,M.x])),$=new Map(N.map(M=>[M.sid,M.y])),L=new Map(N.map(M=>[M.sid,Math.min(0,M.x)])),U=new Map(N.map(M=>[M.sid,Math.min(0,M.y)]));for(let M=0;M<m;M++){const q=new Map,A=new Map;let D=0;for(let P=0;P<N.length;P++)for(let K=P+1;K<N.length;K++){const G=N[P],W=N[K];if(G.anchored&&W.anchored)continue;const H=G.x+G.w/2,F=G.y+G.h/2,B=W.x+W.w/2,Z=W.y+W.h/2,V=(G.w+W.w)/2+d-Math.abs(H-B),X=(G.h+W.h)/2+h-Math.abs(F-Z);if(V<=0||X<=0)continue;const Y=(Le,Qe)=>!Le.anchored&&!(Qe<0&&Le.x<=L.get(Le.sid)),J=(Le,Qe)=>!Le.anchored&&!(Qe<0&&Le.y<=U.get(Le.sid)),ee=(Le,Qe,je)=>{const Ae=Le===Qe,De=Ae?G.sid<W.sid?-1:1:Math.sign(Le-Qe);return je(G,De)||je(W,-De)?De:Ae&&(je(G,-De)||je(W,De))?-De:0},ne=ee(H,B,Y),le=ee(F,Z,J),de=ne!==0,ue=le!==0;if(!de&&!ue)continue;const re=de&&(!ue||V*p<X),[pe,ye,_e,he]=re?[ne,V,q,Y]:[le,X,A,J],ae=he(G,pe),ge=he(W,-pe),Se=G.mass,me=W.mass,$e=ae?ge?me/(Se+me):1:0,Pe=ge?ae?Se/(Se+me):1:0,qe=ye*w;_e.set(G.sid,(_e.get(G.sid)??0)+pe*qe*$e),_e.set(W.sid,(_e.get(W.sid)??0)-pe*qe*Pe),D+=qe}for(const P of N)P.anchored||(P.x=Math.max(L.get(P.sid),P.x+(q.get(P.sid)??0)),P.y=Math.max(U.get(P.sid),P.y+(A.get(P.sid)??0)));if(D<j)break}const O=[];for(const M of N){const q=M.x-R.get(M.sid),A=M.y-$.get(M.sid);if(!(Math.abs(q)<1&&Math.abs(A)<1)){for(const D of M.members){if(n.has(D))continue;const P=t.get(D);P&&t.set(D,{x:P.x+q,y:P.y+A})}O.push(M.sid)}}return O}function Sle(e,t,n,s,r,o){const i=new F$.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(v=>!r.has(v)),d=new Set(c);for(const v of c){const{w:N,h:S}=ou(v,s,o);i.setNode(v,{width:N,height:S})}for(const v of t)d.has(v.source)&&d.has(v.target)&&i.setEdge(v.source,v.target);F$.layout(i);const h=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const v of c){const N=i.node(v);if(!N)continue;const{w:S,h:E}=nf(v,s),C=ou(v,s,o),I=N.x-C.w/2,R=N.y-C.h/2;h.set(v,{x:I,y:R}),I<f&&(f=I),R<p&&(p=R),I+S>m&&(m=I+S),R+E>w&&(w=R+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[v,N]of h)h.set(v,{x:N.x-f,y:N.y-p});const j=Number.isFinite(m)?m-f:0,b=Number.isFinite(w)?w-p:0;let k=null;for(const v of e){const N=r.get(v);if(!N)continue;const{w:S,h:E}=nf(v,s);k=k===null?{minX:N.x,minY:N.y,maxX:N.x+S,maxY:N.y+E}:{minX:Math.min(k.minX,N.x),minY:Math.min(k.minY,N.y),maxX:Math.max(k.maxX,N.x+S),maxY:Math.max(k.maxY,N.y+E)}}return{positions:h,width:j,height:b,pinnedBox:k}}function AD(e,t,n){const s=n.direction??"LR",r=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,c=Vf(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...Sle(c.get(f).map(p=>p.id),t,s,o,r,i)})),gap:q3(e,o)}}const MD=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+tf,_le=e=>e.reduce((t,n)=>t+n.height,0)+Qi*Math.max(0,e.length-1);function E0(e,t,n,s){const r=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+Qi;return h},o=[];for(let d=0;d<e.length;d++){let h=-Qi;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+Qi)}o.sort((d,h)=>d-h);const i=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;r(o[p]).length<=d?f=p:h=p+1}return r(o[h])};let c=[e];if(n>0&&s>0){const d=f=>hK(f.reduce((p,m)=>p+MD(m),0)+t*(f.length-1),Math.max(...f.map(_le)),n,s);let h=d(c);for(let f=2;f<=e.length;f++){const p=i(f),m=d(p);m>h+1e-9&&(h=m,c=p)}}return c}function Ele(e,t,n,s,r){if(!(s.width>0&&s.height>0&&r.width>0&&r.height>0))return!1;const{laid:o,gap:i}=AD(e,t,n);return o.length<2?!1:E0(o,i,s.width,s.height).length!==E0(o,i,r.width,r.height).length}function Cle(e,t,n={}){const s=n.pinned??new Map,{laid:r,gap:o}=AD(e,t,n),i=E0(r,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of i){const f=MD(h);let p=0;for(const{positions:m,height:w,pinnedBox:j}of h){for(const[k,v]of m)c.set(k,{x:v.x+d,y:v.y+p});let b=p+w;j&&j.maxY>b&&j.minX<d+f&&d<j.maxX&&(b=j.maxY),p=b+Qi}d+=f+o}return e.map(h=>{const f=s.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function $h(e,t,n){return!t.has(e)||n.has(e)}function Tle(e,t,n,s){return!t.has(e)&&$h(e,n,s)}function Rle(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function B$(e,t,n,s){n.set(e,t),s.delete(e)}const Ale=300,q$=130,Mle=160,U$=new WeakMap;function $le(e,t){let n=U$.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:s9(e.agents.values()),groups:$f(e.agents.values())},U$.set(e,n));const{byId:s,branches:r,groups:o}=n;return i=>{let c=s.get(i.id);if(!c){const d=i.kind==="root"?r.get(i.sessionId):void 0;c=d?{...i,onOpenContext:t,branch:d}:{...i,onOpenContext:t},c.canvasSessionId=o.get(i.id),s.set(i.id,c)}return c}}function Nj(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 Ile(e,t){const n=i=>Gn(i),s=new Map;for(const i of e){const c=n(i),d=i.position.x+(i.width??au),h=s.get(c);h?(h.minX=Math.min(h.minX,i.position.x),h.maxX=Math.max(h.maxX,d),h.minY=Math.min(h.minY,i.position.y)):s.set(c,{minX:i.position.x,maxX:d,minY:i.position.y})}const r=[];for(const[i,c]of[...s].sort((d,h)=>d[1].minX-h[1].minX)){const d=r[r.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:i,top:c.minY})):r.push({maxX:c.maxX,sessions:[{sid:i,top:c.minY}]})}const o=new Map;for(const i of r)for(const{sid:c}of i.sessions.sort((d,h)=>d.top-h.top))o.set(c,o.size);return e.slice().sort((i,c)=>o.get(n(i))-o.get(n(c))||t(i)-t(c)||i.position.y-c.position.y||i.position.x-c.position.x)}function Lle(e,t){var s;let n=0;for(let r=t.parentId;r!=null&&n<e.agents.size;r=(s=e.agents.get(r))==null?void 0:s.parentId)n++;return n}function Ole(e,t,n,s,r,o,i,c,d,h,f,p,m,w,j,b,k,v,N,S){var G,W,H,F;const E=[],C=[],I=$le(e,v);for(const B of e.agents.values()){if(!k.has(B.id))continue;const Z=B.exitAt!=null,V=b!=null&&!b.has(B.id),X=[Z?"rf-exiting":"",V?"rf-spotlit-out":"",j.has(B.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,Y=o.get(B.id);if(E.push({id:B.id,type:"agent",position:{x:0,y:0},data:I(B),className:X,ariaLabel:m7(B,t,j.has(B.id)),...Y?{width:Y.width,height:Y.height}:null}),B.parentId&&k.has(B.parentId)){const ne=eu(B.sessionId),le=Z,de=j.size>0&&(j.has(B.id)||j.has(B.parentId)),ue=b!=null&&!b.has(B.id)&&!b.has(B.parentId),re=B.state==="active"?2:1.5,pe=de?re+1.5:re,ye=le?.2:ue?.12:1,_e=["sess-edge",B.state==="active"?"sess-live":"sess-idle",le?"rf-edge-exiting":"",de?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${B.parentId}->${B.id}`,source:B.parentId,target:B.id,animated:(B.state==="active"||de)&&!le,type:"smoothstep",style:{"--session-hue":ne,strokeWidth:`calc(${pe}px * var(--edge-k, 1))`,opacity:ye,transition:"var(--edge-transition)"},className:_e})}const J=B.kind==="root"?qf(B):null,ee=J?J.key:null;if(J&&ee&&!G7(ee)){const ne=v1(B.id),le=eu(B.sessionId),de=o.get(ne);E.push({id:ne,type:"recapNote",position:{x:0,y:0},data:{sessionId:B.sessionId,canvasSessionId:I(B).canvasSessionId,parentId:B.id,note:J,noteKey:ee,hue:le},className:V?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:J.kind==="recap"?`Claude Code's recap for ${B.label}`:`${B.label}: ${Oa(J.kind)}`,...de?{width:de.width,height:de.height}:null}),C.push({id:`e:recap:${B.id}`,source:ne,target:B.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":le}})}}const R=Nj(e),$=S.size>0&&!(d&&N);$||S.clear();const L=E.filter(B=>B.data.provider==="codex"&&B.data.parentId).map(B=>`${B.id}:${Gn(B)}:${B.data.parentId}`).sort().join("|"),U=`${m}${L?`#codex:${L}`:""}#lanes:${mK(R)}${$?"#held":""}`,O=new Set(E.filter(B=>B.type==="recapNote").map(B=>B.id));for(const B of Array.from(f.keys()))N&&Z7(B)&&!O.has(B)&&!r.has(B)&&(f.delete(B),p.delete(B));const M=E.filter(B=>Tle(B.id,r,f,p));if(M.length>0||U!==w.current){if(M.length>0){for(const Z of M)S.delete(Z.id);const B=ble(Cle(E,C,{direction:"LR",pinned:r,measured:o,availableWidth:n,availableHeight:s,lanes:R}),r,Z=>$h(Z,f,p)?void 0:f.get(Z));for(const Z of B)$h(Z.id,f,p)&&B$(Z.id,Z.position,f,p);kle(E,f,r,o,new Set(M.filter(Z=>Z.type!=="recapNote").map(Z=>Z.id)),R,{width:n,height:s});for(const Z of M){if(Z.type!=="recapNote")continue;const V=(G=Z.data)==null?void 0:G.parentId;if(!V)continue;const X=r.get(V)??($h(V,f,p)?void 0:f.get(V));if(!X)continue;const Y=((W=o.get(Z.id))==null?void 0:W.width)??Ale,J=((H=o.get(Z.id))==null?void 0:H.height)??q$,ee=((F=o.get(V))==null?void 0:F.height)??q$;B$(Z.id,{x:X.x-Mle-Y,y:X.y+(ee-J)/2},f,p)}}jle(E,f,r,o,R,$?S:void 0),w.current=U}const q=Nle(E,f,r,o,i,!d||h,R);q.length>0&&c(q);const A=eae(e.agents.values());N&&ph(f,A),ph(p,A),N&&ph(r,A),ph(o,Qre(e.agents.values()));const D=[];let P=!1;for(const B of E){let Z=r.get(B.id)??f.get(B.id);Z||(Z=Rle(B.id,f,p),P=!0),D.push({...B,position:Z})}return P&&(w.current=""),{nodes:Ile(D,B=>{if(B.type==="recapNote")return-1;const Z=e.agents.get(B.id);return Z?Lle(e,Z):0}),edges:C}}function Ple(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Dle(e,t,n){var i;if(e.length===0)return null;const s=Ple(e),r=t?s.findIndex(c=>c.id===t):-1,o=r===-1?n===1?0:s.length-1:(r+n+s.length)%s.length;return((i=s[o])==null?void 0:i.id)??null}const Fle=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function Ble(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Fle.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const qle=new Set(["","BODY","HTML","#DOCUMENT"]);function Ule(e){return!e||$o(e)?!1:!qle.has(String(e.tagName??"").toUpperCase())}const $D="react-flow__node";function Sj(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,$D))===!0}function ID(e){try{const t=document.querySelector(`.${$D}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Oo=null,Ki=null;const C0=new Set,T0=()=>{for(const e of C0)e()},Wle=e=>(C0.add(e),()=>{C0.delete(e)}),W$=()=>Oo,Hle=90;function LD(e){!Ki||e!=null&&Ki.at.id!==e||(clearTimeout(Ki.timer),Ki=null)}function OD(e,t,n="pointer"){LD();const s={id:e,anchor:t,by:n};if(Oo||n==="focus"){Oo=s,T0();return}Ki={at:s,timer:setTimeout(()=>{Ki=null,Oo=s,T0()},Hle)}}function Ua(e){LD(e),!(!Oo||e!=null&&Oo.id!==e)&&(Oo=null,T0())}function zle({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const r=y.useSyncExternalStore(Wle,W$,W$),o=r?e(r.id):void 0,i=r&&!o?t(r.id):void 0,c=r!=null&&(!o&&!i||!r.anchor.isConnected);return y.useEffect(()=>{c&&r&&Ua(r.id)},[c,r]),!r||c?null:o?a.jsx(Gle,{a:o,anchor:r.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},r.id):i?a.jsx(Vle,{r:i,anchor:r.anchor,bounds:s},r.id):null}function PD(e,t){const n=y.useRef(null),s=y.useCallback(()=>{const r=n.current;if(!r||!e.isConnected)return;r.style.maxHeight="";const o=B1(e.getBoundingClientRect(),{width:r.offsetWidth,height:r.offsetHeight},t());r.style.top=`${o.top}px`,r.style.left=`${o.left}px`,r.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,r.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{s()}),n}function Vle({r:e,anchor:t,bounds:n}){const s=PD(t,n),r=Go(3e4),o=e.note,i=o.kind==="recap",c=Zh(o.at,r);return wt.createPortal(a.jsxs("div",{ref:s,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(Gh,{recap:i}),Oa(o.kind)]}),a.jsx("span",{className:"node-peek-time",title:c.title,children:c.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:[Uf(o)," · ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:o.text}),o.reply&&a.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function Gle({a:e,anchor:t,parentLabel:n,bounds:s}){const r=PD(t,s),o=Go(1e3),i=w1(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(b=>!b.endedAt).length,h=In(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Mn(e.waiting),m=ZO(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",j=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${gt(f)} tok`:null,h>0?`${Xe(h)}${nu(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return wt.createPortal(a.jsxs("div",{ref:r,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",title:e.label,children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",cl(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":qk(e.state),children:[a.jsx(y3,{kind:qk(e.state)}),il(e.state)]}),a.jsx("span",{children:w}),e.model?a.jsx("span",{children:Pf(e.model,e.effort)}):null]}),e.kind==="root"&&i.face&&a.jsx("p",{className:"node-peek-title",title:i.face,children:i.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(j1,{}),a.jsxs("span",{className:"node-peek-said",title:zh(e.waiting),children:[a.jsx("span",{className:"node-peek-since",children:a.jsx("b",{children:cl(e.waiting.since,void 0,o)})}),zh(e.waiting)]})]}),m&&a.jsxs("p",{className:"node-peek-blind",children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),m.label]}),a.jsxs("p",{className:"node-peek-facts",children:[j,c>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:u3(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Kle(e){const t=e.minZoom??rre,n=e.maxZoom??are,s=e.fill??.9,r=e.insets.left,o=e.insets.top,i=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(i/Math.max(1,d.width),c/Math.max(1,d.height))*s,p=Math.max(t,Math.min(n,f)),m=(w,j,b,k,v,N)=>{let S=w+(j-k*p)/2-b*p;const E=v*p+S,C=(v+N)*p+S;return N*p<=j?E<w?S+=w-E:C>w+j&&(S-=C-(w+j)):S+=w-E,S};return{x:m(r,i,d.x,d.width,h.x,h.width),y:m(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Yle(e){let t=1/0,n=1/0,s=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),s=Math.max(s,o.x+o.width),r=Math.max(r,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:s-t,height:r-n}:null}function zn(e){const t=y.useRef(e);return t.current=e,t}const R0=80,A0=.86;function DD(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const s of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const r=s.getBoundingClientRect();r.width>0&&r.left>t.left&&(n=Math.min(n,r.left))}return Math.max(0,t.right-n)}function Xle({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:r,detailShown:o}){const[i,c]=y.useState(0);y.useEffect(()=>{const p=DD(e.current);c(m=>Math.abs(m-p)>40?p:m)},[n,s,r,o,t.w]);const d=zn(i),h=t.w>0?Math.max(0,(t.w-i-R0*2)*A0):0,f=t.h>0?Math.max(0,(t.h-R0*2)*A0):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const H$=1e-6;function Hc(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function z$(e,t,n){return Math.abs(e[2]-t[2])<=H$*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=H$*n}function Zle(e,t){const n=t[2]/e[2];return s=>[e[0]+(t[0]-e[0])*s,e[1]+(t[1]-e[1])*s,e[2]*n**s]}function Jle(e,t,n){const s=e(0),r=e(.5),o=e(1);if(!Hc(s)||!Hc(r)||!Hc(o))return!1;const i=Math.max(t[2],n[2]);return z$(s,t,i)&&z$(o,n,i)}function Qle(e){return(t,n)=>{const s=e(t,n),r=Jle(s,t,n)?s:Zle(t,n);let o=Hc(t)?t:n;return i=>{const c=r(i);return Hc(c)&&(o=c),o}}}function ece(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const V$=new WeakSet,FD=420;function tce(){const e=ml(),t=$t(),n=y.useCallback((h,f)=>{if(!ece(h))return;if(Pk({durationMs:f,documentHidden:document.hidden})){e.setViewport(h,{duration:f});return}const{d3Zoom:p,d3Selection:m}=t.getState(),w=m==null?void 0:m.property("__zoom");if(p&&m&&w&&w.k>0&&h.zoom>0){p.transform(m,w.scale(h.zoom/w.k).translate((h.x-w.x)/h.zoom,(h.y-w.y)/h.zoom));return}e.setViewport(h,{duration:0})},[e,t]);y.useEffect(()=>{const h=f=>{!f||V$.has(f)||(V$.add(f),f.interpolate(Qle(f.interpolate())))};return h(t.getState().d3Zoom),t.subscribe(f=>h(f.d3Zoom))},[t]);const s=y.useRef(null),r=y.useRef(0),o=y.useRef(0),i=y.useCallback((h,f)=>{const p=++r.current;return o.current=Date.now(),n(h,f),s.current=Pk({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),c=y.useCallback((h=500)=>{const f=R0,p=1,m=.2,w=A0;try{const j=document.querySelector(".canvas-wrap"),b=Array.from(document.querySelectorAll(".react-flow__node")).filter(D=>D.offsetWidth>0);if(!j||b.length===0)return;const k=j.getBoundingClientRect(),v=e.getViewport();if(!Number.isFinite(v.zoom)||v.zoom<=0)return;const N=new Map(e.getNodes().map(D=>[D.id,D])),S=b.flatMap(D=>{const P=N.get(D.dataset.id??"");if(!P)return[];const K=P.positionAbsolute??P.position,G=P.width??D.offsetWidth,W=P.height??D.offsetHeight;return G>0&&W>0?[{left:K.x,right:K.x+G,top:K.y,bottom:K.y+W}]:[]});if(S.length===0)return;const E=Math.min(...S.map(D=>D.left)),C=Math.max(...S.map(D=>D.right)),I=Math.min(...S.map(D=>D.top)),R=Math.max(...S.map(D=>D.bottom)),$=C-E,L=R-I;if(!($>0&&L>0))return;const U=DD(j),O=D=>Math.max(m,Math.min(p,(k.width-U-f*2)/($+D)*w,(k.height-f*2)/L*w)),M=sre(O(FD),O(0),v4(A1[M1()])),q={x:f-E*M,y:(k.height>k.width-U?f:Math.max(f,(k.height-L*M)/2))-I*M,zoom:M},A=i(q,h);window.setTimeout(()=>{var D;try{if(((D=s.current)==null?void 0:D.target)===q&&(s.current=null),r.current!==A)return;const P=e.getViewport();(Math.abs(P.zoom-M)>.01||Math.abs(P.x-q.x)>2||Math.abs(P.y-q.y)>2)&&n(q,0)}catch{}},h+60)}catch{}},[e,n,i]);y.useEffect(()=>{const h=()=>{if(!document.hidden)return;const f=s.current;if(s.current=null,!(!f||Date.now()>f.until)){try{n(f.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",h),()=>document.removeEventListener("visibilitychange",h)},[n]);const d=y.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:i,fitLeft:c,currentViewport:d,cameraEpochRef:r,lastFitTimeRef:o}}const nce=450;function sce({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:s,railInsetRef:r,moveCamera:o,disableAutoFit:i,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(j=>{const b=e.current,k=t.current.agents.get(j);if(!b||!k)return;const v=Nj(t.current),N=($,L)=>{const U=n.current.get($.id);if(!U)return null;const O=L&&v.has($.id)?FD:0;return{x:$.position.x,y:$.position.y,width:U.width+O,height:U.height}},S=s.current.find($=>$.id===j),E=S?N(S,!1):null;if(!E)return;const C=[];for(const $ of s.current){if($.type!=="agent"&&$.type!=="recapNote"||Gn($)!==Gn(S))continue;const L=N($,$.type==="agent");L&&C.push(L)}const I=b.getBoundingClientRect(),R=Kle({pane:{width:I.width,height:I.height},insets:{top:56,left:72,bottom:32,right:r.current+32},context:Yle(C)??E,anchor:E});Ua(),i(),c.current={id:j,at:Date.now()},o(R,nce)},[o,i]);d.current=p;const m=y.useCallback(j=>{const b=s.current.filter(S=>S.type==="agent"),k=Dle(b.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,j),v=k?b.find(S=>S.id===k):void 0;if(!v)return;const N=Sj(document.activeElement);h(v.id,!1),window.setTimeout(()=>{try{p(v.id)}catch{}N&&ID(v.id)},30)},[h,p]),w=y.useCallback(j=>{h(j,!1),window.setTimeout(()=>{try{p(j)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function rce({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:s}){const r=y.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=y.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),i=y.useCallback(d=>{var p;const h=e.current.find(m=>m.id===d&&m.type==="recapNote");if(!h)return;const f=h.data;return{note:f.note,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),c=y.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-s.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:r,peekLabel:o,peekRecap:i,peekBounds:c}}function ace(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[r,o]of e.positions)n.set(r,o),t.has(r)&&s.set(r,o);return{positions:n,pinned:s,restored:new Set(n.keys())}}function G$(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function oce(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 r=G$(n);return{positions:r,pins:r.map(([o])=>o)}}const s=n;return{positions:G$(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function ice(e,t){const n={};for(const[s,r]of e)n[s]=r;for(const[s,r]of t)n[s]=r;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function lce(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 Lu="agent-dag.layout",Ou="agent-dag.layoutFrame",Pu="agent-dag.viewport";function cce(){return oce(Ve(Lu))}function nl(e,t){ze(Lu,ice(e,t))}function uce(){return lce(Ve(Ou))}function BD(e){ze(Ou,JSON.stringify(e))}function dce(){return jH(Ve(Pu))}function hce(e){ze(Pu,JSON.stringify(e))}function fce(){return{layout:Ve(Lu),frame:Ve(Ou),viewport:Ve(Pu)}}function pce(e){const t=(n,s)=>s===null?hr(n):ze(n,s);t(Lu,e.layout),t(Ou,e.frame),t(Pu,e.viewport)}function qD(){hr(Lu),hr(Pu),hr(Ou)}function mce({fitLeft:e,moveCamera:t,currentViewport:n}){const s=y.useState(()=>ace(cce()))[0],r=y.useRef(s.pinned),o=y.useRef(s.positions),i=y.useRef(new Set),c=y.useRef(""),[d,h]=y.useState(0),f=y.useState(uce)[0],p=y.useRef(f),[m,w]=y.useState(!1),[j,b]=y.useState(""),k=y.useState(()=>sK(L=>{w(L),L||b(U=>U===VE?U:"")}))[0];y.useEffect(()=>()=>k.close(),[k]),y.useEffect(()=>{if(typeof document>"u")return;const L=()=>document.hidden?k.hold("hidden"):k.release("hidden");return document.addEventListener("visibilitychange",L),()=>document.removeEventListener("visibilitychange",L)},[k]);const v=y.useRef(null),N=()=>({positions:o.current,pinned:r.current,provisional:i.current,layoutSig:c}),S=y.useCallback(()=>{k.open(k.snapshot??XG(N(),fce(),n())),b(tK),r.current.clear(),o.current.clear(),c.current="",qD(),h(L=>L+1),v.current!=null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{v.current=null,nl(o.current,r.current),p.current&&BD(p.current),e(500)},80)},[e,n,k]),E=y.useCallback(()=>{const L=k.take();return L?(v.current!=null&&window.clearTimeout(v.current),v.current=null,ZG(L,N()),pce(L.stored),h(U=>U+1),L.viewport&&t(L.viewport,500),b(VE),!0):!1},[t,k]),C=y.useCallback(()=>k.close(),[k]),I=y.useCallback(L=>k.hold(L),[k]),R=y.useCallback(L=>k.release(L),[k]);return{restoredLayout:s,pinnedRef:r,positionsRef:o,provisionalRef:i,lastLayoutSigRef:c,layoutEpoch:d,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:m,said:j,undo:E,dismiss:C,hold:I,release:R}}}function gce(e,t){const{positionsRef:n,pinnedRef:s}=t,r=y.useRef(null);y.useEffect(()=>(r.current!=null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{nl(n.current,s.current)},1500),()=>{r.current!=null&&window.clearTimeout(r.current)}),[e])}function yce({nodes:e,edges:t,settled:n,dragging:s,availableWidth:r,availableHeight:o,layout:i,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:m,focusAgentRef:w,autoFitDisabledRef:j}){const{lastLayoutFrameRef:b,pinnedRef:k,positionsRef:v,provisionalRef:N,lastLayoutSigRef:S,setLayoutEpoch:E}=i,{applyViewport:C,fitLeft:I,cameraEpochRef:R,lastFitTimeRef:$}=c;y.useEffect(()=>{if(!n||s)return;const L={width:r,height:o};if(!(L.width>0&&L.height>0))return;const U=b.current;if(b.current=L,BD(L),!U||U.width===L.width&&U.height===L.height)return;const O={direction:"LR",pinned:k.current,measured:h.current,lanes:Nj(f.current)},M=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!Ele(e,t,O,U,L)){const D=R.current,P=window.setTimeout(()=>{var K;R.current===D&&(j.current?M&&((K=p.current)==null?void 0:K.id)===M&&w.current(M):I(500))},80);return()=>window.clearTimeout(P)}const q=M??m.current,A=q?k.current.get(q)??v.current.get(q):void 0;for(const D of Array.from(v.current.keys()))k.current.has(D)||v.current.delete(D);N.current.clear(),S.current="",E(D=>D+1),window.setTimeout(()=>{if(nl(v.current,k.current),j.current){if(M){w.current(M);return}const D=q?k.current.get(q)??v.current.get(q):void 0;if(A&&D&&(D.x!==A.x||D.y!==A.y)){const P=d.getViewport();R.current+=1,C({x:P.x-(D.x-A.x)*P.zoom,y:P.y-(D.y-A.y)*P.zoom,zoom:P.zoom},0),$.current=Date.now()}return}I(500)},80)},[r,o,n,s,I,d,C])}function wce(e,t,n,s,r){const o=[];for(const i of e)!Gf(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${r}`}const _j="agent-dag.removedNodes";function xce(e){try{const t=JSON.parse((e==null?void 0:e.getItem(_j))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function uk(e,t){try{e==null||e.setItem(_j,JSON.stringify([...t]))}catch{}}function UD(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),s=new Set(t),r=o=>{if(s.has(o))return!0;const i=new Set([o]);let c=n.get(o);for(;c&&!i.has(c);){if(s.has(c))return s.add(o),!0;i.add(c),c=n.get(c)}return!1};return o=>r(o.id)||r(o.sessionId??o.id)}function vce(e,t){if(t.size===0)return new Set;const n=[...e],s=UD(n,t);return new Set(n.filter(s).map(r=>r.id))}function bce(e,t,n){const s=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),r=UD(e.map(s),n),o=e.filter(c=>!r(s(c))),i=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>i.has(c.source)&&i.has(c.target))}}function kce(e,t){let n=null;for(const s of t)e.has(s)&&(n??(n=new Set(e)),n.delete(s));return n??e}function jce(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Nce(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 s=e.prompts[e.prompts.length-1];return s&&s.at>t&&(t=s.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function Sce(e,t,n){let s=null;for(const r of t)e.has(r)||(s??(s=new Map(e)),s.set(r,n));for(const r of e.keys())t.has(r)||(s??(s=new Map(e)),s.delete(r));return s??e}function _ce(e,t,n,s){if(n.size===0)return[];let r=1/0;for(const i of s.values())i<r&&(r=i);const o=new Set;for(const i of t){const c=e.get(i);if(!c)continue;const d=Nce(c);if(d<=r)continue;const h=[],f=new Set,p=w=>{var j;for(let b=w;b&&!f.has(b);b=(j=e.get(b))==null?void 0:j.parentId)f.add(b),n.has(b)&&h.push(b)};p(c.id),p(c.sessionId);let m=-1/0;for(const w of h)m=Math.max(m,s.get(w)??1/0);if(d>m)for(const w of h)o.add(w)}return[...o]}const xf="sessionGroup";function Ece(e,t){var s,r;if(e.type===xf)return"transparent";if(Mn((s=e.data)==null?void 0:s.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(r=e.data)==null?void 0:r.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const mh=To;function Cce(e){const t=new Map;for(const s of e){const r=s.data;if(!(r!=null&&r.sessionId)||r.exitAt!=null)continue;const o=s.width,i=s.height;if(o==null||i==null)continue;const c=s.position.x,d=s.position.y,h=c+o,f=d+i,p=t.get(Gn(s));p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(Gn(s),{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[s,r]of t){const o=r.maxX-r.minX+mh*2,i=r.maxY-r.minY+mh*2;n.push({id:`group:${s}`,type:xf,position:{x:r.minX-mh,y:r.minY-mh},data:{sessionId:s,w:o,h:i},width:o,height:i,style:{width:o,height:i},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}function Tce(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let r=t;for(;r;){const i=e.agents.get(r);if(!(i!=null&&i.parentId)||s.has(i.parentId))break;s.add(i.parentId),r=i.parentId}let o=!0;for(;o;){o=!1;for(const i of e.agents.values())i.parentId&&s.has(i.parentId)&&!s.has(i.id)&&(s.add(i.id),o=!0)}return s}function Rce(e,t){const n=new Set;for(const s of t){const r=Tce(e,s);if(r)for(const o of r)n.add(o)}return n.size>0?n:null}function Ace({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:r}){return y.useMemo(()=>wce(e.current.agents.values(),t,n,s,r),[e.current,e.current.revision,t,s,r,n])}function Mce({stateRef:e,now:t,availableWidth:n,availableHeight:s,layout:r,measuredRef:o,onBubble:i,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:m,removedNodes:w,removedAgentIds:j,dragTick:b,dragPatchRef:k,dragMoveTick:v}){const{pinnedRef:N,positionsRef:S,provisionalRef:E,lastLayoutSigRef:C,restoredLayout:I,layoutEpoch:R}=r,$=y.useMemo(()=>Rce(e.current,f),[e.current,e.current.revision,f]),L=y.useMemo(()=>{const P=uY(e.current,t);for(const K of j)P.delete(K);return P},[e.current,e.current.revision,t,j]),U=y.useRef(new Map),O=J7(),{nodes:M,edges:q}=y.useMemo(()=>{const P=Ole(e.current,t,n,s,N.current,o.current,U.current,i,c,d,S.current,E.current,h,C,f,$,L,p,m,I.restored);return bce(P.nodes,P.edges,w)},[e.current,e.current.revision,t,n,s,c,d,h,f,$,L,p,b,O,w,R,m]),A=y.useMemo(()=>Cce(M),[M]),D=y.useMemo(()=>{const P=[...A,...M],K=k.current;return!K||K.size===0?P:P.map(G=>{const W=K.get(G.id);return W?{...G,position:W}:G})},[A,M,v]);return{spotlightSet:$,visibleAgentIds:L,nodes:M,edges:q,allNodes:D}}function $ce(e,t,n){const s=e.x*t.zoom+t.x,r=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,i=(e.y+e.height)*t.zoom+t.y;return o>0&&s<n.width&&i>0&&r<n.height}function Ice({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let s=!1;for(const r of n)if(s=!0,$ce(r,t,e))return!1;return s}function Lce({layoutSig:e,rf:t,stateRef:n,measuredRef:s,pinnedRef:r,positionsRef:o,paneSizeRef:i,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),m=y.useRef("");y.useEffect(()=>{const w=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const j=n.current,b=Date.now(),k=[];for(const N of j.agents.values())Gf(N,b)&&k.push({id:N.id});if(k.length===0)return;const v=[];for(const{id:N}of k){const S=s.current.get(N),E=r.current.get(N)??o.current.get(N);!S||!E||v.push({x:E.x,y:E.y,width:S.width,height:S.height})}Ice({pane:i.current,viewport:t.getViewport(),boxes:v})&&f(600)},1500);return()=>clearInterval(w)},[t]),y.useEffect(()=>{if(m.current===e)return;const w=m.current;if(m.current=e,!w||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 Oce({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:r,primarySelectedId:o}){const[i,c]=y.useState(()=>xce(cr())),[d,h]=y.useState(null),f=y.useMemo(()=>vce(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=y.useCallback(N=>{const S=e.current.agents.get(N);S&&(c(E=>{const C=new Set(E);return C.add(N),uk(cr(),C),C}),h({id:N,label:S.label}),t.current.delete(N),n.current.delete(N),r())},[r]),m=y.useCallback(()=>{o&&p(o)},[o,p]),w=d&&i.has(d.id)?d:null;y.useEffect(()=>{var N;d&&((N=s.current)==null||N.focus())},[d]);const j=y.useCallback(N=>{const S=[...N];c(E=>{let C=null;for(const I of S)E.has(I)||(C??(C=new Set(E)),C.add(I));return C?(uk(cr(),C),C):E});for(const E of S)t.current.delete(E),n.current.delete(E)},[]),b=y.useCallback(N=>{const S=[...N];c(E=>{const C=kce(E,S);return C!==E&&uk(cr(),C),C})},[]),k=y.useCallback(()=>{b([...i]),h(null)},[b,i]),v=y.useCallback(()=>{c(new Set),h(null),hr(_j)},[]);return{removedNodes:i,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:j,bringBack:b,bringBackAll:k,forgetRemovals:v}}function Pce({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:r}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=Sce(o.current,s,Date.now());const i=[...jce(t,n),..._ce(e.current.agents,n,s,o.current)];i.length>0&&r(i)},[t,n,s,r])}const WD=[0,5,15,30,60],Ej="agent-dag.hide-finished-after",HD="agent-dag.hide-finished-turns",Dce=300,Fce=1e4;function Cj(e){const t=Number(e);return WD.includes(t)?t:0}function Bce(e){return e===0?"Never":`${e} min`}let Po=null;const $c=new Set;function zD(){for(const e of $c)e()}function K$(){return Po===null&&(Po=Cj(Ve(Ej))),Po}function qce(e){const t=Cj(String(e));Po!==t&&(Po=t,ze(Ej,String(t)),zD())}function Y$(e){if(e.key!==Ej)return;const t=Cj(e.newValue);t!==Po&&(Po=t,zD())}function Uce(e){var t;return $c.add(e),$c.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",Y$)),()=>{var n;$c.delete(e),$c.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",Y$))}}function Wce(e){try{const t=JSON.parse((e==null?void 0:e.getItem(HD))??"{}");return!t||typeof t!="object"||Array.isArray(t)?new Map:new Map(Object.entries(t).filter(n=>typeof n[1]=="number"))}catch{return new Map}}function X$(e,t){const n=[...t].sort((s,r)=>r[1]-s[1]).slice(0,Dce);try{e==null||e.setItem(HD,JSON.stringify(Object.fromEntries(n)))}catch{}}function VD(e){const t=new Map;for(const s of e){let r=t.get(s.sessionId);r||(r={endedAt:0,live:!1},t.set(s.sessionId,r)),s.kind==="root"&&Mn(s.waiting)&&(r.live=!0),s.state==="done"&&s.endedAt!=null?r.endedAt=Math.max(r.endedAt,s.endedAt):r.live=!0}const n=new Map;for(const[s,r]of t)!r.live&&r.endedAt>0&&n.set(s,r.endedAt);return n}function Hce(e,{afterMs:t,now:n,removed:s,handled:r,keep:o}){if(t<=0)return[];const i=[];for(const[c,d]of VD(e))n-d<t||s.has(c)||c===o||r.get(c)!==d&&i.push({id:c,endedAt:d});return i}function zce(e,t,n,s){const r=[...t].filter(c=>!n.has(c));if(r.length===0)return e;const o=VD(s);let i=null;for(const c of r){const d=o.get(c);d==null||e.get(c)===d||(i??(i=new Map(e)),i.set(c,d))}return i??e}function GD(){return y.useSyncExternalStore(Uce,K$,K$)}function Vce({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:r}){const o=GD(),[i]=y.useState(()=>Wce(cr())),c=y.useRef(i),d=y.useRef(t);y.useEffect(()=>{const h=zce(c.current,d.current,t,e.current.agents.values());d.current=t,h!==c.current&&(c.current=h,X$(cr(),h))},[t]),y.useEffect(()=>{if(!r||o===0)return;const h=()=>{const p=Hce(e.current.agents.values(),{afterMs:o*6e4,now:Date.now(),removed:t,handled:c.current,keep:s});if(p.length===0)return;const m=new Map(c.current);for(const{id:w,endedAt:j}of p)m.set(w,j);c.current=m,X$(cr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,Fce);return()=>window.clearInterval(f)},[r,o,t,s,n])}function Gce({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Ct}`:Ct,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const KD=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),YD=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Kce=Object.freeze([...new Set([...Object.values(KD),...Object.values(YD)])]),M0=new Map;function Z$(e){return M0.get(e)??e}async function Yce(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!M0.has(n))try{const s=await t(n),r=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!r.startsWith("image/"))return;M0.set(n,`data:${r};base64,${Xce(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function Xce(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Zce({stateRef:e,waitingSessions:t,live:n}){const s=y.useMemo(()=>o7(e.current.agents.values()),[e.current,e.current.revision]),r=y.useRef(null);y.useEffect(()=>{n&&Yce(Kce)},[n]),y.useEffect(()=>{const o=Gce({waiting:t.length,running:s,connected:n}),i=r.current;r.current=o,(i==null?void 0:i.title)!==o.title&&(document.title=o.title),(i==null?void 0:i.icon)!==o.icon&&XD(o.icon)},[t.length,s,n])}function XD(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=Z$(KD[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=Z$(YD[e]))}const Jce=1200,Qce=1e3;function dk(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<Jce?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<Qce}function eue({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:r,canvasRef:o,applyZoom:i}){const c=y.useState(()=>dce())[0];y.useEffect(()=>{if(!c)return;const j=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(j)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(j=>({hasSourceEvent:!!j,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:j=>{Ua(),dk(p(j))&&(n.current+=1),dk(p(j))&&s()},onMove:(j,b)=>{var k;r(),dk(p(j))&&s(),(k=o.current)==null||k.style.setProperty("--zoom",String(b.zoom)),i(b.zoom)==="detail"&&Ua(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>hce(b),250)}}}function tue({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:s,detailShown:r,focusAgent:o,draggingRef:i,lodRef:c}){const d=y.useRef(o);d.current=o;const[h]=y.useState(()=>z3({focus:b=>d.current(b),setTimeout:(b,k)=>window.setTimeout(b,k),clearTimeout:b=>window.clearTimeout(b)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(b,k)=>{if(k.type==="sessionGroup"){h.cancel(),e();return}const v=k.type==="recapNote"?k.data.parentId:k.id;t(v,b.shiftKey,!1),!b.shiftKey&&(n&&s(!1),vu()?h.hold(v):r?window.setTimeout(()=>{try{o(v)}catch{}},80):o(v))},onPaneClick:()=>{h.cancel(),Ua(),e()},onNodeDoubleClick:(b,k)=>{if(k.type!=="agent"&&k.type!=="recapNote")return;h.cancel();const v=k.type==="recapNote"?k.data.parentId:k.id;t(v,!1),window.setTimeout(()=>{try{o(v)}catch{}},80)},onNodeMouseEnter:(b,k)=>{k.type!=="agent"&&k.type!=="recapNote"||i.current||c.current==null||c.current==="detail"||OD(k.id,b.currentTarget)},onNodeMouseLeave:(b,k)=>Ua(k.id)}}function nue({settleAt:e,now:t,take:n,schedule:s,cancel:r}){let o=null;const i=()=>{o!=null&&r(o),o=null};return{read(c,d){i();const h=e()-t();if(h>0){o=s(()=>{o=null,n(c,d)},h);return}n(c,d)},dispose:i}}function sue(e){const t=y.useRef(null),n=y.useRef(null),[s,r]=y.useState({w:0,h:0});return y.useEffect(()=>{const o=n.current;if(!o||typeof ResizeObserver>"u")return;const i=nue({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(d,h)=>r(f=>Math.abs(f.w-d)>40||Math.abs(f.h-h)>40?{w:d,h}:f),schedule:(d,h)=>window.setTimeout(d,h),cancel:d=>window.clearTimeout(d)}),c=new ResizeObserver(d=>{var f;const h=(f=d[0])==null?void 0:f.contentRect;h&&(t.current={width:h.width,height:h.height},i.read(h.width,h.height))});return c.observe(o),t.current={width:o.clientWidth,height:o.clientHeight},r({w:o.clientWidth,h:o.clientHeight}),()=>{c.disconnect(),i.dispose()}},[]),{canvasRef:n,canvasSize:s,paneSizeRef:t}}function rue(e){const t=$t(),n=y.useRef(new Map),s=y.useRef(0),r=y.useRef(new Map),[o,i]=y.useState(0),[c,d]=y.useState(0),h=y.useRef(null),f=y.useCallback(()=>{h.current=null;let m=!1;for(const j of t.getState().nodeInternals.values()){if(j.type===xf)continue;const b=j.width,k=j.height;if(b==null||k==null)continue;const v=r.current.get(j.id);(!v||Math.abs(v.width-b)>4||Math.abs(v.height-k)>4)&&(r.current.set(j.id,{width:b,height:k}),n.current.set(j.id,{width:b,height:k}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const j of document.querySelectorAll(".react-flow__node[data-id]")){if(j.classList.contains(`react-flow__node-${xf}`))continue;const b=j.getAttribute("data-id");if(!b)continue;const k=j.offsetWidth,v=j.offsetHeight;if(!k||!v)continue;const N=n.current.get(b);(!N||Math.abs(N.width-k)>4||Math.abs(N.height-v)>4)&&(n.current.set(b,{width:k,height:v}),w=!0)}w&&d(j=>j+1)},[t,e]),p=y.useCallback(()=>{h.current||(h.current=document.visibilityState==="hidden"?{frame:0,timer:window.setTimeout(f,32)}:{frame:requestAnimationFrame(f),timer:0})},[f]);return y.useEffect(()=>{const m=t.subscribe(p);return p(),()=>{m();const w=h.current;w&&(cancelAnimationFrame(w.frame),window.clearTimeout(w.timer),h.current=null)}},[t,p]),y.useEffect(p),{measuredRef:n,measuredVersionRef:s,sizeVersion:o,domSizeVersion:c}}function aue(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function oue(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},s=r=>{e.current=performance.now()-t<250?r.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",s,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",s,!0)}},[]),e}const Aa=[{id:"general",label:"General",note:"The board, updates, and the settings that live in their own panels."},{id:"appearance",label:"Appearance",note:"The colour theme and the character on the canvas."},{id:"reading",label:"Text & density",note:"Make the deck comfortable to read. Changes apply immediately and stay separate from canvas zoom."},{id:"keyboard",label:"Keyboard",note:"Every shortcut, and whether single keys answer."},{id:"notifications",label:"Notifications",note:"How the deck reaches you while you are not looking at it."},{id:"sounds",label:"Sounds",note:"What plays when a turn finishes and when Claude asks."},{id:"data",label:"Data",note:"What the deck keeps on this device."},{id:"about",label:"About",note:"The version you are running, and where to say what you think of it."}];function iue(e){return Math.max(0,Aa.findIndex(t=>t.id===e))}const J$="settings-tab-";function lue(e,t){return e!=null&&e.startsWith(J$)?e===`${J$}${t}`?null:t:null}const cue={open:!1,section:"general"};function uue(e,t){return{open:!0,section:t??e.section}}function vo(e,t){return()=>{e(),t()}}function due(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function hue(e){return Eu(e)?"⌘,":"Ctrl+,"}function fue(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey)return!1;const t=e.key.toLowerCase();return t==="f"||!/^[a-z]$/.test(t)&&e.code==="KeyF"}const Du={light:{name:"Light",colorScheme:"light"},dark:{name:"Dark",colorScheme:"dark"},"rider-black":{name:"Rider Black",colorScheme:"dark"},"vscode-black":{name:"VS Code Black",colorScheme:"dark"},omarchy:{name:"Omarchy",colorScheme:"dark"},matrix:{name:"Matrix",colorScheme:"dark"},"black-contrast":{name:"Black Contrast",colorScheme:"dark"},"white-contrast":{name:"White Contrast",colorScheme:"light"},"catppuccin-mocha":{name:"Catppuccin Mocha",colorScheme:"dark"},"gruvbox-dark":{name:"Gruvbox Dark",colorScheme:"dark"},"gruvbox-light":{name:"Gruvbox Light",colorScheme:"light"},"gruvbox-material":{name:"Gruvbox Material",colorScheme:"dark"}},Wr=Object.keys(Du);function $0(e){return Wr[(Wr.indexOf(e)+1)%Wr.length]}const ZD="agent-dag.theme";function pue(e,t=!1){return typeof e=="string"&&Object.hasOwn(Du,e)?e:"rider-black"}function mue(){return pue(Ve(ZD))}function gue({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:s,providersRef:r,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:m,focusAgent:w,stepAgent:j,focusSession:b,requestClear:k,handleRelayout:v,undoRearrange:N,handleFit:S,togglePause:E,toggleSessionList:C,toggleAccountsPanel:I,setDetailOpen:R,setUsageHistoryOpen:$,setUsagePanelOpen:L,setMachinePanelOpen:U,setBrowserWatchOpen:O,setKeyHelpOpen:M,setTheme:q,openSettings:A}){y.useEffect(()=>{const D=P=>{var B,Z;const K=P.target,G={tagName:K==null?void 0:K.tagName,isContentEditable:K==null?void 0:K.isContentEditable,role:(B=K==null?void 0:K.getAttribute)==null?void 0:B.call(K,"role"),type:K==null?void 0:K.type,pointerFocused:K!=null&&K===e.current};if(P.key==="Escape"){const V=k7({overlayOpen:Cn.depth()>0,typing:$o(G)});V==="dismiss"?Cn.dismissTop():V==="blur"?K==null||K.blur():(Ule(G)&&(K==null||K.blur()),p());return}if(P.key===","&&due(P)){if($o(G)||Sh({appModal:c.current,dialogDepth:Cn.dialogDepth()}))return;P.preventDefault(),P.repeat||A();return}if(rK(P)){if($o(G)||Sh({appModal:c.current,dialogDepth:Cn.dialogDepth()}))return;!P.repeat&&N()&&P.preventDefault();return}if(Bf(P))return;const W=Sj(K)?(Z=K==null?void 0:K.getAttribute)==null?void 0:Z.call(K,"data-id"):null,H=W&&t.current.some(V=>V.id===W)?W:null,F=Ble(P,H);if(F.kind==="activate"){P.preventDefault(),m(F.nodeId,F.additive);return}if(F.kind!=="node"&&!b3(P.key,Wk())){if(M7({key:P.key,sheetOpen:i.current,target:G})){P.repeat||M(!1);return}if(!(F.nodeId==null&&R7(G,P.key))&&!A7({key:P.key,modalOpen:Sh({appModal:c.current,dialogDepth:Cn.dialogDepth()}),sheetOpen:i.current})&&!(P.repeat&&!/^[ jkJK]$/.test(P.key))){if(P.key===" "&&(P.preventDefault(),P.repeat||E()),(P.key==="c"||P.key==="C")&&k("shortcut"),(P.key==="r"||P.key==="R")&&v(),(P.key==="f"||P.key==="F")&&S(),(P.key==="z"||P.key==="Z")&&s.current&&w(s.current),P.key==="Delete"&&h.current(),(P.key==="l"||P.key==="L")&&C(),P.key==="d"||P.key==="D")if(s.current)R(V=>!V);else{const V=Fk(n.current.agents.values());V.length>0?b(V[0].id):j(1)}if((P.key==="h"||P.key==="H")&&$(V=>!V),(P.key==="u"||P.key==="U")&&L(V=>!V),(P.key==="a"||P.key==="A")&&r.current.claude&&I(),(P.key==="j"||P.key==="J")&&j(1),(P.key==="k"||P.key==="K")&&j(-1),P.key==="w"||P.key==="W"){const V=a7(Fk(n.current.agents.values()),d.current);V&&(d.current=V.id,b(V.id))}(P.key==="t"||P.key==="T")&&q($0),(P.key==="m"||P.key==="M")&&o.current!==null&&f.current(P.shiftKey),(P.key==="s"||P.key==="S")&&U(V=>!V),(P.key==="b"||P.key==="B")&&O(V=>!V),(P.key==="v"||P.key==="V")&&A("sounds"),P.key==="?"&&M(V=>!V)}}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[k,v,N,S,p,m,j,b,w,E])}function yue(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function wue({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:s,detailShown:r,primarySelectedId:o,canvasRef:i}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{yue()&&h()};return{toggles:c,sessionList:d(Ur(!e,c.sessionList)),usage:d(Ur(!t,c.usage)),machine:d(Ur(!n,c.machine)),accounts:d(Ur(!s,c.accounts)),detail:d(Ur(!r,()=>{var h,f;o&&ID(o),Kn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function xue({nodes:e,stateRef:t,pinnedRef:n,positionsRef:s,draggingRef:r,dragPatchRef:o,setDragging:i,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:m,trackTrashDrag:w,endTrashDrag:j,removeNode:b}){const k=y.useRef(null);return{onNodeDragStart:(E,C)=>{var I,R;if(C){if(Ua(),h(),r.current=!0,o.current=new Map,i(!0),f(),p(),C.type==="sessionGroup"){const $=(I=C.data)==null?void 0:I.sessionId,L=new Map,U=new Map;if($)for(const M of e)!M.data||Gn(M)!==$||(L.set(M.id,{x:M.position.x,y:M.position.y}),U.set(M.id,n.current.get(M.id)));k.current={sessionId:$,start:{x:C.position.x,y:C.position.y},members:L,pinsBefore:U};const O=$?t.current.agents.get($):void 0;m(O?O.label:null);return}m(C.type==="agent"?((R=t.current.agents.get(C.id))==null?void 0:R.label)??"":null),n.current.set(C.id,{x:C.position.x,y:C.position.y})}},onNodeDrag:(E,C)=>{var I;if(C){if(f(),(C.type==="agent"||C.type==="sessionGroup")&&w(E),C.type==="sessionGroup"){const R=k.current;if(!R)return;const $=C.position.x-R.start.x,L=C.position.y-R.start.y;for(const[O,M]of R.members){const q={x:M.x+$,y:M.y+L};n.current.set(O,q),s.current.set(O,q)}const U=o.current;if(U){for(const[O,M]of R.members)U.set(O,{x:M.x+$,y:M.y+L});U.set(C.id,{x:C.position.x,y:C.position.y})}c(O=>O+1);return}n.current.set(C.id,{x:C.position.x,y:C.position.y}),s.current.set(C.id,{x:C.position.x,y:C.position.y}),(I=o.current)==null||I.set(C.id,{x:C.position.x,y:C.position.y}),c(R=>R+1)}},onNodeDragStop:(E,C)=>{f();const I=j(E,(C==null?void 0:C.type)==="agent"||(C==null?void 0:C.type)==="sessionGroup");if(r.current=!1,o.current=null,i(!1),d(R=>R+1),!C){k.current=null,nl(s.current,n.current);return}if(C.type==="sessionGroup"){const R=k.current;if(R&&I&&R.sessionId){for(const[$,L]of R.members){const U=R.pinsBefore.get($);U?n.current.set($,U):n.current.delete($),s.current.set($,L)}k.current=null,b(R.sessionId);return}if(R){const $=C.position.x-R.start.x,L=C.position.y-R.start.y;for(const[U,O]of R.members){const M={x:O.x+$,y:O.y+L};n.current.set(U,M),s.current.set(U,M)}}k.current=null,nl(s.current,n.current),d($=>$+1);return}if(n.current.set(C.id,{x:C.position.x,y:C.position.y}),s.current.set(C.id,{x:C.position.x,y:C.position.y}),I){b(C.id);return}nl(s.current,n.current)}}}function vue(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 JD({active:e=!1}){const[t,n]=y.useState(()=>typeof document>"u"||!document.hidden);return y.useEffect(()=>{const s=()=>n(!document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),a.jsx("div",{className:"empty-symbol","aria-hidden":"true","data-active":e&&t,children:a.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"m6 8 4 4-4 4"}),a.jsx("path",{className:"empty-cursor",d:"M13 16h5"})]})})}function bue({reservedRight:e=0}){return a.jsx("div",{className:"empty-stage",style:{right:e},children:a.jsxs("div",{className:"empty-hero",children:[a.jsx(JD,{}),a.jsxs("h2",{children:["Too many ",Ct," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:Ct})," tabs are holding them. Close one and this tab connects on its own."]})]})})}function kue({live:e,everConnected:t,providers:n,workspace:s,onTour:r,reservedRight:o=0}){const i=!e;return a.jsx("div",{className:"empty-stage",style:{right:o},children:a.jsxs("div",{className:"empty-hero",children:[a.jsx(JD,{active:e}),i?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:Ct}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):jue(n,s),!i&&a.jsxs("div",{className:"empty-actions",role:"group","aria-label":"Explore ccdeck",children:[a.jsx("button",{type:"button",className:"btn empty-tour",onClick:r,children:"Take the tour"}),a.jsx(cu,{film:"tour",action:!0})]})]})})}function jue(e,t){const n=vue(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."]}),a.jsxs("details",{className:"empty-help",children:[a.jsx("summary",{children:"Session not showing up?"}),EX(e).map(s=>a.jsx("p",{className:"hint-row",children:s.spans.map((r,o)=>r.code?a.jsx("code",{children:r.text},o):a.jsx("span",{children:r.text},o))},s.provider))]})]})}const Nue=1;function Sue(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 _ue(e,t,n){const s=e.agents.get(t);if(!s)return null;const r=[];for(const o of e.agents.values())o.sessionId===t&&r.push(o);return{schemaVersion:Nue,exportedAt:n,sessionId:t,label:s.label,cwd:s.cwd,startedAt:s.startedAt,endedAt:s.endedAt,model:s.model,agents:r.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(Sue)}))}}function Eue(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Ct}-${n}-${Qh(t,8)}.json`}const QD={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Cue={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 Tue({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:Cue[e]})})}const vf={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},e5=h3;function Rue({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:r,onRemove:o,singleKeys:i=!0}){var k;const c=`${e.synthetic?"≥ ":""}${cl(e.startedAt,e.endedAt,t)}`,d=In(e),h=d.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[v,N]of e.toolCountByName??[]){const S=e5(v);p.set(S,(p.get(S)??0)+N)}const m=e.toolErrorCount??0,w=e.tools.filter(v=>!v.endedAt).length,j=Array.from(p.entries()).sort((v,N)=>N[1]-v[1]),b=p.has("mcp")?I9(((k=e.toolCountByName)==null?void 0:k.keys())??[]):null;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"detail-hero",children:[a.jsxs("div",{className:"hero-line",children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),a.jsxs("div",{className:"hero-meta",children:[a.jsx("span",{className:"hero-meta-item",children:Ff(e)}),a.jsx("span",{className:"hero-sep",children:"·"}),a.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&(()=>{const v=y1(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":Of(e.model),title:v.length>0?`${su(e.model,e.effort)}
99
- spend on this panel also covers:
100
- ${v.join(`
101
- `)}`:su(e.model,e.effort),children:[Pf(e.model,e.effort),v.length>0?` +${v.length}`:""]})]})})()]}),h&&a.jsxs("div",{className:"hero-cost",children:[a.jsxs("div",{className:"hero-cost-headline",children:[a.jsx("span",{className:"hero-cost-value",children:Xe(d.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(L1,{cost:d})]}),a.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),r&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>r(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; ${gn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${gn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),(()=>{const v=qf(e);if(!v)return null;const N=Zh(v.at,t),S=v.kind==="recap"?"Recap":Oa(v.kind).replace(/^./,E=>E.toUpperCase());return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:[S," ",a.jsx("span",{className:"section-count",title:N.title,children:N.label})]}),a.jsx("p",{className:"detail-recap",title:Uf(v),children:v.text}),v.reply&&a.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",v.reply,"”"]})]})})(),(()=>{const v=bu(e.plan);return!v||!e.plan?null:a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Plan"," ",a.jsxs("span",{className:"section-count","aria-hidden":!0,children:[v.done,"/",v.total]}),a.jsxs("span",{className:"vis-hidden",children:[v.done," of ",v.total," done"]})]}),e.plan.note&&a.jsx("p",{className:"detail-plan-note",children:e.plan.note}),a.jsx("ol",{className:"plan-list",children:e.plan.items.map((N,S)=>a.jsxs("li",{className:"plan-item","data-status":N.status,children:[a.jsx("span",{className:"plan-mark","aria-hidden":!0}),a.jsxs("span",{className:"vis-hidden",children:[Iue[N.status],": "]}),a.jsx("span",{className:"plan-text",children:N.status==="in_progress"&&N.active?N.active:N.text}),N.status==="in_progress"&&a.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},N.id??`${S}:${N.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"]}),w>0&&a.jsxs("span",{className:"ac-item ac-live",children:[a.jsx("b",{children:w})," live"]}),m>0&&a.jsxs("span",{className:"ac-item ac-err",children:[a.jsx("b",{children:m})," err"]})]}),a.jsx("div",{className:"cat-strip",children:j.map(([v,N])=>{const S=v==="mcp"?b:null,E=S==null?void 0:S.hue,C=`${N} ${vf[v]} call${N===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${v}${E!=null?" mcp-hue":""}`,style:E!=null?{"--mcp-hue":E}:void 0,title:S?`${C}, all to ${S.label}`:C,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:QD[v]}),a.jsx("span",{className:"cat-name",children:vf[v]}),a.jsx("span",{className:"cat-count",children:N}),S&&a.jsx("span",{className:"cat-server",children:S.label})]},v)})})]})]}),f>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:gt(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:gt(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:gt(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:gt(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:TO(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:Aue(e.prompts).reverse().map(({pr:v,key:N})=>{const S=Zh(v.at,t),E=Mf(v.text);return E?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:E.label})]}),E.detail&&a.jsx("div",{className:"prompt-injected-detail",children:E.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:v.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(v=>a.jsx($ue,{t:v,onClick:()=>n(e.id,v.id)},v.id))})]})]})}function Aue(e){const t=new Map;return e.map(n=>{const s=t.get(n.at)??0;return t.set(n.at,s+1),{pr:n,key:s===0?String(n.at):`${n.at}:${s}`}})}const Mue={inflight:"in-flight",done:"done",err:"error"};function $ue({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e3(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:Mue[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const Iue={completed:"done",in_progress:"now",pending:"to do"};function Lue(e,t){const n=_ue(e,t,new Date().toISOString());if(!n)return;const s=JSON.stringify(n,null,2),r=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=Eue(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Oue({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:r,stateRef:o,removeSelectedNode:i}){nn("detail-panel");const c=Ln();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:r,children:"×"}),a.jsx(Rue,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:d=>Lue(o.current,d),onRemove:i,singleKeys:c})]})}const Pue=450,Due=400,Fue=100,gh=8,Bue={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},jc=8;let Fr=null,Q$=-1/0;function que(e,t,n){return n||e-t<Due}function Uue(e,t,n,s,r=null){const o=Math.max(jc,((r==null?void 0:r.left)??0)+jc),i=Math.min(window.innerWidth,(r==null?void 0:r.right)??1/0)-n-jc,c=p=>Math.max(o,Math.min(p,i)),d=p=>Math.max(jc,Math.min(p,window.innerHeight-s-jc)),h=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+gh,top:d(h)}:e==="left"?{left:t.left-gh-n,top:d(h)}:e==="above"?{left:c(f),top:t.top-gh-s}:{left:c(f),top:t.bottom+gh}}const Wue={chrome:"",dialog:" hint-over-dialog"};function jl(e,t="chrome"){const[n,s]=y.useState(null),r=y.useRef(void 0),o=y.useRef(void 0),i=y.useRef(null),c=y.useCallback(()=>{window.clearTimeout(r.current),window.clearTimeout(o.current),s(w=>(w&&(Q$=performance.now()),null))},[]),d=y.useCallback((w,j,b)=>{window.clearTimeout(r.current),window.clearTimeout(o.current);const k=Fr!==null,v=que(performance.now(),Q$,k),N=()=>{var E;Fr&&Fr!==c&&Fr(),Fr=c;const S=t==="dialog"?((E=w.closest('[role="dialog"]'))==null?void 0:E.getBoundingClientRect())??null:null;s({spec:j,box:w.getBoundingClientRect(),within:S,instant:v})};b||v?N():r.current=window.setTimeout(N,Pue)},[c,t]),h=y.useCallback(()=>{window.clearTimeout(r.current),window.clearTimeout(o.current),o.current=window.setTimeout(c,Fue)},[c]),f=n!==null;y.useEffect(()=>{if(!f)return;const w=Cn.push(c,0,"popover");return window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{w(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0),Fr===c&&(Fr=null)}},[f,c]),y.useEffect(()=>()=>{window.clearTimeout(r.current),window.clearTimeout(o.current),Fr===c&&(Fr=null)},[c]),y.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:j,height:b}=w.getBoundingClientRect(),k=Uue(e,n.box,j,b,n.within);w.style.left=`${k.left}px`,w.style.top=`${k.top}px`,w.style.visibility="visible"},[n,e]);const p=y.useCallback(w=>({onPointerEnter:j=>{w&&j.pointerType==="mouse"&&d(j.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:c,onFocus:j=>{w&&j.currentTarget.matches(":focus-visible")&&d(j.currentTarget,w,!0)},onBlur:c}),[d,h,c]),m=n&&wt.createPortal(a.jsxs("span",{ref:i,className:Bue[e]+Wue[t],"data-instant":n.instant||void 0,style:{left:0,top:0,visibility:"hidden"},"aria-hidden":!0,onPointerEnter:()=>window.clearTimeout(o.current),onPointerLeave:c,children:[a.jsxs("span",{className:"hint-head",children:[a.jsx("span",{className:"hint-label",children:n.spec.label}),n.spec.keys&&a.jsx("kbd",{className:"hint-key",children:n.spec.keys})]}),n.spec.detail&&a.jsx("span",{className:"hint-detail",children:n.spec.detail})]}),document.body);return{bind:p,node:m}}function t5(e,t){return e&&(t||!e.single)?e:void 0}function Hue(e,t,n){var i;const s=(i=t5(e.key,t))==null?void 0:i.cap,r=e.hint??e.label;return s!=null||e.detail!=null||r!==e.label||!n?{label:r,keys:s,detail:e.detail}:null}const n5={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},zue={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},Vue={vertical:"ArrowDown",horizontal:"ArrowRight"},Gue={vertical:"ArrowUp",horizontal:"ArrowLeft"};function s5(e,t){const[n,s]=y.useState(0),r=Math.min(n,Math.max(0,e-1)),o=y.useCallback(i=>{const c=Array.from(i.currentTarget.querySelectorAll("button[data-rail-item]")),d=c.indexOf(document.activeElement);if(d<0)return;let h=-1;i.key===Vue[t]?h=(d+1)%c.length:i.key===Gue[t]?h=(d-1+c.length)%c.length:i.key==="Home"?h=0:i.key==="End"&&(h=c.length-1),!(h<0)&&(i.preventDefault(),i.stopPropagation(),s(h),c[h].focus())},[t]);return{active:r,setCurrent:s,onKeyDown:o}}let Wi=null;function Tj(e){y.useLayoutEffect(()=>{var r,o;Wi&&document.activeElement===document.body&&((o=(r=e.current)==null?void 0:r.querySelector(`[data-rail-item="${Wi}"]`))==null||o.focus()),Wi=null;const t=i=>{var d;const c=(d=i.target.dataset)==null?void 0:d.railItem;c&&(Wi=c)},n=i=>{var c;(c=e.current)!=null&&c.contains(i.relatedTarget)||(Wi=null)},s=e.current;return s==null||s.addEventListener("focusin",t),s==null||s.addEventListener("focusout",n),()=>{s==null||s.removeEventListener("focusin",t),s==null||s.removeEventListener("focusout",n)}},[e])}function Rj({item:e,index:t,tabbable:n,onFocusIndex:s,hint:r,variant:o}){var h;const i=Ln(),c=r.bind(Hue(e,i,o!=="stripe")),d=e.kind==="panel";return a.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:n5[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=t5(e.key,i))==null?void 0:h.aria,"aria-expanded":d?e.open===!0:void 0,"aria-controls":d&&e.open?e.controls:void 0,"aria-haspopup":d?void 0:"dialog",...c,onFocus:f=>{s(t),c.onFocus(f)},onClick:()=>e.onPress(),children:[e.glyph,o!=="stripe"&&a.jsx("span",{className:"rail-word",children:o==="dock"?e.short:e.label}),e.badge!=null&&e.badge>0&&a.jsx("span",{className:"rail-badge","aria-hidden":!0,children:e.badge})]})}function eI({side:e,label:t,groups:n}){const s=jl(e==="left"?"right":"left"),r=n.filter(d=>d.length>0),o=s5(r.flat().length,"vertical"),i=y.useRef(null);Tj(i);let c=0;return a.jsxs("div",{ref:i,className:zue[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[r.map((d,h)=>a.jsx("div",{className:"rail-group",children:d.map(f=>{const p=c++;return a.jsx(Rj,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},h)),s.node]})}const yh="dock-more",tI="dock-more-menu";function Kue({items:e,tabbable:t,onFocusIndex:n,index:s}){const[r,o]=y.useState(null),i=r!==null,c=e.reduce((h,f)=>h+(f.badge??0),0),d=h=>()=>{var f;(f=document.getElementById(yh))==null||f.focus(),o(null),h.onPress()};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{id:yh,type:"button","data-rail-item":"more",className:n5.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?tI:void 0,onFocus:()=>n(s),onKeyDown:h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),o(h.key==="ArrowUp"?"last":"first"))},onClick:()=>o(i?null:"first"),children:[a.jsxs("svg",{className:"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("circle",{cx:"2.8",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),a.jsx("span",{className:"rail-word",children:"More"}),c>0&&a.jsx("span",{className:"rail-badge","aria-hidden":!0,children:c})]}),i&&a.jsx(Qf,{anchorId:yh,id:tI,className:"ap-pop",role:"menu",labelledBy:yh,start:r,onClose:()=>o(null),children:e.map(h=>a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item","data-rail-item":h.id,onFocus:()=>{Wi=h.id},onClick:d(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function Yue({items:e,more:t}){const n=jl("above"),s=s5(e.length+1,"horizontal"),r=y.useRef(null);return Tj(r),a.jsxs("div",{ref:r,className:"edge-dock",role:"toolbar","aria-label":"Panels and tools",onKeyDown:s.onKeyDown,children:[e.map((o,i)=>a.jsx(Rj,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),a.jsx(Kue,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function Xue({items:e,side:t="below"}){const n=jl(t),s=y.useRef(null);return Tj(s),a.jsxs("div",{ref:s,className:"utility-run",children:[e.map((r,o)=>a.jsx(Rj,{item:r,index:o,tabbable:!0,onFocusIndex:Zue,hint:n,variant:"bar"},r.id)),n.node]})}function Zue(){}const Jue="(max-width: 640px)";function Que(e,t){const n=e?"Watching — the deck keeps its own copy of the history":"Not watching — reads the browser's history when opened";return t>0?`${n}
102
- ${t} unread`:n}function ede({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:s,toggleAccountsPanel:r,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:c,setMachinePanelOpen:d,setUsageHistoryOpen:h,watchOn:f,watchUnseen:p,setBrowserWatchOpen:m,setTrafficRadarOpen:w,radioOpen:j,setRadioOpen:b,openToolActivity:k,openSettings:v,onFeedback:N,toggles:S}){const E=hue(_u()),C={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:a.jsx(CQ,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:S.sessionList},I={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:a.jsx(TQ,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:r,buttonRef:S.accounts},R={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:a.jsx(RQ,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(q=>!q),buttonRef:S.usage},$={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:a.jsx(MQ,{}),kind:"panel",open:c,controls:"system-panel",onPress:()=>d(q=>!q),buttonRef:S.machine},L={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:a.jsx(AQ,{}),kind:"dialog",onPress:()=>h(q=>!q)},U={id:"browser-watch",label:"Browser watch",short:"Watch",key:{cap:"B",aria:"B",single:!0},ariaLabel:`Browser watch, ${f?"watching":"not watching"}${p>0?`, ${p} unread`:""}`,detail:Que(f,p),glyph:a.jsx(IQ,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(q=>!q),badge:p},O={id:"settings",label:"Settings",short:"Settings",key:{cap:E,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:a.jsx(LQ,{}),kind:"dialog",onPress:()=>v()},M={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:a.jsx(OQ,{}),kind:"dialog",onPress:N};return{left:e.claude?[I,C]:[C],right:[[R,$],[L,...k?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:a.jsx(qQ,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>k()}]:[],U,...w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:a.jsx($Q,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[]],...b?[[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:a.jsx(BQ,{}),kind:"panel",open:j,controls:"radio-panel",detail:"Explore stations around the world",onPress:()=>b(q=>!q)}]]:[]],utilities:[O,M]}}function tde({widths:e,room:t,gap:n,more:s}){let r=0,o=0;for(let i=0;i<e.length;i++){r+=(i>0?n:0)+e[i];const c=i+1<e.length?n+s:0;if(r+c>t)break;o=i+1}return o}function r5(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const nde=20;function sde(e,t=nde){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),s=t-1-n;return`${e.slice(0,s)}…${e.slice(e.length-n)}`}function rde(e){const t=Math.floor(Math.max(0,e)/6e4);if(t<1)return"less than a minute";const n=(o,i)=>`${o} ${i}${o===1?"":"s"}`;if(t<60)return n(t,"minute");const s=Math.floor(t/60),r=t%60;return r===0?n(s,"hour"):`${n(s,"hour")} ${n(r,"minute")}`}function ade(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${rde(n)} ${s}; go to session`}function ode(e){const t=ll(e),n=QO(e,t);return n?`${t}
103
- ${n}`:t}const ide=new Set(["idle","checking","current","downloading","ready","error"]);function nI(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!ide.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 lde(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function a5(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const pl="Restart to update",o5=3e4;function i5(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 cde(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 ${pl} comes first`}}function l5(e,t=!1){return{text:t?"Restarting…":pl,label:t?void 0:`${pl} to v${e}`,title:`Install ccdeck v${e} now: ccdeck restarts and is back in a few seconds. Your Claude Code and Codex sessions keep running.`}}function ude(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function c5(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=i5(n),r=`Use ${pl} in ${s}.`;switch(e){case"app_disconnected":return`Nothing restarted: the app is not connected to this deck, so the request had nowhere to go. ${r}`;case"update_not_ready":return`Nothing restarted: the app no longer has v${t} ready. When it has one, ${pl} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${o5/1e3} seconds. ${r}`;case"refused":return`Nothing restarted: the deck turned the request down. ${r}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${r}`}}const dde="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",hk="click for what's new";function hde(e){if(e.checkDisabled)return`${dde} · ${hk}`;if(e.checking)return`Asking npm for the newest release… · ${hk}`;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 · ${hk}, and to check npm now`}function fde(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 pde(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 u5(e){return e?`${e.kind}:${e.to}`:""}function mde(e,t){return e!=null&&t!==u5(e)}function gde({readyAppUpdate:e,notice:t,noticeOpen:n,version:s,chipVersion:r,versionChecking:o,now:i,openReleaseNotes:c,showNotice:d,loadVersion:h,restartToUpdate:f,updateRestarting:p=!1}){return a.jsx(a.Fragment,{children:e?(()=>{const m=cde(a5()??r,e.version),w=f&&l5(e.version,p);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":m.label,title:m.title,children:[m.text,a.jsx("span",{className:"v-dot","aria-hidden":!0})]}),w&&a.jsx("button",{type:"button",className:"v ready v-update",onClick:()=>f(e.version),"aria-busy":p||void 0,"aria-label":w.label,title:w.title,children:w.text})]})})():t?a.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":pde({...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 m={running:r,latest:s==null?void 0:s.latest,latestPending:s==null?void 0:s.latestPending,checkedAgo:s!=null&&s.checkedAt?Kk(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?Kk(i-s.checkFailedAt):null,checkDisabled:s==null?void 0:s.checkDisabled,checking:o};return a.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":fde(m),title:hde(m),children:["v",m.running]})})()})}function yde({live:e,paused:t,pauseGate:n}){const s=Ln();return a.jsx("span",{className:"status",children:(()=>{const r=eV({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:s});return r.resting?null:a.jsx("span",{className:`pill ${r.tone}`,title:r.title,children:a.jsxs("span",{className:"pill-box",children:[a.jsx("span",{className:"pill-widest","aria-hidden":!0,children:r.widest}),a.jsx("span",{className:"pill-label",children:r.label})]})})})()})}function wde(e,t){return`${e.label} — ${r5(e.waiting)} · ${rf(e.waiting.since,void 0,t)}`}function d5(e,t){const n=e.slice(0,6).map(s=>wde(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
104
- `)}function xde({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:r}){const o=Ln(),i=jl("below"),c=e.slice(r),d=e.length;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},"aria-label":`${d} session${d===1?"":"s"} waiting for you`,"aria-keyshortcuts":o?"W":void 0,...i.bind({label:"Go to the longest wait",keys:o?"W":void 0,detail:c.length>0?d5(c,s):void 0}),children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:d})," waiting"]}),i.node]})}function sI({w:e,now:t}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"we-name",children:sde(e.label)}),a.jsx("span",{className:"we-wait",children:rf(e.waiting.since,void 0,t)}),a.jsxs("span",{className:"we-what",children:["· ",r5(e.waiting)]})]})}const vde=12,bde=2e3,kde=4;function jde({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:r,onMore:o}){const i=Ln(),c=jl("below"),d=y.useRef(null),h=y.useRef(null),[f,p]=y.useState(0),m=e.map(k=>k.id).join(`
105
- `);y.useLayoutEffect(()=>{const k=d.current,v=h.current;if(!k||!v)return;const N=()=>{const E=Array.from(v.children),C=E.pop();p(tde({widths:E.map(I=>I.getBoundingClientRect().width),room:k.clientWidth-vde,gap:kde,more:(C==null?void 0:C.getBoundingClientRect().width)??0}))};if(N(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(N);return S.observe(k),S.observe(v),()=>S.disconnect()},[m]);const w=e.slice(0,f),j=e.slice(f);y.useEffect(()=>{r(w.length)},[w.length,r]);const b=k=>{t.current=k,n(k)};return a.jsxs("div",{className:"wait-names",ref:d,children:[a.jsxs("ul",{className:"wait-list",children:[w.map(k=>a.jsx("li",{"data-fresh":s-k.waiting.since<bde||void 0,children:a.jsx("button",{type:"button",className:"wait-entry",onClick:()=>b(k.id),"aria-label":ade(k.label,k.waiting,s-k.waiting.since),...c.bind({label:k.label,detail:ode(k.waiting)}),children:a.jsx(sI,{w:k,now:s})})},k.id)),w.length>0&&j.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${j.length} more waiting; open the session list`,"aria-keyshortcuts":i?"L":void 0,...c.bind({label:"Open the session list",keys:i?"L":void 0,detail:d5(j,s)}),children:["+",j.length," more"]})})]}),e.length>0&&a.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(k=>a.jsx("span",{className:"wait-entry",children:a.jsx(sI,{w:k,now:s})},k.id)),a.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),c.node]})}const I0={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 Nde(e){return e==="on"?`Notifications on. ${I0.on}.`:e==="blocked"?`${I0.blocked}.`:""}function Sde({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:I0[e],children:e==="on"?"notifications on":"notifications blocked"})}function _de({versionCheck:e,welcome:t,desktopUpdate:n,pause:s,announcements:r,notify:o,waitingSessions:i,waitingCursorRef:c,focusSession:d,live:h,now:f,incidents:p,queueNamed:m}){const{version:w,notice:j,noticeOpen:b,showNotice:k,versionChecking:v,loadVersion:N}=e,{chipVersion:S,openReleaseNotes:E}=t,{readyAppUpdate:C,desktopUpdateRestarting:I,desktopUpdateFailure:R,askDesktopUpdateRestart:$}=n,L=y.useRef(!1);y.useEffect(()=>{I||!L.current||(L.current=!1,R&&E())},[I,R,E]);const U=K=>{L.current=!0,$(K)},{paused:O,pauseGate:M}=s,{blockedSaid:q,watchSaid:A,incidentSaid:D}=r,{notifySaid:P}=o;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:uX,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:dX,width:19,height:16,alt:""}),a.jsx("h1",{children:Ct}),a.jsx(gde,{readyAppUpdate:C,notice:j,noticeOpen:b,version:w,chipVersion:S,versionChecking:v,now:f,openReleaseNotes:E,showNotice:k,loadVersion:N,restartToUpdate:U,updateRestarting:I})]}),a.jsx(yde,{live:h,paused:O,pauseGate:M}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:q}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:A}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:D}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Nde(P)}),a.jsx(hX,{incidents:p}),i.length>0&&a.jsx(xde,{waitingSessions:i,waitingCursorRef:c,focusSession:d,now:f,named:m}),P&&a.jsx(Sde,{notifySaid:P})]})}function Ede({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:r}){const o=Ln(),i=In(e),c=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),d=e.state==="active"&&!e.synthetic?g1(i.total,c):null,h=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`${gn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
106
- ${Xe(i.total)} spent${d?` · ${d}`:""}`:""}`,onClick:()=>{try{s(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}),i.total>0&&a.jsxs("span",{className:"selected-cost",children:[Xe(i.total),d?a.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&a.jsxs("span",{className:"selected-extra",children:["+",h]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),r()},children:"×"})]})}function Cde({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:s,toggleCat:r}){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 i=s.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>r(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${vf[o]} tools`,children:[a.jsx(Tue,{cat:o}),a.jsx("span",{className:"cat-name",children:vf[o]})]},o)})})}const Tde=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Rde(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(Tde)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function Ade({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const r=Ln();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:s||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?`${gn("The session list","L",r)} brings it back`:"The session keeps running"})]})]})}function Mde({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:r,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:j,lodRef:b}=r,{markCanvasInput:k}=o,{peekAgent:v,peekLabel:N,peekRecap:S,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":j,ref:e,onMouseDownCapture:Rde,onPointerDownCapture:k,onPointerUpCapture:k,onWheelCapture:k,onFocusCapture:C=>{const I=C.target;if(!Sj(I)||b.current==null||b.current==="detail")return;const R=I.getAttribute("data-id");R&&i.current.agents.has(R)&&I.matches(":focus-visible")&&OD(R,I,"focus")},onBlurCapture:C=>{var R,$;const I=($=(R=C.target).getAttribute)==null?void 0:$.call(R,"data-id");I&&Ua(I)},children:[d,Ma(p)&&a.jsx(Ade,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),a.jsx(zle,{agentFor:v,recapFor:S,labelFor:N,bounds:E})]})}function $de({restarting:e,restartMode:t,live:n,paused:s}){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 ${Ct}…`:(()=>{const r=J9({connected:n,paused:s});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${Ct} server. Reconnecting…`,r&&a.jsx("span",{className:"conn-sub",children:r})]})})()]})}function Ide({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 ",Ct," 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 h5="Thanks — that helps.",Lde=Array.from({length:11},(e,t)=>t);function Ode(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Pde=6;function Dde(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,s=n==null?void 0:n.closest(".app");if(!n||!s)return;const r=()=>s.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);r();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return o==null||o.observe(n),()=>{o==null||o.disconnect(),s.style.removeProperty("--rating-h")}},[e]),t}function Fde(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Bde({phase:e,score:t,onAnswer:n,onLater:s,onClose:r,onFeedback:o,onHold:i}){const c=Dde(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var m,w;e!=="thanks"||!f.current||(f.current=!1,Kn(((m=document.activeElement)==null?void 0:m.tagName)??null)&&((w=d.current??h.current)==null||w.focus()))},[e]);const p=m=>{var w;(w=c.current)!=null&&w.contains(document.activeElement)&&Fde(),m()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||i(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:h5}),t!==null&&t<=Pde?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(r),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:Lde.map(m=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":Ode(m),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(m)},children:m},m))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(s),children:"Not now"})]})}const qde=3e4;function Ude({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Wde({bundle:e,running:t,pending:n,lastTried:s}){return t?Ude({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Hde(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function zde({asked:e,reported:t}){return t?t!==e:!1}function f5(e){const t=e.thresholdMs??qde;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 Vde(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 Gde(e,t){return e?t==null?"auto when idle":`auto in ${Vde(t)}`:"auto-restart off"}function rI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Kde(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 Yde(e){const t=f5(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 L0={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function Xde({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:r,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:m}){var w,j,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(),...Ps(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
107
-
108
- Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:m?"restarting…":f.label}),!m&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:Gde(c,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[Ct," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&s!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:r,...Ps(s==="running",s==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:s==="running"?"installing…":s==="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}),...Ps(m),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:m?"fetching…":s==="failed"?"Retry update":"Update & restart"}),s==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((j=t==null?void 0:t.upgrade)==null?void 0:j.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:":L0.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Vt(L0,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:i?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Zde({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:r,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:j,restartCopy:b,restartFuseMs:k}=e,{version:v,notice:N,noticeOpen:S,dismissNotice:E}=t,{upgradeState:C,startUpgrade:I,copyCommand:R,cmdCopied:$}=n,{oldName:L,oldNameOpen:U,dismissOldName:O}=s,{ratingPhase:M,ratingScore:q,answerRating:A,rateLater:D,closeRating:P,holdThanks:K}=r,G=w?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",w,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?a.jsx($de,{restarting:p,restartMode:m,live:c,paused:d}):S&&N?a.jsx(Xde,{notice:N,version:v,dismissNotice:E,upgradeState:C,startUpgrade:I,copyCommand:R,cmdCopied:$,autoRestart:h,toggleAutoRestart:f,askRestart:j,restartCopy:b,restartFuseMs:k,restarting:p}):U&&L?a.jsx(Ide,{oldName:L,version:v,dismissOldName:O}):M!=="hidden"?a.jsx(Bde,{phase:M,score:q,onAnswer:A,onLater:D,onClose:P,onFeedback:o,onHold:K}):null;return a.jsxs(a.Fragment,{children:[G,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?h5:""})]})}function Jde(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Qde(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 ehe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function the(e,t){const n=ehe(e),s=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==null),r="This cannot be undone.";if(!t)return{goes:s("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:r,confirm:"Clear everything"};if(!t.path)return{goes:s(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${r}`,confirm:"Clear everything"};if(!t.mine){const i=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:s(),stays:[`the event log — ${i}${c}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:s("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:r,confirm:"Clear everything"};const o=t.decks-1;return{goes:s(`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:r,confirm:"Clear everything"}}function nhe({agentCount:e,onConfirm:t,onCancel:n}){const s=y.useRef(null),r=ct(n,{focusRef:s,layer:v7}),o=xt(n),[i,c]=y.useState(null);y.useEffect(()=>{let m=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{m||c(Qde(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=the(e,i);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(m=>a.jsx("span",{children:m},m))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(m=>a.jsx("span",{children:m},m)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const bf=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
109
- What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function p5(e){return bf.find(t=>t.value===e)??bf[0]}const O0=3,fk=120,m5=1e4,g5=200,she="Write something first.";function aI(e){return e.trim()!==""}function rhe(e){var o;const t=e.trim();if(t==="")return"";const n=oI(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,r=pk(s).length>=O0?pk(s):pk(n);return ohe(r.length>=O0?r:oI(t))}function ahe(e,t){const n=rhe(t);return n.length>=O0?n:`${p5(e).label}: ${n}`}function oI(e){return e.replace(/\s+/g," ").trim()}function pk(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function ohe(e){if(e.length<=fk)return e;const t=e.slice(0,fk-1),n=t.lastIndexOf(" ");return`${(n>=fk/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function ihe({kind:e,body:t,contact:n}){const s={kind:e,title:ahe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function lhe(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 che={darwin:"macOS",win32:"Windows",linux:"Linux"};function uhe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),r=che[n]??n;return s?`${r} · ${s}`:r}function dhe(e){return e?`ccdeck ${e.appVersion} · ${uhe(e.platform)}`:null}const hhe="sent with it",fhe="Your ccdeck version and system are sent with it.",phe="Add details",mhe="How to reach you",ghe="Email or GitHub @name",yhe="Only if you would like an answer.",whe=["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 xhe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function y5(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function vhe(e){return Eu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function bhe(e){return[...e].length===1}const w5="Thanks — feedback sent.";function iI(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 s=n==null?void 0:n.images;return e===400&&Array.isArray(s)&&typeof s[0]=="string"?`The server did not accept an image. ${s[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."}function khe(e){return e==="sending"?"Sending…":e==="sent"?w5:""}const lI=1400,jhe=160;function Nhe({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),bf.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:s=>{y5(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const x5="fb-details";function She({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":x5,onClick:t,children:[phe,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 _he({open:e,contact:t,onContact:n}){const s=y.useId();return a.jsx("div",{id:x5,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:[mhe,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:g5,autoComplete:"email",placeholder:ghe,"aria-describedby":s,onChange:r=>n(r.target.value),onKeyDown:r=>{y5(r.nativeEvent)&&r.preventDefault()}}),a.jsx("p",{id:s,className:"fb-hint",children:yhe})]}),a.jsx("div",{className:"fb-where",children:whe.map(r=>a.jsx("p",{children:r},r))})]})})})}const Ro=3,Ehe=5*1024*1024,Che=12*1024*1024,P0=8192,The=64*1024,Rhe=256*1024,Ahe=.92,Mhe=640,v5=.9,$he=.85,Ihe=6,Lhe=512*1024,kf={png:"image/png",jpeg:"image/jpeg"},Ohe={png:"png",jpeg:"jpg"},Phe=[137,80,78,71,13,10,26,10],Dhe=[255,216,255];function b5(e){const t=n=>e.length>=n.length&&n.every((s,r)=>e[r]===s);return t(Phe)?"png":t(Dhe)?"jpeg":null}function Fhe(e){const t=b5(e);return t==="png"?Bhe(e):t==="jpeg"?Uhe(e):null}function Bhe(e){const t=[73,72,68,82];if(e.length<24||!t.every((s,r)=>e[12+r]===s))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function qhe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Uhe(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 s=e[t]<<8|e[t+1];if(s<2)return null;if(qhe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=s}return null}function cI(e,t){return e.bytes>t||e.width>P0||e.height>P0}function Whe(e){return Math.min(Ehe,Che-The-e)}function k5(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Hhe(e,t){const n=P0/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*v5:1;return k5(e,Math.min(1,n,s))}async function zhe(e,t,n){let s=Hhe(e,t),r=e.format;for(let o=0;o<Ihe;o++){const i=await n(s,r,r==="jpeg"?Ahe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:r};if(r==="png"){r="jpeg";continue}if(s=k5(s,Math.min($he,Math.sqrt(t/i.size)*v5)),Math.max(s.width,s.height)<Mhe)return null}return null}async function Vhe(e,t,n){const s=new Uint8Array(await e.slice(0,Lhe).arrayBuffer()),r=b5(s);if(!r)return{ok:!1,problem:"type"};if(t<Rhe)return{ok:!1,problem:"no_room"};const o=e.type===kf[r]?e:new Blob([e],{type:kf[r]}),i=Fhe(s);if(i&&!cI({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:r};if(!cI(d,t))return{ok:!0,blob:o,resized:null};const h=await zhe(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Ghe(e){return({width:t,height:n},s,r)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);s==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},kf[s],r)})}const Khe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Ghe(t),release:()=>t.close()}};function Yhe(e){return e.includes("Files")}function Xhe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Zhe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Jhe(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((s,r)=>{const o=s.type===kf.jpeg?"jpeg":"png";n.append("images",s,`image-${r+1}.${Ohe[o]}`)}),{method:"POST",body:n}}const Qhe="Add screenshot",uI="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",efe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",dI="Three images at most. Remove one to add another.",tfe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function nfe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function sfe(e,t){const n=`${e} of ${Ro}`;return t>0?`${n} · ${t} resized to fit`:n}function rfe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function afe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function ofe(e,t){const n=afe(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 j5="image/png,image/jpeg";function N5({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 ife({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=Ro;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:uI,"aria-describedby":"fb-attach-hint",onClick:()=>{var r;return s?e.sayFull():(r=n.current)==null?void 0:r.click()},children:[a.jsx(N5,{}),Qhe]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:uI}),a.jsx("input",{ref:n,type:"file",accept:j5,multiple:!0,hidden:!0,onChange:r=>{e.add(Array.from(r.target.files??[])),r.target.value=""}})]})}function lfe({images:e,addRef:t}){const n=y.useRef(new Map),s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=sfe(d.length,d.filter(m=>m.resized).length);y.useLayoutEffect(()=>{var m;i!==null&&((m=i==="add"?t.current:n.current.get(i))==null||m.focus(),c(null))},[i,t]),y.useEffect(()=>{var m;e.problem&&((m=s.current)==null||m.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(m){c(Zhe(d.map(w=>w.id),m)??"add"),e.remove(m)}function p(m){var w;o.current=m,(w=r.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:r,type:"file",accept:j5,hidden:!0,onChange:m=>{const w=o.current;w!==null&&e.replace(w,Array.from(m.target.files??[])),o.current=null,m.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((m,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":m.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":nfe(w,m.name,m.resized),onClick:()=>p(m.id),children:[a.jsx("img",{className:"fb-shot-img",src:m.url,alt:""}),m.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:j=>{j?n.current.set(m.id,j):n.current.delete(m.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(m.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"})})})]},m.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:efe})]}),e.problem&&a.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function cfe(e,t){return e.map((n,s)=>({id:t+s,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function ufe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function dfe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function hfe(e){const[t,n]=y.useState(()=>cfe((e==null?void 0:e.ready)??[],1)),[s,r]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(M=>{M&&o.current++,r(q=>M?{problem:M,id:q.id+1}:q.problem?{problem:"",id:q.id}:q)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),m=y.useRef(!0),w=y.useRef(new Map),j=y.useRef([]),b=y.useRef(0),k=y.useCallback(M=>{h.current=M(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const M of h.current)URL.revokeObjectURL(M.url)}),[]);const v=y.useCallback(async(M,q)=>{const A=h.current.reduce((Z,V)=>{var X;return Z+(V.id===(q==null?void 0:q.id)?0:((X=V.blob)==null?void 0:X.size)??0)},0),D=(q==null?void 0:q.id)??++p.current,P=URL.createObjectURL(M),K={id:D,name:M.name||"image",url:P,blob:null,resized:null},G=b.current;w.current.set(D,M);let W=!1;const H=()=>{W||(W=!0,k(Z=>ufe(Z,K,q!==void 0)))},F=await Vhe(M,Whe(A),async Z=>(H(),Khe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),B=h.current.some(Z=>Z.id===D);return!m.current||b.current!==G||!B&&(W||q)?(URL.revokeObjectURL(P),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(D),""):(w.current.delete(D),F.ok?(H(),q&&URL.revokeObjectURL(q.url),k(Z=>Z.map(V=>V.id===D?{...V,blob:F.blob,resized:F.resized}:V)),""):(URL.revokeObjectURL(P),W&&k(Z=>dfe(Z,D,q)),ofe(F.problem,M.name||"image")))},[k]),N=y.useCallback(async M=>{i("");const q=b.current,A=[];let D=0,P=0;for(const G of M){if(!m.current||b.current!==q)return;const W=j.current.indexOf(G);if(W!==-1&&j.current.splice(W,1),h.current.length>=Ro){D++;continue}const H=h.current.length,F=await v(G);F&&A.push(F),h.current.length>H&&P++}if(!m.current||b.current!==q)return;D>0&&A.push(P===0&&A.length===0?dI:rfe(D)),i(A.join(" "));const K=h.current.length;P>0&&d(`${P===1?"Image":`${P} images`} added, ${K} of ${Ro}.`)},[v,i]),S=y.useCallback(async(M,q)=>{i("");const A=h.current.find(K=>K.id===M);if(!A)return N([q]);const D=await v(q,A);if(!m.current)return;i(D);const P=h.current.findIndex(K=>K.id===M);!D&&P!==-1&&d(`Image ${P+1} replaced, ${h.current.length} of ${Ro}.`)},[N,v,i]),E=y.useCallback(M=>{const q=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===q?M():void 0).catch(()=>{})},[]),C=y.useCallback(M=>{M.length!==0&&(j.current.push(...M),E(()=>N(M)))},[N,E]);y.useEffect(()=>{e&&e.waiting.length>0&&C(e.waiting)},[]);const I=y.useCallback((M,q)=>{const A=q[0];A&&E(()=>S(M,A))},[E,S]),R=y.useCallback(M=>{const q=h.current.find(A=>A.id===M);q&&(URL.revokeObjectURL(q.url),w.current.delete(M),k(A=>A.filter(D=>D.id!==M)),i(""),d(`Image removed, ${h.current.length} of ${Ro}.`))},[k,i]),$=y.useCallback(()=>i(dI),[i]),L=y.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(M=>M.blob&&!w.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...w.current.values(),...j.current]}),[]),O=y.useCallback(()=>{b.current++;for(const M of h.current)URL.revokeObjectURL(M.url);w.current.clear(),j.current=[],k(()=>[]),i("")},[k,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:C,replace:I,remove:R,sayFull:$,ready:L,kept:U,clear:O}}function ffe(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(s=>s.ok?s.json():null).then(s=>{n&&t(lhe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function pfe(e){const[t,n]=y.useState({state:"idle"}),s=y.useRef(!1),r=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=r.current)==null?void 0:c.abort()},[]);async function o(c){if(!An(s.current))return;s.current=!0;const{signal:d}=r.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:tfe});return}const f=await fetch("/api/feedback",{...Jhe(ihe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:iI(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:iI(0,null)})}finally{s.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function mfe(e,t){const[n,s]=y.useState(!1),r=y.useRef(t);return r.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),lI),i=window.setTimeout(()=>r.current(),lI+jhe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const mk="agent-dag.feedbackDrafts",hI=4;function gfe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function yfe(e){return JSON.stringify([e.kind,e.body])}function wfe(e){return e.ready.length+e.waiting.length}function S5(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function xfe(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const vfe="Discard",bfe="Confirm discard",kfe="Clear the message, the screenshots and the contact",fI="Press again to clear this draft. It cannot be brought back.",jfe={ready:[],waiting:[]};function Nfe(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:s,contact:r,images:o}=t;return!bf.some(i=>i.value===n)||typeof s!="string"||s.length>m5||typeof r!="string"||r.length>g5||typeof o!="number"||!Number.isInteger(o)||o<0||o>Ro?null:[e[0],{kind:n,body:s,contact:r,images:o}]}function Sfe(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(mk),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-hI)){const h=Nfe(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function s(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(mk):o.setItem(mk,JSON.stringify(i))}catch{}}function r(o){n().delete(o)&&s()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??jfe,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=wfe(i.images);if(!S5({body:i.body,contact:i.contact,images:d},c)){r(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=hI)break;h.delete(f)}s()},forget:r}}function _fe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const D0=Sfe(_fe),Efe=4e3;function Cfe(e,t,n,s,r){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:r};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||D0.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,s.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{r&&D0.forget(e)},[r,e])}const pI="draft";function Tfe(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Efe);return()=>window.clearTimeout(o)},[t]);function r(){const o=Date.now(),i=fl({armedFor:t?pI:null,target:pI,armedAt:s.current,now:o,gapMs:hl});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:r}}function _5({onClose:e,initialKind:t,initialBody:n}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),m=ct(e,{focusRef:s}),w=xt(e),j=gfe({initialKind:t,initialBody:n}),b=yfe(j),[k]=y.useState(()=>D0.read(b)),[v,N]=y.useState((k==null?void 0:k.kind)??j.kind),[S,E]=y.useState((k==null?void 0:k.body)??j.body),[C,I]=y.useState((k==null?void 0:k.contact)??""),[R,$]=y.useState((k==null?void 0:k.imagesLost)??0),[L,U]=y.useState(!1),[O,M]=y.useState(!1),[q,A]=y.useState(!1),D=hfe(k==null?void 0:k.images),P=dhe(ffe()),{outcome:K,sending:G,send:W,clearFailure:H}=pfe(D),F=K.state==="sent",B=mfe(F,e);Cfe(b,j,{kind:v,body:S,contact:C},D,F);const Z=S5({body:S,contact:C,images:D.shots.length},j),V=Tfe(()=>{var me;N(j.kind),E(j.body),I(""),$(0),M(!1),D.clear(),H(),(me=s.current)==null||me.focus()}),X=p5(v),Y=O&&!aI(S),J=R>0&&D.shots.length===0,ee=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ne,le]=vhe(_u());y.useEffect(()=>{var Pe,qe;const me=i.current;if(!me)return;const $e=me.contains(document.activeElement)||Kn(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null);me.inert=F,F&&$e&&((qe=r.current)==null||qe.focus())},[F]),y.useEffect(()=>{var Le,Qe;const me=c.current;if(!me)return;const $e=h.current;if(G){const je=document.activeElement,Ae=je!=null&&(me.contains(je)||je===$e);f.current=Ae?je:null,me.inert=!0,$e&&($e.inert=!0),f.current&&((Le=d.current)==null||Le.focus());return}me.inert=!1,$e&&($e.inert=!1);const Pe=f.current;f.current=null;const qe=document.activeElement===d.current||Kn(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null);!F&&Pe&&qe&&Pe.focus()},[G,F]);function de(me){var $e;if(me.preventDefault(),!aI(S)){M(!0),($e=s.current)==null||$e.focus();return}W({kind:v,body:S,contact:C})}const ue=!F&&!G,re=me=>Yhe(Array.from(me.dataTransfer.types));function pe(me){!re(me)||!ue||(me.preventDefault(),p.current++,A(!0))}function ye(me){re(me)&&(me.preventDefault(),me.dataTransfer.dropEffect=ue?"copy":"none")}function _e(me){re(me)&&(p.current=Math.max(0,p.current-1),p.current===0&&A(!1))}function he(me){re(me)&&(me.preventDefault(),p.current=0,A(!1),ue&&D.add(Array.from(me.dataTransfer.files)))}function ae(me){me.target!==me.currentTarget||!re(me)||(me.preventDefault(),me.dataTransfer.dropEffect="none")}function ge(me){re(me)&&me.preventDefault()}function Se(me){if(!ue)return;const $e=Array.from(me.clipboardData.files),Pe=me.target,qe=Pe instanceof HTMLTextAreaElement||Pe instanceof HTMLInputElement,Le=Array.from(me.clipboardData.types).includes("text/plain");Xhe({files:$e.length,hasText:Le,intoTextField:qe})&&(me.preventDefault(),D.add($e))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ae,onDrop:ge,"data-leaving":B||void 0,children:a.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:me=>me.stopPropagation(),onDragEnter:pe,onDragOver:ye,onDragLeave:_e,onDrop:he,onPaste:Se,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:r,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:V.armed?fI:khe(K.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:me=>{xhe(me.nativeEvent)&&(me.preventDefault(),me.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(Nhe,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:m5,rows:5,placeholder:X.placeholder,onChange:me=>E(me.target.value),"aria-invalid":Y||void 0,"aria-describedby":ee,required:!0}),Y&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:she}),a.jsx(lfe,{images:D,addRef:o}),J&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:xfe(R)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(ife,{images:D,buttonRef:o}),a.jsx(She,{open:L,onToggle:()=>U(me=>!me)})]}),a.jsx(_he,{open:L,contact:C,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:P?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:P})," — ",hhe]}):fhe}),K.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${V.armed?" armed":""}`,onKeyDown:me=>{me.repeat&&me.preventDefault()},onClick:V.press,title:V.armed?fI:kfe,children:V.armed?bfe:vfe}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":bhe(ne)||void 0,children:ne}),a.jsx("kbd",{children:le})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Ps(G),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…"})]})})]})]}),F&&a.jsxs("div",{className:"fb-done",children:[a.jsx(hf,{}),a.jsx("p",{className:"fb-done-line",children:w5})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":q||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(N5,{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 E5="Press Esc first if a key does nothing.",mI=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{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:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{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:[]}]}],Rfe=/ \([A-Z?]\)/g;function C5(e){return e?mI:mI.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(v3)).map(n=>({...n,action:n.action.replace(Rfe,"")}))})).filter(t=>t.rows.length>0)}const Afe="Single-key shortcuts are off.",T5="Settings › Keyboard",Mfe=`Single-key shortcuts can be turned off in ${T5}.`;function $fe({onClose:e,onTour:t,onSettings:n}){const s=ct(e),r=xt(e),o=Eu(_u()),i=Ln(),c=C5(i);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",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:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:Afe})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:T5}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),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:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[E5," ",Mfe]})]})]})})}function Aj(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:s})=>a.jsx(Ife,{name:t,onClose:s})})))}function Ife({name:e,onClose:t}){const n=y.useRef(null),s=ct(t,{focusRef:n}),r=xt(t);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function Lfe(e,t){return`${e}#${t}`}function Ofe(e,{lan:t,now:n,closed:s}){if(t===void 0)return[];const r=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=Lfe(i.key,i.since);if(s.has(c)||bQ(i.key,o.email,t,n))continue;const d=o.email??"";r.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return r}function Pfe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(s=>s.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(s.num)===String(t.num))).map(s=>s.id):[]}function R5({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Dfe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Ffe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Bfe="Login expired",qfe="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.",Ufe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Wfe(e,t){const n=(e??[]).filter(r=>r&&typeof r.fp=="string"&&!t.has(r.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((r,o)=>(r.at??0)-(o.at??0));return{request:s[0],waiting:s.length-1}}function Hfe({request:e,waiting:t,busy:n,now:s,onAccept:r,onDecline:o,onLater:i}){const c=y.useRef(null),d=ct(i,{focusRef:c}),h=xt(i),f=Fa(n,"accept"),p=Fa(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:m=>m.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:i,"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 ",Y1(e.at,s)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:r,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function zfe(e){const t=y.useRef(!1),n=Vfe(e),s=R5({rows:n?1:0,ours:t.current,dialogs:Cn.dialogDepth()});return t.current=s,s?n:null}function Vfe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:r}){const{request:o,waiting:i}=Wfe(e,t.current);return o?a.jsx(Hfe,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void s("accept",o.fp),onDecline:()=>void s("dismiss",o.fp),onLater:()=>r(o.fp)},o.fp):null}function Gfe({rows:e,onSignIn:t,onLater:n,firstRef:s}){const r=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[r?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:r.name}),r.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",r.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:qfe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Ffe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>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:Bfe}),a.jsx("button",{type:"button",className:"btn",ref:i===0?s: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:Ufe,onClick:n,children:"Not now"}),r&&a.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(r),children:"Sign in again"})]})]})}function Kfe({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),r=ct(n,{focusRef:s}),o=xt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal reauth-ask",onClick:i=>i.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:Dfe(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(Gfe,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function Yfe({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:r,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=Cn.dialogDepth()+(c?1:0),f=t!=null||R5({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(KP,{email:t.email||null,onClose:o,onChanged:r,onSignedIn:s}):f?a.jsx(Kfe,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Xfe={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3","3.43.1","3.43.3"],"3.43.0":[{title:"🏠 Auto-switch can come back to a home account",body:"Choose Set as home in an account’s ⋯ menu. With Auto-switch on, Next account › Soonest weekly reset uses up quota that resets within 4 days first."},{title:"🔄 Sessions already running appear when ccdeck starts",body:"Busy Codex sessions, and Claude ones on macOS and Linux, show up again after a restart. Restore unfinished sessions, in Settings › General, turns it off."},{title:"⚙️ Settings, reorganized and searchable",body:"Search every setting from the top of the list. Keyboard, Data and About have sections of their own."},{title:"📋 Plan progress and reasoning effort on agent cards",body:"Cards show how far an agent is through its plan, and the effort beside the model. Finished sessions can hide themselves after a delay you choose."},{title:"✨ Calmer desktop updates, marked shared accounts, Codex sub-agents kept together",body:"The desktop app installs an update only when no agent is working or waiting. Accounts shared on Local network are marked."}],"3.42.0":[{title:"🔠 Text size and density, in Settings",body:"Five text sizes and five spacing levels, under Settings › Text & density."},{title:"🛠️ Tool activity: which tools your agents use, how long they take and what fails",body:"A new page on the stripe on the right. Its history is kept on this device only."},{title:"🎨 Gruvbox Dark, Light and Material themes",body:"Pick one in Settings › General. Switching themes now fades instead of snapping."},{title:"✨ A session-list drawer on phones, whole dates in usage history, the waiting session in the minimap",body:"Smaller fixes for the phone layout, the usage history chart and the canvas minimap."}],"3.41.1":[{title:"🪟 More reliable Windows updates",body:"Restart to update stops the app’s background server before installation begins."},{title:"📊 More accurate account capacity",body:"Elapsed resets and older readings no longer imply newly available quota. Account refreshes keep the latest valid readings."},{title:"🖥️ Better layouts on portrait displays",body:"Sessions fill the right columns, and the canvas starts near the top. Usage history controls stay reachable in narrow windows."},{title:"✨ Clearer load history and consistent icons",body:"Load history includes the current core-capacity multiplier below the charts. Refresh and external-link icons look consistent across system fonts."}],"3.41.0":[{title:"📅 Plan account resets",body:"See the next seven days of resets, account capacity and which readings need refreshing."},{title:"📊 Follow quota history",body:"Inspect recorded Claude and Codex quota readings to see how remaining capacity changes over time."},{title:"♻️ See cached input reuse",body:"Session usage details now show the percentage of measured input reused from cache."},{title:"📻 A more polished Radio Explorer",body:"Find radio stations with compact search and filters, explore workspace streams separately, and save favorites from either source. Playback and keyboard navigation are more reliable."},{title:"🌍 Radio flags on Windows",body:"Country flags now display correctly in the radio station list on Windows."},{title:"🔧 Clearer Telemetry Radar controls",body:"Change individual telemetry flags and use a simpler Monitor view."}],"3.40.2":[{title:"📻 Music is in Radio now, not in Settings",body:"Settings no longer has a Music section. Claude FM, Lofi Girl and the streams you added are under Workspace streams in Radio, on the right sidebar, and Radio’s player has the volume and mute. Your station, volume and streams are kept. Adding, renaming or removing a stream link is no longer offered."}],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › General. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."},{title:"🔎 Telemetry Radar on Linux and Windows, with no Terminal step",body:"Radar now works on macOS, Linux and Windows. Press Start monitoring and ccdeck runs the capture itself, with no command to paste into Terminal, and keeps listening until you stop it. Capture needs a one-time setup for your user: Wireshark’s ChmodBPF helper on macOS, tcpdump with capture permission on Linux, or Wireshark with Npcap on Windows. Radar says what is missing, and once permission is granted it starts listening by itself."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › General. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Captured messages stay in ccdeck's memory, and no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › General. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). V opens it at Sounds, with each tone's volume and sound, and M turns sounds off or on from anywhere. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in Settings › Notifications, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:"Feedback, beside Settings at the right of the topbar (under More on a phone), opens a short form: pick what kind it is, write a few lines, and add a way to reach you under Add details 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 desktop app can also 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:"Settings › General shows a small preview of the deck in each theme. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
110
-
111
- A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
112
-
113
- The canvas also says when auto-fit is off, with one press to bring new sessions back into view.`},{title:"🔍 A tool call's detail reads as the call",body:"A tool call's arguments are shown as the call rather than as escaped JSON, and can be copied."},{title:"🔐 Saying yes to every deck that asks takes two presses",body:"The switch that accepts every pairing request arms first and says what it hands over, so one stray click cannot put this machine's logins on another deck."},{title:"🖐️ Targets, themes and contrast",body:"The panel's smallest controls reach the 24px target floor, and grow further under a finger. A first run follows the system's light or dark setting instead of picking one. Status dots, meters and switch knobs survive a Windows Contrast theme."}],"3.22.15":[{title:"🖱️ Clicking a card opens its details",body:"Selecting an agent is inspecting it: a click, `j`/`k`, a session picked from the list and Enter on a focused card all open the detail panel — prompt, every tool call, tokens, timing. It used to open only with `D`, so anybody who closed it with its × and never found the key did not get it back. The × still closes it until the next selection, and `D` still toggles it.\n\n`D` with nothing selected now picks a card first — the session that has waited longest, or the one `j` would land on — instead of flipping a switch with nothing on screen to show for it."},{title:"⌨️ The keyboard and screen readers reach the whole deck",body:`Shortcuts keep working after a mouse click on a button. A click left focus on the button it pressed, and the key handler leaves a focused control its own keys, so every single-key shortcut was dead until you pressed Esc — with nothing on screen to say so.
114
-
115
- Tab follows the page now — topbar, the accounts column, the canvas, usage, machine — instead of zig-zagging left and right across it, and a canvas card reached by Tab draws the focus ring. A screen reader hears each card by name, with its kind, state, model and cost, rather than every word on it run together; the machine panel has a heading its region is named by; and the theme button is named for the theme it switches to.
116
-
117
- With **Reduce motion** set, the camera no longer flies across the canvas to a card.`},{title:"💵 The money figures say what they measure",body:"The usage header's **$/min** is spend over a trailing window, and says which span it measured: `$3.54/min · 2 min`. It used to divide the live agents' cost by how long the longest of them had been running, so one deck read $2.39/min in a tab left open and $19.49/min in a tab opened minutes later.\n\nA quota bar's pace says **over pace** or **under pace**. It said `ahead`, which is how plain English says winning, on the very line meant to warn you that you are burning the window faster than it lasts.\n\nA card's clock reads `≥ 53m 52s` for a session this page joined after it had started, instead of presenting the part it saw as the whole of it — and that card's per-minute burn is left out rather than divided by the short clock."},{title:"↔️ Narrow windows keep every topbar control on screen",body:`At 400px six of the topbar's buttons sat past the right edge and the page scrolled sideways. The readouts give way first now and the controls stay; below 640px the side panels span the window instead of leaving the canvas a sliver; and the category filter wraps inside the canvas rather than being clipped by it.
118
-
119
- Zoomed out, a card's name and a cluster's label stay readable instead of shrinking to about four pixels — which is the view a board of any size actually sits at.`},{title:"🔑 A paired deck's dialog says which account that machine is on",body:`The lane of the account the other machine is working on takes the accent and a slow ring on that machine's end. An account is named only if that deck shares it: on one it does not share, the dialog reads "on another account" and never which. A new switch under **SHARE THESE ACCOUNTS**, on by default, turns the telling off, and paired decks then read "current account hidden".
120
-
121
- **This deck on the network** prints this deck's own fingerprint again. A pairing request asks you to match it against the one on the other machine's screen, and no screen here was showing it — so the one check a person can make against a rogue deck could not be made, on the step that hands over logins.`},{title:"💬 The deck's messages send you somewhere worth going",body:'An empty canvas no longer ends with "Make sure ccdeck is running" while the page is plainly connected to it. The capture hints under that line, one per CLI, are the real reasons a canvas stays empty, and they stay. With the stream down the screen says whether this page lost a deck that was there or never found one, in those words, rather than naming the `/events` route nobody who typed `npx ccdeck` has seen.\n\nAnd a slow `claude-swap` now reads as a slow answer — "still waiting on the deck server" — instead of "couldn\'t reach the deck server", which sent people off to restart a server that was fine.'}],"3.22.10":[{title:"🖱️ Icon buttons are easier to hit",body:"Icon buttons react when the pointer is near them — no need to hit the icon exactly."},{title:"🧩 Sessions spread across the canvas",body:"Sessions now spread across the canvas in columns instead of one tall column, and new sessions and subagents land in the free space beside them. Nothing is placed under the Machine or Usage panels. Press R once to rearrange a board you already have."}],"3.21.0":[{title:"🖼️ The deck explains itself in pictures",body:"🎬 First run opens an eight-picture tour instead of the changelog — who is waiting on you, the tree, a node's inside, cost and quota, this machine, accounts, local network, how to start. `Take the tour` on an empty canvas brings it back.\n\n📡 **Local network** has a guide: a card while it is off, `How it works` under an empty list, four pictures ending on `Turn it on`. A machine's row opens its own dialog — address, version and system, the logins it offers, and a name of your own for it. Setup ends on Done.\n\n🔄 The deck updates itself when nobody is looking: no tab focused, no agent mid-turn, thirty seconds quiet. The banner's `auto when idle` switch governs it.\n\n🔑 An account whose numbers were paused resumes on its own, and the panel is titled **Claude accounts** — a Codex login is not in it."}],"3.20.0":[{title:"🟢 The deck keeps running after you close the terminal",body:"`ccdeck` prints the same boot report and gives you the prompt back. The deck stays up, and starts again when you log in.\n\n🛑 **`ccdeck --stop` is the off switch now** — Ctrl+C only cancels a start that is still printing. `--status` says what is running, `--logs` shows what the deck wrote while you were away, and `--foreground` holds the terminal the way every version before this one did.\n\n🔁 Typing `ccdeck` beside a deck that is already up opens **that deck's tab** instead of building a second one. `ccdeck --stop --all` clears any older deck still running from before this version. An `npx` run cannot start at login — `npx ccdeck --install` puts it on your PATH and sets that up.\n\n🔑 An account that will not collect now says which of three things is wrong: **no stored login**, a **login that expired**, or a **keychain the deck cannot open** — with the fix beside it. One with no stored login is filled over the local network by a paired deck that has it.\n\n📡 And decks find each other again on a machine with a VPN up: the beacon was going to an address that never left the machine, so this deck could hear colleagues and none of them could hear it."}],"3.19.0":[{title:"🟢 Local network: fixes and improvements",body:`The list of decks is quiet now. A deck that is **on**, with nothing to repair, is a name and a green mark — no sentence under it. Every healthy row used to carry the same words, so the one row worth reading looked like all the others. A failure, a login that arrived, a machine that is away, still say so, and they are now the only rows with anything written on them.
122
-
123
- \`unpair\` arrives when you point at a row rather than sitting on every one of them, two machines that share a name show their addresses, and the ↻ turns while a round is out.
124
-
125
- **Add a deck** is two ways in — by address, or with an invite — with \`make one to send\` beside the invite heading instead of under the paste field, where it read as that field's button. A refused address now says which mistake it was, and an invite that will not work says whether it ran out, was not an invite, or reached nothing.
126
-
127
- Switching **Local network** on opens your name and shared logins, every time, so nothing goes on the network without you having just seen what goes with it.`}],"3.18.3":[{title:"🟢 The list shows what is on, and folds the rest",body:'A machine that is off, or nearby and unpaired, or one you said no to, is context rather than an answer to "who can I use right now" — so the decks that are **on** lead the list and everything else is one line: `2 more`. Nothing worrying is hidden by it: a deck that cannot be reached is counted in that line, in the warning colour, so the fold says whether it is worth opening.\n\nThe round moved to a **↻ beside the switch**, where the accounts header has kept the same act since it was written, and the line under the state now says when it last ran — `checked 2m ago`, or `not checked yet`. A list that refreshes itself and a list that has stopped used to look identical, and pressing the button to find out was the only way to tell.'}],"3.18.1":[{title:"🔁 A deck stops asking to pair over and over",body:"Several decks on one computer share a config directory, so they start with one key. Each read the others' beacons as somebody wearing its name, took a fresh key, and wrote it to the file the others read — a loop that never settles. Every new key is a **new deck** to everyone else on the network, so one machine sent a fresh pairing request every few seconds and accepting one accomplished nothing: the deck that asked no longer existed by the time the answer arrived.\n\nDecks on one computer now recognise each other as the same machine and leave the key alone. The clash still worth healing — a `~/.claude` copied to a second machine — is unchanged.\n\nThis also collapses the rows: a computer that has run the deck a few times appeared several times on everybody else's panel and is one row now. **Both machines need this version** for that to take effect on the other one's screen.\n\nA deck that answered is no longer counted as unreachable, the list refreshes itself in seconds while somebody is deciding rather than at the next minute, and a failed round says what happened — `not listening`, `no route to it` — with the address and the raw error on the hover."}],"3.18.0":[{title:"🟢 A deck that is switched off no longer reads as on",body:"A paired deck this one has no address for was drawn **live** on the strength of being paired — a machine closed an hour ago still sat under `1 deck ready`. Every row now leads with whether that machine is actually there, and when it last was: `online · 1 login arrived`, `no answer · last online 20m ago`, `never reached`. The mark beside the name is a traffic light — green for a deck that answered, amber for one that cannot be reached, grey for one nothing has heard from.\n\n**+ add a deck** opens a dialog now instead of unfolding inside the panel. An address, an invite and the firewall note never fitted a 288px column, and unfolded they turned a list of machines into a form."}],"3.17.0":[{title:"🔔 Pairing is two presses",body:`When another deck asks to pair, the question now arrives **over the deck** rather than in a row three sections down a panel: its name, its address, the fingerprint to compare, **Accept** or **Decline**. Escape means later — the request stays in the panel until you answer it.
128
-
129
- The rest is one list. Every deck you are paired with, every deck on the network, and every one you turned away, each a row with its state under the name and one verb at the end — and a deck that cannot be reached now reads differently from one that is fine. Saying no also reaches the other machine now, instead of leaving it waiting forever; you can take it back.
130
-
131
- The dialog behind **setup** is down to the two things it is really about: what this deck is called, and which logins it offers.`}],"3.15.0":[{title:"🔗 Decks on one network heal each other's dead logins",body:`A login dies on the machine that has not used it while the same account keeps working on the machine that has. The fix was a blob copied out of one deck and pasted into another. Now: **Accounts ▸ Local network**, the same passphrase on each deck — it offers you six words — and they find each other and repair themselves.
132
-
133
- A deck only **adds** an account it does not have, or **replaces one it has proven dead** — proven by Anthropic refusing the token, not guessed. A credential that works is never touched. The passphrase is the only gate; a stranger on the same wifi sees that a deck exists and nothing else.`},{title:"⚠️ What sharing a login actually means",body:`**A login you share is a live one, and it cannot be taken back.** Turning the switch off stops what has not happened yet; a credential that has left your machine is gone, and the only real revocation is signing in again at Anthropic — which ends the session everywhere at once.
134
-
135
- Sharing a Claude account may also be against Anthropic's terms. Your call; the deck says it once and does not nag.`}],"3.14.0":[{title:"📊 The machine comes back beside the list that covers it",body:`**Busiest processes** opens over the machine panel and hides the very readings that sent you looking. They are back beside the list — cores, memory, swap, queued work, temperature — with up to an hour behind each: a column down the side on a wide screen, a band under the table on a narrow one.
136
-
137
- Each is drawn against the line it is measured to — memory and swap at 90%, load at your core count, the GPU at 75° and again at 90° — so swap sitting *on* its line is something you see rather than work out. The processor readings get no line on purpose: a CPU at 90% is your machine doing what you asked for. Throttling appears only once your machine has actually been held back, and the band says how much history it really has rather than claiming an hour it has not had.`},{title:"📋 The process dialog's footnote moved onto the columns it was about",body:"A band ran along the bottom of **Busiest processes** saying three things. Two were worth keeping and are now on the header of the column they describe — hover `memory` to read what that number measures, `process` to read that the command-line redaction is a filter rather than a promise.\n\nThe third said the list is the busiest by processor and memory, refreshed every four seconds. The heading, the count beside it and the moving numbers were already saying that."},{title:"📝 These notes render what they were written in",body:`Every note in this dialog is written in Markdown — **bold** for the sentence that carries the change, backticks for a flag or a path — and the dialog printed the string raw. So the first window you see after an upgrade has been showing you \`**this**\`, backticks and all, since the feature shipped: 25 of 52 notes, 52 bold spans, 54 code spans.
138
-
139
- What you are reading is the first version that does not.
140
-
141
- No Markdown library came along for it. Counted in the file: bold 52, code 54, links 0, headings 0, lists 0 — and the smallest library that reads all of Markdown is 40KB on a bundle the deck fetches while you wait for it to start.`},{title:"⎋ Esc leaves the machine panel where it is",body:"The × on **This machine** read `Close (Esc)`, so Escape put the panel away. Escape belongs to the canvas — it deselects and hands the keyboard back — and pressing it while you are reading your instruments should not close them.\n\nThe panel now closes the ways it opens: its ×, its button on the window's right edge, and S. 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, on the window's right edge now, opens the same **This machine** panel — cores, memory, swap, load, temperature, busiest processes — and the bar stops moving in the corner of your eye.
142
-
143
- It 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.
144
-
145
- 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.
146
-
147
- 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.
148
-
149
- 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.
150
-
151
- 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.
152
-
153
- The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
154
-
155
- **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.
156
-
157
- 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.
158
-
159
- \`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.
160
-
161
- 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. Its button is on the window\'s left edge now.\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.
162
-
163
- **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.
164
-
165
- **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.
166
-
167
- **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.
168
-
169
- **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.
170
-
171
- **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.
172
-
173
- **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.
174
-
175
- 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.
176
-
177
- 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.
178
-
179
- 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.
180
-
181
- 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.
182
-
183
- 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 Settings › Notifications 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.
184
-
185
- There is a **Notifications** switch in Settings › Notifications now. One switch governs both notifiers, it takes effect immediately without a restart, and it is remembered across restarts.
186
-
187
- 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 Settings 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.
188
-
189
- 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 appeared while something was actually blocked.
190
-
191
- 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.
192
-
193
- 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.
194
-
195
- Now it reaches the desktop, two ways that never overlap. With the deck open behind something, the page raises the notification itself: the browser asks for permission when you turn notifications on in Settings › Notifications — nothing is requested before you do. 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.
196
-
197
- 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.
198
-
199
- 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.
200
-
201
- 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.
202
-
203
- 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.
204
-
205
- 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.
206
-
207
- 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.
208
-
209
- 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.
210
-
211
- 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.
212
-
213
- 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.
214
-
215
- 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.
216
-
217
- It is gone. The panel still shows the board's tokens and cost 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.
218
-
219
- 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.
220
-
221
- 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.
222
-
223
- 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.
224
-
225
- 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 Browser Watch badge no longer counts findings while the watch is off; open the panel to see them.
226
-
227
- 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.
228
-
229
- 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.
230
-
231
- 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.
232
-
233
- 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.
234
-
235
- 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.
236
-
237
- 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.
238
-
239
- 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.
240
-
241
- 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.
242
-
243
- 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.
244
-
245
- 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.
246
-
247
- 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.
248
-
249
- 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.
250
-
251
- 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.
252
-
253
- 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".
254
-
255
- 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.
256
-
257
- 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.
258
-
259
- 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.
260
-
261
- 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.
262
-
263
- 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.
264
-
265
- 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.
266
-
267
- 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.
268
-
269
- 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:`Browser Watch is new, on the window's right edge (or press B). 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.
270
-
271
- 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.
272
-
273
- 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.
274
-
275
- When it finds something, its button shows 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.
276
-
277
- 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.
278
-
279
- 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.
280
-
281
- 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.
282
-
283
- 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:`Open Settings › Sounds, or press V. 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.
284
-
285
- 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.
286
-
287
- 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.
288
-
289
- 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.
290
-
291
- 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.
292
-
293
- 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.
294
-
295
- 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.
296
-
297
- 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.
298
-
299
- 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.
300
-
301
- 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.
302
-
303
- 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.`}]},Mj="agent-dag.releaseNotesSeen";function gI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Vo(e,t){const n=gI(e),s=gI(t);for(let r=0;r<Math.max(n.length,s.length);r++){const o=(n[r]??0)-(s[r]??0);if(o!==0)return o<0?-1:1}return 0}function Wa(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Zfe(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 Jfe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!Wa(n)||!Array.isArray(s))continue;const r=s.filter(Zfe);r.length&&t.push({version:n,notes:r})}return t.sort((n,s)=>Vo(s.version,n.version))}const yI=Jfe(Xfe);function A5(e,t,n){return e.filter(s=>Vo(s.version,n)<=0&&(t===null||Vo(s.version,t)>0))}function Qfe(e,t){return e.filter(n=>Vo(n.version,t)===0)}function epe(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 tpe({since:e,running:t,entries:n,firstRun:s}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const i=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${i} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&Wa(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 r=n[0].version;if(!Wa(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=Vo(r,t);return o<0?`v${t} · 🐛 Bug fixes and performance improvements. Earlier release notes are shown below.`: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 npe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function spe(e){const t=npe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function rpe(e){if(!e)return null;let t=null;try{t=e.getItem(Mj)}catch{return null}return Wa(t)?t:null}function ape(e){if(!e)return!1;try{return e.getItem(Mj),!0}catch{return!1}}function ope(e,t){if(!e)return!1;try{return e.setItem(Mj,t),!0}catch{return!1}}const M5="agent-dag.tourSeen";function ipe(e){if(!e)return!1;try{return e.getItem(M5)==="1"}catch{return!1}}function lpe(e){if(!e)return!1;try{return e.setItem(M5,"1"),!0}catch{return!1}}function cpe({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 upe({stored:e,running:t,notes:n,remembers:s=!0}){if(!Wa(t))return{show:[],record:null,reason:"no-version"};if(!Wa(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=Qfe(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const r=Vo(e,t);if(r===0)return{show:[],record:null,reason:"seen"};if(r>0)return{show:[],record:null,reason:"ahead"};const o=A5(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function dpe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const s=e.indexOf("`",n+1);if(s<0)break;n=s+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function $5(e,t=!0){const n=[];let s="";const r=()=>{s&&(n.push({kind:"text",text:s}),s="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){r(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=dpe(e,o);if(i>0){r(),n.push({kind:"bold",kids:$5(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return r(),n}function Ha(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Iwe(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function Lwe(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function hpe(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Owe(e){return!Number.isFinite(e)||e<=0?"empty":qr(e)}function Pwe(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,r)=>s+r.programVisits,0)}))}function fpe(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function Dwe(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],r=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(r>0?`, and ${r} more`:"")+". The watch continues on the profiles it can read."}}const n=hpe(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(s=>s.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}const ppe="Check for updates",I5="Ask npm now whether a newer ccdeck is out.",wI="Checking…",mpe="Couldn't reach npm. Try again.",gpe="Couldn't reach the deck. Try again.",L5="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",ype="The deck looks again in five minutes.";function wpe(e,t,n,s){const r=s?t.npx:n?Vt(t,n):void 0;return r?`${e} is out, but ${r}`:`${e} is out. Run:`}const Tn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),No=e=>Tn(e,{tone:"note"});function xI(e,t){return fpe(e,t)??"just now"}function xpe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?No(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?No("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?No(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?No(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?No("The app's last update check failed. Try Check for updates again."):No("The app keeps itself up to date. Check for updates here.")}function vpe(e,t,n){var i;const s=e.version;if((s==null?void 0:s.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return Tn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=s.upgrade)==null?void 0:i.command)??s.command} here, then restarts once nothing is running.`;return Tn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((s==null?void 0:s.upgradeMode)==="npx"&&s.canRestart){const c=e.upgradeState==="failed";return Tn(c?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:c?"Retry update":"Update & restart",busy:e.restarting,why:`Runs ${s.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const r=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:wpe(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Tn(r,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function bpe(e){const t=e.version;if(e.unreachable)return Tn(gpe,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Tn(mpe,{tone:"warn",age:e.answered?null:`Last tried ${xI(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Tn(`${s} is tagged on npm but can't be installed yet. ${ype}`);const r=t!=null&&t.checkedAt?xI(t.checkedAt,e.now):null;if(e.answered&&(t!=null&&t.latest)){const o=t.latest===e.running?`You're on the latest, ${e.running}.`:`You're on ${e.running}, ahead of npm's ${t.latest}.`;return Tn(o,{age:r?`Checked ${r}.`:null})}return Tn("",{age:r?`Last checked ${r}.`:null})}function kpe(e,t){var r,o;const n=e.version;if((r=e.app)!=null&&r.inApp&&(n!=null&&n.checkDisabled)){const i=xpe(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Tn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Tn(wI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:No(L5)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:vpe(e,s.to,t)};if((s==null?void 0:s.kind)==="restart"){const i=n!=null&&n.canRestart?`${s.to} is installed. Restart the deck to start running it.`:`${s.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:Tn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Tn(wI)}:{canCheck:!0,checking:!1,line:bpe(e)}}const O5=450;async function jpe(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(O5)]);return n?"answered":"unreachable"}async function Npe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,O5))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const F0="Eight pictures of what the deck shows.",vI="Restart the deck. Sessions, settings and pairings come back as they were.";function Spe(e){var I;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Go(3e4),[s,r]=y.useState(!1),o=y.useRef(!1),[i,c]=y.useState(!1),[d,h]=y.useState(!1),f=y.useRef(t);if(y.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:m,restart:w,desktopUpdate:j,running:b,onHandOff:k}=e,v=kpe({version:p.version,running:b,checking:s||t,answered:d,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:Ha(),update:j.appUpdate,version:a5(),menu:i5()}},L0);if(!v)return null;const N=Ha()&&((I=p.version)==null?void 0:I.checkDisabled);return{state:v,check:async()=>{var $;if(!An(o.current||t)||N&&(($=j.appUpdate)==null?void 0:$.status)==="checking")return;o.current=!0,r(!0);const R=N?await Npe():await jpe(p.loadVersion);o.current=!1,r(!1),c(R==="unreachable"),h(!0)},act:R=>{if(R.kind==="copy")return void m.copyCommand();k(),p.showNotice(),R.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:N?"Ask the desktop app whether a newer ccdeck is out.":I5}}function _pe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=jl("above","dialog"),r=Spe(n),o=y.useId(),i=(r==null?void 0:r.state.canCheck)??!1,d=((h=r==null?void 0:r.state.line.action)==null?void 0:h.kind)==="install"||((f=r==null?void 0:r.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!r?null:a.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&a.jsxs("div",{className:"rn-acts",children:[e&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...s.bind({label:F0}),children:[a.jsx(PQ,{}),"Take the tour"]}),r&&i&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void r.check(),"aria-busy":r.state.checking||void 0,"aria-describedby":`${o}-check`,...s.bind({label:r.checkWhy}),children:[a.jsx(DQ,{}),ppe]}),d&&a.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:vI}),children:[a.jsx(FQ,{}),"Restart"]})]}),r&&a.jsx(Epe,{line:r.state.line,onAct:r.act,bindHint:s.bind,whyId:`${o}-act`}),a.jsx("span",{hidden:!0,id:`${o}-tour`,children:F0}),a.jsx("span",{hidden:!0,id:`${o}-check`,children:(r==null?void 0:r.checkWhy)??I5}),a.jsx("span",{hidden:!0,id:`${o}-restart`,children:vI}),s.node]})}function Epe({line:e,onAct:t,bindHint:n,whyId:s}){const{action:r}=e,o=r&&a.jsx(Cpe,{action:r,onAct:t,bindHint:n,whyId:s});return a.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[a.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&a.jsx("span",{className:"rn-update-age",children:e.age}),e.command?a.jsxs("span",{className:"rn-update-cmd",children:[a.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function Cpe({action:e,onAct:t,bindHint:n,whyId:s}){const r=e.kind==="copy"?null:e.why;return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:r?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":r&&s?s:void 0,...r&&n?n({label:r}):{},children:e.label}),r&&s&&a.jsx("span",{hidden:!0,id:s,children:r})]})}function Tpe({entries:e,since:t,running:n,firstRun:s,onClose:r,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const m=ct(r),w=xt(r),j=epe(e);return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:a.jsxs("div",{ref:m,className:"modal release-notes",onClick:b=>b.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"}),j&&a.jsx("span",{className:"modal-tool-id",children:j})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(i||h)&&a.jsxs("div",{className:"rn-update",children:[i&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":pl})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:tpe({since:t,running:n,firstRun:s,entries:e})}),a.jsx(_pe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(b=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",b.version]}),a.jsx("ul",{className:"rn-notes",children:b.notes.map((k,v)=>{const{icon:N,rest:S}=spe(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[N&&a.jsx("span",{className:"rn-note-icon",children:N}),S]}),a.jsx("p",{className:"rn-note-body",children:P5($5(k.body))})]},v)})})]},b.version))]})]})})}function P5(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:P5(t.kids)},n))}function Rpe({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>Ape(e,t),[e,e.revision,t]),r=y.useRef(null),o=ct(n,{focusRef:r}),i=xt(n);return s?a.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),a.jsx("button",{type:"button",ref:r,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:K3}),a.jsx("div",{className:"ss-cost",children:Xe(s.cost.total)}),s.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":Of(c),title:c,children:Da(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(L1,{cost:s.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:Xe(s.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Xe(s.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Xe(s.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Xe(s.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Fi,{label:"agents",value:s.agentCount}),a.jsx(Fi,{label:"subagents",value:s.subagentCount}),a.jsx(Fi,{label:"tool calls",value:s.toolCount}),a.jsx(Fi,{label:"prompts",value:s.promptCount}),a.jsx(Fi,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&a.jsx(Fi,{label:"errors",value:s.errCount,tone:"err"})]}),s.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:s.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Fi({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 Ape(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const S of e.agents.values())S.sessionId===t&&s.push(S);if(s.length===0)return null;const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let c=0,d=0,h=0,f=0,p=0,m,w=1/0,j=0;for(const S of s){const E=In(S);r.input+=E.input,r.output+=E.output,r.cacheRead+=E.cacheRead,r.cacheWrite+=E.cacheWrite,r.total+=E.total;for(const I of YO(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const C=TO(S.prompts);d+=C.length,!m&&C.length>0&&(m=C[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,R]of S.toolCountByName??[])i.set(I,(i.get(I)??0)+R);w=Math.min(w,S.startedAt),j=Math.max(j,S.endedAt??Date.now())}const b=Math.max(0,j-w),k=Math.floor(b/1e3),v=k<60?`${k}s`:k<3600?`${Math.floor(k/60)}m ${String(k%60).padStart(2,"0")}s`:`${Math.floor(k/3600)}h ${Math.floor(k%3600/60)}m`,N=Array.from(i.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:v,cost:r,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:N,firstPrompt:m}}function sn({id:e,title:t,note:n,noteId:s,aside:r,list:o=!0,settingId:i,className:c,children:d}){const h=c?`settings-group ${c}`:"settings-group",f=o?a.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?a.jsx("div",{className:h,"data-setting":i,children:f}):a.jsxs("section",{className:h,"aria-labelledby":e,"data-setting":i,children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{className:"settings-caption-text",children:[a.jsx("h3",{id:e,children:t}),n&&a.jsx("p",{className:"settings-caption-note",id:s,children:n})]}),r]}),f]})}function yt({name:e,nameId:t,note:n,noteId:s,control:r,as:o="label",settingId:i,className:c,children:d}){const h=o;return a.jsxs(h,{className:c?`settings-row ${c}`:"settings-row","data-setting":i,children:[a.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&a.jsx("span",{className:"settings-row-note",id:s,children:n}),r!==void 0&&a.jsx("span",{className:"settings-row-control",children:r}),d]})}function bI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,[s,r]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(""),h=y.useRef(!1);y.useEffect(()=>{let p=!0;return fetch("/api/prefs").then(m=>{if(!m.ok)throw new Error;return m.json()}).then(m=>{var w;if(!m.ok)throw new Error;p&&r(((w=m.prefs)==null?void 0:w[t])!==!1)}).catch(()=>{p&&d("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[t]);const f=async()=>{if(!(s===null||!An(h.current))){h.current=!0,i(!0),d("");try{const p=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[t]:!s})});if(!p.ok)throw new Error;const m=await p.json();if(!m.ok)throw new Error;r(m.prefs[t]!==!1)}catch{d("Could not save this setting. Try again.")}finally{h.current=!1,i(!1)}}};return a.jsxs(sn,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[a.jsx(yt,{settingId:n,name:"Restore unfinished sessions",note:e==="Codex"?"Find unfinished turns in recent local Codex logs on the next start. A missing ending does not confirm the process is still running.":"On the next start, find busy local Claude sessions whose process identity can be verified.",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":`Restore unfinished ${e} sessions`,"aria-checked":s===!0,...Ps(o,s===null),onClick:()=>{f()},children:a.jsx("span",{className:"switch-knob"})})}),c&&a.jsx("p",{role:"alert",children:c})]})}const D5="agent-dag.character",Ih=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Mpe(e){return e==="fox"||e==="penguin"?e:"deck"}function $pe(){return Mpe(Ve(D5))}const Ipe="With no deck tab open, get a notification wherever a sound would have played.",Lpe="With the ccdeck window closed, get a notification wherever a sound would have played.";function Ope(e){return e?Lpe:Ipe}const Ppe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",F5=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],Dpe="For the Claude and Codex accounts you're on, whether or not the deck is open.",Fpe="Held off for this run too.",kI="Get notified when you're away from this tab.";function Bpe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:kI};case"default":return{status:null,ask:!0,ok:!1,note:kI};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."}}}const B5="section:";function q5(e){return e.id.startsWith(B5)}const qpe={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],data:["privacy","local data"],about:["information"]},Upe={done:"Turn finished","needs-input":"Claude is asking"},Wpe={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},Hpe={notifySwap:["auto-switch","switch account","swap","alerts"],notifyQuota:["quota","limit","rate limit","usage","alerts"],notifyReset:["quota","limit","window","available","alerts"]},$j=e=>{var t;return((t=Aa.find(n=>n.id===e))==null?void 0:t.label)??e};function zpe(e){return{id:`${B5}${e}`,section:e,label:$j(e),keywords:qpe[e]}}function Vpe(){const e={general:[{id:"claude-session-recovery",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Restore unfinished sessions",keywords:["claude","recover","restore","startup","restart","busy"]},{id:"codex-session-recovery",section:"general",group:"Codex sessions",label:"Restore unfinished sessions",keywords:["codex","recover","restore","startup","restart","unfinished"]},{id:"hide-finished",section:"general",group:"Board",label:"Hide finished sessions after",keywords:["finished","done","completed","idle","clean up","auto hide","canvas","board","remove"]},{id:"auto-update",section:"general",group:"Updates",label:"Update when idle",keywords:["update","auto update","automatic updates","upgrade","restart","new version"]},{id:"accounts",section:"general",group:"Elsewhere on the deck",label:"Accounts and auto-switch",claudeOnly:!0,keywords:["accounts","auto-switch","switch account","login","claude accounts"]},{id:"local-network",section:"general",group:"Elsewhere on the deck",label:"Local network",claudeOnly:!0,keywords:["lan","pairing","pair","other machines","sync","network"]},{id:"browser-watch",section:"general",group:"Elsewhere on the deck",label:"Browser Watch",keywords:["browser","watch","away","automation","security"]}],appearance:[{id:"theme",section:"appearance",label:"Theme",keywords:["colour theme","color theme","dark mode","light mode","colours","colors","palette","skin"]},...Wr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:Du[t].name,keywords:t.endsWith("contrast")?["high contrast","accessibility"]:[]})),{id:"character",section:"appearance",group:"Character",label:"Show the character",keywords:["character","mascot","companion","claude fm","radio","music","minimap","hide the character"]},{id:"character-choice",section:"appearance",group:"Character",label:"Choose character",keywords:["mascot","avatar",...Ih.map(t=>t.name.toLowerCase())]}],reading:[{id:"text-size",section:"reading",label:"Text size",keywords:["font","font size","zoom","bigger","larger","smaller","scale","readability"]},{id:"density",section:"reading",label:"Density",keywords:["spacing","compact","comfortable","padding","tight","dense"]}],keyboard:[{id:"single-keys",section:"keyboard",label:"Single-key shortcuts",keywords:["single key","letters","voice control","dictation","accessibility"]}],notifications:[{id:"notify-closed",section:"notifications",group:"While the deck is closed",label:"Notifications while closed",keywords:["alerts","desktop notifications","browser notifications","push","background","permission"]},...F5.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:Hpe[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...Wc.map(t=>({id:`tone-${t}`,section:"sounds",label:Upe[t],keywords:Wpe[t]})),{id:"custom-sounds",section:"sounds",label:"Custom sounds",keywords:["voice","speech","text to speech","spoken voice","own sound","library"]},{id:"custom-import",section:"sounds",group:"Custom sounds",label:"Import audio",keywords:["import","upload","file","mp3","wav","ogg","own sound"]},{id:"custom-record",section:"sounds",group:"Custom sounds",label:"Record a clip",keywords:["record","microphone","mic","clip"]}],data:[{id:"tool-history-retention",section:"data",group:"Tool history",label:"Keep history",keywords:["retention","delete history","history","days","tool calls","statistics"]},{id:"tool-history-size",section:"data",group:"Tool history",label:"Space used",keywords:["storage","disk","size","bytes"]},{id:"tool-history-clear",section:"data",group:"Tool history",label:"Clear history",keywords:["delete history","erase","wipe","remove"]}],about:[{id:"version",section:"about",group:"ccdeck",label:"Version",keywords:["update","release","build","about"]},{id:"whats-new",section:"about",group:"ccdeck",label:"What's new",keywords:["changelog","release notes","changes","news"]},{id:"licence",section:"about",group:"ccdeck",label:"Licence",keywords:["license","agpl","source","source code","open source","github"]},{id:"tour",section:"about",group:"Tour and feedback",label:"Take the tour",keywords:["tour","guide","help","onboarding","tutorial","introduction"]},{id:"feedback",section:"about",group:"Tour and feedback",label:"Send feedback",keywords:["feedback","bug","report","contact","suggestion","idea"]}]};return Aa.flatMap(({id:t})=>[zpe(t),...e[t]])}const B0=Vpe();function Gpe(e){return e?B0:B0.filter(t=>!t.claudeOnly)}function U5(e){if(q5(e))return"Section";const t=$j(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function Kpe(e){return`${e.label}, ${U5(e).replace(/ › /g,", ")}`}function Ic(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function wh(e,t){for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1))if(n===0||!/[a-z0-9]/.test(e[n-1]))return!0;return!1}function Ype(e,t){const n=Ic(e.label);if(n.startsWith(t))return 0;if(wh(n,t))return 1;const s=e.keywords.map(Ic);if(s.some(i=>wh(i,t)))return 2;const r=[Ic($j(e.section)),...e.group?[Ic(e.group)]:[]];if(r.some(i=>wh(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...r];if(o.every(c=>i.some(d=>wh(d,c))))return 4}return null}const Xpe=12;function Zpe(e,t=B0){const n=Ic(e);return n?t.map((s,r)=>({entry:s,at:r,score:Ype(s,n)})).filter(s=>s.score!==null).sort((s,r)=>s.score-r.score||s.at-r.at).slice(0,Xpe).map(s=>s.entry):[]}function W5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function Jpe(e,t,n,s){if(e==="Escape")return t!==""?{kind:"clear"}:{kind:"pass"};if(n===0)return{kind:"pass"};const r=Math.min(Math.max(s,0),n-1);return e==="ArrowDown"?{kind:"move",index:(r+1)%n}:e==="ArrowUp"?{kind:"move",index:(r-1+n)%n}:e==="Enter"?{kind:"open",index:r}:{kind:"pass"}}const Qpe="Hide finished sessions after",eme="A finished session leaves the canvas after this long. It stays in the session list (L), and comes back when it starts working again or needs you.";function tme(){const e=GD();return a.jsx(sn,{id:"settings-board-caption",title:"Board",children:a.jsx(yt,{settingId:"hide-finished",name:Qpe,nameId:"settings-hide-finished-label",note:eme,noteId:"settings-hide-finished-note",control:a.jsx("select",{className:"sm-select",value:e,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:t=>qce(Number(t.target.value)),children:WD.map(t=>a.jsx("option",{value:t,children:Bce(t)},t))})})})}const nme="Accounts and auto-switch",sme="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",rme="Local network",ame="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",ome="Browser Watch",ime="Whether something drove your browser while you were away, and what the deck does about it.";function lme({claudeHere:e,singleKeys:t,doors:n}){return a.jsxs(sn,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&a.jsx(gk,{settingId:"accounts",name:nme,note:sme,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&a.jsx(gk,{settingId:"local-network",name:rme,note:ame,onOpen:n.localNetwork,cap:null}),a.jsx(gk,{settingId:"browser-watch",name:ome,note:ime,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function gk({settingId:e,name:t,note:n,onOpen:s,cap:r,dialog:o=!1}){const i=`settings-${e}`;return a.jsx(yt,{as:"div",settingId:e,name:t,nameId:`${i}-name`,note:n,control:a.jsxs(a.Fragment,{children:[r&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:r.title,children:r.key}),a.jsx("button",{type:"button",className:"btn",id:`${i}-open`,"aria-labelledby":`${i}-open ${i}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":r?r.key:void 0,onClick:s,children:"Open"})]})})}const cme="Single-key shortcuts",ume="Keys like L, U, M, ? and Space open panels and toggle things. Turn this off if you use voice control or press them by accident.";function dme(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function hme(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function fme({singleKeys:e,onToggleSingleKeys:t}){const n=Eu(_u()),[s,r]=y.useState(""),o=y.useId(),i=C5(e).map(c=>({...c,rows:c.rows.filter(d=>hme(d,s))})).filter(c=>c.rows.length>0);return a.jsxs(a.Fragment,{children:[a.jsx(sn,{children:a.jsx(yt,{settingId:"single-keys",name:cme,nameId:"settings-single-keys-label",note:ume,noteId:"settings-single-keys-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsxs("div",{className:"settings-filter",children:[a.jsx("label",{className:"vis-hidden",htmlFor:o,children:"Filter shortcuts"}),a.jsx("input",{id:o,type:"search",className:"settings-filter-field",placeholder:"Filter shortcuts",autoComplete:"off",spellCheck:!1,value:s,onChange:c=>r(c.target.value),onKeyDown:c=>{n3(c.key)&&s&&(c.stopPropagation(),r(""))}})]}),i.map(c=>{const d=`settings-keys-${c.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return a.jsx(sn,{id:d,title:c.title,className:"settings-keys",children:c.rows.map(h=>a.jsx(yt,{as:"div",name:dme(h),control:a.jsx("kbd",{className:"settings-key",children:n&&h.macCap?h.macCap:h.cap})},`${h.cap}:${h.action}`))},c.title)}),i.length===0&&a.jsxs("p",{className:"settings-empty",role:"status",children:["No shortcut matches “",s.trim(),"”."]}),s.trim()===""&&a.jsx("p",{className:"settings-foot",children:E5})]})}function pme({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:r,accountNotify:o,onToggleAccountNotify:i}){const c=Bpe(s),d=Ha(),h=e&&!n&&!d,f=y.useRef(null),p=Ur(!c.ask,f);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"sm-closed-caption",title:"While the deck is closed",children:[a.jsx(yt,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?Ppe:Ope(d),noteId:"sm-notify-note",control:a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})}),h&&a.jsx(yt,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:c.note,control:c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),r()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})})]}),a.jsx(sn,{id:"sm-accounts-caption",title:"Accounts",note:n?Fpe:Dpe,children:F5.map(({kind:m,label:w,title:j})=>a.jsx(yt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:j,noteId:`sm-${m}-note`,control:a.jsx("button",{type:"button",role:"switch","aria-checked":o[m],"aria-labelledby":`sm-${m}-label`,"aria-describedby":`sm-${m}-note`,className:"switch",onClick:()=>i(m),children:a.jsx("span",{className:"switch-knob"})})},m))})]})}function H5({section:e}){return 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:[e==="reading"&&a.jsx(a.Fragment,{children:a.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),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"})]}),e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="appearance"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M7 1.7a5.3 5.3 0 1 0 0 10.6c.8 0 1.3-.5 1.3-1.2 0-.6-.5-1-.5-1.6 0-.7.5-1.2 1.2-1.2h1.3a2.3 2.3 0 0 0 2.3-2.3C12.6 3.7 10.1 1.7 7 1.7z"}),a.jsx("path",{d:"M4.3 6.7h.01M5.7 4.4h.01M8.4 4.2h.01"})]}),e==="keyboard"&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"1.5",y:"3.5",width:"11",height:"7",rx:"1.4"}),a.jsx("path",{d:"M4 5.9h.01M6 5.9h.01M8 5.9h.01M10 5.9h.01M4.6 8.2h4.8"})]}),e==="data"&&a.jsxs(a.Fragment,{children:[a.jsx("ellipse",{cx:"7",cy:"3.6",rx:"4.6",ry:"1.7"}),a.jsx("path",{d:"M2.4 3.6v6.8c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7V3.6"}),a.jsx("path",{d:"M2.4 7c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7"})]}),e==="about"&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5.4"}),a.jsx("path",{d:"M7 6.4v3.4M7 4.4h.01"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const mme=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function gme(e){return mme.find(t=>e(t))}const yme=4400;function wme(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function xme({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[r,o]=y.useState(!1),i=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=i.current)==null?void 0:p.state)==="recording"&&i.current.stop()},f=async()=>{var m;if(e)return;if(t(""),!((m=navigator.mediaDevices)!=null&&m.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=gme(k=>MediaRecorder.isTypeSupported(k)),j=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=j,j.ondataavailable=k=>{k.data.size&&b.push(k.data)},j.onerror=()=>t("Recording failed. Please try again."),j.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const k=i.current===j;if(k&&(i.current=null),o(!1),!k||!b.length)return;const v=wme(j.mimeType),N=new File(b,v.name,{type:v.type});n(()=>s(N))},j.start(200),o(!0),c.current=setTimeout(h,yme)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:r,startRecording:f,stopRecording:h}}function vme({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[r,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[m,w]=y.useState("1"),[j,b]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const k=()=>{b(window.speechSynthesis.getVoices())};return k(),window.speechSynthesis.addEventListener("voiceschanged",k),()=>window.speechSynthesis.removeEventListener("voiceschanged",k)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{className:"settings-row",...t,onClick:k=>{const v=k.currentTarget.parentElement;e&&v&&!v.open&&k.preventDefault()},children:[a.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),a.jsx("span",{className:"settings-row-note",children:"Create from text"}),a.jsx("span",{className:"settings-row-control",children:a.jsx("svg",{className:"sm-voice-chevron",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.5 3.5 9 7l-3.5 3.5"})})})]}),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:r,maxLength:80,onChange:k=>o(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:k=>c(k.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:k=>h(k.target.value),children:[a.jsx("option",{value:"",children:"System default"}),j.map(k=>a.jsx("option",{value:k.voiceURI,children:k.name},k.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:k=>p(k.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:m,onChange:k=>w(k.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:r,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(m)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function bme({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:r,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=S0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),j=y.useRef(0),b=y.useRef(new Map),k=y.useRef(null),v=y.useRef(null);y.useEffect(()=>{if(!m)return;const R=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(R)},[m]);const N=async R=>{c("");try{await R()}catch($){c($ instanceof Error?$.message:"Custom audio could not be saved.")}},S=(R,$)=>{const L=Date.now(),U=fl({armedFor:m,target:R,armedAt:j.current,now:L,gapMs:hl});if(U==="arm"){w(R),j.current=L;return}if(U==="ignore")return;w(null);const O=yre(e.map(M=>M.id),R);N(async()=>{var q;await o(R);const M=document.activeElement;M!==$&&!Kn((M==null?void 0:M.tagName)??null)||(q=O?b.current.get(O):k.current)==null||q.focus()})},{recording:E,startRecording:C,stopRecording:I}=xme({full:f,setCustomError:c,runCustom:N,onImportCustom:t});return a.jsxs(sn,{id:"sm-custom-title",title:"Custom sounds",note:"Your own files, clips and voices, kept on this machine. Either tone above can play one.",aside:a.jsxs("span",{className:"settings-caption-count",children:[d," of ",N0]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&a.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),a.jsx(yt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:a.jsx("button",{ref:k,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var R;f||(R=v.current)==null||R.click()},children:"Choose file"}),children:a.jsx("input",{ref:v,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:R=>{var L;const $=(L=R.target.files)==null?void 0:L[0];R.currentTarget.value="",$&&!f&&N(()=>t($))}})}),a.jsx(yt,{as:"div",settingId:"custom-record",name:"Record a clip",note:E?"Recording…":"Up to 5 seconds",control:E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void C(),children:"Record"})}),a.jsx(vme,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.map(R=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${R.name}`,defaultValue:R.name,maxLength:80,onBlur:$=>{if(!$.target.value.trim()){$.target.value=R.name;return}N(()=>s(R.id,$.target.value))},onKeyDown:$=>{$.key==="Enter"&&$.currentTarget.blur()}}),a.jsx("span",{children:R.kind==="audio"?`${R.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${R.name}`,onClick:()=>r(R.id),children:"Play"}),a.jsx("button",{type:"button",ref:$=>{$?b.current.set(R.id,$):b.current.delete(R.id)},className:`btn sm-custom-icon${m===R.id?" armed":""}`,onKeyDown:$=>{$.repeat&&$.preventDefault()},onClick:$=>S(R.id,$.currentTarget),"aria-label":m===R.id?`Confirm deleting ${R.name}`:`Delete ${R.name}`,title:m===R.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===R.id?"Confirm":"Delete"})]},R.id)),i&&a.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const kme="A tone when a turn finishes, and when Claude asks for something.";function jme({soundOn:e,onToggleSound:t}){const n=y.useId(),s=Ln(),r=y.useId();return a.jsx(sn,{children:a.jsx(yt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:kme,noteId:r,control:a.jsxs(a.Fragment,{children:[s&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press M anywhere to mute or unmute",children:"M"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,"aria-describedby":r,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:a.jsx("span",{className:"switch-knob"})})]})})})}const q0="custom:";function jI(e){return`${q0}${e}`}function Nme(e){return e.startsWith(q0)?e.slice(q0.length):null}function Sme({id:e,label:t="Volume",value:n,step:s=rj,onLevel:r,"aria-describedby":o}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:Mh,max:gf,step:s,value:n,"aria-describedby":o,onChange:i=>r(Number(i.target.value)),style:{"--sm-level":`${(n-Mh)/(gf-Mh)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const NI={done:"Turn finished","needs-input":"Claude is asking"},_me={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Eme({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:r,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=r[e];return a.jsxs(sn,{id:`sm-name-${e}`,title:NI[e],note:_me[e],settingId:`tone-${e}`,aside:a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${NI[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when sounds are 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"]}),children:[a.jsx(Sme,{id:f,value:t.level,onLevel:w=>o(e,w)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:m?jI(m):t.figure,onChange:w=>{const j=w.target.value,b=Nme(j);b!==null?h(e,b):(d(e),i(e,j))},children:[sj[e].map(w=>a.jsx("option",{value:w.id,children:w.label},w.id)),s.length>0&&a.jsx("optgroup",{label:"Custom",children:s.map(w=>a.jsx("option",{value:jI(w.id),children:w.name},w.id))})]})]})]})}const Cme="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Tme({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:r,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b}){var S;const k=mre(d),v=((S=c.find(E=>E.id===k))==null?void 0:S.name)??"the same custom sound",N=k?`Both tones use “${v}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(jme,{soundOn:e,onToggleSound:t}),!s&&a.jsx("p",{className:"sm-note",children:Cme}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when sounds are off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:Wc.map(E=>a.jsx(Eme,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:r,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},E))}),N&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:N}),a.jsx("p",{className:"vis-hidden",role:"status",children:N}),a.jsx(bme,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:b})]})}const Rme="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function Ame(){const[e,t]=y.useState(null),[n,s]=y.useState(""),[r,o]=y.useState(!1),[i,c]=y.useState(null),[d,h]=y.useState(""),f=y.useRef(!1),p=y.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const b=new AbortController,k=window.setTimeout(()=>b.abort(),12e3);try{const v=await fetch("/api/tool-audit/storage",{signal:b.signal}),N=await v.json();if(!v.ok||!N.ok)throw new Error;p.current&&t(N)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(k),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,k)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let v=!1;const N=new AbortController,S=window.setTimeout(()=>N.abort(),15e3);try{const E=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b==="clear"?{action:b,confirm:!0}:{action:b,days:k}),signal:N.signal}),C=await E.json();if(!E.ok||!C.ok)throw new Error;v=!0,p.current&&(c(null),h(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${k} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),v&&m())}},j=i!==null&&a.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":"Confirm",children:[a.jsx("p",{children:i==="clear"?"Delete all recorded tool statistics on this device? This cannot be undone.":`Keep ${i} days? Older calls will be permanently deleted.`}),a.jsxs("div",{children:[a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]});return a.jsxs(sn,{id:"tool-history-settings-title",title:"Tool history",note:Rme,className:"ta-settings",children:[e?a.jsxs(a.Fragment,{children:[a.jsx(yt,{settingId:"tool-history-retention",name:"Keep history",nameId:"ta-keep-label",note:"Calls older than this are deleted.",control:a.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:e.retentionDays,"aria-busy":r,onChange:b=>{if(f.current)return;const k=Number(b.target.value);k<e.retentionDays?c(k):w("retention",k)},children:[30,60,90].map(b=>a.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&j,a.jsx(yt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${yY(e.startedAt)}`,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:gY(e.bytes)}),a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Refresh"})]})}),a.jsx(yt,{as:"div",settingId:"tool-history-clear",name:"Clear history",note:"Deletes every recorded call on this device. New calls are still recorded.",control:a.jsx("button",{type:"button",className:"btn danger","aria-busy":r,onClick:()=>{f.current||c("clear")},children:"Clear…"})}),i==="clear"&&j,!e.storageOk&&a.jsx(yt,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):a.jsx(yt,{as:"div",name:r?"Reading storage…":"Storage size unavailable."}),n&&a.jsxs("div",{className:"settings-row",role:"alert",children:[a.jsx("span",{className:"settings-row-name",children:n}),a.jsx("span",{className:"settings-row-control",children:a.jsx("button",{type:"button",className:"btn","aria-busy":r,onClick:()=>{m()},children:"Retry"})})]}),d&&a.jsx("p",{className:"settings-row settings-row-status",role:"status",children:d})]})}function Mme({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 $me({theme:e,onTheme:t,singleKeys:n}){const s=r=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r.key))return;r.preventDefault();const o=(d=r.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(Wr.indexOf(o??e)+(r.key==="ArrowLeft"||r.key==="ArrowUp"?-1:1)+Wr.length)%Wr.length;t(Wr[c]),(h=r.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return a.jsx(sn,{id:"appearance-theme-caption",title:"Theme",list:!1,settingId:"theme",aside:n&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"}),children:a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:Wr.map(r=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":r,"data-setting":`theme-${r}`,"aria-checked":e===r,tabIndex:e===r?0:-1,onClick:()=>t(r),children:[a.jsx(Mme,{theme:r}),a.jsxs("span",{className:"appearance-theme-name",children:[Du[r].name,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"})})]})]},r))})})}const Ime=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],Lme=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function SI(){return a.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:a.jsx("path",{d:"m2.5 6 2.2 2.2 4.8-4.4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ome({textSize:e,density:t,onTextSize:n,onDensity:s}){const r=e!=="default"||t!=="default";return a.jsx("button",{type:"button",className:"btn",disabled:!r,onClick:()=>{n("default"),s("default")},children:"Reset to defaults"})}function Pme({textSize:e,density:t,onTextSize:n,onDensity:s}){return a.jsxs(a.Fragment,{children:[a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Text size"}),a.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":nC.length,"--reading-selected":nC.indexOf(e)},children:Ime.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice","data-size":r,children:[a.jsx("input",{type:"radio",name:"text-size","aria-label":`${o} ${i}`,value:r,checked:e===r,onChange:()=>n(r)}),a.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Density"}),a.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":sC.length,"--reading-selected":sC.indexOf(t)},children:Lme.map(([r,o,i])=>a.jsxs("label",{className:"reading-choice",children:[a.jsx("input",{type:"radio",name:"density","aria-label":`${o} ${i} spacing`,value:r,checked:t===r,onChange:()=>s(r)}),a.jsxs("span",{className:"reading-density-sample","data-density":r,"aria-hidden":"true",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:o}),a.jsx("small",{children:i})]}),a.jsx(SI,{})]},r))})]}),a.jsxs(sn,{id:"reading-preview-title",title:"Preview",children:[a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Frontend session"}),a.jsx("span",{children:"Waiting for your review"})]}),a.jsx("span",{className:"reading-preview-time",children:"4m"})]}),a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"API integration"}),a.jsx("span",{children:"Working · 3 tool calls"})]}),a.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),a.jsx("p",{className:"settings-foot",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const Dme="AGPL-3.0-only",Fme="GNU Affero General Public License, version 3 only.",Bme="https://github.com/BarganConstantin/ccdeck",qme="What changed in each release, newest first.",Ume="Tell the people who make ccdeck what works and what does not.";function Wme(e){return`This page is from v${e}. The deck has most likely been updated since this tab opened, and a reload picks up the new version.`}function Hme(e,t){return Wa(e)&&Wa(t)&&Vo(e,t)<0}function zme(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${Ct} v${e.version} is downloaded and verified.`}:t?t.kind==="restart"?{kind:"notice",name:"Update installed",note:`v${t.to} is installed — this deck still runs v${t.from}.`}:{kind:"notice",name:"Update available",note:`${Ct} v${t.to} is out — you are on v${t.from}.`}:null}function Vme({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:r,onUpdateRestart:o,doors:i,bundle:c="3.43.3"}){const d=(e==null?void 0:e.running)??c,h=zme(n,t);return a.jsxs(a.Fragment,{children:[a.jsxs(sn,{id:"settings-about-caption",title:Ct,children:[a.jsx(yt,{as:"div",settingId:"version",name:"Version",note:Hme(c,e==null?void 0:e.running)?Wme(c):void 0,control:a.jsx("span",{className:"settings-read",children:d})}),h&&a.jsx(Gme,{offer:h,restarting:s,failure:r,onRestart:o,onUpdate:i.update}),a.jsx(yt,{as:"div",settingId:"whats-new",name:"What's new",note:qme,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),a.jsx(yt,{as:"div",settingId:"licence",name:"Licence",note:Fme,control:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"settings-read",children:Dme}),a.jsxs("a",{className:"settings-link",href:Bme,target:"_blank",rel:"noreferrer",children:["Source",a.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),a.jsxs(sn,{id:"settings-about-help-caption",title:"Tour and feedback",children:[a.jsx(yt,{as:"div",settingId:"tour",name:"Take the tour",note:F0,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),a.jsx(yt,{as:"div",settingId:"feedback",name:"Send feedback",note:Ume,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Gme({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:r}){if(e.kind==="notice")return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:r,children:"Update…"})});const o=l5(e.to,t),i=n&&n.version===e.to?c5(n.failure,n.version):"";return a.jsx(yt,{as:"div",name:e.name,note:e.note,control:a.jsx("button",{type:"button",className:"btn",onClick:()=>s(e.to),"aria-busy":t||void 0,"aria-label":o.label,title:o.title,children:o.text}),children:a.jsx("span",{className:"settings-row-said",role:"status",children:i})})}const Kme="Update when idle",Yme="When nothing has been running for 30 seconds, the deck restarts into a newer version. While you are looking at it, that is one already installed, and only while its notice is up; while nobody is, it installs the new version first. Off, it updates only when you press.",Xme=`${L5} It hears of no new release from npm, and restarts only into a version installed some other way, once nothing has been running for 30 seconds.`,Zme="This deck cannot restart itself (it runs without its supervisor, with --no-persist, or cannot write its event log), so nothing updates on its own here. Your choice is saved for the next start.",Jme="The desktop app keeps itself up to date. It installs a new version once it has been left alone and no agent has been working for a minute, or after waiting a day for that.";function Qme(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const ege={plain:Yme,"checks-off":Xme,"no-restart":Zme};function tge({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=Ha()}){const r=Qme(n,s);return a.jsx(sn,{id:"settings-updates-caption",title:"Updates",children:r==="app"?a.jsx(yt,{as:"div",settingId:"auto-update",name:"Updates",note:Jme}):a.jsx(yt,{settingId:"auto-update",name:Kme,nameId:"settings-auto-update-label",note:ege[r],noteId:"settings-auto-update-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":"settings-auto-update-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})})}function nge({character:e,onCharacter:t}){const n=y.useRef([]);function s(r,o){var c;const i=J1(r,o,Ih.length,"vertical");i.kind==="select"&&(r.preventDefault(),t(Ih[i.index].id),(c=n.current[i.index])==null||c.focus())}return a.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:Ih.map((r,o)=>a.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===r.id,tabIndex:e===r.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(r.id),onKeyDown:i=>s(i,o),children:[a.jsx("span",{className:"character-preview",children:a.jsx(L3,{character:r.id,act:null,facing:"right"})}),a.jsx("span",{children:r.name}),a.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},r.id))})}const sge="Stands beside the minimap. Press it to play the radio.";function rge({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return a.jsxs(sn,{id:"appearance-character-caption",title:"Character",list:!1,children:[a.jsx("div",{className:"settings-list",children:a.jsx(yt,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:sge,noteId:"appearance-character-note",control:a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})})})}),a.jsx(nge,{character:n,onCharacter:s})]})}const _I="settings-search-field",z5="settings-search-results",U0=e=>`settings-result-${e}`;function age({inputRef:e,query:t,onQuery:n,results:s,active:r,onActive:o,onOpen:i}){const c=t.trim()!=="",d=c&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=Jpe(f.key,t,c?s.length:0,r);p.kind!=="pass"&&(f.preventDefault(),p.kind==="move"?o(p.index):p.kind==="open"?i(s[p.index]):(f.stopPropagation(),n("")))};return a.jsxs("div",{className:"settings-search",children:[a.jsx("label",{className:"vis-hidden",htmlFor:_I,children:"Search settings"}),a.jsxs("svg",{className:"settings-search-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),a.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),a.jsx("input",{ref:e,id:_I,type:"search",className:"settings-filter-field settings-search-field",placeholder:"Search settings",autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":d,"aria-controls":d?z5:void 0,"aria-activedescendant":d?U0(Math.min(r,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:h})]})}function oge({query:e,results:t,active:n,onOpen:s}){const r=W5(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(U0(n)))==null?void 0:o.scrollIntoView)==null||i.call(o,{block:"nearest"})},[n]),a.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[a.jsx("div",{className:"settings-pane-head",children:a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:"Search"}),a.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:r})]})}),t.length>0&&a.jsx("div",{className:"settings-group",children:a.jsx("div",{className:"settings-list",id:z5,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>a.jsxs("button",{type:"button",role:"option",id:U0(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":Kpe(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[a.jsx(H5,{section:o.section}),a.jsxs("span",{className:"settings-result-text",children:[a.jsx("span",{className:"settings-result-name",children:o.label}),a.jsx("span",{className:"settings-result-place",children:U5(o)})]})]},o.id))})})]})}function ige({query:e,count:t}){return a.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?W5(t,e):""})}const lge=1500,cge=3e3,uge=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function dge(e){if(e.matches(Vh)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(Vh)).filter(s=>s3({disabled:s.disabled,tabIndex:s.tabIndex,rendered:uge(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function hge(e,t,n){const[s,r]=y.useState(null),o=y.useRef(void 0),i=y.useRef(null);return y.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=i.current)==null||c.removeAttribute("data-jumped")},[]),y.useEffect(()=>{const c=e.current;if(!s||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(s)}"]`),h=w=>{var b,k;r(null);const j=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:j?"start":"center"}),(b=dge(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(k=i.current)==null||k.removeAttribute("data-jumped"),w.offsetWidth,w.setAttribute("data-jumped",""),i.current=w,o.current=window.setTimeout(()=>{w.removeAttribute("data-jumped"),i.current===w&&(i.current=null)},lge)},f=d();if(f){h(f);return}const p=new MutationObserver(()=>{const w=d();w&&(p.disconnect(),window.clearTimeout(m),h(w))});p.observe(c,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),r(null)},cge);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),r}function fge({section:e,onSection:t,onClose:n,providers:s,sound:r,tones:o,customTones:i,notify:c,appearance:d,versionCheck:h,desktopUpdate:f,restart:p,doors:m}){const w=y.useRef(null),j=ct(n,{focusRef:w}),b=xt(n),k=y.useRef([]),v=iue(e),[N,S]=y.useState(""),[E,C]=y.useState(0),I=y.useRef(null),R=y.useRef(null),$=N.trim()!=="",L=y.useMemo(()=>Zpe(N,Gpe(s.claude)),[N,s.claude]),U=hge(R,!$,e),O=je=>{S(je),C(0)},M=je=>{O(""),t(je)},q=je=>{O(""),t(je.section),q5(je)||U(je.id)};y.useEffect(()=>{const je=Ae=>{var Ze,ft;if(!fue(Ae))return;const De=j.current,He=Ae.target;!De||!(He===document.body||He===document.documentElement||He&&De.contains(He))||(Ae.preventDefault(),(Ze=I.current)==null||Ze.focus(),(ft=I.current)==null||ft.select())};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[j]),y.useEffect(()=>{var je,Ae,De,He;lue((je=document.activeElement)==null?void 0:je.id,e)&&((Ae=w.current)==null||Ae.focus()),(He=(De=w.current)==null?void 0:De.scrollIntoView)==null||He.call(De,{block:"nearest",inline:"nearest"})},[e]);const{theme:A,setTheme:D,characterEnabled:P,setCharacterEnabled:K,character:G,setCharacter:W}=d,H=Ln(),F=je=>{var De;const Ae=J1(je,v,Aa.length,"vertical");Ae.kind!=="pass"&&(je.preventDefault(),O(""),t(Aa[Ae.index].id),(De=k.current[Ae.index])==null||De.focus())},B=je=>{var He;if(je.key===" "){je.stopPropagation();return}if(b3(je.key,H))return;const Ae=je.target;if($o(Ae)||Ae.tagName==="SELECT"||je.key!=="t"&&je.key!=="T"||je.ctrlKey||je.metaKey||je.altKey)return;je.preventDefault(),je.stopPropagation();const De=$0(Ae.dataset.themeChoice??A);D($0),Ae.getAttribute("role")==="radio"&&((He=je.currentTarget.querySelector(`[role="radio"][data-theme-choice="${De}"]`))==null||He.focus())},{soundOn:Z,toggleSound:V}=r,{tonePrefs:X,previewTone:Y,changeTone:J}=o,{customSelections:ee,customAssets:ne,clearCustomOnly:le,selectCustomTone:de,importNotificationAudio:ue,createNotificationVoice:re,renameCustomAsset:pe,deleteCustomAsset:ye,previewCustomAsset:_e}=i,{notifyPermission:he,notifyOn:ae,notifyVetoed:ge,toggleNotify:Se,notifySupported:me,askForNotifications:$e,accountNotify:Pe,toggleAccountNotify:qe}=c,Le=(()=>{switch(e){case"appearance":return a.jsxs(a.Fragment,{children:[a.jsx($me,{theme:A,onTheme:D,singleKeys:H}),a.jsx(rge,{characterEnabled:P,character:G,onCharacter:W,onToggleCharacter:()=>K(je=>!je)})]});case"reading":return a.jsx(Pme,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return a.jsx(fme,{singleKeys:H,onToggleSingleKeys:()=>G9(!H)});case"notifications":return a.jsx(pme,{notifyOn:ae,onToggleNotify:Se,notifyVetoed:ge,notifyPermission:me?he:"unsupported",onAskNotify:$e,accountNotify:Pe,onToggleAccountNotify:qe});case"sounds":return a.jsx(Tme,{soundOn:Z===!0,onToggleSound:V,prefs:X,claudeHere:s.claude,onLevel:(je,Ae)=>J(je,{level:Ae}),onFigure:(je,Ae)=>J(je,{figure:Ae}),onPreview:je=>Y(je),customAssets:ne,customSelections:ee,onBuiltInSelected:le,onCustomSelected:de,onImportCustom:ue,onCreateVoice:re,onRenameCustom:pe,onPreviewCustom:_e,onDeleteCustom:ye});case"data":return a.jsx(Ame,{});case"about":return a.jsx(Vme,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:je=>{f.askDesktopUpdateRestart(je)},doors:m});default:return a.jsxs(a.Fragment,{children:[a.jsx(tme,{}),a.jsx(bI,{provider:"Codex"}),s.claude&&a.jsx(bI,{provider:"Claude"}),a.jsx(tge,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),a.jsx(lme,{claudeHere:s.claude,singleKeys:H,doors:m})]})}})(),Qe=e==="reading"?a.jsx(Ome,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:j,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:je=>je.stopPropagation(),onKeyDown:B,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsxs("div",{className:"settings-side",children:[a.jsx(age,{inputRef:I,query:N,onQuery:O,results:L,active:E,onActive:C,onOpen:q}),a.jsx(ige,{query:N,count:L.length}),a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:F,children:Aa.map((je,Ae)=>a.jsxs("button",{ref:De=>{k.current[Ae]=De,je.id===e&&(w.current=De)},type:"button",role:"tab",id:`settings-tab-${je.id}`,className:"settings-tab","aria-selected":je.id===e,"aria-controls":"settings-pane",tabIndex:je.id===e?0:-1,onClick:()=>M(je.id),children:[a.jsx(H5,{section:je.id}),a.jsx("span",{className:"settings-tab-label",children:je.label})]},je.id))})]}),a.jsxs("div",{ref:R,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:$||void 0,children:[a.jsxs("div",{className:"settings-pane-head",children:[a.jsxs("div",{className:"settings-pane-heading",children:[a.jsx("h2",{className:"settings-pane-title",children:Aa[v].label}),a.jsx("p",{className:"settings-pane-note",children:Aa[v].note})]}),Qe]}),Le]},e),$&&a.jsx(oge,{query:N,results:L,active:E,onOpen:q})]})]})})}function pge({tool:e,onClose:t}){const n=ct(t),s=xt(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const i=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=ez(e.name,i,c);return{input:f.input.map((p,m)=>a.jsx(EI,{block:p},m)),response:f.response.map((p,m)=>a.jsx(EI,{block:p},m)),copyInput:Z_(e.name,"input",i),copyResponse:Z_(e.name,"response",c)}},[e.name,i,c]);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${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:e3(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(CI,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",r==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(CI,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const mge={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function EI({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const s=y.useMemo(()=>GH(e),[e]),{shown:r}=RO(s,t),o=KH(s,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?r.map((i,c)=>a.jsxs("span",{className:i.tone?mge[i.tone]:void 0,children:[i.text,c<r.length-1?`
304
- `:""]},c)):r.map(i=>i.text).join(`
305
- `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function CI({text:e,what:t}){const[n,s]=y.useState(!1),r=y.useRef(!0);return y.useEffect(()=>()=>{r.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 Ko(e).then(o=>{!o||!r.current||(s(!0),window.setTimeout(()=>{r.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const gge=Aj(()=>Nu(()=>import("./UsageHistoryModal-CfVS-N_Z.js"),[]),"Usage history"),yge=Aj(()=>Nu(()=>import("./BrowserWatchModal-DZTMfoGp.js"),[]),"Browser Watch"),wge=Aj(()=>Nu(()=>import("./TrafficRadar-CPzsjc2O.js"),[]),"Telemetry Radar");function xge({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:r,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:j,menus:b,sound:k,tones:v,customTones:N,notify:S,panelDoors:E}){const{openedTool:C,setOpenedToolKey:I,usageHistoryOpen:R,setUsageHistoryOpen:$,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:O,setContextFor:M,summaryFor:q,setSummaryFor:A,keyHelpOpen:D,setKeyHelpOpen:P,feedbackOpen:K,setFeedbackOpen:G,feedbackPrefill:W,setFeedbackPrefill:H,openFeedback:F}=e,{trafficRadarOpen:B,setTrafficRadarOpen:Z}=e,{tourOpen:V,openTour:X,closeTour:Y,releaseNotes:J,closeReleaseNotes:ee,chipVersion:ne,openReleaseNotes:le}=t,{desktopUpdateRestarting:de,desktopUpdateFailure:ue,readyAppUpdate:re,askDesktopUpdateRestart:pe}=n,{version:ye,showNotice:_e}=s,{askRestart:he}=r,{clearConfirmOpen:ae,setClearConfirmOpen:ge,requestClear:Se}=d,{setWatchOn:me,markWatchSeen:$e}=h,{setWatchSaid:Pe}=f,{palette:qe}=p,{settingsOpen:Le,settingsSection:Qe,showSection:je,closeSettings:Ae,openSettings:De}=b;return a.jsxs(a.Fragment,{children:[C&&a.jsx(pge,{tool:C,onClose:()=>I(null)}),R&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(gge,{providers:m,onClose:()=>$(!1)})}),L&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(yge,{onClose:()=>U(!1),onSeen:He=>{Pe(""),$e(He)},onWatching:me,palette:qe})}),O&&a.jsx(P7,{agent:O,onClose:()=>M(null)}),B&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(wge,{sessions:[...w.current.agents.values()].filter(He=>He.kind==="root"&&He.provider!=="codex").map(He=>({id:He.sessionId,label:He.cwdBasename??He.label})),onClose:()=>Z(!1)})}),K&&a.jsx(_5,{initialKind:W==null?void 0:W.initialKind,initialBody:W==null?void 0:W.initialBody,onClose:()=>{G(!1),H(null)}}),q&&a.jsx(Rpe,{state:w.current,sessionId:q,onClose:()=>A(null)}),Le&&a.jsx(fge,{section:Qe,onSection:je,onClose:Ae,providers:m,sound:k,tones:v,customTones:N,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:r,doors:{whatsNew:vo(Ae,le),update:vo(Ae,()=>{le(),_e()}),tour:vo(Ae,X),feedback:vo(Ae,()=>F()),accounts:vo(Ae,E.accounts),localNetwork:vo(Ae,E.localNetwork),browserWatch:vo(Ae,()=>U(!0))}}),J&&a.jsx(Tpe,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:ne,onClose:ee,onTour:()=>{ee(),X()},updateVersion:re==null?void 0:re.version,updateBusy:de,updateFailure:ue&&(!re||re.version===ue.version)?c5(ue.failure,ue.version):void 0,onUpdateRestart:re?()=>{pe(re.version)}:void 0,onRestart:!re&&(ye!=null&&ye.canRestart)?()=>{ee(),he()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:r,desktopUpdate:n,running:ne,onHandOff:ee}}),a.jsx(vge,{lanPairs:i,attention:c}),D&&a.jsx($fe,{onClose:()=>P(!1),onTour:()=>{P(!1),X()},onSettings:()=>{P(!1),De("keyboard")}}),V&&a.jsx(JP,{title:"What the deck shows you",steps:bte,onClose:Y}),ae&&a.jsx(nhe,{agentCount:j,onConfirm:()=>Se("confirmation"),onCancel:()=>ge(!1)})]})}function vge({lanPairs:e,attention:t}){const n=zfe(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Yfe,{...t,pairing:n!=null})]})}const bge=10,V5=500,G5=4e3,kge=[/ResizeObserver loop/i,/^Script error\.?$/i],TI=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,jge=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function Nge(e,t){const n=typeof e=="string"?e.split(`
306
- `):[],s=n.some(o=>/^\s*at\s/.test(o)),r=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(jge)??[]:[]);return r.length?r.every(o=>TI.test(o)):typeof t=="string"&&TI.test(t)}const jf=String.raw`[^\s\\/:'"\`<>|?*;,]`,Sge=String.raw`${jf}(?:[^\\/\r\n:'"\`<>|?*;,]*${jf})?[\\/]`,_ge=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Nc=String.raw`(?:${Sge})*(?:${_ge})?`,Ege=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Nc}|[A-Za-z]:[\\/]${Nc}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Nc}|/(?=${jf})${Nc}|(?<!:)//(?=${jf})${Nc})`,Cge=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Tge=new Set([".claude",".codex"]);function Rge(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?Tge.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Age=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Mge(e,t,n){return n?"<deck>":`${t}://<host>`}const RI=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,K5=String.raw`${RI}(?:\.${RI}){3}`,yk=String.raw`[0-9A-Fa-f]{1,4}`,AI=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${yk}:){7})(?:(?:${yk})?:)+(?:${K5}|${yk})?`,MI=String.raw`%[\w-]+(?:\.[\w-]+)*`,$I=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,$ge=String.raw`(?<![\w:.%-])(?:\[(?!${$I}\])${AI}(?:${MI})?\]|(?!${$I}(?::\d{1,5})?(?![\w:%]|\.\d))${AI}(?:${MI})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${K5}(?![\w-]|\.\d)`,wk=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Ige=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${wk}|${wk}(?=:\d{1,5}(?![\w:-]|\.\w))|${wk}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function II(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Ege,"g"),Rge).replace(new RegExp(Cge,"g"),"<project>").replace(new RegExp(Age,"g"),Mge).replace(new RegExp($ge,"g"),"<host>").replace(new RegExp(Ige,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const Y5=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Lge(e,t,n=Y5){const s=String(e??"").slice(0,V5).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,G5):void 0})}function Oge(e,t=window,n=Y5){let s=0;const r=new Set,o=(d,h,f)=>{const p=String(d??"").slice(0,V5).trim();!e()||!p||s>=bge||r.has(p)||kge.some(m=>m.test(p))||Nge(h,f)||(r.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,G5):void 0}))},i=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack,d.filename)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",c)}}const Pge=12;function Dge(e,t){const n=[II(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const r=s.split(`
307
- `).slice(0,Pge).join(`
308
- `);n.push("",II(r).trim())}return n.join(`
309
- `)}class Fge extends y.Component{constructor(){super(...arguments);rg(this,"state",{error:null,componentStack:null,reportOpen:!1});rg(this,"onKey",n=>{n3(n.key)&&Cn.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){console.error("ccdeck hit a render error it could not draw past",n,s.componentStack),this.setState({componentStack:s.componentStack??null}),Lge(n.message,n.stack),XD("offline")}componentDidUpdate(n,s){this.state.reportOpen!==s.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:s,reportOpen:r}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),r&&a.jsx(_5,{initialKind:"bug",initialBody:Dge(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Bge=1e3;function qge(e={}){const t=Math.max(1,Math.floor(e.limit??Bge)),n=e.protect;let s=!1,r=[],o=new Set,i=0,c=0,d=null;return{get paused(){return s},get size(){return r.length},get dropped(){return i},get overflowed(){return i>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,m=p!==null&&p!==d;m&&(d=p,c=0);const w=f!==null&&!m&&f<=c;if(f!==null&&f>c&&(c=f),!s)return!0;if(w)return!1;if(r.push(h),n!=null&&n(h)&&o.add(h),r.length>t){let j=0;if(o.size<r.length)for(;o.has(r[j]);)j++;const[b]=r.splice(j,1);o.delete(b),i++}return!1},setPaused(h){if(s=h,h)return[];const f=r;return r=[],o=new Set,i=0,f}}}function Uge(e){const t=y.useState(()=>qge({protect:o=>dz(e.current,o)}))[0],[n,s]=y.useState(!1),r=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&Hz(e.current);for(const c of i)e.current=HO(e.current,c);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:r}}const W0={kind:"assumed",claude:!0,codex:!0};function Wge(e){if(!e||typeof e!="object")return W0;const t=e.providers;if(!t||typeof t!="object")return W0;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Hge(e){const[t,n]=y.useState(null),[s,r]=y.useState(W0);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(r(Wge(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=zn(s);return{workspace:t,providers:s,providersRef:o}}const X5=3*6e4,zge=2e4;function Vge({fetchReport:e,visible:t,now:n,onReport:s}){let r=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(r=n(),s(c))};return{tick:i,wake:async()=>{t()&&n()-r>=X5&&await i()},stop:()=>{o=!1}}}async function Gge(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(zge)});return e.ok?await e.json():null}catch{return null}}function Kge(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const s=Vge({fetchReport:Gge,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const r=window.setInterval(s.tick,X5),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(r),document.removeEventListener("visibilitychange",o)}},[e]),t}const Yge={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Xge={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Zge={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Jge={claude:"Claude",codex:"Codex"},Qge=new Set(["status.claude.com","status.openai.com"]),eye=30*6e4,tye=10*6e4;function nye(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Qge.has(t.hostname)?t:null}catch{return null}}function LI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function sye(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function rye(e,t){if(!e||typeof e!="object")return null;const n=Vt(Yge,e.state),s=Vt(Jge,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>eye)return null;const r=nye(e.statusPageUrl);if(!r)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>tye,c=[`${s}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${s}'s components`:null,i?`Last read from ${r.hostname} at ${LI(e.checkedAt)}; this is the last thing it said`:`Reported by ${r.hostname}, checked ${sye(t-e.checkedAt)}`,"Opens the status page"],d=i?LI(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Vt(Xge,e.state)??n,shortWords:Vt(Zge,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:r.href,host:r.hostname,stale:i,detail:c.filter(Boolean).join(`
310
- `)}}function aye(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>rye(n,t)).filter(n=>n!==null)}function oye(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const iye="The providers' status pages report no incident.";function lye({version:e,loadVersion:t}){var h;const[n,s]=y.useState(!1),r=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Hde(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(An(i.current||r==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[r,t]);y.useEffect(()=>{if(r!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[r,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Ko(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:r,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const OI="agent-dag.browserWatch.seenMs";function cye(e,t){return e.filter(n=>n.startMs>t)}function uye(){const[e,t]=y.useState(()=>Number(Ve(OI))||0),[n,s]=y.useState([]),[r,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var m;!d||!(p!=null&&p.ok)||(s(p.episodes??[]),o(((m=p.settings)==null?void 0:m.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>cye(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),ze(OI,String(d))},[]);return{watchOn:r,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z5="agent-dag.character-enabled",J5="agent-dag.fm-volume",dye=1,PI="agent-dag.fm-source",Fwe=[{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:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function hye(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 fye(e){return e!=="0"}function pye(){return fye(Ve(Z5))}function mye(e){return R4(e,dye)}function gye(){return mye(Ve(J5))}const Q5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function DI(e){const t={};for(const n of Q5)t[n]=e(n);return t}function yye(e){return t=>e[t]??""}function wye(e,t){return Q5.every(n=>e[n]===t[n])}function xye(e,t){let n=null,s=0;function r(){s++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:r,run(o){r();const i=s;let c=!1;const d=()=>{i!==s||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const h=e.startViewTransition(d);n=h,h.ready.catch(()=>{}),h.updateCallbackDone.catch(()=>{d()}),h.finished.then(()=>{n===h&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===h&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function FI(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function vye(){const[e,t]=y.useState(IY),[n,s]=y.useState(LY),[r,o]=y.useState(mue),i=y.useRef(r),[c]=y.useState(()=>xye(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(v=>{const N=typeof v=="function"?v(i.current):v;N!==i.current&&(i.current=N,c.run(()=>wt.flushSync(()=>o(N))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(pye),[p,m]=y.useState($pe),[w,j]=y.useState(()=>DI(FI)),b=y.useMemo(()=>yye(w),[w]),k=y.useCallback(v=>Ece(v,b),[b]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,ze(e0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,ze(t0,n)},[n]),y.useEffect(()=>{const v=N=>{N.storageArea===cr()&&((N.key===e0||N.key===null)&&t($1(N.newValue)),(N.key===t0||N.key===null)&&s(Z3(N.newValue)))};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=r,document.documentElement.dataset.colorScheme=Du[r].colorScheme,ze(ZD,r),j(v=>{const N=DI(FI);return wye(v,N)?v:N})},[r]),y.useEffect(()=>{ze(Z5,h?"1":"0")},[h]),y.useEffect(()=>{ze(D5,p)},[p]),y.useEffect(()=>{const v=document.querySelector('meta[name="theme-color"]'),N=w["--panel"];v&&N&&v.setAttribute("content",N)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:r,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:k}}function bye(e){const t=y.useRef(null),[n,s]=y.useState(!1),[r,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(e5(f.name));return Object.keys(QD).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){s(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),m=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(j=>j.getBoundingClientRect()),w=hY(p,m,8);s(j=>j===w?j:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:r,toggleCat:c,catBarRef:t,catBarOccluded:n}}function kye(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const s=new Set,r=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,r())};function i(){var m,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(m=n.addEventListener)==null||m.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(m,w,j=w.figure){if(!n||n.state!=="running")return!1;const b=_0(m,j),k=Rre(w.level,b),v=n.currentTime;for(const N of b.notes){const S=n.createOscillator(),E=n.createGain();S.type=b.type??"sine",S.frequency.value=N.hz;const C=v+N.at,I=C+N.ms/1e3;E.gain.setValueAtTime(yT,C),E.gain.exponentialRampToValueAtTime(k,C+Are),E.gain.exponentialRampToValueAtTime(yT,I),S.connect(E).connect(n.destination),S.start(C),S.stop(I+.02)}return!0}async function d(m,w){var k;if(!e.loadCustom)return"unavailable";let j;try{j=await e.loadCustom(m)}catch{return"unavailable"}if(!j)return"missing";if(j.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const v=new SpeechSynthesisUtterance(j.text),N=window.speechSynthesis.getVoices();v.voice=N.find(S=>S.voiceURI===j.voiceURI)??null,v.rate=j.rate,v.pitch=j.pitch,v.volume=Mre(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(v),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(j.bytes.slice(0))}catch{return"broken"}try{const v=n.createBufferSource(),N=n.createGain();return v.buffer=b,N.gain.setValueAtTime($re(j.normalizationGain,w.level),n.currentTime),v.connect(N).connect(n.destination),s.add(v),(k=v.addEventListener)==null||k.call(v,"ended",()=>s.delete(v)),v.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var k,v;if(!w&&!e.enabled())return!1;const j=Bre((k=e.prefs)==null?void 0:k.call(e),m),b=((v=e.customSelection)==null?void 0:v.call(e)[m])??null;return b&&e.loadCustom?(d(b,j).then(N=>{var S;N==="played"||N==="locked"||((N==="missing"||N==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),c(m,{...j,figure:Hn},Hn))}),!0):!n||n.state!=="running"?!1:c(m,j)}function f(m,w=zo){return d(m,{level:ip(w),figure:Hn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const m of s)try{m.stop()}catch{}s.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:r,get context(){return n}}}function jye({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:r}){y.useEffect(()=>{const o=kye({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:Sre,onCustomFailure:(h,f)=>r.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function Nye(){const[e,t]=y.useState(gye),[n,s]=y.useState(()=>hV(Ve(kE))),[r,o]=y.useState(()=>dV(Ve(jE))),[i,c]=y.useState(()=>fV(Ve(PI),n,hye)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{ze(J5,String(e))},[e]),y.useEffect(()=>{ze(jE,r?"1":"0")},[r]),y.useEffect(()=>{ze(kE,JSON.stringify(n))},[n]),y.useEffect(()=>{ze(PI,i)},[i]);const m=y.useCallback((v,N=!1)=>{s(S=>{const E=S.find(C=>C.id===v.id);return E?!N||!v.radio||!E.radio||E.url===v.url&&JSON.stringify(E.radio)===JSON.stringify(v.radio)?S:S.map(C=>C.id===v.id?{...C,url:v.url,radio:v.radio}:C):[...S,v]}),h(S=>{if(!S.has(v.id))return S;const E=new Set(S);return E.delete(v.id),E})},[]),w=y.useCallback((v,N)=>{const S=N.trim();!S||S.length>S3||s(E=>E.map(C=>C.id===v?{...C,name:S}:C))},[]),j=y.useCallback(v=>{s(N=>N.filter(S=>S.id!==v)),c(N=>pV(N,v)),h(N=>{if(!N.has(v))return N;const S=new Set(N);return S.delete(v),S})},[]),b=y.useCallback((v,N=!1)=>{const S=NE(v),E=d.has(S);v===i&&!E&&!N||(E&&h(C=>{const I=new Set(C);return I.delete(S),I}),c(v),p(C=>C+1))},[i,d]),k=y.useCallback((v,N)=>{const S=NE(v);h(E=>{if(E.has(S)===N)return E;const I=new Set(E);return N?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:r,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:j,pickFmSource:b,markFmStationAvailability:k}}function Sye(e){const[t,n]=y.useState(null),[s,r]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!Ha())return;let j=!1;const b=c.current;return fetch("/api/desktop-update").then(k=>k.ok?k.json():null).then(k=>{if(j||c.current!==b)return;const v=nI(k);v&&n(v)}).catch(()=>{}),()=>{j=!0}},[e]);const d=lde(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async j=>{if(!An(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,r(!0),i(null);const k=v=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,r(!1),i({failure:v,version:j}))};try{const v=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:j})});if(!v.ok)return k(ude(await v.json().catch(()=>null)))}catch{return k("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>k("timeout"),o5))},[]),w=y.useCallback(j=>{if(Ha())try{const b=nI(JSON.parse(j));b&&(c.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,r(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const xh="agent-dag.autoRestart",BI="agent-dag.bundleReloadedFor";function _ye({now:e,stateRef:t,version:n,notice:s,noticeOpen:r,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ve(xh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,hr(xh),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(O=>O.ok?O.json():null).then(O=>{var M;O!=null&&O.ok&&d(((M=O.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,j]=y.useState("restart"),[b,k]=y.useState(null),v=y.useRef(!1),N=y.useRef(null),S=y.useRef(0),E=y.useRef(null),C=y.useCallback(async U=>{if(!An(v.current))return;const O=(U==null?void 0:U.upgrade)===!0,M=(U==null?void 0:U.whenIdle)===!0;v.current=!0,N.current=o;const q=++S.current,A=()=>{j(O?"npx":"restart"),m(!0)};M||A();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let D=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:O,whenIdle:M}:{upgrade:O})});D=M&&P.status===409}catch{}if(D){v.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&A(),window.setTimeout(()=>{if(S.current===q&&v.current){v.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const U=rI(t.current.agents.values())>0,O=Yde({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&C({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,r,e,C]);const I=rI(t.current.agents.values()),R=Kde(I,i),$=f5({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:r,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let O=null,M=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(BI)}catch{return}const q=Wde({bundle:"3.43.3",running:U,pending:O,lastTried:M});if(q==="reload"){try{window.sessionStorage.setItem(BI,U??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1),k(U??null);const A=window.setTimeout(()=>k(null),6e3);return()=>window.clearTimeout(A)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&zde({asked:N.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}v.current=!1,m(!1)}},[p,o]);const L=y.useCallback(U=>{var O,M;if(!h.current){const q=Ve(xh)==="0";hr(xh),q&&((O=U.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(((M=U.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:C,restartCopy:R,restartFuseMs:$,loadAutoRestartPrefs:L}}function Eye(){const[e,t]=y.useState([]),n=y.useRef(new Set),[s,r]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(m=>m.ok?m.json():null).then(m=>h?(m!=null&&m.ok&&t(AC(Array.isArray(m.pending)?m.pending:[],m.aliases)),m):null).catch(()=>null).then(m=>{h&&(i(w=>m!=null&&m.ok?m:w===void 0?null:w),f=window.setTimeout(p,(m==null?void 0:m.enabled)===!0?w0:ZP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!s){r(h);try{const m=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);m&&Array.isArray(m.pending)?t(AC(m.pending,m.aliases)):t(w=>w.filter(j=>j.fp!==f))}catch{}finally{r(null)}}},[s]),d=y.useCallback(h=>{s||(n.current.add(h),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Cye=6e4;function Tye({enabled:e,lanStatus:t,now:n}){const[s,r]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(v=>{v!=null&&v.ok&&Array.isArray(v.accounts)&&r(v.accounts)},[]),f=y.useCallback(async v=>{try{const N=await fetch(`/api/claude-accounts${v?"?refresh=1":""}`);N.ok&&h(await N.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let v=Date.now();const N=()=>{document.visibilityState!=="visible"||Date.now()-v<Cye||(v=Date.now(),f(!1))};return document.addEventListener("visibilitychange",N),window.addEventListener("focus",N),()=>{document.removeEventListener("visibilitychange",N),window.removeEventListener("focus",N)}},[e,f]);const p=y.useMemo(()=>e?Ofe(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(v=>{v.length&&i(N=>new Set([...N,...v]))},[]),j=y.useCallback(()=>{const v=m.current;v.length&&(w(v.map(N=>N.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:v.map(N=>({key:N.key,since:N.since}))})}).catch(()=>{}))},[w]),b=y.useRef(c);b.current=c;const k=y.useCallback(v=>{const N=b.current;w(Pfe(N?[N,...m.current]:m.current,v))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:k,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:j}}const e6=288,Rye=e6;function Aye(e,t,n){return e?"session-list":t||n?"accounts":null}function Mye(e){return e==="session-list"?Rye:e==="accounts"?e6:0}const $ye=240,Iye=20;function Lye(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=vu()?0:performance.now()+$ye+Iye)},[e]),t}const t6="agent-dag.sessionListOpen",n6="agent-dag.accountsPanelOpen";function Oye(){return Ve(t6)==="1"}function Pye(e){ze(t6,e?"1":"0")}function Dye(){const e=Ve(n6);return e===null?!0:e==="1"}function Fye(){const[e,t]=y.useState(Oye);y.useEffect(()=>{Pye(e)},[e]);const n=y.useRef(!1),[s,r]=y.useState(()=>{const m=Dye();return m&&e?(n.current=!0,!1):m});y.useEffect(()=>{!s&&n.current||ze(n6,s?"1":"0")},[s]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,r(!0))},[e]);const o=y.useCallback(()=>{t(m=>(m||r(w=>(w&&(n.current=!0),!1)),!m))},[]),i=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!m))},[]),c=y.useCallback(()=>{n.current=!1,r(m=>(m||t(!1),!0))},[]),d=y.useCallback(()=>t(!1),[]),h=y.useCallback(()=>{n.current=!1,t(!1)},[]),f=y.useCallback(()=>r(!1),[]),p=Aye(e,s,n.current);return{sessionListOpen:e,accountsPanelOpen:s,panel:p,toggleSessionList:o,toggleAccountsPanel:i,openAccountsPanel:c,closeSessionList:d,closeSessionListToCanvas:h,closeAccountsPanel:f}}const s6="agent-dag.detailOpen",r6="agent-dag.usagePanelOpen",a6="agent-dag.systemPanelOpen";function Bye(){return Ve(s6)==="1"}function qye(e){ze(s6,e?"1":"0")}function Uye(){const e=Ve(r6);return e===null?!0:e==="1"}function Wye(e){ze(r6,e?"1":"0")}function Hye(){const e=Ve(a6);return e===null?!0:e==="1"}function zye(e){ze(a6,e?"1":"0")}function Vye(){const[e,t]=y.useState(Bye);y.useEffect(()=>{qye(e)},[e]);const[n,s]=y.useState(Uye);y.useEffect(()=>{Wye(n)},[n]);const[r,o]=y.useState(Hye);return y.useEffect(()=>{zye(r)},[r]),nn("usage-panel",n),nn("machine-panel",r),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:s,machinePanelOpen:r,setMachinePanelOpen:o}}const Gye={permission:"your permission",asked:"your answer"},Kye="No sessions are waiting for you.";function Yye(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,r=n.every(i=>i.waiting.kind===s)?Gye[s]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${r}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${r}.`}function xk(e,t,n=Kye){return t!==""?t:e===""?"":n}function Xye({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,r]=y.useState(""),o=Yye(e);y.useEffect(()=>{r(m=>xk(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>xk(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=oye(n);return y.useEffect(()=>{f(m=>xk(m,p,iye))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Zye="/icon-192.png",o6=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function qI(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:o6[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Jye({waitingSessions:e,liveSince:t,focusSession:n}){const[s,r]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,m]=y.useState(o6),w=y.useCallback($=>{const L=!p[$];m(U=>({...U,[$]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[$]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(qI(U.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),b=y.useRef(new Set),k=zn(e),v=y.useCallback(()=>{const $=!c;d($),$&&(b.current=eh(k.current)),$&&typeof Notification<"u"&&Notification.permission==="default"&&j.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:$})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),N=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then($=>{const L=$;r(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);j.current=S;const E=y.useRef(null),C=e.map($=>Df($.id,$.waiting)).join("|");y.useEffect(()=>{u7(E.current,s)&&(E.current=s,b.current=eh(e))},[s]);const I=y.useRef(!1);y.useEffect(()=>{d7(I.current,t)&&(I.current=!0,b.current=eh(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!h7(E.current,t))return;const $=typeof document>"u"||!document.hidden,L=l7(e,b.current,$,c);for(const U of L)try{const O=new Notification(U.title,{body:U.body,tag:U.key,icon:Zye});O.onclick=()=>{window.focus(),n(U.sessionId),O.close()}}catch{}b.current=$?eh(e):c7(e,L,b.current)},[C,t]);const R=y.useCallback($=>{var L;d(((L=$.prefs)==null?void 0:L.notifications)===!0),f($.notificationsVetoed===!0),m(qI($.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:v,notifySupported:N,askForNotifications:S,loadNotifyPrefs:R,accountNotify:p,toggleAccountNotify:w}}function Qye({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:r,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=zn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||s||r!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function ewe({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,r]=y.useState(null),o=y.useCallback((M,q)=>r({agentId:M,toolId:q}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(M=>h(M),[]),[p,m]=y.useState(!1),[w,j]=y.useState(!1),[b,k]=y.useState(!1),[v,N]=y.useState(!1),[S,E]=y.useState(!1),[C,I]=y.useState(null),R=y.useCallback(M=>{I(M??null),E(!0)},[]);nn("tool-detail",s!==null),nn("session-summary",i!==null),nn("context-window",d!==null),nn("keyboard-help",p),nn("usage-history",w),nn("browser-watch",b),nn("feedback",S);const $=s?iz(e.current.agents,s.agentId,s.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:O}=Qye({openedTool:$,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:v});return{setOpenedToolKey:r,openTool:o,openedTool:$,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:j,browserWatchOpen:b,setBrowserWatchOpen:k,trafficRadarOpen:v,setTrafficRadarOpen:N,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:C,setFeedbackPrefill:I,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:O}}function twe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:r,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=c1(),t.current.clear(),n.current.clear(),s.current.clear(),r.current="",qD(),o(),i(),c()},[c,i,o]),m=zn(h),w=y.useCallback(j=>{const b=Jde(j,{confirmOpen:m.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const UI="agent-dag.oldNameNoticeDismissed";function nwe(e){const[t,n]=y.useState(()=>Ve(UI)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Ct?e.invokedAs:null,r=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),ze(UI,s))},[s]);return{oldName:s,oldNameOpen:r,dismissOldName:o}}const swe=300*1e3,rwe=1800*1e3,awe=8e3,owe=3e4;function WI(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function iwe({modalOpenRef:e}){const t=y.useCallback(()=>Sh({appModal:e.current,dialogDepth:Cn.dialogDepth()}),[e]),[n,s]=y.useState("hidden"),[r,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const j=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const v=await fetch("/api/rating").then(N=>N.ok?N.json():null).catch(()=>null);w||!v||s(N=>N==="thanks"?N:v.ask===!0?"asking":"hidden")},b=window.setTimeout(j,swe),k=window.setInterval(j,rwe);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(k)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=r!==null&&r<=6?owe:awe;let j=0;const b=()=>{t()?j=window.setTimeout(b,w):s("hidden")};return j=window.setTimeout(b,w),()=>window.clearTimeout(j)},[n,r,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),WI({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),WI({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:r,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function lwe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[r,o]=y.useState(()=>fre(Ve)),i=zn(r),[c,d]=y.useState([]),h=y.useCallback(N=>{o(S=>{const E={...S,[N]:null};return i.current=E,E}),hr(Uc[N])},[]),f=y.useCallback((N,S)=>{const E=i.current[N];S&&E!==S||(h(N),t(C=>{const I={...C,[N]:{...C[N],figure:Hn}};return n.current=I,I}),ze(yf[N],Hn))},[h]),p=zn(f);y.useEffect(()=>{let N=!0;return Nre().then(S=>{if(!N)return;d(S);const E=new Set(S.map(C=>C.id));for(const C of Wc){const I=i.current[C];I&&!E.has(I)&&p.current(C,I)}},()=>{}),()=>{N=!1}},[]);const m=y.useCallback((N,S)=>{if(!c.some(C=>C.id===S))return;const E={...i.current,[N]:S};i.current=E,o(E),ze(Uc[N],S),s(N,!0)},[c,s]),w=y.useCallback(async N=>{var I;const S=S0(c.length);if(S)throw new Error(S);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const C=new E;try{const R=await xre(N,L=>C.decodeAudioData(L));await mT(R);const $=mu(R);d(L=>[...L.filter(U=>U.id!==$.id),$])}finally{(I=C.close)==null||I.call(C)}},[c.length]),j=y.useCallback(async N=>{const S=S0(c.length);if(S)throw new Error(S);const E=vre(N);await mT(E);const C=mu(E);d(I=>[...I.filter(R=>R.id!==C.id),C])},[c.length]),b=y.useCallback(async(N,S)=>{const E=c.find(I=>I.id===N),C=S.trim().slice(0,80);!E||!C||C===E.name||(await _re(N,C),d(I=>I.map(R=>R.id===N?{...R,name:C}:R)))},[c]),k=y.useCallback(async N=>{await Ere(N),d(I=>I.filter(R=>R.id!==N));const S=i.current,E=pre(S,N);i.current=E,o(E);const C=Wc.filter(I=>S[I]===N);for(const I of C)hr(Uc[I]),ze(yf[I],Hn);C.length>0&&t(I=>{const R={...I};for(const $ of C)R[$]={...R[$],figure:Hn};return n.current=R,R})},[]),v=y.useCallback(N=>{var C,I;const S=Wc.find(R=>i.current[R]===N),E=S?n.current[S].level:zo;(C=e.current)==null||C.unlock(),(I=e.current)==null||I.previewCustom(N,E)},[]);return{customSelections:r,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:j,renameCustomAsset:b,deleteCustomAsset:k,previewCustomAsset:v}}function cwe(e){const[t,n]=y.useState(()=>Fre(Ve)),s=zn(t),r=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),r.current!==null&&clearTimeout(r.current),r.current=null,!d){(f=e.current)==null||f.play(c,!0);return}r.current=setTimeout(()=>{var p;r.current=null,(p=e.current)==null||p.play(c,!0)},Ire)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:ip(d.level??h[c].level),figure:C4(c,d.figure??h[c].figure)};return ze(A4[c],String(f.level)),ze(yf[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const uwe=15e3;function dwe(e){return e.visibilityState==="visible"&&e.hasFocus()}function hwe(e,t){return t||e===!0}function fwe(){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 pwe(){y.useEffect(()=>{const e=fwe();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},s=()=>{const i=dwe(document);hwe(t,i)&&n(i),t=i},r=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,uwe);return window.addEventListener("focus",s),window.addEventListener("blur",s),document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",r),()=>{window.clearInterval(o),window.removeEventListener("focus",s),window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",r),r()}},[])}function mwe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let s=!0;return fetch("/api/prefs").then(r=>r.ok?r.json():null).then(r=>{!s||!(r!=null&&r.ok)||(e(r),t(r),n(r))}).catch(()=>{}),()=>{s=!1}},[])}const vk="agent-dag.versionNoticeDismissed",gwe=15*6e4;function ywe(e){const[t,n]=y.useState(null),[s,r]=y.useState(()=>Ve(vk)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((b=!1)=>(b&&(o.current=Date.now(),c(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(k=>k.ok?k.json():null).then(k=>(k&&n(k),k??null)).catch(()=>null).finally(()=>{b&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=gwe)},[d]);y.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),k=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",k)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=u5(f),m=mde(f,s),w=y.useCallback(()=>{r(""),ze(vk,"")},[]),j=y.useCallback(()=>{f&&(r(p),ze(vk,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:j,versionChecking:i,loadVersion:d}}function wwe({version:e,readyAppUpdate:t}){const[n,s]=y.useState(!1),r=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const k=cr(),v=rpe(k),N=upe({stored:v,running:(e==null?void 0:e.running)??null,notes:yI,remembers:ape(k)});if(N.reason==="no-version")return;h.current=!0,N.record&&ope(k,N.record);let S=!0;return(async()=>{var $;let C=ipe(k);if(Ha())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const O=(($=U.prefs)==null?void 0:$.tourSeen)===!0;C&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),C=C||O}catch{C=!0}if(!S)return;const I=cpe({tourSeen:C,decision:N}),R=N.show.length?{entries:N.show,since:v,firstRun:!1}:null;I.tour&&s(!0),I.notes==="now"?i(R):I.notes==="after"&&(r.current=R)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.43.3",p=y.useMemo(()=>A5(yI,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),j=y.useCallback(()=>i(null),[]),b=y.useCallback(()=>{s(!1),lpe(cr()),Ha()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const k=r.current;r.current=null,k&&i(k)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:j,chipVersion:f,openReleaseNotes:m}}function xwe(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),r=y.useRef(!1);return r.current=e===!0&&!n,y.useEffect(()=>Oge(()=>r.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function vwe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ve("agent-dag.sound");n(c===null?!0:c==="on")},[]);const s=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),r=y.useCallback(c=>{s()},[s]),o=zn(r),i=zn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function bwe(){const[e,t]=y.useState(cue),n=y.useCallback(o=>{t(i=>uue(i,o))},[]),s=y.useCallback(()=>t(o=>({...o,open:!1})),[]),r=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:s,showSection:r}}const kwe="agent-dag.autoFitDisabled";function jwe(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{hr(kwe)},[]);const r=y.useCallback(()=>{t.current||(t.current=!0,s(!0))},[]),o=y.useCallback(()=>{t.current=!1,s(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:r,enableAutoFitAndRefit:o}}function Nwe(){return a.jsx(l1,{children:a.jsx(Fge,{children:a.jsx(Swe,{})})})}function Swe(){var Yu;const e=ml(),t=y.useState(c1)[0],n=y.useRef(t),[,s]=y.useState(0),r=y.useCallback(()=>s(Qn=>Qn+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Vye(),{selectedIds:p,primarySelectedId:m,selectAgent:w,clearSelection:j,pruneSelectionToBoard:b}=sae(n,i),{sessionListOpen:k,accountsPanelOpen:v,panel:N,toggleSessionList:S,toggleAccountsPanel:E,openAccountsPanel:C,closeSessionList:I,closeSessionListToCanvas:R,closeAccountsPanel:$}=Fye(),L=zi(v,200),U=zi(k,200),O=H_(k,U),M=zi(c,130),q=zi(h,130),A=y.useRef(null),D=vwe(A),{activateSoundRef:P,soundOnRef:K}=D,G=cwe(A),{setTonePrefs:W,tonePrefsRef:H,previewTone:F}=G,B=lwe({chimesRef:A,setTonePrefs:W,tonePrefsRef:H,previewTone:F}),{customSelectionsRef:Z,fallbackCustomRef:V}=B,X=bwe(),{openSettings:Y}=X;jye({chimesRef:A,soundOnRef:K,tonePrefsRef:H,customSelectionsRef:Z,fallbackCustomRef:V});const J=Uge(n),{pauseGate:ee,paused:ne,togglePause:le}=J,de=y.useRef(()=>{}),{live:ue,tabCapped:re,everConnected:pe,liveSince:ye}=Gre({stateRef:n,rerender:r,pauseGate:ee,chimesRef:A,desktopUpdateRef:de}),_e=ywe(ue),{version:he,notice:ae,noticeOpen:ge,loadVersion:Se}=_e,me=Sye(ue),{readyAppUpdate:$e,onDesktopUpdateEvent:Pe}=me;de.current=Pe,pwe();const qe=wwe({version:he,readyAppUpdate:$e}),{tourOpen:Le,openTour:Qe,releaseNotes:je}=qe,{workspace:Ae,providers:De,providersRef:He}=Hge(ue),Ze=Mye(N==="accounts"&&!De.claude?null:N),ft=Lye(Ze),ut=H_(v,L)&&De.claude,[Je,Dt]=y.useState(!1),vt=y.useCallback(()=>{C(),Dt(!0)},[C]);y.useEffect(()=>{v||Dt(!1)},[v]);const It=y.useCallback(()=>Dt(!1),[]),it=nwe(he),Lt=lye({version:he,loadVersion:Se}),{upgradeFailure:Ft}=Lt,dt=ewe({stateRef:n,tourOpen:Le,releaseNotes:je}),St=iwe({modalOpenRef:dt.modalOpenRef}),{openTool:rt,setSummaryFor:ys,setContextFor:Ws,openContext:ws,setKeyHelpOpen:Yn,setUsageHistoryOpen:Xn,setBrowserWatchOpen:wn,keyHelpOpenRef:At,modalOpenRef:an}=dt,Ne=xwe(),Te=uye(),{watchOn:We,watchUnseen:pt}=Te,at=Eye(),[Zn,Hs]=y.useState(0),{presentCats:zs,hiddenCats:On,toggleCat:xn,catBarRef:Jr,catBarOccluded:Vs}=bye(n),yr=y.useRef(null),[wr,xr]=y.useState(0),Bt=rae({stateRef:n,rerender:r,pruneSelectionToBoard:b,setContextFor:Ws,setSummaryFor:ys}),Qr=Kge(De.claude||De.codex),Gs=aye(Qr,Bt),vr=Tye({enabled:De.claude,lanStatus:at.lanStatus,now:Bt}),ot=_ye({now:Bt,stateRef:n,version:he,notice:ae,noticeOpen:ge,upgradeFailure:Ft,paused:J.paused}),{askRestart:Ya,loadAutoRestartPrefs:br}=ot,xs=vye(),{setTheme:vs,palette:ea}=xs,kr=Nye(),Pn=tce(),{applyViewport:Jt,moveCamera:Ks,fitLeft:qt,cameraEpochRef:we,lastFitTimeRef:Ye}=Pn,lt=mce(Pn),{pinnedRef:ht,positionsRef:dn,lastLayoutSigRef:bs,handleRelayout:ta,rearrangeUndo:Nl}=lt,Xa=y.useRef(null),Ys=y.useRef(()=>{}),Sl=ye!==null,Qo=y.useRef(0),na=y.useCallback(()=>{Qo.current=Date.now()},[]),{canvasRef:Xs,canvasSize:_l,paneSizeRef:st}=sue(ft),El=jwe(qt),{autoFitDisabledRef:Cl,disableAutoFit:Za}=El,ei=y.useRef(!1),{measuredRef:Zs,measuredVersionRef:Fu,sizeVersion:Tl,domSizeVersion:ti}=rue(ei),{removedNodes:Jn,removedAgentIds:hn,removeNode:Js,removeSelectedNode:sa,removalNotice:ra,hideSessions:Qs,bringBack:Rl,bringBackAll:Bu,forgetRemovals:Ja}=Oce({stateRef:n,pinnedRef:ht,positionsRef:dn,canvasRef:Xs,clearSelection:j,primarySelectedId:m});Vce({stateRef:n,removedNodes:Jn,hideSessions:Qs,ready:Sl,keepSessionId:m?((Yu=n.current.agents.get(m))==null?void 0:Yu.sessionId)??m:null});const Al=Ace({stateRef:n,now:Bt,removedAgentIds:hn,sizeVersion:Tl,domSizeVersion:ti});gce(Al,lt),Lce({layoutSig:Al,rf:e,stateRef:n,measuredRef:Zs,pinnedRef:ht,positionsRef:dn,paneSizeRef:st,lastInteractRef:Qo,autoFitDisabledRef:Cl,lastFitTimeRef:Ye,fitLeft:qt});const Ml=aue(),{bubbling:ni,endBubble:qu,onBubble:Sp}=Qse(),[jr,Qa]=y.useState(!1),Nr=Zse(),{beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep}=Nr,ri=ore({stateRef:n,measuredRef:Zs,measuredVersionRef:Fu,canvasRef:Xs}),{lodRef:ai,applyZoom:$l}=ri,Il=eue({applyViewport:Jt,lastFitTimeRef:Ye,cameraEpochRef:we,disableAutoFit:Za,markInteract:na,canvasRef:Xs,applyZoom:$l}),vn=m?n.current.agents.get(m):null,eo=o&&vn!=null,ks=wue({sessionListShown:O,usageShown:Ma(M),machineShown:Ma(q),accountsShown:ut,detailShown:eo,primarySelectedId:m,canvasRef:Xs}),{railInsetRef:to,availableWidth:no,availableHeight:so}=Xle({canvasRef:Xs,canvasSize:_l,machinePhase:q,usagePhase:M,usagePanelOpen:c,detailShown:eo}),Ll=Mce({stateRef:n,now:Bt,availableWidth:no,availableHeight:so,layout:lt,measuredRef:Zs,onBubble:Sp,settled:Ml,dragging:jr,layoutSig:Al,selectedIds:p,openContext:ws,historyReplayed:Sl,removedNodes:Jn,removedAgentIds:hn,dragTick:Zn,dragPatchRef:yr,dragMoveTick:wr}),{nodes:Qt,edges:aa}=Ll,ro=zn(m);yce({nodes:Qt,edges:aa,settled:Ml,dragging:jr,availableWidth:no,availableHeight:so,layout:lt,camera:Pn,rf:e,measuredRef:Zs,stateRef:n,lastFocusRef:Xa,primarySelectedIdRef:ro,focusAgentRef:Ys,autoFitDisabledRef:Cl});const oa=twe({stateRef:n,pinnedRef:ht,measuredRef:Zs,positionsRef:dn,lastLayoutSigRef:bs,forgetRemovals:Ja,clearSelection:j,rerender:r,modalOpenRef:an}),{requestClear:Uu}=oa,Ol=xue({nodes:Qt,stateRef:n,pinnedRef:ht,positionsRef:dn,draggingRef:ei,dragPatchRef:yr,setDragging:Qa,setDragMoveTick:xr,setDragTick:Hs,endBubble:qu,markInteract:na,disableAutoFit:Za,beginTrashDrag:si,trackTrashDrag:_p,endTrashDrag:Ep,removeNode:Js}),Pl=y.useCallback(()=>qt(500),[qt]),Sr=zn(Qt),{focusAgent:_r,stepAgent:Wu,focusSession:ia}=sce({canvasRef:Xs,stateRef:n,measuredRef:Zs,nodesRef:Sr,railInsetRef:to,moveCamera:Ks,disableAutoFit:Za,lastFocusRef:Xa,focusAgentRef:Ys,selectAgent:w,primarySelectedIdRef:ro}),Cp=tue({clearSelection:j,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:eo,focusAgent:_r,draggingRef:ei,lodRef:ai}),Tp=rce({nodesRef:Sr,stateRef:n,canvasRef:Xs,railInsetRef:to}),Dl=zn(sa),Fl=y.useRef(null),Hu=y.useCallback(Qn=>{hn.has(Qn)&&Rl([Qn]),ia(Qn)},[hn,Rl,ia]),Rp=oue();gue({pointerFocusRef:Rp,nodesRef:Sr,stateRef:n,primarySelectedIdRef:ro,providersRef:He,soundOnRef:K,keyHelpOpenRef:At,modalOpenRef:an,waitingCursorRef:Fl,removeSelectedRef:Dl,activateSoundRef:P,clearSelection:j,selectAgent:w,focusAgent:_r,stepAgent:Wu,focusSession:ia,requestClear:Uu,handleRelayout:ta,undoRearrange:Nl.undo,handleFit:Pl,togglePause:le,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:Xn,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:wn,setKeyHelpOpen:Yn,setTheme:vs,openSettings:Y});const zu=n.current.agents.size,la=y.useMemo(()=>Fk(n.current.agents.values()),[n.current,n.current.revision]);Pce({stateRef:n,waitingSessions:la,removedAgentIds:hn,removedNodes:Jn,bringBack:Rl}),Zce({stateRef:n,waitingSessions:la,live:ue});const Bl=Xye({waitingSessions:la,watchUnseen:pt,incidents:Gs}),ql=Jye({waitingSessions:la,liveSince:ye,focusSession:ia}),{loadNotifyPrefs:Ap}=ql;mwe({loadAutoRestartPrefs:br,loadNotifyPrefs:Ap,loadReportsPrefs:Ne.loadReportsPrefs});const Er=R1(Jue),[Vu,oi]=y.useState(!1),[Mp,Gu]=y.useState(!1),$p=y.useCallback(()=>Gu(!1),[]),Ku=y.useCallback(()=>oi(!1),[]),er=ede({providers:De,sessionListOpen:k,toggleSessionList:S,accountsPanelOpen:v,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Xn,watchOn:We,watchUnseen:pt,setBrowserWatchOpen:wn,setTrafficRadarOpen:dt.setTrafficRadarOpen,openSettings:Y,onFeedback:dt.openFeedback,radioOpen:Vu,setRadioOpen:oi,openToolActivity:()=>Gu(!0),toggles:ks.toggles}),[Ip,Lp]=y.useState(0),Op=y.useCallback(Qn=>{Hu(Qn),Er&&R()},[Hu,Er,R]),Pp=y.useCallback(()=>{k||S(),requestAnimationFrame(()=>{var Qn;return(Qn=document.querySelector("#session-list .sl-row"))==null?void 0:Qn.focus()})},[k,S]);return 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(tY,{}),a.jsx(_de,{versionCheck:_e,welcome:qe,desktopUpdate:me,pause:J,announcements:Bl,notify:ql,waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,live:ue,now:Bt,incidents:Gs,queueNamed:Er?0:Ip}),!Er&&a.jsx(jde,{waitingSessions:la,waitingCursorRef:Fl,focusSession:ia,now:Bt,onFit:Lp,onMore:Pp}),vn&&a.jsx(Ede,{selected:vn,now:Bt,selectedIds:p,focusAgent:_r,clearSelection:j}),!Er&&a.jsx("div",{className:"actions",children:a.jsx(Xue,{items:er.utilities})})]}),Er?a.jsx(Yue,{items:[...er.left,...er.right[0],er.utilities[0]],more:[...er.right.slice(1).flat(),er.utilities[1]]}):a.jsx(eI,{side:"left",label:"Left column",groups:[er.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ra?`${ra.label} removed from the board.`:""}),a.jsx(Zde,{restart:ot,versionCheck:_e,upgrade:Lt,oldNameNotice:it,rating:St,onFeedback:dt.openFeedback,everConnected:pe,live:ue,paused:ne}),(O||ut)&&a.jsxs(Hse,{width:Ze,children:[ut&&a.jsx(Wse,{leaving:z_(v,L),onReport:dt.openFeedback,onRoster:vr.observe,onClose:()=>{ks.accounts(),$()},lanWanted:Je,onLanShown:It}),O&&a.jsx(mY,{leaving:z_(k,U),state:n.current,now:Bt,selectedIds:p,onSelect:Op,onClose:()=>{ks.sessionList(),I()},removedIds:hn,onBringBackAll:Bu})]}),a.jsxs(Mde,{canvasRef:Xs,bubbling:ni,dragging:jr,trash:Nr,zoom:ri,viewport:Il,stateRef:n,peek:Tp,children:[zu===0&&(!ue&&re?a.jsx(bue,{reservedRight:to.current}):a.jsx(kue,{live:ue,everConnected:pe,providers:De,workspace:Ae,onTour:Qe,reservedRight:to.current})),(zs.length>1||On.size>0)&&a.jsx(Cde,{catBarRef:Jr,catBarOccluded:Vs,presentCats:zs,hiddenCats:On,toggleCat:xn}),a.jsx(eY,{graph:Ll,layout:lt,viewport:Il,clicks:Cp,drag:Ol,appearance:xs,fm:kr,radioOpen:Vu,onRadioClose:Ku,autoFit:El,pause:J,stateRef:n,measuredRef:Zs,hiddenCats:On,now:Bt,openTool:rt,focusAgent:_r,requestClear:Uu,setKeyHelpOpen:Yn})]}),!Er&&a.jsx(eI,{side:"right",label:"Right panels",groups:er.right}),Mp&&a.jsx(GY,{onClose:$p}),Ma(M)&&a.jsx(eZ,{state:n.current,now:Bt,providers:De,incidents:Gs,liveSince:ye,leaving:M==="leaving",onClose:()=>{ks.usage(),d(!1)}}),Ma(q)&&a.jsx(FZ,{usageOpen:c,leaving:q==="leaving",onClose:()=>{ks.machine(),f(!1)}}),o&&vn?a.jsx(Oue,{selected:vn,now:Bt,openTool:rt,setSummaryFor:ys,stateRef:n,removeSelectedNode:sa,onClose:()=>{ks.detail(),i(!1)}}):null,a.jsx(xge,{dialogs:dt,welcome:qe,desktopUpdate:me,versionCheck:_e,restart:ot,upgrade:Lt,lanPairs:at,attention:vr,clearFlow:oa,watchBadge:Te,announcements:Bl,appearance:xs,providers:De,stateRef:n,agentCount:zu,menus:X,sound:D,tones:G,customTones:B,notify:ql,panelDoors:{accounts:C,localNetwork:vt}})]})}try{H7(window.localStorage)}catch{}const _we=vF.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);_we.render(a.jsx(Nwe,{}));export{fl as A,Fa as B,J1 as C,WG as D,Qf as E,Fwe as F,S1 as G,dl as H,NV as I,Awe as J,Twe as K,Rwe as L,Hf as M,S7 as N,dye as O,Cwe as P,HG as Q,rP as R,Sme as V,lP as a,gt as b,Da as c,xt as d,Ur as e,Xe as f,Mwe as g,Ps as h,$we as i,a as j,fu as k,Kn as l,yre as m,Iwe as n,fpe as o,r0 as p,Lwe as q,y as r,An as s,Owe as t,ct as u,Pwe as v,Ko as w,hpe as x,Dwe as y,Xf as z};