ccdeck 3.44.0 → 3.45.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 (44) hide show
  1. package/README.md +14 -5
  2. package/THIRD_PARTY_NOTICES.md +27 -0
  3. package/dist/web/assets/BrowserWatchModal-Cbzf3TWa.js +1 -0
  4. package/dist/web/assets/IntegrationModal-BnnBr0a3.js +5 -0
  5. package/dist/web/assets/RadioPanel-BIqrMLQN.js +1 -0
  6. package/dist/web/assets/{TrafficRadar-Ch0LVdSl.js → TrafficRadar-D1gZCIwX.js} +1 -1
  7. package/dist/web/assets/{UsageHistoryModal-Du0ZkIJ1.js → UsageHistoryModal-DAhplVju.js} +1 -1
  8. package/dist/web/assets/app-BW3NYUYB.js +318 -0
  9. package/dist/web/assets/app-C5RY_wZ4.css +1 -0
  10. package/dist/web/assets/{index-BQbOfxbL.js → index-r8Ymr47Q.js} +1 -1
  11. package/dist/web/index.html +3 -3
  12. package/package.json +1 -1
  13. package/release-notes.json +18 -0
  14. package/src/server/account-notify.mjs +68 -6
  15. package/src/server/account-watch.mjs +61 -2
  16. package/src/server/claude-accounts.mjs +12 -2
  17. package/src/server/deck-prefs.mjs +15 -5
  18. package/src/server/feature-use.mjs +11 -1
  19. package/src/server/forge-http.mjs +514 -0
  20. package/src/server/forge-public-fetch.mjs +228 -0
  21. package/src/server/forge-routes.mjs +154 -0
  22. package/src/server/github-api.mjs +1369 -0
  23. package/src/server/gitlab-api.mjs +1271 -0
  24. package/src/server/index.mjs +6 -2
  25. package/src/server/integrations/cache.mjs +42 -0
  26. package/src/server/integrations/errors.mjs +167 -0
  27. package/src/server/integrations/forge.mjs +76 -0
  28. package/src/server/integrations/jira.mjs +1026 -0
  29. package/src/server/integrations/providers.mjs +11 -0
  30. package/src/server/integrations/proxy.mjs +314 -0
  31. package/src/server/integrations/registry.mjs +142 -0
  32. package/src/server/integrations/routes.mjs +498 -0
  33. package/src/server/integrations/store.mjs +226 -0
  34. package/src/server/lan-deck.mjs +7 -0
  35. package/src/server/lan-elsewhere.d.mts +30 -0
  36. package/src/server/lan-elsewhere.mjs +137 -0
  37. package/src/server/org-telemetry.mjs +173 -0
  38. package/src/server/pinned-build.mjs +3 -0
  39. package/src/server/request-gates.mjs +19 -0
  40. package/src/server/usage-day.mjs +2 -0
  41. package/dist/web/assets/BrowserWatchModal-DMIUygWz.js +0 -1
  42. package/dist/web/assets/RadioPanel-DNB_AHSs.js +0 -1
  43. package/dist/web/assets/app-CQIstkMF.js +0 -318
  44. package/dist/web/assets/app-Ch-0CYlK.css +0 -1
@@ -0,0 +1,318 @@
1
+ var Q8=Object.defineProperty;var eB=(e,t,n)=>t in e?Q8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ua=(e,t,n)=>eB(e,typeof t!="symbol"?t+"":t,n);var yh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function H1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vg={exports:{}},Ec={},Gg={exports:{}},et={};/**
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 Y_;function tB(){if(Y_)return et;Y_=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=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(B){return B===null||typeof B!="object"?null:(B=p&&B[p]||B["@@iterator"],typeof B=="function"?B:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function v(B,W,ee){this.props=B,this.context=W,this.refs=b,this.updater=ee||w}v.prototype.isReactComponent={},v.prototype.setState=function(B,W){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,W,"setState")},v.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function N(){}N.prototype=v.prototype;function j(B,W,ee){this.props=B,this.context=W,this.refs=b,this.updater=ee||w}var S=j.prototype=new N;S.constructor=j,k(S,v.prototype),S.isPureReactComponent=!0;var _=Array.isArray,T=Object.prototype.hasOwnProperty,$={current:null},M={key:!0,ref:!0,__self:!0,__source:!0};function O(B,W,ee){var U,Y={},X=null,Z=null;if(W!=null)for(U in W.ref!==void 0&&(Z=W.ref),W.key!==void 0&&(X=""+W.key),W)T.call(W,U)&&!M.hasOwnProperty(U)&&(Y[U]=W[U]);var J=arguments.length-2;if(J===1)Y.children=ee;else if(1<J){for(var te=Array(J),ce=0;ce<J;ce++)te[ce]=arguments[ce+2];Y.children=te}if(B&&B.defaultProps)for(U in J=B.defaultProps,J)Y[U]===void 0&&(Y[U]=J[U]);return{$$typeof:e,type:B,key:X,ref:Z,props:Y,_owner:$.current}}function I(B,W){return{$$typeof:e,type:B.type,key:W,ref:B.ref,props:B.props,_owner:B._owner}}function F(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function L(B){var W={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(ee){return W[ee]})}var A=/\/+/g;function q(B,W){return typeof B=="object"&&B!==null&&B.key!=null?L(""+B.key):W.toString(36)}function E(B,W,ee,U,Y){var X=typeof B;(X==="undefined"||X==="boolean")&&(B=null);var Z=!1;if(B===null)Z=!0;else switch(X){case"string":case"number":Z=!0;break;case"object":switch(B.$$typeof){case e:case t:Z=!0}}if(Z)return Z=B,Y=Y(Z),B=U===""?"."+q(Z,0):U,_(Y)?(ee="",B!=null&&(ee=B.replace(A,"$&/")+"/"),E(Y,W,ee,"",function(ce){return ce})):Y!=null&&(F(Y)&&(Y=I(Y,ee+(!Y.key||Z&&Z.key===Y.key?"":(""+Y.key).replace(A,"$&/")+"/")+B)),W.push(Y)),1;if(Z=0,U=U===""?".":U+":",_(B))for(var J=0;J<B.length;J++){X=B[J];var te=U+q(X,J);Z+=E(X,W,ee,te,Y)}else if(te=m(B),typeof te=="function")for(B=te.call(B),J=0;!(X=B.next()).done;)X=X.value,te=U+q(X,J++),Z+=E(X,W,ee,te,Y);else if(X==="object")throw W=String(B),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return Z}function D(B,W,ee){if(B==null)return B;var U=[],Y=0;return E(B,U,"","",function(X){return W.call(ee,X,Y++)}),U}function P(B){if(B._status===-1){var W=B._result;W=W(),W.then(function(ee){(B._status===0||B._status===-1)&&(B._status=1,B._result=ee)},function(ee){(B._status===0||B._status===-1)&&(B._status=2,B._result=ee)}),B._status===-1&&(B._status=0,B._result=W)}if(B._status===1)return B._result.default;throw B._result}var z={current:null},G={transition:null},V={ReactCurrentDispatcher:z,ReactCurrentBatchConfig:G,ReactCurrentOwner:$};function H(){throw Error("act(...) is not supported in production builds of React.")}return et.Children={map:D,forEach:function(B,W,ee){D(B,function(){W.apply(this,arguments)},ee)},count:function(B){var W=0;return D(B,function(){W++}),W},toArray:function(B){return D(B,function(W){return W})||[]},only:function(B){if(!F(B))throw Error("React.Children.only expected to receive a single React element child.");return B}},et.Component=v,et.Fragment=n,et.Profiler=a,et.PureComponent=j,et.StrictMode=s,et.Suspense=d,et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,et.act=H,et.cloneElement=function(B,W,ee){if(B==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+B+".");var U=k({},B.props),Y=B.key,X=B.ref,Z=B._owner;if(W!=null){if(W.ref!==void 0&&(X=W.ref,Z=$.current),W.key!==void 0&&(Y=""+W.key),B.type&&B.type.defaultProps)var J=B.type.defaultProps;for(te in W)T.call(W,te)&&!M.hasOwnProperty(te)&&(U[te]=W[te]===void 0&&J!==void 0?J[te]:W[te])}var te=arguments.length-2;if(te===1)U.children=ee;else if(1<te){J=Array(te);for(var ce=0;ce<te;ce++)J[ce]=arguments[ce+2];U.children=J}return{$$typeof:e,type:B.type,key:Y,ref:X,props:U,_owner:Z}},et.createContext=function(B){return B={$$typeof:i,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},B.Provider={$$typeof:o,_context:B},B.Consumer=B},et.createElement=O,et.createFactory=function(B){var W=O.bind(null,B);return W.type=B,W},et.createRef=function(){return{current:null}},et.forwardRef=function(B){return{$$typeof:c,render:B}},et.isValidElement=F,et.lazy=function(B){return{$$typeof:f,_payload:{_status:-1,_result:B},_init:P}},et.memo=function(B,W){return{$$typeof:h,type:B,compare:W===void 0?null:W}},et.startTransition=function(B){var W=G.transition;G.transition={};try{B()}finally{G.transition=W}},et.unstable_act=H,et.useCallback=function(B,W){return z.current.useCallback(B,W)},et.useContext=function(B){return z.current.useContext(B)},et.useDebugValue=function(){},et.useDeferredValue=function(B){return z.current.useDeferredValue(B)},et.useEffect=function(B,W){return z.current.useEffect(B,W)},et.useId=function(){return z.current.useId()},et.useImperativeHandle=function(B,W,ee){return z.current.useImperativeHandle(B,W,ee)},et.useInsertionEffect=function(B,W){return z.current.useInsertionEffect(B,W)},et.useLayoutEffect=function(B,W){return z.current.useLayoutEffect(B,W)},et.useMemo=function(B,W){return z.current.useMemo(B,W)},et.useReducer=function(B,W,ee){return z.current.useReducer(B,W,ee)},et.useRef=function(B){return z.current.useRef(B)},et.useState=function(B){return z.current.useState(B)},et.useSyncExternalStore=function(B,W,ee){return z.current.useSyncExternalStore(B,W,ee)},et.useTransition=function(){return z.current.useTransition()},et.version="18.3.1",et}var X_;function Ou(){return X_||(X_=1,Gg.exports=tB()),Gg.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 Z_;function nB(){if(Z_)return Ec;Z_=1;var e=Ou(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=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:a.current}}return Ec.Fragment=n,Ec.jsx=i,Ec.jsxs=i,Ec}var J_;function sB(){return J_||(J_=1,Vg.exports=nB()),Vg.exports}var r=sB(),wh={},Kg={exports:{}},En={},Yg={exports:{}},Xg={};/**
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 Q_;function rB(){return Q_||(Q_=1,(function(e){function t(G,V){var H=G.length;G.push(V);e:for(;0<H;){var B=H-1>>>1,W=G[B];if(0<a(W,V))G[B]=V,G[H]=W,H=B;else break e}}function n(G){return G.length===0?null:G[0]}function s(G){if(G.length===0)return null;var V=G[0],H=G.pop();if(H!==V){G[0]=H;e:for(var B=0,W=G.length,ee=W>>>1;B<ee;){var U=2*(B+1)-1,Y=G[U],X=U+1,Z=G[X];if(0>a(Y,H))X<W&&0>a(Z,Y)?(G[B]=Z,G[X]=H,B=X):(G[B]=Y,G[U]=H,B=U);else if(X<W&&0>a(Z,H))G[B]=Z,G[X]=H,B=X;else break e}}return V}function a(G,V){var H=G.sortIndex-V.sortIndex;return H!==0?H:G.id-V.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,k=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,j=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 V=n(h);V!==null;){if(V.callback===null)s(h);else if(V.startTime<=G)s(h),V.sortIndex=V.expirationTime,t(d,V);else break;V=n(h)}}function _(G){if(b=!1,S(G),!k)if(n(d)!==null)k=!0,P(T);else{var V=n(h);V!==null&&z(_,V.startTime-G)}}function T(G,V){k=!1,b&&(b=!1,N(O),O=-1),w=!0;var H=m;try{for(S(V),p=n(d);p!==null&&(!(p.expirationTime>V)||G&&!L());){var B=p.callback;if(typeof B=="function"){p.callback=null,m=p.priorityLevel;var W=B(p.expirationTime<=V);V=e.unstable_now(),typeof W=="function"?p.callback=W:p===n(d)&&s(d),S(V)}else s(d);p=n(d)}if(p!==null)var ee=!0;else{var U=n(h);U!==null&&z(_,U.startTime-V),ee=!1}return ee}finally{p=null,m=H,w=!1}}var $=!1,M=null,O=-1,I=5,F=-1;function L(){return!(e.unstable_now()-F<I)}function A(){if(M!==null){var G=e.unstable_now();F=G;var V=!0;try{V=M(!0,G)}finally{V?q():($=!1,M=null)}}else $=!1}var q;if(typeof j=="function")q=function(){j(A)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,D=E.port2;E.port1.onmessage=A,q=function(){D.postMessage(null)}}else q=function(){v(A,0)};function P(G){M=G,$||($=!0,q())}function z(G,V){O=v(function(){G(e.unstable_now())},V)}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(){k||w||(k=!0,P(T))},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"):I=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 V=3;break;default:V=m}var H=m;m=V;try{return G()}finally{m=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,V){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var H=m;m=G;try{return V()}finally{m=H}},e.unstable_scheduleCallback=function(G,V,H){var B=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?B+H:B):H=B,G){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=H+W,G={id:f++,callback:V,priorityLevel:G,startTime:H,expirationTime:W,sortIndex:-1},H>B?(G.sortIndex=H,t(h,G),n(d)===null&&G===n(h)&&(b?(N(O),O=-1):b=!0,z(_,H-B))):(G.sortIndex=W,t(d,G),k||w||(k=!0,P(T))),G},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(G){var V=m;return function(){var H=m;m=V;try{return G.apply(this,arguments)}finally{m=H}}}})(Xg)),Xg}var eC;function aB(){return eC||(eC=1,Yg.exports=rB()),Yg.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 tC;function oB(){if(tC)return En;tC=1;var e=Ou(),t=aB();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,a={};function o(l,u){i(l,u),i(l+"Capture",u)}function i(l,u){for(a[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 k(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,C,R,K){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=x,this.attributeNamespace=C,this.mustUseProperty=g,this.propertyName=l,this.type=u,this.sanitizeURL=R,this.removeEmptyString=K}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[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];v[u]=new b(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new b(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[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){v[l]=new b(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new b(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new b(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new b(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new b(l,5,!1,l.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function j(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(N,j);v[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(N,j);v[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(N,j);v[u]=new b(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new b(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new b(l,1,!1,l.toLowerCase(),null,!0,!0)});function S(l,u,g,x){var C=v.hasOwnProperty(u)?v[u]:null;(C!==null?C.type!==0:x||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(k(u,g,C,x)&&(g=null),x||C===null?m(u)&&(g===null?l.removeAttribute(u):l.setAttribute(u,""+g)):C.mustUseProperty?l[C.propertyName]=g===null?C.type===3?!1:"":g:(u=C.attributeName,x=C.attributeNamespace,g===null?l.removeAttribute(u):(C=C.type,g=C===3||C===4&&g===!0?"":""+g,x?l.setAttributeNS(x,u,g):l.setAttribute(u,g))))}var _=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),$=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),L=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),z=Symbol.for("react.offscreen"),G=Symbol.iterator;function V(l){return l===null||typeof l!="object"?null:(l=G&&l[G]||l["@@iterator"],typeof l=="function"?l:null)}var H=Object.assign,B;function W(l){if(B===void 0)try{throw Error()}catch(g){var u=g.stack.trim().match(/\n( *(at )?)/);B=u&&u[1]||""}return`
34
+ `+B+l}var ee=!1;function U(l,u){if(!l||ee)return"";ee=!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(ue){var x=ue}Reflect.construct(l,[],u)}else{try{u.call()}catch(ue){x=ue}l.call(u.prototype)}else{try{throw Error()}catch(ue){x=ue}l()}}catch(ue){if(ue&&x&&typeof ue.stack=="string"){for(var C=ue.stack.split(`
35
+ `),R=x.stack.split(`
36
+ `),K=C.length-1,Q=R.length-1;1<=K&&0<=Q&&C[K]!==R[Q];)Q--;for(;1<=K&&0<=Q;K--,Q--)if(C[K]!==R[Q]){if(K!==1||Q!==1)do if(K--,Q--,0>Q||C[K]!==R[Q]){var ne=`
37
+ `+C[K].replace(" at new "," at ");return l.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",l.displayName)),ne}while(1<=K&&0<=Q);break}}}finally{ee=!1,Error.prepareStackTrace=g}return(l=l?l.displayName||l.name:"")?W(l):""}function Y(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=U(l.type,!1),l;case 11:return l=U(l.type.render,!1),l;case 1:return l=U(l.type,!0),l;default:return""}}function X(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 M:return"Fragment";case $:return"Portal";case I:return"Profiler";case O:return"StrictMode";case q:return"Suspense";case E:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case L:return(l.displayName||"Context")+".Consumer";case F:return(l._context.displayName||"Context")+".Provider";case A: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:X(l.type)||"Memo";case P:u=l._payload,l=l._init;try{return X(l(u))}catch{}}return null}function Z(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 X(u);case 8:return u===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function J(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function te(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function ce(l){var u=te(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 C=g.get,R=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return C.call(this)},set:function(K){x=""+K,R.call(this,K)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return x},setValue:function(K){x=""+K},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function he(l){l._valueTracker||(l._valueTracker=ce(l))}function le(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var g=u.getValue(),x="";return l&&(x=te(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 ae(l,u){var g=u.checked;return H({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:g??l._wrapperState.initialChecked})}function de(l,u){var g=u.defaultValue==null?"":u.defaultValue,x=u.checked!=null?u.checked:u.defaultChecked;g=J(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 fe(l,u){_e(l,u);var g=J(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")?ke(l,u.type,g):u.hasOwnProperty("defaultValue")&&ke(l,u.type,J(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function ye(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 ke(l,u,g){(u!=="number"||re(l.ownerDocument)!==l)&&(g==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+g&&(l.defaultValue=""+g))}var Ne=Array.isArray;function ge(l,u,g,x){if(l=l.options,u){u={};for(var C=0;C<g.length;C++)u["$"+g[C]]=!0;for(g=0;g<l.length;g++)C=u.hasOwnProperty("$"+l[g].value),l[g].selected!==C&&(l[g].selected=C),C&&x&&(l[g].defaultSelected=!0)}else{for(g=""+J(g),u=null,C=0;C<l.length;C++){if(l[C].value===g){l[C].selected=!0,x&&(l[C].defaultSelected=!0);return}u!==null||l[C].disabled||(u=l[C])}u!==null&&(u.selected=!0)}}function Me(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Ie(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(Ne(g)){if(1<g.length)throw Error(n(93));g=g[0]}u=g}u==null&&(u=""),g=u}l._wrapperState={initialValue:J(g)}}function We(l,u){var g=J(u.value),x=J(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 Te(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function at(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"?at(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var Ve,be=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,g,x,C){MSApp.execUnsafeLocalFunction(function(){return l(u,g,x,C)})}:l})(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{for(Ve=Ve||document.createElement("div"),Ve.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Ve.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function Oe(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},st=["Webkit","ms","Moz","O"];Object.keys(ze).forEach(function(l){st.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),ze[u]=ze[l]})});function ot(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 Qe(l,u){l=l.style;for(var g in u)if(u.hasOwnProperty(g)){var x=g.indexOf("--")===0,C=ot(g,u[g],x);g==="float"&&(g="cssFloat"),x?l.setProperty(g,C):l[g]=C}}var we=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 Fe(l,u){if(u){if(we[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 Xe(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 He=null;function ht(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Ct=null,mt=null,Et=null;function Ot(l){if(l=fc(l)){if(typeof Ct!="function")throw Error(n(280));var u=l.stateNode;u&&(u=Md(u),Ct(l.stateNode,l.type,u))}}function js(l){mt?Et?Et.push(l):Et=[l]:mt=l}function tr(){if(mt){var l=mt,u=Et;if(Et=mt=null,Ot(l),u)for(l=0;l<u.length;l++)Ot(u[l])}}function Ns(l,u){return l(u)}function es(){}var Pt=!1;function Ss(l,u,g){if(Pt)return l(u,g);Pt=!0;try{return Ns(l,u,g)}finally{Pt=!1,(mt!==null||Et!==null)&&(es(),tr())}}function pn(l,u){var g=l.stateNode;if(g===null)return null;var x=Md(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 Fn=!1;if(c)try{var Ce={};Object.defineProperty(Ce,"passive",{get:function(){Fn=!0}}),window.addEventListener("test",Ce,Ce),window.removeEventListener("test",Ce,Ce)}catch{Fn=!1}function Pe(l,u,g,x,C,R,K,Q,ne){var ue=Array.prototype.slice.call(arguments,3);try{u.apply(g,ue)}catch(ve){this.onError(ve)}}var Ke=!1,jt=null,Nt=!1,Xt=null,ts={onError:function(l){Ke=!0,jt=l}};function pa(l,u,g,x,C,R,K,Q,ne){Ke=!1,jt=null,Pe.apply(ts,arguments)}function Bn(l,u,g,x,C,R,K,Q,ne){if(pa.apply(this,arguments),Ke){if(Ke){var ue=jt;Ke=!1,jt=null}else throw Error(n(198));Nt||(Nt=!0,Xt=ue)}}function qn(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 _s(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 rn(l){if(qn(l)!==l)throw Error(n(188))}function ma(l){var u=l.alternate;if(!u){if(u=qn(l),u===null)throw Error(n(188));return u!==l?null:l}for(var g=l,x=u;;){var C=g.return;if(C===null)break;var R=C.alternate;if(R===null){if(x=C.return,x!==null){g=x;continue}break}if(C.child===R.child){for(R=C.child;R;){if(R===g)return rn(C),l;if(R===x)return rn(C),u;R=R.sibling}throw Error(n(188))}if(g.return!==x.return)g=C,x=R;else{for(var K=!1,Q=C.child;Q;){if(Q===g){K=!0,g=C,x=R;break}if(Q===x){K=!0,x=C,g=R;break}Q=Q.sibling}if(!K){for(Q=R.child;Q;){if(Q===g){K=!0,g=R,x=C;break}if(Q===x){K=!0,x=R,g=C;break}Q=Q.sibling}if(!K)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 nr(l){return l=ma(l),l!==null?Zt(l):null}function Zt(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=Zt(l);if(u!==null)return u;l=l.sibling}return null}var ns=t.unstable_scheduleCallback,Un=t.unstable_cancelCallback,sr=t.unstable_shouldYield,rr=t.unstable_requestPaint,ft=t.unstable_now,ga=t.unstable_getCurrentPriorityLevel,Cs=t.unstable_ImmediatePriority,_r=t.unstable_UserBlockingPriority,Tt=t.unstable_NormalPriority,Cr=t.unstable_LowPriority,ar=t.unstable_IdlePriority,Es=null,Jt=null;function Er(l){if(Jt&&typeof Jt.onCommitFiberRoot=="function")try{Jt.onCommitFiberRoot(Es,l,void 0,(l.current.flags&128)===128)}catch{}}var mn=Math.clz32?Math.clz32:Gl,ya=Math.log,Vl=Math.LN2;function Gl(l){return l>>>=0,l===0?32:31-(ya(l)/Vl|0)|0}var Tr=64,Ts=4194304;function or(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 Ar(l,u){var g=l.pendingLanes;if(g===0)return 0;var x=0,C=l.suspendedLanes,R=l.pingedLanes,K=g&268435455;if(K!==0){var Q=K&~C;Q!==0?x=or(Q):(R&=K,R!==0&&(x=or(R)))}else K=g&~C,K!==0?x=or(K):R!==0&&(x=or(R));if(x===0)return 0;if(u!==0&&u!==x&&(u&C)===0&&(C=x&-x,R=u&-u,C>=R||C===16&&(R&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-mn(u),C=1<<g,x|=l[g],u&=~C;return x}function Rr(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 pi(l,u){for(var g=l.suspendedLanes,x=l.pingedLanes,C=l.expirationTimes,R=l.pendingLanes;0<R;){var K=31-mn(R),Q=1<<K,ne=C[K];ne===-1?((Q&g)===0||(Q&x)!==0)&&(C[K]=Rr(Q,u)):ne<=u&&(l.expiredLanes|=Q),R&=~Q}}function Mr(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function As(){var l=Tr;return Tr<<=1,(Tr&4194240)===0&&(Tr=64),l}function me(l){for(var u=[],g=0;31>g;g++)u.push(l);return u}function Be(l,u,g){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-mn(u),l[u]=g}function dt(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 C=31-mn(g),R=1<<C;u[C]=0,x[C]=-1,l[C]=-1,g&=~R}}function At(l,u){var g=l.entangledLanes|=u;for(l=l.entanglements;g;){var x=31-mn(g),C=1<<x;C&u|l[x]&u&&(l[x]|=u),g&=~C}}var rt=0;function $r(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var mo,wa,xa,Lr,Rs,Kl=!1,mi=[],Ms=null,$s=null,ss=null,Ir=new Map,Wn=new Map,ir=[],mm="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 id(l,u){switch(l){case"focusin":case"focusout":Ms=null;break;case"dragenter":case"dragleave":$s=null;break;case"mouseover":case"mouseout":ss=null;break;case"pointerover":case"pointerout":Ir.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wn.delete(u.pointerId)}}function Or(l,u,g,x,C,R){return l===null||l.nativeEvent!==R?(l={blockedOn:u,domEventName:g,eventSystemFlags:x,nativeEvent:R,targetContainers:[C]},u!==null&&(u=fc(u),u!==null&&wa(u)),l):(l.eventSystemFlags|=x,u=l.targetContainers,C!==null&&u.indexOf(C)===-1&&u.push(C),l)}function va(l,u,g,x,C){switch(u){case"focusin":return Ms=Or(Ms,l,u,g,x,C),!0;case"dragenter":return $s=Or($s,l,u,g,x,C),!0;case"mouseover":return ss=Or(ss,l,u,g,x,C),!0;case"pointerover":var R=C.pointerId;return Ir.set(R,Or(Ir.get(R)||null,l,u,g,x,C)),!0;case"gotpointercapture":return R=C.pointerId,Wn.set(R,Or(Wn.get(R)||null,l,u,g,x,C)),!0}return!1}function ld(l){var u=ko(l.target);if(u!==null){var g=qn(u);if(g!==null){if(u=g.tag,u===13){if(u=_s(g),u!==null){l.blockedOn=u,Rs(l.priority,function(){xa(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 go(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var g=wo(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(g===null){g=l.nativeEvent;var x=new g.constructor(g.type,g);He=x,g.target.dispatchEvent(x),He=null}else return u=fc(g),u!==null&&wa(u),l.blockedOn=g,!1;u.shift()}return!0}function Yl(l,u,g){go(l)&&g.delete(u)}function gm(){Kl=!1,Ms!==null&&go(Ms)&&(Ms=null),$s!==null&&go($s)&&($s=null),ss!==null&&go(ss)&&(ss=null),Ir.forEach(Yl),Wn.forEach(Yl)}function Pr(l,u){l.blockedOn===u&&(l.blockedOn=null,Kl||(Kl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,gm)))}function yo(l){function u(C){return Pr(C,l)}if(0<mi.length){Pr(mi[0],l);for(var g=1;g<mi.length;g++){var x=mi[g];x.blockedOn===l&&(x.blockedOn=null)}}for(Ms!==null&&Pr(Ms,l),$s!==null&&Pr($s,l),ss!==null&&Pr(ss,l),Ir.forEach(u),Wn.forEach(u),g=0;g<ir.length;g++)x=ir[g],x.blockedOn===l&&(x.blockedOn=null);for(;0<ir.length&&(g=ir[0],g.blockedOn===null);)ld(g),g.blockedOn===null&&ir.shift()}var ba=_.ReactCurrentBatchConfig,ka=!0;function cd(l,u,g,x){var C=rt,R=ba.transition;ba.transition=null;try{rt=1,Xl(l,u,g,x)}finally{rt=C,ba.transition=R}}function ym(l,u,g,x){var C=rt,R=ba.transition;ba.transition=null;try{rt=4,Xl(l,u,g,x)}finally{rt=C,ba.transition=R}}function Xl(l,u,g,x){if(ka){var C=wo(l,u,g,x);if(C===null)Om(l,u,x,gi,g),id(l,x);else if(va(C,l,u,g,x))x.stopPropagation();else if(id(l,x),u&4&&-1<mm.indexOf(l)){for(;C!==null;){var R=fc(C);if(R!==null&&mo(R),R=wo(l,u,g,x),R===null&&Om(l,u,x,gi,g),R===C)break;C=R}C!==null&&x.stopPropagation()}else Om(l,u,x,null,g)}}var gi=null;function wo(l,u,g,x){if(gi=null,l=ht(x),l=ko(l),l!==null)if(u=qn(l),u===null)l=null;else if(g=u.tag,g===13){if(l=_s(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 gi=l,null}function ud(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(ga()){case Cs:return 1;case _r:return 4;case Tt:case Cr:return 16;case ar:return 536870912;default:return 16}default:return 16}}var Ls=null,Zl=null,yi=null;function dd(){if(yi)return yi;var l,u=Zl,g=u.length,x,C="value"in Ls?Ls.value:Ls.textContent,R=C.length;for(l=0;l<g&&u[l]===C[l];l++);var K=g-l;for(x=1;x<=K&&u[g-x]===C[R-x];x++);return yi=C.slice(l,1<x?1-x:void 0)}function xo(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 wi(){return!0}function hd(){return!1}function cn(l){function u(g,x,C,R,K){this._reactName=g,this._targetInst=C,this.type=x,this.nativeEvent=R,this.target=K,this.currentTarget=null;for(var Q in l)l.hasOwnProperty(Q)&&(g=l[Q],this[Q]=g?g(R):R[Q]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?wi:hd,this.isPropagationStopped=hd,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=wi)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=wi)},persist:function(){},isPersistent:wi}),u}var rs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vo=cn(rs),as=H({},rs,{view:0,detail:0}),xi=cn(as),vi,bi,ja,Na=H({},as,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nc,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!==ja&&(ja&&l.type==="mousemove"?(vi=l.screenX-ja.screenX,bi=l.screenY-ja.screenY):bi=vi=0,ja=l),vi)},movementY:function(l){return"movementY"in l?l.movementY:bi}}),fd=cn(Na),Jl=H({},Na,{dataTransfer:0}),pd=cn(Jl),md=H({},as,{relatedTarget:0}),Ql=cn(md),wm=H({},rs,{animationName:0,elapsedTime:0,pseudoElement:0}),ec=cn(wm),ki=H({},rs,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),xm=cn(ki),Sa=H({},rs,{data:0}),gd=cn(Sa),vm={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bm={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"},tc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ji(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=tc[l])?!!u[l]:!1}function nc(){return ji}var yd=H({},as,{key:function(l){if(l.key){var u=vm[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=xo(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?bm[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nc,charCode:function(l){return l.type==="keypress"?xo(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?xo(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),_a=cn(yd),wd=H({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ni=cn(wd),km=H({},as,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nc}),Dr=cn(km),xd=H({},rs,{propertyName:0,elapsedTime:0,pseudoElement:0}),vd=cn(xd),jm=H({},Na,{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}),sc=cn(jm),Nm=[9,13,27,32],rc=c&&"CompositionEvent"in window,bo=null;c&&"documentMode"in document&&(bo=document.documentMode);var Sm=c&&"TextEvent"in window&&!bo,Hn=c&&(!rc||bo&&8<bo&&11>=bo),bd=" ",kd=!1;function jd(l,u){switch(l){case"keyup":return Nm.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Nd(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Fr=!1;function vt(l,u){switch(l){case"compositionend":return Nd(u);case"keypress":return u.which!==32?null:(kd=!0,bd);case"textInput":return l=u.data,l===bd&&kd?null:l;default:return null}}function Ca(l,u){if(Fr)return l==="compositionend"||!rc&&jd(l,u)?(l=dd(),yi=Zl=Ls=null,Fr=!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 Hn&&u.locale!=="ko"?null:u.data;default:return null}}var _m={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 VN(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!_m[l.type]:u==="textarea"}function GN(l,u,g,x){js(x),u=Td(u,"onChange"),0<u.length&&(g=new vo("onChange","change",null,g,x),l.push({event:g,listeners:u}))}var ac=null,oc=null;function QF(l){dS(l,0)}function Sd(l){var u=Ti(l);if(le(u))return l}function e8(l,u){if(l==="change")return u}var KN=!1;if(c){var Cm;if(c){var Em="oninput"in document;if(!Em){var YN=document.createElement("div");YN.setAttribute("oninput","return;"),Em=typeof YN.oninput=="function"}Cm=Em}else Cm=!1;KN=Cm&&(!document.documentMode||9<document.documentMode)}function XN(){ac&&(ac.detachEvent("onpropertychange",ZN),oc=ac=null)}function ZN(l){if(l.propertyName==="value"&&Sd(oc)){var u=[];GN(u,oc,l,ht(l)),Ss(QF,u)}}function t8(l,u,g){l==="focusin"?(XN(),ac=u,oc=g,ac.attachEvent("onpropertychange",ZN)):l==="focusout"&&XN()}function n8(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Sd(oc)}function s8(l,u){if(l==="click")return Sd(u)}function r8(l,u){if(l==="input"||l==="change")return Sd(u)}function a8(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var Is=typeof Object.is=="function"?Object.is:a8;function ic(l,u){if(Is(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 C=g[x];if(!d.call(u,C)||!Is(l[C],u[C]))return!1}return!0}function JN(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function QN(l,u){var g=JN(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=JN(g)}}function eS(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?eS(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function tS(){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 Tm(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 o8(l){var u=tS(),g=l.focusedElem,x=l.selectionRange;if(u!==g&&g&&g.ownerDocument&&eS(g.ownerDocument.documentElement,g)){if(x!==null&&Tm(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 C=g.textContent.length,R=Math.min(x.start,C);x=x.end===void 0?R:Math.min(x.end,C),!l.extend&&R>x&&(C=x,x=R,R=C),C=QN(g,R);var K=QN(g,x);C&&K&&(l.rangeCount!==1||l.anchorNode!==C.node||l.anchorOffset!==C.offset||l.focusNode!==K.node||l.focusOffset!==K.offset)&&(u=u.createRange(),u.setStart(C.node,C.offset),l.removeAllRanges(),R>x?(l.addRange(u),l.extend(K.node,K.offset)):(u.setEnd(K.node,K.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 i8=c&&"documentMode"in document&&11>=document.documentMode,Si=null,Am=null,lc=null,Rm=!1;function nS(l,u,g){var x=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;Rm||Si==null||Si!==re(x)||(x=Si,"selectionStart"in x&&Tm(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}),lc&&ic(lc,x)||(lc=x,x=Td(Am,"onSelect"),0<x.length&&(u=new vo("onSelect","select",null,u,g),l.push({event:u,listeners:x}),u.target=Si)))}function _d(l,u){var g={};return g[l.toLowerCase()]=u.toLowerCase(),g["Webkit"+l]="webkit"+u,g["Moz"+l]="moz"+u,g}var _i={animationend:_d("Animation","AnimationEnd"),animationiteration:_d("Animation","AnimationIteration"),animationstart:_d("Animation","AnimationStart"),transitionend:_d("Transition","TransitionEnd")},Mm={},sS={};c&&(sS=document.createElement("div").style,"AnimationEvent"in window||(delete _i.animationend.animation,delete _i.animationiteration.animation,delete _i.animationstart.animation),"TransitionEvent"in window||delete _i.transitionend.transition);function Cd(l){if(Mm[l])return Mm[l];if(!_i[l])return l;var u=_i[l],g;for(g in u)if(u.hasOwnProperty(g)&&g in sS)return Mm[l]=u[g];return l}var rS=Cd("animationend"),aS=Cd("animationiteration"),oS=Cd("animationstart"),iS=Cd("transitionend"),lS=new Map,cS="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 Ea(l,u){lS.set(l,u),o(u,[l])}for(var $m=0;$m<cS.length;$m++){var Lm=cS[$m],l8=Lm.toLowerCase(),c8=Lm[0].toUpperCase()+Lm.slice(1);Ea(l8,"on"+c8)}Ea(rS,"onAnimationEnd"),Ea(aS,"onAnimationIteration"),Ea(oS,"onAnimationStart"),Ea("dblclick","onDoubleClick"),Ea("focusin","onFocus"),Ea("focusout","onBlur"),Ea(iS,"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 cc="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(" "),u8=new Set("cancel close invalid load scroll toggle".split(" ").concat(cc));function uS(l,u,g){var x=l.type||"unknown-event";l.currentTarget=g,Bn(x,u,void 0,l),l.currentTarget=null}function dS(l,u){u=(u&4)!==0;for(var g=0;g<l.length;g++){var x=l[g],C=x.event;x=x.listeners;e:{var R=void 0;if(u)for(var K=x.length-1;0<=K;K--){var Q=x[K],ne=Q.instance,ue=Q.currentTarget;if(Q=Q.listener,ne!==R&&C.isPropagationStopped())break e;uS(C,Q,ue),R=ne}else for(K=0;K<x.length;K++){if(Q=x[K],ne=Q.instance,ue=Q.currentTarget,Q=Q.listener,ne!==R&&C.isPropagationStopped())break e;uS(C,Q,ue),R=ne}}}if(Nt)throw l=Xt,Nt=!1,Xt=null,l}function bt(l,u){var g=u[Um];g===void 0&&(g=u[Um]=new Set);var x=l+"__bubble";g.has(x)||(hS(u,l,2,!1),g.add(x))}function Im(l,u,g){var x=0;u&&(x|=4),hS(g,l,x,u)}var Ed="_reactListening"+Math.random().toString(36).slice(2);function uc(l){if(!l[Ed]){l[Ed]=!0,s.forEach(function(g){g!=="selectionchange"&&(u8.has(g)||Im(g,!1,l),Im(g,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[Ed]||(u[Ed]=!0,Im("selectionchange",!1,u))}}function hS(l,u,g,x){switch(ud(u)){case 1:var C=cd;break;case 4:C=ym;break;default:C=Xl}g=C.bind(null,u,g,l),C=void 0,!Fn||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(C=!0),x?C!==void 0?l.addEventListener(u,g,{capture:!0,passive:C}):l.addEventListener(u,g,!0):C!==void 0?l.addEventListener(u,g,{passive:C}):l.addEventListener(u,g,!1)}function Om(l,u,g,x,C){var R=x;if((u&1)===0&&(u&2)===0&&x!==null)e:for(;;){if(x===null)return;var K=x.tag;if(K===3||K===4){var Q=x.stateNode.containerInfo;if(Q===C||Q.nodeType===8&&Q.parentNode===C)break;if(K===4)for(K=x.return;K!==null;){var ne=K.tag;if((ne===3||ne===4)&&(ne=K.stateNode.containerInfo,ne===C||ne.nodeType===8&&ne.parentNode===C))return;K=K.return}for(;Q!==null;){if(K=ko(Q),K===null)return;if(ne=K.tag,ne===5||ne===6){x=R=K;continue e}Q=Q.parentNode}}x=x.return}Ss(function(){var ue=R,ve=ht(g),je=[];e:{var xe=lS.get(l);if(xe!==void 0){var Ee=vo,Re=l;switch(l){case"keypress":if(xo(g)===0)break e;case"keydown":case"keyup":Ee=_a;break;case"focusin":Re="focus",Ee=Ql;break;case"focusout":Re="blur",Ee=Ql;break;case"beforeblur":case"afterblur":Ee=Ql;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=fd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=pd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=Dr;break;case rS:case aS:case oS:Ee=ec;break;case iS:Ee=vd;break;case"scroll":Ee=xi;break;case"wheel":Ee=sc;break;case"copy":case"cut":case"paste":Ee=xm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=Ni}var $e=(u&4)!==0,Dt=!$e&&l==="scroll",oe=$e?xe!==null?xe+"Capture":null:xe;$e=[];for(var se=ue,ie;se!==null;){ie=se;var Se=ie.stateNode;if(ie.tag===5&&Se!==null&&(ie=Se,oe!==null&&(Se=pn(se,oe),Se!=null&&$e.push(dc(se,Se,ie)))),Dt)break;se=se.return}0<$e.length&&(xe=new Ee(xe,Re,null,g,ve),je.push({event:xe,listeners:$e}))}}if((u&7)===0){e:{if(xe=l==="mouseover"||l==="pointerover",Ee=l==="mouseout"||l==="pointerout",xe&&g!==He&&(Re=g.relatedTarget||g.fromElement)&&(ko(Re)||Re[Br]))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=ue,Re=Re?ko(Re):null,Re!==null&&(Dt=qn(Re),Re!==Dt||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(Ee=null,Re=ue),Ee!==Re)){if($e=fd,Se="onMouseLeave",oe="onMouseEnter",se="mouse",(l==="pointerout"||l==="pointerover")&&($e=Ni,Se="onPointerLeave",oe="onPointerEnter",se="pointer"),Dt=Ee==null?xe:Ti(Ee),ie=Re==null?xe:Ti(Re),xe=new $e(Se,se+"leave",Ee,g,ve),xe.target=Dt,xe.relatedTarget=ie,Se=null,ko(ve)===ue&&($e=new $e(oe,se+"enter",Re,g,ve),$e.target=ie,$e.relatedTarget=Dt,Se=$e),Dt=Se,Ee&&Re)t:{for($e=Ee,oe=Re,se=0,ie=$e;ie;ie=Ci(ie))se++;for(ie=0,Se=oe;Se;Se=Ci(Se))ie++;for(;0<se-ie;)$e=Ci($e),se--;for(;0<ie-se;)oe=Ci(oe),ie--;for(;se--;){if($e===oe||oe!==null&&$e===oe.alternate)break t;$e=Ci($e),oe=Ci(oe)}$e=null}else $e=null;Ee!==null&&fS(je,xe,Ee,$e,!1),Re!==null&&Dt!==null&&fS(je,Dt,Re,$e,!0)}}e:{if(xe=ue?Ti(ue):window,Ee=xe.nodeName&&xe.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&xe.type==="file")var Le=e8;else if(VN(xe))if(KN)Le=r8;else{Le=n8;var qe=t8}else(Ee=xe.nodeName)&&Ee.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(Le=s8);if(Le&&(Le=Le(l,ue))){GN(je,Le,g,ve);break e}qe&&qe(l,xe,ue),l==="focusout"&&(qe=xe._wrapperState)&&qe.controlled&&xe.type==="number"&&ke(xe,"number",xe.value)}switch(qe=ue?Ti(ue):window,l){case"focusin":(VN(qe)||qe.contentEditable==="true")&&(Si=qe,Am=ue,lc=null);break;case"focusout":lc=Am=Si=null;break;case"mousedown":Rm=!0;break;case"contextmenu":case"mouseup":case"dragend":Rm=!1,nS(je,g,ve);break;case"selectionchange":if(i8)break;case"keydown":case"keyup":nS(je,g,ve)}var Ue;if(rc)e:{switch(l){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else Fr?jd(l,g)&&(Ge="onCompositionEnd"):l==="keydown"&&g.keyCode===229&&(Ge="onCompositionStart");Ge&&(Hn&&g.locale!=="ko"&&(Fr||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&Fr&&(Ue=dd()):(Ls=ve,Zl="value"in Ls?Ls.value:Ls.textContent,Fr=!0)),qe=Td(ue,Ge),0<qe.length&&(Ge=new gd(Ge,l,null,g,ve),je.push({event:Ge,listeners:qe}),Ue?Ge.data=Ue:(Ue=Nd(g),Ue!==null&&(Ge.data=Ue)))),(Ue=Sm?vt(l,g):Ca(l,g))&&(ue=Td(ue,"onBeforeInput"),0<ue.length&&(ve=new gd("onBeforeInput","beforeinput",null,g,ve),je.push({event:ve,listeners:ue}),ve.data=Ue))}dS(je,u)})}function dc(l,u,g){return{instance:l,listener:u,currentTarget:g}}function Td(l,u){for(var g=u+"Capture",x=[];l!==null;){var C=l,R=C.stateNode;C.tag===5&&R!==null&&(C=R,R=pn(l,g),R!=null&&x.unshift(dc(l,R,C)),R=pn(l,u),R!=null&&x.push(dc(l,R,C))),l=l.return}return x}function Ci(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function fS(l,u,g,x,C){for(var R=u._reactName,K=[];g!==null&&g!==x;){var Q=g,ne=Q.alternate,ue=Q.stateNode;if(ne!==null&&ne===x)break;Q.tag===5&&ue!==null&&(Q=ue,C?(ne=pn(g,R),ne!=null&&K.unshift(dc(g,ne,Q))):C||(ne=pn(g,R),ne!=null&&K.push(dc(g,ne,Q)))),g=g.return}K.length!==0&&l.push({event:u,listeners:K})}var d8=/\r\n?/g,h8=/\u0000|\uFFFD/g;function pS(l){return(typeof l=="string"?l:""+l).replace(d8,`
38
+ `).replace(h8,"")}function Ad(l,u,g){if(u=pS(u),pS(l)!==u&&g)throw Error(n(425))}function Rd(){}var Pm=null,Dm=null;function Fm(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 Bm=typeof setTimeout=="function"?setTimeout:void 0,f8=typeof clearTimeout=="function"?clearTimeout:void 0,mS=typeof Promise=="function"?Promise:void 0,p8=typeof queueMicrotask=="function"?queueMicrotask:typeof mS<"u"?function(l){return mS.resolve(null).then(l).catch(m8)}:Bm;function m8(l){setTimeout(function(){throw l})}function qm(l,u){var g=u,x=0;do{var C=g.nextSibling;if(l.removeChild(g),C&&C.nodeType===8)if(g=C.data,g==="/$"){if(x===0){l.removeChild(C),yo(u);return}x--}else g!=="$"&&g!=="$?"&&g!=="$!"||x++;g=C}while(g);yo(u)}function Ta(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 gS(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 Ei=Math.random().toString(36).slice(2),lr="__reactFiber$"+Ei,hc="__reactProps$"+Ei,Br="__reactContainer$"+Ei,Um="__reactEvents$"+Ei,g8="__reactListeners$"+Ei,y8="__reactHandles$"+Ei;function ko(l){var u=l[lr];if(u)return u;for(var g=l.parentNode;g;){if(u=g[Br]||g[lr]){if(g=u.alternate,u.child!==null||g!==null&&g.child!==null)for(l=gS(l);l!==null;){if(g=l[lr])return g;l=gS(l)}return u}l=g,g=l.parentNode}return null}function fc(l){return l=l[lr]||l[Br],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Ti(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function Md(l){return l[hc]||null}var Wm=[],Ai=-1;function Aa(l){return{current:l}}function kt(l){0>Ai||(l.current=Wm[Ai],Wm[Ai]=null,Ai--)}function yt(l,u){Ai++,Wm[Ai]=l.current,l.current=u}var Ra={},un=Aa(Ra),jn=Aa(!1),jo=Ra;function Ri(l,u){var g=l.type.contextTypes;if(!g)return Ra;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===u)return x.__reactInternalMemoizedMaskedChildContext;var C={},R;for(R in g)C[R]=u[R];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=C),C}function Nn(l){return l=l.childContextTypes,l!=null}function $d(){kt(jn),kt(un)}function yS(l,u,g){if(un.current!==Ra)throw Error(n(168));yt(un,u),yt(jn,g)}function wS(l,u,g){var x=l.stateNode;if(u=u.childContextTypes,typeof x.getChildContext!="function")return g;x=x.getChildContext();for(var C in x)if(!(C in u))throw Error(n(108,Z(l)||"Unknown",C));return H({},g,x)}function Ld(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Ra,jo=un.current,yt(un,l),yt(jn,jn.current),!0}function xS(l,u,g){var x=l.stateNode;if(!x)throw Error(n(169));g?(l=wS(l,u,jo),x.__reactInternalMemoizedMergedChildContext=l,kt(jn),kt(un),yt(un,l)):kt(jn),yt(jn,g)}var qr=null,Id=!1,Hm=!1;function vS(l){qr===null?qr=[l]:qr.push(l)}function w8(l){Id=!0,vS(l)}function Ma(){if(!Hm&&qr!==null){Hm=!0;var l=0,u=rt;try{var g=qr;for(rt=1;l<g.length;l++){var x=g[l];do x=x(!0);while(x!==null)}qr=null,Id=!1}catch(C){throw qr!==null&&(qr=qr.slice(l+1)),ns(Cs,Ma),C}finally{rt=u,Hm=!1}}return null}var Mi=[],$i=0,Od=null,Pd=0,os=[],is=0,No=null,Ur=1,Wr="";function So(l,u){Mi[$i++]=Pd,Mi[$i++]=Od,Od=l,Pd=u}function bS(l,u,g){os[is++]=Ur,os[is++]=Wr,os[is++]=No,No=l;var x=Ur;l=Wr;var C=32-mn(x)-1;x&=~(1<<C),g+=1;var R=32-mn(u)+C;if(30<R){var K=C-C%5;R=(x&(1<<K)-1).toString(32),x>>=K,C-=K,Ur=1<<32-mn(u)+C|g<<C|x,Wr=R+l}else Ur=1<<R|g<<C|x,Wr=l}function zm(l){l.return!==null&&(So(l,1),bS(l,1,0))}function Vm(l){for(;l===Od;)Od=Mi[--$i],Mi[$i]=null,Pd=Mi[--$i],Mi[$i]=null;for(;l===No;)No=os[--is],os[is]=null,Wr=os[--is],os[is]=null,Ur=os[--is],os[is]=null}var zn=null,Vn=null,St=!1,Os=null;function kS(l,u){var g=ds(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 jS(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,zn=l,Vn=Ta(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,zn=l,Vn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(g=No!==null?{id:Ur,overflow:Wr}:null,l.memoizedState={dehydrated:u,treeContext:g,retryLane:1073741824},g=ds(18,null,null,0),g.stateNode=u,g.return=l,l.child=g,zn=l,Vn=null,!0):!1;default:return!1}}function Gm(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Km(l){if(St){var u=Vn;if(u){var g=u;if(!jS(l,u)){if(Gm(l))throw Error(n(418));u=Ta(g.nextSibling);var x=zn;u&&jS(l,u)?kS(x,g):(l.flags=l.flags&-4097|2,St=!1,zn=l)}}else{if(Gm(l))throw Error(n(418));l.flags=l.flags&-4097|2,St=!1,zn=l}}}function NS(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;zn=l}function Dd(l){if(l!==zn)return!1;if(!St)return NS(l),St=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!Fm(l.type,l.memoizedProps)),u&&(u=Vn)){if(Gm(l))throw SS(),Error(n(418));for(;u;)kS(l,u),u=Ta(u.nextSibling)}if(NS(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){Vn=Ta(l.nextSibling);break e}u--}else g!=="$"&&g!=="$!"&&g!=="$?"||u++}l=l.nextSibling}Vn=null}}else Vn=zn?Ta(l.stateNode.nextSibling):null;return!0}function SS(){for(var l=Vn;l;)l=Ta(l.nextSibling)}function Li(){Vn=zn=null,St=!1}function Ym(l){Os===null?Os=[l]:Os.push(l)}var x8=_.ReactCurrentBatchConfig;function pc(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 C=x,R=""+l;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===R?u.ref:(u=function(K){var Q=C.refs;K===null?delete Q[R]:Q[R]=K},u._stringRef=R,u)}if(typeof l!="string")throw Error(n(284));if(!g._owner)throw Error(n(290,l))}return l}function Fd(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function _S(l){var u=l._init;return u(l._payload)}function CS(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 C(oe,se){return oe=Ba(oe,se),oe.index=0,oe.sibling=null,oe}function R(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 K(oe){return l&&oe.alternate===null&&(oe.flags|=2),oe}function Q(oe,se,ie,Se){return se===null||se.tag!==6?(se=Bg(ie,oe.mode,Se),se.return=oe,se):(se=C(se,ie),se.return=oe,se)}function ne(oe,se,ie,Se){var Le=ie.type;return Le===M?ve(oe,se,ie.props.children,Se,ie.key):se!==null&&(se.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===P&&_S(Le)===se.type)?(Se=C(se,ie.props),Se.ref=pc(oe,se,ie),Se.return=oe,Se):(Se=ch(ie.type,ie.key,ie.props,null,oe.mode,Se),Se.ref=pc(oe,se,ie),Se.return=oe,Se)}function ue(oe,se,ie,Se){return se===null||se.tag!==4||se.stateNode.containerInfo!==ie.containerInfo||se.stateNode.implementation!==ie.implementation?(se=qg(ie,oe.mode,Se),se.return=oe,se):(se=C(se,ie.children||[]),se.return=oe,se)}function ve(oe,se,ie,Se,Le){return se===null||se.tag!==7?(se=$o(ie,oe.mode,Se,Le),se.return=oe,se):(se=C(se,ie),se.return=oe,se)}function je(oe,se,ie){if(typeof se=="string"&&se!==""||typeof se=="number")return se=Bg(""+se,oe.mode,ie),se.return=oe,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case T:return ie=ch(se.type,se.key,se.props,null,oe.mode,ie),ie.ref=pc(oe,null,se),ie.return=oe,ie;case $:return se=qg(se,oe.mode,ie),se.return=oe,se;case P:var Se=se._init;return je(oe,Se(se._payload),ie)}if(Ne(se)||V(se))return se=$o(se,oe.mode,ie,null),se.return=oe,se;Fd(oe,se)}return null}function xe(oe,se,ie,Se){var Le=se!==null?se.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Le!==null?null:Q(oe,se,""+ie,Se);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:return ie.key===Le?ne(oe,se,ie,Se):null;case $:return ie.key===Le?ue(oe,se,ie,Se):null;case P:return Le=ie._init,xe(oe,se,Le(ie._payload),Se)}if(Ne(ie)||V(ie))return Le!==null?null:ve(oe,se,ie,Se,null);Fd(oe,ie)}return null}function Ee(oe,se,ie,Se,Le){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return oe=oe.get(ie)||null,Q(se,oe,""+Se,Le);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case T:return oe=oe.get(Se.key===null?ie:Se.key)||null,ne(se,oe,Se,Le);case $:return oe=oe.get(Se.key===null?ie:Se.key)||null,ue(se,oe,Se,Le);case P:var qe=Se._init;return Ee(oe,se,ie,qe(Se._payload),Le)}if(Ne(Se)||V(Se))return oe=oe.get(ie)||null,ve(se,oe,Se,Le,null);Fd(se,Se)}return null}function Re(oe,se,ie,Se){for(var Le=null,qe=null,Ue=se,Ge=se=0,tn=null;Ue!==null&&Ge<ie.length;Ge++){Ue.index>Ge?(tn=Ue,Ue=null):tn=Ue.sibling;var ct=xe(oe,Ue,ie[Ge],Se);if(ct===null){Ue===null&&(Ue=tn);break}l&&Ue&&ct.alternate===null&&u(oe,Ue),se=R(ct,se,Ge),qe===null?Le=ct:qe.sibling=ct,qe=ct,Ue=tn}if(Ge===ie.length)return g(oe,Ue),St&&So(oe,Ge),Le;if(Ue===null){for(;Ge<ie.length;Ge++)Ue=je(oe,ie[Ge],Se),Ue!==null&&(se=R(Ue,se,Ge),qe===null?Le=Ue:qe.sibling=Ue,qe=Ue);return St&&So(oe,Ge),Le}for(Ue=x(oe,Ue);Ge<ie.length;Ge++)tn=Ee(Ue,oe,Ge,ie[Ge],Se),tn!==null&&(l&&tn.alternate!==null&&Ue.delete(tn.key===null?Ge:tn.key),se=R(tn,se,Ge),qe===null?Le=tn:qe.sibling=tn,qe=tn);return l&&Ue.forEach(function(qa){return u(oe,qa)}),St&&So(oe,Ge),Le}function $e(oe,se,ie,Se){var Le=V(ie);if(typeof Le!="function")throw Error(n(150));if(ie=Le.call(ie),ie==null)throw Error(n(151));for(var qe=Le=null,Ue=se,Ge=se=0,tn=null,ct=ie.next();Ue!==null&&!ct.done;Ge++,ct=ie.next()){Ue.index>Ge?(tn=Ue,Ue=null):tn=Ue.sibling;var qa=xe(oe,Ue,ct.value,Se);if(qa===null){Ue===null&&(Ue=tn);break}l&&Ue&&qa.alternate===null&&u(oe,Ue),se=R(qa,se,Ge),qe===null?Le=qa:qe.sibling=qa,qe=qa,Ue=tn}if(ct.done)return g(oe,Ue),St&&So(oe,Ge),Le;if(Ue===null){for(;!ct.done;Ge++,ct=ie.next())ct=je(oe,ct.value,Se),ct!==null&&(se=R(ct,se,Ge),qe===null?Le=ct:qe.sibling=ct,qe=ct);return St&&So(oe,Ge),Le}for(Ue=x(oe,Ue);!ct.done;Ge++,ct=ie.next())ct=Ee(Ue,oe,Ge,ct.value,Se),ct!==null&&(l&&ct.alternate!==null&&Ue.delete(ct.key===null?Ge:ct.key),se=R(ct,se,Ge),qe===null?Le=ct:qe.sibling=ct,qe=ct);return l&&Ue.forEach(function(J8){return u(oe,J8)}),St&&So(oe,Ge),Le}function Dt(oe,se,ie,Se){if(typeof ie=="object"&&ie!==null&&ie.type===M&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case T:e:{for(var Le=ie.key,qe=se;qe!==null;){if(qe.key===Le){if(Le=ie.type,Le===M){if(qe.tag===7){g(oe,qe.sibling),se=C(qe,ie.props.children),se.return=oe,oe=se;break e}}else if(qe.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===P&&_S(Le)===qe.type){g(oe,qe.sibling),se=C(qe,ie.props),se.ref=pc(oe,qe,ie),se.return=oe,oe=se;break e}g(oe,qe);break}else u(oe,qe);qe=qe.sibling}ie.type===M?(se=$o(ie.props.children,oe.mode,Se,ie.key),se.return=oe,oe=se):(Se=ch(ie.type,ie.key,ie.props,null,oe.mode,Se),Se.ref=pc(oe,se,ie),Se.return=oe,oe=Se)}return K(oe);case $:e:{for(qe=ie.key;se!==null;){if(se.key===qe)if(se.tag===4&&se.stateNode.containerInfo===ie.containerInfo&&se.stateNode.implementation===ie.implementation){g(oe,se.sibling),se=C(se,ie.children||[]),se.return=oe,oe=se;break e}else{g(oe,se);break}else u(oe,se);se=se.sibling}se=qg(ie,oe.mode,Se),se.return=oe,oe=se}return K(oe);case P:return qe=ie._init,Dt(oe,se,qe(ie._payload),Se)}if(Ne(ie))return Re(oe,se,ie,Se);if(V(ie))return $e(oe,se,ie,Se);Fd(oe,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,se!==null&&se.tag===6?(g(oe,se.sibling),se=C(se,ie),se.return=oe,oe=se):(g(oe,se),se=Bg(ie,oe.mode,Se),se.return=oe,oe=se),K(oe)):g(oe,se)}return Dt}var Ii=CS(!0),ES=CS(!1),Bd=Aa(null),qd=null,Oi=null,Xm=null;function Zm(){Xm=Oi=qd=null}function Jm(l){var u=Bd.current;kt(Bd),l._currentValue=u}function Qm(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 Pi(l,u){qd=l,Xm=Oi=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(Sn=!0),l.firstContext=null)}function ls(l){var u=l._currentValue;if(Xm!==l)if(l={context:l,memoizedValue:u,next:null},Oi===null){if(qd===null)throw Error(n(308));Oi=l,qd.dependencies={lanes:0,firstContext:l}}else Oi=Oi.next=l;return u}var _o=null;function eg(l){_o===null?_o=[l]:_o.push(l)}function TS(l,u,g,x){var C=u.interleaved;return C===null?(g.next=g,eg(u)):(g.next=C.next,C.next=g),u.interleaved=g,Hr(l,x)}function Hr(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 $a=!1;function tg(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function AS(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 zr(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function La(l,u,g){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(it&2)!==0){var C=x.pending;return C===null?u.next=u:(u.next=C.next,C.next=u),x.pending=u,Hr(l,g)}return C=x.interleaved,C===null?(u.next=u,eg(x)):(u.next=C.next,C.next=u),x.interleaved=u,Hr(l,g)}function Ud(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,At(l,g)}}function RS(l,u){var g=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,g===x)){var C=null,R=null;if(g=g.firstBaseUpdate,g!==null){do{var K={eventTime:g.eventTime,lane:g.lane,tag:g.tag,payload:g.payload,callback:g.callback,next:null};R===null?C=R=K:R=R.next=K,g=g.next}while(g!==null);R===null?C=R=u:R=R.next=u}else C=R=u;g={baseState:x.baseState,firstBaseUpdate:C,lastBaseUpdate:R,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 Wd(l,u,g,x){var C=l.updateQueue;$a=!1;var R=C.firstBaseUpdate,K=C.lastBaseUpdate,Q=C.shared.pending;if(Q!==null){C.shared.pending=null;var ne=Q,ue=ne.next;ne.next=null,K===null?R=ue:K.next=ue,K=ne;var ve=l.alternate;ve!==null&&(ve=ve.updateQueue,Q=ve.lastBaseUpdate,Q!==K&&(Q===null?ve.firstBaseUpdate=ue:Q.next=ue,ve.lastBaseUpdate=ne))}if(R!==null){var je=C.baseState;K=0,ve=ue=ne=null,Q=R;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,$e=Q;switch(xe=u,Ee=g,$e.tag){case 1:if(Re=$e.payload,typeof Re=="function"){je=Re.call(Ee,je,xe);break e}je=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=$e.payload,xe=typeof Re=="function"?Re.call(Ee,je,xe):Re,xe==null)break e;je=H({},je,xe);break e;case 2:$a=!0}}Q.callback!==null&&Q.lane!==0&&(l.flags|=64,xe=C.effects,xe===null?C.effects=[Q]:xe.push(Q))}else Ee={eventTime:Ee,lane:xe,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ve===null?(ue=ve=Ee,ne=je):ve=ve.next=Ee,K|=xe;if(Q=Q.next,Q===null){if(Q=C.shared.pending,Q===null)break;xe=Q,Q=xe.next,xe.next=null,C.lastBaseUpdate=xe,C.shared.pending=null}}while(!0);if(ve===null&&(ne=je),C.baseState=ne,C.firstBaseUpdate=ue,C.lastBaseUpdate=ve,u=C.shared.interleaved,u!==null){C=u;do K|=C.lane,C=C.next;while(C!==u)}else R===null&&(C.shared.lanes=0);To|=K,l.lanes=K,l.memoizedState=je}}function MS(l,u,g){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var x=l[u],C=x.callback;if(C!==null){if(x.callback=null,x=g,typeof C!="function")throw Error(n(191,C));C.call(x)}}}var mc={},cr=Aa(mc),gc=Aa(mc),yc=Aa(mc);function Co(l){if(l===mc)throw Error(n(174));return l}function ng(l,u){switch(yt(yc,u),yt(gc,l),yt(cr,mc),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(cr),yt(cr,u)}function Di(){kt(cr),kt(gc),kt(yc)}function $S(l){Co(yc.current);var u=Co(cr.current),g=Je(u,l.type);u!==g&&(yt(gc,l),yt(cr,g))}function sg(l){gc.current===l&&(kt(cr),kt(gc))}var Rt=Aa(0);function Hd(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 rg=[];function ag(){for(var l=0;l<rg.length;l++)rg[l]._workInProgressVersionPrimary=null;rg.length=0}var zd=_.ReactCurrentDispatcher,og=_.ReactCurrentBatchConfig,Eo=0,Mt=null,Wt=null,Qt=null,Vd=!1,wc=!1,xc=0,v8=0;function dn(){throw Error(n(321))}function ig(l,u){if(u===null)return!1;for(var g=0;g<u.length&&g<l.length;g++)if(!Is(l[g],u[g]))return!1;return!0}function lg(l,u,g,x,C,R){if(Eo=R,Mt=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,zd.current=l===null||l.memoizedState===null?N8:S8,l=g(x,C),wc){R=0;do{if(wc=!1,xc=0,25<=R)throw Error(n(301));R+=1,Qt=Wt=null,u.updateQueue=null,zd.current=_8,l=g(x,C)}while(wc)}if(zd.current=Yd,u=Wt!==null&&Wt.next!==null,Eo=0,Qt=Wt=Mt=null,Vd=!1,u)throw Error(n(300));return l}function cg(){var l=xc!==0;return xc=0,l}function ur(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qt===null?Mt.memoizedState=Qt=l:Qt=Qt.next=l,Qt}function cs(){if(Wt===null){var l=Mt.alternate;l=l!==null?l.memoizedState:null}else l=Wt.next;var u=Qt===null?Mt.memoizedState:Qt.next;if(u!==null)Qt=u,Wt=l;else{if(l===null)throw Error(n(310));Wt=l,l={memoizedState:Wt.memoizedState,baseState:Wt.baseState,baseQueue:Wt.baseQueue,queue:Wt.queue,next:null},Qt===null?Mt.memoizedState=Qt=l:Qt=Qt.next=l}return Qt}function vc(l,u){return typeof u=="function"?u(l):u}function ug(l){var u=cs(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=Wt,C=x.baseQueue,R=g.pending;if(R!==null){if(C!==null){var K=C.next;C.next=R.next,R.next=K}x.baseQueue=C=R,g.pending=null}if(C!==null){R=C.next,x=x.baseState;var Q=K=null,ne=null,ue=R;do{var ve=ue.lane;if((Eo&ve)===ve)ne!==null&&(ne=ne.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),x=ue.hasEagerState?ue.eagerState:l(x,ue.action);else{var je={lane:ve,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};ne===null?(Q=ne=je,K=x):ne=ne.next=je,Mt.lanes|=ve,To|=ve}ue=ue.next}while(ue!==null&&ue!==R);ne===null?K=x:ne.next=Q,Is(x,u.memoizedState)||(Sn=!0),u.memoizedState=x,u.baseState=K,u.baseQueue=ne,g.lastRenderedState=x}if(l=g.interleaved,l!==null){C=l;do R=C.lane,Mt.lanes|=R,To|=R,C=C.next;while(C!==l)}else C===null&&(g.lanes=0);return[u.memoizedState,g.dispatch]}function dg(l){var u=cs(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=g.dispatch,C=g.pending,R=u.memoizedState;if(C!==null){g.pending=null;var K=C=C.next;do R=l(R,K.action),K=K.next;while(K!==C);Is(R,u.memoizedState)||(Sn=!0),u.memoizedState=R,u.baseQueue===null&&(u.baseState=R),g.lastRenderedState=R}return[R,x]}function LS(){}function IS(l,u){var g=Mt,x=cs(),C=u(),R=!Is(x.memoizedState,C);if(R&&(x.memoizedState=C,Sn=!0),x=x.queue,hg(DS.bind(null,g,x,l),[l]),x.getSnapshot!==u||R||Qt!==null&&Qt.memoizedState.tag&1){if(g.flags|=2048,bc(9,PS.bind(null,g,x,C,u),void 0,null),en===null)throw Error(n(349));(Eo&30)!==0||OS(g,u,C)}return C}function OS(l,u,g){l.flags|=16384,l={getSnapshot:u,value:g},u=Mt.updateQueue,u===null?(u={lastEffect:null,stores:null},Mt.updateQueue=u,u.stores=[l]):(g=u.stores,g===null?u.stores=[l]:g.push(l))}function PS(l,u,g,x){u.value=g,u.getSnapshot=x,FS(u)&&BS(l)}function DS(l,u,g){return g(function(){FS(u)&&BS(l)})}function FS(l){var u=l.getSnapshot;l=l.value;try{var g=u();return!Is(l,g)}catch{return!0}}function BS(l){var u=Hr(l,1);u!==null&&Bs(u,l,1,-1)}function qS(l){var u=ur();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:l},u.queue=l,l=l.dispatch=j8.bind(null,Mt,l),[u.memoizedState,l]}function bc(l,u,g,x){return l={tag:l,create:u,destroy:g,deps:x,next:null},u=Mt.updateQueue,u===null?(u={lastEffect:null,stores:null},Mt.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 US(){return cs().memoizedState}function Gd(l,u,g,x){var C=ur();Mt.flags|=l,C.memoizedState=bc(1|u,g,void 0,x===void 0?null:x)}function Kd(l,u,g,x){var C=cs();x=x===void 0?null:x;var R=void 0;if(Wt!==null){var K=Wt.memoizedState;if(R=K.destroy,x!==null&&ig(x,K.deps)){C.memoizedState=bc(u,g,R,x);return}}Mt.flags|=l,C.memoizedState=bc(1|u,g,R,x)}function WS(l,u){return Gd(8390656,8,l,u)}function hg(l,u){return Kd(2048,8,l,u)}function HS(l,u){return Kd(4,2,l,u)}function zS(l,u){return Kd(4,4,l,u)}function VS(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 GS(l,u,g){return g=g!=null?g.concat([l]):null,Kd(4,4,VS.bind(null,u,l),g)}function fg(){}function KS(l,u){var g=cs();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&ig(u,x[1])?x[0]:(g.memoizedState=[l,u],l)}function YS(l,u){var g=cs();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&ig(u,x[1])?x[0]:(l=l(),g.memoizedState=[l,u],l)}function XS(l,u,g){return(Eo&21)===0?(l.baseState&&(l.baseState=!1,Sn=!0),l.memoizedState=g):(Is(g,u)||(g=As(),Mt.lanes|=g,To|=g,l.baseState=!0),u)}function b8(l,u){var g=rt;rt=g!==0&&4>g?g:4,l(!0);var x=og.transition;og.transition={};try{l(!1),u()}finally{rt=g,og.transition=x}}function ZS(){return cs().memoizedState}function k8(l,u,g){var x=Da(l);if(g={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null},JS(l))QS(u,g);else if(g=TS(l,u,g,x),g!==null){var C=yn();Bs(g,l,x,C),e_(g,u,x)}}function j8(l,u,g){var x=Da(l),C={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null};if(JS(l))QS(u,C);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=u.lastRenderedReducer,R!==null))try{var K=u.lastRenderedState,Q=R(K,g);if(C.hasEagerState=!0,C.eagerState=Q,Is(Q,K)){var ne=u.interleaved;ne===null?(C.next=C,eg(u)):(C.next=ne.next,ne.next=C),u.interleaved=C;return}}catch{}finally{}g=TS(l,u,C,x),g!==null&&(C=yn(),Bs(g,l,x,C),e_(g,u,x))}}function JS(l){var u=l.alternate;return l===Mt||u!==null&&u===Mt}function QS(l,u){wc=Vd=!0;var g=l.pending;g===null?u.next=u:(u.next=g.next,g.next=u),l.pending=u}function e_(l,u,g){if((g&4194240)!==0){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,At(l,g)}}var Yd={readContext:ls,useCallback:dn,useContext:dn,useEffect:dn,useImperativeHandle:dn,useInsertionEffect:dn,useLayoutEffect:dn,useMemo:dn,useReducer:dn,useRef:dn,useState:dn,useDebugValue:dn,useDeferredValue:dn,useTransition:dn,useMutableSource:dn,useSyncExternalStore:dn,useId:dn,unstable_isNewReconciler:!1},N8={readContext:ls,useCallback:function(l,u){return ur().memoizedState=[l,u===void 0?null:u],l},useContext:ls,useEffect:WS,useImperativeHandle:function(l,u,g){return g=g!=null?g.concat([l]):null,Gd(4194308,4,VS.bind(null,u,l),g)},useLayoutEffect:function(l,u){return Gd(4194308,4,l,u)},useInsertionEffect:function(l,u){return Gd(4,2,l,u)},useMemo:function(l,u){var g=ur();return u=u===void 0?null:u,l=l(),g.memoizedState=[l,u],l},useReducer:function(l,u,g){var x=ur();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=k8.bind(null,Mt,l),[x.memoizedState,l]},useRef:function(l){var u=ur();return l={current:l},u.memoizedState=l},useState:qS,useDebugValue:fg,useDeferredValue:function(l){return ur().memoizedState=l},useTransition:function(){var l=qS(!1),u=l[0];return l=b8.bind(null,l[1]),ur().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,g){var x=Mt,C=ur();if(St){if(g===void 0)throw Error(n(407));g=g()}else{if(g=u(),en===null)throw Error(n(349));(Eo&30)!==0||OS(x,u,g)}C.memoizedState=g;var R={value:g,getSnapshot:u};return C.queue=R,WS(DS.bind(null,x,R,l),[l]),x.flags|=2048,bc(9,PS.bind(null,x,R,g,u),void 0,null),g},useId:function(){var l=ur(),u=en.identifierPrefix;if(St){var g=Wr,x=Ur;g=(x&~(1<<32-mn(x)-1)).toString(32)+g,u=":"+u+"R"+g,g=xc++,0<g&&(u+="H"+g.toString(32)),u+=":"}else g=v8++,u=":"+u+"r"+g.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},S8={readContext:ls,useCallback:KS,useContext:ls,useEffect:hg,useImperativeHandle:GS,useInsertionEffect:HS,useLayoutEffect:zS,useMemo:YS,useReducer:ug,useRef:US,useState:function(){return ug(vc)},useDebugValue:fg,useDeferredValue:function(l){var u=cs();return XS(u,Wt.memoizedState,l)},useTransition:function(){var l=ug(vc)[0],u=cs().memoizedState;return[l,u]},useMutableSource:LS,useSyncExternalStore:IS,useId:ZS,unstable_isNewReconciler:!1},_8={readContext:ls,useCallback:KS,useContext:ls,useEffect:hg,useImperativeHandle:GS,useInsertionEffect:HS,useLayoutEffect:zS,useMemo:YS,useReducer:dg,useRef:US,useState:function(){return dg(vc)},useDebugValue:fg,useDeferredValue:function(l){var u=cs();return Wt===null?u.memoizedState=l:XS(u,Wt.memoizedState,l)},useTransition:function(){var l=dg(vc)[0],u=cs().memoizedState;return[l,u]},useMutableSource:LS,useSyncExternalStore:IS,useId:ZS,unstable_isNewReconciler:!1};function Ps(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 pg(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 Xd={isMounted:function(l){return(l=l._reactInternals)?qn(l)===l:!1},enqueueSetState:function(l,u,g){l=l._reactInternals;var x=yn(),C=Da(l),R=zr(x,C);R.payload=u,g!=null&&(R.callback=g),u=La(l,R,C),u!==null&&(Bs(u,l,C,x),Ud(u,l,C))},enqueueReplaceState:function(l,u,g){l=l._reactInternals;var x=yn(),C=Da(l),R=zr(x,C);R.tag=1,R.payload=u,g!=null&&(R.callback=g),u=La(l,R,C),u!==null&&(Bs(u,l,C,x),Ud(u,l,C))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var g=yn(),x=Da(l),C=zr(g,x);C.tag=2,u!=null&&(C.callback=u),u=La(l,C,x),u!==null&&(Bs(u,l,x,g),Ud(u,l,x))}};function t_(l,u,g,x,C,R,K){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,R,K):u.prototype&&u.prototype.isPureReactComponent?!ic(g,x)||!ic(C,R):!0}function n_(l,u,g){var x=!1,C=Ra,R=u.contextType;return typeof R=="object"&&R!==null?R=ls(R):(C=Nn(u)?jo:un.current,x=u.contextTypes,R=(x=x!=null)?Ri(l,C):Ra),u=new u(g,R),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Xd,l.stateNode=u,u._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=C,l.__reactInternalMemoizedMaskedChildContext=R),u}function s_(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&&Xd.enqueueReplaceState(u,u.state,null)}function mg(l,u,g,x){var C=l.stateNode;C.props=g,C.state=l.memoizedState,C.refs={},tg(l);var R=u.contextType;typeof R=="object"&&R!==null?C.context=ls(R):(R=Nn(u)?jo:un.current,C.context=Ri(l,R)),C.state=l.memoizedState,R=u.getDerivedStateFromProps,typeof R=="function"&&(pg(l,u,R,g),C.state=l.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(u=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),u!==C.state&&Xd.enqueueReplaceState(C,C.state,null),Wd(l,g,C,x),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308)}function Fi(l,u){try{var g="",x=u;do g+=Y(x),x=x.return;while(x);var C=g}catch(R){C=`
39
+ Error generating stack: `+R.message+`
40
+ `+R.stack}return{value:l,source:u,stack:C,digest:null}}function gg(l,u,g){return{value:l,source:null,stack:g??null,digest:u??null}}function yg(l,u){try{console.error(u.value)}catch(g){setTimeout(function(){throw g})}}var C8=typeof WeakMap=="function"?WeakMap:Map;function r_(l,u,g){g=zr(-1,g),g.tag=3,g.payload={element:null};var x=u.value;return g.callback=function(){sh||(sh=!0,Mg=x),yg(l,u)},g}function a_(l,u,g){g=zr(-1,g),g.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var C=u.value;g.payload=function(){return x(C)},g.callback=function(){yg(l,u)}}var R=l.stateNode;return R!==null&&typeof R.componentDidCatch=="function"&&(g.callback=function(){yg(l,u),typeof x!="function"&&(Oa===null?Oa=new Set([this]):Oa.add(this));var K=u.stack;this.componentDidCatch(u.value,{componentStack:K!==null?K:""})}),g}function o_(l,u,g){var x=l.pingCache;if(x===null){x=l.pingCache=new C8;var C=new Set;x.set(u,C)}else C=x.get(u),C===void 0&&(C=new Set,x.set(u,C));C.has(g)||(C.add(g),l=q8.bind(null,l,u,g),u.then(l,l))}function i_(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 l_(l,u,g,x,C){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=zr(-1,1),u.tag=2,La(g,u,1))),g.lanes|=1),l):(l.flags|=65536,l.lanes=C,l)}var E8=_.ReactCurrentOwner,Sn=!1;function gn(l,u,g,x){u.child=l===null?ES(u,null,g,x):Ii(u,l.child,g,x)}function c_(l,u,g,x,C){g=g.render;var R=u.ref;return Pi(u,C),x=lg(l,u,g,x,R,C),g=cg(),l!==null&&!Sn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Vr(l,u,C)):(St&&g&&zm(u),u.flags|=1,gn(l,u,x,C),u.child)}function u_(l,u,g,x,C){if(l===null){var R=g.type;return typeof R=="function"&&!Fg(R)&&R.defaultProps===void 0&&g.compare===null&&g.defaultProps===void 0?(u.tag=15,u.type=R,d_(l,u,R,x,C)):(l=ch(g.type,null,x,u,u.mode,C),l.ref=u.ref,l.return=u,u.child=l)}if(R=l.child,(l.lanes&C)===0){var K=R.memoizedProps;if(g=g.compare,g=g!==null?g:ic,g(K,x)&&l.ref===u.ref)return Vr(l,u,C)}return u.flags|=1,l=Ba(R,x),l.ref=u.ref,l.return=u,u.child=l}function d_(l,u,g,x,C){if(l!==null){var R=l.memoizedProps;if(ic(R,x)&&l.ref===u.ref)if(Sn=!1,u.pendingProps=x=R,(l.lanes&C)!==0)(l.flags&131072)!==0&&(Sn=!0);else return u.lanes=l.lanes,Vr(l,u,C)}return wg(l,u,g,x,C)}function h_(l,u,g){var x=u.pendingProps,C=x.children,R=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},yt(qi,Gn),Gn|=g;else{if((g&1073741824)===0)return l=R!==null?R.baseLanes|g:g,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,yt(qi,Gn),Gn|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=R!==null?R.baseLanes:g,yt(qi,Gn),Gn|=x}else R!==null?(x=R.baseLanes|g,u.memoizedState=null):x=g,yt(qi,Gn),Gn|=x;return gn(l,u,C,g),u.child}function f_(l,u){var g=u.ref;(l===null&&g!==null||l!==null&&l.ref!==g)&&(u.flags|=512,u.flags|=2097152)}function wg(l,u,g,x,C){var R=Nn(g)?jo:un.current;return R=Ri(u,R),Pi(u,C),g=lg(l,u,g,x,R,C),x=cg(),l!==null&&!Sn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Vr(l,u,C)):(St&&x&&zm(u),u.flags|=1,gn(l,u,g,C),u.child)}function p_(l,u,g,x,C){if(Nn(g)){var R=!0;Ld(u)}else R=!1;if(Pi(u,C),u.stateNode===null)Jd(l,u),n_(u,g,x),mg(u,g,x,C),x=!0;else if(l===null){var K=u.stateNode,Q=u.memoizedProps;K.props=Q;var ne=K.context,ue=g.contextType;typeof ue=="object"&&ue!==null?ue=ls(ue):(ue=Nn(g)?jo:un.current,ue=Ri(u,ue));var ve=g.getDerivedStateFromProps,je=typeof ve=="function"||typeof K.getSnapshotBeforeUpdate=="function";je||typeof K.UNSAFE_componentWillReceiveProps!="function"&&typeof K.componentWillReceiveProps!="function"||(Q!==x||ne!==ue)&&s_(u,K,x,ue),$a=!1;var xe=u.memoizedState;K.state=xe,Wd(u,x,K,C),ne=u.memoizedState,Q!==x||xe!==ne||jn.current||$a?(typeof ve=="function"&&(pg(u,g,ve,x),ne=u.memoizedState),(Q=$a||t_(u,g,Q,x,xe,ne,ue))?(je||typeof K.UNSAFE_componentWillMount!="function"&&typeof K.componentWillMount!="function"||(typeof K.componentWillMount=="function"&&K.componentWillMount(),typeof K.UNSAFE_componentWillMount=="function"&&K.UNSAFE_componentWillMount()),typeof K.componentDidMount=="function"&&(u.flags|=4194308)):(typeof K.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=ne),K.props=x,K.state=ne,K.context=ue,x=Q):(typeof K.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{K=u.stateNode,AS(l,u),Q=u.memoizedProps,ue=u.type===u.elementType?Q:Ps(u.type,Q),K.props=ue,je=u.pendingProps,xe=K.context,ne=g.contextType,typeof ne=="object"&&ne!==null?ne=ls(ne):(ne=Nn(g)?jo:un.current,ne=Ri(u,ne));var Ee=g.getDerivedStateFromProps;(ve=typeof Ee=="function"||typeof K.getSnapshotBeforeUpdate=="function")||typeof K.UNSAFE_componentWillReceiveProps!="function"&&typeof K.componentWillReceiveProps!="function"||(Q!==je||xe!==ne)&&s_(u,K,x,ne),$a=!1,xe=u.memoizedState,K.state=xe,Wd(u,x,K,C);var Re=u.memoizedState;Q!==je||xe!==Re||jn.current||$a?(typeof Ee=="function"&&(pg(u,g,Ee,x),Re=u.memoizedState),(ue=$a||t_(u,g,ue,x,xe,Re,ne)||!1)?(ve||typeof K.UNSAFE_componentWillUpdate!="function"&&typeof K.componentWillUpdate!="function"||(typeof K.componentWillUpdate=="function"&&K.componentWillUpdate(x,Re,ne),typeof K.UNSAFE_componentWillUpdate=="function"&&K.UNSAFE_componentWillUpdate(x,Re,ne)),typeof K.componentDidUpdate=="function"&&(u.flags|=4),typeof K.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof K.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof K.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Re),K.props=x,K.state=Re,K.context=ne,x=ue):(typeof K.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof K.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),x=!1)}return xg(l,u,g,x,R,C)}function xg(l,u,g,x,C,R){f_(l,u);var K=(u.flags&128)!==0;if(!x&&!K)return C&&xS(u,g,!1),Vr(l,u,R);x=u.stateNode,E8.current=u;var Q=K&&typeof g.getDerivedStateFromError!="function"?null:x.render();return u.flags|=1,l!==null&&K?(u.child=Ii(u,l.child,null,R),u.child=Ii(u,null,Q,R)):gn(l,u,Q,R),u.memoizedState=x.state,C&&xS(u,g,!0),u.child}function m_(l){var u=l.stateNode;u.pendingContext?yS(l,u.pendingContext,u.pendingContext!==u.context):u.context&&yS(l,u.context,!1),ng(l,u.containerInfo)}function g_(l,u,g,x,C){return Li(),Ym(C),u.flags|=256,gn(l,u,g,x),u.child}var vg={dehydrated:null,treeContext:null,retryLane:0};function bg(l){return{baseLanes:l,cachePool:null,transitions:null}}function y_(l,u,g){var x=u.pendingProps,C=Rt.current,R=!1,K=(u.flags&128)!==0,Q;if((Q=K)||(Q=l!==null&&l.memoizedState===null?!1:(C&2)!==0),Q?(R=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(C|=1),yt(Rt,C&1),l===null)return Km(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):(K=x.children,l=x.fallback,R?(x=u.mode,R=u.child,K={mode:"hidden",children:K},(x&1)===0&&R!==null?(R.childLanes=0,R.pendingProps=K):R=uh(K,x,0,null),l=$o(l,x,g,null),R.return=u,l.return=u,R.sibling=l,u.child=R,u.child.memoizedState=bg(g),u.memoizedState=vg,l):kg(u,K));if(C=l.memoizedState,C!==null&&(Q=C.dehydrated,Q!==null))return T8(l,u,K,x,Q,C,g);if(R){R=x.fallback,K=u.mode,C=l.child,Q=C.sibling;var ne={mode:"hidden",children:x.children};return(K&1)===0&&u.child!==C?(x=u.child,x.childLanes=0,x.pendingProps=ne,u.deletions=null):(x=Ba(C,ne),x.subtreeFlags=C.subtreeFlags&14680064),Q!==null?R=Ba(Q,R):(R=$o(R,K,g,null),R.flags|=2),R.return=u,x.return=u,x.sibling=R,u.child=x,x=R,R=u.child,K=l.child.memoizedState,K=K===null?bg(g):{baseLanes:K.baseLanes|g,cachePool:null,transitions:K.transitions},R.memoizedState=K,R.childLanes=l.childLanes&~g,u.memoizedState=vg,x}return R=l.child,l=R.sibling,x=Ba(R,{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 kg(l,u){return u=uh({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function Zd(l,u,g,x){return x!==null&&Ym(x),Ii(u,l.child,null,g),l=kg(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function T8(l,u,g,x,C,R,K){if(g)return u.flags&256?(u.flags&=-257,x=gg(Error(n(422))),Zd(l,u,K,x)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(R=x.fallback,C=u.mode,x=uh({mode:"visible",children:x.children},C,0,null),R=$o(R,C,K,null),R.flags|=2,x.return=u,R.return=u,x.sibling=R,u.child=x,(u.mode&1)!==0&&Ii(u,l.child,null,K),u.child.memoizedState=bg(K),u.memoizedState=vg,R);if((u.mode&1)===0)return Zd(l,u,K,null);if(C.data==="$!"){if(x=C.nextSibling&&C.nextSibling.dataset,x)var Q=x.dgst;return x=Q,R=Error(n(419)),x=gg(R,x,void 0),Zd(l,u,K,x)}if(Q=(K&l.childLanes)!==0,Sn||Q){if(x=en,x!==null){switch(K&-K){case 4:C=2;break;case 16:C=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:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(x.suspendedLanes|K))!==0?0:C,C!==0&&C!==R.retryLane&&(R.retryLane=C,Hr(l,C),Bs(x,l,C,-1))}return Dg(),x=gg(Error(n(421))),Zd(l,u,K,x)}return C.data==="$?"?(u.flags|=128,u.child=l.child,u=U8.bind(null,l),C._reactRetry=u,null):(l=R.treeContext,Vn=Ta(C.nextSibling),zn=u,St=!0,Os=null,l!==null&&(os[is++]=Ur,os[is++]=Wr,os[is++]=No,Ur=l.id,Wr=l.overflow,No=u),u=kg(u,x.children),u.flags|=4096,u)}function w_(l,u,g){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),Qm(l.return,u,g)}function jg(l,u,g,x,C){var R=l.memoizedState;R===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:g,tailMode:C}:(R.isBackwards=u,R.rendering=null,R.renderingStartTime=0,R.last=x,R.tail=g,R.tailMode=C)}function x_(l,u,g){var x=u.pendingProps,C=x.revealOrder,R=x.tail;if(gn(l,u,x.children,g),x=Rt.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&&w_(l,g,u);else if(l.tag===19)w_(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(yt(Rt,x),(u.mode&1)===0)u.memoizedState=null;else switch(C){case"forwards":for(g=u.child,C=null;g!==null;)l=g.alternate,l!==null&&Hd(l)===null&&(C=g),g=g.sibling;g=C,g===null?(C=u.child,u.child=null):(C=g.sibling,g.sibling=null),jg(u,!1,C,g,R);break;case"backwards":for(g=null,C=u.child,u.child=null;C!==null;){if(l=C.alternate,l!==null&&Hd(l)===null){u.child=C;break}l=C.sibling,C.sibling=g,g=C,C=l}jg(u,!0,g,null,R);break;case"together":jg(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 Vr(l,u,g){if(l!==null&&(u.dependencies=l.dependencies),To|=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 A8(l,u,g){switch(u.tag){case 3:m_(u),Li();break;case 5:$S(u);break;case 1:Nn(u.type)&&Ld(u);break;case 4:ng(u,u.stateNode.containerInfo);break;case 10:var x=u.type._context,C=u.memoizedProps.value;yt(Bd,x._currentValue),x._currentValue=C;break;case 13:if(x=u.memoizedState,x!==null)return x.dehydrated!==null?(yt(Rt,Rt.current&1),u.flags|=128,null):(g&u.child.childLanes)!==0?y_(l,u,g):(yt(Rt,Rt.current&1),l=Vr(l,u,g),l!==null?l.sibling:null);yt(Rt,Rt.current&1);break;case 19:if(x=(g&u.childLanes)!==0,(l.flags&128)!==0){if(x)return x_(l,u,g);u.flags|=128}if(C=u.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),yt(Rt,Rt.current),x)break;return null;case 22:case 23:return u.lanes=0,h_(l,u,g)}return Vr(l,u,g)}var v_,Ng,b_,k_;v_=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}},Ng=function(){},b_=function(l,u,g,x){var C=l.memoizedProps;if(C!==x){l=u.stateNode,Co(cr.current);var R=null;switch(g){case"input":C=ae(l,C),x=ae(l,x),R=[];break;case"select":C=H({},C,{value:void 0}),x=H({},x,{value:void 0}),R=[];break;case"textarea":C=Me(l,C),x=Me(l,x),R=[];break;default:typeof C.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=Rd)}Fe(g,x);var K;g=null;for(ue in C)if(!x.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var Q=C[ue];for(K in Q)Q.hasOwnProperty(K)&&(g||(g={}),g[K]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(a.hasOwnProperty(ue)?R||(R=[]):(R=R||[]).push(ue,null));for(ue in x){var ne=x[ue];if(Q=C!=null?C[ue]:void 0,x.hasOwnProperty(ue)&&ne!==Q&&(ne!=null||Q!=null))if(ue==="style")if(Q){for(K in Q)!Q.hasOwnProperty(K)||ne&&ne.hasOwnProperty(K)||(g||(g={}),g[K]="");for(K in ne)ne.hasOwnProperty(K)&&Q[K]!==ne[K]&&(g||(g={}),g[K]=ne[K])}else g||(R||(R=[]),R.push(ue,g)),g=ne;else ue==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,Q=Q?Q.__html:void 0,ne!=null&&Q!==ne&&(R=R||[]).push(ue,ne)):ue==="children"?typeof ne!="string"&&typeof ne!="number"||(R=R||[]).push(ue,""+ne):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(a.hasOwnProperty(ue)?(ne!=null&&ue==="onScroll"&&bt("scroll",l),R||Q===ne||(R=[])):(R=R||[]).push(ue,ne))}g&&(R=R||[]).push("style",g);var ue=R;(u.updateQueue=ue)&&(u.flags|=4)}},k_=function(l,u,g,x){g!==x&&(u.flags|=4)};function kc(l,u){if(!St)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 hn(l){var u=l.alternate!==null&&l.alternate.child===l.child,g=0,x=0;if(u)for(var C=l.child;C!==null;)g|=C.lanes|C.childLanes,x|=C.subtreeFlags&14680064,x|=C.flags&14680064,C.return=l,C=C.sibling;else for(C=l.child;C!==null;)g|=C.lanes|C.childLanes,x|=C.subtreeFlags,x|=C.flags,C.return=l,C=C.sibling;return l.subtreeFlags|=x,l.childLanes=g,u}function R8(l,u,g){var x=u.pendingProps;switch(Vm(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hn(u),null;case 1:return Nn(u.type)&&$d(),hn(u),null;case 3:return x=u.stateNode,Di(),kt(jn),kt(un),ag(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(Dd(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Os!==null&&(Ig(Os),Os=null))),Ng(l,u),hn(u),null;case 5:sg(u);var C=Co(yc.current);if(g=u.type,l!==null&&u.stateNode!=null)b_(l,u,g,x,C),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!x){if(u.stateNode===null)throw Error(n(166));return hn(u),null}if(l=Co(cr.current),Dd(u)){x=u.stateNode,g=u.type;var R=u.memoizedProps;switch(x[lr]=u,x[hc]=R,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(C=0;C<cc.length;C++)bt(cc[C],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":de(x,R),bt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!R.multiple},bt("invalid",x);break;case"textarea":Ie(x,R),bt("invalid",x)}Fe(g,R),C=null;for(var K in R)if(R.hasOwnProperty(K)){var Q=R[K];K==="children"?typeof Q=="string"?x.textContent!==Q&&(R.suppressHydrationWarning!==!0&&Ad(x.textContent,Q,l),C=["children",Q]):typeof Q=="number"&&x.textContent!==""+Q&&(R.suppressHydrationWarning!==!0&&Ad(x.textContent,Q,l),C=["children",""+Q]):a.hasOwnProperty(K)&&Q!=null&&K==="onScroll"&&bt("scroll",x)}switch(g){case"input":he(x),ye(x,R,!0);break;case"textarea":he(x),Te(x);break;case"select":case"option":break;default:typeof R.onClick=="function"&&(x.onclick=Rd)}x=C,u.updateQueue=x,x!==null&&(u.flags|=4)}else{K=C.nodeType===9?C:C.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=at(g)),l==="http://www.w3.org/1999/xhtml"?g==="script"?(l=K.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=K.createElement(g,{is:x.is}):(l=K.createElement(g),g==="select"&&(K=l,x.multiple?K.multiple=!0:x.size&&(K.size=x.size))):l=K.createElementNS(l,g),l[lr]=u,l[hc]=x,v_(l,u,!1,!1),u.stateNode=l;e:{switch(K=Xe(g,x),g){case"dialog":bt("cancel",l),bt("close",l),C=x;break;case"iframe":case"object":case"embed":bt("load",l),C=x;break;case"video":case"audio":for(C=0;C<cc.length;C++)bt(cc[C],l);C=x;break;case"source":bt("error",l),C=x;break;case"img":case"image":case"link":bt("error",l),bt("load",l),C=x;break;case"details":bt("toggle",l),C=x;break;case"input":de(l,x),C=ae(l,x),bt("invalid",l);break;case"option":C=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},C=H({},x,{value:void 0}),bt("invalid",l);break;case"textarea":Ie(l,x),C=Me(l,x),bt("invalid",l);break;default:C=x}Fe(g,C),Q=C;for(R in Q)if(Q.hasOwnProperty(R)){var ne=Q[R];R==="style"?Qe(l,ne):R==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&be(l,ne)):R==="children"?typeof ne=="string"?(g!=="textarea"||ne!=="")&&Oe(l,ne):typeof ne=="number"&&Oe(l,""+ne):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(a.hasOwnProperty(R)?ne!=null&&R==="onScroll"&&bt("scroll",l):ne!=null&&S(l,R,ne,K))}switch(g){case"input":he(l),ye(l,x,!1);break;case"textarea":he(l),Te(l);break;case"option":x.value!=null&&l.setAttribute("value",""+J(x.value));break;case"select":l.multiple=!!x.multiple,R=x.value,R!=null?ge(l,!!x.multiple,R,!1):x.defaultValue!=null&&ge(l,!!x.multiple,x.defaultValue,!0);break;default:typeof C.onClick=="function"&&(l.onclick=Rd)}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 hn(u),null;case 6:if(l&&u.stateNode!=null)k_(l,u,l.memoizedProps,x);else{if(typeof x!="string"&&u.stateNode===null)throw Error(n(166));if(g=Co(yc.current),Co(cr.current),Dd(u)){if(x=u.stateNode,g=u.memoizedProps,x[lr]=u,(R=x.nodeValue!==g)&&(l=zn,l!==null))switch(l.tag){case 3:Ad(x.nodeValue,g,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&Ad(x.nodeValue,g,(l.mode&1)!==0)}R&&(u.flags|=4)}else x=(g.nodeType===9?g:g.ownerDocument).createTextNode(x),x[lr]=u,u.stateNode=x}return hn(u),null;case 13:if(kt(Rt),x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(St&&Vn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)SS(),Li(),u.flags|=98560,R=!1;else if(R=Dd(u),x!==null&&x.dehydrated!==null){if(l===null){if(!R)throw Error(n(318));if(R=u.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(n(317));R[lr]=u}else Li(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;hn(u),R=!1}else Os!==null&&(Ig(Os),Os=null),R=!0;if(!R)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||(Rt.current&1)!==0?Ht===0&&(Ht=3):Dg())),u.updateQueue!==null&&(u.flags|=4),hn(u),null);case 4:return Di(),Ng(l,u),l===null&&uc(u.stateNode.containerInfo),hn(u),null;case 10:return Jm(u.type._context),hn(u),null;case 17:return Nn(u.type)&&$d(),hn(u),null;case 19:if(kt(Rt),R=u.memoizedState,R===null)return hn(u),null;if(x=(u.flags&128)!==0,K=R.rendering,K===null)if(x)kc(R,!1);else{if(Ht!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(K=Hd(l),K!==null){for(u.flags|=128,kc(R,!1),x=K.updateQueue,x!==null&&(u.updateQueue=x,u.flags|=4),u.subtreeFlags=0,x=g,g=u.child;g!==null;)R=g,l=x,R.flags&=14680066,K=R.alternate,K===null?(R.childLanes=0,R.lanes=l,R.child=null,R.subtreeFlags=0,R.memoizedProps=null,R.memoizedState=null,R.updateQueue=null,R.dependencies=null,R.stateNode=null):(R.childLanes=K.childLanes,R.lanes=K.lanes,R.child=K.child,R.subtreeFlags=0,R.deletions=null,R.memoizedProps=K.memoizedProps,R.memoizedState=K.memoizedState,R.updateQueue=K.updateQueue,R.type=K.type,l=K.dependencies,R.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),g=g.sibling;return yt(Rt,Rt.current&1|2),u.child}l=l.sibling}R.tail!==null&&ft()>Ui&&(u.flags|=128,x=!0,kc(R,!1),u.lanes=4194304)}else{if(!x)if(l=Hd(K),l!==null){if(u.flags|=128,x=!0,g=l.updateQueue,g!==null&&(u.updateQueue=g,u.flags|=4),kc(R,!0),R.tail===null&&R.tailMode==="hidden"&&!K.alternate&&!St)return hn(u),null}else 2*ft()-R.renderingStartTime>Ui&&g!==1073741824&&(u.flags|=128,x=!0,kc(R,!1),u.lanes=4194304);R.isBackwards?(K.sibling=u.child,u.child=K):(g=R.last,g!==null?g.sibling=K:u.child=K,R.last=K)}return R.tail!==null?(u=R.tail,R.rendering=u,R.tail=u.sibling,R.renderingStartTime=ft(),u.sibling=null,g=Rt.current,yt(Rt,x?g&1|2:g&1),u):(hn(u),null);case 22:case 23:return Pg(),x=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(u.flags|=8192),x&&(u.mode&1)!==0?(Gn&1073741824)!==0&&(hn(u),u.subtreeFlags&6&&(u.flags|=8192)):hn(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function M8(l,u){switch(Vm(u),u.tag){case 1:return Nn(u.type)&&$d(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Di(),kt(jn),kt(un),ag(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return sg(u),null;case 13:if(kt(Rt),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Li()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return kt(Rt),null;case 4:return Di(),null;case 10:return Jm(u.type._context),null;case 22:case 23:return Pg(),null;case 24:return null;default:return null}}var Qd=!1,fn=!1,$8=typeof WeakSet=="function"?WeakSet:Set,Ae=null;function Bi(l,u){var g=l.ref;if(g!==null)if(typeof g=="function")try{g(null)}catch(x){Lt(l,u,x)}else g.current=null}function Sg(l,u,g){try{g()}catch(x){Lt(l,u,x)}}var j_=!1;function L8(l,u){if(Pm=ka,l=tS(),Tm(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 C=x.anchorOffset,R=x.focusNode;x=x.focusOffset;try{g.nodeType,R.nodeType}catch{g=null;break e}var K=0,Q=-1,ne=-1,ue=0,ve=0,je=l,xe=null;t:for(;;){for(var Ee;je!==g||C!==0&&je.nodeType!==3||(Q=K+C),je!==R||x!==0&&je.nodeType!==3||(ne=K+x),je.nodeType===3&&(K+=je.nodeValue.length),(Ee=je.firstChild)!==null;)xe=je,je=Ee;for(;;){if(je===l)break t;if(xe===g&&++ue===C&&(Q=K),xe===R&&++ve===x&&(ne=K),(Ee=je.nextSibling)!==null)break;je=xe,xe=je.parentNode}je=Ee}g=Q===-1||ne===-1?null:{start:Q,end:ne}}else g=null}g=g||{start:0,end:0}}else g=null;for(Dm={focusedElem:l,selectionRange:g},ka=!1,Ae=u;Ae!==null;)if(u=Ae,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Ae=l;else for(;Ae!==null;){u=Ae;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 $e=Re.memoizedProps,Dt=Re.memoizedState,oe=u.stateNode,se=oe.getSnapshotBeforeUpdate(u.elementType===u.type?$e:Ps(u.type,$e),Dt);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(Se){Lt(u,u.return,Se)}if(l=u.sibling,l!==null){l.return=u.return,Ae=l;break}Ae=u.return}return Re=j_,j_=!1,Re}function jc(l,u,g){var x=u.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var C=x=x.next;do{if((C.tag&l)===l){var R=C.destroy;C.destroy=void 0,R!==void 0&&Sg(u,g,R)}C=C.next}while(C!==x)}}function eh(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 _g(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 N_(l){var u=l.alternate;u!==null&&(l.alternate=null,N_(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[lr],delete u[hc],delete u[Um],delete u[g8],delete u[y8])),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 S_(l){return l.tag===5||l.tag===3||l.tag===4}function __(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||S_(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 Cg(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=Rd));else if(x!==4&&(l=l.child,l!==null))for(Cg(l,u,g),l=l.sibling;l!==null;)Cg(l,u,g),l=l.sibling}function Eg(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(Eg(l,u,g),l=l.sibling;l!==null;)Eg(l,u,g),l=l.sibling}var an=null,Ds=!1;function Ia(l,u,g){for(g=g.child;g!==null;)C_(l,u,g),g=g.sibling}function C_(l,u,g){if(Jt&&typeof Jt.onCommitFiberUnmount=="function")try{Jt.onCommitFiberUnmount(Es,g)}catch{}switch(g.tag){case 5:fn||Bi(g,u);case 6:var x=an,C=Ds;an=null,Ia(l,u,g),an=x,Ds=C,an!==null&&(Ds?(l=an,g=g.stateNode,l.nodeType===8?l.parentNode.removeChild(g):l.removeChild(g)):an.removeChild(g.stateNode));break;case 18:an!==null&&(Ds?(l=an,g=g.stateNode,l.nodeType===8?qm(l.parentNode,g):l.nodeType===1&&qm(l,g),yo(l)):qm(an,g.stateNode));break;case 4:x=an,C=Ds,an=g.stateNode.containerInfo,Ds=!0,Ia(l,u,g),an=x,Ds=C;break;case 0:case 11:case 14:case 15:if(!fn&&(x=g.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){C=x=x.next;do{var R=C,K=R.destroy;R=R.tag,K!==void 0&&((R&2)!==0||(R&4)!==0)&&Sg(g,u,K),C=C.next}while(C!==x)}Ia(l,u,g);break;case 1:if(!fn&&(Bi(g,u),x=g.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=g.memoizedProps,x.state=g.memoizedState,x.componentWillUnmount()}catch(Q){Lt(g,u,Q)}Ia(l,u,g);break;case 21:Ia(l,u,g);break;case 22:g.mode&1?(fn=(x=fn)||g.memoizedState!==null,Ia(l,u,g),fn=x):Ia(l,u,g);break;default:Ia(l,u,g)}}function E_(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var g=l.stateNode;g===null&&(g=l.stateNode=new $8),u.forEach(function(x){var C=W8.bind(null,l,x);g.has(x)||(g.add(x),x.then(C,C))})}}function Fs(l,u){var g=u.deletions;if(g!==null)for(var x=0;x<g.length;x++){var C=g[x];try{var R=l,K=u,Q=K;e:for(;Q!==null;){switch(Q.tag){case 5:an=Q.stateNode,Ds=!1;break e;case 3:an=Q.stateNode.containerInfo,Ds=!0;break e;case 4:an=Q.stateNode.containerInfo,Ds=!0;break e}Q=Q.return}if(an===null)throw Error(n(160));C_(R,K,C),an=null,Ds=!1;var ne=C.alternate;ne!==null&&(ne.return=null),C.return=null}catch(ue){Lt(C,u,ue)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)T_(u,l),u=u.sibling}function T_(l,u){var g=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Fs(u,l),dr(l),x&4){try{jc(3,l,l.return),eh(3,l)}catch($e){Lt(l,l.return,$e)}try{jc(5,l,l.return)}catch($e){Lt(l,l.return,$e)}}break;case 1:Fs(u,l),dr(l),x&512&&g!==null&&Bi(g,g.return);break;case 5:if(Fs(u,l),dr(l),x&512&&g!==null&&Bi(g,g.return),l.flags&32){var C=l.stateNode;try{Oe(C,"")}catch($e){Lt(l,l.return,$e)}}if(x&4&&(C=l.stateNode,C!=null)){var R=l.memoizedProps,K=g!==null?g.memoizedProps:R,Q=l.type,ne=l.updateQueue;if(l.updateQueue=null,ne!==null)try{Q==="input"&&R.type==="radio"&&R.name!=null&&_e(C,R),Xe(Q,K);var ue=Xe(Q,R);for(K=0;K<ne.length;K+=2){var ve=ne[K],je=ne[K+1];ve==="style"?Qe(C,je):ve==="dangerouslySetInnerHTML"?be(C,je):ve==="children"?Oe(C,je):S(C,ve,je,ue)}switch(Q){case"input":fe(C,R);break;case"textarea":We(C,R);break;case"select":var xe=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!R.multiple;var Ee=R.value;Ee!=null?ge(C,!!R.multiple,Ee,!1):xe!==!!R.multiple&&(R.defaultValue!=null?ge(C,!!R.multiple,R.defaultValue,!0):ge(C,!!R.multiple,R.multiple?[]:"",!1))}C[hc]=R}catch($e){Lt(l,l.return,$e)}}break;case 6:if(Fs(u,l),dr(l),x&4){if(l.stateNode===null)throw Error(n(162));C=l.stateNode,R=l.memoizedProps;try{C.nodeValue=R}catch($e){Lt(l,l.return,$e)}}break;case 3:if(Fs(u,l),dr(l),x&4&&g!==null&&g.memoizedState.isDehydrated)try{yo(u.containerInfo)}catch($e){Lt(l,l.return,$e)}break;case 4:Fs(u,l),dr(l);break;case 13:Fs(u,l),dr(l),C=l.child,C.flags&8192&&(R=C.memoizedState!==null,C.stateNode.isHidden=R,!R||C.alternate!==null&&C.alternate.memoizedState!==null||(Rg=ft())),x&4&&E_(l);break;case 22:if(ve=g!==null&&g.memoizedState!==null,l.mode&1?(fn=(ue=fn)||ve,Fs(u,l),fn=ue):Fs(u,l),dr(l),x&8192){if(ue=l.memoizedState!==null,(l.stateNode.isHidden=ue)&&!ve&&(l.mode&1)!==0)for(Ae=l,ve=l.child;ve!==null;){for(je=Ae=ve;Ae!==null;){switch(xe=Ae,Ee=xe.child,xe.tag){case 0:case 11:case 14:case 15:jc(4,xe,xe.return);break;case 1:Bi(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($e){Lt(x,g,$e)}}break;case 5:Bi(xe,xe.return);break;case 22:if(xe.memoizedState!==null){M_(je);continue}}Ee!==null?(Ee.return=xe,Ae=Ee):M_(je)}ve=ve.sibling}e:for(ve=null,je=l;;){if(je.tag===5){if(ve===null){ve=je;try{C=je.stateNode,ue?(R=C.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none"):(Q=je.stateNode,ne=je.memoizedProps.style,K=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,Q.style.display=ot("display",K))}catch($e){Lt(l,l.return,$e)}}}else if(je.tag===6){if(ve===null)try{je.stateNode.nodeValue=ue?"":je.memoizedProps}catch($e){Lt(l,l.return,$e)}}else if((je.tag!==22&&je.tag!==23||je.memoizedState===null||je===l)&&je.child!==null){je.child.return=je,je=je.child;continue}if(je===l)break e;for(;je.sibling===null;){if(je.return===null||je.return===l)break e;ve===je&&(ve=null),je=je.return}ve===je&&(ve=null),je.sibling.return=je.return,je=je.sibling}}break;case 19:Fs(u,l),dr(l),x&4&&E_(l);break;case 21:break;default:Fs(u,l),dr(l)}}function dr(l){var u=l.flags;if(u&2){try{e:{for(var g=l.return;g!==null;){if(S_(g)){var x=g;break e}g=g.return}throw Error(n(160))}switch(x.tag){case 5:var C=x.stateNode;x.flags&32&&(Oe(C,""),x.flags&=-33);var R=__(l);Eg(l,R,C);break;case 3:case 4:var K=x.stateNode.containerInfo,Q=__(l);Cg(l,Q,K);break;default:throw Error(n(161))}}catch(ne){Lt(l,l.return,ne)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function I8(l,u,g){Ae=l,A_(l)}function A_(l,u,g){for(var x=(l.mode&1)!==0;Ae!==null;){var C=Ae,R=C.child;if(C.tag===22&&x){var K=C.memoizedState!==null||Qd;if(!K){var Q=C.alternate,ne=Q!==null&&Q.memoizedState!==null||fn;Q=Qd;var ue=fn;if(Qd=K,(fn=ne)&&!ue)for(Ae=C;Ae!==null;)K=Ae,ne=K.child,K.tag===22&&K.memoizedState!==null?$_(C):ne!==null?(ne.return=K,Ae=ne):$_(C);for(;R!==null;)Ae=R,A_(R),R=R.sibling;Ae=C,Qd=Q,fn=ue}R_(l)}else(C.subtreeFlags&8772)!==0&&R!==null?(R.return=C,Ae=R):R_(l)}}function R_(l){for(;Ae!==null;){var u=Ae;if((u.flags&8772)!==0){var g=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:fn||eh(5,u);break;case 1:var x=u.stateNode;if(u.flags&4&&!fn)if(g===null)x.componentDidMount();else{var C=u.elementType===u.type?g.memoizedProps:Ps(u.type,g.memoizedProps);x.componentDidUpdate(C,g.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var R=u.updateQueue;R!==null&&MS(u,R,x);break;case 3:var K=u.updateQueue;if(K!==null){if(g=null,u.child!==null)switch(u.child.tag){case 5:g=u.child.stateNode;break;case 1:g=u.child.stateNode}MS(u,K,g)}break;case 5:var Q=u.stateNode;if(g===null&&u.flags&4){g=Q;var ne=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&g.focus();break;case"img":ne.src&&(g.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ue=u.alternate;if(ue!==null){var ve=ue.memoizedState;if(ve!==null){var je=ve.dehydrated;je!==null&&yo(je)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}fn||u.flags&512&&_g(u)}catch(xe){Lt(u,u.return,xe)}}if(u===l){Ae=null;break}if(g=u.sibling,g!==null){g.return=u.return,Ae=g;break}Ae=u.return}}function M_(l){for(;Ae!==null;){var u=Ae;if(u===l){Ae=null;break}var g=u.sibling;if(g!==null){g.return=u.return,Ae=g;break}Ae=u.return}}function $_(l){for(;Ae!==null;){var u=Ae;try{switch(u.tag){case 0:case 11:case 15:var g=u.return;try{eh(4,u)}catch(ne){Lt(u,g,ne)}break;case 1:var x=u.stateNode;if(typeof x.componentDidMount=="function"){var C=u.return;try{x.componentDidMount()}catch(ne){Lt(u,C,ne)}}var R=u.return;try{_g(u)}catch(ne){Lt(u,R,ne)}break;case 5:var K=u.return;try{_g(u)}catch(ne){Lt(u,K,ne)}}}catch(ne){Lt(u,u.return,ne)}if(u===l){Ae=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,Ae=Q;break}Ae=u.return}}var O8=Math.ceil,th=_.ReactCurrentDispatcher,Tg=_.ReactCurrentOwner,us=_.ReactCurrentBatchConfig,it=0,en=null,Bt=null,on=0,Gn=0,qi=Aa(0),Ht=0,Nc=null,To=0,nh=0,Ag=0,Sc=null,_n=null,Rg=0,Ui=1/0,Gr=null,sh=!1,Mg=null,Oa=null,rh=!1,Pa=null,ah=0,_c=0,$g=null,oh=-1,ih=0;function yn(){return(it&6)!==0?ft():oh!==-1?oh:oh=ft()}function Da(l){return(l.mode&1)===0?1:(it&2)!==0&&on!==0?on&-on:x8.transition!==null?(ih===0&&(ih=As()),ih):(l=rt,l!==0||(l=window.event,l=l===void 0?16:ud(l.type)),l)}function Bs(l,u,g,x){if(50<_c)throw _c=0,$g=null,Error(n(185));Be(l,g,x),((it&2)===0||l!==en)&&(l===en&&((it&2)===0&&(nh|=g),Ht===4&&Fa(l,on)),Cn(l,x),g===1&&it===0&&(u.mode&1)===0&&(Ui=ft()+500,Id&&Ma()))}function Cn(l,u){var g=l.callbackNode;pi(l,u);var x=Ar(l,l===en?on:0);if(x===0)g!==null&&Un(g),l.callbackNode=null,l.callbackPriority=0;else if(u=x&-x,l.callbackPriority!==u){if(g!=null&&Un(g),u===1)l.tag===0?w8(I_.bind(null,l)):vS(I_.bind(null,l)),p8(function(){(it&6)===0&&Ma()}),g=null;else{switch($r(x)){case 1:g=Cs;break;case 4:g=_r;break;case 16:g=Tt;break;case 536870912:g=ar;break;default:g=Tt}g=W_(g,L_.bind(null,l))}l.callbackPriority=u,l.callbackNode=g}}function L_(l,u){if(oh=-1,ih=0,(it&6)!==0)throw Error(n(327));var g=l.callbackNode;if(Wi()&&l.callbackNode!==g)return null;var x=Ar(l,l===en?on:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||u)u=lh(l,x);else{u=x;var C=it;it|=2;var R=P_();(en!==l||on!==u)&&(Gr=null,Ui=ft()+500,Ro(l,u));do try{F8();break}catch(Q){O_(l,Q)}while(!0);Zm(),th.current=R,it=C,Bt!==null?u=0:(en=null,on=0,u=Ht)}if(u!==0){if(u===2&&(C=Mr(l),C!==0&&(x=C,u=Lg(l,C))),u===1)throw g=Nc,Ro(l,0),Fa(l,x),Cn(l,ft()),g;if(u===6)Fa(l,x);else{if(C=l.current.alternate,(x&30)===0&&!P8(C)&&(u=lh(l,x),u===2&&(R=Mr(l),R!==0&&(x=R,u=Lg(l,R))),u===1))throw g=Nc,Ro(l,0),Fa(l,x),Cn(l,ft()),g;switch(l.finishedWork=C,l.finishedLanes=x,u){case 0:case 1:throw Error(n(345));case 2:Mo(l,_n,Gr);break;case 3:if(Fa(l,x),(x&130023424)===x&&(u=Rg+500-ft(),10<u)){if(Ar(l,0)!==0)break;if(C=l.suspendedLanes,(C&x)!==x){yn(),l.pingedLanes|=l.suspendedLanes&C;break}l.timeoutHandle=Bm(Mo.bind(null,l,_n,Gr),u);break}Mo(l,_n,Gr);break;case 4:if(Fa(l,x),(x&4194240)===x)break;for(u=l.eventTimes,C=-1;0<x;){var K=31-mn(x);R=1<<K,K=u[K],K>C&&(C=K),x&=~R}if(x=C,x=ft()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*O8(x/1960))-x,10<x){l.timeoutHandle=Bm(Mo.bind(null,l,_n,Gr),x);break}Mo(l,_n,Gr);break;case 5:Mo(l,_n,Gr);break;default:throw Error(n(329))}}}return Cn(l,ft()),l.callbackNode===g?L_.bind(null,l):null}function Lg(l,u){var g=Sc;return l.current.memoizedState.isDehydrated&&(Ro(l,u).flags|=256),l=lh(l,u),l!==2&&(u=_n,_n=g,u!==null&&Ig(u)),l}function Ig(l){_n===null?_n=l:_n.push.apply(_n,l)}function P8(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 C=g[x],R=C.getSnapshot;C=C.value;try{if(!Is(R(),C))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 Fa(l,u){for(u&=~Ag,u&=~nh,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var g=31-mn(u),x=1<<g;l[g]=-1,u&=~x}}function I_(l){if((it&6)!==0)throw Error(n(327));Wi();var u=Ar(l,0);if((u&1)===0)return Cn(l,ft()),null;var g=lh(l,u);if(l.tag!==0&&g===2){var x=Mr(l);x!==0&&(u=x,g=Lg(l,x))}if(g===1)throw g=Nc,Ro(l,0),Fa(l,u),Cn(l,ft()),g;if(g===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,Mo(l,_n,Gr),Cn(l,ft()),null}function Og(l,u){var g=it;it|=1;try{return l(u)}finally{it=g,it===0&&(Ui=ft()+500,Id&&Ma())}}function Ao(l){Pa!==null&&Pa.tag===0&&(it&6)===0&&Wi();var u=it;it|=1;var g=us.transition,x=rt;try{if(us.transition=null,rt=1,l)return l()}finally{rt=x,us.transition=g,it=u,(it&6)===0&&Ma()}}function Pg(){Gn=qi.current,kt(qi)}function Ro(l,u){l.finishedWork=null,l.finishedLanes=0;var g=l.timeoutHandle;if(g!==-1&&(l.timeoutHandle=-1,f8(g)),Bt!==null)for(g=Bt.return;g!==null;){var x=g;switch(Vm(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&$d();break;case 3:Di(),kt(jn),kt(un),ag();break;case 5:sg(x);break;case 4:Di();break;case 13:kt(Rt);break;case 19:kt(Rt);break;case 10:Jm(x.type._context);break;case 22:case 23:Pg()}g=g.return}if(en=l,Bt=l=Ba(l.current,null),on=Gn=u,Ht=0,Nc=null,Ag=nh=To=0,_n=Sc=null,_o!==null){for(u=0;u<_o.length;u++)if(g=_o[u],x=g.interleaved,x!==null){g.interleaved=null;var C=x.next,R=g.pending;if(R!==null){var K=R.next;R.next=C,x.next=K}g.pending=x}_o=null}return l}function O_(l,u){do{var g=Bt;try{if(Zm(),zd.current=Yd,Vd){for(var x=Mt.memoizedState;x!==null;){var C=x.queue;C!==null&&(C.pending=null),x=x.next}Vd=!1}if(Eo=0,Qt=Wt=Mt=null,wc=!1,xc=0,Tg.current=null,g===null||g.return===null){Ht=1,Nc=u,Bt=null;break}e:{var R=l,K=g.return,Q=g,ne=u;if(u=on,Q.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var ue=ne,ve=Q,je=ve.tag;if((ve.mode&1)===0&&(je===0||je===11||je===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=i_(K);if(Ee!==null){Ee.flags&=-257,l_(Ee,K,Q,R,u),Ee.mode&1&&o_(R,ue,u),u=Ee,ne=ue;var Re=u.updateQueue;if(Re===null){var $e=new Set;$e.add(ne),u.updateQueue=$e}else Re.add(ne);break e}else{if((u&1)===0){o_(R,ue,u),Dg();break e}ne=Error(n(426))}}else if(St&&Q.mode&1){var Dt=i_(K);if(Dt!==null){(Dt.flags&65536)===0&&(Dt.flags|=256),l_(Dt,K,Q,R,u),Ym(Fi(ne,Q));break e}}R=ne=Fi(ne,Q),Ht!==4&&(Ht=2),Sc===null?Sc=[R]:Sc.push(R),R=K;do{switch(R.tag){case 3:R.flags|=65536,u&=-u,R.lanes|=u;var oe=r_(R,ne,u);RS(R,oe);break e;case 1:Q=ne;var se=R.type,ie=R.stateNode;if((R.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(Oa===null||!Oa.has(ie)))){R.flags|=65536,u&=-u,R.lanes|=u;var Se=a_(R,Q,u);RS(R,Se);break e}}R=R.return}while(R!==null)}F_(g)}catch(Le){u=Le,Bt===g&&g!==null&&(Bt=g=g.return);continue}break}while(!0)}function P_(){var l=th.current;return th.current=Yd,l===null?Yd:l}function Dg(){(Ht===0||Ht===3||Ht===2)&&(Ht=4),en===null||(To&268435455)===0&&(nh&268435455)===0||Fa(en,on)}function lh(l,u){var g=it;it|=2;var x=P_();(en!==l||on!==u)&&(Gr=null,Ro(l,u));do try{D8();break}catch(C){O_(l,C)}while(!0);if(Zm(),it=g,th.current=x,Bt!==null)throw Error(n(261));return en=null,on=0,Ht}function D8(){for(;Bt!==null;)D_(Bt)}function F8(){for(;Bt!==null&&!sr();)D_(Bt)}function D_(l){var u=U_(l.alternate,l,Gn);l.memoizedProps=l.pendingProps,u===null?F_(l):Bt=u,Tg.current=null}function F_(l){var u=l;do{var g=u.alternate;if(l=u.return,(u.flags&32768)===0){if(g=R8(g,u,Gn),g!==null){Bt=g;return}}else{if(g=M8(g,u),g!==null){g.flags&=32767,Bt=g;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{Ht=6,Bt=null;return}}if(u=u.sibling,u!==null){Bt=u;return}Bt=u=l}while(u!==null);Ht===0&&(Ht=5)}function Mo(l,u,g){var x=rt,C=us.transition;try{us.transition=null,rt=1,B8(l,u,g,x)}finally{us.transition=C,rt=x}return null}function B8(l,u,g,x){do Wi();while(Pa!==null);if((it&6)!==0)throw Error(n(327));g=l.finishedWork;var C=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 R=g.lanes|g.childLanes;if(dt(l,R),l===en&&(Bt=en=null,on=0),(g.subtreeFlags&2064)===0&&(g.flags&2064)===0||rh||(rh=!0,W_(Tt,function(){return Wi(),null})),R=(g.flags&15990)!==0,(g.subtreeFlags&15990)!==0||R){R=us.transition,us.transition=null;var K=rt;rt=1;var Q=it;it|=4,Tg.current=null,L8(l,g),T_(g,l),o8(Dm),ka=!!Pm,Dm=Pm=null,l.current=g,I8(g),rr(),it=Q,rt=K,us.transition=R}else l.current=g;if(rh&&(rh=!1,Pa=l,ah=C),R=l.pendingLanes,R===0&&(Oa=null),Er(g.stateNode),Cn(l,ft()),u!==null)for(x=l.onRecoverableError,g=0;g<u.length;g++)C=u[g],x(C.value,{componentStack:C.stack,digest:C.digest});if(sh)throw sh=!1,l=Mg,Mg=null,l;return(ah&1)!==0&&l.tag!==0&&Wi(),R=l.pendingLanes,(R&1)!==0?l===$g?_c++:(_c=0,$g=l):_c=0,Ma(),null}function Wi(){if(Pa!==null){var l=$r(ah),u=us.transition,g=rt;try{if(us.transition=null,rt=16>l?16:l,Pa===null)var x=!1;else{if(l=Pa,Pa=null,ah=0,(it&6)!==0)throw Error(n(331));var C=it;for(it|=4,Ae=l.current;Ae!==null;){var R=Ae,K=R.child;if((Ae.flags&16)!==0){var Q=R.deletions;if(Q!==null){for(var ne=0;ne<Q.length;ne++){var ue=Q[ne];for(Ae=ue;Ae!==null;){var ve=Ae;switch(ve.tag){case 0:case 11:case 15:jc(8,ve,R)}var je=ve.child;if(je!==null)je.return=ve,Ae=je;else for(;Ae!==null;){ve=Ae;var xe=ve.sibling,Ee=ve.return;if(N_(ve),ve===ue){Ae=null;break}if(xe!==null){xe.return=Ee,Ae=xe;break}Ae=Ee}}}var Re=R.alternate;if(Re!==null){var $e=Re.child;if($e!==null){Re.child=null;do{var Dt=$e.sibling;$e.sibling=null,$e=Dt}while($e!==null)}}Ae=R}}if((R.subtreeFlags&2064)!==0&&K!==null)K.return=R,Ae=K;else e:for(;Ae!==null;){if(R=Ae,(R.flags&2048)!==0)switch(R.tag){case 0:case 11:case 15:jc(9,R,R.return)}var oe=R.sibling;if(oe!==null){oe.return=R.return,Ae=oe;break e}Ae=R.return}}var se=l.current;for(Ae=se;Ae!==null;){K=Ae;var ie=K.child;if((K.subtreeFlags&2064)!==0&&ie!==null)ie.return=K,Ae=ie;else e:for(K=se;Ae!==null;){if(Q=Ae,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:eh(9,Q)}}catch(Le){Lt(Q,Q.return,Le)}if(Q===K){Ae=null;break e}var Se=Q.sibling;if(Se!==null){Se.return=Q.return,Ae=Se;break e}Ae=Q.return}}if(it=C,Ma(),Jt&&typeof Jt.onPostCommitFiberRoot=="function")try{Jt.onPostCommitFiberRoot(Es,l)}catch{}x=!0}return x}finally{rt=g,us.transition=u}}return!1}function B_(l,u,g){u=Fi(g,u),u=r_(l,u,1),l=La(l,u,1),u=yn(),l!==null&&(Be(l,1,u),Cn(l,u))}function Lt(l,u,g){if(l.tag===3)B_(l,l,g);else for(;u!==null;){if(u.tag===3){B_(u,l,g);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Oa===null||!Oa.has(x))){l=Fi(g,l),l=a_(u,l,1),u=La(u,l,1),l=yn(),u!==null&&(Be(u,1,l),Cn(u,l));break}}u=u.return}}function q8(l,u,g){var x=l.pingCache;x!==null&&x.delete(u),u=yn(),l.pingedLanes|=l.suspendedLanes&g,en===l&&(on&g)===g&&(Ht===4||Ht===3&&(on&130023424)===on&&500>ft()-Rg?Ro(l,0):Ag|=g),Cn(l,u)}function q_(l,u){u===0&&((l.mode&1)===0?u=1:(u=Ts,Ts<<=1,(Ts&130023424)===0&&(Ts=4194304)));var g=yn();l=Hr(l,u),l!==null&&(Be(l,u,g),Cn(l,g))}function U8(l){var u=l.memoizedState,g=0;u!==null&&(g=u.retryLane),q_(l,g)}function W8(l,u){var g=0;switch(l.tag){case 13:var x=l.stateNode,C=l.memoizedState;C!==null&&(g=C.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(u),q_(l,g)}var U_;U_=function(l,u,g){if(l!==null)if(l.memoizedProps!==u.pendingProps||jn.current)Sn=!0;else{if((l.lanes&g)===0&&(u.flags&128)===0)return Sn=!1,A8(l,u,g);Sn=(l.flags&131072)!==0}else Sn=!1,St&&(u.flags&1048576)!==0&&bS(u,Pd,u.index);switch(u.lanes=0,u.tag){case 2:var x=u.type;Jd(l,u),l=u.pendingProps;var C=Ri(u,un.current);Pi(u,g),C=lg(null,u,x,l,C,g);var R=cg();return u.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,Nn(x)?(R=!0,Ld(u)):R=!1,u.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,tg(u),C.updater=Xd,u.stateNode=C,C._reactInternals=u,mg(u,x,l,g),u=xg(null,u,x,!0,R,g)):(u.tag=0,St&&R&&zm(u),gn(null,u,C,g),u=u.child),u;case 16:x=u.elementType;e:{switch(Jd(l,u),l=u.pendingProps,C=x._init,x=C(x._payload),u.type=x,C=u.tag=z8(x),l=Ps(x,l),C){case 0:u=wg(null,u,x,l,g);break e;case 1:u=p_(null,u,x,l,g);break e;case 11:u=c_(null,u,x,l,g);break e;case 14:u=u_(null,u,x,Ps(x.type,l),g);break e}throw Error(n(306,x,""))}return u;case 0:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ps(x,C),wg(l,u,x,C,g);case 1:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ps(x,C),p_(l,u,x,C,g);case 3:e:{if(m_(u),l===null)throw Error(n(387));x=u.pendingProps,R=u.memoizedState,C=R.element,AS(l,u),Wd(u,x,null,g);var K=u.memoizedState;if(x=K.element,R.isDehydrated)if(R={element:x,isDehydrated:!1,cache:K.cache,pendingSuspenseBoundaries:K.pendingSuspenseBoundaries,transitions:K.transitions},u.updateQueue.baseState=R,u.memoizedState=R,u.flags&256){C=Fi(Error(n(423)),u),u=g_(l,u,x,g,C);break e}else if(x!==C){C=Fi(Error(n(424)),u),u=g_(l,u,x,g,C);break e}else for(Vn=Ta(u.stateNode.containerInfo.firstChild),zn=u,St=!0,Os=null,g=ES(u,null,x,g),u.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(Li(),x===C){u=Vr(l,u,g);break e}gn(l,u,x,g)}u=u.child}return u;case 5:return $S(u),l===null&&Km(u),x=u.type,C=u.pendingProps,R=l!==null?l.memoizedProps:null,K=C.children,Fm(x,C)?K=null:R!==null&&Fm(x,R)&&(u.flags|=32),f_(l,u),gn(l,u,K,g),u.child;case 6:return l===null&&Km(u),null;case 13:return y_(l,u,g);case 4:return ng(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=Ii(u,null,x,g):gn(l,u,x,g),u.child;case 11:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ps(x,C),c_(l,u,x,C,g);case 7:return gn(l,u,u.pendingProps,g),u.child;case 8:return gn(l,u,u.pendingProps.children,g),u.child;case 12:return gn(l,u,u.pendingProps.children,g),u.child;case 10:e:{if(x=u.type._context,C=u.pendingProps,R=u.memoizedProps,K=C.value,yt(Bd,x._currentValue),x._currentValue=K,R!==null)if(Is(R.value,K)){if(R.children===C.children&&!jn.current){u=Vr(l,u,g);break e}}else for(R=u.child,R!==null&&(R.return=u);R!==null;){var Q=R.dependencies;if(Q!==null){K=R.child;for(var ne=Q.firstContext;ne!==null;){if(ne.context===x){if(R.tag===1){ne=zr(-1,g&-g),ne.tag=2;var ue=R.updateQueue;if(ue!==null){ue=ue.shared;var ve=ue.pending;ve===null?ne.next=ne:(ne.next=ve.next,ve.next=ne),ue.pending=ne}}R.lanes|=g,ne=R.alternate,ne!==null&&(ne.lanes|=g),Qm(R.return,g,u),Q.lanes|=g;break}ne=ne.next}}else if(R.tag===10)K=R.type===u.type?null:R.child;else if(R.tag===18){if(K=R.return,K===null)throw Error(n(341));K.lanes|=g,Q=K.alternate,Q!==null&&(Q.lanes|=g),Qm(K,g,u),K=R.sibling}else K=R.child;if(K!==null)K.return=R;else for(K=R;K!==null;){if(K===u){K=null;break}if(R=K.sibling,R!==null){R.return=K.return,K=R;break}K=K.return}R=K}gn(l,u,C.children,g),u=u.child}return u;case 9:return C=u.type,x=u.pendingProps.children,Pi(u,g),C=ls(C),x=x(C),u.flags|=1,gn(l,u,x,g),u.child;case 14:return x=u.type,C=Ps(x,u.pendingProps),C=Ps(x.type,C),u_(l,u,x,C,g);case 15:return d_(l,u,u.type,u.pendingProps,g);case 17:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ps(x,C),Jd(l,u),u.tag=1,Nn(x)?(l=!0,Ld(u)):l=!1,Pi(u,g),n_(u,x,C),mg(u,x,C,g),xg(null,u,x,!0,l,g);case 19:return x_(l,u,g);case 22:return h_(l,u,g)}throw Error(n(156,u.tag))};function W_(l,u){return ns(l,u)}function H8(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 ds(l,u,g,x){return new H8(l,u,g,x)}function Fg(l){return l=l.prototype,!(!l||!l.isReactComponent)}function z8(l){if(typeof l=="function")return Fg(l)?1:0;if(l!=null){if(l=l.$$typeof,l===A)return 11;if(l===D)return 14}return 2}function Ba(l,u){var g=l.alternate;return g===null?(g=ds(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 ch(l,u,g,x,C,R){var K=2;if(x=l,typeof l=="function")Fg(l)&&(K=1);else if(typeof l=="string")K=5;else e:switch(l){case M:return $o(g.children,C,R,u);case O:K=8,C|=8;break;case I:return l=ds(12,g,u,C|2),l.elementType=I,l.lanes=R,l;case q:return l=ds(13,g,u,C),l.elementType=q,l.lanes=R,l;case E:return l=ds(19,g,u,C),l.elementType=E,l.lanes=R,l;case z:return uh(g,C,R,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case F:K=10;break e;case L:K=9;break e;case A:K=11;break e;case D:K=14;break e;case P:K=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=ds(K,g,u,C),u.elementType=l,u.type=x,u.lanes=R,u}function $o(l,u,g,x){return l=ds(7,l,x,u),l.lanes=g,l}function uh(l,u,g,x){return l=ds(22,l,x,u),l.elementType=z,l.lanes=g,l.stateNode={isHidden:!1},l}function Bg(l,u,g){return l=ds(6,l,null,u),l.lanes=g,l}function qg(l,u,g){return u=ds(4,l.children!==null?l.children:[],l.key,u),u.lanes=g,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function V8(l,u,g,x,C){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=me(0),this.expirationTimes=me(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=me(0),this.identifierPrefix=x,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Ug(l,u,g,x,C,R,K,Q,ne){return l=new V8(l,u,g,Q,ne),u===1?(u=1,R===!0&&(u|=8)):u=0,R=ds(3,null,null,u),l.current=R,R.stateNode=l,R.memoizedState={element:x,isDehydrated:g,cache:null,transitions:null,pendingSuspenseBoundaries:null},tg(R),l}function G8(l,u,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:x==null?null:""+x,children:l,containerInfo:u,implementation:g}}function H_(l){if(!l)return Ra;l=l._reactInternals;e:{if(qn(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(Nn(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(Nn(g))return wS(l,g,u)}return u}function z_(l,u,g,x,C,R,K,Q,ne){return l=Ug(g,x,!0,l,C,R,K,Q,ne),l.context=H_(null),g=l.current,x=yn(),C=Da(g),R=zr(x,C),R.callback=u??null,La(g,R,C),l.current.lanes=C,Be(l,C,x),Cn(l,x),l}function dh(l,u,g,x){var C=u.current,R=yn(),K=Da(C);return g=H_(g),u.context===null?u.context=g:u.pendingContext=g,u=zr(R,K),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=La(C,u,K),l!==null&&(Bs(l,C,K,R),Ud(l,C,K)),K}function hh(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 V_(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var g=l.retryLane;l.retryLane=g!==0&&g<u?g:u}}function Wg(l,u){V_(l,u),(l=l.alternate)&&V_(l,u)}function K8(){return null}var G_=typeof reportError=="function"?reportError:function(l){console.error(l)};function Hg(l){this._internalRoot=l}fh.prototype.render=Hg.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));dh(l,u,null,null)},fh.prototype.unmount=Hg.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;Ao(function(){dh(null,l,null,null)}),u[Br]=null}};function fh(l){this._internalRoot=l}fh.prototype.unstable_scheduleHydration=function(l){if(l){var u=Lr();l={blockedOn:null,target:l,priority:u};for(var g=0;g<ir.length&&u!==0&&u<ir[g].priority;g++);ir.splice(g,0,l),g===0&&ld(l)}};function zg(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function ph(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function K_(){}function Y8(l,u,g,x,C){if(C){if(typeof x=="function"){var R=x;x=function(){var ue=hh(K);R.call(ue)}}var K=z_(u,x,l,0,null,!1,!1,"",K_);return l._reactRootContainer=K,l[Br]=K.current,uc(l.nodeType===8?l.parentNode:l),Ao(),K}for(;C=l.lastChild;)l.removeChild(C);if(typeof x=="function"){var Q=x;x=function(){var ue=hh(ne);Q.call(ue)}}var ne=Ug(l,0,!1,null,null,!1,!1,"",K_);return l._reactRootContainer=ne,l[Br]=ne.current,uc(l.nodeType===8?l.parentNode:l),Ao(function(){dh(u,ne,g,x)}),ne}function mh(l,u,g,x,C){var R=g._reactRootContainer;if(R){var K=R;if(typeof C=="function"){var Q=C;C=function(){var ne=hh(K);Q.call(ne)}}dh(u,K,l,C)}else K=Y8(g,u,l,C,x);return hh(K)}mo=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var g=or(u.pendingLanes);g!==0&&(At(u,g|1),Cn(u,ft()),(it&6)===0&&(Ui=ft()+500,Ma()))}break;case 13:Ao(function(){var x=Hr(l,1);if(x!==null){var C=yn();Bs(x,l,1,C)}}),Wg(l,1)}},wa=function(l){if(l.tag===13){var u=Hr(l,134217728);if(u!==null){var g=yn();Bs(u,l,134217728,g)}Wg(l,134217728)}},xa=function(l){if(l.tag===13){var u=Da(l),g=Hr(l,u);if(g!==null){var x=yn();Bs(g,l,u,x)}Wg(l,u)}},Lr=function(){return rt},Rs=function(l,u){var g=rt;try{return rt=l,u()}finally{rt=g}},Ct=function(l,u,g){switch(u){case"input":if(fe(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 C=Md(x);if(!C)throw Error(n(90));le(x),fe(x,C)}}}break;case"textarea":We(l,g);break;case"select":u=g.value,u!=null&&ge(l,!!g.multiple,u,!1)}},Ns=Og,es=Ao;var X8={usingClientEntryPoint:!1,Events:[fc,Ti,Md,js,tr,Og]},Cc={findFiberByHostInstance:ko,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Z8={bundleType:Cc.bundleType,version:Cc.version,rendererPackageName:Cc.rendererPackageName,rendererConfig:Cc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=nr(l),l===null?null:l.stateNode},findFiberByHostInstance:Cc.findFiberByHostInstance||K8,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 gh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gh.isDisabled&&gh.supportsFiber)try{Es=gh.inject(Z8),Jt=gh}catch{}}return En.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X8,En.createPortal=function(l,u){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zg(u))throw Error(n(200));return G8(l,u,null,g)},En.createRoot=function(l,u){if(!zg(l))throw Error(n(299));var g=!1,x="",C=G_;return u!=null&&(u.unstable_strictMode===!0&&(g=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(C=u.onRecoverableError)),u=Ug(l,1,!1,null,null,g,!1,x,C),l[Br]=u.current,uc(l.nodeType===8?l.parentNode:l),new Hg(u)},En.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=nr(u),l=l===null?null:l.stateNode,l},En.flushSync=function(l){return Ao(l)},En.hydrate=function(l,u,g){if(!ph(u))throw Error(n(200));return mh(null,l,u,!0,g)},En.hydrateRoot=function(l,u,g){if(!zg(l))throw Error(n(405));var x=g!=null&&g.hydratedSources||null,C=!1,R="",K=G_;if(g!=null&&(g.unstable_strictMode===!0&&(C=!0),g.identifierPrefix!==void 0&&(R=g.identifierPrefix),g.onRecoverableError!==void 0&&(K=g.onRecoverableError)),u=z_(u,null,l,1,g??null,C,!1,R,K),l[Br]=u.current,uc(l),x)for(l=0;l<x.length;l++)g=x[l],C=g._getVersion,C=C(g._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[g,C]:u.mutableSourceEagerHydrationData.push(g,C);return new fh(u)},En.render=function(l,u,g){if(!ph(u))throw Error(n(200));return mh(null,l,u,!1,g)},En.unmountComponentAtNode=function(l){if(!ph(l))throw Error(n(40));return l._reactRootContainer?(Ao(function(){mh(null,null,l,!1,function(){l._reactRootContainer=null,l[Br]=null})}),!0):!1},En.unstable_batchedUpdates=Og,En.unstable_renderSubtreeIntoContainer=function(l,u,g,x){if(!ph(g))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return mh(l,u,g,!1,x)},En.version="18.3.1-next-f1338f8080-20240426",En}var nC;function lO(){if(nC)return Kg.exports;nC=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(),Kg.exports=oB(),Kg.exports}var sC;function iB(){if(sC)return wh;sC=1;var e=lO();return wh.createRoot=e.createRoot,wh.hydrateRoot=e.hydrateRoot,wh}var lB=iB(),y=Ou();const pe=H1(y);function ln(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=ln(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Zg={exports:{}},Jg={},Qg={exports:{}},ey={};/**
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 rC;function cB(){if(rC)return ey;rC=1;var e=Ou();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,a=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function c(p,m){var w=m(),k=s({inst:{value:w,getSnapshot:m}}),b=k[0].inst,v=k[1];return o(function(){b.value=w,b.getSnapshot=m,d(b)&&v({inst:b})},[p,w,m]),a(function(){return d(b)&&v({inst:b}),p(function(){d(b)&&v({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 ey.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,ey}var aC;function uB(){return aC||(aC=1,Qg.exports=cB()),Qg.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 oC;function dB(){if(oC)return Jg;oC=1;var e=Ou(),t=uB();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,a=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Jg.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var k=o(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=c(function(){function N($){if(!j){if(j=!0,S=$,$=m($),w!==void 0&&b.hasValue){var M=b.value;if(w(M,$))return _=M}return _=$}if(M=_,s(S,$))return M;var O=m($);return w!==void 0&&w(M,O)?(S=$,M):(S=$,_=O)}var j=!1,S,_,T=p===void 0?null:p;return[function(){return N(f())},T===null?void 0:function(){return N(T())}]},[f,p,m,w]);var v=a(h,k[0],k[1]);return i(function(){b.hasValue=!0,b.value=v},[v]),d(v),v},Jg}var iC;function hB(){return iC||(iC=1,Zg.exports=dB()),Zg.exports}var fB=hB();const pB=H1(fB),mB={},lC=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(k=>k(t,w))}},a=()=>t,d={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(mB?"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,a,d);return d},gB=e=>e?lC(e):lC,{useDebugValue:yB}=pe,{useSyncExternalStoreWithSelector:wB}=pB,xB=e=>e;function cO(e,t=xB,n){const s=wB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yB(s),s}const cC=(e,t)=>{const n=gB(e),s=(a,o=t)=>cO(n,a,o);return Object.assign(s,n),s},vB=(e,t)=>e?cC(e,t):cC;function Yt(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,a]of e)if(!Object.is(a,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 bB={value:()=>{}};function dp(){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 Zh(n)}function Zh(e){this._=e}function kB(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",a=n.indexOf(".");if(a>=0&&(s=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}Zh.prototype=dp.prototype={constructor:Zh,on:function(e,t){var n=this._,s=kB(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=jB(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(a=(e=s[o]).type)n[a]=uC(n[a],e.name,t);else if(t==null)for(a in n)n[a]=uC(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Zh(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),s=0,a,o;s<a;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],s=0,a=o.length;s<a;++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],a=0,o=s.length;a<o;++a)s[a].value.apply(t,n)}};function jB(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function uC(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=bB,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var f0="http://www.w3.org/1999/xhtml";const dC={svg:"http://www.w3.org/2000/svg",xhtml:f0,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hp(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),dC.hasOwnProperty(t)?{space:dC[t],local:e}:e}function NB(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===f0&&t.documentElement.namespaceURI===f0?t.createElement(e):t.createElementNS(n,e)}}function SB(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function uO(e){var t=hp(e);return(t.local?SB:NB)(t)}function _B(){}function z1(e){return e==null?_B:function(){return this.querySelector(e)}}function CB(e){typeof e!="function"&&(e=z1(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=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 Jn(s,this._parents)}function EB(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function TB(){return[]}function dO(e){return e==null?TB:function(){return this.querySelectorAll(e)}}function AB(e){return function(){return EB(e.apply(this,arguments))}}function RB(e){typeof e=="function"?e=AB(e):e=dO(e);for(var t=this._groups,n=t.length,s=[],a=[],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)),a.push(d));return new Jn(s,a)}function hO(e){return function(){return this.matches(e)}}function fO(e){return function(t){return t.matches(e)}}var MB=Array.prototype.find;function $B(e){return function(){return MB.call(this.children,e)}}function LB(){return this.firstElementChild}function IB(e){return this.select(e==null?LB:$B(typeof e=="function"?e:fO(e)))}var OB=Array.prototype.filter;function PB(){return Array.from(this.children)}function DB(e){return function(){return OB.call(this.children,e)}}function FB(e){return this.selectAll(e==null?PB:DB(typeof e=="function"?e:fO(e)))}function BB(e){typeof e!="function"&&(e=hO(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Jn(s,this._parents)}function pO(e){return new Array(e.length)}function qB(){return new Jn(this._enter||this._groups.map(pO),this._parents)}function gf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}gf.prototype={constructor:gf,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 UB(e){return function(){return e}}function WB(e,t,n,s,a,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 gf(e,o[i]);for(;i<d;++i)(c=t[i])&&(a[i]=c)}function HB(e,t,n,s,a,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)?a[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 gf(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(m[c])===d&&(a[c]=d)}function zB(e){return e.__data__}function VB(e,t){if(!arguments.length)return Array.from(this,zB);var n=t?HB:WB,s=this._parents,a=this._groups;typeof e!="function"&&(e=UB(e));for(var o=a.length,i=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=s[h],p=a[h],m=p.length,w=GB(e.call(f,f&&f.__data__,h,s)),k=w.length,b=c[h]=new Array(k),v=i[h]=new Array(k),N=d[h]=new Array(m);n(f,p,b,v,N,w,t);for(var j=0,S=0,_,T;j<k;++j)if(_=b[j]){for(j>=S&&(S=j+1);!(T=v[S])&&++S<k;);_._next=T||null}}return i=new Jn(i,s),i._enter=c,i._exit=d,i}function GB(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function KB(){return new Jn(this._exit||this._groups.map(pO),this._parents)}function YB(e,t,n){var s=this.enter(),a=this,o=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?o.remove():n(o),s&&a?s.merge(a).order():a}function XB(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,a=n.length,o=s.length,i=Math.min(a,o),c=new Array(a),d=0;d<i;++d)for(var h=n[d],f=s[d],p=h.length,m=c[d]=new Array(p),w,k=0;k<p;++k)(w=h[k]||f[k])&&(m[k]=w);for(;d<a;++d)c[d]=n[d];return new Jn(c,this._parents)}function ZB(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],a=s.length-1,o=s[a],i;--a>=0;)(i=s[a])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function JB(e){e||(e=QB);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,a=new Array(s),o=0;o<s;++o){for(var i=n[o],c=i.length,d=a[o]=new Array(c),h,f=0;f<c;++f)(h=i[f])&&(d[f]=h);d.sort(t)}return new Jn(a,this._parents).order()}function QB(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function eq(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tq(){return Array.from(this)}function nq(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length;a<o;++a){var i=s[a];if(i)return i}return null}function sq(){let e=0;for(const t of this)++e;return e}function rq(){return!this.node()}function aq(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],o=0,i=a.length,c;o<i;++o)(c=a[o])&&e.call(c,c.__data__,o,a);return this}function oq(e){return function(){this.removeAttribute(e)}}function iq(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lq(e,t){return function(){this.setAttribute(e,t)}}function cq(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function uq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function dq(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 hq(e,t){var n=hp(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?iq:oq:typeof t=="function"?n.local?dq:uq:n.local?cq:lq)(n,t))}function mO(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function fq(e){return function(){this.style.removeProperty(e)}}function pq(e,t,n){return function(){this.style.setProperty(e,t,n)}}function mq(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function gq(e,t,n){return arguments.length>1?this.each((t==null?fq:typeof t=="function"?mq:pq)(e,t,n??"")):Nl(this.node(),e)}function Nl(e,t){return e.style.getPropertyValue(t)||mO(e).getComputedStyle(e,null).getPropertyValue(t)}function yq(e){return function(){delete this[e]}}function wq(e,t){return function(){this[e]=t}}function xq(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function vq(e,t){return arguments.length>1?this.each((t==null?yq:typeof t=="function"?xq:wq)(e,t)):this.node()[e]}function gO(e){return e.trim().split(/^|\s+/)}function V1(e){return e.classList||new yO(e)}function yO(e){this._node=e,this._names=gO(e.getAttribute("class")||"")}yO.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 wO(e,t){for(var n=V1(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function xO(e,t){for(var n=V1(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function bq(e){return function(){wO(this,e)}}function kq(e){return function(){xO(this,e)}}function jq(e,t){return function(){(t.apply(this,arguments)?wO:xO)(this,e)}}function Nq(e,t){var n=gO(e+"");if(arguments.length<2){for(var s=V1(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?jq:t?bq:kq)(n,t))}function Sq(){this.textContent=""}function _q(e){return function(){this.textContent=e}}function Cq(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Eq(e){return arguments.length?this.each(e==null?Sq:(typeof e=="function"?Cq:_q)(e)):this.node().textContent}function Tq(){this.innerHTML=""}function Aq(e){return function(){this.innerHTML=e}}function Rq(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Mq(e){return arguments.length?this.each(e==null?Tq:(typeof e=="function"?Rq:Aq)(e)):this.node().innerHTML}function $q(){this.nextSibling&&this.parentNode.appendChild(this)}function Lq(){return this.each($q)}function Iq(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Oq(){return this.each(Iq)}function Pq(e){var t=typeof e=="function"?e:uO(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Dq(){return null}function Fq(e,t){var n=typeof e=="function"?e:uO(e),s=t==null?Dq:typeof t=="function"?t:z1(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Bq(){var e=this.parentNode;e&&e.removeChild(this)}function qq(){return this.each(Bq)}function Uq(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wq(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hq(e){return this.select(e?Wq:Uq)}function zq(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vq(e){return function(t){e.call(this,t,this.__data__)}}function Gq(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 Kq(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,a=t.length,o;n<a;++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 Yq(e,t,n){return function(){var s=this.__on,a,o=Vq(t);if(s){for(var i=0,c=s.length;i<c;++i)if((a=s[i]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=o,a.options=n),a.value=t;return}}this.addEventListener(e.type,o,n),a={type:e.type,name:e.name,value:t,listener:o,options:n},s?s.push(a):this.__on=[a]}}function Xq(e,t,n){var s=Gq(e+""),a,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(a=0,f=c[d];a<o;++a)if((i=s[a]).type===f.type&&i.name===f.name)return f.value}return}for(c=t?Yq:Kq,a=0;a<o;++a)this.each(c(s[a],t,n));return this}function vO(e,t,n){var s=mO(e),a=s.CustomEvent;typeof a=="function"?a=new a(t,n):(a=s.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function Zq(e,t){return function(){return vO(this,e,t)}}function Jq(e,t){return function(){return vO(this,e,t.apply(this,arguments))}}function Qq(e,t){return this.each((typeof t=="function"?Jq:Zq)(e,t))}function*eU(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length,i;a<o;++a)(i=s[a])&&(yield i)}var bO=[null];function Jn(e,t){this._groups=e,this._parents=t}function Pu(){return new Jn([[document.documentElement]],bO)}function tU(){return this}Jn.prototype=Pu.prototype={constructor:Jn,select:CB,selectAll:RB,selectChild:IB,selectChildren:FB,filter:BB,data:VB,enter:qB,exit:KB,join:YB,merge:XB,selection:tU,order:ZB,sort:JB,call:eq,nodes:tq,node:nq,size:sq,empty:rq,each:aq,attr:hq,style:gq,property:vq,classed:Nq,text:Eq,html:Mq,raise:Lq,lower:Oq,append:Pq,insert:Fq,remove:qq,clone:Hq,datum:zq,on:Xq,dispatch:Qq,[Symbol.iterator]:eU};function gs(e){return typeof e=="string"?new Jn([[document.querySelector(e)]],[document.documentElement]):new Jn([[e]],bO)}function nU(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Hs(e,t){if(e=nU(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 a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const sU={passive:!1},uu={capture:!0,passive:!1};function ty(e){e.stopImmediatePropagation()}function pl(e){e.preventDefault(),e.stopImmediatePropagation()}function kO(e){var t=e.document.documentElement,n=gs(e).on("dragstart.drag",pl,uu);"onselectstart"in t?n.on("selectstart.drag",pl,uu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function jO(e,t){var n=e.document.documentElement,s=gs(e).on("dragstart.drag",null);t&&(s.on("click.drag",pl,uu),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 xh=e=>()=>e;function p0(e,{sourceEvent:t,subject:n,target:s,identifier:a,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:a,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}})}p0.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function rU(e){return!e.ctrlKey&&!e.button}function aU(){return this.parentNode}function oU(e,t){return t??{x:e.x,y:e.y}}function iU(){return navigator.maxTouchPoints||"ontouchstart"in this}function lU(){var e=rU,t=aU,n=oU,s=iU,a={},o=dp("start","drag","end"),i=0,c,d,h,f,p=0;function m(_){_.on("mousedown.drag",w).filter(s).on("touchstart.drag",v).on("touchmove.drag",N,sU).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(_,T){if(!(f||!e.call(this,_,T))){var $=S(this,t.call(this,_,T),_,T,"mouse");$&&(gs(_.view).on("mousemove.drag",k,uu).on("mouseup.drag",b,uu),kO(_.view),ty(_),h=!1,c=_.clientX,d=_.clientY,$("start",_))}}function k(_){if(pl(_),!h){var T=_.clientX-c,$=_.clientY-d;h=T*T+$*$>p}a.mouse("drag",_)}function b(_){gs(_.view).on("mousemove.drag mouseup.drag",null),jO(_.view,h),pl(_),a.mouse("end",_)}function v(_,T){if(e.call(this,_,T)){var $=_.changedTouches,M=t.call(this,_,T),O=$.length,I,F;for(I=0;I<O;++I)(F=S(this,M,_,T,$[I].identifier,$[I]))&&(ty(_),F("start",_,$[I]))}}function N(_){var T=_.changedTouches,$=T.length,M,O;for(M=0;M<$;++M)(O=a[T[M].identifier])&&(pl(_),O("drag",_,T[M]))}function j(_){var T=_.changedTouches,$=T.length,M,O;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<$;++M)(O=a[T[M].identifier])&&(ty(_),O("end",_,T[M]))}function S(_,T,$,M,O,I){var F=o.copy(),L=Hs(I||$,T),A,q,E;if((E=n.call(_,new p0("beforestart",{sourceEvent:$,target:m,identifier:O,active:i,x:L[0],y:L[1],dx:0,dy:0,dispatch:F}),M))!=null)return A=E.x-L[0]||0,q=E.y-L[1]||0,function D(P,z,G){var V=L,H;switch(P){case"start":a[O]=D,H=i++;break;case"end":delete a[O],--i;case"drag":L=Hs(G||z,T),H=i;break}F.call(P,_,new p0(P,{sourceEvent:z,subject:E,target:m,identifier:O,active:H,x:L[0]+A,y:L[1]+q,dx:L[0]-V[0],dy:L[1]-V[1],dispatch:F}),M)}}return m.filter=function(_){return arguments.length?(e=typeof _=="function"?_:xh(!!_),m):e},m.container=function(_){return arguments.length?(t=typeof _=="function"?_:xh(_),m):t},m.subject=function(_){return arguments.length?(n=typeof _=="function"?_:xh(_),m):n},m.touchable=function(_){return arguments.length?(s=typeof _=="function"?_:xh(!!_),m):s},m.on=function(){var _=o.on.apply(o,arguments);return _===o?m:_},m.clickDistance=function(_){return arguments.length?(p=(_=+_)*_,m):Math.sqrt(p)},m}function G1(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function NO(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function Du(){}var du=.7,yf=1/du,ml="\\s*([+-]?\\d+)\\s*",hu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",cU=/^#([0-9a-f]{3,8})$/,uU=new RegExp(`^rgb\\(${ml},${ml},${ml}\\)$`),dU=new RegExp(`^rgb\\(${xr},${xr},${xr}\\)$`),hU=new RegExp(`^rgba\\(${ml},${ml},${ml},${hu}\\)$`),fU=new RegExp(`^rgba\\(${xr},${xr},${xr},${hu}\\)$`),pU=new RegExp(`^hsl\\(${hu},${xr},${xr}\\)$`),mU=new RegExp(`^hsla\\(${hu},${xr},${xr},${hu}\\)$`),hC={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};G1(Du,fu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fC,formatHex:fC,formatHex8:gU,formatHsl:yU,formatRgb:pC,toString:pC});function fC(){return this.rgb().formatHex()}function gU(){return this.rgb().formatHex8()}function yU(){return SO(this).formatHsl()}function pC(){return this.rgb().formatRgb()}function fu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=cU.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?mC(t):n===3?new An(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?vh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?vh(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=uU.exec(e))?new An(t[1],t[2],t[3],1):(t=dU.exec(e))?new An(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hU.exec(e))?vh(t[1],t[2],t[3],t[4]):(t=fU.exec(e))?vh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=pU.exec(e))?wC(t[1],t[2]/100,t[3]/100,1):(t=mU.exec(e))?wC(t[1],t[2]/100,t[3]/100,t[4]):hC.hasOwnProperty(e)?mC(hC[e]):e==="transparent"?new An(NaN,NaN,NaN,0):null}function mC(e){return new An(e>>16&255,e>>8&255,e&255,1)}function vh(e,t,n,s){return s<=0&&(e=t=n=NaN),new An(e,t,n,s)}function wU(e){return e instanceof Du||(e=fu(e)),e?(e=e.rgb(),new An(e.r,e.g,e.b,e.opacity)):new An}function m0(e,t,n,s){return arguments.length===1?wU(e):new An(e,t,n,s??1)}function An(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}G1(An,m0,NO(Du,{brighter(e){return e=e==null?yf:Math.pow(yf,e),new An(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?du:Math.pow(du,e),new An(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new An(Vo(this.r),Vo(this.g),Vo(this.b),wf(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:gC,formatHex:gC,formatHex8:xU,formatRgb:yC,toString:yC}));function gC(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}`}function xU(){return`#${Uo(this.r)}${Uo(this.g)}${Uo(this.b)}${Uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function yC(){const e=wf(this.opacity);return`${e===1?"rgb(":"rgba("}${Vo(this.r)}, ${Vo(this.g)}, ${Vo(this.b)}${e===1?")":`, ${e})`}`}function wf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Vo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Uo(e){return e=Vo(e),(e<16?"0":"")+e.toString(16)}function wC(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new zs(e,t,n,s)}function SO(e){if(e instanceof zs)return new zs(e.h,e.s,e.l,e.opacity);if(e instanceof Du||(e=fu(e)),!e)return new zs;if(e instanceof zs)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,a=Math.min(t,n,s),o=Math.max(t,n,s),i=NaN,c=o-a,d=(o+a)/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+a:2-o-a,i*=60):c=d>0&&d<1?0:i,new zs(i,c,d,e.opacity)}function vU(e,t,n,s){return arguments.length===1?SO(e):new zs(e,t,n,s??1)}function zs(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}G1(zs,vU,NO(Du,{brighter(e){return e=e==null?yf:Math.pow(yf,e),new zs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?du:Math.pow(du,e),new zs(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,a=2*n-s;return new An(ny(e>=240?e-240:e+120,a,s),ny(e,a,s),ny(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new zs(xC(this.h),bh(this.s),bh(this.l),wf(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=wf(this.opacity);return`${e===1?"hsl(":"hsla("}${xC(this.h)}, ${bh(this.s)*100}%, ${bh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function xC(e){return e=(e||0)%360,e<0?e+360:e}function bh(e){return Math.max(0,Math.min(1,e||0))}function ny(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 _O=e=>()=>e;function bU(e,t){return function(n){return e+n*t}}function kU(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 jU(e){return(e=+e)==1?CO:function(t,n){return n-t?kU(t,n,e):_O(isNaN(t)?n:t)}}function CO(e,t){var n=t-e;return n?bU(e,n):_O(isNaN(e)?t:e)}const vC=(function e(t){var n=jU(t);function s(a,o){var i=n((a=m0(a)).r,(o=m0(o)).r),c=n(a.g,o.g),d=n(a.b,o.b),h=CO(a.opacity,o.opacity);return function(f){return a.r=i(f),a.g=c(f),a.b=d(f),a.opacity=h(f),a+""}}return s.gamma=e,s})(1);function Ga(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var g0=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,sy=new RegExp(g0.source,"g");function NU(e){return function(){return e}}function SU(e){return function(t){return e(t)+""}}function _U(e,t){var n=g0.lastIndex=sy.lastIndex=0,s,a,o,i=-1,c=[],d=[];for(e=e+"",t=t+"";(s=g0.exec(e))&&(a=sy.exec(t));)(o=a.index)>n&&(o=t.slice(n,o),c[i]?c[i]+=o:c[++i]=o),(s=s[0])===(a=a[0])?c[i]?c[i]+=a:c[++i]=a:(c[++i]=null,d.push({i,x:Ga(s,a)})),n=sy.lastIndex;return n<t.length&&(o=t.slice(n),c[i]?c[i]+=o:c[++i]=o),c.length<2?d[0]?SU(d[0].x):NU(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 bC=180/Math.PI,y0={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function EO(e,t,n,s,a,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:a,translateY:o,rotate:Math.atan2(t,e)*bC,skewX:Math.atan(d)*bC,scaleX:i,scaleY:c}}var kh;function CU(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?y0:EO(t.a,t.b,t.c,t.d,t.e,t.f)}function EU(e){return e==null||(kh||(kh=document.createElementNS("http://www.w3.org/2000/svg","g")),kh.setAttribute("transform",e),!(e=kh.transform.baseVal.consolidate()))?y0:(e=e.matrix,EO(e.a,e.b,e.c,e.d,e.e,e.f))}function TO(e,t,n,s){function a(h){return h.length?h.pop()+" ":""}function o(h,f,p,m,w,k){if(h!==p||f!==m){var b=w.push("translate(",null,t,null,n);k.push({i:b-4,x:Ga(h,p)},{i:b-2,x:Ga(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(a(p)+"rotate(",null,s)-2,x:Ga(h,f)})):f&&p.push(a(p)+"rotate("+f+s)}function c(h,f,p,m){h!==f?m.push({i:p.push(a(p)+"skewX(",null,s)-2,x:Ga(h,f)}):f&&p.push(a(p)+"skewX("+f+s)}function d(h,f,p,m,w,k){if(h!==p||f!==m){var b=w.push(a(w)+"scale(",null,",",null,")");k.push({i:b-4,x:Ga(h,p)},{i:b-2,x:Ga(f,m)})}else(p!==1||m!==1)&&w.push(a(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 k=-1,b=m.length,v;++k<b;)p[(v=m[k]).i]=v.x(w);return p.join("")}}}var TU=TO(CU,"px, ","px)","deg)"),AU=TO(EU,", ",")",")"),RU=1e-12;function kC(e){return((e=Math.exp(e))+1/e)/2}function MU(e){return((e=Math.exp(e))-1/e)/2}function $U(e){return((e=Math.exp(2*e))-1)/(e+1)}const LU=(function e(t,n,s){function a(o,i){var c=o[0],d=o[1],h=o[2],f=i[0],p=i[1],m=i[2],w=f-c,k=p-d,b=w*w+k*k,v,N;if(b<RU)N=Math.log(m/h)/t,v=function(M){return[c+M*w,d+M*k,h*Math.exp(t*M*N)]};else{var j=Math.sqrt(b),S=(m*m-h*h+s*b)/(2*h*n*j),_=(m*m-h*h-s*b)/(2*m*n*j),T=Math.log(Math.sqrt(S*S+1)-S),$=Math.log(Math.sqrt(_*_+1)-_);N=($-T)/t,v=function(M){var O=M*N,I=kC(T),F=h/(n*j)*(I*$U(t*O+T)-MU(T));return[c+F*w,d+F*k,h*I/kC(t*O+T)]}}return v.duration=N*1e3*t/Math.SQRT2,v}return a.rho=function(o){var i=Math.max(.001,+o),c=i*i,d=c*c;return e(i,c,d)},a})(Math.SQRT2,2,4);var Sl=0,Wc=0,Tc=0,AO=1e3,xf,Hc,vf=0,ei=0,fp=0,pu=typeof performance=="object"&&performance.now?performance:Date,RO=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function K1(){return ei||(RO(IU),ei=pu.now()+fp)}function IU(){ei=0}function bf(){this._call=this._time=this._next=null}bf.prototype=MO.prototype={constructor:bf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?K1():+n)+(t==null?0:+t),!this._next&&Hc!==this&&(Hc?Hc._next=this:xf=this,Hc=this),this._call=e,this._time=n,w0()},stop:function(){this._call&&(this._call=null,this._time=1/0,w0())}};function MO(e,t,n){var s=new bf;return s.restart(e,t,n),s}function OU(){K1(),++Sl;for(var e=xf,t;e;)(t=ei-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Sl}function jC(){ei=(vf=pu.now())+fp,Sl=Wc=0;try{OU()}finally{Sl=0,DU(),ei=0}}function PU(){var e=pu.now(),t=e-vf;t>AO&&(fp-=t,vf=e)}function DU(){for(var e,t=xf,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:xf=n);Hc=e,w0(s)}function w0(e){if(!Sl){Wc&&(Wc=clearTimeout(Wc));var t=e-ei;t>24?(e<1/0&&(Wc=setTimeout(jC,e-pu.now()-fp)),Tc&&(Tc=clearInterval(Tc))):(Tc||(vf=pu.now(),Tc=setInterval(PU,AO)),Sl=1,RO(jC))}}function NC(e,t,n){var s=new bf;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var FU=dp("start","end","cancel","interrupt"),BU=[],$O=0,SC=1,x0=2,Jh=3,_C=4,v0=5,Qh=6;function pp(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;qU(e,n,{name:t,index:s,group:a,on:FU,tween:BU,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:$O})}function Y1(e,t){var n=Qs(e,t);if(n.state>$O)throw new Error("too late; already scheduled");return n}function jr(e,t){var n=Qs(e,t);if(n.state>Jh)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 qU(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=MO(o,0,n.time);function o(h){n.state=SC,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!==SC)return d();for(f in s)if(w=s[f],w.name===n.name){if(w.state===Jh)return NC(i);w.state===_C?(w.state=Qh,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=Qh,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(NC(function(){n.state===Jh&&(n.state=_C,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=x0,n.on.call("start",e,e.__data__,n.index,n.group),n.state===x0){for(n.state=Jh,a=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))&&(a[++p]=w);a.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=v0,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===v0&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Qh,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function ef(e,t){var n=e.__transition,s,a,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){o=!1;continue}a=s.state>x0&&s.state<v0,s.state=Qh,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function UU(e){return this.each(function(){ef(this,e)})}function WU(e,t){var n,s;return function(){var a=jr(this,e),o=a.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}}a.tween=s}}function HU(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=jr(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var c={name:t,value:n},d=0,h=a.length;d<h;++d)if(a[d].name===t){a[d]=c;break}d===h&&a.push(c)}o.tween=a}}function zU(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Qs(this.node(),n).tween,a=0,o=s.length,i;a<o;++a)if((i=s[a]).name===e)return i.value;return null}return this.each((t==null?WU:HU)(n,e,t))}function X1(e,t,n){var s=e._id;return e.each(function(){var a=jr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Qs(a,s).value[t]}}function LO(e,t){var n;return(typeof t=="number"?Ga:t instanceof fu?vC:(n=fu(t))?(t=n,vC):_U)(e,t)}function VU(e){return function(){this.removeAttribute(e)}}function GU(e){return function(){this.removeAttributeNS(e.space,e.local)}}function KU(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttribute(e);return i===a?null:i===s?o:o=t(s=i,n)}}function YU(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===a?null:i===s?o:o=t(s=i,n)}}function XU(e,t,n){var s,a,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===a?o:(a=d,o=t(s=i,c)))}}function ZU(e,t,n){var s,a,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===a?o:(a=d,o=t(s=i,c)))}}function JU(e,t){var n=hp(e),s=n==="transform"?AU:LO;return this.attrTween(e,typeof t=="function"?(n.local?ZU:XU)(n,s,X1(this,"attr."+e,t)):t==null?(n.local?GU:VU)(n):(n.local?YU:KU)(n,s,t))}function QU(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function eW(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function tW(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&eW(e,o)),n}return a._value=t,a}function nW(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&QU(e,o)),n}return a._value=t,a}function sW(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=hp(e);return this.tween(n,(s.local?tW:nW)(s,t))}function rW(e,t){return function(){Y1(this,e).delay=+t.apply(this,arguments)}}function aW(e,t){return t=+t,function(){Y1(this,e).delay=t}}function oW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rW:aW)(t,e)):Qs(this.node(),t).delay}function iW(e,t){return function(){jr(this,e).duration=+t.apply(this,arguments)}}function lW(e,t){return t=+t,function(){jr(this,e).duration=t}}function cW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?iW:lW)(t,e)):Qs(this.node(),t).duration}function uW(e,t){if(typeof t!="function")throw new Error;return function(){jr(this,e).ease=t}}function dW(e){var t=this._id;return arguments.length?this.each(uW(t,e)):Qs(this.node(),t).ease}function hW(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;jr(this,e).ease=n}}function fW(e){if(typeof e!="function")throw new Error;return this.each(hW(this._id,e))}function pW(e){typeof e!="function"&&(e=hO(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new oa(s,this._parents,this._name,this._id)}function mW(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,a=n.length,o=Math.min(s,a),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 oa(i,this._parents,this._name,this._id)}function gW(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 yW(e,t,n){var s,a,o=gW(t)?Y1:jr;return function(){var i=o(this,e),c=i.on;c!==s&&(a=(s=c).copy()).on(t,n),i.on=a}}function wW(e,t){var n=this._id;return arguments.length<2?Qs(this.node(),n).on.on(e):this.each(yW(n,e,t))}function xW(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vW(){return this.on("end.remove",xW(this._id))}function bW(e){var t=this._name,n=this._id;typeof e!="function"&&(e=z1(e));for(var s=this._groups,a=s.length,o=new Array(a),i=0;i<a;++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,pp(h[m],t,n,m,h,Qs(f,n)));return new oa(o,this._parents,t,n)}function kW(e){var t=this._name,n=this._id;typeof e!="function"&&(e=dO(e));for(var s=this._groups,a=s.length,o=[],i=[],c=0;c<a;++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,k=Qs(f,n),b=0,v=m.length;b<v;++b)(w=m[b])&&pp(w,t,n,b,m,k);o.push(m),i.push(f)}return new oa(o,i,t,n)}var jW=Pu.prototype.constructor;function NW(){return new jW(this._groups,this._parents)}function SW(e,t){var n,s,a;return function(){var o=Nl(this,e),i=(this.style.removeProperty(e),Nl(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function IO(e){return function(){this.style.removeProperty(e)}}function _W(e,t,n){var s,a=n+"",o;return function(){var i=Nl(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function CW(e,t,n){var s,a,o;return function(){var i=Nl(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Nl(this,e))),i===d?null:i===s&&d===a?o:(a=d,o=t(s=i,c))}}function EW(e,t){var n,s,a,o="style."+t,i="end."+o,c;return function(){var d=jr(this,e),h=d.on,f=d.value[o]==null?c||(c=IO(t)):void 0;(h!==n||a!==f)&&(s=(n=h).copy()).on(i,a=f),d.on=s}}function TW(e,t,n){var s=(e+="")=="transform"?TU:LO;return t==null?this.styleTween(e,SW(e,s)).on("end.style."+e,IO(e)):typeof t=="function"?this.styleTween(e,CW(e,s,X1(this,"style."+e,t))).each(EW(this._id,e)):this.styleTween(e,_W(e,s,t),n).on("end.style."+e,null)}function AW(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function RW(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&AW(e,i,n)),s}return o._value=t,o}function MW(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,RW(e,t,n??""))}function $W(e){return function(){this.textContent=e}}function LW(e){return function(){var t=e(this);this.textContent=t??""}}function IW(e){return this.tween("text",typeof e=="function"?LW(X1(this,"text",e)):$W(e==null?"":e+""))}function OW(e){return function(t){this.textContent=e.call(this,t)}}function PW(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&OW(a)),t}return s._value=e,s}function DW(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,PW(e))}function FW(){for(var e=this._name,t=this._id,n=OO(),s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)if(d=i[h]){var f=Qs(d,t);pp(d,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new oa(s,this._parents,e,n)}function BW(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(o,i){var c={value:i},d={value:function(){--a===0&&o()}};n.each(function(){var h=jr(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}),a===0&&o()})}var qW=0;function oa(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function OO(){return++qW}var Kr=Pu.prototype;oa.prototype={constructor:oa,select:bW,selectAll:kW,selectChild:Kr.selectChild,selectChildren:Kr.selectChildren,filter:pW,merge:mW,selection:NW,transition:FW,call:Kr.call,nodes:Kr.nodes,node:Kr.node,size:Kr.size,empty:Kr.empty,each:Kr.each,on:wW,attr:JU,attrTween:sW,style:TW,styleTween:MW,text:IW,textTween:DW,remove:vW,tween:zU,delay:oW,duration:cW,ease:dW,easeVarying:fW,end:BW,[Symbol.iterator]:Kr[Symbol.iterator]};function UW(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var WW={time:null,delay:0,duration:250,ease:UW};function HW(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 zW(e){var t,n;e instanceof oa?(t=e._id,e=e._name):(t=OO(),(n=WW).time=K1(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&pp(d,e,t,h,i,n||HW(d,t));return new oa(s,this._parents,e,t)}Pu.prototype.interrupt=UU;Pu.prototype.transition=zW;const jh=e=>()=>e;function VW(e,{sourceEvent:t,target:n,transform:s,dispatch:a}){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:a}})}function na(e,t,n){this.k=e,this.x=t,this.y=n}na.prototype={constructor:na,scale:function(e){return e===1?this:new na(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new na(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 sa=new na(1,0,0);na.prototype;function ry(e){e.stopImmediatePropagation()}function Ac(e){e.preventDefault(),e.stopImmediatePropagation()}function GW(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function KW(){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 CC(){return this.__zoom||sa}function YW(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XW(){return navigator.maxTouchPoints||"ontouchstart"in this}function ZW(e,t,n){var s=e.invertX(t[0][0])-n[0][0],a=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(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function PO(){var e=GW,t=KW,n=ZW,s=YW,a=XW,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,d=LU,h=dp("start","zoom","end"),f,p,m,w=500,k=150,b=0,v=10;function N(E){E.property("__zoom",CC).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",F).filter(a).on("touchstart.zoom",L).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(E,D,P,z){var G=E.selection?E.selection():E;G.property("__zoom",CC),E!==G?T(E,D,P,z):G.interrupt().each(function(){$(this,arguments).event(z).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},N.scaleBy=function(E,D,P,z){N.scaleTo(E,function(){var G=this.__zoom.k,V=typeof D=="function"?D.apply(this,arguments):D;return G*V},P,z)},N.scaleTo=function(E,D,P,z){N.transform(E,function(){var G=t.apply(this,arguments),V=this.__zoom,H=P==null?_(G):typeof P=="function"?P.apply(this,arguments):P,B=V.invert(H),W=typeof D=="function"?D.apply(this,arguments):D;return n(S(j(V,W),H,B),G,i)},P,z)},N.translateBy=function(E,D,P,z){N.transform(E,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,z)},N.translateTo=function(E,D,P,z,G){N.transform(E,function(){var V=t.apply(this,arguments),H=this.__zoom,B=z==null?_(V):typeof z=="function"?z.apply(this,arguments):z;return n(sa.translate(B[0],B[1]).scale(H.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof P=="function"?-P.apply(this,arguments):-P),V,i)},z,G)};function j(E,D){return D=Math.max(o[0],Math.min(o[1],D)),D===E.k?E:new na(D,E.x,E.y)}function S(E,D,P){var z=D[0]-P[0]*E.k,G=D[1]-P[1]*E.k;return z===E.x&&G===E.y?E:new na(E.k,z,G)}function _(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function T(E,D,P,z){E.on("start.zoom",function(){$(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(z).end()}).tween("zoom",function(){var G=this,V=arguments,H=$(G,V).event(z),B=t.apply(G,V),W=P==null?_(B):typeof P=="function"?P.apply(G,V):P,ee=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),U=G.__zoom,Y=typeof D=="function"?D.apply(G,V):D,X=d(U.invert(W).concat(ee/U.k),Y.invert(W).concat(ee/Y.k));return function(Z){if(Z===1)Z=Y;else{var J=X(Z),te=ee/J[2];Z=new na(te,W[0]-J[0]*te,W[1]-J[1]*te)}H.zoom(null,Z)}})}function $(E,D,P){return!P&&E.__zooming||new M(E,D)}function M(E,D){this.that=E,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(E,D),this.taps=0}M.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,D){return this.mouse&&E!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&E!=="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(E){var D=gs(this.that).datum();h.call(E,this.that,new VW(E,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),D)}};function O(E,...D){if(!e.apply(this,arguments))return;var P=$(this,D).event(E),z=this.__zoom,G=Math.max(o[0],Math.min(o[1],z.k*Math.pow(2,s.apply(this,arguments)))),V=Hs(E);if(P.wheel)(P.mouse[0][0]!==V[0]||P.mouse[0][1]!==V[1])&&(P.mouse[1]=z.invert(P.mouse[0]=V)),clearTimeout(P.wheel);else{if(z.k===G)return;P.mouse=[V,z.invert(V)],ef(this),P.start()}Ac(E),P.wheel=setTimeout(H,k),P.zoom("mouse",n(S(j(z,G),P.mouse[0],P.mouse[1]),P.extent,i));function H(){P.wheel=null,P.end()}}function I(E,...D){if(m||!e.apply(this,arguments))return;var P=E.currentTarget,z=$(this,D,!0).event(E),G=gs(E.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",ee,!0),V=Hs(E,P),H=E.clientX,B=E.clientY;kO(E.view),ry(E),z.mouse=[V,this.__zoom.invert(V)],ef(this),z.start();function W(U){if(Ac(U),!z.moved){var Y=U.clientX-H,X=U.clientY-B;z.moved=Y*Y+X*X>b}z.event(U).zoom("mouse",n(S(z.that.__zoom,z.mouse[0]=Hs(U,P),z.mouse[1]),z.extent,i))}function ee(U){G.on("mousemove.zoom mouseup.zoom",null),jO(U.view,z.moved),Ac(U),z.event(U).end()}}function F(E,...D){if(e.apply(this,arguments)){var P=this.__zoom,z=Hs(E.changedTouches?E.changedTouches[0]:E,this),G=P.invert(z),V=P.k*(E.shiftKey?.5:2),H=n(S(j(P,V),z,G),t.apply(this,D),i);Ac(E),c>0?gs(this).transition().duration(c).call(T,H,z,E):gs(this).call(N.transform,H,z,E)}}function L(E,...D){if(e.apply(this,arguments)){var P=E.touches,z=P.length,G=$(this,D,E.changedTouches.length===z).event(E),V,H,B,W;for(ry(E),H=0;H<z;++H)B=P[H],W=Hs(B,this),W=[W,this.__zoom.invert(W),B.identifier],G.touch0?!G.touch1&&G.touch0[2]!==W[2]&&(G.touch1=W,G.taps=0):(G.touch0=W,V=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),V&&(G.taps<2&&(p=W[0],f=setTimeout(function(){f=null},w)),ef(this),G.start())}}function A(E,...D){if(this.__zooming){var P=$(this,D).event(E),z=E.changedTouches,G=z.length,V,H,B,W;for(Ac(E),V=0;V<G;++V)H=z[V],B=Hs(H,this),P.touch0&&P.touch0[2]===H.identifier?P.touch0[0]=B:P.touch1&&P.touch1[2]===H.identifier&&(P.touch1[0]=B);if(H=P.that.__zoom,P.touch1){var ee=P.touch0[0],U=P.touch0[1],Y=P.touch1[0],X=P.touch1[1],Z=(Z=Y[0]-ee[0])*Z+(Z=Y[1]-ee[1])*Z,J=(J=X[0]-U[0])*J+(J=X[1]-U[1])*J;H=j(H,Math.sqrt(Z/J)),B=[(ee[0]+Y[0])/2,(ee[1]+Y[1])/2],W=[(U[0]+X[0])/2,(U[1]+X[1])/2]}else if(P.touch0)B=P.touch0[0],W=P.touch0[1];else return;P.zoom("touch",n(S(H,B,W),P.extent,i))}}function q(E,...D){if(this.__zooming){var P=$(this,D).event(E),z=E.changedTouches,G=z.length,V,H;for(ry(E),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),V=0;V<G;++V)H=z[V],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=Hs(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<v)){var B=gs(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return N.wheelDelta=function(E){return arguments.length?(s=typeof E=="function"?E:jh(+E),N):s},N.filter=function(E){return arguments.length?(e=typeof E=="function"?E:jh(!!E),N):e},N.touchable=function(E){return arguments.length?(a=typeof E=="function"?E:jh(!!E),N):a},N.extent=function(E){return arguments.length?(t=typeof E=="function"?E:jh([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),N):t},N.scaleExtent=function(E){return arguments.length?(o[0]=+E[0],o[1]=+E[1],N):[o[0],o[1]]},N.translateExtent=function(E){return arguments.length?(i[0][0]=+E[0][0],i[1][0]=+E[1][0],i[0][1]=+E[0][1],i[1][1]=+E[1][1],N):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},N.constrain=function(E){return arguments.length?(n=E,N):n},N.duration=function(E){return arguments.length?(c=+E,N):c},N.interpolate=function(E){return arguments.length?(d=E,N):d},N.on=function(){var E=h.on.apply(h,arguments);return E===h?N:E},N.clickDistance=function(E){return arguments.length?(b=(E=+E)*E,N):Math.sqrt(b)},N.tapDistance=function(E){return arguments.length?(v=+E,N):v},N}var xt=lO();const mp=y.createContext(null),JW=mp.Provider,ia={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.`},DO=ia.error001();function lt(e,t){const n=y.useContext(mp);if(n===null)throw new Error(DO);return cO(n,e,t)}const Ft=()=>{const e=y.useContext(mp);if(e===null)throw new Error(DO);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},QW=e=>e.userSelectionActive?"none":"all";function Z1({position:e,children:t,className:n,style:s,...a}){const o=lt(QW),i=`${e}`.split("-");return pe.createElement("div",{className:ln(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function e7({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:pe.createElement(Z1,{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"},pe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const t7=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!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}),k=ln(["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:pe.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:k,visibility:m.width?"visible":"hidden",...f},a&&pe.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}),pe.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:p,style:s},n),d)};var n7=y.memo(t7);const J1=e=>({width:e.offsetWidth,height:e.offsetHeight}),_l=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Q1=(e={x:0,y:0},t)=>({x:_l(e.x,t[0][0],t[1][0]),y:_l(e.y,t[0][1],t[1][1])}),EC=(e,t,n)=>e<t?_l(Math.abs(e-t),1,50)/50:e>n?-_l(Math.abs(e-n),1,50)/50:0,FO=(e,t)=>{const n=EC(e.x,35,t.width-35)*20,s=EC(e.y,35,t.height-35)*20;return[n,s]},BO=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},qO=(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)}),mu=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),UO=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),TC=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),s7=(e,t)=>UO(qO(mu(e),mu(t))),b0=(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)},r7=e=>ys(e.width)&&ys(e.height)&&ys(e.x)&&ys(e.y),ys=e=>!isNaN(e)&&isFinite(e),It=Symbol.for("internals"),WO=["Enter"," ","Escape"],a7=(e,t)=>{},o7=e=>"nativeEvent"in e;function k0(e){var a,o;const t=o7(e)?e.nativeEvent:e,n=((o=(a=t.composedPath)==null?void 0:a.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 HO=e=>"clientX"in e,to=(e,t)=>{var o,i;const n=HO(e),s=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},kf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Fu=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w=20})=>pe.createElement(pe.Fragment,null,pe.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:m}),w&&pe.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),a&&ys(n)&&ys(s)?pe.createElement(n7,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Fu.displayName="BaseEdge";function Rc(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function zO({sourceX:e,sourceY:t,targetX:n,targetY:s}){const a=Math.abs(n-e)/2,o=n<e?n+a:n-a,i=Math.abs(s-t)/2,c=s<t?s+i:s-i;return[o,c,a,i]}function VO({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:o,targetControlX:i,targetControlY:c}){const d=e*.125+a*.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 ti;(function(e){e.Strict="strict",e.Loose="loose"})(ti||(ti={}));var Wo;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wo||(Wo={}));var gu;(function(e){e.Partial="partial",e.Full="full"})(gu||(gu={}));var Ya;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ya||(Ya={}));var jf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(jf||(jf={}));var De;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(De||(De={}));function AC({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===De.Left||e===De.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function GO({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top}){const[i,c]=AC({pos:n,x1:e,y1:t,x2:s,y2:a}),[d,h]=AC({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=VO({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:i,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${i},${c} ${d},${h} ${s},${a}`,f,p,m,w]}const ej=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=De.Bottom,targetPosition:o=De.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:k,interactionWidth:b})=>{const[v,N,j]=GO({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return pe.createElement(Fu,{path:v,labelX:N,labelY:j,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:k,interactionWidth:b})});ej.displayName="SimpleBezierEdge";const RC={[De.Left]:{x:-1,y:0},[De.Right]:{x:1,y:0},[De.Top]:{x:0,y:-1},[De.Bottom]:{x:0,y:1}},i7=({source:e,sourcePosition:t=De.Bottom,target:n})=>t===De.Left||t===De.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},MC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function l7({source:e,sourcePosition:t=De.Bottom,target:n,targetPosition:s=De.Top,center:a,offset:o}){const i=RC[t],c=RC[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=i7({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],k,b;const v={x:0,y:0},N={x:0,y:0},[j,S,_,T]=zO({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*c[p]===-1){k=a.x??j,b=a.y??S;const M=[{x:k,y:d.y},{x:k,y:h.y}],O=[{x:d.x,y:b},{x:h.x,y:b}];i[p]===m?w=p==="x"?M:O:w=p==="x"?O:M}else{const M=[{x:d.x,y:h.y}],O=[{x:h.x,y:d.y}];if(p==="x"?w=i.x===m?O:M:w=i.y===m?M:O,t===s){const q=Math.abs(e[p]-n[p]);if(q<=o){const E=Math.min(o-1,o-q);i[p]===m?v[p]=(d[p]>e[p]?-1:1)*E:N[p]=(h[p]>n[p]?-1:1)*E}}if(t!==s){const q=p==="x"?"y":"x",E=i[p]===c[q],D=d[q]>h[q],P=d[q]<h[q];(i[p]===1&&(!E&&D||E&&P)||i[p]!==1&&(!E&&P||E&&D))&&(w=p==="x"?M:O)}const I={x:d.x+v.x,y:d.y+v.y},F={x:h.x+N.x,y:h.y+N.y},L=Math.max(Math.abs(I.x-w[0].x),Math.abs(F.x-w[0].x)),A=Math.max(Math.abs(I.y-w[0].y),Math.abs(F.y-w[0].y));L>=A?(k=(I.x+F.x)/2,b=w[0].y):(k=w[0].x,b=(I.y+F.y)/2)}return[[e,{x:d.x+v.x,y:d.y+v.y},...w,{x:h.x+N.x,y:h.y+N.y},n],k,b,_,T]}function c7(e,t,n,s){const a=Math.min(MC(e,t)/2,MC(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+a*h},${i}Q ${o},${i} ${o},${i+a*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${i+a*d}Q ${o},${i} ${o+a*c},${i}`}function j0({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top,borderRadius:i=5,centerX:c,centerY:d,offset:h=20}){const[f,p,m,w,k]=l7({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((v,N,j)=>{let S="";return j>0&&j<f.length-1?S=c7(f[j-1],N,f[j+1],i):S=`${j===0?"M":"L"}${N.x} ${N.y}`,v+=S,v},""),p,m,w,k]}const gp=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=De.Bottom,targetPosition:m=De.Top,markerEnd:w,markerStart:k,pathOptions:b,interactionWidth:v})=>{const[N,j,S]=j0({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 pe.createElement(Fu,{path:N,labelX:j,labelY:S,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:k,interactionWidth:v})});gp.displayName="SmoothStepEdge";const tj=y.memo(e=>{var t;return pe.createElement(gp,{...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])})});tj.displayName="StepEdge";function u7({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,c]=zO({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,c]}const nj=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[k,b,v]=u7({sourceX:e,sourceY:t,targetX:n,targetY:s});return pe.createElement(Fu,{path:k,labelX:b,labelY:v,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});nj.displayName="StraightEdge";function Nh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $C({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case De.Left:return[t-Nh(t-s,o),n];case De.Right:return[t+Nh(s-t,o),n];case De.Top:return[t,n-Nh(n-a,o)];case De.Bottom:return[t,n+Nh(a-n,o)]}}function sj({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top,curvature:i=.25}){const[c,d]=$C({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[h,f]=$C({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,k]=VO({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${s},${a}`,p,m,w,k]}const Nf=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=De.Bottom,targetPosition:o=De.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:k,pathOptions:b,interactionWidth:v})=>{const[N,j,S]=sj({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:b==null?void 0:b.curvature});return pe.createElement(Fu,{path:N,labelX:j,labelY:S,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:k,interactionWidth:v})});Nf.displayName="BezierEdge";const rj=y.createContext(null),d7=rj.Provider;rj.Consumer;const h7=()=>y.useContext(rj),f7=e=>"id"in e&&"source"in e&&"target"in e,p7=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,N0=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,m7=(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)),g7=(e,t)=>{if(!e.source||!e.target)return t;let n;return f7(e)?n={...e}:n={...e,id:p7(e)},m7(n,t)?t:t.concat(n)},S0=({x:e,y:t},[n,s,a],o,[i,c])=>{const d={x:(e-n)/a,y:(t-s)/a};return o?{x:i*Math.round(d.x/i),y:c*Math.round(d.y/c)}:d},KO=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),Go=(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],a={x:e.position.x-n,y:e.position.y-s};return{...a,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-s}:a}},yp=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,a)=>{const{x:o,y:i}=Go(a,t).positionAbsolute;return qO(s,mu({x:o,y:i,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return UO(n)},YO=(e,t,[n,s,a]=[0,0,1],o=!1,i=!1,c=[0,0])=>{const d={x:(t.x-n)/a,y:(t.y-s)/a,width:t.width/a,height:t.height/a},h=[];return e.forEach(f=>{const{width:p,height:m,selectable:w=!0,hidden:k=!1}=f;if(i&&!w||k)return!1;const{positionAbsolute:b}=Go(f,c),v={x:b.x,y:b.y,width:p||0,height:m||0},N=b0(d,v),j=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&N>0,_=(p||0)*(m||0);(j||S||N>=_||f.dragging)&&h.push(f)}),h},XO=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},ZO=(e,t,n,s,a,o=.1)=>{const i=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(i,c),h=_l(d,s,a),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}},Oo=(e,t=0)=>e.transition().duration(t);function LC(e,t,n,s){return(t[n]||[]).reduce((a,o)=>{var i,c;return`${e.id}-${o.id}-${n}`!==s&&a.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}),a},[])}function y7(e,t,n,s,a,o){const{x:i,y:c}=to(e),h=t.elementsFromPoint(i,c).find(k=>k.classList.contains("react-flow__handle"));if(h){const k=h.getAttribute("data-nodeid");if(k){const b=aj(void 0,h),v=h.getAttribute("data-handleid"),N=o({nodeId:k,id:v,type:b});if(N){const j=a.find(S=>S.nodeId===k&&S.type===b&&S.id===v);return{handle:{id:v,type:b,nodeId:k,x:(j==null?void 0:j.x)||n.x,y:(j==null?void 0:j.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(a.forEach(k=>{const b=Math.sqrt((k.x-n.x)**2+(k.y-n.y)**2);if(b<=s){const v=o(k);b<=p&&(b<p?f=[{handle:k,validHandleResult:v}]:b===p&&f.push({handle:k,validHandleResult:v}),p=b)}}),!f.length)return{handle:null,validHandleResult:JO()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:k})=>k.isValid),w=f.some(({handle:k})=>k.type==="target");return f.find(({handle:k,validHandleResult:b})=>w?k.type==="target":m?b.isValid:!0)||f[0]}const w7={source:null,target:null,sourceHandle:null,targetHandle:null},JO=()=>({handleDomNode:null,isValid:!1,connection:w7,endHandle:null});function QO(e,t,n,s,a,o,i){const c=a==="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={...JO(),handleDomNode:d};if(d){const f=aj(void 0,d),p=d.getAttribute("data-nodeid"),m=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),k=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&&k&&(t===ti.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 x7({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,o)=>{if(o[It]){const{handleBounds:i}=o[It];let c=[],d=[];i&&(c=LC(o,i,"source",`${t}-${n}-${s}`),d=LC(o,i,"target",`${t}-${n}-${s}`)),a.push(...c,...d)}return a},[])}function aj(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function ay(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function v7(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function e3({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=BO(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:k,onConnectStart:b,panBy:v,getNodes:N,cancelConnection:j}=o();let S=0,_;const{x:T,y:$}=to(e),M=f==null?void 0:f.elementFromPoint(T,$),O=aj(d,M),I=m==null?void 0:m.getBoundingClientRect();if(!I||!O)return;let F,L=to(e,I),A=!1,q=null,E=!1,D=null;const P=x7({nodes:N(),nodeId:n,handleId:t,handleType:O}),z=()=>{if(!w)return;const[H,B]=FO(L,I);v({x:H,y:B}),S=requestAnimationFrame(z)};i({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:O,connectionStartHandle:{nodeId:n,handleId:t,type:O},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:O});function G(H){const{transform:B}=o();L=to(H,I);const{handle:W,validHandleResult:ee}=y7(H,f,S0(L,B,!1,[1,1]),k,P,U=>QO(U,p,n,t,a?"target":"source",c,f));if(_=W,A||(z(),A=!0),D=ee.handleDomNode,q=ee.connection,E=ee.isValid,i({connectionPosition:_&&E?KO({x:_.x,y:_.y},B):L,connectionStatus:v7(!!_,E),connectionEndHandle:ee.endHandle}),!_&&!E&&!D)return ay(F);q.source!==q.target&&D&&(ay(F),F=D,D.classList.add("connecting","react-flow__handle-connecting"),D.classList.toggle("valid",E),D.classList.toggle("react-flow__handle-valid",E))}function V(H){var B,W;(_||D)&&q&&E&&(s==null||s(q)),(W=(B=o()).onConnectEnd)==null||W.call(B,H),d&&(h==null||h(H)),ay(F),j(),cancelAnimationFrame(S),A=!1,E=!1,q=null,D=null,f.removeEventListener("mousemove",G),f.removeEventListener("mouseup",V),f.removeEventListener("touchmove",G),f.removeEventListener("touchend",V)}f.addEventListener("mousemove",G),f.addEventListener("mouseup",V),f.addEventListener("touchmove",G),f.addEventListener("touchend",V)}const IC=()=>!0,b7=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),k7=(e,t,n)=>s=>{const{connectionStartHandle:a,connectionEndHandle:o,connectionClickStartHandle:i}=s;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.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}},t3=y.forwardRef(({type:e="source",position:t=De.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:i,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...m},w)=>{var I,F;const k=i||null,b=e==="target",v=Ft(),N=h7(),{connectOnClick:j,noPanClassName:S}=lt(b7,Yt),{connecting:_,clickConnecting:T}=lt(k7(N,k,e),Yt);N||(F=(I=v.getState()).onError)==null||F.call(I,"010",ia.error010());const $=L=>{const{defaultEdgeOptions:A,onConnect:q,hasDefaultEdges:E}=v.getState(),D={...A,...L};if(E){const{edges:P,setEdges:z}=v.getState();z(g7(D,P))}q==null||q(D),c==null||c(D)},M=L=>{if(!N)return;const A=HO(L);a&&(A&&L.button===0||!A)&&e3({event:L,handleId:k,nodeId:N,onConnect:$,isTarget:b,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||IC}),A?f==null||f(L):p==null||p(L)},O=L=>{const{onClickConnectStart:A,onClickConnectEnd:q,connectionClickStartHandle:E,connectionMode:D,isValidConnection:P}=v.getState();if(!N||!E&&!a)return;if(!E){A==null||A(L,{nodeId:N,handleId:k,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:k}});return}const z=BO(L.target),G=n||P||IC,{connection:V,isValid:H}=QO({nodeId:N,id:k,type:e},D,E.nodeId,E.handleId||null,E.type,G,z);H&&$(V),q==null||q(L),v.setState({connectionClickStartHandle:null})};return pe.createElement("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${k}-${e}`,className:ln(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:o,connecting:T,connectionindicator:s&&(a&&!_||o&&_)}]),onMouseDown:M,onTouchStart:M,onClick:j?O:void 0,ref:w,...m},d)});t3.displayName="Handle";var ni=y.memo(t3);const n3=({data:e,isConnectable:t,targetPosition:n=De.Top,sourcePosition:s=De.Bottom})=>pe.createElement(pe.Fragment,null,pe.createElement(ni,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,pe.createElement(ni,{type:"source",position:s,isConnectable:t}));n3.displayName="DefaultNode";var _0=y.memo(n3);const s3=({data:e,isConnectable:t,sourcePosition:n=De.Bottom})=>pe.createElement(pe.Fragment,null,e==null?void 0:e.label,pe.createElement(ni,{type:"source",position:n,isConnectable:t}));s3.displayName="InputNode";var r3=y.memo(s3);const a3=({data:e,isConnectable:t,targetPosition:n=De.Top})=>pe.createElement(pe.Fragment,null,pe.createElement(ni,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);a3.displayName="OutputNode";var o3=y.memo(a3);const oj=()=>null;oj.displayName="GroupNode";const j7=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Sh=e=>e.id;function N7(e,t){return Yt(e.selectedNodes.map(Sh),t.selectedNodes.map(Sh))&&Yt(e.selectedEdges.map(Sh),t.selectedEdges.map(Sh))}const i3=y.memo(({onSelectionChange:e})=>{const t=Ft(),{selectedNodes:n,selectedEdges:s}=lt(j7,N7);return y.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});i3.displayName="SelectionListener";const S7=e=>!!e.onSelectionChange;function _7({onSelectionChange:e}){const t=lt(S7);return e||t?pe.createElement(i3,{onSelectionChange:e}):null}const C7=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 Hi(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function tt(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const E7=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:o,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:m,edgesUpdatable:w,elevateNodesOnSelect:k,minZoom:b,maxZoom:v,nodeExtent:N,onNodesChange:j,onEdgesChange:S,elementsSelectable:_,connectionMode:T,snapGrid:$,snapToGrid:M,translateExtent:O,connectOnClick:I,defaultEdgeOptions:F,fitView:L,fitViewOptions:A,onNodesDelete:q,onEdgesDelete:E,onNodeDrag:D,onNodeDragStart:P,onNodeDragStop:z,onSelectionDrag:G,onSelectionDragStart:V,onSelectionDragStop:H,noPanClassName:B,nodeOrigin:W,rfId:ee,autoPanOnConnect:U,autoPanOnNodeDrag:Y,onError:X,connectionRadius:Z,isValidConnection:J,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:he,setDefaultNodesAndEdges:le,setMinZoom:re,setMaxZoom:ae,setTranslateExtent:de,setNodeExtent:_e,reset:fe}=lt(C7,Yt),ye=Ft();return y.useEffect(()=>{const ke=s==null?void 0:s.map(Ne=>({...Ne,...F}));return le(n,ke),()=>{fe()}},[]),tt("defaultEdgeOptions",F,ye.setState),tt("connectionMode",T,ye.setState),tt("onConnect",a,ye.setState),tt("onConnectStart",o,ye.setState),tt("onConnectEnd",i,ye.setState),tt("onClickConnectStart",c,ye.setState),tt("onClickConnectEnd",d,ye.setState),tt("nodesDraggable",h,ye.setState),tt("nodesConnectable",f,ye.setState),tt("nodesFocusable",p,ye.setState),tt("edgesFocusable",m,ye.setState),tt("edgesUpdatable",w,ye.setState),tt("elementsSelectable",_,ye.setState),tt("elevateNodesOnSelect",k,ye.setState),tt("snapToGrid",M,ye.setState),tt("snapGrid",$,ye.setState),tt("onNodesChange",j,ye.setState),tt("onEdgesChange",S,ye.setState),tt("connectOnClick",I,ye.setState),tt("fitViewOnInit",L,ye.setState),tt("fitViewOnInitOptions",A,ye.setState),tt("onNodesDelete",q,ye.setState),tt("onEdgesDelete",E,ye.setState),tt("onNodeDrag",D,ye.setState),tt("onNodeDragStart",P,ye.setState),tt("onNodeDragStop",z,ye.setState),tt("onSelectionDrag",G,ye.setState),tt("onSelectionDragStart",V,ye.setState),tt("onSelectionDragStop",H,ye.setState),tt("noPanClassName",B,ye.setState),tt("nodeOrigin",W,ye.setState),tt("rfId",ee,ye.setState),tt("autoPanOnConnect",U,ye.setState),tt("autoPanOnNodeDrag",Y,ye.setState),tt("onError",X,ye.setState),tt("connectionRadius",Z,ye.setState),tt("isValidConnection",J,ye.setState),tt("nodeDragThreshold",te,ye.setState),Hi(e,ce),Hi(t,he),Hi(b,re),Hi(v,ae),Hi(O,de),Hi(N,_e),null},OC={display:"none"},T7={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},l3="react-flow__node-desc",c3="react-flow__edge-desc",A7="react-flow__aria-live",R7=e=>e.ariaLiveMessage;function M7({rfId:e}){const t=lt(R7);return pe.createElement("div",{id:`${A7}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:T7},t)}function $7({rfId:e,disableKeyboardA11y:t}){return pe.createElement(pe.Fragment,null,pe.createElement("div",{id:`${l3}-${e}`,style:OC},"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."," "),pe.createElement("div",{id:`${c3}-${e}`,style:OC},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&pe.createElement(M7,{rfId:e}))}var yu=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=y.useState(!1),a=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(a.current=w.ctrlKey||w.metaKey||w.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&k0(w))return!1;const b=DC(w.code,c);o.current.add(w[b]),PC(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&k0(w))return!1;const b=DC(w.code,c);PC(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[b]),w.key==="Meta"&&o.current.clear(),a.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 PC(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function DC(e,t){return t.includes(e)?"code":"key"}function u3(e,t,n,s){var c,d;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=Go(o,s);return u3(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=o[It])==null?void 0:c.z)??0)>(n.z??0)?((d=o[It])==null?void 0:d.z)??0:n.z??0},s)}function d3(e,t,n){e.forEach(s=>{var o;const a=s.parentNode||s.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||n!=null&&n[s.id]){const{x:i,y:c,z:d}=u3(s,e,{...s.position,z:((o=s[It])==null?void 0:o.z)??0},t);s.positionAbsolute={x:i,y:c},s[It].z=d,n!=null&&n[s.id]&&(s[It].isParent=!0)}})}function oy(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(c=>{var w;const d=(ys(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,It,{enumerable:!1,value:{handleBounds:m||(w=h==null?void 0:h[It])==null?void 0:w.handleBounds,z:d}}),a.set(c.id,f)}),d3(a,n,o),a}function h3(e,t={}){const{getNodes:n,width:s,height:a,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 k=n().filter(v=>{var j;const N=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return(j=t.nodes)!=null&&j.length?N&&t.nodes.some(S=>S.id===v.id):N}),b=k.every(v=>v.width&&v.height);if(k.length>0&&b){const v=yp(k,p),{x:N,y:j,zoom:S}=ZO(v,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),_=sa.translate(N,j).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform(Oo(d,t.duration),_):c.transform(d,_),!0}}return!1}function L7(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[It]:s[It],selected:n.selected})}),new Map(t)}function I7(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function _h({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:o,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&s({nodeInternals:L7(e,a)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:I7(t,o)}),c==null||c(t))}const zi=()=>{},O7={zoomIn:zi,zoomOut:zi,zoomTo:zi,getZoom:()=>1,setViewport:zi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:zi,fitBounds:zi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},P7=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),D7=()=>{const e=Ft(),{d3Zoom:t,d3Selection:n}=lt(P7,Yt);return y.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Oo(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Oo(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo(Oo(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,c,d]=e.getState().transform,h=sa.translate(a.x??i,a.y??c).scale(a.zoom??d);t.transform(Oo(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[a,o,i]=e.getState().transform;return{x:a,y:o,zoom:i}},fitView:a=>h3(e.getState,a),setCenter:(a,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-a*f,m=d/2-o*f,w=sa.translate(p,m).scale(f);t.transform(Oo(n,i==null?void 0:i.duration),w)},fitBounds:(a,o)=>{const{width:i,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:m}=ZO(a,i,c,d,h,(o==null?void 0:o.padding)??.1),w=sa.translate(f,p).scale(m);t.transform(Oo(n,o==null?void 0:o.duration),w)},project:a=>{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"),S0(a,o,i,c)},screenToFlowPosition:a=>{const{transform:o,snapToGrid:i,snapGrid:c,domNode:d}=e.getState();if(!d)return a;const{x:h,y:f}=d.getBoundingClientRect(),p={x:a.x-h,y:a.y-f};return S0(p,o,i,c)},flowToScreenPosition:a=>{const{transform:o,domNode:i}=e.getState();if(!i)return a;const{x:c,y:d}=i.getBoundingClientRect(),h=KO(a,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:O7,[t,n])};function Il(){const e=D7(),t=Ft(),n=y.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),s=y.useCallback(b=>t.getState().nodeInternals.get(b),[]),a=y.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(v=>({...v}))},[]),o=y.useCallback(b=>{const{edges:v=[]}=t.getState();return v.find(N=>N.id===b)},[]),i=y.useCallback(b=>{const{getNodes:v,setNodes:N,hasDefaultNodes:j,onNodesChange:S}=t.getState(),_=v(),T=typeof b=="function"?b(_):b;if(j)N(T);else if(S){const $=T.length===0?_.map(M=>({type:"remove",id:M.id})):T.map(M=>({item:M,type:"reset"}));S($)}},[]),c=y.useCallback(b=>{const{edges:v=[],setEdges:N,hasDefaultEdges:j,onEdgesChange:S}=t.getState(),_=typeof b=="function"?b(v):b;if(j)N(_);else if(S){const T=_.length===0?v.map($=>({type:"remove",id:$.id})):_.map($=>({item:$,type:"reset"}));S(T)}},[]),d=y.useCallback(b=>{const v=Array.isArray(b)?b:[b],{getNodes:N,setNodes:j,hasDefaultNodes:S,onNodesChange:_}=t.getState();if(S){const $=[...N(),...v];j($)}else if(_){const T=v.map($=>({item:$,type:"add"}));_(T)}},[]),h=y.useCallback(b=>{const v=Array.isArray(b)?b:[b],{edges:N=[],setEdges:j,hasDefaultEdges:S,onEdgesChange:_}=t.getState();if(S)j([...N,...v]);else if(_){const T=v.map($=>({item:$,type:"add"}));_(T)}},[]),f=y.useCallback(()=>{const{getNodes:b,edges:v=[],transform:N}=t.getState(),[j,S,_]=N;return{nodes:b().map(T=>({...T})),edges:v.map(T=>({...T})),viewport:{x:j,y:S,zoom:_}}},[]),p=y.useCallback(({nodes:b,edges:v})=>{const{nodeInternals:N,getNodes:j,edges:S,hasDefaultNodes:_,hasDefaultEdges:T,onNodesDelete:$,onEdgesDelete:M,onNodesChange:O,onEdgesChange:I}=t.getState(),F=(b||[]).map(D=>D.id),L=(v||[]).map(D=>D.id),A=j().reduce((D,P)=>{const z=P.parentNode||P.parentId,G=!F.includes(P.id)&&z&&D.find(H=>H.id===z);return(typeof P.deletable=="boolean"?P.deletable:!0)&&(F.includes(P.id)||G)&&D.push(P),D},[]),q=S.filter(D=>typeof D.deletable=="boolean"?D.deletable:!0),E=q.filter(D=>L.includes(D.id));if(A||E){const D=XO(A,q),P=[...E,...D],z=P.reduce((G,V)=>(G.includes(V.id)||G.push(V.id),G),[]);if((T||_)&&(T&&t.setState({edges:S.filter(G=>!z.includes(G.id))}),_&&(A.forEach(G=>{N.delete(G.id)}),t.setState({nodeInternals:new Map(N)}))),z.length>0&&(M==null||M(P),I&&I(z.map(G=>({id:G,type:"remove"})))),A.length>0&&($==null||$(A),O)){const G=A.map(V=>({id:V.id,type:"remove"}));O(G)}}},[]),m=y.useCallback(b=>{const v=r7(b),N=v?null:t.getState().nodeInternals.get(b.id);return!v&&!N?[null,null,v]:[v?b:TC(N),N,v]},[]),w=y.useCallback((b,v=!0,N)=>{const[j,S,_]=m(b);return j?(N||t.getState().getNodes()).filter(T=>{if(!_&&(T.id===S.id||!T.positionAbsolute))return!1;const $=TC(T),M=b0($,j);return v&&M>0||M>=j.width*j.height}):[]},[]),k=y.useCallback((b,v,N=!0)=>{const[j]=m(b);if(!j)return!1;const S=b0(j,v);return N&&S>0||S>=j.width*j.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:o,setNodes:i,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:k}),[e,n,s,a,o,i,c,d,h,f,p,w,k])}const F7={actInsideInputWithModifier:!1};var B7=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ft(),{deleteElements:s}=Il(),a=yu(e,F7),o=yu(t);y.useEffect(()=>{if(a){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})}},[a]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function q7(e){const t=Ft();y.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=J1(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",ia.error004())),t.setState({width:a.width||500,height:a.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 ij={position:"absolute",width:"100%",height:"100%",top:0,left:0},U7=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Ch=e=>({x:e.x,y:e.y,zoom:e.k}),Vi=(e,t)=>e.target.closest(`.${t}`),FC=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),BC=e=>{const t=e.ctrlKey&&kf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},W7=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),H7=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Wo.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:k,maxZoom:b,zoomActivationKeyCode:v,preventScrolling:N=!0,children:j,noWheelClassName:S,noPanClassName:_})=>{const T=y.useRef(),$=Ft(),M=y.useRef(!1),O=y.useRef(!1),I=y.useRef(null),F=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:A,d3ZoomHandler:q,userSelectionActive:E}=lt(W7,Yt),D=yu(v),P=y.useRef(0),z=y.useRef(!1),G=y.useRef();return q7(I),y.useEffect(()=>{if(I.current){const V=I.current.getBoundingClientRect(),H=PO().scaleExtent([k,b]).translateExtent(w),B=gs(I.current).call(H),W=sa.translate(m.x,m.y).scale(_l(m.zoom,k,b)),ee=[[0,0],[V.width,V.height]],U=H.constrain()(W,ee,w);H.transform(B,U),H.wheelDelta(BC),$.setState({d3Zoom:H,d3Selection:B,d3ZoomHandler:B.on("wheel.zoom"),transform:[U.x,U.y,U.k],domNode:I.current.closest(".react-flow")})}},[]),y.useEffect(()=>{A&&L&&(i&&!D&&!E?A.on("wheel.zoom",V=>{if(Vi(V,S))return!1;V.preventDefault(),V.stopImmediatePropagation();const H=A.property("__zoom").k||1;if(V.ctrlKey&&o){const J=Hs(V),te=BC(V),ce=H*Math.pow(2,te);L.scaleTo(A,ce,J,V);return}const B=V.deltaMode===1?20:1;let W=d===Wo.Vertical?0:V.deltaX*B,ee=d===Wo.Horizontal?0:V.deltaY*B;!kf()&&V.shiftKey&&d!==Wo.Vertical&&(W=V.deltaY*B,ee=0),L.translateBy(A,-(W/H)*c,-(ee/H)*c,{internal:!0});const U=Ch(A.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:X,onViewportChangeEnd:Z}=$.getState();clearTimeout(G.current),z.current||(z.current=!0,t==null||t(V,U),Y==null||Y(U)),z.current&&(e==null||e(V,U),X==null||X(U),G.current=setTimeout(()=>{n==null||n(V,U),Z==null||Z(U),z.current=!1},150))},{passive:!1}):typeof q<"u"&&A.on("wheel.zoom",function(V,H){if(!N&&V.type==="wheel"&&!V.ctrlKey||Vi(V,S))return null;V.preventDefault(),q.call(this,V,H)},{passive:!1}))},[E,i,d,A,L,q,D,o,N,S,t,e,n]),y.useEffect(()=>{L&&L.on("start",V=>{var W,ee;if(!V.sourceEvent||V.sourceEvent.internal)return null;P.current=(W=V.sourceEvent)==null?void 0:W.button;const{onViewportChangeStart:H}=$.getState(),B=Ch(V.transform);M.current=!0,F.current=B,((ee=V.sourceEvent)==null?void 0:ee.type)==="mousedown"&&$.setState({paneDragging:!0}),H==null||H(B),t==null||t(V.sourceEvent,B)})},[L,t]),y.useEffect(()=>{L&&(E&&!M.current?L.on("zoom",null):E||L.on("zoom",V=>{var B;const{onViewportChange:H}=$.getState();if($.setState({transform:[V.transform.x,V.transform.y,V.transform.k]}),O.current=!!(s&&FC(p,P.current??0)),(e||H)&&!((B=V.sourceEvent)!=null&&B.internal)){const W=Ch(V.transform);H==null||H(W),e==null||e(V.sourceEvent,W)}}))},[E,L,e,p,s]),y.useEffect(()=>{L&&L.on("end",V=>{if(!V.sourceEvent||V.sourceEvent.internal)return null;const{onViewportChangeEnd:H}=$.getState();if(M.current=!1,$.setState({paneDragging:!1}),s&&FC(p,P.current??0)&&!O.current&&s(V.sourceEvent),O.current=!1,(n||H)&&U7(F.current,V.transform)){const B=Ch(V.transform);F.current=B,clearTimeout(T.current),T.current=setTimeout(()=>{H==null||H(B),n==null||n(V.sourceEvent,B)},i?150:0)}})},[L,i,p,n,s]),y.useEffect(()=>{L&&L.filter(V=>{const H=D||a,B=o&&V.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&V.button===1&&V.type==="mousedown"&&(Vi(V,"react-flow__node")||Vi(V,"react-flow__edge")))return!0;if(!p&&!H&&!i&&!h&&!o||E||!h&&V.type==="dblclick"||Vi(V,S)&&V.type==="wheel"||Vi(V,_)&&(V.type!=="wheel"||i&&V.type==="wheel"&&!D)||!o&&V.ctrlKey&&V.type==="wheel"||!H&&!i&&!B&&V.type==="wheel"||!p&&(V.type==="mousedown"||V.type==="touchstart")||Array.isArray(p)&&!p.includes(V.button)&&V.type==="mousedown")return!1;const W=Array.isArray(p)&&p.includes(V.button)||!V.button||V.button<=1;return(!V.ctrlKey||V.type==="wheel")&&W})},[E,L,a,o,i,h,p,f,D]),pe.createElement("div",{className:"react-flow__renderer",ref:I,style:ij},j)},z7=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function V7(){const{userSelectionActive:e,userSelectionRect:t}=lt(z7,Yt);return e&&t?pe.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 qC(e,t){const n=t.parentNode||t.parentId,s=e.find(a=>a.id===n);if(s){const a=t.position.x+t.width-s.width,o=t.position.y+t.height-s.height;if(a>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,a>0&&(s.style.width+=a),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 G7(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,a)=>{const o=e.filter(c=>c.id===a.id);if(o.length===0)return s.push(a),s;const i={...a};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&&qC(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&&qC(s,i);break}case"remove":return s}return s.push(i),s},n)}function K7(e,t){return G7(e,t)}const Ka=(e,t)=>({id:e,type:"select",selected:t});function il(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Ka(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Ka(s.id,!1))),n},[])}const iy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Y7=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),f3=y.memo(({isSelecting:e,selectionMode:t=gu.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const m=y.useRef(null),w=Ft(),k=y.useRef(0),b=y.useRef(0),v=y.useRef(),{userSelectionActive:N,elementsSelectable:j,dragging:S}=lt(Y7,Yt),_=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),k.current=0,b.current=0},T=q=>{o==null||o(q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},$=q=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){q.preventDefault();return}i==null||i(q)},M=c?q=>c(q):void 0,O=q=>{const{resetSelectedElements:E,domNode:D}=w.getState();if(v.current=D==null?void 0:D.getBoundingClientRect(),!j||!e||q.button!==0||q.target!==m.current||!v.current)return;const{x:P,y:z}=to(q,v.current);E(),w.setState({userSelectionRect:{width:0,height:0,startX:P,startY:z,x:P,y:z}}),s==null||s(q)},I=q=>{const{userSelectionRect:E,nodeInternals:D,edges:P,transform:z,onNodesChange:G,onEdgesChange:V,nodeOrigin:H,getNodes:B}=w.getState();if(!e||!v.current||!E)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const W=to(q,v.current),ee=E.startX??0,U=E.startY??0,Y={...E,x:W.x<ee?W.x:ee,y:W.y<U?W.y:U,width:Math.abs(W.x-ee),height:Math.abs(W.y-U)},X=B(),Z=YO(D,Y,z,t===gu.Partial,!0,H),J=XO(Z,P).map(ce=>ce.id),te=Z.map(ce=>ce.id);if(k.current!==te.length){k.current=te.length;const ce=il(X,te);ce.length&&(G==null||G(ce))}if(b.current!==J.length){b.current=J.length;const ce=il(P,J);ce.length&&(V==null||V(ce))}w.setState({userSelectionRect:Y})},F=q=>{if(q.button!==0)return;const{userSelectionRect:E}=w.getState();!N&&E&&q.target===m.current&&(T==null||T(q)),w.setState({nodesSelectionActive:k.current>0}),_(),a==null||a(q)},L=q=>{N&&(w.setState({nodesSelectionActive:k.current>0}),a==null||a(q)),_()},A=j&&(e||N);return pe.createElement("div",{className:ln(["react-flow__pane",{dragging:S,selection:e}]),onClick:A?void 0:iy(T,m),onContextMenu:iy($,m),onWheel:iy(M,m),onMouseEnter:A?void 0:d,onMouseDown:A?O:void 0,onMouseMove:A?I:h,onMouseUp:A?F:void 0,onMouseLeave:A?L:f,ref:m,style:ij},p,pe.createElement(V7,null))});f3.displayName="Pane";function p3(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:p3(s,t):!1}function UC(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 X7(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!p3(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var o,i;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=a.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=a.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:a.extent,parentNode:a.parentNode||a.parentId,parentId:a.parentNode||a.parentId,width:a.width,height:a.height,expandParent:a.expandParent}})}function Z7(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function m3(e,t,n,s,a=[0,0],o){const i=Z7(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}=Go(p,a).positionAbsolute;c=p&&ys(m)&&ys(w)&&ys(p.width)&&ys(p.height)?[[m+e.width*a[0],w+e.height*a[1]],[m+p.width-e.width+e.width*a[0],w+p.height-e.height+e.height*a[1]]]:c}else o==null||o("005",ia.error005()),c=i;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:m,y:w}=Go(p,a).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=Go(p,a).positionAbsolute}const f=c&&c!=="parent"?Q1(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function ly({nodeId:e,dragItems:t,nodeInternals:n}){const s=t.map(a=>({...n.get(a.id),position:a.position,positionAbsolute:a.positionAbsolute}));return[e?s.find(a=>a.id===e):s[0],s]}const WC=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const o=Array.from(a),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,...J1(d)}})};function Mc(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function C0({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",ia.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()})):a([e])}function J7(){const e=Ft();return y.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,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?a[0]*Math.round(d.x/a[0]):d.x,ySnapped:o?a[1]*Math.round(d.y/a[1]):d.y,...d}},[])}function cy(e){return(t,n,s)=>e==null?void 0:e(t,s)}function g3({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const c=Ft(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),m=y.useRef(0),w=y.useRef(null),k=y.useRef({x:0,y:0}),b=y.useRef(null),v=y.useRef(!1),N=y.useRef(!1),j=y.useRef(!1),S=J7();return y.useEffect(()=>{if(e!=null&&e.current){const _=gs(e.current),T=({x:O,y:I})=>{const{nodeInternals:F,onNodeDrag:L,onSelectionDrag:A,updateNodePositions:q,nodeExtent:E,snapGrid:D,snapToGrid:P,nodeOrigin:z,onError:G}=c.getState();p.current={x:O,y:I};let V=!1,H={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&E){const W=yp(f.current,z);H=mu(W)}if(f.current=f.current.map(W=>{const ee={x:O-W.distance.x,y:I-W.distance.y};P&&(ee.x=D[0]*Math.round(ee.x/D[0]),ee.y=D[1]*Math.round(ee.y/D[1]));const U=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];f.current.length>1&&E&&!W.extent&&(U[0][0]=W.positionAbsolute.x-H.x+E[0][0],U[1][0]=W.positionAbsolute.x+(W.width??0)-H.x2+E[1][0],U[0][1]=W.positionAbsolute.y-H.y+E[0][1],U[1][1]=W.positionAbsolute.y+(W.height??0)-H.y2+E[1][1]);const Y=m3(W,ee,F,U,z,G);return V=V||W.position.x!==Y.position.x||W.position.y!==Y.position.y,W.position=Y.position,W.positionAbsolute=Y.positionAbsolute,W}),!V)return;q(f.current,!0,!0),h(!0);const B=a?L:cy(A);if(B&&b.current){const[W,ee]=ly({nodeId:a,dragItems:f.current,nodeInternals:F});B(b.current,W,ee)}},$=()=>{if(!w.current)return;const[O,I]=FO(k.current,w.current);if(O!==0||I!==0){const{transform:F,panBy:L}=c.getState();p.current.x=(p.current.x??0)-O/F[2],p.current.y=(p.current.y??0)-I/F[2],L({x:O,y:I})&&T(p.current)}m.current=requestAnimationFrame($)},M=O=>{var z;const{nodeInternals:I,multiSelectionActive:F,nodesDraggable:L,unselectNodesAndEdges:A,onNodeDragStart:q,onSelectionDragStart:E}=c.getState();N.current=!0;const D=a?q:cy(E);(!i||!o)&&!F&&a&&((z=I.get(a))!=null&&z.selected||A()),a&&o&&i&&C0({id:a,store:c,nodeRef:e});const P=S(O);if(p.current=P,f.current=X7(I,L,P,a),D&&f.current){const[G,V]=ly({nodeId:a,dragItems:f.current,nodeInternals:I});D(O.sourceEvent,G,V)}};if(t)_.on(".drag",null);else{const O=lU().on("start",I=>{const{domNode:F,nodeDragThreshold:L}=c.getState();L===0&&M(I),j.current=!1;const A=S(I);p.current=A,w.current=(F==null?void 0:F.getBoundingClientRect())||null,k.current=to(I.sourceEvent,w.current)}).on("drag",I=>{var q,E;const F=S(I),{autoPanOnNodeDrag:L,nodeDragThreshold:A}=c.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(j.current=!0),!j.current){if(!v.current&&N.current&&L&&(v.current=!0,$()),!N.current){const D=F.xSnapped-(((q=p==null?void 0:p.current)==null?void 0:q.x)??0),P=F.ySnapped-(((E=p==null?void 0:p.current)==null?void 0:E.y)??0);Math.sqrt(D*D+P*P)>A&&M(I)}(p.current.x!==F.xSnapped||p.current.y!==F.ySnapped)&&f.current&&N.current&&(b.current=I.sourceEvent,k.current=to(I.sourceEvent,w.current),T(F))}}).on("end",I=>{if(!(!N.current||j.current)&&(h(!1),v.current=!1,N.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:F,nodeInternals:L,onNodeDragStop:A,onSelectionDragStop:q}=c.getState(),E=a?A:cy(q);if(F(f.current,!1,!1),E){const[D,P]=ly({nodeId:a,dragItems:f.current,nodeInternals:L});E(I.sourceEvent,D,P)}}}).filter(I=>{const F=I.target;return!I.button&&(!n||!UC(F,`.${n}`,e))&&(!s||UC(F,s,e))});return _.call(O),()=>{_.on(".drag",null)}}}},[e,t,n,s,o,c,a,i,S]),d}function y3(){const e=Ft();return y.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:o,getNodes:i,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=i().filter(j=>j.selected&&(j.draggable||f&&typeof j.draggable>"u")),m=c?d[0]:5,w=c?d[1]:5,k=n.isShiftPressed?4:1,b=n.x*m*k,v=n.y*w*k,N=p.map(j=>{if(j.positionAbsolute){const S={x:j.positionAbsolute.x+b,y:j.positionAbsolute.y+v};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:_,position:T}=m3(j,S,s,a,void 0,h);j.position=T,j.positionAbsolute=_}return j});o(N,!0,!1)},[])}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var $c=e=>{const t=({id:n,type:s,data:a,xPos:o,yPos:i,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:m,onMouseLeave:w,onContextMenu:k,onDoubleClick:b,style:v,className:N,isDraggable:j,isSelectable:S,isConnectable:_,isFocusable:T,selectNodesOnDrag:$,sourcePosition:M,targetPosition:O,hidden:I,resizeObserver:F,dragHandle:L,zIndex:A,isParent:q,noDragClassName:E,noPanClassName:D,initialized:P,disableKeyboardA11y:z,ariaLabel:G,rfId:V,hasHandleBounds:H})=>{const B=Ft(),W=y.useRef(null),ee=y.useRef(null),U=y.useRef(M),Y=y.useRef(O),X=y.useRef(s),Z=S||j||f||p||m||w,J=y3(),te=Mc(n,B.getState,p),ce=Mc(n,B.getState,m),he=Mc(n,B.getState,w),le=Mc(n,B.getState,k),re=Mc(n,B.getState,b),ae=fe=>{const{nodeDragThreshold:ye}=B.getState();if(S&&(!$||!j||ye>0)&&C0({id:n,store:B,nodeRef:W}),f){const ke=B.getState().nodeInternals.get(n);ke&&f(fe,{...ke})}},de=fe=>{if(!k0(fe)&&!z)if(WO.includes(fe.key)&&S){const ye=fe.key==="Escape";C0({id:n,store:B,unselect:ye,nodeRef:W})}else j&&h&&Object.prototype.hasOwnProperty.call(gl,fe.key)&&(B.setState({ariaLiveMessage:`Moved selected node ${fe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),J({x:gl[fe.key].x,y:gl[fe.key].y,isShiftPressed:fe.shiftKey}))};y.useEffect(()=>()=>{ee.current&&(F==null||F.unobserve(ee.current),ee.current=null)},[]),y.useEffect(()=>{if(W.current&&!I){const fe=W.current;(!P||!H||ee.current!==fe)&&(ee.current&&(F==null||F.unobserve(ee.current)),F==null||F.observe(fe),ee.current=fe)}},[I,P,H]),y.useEffect(()=>{const fe=X.current!==s,ye=U.current!==M,ke=Y.current!==O;W.current&&(fe||ye||ke)&&(fe&&(X.current=s),ye&&(U.current=M),ke&&(Y.current=O),B.getState().updateNodeDimensions([{id:n,nodeElement:W.current,forceUpdate:!0}]))},[n,s,M,O]);const _e=g3({nodeRef:W,disabled:I||!j,noDragClassName:E,handleSelector:L,nodeId:n,isSelectable:S,selectNodesOnDrag:$});return I?null:pe.createElement("div",{className:ln(["react-flow__node",`react-flow__node-${s}`,{[D]:j},N,{selected:h,selectable:S,parent:q,dragging:_e}]),ref:W,style:{zIndex:A,transform:`translate(${c}px,${d}px)`,pointerEvents:Z?"all":"none",visibility:P?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:te,onMouseMove:ce,onMouseLeave:he,onContextMenu:le,onClick:ae,onDoubleClick:re,onKeyDown:T?de:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":z?void 0:`${l3}-${V}`,"aria-label":G},pe.createElement(d7,{value:n},pe.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:h,isConnectable:_,sourcePosition:M,targetPosition:O,dragging:_e,dragHandle:L,zIndex:A})))};return t.displayName="NodeWrapper",y.memo(t)};const Q7=e=>{const t=e.getNodes().filter(n=>n.selected);return{...yp(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function eH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Ft(),{width:a,height:o,x:i,y:c,transformString:d,userSelectionActive:h}=lt(Q7,Yt),f=y3(),p=y.useRef(null);if(y.useEffect(()=>{var k;n||(k=p.current)==null||k.focus({preventScroll:!0})},[n]),g3({nodeRef:p}),h||!a||!o)return null;const m=e?k=>{const b=s.getState().getNodes().filter(v=>v.selected);e(k,b)}:void 0,w=k=>{Object.prototype.hasOwnProperty.call(gl,k.key)&&f({x:gl[k.key].x,y:gl[k.key].y,isShiftPressed:k.shiftKey})};return pe.createElement("div",{className:ln(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},pe.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:a,height:o,top:c,left:i}}))}var tH=y.memo(eH);const nH=e=>e.nodesSelectionActive,w3=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:w,onSelectionStart:k,onSelectionEnd:b,multiSelectionKeyCode:v,panActivationKeyCode:N,zoomActivationKeyCode:j,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:$,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:I,panOnDrag:F,defaultViewport:L,translateExtent:A,minZoom:q,maxZoom:E,preventScrolling:D,onSelectionContextMenu:P,noWheelClassName:z,noPanClassName:G,disableKeyboardA11y:V})=>{const H=lt(nH),B=yu(p),W=yu(N),ee=W||F,U=W||$,Y=B||m&&ee!==!0;return B7({deleteKeyCode:c,multiSelectionKeyCode:v}),pe.createElement(H7,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:U,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:I,panOnDrag:!B&&ee,defaultViewport:L,translateExtent:A,minZoom:q,maxZoom:E,zoomActivationKeyCode:j,preventScrolling:D,noWheelClassName:z,noPanClassName:G},pe.createElement(f3,{onSelectionStart:k,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:ee,isSelecting:!!Y,selectionMode:w},e,H&&pe.createElement(tH,{onSelectionContextMenu:P,noPanClassName:G,disableKeyboardA11y:V})))};w3.displayName="FlowRenderer";var sH=y.memo(w3);function rH(e){return lt(y.useCallback(n=>e?YO(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function aH(e){const t={input:$c(e.input||r3),default:$c(e.default||_0),output:$c(e.output||o3),group:$c(e.group||oj)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=$c(e[o]||_0),a),n);return{...t,...s}}const oH=({x:e,y:t,width:n,height:s,origin:a})=>!n||!s?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-s*a[1]},iH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),x3=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=lt(iH,Yt),c=rH(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()},[]),pe.createElement("div",{className:"react-flow__nodes",style:ij},c.map(f=>{var T,$,M;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",ia.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),k=!!(f.selectable||a&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),v=!!(f.focusable||s&&typeof f.focusable>"u"),N=e.nodeExtent?Q1(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,j=(N==null?void 0:N.x)??0,S=(N==null?void 0:N.y)??0,_=oH({x:j,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return pe.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||De.Bottom,targetPosition:f.targetPosition||De.Top,hidden:f.hidden,xPos:j,yPos:S,xPosOrigin:_.x,yPosOrigin:_.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:k,isConnectable:b,isFocusable:v,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((T=f[It])==null?void 0:T.z)??0,isParent:!!(($=f[It])!=null&&$.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((M=f[It])!=null&&M.handleBounds)})}))};x3.displayName="NodeRenderer";var lH=y.memo(x3);const cH=(e,t,n)=>n===De.Left?e-t:n===De.Right?e+t:e,uH=(e,t,n)=>n===De.Top?e-t:n===De.Bottom?e+t:e,HC="react-flow__edgeupdater",zC=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:o,onMouseOut:i,type:c})=>pe.createElement("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:i,className:ln([HC,`${HC}-${c}`]),cx:cH(t,s,e),cy:uH(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),dH=()=>!0;var Gi=e=>{const t=({id:n,className:s,type:a,data:o,onClick:i,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:b,style:v,source:N,target:j,sourceX:S,sourceY:_,targetX:T,targetY:$,sourcePosition:M,targetPosition:O,elementsSelectable:I,hidden:F,sourceHandleId:L,targetHandleId:A,onContextMenu:q,onMouseEnter:E,onMouseMove:D,onMouseLeave:P,reconnectRadius:z,onReconnect:G,onReconnectStart:V,onReconnectEnd:H,markerEnd:B,markerStart:W,rfId:ee,ariaLabel:U,isFocusable:Y,isReconnectable:X,pathOptions:Z,interactionWidth:J,disableKeyboardA11y:te})=>{const ce=y.useRef(null),[he,le]=y.useState(!1),[re,ae]=y.useState(!1),de=Ft(),_e=y.useMemo(()=>`url('#${N0(W,ee)}')`,[W,ee]),fe=y.useMemo(()=>`url('#${N0(B,ee)}')`,[B,ee]);if(F)return null;const ye=ze=>{var Xe;const{edges:st,addSelectedEdges:ot,unselectNodesAndEdges:Qe,multiSelectionActive:we}=de.getState(),Fe=st.find(He=>He.id===n);Fe&&(I&&(de.setState({nodesSelectionActive:!1}),Fe.selected&&we?(Qe({nodes:[],edges:[Fe]}),(Xe=ce.current)==null||Xe.blur()):ot([n])),i&&i(ze,Fe))},ke=Rc(n,de.getState,c),Ne=Rc(n,de.getState,q),ge=Rc(n,de.getState,E),Me=Rc(n,de.getState,D),Ie=Rc(n,de.getState,P),We=(ze,st)=>{if(ze.button!==0)return;const{edges:ot,isValidConnection:Qe}=de.getState(),we=st?j:N,Fe=(st?A:L)||null,Xe=st?"target":"source",He=Qe||dH,ht=st,Ct=ot.find(Ot=>Ot.id===n);ae(!0),V==null||V(ze,Ct,Xe);const mt=Ot=>{ae(!1),H==null||H(Ot,Ct,Xe)};e3({event:ze,handleId:Fe,nodeId:we,onConnect:Ot=>G==null?void 0:G(Ct,Ot),isTarget:ht,getState:de.getState,setState:de.setState,isValidConnection:He,edgeUpdaterType:Xe,onReconnectEnd:mt})},Te=ze=>We(ze,!0),at=ze=>We(ze,!1),Je=()=>le(!0),Ve=()=>le(!1),be=!I&&!i,Oe=ze=>{var st;if(!te&&WO.includes(ze.key)&&I){const{unselectNodesAndEdges:ot,addSelectedEdges:Qe,edges:we}=de.getState();ze.key==="Escape"?((st=ce.current)==null||st.blur(),ot({edges:[we.find(Xe=>Xe.id===n)]})):Qe([n])}};return pe.createElement("g",{className:ln(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:d,animated:h,inactive:be,updating:he}]),onClick:ye,onDoubleClick:ke,onContextMenu:Ne,onMouseEnter:ge,onMouseMove:Me,onMouseLeave:Ie,onKeyDown:Y?Oe:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":U===null?void 0:U||`Edge from ${N} to ${j}`,"aria-describedby":Y?`${c3}-${ee}`:void 0,ref:ce},!re&&pe.createElement(e,{id:n,source:N,target:j,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:b,data:o,style:v,sourceX:S,sourceY:_,targetX:T,targetY:$,sourcePosition:M,targetPosition:O,sourceHandleId:L,targetHandleId:A,markerStart:_e,markerEnd:fe,pathOptions:Z,interactionWidth:J}),X&&pe.createElement(pe.Fragment,null,(X==="source"||X===!0)&&pe.createElement(zC,{position:M,centerX:S,centerY:_,radius:z,onMouseDown:Te,onMouseEnter:Je,onMouseOut:Ve,type:"source"}),(X==="target"||X===!0)&&pe.createElement(zC,{position:O,centerX:T,centerY:$,radius:z,onMouseDown:at,onMouseEnter:Je,onMouseOut:Ve,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function hH(e){const t={default:Gi(e.default||Nf),straight:Gi(e.bezier||nj),step:Gi(e.step||tj),smoothstep:Gi(e.step||gp),simplebezier:Gi(e.simplebezier||ej)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=Gi(e[o]||Nf),a),n);return{...t,...s}}function VC(e,t,n=null){const s=((n==null?void 0:n.x)||0)+t.x,a=((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 De.Top:return{x:s+o/2,y:a};case De.Right:return{x:s+o,y:a+i/2};case De.Bottom:return{x:s+o/2,y:a+i};case De.Left:return{x:s,y:a+i/2}}}function GC(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const fH=(e,t,n,s,a,o)=>{const i=VC(n,e,t),c=VC(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function pH({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,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+a),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=mu({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 KC(e){var s,a,o,i,c;const t=((s=e==null?void 0:e[It])==null?void 0:s.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.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 mH=[{level:0,isMaxLevel:!0,edges:[]}];function gH(e,t,n=!1){let s=-1;const a=e.reduce((i,c)=>{var f,p;const d=ys(c.zIndex);let h=d?c.zIndex:0;if(n){const m=t.get(c.target),w=t.get(c.source),k=c.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),b=Math.max(((f=w==null?void 0:w[It])==null?void 0:f.z)||0,((p=m==null?void 0:m[It])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(k?b:0)}return i[h]?i[h].push(c):i[h]=[c],s=h>s?h:s,i},{}),o=Object.entries(a).map(([i,c])=>{const d=+i;return{edges:c,level:d,isMaxLevel:d===s}});return o.length===0?mH:o}function yH(e,t,n){const s=lt(y.useCallback(a=>e?a.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)&&pH({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:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return gH(s,t,n)}const wH=({color:e="none",strokeWidth:t=1})=>pe.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),xH=({color:e="none",strokeWidth:t=1})=>pe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),YC={[jf.Arrow]:wH,[jf.ArrowClosed]:xH};function vH(e){const t=Ft();return y.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(YC,e)?YC[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",ia.error009(e)),null)},[e])}const bH=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const d=vH(t);return d?pe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},pe.createElement(d,{color:n,strokeWidth:i})):null},kH=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((a,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const c=N0(i,t);s.includes(c)||(a.push({id:c,color:i.color||e,...i}),s.push(c))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))},v3=({defaultColor:e,rfId:t})=>{const n=lt(y.useCallback(kH({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((o,i)=>o.id!==a[i].id)));return pe.createElement("defs",null,n.map(s=>pe.createElement(bH,{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})))};v3.displayName="MarkerDefinitions";var jH=y.memo(v3);const NH=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}),b3=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:b,children:v,disableKeyboardA11y:N})=>{const{edgesFocusable:j,edgesUpdatable:S,elementsSelectable:_,width:T,height:$,connectionMode:M,nodeInternals:O,onError:I}=lt(NH,Yt),F=yH(t,O,n);return T?pe.createElement(pe.Fragment,null,F.map(({level:L,edges:A,isMaxLevel:q})=>pe.createElement("svg",{key:L,style:{zIndex:L},width:T,height:$,className:"react-flow__edges react-flow__container"},q&&pe.createElement(jH,{defaultColor:e,rfId:s}),pe.createElement("g",null,A.map(E=>{const[D,P,z]=KC(O.get(E.source)),[G,V,H]=KC(O.get(E.target));if(!z||!H)return null;let B=E.type||"default";a[B]||(I==null||I("011",ia.error011(B)),B="default");const W=a[B]||a.default,ee=M===ti.Strict?V.target:(V.target??[]).concat(V.source??[]),U=GC(P.source,E.sourceHandle),Y=GC(ee,E.targetHandle),X=(U==null?void 0:U.position)||De.Bottom,Z=(Y==null?void 0:Y.position)||De.Top,J=!!(E.focusable||j&&typeof E.focusable>"u"),te=E.reconnectable||E.updatable,ce=typeof m<"u"&&(te||S&&typeof te>"u");if(!U||!Y)return I==null||I("008",ia.error008(U,E)),null;const{sourceX:he,sourceY:le,targetX:re,targetY:ae}=fH(D,U,X,G,Y,Z);return pe.createElement(W,{key:E.id,id:E.id,className:ln([E.className,o]),type:B,data:E.data,selected:!!E.selected,animated:!!E.animated,hidden:!!E.hidden,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,style:E.style,source:E.source,target:E.target,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerEnd:E.markerEnd,markerStart:E.markerStart,sourceX:he,sourceY:le,targetX:re,targetY:ae,sourcePosition:X,targetPosition:Z,elementsSelectable:_,onContextMenu:i,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:b,rfId:s,ariaLabel:E.ariaLabel,isFocusable:J,isReconnectable:ce,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth,disableKeyboardA11y:N})})))),v):null};b3.displayName="EdgeRenderer";var SH=y.memo(b3);const _H=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function CH({children:e}){const t=lt(_H);return pe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function EH(e){const t=Il(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const TH={[De.Left]:De.Right,[De.Right]:De.Left,[De.Top]:De.Bottom,[De.Bottom]:De.Top},k3=({nodeId:e,handleType:t,style:n,type:s=Ya.Bezier,CustomComponent:a,connectionStatus:o})=>{var $,M,O;const{fromNode:i,handleId:c,toX:d,toY:h,connectionMode:f}=lt(y.useCallback(I=>({fromNode:I.nodeInternals.get(e),handleId:I.connectionHandleId,toX:(I.connectionPosition.x-I.transform[0])/I.transform[2],toY:(I.connectionPosition.y-I.transform[1])/I.transform[2],connectionMode:I.connectionMode}),[e]),Yt),p=($=i==null?void 0:i[It])==null?void 0:$.handleBounds;let m=p==null?void 0:p[t];if(f===ti.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=c?m.find(I=>I.id===c):m[0],k=w?w.x+w.width/2:(i.width??0)/2,b=w?w.y+w.height/2:i.height??0,v=(((M=i.positionAbsolute)==null?void 0:M.x)??0)+k,N=(((O=i.positionAbsolute)==null?void 0:O.y)??0)+b,j=w==null?void 0:w.position,S=j?TH[j]:null;if(!j||!S)return null;if(a)return pe.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:v,fromY:N,toX:d,toY:h,fromPosition:j,toPosition:S,connectionStatus:o});let _="";const T={sourceX:v,sourceY:N,sourcePosition:j,targetX:d,targetY:h,targetPosition:S};return s===Ya.Bezier?[_]=sj(T):s===Ya.Step?[_]=j0({...T,borderRadius:0}):s===Ya.SmoothStep?[_]=j0(T):s===Ya.SimpleBezier?[_]=GO(T):_=`M${v},${N} ${d},${h}`,pe.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};k3.displayName="ConnectionLine";const AH=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function RH({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:c,height:d,connectionStatus:h}=lt(AH,Yt);return!(a&&o&&c&&i)?null:pe.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},pe.createElement("g",{className:ln(["react-flow__connection",h])},pe.createElement(k3,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function XC(e,t){return y.useRef(null),Ft(),y.useMemo(()=>t(e),[e])}const j3=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:o,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,onSelectionContextMenu:k,onSelectionStart:b,onSelectionEnd:v,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:T,selectionOnDrag:$,selectionMode:M,multiSelectionKeyCode:O,panActivationKeyCode:I,zoomActivationKeyCode:F,deleteKeyCode:L,onlyRenderVisibleElements:A,elementsSelectable:q,selectNodesOnDrag:E,defaultViewport:D,translateExtent:P,minZoom:z,maxZoom:G,preventScrolling:V,defaultMarkerColor:H,zoomOnScroll:B,zoomOnPinch:W,panOnScroll:ee,panOnScrollSpeed:U,panOnScrollMode:Y,zoomOnDoubleClick:X,panOnDrag:Z,onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:he,onPaneScroll:le,onPaneContextMenu:re,onEdgeContextMenu:ae,onEdgeMouseEnter:de,onEdgeMouseMove:_e,onEdgeMouseLeave:fe,onReconnect:ye,onReconnectStart:ke,onReconnectEnd:Ne,reconnectRadius:ge,noDragClassName:Me,noWheelClassName:Ie,noPanClassName:We,elevateEdgesOnSelect:Te,disableKeyboardA11y:at,nodeOrigin:Je,nodeExtent:Ve,rfId:be})=>{const Oe=XC(e,aH),ze=XC(t,hH);return EH(o),pe.createElement(sH,{onPaneClick:J,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:he,onPaneContextMenu:re,onPaneScroll:le,deleteKeyCode:L,selectionKeyCode:T,selectionOnDrag:$,selectionMode:M,onSelectionStart:b,onSelectionEnd:v,multiSelectionKeyCode:O,panActivationKeyCode:I,zoomActivationKeyCode:F,elementsSelectable:q,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:B,zoomOnPinch:W,zoomOnDoubleClick:X,panOnScroll:ee,panOnScrollSpeed:U,panOnScrollMode:Y,panOnDrag:Z,defaultViewport:D,translateExtent:P,minZoom:z,maxZoom:G,onSelectionContextMenu:k,preventScrolling:V,noDragClassName:Me,noWheelClassName:Ie,noPanClassName:We,disableKeyboardA11y:at},pe.createElement(CH,null,pe.createElement(SH,{edgeTypes:ze,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:A,onEdgeContextMenu:ae,onEdgeMouseEnter:de,onEdgeMouseMove:_e,onEdgeMouseLeave:fe,onReconnect:ye,onReconnectStart:ke,onReconnectEnd:Ne,reconnectRadius:ge,defaultMarkerColor:H,noPanClassName:We,elevateEdgesOnSelect:!!Te,disableKeyboardA11y:at,rfId:be},pe.createElement(RH,{style:j,type:N,component:S,containerStyle:_})),pe.createElement("div",{className:"react-flow__edgelabel-renderer"}),pe.createElement(lH,{nodeTypes:Oe,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:E,onlyRenderVisibleElements:A,noPanClassName:We,noDragClassName:Me,disableKeyboardA11y:at,nodeOrigin:Je,nodeExtent:Ve,rfId:be})))};j3.displayName="GraphView";var MH=y.memo(j3);const E0=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Wa={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:E0,nodeExtent:E0,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ti.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:a7,isValidConnection:void 0},$H=()=>vB((e,t)=>({...Wa,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:oy(n,s,a,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:s={}}=t();e({edges:n.map(a=>({...s,...a}))})},setDefaultNodesAndEdges:(n,s)=>{const a=typeof n<"u",o=typeof s<"u",i=a?oy(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?s:[],hasDefaultNodes:a,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:a,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,v)=>{const N=a.get(v.id);if(N!=null&&N.hidden)a.set(N.id,{...N,[It]:{...N[It],handleBounds:void 0}});else if(N){const j=J1(v.nodeElement);!!(j.width&&j.height&&(N.width!==j.width||N.height!==j.height||v.forceUpdate))&&(a.set(N.id,{...N,[It]:{...N[It],handleBounds:{source:WC(".source",v.nodeElement,m,h),target:WC(".target",v.nodeElement,m,h)}},...j}),b.push({id:N.id,type:"dimensions",dimensions:j}))}return b},[]);d3(a,h);const k=i||o&&!i&&h3(t,{initial:!0,...c});e({nodeInternals:new Map(a),fitViewOnInitDone:k}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(n,s=!0,a=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(c=>{const d={id:c.id,type:"position",dragging:a};return s&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(i)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:o,nodeOrigin:i,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=K7(n,c()),f=oy(h,a,i,d);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ka(d,!0)):(i=il(o(),n),c=il(a,[])),_h({changedNodes:i,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ka(d,!0)):(i=il(a,n),c=il(o(),[])),_h({changedNodes:c,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:o}=t(),i=n||o(),c=s||a,d=i.map(f=>(f.selected=!1,Ka(f.id,!1))),h=c.map(f=>Ka(f.id,!1));_h({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:s,maxZoom:a}=t();s==null||s.scaleExtent([n,a]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:s,minZoom:a}=t();s==null||s.scaleExtent([a,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=>Ka(c.id,!1)),i=n.filter(c=>c.selected).map(c=>Ka(c.id,!1));_h({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Q1(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:o,d3Zoom:i,d3Selection:c,translateExtent:d}=t();if(!i||!c||!n.x&&!n.y)return!1;const h=sa.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[a,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:Wa.connectionNodeId,connectionHandleId:Wa.connectionHandleId,connectionHandleType:Wa.connectionHandleType,connectionStatus:Wa.connectionStatus,connectionStartHandle:Wa.connectionStartHandle,connectionEndHandle:Wa.connectionEndHandle}),reset:()=>e({...Wa})}),Object.is),lj=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=$H()),pe.createElement(JW,{value:t.current},e)};lj.displayName="ReactFlowProvider";const N3=({children:e})=>y.useContext(mp)?pe.createElement(pe.Fragment,null,e):pe.createElement(lj,null,e);N3.displayName="ReactFlowWrapper";const LH={input:r3,default:_0,output:o3,group:oj},IH={default:Nf,straight:nj,step:tj,smoothstep:gp,simplebezier:ej},OH=[0,0],PH=[15,15],DH={x:0,y:0,zoom:1},FH={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},S3=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=LH,edgeTypes:i=IH,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:k,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:N,onNodeMouseEnter:j,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:$,onNodeDragStart:M,onNodeDrag:O,onNodeDragStop:I,onNodesDelete:F,onEdgesDelete:L,onSelectionChange:A,onSelectionDragStart:q,onSelectionDrag:E,onSelectionDragStop:D,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:G,connectionMode:V=ti.Strict,connectionLineType:H=Ya.Bezier,connectionLineStyle:B,connectionLineComponent:W,connectionLineContainerStyle:ee,deleteKeyCode:U="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:X=!1,selectionMode:Z=gu.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:te=kf()?"Meta":"Control",zoomActivationKeyCode:ce=kf()?"Meta":"Control",snapToGrid:he=!1,snapGrid:le=PH,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:ae=!0,nodesDraggable:de,nodesConnectable:_e,nodesFocusable:fe,nodeOrigin:ye=OH,edgesFocusable:ke,edgesUpdatable:Ne,elementsSelectable:ge,defaultViewport:Me=DH,minZoom:Ie=.5,maxZoom:We=2,translateExtent:Te=E0,preventScrolling:at=!0,nodeExtent:Je,defaultMarkerColor:Ve="#b1b1b7",zoomOnScroll:be=!0,zoomOnPinch:Oe=!0,panOnScroll:ze=!1,panOnScrollSpeed:st=.5,panOnScrollMode:ot=Wo.Free,zoomOnDoubleClick:Qe=!0,panOnDrag:we=!0,onPaneClick:Fe,onPaneMouseEnter:Xe,onPaneMouseMove:He,onPaneMouseLeave:ht,onPaneScroll:Ct,onPaneContextMenu:mt,children:Et,onEdgeContextMenu:Ot,onEdgeDoubleClick:js,onEdgeMouseEnter:tr,onEdgeMouseMove:Ns,onEdgeMouseLeave:es,onEdgeUpdate:Pt,onEdgeUpdateStart:Ss,onEdgeUpdateEnd:pn,onReconnect:Fn,onReconnectStart:Ce,onReconnectEnd:Pe,reconnectRadius:Ke=10,edgeUpdaterRadius:jt=10,onNodesChange:Nt,onEdgesChange:Xt,noDragClassName:ts="nodrag",noWheelClassName:pa="nowheel",noPanClassName:Bn="nopan",fitView:qn=!1,fitViewOptions:_s,connectOnClick:rn=!0,attributionPosition:ma,proOptions:nr,defaultEdgeOptions:Zt,elevateNodesOnSelect:ns=!0,elevateEdgesOnSelect:Un=!1,disableKeyboardA11y:sr=!1,autoPanOnConnect:rr=!0,autoPanOnNodeDrag:ft=!0,connectionRadius:ga=20,isValidConnection:Cs,onError:_r,style:Tt,id:Cr,nodeDragThreshold:ar,...Es},Jt)=>{const Er=Cr||"1";return pe.createElement("div",{...Es,style:{...Tt,...FH},ref:Jt,className:ln(["react-flow",a]),"data-testid":"rf__wrapper",id:Cr},pe.createElement(N3,null,pe.createElement(MH,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:j,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:$,nodeTypes:o,edgeTypes:i,connectionLineType:H,connectionLineStyle:B,connectionLineComponent:W,connectionLineContainerStyle:ee,selectionKeyCode:Y,selectionOnDrag:X,selectionMode:Z,deleteKeyCode:U,multiSelectionKeyCode:te,panActivationKeyCode:J,zoomActivationKeyCode:ce,onlyRenderVisibleElements:re,selectNodesOnDrag:ae,defaultViewport:Me,translateExtent:Te,minZoom:Ie,maxZoom:We,preventScrolling:at,zoomOnScroll:be,zoomOnPinch:Oe,zoomOnDoubleClick:Qe,panOnScroll:ze,panOnScrollSpeed:st,panOnScrollMode:ot,panOnDrag:we,onPaneClick:Fe,onPaneMouseEnter:Xe,onPaneMouseMove:He,onPaneMouseLeave:ht,onPaneScroll:Ct,onPaneContextMenu:mt,onSelectionContextMenu:P,onSelectionStart:z,onSelectionEnd:G,onEdgeContextMenu:Ot,onEdgeDoubleClick:js,onEdgeMouseEnter:tr,onEdgeMouseMove:Ns,onEdgeMouseLeave:es,onReconnect:Fn??Pt,onReconnectStart:Ce??Ss,onReconnectEnd:Pe??pn,reconnectRadius:Ke??jt,defaultMarkerColor:Ve,noDragClassName:ts,noWheelClassName:pa,noPanClassName:Bn,elevateEdgesOnSelect:Un,rfId:Er,disableKeyboardA11y:sr,nodeOrigin:ye,nodeExtent:Je}),pe.createElement(E7,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:k,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:N,nodesDraggable:de,nodesConnectable:_e,nodesFocusable:fe,edgesFocusable:ke,edgesUpdatable:Ne,elementsSelectable:ge,elevateNodesOnSelect:ns,minZoom:Ie,maxZoom:We,nodeExtent:Je,onNodesChange:Nt,onEdgesChange:Xt,snapToGrid:he,snapGrid:le,connectionMode:V,translateExtent:Te,connectOnClick:rn,defaultEdgeOptions:Zt,fitView:qn,fitViewOptions:_s,onNodesDelete:F,onEdgesDelete:L,onNodeDragStart:M,onNodeDrag:O,onNodeDragStop:I,onSelectionDrag:E,onSelectionDragStart:q,onSelectionDragStop:D,noPanClassName:Bn,nodeOrigin:ye,rfId:Er,autoPanOnConnect:rr,autoPanOnNodeDrag:ft,onError:_r,connectionRadius:ga,isValidConnection:Cs,nodeDragThreshold:ar}),pe.createElement(_7,{onSelectionChange:A}),Et,pe.createElement(e7,{proOptions:nr,position:ma}),pe.createElement($7,{rfId:Er,disableKeyboardA11y:sr})))});S3.displayName="ReactFlow";const BH=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function _3(){return lt(BH,Yt)}const C3=({id:e,x:t,y:n,width:s,height:a,style:o,color:i,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:m,selected:w})=>{const{background:k,backgroundColor:b}=o||{},v=i||k||b;return pe.createElement("rect",{className:ln(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:v,stroke:c,strokeWidth:d,shapeRendering:p,onClick:m?N=>m(N,e):void 0})};C3.displayName="MiniMapNode";var qH=y.memo(C3);const UH=e=>e.nodeOrigin,WH=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),uy=e=>e instanceof Function?e:()=>e;function HH({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=qH,onClick:i}){const c=lt(WH,Yt),d=lt(UH),h=uy(t),f=uy(e),p=uy(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return pe.createElement(pe.Fragment,null,c.map(w=>{const{x:k,y:b}=Go(w,d).positionAbsolute;return pe.createElement(o,{key:w.id,x:k,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:a,shapeRendering:m,onClick:i,id:w.id})}))}var zH=y.memo(HH);const VH=200,GH=150,KH=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?s7(yp(t,e.nodeOrigin),n):n,rfId:e.rfId}},YH="react-flow__minimap-desc";function E3({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",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:k=!1,zoomable:b=!1,ariaLabel:v="React Flow mini map",inversePan:N=!1,zoomStep:j=10,offsetScale:S=5}){const _=Ft(),T=y.useRef(null),{boundingRect:$,viewBB:M,rfId:O}=lt(KH,Yt),I=(e==null?void 0:e.width)??VH,F=(e==null?void 0:e.height)??GH,L=$.width/I,A=$.height/F,q=Math.max(L,A),E=q*I,D=q*F,P=S*q,z=$.x-(E-$.width)/2-P,G=$.y-(D-$.height)/2-P,V=E+P*2,H=D+P*2,B=`${YH}-${O}`,W=y.useRef(0);W.current=q,y.useEffect(()=>{if(T.current){const Y=gs(T.current),X=te=>{const{transform:ce,d3Selection:he,d3Zoom:le}=_.getState();if(te.sourceEvent.type!=="wheel"||!he||!le)return;const re=-te.sourceEvent.deltaY*(te.sourceEvent.deltaMode===1?.05:te.sourceEvent.deltaMode?1:.002)*j,ae=ce[2]*Math.pow(2,re);le.scaleTo(he,ae)},Z=te=>{const{transform:ce,d3Selection:he,d3Zoom:le,translateExtent:re,width:ae,height:de}=_.getState();if(te.sourceEvent.type!=="mousemove"||!he||!le)return;const _e=W.current*Math.max(1,ce[2])*(N?-1:1),fe={x:ce[0]-te.sourceEvent.movementX*_e,y:ce[1]-te.sourceEvent.movementY*_e},ye=[[0,0],[ae,de]],ke=sa.translate(fe.x,fe.y).scale(ce[2]),Ne=le.constrain()(ke,ye,re);le.transform(he,Ne)},J=PO().on("zoom",k?Z:null).on("zoom.wheel",b?X:null);return Y.call(J),()=>{Y.on("zoom",null)}}},[k,b,N,j]);const ee=m?Y=>{const X=Hs(Y);m(Y,{x:X[0],y:X[1]})}:void 0,U=w?(Y,X)=>{const Z=_.getState().nodeInternals.get(X);w(Y,Z)}:void 0;return pe.createElement(Z1,{position:p,style:e,className:ln(["react-flow__minimap",t]),"data-testid":"rf__minimap"},pe.createElement("svg",{width:I,height:F,viewBox:`${z} ${G} ${V} ${H}`,role:"img","aria-labelledby":B,ref:T,onClick:ee},v&&pe.createElement("title",{id:B},v),pe.createElement(zH,{onClick:U,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:c}),pe.createElement("path",{className:"react-flow__minimap-mask",d:`M${z-P},${G-P}h${V+P*2}v${H+P*2}h${-V-P*2}z
57
+ M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}E3.displayName="MiniMap";var XH=y.memo(E3);function ZH(){return pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},pe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function JH(){return pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},pe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function QH(){return pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},pe.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 ez(){return pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},pe.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 tz(){return pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},pe.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 fs=({children:e,className:t,...n})=>pe.createElement("button",{type:"button",className:ln(["react-flow__controls-button",t]),...n},e);fs.displayName="ControlButton";const nz=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),T3=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:i,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const m=Ft(),[w,k]=y.useState(!1),{isInteractive:b,minZoomReached:v,maxZoomReached:N}=lt(nz,Yt),{zoomIn:j,zoomOut:S,fitView:_}=Il();if(y.useEffect(()=>{k(!0)},[]),!w)return null;const T=()=>{j(),o==null||o()},$=()=>{S(),i==null||i()},M=()=>{_(a),c==null||c()},O=()=>{m.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)};return pe.createElement(Z1,{className:ln(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&pe.createElement(pe.Fragment,null,pe.createElement(fs,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},pe.createElement(ZH,null)),pe.createElement(fs,{onClick:$,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},pe.createElement(JH,null))),n&&pe.createElement(fs,{className:"react-flow__controls-fitview",onClick:M,title:"fit view","aria-label":"fit view"},pe.createElement(QH,null)),s&&pe.createElement(fs,{className:"react-flow__controls-interactive",onClick:O,title:"toggle interactivity","aria-label":"toggle interactivity"},b?pe.createElement(tz,null):pe.createElement(ez,null)),f)};T3.displayName="Controls";var sz=y.memo(T3),Ks;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ks||(Ks={}));function rz({color:e,dimensions:t,lineWidth:n}){return pe.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function az({color:e,radius:t}){return pe.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const oz={[Ks.Dots]:"#91919a",[Ks.Lines]:"#eee",[Ks.Cross]:"#e2e2e2"},iz={[Ks.Dots]:1,[Ks.Lines]:1,[Ks.Cross]:6},lz=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function A3({id:e,variant:t=Ks.Dots,gap:n=20,size:s,lineWidth:a=1,offset:o=2,color:i,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=lt(lz,Yt),m=i||oz[t],w=s||iz[t],k=t===Ks.Dots,b=t===Ks.Cross,v=Array.isArray(n)?n:[n,n],N=[v[0]*f[2]||1,v[1]*f[2]||1],j=w*f[2],S=b?[j,j]:N,_=k?[j/o,j/o]:[S[0]/o,S[1]/o];return pe.createElement("svg",{className:ln(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},pe.createElement("pattern",{id:p+e,x:f[0]%N[0],y:f[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},k?pe.createElement(az,{color:m,radius:j/o}):pe.createElement(rz,{dimensions:S,color:m,lineWidth:a})),pe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}A3.displayName="Background";var cz=y.memo(A3);function uz(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ja(e){return e!=="gone"}function ZC(e,t){return e||Ja(t)}function JC(e,t){return!e&&Ja(t)}function ll(e,t){const[n,s]=y.useState(()=>e?"here":"gone"),a=y.useRef(null);return y.useEffect(()=>{s(o=>uz(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return a.current=window.setTimeout(()=>s("gone"),t),()=>{a.current!=null&&window.clearTimeout(a.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&s("here")},[n]),n}const R3=.2,M3=1.6;function dz(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:a}=t;return typeof n!="number"||typeof s!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(a)||a<R3||a>M3?null:{x:n,y:s,zoom:a}}function T0({durationMs:e,documentHidden:t,reducedMotion:n=Bu()}){return t||n?!1:Number.isFinite(e)&&e>0}function Bu(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function cj(){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 da(e,t){return`${e}::${t}`}function Ol(e,t){return`${e}\0${t}`}const hz=/[0-9a-f]{16,}/i,fz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $3(e){return hz.test(e)||fz.test(e)}function pz(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!$3(t[n]))return t[n];return t[t.length-1]}function L3(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function I3(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,s=n.ephemeral_1h_input_tokens,a=n.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof a!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(a??0)}}function wp(e){const t=I3(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=wp({...e.longContext,longContext:void 0})),n}function mz(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 a=s;t[n]=wp(a);const o=gz(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function gz(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,wp(s)]);return t.length?Object.fromEntries(t):void 0}function O3(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),...I3(n)};for(const s of Object.values(n)){const a=O3(s,t+1);if(a)return a}return null}function uj(e){return pz(e)}function dj(e){const t=e.agent_type??e.subagent_type;return t&&!$3(t)?t:"subagent"}function Pl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function si(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=uj(t.cwd))}function hj(e,t){e.label==="session"&&t.cwd&&(e.label=uj(t.cwd)??"session")}function P3(e,t){const n=dj(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function uo(e,t,n,s){const a=t;let o=e.agents.get(a);return o||(o={id:a,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:L3()},e.agents.set(a,o),o)}function D3(e,t,n,s){const a=da(t,n),o=e.agents.get(a);return o?(si(o,s),P3(o,s),o):null}function yz(e,t,n){var h;const s=t.session_id??"unknown",a=Pl(t);if(a){const f=D3(e,s,a,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(da(s,c));if(f)return si(f,t),f}const d=uo(e,s,n,t.hook_event_name!=="SessionStart");return si(d,t),hj(d,t),d}function wz(e,t,n,s){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const a=e.agents.get(s);return!a||a.keyedSubagents?!1:(a.keyedSubagents=!0,!0)}function xz(e,t,n,s,a){const o=da(t,n),i=uo(e,t,a,!0);let c=e.agents.get(o);if(c)return si(c,s),P3(c,s),c;c={id:o,sessionId:t,label:dj(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:uj(s.cwd),toolCount:0,childCount:0,usage:L3()},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 vz(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function F3(e,t,n){const s=e.activeSubagentStack.get(t);if(s){for(let a=s.length-1;a>=0;a--)if(s[a]===n){s.splice(a,1);break}s.length===0&&e.activeSubagentStack.delete(t)}}const bz=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),B3=/^[a-z][a-z0-9_-]{0,23}$/i;function kz(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&B3.test(n)?n:bz.has(e)?null:void 0}function q3(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function fj(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"&&B3.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??q3(),currentContextTokens:t.context_tokens})}}const jz=6e4,QC=64;function U3(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 a=t.subagentModels;if(a&&typeof a=="object")for(const[o,i]of Object.entries(a)){if(typeof i!="string")continue;const c=da(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 W3(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??q3(),i=(d,h)=>typeof s[d]=="number"?s[d]:h,c=Array.isArray(s.memoryFiles)?s.memoryFiles:Array.isArray(s.claudeMdFiles)?s.claudeMdFiles:null;a.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 H3(e,t,n){const s=e.agents.get(n);if(s){const a=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";a&&(s.sessionName=a),o&&(s.sessionTitle=o);const i=s.sessionName??"";s.sessionTitle&&i&&s.sessionTitle.toLowerCase()===i.toLowerCase()&&(s.sessionTitle=void 0)}}function Nz(e,t,n){const s=e.agents.get(n);if(s){const a=t.recap;a===null?s.recap=void 0:a&&typeof a.text=="string"&&a.text.trim()&&Number.isFinite(a.at)&&(s.recap={text:a.text.trim(),at:a.at})}}function z3(e,t,n){const s=e.agents.get(n),a=t.activity;!s||!a||typeof a.text!="string"||!a.text.trim()||!Number.isFinite(a.at)||s.activity&&a.at<s.activity.at||(s.activity={text:a.text.trim(),source:a.source==="said"?"said":"tool",at:a.at})}const Sz=new Set(["working","blocked","done","failed","stopped"]);function V3(e,t,n){const s=e.agents.get(n);if(!s)return;const a=t.job;if(a===null){s.job=void 0;return}if(!a||typeof a!="object"||!Sz.has(a.state))return;const o=i=>typeof i=="string"&&i.trim()?i.trim():void 0;s.job={id:o(a.id)??"",state:a.state,detail:o(a.detail)??"",needs:o(a.needs),suggestedReply:o(a.suggestedReply),result:o(a.result),updatedAt:Number.isFinite(a.updatedAt)?a.updatedAt:0}}function _z(e,t,n,s){const a=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(!a)return;const i=e.agents.get(n);if(i&&!(i.lastOutputAt!=null&&o<=i.lastOutputAt)){if(i.lastOutputAt=o,a!=="tool_use"){const c=(i.outputs??[]).filter(d=>o-d<jz);c.push(o),i.outputs=c.length>QC?c.slice(-QC):c}e.revision+=1}}function pj(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=wp(s),i=o.inputTokens<a.usage.inputTokens||o.outputTokens<a.usage.outputTokens||o.cacheReadTokens<a.usage.cacheReadTokens||o.cacheCreateTokens<a.usage.cacheCreateTokens;Object.assign(a.usage,o),(a.provider!=="codex"||t.usageByModel!==void 0||i)&&(a.usageByModel=mz(t.usageByModel))}}}function Gt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Cz=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function eE(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const Ez={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function xp(e){const t=Cz.exec(e);if(!t)return null;const n=eE(t[1],"status");return{label:(n?Gt(Ez,n):void 0)??"background task update",detail:eE(t[1],"summary")}}function G3(e){return e.filter(t=>!xp(t.text))}const tE=2e3;function Tz(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-tE)return!1;if(a.text===n&&a.at<=t+tE)return!0}return!1}function Az(e,t,n){if(Tz(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 Sf=2e3;function Rz(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const nE=["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<nE.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${nE[n]}`}const Mz=60,$z=6e3,ws=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Kn=e=>typeof e=="string"?e:null;function Lz(e){return ws(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function Cl(e){const t=Lz(e);if(t!=null)return`(too large to show — ${Qr(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(Cl);return n.some((s,a)=>s!==e[a])?n:e}if(ws(e)){let n=!1;const s={};for(const[a,o]of Object.entries(e))s[a]=Cl(o),s[a]!==o&&(n=!0);return n?s:e}return e}function ri(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 a=[];for(const[o,i]of s){const c=n?`${t}-`:`${t}${o}:`;if(typeof i=="string"&&i.includes(`
58
+ `)){a.push(c);for(const d of i.split(`
59
+ `))a.push(`${t} ${d}`)}else if(i!==null&&typeof i=="object"){const d=ri(i,`${t} `);d==="[]"||d==="{}"?a.push(`${c} ${d}`):a.push(c,d)}else a.push(`${c} ${i===void 0?"(none)":String(i)}`)}return a.join(`
60
+ `)}function Iz(e){return e.lines??e.text.split(`
61
+ `).map(t=>({text:t}))}function K3(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===Mz)return{shown:n,cut:!0};const o=$z-s;if(a.text.length>o)return n.push({...a,text:`${a.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(a),s+=a.text.length+1}return{shown:n,cut:!1}}function Oz(e,t){return K3(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const xn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Yn=(e,t)=>({label:e,text:t,inline:!0}),Y3=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
+ `),lines:t});function Pz(e,t){return[...e.split(`
63
+ `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
+ `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function Dz(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!ws(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 a=String(s);t.push(a.startsWith("+")?{text:a,tone:"add"}:a.startsWith("-")?{text:a,tone:"del"}:{text:a})}}return t}function sE(e){if(typeof e=="string")return[xn(void 0,e)];if(!ws(e))return[xn(void 0,ri(e))];const t=[],n=Kn(e.type);n==="create"&&t.push(Yn("result","created the file"));const s=Dz(e.structuredPatch);return s&&t.push(Y3("applied",s)),e.userModified===!0&&t.push(Yn("note","the user changed it before it was applied")),t.length?t:[Yn("result",n==="update"?"updated the file":"done")]}function Fz(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 Bz(e){if(typeof e=="string")return[xn(void 0,e)];const t=ws(e)&&ws(e.file)?e.file:null,n=Kn(t==null?void 0:t.content);if(t&&n!=null){const a=[],o=Number(t.numLines),i=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&a.push(Yn("lines",o>=i?`all ${i}`:Number.isFinite(c)?`${c}–${c+o-1} of ${i}`:`${o} of ${i}`)),a.push(xn("content",n)),a}const s=ws(e)?Kn(e.type):null;return s&&s!=="text"?[Yn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[xn(void 0,ri(e))]}function qz(e){if(typeof e=="string")return[xn("output",e)];if(!ws(e))return[xn(void 0,ri(e))];const t=Kn(e.stdout),n=Kn(e.stderr);if(t==null&&n==null)return[xn(void 0,ri(e))];const s=[];return t&&s.push(xn("output",t.replace(/\n$/,""))),n&&s.push(xn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Yn("note","interrupted before it finished")),s.length?s:[Yn("output","none")]}function Uz(e,t,n){const s=Cl(t),a=Cl(n),o=ws(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Kn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(ws).filter(d=>Kn(d.old_string)!=null&&Kn(d.new_string)!=null);if(i&&c.length){const d=[Yn("file",i)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(Y3(c.length>1?`change ${f+1}${p}`:`change${p}`,Pz(h.old_string,h.new_string)))}),{input:d,response:sE(a)}}}if(o&&e==="Write"){const i=Kn(o.file_path),c=Kn(o.content);if(i&&c!=null)return{input:[Yn("file",i),xn("content",c)],response:sE(a)}}if(o&&e==="Read"){const i=Kn(o.file_path);if(i){const c=Fz(o);return{input:c?[Yn("file",i),Yn("lines",c)]:[Yn("file",i)],response:Bz(a)}}}if(o&&e==="Bash"){const i=Kn(o.command);if(i!=null){const c=Kn(o.description);return{input:c?[xn("command",i),Yn("why",c)]:[xn("command",i)],response:qz(a)}}}return{input:[xn(void 0,ri(s))],response:[xn(void 0,ri(a))]}}function rE(e,t,n){const s=Cl(n);if(s==null)return"";if(typeof s=="string")return s;if(ws(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(a=>typeof a=="string"&&a!=="").join(`
65
+ `);if(e==="Read"&&t==="response"&&ws(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 Wz=new Set(["TodoWrite","update_plan"]),Hz=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function zc(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function ps(e){return typeof e=="string"?e.trim():""}function Po(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 zz(e,t){const n=Po(t);if(!n)return null;const s=e==="TodoWrite"?n.todos:n.plan;if(!Array.isArray(s))return null;const a=[];for(const i of s){if(!i||typeof i!="object")continue;const c=i,d=ps(e==="TodoWrite"?c.content:c.step),h=zc(c.status);if(!d||!h)continue;const f=ps(c.activeForm??c.active_form);a.push(f?{text:d,status:h,active:f}:{text:d,status:h})}const o=e==="update_plan"?ps(n.explanation):"";return o?{items:a,note:o}:{items:a}}function Va(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function Vz(e,t,n,s){if(!t||!Wz.has(t)||e.plan&&s<e.plan.at)return;const a=zz(t,n);a&&(e.plan=Va(a.items,s,a.note))}function Ki(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):ps(t)}function Gz(e,t,n,s,a){var b,v,N,j,S,_,T,$,M,O,I,F,L,A,q;if(!t||!Hz.has(t))return;const o=Po(n),i=Po(s),c=((b=e.plan)==null?void 0:b.items)??[],d=E=>c.findIndex(D=>D.id===E);if(t==="TaskCreate"){const E=Po(i==null?void 0:i.task),D=Ki(E),P=ps(E==null?void 0:E.subject)||ps(o==null?void 0:o.subject);if(!D||!P)return;const z=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),G=d(D),V={id:D,text:P,status:G>=0?c[G].status:"pending",...z?{active:z}:{}},H=c.slice();G>=0?H[G]=V:H.push(V),e.plan=Va(H,Math.max(a,((v=e.plan)==null?void 0:v.at)??a),(N=e.plan)==null?void 0:N.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const E=Ki(i)||Ki(o);if(!E)return;const D=o==null?void 0:o.status,P=d(E);if(D==="deleted"){if(P<0)return;e.plan=Va(c.filter((ee,U)=>U!==P),Math.max(a,((j=e.plan)==null?void 0:j.at)??a),(S=e.plan)==null?void 0:S.note);return}const z=ps(o==null?void 0:o.subject),G=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),V=zc(D)??zc((_=Po(i==null?void 0:i.statusChange))==null?void 0:_.to);if(P<0){if(!z)return;const ee={id:E,text:z,status:V??"pending",...G?{active:G}:{}};e.plan=Va([...c,ee],Math.max(a,((T=e.plan)==null?void 0:T.at)??a),($=e.plan)==null?void 0:$.note);return}const B={...c[P],...z?{text:z}:{},...V?{status:V}:{},...G?{active:G}:{}},W=c.slice();W[P]=B,e.plan=Va(W,Math.max(a,((M=e.plan)==null?void 0:M.at)??a),(O=e.plan)==null?void 0:O.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&a<e.plan.at)return;const E=[];for(const D of i.tasks){const P=Po(D),z=Ki(P),G=ps(P==null?void 0:P.subject),V=zc(P==null?void 0:P.status);if(!z||!G||!V)continue;const H=c.find(B=>B.id===z);E.push(H!=null&&H.active?{id:z,text:G,status:V,active:H.active}:{id:z,text:G,status:V})}e.plan=Va(E,a,(I=e.plan)==null?void 0:I.note);return}const h=i&&"task"in i?Po(i.task):void 0,f=Ki(h??null)||Ki(o),p=f?d(f):-1;if(p<0)return;if(h===null){e.plan=Va(c.filter((E,D)=>D!==p),Math.max(a,((F=e.plan)==null?void 0:F.at)??a),(L=e.plan)==null?void 0:L.note);return}const m=ps(h==null?void 0:h.subject),w=zc(h==null?void 0:h.status);if(!m&&!w)return;const k=c.slice();k[p]={...c[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=Va(k,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(q=e.plan)==null?void 0:q.note)}function qu(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"),a=s?null:t.find(i=>i.status==="pending"),o=s?s.active||s.text:a?a.text:null;return{done:n,total:t.length,current:o,next:!s&&!!a,allDone:n===t.length}}function Kz(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function X3(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function Z3(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
66
+ `)}function wu(e,t=80){const n=Cl(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 aE=200;function J3(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function Q3(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Qc(e,t,n){const s=e.toolCountByName??(e.toolCountByName=new Map),a=(s.get(t)??0)+n;a>0?s.set(t,a):s.delete(t)}function Yz(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const e4=25;function t4(e,t){const n=t.tools;if(n.length>aE){const s=n.splice(0,n.length-aE);for(const a of s)s4(e,t,a)}for(let s=n.length-e4-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function Xz(e,t,n){const s=e.toolIndex.get(Ol(t.sessionId,n));if(s)return s;for(let a=t.tools.length-1;a>=0;a--)if(t.tools[a].id===n)return t.tools[a];return null}function n4(e,t){for(const n of t.tools)s4(e,t,n)}function s4(e,t,n){const s=Ol(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function Zz(e,t){const n=e.agents.get(t);if(!n)return;let s=!1;for(const a of e.agents.values()){if(a===n||a.sessionId!==t)continue;const o=a.tools.filter(i=>i.explicitSubagentId==null);if(o.length!==0){for(const i of o)a.toolCount-=1,Qc(a,i.name,-1),i.ok===!1&&(a.toolErrorCount=(a.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,Qc(n,i.name,1),i.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);a.tools=a.tools.filter(i=>i.explicitSubagentId!=null),s=!0}}if(s){n.tools.sort((a,o)=>a.startedAt-o.startedAt),t4(e,n);for(let a=0;a<n.tools.length-e4;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const Jz="no result reached the deck — events were dropped while the deck was paused";function r4(e,t,n,s,a){n.endedAt=s,J3(t,n,!1),n.errorPreview=n.outcomeGap?Jz:a,e.toolIndex.delete(Ol(t.sessionId,n.id))}function Qz(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 a=n==null?void 0:n.tool_use_id;return typeof a!="string"||a.length===0?!1:e.toolIndex.has(Ol((n==null?void 0:n.session_id)??"unknown",a))}function e9(e,t,n,s,a){const o=t.tool_use_id?Xz(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=Q3(e,o);h&&(Qc(h,"?",-1),Qc(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=wu(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,c=Pl(t),d={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:wu(t.tool_input),agentId:s.id,explicitSubagentId:c?da(n,c):void 0,startedAt:a};s.tools.push(d),s.toolCount+=1,Qc(s,d.name,1),s.state="active",e.toolIndex.set(Ol(s.sessionId,i),d),t4(e,s),Vz(s,d.name,t.tool_input,a)}function t9(e,t,n,s,a){const o=t.tool_use_id;if(!o)return;const i=Ol(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&&Gz(f,t.tool_name??c.name,t.tool_input??c.input,t.tool_response,a)}c.outcomeGap=void 0,c.endedAt=a,J3(Q3(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=wu(t.tool_response):d&&(c.errorPreview=void 0);const h=O3(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(i)}function n9(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 mj(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function s9(e,t,n,s){const a=uo(e,n,s,!1);a.synthetic=!1,a.state="active",a.closedAt=void 0,a.endedAt=void 0,mj(a,s),a.startedAt=Math.min(a.startedAt??s,s),si(a,t),hj(a,t)}function r9(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 a=uo(e,n,s,!1);a.state="active",a.endedAt=void 0,a.closedAt=void 0,a.exitAt=void 0,mj(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&Az(a.prompts,s,o)&&!a.firstPrompt&&!xp(o)&&(a.firstPrompt=wu(o,120))}function A0(e,t,n,s,a){const o=uo(e,n,s,!1),i=Rz(o);if(s<i)return;const c=o.lastTurnEndAt;if(!(c!=null&&i>c&&s<=c+Sf)){o.state="done",o.endedAt=s,o.lastTurnEndAt=s,a&&(!o.stopFailure||s>=o.stopFailure.at)&&(o.stopFailure=a.stopFailure);for(const d of o.provider==="codex"?[]:e.agents.values())if(d.sessionId===n)for(const h of d.tools)h.endedAt==null&&h.explicitSubagentId==null&&r4(e,d,h,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function a9(e,t,n){var i;const s=t.session_id;if(t.provider!=="codex"&&t.provider!=="claude"||typeof s!="string"||!s)return;const a=e.agents.get(s);if(a!=null&&a.provider&&a.provider!==t.provider||a&&Number.isFinite(t.snapshot_observed_at)&&(a.recoveryLiveAt??a.lastEventAt??0)>=t.snapshot_observed_at)return;if(t.recovery_active===!1){a&&(A0(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),a.restoredFromLog=void 0);return}const o=uo(e,s,n,!0);o.recoveryLiveAt??(o.recoveryLiveAt=(a==null?void 0:a.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,si(o,t),hj(o,t),typeof t.model=="string"&&t.model&&(o.model=t.model),!a&&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=wu(t.prompt,120))),fj(e,t,s),pj(e,t,s)}function o9(e,t,n){const s=t.session_id,a=t.parent_session_id;if(t.provider!=="codex"||typeof s!="string"||!s||typeof a!="string"||!a||s===a)return;const o=e.agents.get(s);if(o!=null&&o.provider&&o.provider!=="codex"||o!=null&&o.parentId&&o.parentId!==a)return;const i=new Set([s]);for(let f=a;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=uo(e,s,n,!0);c.provider="codex",c.parentId=a,si(c,t);const d=t.agent_nickname||t.agent_role;typeof d=="string"&&d.trim()&&(c.label=d);const h=e.agents.get(a);h&&(h.childCount=[...e.agents.values()].filter(f=>f.parentId===a).length)}const i9=["us-gov","global","apac","us","eu","jp","au"],l9=new RegExp(`^(?:(?:${i9.join("|")})\\.)?anthropic\\.`,"i");function mr(e){return e.replace(l9,"")}const c9=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,u9=new Set(["tool_input","tool_response"]);function a4(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&c9.test(mr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(u9.has(s))continue;const o=a4(a,t+1);if(o)return o}return null}const d9=256,tf={ModelObserved:U3,UsageObserved:pj,ContextObserved:W3,SessionNamed:H3,ActivityObserved:z3,JobObserved:V3},Jr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Eh=e=>typeof e=="string"&&e.trim()!=="",h9=[["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]],f9=new Set(["working","blocked","done","failed","stopped"]),oE=e=>Jr(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function p9(e,t){if(!e)return t;const n={...e};for(const[a,o]of Object.entries(t))o!==void 0&&(n[a]=o);const s=a=>{a in e?n[a]=e[a]:delete n[a]};for(const[a,o]of h9)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Jr(e.subagentModels)||Jr(t.subagentModels))&&(n.subagentModels={...Jr(e.subagentModels)?e.subagentModels:{},...Jr(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Jr(t.context)){s("context");break}const a=Jr(e.context)?{...e.context}:{};for(const[o,i]of Object.entries(t.context))(typeof i=="number"||Array.isArray(i))&&(a[o]=i);n.context=a;break}case"SessionNamed":{const a=Eh(t.sessionName)?t.sessionName:e.sessionName??null;let o=Eh(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Eh(a)&&Eh(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!oE(t.activity)||oE(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Jr(t.job)&&f9.has(t.job.state)||s("job");break;case"UsageObserved":Jr(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function m9(e,t,n,s){if(!(t in tf)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=p9(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>d9;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function g9(e,t){var s;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[a,o]of n)fj(e,o,t),(s=tf[a])==null||s.call(tf,e,o,t)}}function o4(e,t){e.parkedEnrichment.delete(t)}const y9="StopFailure",iE=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function w9(e){return typeof e=="string"&&Object.hasOwn(iE,e)?iE[e]:"api-error"}const x9=/^[a-z][a-z0-9_]{0,39}$/;function v9(e){const t=e==null?void 0:e.error;return typeof t=="string"&&x9.test(t)?t:"unknown"}const lE=160;function cE(e){if(typeof e!="string")return"";const t=e.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?/g,"").replace(/[\p{Cc}\p{Cf}]/gu," ").replace(/\bsk-ant-[A-Za-z0-9_-]+/g,"sk-ant-…").replace(/\b(Bearer)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 …").replace(/\s+/g," ").trim(),n=[...t];return n.length>lE?`${n.slice(0,lE-1).join("").trimEnd()}…`:t}function b9(e){return cE(e==null?void 0:e.last_assistant_message)||cE(e==null?void 0:e.error_details)}function k9(e,t){if(!e||typeof e!="object"||e.hook_event_name!==y9)return null;const n=v9(e);return{kind:w9(n),error:n,message:b9(e),at:t}}function j9(e,t,n,s){const a=Pl(t);if(!a)return;const o=xz(e,n,a,t,s),i=dj(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<=Sf,h=c!=null&&s-c<=Sf;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),F3(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,vz(e,n,a)}function N9(e,t,n,s){const a=Pl(t);if(!a)return;const o=D3(e,n,a,t);if(!o){for(const[i,c]of e.subagentTombstones)s-c>Sf&&e.subagentTombstones.delete(i);e.subagentTombstones.set(da(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),F3(e,n,a)}const S9=["command","cmd","file_path","path","url","pattern","notebook_path"],uE=120,dy=e=>e.length>uE?`${e.slice(0,uE-1)}…`:e;function _9(e){if(typeof e=="string")return e.trim()?dy(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of S9){const s=t[n];if(typeof s=="string"&&s.trim())return dy(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return dy(a)}}return null}function C9(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const E9=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function T9(e,t){let n=null;for(const s of e.toolIndex.values()){const a=s.agentId?e.agents.get(s.agentId):void 0;!a||a.sessionId!==t||(!n||s.startedAt>n.startedAt)&&(n=s)}return n}const A9=3e4;function R9(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>A9)&&!(e.startedAt>t))return{name:e.name,preview:_9(e.input)??""}}function M9(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=T9(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const c=R9(o,a);return c&&(i.tool=c),i}function $9(e,t,n){if(e.kind==="idle")return!0;const s=Pl(t);return s==null?!0:e.subagentId!=null&&da(n,s)===e.subagentId}function L9(e,t,n,s){if(!E9.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&$9(a.waiting,n,s)&&(a.waiting=null)}}function I9(e,t,n,s){const a=C9(t.notification_type);if(!a)return;const o=uo(e,n,s,!1),i=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===a&&c.message===i?{...c,since:Math.min(c.since,s)}:M9(e,n,a,i,s)}function vp(e){const t=[...e],n=new Map(t.map(a=>[a.id,a])),s=new Map;for(const a of t){let o=a;const i=new Set;for(;o.provider==="codex"&&o.parentId;){if(i.has(o.id)){o=a;break}i.add(o.id);const c=n.get(o.parentId);if(!c||c.provider!=="codex")break;o=c}s.set(a.id,o.sessionId)}return s}function Uu(e,t){return t&&(e.revision+=1),t}function O9(e,t,n,s,a){if(e.agents.size<=n)return!1;const o=w=>w.state==="done"&&w.endedAt!=null&&t-w.endedAt>s,i=vp(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,k]of e.agents){if(k.parentId!=null){const b=h.get(k.parentId);b?b.push(w):h.set(k.parentId,[w])}o(k)&&!c.has(i.get(w))&&d.push({id:w,endedAt:k.endedAt})}if(d.length===0)return!1;d.sort((w,k)=>w.endedAt-k.endedAt);let f=0;const p=new Set,m=w=>{const k=e.agents.get(w);k&&(n4(e,k),e.agents.delete(w),k.kind==="root"&&o4(e,k.sessionId),p.add(k.sessionId),f++)};for(const w of d){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const k=[],b=new Set([w.id]),v=[...h.get(w.id)??[]];for(;v.length;){const N=v.pop();if(b.has(N))continue;b.add(N);const j=e.agents.get(N);j&&(k.push(j),v.push(...h.get(N)??[]))}if(!k.some(N=>!o(N))){for(const N of k.reverse())m(N.id);m(w.id)}}if(a&&p.size>0){const w=new Set;for(const k of e.agents.values())w.add(k.sessionId);for(const k of p)w.has(k)||a(k)}return Uu(e,f>0)}function P9(e,t,n,s,a){const o=new Map;for(const[m,w]of e.agents){let k=o.get(w.sessionId);k||(k={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,k)),k.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(k.closed=!0),w.state==="done"&&w.endedAt!=null?k.endedAt=Math.max(k.endedAt,w.endedAt):k.live=!0}const i=vp(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 v=e.agents.get(b);v&&n4(e,v),e.agents.delete(b)}o4(e,m);const k=da(m,"");for(const b of e.pendingSubagentModels.keys())b.startsWith(k)&&e.pendingSubagentModels.delete(b);a==null||a(m),f--,p=!0}return Uu(e,p)}function D9(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 Uu(e,t)}function F9(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.provider==="codex")continue;const o=e.agents.get(a.sessionId),i=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of a.tools){const d=Math.max(c.startedAt,i??c.startedAt);c.endedAt==null&&t-d>n&&(r4(e,a,c,d,"session ended before this call returned"),s=!0)}}return Uu(e,s)}const dE=90*6e4;function B9(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.kind!=="root")continue;const o=a.lastEventAt??a.startedAt;if(!(t-o<=n)){a.waiting&&(a.waiting=null,s=!0),a.closedAt==null&&(a.closedAt=o),a.state==="active"&&(a.state="done",a.endedAt=o,a.reaped=!0,s=!0);for(const i of e.agents.values())i.sessionId!==a.sessionId||i.kind==="root"||i.state!=="active"||(i.state="done",i.endedAt=o,s=!0);e.activeSubagentStack.delete(a.sessionId)}}return Uu(e,s)}function xu(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 i4(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??{},a=t.receivedAt,o=s.hook_event_name??"Unknown";if(o==="__clear")return{...cj(),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 a9(e,s,a),e;if(o==="CodexThreadLinked")return o9(e,s,a),e;const i=s.session_id??"unknown";if(L9(e,o,s,i),o!=="JobObserved"&&n9(e,i,a),fj(e,s,i),m9(e,o,s,i))return e;switch(o){case"ModelObserved":return U3(e,s,i),e;case"ContextObserved":return W3(e,s,i),e;case"SessionNamed":return H3(e,s,i),e;case"SessionRecapped":return Nz(e,s,i),e;case"ActivityObserved":return z3(e,s,i),e;case"JobObserved":return V3(e,s,i),e;case"OutputObserved":return _z(e,s,i,a),e;case"UsageObserved":return pj(e,s,i),e}const c=yz(e,s,a),d=e.agents.get(i);d&&a>=(d.recoveryLiveAt??0)&&(d.recoveryLiveAt=a,d.restoredFromLog=void 0),g9(e,i),wz(e,o,s,i)&&Zz(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=a4(s),f=Pl(s),p=f?da(i,f):i;h&&c.id===p&&(c.model=h);const m=kz(o,s);switch(m!==void 0&&c.id===p&&(c.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&mj(e.agents.get(i),a),o){case"SessionStart":s9(e,s,i,a);break;case"UserPromptSubmit":r9(e,s,i,a);break;case"PreToolUse":e9(e,s,i,c,a);break;case"PostToolUse":case"PostToolUseFailure":t9(e,s,o,i,a);break;case"SubagentStart":j9(e,s,i,a);break;case"SubagentStop":N9(e,s,i,a);break;case"Stop":case"StopFailure":A0(e,o,i,a,{stopFailure:k9(s,a)});break;case"SessionEnd":A0(e,o,i,a);break;case"Notification":I9(e,s,i,a);break}return e}const q9="codex-auto-review",l4="chatgpt-auto-review-free",U9={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},W9=[{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:U9},{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}}],H9=[{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 c4(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function br(e,t=Date.now(),n=la){if(!e)return null;if(e===q9&&n===l4)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==la&&c4(e)){const i=/^gpt[-_]6(?:[-_.]1)?[-_](?:astra|sol|luna)\b(?![-_][A-Za-z])/i.test(e)?new Map([["fast",2],["flex",.5]]).get(n):void 0,c=i===void 0?null:br(e,t);return c&&i!==void 0?{input:c.input*i,output:c.output*i,cacheRead:c.cacheRead*i,cacheWrite:c.cacheWrite*i}:null}const s=z9.get(n);if(!s)return null;const a=mr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const la="standard",z9=new Map([[la,W9],["fast",H9]]);function eu(e,t){return e*t/1e6}function u4(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),a=Math.max(0,e.cacheCreateTokens-n-s),o=s+a,i=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:eu(o,t.cacheWrite),usd1h:eu(n,i)}}function d4(e,t,n=Date.now()){if(!c4(t))return e.inputTokens;const s=br(t,n),a=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-a)}function bp(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of Wu(e)){const o=vu(a.usage,t,a.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 vu(e,t,n,s=Date.now()){const a=br(t,s,n);if(!a)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 h4(e,t)){const c=i.usage,d=f4(a,i.long);o.input+=eu(d4(c,t,s),d.input),o.output+=eu(c.outputTokens,d.output),o.cacheRead+=eu(c.cacheReadTokens,d.cacheRead);const h=u4(c,d);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function h4(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(mr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:gj(e,[n]),long:!1},{usage:n,long:!0}]}function f4(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 Wu(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:la,usage:e}]:[{speed:la,usage:gj(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function gj(e,t){const n=o=>t.reduce((i,c)=>i+(o(c)??0),0),s=o=>Math.max(0,(o(e)??0)-n(o)),a={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)&&(a.cacheCreate1hTokens=s(o=>o.cacheCreate1hTokens),a.cacheCreate5mTokens=s(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(a.reasoningOutputTokens=e.reasoningOutputTokens),e.longContext&&(a.longContext=gj(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const ca="not priced";function tu(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function nt(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=tu(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=tu(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=tu(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function yj(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${nt(s)}/min`:`${nt(n*3600)}/hr`}function R0(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=R0(e.longContext??s,t.longContext??s)}if(e.bySpeed||t.bySpeed){const s=new Map(Object.entries(e.bySpeed??{}));for(const[a,o]of Object.entries(t.bySpeed??{})){const i=s.get(a);s.set(a,i?R0(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function V9(e,t){let n=0,s=0,a=0,o=0,i=0,c=0;for(const p of t)n+=p.inputTokens,s+=p.outputTokens,a+=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,a),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 Dl(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]})),a=V9(e.usage,s.map(o=>o.usage));if(a){const o=s.findIndex(i=>i.model===e.model);o>=0?s[o]={model:s[o].model,usage:R0(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function On(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Dl(e)){const a=bp(s.usage,s.model,t);n.input+=a.input,n.output+=a.output,n.cacheRead+=a.cacheRead,n.cacheWrite+=a.cacheWrite,n.total+=a.total}return n}function M0(e,t=Date.now()){return Dl(e).every(n=>{const s=Wu(n.usage).filter(({usage:a})=>a.inputTokens+a.outputTokens+a.cacheReadTokens+a.cacheCreateTokens+(a.cacheCreate1hTokens??0)+(a.cacheCreate5mTokens??0)>0);return s.length>0?s.every(a=>br(n.model,t,a.speed)!==null):br(n.model,t)!==null})}function El(e,t=Date.now()){let n=0;for(const s of Dl(e))for(const a of Wu(s.usage))br(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function p4(e){const t=[];for(const n of Dl(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 wj(e){return p4(e).filter(t=>t!==e.model)}function hE(e,t){return(/^gpt[-_]/i.test(t??"")?`API-equivalent estimate. Recorded Codex settings do not confirm the served tier; tokens without tier evidence use standard rates.
67
+ `:"")+G9(e,t)}function G9(e,t){if(!e.bySpeed)return hy(e,t,la);const n=Wu(e).filter(s=>s.speed!==la||m4(s.usage));return n.length===1?hy(n[0].usage,t,n[0].speed):[...n.map(s=>hy(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${nt(bp(e,t).total)}`].join(`
68
+ `)}function m4(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function hy(e,t,n){const s=h4(e,t).filter(a=>m4(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>fE(a.usage,t,n,a.long)),`all context tiers = ${nt(vu(e,t,n).total)}`].join(`
69
+ `):fE(e,t,n,!1)}function fE(e,t,n,s){const a=br(t,Date.now(),n),o=a?f4(a,s):null,i=s?" · prompt >100K":"",c=(n===l4?`model: ${t} · no charge for ChatGPT auto-review`:n===la?`model: ${t}`:`model: ${t} · ${n}`)+i;if(!o)return`${c}
70
+ no published rate in this build — the tokens are counted, the dollars are not`;const d=b=>b.toLocaleString(),h=b=>`$${b}/MTok`,f=vu(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=u4(e,o),m=p.tokens1h>0?[`cache w5m${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${nt(p.usd5m)}`,`cache w1h${d(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${nt(p.usd1h)}`]:[`cache w ${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${nt(p.usd5m)}`],w=d4(e,t),k=w===e.inputTokens?"input":"uncached";return[c,`${k.padEnd(9)}${d(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${nt(f.input)}`,`output ${d(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${nt(f.output)}`,`cache r ${d(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${nt(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${nt(f.total)}`].join(`
71
+ `)}function pE(e){const t=Dl(e),[n]=t;return t.length<=1?hE(n.usage,n.model):[...t.map(s=>hE(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${nt(On(e).total)}`].join(`
72
+ `)}function K9(e){if(!e.model)return null;const t=br(e.model),n=On(e),s=El(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:pE(e)};if(n.total<=0)return null;const a=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?yj(n.total,a):null,i=pE(e)+(o?`
73
+ burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const Y9=new Set(["untrusted","on-request","on-failure"]);function X9(e){return typeof e!="string"||!e?null:Y9.has(e)?!0:e==="never"?!1:null}function g4(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=X9(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."}
74
+
75
+ 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 mE(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function ro(e){const t=mr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=mE(n[1]),o=n[2].replace(/[-_]/g,".");return`${a} ${o}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const a=s[1].replace(/[-_]/g,"."),o=s[2].split(/[-_]/).filter(Boolean).map(mE);return[`GPT-${a}`,...o].join(" ")}return e}function kp(e){const t=mr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function jp(e,t){return t?`${ro(e)} · ${t}`:ro(e)}function bu(e,t){return t?`${e}
76
+ effort: ${t}`:e}function Z9(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function J9(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function Q9(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 $0(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 eV(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function tV(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Np(e,t){return`${e}@${t.since}`}function y4(e,t){if(!e.tool)return null;const{name:n,preview:s}=e.tool,a=new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(t);return s?a?s:`${n} · ${s}`:a?null:n}function nV(e){const t=e.message||"Needs your permission",n=y4(e,t);return n?`${t}
77
+ Likely on: ${n}`:t}function sV(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!Mn(o.waiting))continue;const i=Np(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:nV(o.waiting),sessionId:o.id})}return a}function rV(e,t,n){const s=new Set;for(const o of e)s.add(Np(o.id,o.waiting));const a=new Set;for(const o of n)s.has(o)&&a.add(o);for(const o of t)a.add(o.key);return a}function Th(e){return new Set(e.map(t=>Np(t.id,t.waiting)))}function aV(e,t){return e!==t}function oV(e,t){return!e&&t!=null}function iV(e,t){return e!==null&&t!=null}function xj(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function w4(e){return`Stopped · ${xj(e.kind)}`}function x4(e){const t=xj(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function vj(e,t=!1){if(t)switch(e){case"login":return"Press Continue once a working login is active.";case"usage-limit":return"Press Continue once the limit resets or another account is active.";default:return"Press Continue to run the turn again."}switch(e){case"login":return"Type “continue” in this session once a working login is active.";case"usage-limit":return"Type “continue” in this session once the limit resets or another account is active.";default:return"Type “continue” in this session to run the turn again."}}function lV(e){switch(e.kind){case"login":return"Claude Code stopped this turn: the login expired.";case"usage-limit":return"Claude Code stopped this turn: a usage limit was reached.";default:return`Claude Code stopped this turn on an API error (${e.error.replace(/_/g," ")}).`}}function cV(e){return e.message?`It said: “${e.message}”`:""}function uV(e,t=!1){return[lV(e),cV(e),vj(e.kind,t)].filter(Boolean).join(`
78
+ `)}function dV(e,t=!1){return`${x4(e)}. ${vj(e.kind,t)}`}function hV(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function fV(e,t=!1){const n=vj(e.kind,t).replace(/\.$/,"");return`stopped, ${xj(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function Sp(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function Tl(e){return e==="active"?"live":e==="done"?"done":"err"}function Al(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function pV(e){return`${e} subagent${e===1?"":"s"} spawned`}function mV(e){const t=[Sp(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=wj(e).length;t.push(`${ro(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function gV(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=On(e,t).total;return[e.label,Sp(e),e.kind==="root"&&e.stopFailure?fV(e.stopFailure,e.job!=null):Tl(e.state),Mn(e.waiting)?Al(e.waiting):null,e.model?ro(e.model):null,(()=>{const o=qu(e.plan);return o?X3(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,a>0?`${nt(a)}${El(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function v4(e,t){const n=y4(e,t);return n?`Likely on: ${n}`:null}function _f(e){return e.kind==="idle"?"Your turn":Al(e)}function wt(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=tu(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=tu(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function Rl(e,t,n){const s=(t??n)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const o=Math.floor(a/60);if(o>=100)return`${Math.floor(o/60)}h ${o%60}m`;const i=a%60;return`${o}m ${String(i).padStart(2,"0")}s`}function b4(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 _p(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 gE=2e5,yV=1e6,wV=[/\[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],xV=[{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 vV(e){if(!e)return gE;const t=mr(e);for(const n of wV)if(n.test(t))return yV;for(const n of xV)if(n.match.test(t))return n.window;return gE}function k4(e,t){return typeof e=="number"&&e>0?e:vV(t)}const bV=1;function kV(){const e=[];let t=0;function n(){let s;for(const a of e)(!s||a.layer>s.layer||a.layer===s.layer&&a.seq>s.seq)&&(s=a);return s}return{push(s,a=0,o="dialog"){const i={dismiss:s,layer:a,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 a=n();return a!=null&&a.dismiss===s},depth(){return e.length},dialogDepth(){return e.filter(s=>s.kind==="dialog").length}}}const vn=kV(),j4=e=>e==="Escape";function jV(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function yE(e){return String(e.tagName??"").toUpperCase()==="BODY"}function wE(e,t){return!e||!e.isConnected||yE(e)?!1:t==null||yE(t)}const Cf="a[href], button, input, select, textarea, summary, [tabindex]";function N4(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function NV(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function SV({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 Cp(e){return e.ctrlKey||e.metaKey||e.altKey}function _V(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const CV=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),EV=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),TV=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function bj(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function AV(e){return bj(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Ko(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=bj(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!CV.has(String(e.type??"text").toLowerCase())}function RV(e,t){if(!e)return!1;if(Ko(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&AV(e))return!1;if(EV.has(bj(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>TV.has(s))}function MV({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function $V({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!Ko(n)}function nf({appModal:e,dialogDepth:t}){return e||t>0}function S4(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Cf))return N4({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)&&NV({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Cf)!=null}):!1}):[]}function LV(e,t){const n=S4(e);if(!t||!e.contains(t)||n.includes(t))return n;const s=n.findIndex(a=>(t.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return s===-1?[...n,t]:[...n.slice(0,s),t,...n.slice(s)]}function pt(e,t={}){const{focusRef:n,restoreFocusFallback:s,layer:a,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(()=>vn.push(f,a,i),[f,a,i]),y.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??S4(c.current)[0])==null||m.focus(),()=>{if(wE(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();wE(w,document.activeElement)&&w.focus()}}},[]),y.useEffect(()=>{const p=m=>{var j;if(m.key!=="Tab"||Cp(m))return;const w=c.current;if(!w)return;const k=document.activeElement;if(!(k!=null&&w.contains(k))&&!vn.isTop(f))return;const v=LV(w,k),N=SV({count:v.length,index:k?v.indexOf(k):-1,shiftKey:m.shiftKey});N.kind!=="allow"&&(m.preventDefault(),N.kind==="focus"&&((j=v[N.index])==null||j.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),c}function gt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const s=t.current&&n.target===n.currentTarget;t.current=!1,s&&e()}}}function IV(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 hs(e){return e.toLocaleString()}const OV=60;function PV(e,t=OV){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 DV({agent:e,onClose:t}){var w;const n=y.useRef(null),s=pt(t,{focusRef:n}),a=gt(t),o=e.context,i=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=k4(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=On(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=IV(e.provider);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[r.jsxs("header",{className:"ctx-modal-head",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),r.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),r.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("section",{className:"ctx-window-row",children:[r.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:r.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),r.jsxs("div",{className:"ctx-window-meta",children:[r.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),r.jsxs("span",{children:[hs(c)," / ",hs(d)," tok (",m.windowScope,")"]})]})]}),r.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),r.jsxs("div",{className:"ctx-grid",children:[r.jsx(qs,{label:"input tokens",val:hs(i.inputTokens)}),r.jsx(qs,{label:"output tokens",val:hs(i.outputTokens)}),r.jsx(qs,{label:"cache reads",val:hs(i.cacheReadTokens)}),r.jsx(qs,{label:"cache writes",val:hs(i.cacheCreateTokens)}),r.jsx(qs,{label:"cumulative total",val:hs(p)}),r.jsx(qs,{label:"estimated cost",val:nt(f.total),accent:!0})]}),r.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?r.jsxs("div",{className:"ctx-grid",children:[r.jsx(qs,{label:"user messages",val:hs((o==null?void 0:o.msgsUser)??0)}),r.jsx(qs,{label:"assistant messages",val:hs((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(qs,{label:"tool uses",val:hs((o==null?void 0:o.toolUses)??0)}),r.jsx(qs,{label:"tool results",val:hs((o==null?void 0:o.toolResults)??0)}),r.jsx(qs,{label:"system-reminders",val:hs((o==null?void 0:o.systemReminders)??0)})]}):r.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),r.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((w=o==null?void 0:o.memoryFiles)==null?void 0:w.length)??0)===0?r.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):r.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(k=>r.jsxs("li",{children:[r.jsx("span",{className:"ctx-md-path",title:k.path,children:PV(k.path)}),r.jsx("span",{className:"ctx-md-size",children:Qr(k.bytes)})]},k.path))})]})})}function qs({label:e,val:t,accent:n}){return r.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[r.jsx("span",{className:"ctx-row-label",children:e}),r.jsx("span",{className:"ctx-row-val",children:t})]})}function FV({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=k4(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 r.jsx("button",{type:"button",className:"ctx-donut",onClick:m=>{m.stopPropagation(),a==null||a()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(i*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(i*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:r.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,"aria-hidden":"true",children:[r.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),r.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)"}}),r.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(i*100)})]})})}const xE=new Map;function _4(e){let t=xE.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},xE.set(e,t)),t}function BV(e,t){const n=_4(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 qV(e){return _4(e).now}const vE=new Map,bE=new Map;function Nr(e=1e3){let t=vE.get(e);t||(t=s=>BV(e,s),vE.set(e,t));let n=bE.get(e);return n||(n=()=>qV(e),bE.set(e,n)),y.useSyncExternalStore(t,n,n)}function UV(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 WV="1",kE="agent-dag.schema",HV=["agent-dag.layout","agent-dag.viewport"];function Ye(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 Ys(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function gr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function zV(e,t=WV){let n=null;try{n=e.getItem(kE)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of HV)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(kE,t)}catch{}return s}const C4="agent-dag.recapsDismissed",jE=200;function VV(){const e=Ye(C4);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Ml=new Set(VV());const L0=new Set;let E4=0;function T4(e){return L0.add(e),()=>{L0.delete(e)}}function A4(e){Ml=e,E4++;const t=Array.from(e);Ze(C4,JSON.stringify(t.length>jE?t.slice(-jE):t));for(const n of L0)n()}function GV(e,t){return`${e}@${t}`}function KV(e){return Ml.has(e)}function YV(e){if(Ml.has(e))return;const t=new Set(Ml);t.add(e),A4(t)}function XV(e){const t=new Set(Ml);t.delete(e)||t.add(e),A4(t)}function ZV(e){return y.useSyncExternalStore(T4,()=>e!=null&&Ml.has(e),()=>!1)}function kj(e){return`recap:${e}`}function JV(e){return e.startsWith("recap:")}function QV(){return y.useSyncExternalStore(T4,()=>E4,()=>0)}function no(e){switch(e){case"recap":return"recap";case"needs":return"needs you";case"done":return"done";case"failed":return"failed";case"stopped":return"stopped";case"last":return"last";default:return"now"}}function eG(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 tG(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const NE=160;function nG(e){const t=xp(e);if(t)return t.detail?`${t.label}: ${t.detail}`:t.label;const s=(e.split(`
79
+ `).map(a=>a.trim()).find(Boolean)??"").replace(/\s+/g," ");return s.length>NE?s.slice(0,NE-1).trimEnd()+"…":s}function sG(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:dV(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=tG(e),s=(n==null?void 0:n.at)??e.startedAt,a=c=>({...c,key:`${e.sessionId}@${c.kind==="last"?"now":c.kind}:${s}`}),o=e.job?eG(e.job):null;if(o)return a(o);const i=e.activity;if(i&&(!n||n.at<=i.at))return a({kind:e.state==="active"?"now":"last",text:i.text,at:i.at,source:"activity"});if(n&&e.state==="active"){const c=nG(n.text);if(c){const d={kind:"now",text:c,at:n.at,source:"prompt"};return e.provider==="codex"&&(d.codex=!0),a(d)}}return null}function Ep(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=sG(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=UV(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:GV(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function Tp(e){switch(e.source){case"recap":return"Claude Code's recap";case"job":return"Claude Code's own line for this background session";case"stop":return hV(e.stop);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 rG(e){const t=new Map,n=[...e],s=vp(n);for(const a of n){if(a.kind!=="subagent"&&!(a.provider==="codex"&&a.parentId)||a.exitAt!=null)continue;const o=s.get(a.id)??a.sessionId;if(a.provider==="codex"&&o===a.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,a.state==="active"?i.live+=1:a.state==="err"?i.err+=1:i.done+=1,i.failed+=a.toolErrorCount??0}return t}function R4(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 M4(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function aG(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"};const a=e.kind==="root"?e.stopFailure:null;if(a)return{tone:"err",long:w4(a),short:x4(a)};if(s&&s.kind==="idle"){const i=n.sayWaiting(s);return{tone:"idle",long:i,short:i}}const o=e.toolErrorCount??0;if(o>0)return{tone:"err",long:`${o} tool ${o===1?"call":"calls"} failed`,short:`${o} failed`};if(t&&t.total>0)return{tone:"muted",long:R4(t),short:M4(t)};if(e.state==="active"){const i=qu(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:Kz(i),short:`${i.done}/${i.total} done`}}if(e.state==="active")for(let i=e.tools.length-1;i>=0;i--){const c=e.tools[i];if(c.endedAt!=null)continue;const{name:d,subject:h}=n.describeCall(c);return{tone:"muted",long:h?`${d} · ${h}`:d,short:d}}return null}function oG(e,t){return t?t.includes(e)?t:`${e}
80
+ ${t}`:e}function yl(e){return e.kind==="root"&&e.stopFailure&&e.state==="done"?"err":e.state}function I0(e){return e==="active"?"live":e==="done"?"done":"err"}const Ap={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"}},iG=Object.fromEntries(Object.entries(Ap).map(([e,t])=>[e,t.category])),lG=Object.fromEntries(Object.entries(Ap).map(([e,t])=>[e,t.emoji])),cG=Object.fromEntries(Object.entries(Ap).map(([e,t])=>[e,t.label])),uG=new Set(Object.entries(Ap).filter(([,e])=>e.shell).map(([e])=>e)),dG={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",...iG};function $4(e){return e.startsWith("mcp__")?"mcp":Gt(dG,e)??"other"}const hG=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,fG=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function pG(e){if(typeof e!="string"||!e)return null;const t=hG.exec(e);if(t){const s=mG(t[2]);if(s.trim())return s}const n=fG.exec(e);return n?n[1]:null}function mG(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
81
+ `:n==="r"?"\r":n==="t"?" ":n)}const gG={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:"📡",...lG};function SE(e){return e.startsWith("mcp__")?"🔌":Gt(gG,e)??"✨"}const yG={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 L4(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function I4(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=>L4(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return I4(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 a=s[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(a.replace(/^.*[/\\]/,""))?(a=a.replace(/^.*[/\\]/,""),a=a.replace(/\.(exe|cmd|bat|ps1)$/i,""),a||null):null}function wG(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=pG(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(L4);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const xG=new Set(["Bash","PowerShell",...uG]);function vG(e,t){if(!xG.has(e))return null;const n=wG(t);if(!n)return null;const s=I4(n);return s?{emoji:Gt(yG,s)??"⚙️",label:s,category:"shell",detail:n}:null}const bG=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),kG={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:"🗄️"},jG={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 NG(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function SG(e){const t=e.toLowerCase(),n=Gt(jG,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 a=Gt(kG,t.slice(s+1));if(a!==void 0)return a}return"📄"}function _G(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 CG(e,t){if(!bG.has(e))return null;const n=_G(e,t);if(!n)return null;const s=NG(n);return s?{emoji:e==="LS"?"📂":SG(s),label:s,category:"file",detail:n}:null}const EG={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 jj(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 TG(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 O4(e){return Gt(EG,e.toLowerCase())}function AG(e,t){const n=jj(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=O4(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function P4(e,t){return vG(e,t)??CG(e,t)??AG(e)}function RG(e,t){var n;return((n=P4(e,t))==null?void 0:n.label)??null}const MG=cG,_E=18;function Ah(e){const t=[...e];return t.length<=_E?e:t.slice(0,_E-1).join("")+"…"}const fy=13,$G=6;function LG(e,t){const n=[...e];if(n.length<=fy)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=$G?n.slice(0,fy-1-a.length).join("")+"…"+a.join(""):n.slice(0,fy-1).join("")+"…"}function Nj(e){const t=jj(e);if(t){const s=O4(t.server);return s?{emoji:s.emoji,label:Ah(s.name)}:{emoji:"🔌",label:Ah(t.server),hue:TG(t.server)}}const n=Gt(MG,e)??"";return n?{emoji:SE(e),label:Ah(n)}:{emoji:SE(e),label:Ah(e)}}function IG(e){let t=null,n="";for(const s of e){const a=jj(s);if(a){if(!a.server)return null;if(t===null)t=a.server,n=s;else if(a.server!==t)return null}}return t===null?null:Nj(n)}const O0=6e4,wl=24,CE=O0/wl,py=132,sf=14;function OG(e,t,n){const s=new Array(wl).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=O0)return;const k=wl-1-Math.floor(w/CE);k>=0&&k<wl&&(s[k]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const c=Math.max(0,...s)/(CE/1e3),d=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<O0).length,h=a-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=a===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:s,title:p}}const PG=2;function DG(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/PG)*sf)}function D4({kind:e}){return r.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"&&r.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&r.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"&&r.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 Sj(){return r.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),r.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function F4(){return r.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[r.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"}),r.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function Ef({recap:e}){return e?r.jsx(F4,{}):r.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:r.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}async function ho(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(a=>window.setTimeout(()=>a(!1),t))])}catch{n=!1}if(n)return!0;try{const a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(a),a.select(),n=document.execCommand("copy"),a.remove()}catch{n=!1}return n}function ao(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Rp(e){return e==null}const P0="self";function $n(e,t=!1){const n=ao(e?P0:null,P0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function bn(e){return Rp(e?P0:null)}const ai=400;function oi({armedFor:e,target:t,armedAt:n,now:s,gapMs:a}){return e!==t?"arm":s-n<a?"ignore":"fire"}function B4(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Pn(e){return e==null||e==="BODY"||e==="HTML"}const q4="Continue from where you left off.";function FG(e,t){return!e||typeof e!="object"?{ready:!1,reason:"no-login"}:e.kind!=="login"&&e.kind!=="usage-limit"?{ready:!0,reason:null}:!t||!t.ok?{ready:!1,reason:"no-login"}:t.at>e.at?t.room===!1?{ready:!1,reason:"no-room"}:{ready:!0,reason:null}:{ready:!1,reason:"before-stop"}}function U4(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 Tf(e){return U4(Math.floor(e/1e3))}function Hu(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),a=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return s>0?`${s}d ${a}h`:a>0?`${a}h ${o}m`:`${o}m`}function BG(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Af(e,t,n){const s=new Date(e),a=Tf(t-e);return{label:BG(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function _j(e){switch(e){case"before-stop":return"Not yet: nothing shows a working login since it stopped. The active account's next usage reading will.";case"no-room":return"Not yet: the active account has no room left in its 5-hour or 7-day window.";case"no-login":return"Not yet: the active account's usage could not be read, so there is no sign of a working login.";default:return""}}function qG(e,t="",n=!1){const s=t?`: ${t.replace(/[.\s]+$/,"")}`:"";switch(e){case"interactive":return"This session runs in a terminal, so ccdeck can't continue it. Type “continue” there.";case"not_listed":return"Claude Code doesn't list it as a background session any more, so nothing was sent.";case"working":return"It's working again already, so nothing was sent.";case"waiting":return"It's waiting on a prompt or a dialog. Answer it in agent view or with claude attach.";case"not_held":return"Claude Code doesn't show it as held up, so it wasn't continued automatically.";case"no_dir":return"Its folder is gone, so it can't be resumed there.";case"unreadable":return"claude agents --json printed something ccdeck couldn't read, so nothing was sent.";case"cli_failed":return`claude agents --json failed${s}. Nothing was sent.`;case"stop_failed":return`claude stop failed${s}. Nothing was sent.`;case"still_running":return"Claude Code still lists its process as running after claude stop, so nothing was sent.";case"resume_failed":return n?`ccdeck stopped it, then claude --resume --bg failed${s}. The conversation is kept: open it from agent view.`:`claude --resume --bg failed${s}.`;case"busy":return"A continue is already running for it.";case"not_ready":return t||"Not yet: there is no sign of a working login since it stopped.";case"unreachable":return"ccdeck's server could not be reached.";default:return"ccdeck refused the request."}}function Cj(e,t){const n=Tf(t-e.at);return e.ok?`${e.outcome==="copied"?"Continued as a copy":"Continued"}${e.auto?" automatically":""} ${n}`:`${e.auto?"Automatic continue failed":"Continue failed"} ${n}`}function Rf(e){if(!e.ok)return qG(e.reason,e.detail,e.stopped);const t=e.auto?"ccdeck continued it automatically once a working login was active":"Continued from ccdeck",n=e.outcome==="copied"?`
82
+ Claude Code started a copy instead of continuing it in place${e.detail?`: “${e.detail}”`:"."}`:"";return`${t}. It sent: “${q4}”${n}`}function W4({auto:e,kind:t,held:n,tried:s}){return!e||t!=="login"&&t!=="usage-limit"?"":n?"Not continued automatically: it stopped again after the last automatic continue. Press Continue to try again.":s?"":"Continues automatically once a working login with room is active."}function UG(e){return`This session runs in a terminal, and ccdeck can't type into it. Type “continue” there${e==="login"?" once a working login is active":e==="usage-limit"?" once the limit resets or another account is active":""}.`}function WG(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${q4}"`].join(`
83
+ `)}let so={answer:null,pressing:new Set,pressed:{}};const my={current:new Set},D0=new Set;function F0(e){so={...so,...e};for(const t of D0)t()}const HG=e=>(D0.add(e),()=>{D0.delete(e)}),EE=()=>so;function Ej(){return y.useSyncExternalStore(HG,EE,EE)}const zG=new Set(["login","usage-limit","api-error"]),Tj=e=>typeof e=="number"&&Number.isFinite(e)?e:null,H4=e=>typeof e=="string"?e:"";function VG(e){if(!e||typeof e!="object")return null;const t=e,n=Tj(t.at);return n==null?null:{at:n,auto:t.auto===!0,ok:t.ok===!0,outcome:t.outcome==="continued"||t.outcome==="copied"?t.outcome:null,reason:typeof t.reason=="string"?t.reason:null,detail:H4(t.detail),stopped:t.stopped===!0}}function GG(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:Tj(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function KG(e,t){if(!e||typeof e!="object"||e.ok!==!0)return null;const n=e,s={},a=n.sessions&&typeof n.sessions=="object"?n.sessions:{};for(const[o,i]of Object.entries(a)){if(!i||typeof i!="object")continue;const c=i,d=c.stop,h=d&&zG.has(d.kind)&&Tj(d.at)!=null?{kind:d.kind,at:d.at}:null;s[o]={stop:h,held:c.held===!0,tried:c.tried===!0,last:VG(c.last)}}return{auto:n.auto===!0,login:t?GG(n.login):null,withLogin:t,sessions:s}}async function rf(e=!0){var t,n;try{const s=await fetch(`/api/stop-continue${e?"?login=1":""}`,{signal:AbortSignal.timeout(2e4)});if(!s.ok)return;const a=KG(await s.json(),e);if(!a)return;const o=e?a.login:((t=so.answer)==null?void 0:t.login)??null;F0({answer:{...a,login:o,withLogin:e||(((n=so.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function YG(e,t){if(!bn(my.current.has(e)))return null;my.current.add(e),F0({pressing:new Set([...so.pressing,e])});let n;try{const a=await fetch("/api/stop-continue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,stop:{kind:t.kind,at:t.at}})}),o=await a.json().catch(()=>null),i=typeof(o==null?void 0:o.reason)=="string"?o.reason:a.ok?null:a.status===401||a.status===403?"refused":"failed";n={at:Date.now(),auto:!1,ok:(o==null?void 0:o.ok)===!0,outcome:(o==null?void 0:o.outcome)==="copied"?"copied":(o==null?void 0:o.ok)===!0?"continued":null,reason:i,detail:i==="not_ready"?_j((o==null?void 0:o.gate)??null):H4(o==null?void 0:o.detail),stopped:(o==null?void 0:o.stopped)===!0}}catch{n={at:Date.now(),auto:!1,ok:!1,outcome:null,reason:"unreachable",detail:"",stopped:!1}}my.current.delete(e);const s=new Set(so.pressing);return s.delete(e),F0({pressing:s,pressed:{...so.pressed,[e]:n}}),rf(!0),n}const z4=30*6e4;function Aj(e,t){var c,d,h,f,p;if(e.kind!=="root"||e.provider==="codex")return null;const n=((c=t.answer)==null?void 0:c.sessions[e.sessionId])??null,s=t.pressed[e.sessionId]??null,a=[(n==null?void 0:n.last)??null,s].filter(m=>m!=null).sort((m,w)=>w.at-m.at)[0]??null,o=e.stopFailure??null;if(!o&&!a)return null;const i=(n==null?void 0:n.stop)!=null&&o!=null&&n.stop.at===o.at;return{stop:o,background:e.job!=null,jobId:((d=e.job)==null?void 0:d.id)||null,loaded:((h=t.answer)==null?void 0:h.withLogin)===!0,gate:FG(o,((f=t.answer)==null?void 0:f.login)??null),pressing:t.pressing.has(e.sessionId),auto:((p=t.answer)==null?void 0:p.auto)===!0,held:i&&n.held,tried:i&&n.tried,last:a}}const XG=15e3,ZG=2*6e4;function JG(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function QG({stateRef:e,now:t,enabled:n}){const s=y.useRef(0);n&&JG(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<ZG;y.useEffect(()=>{n&&rf(!1)},[n]),y.useEffect(()=>{if(!a)return;rf(!0);const o=window.setInterval(()=>{rf(!0)},XG);return()=>window.clearInterval(o)},[a])}function V4(e,t){return[e.pressing?"Continuing…":e.loaded?e.gate.ready?"Run the turn that failed again, in place, through Claude Code's background commands.":_j(e.gate.reason):"Checking for a working login…",e.stop?W4({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${Cj(e.last,t)}. ${Rf(e.last)}`:""].filter(Boolean).join(`
84
+ `)}function G4(e,t){return y.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||YG(t,e.stop)},[e,t])}function eK({data:e}){const t=Ej(),n=Nr(15e3),s=Aj(e,t),a=G4(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...$n(s.pressing,!(s.loaded&&s.gate.ready)),title:V4(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function tK({data:e}){const t=Ej(),n=Nr(15e3),s=Aj(e,t);return!s||s.stop||!s.last||n-s.last.at>z4?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:Rf(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:Cj(s.last,n)})]})}function nK({agent:e}){const t=Ej(),n=Nr(15e3),s=Aj(e,t),a=G4(s,e.sessionId),[o,i]=y.useState(null),c=y.useCallback(async(m,w)=>{await ho(w)&&(i(m),window.setTimeout(()=>i(k=>k===m?null:k),1600))},[]);if(!s)return null;const d=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=z4?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:Rf(s.last),children:[Cj(s.last,n),". ",Rf(s.last)]}):null;if(!s.stop)return d?r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),d]}):null;const h=s.loaded?s.gate.ready?s.stop.kind==="api-error"?"":"A working login with room is active now.":_j(s.gate.reason):"Checking for a working login…";if(!s.background)return r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),r.jsx("p",{className:"detail-recap",children:UG(s.stop.kind)}),h&&r.jsx("p",{className:"detail-continue-state",children:h}),r.jsx("div",{className:"detail-continue-actions",children:r.jsx("button",{type:"button",className:"btn detail-continue-btn",onClick:()=>{c("word","continue")},children:o==="word"?"Copied":"Copy “continue”"})})]});const f=W4({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?WG(s.jobId,e.sessionId):null;return r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),r.jsx("p",{className:"detail-recap",children:"A background session: ccdeck can run the turn that failed again, in place, through Claude Code's own background commands."}),h&&r.jsx("p",{className:"detail-continue-state",children:h}),f&&r.jsx("p",{className:"detail-continue-state",children:f}),d,r.jsx("div",{className:"detail-continue-actions",children:r.jsx("button",{type:"button",className:"btn primary detail-continue-btn",...$n(s.pressing,!(s.loaded&&s.gate.ready)),title:V4(s,n),onClick:a,children:s.pressing?"Continuing…":"Continue"})}),p&&r.jsxs("details",{className:"detail-continue-how",children:[r.jsx("summary",{children:"The commands it runs"}),r.jsx("pre",{className:"detail-continue-cmd",children:r.jsx("code",{children:p})}),r.jsx("p",{className:"detail-continue-note",children:"The stop runs only while its process is alive and idle, and the resume only once Claude Code lists no live process for it."}),r.jsx("button",{type:"button",className:"btn detail-continue-btn",onClick:()=>{c("commands",p)},children:o==="commands"?"Copied":"Copy"})]})]})}const TE=typeof window>"u"?y.useEffect:y.useLayoutEffect;function sK({data:e}){var F,L;const t=yl(e),n=["agent-node",`state-${t}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),s=e.tools.filter(A=>!A.endedAt).length,a=e.toolErrorCount??0,o=xu(e.canvasSessionId??e.sessionId),i=((F=e.context)==null?void 0:F.currentContextTokens)??0,c=e.kind==="root"&&i>0,d=e.sessionTitle?e.cwd?`${e.cwd}
85
+ ${e.sessionTitle}`:e.sessionTitle:e.cwd,h=wj(e),f=y.useRef(null),p=y.useRef(null),m=Z9(e),[w,k]=y.useState(0),[b,v]=y.useState(null);TE(()=>{k(0)},[e.effort,e.model,h.length,e.cwdBasename,e.childCount,e.kind,m,b]),TE(()=>{const A=f.current;if(!A||w>=m)return;const q=p.current,E=J9(w,{overflowing:A.scrollWidth>A.clientWidth,folderCut:!!q&&q.scrollWidth>q.clientWidth,max:m});E!==w&&k(E)}),y.useEffect(()=>{const A=f.current;if(!A||typeof ResizeObserver>"u")return;let q=A.clientWidth;const E=new ResizeObserver(()=>{A.clientWidth!==q&&(q=A.clientWidth,xt.flushSync(()=>v(q)))});return E.observe(A),()=>E.disconnect()},[]);const N=Q9(w),j=e.model&&(h.length>0?`${bu(e.model,e.effort)}
86
+ spend on this card also covers:
87
+ ${h.join(`
88
+ `)}`:bu(e.model,e.effort)),S=_p(e.sessionName,e.sessionTitle),_=Ep(e),T=_?_.key:null,$=ZV(T),M=_!=null&&!$,O=(_==null?void 0:_.kind)==="recap",I=K9(e);return r.jsxs("div",{className:n,style:{"--session-hue":o},children:[r.jsx("span",{className:"accent-stripe"}),r.jsx(ni,{type:"target",position:De.Left,style:{background:"transparent",border:"none"}}),r.jsxs("div",{className:"head",children:[r.jsxs("div",{className:"title",children:[r.jsx(lK,{state:t}),r.jsx("span",{className:"label",title:d,children:e.label}),e.restoredFromLog&&r.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&&r.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),_&&T&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":O?"Claude Code's recap":`Session note: ${no(_.kind)}`,"aria-expanded":M,title:O?M?"Hide the recap":"Show Claude Code's recap":M?"Hide this note":"Show what this session is doing",onClick:A=>{A.stopPropagation(),XV(T)},children:r.jsx(Ef,{recap:O})})]}),r.jsx("div",{className:"head-right",children:c&&e.onOpenContext&&r.jsx(FV,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:mV(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[N.kind&&r.jsx("span",{children:Sp(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:pV(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&r.jsxs("span",{className:"sub-folder",ref:p,children:[N.kind?"· ":"",e.cwdBasename]}),e.model?r.jsxs("span",{className:"model-chip","data-family":kp(e.model),title:j,children:[jp(e.model,N.effort?e.effort:void 0),h.length>0?` +${h.length}`:""]}):e.provider==="codex"?r.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),r.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?"≥ ":"",r.jsx(iK,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&S.face&&r.jsx("div",{className:"session-name",title:S.tooltip,children:S.face}),e.kind==="root"&&e.stopFailure&&r.jsx(cK,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(tK,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(uK,{waiting:e.waiting}),(()=>{const A=g4(e);return A?r.jsxs("div",{className:"approval-blind-row",title:A.detail,children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),r.jsx("span",{className:"approval-blind-said",children:A.label})]}):null})(),(()=>{const A=qu(e.plan);return A&&e.plan?r.jsx(aK,{plan:A,items:e.plan.items}):null})(),(e.tools.length>0||(((L=e.outputs)==null?void 0:L.length)??0)>0)&&r.jsx(dK,{tools:e.tools,outputs:e.outputs}),r.jsxs("div",{className:"meta",children:[r.jsxs("span",{children:[r.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),a>0&&r.jsxs("span",{className:"failed-meta",title:`${a} tool ${a===1?"call":"calls"} returned an error`,children:[r.jsx("b",{children:a})," err"]}),s>0&&r.jsxs("span",{className:"inflight-meta",children:[r.jsx("b",{children:s})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&r.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:[r.jsx("b",{children:wt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(I==null?void 0:I.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:I.tt,children:ca}),(I==null?void 0:I.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:I.tt,children:r.jsxs("b",{children:[nt(I.total),I.floor?"+":""]})})]}),r.jsx(oK,{data:e,title:e.kind==="root"?S.face:void 0}),r.jsx(ni,{type:"source",position:De.Right,style:{background:"transparent",border:"none"}})]})}const rK=y.memo(sK);function aK({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Z3(t),children:[r.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),r.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),r.jsx("span",{className:"plan-step",children:e.allDone||!e.current?"done":r.jsxs(r.Fragment,{children:[e.next&&r.jsx("span",{className:"plan-next",children:"next: "}),e.current]})})]})}function oK({data:e,title:t}){const n=e.kind==="root"&&Mn(e.waiting),s=aG(e,e.branch,{sayWaiting:_f,describeCall:a=>({name:Nj(a.name).label,subject:RG(a.name,a.input)})});return r.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":s?"":void 0,"aria-hidden":!0,children:[r.jsxs("div",{className:"lod-id",children:[r.jsx(D4,{kind:I0(yl(e))}),r.jsx("span",{className:"lod-name",children:e.label}),s&&r.jsx("span",{className:"lod-inline","data-tone":s.tone,children:s.short}),n&&r.jsx(Sj,{})]}),t&&r.jsx("div",{className:"lod-title",children:t}),s&&r.jsxs("div",{className:"lod-signal","data-tone":s.tone,children:[r.jsx("span",{className:"lod-long",children:s.long}),r.jsx("span",{className:"lod-short",children:s.short})]})]})}function iK({start:e,end:t}){const n=Nr(1e3);return r.jsx(r.Fragment,{children:Rl(e,t,n)})}function lK({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:Tl(e)})}function cK({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:uV(t,e.job!=null),"data-kind":t.kind,children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"stop-said",children:w4(t)}),r.jsx(eK,{data:e})]})}function uK({waiting:e}){const t=Nr(1e3),n=Mn(e),s=Al(e);return r.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
89
+ Blocked for ${Rl(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?r.jsx("span",{className:"ap-pulse","aria-hidden":!0}):r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"waiting-said",children:_f(e)}),r.jsx("b",{children:Rl(e.since,void 0,t)})]})}function dK({tools:e,outputs:t}){const n=Nr(1e3),{counts:s,title:a}=OG(e,t,n),o=py/wl;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:py,height:sf,viewBox:`0 0 ${py} ${sf}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=DG(i),h=c===wl-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return r.jsx("rect",{x:c*o+.4,y:sf-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),r.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function hK({enableAutoFitAndRefit:e}){return r.jsxs("div",{className:"autofit-chip",children:[r.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),r.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const Rj="agent-dag.single-key-shortcuts";function K4(e){return e!=="0"}function Y4(e){return e.length===1}function X4(e,t){return!t&&Y4(e)}function kn(e,t,n){return n?`${e} (${t})`:e}let Yo=null;const Vc=new Set;function Z4(){for(const e of Vc)e()}function B0(){return Yo===null&&(Yo=K4(Ye(Rj))),Yo}function fK(e){Yo!==e&&(Yo=e,Ze(Rj,e?"1":"0"),Z4())}function AE(e){if(e.key!==Rj)return;const t=K4(e.newValue);t!==Yo&&(Yo=t,Z4())}function pK(e){var t;return Vc.add(e),Vc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",AE)),()=>{var n;Vc.delete(e),Vc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",AE))}}function Mf(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const RE=99;function mK(e){const t=Math.max(0,Math.floor(e));return t>RE?`${RE}+`:String(t)}const gK="Pause the canvas";function yK(e){const t=e.singleKeys??!0;if(!e.paused)return kn("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?kn(`The pause is full — ${Mf(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?kn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):kn(`${Mf(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function wK(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 J4="paused · full",xK=(e,t)=>t>0?J4:e>0?`paused · ${mK(e)}`:"paused";function vK(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:xK(e.held,t),widest:J4,title:kn(t>0?`Connected — the pause is full at ${Mf(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${Mf(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 Dn(){return y.useSyncExternalStore(pK,B0,B0)}const bK=e=>e.transform[2]>=e.maxZoom,kK=e=>e.transform[2]<=e.minZoom;function jK({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=Il(),h=lt(bK),f=lt(kK),p=Dn();return r.jsxs(sz,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(fs,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"",onClick:a,title:yK({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":gK,"aria-pressed":n,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:o,title:kn("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:kn("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),r.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"}),r.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"}),r.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?kn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.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"}),r.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const NK="modulepreload",SK=function(e){return"/"+e},ME={},Fl=function(t,n,s){let a=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"));a=i(n.map(h=>{if(h=SK(h),h in ME)return;ME[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":NK,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,k)=>{m.addEventListener("load",w),m.addEventListener("error",()=>k(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 a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},$E="agent-dag.fm-custom-stations",LE="agent-dag.fm-muted",q0="custom:",_K=/^UC[A-Za-z0-9_-]{22}$/,CK=/^[A-Za-z0-9_-]{11}$/,Q4=/^[A-Za-z0-9_-]{1,80}$/,EK=/\.(mp3|aac|ogg)$/i,TK=/\.m3u8$/i,AK=2048,eP=80;function $l(e){return`${q0}${e}`}function Mp(e){if(!e.startsWith(q0))return null;const t=e.slice(q0.length);return Q4.test(t)?t:null}function IE(e){return Mp(e)??e}function Mj(e){var i,c;const t=e.trim();if(t.length>AK)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(),a=n.hostname.toLowerCase();if(a==="youtube.com"||a==="www.youtube.com"||a==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&_K.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(CK.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return TK.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:EK.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 RK(e){return e==="1"}function MK(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 a of t){if(!a||typeof a!="object")continue;const o=typeof a.id=="string"?a.id:"",i=typeof a.name=="string"?a.name.trim():"",c=typeof a.url=="string"?a.url.trim():"",d=Mj(c);if(!Q4.test(o)||n.has(o)||!i||i.length>eP||!d)continue;n.add(o);const h=tP(a.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function $K(e,t,n){const s=Mp(e??"");return s&&t.some(a=>a.id===s)?$l(s):n(e)}function LK(e,t){return e===$l(t)?"claude-fm":e}function tP(e){if(!e||typeof e!="object")return null;const t=e,n=(a,o)=>typeof t[a]=="string"?t[a].slice(0,o):"",s=(a,o)=>typeof t[a]=="number"&&Number.isFinite(t[a])&&Math.abs(t[a])<=o?t[a]: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 U0="https://www.youtube-nocookie.com";function IK(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${U0}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Yi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function OK(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const PK=[1],DK=[0,2],FK=[2,5,100,101,150,153];function BK(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 a=typeof s=="number"?s:Number(s==null?void 0:s.errorCode);return Number.isFinite(a)?{kind:"error",code:a}:null}if(n==="onStateChange"||n==="infoDelivery"){const a=typeof s=="number"?s:s==null?void 0:s.playerState;return typeof a!="number"||!Number.isFinite(a)?null:PK.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:DK.includes(a)?{kind:"playing",playing:!1}:null}return null}const Lc=new Set;let OE="";function PE(e){const t=new Date().toISOString().slice(0,10);if(t!==OE&&(Lc.clear(),OE=t),!Lc.has(e)){Lc.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Lc.delete(e)}catch{Lc.delete(e)}}}const DE=864e5,qK=6e4;function nn(e,t=!0){y.useEffect(()=>{if(!t)return;PE(e);let n;const s=()=>{n=setTimeout(()=>{PE(e),s()},DE-Date.now()%DE+qK)};return s(),()=>clearTimeout(n)},[e,t])}const UK={"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 WK({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:a,playRequest:o,customStation:i,onAvailabilityChange:c}){var q;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[k,b]=y.useState(!1),[v,N]=y.useState(!1);nn("claude-fm",k);const j=y.useRef(o),S=y.useRef(null),_=y.useRef(null),T=y.useRef(void 0),$=y.useRef(null),M=y.useCallback(()=>{var D;clearTimeout(T.current),(D=_.current)==null||D.destroy(),_.current=null;const E=S.current;E&&(E.pause(),E.removeAttribute("src"),E.load(),S.current=null)},[]),O=y.useCallback(E=>{var D,P;(P=(D=$.current)==null?void 0:D.contentWindow)==null||P.postMessage(E,U0)},[]),I=y.useRef(n);I.current=n;const F=y.useRef(s);F.current=s;const L=y.useCallback((E,D,P)=>{M();const z=new Audio;z.preload="none",z.volume=I.current/100,z.muted=F.current,S.current=z,w(!0),b(!1),N(!1);let G=!1;const V=()=>S.current===z,H=()=>{clearTimeout(T.current),M(),w(!1),b(!1),N(!1)},B=()=>{V()&&(H(),p(!0),c==null||c(P,!0))},W=U=>{if(V()&&!(U instanceof DOMException&&U.name==="AbortError")){if(U instanceof DOMException&&U.name==="NotAllowedError"){H();return}B()}};T.current=setTimeout(()=>{V()&&!G&&B()},15e3),z.addEventListener("playing",()=>{V()&&(clearTimeout(T.current),G=!0,b(!0),N(!1),c==null||c(P,!1))});const ee=()=>{V()&&(b(!1),N(G),clearTimeout(T.current),T.current=setTimeout(()=>{V()&&B()},15e3))};z.addEventListener("waiting",ee),z.addEventListener("stalled",ee),z.addEventListener("ended",()=>{V()&&H()}),z.addEventListener("error",B,{once:!0}),D&&!z.canPlayType("application/vnd.apple.mpegurl")?Fl(async()=>{const{default:U}=await import("./hls-BFpXDghs.js");return{default:U}},[]).then(({default:U})=>{if(!V())return;if(!U.isSupported()){B();return}const Y=new U;_.current=Y,Y.on(U.Events.ERROR,(X,Z)=>{Z.fatal&&B()}),Y.on(U.Events.MEDIA_ATTACHED,()=>Y.loadSource(E)),Y.on(U.Events.MANIFEST_PARSED,()=>{z.play().catch(W)}),Y.attachMedia(z)},B):(z.src=E,z.play().catch(W))},[c,M]);y.useEffect(()=>{m&&(O(Yi("setVolume",[n])),O(Yi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,O]),y.useEffect(()=>{var H;let E=!0;const D=e??fetch,P=j.current!==o;if(j.current=o,h(null),p(!1),N(!1),w(P),b(!1),M(),!t){w(!1),b(!1);return}const z=i&&$l(i.id)===a?Mj(i.url):null;if(z){if(z.kind==="direct-audio"){const B=z.format==="hls"||((H=i==null?void 0:i.radio)==null?void 0:H.hls)===!0;return h({live:!0,channel:"",audio:z.url,hls:B}),c==null||c(a,!1),P&&L(z.url,B,a),()=>{E=!1}}return D(`/api/fm-station?url=${encodeURIComponent(z.url)}`).then(B=>B.ok?B.json():null).then(B=>{E&&(B!=null&&B.channel||B!=null&&B.video?(h({live:!0,channel:B.channel??"",video:B.video??void 0}),c==null||c(a,!1)):(p(!0),w(!1),b(!1),N(!1),c==null||c(a,!0)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),N(!1),c==null||c(a,!0))}),()=>{E=!1}}if(Mp(a))return p(!0),c==null||c(a,!0),()=>{E=!1};const G=a,V=UK[G];if(V)D(V).then(B=>B.ok?B.json():null).then(B=>{E&&(B!=null&&B.video&&h({live:!0,channel:"",video:B.video}),B!=null&&B.video||(p(!0),w(!1),b(!1)),c==null||c(a,!(B!=null&&B.video)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))});else if(G!=="claude-fm"){const B=G.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent(B)}`).then(W=>W.ok?W.json():null).then(W=>{E&&(W!=null&&W.video&&h({live:!0,channel:"",video:W.video}),W!=null&&W.video||(p(!0),w(!1),b(!1)),c==null||c(a,!(W!=null&&W.video)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))})}else D("/api/claude-fm").then(B=>B.ok?B.json():null).then(B=>{if(!E)return;const W=!!(B!=null&&B.live&&(B!=null&&B.channel));W&&h({live:!0,channel:B.channel}),W||(p(!0),w(!1),b(!1)),c==null||c(a,!W)}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))});return()=>{E=!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,a,L,M]),y.useEffect(()=>()=>M(),[M]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let E;const D=()=>{clearTimeout(E),E=void 0,w(!1),b(!1),N(!1),p(!0),c==null||c(a,!0)},P=()=>{E??(E=setTimeout(D,15e3))};P();const z=G=>{var H;if(G.origin!==U0||G.source!==((H=$.current)==null?void 0:H.contentWindow))return;const V=BK(G.data);if(V){if(V.kind==="ready"){O(Yi("setVolume",[I.current])),O(Yi(F.current?"mute":"unMute")),O(Yi("playVideo"));return}if(V.kind==="blocked"){clearTimeout(E),E=void 0,w(!1),b(!1),N(!1);return}if(V.kind==="buffering"){b(!1),N(!0),P();return}if(V.kind==="playing"){clearTimeout(E),E=void 0,b(V.playing),N(!1),V.playing||w(!1);return}FK.includes(V.code)&&D()}};return window.addEventListener("message",z),()=>{clearTimeout(E),window.removeEventListener("message",z)}},[m,d==null?void 0:d.audio,o,c,O,a]);const A=y.useCallback(()=>{if(d){if(d.audio){if(m){M(),w(!1),b(!1),N(!1);return}L(d.audio,d.hls===!0,a);return}if(!m){w(!0),b(!1),N(!1);return}O(Yi("pauseVideo")),w(!1),b(!1),N(!1)}},[d,m,k,a,O,L,M]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:k,buffering:v,frame:$,say:O,press:A}),[d,f,m,k,v,O,A])}const FE="agent-dag.radio-favorites",BE="agent-dag.radio-recent",qE="agent-dag.radio-catalogue";function HK(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,a=typeof s.id=="string"?s.id:"",o=typeof s.name=="string"?s.name.trim().slice(0,80):"",i=typeof s.url=="string"?Mj(s.url):null,c=tP(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(a)||!o||!c||!i||i.kind!=="direct-audio"||t.has(a)?[]:(t.add(a),[{id:a,name:o,url:i.url,radio:c}])})}function UE(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 zK(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function rke(e,t,n=Math.random){const s=e.filter(a=>a.id!==t);return s.length?s[Math.min(s.length-1,Math.floor(Math.max(0,n())*s.length))]:null}function ake(e,t,n){if(!e.length)return null;const s=e.findIndex(o=>o.id===t),a=e[s<0?n===1?0:e.length-1:(s+n+e.length)%e.length];return a.id===t?null:a}function nP(e,t,n){const s=e.findIndex(a=>a.id===t);for(let a=1;a<=e.length;a++){const o=e[(s+a)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function oke(e,t){if(!e.length)return null;const n=[...e].sort((a,o)=>a.id.localeCompare(o.id));let s=0;for(const a of t)s=Math.imul(s,31)+a.charCodeAt(0)>>>0;return n[s%n.length]}function ike(e,t,n,s,a){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()))&&(!a||e.radio.language.toLowerCase().includes(a.toLowerCase()))}function VK(){const[e,t]=y.useState(()=>UE(Ye(FE))),[n,s]=y.useState(()=>UE(Ye(BE))),[a,o]=y.useState(()=>{try{return HK(JSON.parse(Ye(qE)??"[]"))}catch{return[]}});y.useEffect(()=>{Ze(FE,JSON.stringify(e))},[e]),y.useEffect(()=>{Ze(BE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>zK(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(qE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:c,updateCatalogue:d}}function GK(e,t,n,s){const a=nP(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const $p=148,WE=6e3,KK=16e3,sP=46,Qa=34;function YK(e,t,n=$p){let s=-Math.round(t()*n);if(Math.abs(s-e)<Qa){const a=e-Qa>=-n?-Qa:Qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*sP)}}function XK(e){return Math.round(WE+e()*(KK-WE))}const HE=[{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 ZK(e){const t=HE.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of HE)if(n-=s.weight,n<0)return s.kind;return"stroll"}const JK=720,QK=260,eY=620,tY=220,zE=520,rP=1600,VE=7e3,nY=15e3,GE=6e3,sY=14e3;function Xi(e,t,n=$p){let s=-Math.round(t()*n);if(Math.abs(s-e)<Qa){const a=e-Qa>=-n?-Qa:Qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const Kt=(e,t)=>Math.round(Math.abs(t-e)*sP),rY=120,Rh=0;function aY(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Kt(e,t)},{x:t,prop:n({}),act:"stoop",ms:JK},{x:Rh,prop:n({held:!0}),act:"carry",ms:Kt(t,Rh)},{x:Rh,prop:n({held:!0}),act:"windup",ms:QK},{x:Rh,prop:n({held:!0,leaving:!0}),act:"toss",ms:eY}]}function oY(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),a=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:a(),act:"walk",ms:Kt(e,s)},{x:s,prop:a(),act:"windup",ms:tY,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:zE,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:rP-zE}]}const aP=640;function iY(e,t,n){const s=Math.max(-70,Math.min(-20,t)),a={x:s,prop:null,facing:"left"};return[{x:s,prop:null,act:"walk",ms:Kt(e,s)},{...a,act:"sit",ms:600},{...a,act:"cast",ms:900},{...a,act:"fish",ms:6e3+Math.round(n()*4e3)},{...a,act:"reel",ms:1200},{...a,act:"stow",ms:500},{...a,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Kt(s,0)}]}function lY(e,t,n){const s=Math.max(-110,Math.min(-30,t)),a={x:s,prop:null};return[{...a,act:"walk",ms:Kt(e,s)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:aP*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Kt(s,0)}]}function cY(e,t,n){return[{x:t,prop:null,act:"walk",ms:Kt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(GE+n()*(sY-GE))},{x:t,prop:null,act:"stand",ms:400}]}function uY(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:Kt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(VE+n()*(nY-VE))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function gy(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 dY=1500,hY=e=>Math.round(1e3*Math.sqrt(2*e/dY)),fY=115,pY=e=>Math.round(e/fY*1e3),mY=620,gY=200,yY=760,wY=600,xY=240;function vY(e,t,n){const a=-(t.ledgeSpan??$p),o=hY(t.ledgeH),i=pY(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:Kt(e,a)},{x:a,act:"peer",prop:null,ms:mY},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:gY,place:"floor"},{x:h,act:"walk",prop:null,ms:Kt(a,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Kt(h,f),place:"floor",floorFrac:d},{x:a,act:"walk",prop:null,ms:Kt(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:yY,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:wY,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:xY,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function bY(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??$p;switch(ZK(t)){case"tidy":return aY(e,Xi(e,t,s));case"kick":return oY(e,Xi(e,t,s));case"sit":return cY(e,Xi(e,t,s),t);case"watch":return uY(e,Xi(e,t,s),t);case"fish":return iY(e,Xi(e,t,s),t);case"skip":return lY(e,Xi(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return vY(e,n,t)}}const o=YK(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const kY=420;function jY(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(kY,Math.max(0,s))}const NY=260,SY=200;function _Y(e,t,n){const s=(f,p=Kt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[s(t)];const a=Math.min(e,t);if(Math.max(e,t)<=n.left||a>=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,Kt(e,c)),{...h,x:c,act:"mount",ms:NY},{...h,x:d,act:"walk",ms:Kt(c,d)},{x:d,prop:null,act:"dismount",ms:SY,place:"floor"},{x:t,prop:null,act:"walk",ms:Kt(d,t),place:"floor"}]}const oP=["bob","sway","groove"],KE=9e3,CY=16e3,iP=1e3,EY=.08;function TY(e,t){const n=oP.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*EY;return{dance:s,beatMs:Math.round(iP*(1+a))}}function AY(e){return Math.round(KE+e()*(CY-KE))}const $j=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],YE=18,RY=$j.length,lP="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",cP="M12 9H14V6H13V3H11V2H9V4H12Z",Lj=new Set(["a","c","p"]);function fo(e=$j){const t=[];return e.forEach((n,s)=>{let a=0;for(;a<n.length;){const o=n[a];if(o==="."){a+=1;continue}let i=1;for(;a+i<n.length&&n[a+i]===o;)i+=1;t.push({x:a,y:s,w:i,cell:o}),a+=i}}),t}const MY=[".xx.","xxxx",".xx."],$Y=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],LY=["...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."],yy={litter:MY,ball:$Y,scope:LY},IY=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],OY=3,PY=-1,W0=11,XE=9;function ZE(e){let t=null,n=null,s=0,a=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(a=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()-a)),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 DY(e,t,n){const[s,a]=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,k]=y.useState("ledge"),[b,v]=y.useState("left"),[N,j]=y.useState(0),S=y.useRef(null),[_,T]=y.useState(()=>document.hidden);y.useEffect(()=>{const A=new Set,q=()=>{var E;if(document.hidden){for(const D of((E=S.current)==null?void 0:E.getAnimations({subtree:!0}))??[])if(D.playState==="running"||D.pending){const P=D.currentTime;D.pause(),P!==null&&(D.currentTime=P),A.add(D)}}else{for(const D of A)D.playState==="paused"&&D.play();A.clear()}T(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[$,M]=y.useState(null),[O,I]=y.useState(iP),[F,L]=y.useState(()=>{var A;return((A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var E;const A=(E=window.matchMedia)==null?void 0:E.call(window,"(prefers-reduced-motion: reduce)");if(!A)return;const q=()=>L(A.matches);return q(),A.addEventListener("change",q),()=>A.removeEventListener("change",q)},[]),y.useEffect(()=>{var Z;if(!e||t||F)return;const A=ZE(document);let q=0;a(J=>q=J);let E=null,D=0,P=0;const z=J=>{var re,ae;const[te,...ce]=J;if(!te){E=null,d(null),f(null),U();return}d(te.act),f(te.prop),k(te.place??"ledge"),j(te.riser??0);const he=q,le=W(te);if(te.act==="kick"){const de=(ae=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ae.getBoundingClientRect();de&&m({x:jY(de.x,gy(te,he,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-de.y+24)})}P=te.act==="walk"?Math.max(Kt(he,le),rY):te.ms,te.act==="carry"&&(P=Kt(he,le)),i(P),v(de=>gy({...te,x:le},he,de)),a(le),q=le,E=te,D=Date.now(),A.schedule(()=>z(ce),P)},G=()=>{const J=S.current,te=J==null?void 0:J.querySelector(".fm-sprite"),ce=J==null?void 0:J.parentElement;if(!J||!te||!ce)return null;const he=J.getBoundingClientRect(),le=ce.getBoundingClientRect(),re=le.right-he.right,ae=le.width-re*2-te.offsetWidth;return ae>0?ae:null},V=()=>{const J=S.current,te=J==null?void 0:J.querySelector(".fm-sprite");return!J||!te?0:Math.max(0,J.getBoundingClientRect().width-te.offsetWidth)},H=()=>{const J=S.current,te=J==null?void 0:J.querySelector(".fm-walker"),ce=G();if(!J||!te||ce==null)return;const he=J.getBoundingClientRect().bottom-te.getBoundingClientRect().bottom;if(he>0)return{ledgeH:he,floorSpan:ce,ledgeSpan:V()}},B=()=>{const J=S.current,te=document.querySelector(".canvas-notices");if(!J||!te)return null;const ce=J.getBoundingClientRect(),he=te.getBoundingClientRect();return he.width<=0||he.height<=0?null:{left:he.left-ce.right,right:he.right-ce.right,height:he.height}},W=J=>{const te=(J.place??"ledge")==="floor",ce=te?G()??V():V(),he=te&&J.floorFrac!=null?-Math.round(J.floorFrac*ce):J.x;return Math.max(-ce,Math.min(0,he))},ee=()=>{if(!E)return;const J=W(E);J!==q&&(i(Math.max(0,D+P-Date.now())),v(te=>gy({...E,x:J},q,te)),a(J),q=J)},U=()=>{A.schedule(()=>{const J=bY(q,Math.random,H()),te=J.some(le=>le.place==="floor")?B():null;let ce=q;const he=J.flatMap(le=>{const re=ce;if(ce=le.x,!(le.place==="floor"&&le.act==="walk"))return[le];const ae=_Y(re,le.x,te),de=ae.length-1;return le.floorFrac==null?ae:ae.map((_e,fe)=>fe===de?{..._e,floorFrac:le.floorFrac}:_e)});z(he)},XK(Math.random))},Y=(Z=S.current)==null?void 0:Z.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(ee);return Y&&X&&X.observe(Y),U(),()=>{A.dispose(),X==null||X.disconnect(),k("ledge"),a(J=>Math.max(-V(),Math.min(0,J))),i(0),d(null),f(null),j(0)}},[e,t,F]),y.useEffect(()=>{if(!n||F){M(null);return}const A=ZE(document),q=E=>{const D=TY(E,Math.random);M(D.dance),I(D.beatMs),A.schedule(()=>q(D.dance),AY(Math.random))};return q(null),()=>A.dispose()},[n,F]),{scene:S,suspended:_,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:b,riser:N,dance:$,beatMs:O}}const wy={e:"fm-eye",s:"fm-shade",p:"fm-pad"},$f=fo().filter(e=>!Lj.has(e.cell)),FY=fo().filter(e=>Lj.has(e.cell)),JE=$f.filter(e=>e.cell==="e"),BY=fo(IY),qY=$f.filter(e=>e.y<W0&&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),UY={left:$f.filter(e=>e.y>=W0&&e.x<XE),right:$f.filter(e=>e.y>=W0&&e.x>=XE)},WY=y.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${YE} ${RY}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:FY.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:wy[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[JE.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),qY.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:wy[s.cell]},`b${s.y}-${s.x}`)),r.jsxs("g",{className:"fm-arms",children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2}),r.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),JE.map(s=>r.jsx("rect",{x:s.x-(s.x>=YE/2?1:0)+(n==="right"?1:0),y:s.y,width:s.w,height:1,className:"fm-eye"},`eye-${s.x}`))]}),r.jsx("g",{className:"fm-hat",children:BY.map(s=>r.jsx("rect",{x:OY+s.x,y:PY+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")&&r.jsxs("g",{className:"fm-grip",children:[r.jsx("path",{className:"fm-grip-left",d:lP}),r.jsx("path",{className:"fm-grip-right",d:cP})]}),(t==="land"||t==="dismount")&&r.jsxs("g",{className:"fm-crouch-legs",children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&r.jsxs("g",{className:"fm-seated-legs",children:[r.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(s=>r.jsx("g",{className:"fm-leg","data-side":s,children:UY[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:wy[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),HY=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],zY=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],hr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},VY={p:"fm-pad"},ku=fo(HY),GY=fo(zY);function H0(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 KY=H0(ku.filter(e=>e.y>=8),12,18),YY=ku.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),QE=ku.filter(e=>e.cell==="e"),XY={left:H0(ku.filter(e=>e.y>=11),0,9),right:H0(ku.filter(e=>e.y>=11),9,12)},ZY=y.memo(function({act:t,facing:n}){const s=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return r.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[r.jsx("g",{className:"fm-body","data-part":"tail",children:KY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:hr[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:GY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:VY[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[YY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:hr[i.cell]},`b${i.y}-${i.x}`)),QE.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:hr.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:hr.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),QE.map(i=>r.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:hr.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:hr.f},children:[r.jsx("path",{className:"fm-grip-left",d:lP}),r.jsx("path",{className:"fm-grip-right",d:cP})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:hr.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:hr.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:hr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:XY[i].map(c=>r.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:hr[c.cell]},`${c.y}-${c.x}`))},i))]})}),JY=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Yr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},QY={p:"fm-pad"},Lf=fo(JY),eX=fo($j).filter(e=>Lj.has(e.cell)),eT=Lf.filter(e=>e.cell==="e"),tX=Lf.filter(e=>e.y<12&&e.cell!=="e"),nX={left:Lf.filter(e=>e.y>=12&&e.x<9),right:Lf.filter(e=>e.y>=12&&e.x>=9)},sX=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",a=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return r.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:eX.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:QY[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[tX.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Yr[o.cell]},`b${o.y}-${o.x}`)),eT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Yr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:Yr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),eT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Yr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:Yr.h},children:[r.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),r.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:Yr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:Yr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:Yr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:nX[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Yr.b},`${i.y}-${i.x}`))},o))]})});function uP({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(sX,{act:t,facing:n}):e==="fox"?r.jsx(ZY,{act:t,facing:n}):r.jsx(WY,{act:t,facing:n})}const rX={"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 dP(e,t){return t&&$l(t.id)===e?t.name:Mp(e)?"Custom FM":rX[e]}function xy(e,t){var s;const n=((s=e[0])==null?void 0:s.length)??0;return r.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:fo(e).map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:a.cell==="s"?"var(--fm-prop-shadow, var(--bg))":a.cell==="l"?"var(--fm-prop-light, var(--text))":a.cell==="a"?"var(--accent)":void 0},`${t}${a.y}-${a.x}`))})}const tT={litter:xy(yy.litter,"litter"),ball:xy(yy.ball,"ball"),scope:xy(yy.scope,"scope")};function aX(e){try{return new URL(e).host}catch{return"the station's server"}}const oX=y.memo(function({player:t,source:n,customStation:s,character:a="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:k,ballFlight:b,place:v,facing:N,riser:j,dance:S,beatMs:_}=DY(o,i,c);if(!o||i)return null;const T=dP(n,s),$=o.audio?aX(o.audio):"YouTube";return r.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":v,style:{"--fm-beat":`${_}ms`},children:[k&&!k.held&&r.jsx("div",{className:"fm-prop","data-prop":k.kind,"data-leaving":k.leaving?"":void 0,style:{"--fm-prop-x":`${k.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${rP}ms`,"--fm-ball-turn":N==="right"?"1080deg":"-1080deg"},children:tT[k.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&r.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${m}ms`},children:[r.jsx("div",{className:"fm-rope-line"}),r.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),r.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),r.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":v,"data-facing":N,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${aP}ms`},children:[(k==null?void 0:k.held)&&r.jsx("div",{className:"fm-held","data-prop":k.kind,"data-toss":k.leaving?"":void 0,children:tT[k.kind]}),["cast","fish","reel","stow"].includes(w)&&r.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsxs("g",{children:[r.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),r.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),r.jsxs("g",{className:"fm-fishing-line",children:[r.jsx("path",{d:"M8 2V26"}),r.jsxs("g",{className:"fm-float",children:[r.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),r.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),r.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&r.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),r.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),r.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),r.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),r.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),r.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??oP[0]:void 0,onClick:d,title:c?`Stop ${T}`:`Play ${T} — streams from ${$}`,"aria-label":c?`Stop ${T}`:`Play ${T}`,children:r.jsx(uP,{character:a,act:w,facing:N})})]})]})});function iX({player:e,label:t}){const{probe:n,armed:s,frame:a,say:o}=e;return n?r.jsx(r.Fragment,{children:s&&!n.audio&&(n.channel||n.video)&&r.jsx("iframe",{ref:a,className:"fm-frame",title:t,src:IK(n.channel,window.location.origin,n.video),onLoad:()=>o(OK()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const lX={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 cX({name:e}){return r.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:r.jsx("path",{d:lX[e]})})}function uX({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)},[]),r.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[r.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:[r.jsxs("g",{className:"radio-tuning-tower",children:[r.jsx("circle",{cx:"40",cy:"24",r:"4"}),r.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),r.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),r.jsxs("g",{className:"radio-tuning-send",children:[r.jsx("path",{d:"M75 26q7 8 0 16"}),r.jsx("path",{d:"M102 26q7 8 0 16"}),r.jsx("path",{d:"M129 26q7 8 0 16"})]}),r.jsxs("g",{className:"radio-tuning-receiver",children:[r.jsx("path",{d:"M165 49l30-22"}),r.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),r.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),r.jsx("circle",{cx:"202",cy:"65",r:"7"}),r.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),r.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),r.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function dX({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=pt(e);return r.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:_V,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(cX,{name:"close"})}),r.jsx(uX,{opening:!0})]})}const hX=y.lazy(()=>Fl(()=>import("./RadioPanel-BIqrMLQN.js"),[]));function fX({fm:e,characterEnabled:t,character:n,open:s,onClose:a}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=VK(),[f,p]=y.useState(null),m=y.useRef(new Set);y.useEffect(()=>{const M=new AbortController;return fetch("/api/music-config",{signal:M.signal}).then(O=>O.ok?O.json():null).then(O=>{M.signal.aborted||(i((O==null?void 0:O.enabled)===!0),d(O?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{M.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>M.abort()},[s]);const w=e.customFmStations.find(M=>$l(M.id)===e.fmSource),k=w!=null&&w.radio?w:void 0,b=WK({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),v=dP(e.fmSource,w),N=o&&k&&b.dead&&e.fmPlayRequest>0?nP(f??h.catalogue,k.id,m.current):null,{remember:j}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{b.playing&&j(S)},[S,b.playing,j]);const _=a,T=gt(a),$=y.useCallback((M,O=!1)=>{var A;if(!o)return;O||m.current.clear();const I=$l(M.id),F=I===e.fmSource;if(F&&b.armed&&!b.dead){b.press();return}const L=F&&!!w&&(w.url!==M.url||((A=w.radio)==null?void 0:A.hls)!==M.radio.hls);e.addFmStation(M,!0),F&&!b.dead&&!L?b.press():e.pickFmSource(I,L),fetch(`/api/radio-click?id=${encodeURIComponent(M.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||!k||!b.dead||e.fmPlayRequest===0))return GK(f??h.catalogue,k.id,m.current,M=>$(M,!0))},[o,k==null?void 0:k.id,b.dead,e.fmPlayRequest,f,h.catalogue,$]),r.jsxs(r.Fragment,{children:[t&&r.jsx(oX,{character:n,player:b,source:e.fmSource,customStation:w}),r.jsx(iX,{player:b,label:v}),s&&xt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",...T,children:r.jsx(y.Suspense,{fallback:r.jsx(dX,{onClose:_}),children:r.jsx(hX,{fm:e,player:b,library:h,selected:k,label:v,enabled:o,disabledReason:c,autoNext:N==null?void 0:N.name,onPick:$,onQueueChange:p,onClose:_})})}),document.body)]})}function pX({data:e}){const t=Nr(3e4),n=e.note,s=n.kind==="recap",a=Af(n.at,t),o=s?"recap-note":`recap-note is-status status-${n.kind}`,i=s?void 0:Tp(n);return r.jsxs("div",{className:o,role:"note","aria-label":s?"Claude Code's recap":`Session note: ${no(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"recap-note-head",title:i,children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(Ef,{recap:s}),no(n.kind)]}),r.jsx("span",{className:"recap-note-age",title:a.title,children:a.label}),r.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(),YV(e.noteKey)},children:"×"})]}),r.jsx("p",{className:"recap-note-text",title:oG(n.text,i),children:n.text}),n.reply&&r.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),r.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[r.jsxs("div",{className:"lod-id",children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(Ef,{recap:s}),no(n.kind)]}),r.jsx("span",{className:"recap-face-age",children:a.label})]}),r.jsx("p",{className:"recap-face-text",children:n.text})]}),r.jsx(ni,{type:"source",position:De.Right,style:{background:"transparent",border:"none"}})]})}function zu(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Vu(e){return/mac|iphone|ipad/i.test(e)}const If=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function mX(e,t,n){return{positions:If(e.positions),pinned:If(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function gX(e,t){t.positions.clear();for(const[n,s]of If(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of If(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 nT=7e3,yX=2e3,wX=140,xX="Layout re-arranged",vX="Layout re-arranged. Undo available.",sT="Layout restored.",bX={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function kX(e,t=bX){let n=null,s=null,a=0,o=nT;const i=new Set,c=()=>{s!==null&&t.clear(s),s=null},d=()=>{c(),!(n===null||i.size>0)&&(a=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=nT,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,a-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,yX),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function jX(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function NX(e){return Vu(e)?"⌘Z":"Ctrl+Z"}function SX({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,c=ll(t,wX),d=y.useRef(null);return y.useEffect(()=>t?vn.push(a,0,"popover"):void 0,[t,a]),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]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),Ja(c)&&r.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:[r.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:xX}),r.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:s,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",r.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:NX(zu())})]})]})]})}function _X({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[c]=sj({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:.35});return r.jsxs("g",{className:"recap-tie",style:i,children:[r.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),r.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),r.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),r.jsx("circle",{className:"recap-tie-end",cx:n,cy:s,r:3.5})]})}function z0(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Of(e,t){const n=z0(e);return n?n.slice(-t):e.slice(-t)}function hP(e,t,n=4){const s=z0(e);if(!s)return Of(e,n);let a=n;for(const o of t){if(o===e)continue;const i=z0(o);let c=0;for(;c<s.length&&c<i.length&&s[s.length-1-c]===i[i.length-1-c];)c++;a=Math.max(a,c+1)}return s.slice(-a)}const nu=" · ",CX=32,EX=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function rT(e){return EX.test(e)?2:1}function aT(e,t=CX){const n=[...e];let s=0;for(const i of n)s+=rT(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const c=rT(i);if(o+c>t-1)break;a.push(i),o+=c}for(;a.length&&/[\s\-_.:/]/.test(a[a.length-1]);)a.pop();return`${a.join("")}…`}function TX(e,t,n,s,a=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=s?hP(n,a):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(nu);return{label:aT(e),name:c?aT(c):void 0,shortId:d,fullLabel:h.join(nu),title:`${i?"waiting on you: ":""}${f}
90
+ Zoom to this session
91
+ drag the wrapper to move the whole session`}}const Ho=18,V0=26,Ij=12,ju=240,fP=130,G0=Ho*2+V0+Ij,AX=72,xl=G0+AX,af=24,pP=Ho*2+af,Pf=xl;function mP(e,t){var s;let n=ju;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ju);return n}const Df=420,gP=1;function RX(e,t,n,s){return Math.min(gP,n/Math.max(1,e),s/Math.max(1,t))}function Qn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function Lp(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=Qn(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function MX(e,t){return((t==null?void 0:t.get(e))??0)>0?Df:0}function $X(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ff(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??ju,h:(n==null?void 0:n.height)??fP}}function Nu(e,t,n){const s=Ff(e,t);return{w:s.w+MX(e,n),h:Math.max(s.h,$X(e,n))}}function LX(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const IX=240,yP=16;function wP(e,t){return(e+IX)*(t||1)}function OX(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 PX(e,t,n,s){return{position:"absolute",left:e.x+yP,top:e.y-Ij/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??wP(e.w,t),"--session-hue":n}}function DX(e){const t=new Map;for(const a of e){if(a.type!=="agent"&&a.type!=="recapNote")continue;const o=a.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||a.width==null||a.height==null)continue;const i=a.position.x,c=a.position.y,d=i+a.width,h=c+a.height,f=t.get(Qn(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:FX(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(Qn(a),{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[a,o]of t){const i=n.get(o.label);i?i.push(a):n.set(o.label,[a])}const s=[];for(const[a,o]of t){const i=n.get(o.label)??[],c=i.length>1;s.push({sessionId:a,...TX(o.label,o.name,a,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-Ho,y:o.minY-Ho-V0,w:o.maxX-o.minX+Ho*2,h:o.maxY-o.minY+Ho*2+V0,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return s}function FX(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:_p(e.sessionName,e.sessionTitle).face,alarm:Mn(e.waiting),branch:t&&t.total>0?M4(t):void 0}}function BX(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],a=t[n];if(s.sessionId!==a.sessionId||s.label!==a.label||s.name!==a.name||s.shortId!==a.shortId||s.alarm!==a.alarm||s.branch!==a.branch||s.fullLabel!==a.fullLabel||s.title!==a.title||s.x!==a.x||s.y!==a.y||s.w!==a.w||s.h!==a.h)return!1}return!0}const qX=20,Xr=4,UX=64,WX=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function HX(e,t,n,s){const a=t.zoom||1,o=wP(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+yP)*a+t.x,c=e.y*a+t.y-Ij,d=c+qX;let h=Math.min(o,n.width-Xr-i),f=i<Xr||c<Xr||d>n.height-Xr;for(const p of s)if(!(p.top-Xr>=d||p.bottom+Xr<=c)&&!(p.right+Xr<=i)){if(p.left-Xr<=i){f=!0;break}h=Math.min(h,p.left-Xr-i)}return h<UX&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function zX(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(WX)){const a=s.getBoundingClientRect(),o=Math.max(a.left,t.left)-t.left,i=Math.max(a.top,t.top)-t.top,c=Math.min(a.right,t.right)-t.left,d=Math.min(a.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 VX(e,t){return e.length===t.length&&e.every((n,s)=>{const a=t[s];return n.left===a.left&&n.top===a.top&&n.right===a.right&&n.bottom===a.bottom})}const GX=500;function xP({focus:e,setTimeout:t,clearTimeout:n,ms:s=GX}){let a=null;const o=()=>{a!==null&&(n(a),a=null)};return{hold(i){o(),a=t(()=>{a=null;try{e(i)}catch{}},s)},cancel:o}}function KX(e){return DX(e.nodeInternals.values())}const YX=e=>e.width,XX=e=>e.height,ZX=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function JX({onFocusSession:e}){const{x:t,y:n,zoom:s}=_3(),a=lt(KX,BX),o=lt(YX),i=lt(XX),c={width:o,height:i},d=y.useRef(null),h=lt(ZX),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var $;const S=($=d.current)==null?void 0:$.parentElement;if(!S)return;const _=zX(S),T=requestAnimationFrame(()=>{p(M=>VX(M,_)?M:_)});return()=>cancelAnimationFrame(T)});const m=y.useRef(e);m.current=e;const[w]=y.useState(()=>xP({focus:S=>{var _;return(_=m.current)==null?void 0:_.call(m,S)},setTimeout:(S,_)=>window.setTimeout(S,_),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),a.length<=1)return null;const k=S=>{try{e==null||e(S)}catch{}},b=(S,_)=>{S.detail>0&&Bu()?w.hold(_):k(_)},v={transform:`translate(${t}px, ${n}px) scale(${s})`},N=r.jsx("div",{className:"session-clusters",style:v,ref:d,children:a.map(S=>{const _=xu(S.sessionId),T=OX(S,_);return r.jsx("div",{className:"cluster-card",style:T,"aria-hidden":!0},S.sessionId)})}),j=h&&xt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(S=>{const _=xu(S.sessionId),T=HX(S,{x:t,y:n,zoom:s},c,f),$=PX(S,s,_,T.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":T.hidden?"":void 0,style:$,title:S.title,onClick:M=>b(M,S.sessionId),children:[S.alarm?r.jsxs(r.Fragment,{children:[r.jsx(Sj,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?r.jsx("span",{className:"cluster-label-branch",children:nu+S.branch}):null,S.name?r.jsx("span",{className:"cluster-label-name",children:nu+S.name}):null,S.shortId?r.jsx("span",{className:"cluster-label-id",children:nu+S.shortId}):null]},S.sessionId)})}),h);return r.jsxs(r.Fragment,{children:[N,j]})}function QX({data:e}){return r.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const vP=600,eZ=4,tZ=36,Bf=14,nZ=60,sZ=6,oT=220,rZ=96,aZ=28;function oZ(e,t){return Math.max(rZ,61+[...t].length*6.8)}function iZ(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function lZ(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/vP)}function cZ(e,t){const n=[],s=new Set;for(let a=e.length-1;a>=0&&n.length<t;a--){const o=e[a];s.has(o.id)||(s.add(o.id),n.push(o))}return n.reverse()}function uZ(e,t,n,s,a,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>vP)continue;const d=s.get(c.id)??n.get(c.id);if(!d)continue;const h=cZ(c.tools,eZ);if(h.length===0)continue;const f=c.exitAt??null,p=a.get(c.id),m=Math.max((p==null?void 0:p.width)??oT,oT),w=(p==null?void 0:p.height)??130,k=d.x,b=d.y,v=k+m,N=b+w/2;h.forEach((j,S)=>{const _=S*tZ,T=k+m+nZ,$=b+sZ+_,M=lZ(o,f),O=j.inputPreview??"",I=iZ(j),F=M<.999,L=Nj(j.name);i.push({id:`${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:L.label,emoji:L.emoji,status:I,category:$4(j.name),mcpHue:L.hue,inputPreview:O,fade:M,fading:F,worldX:T,worldY:$,anchorX:v,anchorY:N,spawnDx:v-T,spawnDy:N-($+Bf)});const A=P4(j.name,j.input);if(A){const q=oZ(j.name,L.label),E=T+q+aZ,D=$,P=T+q,z=$+Bf;i.push({id:`sub:${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:LG(A.label,A.category),fullName:A.label,emoji:A.emoji,isSub:!0,status:I,category:A.category,inputPreview:A.detail??O,fade:M,fading:F,worldX:E,worldY:D,anchorX:P,anchorY:z,spawnDx:P-E,spawnDy:0})}})}return i}function dZ({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=uZ(e,t,n,s,a,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return r.jsx(hZ,{bursts:f,spotlight:o,onOpenTool:d})}function hZ({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+Bf,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,k=d-f*.25,b=t!=null&&!t.has(o.agentId),v=o.fade*(b?.14:1);return r.jsx("path",{d:`M ${i} ${c} C ${m} ${w}, ${k} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:v,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(mZ,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx(fZ,{connectors:s,bubbles:a})}function fZ({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=_3();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*Bf}px`},children:[r.jsx("svg",{className:"tool-bursts-svg",children:r.jsx("g",{transform:`translate(${n} ${s}) scale(${a})`,children:e})}),r.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${s}px) scale(${a})`},children:t})]})}function pZ(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 mZ=y.memo(function({b:t,dim:n,onOpenTool:s}){const a={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 r.jsx("div",{className:"tool-burst-wrap",style:a,children:r.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:[r.jsx("span",{className:"tb-emoji",children:t.emoji}),r.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&r.jsx("span",{className:"tb-spin"}),t.status==="done"&&r.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&r.jsx("span",{className:"tb-mark err",children:"×"})]})})},pZ),gZ={width:140,height:105},yZ={agent:rK,sessionGroup:QX,recapNote:pX},wZ={recapTie:_X},iT=400;function xZ({graph:e,layout:t,viewport:n,clicks:s,drag:a,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:k,openTool:b,focusAgent:v,requestClear:N,setKeyHelpOpen:j}){const{allNodes:S,edges:_,visibleAgentIds:T,spotlightSet:$}=e,{positionsRef:M,pinnedRef:O,handleRelayout:I,rearrangeUndo:F}=t,{restoredViewport:L,onMoveStart:A,onMove:q}=n,{onNodeClick:E,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:z,onNodeMouseLeave:G}=s,{onNodeDragStart:V,onNodeDrag:H,onNodeDragStop:B}=a,{palette:W,minimapNodeFill:ee,characterEnabled:U}=o,{autoFitDisabled:Y,enableAutoFitAndRefit:X}=h,{paused:Z,pauseGate:J,togglePause:te}=f;return r.jsxs(S3,{nodes:S,edges:_,nodeTypes:yZ,edgesFocusable:!1,edgeTypes:wZ,fitView:!L,fitViewOptions:{padding:.25,duration:T0({durationMs:iT,documentHidden:document.hidden})?iT:0},minZoom:R3,maxZoom:M3,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:E,onPaneClick:D,onNodeDoubleClick:P,onNodeMouseEnter:z,onNodeMouseLeave:G,onMoveStart:A,onMove:q,onNodeDragStart:(ce,he,le)=>{F.dismiss(),V(ce,he,le)},onNodeDrag:H,onNodeDragStop:B,children:[r.jsx(cz,{gap:28,size:1,color:W["--grid-line"]}),r.jsx(JX,{onFocusSession:v}),r.jsx(dZ,{agents:p.current.agents,visibleAgentIds:T,positions:M.current,pinned:O.current,measured:m.current,spotlight:$,hiddenCategories:w,now:k,onOpenTool:b}),r.jsxs("div",{className:"canvas-notices",children:[Y&&r.jsx(hK,{enableAutoFitAndRefit:X}),r.jsx(SX,{undo:F})]}),r.jsx(jK,{autoFitDisabled:Y,enableAutoFitAndRefit:X,paused:Z,pauseGate:J,togglePause:te,handleRelayout:I,requestClear:N,setKeyHelpOpen:j}),r.jsx(XH,{style:gZ,zoomable:!0,pannable:!0,nodeColor:ee,nodeStrokeWidth:2,maskColor:W["--minimap-mask"],maskStrokeColor:W["--line"]}),r.jsx(fX,{fm:i,character:o.character,characterEnabled:U,open:c,onClose:d})]})}function vZ(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const s=document.querySelector(".topbar");if(!s)return;const a=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(a.backgroundColor),symbolColor:o(a.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:r.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function bZ(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,a=0,o=0;for(const i of e){const c=On(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,a+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:a,cacheCreateTokens:o,sum:n+s}}const kZ="spend on this board",jZ="on this board",bP=`Everything on the board right now, and only that.
92
+ 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.
93
+ `,NZ=bP+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function lT(e){return e?NZ:bP+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const kP="session spend",K0="__unknown__",SZ=12;function _Z(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of Dl(s)){const o=a.model??K0,i=bp(a.usage,a.model,t),c=M0({model:a.model,usage:a.usage},t),d=n.get(o);d?(d.inputTokens+=a.usage.inputTokens,d.outputTokens+=a.usage.outputTokens,d.cacheReadTokens+=a.usage.cacheReadTokens,d.cacheCreateTokens+=a.usage.cacheCreateTokens,d.cost.total+=i.total,d.cost.input+=i.input,d.cost.output+=i.output,d.cost.cacheRead+=i.cacheRead,d.cost.cacheWrite+=i.cacheWrite,d.agentCount++,d.priced=d.priced&&c):n.set(o,{model:o,inputTokens:a.usage.inputTokens,outputTokens:a.usage.outputTokens,cacheReadTokens:a.usage.cacheReadTokens,cacheCreateTokens:a.usage.cacheCreateTokens,cost:{...i},agentCount:1,priced:c})}return Array.from(n.values()).sort((s,a)=>a.cost.total-s.cost.total||a.inputTokens+a.outputTokens-(s.inputTokens+s.outputTokens))}function CZ(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=On(a,t).total,i=a.usage.inputTokens,c=a.usage.outputTokens,d=El(a,t),h=M0(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=On(f,t).total,i+=f.usage.inputTokens,c+=f.usage.outputTokens,d+=El(f,t),h=h&&M0(f,t));s.push({priced:h,sessionId:a.sessionId,label:a.label||a.cwdBasename||"session",state:a.state,cost:o,inputTokens:i,outputTokens:c,unpricedTokens:d})}return s.sort((a,o)=>o.cost-a.cost||o.inputTokens+o.outputTokens-(a.inputTokens+a.outputTokens)).slice(0,SZ)}const EZ=600;function Ip(e,t){return!(e.exitAt!=null&&t-e.exitAt>EZ||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function TZ(e,t){const n=new Set;for(const s of e.agents.values())Ip(s,t)&&n.add(s.id);return n}function AZ(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 RZ(e,t,n=0){if(!e)return!1;for(const s of t)if(AZ(e,s,n))return!0;return!1}function cT(e){return e.waiting?Mn(e.waiting)?0:1:e.state==="active"?2:3}function MZ(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=On(a).total,c=a.endedAt??a.startedAt;for(const p of e.agents.values()){if(p.sessionId!==a.sessionId||p.kind==="root")continue;o+=p.toolCount,i+=On(p).total;const m=p.endedAt??p.startedAt;m>c&&(c=m)}const d=Ep(a),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:a.sessionId,label:a.label||a.cwdBasename||"session",cwdBasename:a.cwdBasename,state:yl(a),waiting:a.waiting,recap:h,status:f,modelId:a.model,effort:a.effort,plan:qu(a.plan),planTitle:Z3(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:c})}return n.sort((a,o)=>{const i=cT(a),c=cT(o);return i!==c?i-c:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function $Z(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",Tp(e)].filter(Boolean).join(`
94
+ `)}function qf(e,t,n){const s=(t??n)-e;if(s<1e3)return"<1s";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const o=Math.floor(a/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function LZ({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:c=!1}){const d=Dn(),h=y.useMemo(()=>MZ(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>Mn(m.waiting)).length;return r.jsxs("aside",{className:`session-list${c?" leaving":""}`,id:"session-list","aria-label":"Sessions",children:[r.jsxs("div",{className:"sl-header",children:[r.jsxs("h2",{children:["Sessions ",r.jsx("span",{className:"sl-count",children:h.length})]}),p>0&&r.jsxs("span",{className:"sl-waiting-count",children:[p," waiting"]}),f>0&&r.jsxs("span",{className:"sl-live-count",children:[f," live"]}),r.jsx("button",{className:"glyph-btn sl-close",onClick:a,title:kn("Hide sidebar","L",d),"aria-label":"Hide session list",children:"‹"})]}),r.jsxs("ul",{className:"sl-rows",children:[h.length===0&&r.jsx("li",{className:"sl-empty",children:"No sessions yet."}),h.map(m=>{var b;const w=n.has(m.sessionId),k=(o==null?void 0:o.has(m.sessionId))??!1;return r.jsx("li",{className:"sl-row-item",children:r.jsxs("button",{type:"button",className:`sl-row state-${m.state}${w?" selected":""}${k?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:k?`Bring ${m.label} back to the board`:`Focus ${m.label}`,children:[r.jsx("span",{className:`sl-dot state-${m.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:Tl(m.state)}),r.jsxs("div",{className:"sl-row-body",children:[r.jsxs("div",{className:"sl-row-head",children:[r.jsx("span",{className:"sl-label",children:m.label}),k&&r.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&r.jsx("span",{className:"model-chip","data-family":kp(m.modelId),title:bu(m.modelId,m.effort),children:jp(m.modelId,m.effort)})]}),r.jsxs("div",{className:"sl-row-meta",children:[r.jsxs("span",{title:"tool calls",children:[r.jsx("b",{children:m.toolCount})," ",m.toolCount===1?"tool":"tools"]}),m.cost>0&&r.jsx("span",{className:"sl-cost",title:kP,children:r.jsx("b",{children:nt(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[Al(m.waiting),v4(m.waiting,Al(m.waiting)),`${Mn(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
95
+ `),children:[Mn(m.waiting)?"waiting":"your turn"," ",qf(m.waiting.since,void 0,t),m.waiting.tool&&r.jsxs("span",{className:"sl-waiting-tool",children:[" · ",m.waiting.tool.name]})]}):r.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(m.startedAt).toLocaleString()}`,children:qf(m.startedAt,m.state==="active"?void 0:m.lastActivity,t)})]}),m.plan&&r.jsxs("span",{className:m.plan.allDone?"sl-plan sl-plan-done":"sl-plan",title:m.planTitle,children:[r.jsxs("span",{className:"sl-plan-count","aria-hidden":!0,children:[m.plan.done,"/",m.plan.total]}),r.jsx("span",{className:"vis-hidden",children:X3(m.plan)}),r.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&&r.jsxs("span",{className:"sl-recap",title:m.recap.text,children:[r.jsx(F4,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:$Z(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:no(m.status.kind)})," ",m.status.text]}),((b=m.status)==null?void 0:b.reply)&&r.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 k=e.agents.get(w);k&&Ip(k,t)&&m++}return m===0||!i?null:r.jsx("div",{className:"sl-foot",children:r.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:w=>{const k=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var b;return(b=k==null?void 0:k.querySelector(".sl-row"))==null?void 0:b.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const Xn=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`:""}`},IZ=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,OZ=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function Uf(e,t){for(let n=0;n<4;n++){const s=await fetch(`/api/tool-audit?${e}`,{signal:t}),a=await s.json();if(s.status===409&&a.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||!a.ok||!Array.isArray(a.rows))throw new Error("Could not build the report. Try Refresh or reduce history retention in Settings.");return a}throw new Error("A tool report is already running. Try Refresh in a moment.")}const uT={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 Su(e){if(Object.hasOwn(uT,e))return uT[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=jP(e);return n?`From the ${n.server} MCP server`:null}function jP(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const _u=e=>{var t;return((t=jP(e))==null?void 0:t.tool)??e},PZ=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function Wf(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const DZ=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Su(e.operation)??"").toLowerCase().includes(n)};function dT(e,t,n=""){return e.filter(s=>DZ(s,n)).sort((s,a)=>{const o=Wf(s,t),i=Wf(a,t);return o!==i?o===null?1:i===null?-1:i-o:a.calls-s.calls||s.operation.localeCompare(a.operation)})}const Oj=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},Op=e=>e.failed>0&&e.completed>0?Oj(e.failed,e.completed):null;function FZ(e,t){const n=[],a=e.filter(c=>c.totalMs!==null&&c.measured>=2).slice().sort((c,d)=>d.totalMs-c.totalMs)[0];a&&t&&a.totalMs>=t*.2&&n.push({kind:"time",operation:a.operation,title:"takes the most time",detail:`${Xn(a.totalMs)} over ${Ln(a.calls,"call")}, ${Oj(a.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 ${Ln(o.completed,"call")} failed (${Op(o)}).`});const i=e.filter(c=>c.medianMs!==null&&c.measured>=3&&c.medianMs>=1e4&&c.operation!==(a==null?void 0:a.operation)).sort((c,d)=>d.medianMs-c.medianMs)[0];return i&&n.push({kind:"slow",operation:i.operation,title:"is the slowest",detail:`Usually ${Xn(i.medianMs)} per call; the longest took ${Xn(i.maxMs)}.`}),n}const Ln=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,Cu={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},BZ={all:"your agents",claude:"Claude",codex:"Codex"};function qZ(e,t,n){return{lead:`In the last ${Cu[n]??`${n} days`}, ${BZ[t]} made`,calls:Ln(e.total,"tool call"),time:e.totalMs?Xn(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?Oj(e.failed,e.completed):null}}const su=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function Eu(e,t=Date.now()){const n=a=>new Date(a).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}`}function Pp(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),a=()=>n(s.matches);return a(),s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),t}function UZ({keyboard:e,onClose:t,children:n}){const s=y.useRef(null),a=pt(t,{focusRef:s}),o=gt(t);return y.useEffect(()=>{var i,c;s.current=((i=a.current)==null?void 0:i.querySelector("#tool-operation-heading"))??null,(c=s.current)==null||c.focus({preventScroll:!0})},[a]),xt.createPortal(r.jsx("div",{className:"ta-drawer-backdrop",role:"presentation",...o,children:r.jsx("div",{className:"ta-drawer","data-keyboard":e||void 0,ref:a,role:"dialog","aria-modal":"true","aria-labelledby":"tool-operation-heading",children:n})}),document.body)}function WZ({keyboard:e,itemKey:t,onClose:n,children:s}){const a=y.useRef(null),o=y.useRef(n);return o.current=n,y.useEffect(()=>vn.push(()=>o.current(),0,"popover"),[]),y.useLayoutEffect(()=>{var c,d;a.current&&(a.current.scrollTop=0);const i=document.activeElement;(i===document.body||e&&i instanceof HTMLElement&&(i.dataset.operation??i.dataset.skill)===t)&&((d=(c=a.current)==null?void 0:c.querySelector("#tool-operation-heading"))==null||d.focus({preventScroll:!0}))},[t,e]),y.useLayoutEffect(()=>{var d,h;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const i=(d=a.current)==null?void 0:d.querySelector(".ta-inspector"),c=(h=i==null?void 0:i.animate)==null?void 0:h.call(i,[{opacity:.65,transform:"translateX(6px)"},{opacity:1,transform:"translateX(0)"}],{duration:140,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});return()=>c==null?void 0:c.cancel()},[t]),r.jsx("aside",{ref:a,className:"ta-drawer ta-integrated-inspector","data-keyboard":e||void 0,"aria-labelledby":"tool-operation-heading",children:s})}function NP(e){return Pp("(max-width: 700px)")?r.jsx(UZ,{...e}):r.jsx(WZ,{...e})}const Xa=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function HZ(e,t){return e.status==="outside-history"?`${Xa(e.date)} · before recording started`:e.calls?`${Xa(e.date)} · ${Ln(e.calls,t)}${e.medianMs!=null?` · usually ${Xn(e.medianMs)}`:""}`:`${Xa(e.date)} · no ${t}s`}function SP({history:e,noun:t="call"}){const n=e.days,s=[...n].reverse().find(f=>f.calls>0)??n.at(-1),[a,o]=y.useState(null);if(n.length<3||!s)return null;const i=n.find(f=>f.date===a)??s,c=n.reduce((f,p)=>p.calls>f.calls?p:f,n[0]),d=Math.max(1,c.calls),h=`${t[0].toUpperCase()}${t.slice(1)}s`;return r.jsxs("section",{className:"ta-history","aria-labelledby":"ta-history-title",children:[r.jsxs("h4",{id:"ta-history-title",children:[h," per day"]}),r.jsx("div",{className:"ta-history-bars",role:"img","aria-label":`${h} per day from ${Xa(n[0].date)} to ${Xa(n.at(-1).date)}. The busiest day was ${Xa(c.date)} with ${Ln(c.calls,t)}.`,onPointerLeave:()=>o(null),style:{"--ta-days":n.length},children:n.map(f=>r.jsx("span",{"data-shown":f.date===i.date||void 0,"data-outside":f.status==="outside-history"||void 0,onPointerEnter:()=>o(f.date),children:r.jsx("i",{style:{"--ta-height":f.calls/d}})},f.date))}),r.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[r.jsx("span",{children:Xa(n[0].date)}),r.jsx("span",{children:Xa(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:HZ(i,t)})]})}function _P(){return r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const zZ={success:"Done",failed:"Failed",unmatched:"No result"},VZ=({state:e})=>r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:e==="failed"?"m4 4 8 8m0-8-8 8":e==="success"?"m3 8.5 3 3 7-7":"M4 8h8"})});function GZ(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 KZ({row:e,details:t,loading:n,error:s,kind:a,setKind:o,onClose:i,onShowSkills:c}){const d=Su(e.operation),h=(t==null?void 0:t[a])??[],f=Date.now(),p=Op(e);return r.jsxs("section",{className:"ta-inspector","aria-label":`${_u(e.operation)} details`,id:"tool-operation-inspector",children:[r.jsxs("header",{className:"ta-inspector-head",children:[r.jsxs("div",{children:[r.jsx("h3",{tabIndex:-1,id:"tool-operation-heading",children:_u(e.operation)}),d&&r.jsx("p",{children:d})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:r.jsx(_P,{})})]}),r.jsxs("dl",{className:"ta-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Calls"}),r.jsx("dd",{children:e.calls.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total time"}),r.jsx("dd",{children:Xn(e.totalMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:Xn(e.medianMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsxs("dd",{"data-bad":e.failed>0||void 0,children:[e.failed.toLocaleString(),p&&r.jsx("small",{children:p})]})]})]}),r.jsxs("p",{className:"ta-note",children:[GZ(e),e.maxMs!==null&&e.measured>1&&r.jsxs(r.Fragment,{children:[" · longest ",Xn(e.maxMs)]}),e.unmatched>0&&r.jsxs(r.Fragment,{children:[" · ",Ln(e.unmatched,"call")," without a result yet"]})]}),c&&r.jsx("button",{type:"button",className:"btn ta-show-skills",onClick:c,children:"See which skills ran →"}),s&&r.jsx("p",{className:"ta-message",role:"alert",children:s}),(t==null?void 0:t.history)&&r.jsx(SP,{history:t.history},e.operation),r.jsxs("section",{className:"ta-calls-section","aria-labelledby":"ta-calls-title",children:[r.jsxs("div",{className:"ta-calls-head",children:[r.jsx("h4",{id:"ta-calls-title",children:"Calls"}),r.jsxs("div",{className:"uh-range",role:"group","aria-label":"Show calls",children:[r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":a==="recent",onClick:()=>o("recent"),children:"Latest"}),r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":a==="slowest",onClick:()=>o("slowest"),children:"Slowest"})]})]}),n&&!t&&r.jsx("p",{className:"ta-note",role:"status",children:"Reading calls…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls",children:h.map(m=>r.jsxs("li",{"data-state":m.state,children:[r.jsx("span",{className:"ta-call-when",children:Eu(m.capturedAt,f)}),r.jsx("span",{className:"ta-call-who",children:m.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:Xn(m.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(VZ,{state:m.state}),zZ[m.state]]})]},m.id))}),!h.length&&r.jsx("p",{className:"ta-note",children:a==="slowest"?"None of these calls was timed.":"No calls in this period."}),t.total>h.length&&h.length>0&&r.jsxs("p",{className:"ta-note",children:["The ",a==="recent"?"latest":"slowest"," ",h.length," of ",t.total.toLocaleString(),"."]})]})]}),r.jsx("p",{className:"ta-note ta-inspector-foot",children:"Times include any wait for your approval."})]})}const Y0="agent-dag.text-size",X0="agent-dag.density",hT=["smallest","smaller","default","larger","largest"],fT=["tightest","tighter","compact","default","comfortable"],Pj={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function Dj(){var e,t;return Fj(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function Fj(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function CP(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const YZ=()=>Fj(Ye(Y0)),XZ=()=>CP(Ye(X0)),yr={min:320,standard:380,max:1600},ZZ=420,JZ=8,EP="agent-dag.tool-activity.details-width";function Ic(e,t){const n=Math.max(yr.min,Math.min(yr.max,t-ZZ-JZ));return Math.round(Math.min(n,Math.max(yr.min,Number.isFinite(e)?e:Hf())))}function Hf(){return yr.standard+12*Math.max(0,Pj[Dj()])}function TP(){const e=Number(Ye(EP));return Number.isFinite(e)&&e>=yr.min&&e<=yr.max?Math.round(e):Hf()}function AP(e){Ze(EP,String(Math.round(e)))}function RP({width:e,workspace:t,onCommit:n}){const s=y.useRef(null),a=y.useRef(null),o=()=>{var w;return((w=t.current)==null?void 0:w.clientWidth)??window.innerWidth},i=Ic(e,o()),c=w=>{var k,b;(k=t.current)==null||k.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 k;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),a.current={x:w.clientX,width:i,room:o(),last:i},(k=t.current)==null||k.setAttribute("data-resizing",""))},f=w=>{const k=a.current;k&&(k.last=Ic(k.width+k.x-w.clientX,k.room),c(k.last))},p=()=>{var k;const w=a.current;w&&(a.current=null,(k=t.current)==null||k.removeAttribute("data-resizing"),d(w.last))},m=w=>{const k=w.shiftKey?64:16,b=w.key==="ArrowLeft"?i+k:w.key==="ArrowRight"?i-k:w.key==="Home"?yr.min:w.key==="End"?yr.max:w.key==="Enter"?Hf():null;b!==null&&(w.preventDefault(),d(Ic(b,o())))};return r.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":yr.min,"aria-valuemax":Ic(yr.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(Ic(Hf(),o())),onKeyDown:m})}const QZ=[{id:"uses",label:"Most used"},{id:"recent",label:"Latest"},{id:"name",label:"Name"}];function zf(e){const t=e.lastIndexOf(":");return t>0&&t<e.length-1?{namespace:e.slice(0,t+1),short:e.slice(t+1)}:{namespace:"",short:e}}function eJ(e,t,n=""){const s=n.trim().toLowerCase();return e.filter(a=>!s||a.name.toLowerCase().includes(s)).sort((a,o)=>t==="recent"&&a.lastAt!==o.lastAt?o.lastAt-a.lastAt:t==="name"?zf(a.name).short.localeCompare(zf(o.name).short)||a.name.localeCompare(o.name):o.uses-a.uses||o.lastAt-a.lastAt||a.name.localeCompare(o.name))}const tJ={claude:"Claude",codex:"Codex"};function MP(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}function nJ(e){return[e.typed?`${e.typed.toLocaleString()} typed by you`:"",e.agent?`${e.agent.toLocaleString()} called by the agent`:"",e.detected?`${e.detected.toLocaleString()} detected in Codex`:"",e.subagent?`${e.subagent.toLocaleString()} in a subagent`:""].filter(Boolean)}const sJ={typed:"Typed",agent:"By the agent",detected:"Detected"},rJ=e=>tJ[e.provider],aJ={all:"your agents",claude:"Claude",codex:"Codex"};function oJ(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${Cu[n]??`${n} days`}, ${aJ[t]} used`,skills:Ln(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const iJ=e=>e.countedSince>e.since;function lJ({row:e,details:t,loading:n,error:s,onClose:a,sessionLabel:o,onOpenSession:i}){const{namespace:c,short:d}=zf(e.name),h=Date.now(),f=nJ(e),{claude:p,codex:m}=e.providers;return r.jsxs("section",{className:"ta-inspector","aria-label":`${e.name} details`,id:"tool-operation-inspector",children:[r.jsxs("header",{className:"ta-inspector-head",children:[r.jsxs("div",{children:[r.jsxs("h3",{tabIndex:-1,id:"tool-operation-heading",children:[c&&r.jsx("span",{className:"sa-namespace",children:c}),d]}),r.jsx("p",{children:p&&m?`${p.toLocaleString()} by Claude, ${m.toLocaleString()} by Codex`:`All by ${MP(e)}`})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:a,children:r.jsx(_P,{})})]}),r.jsxs("dl",{className:"ta-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Uses"}),r.jsx("dd",{children:e.uses.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Sessions"}),r.jsx("dd",{children:e.sessions.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Last used"}),r.jsx("dd",{className:"sa-fact-time",children:Eu(e.lastAt,h)})]}),e.failed>0?r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!0,children:e.failed.toLocaleString()})]}):r.jsxs("div",{children:[r.jsx("dt",{children:"Projects"}),r.jsx("dd",{children:e.projects.toLocaleString()})]})]}),(f.length>0||e.repeats>0)&&r.jsxs("p",{className:"ta-note",children:[f.join(" · "),e.repeats>0&&r.jsxs(r.Fragment,{children:[f.length>0&&" · ",Ln(e.repeats,"repeated run")," not counted, such as ",r.jsx("code",{children:"/loop"})," ticks"]})]}),s&&r.jsx("p",{className:"ta-message",role:"alert",children:s}),(t==null?void 0:t.history)&&r.jsx(SP,{noun:"use",history:{days:t.history.days.map(w=>({date:w.date,calls:w.uses,status:w.status==="outside-history"?"outside-history":w.uses?"measured":"no-calls"}))}},e.name),t&&t.projects.length>0&&r.jsxs("section",{className:"sa-projects","aria-labelledby":"sa-projects-title",children:[r.jsx("h4",{id:"sa-projects-title",children:"Projects"}),r.jsx("ul",{children:t.projects.map(w=>r.jsxs("li",{children:[r.jsx("span",{children:w.name}),r.jsx("span",{children:Ln(w.uses,"use")})]},w.name))})]}),r.jsxs("section",{className:"ta-calls-section","aria-labelledby":"sa-uses-title",children:[r.jsx("div",{className:"ta-calls-head",children:r.jsx("h4",{id:"sa-uses-title",children:"Latest uses"})}),n&&!t&&r.jsx("p",{className:"ta-note",role:"status",children:"Reading uses…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls sa-uses",children:t.recent.map(w=>{const k=(o==null?void 0:o(w.session))??null;return r.jsxs("li",{"data-state":w.state==="failed"?"failed":void 0,children:[r.jsx("span",{className:"ta-call-when",children:Eu(w.at,h)}),r.jsxs("span",{className:"ta-call-who",children:[rJ(w)," · ",sJ[w.origin],w.subagent?" · subagent":"",w.state==="failed"?" · failed":""]}),r.jsxs("span",{className:"sa-use-where",children:[w.project&&r.jsx("span",{className:"sa-use-project",children:w.project}),k&&i?r.jsx("button",{type:"button",className:"sa-session",onClick:()=>i(w.session),title:"Show this session on the canvas",children:k}):r.jsx("span",{className:"sa-session-gone",children:"not on the canvas"})]})]},w.id)})}),!t.recent.length&&r.jsx("p",{className:"ta-note",children:"No uses in this period."}),t.total>t.recent.length&&t.recent.length>0&&r.jsxs("p",{className:"ta-note",children:["The latest ",t.recent.length," of ",t.total.toLocaleString(),"."]})]})]})]})}const pT=12,cJ=()=>r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),r.jsx("path",{d:"m16 16 4.5 4.5"})]});function uJ(e){return`${e.name}: ${Ln(e.uses,"use")}, last used ${Eu(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function dJ({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:c}){nn("skill-activity");const[d,h]=y.useState("uses"),[f,p]=y.useState(""),[m,w]=y.useState(!1),[k,b]=y.useState(null),[v,N]=y.useState(!1),j=y.useRef(null),[S,_]=y.useState(null),[T,$]=y.useState(null),[M,O]=y.useState(!0),[I,F]=y.useState(!1),[L,A]=y.useState(""),[q,E]=y.useState(""),D=y.useRef(null),P=y.useRef(!1),z=y.useRef(null),G=y.useRef(null),V=Pp("(min-width: 960px)"),[H,B]=y.useState(TP),W=ae=>{B(ae),AP(ae)},ee=new URLSearchParams({view:"skills",provider:t,days:n}).toString(),U=y.useRef(o);U.current=o,y.useEffect(()=>{U.current({loading:M,detailLoading:I,capturedAt:(S==null?void 0:S.capturedAt)??null,hasData:!!S})},[M,I,S]),y.useEffect(()=>{const ae=new AbortController;let de=!0;const _e=window.setTimeout(()=>ae.abort(),65e3);return A(""),D.current!==ee&&(_(null),$(null),w(!1)),P.current=!0,O(!0),(async()=>{try{const fe=await Uf(ee,ae.signal);de&&(D.current=ee,_(fe),b(ye=>ye&&fe.rows.some(ke=>ke.name===ye)?ye:null))}catch(fe){de&&A(fe instanceof Error&&fe.name!=="AbortError"?fe.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(_e),de&&(P.current=!1,O(!1))}})(),()=>{de=!1,ae.abort(),window.clearTimeout(_e),P.current=!1}},[ee,a]),y.useEffect(()=>{if($(fe=>(fe==null?void 0:fe.name)===k&&D.current===ee?fe:null),E(""),!k||!S||M||P.current){F(!1);return}let ae=!0;const de=new AbortController,_e=window.setTimeout(()=>de.abort(),65e3);return F(!0),(async()=>{var fe;try{const ye=await Uf(`${ee}&skill=${encodeURIComponent(k)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,de.signal);ae&&((fe=ye.details)!=null&&fe.row?$(ye.details):b(null))}catch{ae&&E("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout(_e),ae&&F(!1)}})(),()=>{ae=!1,de.abort(),window.clearTimeout(_e)}},[k,S,M,ee]);const Y=y.useMemo(()=>eJ((S==null?void 0:S.rows)??[],d,f),[S,d,f]),X=m||f?Y:Y.slice(0,pT),Z=Y.reduce((ae,de)=>Math.max(ae,de.uses),0),J=S==null?void 0:S.rows.find(ae=>ae.name===k),te=!!S&&S.failed>0,ce=ae=>de=>{j.current=de.currentTarget,N(de.detail===0),b(_e=>_e===ae?null:ae)},he=()=>{const ae=k;b(null),requestAnimationFrame(()=>{var fe,ye;const de=j.current,_e=Array.from(((fe=z.current)==null?void 0:fe.querySelectorAll(".ta-row[data-skill]"))??[]).find(ke=>ke.dataset.skill===ae);(ye=de!=null&&de.isConnected&&de.checkVisibility()?de:_e)==null||ye.focus({preventScroll:!0})})},le=S&&oJ(S,t,n),re=S&&iJ(S);return r.jsxs("div",{className:"ta-workspace",ref:G,"data-inspecting":!!J||void 0,style:{"--ta-details-w":`${H}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[e,M&&!S&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading skill history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),L&&r.jsx("div",{className:"ta-message",role:"alert",children:r.jsxs("p",{children:[S&&"Showing the last numbers. ",L]})}),S&&le&&(S.total===0&&S.repeats===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No skills used in the last ",Cu[n]]}),r.jsxs("p",{children:["ccdeck counts each skill ",t==="all"?"Claude Code and Codex load":t==="claude"?"Claude Code loads":"Codex loads"," on this device, starting ",su(S.countedSince),". Sessions from before that are not imported. Use a skill and it shows up here."]}),n!=="90"&&!re&&r.jsx("button",{type:"button",className:"btn",onClick:()=>s("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[le.lead," ",r.jsx("strong",{children:le.skills}),S.total>0&&r.jsxs(r.Fragment,{children:[" ",r.jsx("strong",{children:le.uses})]}),"."," ",le.failed>0&&r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[le.failed.toLocaleString()," failed"]}),". "]}),le.repeats>0&&r.jsxs(r.Fragment,{children:[Ln(le.repeats,"repeated run"),", such as ",r.jsx("code",{children:"/loop"})," ticks, ",le.repeats===1?"is":"are"," left out."]})]}),re&&r.jsxs("p",{className:"ta-note sa-since",children:["Counting started ",su(S.countedSince),", so the days before it are empty rather than unused."]}),(!S.storageOk||S.dropped>0||S.corrupt>0)&&r.jsxs("p",{className:"ta-warning",role:"status",children:["Some uses could not be saved or read, so these numbers may be a little low.",!S.storageOk&&" Check free disk space."]}),r.jsxs("section",{className:"ta-tools","aria-labelledby":"sa-skills-title",children:[r.jsxs("div",{className:"ta-tools-head",children:[r.jsxs("h3",{id:"sa-skills-title",children:["Skills ",r.jsx("span",{className:"ta-count",children:S.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(cJ,{}),r.jsx("input",{type:"search","aria-label":"Find a skill",placeholder:"Find a skill",value:f,onChange:ae=>p(ae.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts sa-sorts",role:"group","aria-label":"Sort by",children:QZ.map(ae=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":d===ae.id,onClick:()=>h(ae.id),children:ae.label},ae.id))}),r.jsxs("div",{className:"ta-list-head sa-list-head","aria-hidden":"true","data-sort":d,"data-failures":te||void 0,children:[r.jsx("span",{children:"Name"}),r.jsx("span",{"data-col":"uses",children:"Uses"}),r.jsx("span",{"data-col":"recent",children:"Last used"}),te&&r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list sa-list",ref:z,"data-sort":d,"data-failures":te||void 0,children:X.map(ae=>{const{namespace:de,short:_e}=zf(ae.name);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-skill":ae.name,"data-selected":k===ae.name||void 0,"aria-expanded":k===ae.name,"aria-controls":k===ae.name?"tool-operation-inspector":void 0,"aria-label":uJ(ae),onClick:ce(ae.name),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsxs("span",{className:"ta-op",children:[de&&r.jsx("span",{className:"sa-namespace",children:de}),_e]}),r.jsxs("span",{className:"ta-desc",children:[MP(ae)," · ",Ln(ae.sessions,"session"),ae.repeats>0?` · ${Ln(ae.repeats,"repeat")}`:""]}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":Z&&d==="uses"?Math.max(.015,ae.uses/Z):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"uses",children:[ae.uses.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",ae.uses===1?"use":"uses"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"recent",children:[r.jsx("span",{className:"ta-unit",children:"last "}),Eu(ae.lastAt)]}),te&&r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":ae.failed>0||void 0,children:ae.failed?r.jsxs(r.Fragment,{children:[ae.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},ae.name)})}),!Y.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No skill matches “",f.trim(),"”."]}),!f&&!m&&Y.length>pT&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>w(!0),children:["Show all ",Y.length.toLocaleString()]})]}),r.jsxs("details",{className:"ta-explain",children:[r.jsx("summary",{children:"How this is counted"}),r.jsxs("ul",{children:[r.jsxs("li",{children:["A use is a skill loaded into an agent: Claude calling its Skill tool, a slash command you type, or a skill you pick in Codex with ",r.jsx("code",{children:"$"})," or ",r.jsx("code",{children:"/skills"}),". Custom commands count as skills."]}),r.jsxs("li",{children:["When Codex picks a skill itself, it only reads the skill’s ",r.jsx("code",{children:"SKILL.md"})," or runs one of its scripts. That counts once per turn, only for a skill Codex listed for the session, and shows as detected."]}),r.jsxs("li",{children:["Typed commands are counted only when the deck was started with ",r.jsx("code",{children:"AGENTS_DECK_SKILL_HOOK=1"})," and every Claude Code on this device is 2.1.116 or newer, which reports them to its hooks (",r.jsx("code",{children:"UserPromptExpansion"}),"). Otherwise only the skills Claude calls itself are counted."]}),r.jsxs("li",{children:["The same command run again in one session with the same arguments, such as a ",r.jsx("code",{children:"/loop"})," tick, is a repeat and stays out of the ranking."]}),r.jsxs("li",{children:["Built-in commands such as ",r.jsx("code",{children:"/clear"})," or ",r.jsx("code",{children:"/model"}),", MCP prompts and a skill’s name typed inside a message are not uses. Skills that are installed but never ran do not appear."]}),r.jsx("li",{children:"Failures are shown only when Claude reports that loading a skill failed; Codex reports none."}),r.jsxs("li",{children:["Recorded on this device since ",su(S.countedSince)," and kept with the tool history for ",S.retentionDays," days. The skill’s name, the session and the project folder’s name are saved; arguments and paths never are. Change this in Settings."]})]})]})]}))]})}),J&&V&&r.jsx(RP,{width:H,workspace:G,onCommit:W}),J&&r.jsx(NP,{keyboard:v,itemKey:J.name,onClose:he,children:r.jsx(lJ,{row:(T==null?void 0:T.name)===k&&T.row?T.row:J,details:(T==null?void 0:T.name)===k?T:null,loading:I,error:q,onClose:he,sessionLabel:i,onOpenSession:c})})]})}function Dp(e,t,n,s="horizontal"){if(n<=0||Cp(e))return{kind:"pass"};const a=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:a===-1?0:(a+1)%n};if(c)return{kind:"select",index:a===-1?n-1:(a-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"}}}const mT=12,hJ=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],Mh=[{id:"tools",label:"Tools"},{id:"skills",label:"Skills"}],fJ=()=>r.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})}),pJ=()=>r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),r.jsx("path",{d:"m16 16 4.5 4.5"})]}),mJ={time:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"13",r:"8"}),r.jsx("path",{d:"M12 9v4l2.5 2M9.5 2.5h5"})]}),failing:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"m9 9 6 6m0-6-6 6"})]}),slow:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"M3 17h18M6 17a6 6 0 0 1 12 0M12 17l3.5-4.5"})})};function gJ(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${Op(e)})`:"none failed",n=e.totalMs===null?"not timed":`${Xn(e.totalMs)} in total, usually ${Xn(e.medianMs)}`;return`${_u(e.operation)}${Su(e.operation)?`, ${Su(e.operation)}`:""}: ${Ln(e.calls,"call")}, ${n}, ${t}`}function yJ({onClose:e,sessionLabel:t,onOpenSession:n}){const[s,a]=y.useState("tools"),[o,i]=y.useState("all"),[c,d]=y.useState("7"),[h,f]=y.useState(0),[p,m]=y.useState({loading:!0,detailLoading:!1,capturedAt:null,hasData:!1}),[w,k]=y.useState("calls"),[b,v]=y.useState(""),N=y.useRef(w);N.current=w;const j=y.useRef(b);j.current=b;const[S,_]=y.useState(!1),[T,$]=y.useState(null),M=y.useRef(!1),[O,I]=y.useState(!1),F=y.useRef(T);F.current=T;const L=y.useRef(null),[A,q]=y.useState(null),[E,D]=y.useState(null),[P,z]=y.useState("recent"),[G,V]=y.useState(!0),[H,B]=y.useState(!1),[W,ee]=y.useState(""),[U,Y]=y.useState(""),[X,Z]=y.useState(0),J=y.useRef(!1),te=y.useRef(null),ce=y.useRef(null),he=y.useRef(null),le=Pp("(min-width: 960px)"),[re,ae]=y.useState(TP),de=we=>{ae(we),AP(we)},[_e]=y.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),fe=()=>{e(),requestAnimationFrame(()=>{var Xe;const we=_e,Fe=Array.from(document.querySelectorAll('[data-rail-item="tool-activity"], [data-rail-item="more"]')).find(He=>He.checkVisibility());(Xe=we&&we!==document.body&&we.isConnected&&we.checkVisibility()?we:Fe)==null||Xe.focus({preventScroll:!0})})},ye=pt(fe,{focusRef:ce}),ke=gt(fe),Ne=new URLSearchParams({provider:o,days:c}).toString();y.useEffect(()=>{if(s!=="tools")return;const we=new AbortController;let Fe=!0;const Xe=window.setTimeout(()=>we.abort(),65e3);return ee(""),te.current!==Ne&&(q(null),D(null),_(!1)),J.current=!0,V(!0),(async()=>{try{const He=await Uf(Ne,we.signal);if(Fe){te.current=Ne,q(He);const ht=!M.current&&dT(He.rows,N.current,j.current)[0];ht?(M.current=!0,$(ht.operation)):F.current&&!He.rows.some(Ct=>Ct.operation===F.current)&&$(null)}}catch(He){Fe&&ee(He instanceof Error&&He.name!=="AbortError"?He.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Xe),Fe&&(J.current=!1,V(!1))}})(),()=>{Fe=!1,we.abort(),window.clearTimeout(Xe),J.current=!1}},[Ne,X,s]),y.useEffect(()=>{if(D(He=>(He==null?void 0:He.operation)===T&&te.current===Ne?He:null),Y(""),!T||!A||G||J.current||s!=="tools"){B(!1);return}let we=!0;const Fe=new AbortController,Xe=window.setTimeout(()=>Fe.abort(),65e3);return B(!0),(async()=>{var He;try{const ht=await Uf(`${Ne}&operation=${encodeURIComponent(T)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Fe.signal);we&&(((He=ht.details)==null?void 0:He.measurements)===null?$(null):D(ht.details))}catch{we&&Y("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Xe),we&&B(!1)}})(),()=>{we=!1,Fe.abort(),window.clearTimeout(Xe)}},[T,A,G,Ne,s]);const ge=y.useMemo(()=>dT((A==null?void 0:A.rows)??[],w,b),[A,w,b]),Me=y.useMemo(()=>A?FZ(A.rows,A.totalMs):[],[A]),Ie=S||b?ge:ge.slice(0,mT),We=ge.length?Wf(ge[0],w)??0:0,Te=A==null?void 0:A.rows.find(we=>we.operation===T),at=we=>Fe=>{L.current=Fe.currentTarget,I(Fe.detail===0),z("recent"),$(Xe=>Xe===we?null:we)},Je=()=>{const we=T;$(null),requestAnimationFrame(()=>{var He,ht;const Fe=L.current,Xe=Array.from(((He=ye.current)==null?void 0:He.querySelectorAll(".ta-row[data-operation]"))??[]).find(Ct=>Ct.dataset.operation===we);(ht=Fe!=null&&Fe.isConnected&&Fe.checkVisibility()?Fe:Xe??ce.current)==null||ht.focus({preventScroll:!0})})},Ve=()=>{if(s==="skills"){!p.loading&&!p.detailLoading&&f(we=>we+1);return}J.current||H||(J.current=!0,Z(we=>we+1))},be=A&&qZ(A,o,c),Oe=y.useRef([]),ze=we=>{var Xe;const Fe=Dp(we,Mh.findIndex(He=>He.id===s),Mh.length);Fe.kind!=="pass"&&(we.preventDefault(),a(Mh[Fe.index].id),(Xe=Oe.current[Fe.index])==null||Xe.focus())},st=s==="skills"?p.loading:G,ot=s==="skills"?p.hasData?p.capturedAt:null:(A==null?void 0:A.capturedAt)??null,Qe=r.jsxs("div",{className:"ta-filters",children:[r.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(Cu).map(([we,Fe])=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":c===we,onClick:()=>d(we),children:Fe},we))}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:hJ.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":o===we.id,onClick:()=>i(we.id),children:we.label},we.id))})]});return xt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...ke,children:r.jsxs("div",{className:"modal ta-report",ref:ye,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title",children:[r.jsxs("header",{className:"ta-report-header",children:[r.jsx("h2",{id:"tool-audit-title",children:"Tool activity"}),r.jsx("div",{className:"ta-views",role:"tablist","aria-label":"Show",onKeyDown:ze,children:Mh.map((we,Fe)=>r.jsx("button",{ref:Xe=>{Oe.current[Fe]=Xe},type:"button",role:"tab",id:`ta-view-${we.id}`,className:"ta-view","aria-selected":s===we.id,"aria-controls":"ta-view-panel",tabIndex:s===we.id?0:-1,onClick:()=>a(we.id),children:we.label},we.id))}),r.jsxs("div",{className:"ta-actions",children:[r.jsx("span",{className:"ta-freshness",role:"status",children:st?ot!==null?"Updating…":"Reading history…":ot!==null?`Updated ${new Date(ot).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":s==="skills"?"Refresh skill activity":"Refresh tool activity",title:"Refresh","data-loading":st||void 0,"aria-busy":s==="skills"?p.loading||p.detailLoading:G||H,onClick:Ve,children:r.jsx(fJ,{})}),r.jsx("button",{type:"button",ref:ce,className:"glyph-btn",onClick:fe,"aria-label":"Close tool activity",title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",id:"ta-view-panel",role:"tabpanel","aria-labelledby":`ta-view-${s}`,children:s==="skills"?r.jsx(dJ,{filters:Qe,provider:o,period:c,setPeriod:d,refresh:h,onStatus:m,sessionLabel:t,onOpenSession:n}):r.jsxs("div",{className:"ta-workspace",ref:he,"data-inspecting":!!Te||void 0,style:{"--ta-details-w":`${re}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[Qe,G&&!A&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),W&&r.jsxs("div",{className:"ta-message",role:"alert",children:[r.jsxs("p",{children:[A&&"Showing the last numbers. ",W]}),r.jsx("button",{type:"button",className:"btn",onClick:Ve,children:"Try again"})]}),A&&be&&(A.total===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No tool calls in the last ",Cu[c]]}),r.jsxs("p",{children:["ccdeck records each tool ",o==="all"?"Claude Code and Codex use":o==="claude"?"Claude Code uses":"Codex uses"," on this device, starting ",su(A.startedAt),". Run a session and the calls show up here."]}),c!=="90"&&r.jsx("button",{type:"button",className:"btn",onClick:()=>d("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[be.lead," ",r.jsx("strong",{children:be.calls}),be.time&&r.jsxs(r.Fragment,{children:[" and spent ",r.jsx("strong",{children:be.time})," running them"]}),"."," ",be.failed?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[be.failed.toLocaleString()," failed"]})," (",be.failedShare,")."]}):"None failed."]}),(!A.storageOk||A.dropped>0||A.corrupt>0)&&r.jsxs("p",{className:"ta-warning",role:"status",children:["Some calls could not be saved or read, so these numbers may be a little low.",!A.storageOk&&" Check free disk space."]}),Me.length>0&&r.jsxs("section",{className:"ta-highlights","aria-labelledby":"ta-highlights-title",children:[r.jsx("h3",{id:"ta-highlights-title",children:"Worth a look"}),r.jsx("ul",{children:Me.map(we=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":we.kind,"data-operation":we.operation,"aria-expanded":T===we.operation,"aria-controls":T===we.operation?"tool-operation-inspector":void 0,onClick:at(we.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:mJ[we.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:_u(we.operation)})," ",we.title]}),r.jsx("small",{children:we.detail})]})]})},we.kind))})]}),r.jsxs("section",{className:"ta-tools","aria-labelledby":"ta-tools-title",children:[r.jsxs("div",{className:"ta-tools-head",children:[r.jsxs("h3",{id:"ta-tools-title",children:["Tools and commands ",r.jsx("span",{className:"ta-count",children:A.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(pJ,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:b,onChange:we=>v(we.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:PZ.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":w===we.id,onClick:()=>k(we.id),children:we.label},we.id))}),r.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":w,children:[r.jsx("span",{children:"Name"}),r.jsx("span",{"data-col":"calls",children:"Calls"}),r.jsx("span",{"data-col":"time",children:"Total time"}),r.jsx("span",{"data-col":"slowest",children:"Usually"}),r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list","data-sort":w,children:Ie.map(we=>{const Fe=Wf(we,w),Xe=Su(we.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":we.operation,"data-selected":T===we.operation||void 0,"aria-expanded":T===we.operation,"aria-controls":T===we.operation?"tool-operation-inspector":void 0,"aria-label":gJ(we),onClick:at(we.operation),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsx("span",{className:"ta-op",children:_u(we.operation)}),Xe&&r.jsx("span",{className:"ta-desc",children:Xe}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":We&&Fe?Math.max(.015,Fe/We):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"calls",children:[we.calls.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",we.calls===1?"call":"calls"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"time",children:[Xn(we.totalMs),r.jsx("span",{className:"ta-unit",children:" total"})]}),r.jsxs("span",{className:"ta-cell","data-col":"slowest",children:[r.jsx("span",{className:"ta-unit",children:"usually "}),Xn(we.medianMs)]}),r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":we.failed>0||void 0,children:we.failed?r.jsxs(r.Fragment,{children:[we.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"}),r.jsx("small",{children:Op(we)})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},we.operation)})}),!ge.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",b.trim(),"”."]}),!b&&!S&&ge.length>mT&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>_(!0),children:["Show all ",ge.length.toLocaleString()]})]}),r.jsxs("details",{className:"ta-explain",children:[r.jsx("summary",{children:"How this is counted"}),r.jsxs("ul",{children:[r.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."}),r.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."}),r.jsx("li",{children:"“Usually” is the middle value: half of the calls were quicker, half took longer."}),r.jsxs("li",{children:["A command line such as ",r.jsx("code",{children:"git add . && git commit"})," counts once for each command in it, and shares its time and result with both."]}),r.jsx("li",{children:"Claude and Codex report times in different ways, so do not compare one with the other."}),r.jsxs("li",{children:["Recorded on this device since ",su(A.startedAt)," and kept for ",A.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),Te&&le&&r.jsx(RP,{width:re,workspace:he,onCommit:de}),Te&&r.jsx(NP,{keyboard:O,itemKey:Te.operation,onClose:Je,children:r.jsx(KZ,{row:(E==null?void 0:E.operation)===T&&E.measurements?E.measurements:Te,details:(E==null?void 0:E.operation)===T?E:null,loading:H,error:U,kind:P,setKind:z,onClose:Je,onShowSkills:Te.operation==="Skill"?()=>{$(null),a("skills")}:void 0})})]})})]})}),document.body)}const Z0={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function wJ(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function J0(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||wJ(s))continue;const a=On(s,t);n.set(s.sessionId,{cost:a.total,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,unpricedTokens:El(s,t)})}return n}function xJ(e,t){if(!e)return Z0;const n={...Z0};for(const[s,a]of t){const o=e.get(s);if(!o)continue;const i={cost:a.cost-o.cost,inputTokens:a.inputTokens-o.inputTokens,outputTokens:a.outputTokens-o.outputTokens,cacheReadTokens:a.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:a.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.unpricedTokens=(n.unpricedTokens??0)+Math.max(0,(a.unpricedTokens??0)-(o.unpricedTokens??0)),n.sessions+=1)}return n}function Q0(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const Fp=[{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 vJ(e,t,n=Fp.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 bJ(e,t=new Date){return e==="today"?Q0(1,t):e==="month"?Q0(t.getDate(),t):"20200101"}const wn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,of=e=>typeof e=="string"?e:"";function Bj(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const s of t){const a=Array.isArray(s==null?void 0:s.modelBreakdowns)?s.modelBreakdowns:[];for(const o of a){const i=of(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+=wn(o==null?void 0:o.cost),typeof(o==null?void 0:o.missingPricing)=="boolean"&&(c.missingPricing=c.missingPricing===!0||o.missingPricing),typeof(o==null?void 0:o.storedCost)=="number"&&Number.isFinite(o.storedCost)&&o.storedCost>=0&&(c.storedCost=(c.storedCost??0)+Math.min(o.storedCost,Math.max(0,wn(o.cost)))),c.inputTokens+=wn(o==null?void 0:o.inputTokens),c.outputTokens+=wn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=wn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=wn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const kJ=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function jJ(e){var t;return((t=kJ.exec(e))==null?void 0:t[0])??e}function NJ(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(Bj(e).filter(o=>!(o.missingPricing===!0||o.missingPricing===void 0&&o.cost<=0&&o.tokens>0)).map(o=>o.model)),a=[];for(const o of n){const i=of(o==null?void 0:o.period);if(!i)continue;const c=jJ(i),d=o==null?void 0:o.metadata,h=typeof(d==null?void 0:d.lastActivity)=="string"?Date.parse(d.lastActivity):NaN,f=Array.isArray(o==null?void 0:o.modelsUsed)?o.modelsUsed.map(of).filter(Boolean):[];a.push({sessionId:c,label:t.get(c)??null,agent:of(o==null?void 0:o.agent)||"claude",cost:wn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:wn(o==null?void 0:o.totalTokens),models:f,lastActivityMs:Number.isFinite(h)?h:null})}return a.sort((o,i)=>i.cost-o.cost||i.tokens-o.tokens)}function SJ(e,t=qj(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+wn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function _J(e,t,n){const s=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${s}
96
+ 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 qj(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=wn(t.cacheReadTokens),h=wn(t.cacheCreationTokens),f=wn(t.inputTokens),p=wn(t.outputTokens);return{cost:wn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:wn(t.totalTokens)||f+p+d+h}}const n=Bj(e),s=d=>n.reduce((h,f)=>h+d(f),0),a=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:a,outputTokens:o,cacheReadTokens:i,cacheCreateTokens:c,tokens:a+o+i+c}}function CJ(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 $P(e,t){var n;return((n=Fp.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function EJ(e,t,n){const s=e!=null,a=qj(e);return{fromRange:s,cost:s?a.cost+n.cost:t.cost.total,inputTokens:s?a.inputTokens+n.inputTokens:t.inputTokens,outputTokens:s?a.outputTokens+n.outputTokens:t.outputTokens,cacheReadTokens:s?a.cacheReadTokens+n.cacheReadTokens:t.cacheReadTokens,cacheCreateTokens:s?a.cacheCreateTokens+n.cacheCreateTokens:t.cacheCreateTokens,hasCost:s?a.cost>0:t.cost.total>0,tokenSum:s?a.tokens:t.sum,showCostBar:!s}}const LP="agent-dag.usagePeriod";function TJ(){const e=Ye(LP);return Fp.some(t=>t.key===e)?e:"today"}function AJ(e){Ze(LP,e)}const IP="agent-dag.usageSessionsOpen";function RJ(){return Ye(IP)==="1"}function MJ(e){Ze(IP,e?"1":"0")}function Uj({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 r.jsx("span",{className:`cb-seg ${i}`,style:{width:`${d}%`},title:`${c}: ${nt(o)} (${d.toFixed(0)}%)`},i)},a=t==="lg";return r.jsxs("div",{className:a?"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 $h="https://ccdeck.dev/guides",$J={localNetwork:{href:`${$h}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${$h}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${$h}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${$h}/first-run/#film`,subject:"first run"}};function Tu({film:e,action:t=!1}){const{href:n,subject:s}=$J[e];return r.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?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"m8 5 11 7-11 7V5Z"})}),r.jsx("span",{children:"Watch video"}),r.jsx("span",{className:"film-duration",children:"30 s"})]}):"Watch · 30 s",r.jsxs("span",{className:"vis-hidden",children:[": the ",s," video on ccdeck.dev, opens in your browser"]})]})}const $t="ccdeck",LJ="/brand/ccdeck-mark-gradient-small-optical.svg",IJ="/brand/ccdeck-mark-mono-dark-small-optical.svg";function OP(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 PP(){return r.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:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}function Wj(){return r.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:r.jsx("path",{d:"M3.3 10.7L10.7 3.3M5.5 3.3h5.2v5.2"})})}function OJ({incidents:e}){return r.jsx(r.Fragment,{children:e.map(t=>r.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:[r.jsx("span",{className:"pi-dot","aria-hidden":!0}),r.jsx("span",{className:"pi-name",children:t.name}),r.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),r.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&r.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),r.jsx("span",{className:"pi-go","aria-hidden":!0,children:r.jsx(Wj,{})}),r.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function DP({incident:e}){return e?r.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:[r.jsx("span",{className:"pi-dot","aria-hidden":!0}),r.jsxs("span",{className:"up-incident-words",children:[r.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),r.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:r.jsx(Wj,{})}),e.what&&r.jsx("span",{className:"up-incident-what",children:e.what}),r.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function PJ(e,t,n,s,a=!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(a||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),k=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${k}m`:`${k}m`}return m}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Za({pct:e,label:t,reset:n,resetAt:s,windowSec:a,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",k=m?2:h,b=s&&!c?Hu(s,i):null,v=d&&s&&a?PJ(h,s,a,i,o):null,[N,j]=y.useState(!1),S=y.useId();return r.jsxs("div",{className:"qb-row",children:[r.jsxs("div",{className:"qb-meta",children:[r.jsxs("span",{className:"qb-label",children:[t,o&&!c&&r.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),r.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:w})]}),r.jsxs("div",{className:"qb-track",children:[d&&r.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${k/100})`,background:p,opacity:m?.4:1}}),v&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${v.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:v.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(v.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[c?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):b?r.jsxs("span",{className:"qb-reset",children:["resets in ",b]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:v.color},"aria-expanded":N,"aria-controls":N?S:void 0,onClick:()=>j(_=>!_),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:v.isDeficit?"var(--err)":"var(--ok)"}}),v.runsOutIn?`runs out in ${v.runsOutIn}`:v.label]})]}),N&&v&&r.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(v.expectedPct),"% by now."]})]})}function FP(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 DJ(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 FJ(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 BJ(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 qJ({quota:e,quotaLoading:t,nowSec:n,incident:s}){const a=FP(e==null?void 0:e.fetchedAt,n);return r.jsxs("section",{className:"up-section up-quota-section",children:[r.jsxs("h3",{className:"up-section-title",children:["Claude quota",a&&!t&&r.jsxs("span",{className:"up-section-age",title:DJ(e==null?void 0:e.source),children:[a,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(DP,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Za,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Za,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&r.jsx(Za,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Za,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Za,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&r.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&r.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 — ${$t} only reports them`,children:OP("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?r.jsxs("div",{className:"up-quota-na",children:[r.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),r.jsx("span",{className:"up-quota-hint",children:FJ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function UJ({codexQuota:e,codexLoading:t,nowSec:n,incident:s}){var o,i;const a=FP(e==null?void 0:e.fetchedAt,n);return r.jsxs("section",{className:"up-section up-quota-section",children:[r.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&r.jsx("span",{className:"up-plan-badge",children:e.planLabel}),a&&!t&&r.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:a})]}),r.jsx(DP,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[(o=e.windows)==null?void 0:o.map(c=>r.jsx(Za,{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=>r.jsx(Za,{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&&r.jsx(Za,{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&&r.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&r.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&r.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${$t} only reports them`,children:OP("rate-limit reset",e.resetCredits)}),e.promo&&r.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&r.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?r.jsxs("div",{className:"up-quota-na",children:[r.jsx("span",{children:"Quota unavailable."}),r.jsx("span",{className:"up-quota-hint",children:BJ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function e1(e,t){return t&&e<=0?ca:nt(e)+(t?"+":"")}const lke="Some models have no known price. Tokens are counted; their cost is missing from the total.";function gT(e,t){if(e==null)return null;const n=Math.min(Math.max(0,e),Math.max(0,t));return`Recorded in logs: ${nt(n)} · other reported cost: ${nt(Math.max(0,t-n))}. Both are included in the total; recorded costs are not a verified bill.`}function WJ({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?gT(s.length?s.reduce((o,i)=>o+i.storedCost,0):null,t.reduce((o,i)=>o+i.cost,0)):null;return r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:"By model"}),r.jsxs("table",{className:"up-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Model"}),r.jsx("th",{children:"Tokens"}),r.jsx("th",{children:"Cost"})]})}),r.jsx("tbody",{children:e?t.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:[o.model,gT(o.storedCost,o.cost)].filter(Boolean).join(`
97
+ `),children:ro(o.model)}),r.jsx("td",{className:"up-num",children:wt(o.tokens)}),o.missingPricing===!0||o.missingPricing===void 0&&o.cost<=0&&o.tokens>0?r.jsx("td",{className:"up-num up-unpriced",title:"Cost is incomplete because pricing is missing.",children:e1(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:e1(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===K0?"no model reported yet":o.model,children:o.model===K0?"unknown":ro(o.model)}),r.jsx("td",{className:"up-num",children:wt(o.inputTokens+o.outputTokens)}),o.priced?r.jsx("td",{className:"up-num up-cost-val",children:nt(o.cost.total)}):r.jsx("td",{className:"up-num up-unpriced",children:ca})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function HJ({period:e,rangePending:t,setPeriod:n}){const s=y.useRef([]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:a=>{var c;const o=s.current.indexOf(a.target);if(o<0)return;const i=vJ(a.key,o);i!==null&&(a.preventDefault(),(c=s.current[i])==null||c.focus())},children:Fp.map((a,o)=>r.jsx("button",{type:"button",ref:i=>{s.current[o]=i},tabIndex:e===a.key?0:-1,"aria-pressed":e===a.key,"data-pending":e===a.key&&t?"":void 0,title:e===a.key&&t?`Reading ${a.noun} from the transcripts on this machine…`:a.hint,className:"uh-range-btn",onClick:()=>n(a.key),children:a.label},a.key))}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${$P(e,e)}…`:""})]})}function zJ(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 VJ(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 yT({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&zJ(t,e)?r.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:[a,r.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:r.jsx("path",{d:"m3.5 2 3 3-3 3"})}),r.jsx("span",{className:"vis-hidden",children:"Open session usage"})]}):r.jsx("div",{className:"up-session-row",children:a})}function GJ({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:s,sessionsOpen:a,setSessionsOpen:o,periodNoun:i,sessionScale:c,onOpenSession:d,boardProviders:h}){const f=e?t.length:n.length;return r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:r.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":a,"aria-controls":"up-sessions",title:a?"Hide the per-session breakdown":`Show the per-session breakdown — ${f} session${f===1?"":"s"}`,onClick:()=>o(p=>!p),children:["By session",e&&r.jsxs("span",{className:"up-section-age",title:_J(i,c,nt),children:["active ",i]}),r.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:r.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),r.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!a,children:[e&&t.map(p=>{const m=s.get(p.sessionId);return r.jsxs(yT,{sessionId:p.sessionId,agent:p.agent,label:p.label??Of(p.sessionId,8),onOpen:d,children:[m?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`sl-dot state-${m}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:Tl(m)})]}):r.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),r.jsx("span",{className:`up-session-label${p.label?"":" up-session-id"}`,title:p.label?`${p.label}
98
+ ${p.sessionId}`:p.sessionId,children:p.label??Of(p.sessionId,8)}),r.jsx("span",{className:"up-session-tokens",children:wt(p.tokens)}),p.cost>0||p.priced?r.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:nt(p.cost)}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ca})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(yT,{sessionId:p.sessionId,agent:(h==null?void 0:h.get(p.sessionId))??"claude",label:p.label,onOpen:d,children:[r.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:Tl(p.state)}),r.jsx("span",{className:"up-session-label",children:p.label}),r.jsx("span",{className:"up-session-tokens",children:wt(p.inputTokens+p.outputTokens)}),p.cost>0||p.priced?r.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${wt(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[nt(p.cost),p.unpricedTokens>0?"+":""]}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ca})]},p.sessionId))]})]})}function KJ(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const YJ={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function BP(e){const t=e.toLowerCase(),n=Gt(YJ,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function XJ(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function cke(e,t=[]){const n=t.length?XJ(t.map(BP)):KJ(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function ZJ(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function JJ(){const[e,t]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const n=()=>t(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),r.jsxs("div",{className:"su-loading",role:"status","aria-label":"Reading local session usage","data-paused":e||void 0,children:[r.jsxs("svg",{className:"su-loading-art",viewBox:"0 0 144 88",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("path",{d:"M47 21v-7a4 4 0 0 1 4-4h39a4 4 0 0 1 4 4v49"}),r.jsx("rect",{x:"39",y:"21",width:"46",height:"56",rx:"4"}),r.jsx("path",{d:"M49 32h26M49 40h19M49 48h24M49 62h12"}),r.jsx("path",{className:"su-loading-read",d:"M49 32h26"})]}),r.jsx("strong",{children:"Reading local session usage…"}),r.jsx("span",{children:"Checking the session’s recorded tokens and costs."})]})}const Lh=e=>e.toLocaleString(),wT=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function QJ({session:e,onClose:t}){var v,N;const[n,s]=y.useState("auto"),[a,o]=y.useState(0),[i,c]=y.useState(null),d=y.useRef(a),h=y.useRef(null),f=pt(t,{focusRef:h}),p=gt(t),m=i!=null&&i.ok&&((v=i.detail)==null?void 0:v.speed)===n?i.detail:void 0;y.useEffect(()=>{const j=new AbortController;c(null);const S=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return a!==d.current&&S.set("refresh","1"),d.current=a,fetch(`/api/ccusage/session?${S}`,{signal:j.signal}).then(async _=>{const T=await _.json();j.signal.aborted||c(T)}).catch(()=>{j.signal.aborted||c({ok:!1})}),()=>j.abort()},[e.agent,e.sessionId,n,a]);const w=(m==null?void 0:m.models.filter(j=>j.missingPricing))??[],k=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=k.reduce((j,S)=>j+S.n,0);return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"su-title",children:[r.jsx("h2",{id:"session-usage-title",children:"Session usage"}),r.jsx("span",{title:e.label,children:e.label})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(j=>j+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(PP,{})}),r.jsx("button",{type:"button",className:"glyph-btn",ref:h,onClick:t,"aria-label":"Close session usage (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("div",{className:"modal-body su-body","aria-busy":!i,children:[r.jsxs("div",{className:"su-scope",children:[r.jsx("span",{children:BP(e.agent)}),r.jsx("span",{children:"Whole session"})]}),e.agent==="codex"&&r.jsxs("label",{className:"su-pricing",children:["Estimate using",r.jsxs("select",{value:n,disabled:!i,onChange:j=>{c(null),s(j.target.value)},children:[r.jsx("option",{value:"auto",children:"Session settings / config"}),r.jsx("option",{value:"standard",children:"Standard scenario"}),r.jsx("option",{value:"fast",children:"Fast scenario"}),r.jsx("option",{value:"flex",children:"Flex scenario"})]})]}),!i&&r.jsx(JJ,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[VJ(i)," Use Refresh to try again."]}),m&&r.jsxs("div",{className:"su-result",children:[r.jsxs("dl",{className:"su-totals",children:[r.jsxs("div",{children:[r.jsxs("dt",{children:[n==="auto"?"Estimated cost":"Scenario estimate",w.length>0?" · partial":""]}),r.jsxs("dd",{children:[m.totalCost>0?nt(m.totalCost):m.totalTokens>0?"No cost reported":"$0.00",w.length>0&&m.totalCost>0?"+":""]})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total tokens"}),r.jsx("dd",{title:Lh(m.totalTokens),children:wt(m.totalTokens)})]})]}),r.jsxs("section",{"aria-labelledby":"session-tokens-title",children:[r.jsx("div",{className:"su-section-head",children:r.jsx("h3",{id:"session-tokens-title",children:"Token breakdown"})}),r.jsxs("div",{className:"su-cache-reuse",children:[r.jsx("span",{children:"Cached input reuse"}),r.jsx("strong",{children:((N=m.cacheReuse)==null?void 0:N.pct)!=null?`${m.cacheReuse.pct.toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"}),r.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&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:k.filter(j=>j.n>0).map(j=>r.jsx("span",{style:{width:`${j.n/b*100}%`,background:j.color}},j.name))}),r.jsx("dl",{className:"su-tokens",children:k.map(({name:j,n:S,color:_})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:_},"aria-hidden":"true"}),j]}),r.jsxs("dd",{title:Lh(S),children:[wt(S),r.jsx("span",{className:"su-share",children:b>0?`${(S/b*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},j))}),m.reasoningOutputTokens>0&&r.jsxs("p",{className:"su-note su-reasoning",children:[wt(m.reasoningOutputTokens)," reasoning tokens, included in output."]})]}),r.jsxs("section",{className:"su-models","aria-labelledby":"session-models-title",children:[r.jsxs("div",{className:"su-section-head",children:[r.jsx("h3",{id:"session-models-title",children:"Models"}),r.jsxs("span",{children:[m.models.length," used"]})]}),r.jsxs("table",{children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",children:"Model"}),r.jsx("th",{scope:"col",children:"Tokens"})]})}),r.jsx("tbody",{children:m.models.map(j=>r.jsxs("tr",{children:[r.jsxs("th",{scope:"row",title:j.model,children:[ro(j.model),j.missingPricing&&r.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),r.jsx("td",{title:Lh(j.totalTokens),children:wt(j.totalTokens)})]},j.model))})]}),m.models.length===0&&r.jsx("p",{className:"su-note",children:"No model breakdown was reported."})]}),w.length>0&&r.jsx("p",{className:"su-note",children:"Tokens on unpriced models are included; their cost is missing from the estimate."}),r.jsxs("dl",{className:"su-dates",children:[m.firstActivity&&r.jsxs("div",{children:[r.jsx("dt",{children:"First activity"}),r.jsx("dd",{children:r.jsx("time",{dateTime:m.firstActivity,title:new Date(m.firstActivity).toLocaleString(),children:wT(m.firstActivity)})})]}),m.lastActivity&&r.jsxs("div",{children:[r.jsx("dt",{children:"Last activity"}),r.jsx("dd",{children:r.jsx("time",{dateTime:m.lastActivity,title:new Date(m.lastActivity).toLocaleString(),children:wT(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:Lh(m.entries)})]})]})]}),r.jsxs("footer",{className:"su-footer",children:[r.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."]}),r.jsxs("details",{className:"su-id su-assumptions",children:[r.jsx("summary",{children:"Estimate details"}),r.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."]})]}),r.jsxs("details",{className:"su-id",children:[r.jsx("summary",{children:"Session ID"}),r.jsx("code",{children:e.sessionId})]})]})]})]})}),document.body)}const Ih=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function eQ(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,a=[];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=a.at(-1))==null?void 0:o.at(-1);(!c||i.t-c.t>10*6e4||i.t<=c.t)&&a.push([]),a.at(-1).push({...i,x:n(i.t),y:s(i.pct)})}return a}function tQ(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 Hj({kind:e,title:t,note:n,delayed:s=!1}){const[a,o]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const i=()=>o(document.hidden);return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[]),r.jsxs("div",{className:"read-activity","data-kind":e,role:"status","aria-label":t,"data-paused":a||void 0,"data-delayed":s||void 0,children:[r.jsx("svg",{className:"read-activity-art",viewBox:"0 0 180 100",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="quota"?r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M36 26a23 23 0 1 1-3 28M34 20v14h14"}),r.jsx("path",{d:"M56 33v14l8 5"}),r.jsx("rect",{x:"104",y:"20",width:"40",height:"58",rx:"4"}),r.jsx("path",{d:"M113 32h22M113 42h22M113 52h15M82 47h15"}),r.jsx("circle",{className:"read-activity-mark",cx:"80",cy:"47",r:"2"})]}):e==="processes"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"34",y:"18",width:"112",height:"64",rx:"5"}),r.jsx("path",{d:"M34 33h112M43 25h2M51 25h2M59 25h2M49 46h24M49 57h36M49 68h28M113 46h17M113 57h17M113 68h17"}),r.jsx("path",{className:"read-activity-mark",d:"M49 43h24"})]}):r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"37",y:"18",width:"107",height:"64",rx:"5"}),r.jsx("circle",{cx:"65",cy:"48",r:"17"}),r.jsx("path",{d:"M65 38v11l7 4M98 35h32M98 47h25M98 59h30"}),r.jsx("path",{className:"read-activity-mark",d:"M98 32h25"})]})}),r.jsx("strong",{children:t}),n&&r.jsx("span",{children:n})]})}const vl=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),xT=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function nQ({series:e}){const t=eQ(e),n=(e.resetAt-e.windowSec)*1e3,s=e.resetAt*1e3;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"qh-chart-wrap",children:[r.jsxs("div",{className:"qh-axis","aria-hidden":"true",children:[r.jsx("span",{children:"100%"}),r.jsx("span",{children:"50%"}),r.jsx("span",{children:"0%"})]}),r.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(a=>r.jsx("g",{children:r.jsx("line",{className:"qh-grid",x1:"36",x2:"552",y1:12+a*1.5,y2:12+a*1.5})},a)),r.jsx("path",{className:"qh-guide",d:"M36 12 L552 162"}),t.map((a,o)=>r.jsxs("g",{children:[a.length>1&&r.jsx("path",{className:"qh-observed",d:a.map((i,c)=>`${c?"L":"M"}${i.x} ${i.y}`).join(" ")}),[a[0],...a.length>1?[a.at(-1)]:[]].map(i=>r.jsx("circle",{className:"qh-point",cx:i.x,cy:i.y,r:"2.5",children:r.jsxs("title",{children:[vl(i.t)," · ",Math.round(100-i.pct),"% remaining"]})},i.t))]},o))]}),r.jsxs("div",{className:"qh-times","aria-hidden":"true",children:[r.jsx("span",{children:e.windowSec>86400?vl(n):xT(n)}),r.jsx("span",{children:e.windowSec>86400?vl(s):xT(s)})]})]}),r.jsxs("div",{className:"qh-legend",children:[r.jsxs("span",{children:[r.jsx("i",{className:"qh-key"}),"Observed remaining"]}),r.jsxs("span",{children:[r.jsx("i",{className:"qh-key qh-key-guide"}),"Even-use guide"]})]})]})}function sQ({providers:e,accounts:t,onClose:n,instant:s=!1}){const[a,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(""),[k,b]=y.useState(0),[v,N]=y.useState(Date.now),j=y.useRef(!1),S=y.useRef(null),_=pt(n,{focusRef:S}),T=gt(n),$=t[a];y.useEffect(()=>{let L=!1,A=null;c(null),p(!1);const q=async()=>{if(A)return;if(!$){j.current=!1,h(!1);return}const D=new AbortController;A=D,j.current=!0;const P=window.setTimeout(()=>D.abort(),12e3);h(!0);try{const z=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent($)}`,{signal:D.signal}),G=await z.json();if(!z.ok||!G.ok||!Array.isArray(G.series))throw new Error("History unavailable");L||(c(G.account===$?G:{...G,series:[]}),p(!1))}catch{L||p(!0)}finally{window.clearTimeout(P),A=null,L||(j.current=!1,h(!1))}};q();const E=window.setInterval(()=>{N(Date.now()),document.visibilityState==="visible"&&q()},6e4);return()=>{L=!0,A==null||A.abort(),window.clearInterval(E)}},[a,$,k]);const M=((i==null?void 0:i.series)??[]).slice().sort((L,A)=>A.resetAt-L.resetAt||L.windowSec-A.windowSec),O=M.find(L=>Ih(L)===m)??M.find(L=>L.resetAt*1e3>v&&L.windowSec<=6*3600)??M[0],I=O==null?void 0:O.points.at(-1),F=()=>{bn(j.current)&&(j.current=!0,b(L=>L+1))};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...T,children:r.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":s||void 0,ref:_,role:"dialog","aria-modal":"true","aria-labelledby":"quota-history-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("h2",{id:"quota-history-title",children:"Quota history"}),r.jsxs("div",{className:"qh-header-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh quota history",title:"Read recorded quota history",...$n(d),onClick:F,children:d?"…":r.jsx(PP,{})}),r.jsx("button",{type:"button",ref:S,className:"glyph-btn",onClick:n,"aria-label":"Close quota history",children:"×"})]})]}),r.jsxs("div",{className:"modal-body qh-body","aria-busy":d,children:[r.jsxs("div",{className:"qh-controls",children:[r.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(L=>e[L]).map(L=>r.jsx("button",{type:"button",className:"qh-provider","aria-pressed":a===L,onClick:()=>{o(L),w("")},children:L==="claude"?"Claude":"Codex"},L))}),M.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:O?Ih(O):"",onChange:L=>w(L.target.value),children:M.map(L=>r.jsxs("option",{value:Ih(L),children:[L.label," · ",vl(L.resetAt*1e3)]},Ih(L)))})]})]}),f&&r.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."]}),O&&I?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-I.pct),"% remaining"]}),r.jsxs("span",{title:vl(I.t),children:["Captured ",tQ(I.t,v),O.resetAt*1e3<=v&&" · window ended"]})]}),r.jsx(nQ,{series:O}),r.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."}),r.jsxs("details",{className:"qh-readings",children:[r.jsxs("summary",{children:["Recorded readings (",O.points.length,")"]}),r.jsxs("table",{children:[r.jsx("caption",{children:O.points.length>50?"Latest 50 readings":"Recorded readings"}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",children:"Captured"}),r.jsx("th",{scope:"col",children:"Remaining"})]})}),r.jsx("tbody",{children:O.points.slice(-50).reverse().map(L=>r.jsxs("tr",{children:[r.jsx("td",{children:vl(L.t)}),r.jsxs("td",{children:[(100-L.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},L.t))})]})]})]}):!f&&(d&&$?r.jsx(Hj,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:$?"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&&r.jsx("p",{className:"qh-note",role:"status",children:"History is available for this run, but could not be saved to disk."}),r.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 rQ=6e4,aQ=2e4;function oQ(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!bn(i.current))){h&&(i.current=!0,a(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(aQ)});p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,a(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),rQ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&c(!0)}}}const iQ=6e4;function lQ(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!bn(i.current))){h&&(i.current=!0,a(!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,a(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),iQ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&c(!0)}}}const vT=6e4;function cQ(e,t,n){const[s,a]=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,vT),k=()=>{p()&&Date.now()-h.current>=vT&&d(b=>b+1)};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",k)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,k=bJ(w);return i(!0),fetch(`/api/ccusage?since=${k}${m?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(h.current=Date.now(),a({period:w,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,c]),{...CJ(s,e),loading:o}}const uQ=e=>1-Math.pow(1-e,5),qP=420;function dQ(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 hQ(e,t,n,s=qP){return n>=s?t:n<=0?e:e+(t-e)*uQ(n/s)}function UP(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function bT(e,t,n,s={}){const a=s.now??(()=>performance.now()),o=s.raf??(w=>requestAnimationFrame(w)),i=s.cancel??(w=>cancelAnimationFrame(w)),c=s.reducedMotion??UP,d=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!dQ(e,t))return n(t),()=>{};const h=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-h;n(hQ(e,t,w)),w<qP&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const fQ=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Bo(e,{countIn:t=!1}={}){const[n,s]=y.useState(e),a=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{a.current=n},[n]),fQ(()=>{!t||UP()||(a.current=0,s(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return bT(0,e,c=>{a.current=c,s(c)});a.current=e,s(e);return}return bT(a.current,e,c=>{a.current=c,s(c)})},[e]),n}function WP(e,t,n){const s=mQ*Math.max(1,n/zP);let a=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&&(a+=d)}return a}const kT={samples:[],last:new Map,watched:0},HP=10*6e4,pQ=6e4,zP=5e3,mQ=20;function gQ(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<zP)return e;const a=e.watched+WP(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=HP);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function yQ(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<pQ)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+WP(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min(HP/6e4,Math.ceil(a/6e4))}:null}function wQ(e,t,n){const s=y.useRef(kT),a=y.useRef(null);return y.useMemo(()=>{const o=_Z(e.agents.values()),i=bZ(e.agents.values());a.current!==n&&(a.current=n,s.current=kT);const c=J0(e.agents.values(),t);n!=null&&(s.current=gQ(s.current,t,c));const d=n==null?null:yQ(s.current,t,c),h=d?{label:yj(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const xQ=3e4;function VP(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),xQ);return()=>window.clearInterval(n)},[]),e}function jT(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function vQ(e,t,n,s=0){return e?t.some(a=>a.missingPricing===!0||a.missingPricing===void 0&&a.cost<=0&&a.tokens>0)||s>0:n.some(a=>!a.priced)}function bQ(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function kQ(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 jQ(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function NQ(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} ${hP(n.sessionId,s)}`}:n})}function SQ({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const c=Dn(),[d,h]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Map([...e.agents.values()].filter(Te=>Te.kind==="root").map(Te=>[Te.sessionId,Te.provider??"claude"])),[e,e.revision]),{quota:w,loading:k,refresh:b}=oQ(n.claude),{data:v,loading:N,refresh:j}=lQ(n.codex),S=VP(),{byModel:_,totalCost:T,totalTokens:$}=wQ(e,t,i),M=y.useMemo(()=>CZ(e.agents.values()),[e,e.revision]),[O,I]=y.useState(TJ);y.useEffect(()=>{AJ(O)},[O]);const[F,L]=y.useState(RJ);y.useEffect(()=>{MJ(F)},[F]);const[A,q]=y.useState(0),E=y.useRef(()=>new Map);E.current=()=>i==null?null:J0(e.agents.values(),t);const D=y.useCallback(()=>E.current(),[]),{data:P,shown:z,stale:G,loading:V,baseline:H}=cQ(O,A,D),B=P!=null,W=V&&G,ee=y.useMemo(()=>kQ(e.agents.values()),[e,e.revision]),U=y.useMemo(()=>jQ(e.agents.values()),[e,e.revision]),Y=y.useMemo(()=>B?Bj(P):[],[P,B]),X=y.useMemo(()=>B?NQ(NJ(P,ee).slice(0,12)):[],[P,B,ee]),Z=y.useMemo(()=>qj(P),[P]),J=y.useMemo(()=>SJ(P,Z.cost),[P,Z.cost]),te=$P(z,O),ce=y.useMemo(()=>B?xJ(H,J0(e.agents.values(),t)):Z0,[e,e.revision,H,B,t]),he=EJ(P,{...$,cost:T},ce),le=he.hasCost,re=he.tokenSum,ae=Bo(he.cost),de=Bo(he.inputTokens),_e=Bo(he.outputTokens),fe=Bo(he.cacheReadTokens),ye=Bo(he.cacheCreateTokens),ke=_.filter(jT),Ne=M.filter(jT),ge=vQ(B,Y,ke,ce.unpricedTokens),Me=k||N,Ie=()=>{b(),j(),q(Te=>Te+1)},We=bQ(n);return r.jsxs("aside",{className:`usage-panel${a?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[r.jsxs("div",{className:"up-header",children:[r.jsx("h2",{children:"Usage"}),r.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Open quota history",title:"Quota history",onClick:Te=>p(Te.detail===0?"keyboard":"pointer"),children:r.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:r.jsx("path",{d:"M4 4v16h16M8 8l4 4 4-3 4 7"})})}),(n.claude||n.codex)&&r.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Ie,...$n(Me),"aria-label":We,title:We,children:Me?"…":r.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:r.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})})}),r.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:kn("Close","U",c),children:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})})]})]}),n.claude&&r.jsx(qJ,{quota:w,quotaLoading:k,nowSec:S,incident:s.find(Te=>Te.provider==="claude")}),n.codex&&r.jsx(UJ,{codexQuota:v,codexLoading:N,nowSec:S,incident:s.find(Te=>Te.provider==="codex")}),B&&r.jsx(HJ,{period:O,rangePending:W,setPeriod:I}),re>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:B?void 0:lT(c),children:[r.jsx("span",{className:!le&&ge?"up-total-value up-unpriced":"up-total-value",children:le?r.jsxs(r.Fragment,{children:[nt(ae),ge&&"+"]}):e1(0,ge)}),le&&r.jsx("span",{className:"up-total-label",children:B?te:kZ})]}),le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",B?"ccusage":"live sessions"]}),he.showCostBar&&r.jsx(Uj,{cost:T})]}),r.jsxs("div",{className:"up-tokens-row",title:B?void 0:lT(c),children:[r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"in"}),wt(de)]}),r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"out"}),wt(_e)]}),he.cacheReadTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache r"}),wt(fe)]}),he.cacheCreateTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache c"}),wt(ye)]}),!le&&r.jsx("span",{className:"up-tok up-scope",children:B?te:jZ})]}),(B?Y.length:ke.length)>0&&r.jsx(WJ,{fromRange:B,rangeModelRows:Y,boardModelRows:ke}),B&&X.length===0&&Z.tokens>0&&r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:"By session"}),r.jsxs("div",{className:"up-hint",children:["No session is dated ",te," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(B?X.length:Ne.length)>0&&r.jsx(GJ,{fromRange:B,rangeSessionRows:X,boardSessionRows:Ne,boardStates:U,sessionsOpen:F,setSessionsOpen:L,periodNoun:te,sessionScale:J,onOpenSession:h,boardProviders:m}),ge&&r.jsxs("div",{className:"up-hint",children:["“",ca,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):r.jsx("div",{className:"up-empty",children:B?(z??O)==="all"?r.jsx(r.Fragment,{children:"No usage in any transcript on this machine."}):r.jsxs(r.Fragment,{children:["No usage ",te,".",r.jsx("br",{}),"Try a longer period."]}):r.jsxs(r.Fragment,{children:["No usage data yet.",r.jsx("br",{}),"Start a Claude Code or Codex session."]})}),r.jsx("div",{className:"film-foot",children:r.jsx(Tu,{film:"usage"})}),d&&r.jsx(QJ,{session:d,onClose:()=>h(null)},`${d.agent}:${d.sessionId}`),f&&r.jsx(sQ,{providers:n,instant:f==="keyboard",accounts:{claude:w==null?void 0:w.historyAccount,codex:v==null?void 0:v.historyAccount},onClose:()=>p(null)})]})}function vy(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function zj(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:vy(t/1e3),unit:"KB/s"}:t<9995e5?{value:vy(t/1e6),unit:"MB/s"}:{value:vy(t/1e9),unit:"GB/s"}}function Bp(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 Au(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const _Q="thermal:Throttling";function Vj(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function CQ(e){var n,s,a,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((a=e.thermal)==null?void 0:a.celsius)??[])t[`thermal:${i.label}`]=i.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[_Q]=Vj(e.thermal.throttle)),t}function ru(e,t){return t==="B/s"?Au(zj(e)):t==="ms"?Au(Bp(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)?ru(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function EQ(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 TQ(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function AQ(e,t,n=Date.now()){const s=Vj(e),a="timeHeld"in e;return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?a?`CPU throttled ${s}% of the time to cool down`:`CPU held to ${100-s}% of full speed to cool down`:t?a?`at full speed · ${t.peak}% throttled ${NT(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${NT(t.lastMs,n)}`:"running at full speed, and never held back"}}function NT(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 RQ(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 MQ(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?Vj(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`:(a=e.network)!=null&&a.api&&e.network.api.ms==null?"the Claude API is not answering":null}function $Q(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 LQ=3e3;function IQ(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let s=!0;const a=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&&(a(),n.current=window.setInterval(a,LQ))},i=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){i();return}o(),a()};return o(),document.addEventListener("visibilitychange",c),()=>{s=!1,i(),document.removeEventListener("visibilitychange",c)}},[]),e}function OQ(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function sl({col:e,label:t,note:n,sort:s,next:a,onSort:o,className:i}){const c=OQ(s,e);return r.jsx("th",{scope:"col","aria-sort":c,className:i,children:r.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
99
+
100
+ ${n}`:`Sort by ${t}`,onClick:()=>o(a(s,e)),children:[t,r.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function by(e,t){return t==="B/s"?zj(e):t==="ms"?Bp(e):{value:String(e),unit:t==="C"?"°C":t}}const zt={l:30,r:6,t:6,b:2},Ha={l:0,r:0,t:2,b:1},qp=104,PQ=64;function Vs(e,t=100,n=qp,s=zt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function GP(e,t){return t??[e[0].t,e[e.length-1].t]}function Gj(e,[t,n],s,a=zt){const o=s-a.l-a.r,i=n-t;return a.l+(i>0?o*(e-t)/i:o/2)}function KP(e,t,n,s=100,a=qp,o=zt,i){if(!e.length)return"";const c=GP(e,i),d=p=>Gj(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)} ${Vs(p.v,s,a,o).toFixed(1)}`,f=p}return h}function YP(e,t,n,s=100,a=qp,o=zt,i){if(e.length<2)return"";const c=a-o.b,d=GP(e,i),h=w=>Gj(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 k of p)w+=`L${h(k.t).toFixed(1)} ${Vs(k.v,s,a,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 DQ(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 FQ(e,t,n=s=>qo(s)){const s=e.filter(i=>i.v>0);if(!e.length)return null;if(!s.length)return"never held back";const a=s.length*(t/6e4),o=s[s.length-1];return`held back for ${a===1?"1 minute":`${a} minutes`}, last at ${n(o.t)}`}function qo(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Kj(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),a=n%60;return a?`${s}h ${a}m`:`${s}h`}function BQ({group:e,title:t,liveNote:n,onClose:s}){const a=pt(s),o=gt(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 v=await b.json();m&&(v!=null&&v.ok)&&c(v)}catch{}};w();const k=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(k)}},[e]);const d=(i==null?void 0:i.series)??[],[h,f,p]=y.useMemo(()=>{let m=1/0,w=0;for(const k of d)k.points.length&&(m=Math.min(m,k.points[0].t),w=Math.max(w,k.points[k.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 xt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal hist-modal",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),i&&h>0&&r.jsxs("span",{className:"hist-since",children:["since ",qo(h)," · ",Kj(h,f||Date.now())]}),r.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("div",{className:"hist-body",children:[i==null?r.jsx(Hj,{kind:"history",title:"Reading sensor history…",note:"Loading the readings recorded on this machine.",delayed:!0}):d.length===0?r.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):r.jsx("div",{className:"read-result",children:d.map(m=>r.jsx(qQ,{series:m,stepMs:i.stepMs,domain:p},m.label))}),e==="load"&&n&&r.jsxs("p",{className:"hist-note hist-load-summary",children:[r.jsx("span",{children:"Current 1-minute load"}),r.jsx("strong",{children:n})]})]})]})}),document.body)}function qQ({series:e,stepMs:t,domain:n}){const s=y.useRef(null),[a,o]=y.useState(560),[i,c]=y.useState(null);y.useEffect(()=>{const L=s.current;if(!L||typeof ResizeObserver>"u")return;const A=new ResizeObserver(([q])=>o(Math.max(160,q.contentRect.width)));return A.observe(L),()=>A.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:m,top:w,restsAtZero:k,changes:b}=e,v=k?PQ:qp,{now:N,peak:j}=DQ(d),S=N!=null?by(N,h):null,_=j!=null?by(j,h):null,T=m==="Throttling"?FQ(d,t):null,$=i!=null?d[i]:null,[M,O]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),I=L=>Gj(L,[M,O],a),F=L=>{if(d.length<2)return;const A=L.currentTarget.getBoundingClientRect(),q=(L.clientX-A.left-zt.l)/Math.max(1,A.width-zt.l-zt.r),E=M+(O-M)*Math.max(0,Math.min(1,q));let D=0;for(let P=1;P<d.length;P++)Math.abs(d[P].t-E)<Math.abs(d[D].t-E)&&(D=P);c(D)};return r.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[r.jsxs("div",{className:"hist-head",children:[r.jsx("span",{className:"hist-label",children:m}),r.jsxs("span",{className:"hist-stats",children:[S&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:S.value}),r.jsxs("span",{children:[S.unit," now"]})]}),j!=null&&_&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:XP(j,f,p),children:_.value}),r.jsxs("span",{children:[_.unit," peak"]})]})]})]}),r.jsx("div",{className:"hist-plot",ref:s,children:r.jsxs("svg",{className:"hist-chart",width:"100%",height:v,viewBox:`0 0 ${a} ${v}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||_==null?`${m}: nothing measured yet`:`${m}: ${Au(S)} now, peak ${Au(_)}, over ${Kj(d[0].t,d[d.length-1].t)}`,onPointerMove:F,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([L,A])=>A==null||A>w?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${L}`,x1:zt.l,x2:a-zt.r,y1:Vs(A,w,v),y2:Vs(A,w,v)}),r.jsx("text",{className:`hist-rule-tag ${L}`,x:2,y:Vs(A,w,v)+3,children:A})]},L)),r.jsx("line",{className:"hist-floor",x1:zt.l,x2:a-zt.r,y1:v-zt.b,y2:v-zt.b}),(b??[]).filter(L=>L.from!=null&&d.length>1&&L.t>=M&&L.t<=O).map(L=>r.jsx("line",{className:"hist-mark",x1:I(L.t),x2:I(L.t),y1:zt.t,y2:v-zt.b},L.t)),r.jsx("path",{className:"hist-area",d:YP(d,a,t,w,v,zt,[M,O])}),r.jsx("path",{className:"hist-line",d:KP(d,a,t,w,v,zt,[M,O])}),d.length===1&&r.jsx("circle",{className:"hist-dot",cx:I(d[0].t),cy:Vs(d[0].v,w,v),r:3}),$&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:I($.t),x2:I($.t),y1:zt.t,y2:v-zt.b}),r.jsx("circle",{className:"hist-dot",cx:I($.t),cy:Vs($.v,w,v),r:3})]})]})}),r.jsx("div",{className:"hist-axis",children:$?r.jsxs("span",{className:"hist-at",children:[qo($.t)," — ",(()=>{const L=by($.v,h);return r.jsxs(r.Fragment,{children:[r.jsx("b",{children:L.value}),L.unit==="%"||L.unit==="°C"||!L.unit?L.unit:` ${L.unit}`]})})()]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:d.length?qo(M):""}),r.jsx("span",{children:d.length?qo(O):""})]})}),T&&r.jsx("div",{className:"hist-note",children:T}),b==null?void 0:b.slice(-3).map(L=>r.jsx("div",{className:"hist-note hist-route",children:L.from==null?`Since ${qo(L.t)} — ${L.label}`:`${qo(L.t)} — ${L.label.charAt(0).toUpperCase()+L.label.slice(1)}`},L.t))]})}const ST=["cores","memory","load","thermal"],Lo=116,fr=24,UQ=60,WQ=6e4;function HQ(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function zQ(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function VQ(e,t=UQ){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function GQ({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let i=!0;const c=async()=>{const h=await Promise.all(ST.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(),WQ);return()=>{i=!1,clearInterval(d)}},[]);const s=y.useMemo(()=>CQ(e),[e]),a=y.useMemo(()=>ST.flatMap(i=>{const c=t[i];return c?c.series.filter(HQ).map(d=>({series:VQ(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let i=1/0,c=-1/0;for(const{series:d}of a){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)?Kj(i,c):"less than a minute"},[a]);return Object.keys(s).length?r.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:a.map(({series:i,stepMs:c})=>r.jsx(KQ,{series:i,stepMs:c,now:s[i.key],span:o},i.key))}):null}function KQ({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:c,critAt:d}=e,h=zQ(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":XP(f,c,d),m=Math.max(...a.map(k=>k.v));return r.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${ru(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:[r.jsxs("div",{className:"pl-cell-head",children:[r.jsx("span",{className:"pl-cell-label",children:h}),r.jsx("span",{className:"pl-cell-now",children:f==null?"—":ru(f,i)})]}),r.jsxs("svg",{className:"pl-spark",width:Lo,height:fr,viewBox:`0 0 ${Lo} ${fr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:Lo,y1:fr-Ha.b,y2:fr-Ha.b}),r.jsx("path",{className:"pl-spark-area",d:YP(a,Lo,t,o,fr,Ha)}),c!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:Lo,y1:Vs(c,o,fr,Ha),y2:Vs(c,o,fr,Ha)}),d!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:Lo,y1:Vs(d,o,fr,Ha),y2:Vs(d,o,fr,Ha)}),r.jsx("path",{className:"pl-spark-line",d:KP(a,Lo,t,o,fr,Ha)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",ru(m,i)," over the last ",s,c!=null&&`, uncomfortable over ${Oh(c,i)}`,d!=null&&`, the machine acts over ${Oh(d,i)}`]})]})}const ZP={key:"cpu",dir:"desc"};function YQ(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function XQ(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,a=(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)=>a(o,i)||(i.cpu??-1)-(o.cpu??-1)||i.mem-o.mem||o.pid-i.pid)}const ZQ=4e3;function JQ(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 QQ(){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=>JQ(c,i))}catch{}};s();const a=window.setInterval(s,ZQ);return()=>{n=!1,window.clearInterval(a)}},[]),e}function eee(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 tee({sys:e,onClose:t}){nn("process-list");const n=pt(t),s=gt(t),[a,o]=y.useState(ZP),i=QQ();return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:r.jsx(nee,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function nee({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?XQ(e.procs,t):null;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"modal-head",children:[r.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&r.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("div",{className:"pl-split",children:[r.jsx("div",{className:"pl-body",children:o==null?r.jsx(Hj,{kind:"processes",title:"Reading the process list…",delayed:!0}):o.length===0?r.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):r.jsxs("table",{className:"sd-procs pl-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx(Zi,{col:"cpu",label:"cpu",sort:t,onSort:n}),r.jsx(Zi,{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}),r.jsx(Zi,{col:"threads",label:"threads",sort:t,onSort:n}),r.jsx(Zi,{col:"uptime",label:"up",sort:t,onSort:n}),r.jsx(Zi,{col:"user",label:"user",sort:t,onSort:n}),r.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),r.jsx(Zi,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),r.jsx("tbody",{children:o.map(i=>r.jsxs("tr",{children:[r.jsx("td",{className:"sd-num",children:i.cpu==null?"—":i.cpu.toFixed(0)}),r.jsx("td",{className:"sd-num sd-dim",title:`${i.mem.toFixed(1)}% of installed memory`,children:Qr(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:eee(i.uptimeSec)}),r.jsx("td",{className:"sd-dim pl-user",children:i.user??"—"}),r.jsx("td",{className:"sd-num sd-dim pl-pid",children:i.pid}),r.jsxs("td",{className:"pl-name",children:[i.name,i.cmd&&r.jsxs("span",{className:"pl-cmd",title:i.cmd,children:[" ",i.cmd]})]})]},i.pid))})]})}),r.jsx(GQ,{sys:s})]})]})}function Zi(e){return r.jsx(sl,{...e,next:(t,n)=>YQ(t??ZP,n)})}function t1({value:e,unit:t,cap:n}){return t?r.jsxs("span",{className:"sd-fig",children:[r.jsx("span",{className:"sd-fig-cap",children:n}),r.jsxs("span",{className:"sd-fig-read",children:[r.jsx("b",{children:e})," ",r.jsx("span",{className:"sd-fig-unit",children:t})]})]}):r.jsxs("span",{className:"sd-fig",children:[r.jsx("b",{children:e}),r.jsx("span",{className:"sd-fig-cap",children:n})]})}const see=300;function Ru({group:e,title:t,action:n,label:s,value:a,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=k=>{var b;m(),!(k.detail>1||((b=window.getSelection())==null?void 0:b.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var v,N;p.current=null,((v=window.getSelection())==null?void 0:v.isCollapsed)!==!1&&((N=f.current)==null||N.focus({preventScroll:!0}),h(!0))},see))};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"sd-reading",onClick:w,children:[r.jsx("button",{ref:f,type:"button",className:"sd-open",onClick:k=>{k.stopPropagation(),m(),h(!0)},title:n,"aria-label":a==null?`${s}: show history`:`${s}: show history, now ${a}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:r.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[s," ",r.jsx("i",{className:"sd-row-more",children:"›"}),a!=null&&r.jsx("span",{className:"sd-h-val",children:a})]})}),c]}),o&&r.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),d&&r.jsx(BQ,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function Vf({label:e,value:t,pct:n,tone:s="calm",note:a,mark:o,title:i,trackLabel:c}){return r.jsxs("div",{className:"sd-row",title:i,children:[r.jsxs("div",{className:"sd-row-head",children:[r.jsx("span",{className:"sd-row-label",children:e}),r.jsx("span",{className:"sd-row-val",children:t})]}),r.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[r.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&&r.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),a&&r.jsx("div",{className:"sd-note",children:a})]})}function ree(e,t,n){if(n<=0||Cp(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 eo=4,ms=8;function Yj(e,t,n){const s=n.width-ms-(e.right+eo),a=e.left-eo-ms,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+eo:e.left-eo-t.width,c=n.height-ms*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(ms,Math.min(e.top,n.height-ms-h)),p=Math.max(ms,Math.min(i,n.width-ms-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function aee(e,t,n){const s=n.height-ms-(e.bottom+eo),a=e.top-eo-ms,o=t.height<=s||s>=a?"below":"above",i=o==="below"?s:a,c=t.height<=i,d=c?t.height:Math.max(0,i),h=o==="below"?e.bottom+eo:e.top-eo-d,f=Math.max(ms,Math.min(e.right-t.width,n.width-ms-t.width));return{top:Math.max(ms,h),left:f,side:o,maxHeight:c?null:d}}function oee(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function iee(e,t,n){const s=y.useRef(t);s.current=t;const a=y.useRef(n);a.current=n,y.useEffect(()=>{const o=i=>{oee(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const JP='[role="menuitem"]';function _T(e){return e?Array.from(e.querySelectorAll(JP)).filter(t=>!t.disabled):[]}function Up({anchorId:e,boundaryId:t,portalRootId:n,id:s,className:a,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 k=pt(()=>{var S;(S=document.getElementById(e))==null||S.focus(),m.current()},{popover:!0,focusRef:d}),b=y.useCallback(()=>{var O,I,F;const S=k.current;if(!S)return;const _=document.getElementById(e);if(!_){m.current();return}if(_.getClientRects().length===0){S.contains(document.activeElement)&&((I=(O=w.current)==null?void 0:O.call(w))==null||I.focus()),m.current();return}const T=_.getBoundingClientRect(),$=t?(F=document.getElementById(t))==null?void 0:F.getBoundingClientRect():null;if($&&(T.bottom<=$.top||T.top>=$.bottom)){S.contains(document.activeElement)&&_.focus({preventScroll:!0}),m.current();return}S.style.maxHeight="";const M=aee(T,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight});S.style.top=`${M.top}px`,S.style.left=`${M.left}px`,S.style.maxHeight=M.maxHeight==null?"":`${M.maxHeight}px`,S.dataset.side=M.side},[e,t,k]);y.useLayoutEffect(()=>{b()}),y.useEffect(()=>{const S=_=>{var T;(T=k.current)!=null&&T.contains(_.target)||b()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",b)}},[b,k]),iee(k,()=>document.getElementById(e),f),y.useEffect(()=>{var _;if(o!=="menu")return;const S=_T(k.current);(_=c==="last"?S[S.length-1]:S[0])==null||_.focus()},[]);const v=S=>{var _;if(o==="menu"&&S.key==="Tab"){S.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),S.shiftKey&&S.preventDefault(),m.current();return}if(o==="menu"){const T=_T(k.current),$=ree(S,T.indexOf(document.activeElement),T.length);$.kind==="focus"&&(S.preventDefault(),T[$.index].focus())}S.key.length===1&&S.stopPropagation()},N=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},j=S=>{if(o!=="menu"||S.pointerType==="touch")return;const _=S.target.closest(JP);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return xt.createPortal(r.jsx("div",{ref:k,id:s,className:`anchored-popover${a?` ${a}`:""}`,role:o,"aria-labelledby":i,onKeyDown:v,onMouseDown:N,onPointerMove:j,children:p}),(n?document.getElementById(n):null)??document.body)}function lee({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=y.useState(!1),c=s&&s.ms!=null?Bp(s.ms):null,d=t!=null&&n!=null;return r.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[r.jsxs(Ru,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&r.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=zj(f);return r.jsx(t1,{value:p.value,unit:p.unit,cap:h},h)}),c&&r.jsx(t1,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&r.jsx("div",{className:"sd-note",children:"measuring…"}),s&&s.ms==null&&r.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),a&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>i(h=>!h),children:["Connection details",a.relay&&r.jsx("span",{className:"sd-route-relay",children:" · relayed"}),r.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&r.jsx(cee,{route:a,api:s,onClose:()=>i(!1)})]})]})}function cee({route:e,api:t,onClose:n}){return r.jsxs(Up,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[r.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),r.jsxs("dl",{className:"sd-pop-rows",children:[r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),r.jsxs("dd",{children:["through ",$Q(e)]})]}),e.relay&&r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Relay"}),r.jsxs("dd",{children:[r.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&&r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Round trip"}),r.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Au(Bp(t.ms))} to open a connection to ${t.host}`})]}),r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Throughput"}),r.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function CT({usageOpen:e,leaving:t,sub:n,flag:s,onClose:a,children:o}){return r.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[r.jsxs("div",{className:"sd-top",children:[r.jsxs("div",{className:"sd-head",children:[r.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&r.jsx("span",{className:"sd-sub",children:n}),r.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:a,"aria-label":"Close",title:"Close",children:"×"})]}),s&&r.jsx("p",{className:"sd-flag",children:s})]}),o]})}function uee({usageOpen:e,leaving:t,onClose:n}){const s=IQ();if(!s||s.cpu==null||!s.memory)return r.jsx(CT,{usageOpen:e,leaving:t,onClose:n,children:r.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:a,swap:o,perCore:i,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:m,cpu:w}=s;return r.jsxs(CT,{usageOpen:e,leaving:t,sub:`up ${RQ(h)} · ${d} cores`,flag:MQ(s),onClose:n,children:[r.jsx(dee,{cpu:w,perCore:i,loadavg:c,cores:d}),r.jsx(hee,{memory:a,swap:o,platform:f}),m&&r.jsx(lee,{network:m}),r.jsx(fee,{thermal:p}),r.jsx(pee,{sys:s})]})}function dee({cpu:e,perCore:t,loadavg:n,cores:s}){const a=EQ(n==null?void 0:n[0],s),o=!!t&&t.length>0;return!o&&!n?null:r.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[o&&r.jsx(Ru,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:r.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)=>r.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${i}% busy`,children:r.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,i)/100})`}})},c))})}),n&&r.jsxs(Ru,{group:"load",title:"Load history",action:"Show load history",label:"Load average",liveNote:a,hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[r.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)=>r.jsx(t1,{value:i.toFixed(2),cap:["1m","5m","15m"][c]},c))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function hee({memory:e,swap:t,platform:n}){const s=e.total-e.available,a=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:r.jsxs(Ru,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[r.jsx(Vf,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.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&&r.jsx(Vf,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Qr(t.used)})," of ",Qr(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function fee({thermal:e}){if(!e)return null;const t=e.throttle?AQ(e.throttle,e.heldBack):null;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:r.jsxs(Ru,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>r.jsx(Vf,{label:n.label,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:TQ(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&&r.jsx(Vf,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function pee({sys:e}){const[t,n]=y.useState(!1);return r.jsxs("div",{className:"sd-section sd-door-section",children:[r.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:r.jsxs("span",{className:"sd-door-plate",children:[r.jsxs("span",{className:"sd-door-name",children:["Busiest processes",r.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),r.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&r.jsx(tee,{sys:e,onClose:()=>n(!1)})]})}function mee(){const[e,t]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const n=()=>t(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),r.jsxs("div",{className:"ap-proj-loading",role:"status","aria-label":"Reading project activity","data-paused":e||void 0,children:[r.jsxs("svg",{className:"ap-proj-loading-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"100",y:"8",width:"40",height:"43",rx:"4"}),r.jsx("path",{d:"M108 21h24M108 29h18M108 37h21"}),r.jsx("path",{className:"ap-proj-loading-scan",d:"M108 21h24"}),r.jsx("path",{className:"ap-proj-loading-links",d:"M120 51v15M51 76V66h138v10M120 66v10"}),r.jsx("path",{d:"M30 83v-7h14l6 7h22v23H30zM99 83v-7h14l6 7h22v23H99zM168 83v-7h14l6 7h22v23h-42z"})]}),r.jsx("strong",{children:"Reading project activity"}),r.jsx("span",{children:"Gathering this account’s work by project…"})]})}function Gf(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=Gf(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,Gf(a)]))),t}function ET(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(Gf(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function QP(e){return e.i+e.o+e.cr+e.cc}function n1(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&&n1(e.l??(e.l={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),t.l);for(const[s,a]of Object.entries(t.s??{}))n1((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function TT(e,t,n){let s=0,a=0,o=0;const i=[];for(const c of Wu(e)){if(!br(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+=vu(c.usage,t,c.speed,n).total,a+=vu({...c.usage,longContext:void 0},t,la,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function AT(e){let t=0;for(const n of Object.values(e))t+=QP(n);return t}function gee(e){const t=a=>typeof a=="number"&&Number.isFinite(a)?a:0,n=new Map,s=e&&Array.isArray(e.days)?e.days:[];for(const a of s){const o=typeof a.period=="string"?a.period:"",i=Array.isArray(a.modelBreakdowns)?a.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 yee(e,t,n,s=Date.now()){const a=new Map;for(const M of e){const O={},I=F=>{for(const[L,A]of Object.entries(F))n1(O[L]??(O[L]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),A)};for(const F of M.projects)I(F.models);M.unattributed&&I(M.unattributed);for(const[F,L]of Object.entries(O)){if(!L.s&&!L.l)continue;const{atSpeed:A,atStandard:q}=TT(ET(L),F,s);if(!(A>0&&q>0))continue;let E=a.get(M.day);E||(E=new Map,a.set(M.day,E)),E.set(F,A/q),E.has(mr(F))||E.set(mr(F),A/q)}}const o=(M,O)=>{const I=a.get(M);return(I==null?void 0:I.get(O))??(I==null?void 0:I.get(mr(O)))??1},i=new Map;let c=0,d=0;for(const[M,O]of n){const I=M.indexOf("|"),F=M.slice(0,I),L=M.slice(I+1),A=bp(O.usage,L,s).total*o(F,L);if(!(A>0&&O.cost>0))continue;c+=O.cost,d+=A;let q=i.get(F);q||(q=new Map,i.set(F,q)),q.set(L,O.cost/A)}const h=d>0,f=(M,O)=>{const I=i.get(M);return(I==null?void 0:I.get(O))??(I==null?void 0:I.get(mr(O)))??null},p=new Set,m=(M,O)=>{let I=0,F=0;for(const[L,A]of Object.entries(M)){if(br(L,s)){const E=O(L),D=TT(E===null?Gf(A):ET(A),L,s);I+=E===null?D.atSpeed:D.atSpeed*E,F+=D.unpriced;for(const P of D.unpricedSpeeds)p.add(`${L} (${P})`);continue}const q=QP(A);q>0&&(F+=q,p.add(L))}return{cost:I,unpriced:F}},w=new Map,k=[];for(const M of e){const O=new Map,I=new Map;let F=0;for(const L of M.projects){const{cost:A,unpriced:q}=m(L.models,D=>f(M.day,D));O.set(L.path,(O.get(L.path)??0)+A),q>0&&I.set(L.path,(I.get(L.path)??0)+q),F+=A;let E=w.get(L.path);E||(E={path:L.path,cost:0,tokens:0,unpricedTokens:0},w.set(L.path,E)),E.cost+=A,E.tokens+=AT(L.models),E.unpricedTokens+=q}k.push({day:M.day,total:F,byPath:O,unpricedByPath:I})}const b=[...w.values()].sort((M,O)=>O.cost-M.cost||O.tokens-M.tokens),v=b.reduce((M,O)=>M+O.cost,0),N=b.reduce((M,O)=>M+O.tokens,0),j=b.reduce((M,O)=>M+O.unpricedTokens,0),S=h?c/d:null,_=t?AT(t):0,T=t?m(t,()=>S):{cost:0,unpriced:0},$=T.cost>0||_>0?{cost:T.cost,tokens:_,unpricedTokens:T.unpriced}:null;return{projects:b,totalCost:v,totalTokens:N,unpricedTokens:j,perDay:k,unattributed:$,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&j===0}}function pr(e,t,n=nt){return t>0?e>0?`${n(e)}+`:ca:n(e)}function Ji(e){return e>0?`${wt(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function wee(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 ${ca}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ca}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const xee={phase:"running"},vee={phase:"failed"},bee={gen:0,report:null,error:null,early:null};function kee(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 a=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:xee;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:a},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 jee(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function Nee(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:vee}function See(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function _ee(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=Q0(s,a),i=See(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function Cee({num:e,days:t,gen:n,dispatch:s,get:a=(i,c)=>fetch(i,c),now:o=Date.now()}){const i=_ee(e,t,o),c={credentials:"same-origin"};a(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"})),a(i.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>s({type:"cost",gen:n,cost:Nee(d)}))}function eD(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function ky(e){const t=eD(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function RT(e){if(!e)return e;const t=eD(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 Eee(e,t){const n=ky(e);let s;for(const a of t){const o=ky(a.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||ky(s.path).length<o.length)&&(s=a)}return s==null?void 0:s.label}function s1(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function Tee(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${s1(e)}.`}function Aee(e){return e===1?7:e===7?30:e===30?0:null}function Ree(e,t){return e!==1&&t>0}const Mee=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Qi=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],$ee="var(--usage-zinc)",jy=6,Lee=1600;function Iee(e){const t=nt(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Ph(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 Oee(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function Pee(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Ny(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function Dee({num:e,name:t,onClose:n}){var P,z,G,V;nn("account-projects");const[s,a]=y.useState(1),[o,i]=y.useReducer(kee,bee),c=((P=o.report)==null?void 0:P.data)??null,d=((z=o.report)==null?void 0:z.days)??s,h=((G=o.report)==null?void 0:G.cost.phase)==="ready"?o.report.cost.range:null,f=((V=o.report)==null?void 0:V.cost.phase)==="running",[p,m]=y.useState(null),[w,k]=y.useState(()=>new Set),b=jee(o),v=o.error,[N,j]=y.useState(null),S=y.useRef(void 0),_=y.useRef(!0);y.useEffect(()=>()=>{_.current=!1,window.clearTimeout(S.current)},[]);const T=y.useRef(null),$=pt(n,{focusRef:T}),M=gt(n),O=y.useRef(0);y.useEffect(()=>{const H=++O.current;i({type:"start",gen:H}),m(null),k(new Set),Cee({num:e,days:s,gen:H,dispatch:i})},[e,s]);const I=y.useMemo(()=>{const H=Date.now();if(!c)return null;const B=yee(c.daily??[],c.unattributed,gee(h),H),W=ke=>ke.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||ke||"(unknown)",ee=new Map;for(const ke of B.projects)ee.set(W(ke.path),(ee.get(W(ke.path))??0)+1);const U=ke=>{const Ne=W(ke);if((ee.get(Ne)??0)<=1)return Ne;const ge=ke.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return ge?`${ge}/${Ne}`:Ne},Y=B.projects.map(ke=>({path:ke.path,label:U(ke.path)})),X=ke=>({path:ke.path,label:U(ke.path),parentLabel:Eee(ke.path,Y),cost:ke.cost,tokens:ke.tokens,unpricedTokens:ke.unpricedTokens}),Z=Qi[jy%Qi.length],J=new Map,te=[],ce=B.projects.slice(0,jy),he=B.projects.slice(jy);ce.forEach((ke,Ne)=>{J.set(ke.path,Qi[Ne%Qi.length]),te.push({key:ke.path,...X(ke),color:Qi[Ne%Qi.length]})}),he.length&&te.push({key:"__other__",label:`Other · ${he.length} project${he.length>1?"s":""}`,cost:he.reduce((ke,Ne)=>ke+Ne.cost,0),tokens:he.reduce((ke,Ne)=>ke+Ne.tokens,0),unpricedTokens:he.reduce((ke,Ne)=>ke+Ne.unpricedTokens,0),color:Z,muted:!0,members:he.map(X)});const le=B.totalCost,re=B.totalTokens,ae=le>0&&B.unpricedTokens===0?"cost":"tokens",de=ae==="cost"?le:re,_e=te.map(ke=>ke.color),fe=B.perDay.map(ke=>{const Ne=new Map;for(const[Ie,We]of ke.byPath){const Te=J.get(Ie)??Z;Ne.set(Te,(Ne.get(Te)??0)+We)}const ge=new Map;let Me=0;for(const[Ie,We]of ke.unpricedByPath){const Te=J.get(Ie)??Z;ge.set(Te,(ge.get(Te)??0)+We),Me+=We}return{day:ke.day,total:ke.total,costByColor:Ne,unpricedByColor:ge,unpriced:Me}}),ye=fe.reduce((ke,Ne)=>Math.max(ke,Ne.total),0);return{projectCount:B.projects.length,rows:te,totalCost:le,totalTokens:re,basis:ae,denom:de,un:B.unattributed,chart:fe,maxDay:ye,colorOrder:_e,unpricedTokens:B.unpricedTokens,unpricedNote:wee(B.unpricedModels),calibrated:B.calibrated,reconciled:B.reconciled}},[c,h]),F=(H,B)=>{ho(H).then(W=>{_.current&&(window.clearTimeout(S.current),j({path:H,label:B,ok:W}),S.current=window.setTimeout(()=>{_.current&&j(null)},Lee))})},L=H=>N!=null&&N.ok&&N.path===H?"Copied":"Copy",A=c!=null&&c.trackedSince?`Tracked since ${Ny(c.trackedSince)}`:"Tracking starts with this version",q=s1(d),E=Aee(d),D=b&&!!c;return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...M,role:"presentation",children:r.jsxs("div",{ref:$,className:"modal ap-proj-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[r.jsxs("header",{className:"ap-proj-head",children:[r.jsxs("div",{className:"ap-proj-titlewrap",children:[r.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),r.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:Mee.map(H=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===H.days,onClick:()=>a(H.days),children:H.label},H.days))}),r.jsx("button",{ref:T,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:`ap-proj-body${D?" refreshing":""}`,"aria-busy":b,children:[b&&!c&&r.jsx(mee,{}),!b&&v&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",v]}),!v&&I&&r.jsx("div",{className:"ap-proj-ready",children:I.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[D?"Updating…":Tee(d),E!=null&&r.jsx("div",{className:"ap-proj-widen-wrap",children:r.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>a(E),children:["Show ",s1(E)]})}),r.jsxs("div",{className:"ap-proj-note",children:[A,". Only work from this version onward can be tied to an account."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${I.basis==="cost"?nt(I.totalCost):`${wt(I.totalTokens)} tokens`} across ${I.projectCount} project${I.projectCount>1?"s":""}`,children:I.rows.map(H=>{const B=I.basis==="cost"?H.cost:H.tokens,W=I.denom>0?B/I.denom*100:0;if(W<=0)return null;const ee=I.basis==="cost"?Ph(H.cost,I.totalCost):`${Ph(H.tokens,I.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${W}%`,background:H.color},title:`${H.label} · ${pr(H.cost,H.unpricedTokens)} · ${ee}${H.tokens?` · ${wt(H.tokens)} tokens`:""}`},H.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:Ji(I.unpricedTokens),children:pr(I.totalCost,I.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[wt(I.totalTokens)," tokens"]}),r.jsxs("span",{className:"ap-proj-total-win",children:["· ",D?"updating…":q]}),f&&r.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),I.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:I.unpricedNote}),Ree(d,I.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",I.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${I.chart.length} day${I.chart.length>1?"s":""}`,children:I.chart.map(H=>{const B=I.maxDay>0?H.total/I.maxDay*100:0,W=p===H.day,ee=I.rows.map(Y=>({label:Y.label,c:H.costByColor.get(Y.color)??0,u:H.unpricedByColor.get(Y.color)??0})).filter(Y=>Y.c>0||Y.u>0),U=`${Ny(Date.parse(`${H.day}T00:00:00`))}, ${pr(H.total,H.unpriced)}. ${ee.map(Y=>`${Y.label} ${pr(Y.c,Y.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${W?" selected":""}`,"aria-pressed":W,"aria-label":U,title:`${H.day} · ${pr(H.total,H.unpriced)}`,onClick:()=>m(Y=>Y===H.day?null:H.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${B}%`},children:I.colorOrder.map((Y,X)=>{const Z=H.costByColor.get(Y)??0;return Z<=0||H.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${Z/H.total*100}%`,background:Y}},X)})})},H.day)})}),(()=>{const H=Pee(I.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:I.chart.map((B,W)=>r.jsx("div",{className:"ap-proj-axis-cell",children:H(W)?Oee(B.day):""},B.day))})})(),(()=>{const H=p?I.chart.find(W=>W.day===p):null;if(!H)return null;const B=I.rows.map(W=>({r:W,c:H.costByColor.get(W.color)??0,u:H.unpricedByColor.get(W.color)??0})).filter(W=>W.c>0||W.u>0);return r.jsxs("div",{className:"ap-proj-day-detail",children:[r.jsxs("div",{className:"ap-proj-day-detail-head",children:[r.jsx("span",{children:Ny(Date.parse(`${H.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:Ji(H.unpriced),children:pr(H.total,H.unpriced)})]}),B.map(({r:W,c:ee,u:U})=>r.jsxs("div",{className:"ap-proj-day-detail-row",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),r.jsx("span",{className:"ap-proj-day-detail-name",children:W.label}),r.jsx("span",{className:"ap-proj-day-detail-cost",title:Ji(U),children:pr(ee,U)})]},W.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:I.rows.map((H,B)=>{const W=I.basis==="cost"?H.cost:H.tokens,ee=I.denom>0?W/I.denom*100:0,U=w.has(H.key),Y=`ap-proj-details-${B}`,X=U&&(!!H.path||!!H.members),Z=H.members?`${U?"Hide":"Show"} the ${H.members.length} project${H.members.length>1?"s":""} folded into Other`:`${U?"Hide":"Show"} location for ${H.label}`;return r.jsxs("li",{className:`ap-proj-row${H.muted?" muted":""}${U?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[H.label,H.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",H.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:I.basis==="cost"?`${Ph(H.cost,I.totalCost)} of tracked cost`:`${Ph(H.tokens,I.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${ee}%`,background:H.color}})}),r.jsx("span",{className:"ap-proj-cost",title:Ji(H.unpricedTokens),children:pr(H.cost,H.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:wt(H.tokens)}),r.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":U,"aria-controls":X?Y:void 0,"aria-label":Z,onClick:()=>k(J=>{const te=new Set(J);return te.has(H.key)?te.delete(H.key):te.add(H.key),te}),children:"ⓘ"}),U&&H.path&&r.jsxs("div",{className:"ap-proj-details",id:Y,children:[r.jsx("code",{className:"ap-proj-path",children:RT(H.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${L(H.path)} location for ${H.label}`,onClick:()=>F(H.path,H.label),children:L(H.path)})]}),U&&H.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:Y,children:H.members.map(J=>r.jsxs("div",{className:"ap-proj-other-member",children:[r.jsxs("div",{className:"ap-proj-other-name",children:[J.label,J.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",J.parentLabel]})]}),r.jsx("code",{className:"ap-proj-path",children:RT(J.path)}),r.jsx("span",{className:"ap-proj-cost",title:Ji(J.unpricedTokens),children:pr(J.cost,J.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:wt(J.tokens)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${L(J.path)} location for ${J.label}`,onClick:()=>F(J.path,J.label),children:L(J.path)})]},J.path))})]},H.key)})}),I.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:$ee},"aria-hidden":"true"}),r.jsxs("div",{className:"ap-proj-un-labels",children:[r.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),r.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),r.jsx("span",{className:"ap-proj-un-cost",title:Ji(I.un.unpricedTokens),children:pr(I.un.cost,I.un.unpricedTokens,Iee)}),r.jsx("span",{className:"ap-proj-un-tok",children:wt(I.un.tokens)}),r.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:N&&(N.ok?`Copied the location of ${N.label}`:`Could not copy the location of ${N.label} — select it and copy it by hand`)}),r.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":I.reconciled?"Dollars from ccusage · split by activity":I.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",A]})]})})]})]})}),document.body)}function ua(e,t){return U4(t-Math.floor(e/1e3))}function Fee(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 Xj(){return r.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:[r.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),r.jsx("path",{d:"M7 5.6v2.9"}),r.jsx("path",{d:"M7 10.3v.05"})]})}function Bee({anchorId:e,boundaryId:t,issue:n,who:s,fetchedAt:a,nowSec:o,onClose:i,onSignIn:c,onReport:d}){const h=y.useRef(null);return r.jsx(Up,{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:r.jsxs("div",{className:"ap-pop-form",children:[r.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&r.jsx(Xj,{}),n.text]}),r.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),r.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[r.jsx("span",{className:"ap-issue-who",children:s})," · ",a?`last collected ${ua(a,o)}`:"never collected"]}),r.jsxs("div",{className:"ap-pop-actions",children:[d&&r.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{i(),d()},children:"Report this"}),r.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>i(!0),children:"Done"}),n.fix&&r.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})]})]})})}const qee=5*6e4;function Uee(e,t){return typeof e!="string"||!e?!1:e==="::1"||e==="localhost"||e.startsWith("127.")?!0:Array.isArray(t)&&t.includes(e)}function Wee(e,t,n=qee){const s=new Map;if(!(e!=null&&e.enabled))return s;const a=new Set;for(const o of Array.isArray(e.peers)?e.peers:[]){if(!o||o.paired!==!0)continue;const i=o.offers,c=i!=null&&i.current&&typeof i.current.key=="string"?i.current.key:"";if(!c||typeof i.at!="number"||!Number.isFinite(i.at)||t-i.at>n||i.at-t>n||Uee(o.addr,e.addrs))continue;const d=`${c}|${o.peerFp??o.fp}`;a.has(d)||(a.add(d),s.set(c,[...s.get(c)??[],o]))}return s}function tD(e){return e.length<=1?e[0]??"another deck":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Gc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Hee(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)),a=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} ${a} It tries again in ${s}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function zee(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 Vee(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 MT={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 Gee(e){const t=tD(e),n=e.length>1?"are":"is";return{text:`Also active on ${t}`,hint:`${t} ${n} using this login right now as well. A Claude login renews once: whichever machine renews it first keeps it, and the other is signed out (“Login expired · Please run /login”). Use a different account on one of them. Signing in on each machine separately gives each its own login, and those do not collide.`,fix:null,tone:"warn",blocksSwitch:!1}}function ii(e,t,n){var a;const s=Yee(e,t);return e.active===!0&&((a=n==null?void 0:n.elsewhere)!=null&&a.length)&&(!s||s.tone!=="warn")?Gee(n.elsewhere):!s||!(n!=null&&n.noCopyWorksNearby)||!Kee(e)?s:{...s,text:MT.text,hint:MT.hint}}function Kee(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function Yee(e,t){if(e.staleCopy){const n=Hee(e.repair??null,t);return{text:Gc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=Vee(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:Gc(n.text),hint:n.hint,fix:n.fix?Gc(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=zee(e.error);return{text:Gc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function $T(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function LT(e){const t=e.filter(c=>!$T(c)),n=e.filter(c=>$T(c)),s=t.length?t:n,a=t.length?n:[],o=s.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let i=null;for(const c of a)o&&c.pct<=o.pct||(!i||c.pct>i.pct)&&(i=c);return{shown:s,rest:a,fuller:i,peak:i??o}}function Mu(e,t){return!!e.resetAt&&e.resetAt<=t}function Zj(e,t){return(e.lanes??[]).some(s=>Mu(s,t))?null:e.headroom}const Xee="\0";function Gs(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}${Xee}${n}`}function Zee(e,t,n=Gs){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const Wp="slot",Jj=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],nD=e=>e.id.startsWith("scoped-");function Jee(e){var t;return((t=Jj.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function Qee(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function sD(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(nD).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...Jj.map(s=>s.name),...t];return[{id:Wp,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function IT(e,t,n){const s=Jj.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:nD(o)&&o.label===t);return a&&n!=null&&Mu(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function ete(e,t,n=()=>!0,s){const a=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>s==null?p.headroom:Zj(p,s);return o(OT(a,p=>{const m=f(p);return Number.isFinite(m)?m:null},"desc"))}const i=/^(.+):(full|empty)$/.exec(t);if(!i)return a;const[,c,d]=i;if(!a.some(f=>IT(f,c,s)!=null))return a;const h=OT(a,f=>IT(f,c,s),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function OT(e,t,n){const s=e.filter(o=>t(o)!=null),a=e.filter(o=>t(o)==null);return s.sort((o,i)=>n==="desc"?t(i)-t(o):t(o)-t(i)),[...s,...a]}function tte(e,t){return sD(t).some(n=>n.id===e)?e:Wp}function r1(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(Gs(o))).sort((o,i)=>n.get(Gs(o))-n.get(Gs(i))),a=e.filter(o=>!n.has(Gs(o)));return[...s,...a]}function Qj(e){const t=Gs(e);return t.startsWith("slot:")?t:`h:${nte(t)}`}function nte(e){let t=3735928559,n=1103547991;for(let s=0;s<e.length;s++){const a=e.charCodeAt(s);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,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 a1={mode:"some",keys:[]};function rD(e,t){const n=e.keys.includes(Qj(t));return e.mode==="all"?!n:n}function ste(e,t){return{mode:e.mode,keys:Zee(e.keys,t,Qj)}}function aD(e,t){return t.length>0&&t.every(n=>rD(e,n))}function rte(e,t){return aD(e,t)?a1:{mode:"all",keys:[]}}function ate(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Qj)),s=e.keys.filter(a=>n.has(a));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const Xo=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function PT(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function ote(e){const t=PT(e.five_hour),n=PT(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 ite(e,t){const n=Xo.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:ua(e.updatedAt,t),old:!0}}const oD=15*6e4;function Hp(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const iD=e=>e.alias??e.email??`account ${e.num}`;function au(e,t){var s,a;const n=(a=(s=e.lanes)==null?void 0:s.find(o=>o.id===t))==null?void 0:a.resetAt;return n!=null&&n>0&&Number.isFinite(n)&&Number.isFinite(new Date(n*1e3).getTime())?n:null}function o1(e,t,n){const s=Xo.find(w=>w.id===t).label,a=(e.lanes??[]).find(w=>w.id===t),o=a&&Number.isFinite(a.pct)?lD(a.pct):null,i=ii(e,n),c=au(e,t),d=c!=null&&c<=n,h=cD(a,e.fetchedAt,n),f=(w,k)=>({counted:!1,why:w,say:k,last:o,estimate:o,resetAt:d?null:au(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=Hp(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>oD?f("stale",p!=null?`Updated ${ua(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:au(e,t)}}const lD=e=>Math.min(100,Math.max(0,e));function cD(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=Hp(t),a=s!=null?`read ${ua(s,n)}`:"last read";return`Reported reset time passed ${ua(e.resetAt*1e3,n)}, ${oo(lD(e.pct))}% when ${a}`}function lte(e,t){const n=Xo.find(h=>h.id===t);let s=0,a=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&&a++,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:a,included:o,total:e.length,used:o?s/o:null,nextReset:d}}function eN(e,t){const n=e.map(a=>{const o={five_hour:o1(a,"five_hour",t),seven_day:o1(a,"seven_day",t)};return{num:a.num,key:Gs(a),name:iD(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:au(a,"five_hour"),seven_day:au(a,"seven_day")},status:ote(o),updatedAt:Hp(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:Xo.map(a=>lte(n,a.id)),roomInBoth:s}}function Oc(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const cte={ready:0,limited:1,exhausted:2,stale:3};function ute(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function DT(e,t){return t==="status"?cte[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:ute(e.cells[t])}function dte(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,s=new Map(e.map((o,i)=>[o.num,i])),a=(o,i)=>{if(t.key==="account")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});const c=DT(o,t.key),d=DT(i,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>a(o,i)||s.get(o.num)-s.get(i.num))}function oo(e){return e>=100?100:Math.min(99,Math.round(e))}function hte(e){const t=oo(e);return{used:t,available:100-t}}function fte(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 uD=new Set(["awaiting_url","awaiting_code","registering"]);function dD(e){return e!=null&&uD.has(e)}function hD(e){return e!=null&&e!=="done"&&!uD.has(e)}const fD="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",pte="the sign-in did not complete";function mte({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?fD:pte)}}function FT({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 BT({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function gte({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":hD(e==null?void 0:e.state)||n&&t&&!s?"ended":s||dD(e==null?void 0:e.state)?"asking":"primer"}function tN(e,t){return t?Gt(e,t):void 0}const yte={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 ${$t}`,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"},wte={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",login_expired:"that account's login expired, so the deck did not switch to it — sign in again to use it",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"},nN=`claude-swap could not read the login keychain — start ${$t} from a Terminal window rather than a background service`,xte={unreadable_here:{short:"Keychain locked on this Mac",long:`${nN}.`},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 Kf(e){return e?Gt(xte,e)??null:null}const pD={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 i1(e,t,n){const s=n==null?null:pD[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test($u(e)))return nN;const a=tN(wte,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function $u(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const vte={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"},bte="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 kte(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const jte="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",Nte="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",Ste=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),_te=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,Cte=/[\\/]_npx[\\/]/i,Ete=`the copy of ccusage ${$t} installed for itself`;function Tte(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function uke(e,t){const n=Ate(e,t),s=Tte(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 ${Pc(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Pc(n)}`;case"managed":return`${Ete} failed to run: ${Pc(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Pc(n)}`:`the ccusage this deck found on your PATH failed to run: ${Pc(n)}`;default:return n}}const Pc=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function Ate(e,t){const n=$u(e);if(Ste(n)){if(Cte.test(n))return Nte;if(_te.test(n))return jte}if(kte(n))return bte;const s=tN(vte,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function cl(e,t,n){const s=n==null?null:pD[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&hD(e.state))return e.error;const a=tN(yte,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function vr(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 a=Math.round(s/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const Rte={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${nN}. The next round brings it.`},"in use":{short:"in use on the other deck",long:"the other deck is using this login right now and does not send it: two machines on one login race to renew it, and the loser is signed out. It comes on the first round after that deck switches away — or sign in to it here, which gives this machine a login of its own."}};function l1(e){return e.why?Gt(Rte,e.why)??Kf(e.why):null}const sN={"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"}},Mte={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 qT(e){var s;const t=$te[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&Mte[n]||e}const $te={"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 zp(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=zp({...e,error:void 0},t),m=` · ${vr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${qT(e.error)}${m}`,tone:"bad"}}if(e.error)return sN[e.error]??{text:qT(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${vr(e.at,t)}`,tone:"idle"};const s=n.filter(p=>p.ok),a=s.length===1?"login":"logins",o=n.map(p=>({d:p,why:l1(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=vr(e.at,t);return s.length===n.length?{text:`${s.length} ${a} 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 Lte=9e4;function Ite({error:e,host:t,port:n},s,a,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&&a-h.at<Lte);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 Vp(e,t){var n,s;return(n=e.last)!=null&&n.error&&!sN[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<c1||e.lastSeen!=null&&t-e.lastSeen<c1)}const c1=95e3;function Ote(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 a=p=>p.waiting?mD(p.lastSeen,t):Vp(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 yD(s,m=>aN(m,m.peerFp??m.fp,i).name,m=>m.addr??"")){const m=p.filter(a);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 Pte(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=vr(e,t);return s==="now"?"checked just now":`checked ${s}`}function rN(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 mD(e,t){return e!=null&&t-e<c1}function Dte(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=mD(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${vr(e,t)}`,here:n}}function UT(e,t,n){return t?"online":e.lastSeen!=null?`last online ${vr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function Fte(e,t){if(!e)return[];const n=[],s=new Set,a=(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(Bte(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(qte(p,m,t)):i.push(Ute(p,m,o,t)))}n.push(...zte(i).sort(a),...c.sort(a));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),d.push(Wte(p,o,e.pairingMode)));n.push(...d.sort(a));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),h.push(Hte(p,o)));n.push(...h.sort(a));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 Bte(e,t,n){const s=Gp(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${rN(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Kp(e.via)}}function qte(e,t,n){var o;const s=zp(e.last,n),a=e.addr?`${e.addr}:${e.port}`:"";return{fp:a,name:a||e.name||t,addr:e.addr??"",kind:"dialling",state:s?u1(s):"trying…",tone:s?s.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${a} yet — ${e.last.error}.`:`Dialling ${a} until something answers.`,...Kp(e.via)}}function Ute(e,t,n,s){var w,k,b,v;const a=zp(e.last,s),o=Vp(e,s),i=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?Dte(e.lastSeen,s):null,d=c?c.here:o,h=!c&&a?d?`online · ${u1(a)}`:`${u1(a)} · ${UT(e,d,s)}`:c?c.text:UT(e,d,s),f=(w=e.last)!=null&&w.error?sN[e.last.error]:null,p=!c&&d&&!((k=e.last)!=null&&k.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,m=aN(e,t,n);return{fp:t,...m,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":a?a.tone:d?"ok":"idle",here:c?c.here:o,...Kp(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 ${vr(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}`:""}${(v=e.last)!=null&&v.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function aN(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Gp(n,t,e.name||t)}function gD(e,t){return aN(e,e.peerFp??e.fp,t).name}function Wte(e,t,n){const s=Gp(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.`,...Kp(e.via)}}function Hte(e,t){const n=Gp(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 Gp(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function Kp(e){return e==="tailscale"?{via:"tailscale"}:{}}function u1(e){return e.text.replace(/ · .*$/,"")}function zte(e){return yD(e,t=>t.name,t=>t.addr).map(Vte)}function yD(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 a=[];for(const o of s.values()){const i=[...new Set(o.map(n).filter(Boolean))];if(i.length>1){for(const c of i)a.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||a.push([c])}else a.push(o)}return a}function Vte(e){const[t,...n]=[...e].sort((s,a)=>Number(a.here)-Number(s.here)||+!!a.addr-+!!s.addr);return n.length?{...t,twins:n}:t}function WT(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Lu(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 Gte(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 a=s.filter(i=>i.here).length;return a?a===s.length?{text:`${a} online`,tone:"ok",live:!0}:{text:`${a} of ${s.length} online`,tone:"ok",live:!0}:{text:`none of ${s.length} online`,tone:"idle",live:!1}}function Kte(e,t){const n=e.filter(f=>f.kind==="asks"),s=e.filter(f=>f.kind!=="asks"),a=s.filter(f=>f.here),o=s.filter(f=>!f.here),i=o.filter(f=>f.tone==="bad").length,c=t||a.length===0,d=c?[...a,...o]:a,h=s.filter(f=>f.kind==="paired").length;return{asks:n,rest:s,live:a,folded:o,troubled:i,showFolded:c,shown:d,paired:h}}function HT(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,...t.active?{active:!0}:{}}))}function Yte(e,t){if((t==null?void 0:t.sendInUse)===!0)return e;const n=new Set(e.filter(s=>s.active).map(s=>s.key));return e.map(s=>n.has(s.key)?{...s,shareable:!1,inUse:!0}:s)}function Xte(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&Vp(o,n));if(s.some(o=>{var i,c,d;return Zte((i=o.offers)==null?void 0:i.current)&&!((d=(c=o.offers)==null?void 0:c.accounts)!=null&&d.some(h=>h.key===e))}))return!1;const a=s.map(o=>{var i,c;return(c=(i=o.offers)==null?void 0:i.accounts)==null?void 0:c.find(d=>d.key===e)}).filter(o=>o!=null);return a.length>0&&a.every(o=>!o.alive)}const Zte=e=>!!e&&typeof e=="object"&&e.hidden===!0;function Jte(e,t,n,s){if(!(n!=null&&n.enabled)||n.running===!1)return!1;const a=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!Vp(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()===a))})}function Qte(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=>gD(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function ene(e,t,n){const s=Wee(t,n).get(e);if(!(s!=null&&s.length))return null;const a=s.map(o=>gD(o,(t==null?void 0:t.aliases)??{})).filter(Boolean);return[...new Set(a)].sort((o,i)=>o.localeCompare(i))}function tne(e,t){return e.flatMap(n=>{const s=Qte(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function zT(e,t=!1){const n=e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?e.length?`Shared on Local network: in use here · not sent to ${n} while this deck is on it.`:"Shared on Local network: in use here · not sent while this deck is on it. None is paired yet.":e.length?`Shared on Local network: offered to ${n}.`:"Shared on Local network: offered to every deck you pair with. None is paired yet."}const wD={OTEL_LOG_USER_PROMPTS:"prompts",OTEL_LOG_ASSISTANT_RESPONSES:"responses",OTEL_LOG_TOOL_DETAILS:"tool details",OTEL_LOG_TOOL_CONTENT:"tool output",OTEL_LOG_RAW_API_BODIES:"full API bodies"};function Yf(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function nne(e,t,{holdOut:n=!1}={}){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const s=e.level==="content"?e.content.map(c=>wD[c]??c):[],a=e.orgName?e.orgName:"This account's organization",o=s.length?`usage data, and your ${Yf(s)}`:"usage data",i=e.destinations.length?Yf(e.destinations):"its collector";return{text:`Telemetry · ${s.length?s.join(", "):"usage data"}`,tone:s.length?"warn":"quiet",detail:`${a} turns on Claude Code telemetry for new sessions: ${o}, sent to ${i}. Seen ${ua(e.seenAt,t)}, while this account was active.`+(n?" To keep Auto-switch off it, choose Hold out of rotation in its ⋯ menu.":"")}}function sne(e){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const t=e.level==="content"?e.content.map(o=>wD[o]??o):[],n=t.length?`your ${Yf(t)}`:"usage data",s=e.orgName?`${e.orgName}'s telemetry`:"Its organization's telemetry",a=e.destinations.length?` to ${Yf(e.destinations)}`:"";return`${s} is on for them: it sends ${n}${a}.`}function rne(e){return e>=90?"hi":e>=70?"mid":void 0}function ane({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=Mu(e,t),c=s||i,d=c?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!c?Hu(e.resetAt,t):null,f=i?cD(e,n,t):null;return r.jsxs("div",{className:"ap-lane","data-sort-key":a?"":void 0,children:[r.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),r.jsx("div",{className:"ap-lane-track",children:!i&&r.jsx("div",{className:"ap-lane-fill",style:{width:`${o===0?1.5:o}%`,background:d,opacity:o===0||c?.4:1}})}),i?r.jsx("span",{className:"ap-lane-pct",style:{color:d},"data-reset":"",title:f??void 0,children:f?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:"reset"}),r.jsx("span",{className:"vis-hidden",children:f})]}):"reset"}):r.jsxs("span",{className:"ap-lane-pct",style:{color:d},children:[Math.round(o),"%"]}),r.jsx("span",{className:"ap-lane-reset",title:h?`${e.label} resets in ${h}`:void 0,children:h&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"vis-hidden",children:"resets in "}),h]})})]})}function one({a:e,nowSec:t,lan:n,opened:s,onToggleLanes:a,busy:o,pressProps:i,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:m,onSignIn:w,switchedHere:k,swapped:b,displaced:v,issueExpanded:N,onOpenIssue:j,sortKey:S=null,home:_=null,rotating:T=!1}){const $=e.lanes.filter(V=>!Mu(V,t)),{shown:M}=LT(e.lanes),{fuller:O}=LT($),I=S==="room"?$.reduce((V,H)=>V&&V.pct>=H.pct?V:H,null):S?e.lanes.find(V=>Jee(V)===S)??null:null,F=ii(e,t,n),L=e.active||s,A=e.alias??e.email??`account ${e.num}`,q=e.alias&&e.email?`${e.alias} · ${e.email}`:A,E=e.stale||(F==null?void 0:F.blocksSwitch)===!0,D=O?[...M,O]:M,P=e.fetchedAt?ua(e.fetchedAt,t):null,z=nne(e.telemetry,t,{holdOut:T&&!e.active&&!e.disabled}),G=sne(e.telemetry);return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":L?"":void 0,"data-frozen":E?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:q,"aria-expanded":L,"aria-controls":L?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,_?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!L&&!(F!=null&&F.blocksSwitch)?`ap-quota-${e.num}`:null,z?`ap-telemetry-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[A,", ",L?"hide details":"details"]})}),r.jsxs("div",{className:"ap-account-head",children:[e.active?r.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:r.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):r.jsx("span",{className:"ap-num",children:e.num}),e.alias&&r.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),r.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),_&&r.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:_,children:[r.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:[r.jsx("path",{d:"M2.2 6.6 7 2.6l4.8 4"}),r.jsx("path",{d:"M3.6 5.6v5.8h6.8V5.6"}),r.jsx("path",{d:"M6 11.4V8.6h2v2.8"})]}),r.jsx("span",{className:"vis-hidden",children:_})]}),(n==null?void 0:n.sharedTo)&&r.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:zT(n.sharedTo,n.sharedInUse),children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("circle",{cx:"10.5",cy:"3.2",r:"1.7"}),r.jsx("circle",{cx:"3.5",cy:"7",r:"1.7"}),r.jsx("circle",{cx:"10.5",cy:"10.8",r:"1.7"}),r.jsx("path",{d:"M5.2 6.1 8.8 4.1M5.2 7.9l3.6 2"})]}),r.jsx("span",{className:"vis-hidden",children:zT(n.sharedTo,n.sharedInUse)})]}),e.disabled&&r.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(F!=null&&F.blocksSwitch)&&r.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>c(e.num,A),"aria-label":`Switch to ${A}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),r.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:V=>{V.key!=="ArrowDown"&&V.key!=="ArrowUp"||(V.preventDefault(),h(e.num,V.key==="ArrowUp"?"last":"first"))},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[r.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),r.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),r.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&r.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),p.signIn&&w&&r.jsx("button",{type:"button",className:"ap-fix ap-failure-fix",onClick:()=>w(e.email),"aria-label":`Sign in again as ${e.email??A}`,title:"Open the sign-in dialog. Signing in as this account replaces its expired login in place — it keeps its slot, its alias and its history.",children:"Sign in again"}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&k&&r.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."}),e.active&&k&&G&&r.jsx("p",{className:"ap-switched",children:G}),b&&(()=>{const V=(v==null?void 0:v.alias)??(v==null?void 0:v.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${b.at} was taken, so the two accounts traded places: ${V} now holds slot ${b.displaced}.`,children:["swapped with slot ",b.displaced]})})(),F&&r.jsxs("div",{className:"ap-issue-line",children:[r.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":F.tone,"aria-haspopup":"dialog","aria-expanded":N,"aria-controls":N?"ap-issue-pop":void 0,onClick:()=>j(e.num,`ap-issue-${e.num}`),children:[F.tone==="warn"&&r.jsx(Xj,{}),r.jsx("span",{className:"ap-issue-text",children:F.text})]}),!L&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:P??"never collected"})]}),z&&r.jsxs("p",{className:"ap-telemetry",id:`ap-telemetry-${e.num}`,"data-tone":z.tone,title:z.detail,children:[r.jsx("span",{"aria-hidden":!0,children:z.text}),r.jsx("span",{className:"vis-hidden",children:z.detail})]}),!L&&!(F!=null&&F.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[D.length?D.map(V=>r.jsxs("span",{className:"ap-q","data-sort-key":V.id===(I==null?void 0:I.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:V.label})," ",Mu(V,t)?r.jsx("span",{className:"ap-q-pct",title:`${V.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":E?void 0:rne(V.pct),children:[Math.round(V.pct),"%"]})]},V.id)):r.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!F&&r.jsx("span",{className:"ap-q-age","data-never":P?void 0:"",title:"When claude-swap last read this account's usage",children:P??"never collected"})]}),L&&r.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[r.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(V=>r.jsx(ane,{lane:V,nowSec:t,readAt:e.fetchedAt,frozen:E,sortedBy:V.id===(I==null?void 0:I.id)},V.id)):r.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),r.jsx("div",{className:"ap-meta",children:e.fetchedAt?r.jsxs("span",{className:`ap-age${e.stale&&!F?" 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 ",ua(e.fetchedAt,t),F!=null&&F.blocksSwitch?"":Fee(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function ine({data:e}){return r.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"Installing claude-swap…"}),r.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"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"claude-swap isn't installed."}),r.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&&r.jsx("code",{className:"ap-cmd",children:e.hint}),r.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",r.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),r.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"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"No accounts added yet."}),r.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",r.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"Couldn't read the account store."}),r.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function lne({canShare:e,canReport:t,onAdd:n,onReport:s,onShareSet:a,onReload:o,pressProps:i,reloading:c,closeButton:d}){return r.jsxs("div",{className:"ap-header",children:[r.jsx("h2",{children:"Claude accounts"}),r.jsxs("div",{className:"ap-header-right",children:[r.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:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&r.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:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),r.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>a(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${$t} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:r.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:[r.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),r.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),r.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...i("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:r.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:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}function sn({children:e,narrow:t}){return r.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 cne=()=>r.jsxs(sn,{children:[r.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),r.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),une=()=>r.jsxs(sn,{children:[r.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),r.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),dne=()=>r.jsxs(sn,{narrow:!0,children:[r.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"}),r.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),hne=()=>r.jsxs(sn,{children:[r.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),r.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),r.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),fne=()=>r.jsxs(sn,{children:[r.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),r.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"})]}),pne=()=>r.jsxs(sn,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 2v5l3.5-3.5"}),r.jsx("circle",{cx:"4.5",cy:"8.5",r:".7"})]}),mne=({watching:e})=>r.jsxs(sn,{children:[r.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?r.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):r.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),gne=()=>r.jsxs(sn,{children:[r.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"}),r.jsx("circle",{cx:"7",cy:"7",r:"1.9"})]}),yne=()=>r.jsxs(sn,{children:[r.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),r.jsx("path",{d:"M7 4.9v1.7"}),r.jsx("path",{d:"M7 7.7v.05"})]}),wne=()=>r.jsx(sn,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),xne=()=>r.jsxs(sn,{children:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]}),vne=()=>r.jsxs(sn,{children:[r.jsx("path",{d:"M7 1.6v5"}),r.jsx("path",{d:"M4.2 3.6a4.8 4.8 0 1 0 5.6 0"})]}),bne=()=>r.jsx(sn,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),kne=()=>r.jsx(sn,{children:r.jsx("path",{d:"M8.8 1.5a3 3 0 0 0-3.7 3.7l-3 3a1.8 1.8 0 0 0 2.5 2.5l3-3a3 3 0 0 0 3.7-3.7L9.4 5.9 7 3.5z"})}),jne=()=>r.jsxs(sn,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]}),Nne=()=>r.jsx(sn,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.005-1.005zm5.723-5.756H5.736a5.215 5.215 0 0 0 5.215 5.214h2.129v2.058a5.218 5.218 0 0 0 5.215 5.214V6.758a1.001 1.001 0 0 0-1.001-1.001zM23.013 0H11.455a5.215 5.215 0 0 0 5.215 5.215h2.129v2.057A5.215 5.215 0 0 0 24 12.483V1.005A1.001 1.001 0 0 0 23.013 0z"})}),Sne=()=>r.jsx(sn,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})}),_ne=()=>r.jsx(sn,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z"})});function VT(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Cne(e,t,n=!1){const s=new Date(t*1e3),a=Array.from({length:7},(c,d)=>{const h=new Date(s.getFullYear(),s.getMonth(),s.getDate()+d);return{key:VT(h),date:h,entries:[],scheduled:0,outdated:0}}),o=new Map(a.map(c=>[c.key,c])),i=[];for(const c of e){const d=c.lanes.find(j=>j.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=o1(c,"seven_day",t),m=ii(c,t),w=Hp(c.fetchedAt),k=w==null,b=n||k||c.stale||c.staleCopy===!0||c.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>oD,v=n?"Last saved reading":m!=null&&m.blocksSwitch||c.staleCopy||c.stopped?(m==null?void 0:m.text)??"Not collecting":k?"Never read":b?`${c.stale?"Marked stale · ":""}Read ${ua(w,t)}`:null,N={key:Gs(c),name:iD(c),active:c.active,heldOut:c.disabled,at:f,used:p.counted?p.pct:p.last,stale:b,note:v};if(f==null)i.push({...N,reason:"unknown"});else if(f<=t)i.push({...N,reason:"passed"});else{const j=o.get(VT(new Date(f*1e3)));j?(j.entries.push(N),b?j.outdated++:j.scheduled++):i.push({...N,reason:"outside"})}}for(const c of a)c.entries.sort((d,h)=>d.at-h.at);return{days:a,unscheduled:i}}const lf=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Xf=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),ou=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),oN=(e,t)=>e-t<60?"less than 1m":Hu(e,t);function Yp({at:e}){const t=new Date(e*1e3);return r.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 cf({entry:e}){return r.jsxs("span",{className:"ap-reset-name",children:[r.jsx("span",{children:e.name}),e.active&&r.jsx("span",{className:"ap-report-current",children:"Current"}),e.heldOut&&r.jsx("span",{className:"ap-report-tag",children:"held out"})]})}function xD({entry:e,row:t,nowSec:n,withReading:s=!1,older:a=!1,context:o}){return r.jsxs("details",{className:"ap-reset-account",children:[r.jsxs("summary",{children:[o?r.jsxs("span",{className:"ap-reset-summary-other",children:[r.jsx(cf,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(cf,{entry:e}),r.jsx(vD,{entry:e,older:a})]}):r.jsx(cf,{entry:e}),r.jsx("span",{className:"vis-hidden",children:" · Account details"})]}),r.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 r.jsxs("p",{children:[r.jsx("strong",{children:i==="five_hour"?"5-hour":"7-day"}),r.jsx("span",{children:d==null?"No usage reading":`${e.stale||!c.counted?"Last read: ":""}${oo(d)}% used`}),r.jsx("span",{children:h==null?"Reset time unknown":h<=n?"Reported time passed · awaiting a new reading":r.jsxs(r.Fragment,{children:[e.stale?"Last reported reset":`Reset in ${oN(h,n)}`," · ",r.jsx(Yp,{at:h})]})})]},i)}),r.jsx("p",{children:e.heldOut?"Excluded from automatic rotation.":"A weekly reset does not remove a separate 5-hour limit."})]})]})}function vD({entry:e,past:t=!1,older:n=!1}){return r.jsxs("span",{className:"ap-reset-reading","data-level":e.stale||t?"older":e.used!=null&&e.used>=70?"limited":void 0,children:[r.jsx("span",{className:"ap-reset-usage",children:e.used==null?"Usage unavailable":`${e.stale||t?"Last read: ":""}${oo(e.used)}% used`}),e.used!=null&&!e.stale&&!t&&r.jsx("span",{className:"ap-reset-meter","data-level":e.used>=90?"hi":e.used>=70?"mid":void 0,"aria-hidden":"true",children:r.jsx("span",{style:{"--reset-used":Math.min(100,Math.max(0,e.used))/100}})}),e.stale&&r.jsxs("span",{className:"ap-reset-old",children:[!n&&"Needs a fresh reading · ",e.note]})]})}function Ene({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 r.jsx("li",{className:"ap-reset-unplaced-row",children:r.jsx(xD,{entry:e,row:t,nowSec:n,context:r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"ap-reset-unplaced-detail",children:[r.jsx("span",{children:s}),e.at!=null&&r.jsxs("span",{children:[Xf(new Date(e.at*1e3))," · ",r.jsx(Yp,{at:e.at})]})]}),r.jsx(vD,{entry:e,past:e.reason==="passed"})]})})})}function GT({days:e,rows:t,nowSec:n,outdated:s=!1}){return r.jsx("div",{className:"ap-reset-agenda",children:e.map(a=>{const o=a.entries.filter(i=>i.stale===s);return o.length?r.jsxs("section",{className:"ap-reset-day","aria-label":ou(a.date),children:[r.jsxs("h4",{className:"vis-hidden",children:[ou(a.date)," · ",o.length," ",o.length===1?"account":"accounts"]}),r.jsx("ul",{children:Array.from(new Set(o.map(i=>i.at))).map((i,c)=>r.jsxs("li",{className:"ap-reset-event",children:[r.jsxs("div",{className:"ap-reset-when","data-outdated":s?"":void 0,children:[s&&r.jsx("span",{className:"ap-reset-last-reported",children:"Last reported"}),c===0&&r.jsxs("time",{className:"ap-reset-day-label",dateTime:a.key,children:[lf(a.date)," · ",Xf(a.date)]}),r.jsx(Yp,{at:i}),!s&&r.jsxs("span",{children:["in ",oN(i,n)]})]}),r.jsx("ul",{children:o.filter(d=>d.at===i).map(d=>r.jsx("li",{className:"ap-reset-entry","data-outdated":d.stale?"":void 0,children:r.jsx(xD,{entry:d,row:t.get(d.key),nowSec:n,withReading:!0,older:s})},d.key))})]},i))})]},a.key):null})})}function Tne({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:c,unscheduled:d}=Cne(e,t,n!=null),h=c.find(O=>O.key===s)??null,f=h?[h]:c,p=c.reduce((O,I)=>O+I.scheduled,0),m=f.reduce((O,I)=>O+I.outdated,0),w=c.reduce((O,I)=>O+I.outdated,0),k=h?h.scheduled:p,b=c.flatMap(O=>O.entries).find(O=>!O.stale),v=b?c.flatMap(O=>O.entries).filter(O=>!O.stale&&O.at===b.at):[],N=y.useRef(null),j=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{var I,F;const O=S.current;O&&!O.isConnected&&document.activeElement===document.body&&((F=(I=j.current)==null?void 0:I.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||F.focus({preventScroll:!0}))});const _=()=>{N.current&&(N.current.scrollTop=0)},T=O=>{_(),a(null),i(O)},$=Intl.DateTimeFormat().resolvedOptions().timeZone,M=new Map(eN(e,t).rows.map(O=>[O.key,O]));return r.jsxs("div",{ref:j,onFocusCapture:O=>{S.current=O.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-reset-overview",children:[r.jsxs("div",{className:"ap-reset-command",children:[r.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:b?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx(jne,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),v.length>1?r.jsxs("span",{className:"ap-reset-name",children:[v.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:b.name,children:[r.jsx(cf,{entry:b}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:b.name})]}),r.jsxs("p",{children:[lf(new Date(b.at*1e3)),", ",Xf(new Date(b.at*1e3))," · ",r.jsx(Yp,{at:b.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",v.length>1?"s":b.used!=null?` · ${oo(b.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:oN(b.at,t)}),r.jsxs("span",{children:[r.jsx("span",{className:"vis-hidden",children:"until "}),"reported reset"]})]})]}):r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsx("h3",{children:"No upcoming weekly resets"}),r.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."})]})}),r.jsxs("div",{className:"ap-reset-coverage",role:"group","aria-label":"Schedule data",children:[r.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"upcoming","aria-pressed":o==="upcoming",onClick:()=>T("upcoming"),children:[r.jsx("b",{children:p}),r.jsxs("span",{children:["Upcoming",r.jsx("span",{children:"Recent readings"})]})]}),r.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:()=>T("older"),children:[r.jsx("b",{children:w}),r.jsxs("span",{children:["Needs fresh data",r.jsx("span",{children:"This week · excluded"})]})]}),r.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"other","aria-pressed":o==="other",onClick:()=>T("other"),children:[r.jsx("b",{children:d.length}),r.jsxs("span",{children:["Other reset times",r.jsx("span",{children:"Unknown, elapsed or later"})]})]})]})]}),r.jsxs("section",{className:"ap-reset-navigation","aria-label":"Choose a calendar day",children:[r.jsxs("div",{className:"ap-reset-intro",children:[r.jsxs("h3",{children:["Next 7 days ",r.jsxs("span",{children:[p," weekly ",p===1?"reset":"resets"]})]}),r.jsx("p",{children:$})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:c.map((O,I)=>r.jsx("li",{"data-today":I===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":I===0?"date":void 0,"data-active":O.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===O.key,"aria-label":`${ou(O.date)}: ${O.scheduled} scheduled resets${O.outdated?`, ${O.outdated} readings need updating`:""}`,onClick:()=>{_(),i("upcoming"),a((h==null?void 0:h.key)===O.key?null:O.key)},children:[r.jsxs("time",{dateTime:O.key,title:ou(O.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:I===0?"Today":lf(O.date)}),r.jsx("span",{className:"ap-reset-date",children:O.date.getDate()})]}),r.jsxs("span",{className:"ap-reset-count",children:[r.jsx("b",{children:O.scheduled||"—"}),r.jsxs("span",{children:[" ",O.scheduled===1?"reset":"resets"]})]})]})},O.key))})]})]}),r.jsxs("div",{ref:N,className:"ap-reset-results",children:[r.jsxs("section",{className:"ap-reset-scheduled",hidden:o!=="upcoming","aria-label":"Scheduled weekly resets",children:[r.jsxs("div",{className:"ap-reset-list-head",children:[r.jsxs("h3",{children:[h?`${lf(h.date)}, ${Xf(h.date)}`:"All upcoming resets"," ",r.jsx("span",{children:k})]}),r.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{_(),a(null)},children:"All days"})]}),r.jsx("p",{className:"ap-reset-hint",role:"status",children:h?`Showing only ${ou(h.date)}.`:"All days · select a date to narrow the agenda."}),k>0?r.jsx(GT,{days:f,rows:M,nowSec:t}):r.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."})]}),r.jsxs("section",{className:"ap-reset-disclosure",hidden:o!=="older","aria-label":"Accounts needing fresh readings",children:[r.jsxs("h3",{children:["Needs a fresh reading ",r.jsxs("span",{children:[m," ",m===1?"account":"accounts"," · excluded from counts"]})]}),r.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?r.jsx(GT,{days:f,rows:M,nowSec:t,outdated:!0}):r.jsx("p",{className:"ap-reset-empty",children:"No older schedules in these seven days. Unknown or elapsed times are listed in Other reset times."})]}),r.jsxs("section",{className:"ap-reset-disclosure ap-reset-unplaced",hidden:o!=="other","aria-label":"Other reset times",children:[r.jsxs("h3",{children:["Other reset times ",r.jsxs("span",{children:[d.length," ",d.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),d.length>0?r.jsx("ul",{children:d.map(O=>r.jsx(Ene,{entry:O,row:M.get(O.key),nowSec:t},O.key))}):r.jsx("p",{className:"ap-reset-empty",children:"All reported reset times fall within the upcoming week."})]}),r.jsxs("details",{className:"ap-reset-about",children:[r.jsx("summary",{children:"How to read this schedule"}),r.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 ",$,"; 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 bD(e){return e>=90?"hi":e>=70?"mid":void 0}const kD=(e,t,n)=>`${e} ${e===1?t:n}`;function KT(e){const t=e.more>0?`, and ${kD(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${oo(e.pct)}% used)${t}`}function Ane({w:e,nowSec:t}){const n=`ap-report-${e.id}`,s=e.total-e.included,a=s>0&&r.jsxs("p",{className:"ap-report-basis",children:[s," never read"]}),{used:o,available:i}=hte(e.used??0),c=Math.round(Bo(i,{countIn:!0}));if(e.used==null)return r.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[r.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),r.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),a]});const d=e.nextReset?Hu(e.nextReset.at,t):null;return r.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[r.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),r.jsxs("p",{className:"ap-report-left",children:[r.jsxs("b",{children:[c,"%"]})," average remaining"]}),r.jsx("div",{className:"ap-report-meter","data-level":bD(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),d&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:KT(e.nextReset),children:[r.jsxs("span",{children:["Next reported reset in ",r.jsx("span",{className:"ap-report-num",children:d})]}),r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&r.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),r.jsxs("span",{className:"vis-hidden",children:[". ",KT(e.nextReset)]})]}),a]})}function Rne({cell:e,label:t}){if(!e.counted){const n=e.estimate==null?", not counted":", last reading, counted as is";return r.jsxs("td",{className:"ap-report-cell","data-uncounted":"",title:e.reset??void 0,children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsx("span",{className:"ap-report-pct",children:e.last==null?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:"—"}),r.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${oo(e.last)}%`}),r.jsx("span",{className:"vis-hidden",children:e.reset?`. ${e.reset}. Awaiting a fresh reading${n}.`:n})]})}return r.jsxs("td",{className:"ap-report-cell",children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsxs("span",{className:"ap-report-pct","data-level":bD(e.pct),children:[oo(e.pct),"%"]})]})}function Mne({at:e,nowSec:t,label:n}){if(e==null)return r.jsxs("td",{className:"ap-report-reset-cell",children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),r.jsx("span",{"aria-hidden":!0,children:"—"}),r.jsx("span",{className:"vis-hidden",children:"No reset time"})]});const s=new Date(e*1e3),a=Hu(e,t);return r.jsxs("td",{className:"ap-report-reset-cell",title:`Recorded reset: ${s.toLocaleString()}`,children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),r.jsxs("time",{dateTime:s.toISOString(),children:[r.jsx("span",{className:"vis-hidden",children:a?"reported reset in ":"reported reset "}),a??"due"]}),!a&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"}),r.jsxs("span",{className:"vis-hidden",children:[" · Recorded reset: ",s.toLocaleString()]})]})}const $ne={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function Lne({row:e}){return r.jsxs("td",{className:"ap-report-state","data-status":e.status,children:[r.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Status"}),r.jsxs("span",{className:"ap-report-state-word",children:[r.jsx("i",{"aria-hidden":!0}),$ne[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Ine({row:e,nowSec:t}){const n=ite(e,t);return r.jsxs("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:[r.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Updated"}),n.text]})}function One(){return r.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),r.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function Pne({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=eN(e,t),i=o.rows.length,c=Math.round(Bo(o.roomInBoth,{countIn:!0}));return r.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-report-overview",children:[r.jsxs("p",{className:"ap-report-lead",children:[r.jsx("b",{children:c})," of ",kD(i,"Claude account","Claude accounts")," ready"]}),r.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`]})]}),r.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>r.jsx(Ane,{w:d,nowSec:t},d.id))}),r.jsx("div",{className:"ap-report-table-scroll",role:"region","aria-label":"Account capacity table",children:r.jsxs("table",{className:"ap-report-table",children:[r.jsx("caption",{className:"vis-hidden",children:"Each account's use and reset of each window, and what it can do now"}),r.jsxs("colgroup",{children:[r.jsx("col",{}),Xo.map(d=>r.jsxs(y.Fragment,{children:[r.jsx("col",{className:"ap-report-col-win"}),r.jsx("col",{className:"ap-report-col-reset"})]},d.id)),r.jsx("col",{className:"ap-report-col-state"}),r.jsx("col",{className:"ap-report-col-upd"})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx(sl,{col:"account",label:"Account",sort:s,next:Oc,onSort:a}),Xo.map(d=>r.jsxs(y.Fragment,{children:[r.jsx(sl,{col:d.id,label:`${d.label} used`,sort:s,next:Oc,onSort:a}),r.jsx(sl,{col:`${d.id}_reset`,label:`${d.label} reset`,sort:s,next:Oc,onSort:a})]},d.id)),r.jsx(sl,{col:"status",label:"Status",sort:s,next:Oc,onSort:a}),r.jsx(sl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:Oc,onSort:a})]})}),r.jsx("tbody",{children:o.rows.map((d,h)=>r.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[r.jsx("th",{scope:"row",className:"ap-report-acct",children:r.jsxs("span",{className:"ap-report-acct-in",children:[r.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&r.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&r.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Xo.map(f=>r.jsxs(y.Fragment,{children:[r.jsx(Rne,{cell:d.cells[f.id],label:f.label}),r.jsx(Mne,{at:d.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx(Lne,{row:d}),r.jsx(Ine,{row:d,nowSec:t})]},d.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(One,{}),"How usage is calculated"]}),r.jsxs("div",{className:"ap-report-how-body",children:[r.jsxs("p",{children:["Every account here, at its last reading: ",r.jsx("b",{children:"used"})," is their average, and ",r.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."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Ready"})," has room in both windows. ",r.jsx("b",{children:"Limited"})," is at the limit of one, and ",r.jsx("b",{children:"Exhausted"})," of both. ",r.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 Dne({accounts:e,order:t,failed:n,nowSec:s,onClose:a}){const o=y.useRef(null),i=pt(a,{focusRef:o}),c=gt(a),[d,h]=y.useState("accounts"),[f,p]=y.useState("upcoming"),[m,w]=y.useState(null),[k,b]=y.useState(e??[]);y.useEffect(()=>{e!=null&&b(e)},[e]);const v=fte(n,e==null,k.length>0),[N,j]=y.useState(null),S=r1(k,(N==null?void 0:N.order)??t),_=T=>{const $=eN(r1(k,t),s).rows;j({sort:T,order:dte($,T).map(M=>M.key)})};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal ap-report-modal","data-view":d,onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[r.jsxs("header",{className:"ap-proj-head",children:[r.jsx("div",{className:"ap-proj-titlewrap",children:r.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),r.jsxs("div",{className:"ap-report-views",role:"group","aria-label":"Capacity view",children:[r.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="accounts",onClick:()=>h("accounts"),children:"Accounts"}),r.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="calendar",onClick:()=>h("calendar"),children:"Reset calendar"})]}),r.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:a,"aria-label":"Close",children:"×"})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:v??""}),d==="accounts"?r.jsx(Pne,{accounts:S,nowSec:s,held:v,sort:(N==null?void 0:N.sort)??null,onSort:_}):r.jsx(Tne,{accounts:S,nowSec:s,held:v,selectedDate:m,onSelect:w,scope:f,onScope:p})]})}),document.body)}const Fne=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Bne="Uses up quota that resets within 4 days first";function qne(e){return e==="room"||e==="weekly"}function Sy(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function Une(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 _y=[70,80,85,90,95],jD="custom",rl=50,al=99,Wne=`A whole percent from ${rl} to ${al}.`;function Hne(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!_y.includes(t)?[..._y,t]:_y].sort((s,a)=>s-a)}function zne(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${rl} to ${al}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${rl} to ${al}.`};const n=Number(t);return Number.isInteger(n)?n<rl?{ok:!1,reason:"too_low",message:`The lowest is ${rl}%.`}:n>al?{ok:!1,reason:"too_high",message:`The highest is ${al}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${rl} to ${al}.`}}const d1={pick:null,custom:null,refusal:null};function Vne(e,t){switch(t.kind){case"pick":return t.pick===jD?{...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 d1;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?d1:e}}async function Gne(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=zne(e);if(!s.ok)return{kind:"refused",message:s.message};const a=await n({action:"setting",key:"autoswitch.threshold",value:s.value},"threshold");return{kind:"sent",ok:(a==null?void 0:a.ok)===!0}}function Kne({auto:e,threshold:t,thresholdPick:n,thresholdCtl:s,thresholdSaved:a,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:c,thresholdRefusal:d,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:m,leaveThreshold:w,doThreshold:k,nextPick:b,nextCtl:v,nextSaved:N,nextRef:j,nextSaveRef:S,proposeNext:_,doNext:T,pressProps:$,post:M,load:O}){const I=y.useId(),F=y.useId(),L=y.useId();return r.jsxs("div",{className:"ap-policy-block",children:[r.jsxs("div",{className:"ap-policy",onKeyDown:c?m:void 0,children:[r.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),c?r.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:A=>{A.preventDefault(),k(n,s)},children:r.jsxs("span",{className:"ap-threshold-field",title:"Switch once the active account passes this much of its limit",children:[r.jsx("input",{ref:h,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-label":"Switch threshold","aria-describedby":I,"aria-invalid":d?!0:void 0,value:n,...$("threshold"),onChange:A=>p(A.target.value),onBlur:()=>w(),autoComplete:"off",spellCheck:!1}),r.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):r.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:r.jsxs("select",{ref:o,"aria-label":"Switch threshold",value:n,...$("threshold"),onChange:A=>f(A.target.value),children:[Hne(t).map(A=>r.jsxs("option",{value:A,children:[A,"%"]},A)),r.jsx("option",{value:jD,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...$("threshold"),title:s.title,onClick:()=>k(n,s),children:a&&!s.sends?s.done:s.label}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...$("enable"),onClick:()=>M({action:"enable",enabled:!e.enabled},"enable").then(()=>O(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:r.jsx("span",{className:"switch-knob"})})]}),d?r.jsx("p",{id:I,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?r.jsx("p",{id:I,className:"ap-threshold-note",children:Wne},"hint"):null,e.enabled&&r.jsxs("div",{className:"ap-policy ap-next",children:[r.jsx("label",{className:"ap-next-label",htmlFor:F,children:"Next account"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:F,ref:j,value:b,"aria-describedby":b==="weekly"?L:void 0,...$("next"),onChange:A=>_(A.target.value),children:Fne.map(A=>r.jsx("option",{value:A.value,children:A.label},A.value))})}),(v.sends||N)&&r.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...$("next"),title:v.title,onClick:()=>T(),children:N&&!v.sends?v.done:v.label})]}),e.enabled&&b==="weekly"&&r.jsx("p",{id:L,className:"ap-threshold-note",children:Bne}),e.external&&r.jsxs("p",{className:"ap-auto-note",children:[r.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",r.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 YT=18,Yne=1100,el=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},Xne=Array.from({length:YT},(e,t)=>{const n=-72+144*t/(YT-1)+(el(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+el(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+el(t,3)*260),delay:Math.round(el(t,4)*90),dur:760+Math.round(el(t,5)*260),scale:.8+el(t,6)*.45,hue:t%4,round:t%3===0}});function XT({anchor:e}){var a;const[t,n]=y.useState(null),s=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.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),Yne);return()=>window.clearTimeout(c)},[e,s]),s||!t?null:xt.createPortal(r.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:Xne.map((o,i)=>r.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 Zf=y.forwardRef((e,t)=>r.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[r.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),r.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Zf.displayName="SuccessMark";const Zne={done:", done",active:", in progress",failed:", failed",pending:""};function Jne({status:e}){return r.jsx("svg",{className:"aa-stage-icon",viewBox:"0 0 16 16","aria-hidden":!0,children:e==="done"?r.jsx("path",{className:"aa-stage-tick",d:"M4 8.5 L7 11.5 L12.5 5"}):e==="failed"?r.jsx("path",{className:"aa-stage-cross",d:"M5 5 L11 11 M11 5 L5 11"}):e==="active"?r.jsx("circle",{className:"aa-stage-now",cx:"8",cy:"8",r:"3.5"}):r.jsx("circle",{className:"aa-stage-later",cx:"8",cy:"8",r:"3"})})}function Qne({rows:e,phase:t,detail:n,actions:s}){var o;const a=(o=e.find(i=>i.status==="active"))==null?void 0:o.id;return r.jsxs("div",{className:`aa-progress ${t}`,"data-at":a,children:[r.jsxs("svg",{className:"aa-orbit",viewBox:"0 0 44 44","aria-hidden":!0,children:[r.jsx("circle",{className:"aa-orbit-track",cx:"22",cy:"22",r:"20"}),t==="live"||t==="resolving"?r.jsx("circle",{className:"aa-orbit-arc",cx:"22",cy:"22",r:"20"}):null,t==="resolving"?r.jsx("circle",{className:"aa-orbit-close",cx:"22",cy:"22",r:"20"}):null,t==="failed"?r.jsx("path",{className:"aa-orbit-cross",d:"M17 17 L27 27 M27 17 L17 27"}):null]}),r.jsx("ol",{className:"aa-stages",children:e.map(i=>{const c=i.status==="active"||i.status==="failed";return r.jsxs("li",{className:"aa-stage","data-status":i.status,"aria-current":i.status==="active"?"step":void 0,children:[r.jsx(Jne,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:Zne[i.status]})]}),c&&n?r.jsx("div",{className:"aa-stage-more",children:n}):null]},i.id)})}),s?r.jsx("div",{className:"aa-actions aa-progress-actions",children:s}):null]})}const Cy=["link","approve","confirm","save"],ZT={confirm:"confirm",save:"save",restore:"save"};function ND(e){return e!=null&&Object.prototype.hasOwnProperty.call(ZT,e)?ZT[e]:null}function ese({state:e,step:t,starting:n}){return e==="registering"?ND(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function tse({state:e,step:t,url:n,lastLive:s}){return e==="failed"?ND(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const nse={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 sse(e,t,n){return t==="failed"?SD(e,n):nse[e][t]}function rse({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?Cy.length:Cy.indexOf(t??e);return Cy.map((o,i)=>{const c=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:c,label:sse(o,c,s)}})}function ase(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 ose={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 SD(e,t){return t==="idle"?"Sign-in ended":ose[e]}const ise=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function uf(e){const t=String(e??"").trim();if(!t)return"";const n=ise.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}uf(fD);const lse=1e4,cse=1e4,use=5;function dse({since:e,now:t,expiresAt:n}){if(e==null||t-e<lse)return null;const s=n!=null?Math.ceil((n-t)/6e4):NaN,a="Still waiting for the browser. If no tab opened, or you closed it, use the link above";return s>=1&&s<=use?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function hse({since:e,now:t}){return e==null||t-e<cse?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function fse(e){return e==="registering"?400:1500}const _D=460;function pse({fromStages:e,reducedMotion:t}){return e&&!t?_D:0}function mse({added:e,reducedMotion:t}){return e&&!t}function JT({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function gse(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 yse="done";function wse(){let e=!1;return{shouldAnnounce(t){return t!==yse?(e=!1,!1):e?!1:(e=!0,!0)}}}function CD(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 xse(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(),a=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:a,sub:o.length?o.join(" · "):null}})}function vse(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function bse(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function kse(e){return e.length?{action:"share",accounts:[...e]}:null}function jse(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 h1(e){return`${e.email}|${e.org??""}`}function Nse(e,t,n){return e&&e.map(s=>h1(s)===t?n:s)}function Sse(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 QT(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,s=[],a=n("imported");a&&s.push(`${a} 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=Kf(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function _se(e){try{return e?new URL(e).host:""}catch{return""}}const Dh=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],eA="aa-panel",tA=e=>`aa-tab-${e}`;async function Io(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function ED({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){nn("add-account");const[a,o]=y.useState("login"),[i,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[m,w]=y.useState(!1),[k,b]=y.useState(!1),[v,N]=y.useState(null),[j,S]=y.useState(null),_=m||k,[T,$]=y.useState(null),[M,O]=y.useState(null),[I,F]=y.useState(null),L=y.useRef(""),A=y.useRef(!1),q=y.useRef(!1),E=y.useRef(null),D=y.useRef(null),P=y.useRef(null),z=y.useRef(null),G=y.useRef([]),V=y.useRef(!1),H=y.useRef(0),B=y.useRef(null),W=y.useRef("primer"),ee=y.useRef(null),U=y.useRef(null),Y=y.useRef(null),X=y.useRef(!1),Z=y.useState(Bu)[0],[J,te]=y.useState(null),[ce,he]=y.useState(!1),[le,re]=y.useState(()=>Date.now()),[ae,de]=y.useState(null),[_e,fe]=y.useState(null),[ye,ke]=y.useState(null),Ne=y.useCallback(()=>{const Ce=BT({started:A.current,state:i==null?void 0:i.state});Ce&&Io(Ce).catch(()=>{}),e()},[e,i==null?void 0:i.state]),ge=pt(Ne,{focusRef:P}),Me=gt(Ne),Ie=y.useCallback(async()=>{if(!bn(q.current))return;const Ce=++H.current;q.current=!0,w(!0),N(null),ke(null),A.current=!0;let Pe=await Io(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(Pe==null?void 0:Pe.reason)==="bad_email"&&Ce===H.current&&(Pe=await Io({action:"login"}).catch(()=>null)),Ce===H.current){if(q.current=!1,w(!1),!(Pe!=null&&Pe.ok)){N(cl(Pe,"could not start the sign-in"));return}c(Pe)}},[n]);y.useEffect(()=>{if(!dD(i==null?void 0:i.state))return;const Ce=window.setInterval(async()=>{try{const Pe=await fetch("/api/claude-accounts/login");Pe.ok&&c(await Pe.json())}catch{}},fse(i==null?void 0:i.state));return()=>window.clearInterval(Ce)},[i]);const We=y.useCallback(async()=>{const Ce=BT({started:A.current,state:i==null?void 0:i.state});if(H.current+=1,A.current=!1,q.current=!1,w(!1),N(null),c(null),h(""),he(!1),X.current=!0,!Ce)return;const Pe=await Io(Ce).catch(()=>null);ke(FT({restored:Pe==null?void 0:Pe.restored,activeAccount:Pe==null?void 0:Pe.activeAccount}))},[i==null?void 0:i.state]),Te=y.useCallback(()=>{A.current=!1,c(null),N(null),h(""),he(!1),Ie()},[Ie]),at=y.useRef(t);at.current=t;const Je=y.useState(wse)[0];y.useEffect(()=>{Je.shouldAnnounce(i==null?void 0:i.state)&&at.current()},[i==null?void 0:i.state,Je]),y.useEffect(()=>{var Ce;ce&&((Ce=E.current)==null||Ce.focus())},[ce]);const Ve=y.useRef(s);Ve.current=s;const be=y.useRef(null);y.useEffect(()=>{var Ke;const Ce=(i==null?void 0:i.state)==="done"?i.account:null,Pe=Ce?`${Ce.num??""}|${Ce.email}`:null;!Ce||be.current===Pe||(be.current=Pe,(Ke=Ve.current)==null||Ke.call(Ve,Ce))},[i]),y.useEffect(()=>{var Ce;a==="paste"&&!V.current&&((Ce=D.current)==null||Ce.focus()),V.current=!1},[a]);const Oe=y.useCallback(Ce=>{var Ke;const Pe=Dp(Ce,Dh.findIndex(jt=>jt.id===a),Dh.length);Pe.kind!=="pass"&&(Ce.preventDefault(),V.current=!0,o(Dh[Pe.index].id),(Ke=G.current[Pe.index])==null||Ke.focus())},[a]),ze=y.useCallback(async()=>{var Ke;if(!bn(q.current))return;const Ce=H.current;q.current=!0,w(!0),N(null);const Pe=await Io({action:"login-code",code:d}).catch(()=>null);if(Ce===H.current){if(q.current=!1,w(!1),!(Pe!=null&&Pe.ok)){N(cl(Pe,"the code was not accepted")),Pe!=null&&Pe.state&&c(Pe),(Ke=E.current)==null||Ke.select();return}h(""),c(Pe)}},[d,i]),st=y.useCallback(async()=>{if(!bn(q.current))return;q.current=!0,b(!0),S(null);const Ce=await Io({action:"import",blob:f}).catch(()=>null);if(q.current=!1,b(!1),!(Ce!=null&&Ce.ok)){S(cl(Ce,"the import failed"));return}L.current=f,p(""),F(null),$(Ce.results??[]),t()},[f,t]),ot=y.useCallback(async Ce=>{const Pe=h1(Ce);if(!bn(q.current)||!L.current)return;q.current=!0,b(!0),O(Pe),F(null);const Ke=await Io({action:"import",blob:L.current,force:!0,only:{email:Ce.email,org:Ce.org??""}}).catch(()=>null);if(q.current=!1,b(!1),O(null),!(Ke!=null&&Ke.ok)){F({key:Pe,text:cl(Ke,"that account could not be updated")});return}const jt=(Ke.results??[])[0];jt&&$(Nt=>Nse(Nt,Pe,jt)),t()},[t]),Qe=(i==null?void 0:i.state)==="done"?i.account:null,we=FT({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),Fe=gte({login:i,started:A.current,loginError:v,loginBusy:m}),Xe=mte({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:v}),He=Fe==="asking"||Fe==="code"?ese({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:Fe==="asking"})??"link":null,ht=Fe==="ended"?tse({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:B.current}):null,Ct=Qe?`${Qe.num??""}|${Qe.email}`:null,mt=Fe==="done"&&Ct!==J&&pse({fromStages:W.current==="progress",reducedMotion:Z})>0,Et=Fe==="primer"?"primer":Fe==="done"&&Qe&&!mt?"done":"progress",Ot=ht?"failed":mt?"resolving":"live",js=rse(mt?{done:!0}:ht?{failed:ht,state:i==null?void 0:i.state}:{live:He}),tr=ht?SD(ht,i==null?void 0:i.state):"",Ns=uf(Xe.message),es=He==="approve"?dse({since:ae,now:le,expiresAt:i==null?void 0:i.expiresAt}):null,Pt=k?hse({since:_e,now:le}):null,Ss=a==="login"?Et==="done"&&Qe?`${JT(Qe)}.`:Ot==="failed"?`${tr}. ${Ns}`:Et==="progress"&&!mt?gse(He)??"":"":k?"Importing the share.":j?uf(j):T?uf(QT(T)):"";y.useEffect(()=>{He&&(B.current=He)},[He]),y.useEffect(()=>{W.current=Et},[Et]),y.useEffect(()=>{if(!mt||!Ct)return;const Ce=window.setTimeout(()=>te(Ct),_D);return()=>window.clearTimeout(Ce)},[mt,Ct]);const pn=He==="approve";y.useEffect(()=>{de(pn?Date.now():null)},[pn]),y.useEffect(()=>{fe(k?Date.now():null)},[k]);const Fn=pn||k;return y.useEffect(()=>{if(!Fn)return;re(Date.now());const Ce=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Ce)},[Fn]),y.useEffect(()=>{var Pe,Ke,jt,Nt;if(a!=="login")return;if(Et==="done"){(Pe=U.current)==null||Pe.focus();return}if(Et==="primer"){X.current&&((Ke=P.current)==null||Ke.focus()),X.current=!1;return}if(Ot==="failed"){(jt=Y.current)==null||jt.focus();return}const Ce=document.activeElement;He==="approve"&&(!Ce||Ce===document.body)&&((Nt=ee.current)==null||Nt.focus())},[a,Et,Ot,He]),xt.createPortal(r.jsx("div",{className:"modal-backdrop",...Me,role:"presentation",children:r.jsxs("div",{ref:ge,className:"modal aa-modal",onClick:Ce=>Ce.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Oe,children:Dh.map((Ce,Pe)=>r.jsx("button",{type:"button",role:"tab",id:tA(Ce.id),ref:Ke=>{G.current[Pe]=Ke},"aria-selected":a===Ce.id,"aria-controls":eA,tabIndex:a===Ce.id?0:-1,className:`aa-tab${a===Ce.id?" on":""}`,onClick:()=>{V.current=!1,o(Ce.id)},children:Ce.label},Ce.id))})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:Ne,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body aa-body",id:eA,role:"tabpanel","aria-labelledby":tA(a),children:[a==="login"?Et==="done"&&Qe?r.jsxs("div",{className:`aa-done${J===Ct?" from-orbit":""}`,children:[r.jsx(Zf,{ref:z}),mse({added:Qe.added,reducedMotion:Z})&&r.jsx(XT,{anchor:z}),r.jsx("h4",{children:JT(Qe)}),r.jsxs("p",{className:"aa-note",children:[r.jsx("strong",{children:Qe.email}),Qe.added?we?" 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."]}),we?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:we}):null,r.jsx("button",{type:"button",ref:U,className:"btn primary",onClick:Ne,children:"Done"})]}):Et==="progress"?r.jsx(Qne,{rows:js,phase:Ot,detail:Ot==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:Ns}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:Y,className:"btn primary",onClick:Te,children:ht==="link"?"Try again":"Start over"})})]}):He==="approve"&&i?r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"aa-note",children:["Approve the sign-in in the tab that opened",n?r.jsxs(r.Fragment,{children:[", with ",r.jsx("strong",{children:n})," filled in"]}):null,". This moves on by itself."]}),r.jsxs("a",{ref:ee,className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:[r.jsx("span",{children:"Open it in this browser"}),r.jsxs("span",{className:"aa-link-host",children:[_se(i.url),r.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:r.jsx("path",{d:"M3 7 7 3M3.6 3H7v3.4"})})]})]}),es?r.jsx("p",{className:"aa-note aa-arrive",children:es}):null,r.jsxs("details",{className:"aa-code",open:ce,onToggle:Ce=>he(Ce.currentTarget.open),children:[r.jsxs("summary",{children:[r.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:r.jsx("path",{d:"M3.6 2.2 6.4 5 3.6 7.8"})}),"Paste a code, if the page shows one"]}),r.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."}),r.jsxs("div",{className:"aa-field",children:[r.jsx("input",{ref:E,type:"text",value:d,onChange:Ce=>h(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&d.trim()&&!_&&ze()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),r.jsx("button",{type:"button",className:"btn primary",...$n(_,!d.trim()||i.state==="registering"),onClick:ze,children:"Continue"})]}),(v||i.error)&&r.jsx("p",{className:"aa-err",children:v??i.error}),r.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."})]})]}):He?r.jsx("p",{className:"aa-note",children:ase(He,i==null?void 0:i.step)}):null,actions:He==="link"||He==="approve"?r.jsx("button",{type:"button",className:"btn",onClick:We,children:"Cancel"}):null}):r.jsxs("div",{className:"aa-step aa-primer",children:[ye?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:ye}):null,r.jsx("h4",{children:n?r.jsxs(r.Fragment,{children:["Sign in again as ",r.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),r.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."]}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:P,className:"btn primary",...$n(_),onClick:Ie,children:"Open the sign-in page"})})]}):T?(()=>{const Ce=T.filter(Ke=>Ke.state==="imported").length,Pe=T.some(Ke=>Kf(Ke.check));return r.jsxs("div",{className:"aa-done",children:[!Pe&&r.jsx(Zf,{ref:z}),Ce>0&&!Pe&&r.jsx(XT,{anchor:z}),r.jsx("h4",{children:QT(T)}),T.length>0&&r.jsx("ul",{className:"aa-results",children:T.map(Ke=>{const jt=h1(Ke),Nt=Kf(Ke.check);return r.jsxs("li",{className:`aa-result ${Ke.state}`,children:[r.jsx("span",{className:"aa-result-who",children:Ke.email||(Ke.num?`slot ${Ke.num}`:"an account")}),r.jsx("span",{className:"aa-result-what",children:Sse(Ke.state)}),Ke.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":M===jt,title:`Overwrite the stored login for ${Ke.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ot(Ke),children:M===jt?"updating…":"update anyway"}),Nt&&r.jsx("span",{className:"aa-result-err",children:Nt.long}),(I==null?void 0:I.key)===jt&&r.jsx("span",{className:"aa-result-err",children:I.text})]},jt)})}),r.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",r.jsx("strong",{children:" update anyway"}),"."]}),r.jsxs("div",{className:"aa-actions",children:[r.jsx("button",{type:"button",className:"btn primary",onClick:Ne,children:"Done"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{L.current="",F(null),$(null)},children:"Import another"})]})]})})():r.jsxs("div",{className:"aa-step",children:[r.jsx("h4",{children:"Paste an account shared from another deck"}),r.jsxs("div",{className:"aa-field",children:[r.jsx("input",{ref:D,type:"text",value:f,onChange:Ce=>p(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&f.trim()&&!_&&st()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...$n(_,!f.trim()),onClick:st,children:k?"importing…":"Import"})]}),j&&r.jsx("p",{className:"aa-err",children:j}),k?r.jsxs("p",{className:"aa-live-line",children:[r.jsxs("svg",{className:"aa-spin",viewBox:"0 0 16 16","aria-hidden":!0,children:[r.jsx("circle",{className:"aa-spin-track",cx:"8",cy:"8",r:"6"}),r.jsx("circle",{className:"aa-spin-arc",cx:"8",cy:"8",r:"6"})]}),r.jsx("span",{children:Pt??"claude-swap is adding the accounts in this share. Any already here are left as they are."})]}):null,r.jsxs("p",{className:"aa-note",children:["Use ",r.jsx("strong",{children:"share"})," on one account in the other deck, or ",r.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."]})]}),r.jsx("p",{className:"vis-hidden",role:"status","aria-live":"polite",children:Ss})]})]})}),document.body)}function Cse(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((a,o)=>a-o).map(a=>{const o=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:o,label:o==="here"?`slot ${a}`:`slot ${a} · ${o}`}})}function Ese(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 a=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:a&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:a?{at:s,displaced:t}:null}}const Tse=64;function Ase(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function Rse(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function Mse(e,t,n){var a;const s=((a=e.find(o=>o.slot===t))==null?void 0:a.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 $se(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 Lse(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 Ise({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:a,busy:o,pressProps:i,rotating:c,onProjects:d,onRotation:h,home:f,canSetHome:p,onHome:m}){const{menu:w,menuError:k,aliasDraft:b,confirmRemove:v,share:N,shareCopied:j,slotDraft:S,dropMenu:_,closeMenu:T,startRename:$,typeAlias:M,doAlias:O,startMove:I,pickSlot:F,doSlot:L,makeShare:A,copyShare:q,pressRemove:E}=a;if(!w)return null;const D=`ap-pop-title-${e.num}`,P=k&&r.jsx("p",{className:"ap-pop-error",role:"alert",title:k.raw||void 0,children:k.text});return r.jsxs(Up,{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:_,children:[w.view==="menu"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>$(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>I(e.num),children:"Move to slot…"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`share-${e.num}`),title:`Copy this account to another ${$t}. 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:()=>A(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),r.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)&&r.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)&&r.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"}),r.jsx("div",{role:"separator",className:"ap-menu-sep"}),r.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${v===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>E(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),P]}),w.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:z=>{z.preventDefault(),O(e.num,e.alias)},children:[r.jsx("label",{className:"ap-pop-title",id:D,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),r.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:b,onChange:z=>M(z.target.value),maxLength:Tse,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:z=>z.currentTarget.select()}),P,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>T(),children:"Cancel"}),r.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 z=Cse(t,e.num),G=Rse(z,S,e.num),V=Mse(z,G,e.num);return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("label",{className:"ap-pop-title",id:D,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:`ap-slot-${e.num}`,value:String(G),...i(`move-${e.num}`),onChange:H=>F(Number(H.target.value)),autoFocus:!0,children:z.map(H=>r.jsx("option",{value:H.slot,children:H.label},H.slot))})}),P,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>T(),children:"Cancel"}),r.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:V.title,onClick:()=>L(e.num,G,V),children:o===`move-${e.num}`?"…":Gc(V.label)})]})]})})(),w.view==="share"&&(N==null?void 0:N.num)===e.num&&(()=>{const z=CD(N.expiresAt,n),G=z.tone==="gone";return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:D,children:"Share account"}),r.jsx("code",{className:"ap-share-blob",children:N.blob}),r.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:[r.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",r.jsx("span",{className:`ap-share-expiry ${z.tone}`,children:z.text})]}),P,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>T(),children:"Done"}),r.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(G){await A(e.num);return}await q(N.blob)},children:G?"Make a new share":j?"Copied":"Copy"})]})]})})()]})}const Ose=6;function Pse(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`,a=n.length?"ok":"idle",o=t.strained&&!t.armed?Dse(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:a,free:o}}function Dse(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function Fse(e){const t=[...e].sort((a,o)=>{if(a.ready!==o.ready)return a.ready?-1:1;if(!a.ready)return a.name.localeCompare(o.name);const i=a.headroom,c=o.headroom;return i==null&&c==null?a.name.localeCompare(o.name):i==null?1:c==null?-1:c-i}),n=t.slice(0,Ose),s=t.length-n.length;return{title:e.some(a=>a.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:s>0?`and ${s} more`:null}}const TD=160,AD=140;function Bse(){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),AD)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function qse(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function Ws(e,t){return{text:e,giveBack:qse(t),done:!1}}async function Use(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const Wse={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 Hse(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?Wse[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 f1=5e3,RD=6e4;function Vt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Gse(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 zse={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."},Vse=new Set(["EACCES","EPERM"]);function Gse(e,t){const n=zse[e];if(!n)return;const s=e==="prefs_unreadable"&&t?Kse(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function Kse({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&&!Vse.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 tl(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function Yse(e,t){const[n,s]=y.useState(null),[a,o]=y.useState([]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(L=>Rp(f.current)?(f.current=L,c(L),!0):!1,[]),m=y.useCallback(()=>{f.current=null,v.current&&c(null)},[]),w=L=>{const A=ao(i,L);return{disabled:A.disabled,"aria-busy":A.busy}},[k,b]=y.useState(()=>Date.now()),v=y.useRef(!0),N=y.useRef(f1),j=y.useCallback(async()=>{var L,A;try{const[q,E]=await Promise.all([fetch("/api/lan").then(D=>D.json()),fetch("/api/prefs").then(D=>D.json())]);if(!v.current)return;q!=null&&q.ok&&s(q),E!=null&&E.ok&&o(Array.isArray((A=(L=E.prefs)==null?void 0:L.lan)==null?void 0:A.manual)?E.prefs.lan.manual:[]),N.current=(q==null?void 0:q.enabled)===!0?f1:RD}catch{}},[]);y.useEffect(()=>{v.current=!0;let L=0;const A=async()=>{b(Date.now()),await j(),v.current&&(L=window.setTimeout(A,N.current))};return A(),()=>{v.current=!1,window.clearTimeout(L)}},[j]);const S=y.useCallback(async()=>{const L=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const A=await tl("/api/prefs",{lan:{enabled:!L}});if(!v.current)return;A!=null&&A.ok?(h(null),L||t()):h(Ws(Vt(L?"turn this off":"turn this on",A),A)),await j()}catch{v.current&&h(Ws(Vt(L?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,j,p,m,t]),_=y.useCallback(async(L,A,q)=>{if(!p(`${L}:${A}`))return null;let E=null;try{const D=await tl("/api/lan/peer",{action:L,fp:A});if(!v.current)return null;D!=null&&D.ok?(s(D),h(null)):(E=Vt(q,D),h(Ws(E,D))),await j()}catch{E=Vt(q,null),v.current&&h(Ws(E))}finally{m()}return E},[j,p,m]),T=y.useCallback(async L=>{if(!p(`drop:${L}`))return null;let A=null;try{const q=await tl("/api/prefs",{lan:{manual:a.filter(E=>E!==L)}});if(!v.current)return null;q!=null&&q.ok?(h(null),e()):(A=Vt("stop dialling that address",q),h(Ws(A,q))),await j()}catch{A=Vt("stop dialling that address",null),v.current&&h(Ws(A))}finally{m()}return A},[a,j,e,p,m]),$=y.useCallback(async(L,A)=>{if(!p(`alias:${L}`))return"Something else is still being saved. Try again in a moment.";try{const q=await tl("/api/lan/peer",{action:"alias",fp:L,name:A});return v.current?q!=null&&q.ok?(s(q),null):Vt("rename that deck",q):null}catch{return Vt("rename that deck",null)}finally{m()}},[p,m]),M=y.useCallback(async L=>{if(!p(`check:${L}`))return null;try{const A=await tl("/api/lan/sync",{fp:L});return v.current?A!=null&&A.ok?(s(A),e(),null):(A==null?void 0:A.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.":Vt("check that deck",A):null}catch{return Vt("check that deck",null)}finally{m()}},[p,m,e]),O=y.useCallback(async()=>{if(p("check"))try{const L=await tl("/api/lan/sync",{});if(!v.current)return;L!=null&&L.ok?(s(L),h(null)):h(Ws(Vt("check the other decks",L),L)),e()}catch{v.current&&h(Ws(Vt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:k,busy:i,failure:d,dismissFailure:()=>h(null),answerGiveBack:L=>{h(L),L.done&&(j(),e())},pressProps:w,load:j,toggle:S,answer:_,dropAddress:T,rename:$,checkOne:M,checkNow:O}}function Xse(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=oi({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:ai});if(c==="arm"){n(o.fp),s.current=i;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function MD({title:e,steps:t,finish:n,aside:s,onClose:a}){const o=y.useRef(null),i=pt(a,{focusRef:o}),c=gt(a),[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,v;Pn(((b=document.activeElement)==null?void 0:b.tagName)??null)&&((v=o.current)==null||v.focus())},[d]);const w=b=>{b.key!=="ArrowRight"&&b.key!=="ArrowLeft"||(b.preventDefault(),b.stopPropagation(),m(b.key==="ArrowRight"?d+1:d-1))},k=()=>{if(!f){m(d+1);return}n?n.act():a()};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal guide",onClick:b=>b.stopPropagation(),onKeyDown:w,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),r.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsx("div",{className:"guide-stage",children:p.art},d),r.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),r.jsx("p",{className:"guide-tip",children:p.tip??""}),r.jsxs("div",{className:"guide-foot",children:[r.jsx("div",{className:"guide-dots",children:t.map((b,v)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${v+1} of ${t.length}`,"aria-current":v===d?"step":void 0,onClick:()=>m(v)},v))}),f&&s&&r.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),d>0&&r.jsx("button",{type:"button",className:"btn",onClick:()=>m(d-1),children:"Back"}),r.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:k,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const p1={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function vs({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function xs({x:e,y:t=34,w:n=176,h:s=132,label:a}){return r.jsxs(r.Fragment,{children:[a&&r.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),r.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function Xs({x:e,y:t,email:n,state:s,tone:a,bars:o}){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:e+3,cy:t-4,r:3,className:p1[a]}),r.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),r.jsx("text",{x:e+12,y:t+16,className:`ga-s ${p1[a]}`,children:s}),o==null?void 0:o.map((i,c)=>r.jsxs("g",{children:[r.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),r.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:e+22,y:t+35+c*18,width:96*i/100,height:4,rx:2,className:"ga-accent"}),r.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[i,"%"]})]},c))]})}function $D({x:e,y:t,on:n}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),r.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Fh({x:e,y:t,name:n,here:s=!0}){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:e+3,cy:t-4,r:3,className:s?"ga-ok":"ga-dim"}),r.jsx("text",{x:e+12,y:t,className:s?"ga-t":"ga-s",children:n})]})}function nA({x:e,y:t,on:n}){return n?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),r.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):r.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function sA({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function iN({x:e,y:t}){return r.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 lN(){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{r:9,className:"ga-key-bed"}),r.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[r.jsx("circle",{cx:4.6,cy:7,r:2.6}),r.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function ul({x:e,y:t,w:n,title:s,sub:a,tone:o}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),r.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:p1[o]}),r.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),r.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function bl({x:e,y:t,label:n,live:s}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),r.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Jf({x:e,y:t}){return r.jsxs(r.Fragment,{children:[r.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),r.jsx($D,{x:e+118,y:t-13,on:!0})]})}function Zse(){return r.jsxs(vs,{children:[r.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),r.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),r.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),r.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),r.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),r.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),r.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),r.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),r.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),r.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),r.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),r.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),r.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),r.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),r.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),r.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),r.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),r.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),r.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),r.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),r.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function Jse(){return r.jsxs(vs,{children:[r.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),r.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),r.jsx(ul,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),r.jsx(ul,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),r.jsx(ul,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),r.jsx(ul,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),r.jsx(bl,{x:326,y:28,label:"Read"}),r.jsx(bl,{x:380,y:28,label:"Grep",live:!0}),r.jsx(bl,{x:326,y:90,label:"Bash",live:!0})]})}function rA({x:e,y:t,label:n,pct:s,note:a}){return r.jsxs(r.Fragment,{children:[r.jsx("text",{x:e,y:t,className:"ga-s",children:n}),r.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[s,"%"]}),r.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:e,y:t+7,width:194*s/100,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:e,y:t+26,className:"ga-s",children:a})]})}function Qse(){return r.jsxs(vs,{children:[r.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),r.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),r.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),r.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),r.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),r.jsx(rA,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(rA,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function ere(){return r.jsxs(vs,{children:[r.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),r.jsx(ul,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),r.jsx(iN,{x:156,y:106}),r.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),r.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),r.jsx(xs,{x:200,y:22,w:226,h:160}),r.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),r.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),r.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),r.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),r.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),r.jsx(bl,{x:214,y:122,label:"Read"}),r.jsx(bl,{x:266,y:122,label:"Edit"}),r.jsx(bl,{x:318,y:122,label:"Bash",live:!0}),r.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),r.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function tre(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(vs,{children:[r.jsx(xs,{x:14,y:20,w:412,h:160}),r.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),r.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),r.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>r.jsxs("g",{children:[r.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),r.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),r.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),r.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),r.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),r.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),r.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),r.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),r.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),r.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),r.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),r.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function nre(){return r.jsxs(vs,{children:[r.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),r.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),r.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[r.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),r.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),r.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),r.jsx("path",{d:"M210 100H238",className:"ga-arc"}),r.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),r.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),r.jsx("g",{className:"ga-pop",children:r.jsx(ul,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function sre(){return r.jsxs(vs,{children:[r.jsx(xs,{x:14,y:16,w:232,h:170}),r.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),r.jsx(sA,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(sA,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),r.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),r.jsx(Xs,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),r.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),r.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),r.jsx(Xs,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),r.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),r.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),r.jsx(iN,{x:221,y:161}),r.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),r.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),r.jsx(xs,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),r.jsx("g",{className:"ga-pop",children:r.jsx(Xs,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function rre(){return r.jsxs(vs,{children:[r.jsx(xs,{x:14,label:"THIS MACHINE"}),r.jsx(Jf,{x:28,y:60}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Xs,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Xs,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(xs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Jf,{x:264,y:60}),r.jsx(Xs,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),r.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:r.jsx(lN,{})})]})}const are=[{art:r.jsx(Zse,{}),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:r.jsx(Jse,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(ere,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(Qse,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(tre,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(sre,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(rre,{}),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:r.jsx(nre,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function ore(){return r.jsxs(vs,{children:[r.jsx(xs,{x:14,label:"THIS MACHINE"}),r.jsx(Xs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),r.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),r.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),r.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),r.jsx(xs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Xs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function ire(){return r.jsxs(vs,{children:[r.jsx(xs,{x:14,label:"THIS MACHINE"}),r.jsx(Jf,{x:28,y:60}),r.jsx(Fh,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(Fh,{x:28,y:114,name:"Dorin's PC"}),r.jsx(xs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Jf,{x:264,y:60}),r.jsx(Fh,{x:264,y:92,name:"Your MacBook"}),r.jsx(Fh,{x:264,y:114,name:"Dorin's PC"}),r.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),r.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),r.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),r.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function lre(){return r.jsxs(vs,{children:[r.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),r.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),r.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),r.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),r.jsx(nA,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(nA,{x:106,y:112}),r.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),r.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),r.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),r.jsx($D,{x:304,y:157,on:!0}),r.jsx(iN,{x:115,y:97})]})}function cre(){return r.jsxs(vs,{children:[r.jsx(xs,{x:14,label:"THIS MACHINE"}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Xs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Xs,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(xs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Xs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),r.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:r.jsx(lN,{})})]})}const ure=[{art:r.jsx(ore,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(ire,{}),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:r.jsx(lre,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(cre,{}),line:"An expired login is copied from a paired machine within a minute."}];function dre(){return r.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[r.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),r.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),r.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),r.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),r.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),r.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),r.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),r.jsx("g",{transform:"translate(116 13)",children:r.jsx(lN,{})})]})}const hre={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."},fre=1600;function LD({reach:e,where:t}){const[n,s]=y.useState(!1),a=y.useRef(!0);y.useEffect(()=>()=>{a.current=!1},[]);const o=(e==null?void 0:e.steps)??[],i=y.useCallback(async()=>{await ho(o.join(`
101
+ `))&&a.current&&(s(!0),window.setTimeout(()=>{a.current&&s(!1)},fre))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return r.jsxs("div",{className:"ap-lan-reach",children:[r.jsx("p",{className:"lan-warn",children:e.text}),r.jsx("p",{className:"lan-note",children:hre[t]}),o.length>0&&r.jsxs("details",{className:"ap-lan-reach-fix",children:[r.jsx("summary",{children:"or let them find this deck on their own"}),r.jsxs("p",{className:"lan-note",children:[d?r.jsx(r.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?r.jsx(r.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):r.jsxs(r.Fragment,{children:["Run this in PowerShell ",r.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&r.jsx(r.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&&r.jsxs(r.Fragment,{children:[" ",e.unsure]})]}),r.jsx("pre",{className:"ap-lan-cmd",children:r.jsx("code",{children:o.join(`
102
+ `)})}),r.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 pre(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const s=t.slice(0,n).trim(),a=Number(t.slice(n+1).trim());return!s||!Number.isInteger(a)||a<1||a>65535||s.includes(":")&&!(s.startsWith("[")&&s.endsWith("]"))?null:{addr:s,port:a}}function mre(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 Ey(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const gre={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."},yre={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function aA(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Vt(n,t)}function wre({status:e,manual:t,startWith:n,onClose:s,onChanged:a}){const o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=pt(s,{focusRef:h?i:o}),p=gt(s),[m,w]=y.useState(""),[k,b]=y.useState(""),[v,N]=y.useState(null),[j,S]=y.useState(null),[_,T]=y.useState(null),[$,M]=y.useState(null),[O,I]=y.useState(()=>Date.now());y.useEffect(()=>{const X=window.setInterval(()=>I(Date.now()),1e3);return()=>window.clearInterval(X)},[]);const F=y.useRef(!0);y.useEffect(()=>()=>{F.current=!1},[]);const L=y.useRef(null),A=y.useRef(null),q=y.useCallback(X=>Rp(L.current)?(L.current=X,T(X),!0):!1,[]),E=y.useCallback(()=>{L.current=null,F.current&&T(null)},[]),D=X=>{const Z=ao(_,X);return{disabled:Z.disabled,"aria-busy":Z.busy}},P=X=>(v==null?void 0:v.field)===X?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},z=X=>N(Z=>Z&&Z.field===X?null:Z),G=y.useCallback(async()=>{if(h)return;const X=pre(m);if(!X){N({text:xre(m),field:"addr"});return}const Z=`${X.addr}:${X.port}`,J=e.peers.find(te=>te.addr===X.addr&&te.port===X.port&&te.paired);if(J){N({text:`Already paired with ${J.name} at that address.`,field:"addr"});return}if(t.includes(Z)){N({text:"This deck already calls that address.",field:"addr"});return}if(q("add"))try{const te=await Ey("/api/prefs",{lan:{manual:[...t,Z]}});if(!F.current)return;te!=null&&te.ok?(N(null),w(""),a(),s()):N({text:Vt("add that address",te),field:"addr"})}catch{F.current&&N({text:Vt("add that address",null),field:"addr"})}finally{E()}},[m,h,t,e.peers,a,s,q,E]),V=y.useCallback(async X=>{if(!q(`invite:${X}`))return;const Z=X==="make"?"make an invite":"cancel that invite";try{const J=await Ey("/api/lan/invite",{action:X});if(!F.current)return;J!=null&&J.ok?(A.current=X,N(null),S(null),a()):N({text:aA(yre,J,Z)})}catch{F.current&&N({text:Vt(Z,null)})}finally{E()}},[a,q,E]),H=y.useCallback(async()=>{const X=k.trim();if(!(!X||!q("join"))){M(null);try{const Z=await Ey("/api/lan/invite",{action:"join",token:X});if(!F.current)return;Z!=null&&Z.ok?(b(""),N(null),a(),s()):(Z==null?void 0:Z.reason)==="unreachable"&&Array.isArray(Z.tried)&&Z.tried.length?(M(Z.tried),N(null)):(M(null),N({text:aA(gre,Z,"use that invite"),field:"join"}))}catch{F.current&&N({text:Vt("use that invite",null),field:"join"})}finally{E()}}},[k,a,s,q,E]),B=y.useCallback(async(X,Z)=>{try{await navigator.clipboard.writeText(X),S(Z),window.setTimeout(()=>{F.current&&S(J=>J===Z?null:J)},1600)}catch{N({text:"Could not copy it — select the text and copy it by hand."})}},[]),W=e.invite&&e.invite.expiresAt>O?e.invite:null,ee=y.useRef(!1);y.useEffect(()=>{n!=="invite"||ee.current||W||(ee.current=!0,V("make"))},[n,W,V]);const U=y.useRef(!1);y.useEffect(()=>{var X;n!=="invite"||U.current||!W||(U.current=!0,(X=c.current)==null||X.focus())},[n,W]),y.useEffect(()=>{var Z,J;const X=A.current;!X||X==="make"!=!!W||(A.current=null,Pn(((Z=document.activeElement)==null?void 0:Z.tagName)??null)&&((J=(X==="make"?c:d).current)==null||J.focus()))},[W]);const Y=e.port!=null?(e.addrs??[]).map(X=>`${X}:${e.port}`):[];return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{ref:f,className:"modal lan-add",onClick:X=>X.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[v&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:v.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(LD,{reach:e.reach,where:"dialog"}),h&&r.jsx("div",{className:"modal-section",children:r.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"By address"}),r.jsxs("div",{className:"ap-lan-row",children:[r.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:X=>{w(X.target.value),z("addr")},onKeyDown:X=>{X.key==="Enter"&&G()}}),m.trim()!==""&&r.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"})]}),r.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&Y.length>0&&r.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",Y.map((X,Z)=>r.jsxs("span",{children:[Z>0&&" or ",r.jsx("code",{className:"ap-lan-code",children:X})]},X)),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...D("copy:mine"),onClick:()=>void B(Y.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:j==="mine"?"copied":"copy"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:["With an invite",!W&&r.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...D("invite:make"),onClick:()=>void V("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:_==="invite:make"?"making…":"make one to send"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("input",{ref:i,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:k,placeholder:"paste one you were sent",spellCheck:!1,...P("join"),onChange:X=>{b(X.target.value),M(null),z("join")},onKeyDown:X=>{X.key==="Enter"&&H()}}),k.trim()!==""&&r.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:_==="join"?"joining…":"join"})]}),r.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),$&&r.jsxs("div",{className:"ap-lan-tried",children:[r.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."}),$.map(X=>r.jsxs("span",{className:"ap-lan-tried-row",children:[r.jsx("code",{className:"ap-lan-code",children:X.addr}),r.jsx("span",{className:"ap-lan-bad",children:X.why})]},X.addr))]}),W&&r.jsxs("div",{className:"ap-lan-invite",children:[r.jsxs("div",{className:"ap-lan-invite-head",children:[r.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),r.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[mre(W.expiresAt,O)," left"]})]}),r.jsx("code",{className:"ap-lan-token",children:W.token}),r.jsxs("div",{className:"ap-lan-acts",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...D("copy:invite"),"aria-label":j==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void B(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:j==="invite"?"copied":"copy"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...D("invite:withdraw"),onClick:()=>void V("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),r.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function xre(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 vre({asks:e,pressProps:t,answer:n}){return r.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(s=>r.jsxs("div",{className:"ap-lan-ask",children:[r.jsxs("span",{className:"ap-lan-ask-what",children:[r.jsx("strong",{className:"ap-lan-peer-name",children:s.name})," at ",r.jsx("code",{className:"ap-lan-code",children:s.addr})," wants to pair"]}),r.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${s.fp}`,children:["fingerprint ",r.jsx("code",{className:"ap-lan-code",children:s.fp})]}),r.jsxs("span",{className:"ap-lan-ask-acts",children:[r.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"}),r.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 bre({rows:e,pairingMode:t,armed:n,pressProps:s,answer:a,dropAddress:o,onUnpair:i,onOpenPeer:c,onInvite:d}){return r.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>r.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[r.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&r.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),r.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:r.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),r.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`accept:${h.fp}`),onClick:()=>void a("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"&&r.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"&&r.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"&&r.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"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`allow:${h.fp}`),onClick:()=>void a("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 kre(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 jre({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(LD,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&r.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&r.jsx("p",{className:"ap-lan-fine",children:kre(t)})]})}const oA=["online","offline","loose"],Nre={online:0,offline:1,loose:2};function Sre(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const _re=76,Cre=62,Qf=96,Ere={1:[.62],2:[.58,1],3:[.42,.72,1]},Tre=.2,Are=.16,Rre=.05,Mre=20,$re=17,Bh=7,Lre=30,Ire=116,Ore=6.6,Pre=6,Dre=e=>cN(e,null),Fre=1.5,Bre=80,qre=.45,iA=40,Ure=64,Wre=150,lA=.3,cA=84,uA=8,Hre=1.3,ep=6,zre=5.94,dA=7,hA=16,Dc=4,fA=.16;function m1(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function ID(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Vre(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Gre(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>oA.indexOf(t.tier)-oA.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 pA(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 Kre(e,t,n){const s=[...Ere[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=m1(t*s[a],n*s[a])/o;if(!(i>0)||i>=Qf)continue;const c=a+1<s.length?s[a+1]-Tre:1;s[a]=Math.max(s[a],Math.min(c,s[a]*(Qf/i)*1.02))}return s}const Do=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,Ty={h:16,ch:6.1,maxW:100};function Yre(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 OD(e,t,n,s,a,o){const i=t==="loose"?$re:Mre,c=!a||e.kind==="asks",d=c?Lre:Ty.h,h=a?Ty.ch:Ore,f=c?o.length:0,p=Math.min(a?Ty.maxW:Ire,Math.max(2*i,DD(e).length*h,f*Pre)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=ID(n,s)==="top"?{x0:n-p/2,y0:s-i-Bh-d,x1:n+p/2,y1:s-i-Bh}:{x0:n-p/2,y0:s+i+Bh,x1:n+p/2,y1:s+i+Bh+d};return[m,w]}const g1=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]},qh=(e,t)=>((e-t)%360+540)%360-180;function mA(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 a=()=>e.map(f=>{const[p,m]=g1(f);return OD(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*Fre,k=s.get(f.ring),b=(f.count>2?360/f.count:f.turn)*qre,v=k[(f.index+1)%f.count],N=k[(f.index-1+f.count)%f.count];return!(v===f||(p>0?qh(v.theta,w)>=b:qh(w,N.theta)>=b))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>Do(p,m)||Do(w,f)||Do(p,w)||Do(f,m),c=([f,p])=>Do(f,n)||Do(p,n);for(let f=0;f<Bre;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){c(p[w])&&(m=o(e[w],qh(e[w].theta,90)>=0?1:-1,!0)||m);for(let k=w+1;k<e.length;k++){if(!i(p[w],p[k]))continue;const b=e[w],v=e[k],N=v.ring.ring>b.ring.ring||v.ring===b.ring&&k>w?v:b,j=N===v?b:v,S=qh(N.theta,j.theta)>=0?1:-1;m=o(N,S)||o(j,-S)||m}}if(!m)break}const d=a();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 Xre={online:0,offline:1,loose:1};function Zre(e,t,n,s="",a=Dre){const o=[];for(const i of[!0,!1]){const c=gA(e,t,n,s,Nre,a,i);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=gA(e,t,n,s,Xre,a,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 gA(e,t,n,s,a,o,i=!0){const c=new Map;for(const q of e){const E=Sre(q);if(!E)continue;const D=a[E];c.has(D)||c.set(D,[]),c.get(D).push({row:q,tier:E})}const d=[...c.keys()].sort((q,E)=>q-E),h=Math.max(0,t/2-_re),f=Math.max(0,n/2-Cre),p=Kre(d.map(q=>c.get(q).length),h,f),m=d.map((q,E)=>({ring:q,rx:h*p[E],ry:f*p[E],count:c.get(q).length})),w=m.reduce((q,E)=>q+E.count,0),k=q=>q.row.via==="tailscale",b=[...c.values()].flat().filter(k).length,v=Math.max(0,...m.map(q=>{const E=c.get(q.ring).filter(k).length,D=m1(q.rx,q.ry);return E>0&&D>0?E*Qf*Hre/D*360:0})),N=i&&b>0&&b<w?Math.min(Wre,Math.max(Ure,b/w*360,v)):0,j=iA-N/2,S=iA+N/2,_=[];let T=!1;m.forEach((q,E)=>{const D=Gre(c.get(q.ring)),P=D.length,z=P>1&&m1(q.rx,q.ry)/P<Qf;z&&(T=!0);const G=E===m.length-1,V=G?-fA*(p[E]-(p[E-1]??0)):fA*(p[E+1]-p[E]),H=N>0?[{members:D.filter(W=>W.row.via!=="tailscale"),from:S,width:360-N},{members:D.filter(W=>W.row.via==="tailscale"),from:j+360,width:N}]:[{members:D,from:null,width:360}];let B=0;for(const W of H){const ee=W.members.length;if(ee===0)continue;const U=W.width/ee,Y=ee>2;W.members.forEach(({row:X,tier:Z},J)=>{const te=Us(X),ce=W.from==null?Vre(ee,E)+U*J:W.from+U*(J+.5),he=Y?pA(te,1)*Are*U:0,le=z&&B%2===1?1+V/p[E]:1,re=Y?pA(te,2)*Rre:0,ae=U*.3;_.push({row:X,tier:Z,ring:q,index:B,count:P,theta:ce+he,reach:le*(1+(G?-Math.abs(re):re)),lo:W.from==null?-1/0:W.from+ae,hi:W.from==null?1/0:W.from+W.width-ae,turn:U,caption:o(X)}),B++})}});const $=Yre(s);let M=mA(_,T,$);M>0&&!T&&(T=!0,M=mA(_,!0,$));const O=_.map((q,E)=>{const[D,P]=g1(q);return{row:q.row,tier:q.tier,ring:q.ring.ring,x:D,y:P,angle:Jre(Math.atan2(P,D)*180/Math.PI),dist:Math.hypot(D,P),side:ID(D,P),order:E}}),I=m.reduce((q,E,D)=>c.get(E.ring).some(k)?Math.max(q,p[D]):q,0),F=q=>({from:j,to:S,inner:{rx:h*lA,ry:f*lA},outer:{rx:Math.min(t/2-8,h*I+q),ry:Math.min(n/2-8,f*I+q)},count:b}),L={nodes:O,rings:m,dense:T,zone:N>0?{...F(cA),labelAt:null}:null};return{layout:L,clashes:M,named:()=>{if(!L.zone)return L;const q=_.flatMap(P=>{const[z,G]=g1(P);return OD(P.row,P.tier,z,G,T,P.caption)});let E={...L.zone,labelAt:yA(L.zone,q)},D=E.outer;for(let P=cA+uA;E.labelAt==null;P+=uA){const z=F(P);if(z.outer.rx===D.rx&&z.outer.ry===D.ry)break;D=z.outer;const G=yA(z,q);G!=null&&(E={...z,labelAt:G})}return{...L,zone:E}}}}function PD(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function yA(e,t){const n={rx:e.outer.rx-ep,ry:e.outer.ry-ep};if(!(n.rx>0&&n.ry>0))return null;const s=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),a=[];for(let j=e.to;j>=e.from;j-=s){const S=j*Math.PI/180;a.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=dA+Dc,i={x0:Math.min(...a.map(j=>j[0]))-o,x1:Math.max(...a.map(j=>j[0]))+o,y0:Math.min(...a.map(j=>j[1]))-o,y1:Math.max(...a.map(j=>j[1]))+o},c=t.map(j=>({x0:j.x0-Dc,y0:j.y0-Dc,x1:j.x1+Dc,y1:j.y1+Dc})).filter(j=>Do(j,i)),d=(j,S)=>c.some(_=>j>_.x0&&j<_.x1&&S>_.y0&&S<_.y1),h=[],f=[];let p=0;a.forEach(([j,S],_)=>{_>0&&(p+=Math.hypot(j-a[_-1][0],S-a[_-1][1]));const T=Math.hypot(j,S)||1;let $=!1;for(let M=0;M<=dA&&!$;M+=1.75)$=d(j-j/T*M,S-S/T*M);h.push(p),f.push((f.at(-1)??0)+($?1:0))});const m=PD(e.count).length*zre/2,w=m+hA,k=p-m-hA;if(!(p>0)||k<w)return null;const b=j=>{let S=0,_=h.length;for(;S<_;){const T=S+_>>1;h[T]<j?S=T+1:_=T}return S},v=j=>{const S=b(j-m),_=b(j+m+1e-9)-1;return _<S||f[_]-(S>0?f[S-1]:0)===0},N=p/2;for(let j=0;N-j>=w;j+=2)for(const S of j===0?[N]:[N-j,N+j])if(v(S))return S/p;return null}function Jre(e){return(e%360+360)%360}function Qre(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 eae(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 cN(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return FD(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?tae(t):"online";const n=qD(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function DD(e){return FD(e)?e.addr:e.name}function FD(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function BD(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=qD(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 qD(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function tae(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function nae(e){var s;if(!e)return[];const t=(e.addrs??[]).map(a=>`${a}:${e.port}`),n=(s=e.tailscale)==null?void 0:s.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function Us(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function sae(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function rae(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} ${UD}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const UD="This deck pairs by invite only. Send one from Add a deck.";function aae(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"?UD:"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 oae(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 iae(e){const t=e.length,n=e.filter(s=>s.tone==="ok").length;return t===0?"No shared logins":n===t?`${t} shared login${t===1?", fine":"s, all fine"}`:`${t} shared login${t===1?"":"s"} · ${n} fine`}function lae(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),s=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!s)return null;for(let a=1;a<=3;a++){const o=Number(n[a])-Number(s[a]);if(o)return Math.sign(o)}return 0}function cae(e,t){const n=t?t.alive?t.shareable===!1?t.inUse?"in use here":"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:e.inUse?"in use there":"cannot share there",here:n,note:null,tone:e.inUse&&(t!=null&&t.alive)?"ok":"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&&!t.inUse?"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 uae(e,t,n,s=null){var d;const a=new Map;for(const h of t)(d=a.get(h.key))!=null&&d.alive||a.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=a.get(h.key)??null,p=o.has(h.key),m=cae(h,f),w=f?f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired":"missing",k=!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?h.inUse?"inUse":"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:k,tone:m.tone,usedThere:s===h.key})}for(const h of n){const f=a.get(h);!f||c.has(h)||(c.add(h),i.push({key:h,email:f.email,here:f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?f.inUse?"in use here":"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1&&!f.inUse?"idle":"ok":"bad",usedThere:!1}))}return i}const dae=1e3;function hae(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=vr(e,t);return`${n} · ${s==="now"?"just now":s}`}function y1(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const WD={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},HD={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function zD(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck",n=e.usedThere&&e.there!=="inUse"?", in use there":"";return`${WD[e.here]}, ${HD[e.there]}, ${t}${n}.`}function VD({row:e,source:t,status:n,accounts:s,now:a}){var Z,J,te,ce,he;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=((Z=n.about)==null?void 0:Z.version)??null,k=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=y1(n.about),v=y1(m),N=m!=null&&m.version&&w?lae(m.version,w):null,j=o?zp(o.last,a):null,S=o&&((J=o.last)!=null&&J.error)?Ite({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(le=>!le.manual&&le.addr).map(le=>({fp:le.fp,name:le.name,addr:le.addr,port:le.port,at:le.lastSeen??0}))],a):null,_=(te=o==null?void 0:o.last)!=null&&te.error&&j&&j.text!==o.last.error?o.last.error:null,T=((ce=o==null?void 0:o.last)==null?void 0:ce.done)??[],$=!!j&&!!_&&!e.quiet&&e.state.startsWith(j.text),M=c||e.kind==="dialling",O=((o==null?void 0:o.via)??e.via)==="tailscale",I=o?o.waiting?null:o.manual?O?"added by its Tailscale address":"added by address":O?"over Tailscale":"on this network":e.kind==="nearby"?O?"heard over Tailscale":"heard on this network":O?"asked this deck to pair, over Tailscale":"asked this deck to pair",F=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",L=(o==null?void 0:o.offers)??null,A=F==="up"?(L==null?void 0:L.current)??null:null,q=A&&"key"in A?A.key:null,E=!!A&&"hidden"in A,D=!!A&&"other"in A,P=(n.shared??[]).filter(le=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(le))}),z=c?uae((L==null?void 0:L.accounts)??null,s,P,q):[],G=z.filter(le=>le.in==null&&le.out==="cut"&&le.here!=="inUse"),V=z.some(le=>le.in!=null),H=z.some(le=>le.out!=null),B=new Set((n.peers??[]).filter(le=>le.paired).flatMap(le=>le.notOffered??[])),W=z.some(le=>le.out!=null&&B.has(le.key))?"decks you chose":"every paired deck",ee=new Map(T.map(le=>[le.email,le])),U=T.filter(le=>!z.some(re=>re.email===le.email)),Y=c?L?L.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(he=o==null?void 0:o.last)!=null&&he.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,X=L&&(o!=null&&o.last)&&o.last.at-L.at>dae?vr(L.at,a):null;return{peer:o,stranger:i,paired:c,own:d,canRename:h,fp:f,where:p,about:m,unsaid:k,hereRuns:b,thereRuns:v,order:N,line:j,silence:S,raw:_,echoed:$,showRound:M,how:I,link:F,hiddenThere:E,otherThere:D,lanes:z,spent:G,taking:V,giving:H,givenTo:W,told:ee,unplaced:U,unknown:Y,stale:X}}function w1(){return r.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:[r.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),r.jsx("path",{d:"M1 13h14"})]})}function Uh({dir:e}){return r.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:r.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function fae({view:e,row:t,status:n,asking:s,drawn:a,onSettings:o}){const{peer:i,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:m,order:w,line:k,silence:b,raw:v,echoed:N,showRound:j,how:S,link:_,hiddenThere:T,otherThere:$,lanes:M,spent:O,taking:I,giving:F,givenTo:L,told:A,unplaced:q,unknown:E,stale:D}=e;return r.jsxs("div",{className:"lan-map","data-link":_,"data-asking":s||void 0,"data-bus":M.length>0||void 0,children:[r.jsxs("div",{className:"lan-ends",children:[r.jsxs("p",{className:"lan-end",children:[r.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&r.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),r.jsxs("p",{className:"lan-end","data-side":"there",children:[r.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&r.jsxs("span",{className:"lan-end-runs",children:[m??(h?"not said":f),w?` · ${w<0?"older":"newer"}`:null]}),T&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"}),$&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(w1,{}),r.jsxs("span",{className:"lan-span",children:[r.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[r.jsx("i",{className:"lan-glint","data-dir":"out"}),r.jsx("i",{className:"lan-glint","data-dir":"in"})]}),r.jsx("span",{className:"lan-link-label",children:d?r.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),r.jsx(w1,{}),(d&&S||j)&&r.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&j&&" · ",j&&(k?N?r.jsx("code",{className:"ap-lan-code",children:v}):r.jsx("span",{className:"lan-round","data-tone":k.tone,children:k.text.replace(/ · now$/," · just now")}):"not asked yet"),j&&v&&!N&&r.jsx("code",{className:"lan-fact-raw",children:v})]}),q.length>0&&r.jsx("ul",{className:"lan-done",children:q.map(P=>{const z=l1(P);return r.jsxs("li",{"data-ok":P.ok&&!z,children:[P.email," ",r.jsxs("span",{className:"lan-done-what",children:[P.ok?"arrived":"did not arrive",z&&` — ${z.long}`]})]},`${P.email}:${P.action}`)})}),b&&r.jsx("p",{className:"lan-note lan-link-note",children:b}),(i==null?void 0:i.waiting)&&r.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(k==null?void 0:k.hint)&&r.jsx("p",{className:"lan-note lan-link-note",children:k.hint})]}),M.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:M.map((P,z)=>{const G=A.get(P.email),V=G?l1(G):null,H=P.out==="live"||P.in!=null&&P.in!=="cut";return r.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":z},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":P.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":H?"live":"cut","aria-hidden":!0,children:[(P.in==="live"||P.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":P.in}),P.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),P.in&&P.in!=="cut"&&r.jsx(Uh,{dir:"in"}),P.out==="live"&&r.jsx(Uh,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:P.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":P.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:zD(P)}),(P.caption||G)&&r.jsxs("span",{className:"lan-lane-note",children:[P.caption,P.caption&&G&&" · ",G&&r.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!V,children:[G.ok?"arrived last round":"did not arrive last round",V&&` — ${V.long}`]})]})]},P.key)})},a),c&&r.jsxs(r.Fragment,{children:[O.length>0&&r.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",O.length===1?O[0].email:"the expired ones"," until you sign in again here."]}),E&&r.jsx("p",{className:"lan-empty",children:E}),D&&r.jsxs("p",{className:"lan-stale",children:["As of ",D==="now"?"just now":D,", when it last answered."]}),r.jsxs("div",{className:"lan-legend",children:[I&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(Uh,{dir:"in"})}),"from ",t.name]}),F?r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:r.jsx(Uh,{dir:"out"})}),"from this deck, to ",L]}):r.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),r.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const pae=20,mae=17,wA=34,gae=160,yae=80,wae=200,xae=8,vae=14,bae=10,kae=.61803398875;function jae({status:e,rows:t,accounts:n,now:s,covered:a,onOpenDeck:o,onClose:i}){const c=y.useRef(null),d=pt(i,{focusRef:c}),h=gt(i),f=y.useRef(null),[p,m]=y.useState(null),[w,k]=y.useState(!1),b=y.useRef(null);y.useLayoutEffect(()=>{const re=f.current;if(!re)return;let ae=null;const de=()=>{const fe=Math.round(re.clientWidth),ye=Math.round(re.clientHeight);ae&&ae.w===fe&&ae.h===ye||(ae&&(k(!0),b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>k(!1),wae)),ae={w:fe,h:ye},m(ae))};if(de(),typeof ResizeObserver>"u")return;const _e=new ResizeObserver(de);return _e.observe(re),()=>{_e.disconnect(),b.current!=null&&window.clearTimeout(b.current)}},[]);const v=y.useMemo(()=>p?Zre(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var ae,de;return cN(re,(de=(ae=Lu(e,re).peer)==null?void 0:ae.about)==null?void 0:de.os)}):null,[t,p,e]),N=y.useMemo(()=>Qre(t),[t]),j=(v==null?void 0:v.nodes)??[],S=y.useRef(new Map),_=y.useMemo(()=>{const re=new Map;for(const ae of j){const de=Us(ae.row);re.set(de,sae(S.current.get(de),ae.angle))}return S.current=re,re},[j]),[T,$]=y.useState(null),[M,O]=y.useState(null),[I,F]=y.useState("none"),L=y.useRef(null),A=y.useCallback((re,ae)=>{L.current!==re&&(L.current=re,F(ae),O(re))},[]),q=y.useRef(null),E=y.useRef(null),D=y.useCallback(()=>{E.current!=null&&window.clearTimeout(E.current),E.current=null},[]),P=y.useCallback((re,ae)=>{if(q.current!=null&&window.clearTimeout(q.current),q.current=null,D(),$(re),ae==="keyboard"){A(re,"none");return}E.current=window.setTimeout(()=>A(re,L.current?"swap":"full"),yae)},[A,D]),z=y.useCallback(()=>{q.current!=null&&window.clearTimeout(q.current),D(),q.current=window.setTimeout(()=>$(null),gae)},[D]);y.useEffect(()=>()=>{q.current!=null&&window.clearTimeout(q.current),D()},[D]);const G=T&&j.some(re=>Us(re.row)===T)?T:null,V=M?t.find(re=>Us(re)===M)??null:null;y.useEffect(()=>{M&&!V&&A(null,"swap")},[M,V,A]);const[H,B]=y.useState(null),W=y.useRef(new Map),ee=j.findIndex(re=>Us(re.row)===H),U=ee<0?0:ee,Y=re=>{var fe;if(j.length===0)return;const ae=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,de=re.key==="Home"?0:re.key==="End"?j.length-1:ae?(U+ae+j.length)%j.length:null;if(de==null)return;re.preventDefault();const _e=Us(j[de].row);B(_e),(fe=W.current.get(_e))==null||fe.focus()},[X,Z]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const re=()=>Z(document.hidden);return document.addEventListener("visibilitychange",re),()=>document.removeEventListener("visibilitychange",re)},[]);const J=(e==null?void 0:e.enabled)===!0,te=e?J?eae(N):"Local network is off":"checking…",ce=()=>{D(),A(null,"swap"),$(null)},he=G?j.find(re=>Us(re.row)===G)??null:null,le=()=>{var re;M&&((re=W.current.get(M))==null||re.focus()),ce()};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.jsxs("div",{ref:d,className:"modal nm-modal",onClick:re=>re.stopPropagation(),"data-paused":a||X||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[r.jsxs("header",{className:"modal-head nm-head",children:[r.jsxs("div",{className:"nm-heading",children:[r.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),r.jsx("p",{id:"nm-sub",className:"nm-sub",children:te})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("div",{className:"nm-body",children:[r.jsxs("div",{className:"nm-view",children:[r.jsx("div",{ref:f,className:"nm-stage","data-focus":G?"":void 0,"data-focus-via":he==null?void 0:he.row.via,"data-dense":(v==null?void 0:v.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&ce()},children:p&&v&&r.jsxs(r.Fragment,{children:[r.jsx(Nae,{layout:v,w:p.w,h:p.h}),j.map(re=>{const ae=Us(re.row);return r.jsx(Cae,{node:re,angle:_.get(ae)??re.angle,lit:G===ae},ae)}),r.jsx(Eae,{status:e}),r.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),r.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${j.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:Y,children:j.map((re,ae)=>{var _e,fe;const de=Us(re.row);return r.jsx(Tae,{node:re,angle:_.get(de)??re.angle,os:(fe=(_e=Lu(e,re.row).peer)==null?void 0:_e.about)==null?void 0:fe.os,lit:G===de,shown:M===de,tabbable:ae===U,register:ye=>{ye?W.current.set(de,ye):W.current.delete(de)},onHold:ye=>{B(de),P(de,ye)},onRelease:z,onOpen:()=>o(re.row.fp)},de)})}),j.length===0&&r.jsx(Aae,{status:e})]})}),r.jsx(Rae,{slice:(v==null?void 0:v.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:V&&e?r.jsx($ae,{row:V,status:e,accounts:n,now:s,entrance:I,onOpen:()=>o(V.fp),onBack:le},Us(V)):r.jsx(Mae,{status:e,summary:N,entrance:I,slice:(v==null?void 0:v.zone)!=null})})]})]})}),document.body)}function GD(){return r.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:[r.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),r.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),r.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),r.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),r.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function Nae({layout:e,w:t,h:n}){const{zone:s}=e;return r.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[s&&r.jsxs(r.Fragment,{children:[r.jsxs("defs",{children:[r.jsx("path",{id:"nm-zone-arc",d:_ae(s,t/2,n/2)}),r.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(s.outer.rx,s.outer.ry),children:[r.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),r.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),r.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),r.jsx("path",{className:"nm-zone",d:Sae(s,t/2,n/2),fill:"url(#nm-zone-fill)"}),s.labelAt!=null&&r.jsx("text",{className:"nm-zone-label",children:r.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(s.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:PD(s.count)})})]}),e.rings.map((a,o)=>r.jsx("ellipse",{className:"nm-orbit","data-ring":a.ring,"data-folded":e.folded&&a.ring===1||void 0,cx:t/2,cy:n/2,rx:a.rx,ry:a.ry,style:{"--ring":o}},a.ring))]})}function xA(e,t,n,s){const a=s*Math.PI/180;return`${(t+Math.cos(a)*e.rx).toFixed(1)},${(n+Math.sin(a)*e.ry).toFixed(1)}`}function Sae(e,t,n){const s=e.to-e.from>180?1:0,a=(N,j)=>{const S=j*Math.PI/180;return[t+Math.cos(S)*N.rx,n+Math.sin(S)*N.ry]},o=(N,j)=>j/((N.rx+N.ry)/2)*(180/Math.PI),i=(N,j,S)=>{const _=Math.hypot(j[0]-N[0],j[1]-N[1])||1,T=Math.min(.5,S/_);return[N[0]+(j[0]-N[0])*T,N[1]+(j[1]-N[1])*T]},c=([N,j])=>`${N.toFixed(1)},${j.toFixed(1)}`,d=bae,h=vae,f=o(e.inner,d),p=o(e.outer,h),m=a(e.inner,e.from),w=a(e.outer,e.from),k=a(e.outer,e.to),b=a(e.inner,e.to),v=N=>`${N.rx.toFixed(1)},${N.ry.toFixed(1)}`;return[`M${c(a(e.inner,e.from+f))}`,`Q${c(m)} ${c(i(m,w,d))}`,`L${c(i(w,m,h))}`,`Q${c(w)} ${c(a(e.outer,e.from+p))}`,`A${v(e.outer)} 0 ${s} 1 ${c(a(e.outer,e.to-p))}`,`Q${c(k)} ${c(i(k,b,h))}`,`L${c(i(b,k,d))}`,`Q${c(b)} ${c(a(e.inner,e.to-f))}`,`A${v(e.inner)} 0 ${s} 0 ${c(a(e.inner,e.from+f))}`,"Z"].join(" ")}function _ae(e,t,n){const s={rx:e.outer.rx-ep,ry:e.outer.ry-ep},a=e.to-e.from>180?1:0;return`M${xA(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${xA(s,t,n,e.from)}`}function Cae({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*kae%1*xae;return r.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":`${wA}px`,"--gap":`${wA+(e.tier==="loose"?mae:pae)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function Eae({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return r.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[r.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),r.jsxs("span",{className:"nm-core-label",children:[r.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),r.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function Tae({node:e,angle:t,os:n,lit:s,shown:a,tabbable:o,register:i,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${Lae(Us(f))}`,m=e.angle*Math.PI/180,w=cN(f,n);return r.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":a||void 0,"aria-label":`${f.name}: ${BD(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:k=>{k.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:k=>c(k.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[r.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?r.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):r.jsx(w1,{}),e.tier!=="online"&&r.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),r.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[r.jsx("span",{className:"nm-name",children:DD(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function Aae({status:e}){const t=(e==null?void 0:e.enabled)===!0;return r.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 Rae({slice:e}){return r.jsxs("ul",{className:"nm-legend",children:[r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"online"}),r.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),r.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),r.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&r.jsxs("li",{children:[r.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function KD({facts:e}){return r.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>r.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[r.jsx("dt",{children:t.label}),r.jsx("dd",{children:t.value})]},t.label))})}function Mae({status:e,summary:t,entrance:n,slice:s}){const a=nae(e),o=y1(e==null?void 0:e.about),i=[];o&&i.push({label:"Runs",value:o}),i.push({label:a.length>1?"Addresses":"Address",value:a.length?r.jsx("span",{className:"nm-addrs",children:a.map(h=>r.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:a.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:r.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:r.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:r.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:r.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:r.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:r.jsx("i",{"aria-hidden":!0})}],d=rae(t,e==null?void 0:e.pairingMode);return r.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[r.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),r.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),r.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>r.jsxs("li",{"data-count":h.key,children:[h.mark,r.jsx("span",{className:"nm-count-n",children:h.n}),r.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&r.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",s?" — the shaded slice, lower right":""]}),d&&r.jsx("p",{className:"nm-next",children:d}),r.jsx(KD,{facts:i}),r.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 $ae({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var b;const c=VD({row:e,source:Lu(t,e),status:t,accounts:n,now:s}),d=[];c.where&&d.push({label:"Address",value:r.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=aae(e,t.pairingMode),p=oae(c.lanes),m=p.length,w=iae(p),k=c.unknown&&((b=c.peer)!=null&&b.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return r.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":a,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[r.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:i,children:[r.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),r.jsxs("div",{className:"nm-panel-head",children:[r.jsxs("h3",{className:"nm-panel-name",children:[r.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),r.jsx("span",{className:"nm-panel-title",children:e.name})]}),r.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&r.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),r.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:BD(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),d.length>0&&r.jsx(KD,{facts:d}),c.paired&&r.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[r.jsx("p",{className:"nm-logins-title",children:w}),m>0&&r.jsx("ul",{className:"nm-lanes",children:p.map((v,N)=>r.jsxs("li",{className:"nm-lane","data-tone":v.tone,style:{"--k":N},children:[r.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),r.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:v.email}),vA(v)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:vA(v)}),v.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[v.email,": ",zD(v)]})]},v.key))}),k&&r.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function vA(e){return e.caption?e.caption:e.tone==="ok"?null:`${WD[e.here]} · ${HD[e.there]}`}function Lae(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 Iae=6;function Oae({anchorId:e,id:t,rows:n,onHold:s,onLet:a}){const o=y.useRef(null),i=n.filter(m=>m.kind==="paired"),c=i.filter(m=>m.here),d=c.slice(0,Iae),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 k=Yj(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${k.top}px`,m.style.left=`${k.left}px`,m.style.maxHeight=k.maxHeight==null?"":`${k.maxHeight}px`,m.dataset.side=k.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]),xt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&r.jsx("div",{className:"ap-peek-list",children:d.map(m=>r.jsxs("span",{className:"ap-peek-who",children:[r.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),r.jsxs("span",{title:m.via==="tailscale"?`${m.name} · Tailscale`:m.name,children:[m.name,m.via==="tailscale"&&r.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${m.kind}:${m.fp}`))}),f&&r.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function Pae({entry:e,rows:t,onOpen:n,onMap:s,peek:a,openPeek:o,shutPeek:i,holdPeek:c,dropPeek:d}){return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":a?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(TD)},onPointerLeave:i,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:i,children:[r.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:[r.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),r.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Local network"}),r.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&r.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),r.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:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),s&&r.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:r.jsx(GD,{})}),a&&r.jsx(Oae,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:i})]})}function Dae({row:e,run:t,onVerb:n,onUnpair:s}){const[a,o]=y.useState(!1),i=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!a)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[a]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:a,armedTwin:c,pressOwn:()=>{const p=Date.now(),m=oi({armedFor:a?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:ai});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=oi({armedFor:c,target:p,armedAt:i.current,now:m,gapMs:ai});if(w==="arm"){d(p),o(!1),i.current=m;return}w!=="ignore"&&(d(null),t(()=>s(p)))}}}function Fae({row:e,paired:t,peer:n,status:s,busy:a,press:o,checkNow:i,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return r.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&r.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)&&r.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:a===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&r.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:a===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&s.pairingMode!=="invite"&&r.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:a===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&r.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:a===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&s.pairingMode!=="invite"&&r.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:a===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&s.pairingMode==="invite"&&p&&r.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 Bae({instances:e,now:t,busy:n,press:s,armedTwin:a,pressTwin:o,onUnpair:i}){return r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),r.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var k,b,v,N;const h=(k=c.peer)!=null&&k.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(b=c.peer)!=null&&b.pairedAt?vr(c.peer.pairedAt,t):null,m=[(N=(v=c.peer)==null?void 0:v.about)!=null&&N.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 r.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[r.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?r.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):r.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),r.jsx("code",{className:"ap-lan-code lan-twin-fp",children:w}),d>0&&i&&r.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${a===w?" armed":""}`,...s(`unpair:${w}`),onKeyDown:j=>{j.repeat&&j.preventDefault()},onClick:()=>o(w),"aria-label":a===w?`Confirm unpairing ${f}`:`Unpair ${f}`,title:a===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…":a===w?"confirm":"unpair"}),r.jsx("span",{className:"lan-twin-meta",children:d===0?`${m} · shown above`:m})]},w)})})]})}function qae(){return r.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:[r.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),r.jsx("path",{d:"M8.4 3.6l2 2"})]})}function Uae({row:e,source:t,status:n,accounts:s,now:a,busy:o,onClose:i,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:m=[],onUnpair:w}){const k=y.useRef(null),b=pt(i,{focusRef:k}),v=gt(i),[N,j]=y.useState(null),[S,_]=y.useState(null),[T,$]=y.useState(!1),[M,O]=y.useState(0),I=y.useRef(null),F=y.useRef(null),L=y.useRef(!0);y.useEffect(()=>()=>{L.current=!1},[]);const A=N!=null;y.useEffect(()=>{var re;A&&((re=I.current)==null||re.select())},[A]);const q=y.useRef(!1);y.useEffect(()=>{var re,ae;q.current&&!A&&Pn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((ae=F.current)==null||ae.focus()),q.current=A},[A]);const E=re=>{const ae=ao(o,re);return{disabled:ae.disabled,"aria-busy":ae.busy}},D=async re=>{const ae=await re();return L.current&&_(ae),ae==null},{armed:P,armedTwin:z,pressOwn:G,pressTwin:V}=Dae({row:e,run:D,onVerb:h,onUnpair:w}),H=VD({row:e,source:t,status:n,accounts:s,now:a}),{peer:B,stranger:W,paired:ee,own:U,canRename:Y,fp:X}=H,Z=o===`check:${e.fp}`,J=async re=>{const ae=re.trim()===U?"":re;await D(()=>c(ae))&&j(null)},te=()=>void D(d).then(re=>{re&&L.current&&O(ae=>ae+1)}),ce=async()=>{if(X)try{if(await navigator.clipboard.writeText(X),!L.current)return;$(!0),window.setTimeout(()=>{L.current&&$(!1)},1600)}catch{L.current&&_("Could not copy it — select the fingerprint and copy it by hand.")}},he=[];ee&&(B!=null&&B.pairedAt)?he.push({label:"Paired",value:hae(B.pairedAt,a),tone:"meta"}):e.kind==="declined"&&W&&he.push({label:"Paired",value:`no · you said no ${rN(W.at,a)}`,tone:"meta"}),he.push({label:"Fingerprint",value:X?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:X}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void ce(),"aria-label":T?"Fingerprint copied":"Copy the fingerprint",children:T?"copied":"copy"})]}):"not known — nothing has answered there",tone:X?void 0:"quiet"});const le=m.length?[{row:e,peer:B??null},...m]:[];return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...v,role:"presentation",children:r.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:[r.jsxs("header",{className:"modal-head lan-peer-head",children:[r.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("div",{className:"lan-peer-id",children:[A?r.jsxs("form",{className:"lan-peer-edit",onSubmit:re=>{re.preventDefault(),J(N??"")},children:[r.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),r.jsx("input",{ref:I,className:"ap-manage-input lan-peer-input",value:N??"",maxLength:48,placeholder:U,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>j(re.target.value)}),r.jsx("button",{type:"submit",className:"ap-manage-btn",...E(`alias:${e.fp}`),children:"save"}),r.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>j(null),children:"cancel"})]}):r.jsxs("span",{className:"lan-peer-title",children:[r.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),Y&&r.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:F,onClick:()=>{_(null),j(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:r.jsx(qae,{})})]}),r.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&r.jsxs(r.Fragment,{children:["calls itself ",r.jsx("span",{className:"lan-peer-self",children:e.self}),A&&r.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...E(`alias:${e.fp}`),onClick:()=>void J(""),children:"use this name"}),r.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&r.jsx("span",{"aria-hidden":!0,children:" · "})]}),r.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:k,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:S}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>_(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(fae,{view:H,row:e,status:n,asking:Z,drawn:M,onSettings:f}),r.jsx("dl",{className:"lan-facts",children:he.map(re=>r.jsxs("div",{className:"lan-fact","data-tone":re.tone,children:[r.jsx("dt",{children:re.label}),r.jsx("dd",{children:re.value})]},re.label))}),le.length>1&&r.jsx(Bae,{instances:le,now:a,busy:o,press:E,armedTwin:z,pressTwin:V,onUnpair:w})]}),r.jsx(Fae,{row:e,paired:ee,peer:B,status:n,busy:o,press:E,checkNow:te,armed:P,pressOwn:G,run:D,onVerb:h,onInvite:p})]})}),document.body)}function ea(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Pn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function Wae(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Hae(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function bA(e,t,n){return e==null||n!=null&&!n.ok||Wae(e,t)?null:e}function YD({line:e,onDismiss:t,onAnswer:n}){const[s,a]=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,a(!0);const p=await Use();o.current=!1,i.current&&(a(!1),h.current=document.activeElement===c.current,n(Hse(p)))};return r.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&r.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"}),r.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function zae(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 Wh="Paused while this deck pairs only by invite. Turn that off above to use it.";function Vae({status:e,accounts:t,onClose:n,onChanged:s}){nn("lan-setup");const a=pt(n),o=gt(n),[i,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),k=y.useRef(null),b=H=>{const B=ao(m,H);return{disabled:B.disabled,"aria-busy":B.busy}},v=y.useRef(null),N=y.useRef(!0);y.useEffect(()=>()=>{N.current=!1},[]),y.useEffect(()=>{v.current=bA(v.current,e.shared??[],null)},[e.shared]);const j=y.useCallback(async(H,B,W="write")=>{k.current=W,w(W);try{const U=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:H})})).json().catch(()=>null);return N.current?(U!=null&&U.ok?h(null):h(Ws(Vt(B,U),U)),s(),(U==null?void 0:U.ok)===!0):!1}catch{return N.current&&h(Ws(Vt(B,null))),!1}finally{k.current=null,N.current&&w(null)}},[s]),S=y.useCallback(async H=>{const B=await j({name:H},"save the name","name");return B&&N.current&&c(W=>W===H?null:W),B},[j]),_=y.useRef(null),T=i!=null&&i!==(e.name??""),$=ea(!T,_),M=y.useCallback(async()=>{T&&!await S(i)||n()},[T,i,S,n]),O=async()=>{if(!e.fp)return;const H=await ho(e.fp);if(N.current){if(!H){h(Ws("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},I=new Set(v.current??e.shared??[]),F=e.autoAsk!==!1,L=e.autoAccept!==!1,A=e.pairingMode==="invite",q=H=>{const B=b(H);return{...B,disabled:B.disabled||A}},E=e.shareActive!==!1,D=e.sendInUse===!0,P=e.tailscale??null,z=!!(P!=null&&P.on),G=(P==null?void 0:P.ask)!==!1,V=(P==null?void 0:P.accept)!==!1;return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal lan-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsx(YD,{line:d,onDismiss:()=>h(null),onAnswer:H=>{h(H),H.done&&s()}}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Name"}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"appear as"}),r.jsx("input",{ref:_,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:H=>c(H.target.value),onKeyDown:H=>{H.key!=="Enter"||i==null||S(i)}}),T&&r.jsx("button",{type:"button",className:"ap-manage-btn",...b("name"),onClick:()=>{$(),S(i)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:e.fp}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void O(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):r.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Share these accounts"}),r.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&r.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(H=>r.jsxs("label",{className:"ap-lan-pick",title:H.alive?H.inUse?"Offer this account to the decks you have paired with. While this deck is on it, it stays here, and it goes out like the others once this deck switches away. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"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:[r.jsx("input",{type:"checkbox",checked:I.has(H.key),onChange:B=>{const W=Hae(v.current,e.shared??[],H.key,B.target.checked);v.current=W,j({shared:W},B.target.checked?"share that account":"stop sharing that account").then(ee=>{v.current===W&&(v.current=bA(W,e.shared??[],{ok:ee}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:H.email}),!H.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),H.alive&&H.inUse&&I.has(H.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},H.key))]}),t.length>0&&r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":E,"aria-label":"Show paired decks which of these this deck is using",...b("current"),onClick:()=>void j({shareActive:!E},E?"stop showing which account this deck is using":"show which account this deck is using","current"),title:E?"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:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Send the login this deck is using too",D&&r.jsx("span",{id:"lan-send-in-use-detail",className:"lan-switch-detail",children:"The other machine renews its copy even when idle, and whichever renews it second is signed out."})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":D,"aria-label":"Send the login this deck is using too","aria-describedby":D?"lan-send-in-use-detail":void 0,"data-tone":"warn",...b("send-in-use"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void j({sendInUse:!D},D?"keep the login this deck is using here":"send the login this deck is using","send-in-use"),title:D?"Keep the account this deck is signed in to here while it is. It goes out like the others once this deck switches away.":"Also hand out the account this deck is signed in to right now. Two machines on one login race to renew it, and the one that renews it second is signed out (“Login expired · Please run /login”).",children:r.jsx("span",{className:"switch-knob"})})]})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),r.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",A&&r.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."})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":A,"aria-label":"Pair new decks only by invite","aria-describedby":A?"lan-invite-only-detail":void 0,...b("mode"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void j({pairingMode:A?"automatic":"invite"},A?"let decks pair on their own again":"pair new decks only by invite","mode"),title:A?"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:r.jsx("span",{className:"switch-knob"})})]})}),r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",A&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":A||void 0,children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":F,"aria-label":"Ask every deck this one finds",...q("ask"),onClick:()=>void j({autoAsk:!F},F?"stop asking automatically":"ask every deck this one finds","ask"),title:A?Wh:F?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...q("accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void j({autoAccept:!L},L?"stop accepting automatically":"accept every deck that asks","accept"),title:A?Wh:L?"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:r.jsx("span",{className:"switch-knob"})})]})]})]})]}),(P==null?void 0:P.found)&&r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Tailscale"}),r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",r.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:zae(P)})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":z,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...b("tailscale"),onClick:()=>void j({tailscale:!z},z?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:z?"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:r.jsx("span",{className:"switch-knob"})})]}),z&&r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",A&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch","data-paused":A||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...q("tailscale-ask"),onClick:()=>void j({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:A?Wh:G?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch","data-paused":A||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":V,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...q("tailscale-accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void j({tailscaleAccept:!V},V?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:A?Wh:V?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:r.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),r.jsxs("footer",{className:"lan-setup-foot",children:[r.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),r.jsx("button",{type:"button",className:"btn primary",...b("name"),onClick:()=>void M(),children:"Done"})]})]})}),document.body)}function Gae({on:e,status:t,paired:n,busy:s,pressProps:a,checkNow:o,setAddOpen:i,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return r.jsxs("div",{className:"ap-header",children:[r.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:r.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:r.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),r.jsx("h2",{id:"ap-lan-title",children:"Local network"}),r.jsxs("div",{className:"ap-header-right",children:[e&&r.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:r.jsx(GD,{})}),e&&r.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:r.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:[r.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"}),r.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&&r.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...a("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:r.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:[r.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),r.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"}),r.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&&r.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...a("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:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),r.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),r.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function Kae({accounts:e,onChanged:t,onNoCopy:n,onShared:s,onElsewhere:a,view:o,onOpen:i,onBack:c,closeButton:d}){const[h,f]=y.useState(!1),[p,m]=y.useState(!1),[w,k]=y.useState(!1),b=Bse(),[v,N]=y.useState(!1),{status:j,manual:S,now:_,busy:T,failure:$,dismissFailure:M,answerGiveBack:O,pressProps:I,load:F,toggle:L,answer:A,dropAddress:q,rename:E,checkOne:D,checkNow:P}=Yse(t,()=>f(!0)),{armed:z,pressUnpair:G}=Xse(A),[V,H]=y.useState(null),[B,W]=y.useState(!1),ee=y.useMemo(()=>Yte(e,j??null),[e,j]),U=y.useMemo(()=>ee.filter(Ne=>Xte(Ne.key,j??null,_)).map(Ne=>Ne.key).sort().join(`
103
+ `),[ee,j,_]);y.useEffect(()=>{n==null||n(U?U.split(`
104
+ `):[])},[U,n]);const Y=y.useMemo(()=>JSON.stringify(tne(ee,j??null)),[ee,j]);y.useEffect(()=>{s==null||s(new Map(JSON.parse(Y)))},[Y,s]);const X=y.useMemo(()=>JSON.stringify(ee.flatMap(Ne=>{const ge=ene(Ne.key,j??null,_);return ge?[[Ne.key,ge]]:[]})),[ee,j,_]);y.useEffect(()=>{a==null||a(new Map(JSON.parse(X)))},[X,a]);const Z=(j==null?void 0:j.enabled)===!0,J=y.useMemo(()=>Fte((j==null?void 0:j.pairingMode)==="invite"&&j?{...j,pending:[]}:j,_),[j,_]),te=V?J.find(Ne=>{var ge;return Ne.fp===V||((ge=Ne.twins)==null?void 0:ge.some(Me=>Me.fp===V))})??null:null;y.useEffect(()=>{V&&j&&!te&&H(null)},[V,j,te]);const{asks:ce,rest:he,live:le,folded:re,troubled:ae,shown:de,paired:_e}=Kte(J,v),fe=Ote(j,_),ye=Gte(j,J),ke=r.jsxs(r.Fragment,{children:[p&&j&&r.jsx(wre,{status:j,manual:S,startWith:p==="invite"?"invite":void 0,onClose:()=>m(!1),onChanged:()=>{F(),t()}}),w&&r.jsx(MD,{title:"How Local network works",steps:ure,finish:Z?void 0:{label:"Turn it on",act:()=>{k(!1),L()}},onClose:()=>k(!1)}),h&&j&&r.jsx(Vae,{status:{...j,manualRows:S},accounts:ee,manual:S,onClose:()=>f(!1),onChanged:()=>{F(),t()}}),B&&r.jsx(jae,{status:j,rows:J,accounts:ee,now:_,covered:!!te||h||!!p||w,onOpenDeck:H,onClose:()=>W(!1)}),te&&j&&r.jsx(Uae,{row:te,source:Lu(j,te),status:j,accounts:ee,now:_,busy:T,onClose:()=>H(null),onRename:Ne=>E(te.fp,Ne),onCheck:()=>D(te.fp),onVerb:()=>{switch(te.kind){case"paired":return A("unpair",te.fp,"unpair that deck");case"nearby":return A("accept",te.fp,"reach that deck");case"declined":return A("allow",te.fp,"let that deck ask again");case"dialling":return q(te.fp);default:return Promise.resolve(null)}},onSettings:()=>{H(null),f(!0)},onInvite:()=>{H(null),m("invite")},twins:(te.twins??[]).map(Ne=>({row:Ne,peer:Lu(j,Ne).peer??null})),onUnpair:Ne=>A("unpair",Ne,"unpair that deck")})]});return o?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Gae,{on:Z,status:j,paired:_e,busy:T,pressProps:I,checkNow:P,setAddOpen:m,setSetupOpen:f,setMapOpen:W,onBack:c,closeButton:d}),r.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:r.jsxs("div",{className:"ap-lan",children:[r.jsxs("div",{className:"ap-policy",children:[r.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":Z,"aria-label":"Sync with paired decks",...I("switch"),onClick:()=>void L(),title:Z?"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:r.jsx("span",{className:"switch-knob"})})]}),r.jsx(jre,{on:Z,status:j}),!Z&&r.jsxs("div",{className:"ap-lan-intro-row",children:[r.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>k(!0),title:"Four pictures: what this does, and what to do on each machine",children:[r.jsx(dre,{}),r.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),r.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),r.jsx(Tu,{film:"localNetwork"})]}),r.jsx("p",{className:`ap-lan-status ${fe.tone}`,role:"status",children:fe.tone==="ok"?"":fe.text}),r.jsx(YD,{line:$,onDismiss:M,onAnswer:O}),Z&&r.jsxs(r.Fragment,{children:[ce.length>0&&r.jsx(vre,{asks:ce,pressProps:I,answer:A}),de.length>0&&r.jsx(bre,{rows:de,pairingMode:j==null?void 0:j.pairingMode,armed:z,pressProps:I,answer:A,dropAddress:q,onUnpair:G,onOpenPeer:H,onInvite:()=>m("invite")}),(le.length>0&&re.length>0||Z&&_e>0)&&r.jsxs("div",{className:"ap-lan-tail",children:[le.length>0&&re.length>0&&r.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":v,onClick:()=>N(Ne=>!Ne),title:v?"Show only the decks that are on":`Show the ${re.length} deck${re.length===1?"":"s"} that are not responding right now`,children:[r.jsx("span",{className:`ap-lan-chev${v?" open":""}`,"aria-hidden":!0,children:"›"}),v?"fewer":`${re.length} more`,!v&&ae>0&&r.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",ae," not responding"]})]}),Z&&_e>0&&r.jsx("span",{className:"ap-lan-checked",children:Pte(j==null?void 0:j.checkedAt,_,T==="check")})]}),he.length===0&&ce.length===0&&!(j!=null&&j.stalled)&&!(j!=null&&j.deaf)&&!(j!=null&&j.lanTunneled)&&r.jsxs(r.Fragment,{children:[r.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."}),r.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>k(!0),children:"How it works"}),r.jsx(Tu,{film:"localNetwork"})]})]})]})}),ke]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(Pae,{entry:ye,rows:J,onOpen:i,onMap:Z?()=>W(!0):void 0,...b}),r.jsx("p",{className:"vis-hidden",role:"status",children:fe.tone==="ok"?"":fe.text}),ke]})}function Yae({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=y.useRef(null),{title:i,shown:c,rest:d}=Fse(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=Yj(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]),xt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children:i}),r.jsx("div",{className:"ap-peek-list",children:c.map(f=>r.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[r.jsx("span",{className:"ap-fold-name",title:f.name,children:f.name}),r.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&&r.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function Xae({peers:e,strained:t,armed:n,threshold:s,open:a,onToggle:o,order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[m,w]=y.useState(!1),k=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(k.current),[]),y.useEffect(()=>{a&&(window.clearTimeout(k.current),w(!1))},[a]);const b=_=>{a||(window.clearTimeout(k.current),k.current=window.setTimeout(()=>w(!0),_))},v=()=>{window.clearTimeout(k.current),k.current=window.setTimeout(()=>w(!1),AD)},N=()=>window.clearTimeout(k.current),j=()=>{window.clearTimeout(k.current),w(!1)},S=Pse(e,{strained:t&&!a,armed:n,threshold:s});return r.jsxs("div",{className:"ap-rest",children:[r.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":a,"aria-controls":a?"ap-rest-panel":void 0,"aria-describedby":m?"ap-rest-peek":void 0,onClick:()=>{j(),o()},onPointerEnter:_=>{_.pointerType==="mouse"&&b(TD)},onPointerLeave:v,onFocus:_=>{_.target.matches(":focus-visible")&&b(0)},onBlur:v,children:[r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),r.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),r.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:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),m&&r.jsx(Yae,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:v}),a&&r.jsx(Zae,{order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function Zae({order:e,choices:t,onOrder:n,allOpen:s,onToggleAll:a,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 r.jsxs("div",{className:"ap-rest-tools",ref:i,children:[r.jsxs("span",{className:"ap-rest-sort",children:[r.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===Wp?void 0:"","data-held":o?"":void 0,children:t.map(h=>r.jsx("option",{value:h.id,children:h.label},h.id))}),r.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:r.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),r.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:a,children:r.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:r.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 Jae(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Qae=1800;function eoe({accounts:e,onClose:t,copyText:n}){nn("share-accounts");const[s,a]=y.useState([]),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,m]=y.useState(!1),[w,k]=y.useState(()=>Math.floor(Date.now()/1e3)),b=y.useRef(null),v=y.useRef(!1),N=pt(t,{focusRef:b}),j=gt(t),S=ea(o!=null,b),_=ea(o==null,b);y.useEffect(()=>{if(!o)return;k(Math.floor(Date.now()/1e3));const P=window.setInterval(()=>k(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(P)},[o]);const T=xse(e),$=vse(e,s),M=$.length===e.length,O=P=>a(z=>bse(z,P)),I=y.useCallback(async()=>{const P=kse($);if(!bn(v.current)||!P)return;v.current=!0,d(!0),f(null),m(!1);const z=await Jae(P).catch(()=>null);if(v.current=!1,d(!1),!(z!=null&&z.ok)){f(cl(z,"the share could not be made"));return}i({blob:z.blob,expiresAt:z.expiresAt,shared:z.shared??[],failed:z.failed??[]})},[e,$]),F=o?CD(o.expiresAt,w):null,L=(F==null?void 0:F.tone)==="gone",A=(o==null?void 0:o.shared.length)??0,q=L?"This share has expired":A===1?"1 account, ready to paste":`${A} accounts, ready to paste`,E=A===1?"this is the password":`this is ${A} passwords`,D=o?L?q:`${q} — ${E}`:"";return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...j,role:"presentation",children:r.jsxs("div",{ref:N,className:"modal sa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("h3",{children:"Share accounts"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body sa-body",children:[r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:D}),o?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:q}),r.jsx("code",{className:"ap-share-blob",children:o.blob}),r.jsxs("div",{className:"ap-share-foot",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(L){_(),S(),i(null),I();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),Qae))},children:L?"make a new share":p?"copied":`copy ${A===1?"the share":"all "+A}`}),r.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:[r.jsx("span",{className:"ap-share-warn",children:E})," · ",r.jsx("span",{className:`ap-share-expiry ${F==null?void 0:F.tone}`,children:F==null?void 0:F.text})]})]}),o.failed.length>0&&r.jsxs("div",{className:"sa-failed",role:"alert",children:[r.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:`}),r.jsx("ul",{className:"sa-list",children:o.failed.map(P=>{var G;const z=!!(P.email&&((G=P.detail)!=null&&G.includes(P.email)));return r.jsxs("li",{children:[!z&&r.jsx("span",{className:"sa-who",children:P.email||`account ${P.num}`}),r.jsx("span",{className:"sa-why",children:P.detail||"could not be exported"})]},`${P.num}-${P.email}`)})})]}),r.jsx("p",{className:"sa-note",children:L?r.jsx(r.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):r.jsxs(r.Fragment,{children:["Paste it into the other deck with ",r.jsx("strong",{children:"+"})," → ",r.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>{_(),i(null),m(!1)},children:"Pick again"}),r.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:"Nothing to share"}),r.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",r.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),r.jsx("div",{className:"sa-actions",children:r.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):r.jsxs("div",{className:"sa-step",children:[r.jsxs("h4",{children:["Which accounts go to the other ",$t,"?"]}),r.jsx("p",{className:`sa-count${$.length?"":" empty"}`,children:jse($.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:T.map(P=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:$.includes(P.num),onChange:()=>O(P.num)}),r.jsx("span",{className:"sa-who",children:P.label}),P.sub&&r.jsx("span",{className:"sa-sub",children:P.sub})]})},P.num))}),h&&r.jsx("p",{className:"aa-err",role:"alert",children:h}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>a(M?e.map(P=>P.num):[]),children:M?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:b,...$n(c,!$.length),onClick:()=>{S(),I()},children:c?"making the share…":$.length===0?"Share":$.length===1?"Share 1 account":`Share ${$.length} accounts`})]})]})]})]})}),document.body)}function XD(e,t){var n;return!e.disabled&&!((n=ii(e,t))!=null&&n.blocksSwitch)}function toe(e,t,n){return e.map(s=>{const a=ii(s,t,n==null?void 0:n(s));return{key:Gs(s),name:s.alias??s.email??`account ${s.num}`,ready:XD(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:Zj(s,t)}})}function noe(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:Zj(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function soe(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const ZD="agent-dag.otherAccountsOrder",JD="agent-dag.otherAccountsOpen";function roe(){const e=Ye(ZD);return typeof e=="string"&&e.length>0&&e.length<=64?e:Wp}function aoe(e){Ze(ZD,e)}function ooe(){const e=Ye(JD);if(!e)return a1;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 a1}function ioe(e){Ze(JD,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function loe(){const[e,t]=y.useState(null),n=y.useRef(null),s=y.useCallback(i=>Rp(n.current)?(n.current=i,t(i),!0):!1,[]),a=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:s,release:a,pressProps:(i,c=!1)=>{const d=ao(e,i);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const coe=8e3,uoe=1800,doe=4e3;function hoe({claim:e,release:t,load:n,clearFailure:s,rescueFocus:a,afterRemove:o}){const[i,c]=y.useState(null),d=(i==null?void 0:i.num)??null,h=y.useRef(i);h.current=i;const[f,p]=y.useState(null),[m,w]=y.useState(""),[k,b]=y.useState(null),v=y.useRef(0);y.useEffect(()=>{if(k==null)return;const U=window.setTimeout(()=>b(null),doe);return()=>window.clearTimeout(U)},[k]);const[N,j]=y.useState(null),[S,_]=y.useState(!1),[T,$]=y.useState(null),[M,O]=y.useState(null),I=y.useCallback(async(U,Y)=>{if(!e(Y))return null;s(),p(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)}),Z=await X.json().catch(()=>null);return Z!=null&&Z.ok||p({text:cl(Z,"command failed",X.status)}),Z}catch{return p({text:"server unreachable"}),null}finally{t()}},[e,t,s]),F=y.useCallback(()=>{c(null),p(null),b(null),j(null),_(!1)},[]),L=(U,Y="first")=>{F(),O(null),c({num:U,view:"menu",start:Y})},A=y.useCallback(U=>{var Z,J;const Y=h.current;if(!Y||U!=null&&Y.num!==U)return;const X=document.getElementById(`ap-menu-${Y.num}`);(X!=null&&X.contains(document.activeElement)||Pn(((Z=document.activeElement)==null?void 0:Z.tagName)??null))&&((J=document.getElementById(`ap-more-${Y.num}`))==null||J.focus()),F()},[F]),q=y.useCallback(U=>p(U),[]),E=(U,Y)=>{w(Y??""),p(null),c({num:U,view:"rename"})},D=U=>w(U),P=U=>{O(null),p(null),c({num:U,view:"move"})},z=U=>O(U),G=async U=>{var X;_(!1);const Y=await I({action:"share",account:U},`share-${U}`);!(Y!=null&&Y.ok)||((X=h.current)==null?void 0:X.num)!==U||(j({num:U,blob:Y.blob,expiresAt:Y.expiresAt}),c({num:U,view:"share"}))},V=async U=>{await ho(U)&&(_(!0),window.setTimeout(()=>_(!1),uoe))},H=async(U,Y)=>{const{commit:X,alias:Z}=Ase(m,Y);if(X){const J=await I({action:"alias",account:U,alias:Z},`alias-${U}`);if(await n(!0),!(J!=null&&J.ok))return}A(U)},B=async(U,Y)=>{var J,te,ce;const X=await I({action:"move",account:U,slot:Y},`move-${U}`),Z=Ese({menuFor:((J=h.current)==null?void 0:J.num)??null,shareFor:(N==null?void 0:N.num)??null},U,X);if(await n(!0),Z){if(Z.menuFor!=null){const le=document.getElementById(`ap-menu-${U}`),re=document.getElementById(`ap-more-${Z.menuFor}`);re&&(le!=null&&le.contains(document.activeElement)||Pn(((te=document.activeElement)==null?void 0:te.tagName)??null))&&re.focus()}((ce=h.current)==null?void 0:ce.num)===U&&F(),b(Z.confirmRemove),Z.shareFor==null&&(j(null),_(!1)),$(Z.swapNote);const he=Z.swapNote;he&&window.setTimeout(()=>$(le=>le===he?null:le),coe),O(null),a(Z.menuFor)}return X};return{menu:i,menuFor:d,menuError:f,aliasDraft:m,confirmRemove:k,share:N,shareCopied:S,slotDraft:M,swapNote:T,showMenu:L,dropMenu:F,closeMenu:A,sayInMenu:q,startRename:E,typeAlias:D,doAlias:H,startMove:P,pickSlot:z,doSlot:async(U,Y,X)=>{if(!X.sends){A(U);return}await B(U,Y)},makeShare:G,copyShare:V,pressRemove:U=>{const Y=Date.now(),X=oi({armedFor:k,target:U,armedAt:v.current,now:Y,gapMs:ai});if(X==="arm"){b(U),v.current=Y;return}X!=="ignore"&&(b(null),I({action:"remove",account:U},`rm-${U}`).then(Z=>{var J;n(!0),Z!=null&&Z.ok&&(o==null||o(Z),((J=h.current)==null?void 0:J.num)===U&&F(),a(null))}))}}}function foe(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const poe="login_expired";function moe(e,t,n){return(e==null?void 0:e.reason)!==poe?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const goe="Removed. Claude Code is still signed in with that expired login, and no other account here was ready to take over — sign in to one from +";function yoe(e){if(!(e!=null&&e.ok))return null;const t=e.movedTo;return t&&Number.isInteger(t.num)?{switched:{num:t.num,name:t.alias??t.email??`account ${t.num}`}}:e.stillExpired?{failure:{text:goe}}:null}function woe({data:e,claim:t,release:n,load:s,sayFailure:a,clearFailure:o,sayInMenu:i,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(w,k,b="panel")=>{if(!t(k))return null;const v=b==="menu"?i:a;v(null);try{const N=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),j=await N.json().catch(()=>null);return j!=null&&j.ok||v({text:i1(j,"command failed",N.status),raw:$u(j)}),j}catch{return v({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(w=>foe(w,e.accounts))},[e]);const p=async(w,k)=>{if(t(`switch-${w}`)){o(),h(null);try{const v=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),N=moe(v,k,w);N?a(N):v!=null&&v.ok?h({num:w,name:k}):a({text:i1(v,"the switch failed"),raw:$u(v),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),c(w)}}},m=y.useCallback((w,k)=>h({num:w,name:k}),[]);return{switched:d,post:f,doSwitch:p,noteSwitched:m}}const xoe=1800;function voe({auto:e,post:t,load:n}){var $;const[s,a]=y.useReducer(Vne,d1),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=(($=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:$.value)??"90",m=s.pick??p,w=Lse(m,p),k=s.custom!=null,b=s.refusal,v=y.useRef(k);return y.useEffect(()=>{var M,O,I;v.current!==k&&(v.current=k,k?((M=h.current)==null||M.focus(),(O=h.current)==null||O.select()):f.current&&((I=c.current)==null||I.focus()),f.current=!1)},[k]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:k,thresholdRefusal:b,thresholdFieldRef:h,proposeThreshold:M=>a({kind:"pick",pick:M}),typeThreshold:M=>a({kind:"type",text:M}),cancelThreshold:M=>{M.key!=="Escape"||M.nativeEvent.isComposing||!s.custom||(M.preventDefault(),M.stopPropagation(),f.current=!0,a({kind:"cancel"}))},leaveThreshold:()=>a({kind:"leave",stored:p}),doThreshold:async(M,O)=>{const I=await Gne(M,O,t);if(I.kind==="refused"){a({kind:"refuse",message:I.message});return}I.kind==="sent"&&(await n(!0),!I.ok)||(f.current=document.activeElement===h.current,a({kind:"settle"}),i(!0),window.setTimeout(()=>{var F;document.activeElement===d.current&&((F=c.current)==null||F.focus()),i(!1)},xoe))}}}const boe=1800;function koe({auto:e,post:t,load:n}){var k;const[s,a]=y.useState(null),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((k=e==null?void 0:e.choice)==null?void 0:k.next)??"room",f=s??h,p=$se(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:c,nextSaveRef:d,proposeNext:b=>a(qne(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&&(a(null),i(!0),window.setTimeout(()=>{var v;document.activeElement===d.current&&((v=c.current)==null||v.focus()),i(!1)},boe))}}}const joe=Object.freeze({text:"couldn't reach the deck server",reload:!0}),Noe=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function kA(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function Soe(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=$u(t.body);return{text:i1(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function Ay(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 Ry=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),My=e=>e==null||typeof e=="string",$y=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function _oe(e){if(!Ry(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return My(e.reason)&&My(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!Ry(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(My)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!$y(n.fetchedAt)||!$y(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!Ry(a)||typeof a.id!="string"||!a.id||s.has(a.id)||typeof a.label!="string"||typeof a.pct!="number"||!Number.isFinite(a.pct)||a.pct<0||a.pct>100||!$y(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const QD=15e3,Coe=3e4;function Eoe(e){const[t,n]=y.useState(null),[s,a]=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(v=!1)=>{if(!p.current||!v&&m.current.size>0)return;const N=++f.current;v&&i(!0);const j=new AbortController;m.current.add(j);const S=window.setTimeout(()=>j.abort(),Coe);try{const[_,T]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:j.signal}),fetch("/api/cswap-auto",{signal:j.signal})]),[$,M]=await Promise.all([_.ok?_.json():null,T.ok?T.json():null]),O=Soe([await kA(_),await kA(T)]);if(!p.current||N!==f.current)return;if($&&!_oe($)){d(I=>Ay(I,{text:"the deck server returned unreadable account data",reload:!0}));return}$&&(n($),e($)),M&&a(M),d(I=>Ay(I,O))}catch{p.current&&N===f.current&&d(_=>Ay(_,j.signal.aborted?Noe:joe))}finally{window.clearTimeout(S),m.current.delete(j),p.current&&N===f.current&&i(!1)}},[e]);y.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),QD),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const v of m.current)v.abort()}),[w]);const k=y.useCallback(v=>d(v),[]),b=y.useCallback(()=>d(null),[]);return{data:t,auto:s,reloading:o,failure:c,load:w,sayFailure:k,clearFailure:b}}const Toe="#ap-rest-entry";function Aoe(e){return[`#${e}`,Toe,...B4(null)]}function Roe(e){const t=y.useRef(null),n=a=>{t.current=a.target.id||null},s=a=>{a.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const a=t.current;if(!(!a||!Pn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of Aoe(a)){const c=document.querySelector(i);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:s}}function Moe({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var Rr,pi,Mr,As;nn("accounts-panel");const i=Dn(),{busy:c,claim:d,release:h,pressProps:f}=loe(),[p,m]=y.useState("accounts"),[w,k]=y.useState(!1),[b,v]=y.useState(null),N=y.useRef(b);N.current=b;const[j,S]=y.useState(!1),[_,T]=y.useState(null),[$,M]=y.useState(!1),[O,I]=y.useState([]),[F,L]=y.useState(!1),[A,q]=y.useState(null),[E,D]=y.useState(ooe),[P,z]=y.useState(roe),[G,V]=y.useState(null),[H,B]=y.useState(!1),W=y.useRef(s);W.current=s;const ee=y.useCallback(me=>{var Be;D(dt=>ate(dt,me.accounts)),(Be=W.current)==null||Be.call(W,me)},[]),{data:U,auto:Y,reloading:X,failure:Z,load:J,sayFailure:te,clearFailure:ce}=Eoe(ee),he=Roe(U),le=y.useCallback(me=>{window.requestAnimationFrame(()=>{var Be;if(Pn(((Be=document.activeElement)==null?void 0:Be.tagName)??null))for(const dt of B4(me)){const At=document.querySelector(dt);if(At){At.focus();return}}})},[]),re=y.useRef(null),ae=hoe({claim:d,release:h,load:J,clearFailure:ce,rescueFocus:le,afterRemove:me=>{var Be;return(Be=re.current)==null?void 0:Be.call(re,me)}}),{menu:de,menuFor:_e,swapNote:fe,showMenu:ye,dropMenu:ke,closeMenu:Ne,sayInMenu:ge}=ae,{switched:Me,post:Ie,doSwitch:We,noteSwitched:Te}=woe({data:U,claim:d,release:h,load:J,sayFailure:te,clearFailure:ce,sayInMenu:ge,rescueFocus:le});re.current=me=>{const Be=yoe(me);Be&&"switched"in Be?Te(Be.switched.num,Be.switched.name):Be&&te(Be.failure)};const at=me=>{T(me),S(!0)},{threshold:Je,thresholdPick:Ve,thresholdCtl:be,thresholdSaved:Oe,thresholdRef:ze,thresholdSaveRef:st,thresholdCustom:ot,thresholdRefusal:Qe,thresholdFieldRef:we,proposeThreshold:Fe,typeThreshold:Xe,cancelThreshold:He,leaveThreshold:ht,doThreshold:Ct}=voe({auto:Y,post:Ie,load:J}),{nextPick:mt,nextCtl:Et,nextSaved:Ot,nextRef:js,nextSaveRef:tr,proposeNext:Ns,doNext:es}=koe({auto:Y,post:Ie,load:J}),Pt=VP();y.useEffect(()=>{ioe(E)},[E]),y.useEffect(()=>{aoe(P)},[P]);const[Ss,pn]=y.useState(()=>new Set),Fn=y.useCallback(me=>pn(new Set(me)),[]),[Ce,Pe]=y.useState(()=>new Map),[Ke,jt]=y.useState(()=>new Map),Nt=me=>{const Be=HT([me])[0].key,dt=Ce.get(Be);return{noCopyWorksNearby:Ss.has(Be),sharedTo:(dt==null?void 0:dt.to)??null,sharedInUse:(dt==null?void 0:dt.inUse)===!0,elsewhere:Ke.get(Be)??null}},Xt=(Rr=U==null?void 0:U.accounts)==null?void 0:Rr.find(me=>me.active),ts=Xt?ii(Xt,Pt,Nt(Xt)):null,pa=Me?(pi=U==null?void 0:U.accounts)==null?void 0:pi.find(me=>me.num===Me.num):void 0,Bn=pa?Nt(pa).elsewhere:null,qn=Bn!=null&&Bn.length?`. Also active on ${tD(Bn)}: when one machine renews this login, the other is signed out.`:"",_s=(U==null?void 0:U.accounts)??[],rn=Xt?_s.filter(me=>!me.active):[],ma=sD(rn),nr=tte(P,rn),Zt=r1(ete(rn,nr,me=>XD(me,Pt),Pt),G),ns=y.useRef(!1),Un=y.useRef(!1),sr=y.useRef(!1),rr=y.useCallback(()=>{!ns.current&&!Un.current&&!sr.current&&V(null)},[]),ft=()=>V(me=>me??Zt.map(Gs)),ga={onPointerEnter:()=>{ns.current=!0,ft()},onPointerLeave:()=>{ns.current=!1,rr()},onFocus:me=>{me.target.matches(":focus-visible")&&(Un.current=!0,ft())},onBlur:me=>{me.currentTarget.contains(me.relatedTarget)||(Un.current=!1,rr())}},Cs=_e!=null&&rn.some(me=>me.num===_e)||b!=null&&rn.some(me=>me.num===b.num);y.useEffect(()=>{sr.current=Cs,Cs||rr()},[Cs,rr]);const _r=H&&rn.length>0;y.useEffect(()=>{_r||(ns.current=Un.current=sr.current=!1,V(null))},[_r]);const Tt=y.useRef(!1);y.useEffect(()=>{Tt.current&&rn.length===0&&le(null),Tt.current=rn.length>0},[rn.length,le]);const Cr=Zt.length?_s.filter(me=>me.active):_s,ar=toe(Zt,Pt,Nt),Es=noe(Xt,Je,Pt),Jt=soe(Y),Er=me=>H&&Zt.some(Be=>Be.num===me)?"ap-rest-list":"ap-scroll",mn=(me,Be="first")=>{ye(me,Be),v(null)},ya=(me,Be)=>{ke(),v(dt=>(dt==null?void 0:dt.anchor)===Be?null:{num:me,anchor:Be})},Vl=y.useCallback((me=!1)=>{var dt;const Be=N.current;me&&Be&&((dt=document.getElementById(Be.anchor))==null||dt.focus()),v(null)},[]),Gl=()=>{ke(),v(null),m("lan")},Tr=y.useRef(p);y.useEffect(()=>{Tr.current!==p&&(Tr.current=p,window.requestAnimationFrame(()=>{var me;(me=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||me.focus()}))},[p]),y.useEffect(()=>{U!=null&&U.ok&&k(!0)},[U==null?void 0:U.ok]),y.useEffect(()=>{!a||!w||(Gl(),o==null||o())},[a,w]),y.useEffect(()=>{t&&(ke(),v(null))},[t,ke]),y.useEffect(()=>{de&&(U!=null&&U.accounts)&&!U.accounts.some(me=>me.num===de.num)&&ke(),b&&(U!=null&&U.accounts)&&!U.accounts.some(me=>me.num===b.num)&&v(null)},[U,de,b,ke]),y.useEffect(()=>{A==null||!(U!=null&&U.accounts)||U.accounts.some(me=>me.num===A.num)||(q(null),le(null))},[U,A,le]);const Ts=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:kn("Close","A",i),children:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),or=me=>{var xa;const Be=rD(E,me),dt=_e===me.num,At=(Z==null?void 0:Z.row)===me.num?Z:null,rt=(Me==null?void 0:Me.num)===me.num,$r=(fe==null?void 0:fe.at)===me.num?fe:null,mo=$r?_s.find(Lr=>Lr.num===$r.displaced):void 0,wa=(b==null?void 0:b.anchor)===`ap-issue-${me.num}`;return r.jsx(one,{a:me,nowSec:Pt,lan:Nt(me),opened:Be,onToggleLanes:()=>D(Lr=>ste(Lr,me)),busy:c,pressProps:f,onSwitch:We,menuOpen:dt,onOpenMenu:mn,onCloseMenu:Ne,refusal:At,onDismissRefusal:()=>ce(),onSignIn:at,switchedHere:rt,swapped:$r,displaced:mo,issueExpanded:wa,onOpenIssue:ya,sortKey:me.active?null:Qee(nr),home:Sy(me,(xa=Y==null?void 0:Y.choice)==null?void 0:xa.home)?Une(me,!!(Y!=null&&Y.enabled)):null,rotating:!!(Y!=null&&Y.enabled||Y!=null&&Y.external)},me.num)},Ar=U!=null&&U.ok&&(Y!=null&&Y.ok)?r.jsx(Kne,{auto:Y,threshold:Je,thresholdPick:Ve,thresholdCtl:be,thresholdSaved:Oe,thresholdRef:ze,thresholdSaveRef:st,thresholdCustom:ot,thresholdRefusal:Qe,thresholdFieldRef:we,proposeThreshold:Fe,typeThreshold:Xe,cancelThreshold:He,leaveThreshold:ht,doThreshold:Ct,nextPick:mt,nextCtl:Et,nextSaved:Ot,nextRef:js,nextSaveRef:tr,proposeNext:Ns,doNext:es,pressProps:f,post:Ie,load:J}):null;return r.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:he.onFocus,onBlur:he.onBlur,children:[p==="accounts"&&r.jsx(lne,{canShare:(((Mr=U==null?void 0:U.accounts)==null?void 0:Mr.length)??0)>0,canReport:(((As=U==null?void 0:U.accounts)==null?void 0:As.length)??0)>1||$,onAdd:()=>S(!0),onReport:()=>{I([...Cr,...Zt].map(Gs)),M(!0)},onShareSet:()=>L(!0),onReload:()=>J(!0),pressProps:f,reloading:X,closeButton:Ts}),p==="accounts"&&r.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[U==null?Z?r.jsxs("div",{className:"ap-empty",role:"alert",children:[r.jsx("span",{title:Z.raw||void 0,children:Z.text}),r.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",QD/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",X),onClick:()=>J(!0).then(()=>le(null)),children:X?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):U.ok?r.jsxs(r.Fragment,{children:[Xt&&(ts==null?void 0:ts.tone)==="warn"&&r.jsxs("div",{className:"ap-notice",children:[r.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(Xt.num,"ap-notice"),children:[r.jsx(Xj,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),ts.fix&&r.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"})]}),r.jsx("ul",{className:"ap-list",children:Cr.map(or)}),Zt.length>0&&r.jsx(Xae,{peers:ar,strained:Es,armed:Jt,threshold:Y!=null&&Y.ok?Je:null,open:H,onToggle:()=>B(me=>!me),order:nr,choices:ma,onOrder:z,allOpen:aD(E,Zt),onToggleAll:()=>D(me=>rte(me,Zt)),held:G!=null}),Zt.length>0&&H&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...ga,children:Zt.map(or)}),Ar]}),Zt.length===0&&Ar,Z&&Z.row==null&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",title:Z.raw||void 0,children:Z.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>ce(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),de&&(()=>{var Be,dt;const me=(Be=U.accounts)==null?void 0:Be.find(At=>At.num===de.num);return me?r.jsx(Ise,{a:me,accountMenu:ae,slots:(U.accounts??[]).map(At=>At.num),boundaryId:Er(me.num),nowSec:Pt,busy:c,pressProps:f,rotating:!!(Y!=null&&Y.enabled||Y!=null&&Y.external),onProjects:()=>{q({num:me.num,name:me.alias??me.email??`account ${me.num}`}),Ne(me.num)},onRotation:()=>Ie({action:"account",account:me.num,enabled:me.disabled},`rot-${me.num}`,"menu").then(At=>{J(!0),At!=null&&At.ok&&Ne(me.num)}),home:Sy(me,(dt=Y==null?void 0:Y.choice)==null?void 0:dt.home),canSetHome:!!(Y!=null&&Y.enabled)&&!(Y!=null&&Y.external),onHome:()=>{var At;return Ie({action:"home",account:Sy(me,(At=Y==null?void 0:Y.choice)==null?void 0:At.home)?null:me.num},`home-${me.num}`,"menu").then(rt=>{J(!0),rt!=null&&rt.ok&&Ne(me.num)})}}):null})(),b&&(()=>{var dt;const me=(dt=U.accounts)==null?void 0:dt.find(At=>At.num===b.num),Be=me?ii(me,Pt,Nt(me)):null;return!me||!Be?null:r.jsx(Bee,{anchorId:b.anchor,boundaryId:b.anchor==="ap-notice"?"ap-scroll":Er(me.num),issue:Be,who:me.alias??me.email??`account ${me.num}`,fetchedAt:me.fetchedAt,nowSec:Pt,onClose:Vl,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:Be.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Be.text}. ${Be.hint}`}))})})()]}):r.jsx(ine,{data:U}),r.jsx("div",{className:"film-foot",children:r.jsx(Tu,{film:"claudeAccounts"})})]}),r.jsxs("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:[Me?`Now active: ${Me.name}`:"",Me?qn:""]}),w&&r.jsx(Kae,{accounts:HT((U==null?void 0:U.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Fn,onShared:Pe,onElsewhere:jt,view:p==="lan",onOpen:Gl,onBack:()=>m("accounts"),closeButton:Ts}),j&&r.jsx(ED,{email:_,onClose:()=>{S(!1),T(null)},onChanged:()=>J(!0)}),F&&r.jsx(eoe,{accounts:((U==null?void 0:U.accounts)??[]).map(me=>({num:me.num,email:me.email,alias:me.alias,org:me.org})),onClose:()=>L(!1),copyText:ho}),A!=null&&(()=>{var Be;const me=(Be=U==null?void 0:U.accounts)==null?void 0:Be.find(dt=>dt.num===A.num);return U!=null&&U.accounts&&!me?null:r.jsx(Dee,{num:A.num,name:me?me.alias??me.email??`account ${me.num}`:A.name,onClose:()=>q(null)})})(),$&&r.jsx(Dne,{accounts:(U==null?void 0:U.accounts)??null,order:O,failed:Z!=null&&Z.reload?Z.text:null,nowSec:Pt,onClose:()=>M(!1)})]})}function $oe({width:e,children:t}){const n=y.useRef(null);return y.useLayoutEffect(()=>{var s;for(const a of Array.from(((s=n.current)==null?void 0:s.children)??[]))a.inert=a.classList.contains("leaving")}),r.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 Loe=16,Ioe=120;function Ooe(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 Poe(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 Doe(e,t){return Ooe(e,t,Loe)?"over":Poe(e,t)<=Ioe?"near":"far"}function Foe(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 Boe(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[a,o]=y.useState("far"),i=y.useRef(null),c=ll(e,140),d=y.useCallback(m=>{var b;const w=(b=i.current)==null?void 0:b.getBoundingClientRect(),k=Foe(m);return w&&k?Doe(k,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 k=w&&d(m)==="over";return t(!1),k},[d]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const qoe=420;function Uoe(){const[e,t]=y.useState(!1),n=y.useRef(null),s=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),a=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),qoe+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const uN=11;function e5(e=0){return uN+Math.min(0,e)}const t5=7.2,n5=6.6,Woe={width:104,height:48},jA={width:96,height:44},s5={width:220,height:103};function Hoe(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)?s5:{width:Math.max(160,t),height:Math.max(72,n)}}function Ly(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function zoe(e,t,n=s5,s=uN){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=n5?"detail":Ly(n,t,jA)?"compact":"overview":a>=t5?"detail":e==="compact"?Ly(n,t,jA)?"compact":"overview":Ly(n,t,Woe)?"compact":"overview"}function Voe(e,t,n=uN){return e>=t5/n?e:Math.max(e,Math.min(t,n5/n-.001))}const Goe=.8,Koe=1;function Yoe({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:s}){const[a,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 k of e.current.agents.keys()){const b=t.current.get(k);b&&p.push(b)}const m=Hoe(p);return c.current={version:f,card:m},m},[]),h=y.useCallback(f=>{var m;const p=zoe(i.current,f,d(),e5(Pj[Dj()]));return p===i.current?null:(i.current=p,(m=s.current)==null||m.setAttribute("data-lod",p),o(p),p)},[d,s]);return{lod:a,lodRef:i,applyZoom:h}}const Xoe=40,Zoe=120;function Joe(e,t){let n=null,s=0,a=Number.NEGATIVE_INFINITY;const o=()=>{n=null,a=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=Xoe){const h=t.now(),f=Math.max(a+d,h);if(f<=h){i(),o();return}c(f,h,d)},replay(d=Zoe){i(),s=t.now()+d,n=t.setTimeout(o,d)},flush(){i(),o()},cancel(){i()}}}const Qoe=1024*1024,NA=5,r5=.8,x1=24,eie="agent-dag.soundCustom.done",tie="agent-dag.soundCustom.needs-input",iu={done:eie,"needs-input":tie};function Iu(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function SA(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function nie(e){return{done:SA(e(iu.done)),"needs-input":SA(e(iu["needs-input"]))}}function sie(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function rie(e){return e.done&&e.done===e["needs-input"]?e.done:null}const aie={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},a5=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function o5(e,t){const n=t.toLowerCase().split(";")[0].trim();if(a5.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return aie[s]??n}function _A(e,t){const n=o5(e.name,e.type);if(!a5.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>Qoe)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>NA)return`Audio must be ${NA} seconds or shorter.`}return null}function v1(e){return e>=x1?`There are already ${x1} custom sounds. Delete one first.`:null}function oie(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function iie(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,r5/t)}function i5(){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 lie(e,t,n=i5()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",a=_A({name:s,type:e.type,size:e.size});if(a)throw new Error(a);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=_A({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:o5(s,e.type),duration:i.duration,normalizationGain:iie(d),bytes:o}}function cie(e,t=i5()){const n=e.name.trim()||"Custom voice",s=e.text.trim();if(!s)throw new Error("Enter the words this voice should say.");const a=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,a)),pitch:Math.min(2,Math.max(.5,o))}}const uie="ccdeck-notification-audio",die=2,Zs="assets",kr="summaries";function Gu(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function hie(){return new Promise((e,t)=>{const n=indexedDB.open(uie,die);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Zs)?n.transaction.objectStore(Zs):a.createObjectStore(Zs,{keyPath:"id"});if(a.objectStoreNames.contains(kr))return;const i=a.createObjectStore(kr,{keyPath:"id"});if(s.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(i.put(Iu(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Ku(e,t,n){const s=await hie();try{return await new Promise((a,o)=>{const i=s.transaction(e,t),c=n(i),d=()=>o(i.error??new Error("Local audio storage failed."));i.oncomplete=()=>a(c?c.result:void 0),i.onerror=d,i.onabort=d})}finally{s.close()}}async function fie(){const e=Gu();return e?e.list():typeof indexedDB>"u"?[]:await Ku([kr],"readonly",t=>t.objectStore(kr).getAll())??[]}async function pie(e){const t=Gu();return t?t.get(e):typeof indexedDB>"u"?null:await Ku([Zs],"readonly",n=>n.objectStore(Zs).get(e))??null}async function CA(e){const t=Gu();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Ku([Zs,kr],"readwrite",n=>{n.objectStore(Zs).put(e),n.objectStore(kr).put(Iu(e))})}async function mie(e,t){const n=Gu();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 Ku([Zs,kr],"readwrite",s=>{const a=s.objectStore(Zs),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const c={...i,name:t};a.put(c),s.objectStore(kr).put(Iu(c))}})}async function gie(e){const t=Gu();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Ku([Zs,kr],"readwrite",n=>{n.objectStore(Zs).delete(e),n.objectStore(kr).delete(e)})}const lu=["done","needs-input"],yie=[{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}]}],wie=[{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}]}],dN={done:yie,"needs-input":wie},Zn="two";function b1(e,t){const n=dN[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Zn)??n[0]}function l5(e,t){return dN[e].some(s=>s.id===t)?t:Zn}b1("done",Zn).notes,b1("needs-input",Zn).notes;const EA=.04,c5=.24,df=0,tp=100,hN=5,li=50;function Xp(e,t=hN){if(!Number.isFinite(e))return li;const n=Math.round(e/t)*t;return Math.min(tp,Math.max(df,n))}function u5(e,t=hN){if(e==null)return li;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?Xp(Number(n),t):li}function fN(e){const t=Xp(e),n=EA+(c5-EA)*(t/tp);return Math.round(n*1e4)/1e4}function xie(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(fN(e)*s*1e4)/1e4}const vie=.012,TA=1e-4;function bie(e){return Math.min(1,fN(e)/c5)}function kie(e,t){const n=e*(fN(t)/r5);return Math.max(1e-4,n)}const jie=160,Nie="agent-dag.soundLevel.done",Sie="agent-dag.soundLevel.needs-input",_ie="agent-dag.soundFigure.done",Cie="agent-dag.soundFigure.needs-input",d5={done:Nie,"needs-input":Sie},np={done:_ie,"needs-input":Cie},AA={done:{level:li,figure:Zn},"needs-input":{level:li,figure:Zn}};function Eie(e){const t=n=>({level:u5(e(d5[n])),figure:l5(n,e(np[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function Tie(e,t){return(e??AA)[t]??AA[t]}const Aie={Stop:"done",Notification:"needs-input"};function Rie(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:Gt(Aie,n)??null}const Mie=6,$ie="ccdeck-tabs";function Lie(e){return e>=Mie}function Iie(e,t,n){const s=a=>{const o=a.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(a,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)},a)})},leave(){var a;e.removeEventListener("message",s),(a=e.close)==null||a.call(e)}}}function Oie({stateRef:e,rerender:t,pauseGate:n,chimesRef:s,desktopUpdateRef:a}){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 k=new EventSource("/events"),b=Joe(t,{now:()=>Date.now(),setTimeout:(S,_)=>window.setTimeout(S,_),clearTimeout:S=>window.clearTimeout(S)});let v=!1;const N=typeof BroadcastChannel=="function"?Iie(new BroadcastChannel($ie),Math.random().toString(36).slice(2),()=>v):null,j=window.setInterval(()=>{v||!N||N.ask(600).then(S=>{v||d(Lie(S))})},3e3);return k.addEventListener("open",()=>{i(!0),f(!0)}),k.addEventListener("error",()=>{i(!1),w(null)}),k.addEventListener("open",()=>{v=!0,d(!1)}),k.addEventListener("error",()=>{v=!1}),k.addEventListener("replay-end",()=>{p.current=!1,b.flush(),w(Date.now())}),k.addEventListener("desktop-update",S=>a.current(S.data)),k.addEventListener("hook",S=>{var _;try{const T=JSON.parse(S.data);if(!n.accept(T))return;e.current=i4(e.current,T);const $=T.replay===!0||p.current||Date.now()-T.receivedAt>3e4;$?b.replay():b.live();const M=Rie(T,$);M&&((_=s.current)==null||_.play(M))}catch{}}),()=>{k.close(),b.cancel(),window.clearInterval(j),N==null||N.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:m}}const Pie=200,Die=5*6e4,Fie=6,Bie=2*6e4;function Hh(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function qie(e,t){let n=!1;for(const a of e)if(!t.has(a)){n=!0;break}if(!n)return e;const s=new Set;for(const a of e)t.has(a)&&s.add(a);return s}function Uie(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(kj(n.id));return t}function Wie(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(kj(n.id));return t}function Hie(e,t){let n=F9(e,t,dE);B9(e,t,dE)&&(n=!0);const s=[],a=o=>{s.push(o)};return O9(e,t,Pie,Die,a)&&(n=!0),P9(e,t,Fie,Bie,a)&&(n=!0),{changed:n,forgotten:s}}function zie(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 a=null;for(const o of s)a=o;return{ids:s,primary:a}}function Vie(e,t){const[n,s]=y.useState(()=>({ids:new Set,primary:null})),{ids:a,primary:o}=n,i=y.useCallback((h,f,p=!f)=>{s(m=>zie(m,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{s({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{s(h=>{const f=qie(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:a,primarySelectedId:o,selectAgent:i,clearSelection:c,pruneSelectionToBoard:d}}function Gie({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:s,setSummaryFor:a}){const[o,i]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();i(d);const{changed:h,forgotten:f}=Hie(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),a(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function pN(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 Iy,RA;function Kie(){if(RA)return Iy;RA=1;function e(){this.__data__=[],this.size=0}return Iy=e,Iy}var Oy,MA;function Bl(){if(MA)return Oy;MA=1;function e(t,n){return t===n||t!==t&&n!==n}return Oy=e,Oy}var Py,$A;function Zp(){if($A)return Py;$A=1;var e=Bl();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Py=t,Py}var Dy,LA;function Yie(){if(LA)return Dy;LA=1;var e=Zp(),t=Array.prototype,n=t.splice;function s(a){var o=this.__data__,i=e(o,a);if(i<0)return!1;var c=o.length-1;return i==c?o.pop():n.call(o,i,1),--this.size,!0}return Dy=s,Dy}var Fy,IA;function Xie(){if(IA)return Fy;IA=1;var e=Zp();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Fy=t,Fy}var By,OA;function Zie(){if(OA)return By;OA=1;var e=Zp();function t(n){return e(this.__data__,n)>-1}return By=t,By}var qy,PA;function Jie(){if(PA)return qy;PA=1;var e=Zp();function t(n,s){var a=this.__data__,o=e(a,n);return o<0?(++this.size,a.push([n,s])):a[o][1]=s,this}return qy=t,qy}var Uy,DA;function Jp(){if(DA)return Uy;DA=1;var e=Kie(),t=Yie(),n=Xie(),s=Zie(),a=Jie();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=a,Uy=o,Uy}var Wy,FA;function Qie(){if(FA)return Wy;FA=1;var e=Jp();function t(){this.__data__=new e,this.size=0}return Wy=t,Wy}var Hy,BA;function ele(){if(BA)return Hy;BA=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Hy=e,Hy}var zy,qA;function tle(){if(qA)return zy;qA=1;function e(t){return this.__data__.get(t)}return zy=e,zy}var Vy,UA;function nle(){if(UA)return Vy;UA=1;function e(t){return this.__data__.has(t)}return Vy=e,Vy}var Gy,WA;function h5(){if(WA)return Gy;WA=1;var e=typeof yh=="object"&&yh&&yh.Object===Object&&yh;return Gy=e,Gy}var Ky,HA;function er(){if(HA)return Ky;HA=1;var e=h5(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Ky=n,Ky}var Yy,zA;function ql(){if(zA)return Yy;zA=1;var e=er(),t=e.Symbol;return Yy=t,Yy}var Xy,VA;function sle(){if(VA)return Xy;VA=1;var e=ql(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function o(i){var c=n.call(i,a),d=i[a];try{i[a]=void 0;var h=!0}catch{}var f=s.call(i);return h&&(c?i[a]=d:delete i[a]),f}return Xy=o,Xy}var Zy,GA;function rle(){if(GA)return Zy;GA=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Zy=n,Zy}var Jy,KA;function ui(){if(KA)return Jy;KA=1;var e=ql(),t=sle(),n=rle(),s="[object Null]",a="[object Undefined]",o=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?a:s:o&&o in Object(c)?t(c):n(c)}return Jy=i,Jy}var Qy,YA;function bs(){if(YA)return Qy;YA=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Qy=e,Qy}var ew,XA;function Yu(){if(XA)return ew;XA=1;var e=ui(),t=bs(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",o="[object Proxy]";function i(c){if(!t(c))return!1;var d=e(c);return d==s||d==a||d==n||d==o}return ew=i,ew}var tw,ZA;function ale(){if(ZA)return tw;ZA=1;var e=er(),t=e["__core-js_shared__"];return tw=t,tw}var nw,JA;function ole(){if(JA)return nw;JA=1;var e=ale(),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 nw=n,nw}var sw,QA;function f5(){if(QA)return sw;QA=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 sw=n,sw}var rw,eR;function ile(){if(eR)return rw;eR=1;var e=Yu(),t=ole(),n=bs(),s=f5(),a=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,d=i.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(a,"\\$&").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 rw=p,rw}var aw,tR;function lle(){if(tR)return aw;tR=1;function e(t,n){return t==null?void 0:t[n]}return aw=e,aw}var ow,nR;function di(){if(nR)return ow;nR=1;var e=ile(),t=lle();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return ow=n,ow}var iw,sR;function mN(){if(sR)return iw;sR=1;var e=di(),t=er(),n=e(t,"Map");return iw=n,iw}var lw,rR;function Qp(){if(rR)return lw;rR=1;var e=di(),t=e(Object,"create");return lw=t,lw}var cw,aR;function cle(){if(aR)return cw;aR=1;var e=Qp();function t(){this.__data__=e?e(null):{},this.size=0}return cw=t,cw}var uw,oR;function ule(){if(oR)return uw;oR=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return uw=e,uw}var dw,iR;function dle(){if(iR)return dw;iR=1;var e=Qp(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(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 dw=a,dw}var hw,lR;function hle(){if(lR)return hw;lR=1;var e=Qp(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return hw=s,hw}var fw,cR;function fle(){if(cR)return fw;cR=1;var e=Qp(),t="__lodash_hash_undefined__";function n(s,a){var o=this.__data__;return this.size+=this.has(s)?0:1,o[s]=e&&a===void 0?t:a,this}return fw=n,fw}var pw,uR;function ple(){if(uR)return pw;uR=1;var e=cle(),t=ule(),n=dle(),s=hle(),a=fle();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=a,pw=o,pw}var mw,dR;function mle(){if(dR)return mw;dR=1;var e=ple(),t=Jp(),n=mN();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return mw=s,mw}var gw,hR;function gle(){if(hR)return gw;hR=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return gw=e,gw}var yw,fR;function em(){if(fR)return yw;fR=1;var e=gle();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return yw=t,yw}var ww,pR;function yle(){if(pR)return ww;pR=1;var e=em();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return ww=t,ww}var xw,mR;function wle(){if(mR)return xw;mR=1;var e=em();function t(n){return e(this,n).get(n)}return xw=t,xw}var vw,gR;function xle(){if(gR)return vw;gR=1;var e=em();function t(n){return e(this,n).has(n)}return vw=t,vw}var bw,yR;function vle(){if(yR)return bw;yR=1;var e=em();function t(n,s){var a=e(this,n),o=a.size;return a.set(n,s),this.size+=a.size==o?0:1,this}return bw=t,bw}var kw,wR;function gN(){if(wR)return kw;wR=1;var e=mle(),t=yle(),n=wle(),s=xle(),a=vle();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=a,kw=o,kw}var jw,xR;function ble(){if(xR)return jw;xR=1;var e=Jp(),t=mN(),n=gN(),s=200;function a(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 jw=a,jw}var Nw,vR;function tm(){if(vR)return Nw;vR=1;var e=Jp(),t=Qie(),n=ele(),s=tle(),a=nle(),o=ble();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=a,i.prototype.set=o,Nw=i,Nw}var Sw,bR;function yN(){if(bR)return Sw;bR=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a&&n(t[s],s,t)!==!1;);return t}return Sw=e,Sw}var _w,kR;function p5(){if(kR)return _w;kR=1;var e=di(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return _w=t,_w}var Cw,jR;function nm(){if(jR)return Cw;jR=1;var e=p5();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Cw=t,Cw}var Ew,NR;function sm(){if(NR)return Ew;NR=1;var e=nm(),t=Bl(),n=Object.prototype,s=n.hasOwnProperty;function a(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 Ew=a,Ew}var Tw,SR;function Xu(){if(SR)return Tw;SR=1;var e=sm(),t=nm();function n(s,a,o,i){var c=!o;o||(o={});for(var d=-1,h=a.length;++d<h;){var f=a[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 Tw=n,Tw}var Aw,_R;function kle(){if(_R)return Aw;_R=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Aw=e,Aw}var Rw,CR;function Sr(){if(CR)return Rw;CR=1;function e(t){return t!=null&&typeof t=="object"}return Rw=e,Rw}var Mw,ER;function jle(){if(ER)return Mw;ER=1;var e=ui(),t=Sr(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Mw=s,Mw}var $w,TR;function Zu(){if(TR)return $w;TR=1;var e=jle(),t=Sr(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!a.call(i,"callee")};return $w=o,$w}var Lw,AR;function Ut(){if(AR)return Lw;AR=1;var e=Array.isArray;return Lw=e,Lw}var Kc={exports:{}},Iw,RR;function Nle(){if(RR)return Iw;RR=1;function e(){return!1}return Iw=e,Iw}Kc.exports;var MR;function Ul(){return MR||(MR=1,(function(e,t){var n=er(),s=Nle(),a=t&&!t.nodeType&&t,o=a&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===a,c=i?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||s;e.exports=h})(Kc,Kc.exports)),Kc.exports}var Ow,$R;function rm(){if($R)return Ow;$R=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var o=typeof s;return a=a??e,!!a&&(o=="number"||o!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return Ow=n,Ow}var Pw,LR;function wN(){if(LR)return Pw;LR=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Pw=t,Pw}var Dw,IR;function Sle(){if(IR)return Dw;IR=1;var e=ui(),t=wN(),n=Sr(),s="[object Arguments]",a="[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]",k="[object String]",b="[object WeakMap]",v="[object ArrayBuffer]",N="[object DataView]",j="[object Float32Array]",S="[object Float64Array]",_="[object Int8Array]",T="[object Int16Array]",$="[object Int32Array]",M="[object Uint8Array]",O="[object Uint8ClampedArray]",I="[object Uint16Array]",F="[object Uint32Array]",L={};L[j]=L[S]=L[_]=L[T]=L[$]=L[M]=L[O]=L[I]=L[F]=!0,L[s]=L[a]=L[v]=L[o]=L[N]=L[i]=L[c]=L[d]=L[h]=L[f]=L[p]=L[m]=L[w]=L[k]=L[b]=!1;function A(q){return n(q)&&t(q.length)&&!!L[e(q)]}return Dw=A,Dw}var Fw,OR;function am(){if(OR)return Fw;OR=1;function e(t){return function(n){return t(n)}}return Fw=e,Fw}var Yc={exports:{}};Yc.exports;var PR;function xN(){return PR||(PR=1,(function(e,t){var n=h5(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o&&n.process,c=(function(){try{var d=a&&a.require&&a.require("util").types;return d||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(Yc,Yc.exports)),Yc.exports}var Bw,DR;function Ju(){if(DR)return Bw;DR=1;var e=Sle(),t=am(),n=xN(),s=n&&n.isTypedArray,a=s?t(s):e;return Bw=a,Bw}var qw,FR;function m5(){if(FR)return qw;FR=1;var e=kle(),t=Zu(),n=Ut(),s=Ul(),a=rm(),o=Ju(),i=Object.prototype,c=i.hasOwnProperty;function d(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),k=!p&&!m&&!w&&o(h),b=p||m||w||k,v=b?e(h.length,String):[],N=v.length;for(var j in h)(f||c.call(h,j))&&!(b&&(j=="length"||w&&(j=="offset"||j=="parent")||k&&(j=="buffer"||j=="byteLength"||j=="byteOffset")||a(j,N)))&&v.push(j);return v}return qw=d,qw}var Uw,BR;function om(){if(BR)return Uw;BR=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Uw=t,Uw}var Ww,qR;function g5(){if(qR)return Ww;qR=1;function e(t,n){return function(s){return t(n(s))}}return Ww=e,Ww}var Hw,UR;function _le(){if(UR)return Hw;UR=1;var e=g5(),t=e(Object.keys,Object);return Hw=t,Hw}var zw,WR;function vN(){if(WR)return zw;WR=1;var e=om(),t=_le(),n=Object.prototype,s=n.hasOwnProperty;function a(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 zw=a,zw}var Vw,HR;function ha(){if(HR)return Vw;HR=1;var e=Yu(),t=wN();function n(s){return s!=null&&t(s.length)&&!e(s)}return Vw=n,Vw}var Gw,zR;function po(){if(zR)return Gw;zR=1;var e=m5(),t=vN(),n=ha();function s(a){return n(a)?e(a):t(a)}return Gw=s,Gw}var Kw,VR;function Cle(){if(VR)return Kw;VR=1;var e=Xu(),t=po();function n(s,a){return s&&e(a,t(a),s)}return Kw=n,Kw}var Yw,GR;function Ele(){if(GR)return Yw;GR=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Yw=e,Yw}var Xw,KR;function Tle(){if(KR)return Xw;KR=1;var e=bs(),t=om(),n=Ele(),s=Object.prototype,a=s.hasOwnProperty;function o(i){if(!e(i))return n(i);var c=t(i),d=[];for(var h in i)h=="constructor"&&(c||!a.call(i,h))||d.push(h);return d}return Xw=o,Xw}var Zw,YR;function hi(){if(YR)return Zw;YR=1;var e=m5(),t=Tle(),n=ha();function s(a){return n(a)?e(a,!0):t(a)}return Zw=s,Zw}var Jw,XR;function Ale(){if(XR)return Jw;XR=1;var e=Xu(),t=hi();function n(s,a){return s&&e(a,t(a),s)}return Jw=n,Jw}var Xc={exports:{}};Xc.exports;var ZR;function y5(){return ZR||(ZR=1,(function(e,t){var n=er(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.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})(Xc,Xc.exports)),Xc.exports}var Qw,JR;function w5(){if(JR)return Qw;JR=1;function e(t,n){var s=-1,a=t.length;for(n||(n=Array(a));++s<a;)n[s]=t[s];return n}return Qw=e,Qw}var ex,QR;function x5(){if(QR)return ex;QR=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,o=0,i=[];++s<a;){var c=t[s];n(c,s,t)&&(i[o++]=c)}return i}return ex=e,ex}var tx,e2;function v5(){if(e2)return tx;e2=1;function e(){return[]}return tx=e,tx}var nx,t2;function bN(){if(t2)return nx;t2=1;var e=x5(),t=v5(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,o=a?function(i){return i==null?[]:(i=Object(i),e(a(i),function(c){return s.call(i,c)}))}:t;return nx=o,nx}var sx,n2;function Rle(){if(n2)return sx;n2=1;var e=Xu(),t=bN();function n(s,a){return e(s,t(s),a)}return sx=n,sx}var rx,s2;function kN(){if(s2)return rx;s2=1;function e(t,n){for(var s=-1,a=n.length,o=t.length;++s<a;)t[o+s]=n[s];return t}return rx=e,rx}var ax,r2;function im(){if(r2)return ax;r2=1;var e=g5(),t=e(Object.getPrototypeOf,Object);return ax=t,ax}var ox,a2;function b5(){if(a2)return ox;a2=1;var e=kN(),t=im(),n=bN(),s=v5(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var c=[];i;)e(c,n(i)),i=t(i);return c}:s;return ox=o,ox}var ix,o2;function Mle(){if(o2)return ix;o2=1;var e=Xu(),t=b5();function n(s,a){return e(s,t(s),a)}return ix=n,ix}var lx,i2;function k5(){if(i2)return lx;i2=1;var e=kN(),t=Ut();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return lx=n,lx}var cx,l2;function j5(){if(l2)return cx;l2=1;var e=k5(),t=bN(),n=po();function s(a){return e(a,n,t)}return cx=s,cx}var ux,c2;function $le(){if(c2)return ux;c2=1;var e=k5(),t=b5(),n=hi();function s(a){return e(a,n,t)}return ux=s,ux}var dx,u2;function Lle(){if(u2)return dx;u2=1;var e=di(),t=er(),n=e(t,"DataView");return dx=n,dx}var hx,d2;function Ile(){if(d2)return hx;d2=1;var e=di(),t=er(),n=e(t,"Promise");return hx=n,hx}var fx,h2;function N5(){if(h2)return fx;h2=1;var e=di(),t=er(),n=e(t,"Set");return fx=n,fx}var px,f2;function Ole(){if(f2)return px;f2=1;var e=di(),t=er(),n=e(t,"WeakMap");return px=n,px}var mx,p2;function Wl(){if(p2)return mx;p2=1;var e=Lle(),t=mN(),n=Ile(),s=N5(),a=Ole(),o=ui(),i=f5(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),k=i(t),b=i(n),v=i(s),N=i(a),j=o;return(e&&j(new e(new ArrayBuffer(1)))!=m||t&&j(new t)!=c||n&&j(n.resolve())!=h||s&&j(new s)!=f||a&&j(new a)!=p)&&(j=function(S){var _=o(S),T=_==d?S.constructor:void 0,$=T?i(T):"";if($)switch($){case w:return m;case k:return c;case b:return h;case v:return f;case N:return p}return _}),mx=j,mx}var gx,m2;function Ple(){if(m2)return gx;m2=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,o=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(o.index=s.index,o.input=s.input),o}return gx=n,gx}var yx,g2;function S5(){if(g2)return yx;g2=1;var e=er(),t=e.Uint8Array;return yx=t,yx}var wx,y2;function jN(){if(y2)return wx;y2=1;var e=S5();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return wx=t,wx}var xx,w2;function Dle(){if(w2)return xx;w2=1;var e=jN();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return xx=t,xx}var vx,x2;function Fle(){if(x2)return vx;x2=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return vx=t,vx}var bx,v2;function Ble(){if(v2)return bx;v2=1;var e=ql(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return bx=s,bx}var kx,b2;function _5(){if(b2)return kx;b2=1;var e=jN();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return kx=t,kx}var jx,k2;function qle(){if(k2)return jx;k2=1;var e=jN(),t=Dle(),n=Fle(),s=Ble(),a=_5(),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]",k="[object DataView]",b="[object Float32Array]",v="[object Float64Array]",N="[object Int8Array]",j="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",T="[object Uint8ClampedArray]",$="[object Uint16Array]",M="[object Uint32Array]";function O(I,F,L){var A=I.constructor;switch(F){case w:return e(I);case o:case i:return new A(+I);case k:return t(I,L);case b:case v:case N:case j:case S:case _:case T:case $:case M:return a(I,L);case c:return new A;case d:case p:return new A(I);case h:return n(I);case f:return new A;case m:return s(I)}}return jx=O,jx}var Nx,j2;function C5(){if(j2)return Nx;j2=1;var e=bs(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var o=new s;return s.prototype=void 0,o}})();return Nx=n,Nx}var Sx,N2;function E5(){if(N2)return Sx;N2=1;var e=C5(),t=im(),n=om();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Sx=s,Sx}var _x,S2;function Ule(){if(S2)return _x;S2=1;var e=Wl(),t=Sr(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return _x=s,_x}var Cx,_2;function Wle(){if(_2)return Cx;_2=1;var e=Ule(),t=am(),n=xN(),s=n&&n.isMap,a=s?t(s):e;return Cx=a,Cx}var Ex,C2;function Hle(){if(C2)return Ex;C2=1;var e=Wl(),t=Sr(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Ex=s,Ex}var Tx,E2;function zle(){if(E2)return Tx;E2=1;var e=Hle(),t=am(),n=xN(),s=n&&n.isSet,a=s?t(s):e;return Tx=a,Tx}var Ax,T2;function T5(){if(T2)return Ax;T2=1;var e=tm(),t=yN(),n=sm(),s=Cle(),a=Ale(),o=y5(),i=w5(),c=Rle(),d=Mle(),h=j5(),f=$le(),p=Wl(),m=Ple(),w=qle(),k=E5(),b=Ut(),v=Ul(),N=Wle(),j=bs(),S=zle(),_=po(),T=hi(),$=1,M=2,O=4,I="[object Arguments]",F="[object Array]",L="[object Boolean]",A="[object Date]",q="[object Error]",E="[object Function]",D="[object GeneratorFunction]",P="[object Map]",z="[object Number]",G="[object Object]",V="[object RegExp]",H="[object Set]",B="[object String]",W="[object Symbol]",ee="[object WeakMap]",U="[object ArrayBuffer]",Y="[object DataView]",X="[object Float32Array]",Z="[object Float64Array]",J="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",he="[object Uint8Array]",le="[object Uint8ClampedArray]",re="[object Uint16Array]",ae="[object Uint32Array]",de={};de[I]=de[F]=de[U]=de[Y]=de[L]=de[A]=de[X]=de[Z]=de[J]=de[te]=de[ce]=de[P]=de[z]=de[G]=de[V]=de[H]=de[B]=de[W]=de[he]=de[le]=de[re]=de[ae]=!0,de[q]=de[E]=de[ee]=!1;function _e(fe,ye,ke,Ne,ge,Me){var Ie,We=ye&$,Te=ye&M,at=ye&O;if(ke&&(Ie=ge?ke(fe,Ne,ge,Me):ke(fe)),Ie!==void 0)return Ie;if(!j(fe))return fe;var Je=b(fe);if(Je){if(Ie=m(fe),!We)return i(fe,Ie)}else{var Ve=p(fe),be=Ve==E||Ve==D;if(v(fe))return o(fe,We);if(Ve==G||Ve==I||be&&!ge){if(Ie=Te||be?{}:k(fe),!We)return Te?d(fe,a(Ie,fe)):c(fe,s(Ie,fe))}else{if(!de[Ve])return ge?fe:{};Ie=w(fe,Ve,We)}}Me||(Me=new e);var Oe=Me.get(fe);if(Oe)return Oe;Me.set(fe,Ie),S(fe)?fe.forEach(function(ot){Ie.add(_e(ot,ye,ke,ot,fe,Me))}):N(fe)&&fe.forEach(function(ot,Qe){Ie.set(Qe,_e(ot,ye,ke,Qe,fe,Me))});var ze=at?Te?f:h:Te?T:_,st=Je?void 0:ze(fe);return t(st||fe,function(ot,Qe){st&&(Qe=ot,ot=fe[Qe]),n(Ie,Qe,_e(ot,ye,ke,Qe,fe,Me))}),Ie}return Ax=_e,Ax}var Rx,A2;function Vle(){if(A2)return Rx;A2=1;var e=T5(),t=4;function n(s){return e(s,t)}return Rx=n,Rx}var Mx,R2;function NN(){if(R2)return Mx;R2=1;function e(t){return function(){return t}}return Mx=e,Mx}var $x,M2;function Gle(){if(M2)return $x;M2=1;function e(t){return function(n,s,a){for(var o=-1,i=Object(n),c=a(n),d=c.length;d--;){var h=c[t?d:++o];if(s(i[h],h,i)===!1)break}return n}}return $x=e,$x}var Lx,$2;function SN(){if($2)return Lx;$2=1;var e=Gle(),t=e();return Lx=t,Lx}var Ix,L2;function _N(){if(L2)return Ix;L2=1;var e=SN(),t=po();function n(s,a){return s&&e(s,a,t)}return Ix=n,Ix}var Ox,I2;function Kle(){if(I2)return Ox;I2=1;var e=ha();function t(n,s){return function(a,o){if(a==null)return a;if(!e(a))return n(a,o);for(var i=a.length,c=s?i:-1,d=Object(a);(s?c--:++c<i)&&o(d[c],c,d)!==!1;);return a}}return Ox=t,Ox}var Px,O2;function lm(){if(O2)return Px;O2=1;var e=_N(),t=Kle(),n=t(e);return Px=n,Px}var Dx,P2;function fi(){if(P2)return Dx;P2=1;function e(t){return t}return Dx=e,Dx}var Fx,D2;function A5(){if(D2)return Fx;D2=1;var e=fi();function t(n){return typeof n=="function"?n:e}return Fx=t,Fx}var Bx,F2;function R5(){if(F2)return Bx;F2=1;var e=yN(),t=lm(),n=A5(),s=Ut();function a(o,i){var c=s(o)?e:t;return c(o,n(i))}return Bx=a,Bx}var qx,B2;function M5(){return B2||(B2=1,qx=R5()),qx}var Ux,q2;function Yle(){if(q2)return Ux;q2=1;var e=lm();function t(n,s){var a=[];return e(n,function(o,i,c){s(o,i,c)&&a.push(o)}),a}return Ux=t,Ux}var Wx,U2;function Xle(){if(U2)return Wx;U2=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Wx=t,Wx}var Hx,W2;function Zle(){if(W2)return Hx;W2=1;function e(t){return this.__data__.has(t)}return Hx=e,Hx}var zx,H2;function $5(){if(H2)return zx;H2=1;var e=gN(),t=Xle(),n=Zle();function s(a){var o=-1,i=a==null?0:a.length;for(this.__data__=new e;++o<i;)this.add(a[o])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,zx=s,zx}var Vx,z2;function Jle(){if(z2)return Vx;z2=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(t[s],s,t))return!0;return!1}return Vx=e,Vx}var Gx,V2;function L5(){if(V2)return Gx;V2=1;function e(t,n){return t.has(n)}return Gx=e,Gx}var Kx,G2;function I5(){if(G2)return Kx;G2=1;var e=$5(),t=Jle(),n=L5(),s=1,a=2;function o(i,c,d,h,f,p){var m=d&s,w=i.length,k=c.length;if(w!=k&&!(m&&k>w))return!1;var b=p.get(i),v=p.get(c);if(b&&v)return b==c&&v==i;var N=-1,j=!0,S=d&a?new e:void 0;for(p.set(i,c),p.set(c,i);++N<w;){var _=i[N],T=c[N];if(h)var $=m?h(T,_,N,c,i,p):h(_,T,N,i,c,p);if($!==void 0){if($)continue;j=!1;break}if(S){if(!t(c,function(M,O){if(!n(S,O)&&(_===M||f(_,M,d,h,p)))return S.push(O)})){j=!1;break}}else if(!(_===T||f(_,T,d,h,p))){j=!1;break}}return p.delete(i),p.delete(c),j}return Kx=o,Kx}var Yx,K2;function Qle(){if(K2)return Yx;K2=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return Yx=e,Yx}var Xx,Y2;function CN(){if(Y2)return Xx;Y2=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Xx=e,Xx}var Zx,X2;function ece(){if(X2)return Zx;X2=1;var e=ql(),t=S5(),n=Bl(),s=I5(),a=Qle(),o=CN(),i=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",k="[object Set]",b="[object String]",v="[object Symbol]",N="[object ArrayBuffer]",j="[object DataView]",S=e?e.prototype:void 0,_=S?S.valueOf:void 0;function T($,M,O,I,F,L,A){switch(O){case j:if($.byteLength!=M.byteLength||$.byteOffset!=M.byteOffset)return!1;$=$.buffer,M=M.buffer;case N:return!($.byteLength!=M.byteLength||!L(new t($),new t(M)));case d:case h:case m:return n(+$,+M);case f:return $.name==M.name&&$.message==M.message;case w:case b:return $==M+"";case p:var q=a;case k:var E=I&i;if(q||(q=o),$.size!=M.size&&!E)return!1;var D=A.get($);if(D)return D==M;I|=c,A.set($,M);var P=s(q($),q(M),I,F,L,A);return A.delete($),P;case v:if(_)return _.call($)==_.call(M)}return!1}return Zx=T,Zx}var Jx,Z2;function tce(){if(Z2)return Jx;Z2=1;var e=j5(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(o,i,c,d,h,f){var p=c&t,m=e(o),w=m.length,k=e(i),b=k.length;if(w!=b&&!p)return!1;for(var v=w;v--;){var N=m[v];if(!(p?N in i:s.call(i,N)))return!1}var j=f.get(o),S=f.get(i);if(j&&S)return j==i&&S==o;var _=!0;f.set(o,i),f.set(i,o);for(var T=p;++v<w;){N=m[v];var $=o[N],M=i[N];if(d)var O=p?d(M,$,N,i,o,f):d($,M,N,o,i,f);if(!(O===void 0?$===M||h($,M,c,d,f):O)){_=!1;break}T||(T=N=="constructor")}if(_&&!T){var I=o.constructor,F=i.constructor;I!=F&&"constructor"in o&&"constructor"in i&&!(typeof I=="function"&&I instanceof I&&typeof F=="function"&&F instanceof F)&&(_=!1)}return f.delete(o),f.delete(i),_}return Jx=a,Jx}var Qx,J2;function nce(){if(J2)return Qx;J2=1;var e=tm(),t=I5(),n=ece(),s=tce(),a=Wl(),o=Ut(),i=Ul(),c=Ju(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function k(b,v,N,j,S,_){var T=o(b),$=o(v),M=T?f:a(b),O=$?f:a(v);M=M==h?p:M,O=O==h?p:O;var I=M==p,F=O==p,L=M==O;if(L&&i(b)){if(!i(v))return!1;T=!0,I=!1}if(L&&!I)return _||(_=new e),T||c(b)?t(b,v,N,j,S,_):n(b,v,M,N,j,S,_);if(!(N&d)){var A=I&&w.call(b,"__wrapped__"),q=F&&w.call(v,"__wrapped__");if(A||q){var E=A?b.value():b,D=q?v.value():v;return _||(_=new e),S(E,D,N,j,_)}}return L?(_||(_=new e),s(b,v,N,j,S,_)):!1}return Qx=k,Qx}var ev,Q2;function O5(){if(Q2)return ev;Q2=1;var e=nce(),t=Sr();function n(s,a,o,i,c){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,o,i,n,c)}return ev=n,ev}var tv,eM;function sce(){if(eM)return tv;eM=1;var e=tm(),t=O5(),n=1,s=2;function a(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],k=o[w],b=m[1];if(p&&m[2]){if(k===void 0&&!(w in o))return!1}else{var v=new e;if(d)var N=d(k,b,w,o,i,v);if(!(N===void 0?t(b,k,n|s,d,v):N))return!1}}return!0}return tv=a,tv}var nv,tM;function P5(){if(tM)return nv;tM=1;var e=bs();function t(n){return n===n&&!e(n)}return nv=t,nv}var sv,nM;function rce(){if(nM)return sv;nM=1;var e=P5(),t=po();function n(s){for(var a=t(s),o=a.length;o--;){var i=a[o],c=s[i];a[o]=[i,c,e(c)]}return a}return sv=n,sv}var rv,sM;function D5(){if(sM)return rv;sM=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return rv=e,rv}var av,rM;function ace(){if(rM)return av;rM=1;var e=sce(),t=rce(),n=D5();function s(a){var o=t(a);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(i){return i===a||e(i,a,o)}}return av=s,av}var ov,aM;function Hl(){if(aM)return ov;aM=1;var e=ui(),t=Sr(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return ov=s,ov}var iv,oM;function EN(){if(oM)return iv;oM=1;var e=Ut(),t=Hl(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(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 iv=a,iv}var lv,iM;function oce(){if(iM)return lv;iM=1;var e=gN(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var o=function(){var i=arguments,c=a?a.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,lv=n,lv}var cv,lM;function ice(){if(lM)return cv;lM=1;var e=oce(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return cv=n,cv}var uv,cM;function lce(){if(cM)return uv;cM=1;var e=ice(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var o=[];return a.charCodeAt(0)===46&&o.push(""),a.replace(t,function(i,c,d,h){o.push(d?h.replace(n,"$1"):c||i)}),o});return uv=s,uv}var dv,uM;function cm(){if(uM)return dv;uM=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,o=Array(a);++s<a;)o[s]=n(t[s],s,t);return o}return dv=e,dv}var hv,dM;function cce(){if(dM)return hv;dM=1;var e=ql(),t=cm(),n=Ut(),s=Hl(),a=e?e.prototype:void 0,o=a?a.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 hv=i,hv}var fv,hM;function F5(){if(hM)return fv;hM=1;var e=cce();function t(n){return n==null?"":e(n)}return fv=t,fv}var pv,fM;function um(){if(fM)return pv;fM=1;var e=Ut(),t=EN(),n=lce(),s=F5();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return pv=a,pv}var mv,pM;function Qu(){if(pM)return mv;pM=1;var e=Hl();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return mv=t,mv}var gv,mM;function dm(){if(mM)return gv;mM=1;var e=um(),t=Qu();function n(s,a){a=e(a,s);for(var o=0,i=a.length;s!=null&&o<i;)s=s[t(a[o++])];return o&&o==i?s:void 0}return gv=n,gv}var yv,gM;function uce(){if(gM)return yv;gM=1;var e=dm();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return yv=t,yv}var wv,yM;function dce(){if(yM)return wv;yM=1;function e(t,n){return t!=null&&n in Object(t)}return wv=e,wv}var xv,wM;function B5(){if(wM)return xv;wM=1;var e=um(),t=Zu(),n=Ut(),s=rm(),a=wN(),o=Qu();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&&a(p)&&s(w,p)&&(n(c)||t(c)))}return xv=i,xv}var vv,xM;function q5(){if(xM)return vv;xM=1;var e=dce(),t=B5();function n(s,a){return s!=null&&t(s,a,e)}return vv=n,vv}var bv,vM;function hce(){if(vM)return bv;vM=1;var e=O5(),t=uce(),n=q5(),s=EN(),a=P5(),o=D5(),i=Qu(),c=1,d=2;function h(f,p){return s(f)&&a(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 bv=h,bv}var kv,bM;function U5(){if(bM)return kv;bM=1;function e(t){return function(n){return n==null?void 0:n[t]}}return kv=e,kv}var jv,kM;function fce(){if(kM)return jv;kM=1;var e=dm();function t(n){return function(s){return e(s,n)}}return jv=t,jv}var Nv,jM;function pce(){if(jM)return Nv;jM=1;var e=U5(),t=fce(),n=EN(),s=Qu();function a(o){return n(o)?e(s(o)):t(o)}return Nv=a,Nv}var Sv,NM;function fa(){if(NM)return Sv;NM=1;var e=ace(),t=hce(),n=fi(),s=Ut(),a=pce();function o(i){return typeof i=="function"?i:i==null?n:typeof i=="object"?s(i)?t(i[0],i[1]):e(i):a(i)}return Sv=o,Sv}var _v,SM;function W5(){if(SM)return _v;SM=1;var e=x5(),t=Yle(),n=fa(),s=Ut();function a(o,i){var c=s(o)?e:t;return c(o,n(i,3))}return _v=a,_v}var Cv,_M;function mce(){if(_M)return Cv;_M=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Cv=n,Cv}var Ev,CM;function H5(){if(CM)return Ev;CM=1;var e=mce(),t=B5();function n(s,a){return s!=null&&t(s,a,e)}return Ev=n,Ev}var Tv,EM;function gce(){if(EM)return Tv;EM=1;var e=vN(),t=Wl(),n=Zu(),s=Ut(),a=ha(),o=Ul(),i=om(),c=Ju(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function m(w){if(w==null)return!0;if(a(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||o(w)||c(w)||n(w)))return!w.length;var k=t(w);if(k==d||k==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 Tv=m,Tv}var Av,TM;function z5(){if(TM)return Av;TM=1;function e(t){return t===void 0}return Av=e,Av}var Rv,AM;function V5(){if(AM)return Rv;AM=1;var e=lm(),t=ha();function n(s,a){var o=-1,i=t(s)?Array(s.length):[];return e(s,function(c,d,h){i[++o]=a(c,d,h)}),i}return Rv=n,Rv}var Mv,RM;function G5(){if(RM)return Mv;RM=1;var e=cm(),t=fa(),n=V5(),s=Ut();function a(o,i){var c=s(o)?e:n;return c(o,t(i,3))}return Mv=a,Mv}var $v,MM;function yce(){if(MM)return $v;MM=1;function e(t,n,s,a){var o=-1,i=t==null?0:t.length;for(a&&i&&(s=t[++o]);++o<i;)s=n(s,t[o],o,t);return s}return $v=e,$v}var Lv,$M;function wce(){if($M)return Lv;$M=1;function e(t,n,s,a,o){return o(t,function(i,c,d){s=a?(a=!1,i):n(s,i,c,d)}),s}return Lv=e,Lv}var Iv,LM;function K5(){if(LM)return Iv;LM=1;var e=yce(),t=lm(),n=fa(),s=wce(),a=Ut();function o(i,c,d){var h=a(i)?e:s,f=arguments.length<3;return h(i,n(c,4),d,f,t)}return Iv=o,Iv}var Ov,IM;function xce(){if(IM)return Ov;IM=1;var e=ui(),t=Ut(),n=Sr(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return Ov=a,Ov}var Pv,OM;function vce(){if(OM)return Pv;OM=1;var e=U5(),t=e("length");return Pv=t,Pv}var Dv,PM;function bce(){if(PM)return Dv;PM=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="\\u200d",c=RegExp("["+i+e+a+o+"]");function d(h){return c.test(h)}return Dv=d,Dv}var Fv,DM;function kce(){if(DM)return Fv;DM=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="["+e+"]",c="["+a+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",k=h+"?",b="["+o+"]?",v="(?:"+w+"(?:"+[f,p,m].join("|")+")"+b+k+")*",N=b+k+v,j="(?:"+[f+c+"?",c,p,m,i].join("|")+")",S=RegExp(d+"(?="+d+")|"+j+N,"g");function _(T){for(var $=S.lastIndex=0;S.test(T);)++$;return $}return Fv=_,Fv}var Bv,FM;function jce(){if(FM)return Bv;FM=1;var e=vce(),t=bce(),n=kce();function s(a){return t(a)?n(a):e(a)}return Bv=s,Bv}var qv,BM;function Nce(){if(BM)return qv;BM=1;var e=vN(),t=Wl(),n=ha(),s=xce(),a=jce(),o="[object Map]",i="[object Set]";function c(d){if(d==null)return 0;if(n(d))return s(d)?a(d):d.length;var h=t(d);return h==o||h==i?d.size:e(d).length}return qv=c,qv}var Uv,qM;function Sce(){if(qM)return Uv;qM=1;var e=yN(),t=C5(),n=_N(),s=fa(),a=im(),o=Ut(),i=Ul(),c=Yu(),d=bs(),h=Ju();function f(p,m,w){var k=o(p),b=k||i(p)||h(p);if(m=s(m,4),w==null){var v=p&&p.constructor;b?w=k?new v:[]:d(p)?w=c(v)?t(a(p)):{}:w={}}return(b?e:n)(p,function(N,j,S){return m(w,N,j,S)}),w}return Uv=f,Uv}var Wv,UM;function _ce(){if(UM)return Wv;UM=1;var e=ql(),t=Zu(),n=Ut(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return Wv=a,Wv}var Hv,WM;function TN(){if(WM)return Hv;WM=1;var e=kN(),t=_ce();function n(s,a,o,i,c){var d=-1,h=s.length;for(o||(o=t),c||(c=[]);++d<h;){var f=s[d];a>0&&o(f)?a>1?n(f,a-1,o,i,c):e(c,f):i||(c[c.length]=f)}return c}return Hv=n,Hv}var zv,HM;function Cce(){if(HM)return zv;HM=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 zv=e,zv}var Vv,zM;function Y5(){if(zM)return Vv;zM=1;var e=Cce(),t=Math.max;function n(s,a,o){return a=t(a===void 0?s.length-1:a,0),function(){for(var i=arguments,c=-1,d=t(i.length-a,0),h=Array(d);++c<d;)h[c]=i[a+c];c=-1;for(var f=Array(a+1);++c<a;)f[c]=i[c];return f[a]=o(h),e(s,this,f)}}return Vv=n,Vv}var Gv,VM;function Ece(){if(VM)return Gv;VM=1;var e=NN(),t=p5(),n=fi(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Gv=s,Gv}var Kv,GM;function Tce(){if(GM)return Kv;GM=1;var e=800,t=16,n=Date.now;function s(a){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 a.apply(void 0,arguments)}}return Kv=s,Kv}var Yv,KM;function X5(){if(KM)return Yv;KM=1;var e=Ece(),t=Tce(),n=t(e);return Yv=n,Yv}var Xv,YM;function hm(){if(YM)return Xv;YM=1;var e=fi(),t=Y5(),n=X5();function s(a,o){return n(t(a,o,e),a+"")}return Xv=s,Xv}var Zv,XM;function Z5(){if(XM)return Zv;XM=1;function e(t,n,s,a){for(var o=t.length,i=s+(a?1:-1);a?i--:++i<o;)if(n(t[i],i,t))return i;return-1}return Zv=e,Zv}var Jv,ZM;function Ace(){if(ZM)return Jv;ZM=1;function e(t){return t!==t}return Jv=e,Jv}var Qv,JM;function Rce(){if(JM)return Qv;JM=1;function e(t,n,s){for(var a=s-1,o=t.length;++a<o;)if(t[a]===n)return a;return-1}return Qv=e,Qv}var eb,QM;function Mce(){if(QM)return eb;QM=1;var e=Z5(),t=Ace(),n=Rce();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return eb=s,eb}var tb,e$;function $ce(){if(e$)return tb;e$=1;var e=Mce();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return tb=t,tb}var nb,t$;function Lce(){if(t$)return nb;t$=1;function e(t,n,s){for(var a=-1,o=t==null?0:t.length;++a<o;)if(s(n,t[a]))return!0;return!1}return nb=e,nb}var sb,n$;function Ice(){if(n$)return sb;n$=1;function e(){}return sb=e,sb}var rb,s$;function Oce(){if(s$)return rb;s$=1;var e=N5(),t=Ice(),n=CN(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return rb=a,rb}var ab,r$;function Pce(){if(r$)return ab;r$=1;var e=$5(),t=$ce(),n=Lce(),s=L5(),a=Oce(),o=CN(),i=200;function c(d,h,f){var p=-1,m=t,w=d.length,k=!0,b=[],v=b;if(f)k=!1,m=n;else if(w>=i){var N=h?null:a(d);if(N)return o(N);k=!1,m=s,v=new e}else v=h?[]:b;e:for(;++p<w;){var j=d[p],S=h?h(j):j;if(j=f||j!==0?j:0,k&&S===S){for(var _=v.length;_--;)if(v[_]===S)continue e;h&&v.push(S),b.push(j)}else m(v,S,f)||(v!==b&&v.push(S),b.push(j))}return b}return ab=c,ab}var ob,a$;function J5(){if(a$)return ob;a$=1;var e=ha(),t=Sr();function n(s){return t(s)&&e(s)}return ob=n,ob}var ib,o$;function Dce(){if(o$)return ib;o$=1;var e=TN(),t=hm(),n=Pce(),s=J5(),a=t(function(o){return n(e(o,1,s,!0))});return ib=a,ib}var lb,i$;function Fce(){if(i$)return lb;i$=1;var e=cm();function t(n,s){return e(s,function(a){return n[a]})}return lb=t,lb}var cb,l$;function Q5(){if(l$)return cb;l$=1;var e=Fce(),t=po();function n(s){return s==null?[]:e(s,t(s))}return cb=n,cb}var ub,c$;function ks(){if(c$)return ub;c$=1;var e;if(typeof pN=="function")try{e={clone:Vle(),constant:NN(),each:M5(),filter:W5(),has:H5(),isArray:Ut(),isEmpty:gce(),isFunction:Yu(),isUndefined:z5(),keys:po(),map:G5(),reduce:K5(),size:Nce(),transform:Sce(),union:Dce(),values:Q5()}}catch{}return e||(e=window._),ub=e,ub}var db,u$;function AN(){if(u$)return db;u$=1;var e=ks();db=a;var t="\0",n="\0",s="";function a(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={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(f){return this._label=f,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},a.prototype.setNodes=function(f,p){var m=arguments,w=this;return e.each(f,function(k){m.length>1?w.setNode(k,p):w.setNode(k)}),this},a.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)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return e.has(this._nodes,f)},a.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},a.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},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},a.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[]}},a.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},a.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},a.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},a.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},a.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,v){f(v)&&p.setNode(v,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,m.edge(b))});var w={};function k(b){var v=m.parent(b);return v===void 0||p.hasNode(v)?(w[b]=v,v):v in w?w[v]:k(v)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,k(b))}),p},a.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(f,p){var m=this,w=arguments;return e.reduce(f,function(k,b){return w.length>1?m.setEdge(k,b,p):m.setEdge(k,b),b}),this},a.prototype.setEdge=function(){var f,p,m,w,k=!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],k=!0)):(f=b,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],k=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var v=c(this._isDirected,f,p,m);if(e.has(this._edgeLabels,v))return k&&(this._edgeLabels[v]=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[v]=k?w:this._defaultEdgeLabelFn(f,p,m);var N=d(this._isDirected,f,p,m);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[v]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][v]=N,this._out[f][v]=N,this._edgeCount++,this},a.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]},a.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)},a.prototype.removeEdge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m),k=this._edgeObjs[w];return k&&(f=k.v,p=k.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},a.prototype.inEdges=function(f,p){var m=this._in[f];if(m){var w=e.values(m);return p?e.filter(w,function(k){return k.v===p}):w}},a.prototype.outEdges=function(f,p){var m=this._out[f];if(m){var w=e.values(m);return p?e.filter(w,function(k){return k.w===p}):w}},a.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 k=""+p,b=""+m;if(!f&&k>b){var v=k;k=b,b=v}return k+s+b+s+(e.isUndefined(w)?t:w)}function d(f,p,m,w){var k=""+p,b=""+m;if(!f&&k>b){var v=k;k=b,b=v}var N={v:k,w:b};return w&&(N.name=w),N}function h(f,p){return c(f,p.v,p.w,p.name)}return db}var hb,d$;function Bce(){return d$||(d$=1,hb="2.1.8"),hb}var fb,h$;function qce(){return h$||(h$=1,fb={Graph:AN(),version:Bce()}),fb}var pb,f$;function Uce(){if(f$)return pb;f$=1;var e=ks(),t=AN();pb={write:n,read:o};function n(i){var c={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:s(i),edges:a(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 a(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 pb}var mb,p$;function Wce(){if(p$)return mb;p$=1;var e=ks();mb=t;function t(n){var s={},a=[],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&&a.push(o)}),a}return mb}var gb,m$;function e6(){if(m$)return gb;m$=1;var e=ks();gb=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 a=this._keyIndices;if(n=String(n),!e.has(a,n)){var o=this._arr,i=o.length;return a[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 a=this._keyIndices[n];if(s>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+s);this._arr[a].priority=s,this._decrease(a)},t.prototype._heapify=function(n){var s=this._arr,a=2*n,o=a+1,i=n;a<s.length&&(i=s[a].priority<s[i].priority?a: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,a=s[n].priority,o;n!==0&&(o=n>>1,!(s[o].priority<a));)this._swap(n,o),n=o},t.prototype._swap=function(n,s){var a=this._arr,o=this._keyIndices,i=a[n],c=a[s];a[n]=c,a[s]=i,o[c.key]=n,o[i.key]=s},gb}var yb,g$;function t6(){if(g$)return yb;g$=1;var e=ks(),t=e6();yb=s;var n=e.constant(1);function s(o,i,c,d){return a(o,String(i),c||n,d||function(h){return o.outEdges(h)})}function a(o,i,c,d){var h={},f=new t,p,m,w=function(k){var b=k.v!==p?k.v:k.w,v=h[b],N=c(k),j=m.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+k+" Weight: "+N);j<v.distance&&(v.distance=j,v.predecessor=p,f.decrease(b,j))};for(o.nodes().forEach(function(k){var b=k===i?0:Number.POSITIVE_INFINITY;h[k]={distance:b},f.add(k,b)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(w);return h}return yb}var wb,y$;function Hce(){if(y$)return wb;y$=1;var e=t6(),t=ks();wb=n;function n(s,a,o){return t.transform(s.nodes(),function(i,c){i[c]=e(s,c,a,o)},{})}return wb}var xb,w$;function n6(){if(w$)return xb;w$=1;var e=ks();xb=t;function t(n){var s=0,a=[],o={},i=[];function c(d){var h=o[d]={onStack:!0,lowlink:s,index:s++};if(a.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=a.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 xb}var vb,x$;function zce(){if(x$)return vb;x$=1;var e=ks(),t=n6();vb=n;function n(s){return e.filter(t(s),function(a){return a.length>1||a.length===1&&s.hasEdge(a[0],a[0])})}return vb}var bb,v$;function Vce(){if(v$)return bb;v$=1;var e=ks();bb=n;var t=e.constant(1);function n(a,o,i){return s(a,o||t,i||function(c){return a.outEdges(c)})}function s(a,o,i){var c={},d=a.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 k=m[h],b=f[w],v=m[w],N=k.distance+b.distance;N<v.distance&&(v.distance=N,v.predecessor=b.predecessor)})})}),c}return bb}var kb,b$;function s6(){if(b$)return kb;b$=1;var e=ks();kb=t,t.CycleException=n;function t(s){var a={},o={},i=[];function c(d){if(e.has(o,d))throw new n;e.has(a,d)||(o[d]=!0,a[d]=!0,e.each(s.predecessors(d),c),delete o[d],i.push(d))}if(e.each(s.sinks(),c),e.size(a)!==s.nodeCount())throw new n;return i}function n(){}return n.prototype=new Error,kb}var jb,k$;function Gce(){if(k$)return jb;k$=1;var e=s6();jb=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return jb}var Nb,j$;function r6(){if(j$)return Nb;j$=1;var e=ks();Nb=t;function t(s,a,o){e.isArray(a)||(a=[a]);var i=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],d={};return e.each(a,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,a,o,i,c,d){e.has(i,a)||(i[a]=!0,o||d.push(a),e.each(c(a),function(h){n(s,h,o,i,c,d)}),o&&d.push(a))}return Nb}var Sb,N$;function Kce(){if(N$)return Sb;N$=1;var e=r6();Sb=t;function t(n,s){return e(n,s,"post")}return Sb}var _b,S$;function Yce(){if(S$)return _b;S$=1;var e=r6();_b=t;function t(n,s){return e(n,s,"pre")}return _b}var Cb,_$;function Xce(){if(_$)return Cb;_$=1;var e=ks(),t=AN(),n=e6();Cb=s;function s(a,o){var i=new t,c={},d=new n,h;function f(m){var w=m.v===h?m.w:m.v,k=d.priority(w);if(k!==void 0){var b=o(m);b<k&&(c[w]=h,d.decrease(w,b))}}if(a.nodeCount()===0)return i;e.each(a.nodes(),function(m){d.add(m,Number.POSITIVE_INFINITY),i.setNode(m)}),d.decrease(a.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: "+a);p=!0}a.nodeEdges(h).forEach(f)}return i}return Cb}var Eb,C$;function Zce(){return C$||(C$=1,Eb={components:Wce(),dijkstra:t6(),dijkstraAll:Hce(),findCycles:zce(),floydWarshall:Vce(),isAcyclic:Gce(),postorder:Kce(),preorder:Yce(),prim:Xce(),tarjan:n6(),topsort:s6()}),Eb}var Tb,E$;function Jce(){if(E$)return Tb;E$=1;var e=qce();return Tb={Graph:e.Graph,json:Uce(),alg:Zce(),version:e.version},Tb}var Ab,T$;function Js(){if(T$)return Ab;T$=1;var e;if(typeof pN=="function")try{e=Jce()}catch{}return e||(e=window.graphlib),Ab=e,Ab}var Rb,A$;function Qce(){if(A$)return Rb;A$=1;var e=T5(),t=1,n=4;function s(a){return e(a,t|n)}return Rb=s,Rb}var Mb,R$;function fm(){if(R$)return Mb;R$=1;var e=Bl(),t=ha(),n=rm(),s=bs();function a(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 Mb=a,Mb}var $b,M$;function eue(){if(M$)return $b;M$=1;var e=hm(),t=Bl(),n=fm(),s=hi(),a=Object.prototype,o=a.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),k=-1,b=w.length;++k<b;){var v=w[k],N=c[v];(N===void 0||t(N,a[v])&&!o.call(c,v))&&(c[v]=m[v])}return c});return $b=i,$b}var Lb,$$;function tue(){if($$)return Lb;$$=1;var e=fa(),t=ha(),n=po();function s(a){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=a(o,i,c);return f>-1?d[h?o[f]:f]:void 0}}return Lb=s,Lb}var Ib,L$;function nue(){if(L$)return Ib;L$=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Ib=t,Ib}var Ob,I$;function sue(){if(I$)return Ob;I$=1;var e=nue(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Ob=n,Ob}var Pb,O$;function rue(){if(O$)return Pb;O$=1;var e=sue(),t=bs(),n=Hl(),s=NaN,a=/^[-+]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):a.test(h)?s:+h}return Pb=d,Pb}var Db,P$;function a6(){if(P$)return Db;P$=1;var e=rue(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var o=a<0?-1:1;return o*n}return a===a?a:0}return Db=s,Db}var Fb,D$;function aue(){if(D$)return Fb;D$=1;var e=a6();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Fb=t,Fb}var Bb,F$;function oue(){if(F$)return Bb;F$=1;var e=Z5(),t=fa(),n=aue(),s=Math.max;function a(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 Bb=a,Bb}var qb,B$;function iue(){if(B$)return qb;B$=1;var e=tue(),t=oue(),n=e(t);return qb=n,qb}var Ub,q$;function o6(){if(q$)return Ub;q$=1;var e=TN();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Ub=t,Ub}var Wb,U$;function lue(){if(U$)return Wb;U$=1;var e=SN(),t=A5(),n=hi();function s(a,o){return a==null?a:e(a,t(o),n)}return Wb=s,Wb}var Hb,W$;function cue(){if(W$)return Hb;W$=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Hb=e,Hb}var zb,H$;function uue(){if(H$)return zb;H$=1;var e=nm(),t=_N(),n=fa();function s(a,o){var i={};return o=n(o,3),t(a,function(c,d,h){e(i,d,o(c,d,h))}),i}return zb=s,zb}var Vb,z$;function RN(){if(z$)return Vb;z$=1;var e=Hl();function t(n,s,a){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):a(d,h)))var h=d,f=c}return f}return Vb=t,Vb}var Gb,V$;function due(){if(V$)return Gb;V$=1;function e(t,n){return t>n}return Gb=e,Gb}var Kb,G$;function hue(){if(G$)return Kb;G$=1;var e=RN(),t=due(),n=fi();function s(a){return a&&a.length?e(a,n,t):void 0}return Kb=s,Kb}var Yb,K$;function i6(){if(K$)return Yb;K$=1;var e=nm(),t=Bl();function n(s,a,o){(o!==void 0&&!t(s[a],o)||o===void 0&&!(a in s))&&e(s,a,o)}return Yb=n,Yb}var Xb,Y$;function fue(){if(Y$)return Xb;Y$=1;var e=ui(),t=im(),n=Sr(),s="[object Object]",a=Function.prototype,o=Object.prototype,i=a.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 Xb=h,Xb}var Zb,X$;function l6(){if(X$)return Zb;X$=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Zb=e,Zb}var Jb,Z$;function pue(){if(Z$)return Jb;Z$=1;var e=Xu(),t=hi();function n(s){return e(s,t(s))}return Jb=n,Jb}var Qb,J$;function mue(){if(J$)return Qb;J$=1;var e=i6(),t=y5(),n=_5(),s=w5(),a=E5(),o=Zu(),i=Ut(),c=J5(),d=Ul(),h=Yu(),f=bs(),p=fue(),m=Ju(),w=l6(),k=pue();function b(v,N,j,S,_,T,$){var M=w(v,j),O=w(N,j),I=$.get(O);if(I){e(v,j,I);return}var F=T?T(M,O,j+"",v,N,$):void 0,L=F===void 0;if(L){var A=i(O),q=!A&&d(O),E=!A&&!q&&m(O);F=O,A||q||E?i(M)?F=M:c(M)?F=s(M):q?(L=!1,F=t(O,!0)):E?(L=!1,F=n(O,!0)):F=[]:p(O)||o(O)?(F=M,o(M)?F=k(M):(!f(M)||h(M))&&(F=a(O))):L=!1}L&&($.set(O,F),_(F,O,S,T,$),$.delete(O)),e(v,j,F)}return Qb=b,Qb}var ek,Q$;function gue(){if(Q$)return ek;Q$=1;var e=tm(),t=i6(),n=SN(),s=mue(),a=bs(),o=hi(),i=l6();function c(d,h,f,p,m){d!==h&&n(h,function(w,k){if(m||(m=new e),a(w))s(d,h,k,f,c,p,m);else{var b=p?p(i(d,k),w,k+"",d,h,m):void 0;b===void 0&&(b=w),t(d,k,b)}},o)}return ek=c,ek}var tk,eL;function yue(){if(eL)return tk;eL=1;var e=hm(),t=fm();function n(s){return e(function(a,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),a=Object(a);++i<c;){var f=o[i];f&&s(a,f,i,d)}return a})}return tk=n,tk}var nk,tL;function wue(){if(tL)return nk;tL=1;var e=gue(),t=yue(),n=t(function(s,a,o){e(s,a,o)});return nk=n,nk}var sk,nL;function c6(){if(nL)return sk;nL=1;function e(t,n){return t<n}return sk=e,sk}var rk,sL;function xue(){if(sL)return rk;sL=1;var e=RN(),t=c6(),n=fi();function s(a){return a&&a.length?e(a,n,t):void 0}return rk=s,rk}var ak,rL;function vue(){if(rL)return ak;rL=1;var e=RN(),t=fa(),n=c6();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return ak=s,ak}var ok,aL;function bue(){if(aL)return ok;aL=1;var e=er(),t=function(){return e.Date.now()};return ok=t,ok}var ik,oL;function kue(){if(oL)return ik;oL=1;var e=sm(),t=um(),n=rm(),s=bs(),a=Qu();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 k=a(c[f]),b=d;if(k==="__proto__"||k==="constructor"||k==="prototype")return i;if(f!=m){var v=w[k];b=h?h(v,k,w):void 0,b===void 0&&(b=s(v)?v:n(c[f+1])?[]:{})}e(w,k,b),w=w[k]}return i}return ik=o,ik}var lk,iL;function jue(){if(iL)return lk;iL=1;var e=dm(),t=kue(),n=um();function s(a,o,i){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(a,f);i(p,f)&&t(h,n(f,a),p)}return h}return lk=s,lk}var ck,lL;function Nue(){if(lL)return ck;lL=1;var e=jue(),t=q5();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return ck=n,ck}var uk,cL;function Sue(){if(cL)return uk;cL=1;var e=o6(),t=Y5(),n=X5();function s(a){return n(t(a,void 0,e),a+"")}return uk=s,uk}var dk,uL;function _ue(){if(uL)return dk;uL=1;var e=Nue(),t=Sue(),n=t(function(s,a){return s==null?{}:e(s,a)});return dk=n,dk}var hk,dL;function Cue(){if(dL)return hk;dL=1;var e=Math.ceil,t=Math.max;function n(s,a,o,i){for(var c=-1,d=t(e((a-s)/(o||1)),0),h=Array(d);d--;)h[i?d:++c]=s,s+=o;return h}return hk=n,hk}var fk,hL;function Eue(){if(hL)return fk;hL=1;var e=Cue(),t=fm(),n=a6();function s(a){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,a)}}return fk=s,fk}var pk,fL;function Tue(){if(fL)return pk;fL=1;var e=Eue(),t=e();return pk=t,pk}var mk,pL;function Aue(){if(pL)return mk;pL=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return mk=e,mk}var gk,mL;function Rue(){if(mL)return gk;mL=1;var e=Hl();function t(n,s){if(n!==s){var a=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||!a&&f||!i)return 1;if(!o&&!c&&!p&&n<s||p&&a&&i&&!o&&!c||h&&a&&i||!d&&i||!f)return-1}return 0}return gk=t,gk}var yk,gL;function Mue(){if(gL)return yk;gL=1;var e=Rue();function t(n,s,a){for(var o=-1,i=n.criteria,c=s.criteria,d=i.length,h=a.length;++o<d;){var f=e(i[o],c[o]);if(f){if(o>=h)return f;var p=a[o];return f*(p=="desc"?-1:1)}}return n.index-s.index}return yk=t,yk}var wk,yL;function $ue(){if(yL)return wk;yL=1;var e=cm(),t=dm(),n=fa(),s=V5(),a=Aue(),o=am(),i=Mue(),c=fi(),d=Ut();function h(f,p,m){p.length?p=e(p,function(b){return d(b)?function(v){return t(v,b.length===1?b[0]:b)}:b}):p=[c];var w=-1;p=e(p,o(n));var k=s(f,function(b,v,N){var j=e(p,function(S){return S(b)});return{criteria:j,index:++w,value:b}});return a(k,function(b,v){return i(b,v,m)})}return wk=h,wk}var xk,wL;function Lue(){if(wL)return xk;wL=1;var e=TN(),t=$ue(),n=hm(),s=fm(),a=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 xk=a,xk}var vk,xL;function Iue(){if(xL)return vk;xL=1;var e=F5(),t=0;function n(s){var a=++t;return e(s)+a}return vk=n,vk}var bk,vL;function Oue(){if(vL)return bk;vL=1;function e(t,n,s){for(var a=-1,o=t.length,i=n.length,c={};++a<o;){var d=a<i?n[a]:void 0;s(c,t[a],d)}return c}return bk=e,bk}var kk,bL;function Pue(){if(bL)return kk;bL=1;var e=sm(),t=Oue();function n(s,a){return t(s||[],a||[],e)}return kk=n,kk}var jk,kL;function _t(){if(kL)return jk;kL=1;var e;if(typeof pN=="function")try{e={cloneDeep:Qce(),constant:NN(),defaults:eue(),each:M5(),filter:W5(),find:iue(),flatten:o6(),forEach:R5(),forIn:lue(),has:H5(),isUndefined:z5(),last:cue(),map:G5(),mapValues:uue(),max:hue(),merge:wue(),min:xue(),minBy:vue(),now:bue(),pick:_ue(),range:Tue(),reduce:K5(),sortBy:Lue(),uniqueId:Iue(),values:Q5(),zipObject:Pue()}}catch{}return e||(e=window._),jk=e,jk}var Nk,jL;function Due(){if(jL)return Nk;jL=1,Nk=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,a=s._prev;if(a!==s)return t(a),a},e.prototype.enqueue=function(s){var a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a},e.prototype.toString=function(){for(var s=[],a=this._sentinel,o=a._prev;o!==a;)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,a){if(s!=="_next"&&s!=="_prev")return a}return Nk}var Sk,NL;function Fue(){if(NL)return Sk;NL=1;var e=_t(),t=Js().Graph,n=Due();Sk=a;var s=e.constant(1);function a(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],k=f[0],b;h.nodeCount();){for(;b=k.dequeue();)i(h,f,p,b);for(;b=w.dequeue();)i(h,f,p,b);if(h.nodeCount()){for(var v=f.length-2;v>0;--v)if(b=f[v].dequeue(),b){m=m.concat(i(h,f,p,b,!0));break}}}return m}function i(h,f,p,m,w){var k=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(b){var v=h.edge(b),N=h.node(b.v);w&&k.push({v:b.v,w:b.w}),N.out-=v,d(f,p,N)}),e.forEach(h.outEdges(m.v),function(b){var v=h.edge(b),N=b.w,j=h.node(N);j.in-=v,d(f,p,j)}),h.removeNode(m.v),k}function c(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(v){p.setNode(v,{v,in:0,out:0})}),e.forEach(h.edges(),function(v){var N=p.edge(v.v,v.w)||0,j=f(v),S=N+j;p.setEdge(v.v,v.w,S),w=Math.max(w,p.node(v.v).out+=j),m=Math.max(m,p.node(v.w).in+=j)});var k=e.range(w+m+3).map(function(){return new n}),b=m+1;return e.forEach(p.nodes(),function(v){d(k,b,p.node(v))}),{graph:p,buckets:k,zeroIdx:b}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return Sk}var _k,SL;function Bue(){if(SL)return _k;SL=1;var e=_t(),t=Fue();_k={run:n,undo:a};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 a(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 _k}var Ck,_L;function In(){if(_L)return Ck;_L=1;var e=_t(),t=Js().Graph;Ck={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:o,predecessorWeights:i,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:w,time:k,notime:b};function n(v,N,j,S){var _;do _=e.uniqueId(S);while(v.hasNode(_));return j.dummy=N,v.setNode(_,j),_}function s(v){var N=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(j){N.setNode(j,v.node(j))}),e.forEach(v.edges(),function(j){var S=N.edge(j.v,j.w)||{weight:0,minlen:1},_=v.edge(j);N.setEdge(j.v,j.w,{weight:S.weight+_.weight,minlen:Math.max(S.minlen,_.minlen)})}),N}function a(v){var N=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(j){v.children(j).length||N.setNode(j,v.node(j))}),e.forEach(v.edges(),function(j){N.setEdge(j,v.edge(j))}),N}function o(v){var N=e.map(v.nodes(),function(j){var S={};return e.forEach(v.outEdges(j),function(_){S[_.w]=(S[_.w]||0)+v.edge(_).weight}),S});return e.zipObject(v.nodes(),N)}function i(v){var N=e.map(v.nodes(),function(j){var S={};return e.forEach(v.inEdges(j),function(_){S[_.v]=(S[_.v]||0)+v.edge(_).weight}),S});return e.zipObject(v.nodes(),N)}function c(v,N){var j=v.x,S=v.y,_=N.x-j,T=N.y-S,$=v.width/2,M=v.height/2;if(!_&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var O,I;return Math.abs(T)*$>Math.abs(_)*M?(T<0&&(M=-M),O=M*_/T,I=M):(_<0&&($=-$),O=$,I=$*T/_),{x:j+O,y:S+I}}function d(v){var N=e.map(e.range(m(v)+1),function(){return[]});return e.forEach(v.nodes(),function(j){var S=v.node(j),_=S.rank;e.isUndefined(_)||(N[_][S.order]=j)}),N}function h(v){var N=e.min(e.map(v.nodes(),function(j){return v.node(j).rank}));e.forEach(v.nodes(),function(j){var S=v.node(j);e.has(S,"rank")&&(S.rank-=N)})}function f(v){var N=e.min(e.map(v.nodes(),function(T){return v.node(T).rank})),j=[];e.forEach(v.nodes(),function(T){var $=v.node(T).rank-N;j[$]||(j[$]=[]),j[$].push(T)});var S=0,_=v.graph().nodeRankFactor;e.forEach(j,function(T,$){e.isUndefined(T)&&$%_!==0?--S:S&&e.forEach(T,function(M){v.node(M).rank+=S})})}function p(v,N,j,S){var _={width:0,height:0};return arguments.length>=4&&(_.rank=j,_.order=S),n(v,"border",_,N)}function m(v){return e.max(e.map(v.nodes(),function(N){var j=v.node(N).rank;if(!e.isUndefined(j))return j}))}function w(v,N){var j={lhs:[],rhs:[]};return e.forEach(v,function(S){N(S)?j.lhs.push(S):j.rhs.push(S)}),j}function k(v,N){var j=e.now();try{return N()}finally{console.log(v+" time: "+(e.now()-j)+"ms")}}function b(v,N){return N()}return Ck}var Ek,CL;function que(){if(CL)return Ek;CL=1;var e=_t(),t=In();Ek={run:n,undo:a};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 k,b,v;for(v=0,++d;d<f;++v,++d)m.points=[],b={width:0,height:0,edgeLabel:m,edgeObj:i,rank:d},k=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,k,{weight:m.weight},p),v===0&&o.graph().dummyChains.push(k),c=k;o.setEdge(c,h,{weight:m.weight},p)}}function a(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 Ek}var Tk,EL;function sp(){if(EL)return Tk;EL=1;var e=_t();Tk={longestPath:t,slack:n};function t(s){var a={};function o(i){var c=s.node(i);if(e.has(a,i))return c.rank;a[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,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return Tk}var Ak,TL;function u6(){if(TL)return Ak;TL=1;var e=_t(),t=Js().Graph,n=sp().slack;Ak=s;function s(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,m;a(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 a(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 Ak}var Rk,AL;function Uue(){if(AL)return Rk;AL=1;var e=_t(),t=u6(),n=sp().slack,s=sp().longestPath,a=Js().alg.preorder,o=Js().alg.postorder,i=In().simplify;Rk=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=w,c.enterEdge=k,c.exchangeEdges=b;function c(S){S=i(S),s(S);var _=t(S);p(_),d(_,S);for(var T,$;T=w(_);)$=k(_,S,T),b(_,S,T,$)}function d(S,_){var T=o(S,S.nodes());T=T.slice(0,T.length-1),e.forEach(T,function($){h(S,_,$)})}function h(S,_,T){var $=S.node(T),M=$.parent;S.edge(T,M).cutvalue=f(S,_,T)}function f(S,_,T){var $=S.node(T),M=$.parent,O=!0,I=_.edge(T,M),F=0;return I||(O=!1,I=_.edge(M,T)),F=I.weight,e.forEach(_.nodeEdges(T),function(L){var A=L.v===T,q=A?L.w:L.v;if(q!==M){var E=A===O,D=_.edge(L).weight;if(F+=E?D:-D,N(S,T,q)){var P=S.edge(T,q).cutvalue;F+=E?-P:P}}}),F}function p(S,_){arguments.length<2&&(_=S.nodes()[0]),m(S,{},1,_)}function m(S,_,T,$,M){var O=T,I=S.node($);return _[$]=!0,e.forEach(S.neighbors($),function(F){e.has(_,F)||(T=m(S,_,T,F,$))}),I.low=O,I.lim=T++,M?I.parent=M:delete I.parent,T}function w(S){return e.find(S.edges(),function(_){return S.edge(_).cutvalue<0})}function k(S,_,T){var $=T.v,M=T.w;_.hasEdge($,M)||($=T.w,M=T.v);var O=S.node($),I=S.node(M),F=O,L=!1;O.lim>I.lim&&(F=I,L=!0);var A=e.filter(_.edges(),function(q){return L===j(S,S.node(q.v),F)&&L!==j(S,S.node(q.w),F)});return e.minBy(A,function(q){return n(_,q)})}function b(S,_,T,$){var M=T.v,O=T.w;S.removeEdge(M,O),S.setEdge($.v,$.w,{}),p(S),d(S,_),v(S,_)}function v(S,_){var T=e.find(S.nodes(),function(M){return!_.node(M).parent}),$=a(S,T);$=$.slice(1),e.forEach($,function(M){var O=S.node(M).parent,I=_.edge(M,O),F=!1;I||(I=_.edge(O,M),F=!0),_.node(M).rank=_.node(O).rank+(F?I.minlen:-I.minlen)})}function N(S,_,T){return S.hasEdge(_,T)}function j(S,_,T){return T.low<=_.lim&&_.lim<=T.lim}return Rk}var Mk,RL;function Wue(){if(RL)return Mk;RL=1;var e=sp(),t=e.longestPath,n=u6(),s=Uue();Mk=a;function a(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 Mk}var $k,ML;function Hue(){if(ML)return $k;ML=1;var e=_t();$k=t;function t(a){var o=s(a);e.forEach(a.graph().dummyChains,function(i){for(var c=a.node(i),d=c.edgeObj,h=n(a,o,d.v,d.w),f=h.path,p=h.lca,m=0,w=f[m],k=!0;i!==d.w;){if(c=a.node(i),k){for(;(w=f[m])!==p&&a.node(w).maxRank<c.rank;)m++;w===p&&(k=!1)}if(!k){for(;m<f.length-1&&a.node(w=f[m+1]).minRank<=c.rank;)m++;w=f[m]}a.setParent(i,w),i=a.successors(i)[0]}})}function n(a,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=a.parent(m),d.push(m);while(m&&(o[m].low>f||p>o[m].lim));for(w=m,m=c;(m=a.parent(m))!==w;)h.push(m);return{path:d.concat(h.reverse()),lca:w}}function s(a){var o={},i=0;function c(d){var h=i;e.forEach(a.children(d),c),o[d]={low:h,lim:i++}}return e.forEach(a.children(),c),o}return $k}var Lk,$L;function zue(){if($L)return Lk;$L=1;var e=_t(),t=In();Lk={run:n,cleanup:i};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=a(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 k=c.children(w);if(!k.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:h});return}var b=t.addBorderNode(c,"_bt"),v=t.addBorderNode(c,"_bb"),N=c.node(w);c.setParent(b,w),N.borderTop=b,c.setParent(v,w),N.borderBottom=v,e.forEach(k,function(j){s(c,d,h,f,p,m,j);var S=c.node(j),_=S.borderTop?S.borderTop:j,T=S.borderBottom?S.borderBottom:j,$=S.borderTop?f:2*f,M=_!==T?1:p-m[w]+1;c.setEdge(b,_,{weight:$,minlen:M,nestingEdge:!0}),c.setEdge(T,v,{weight:$,minlen:M,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,b,{weight:0,minlen:p+m[w]})}function a(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 Lk}var Ik,LL;function Vue(){if(LL)return Ik;LL=1;var e=_t(),t=In();Ik=n;function n(a){function o(i){var c=a.children(i),d=a.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(a,"borderLeft","_bl",i,d,h),s(a,"borderRight","_br",i,d,h)}}e.forEach(a.children(),o)}function s(a,o,i,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],m=t.addDummyNode(a,"border",f,i);d[o][h]=m,a.setParent(m,c),p&&a.setEdge(p,m,{weight:1})}return Ik}var Ok,IL;function Gue(){if(IL)return Ok;IL=1;var e=_t();Ok={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){a(h.node(f))}),e.forEach(h.edges(),function(f){a(h.edge(f))})}function a(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 Ok}var Pk,OL;function Kue(){if(OL)return Pk;OL=1;var e=_t();Pk=t;function t(n){var s={},a=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(a,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(a,function(h){return n.node(h).rank});return e.forEach(d,c),i}return Pk}var Dk,PL;function Yue(){if(PL)return Dk;PL=1;var e=_t();Dk=t;function t(s,a){for(var o=0,i=1;i<a.length;++i)o+=n(s,a[i-1],a[i]);return o}function n(s,a,o){for(var i=e.zipObject(o,e.map(o,function(m,w){return w})),c=e.flatten(e.map(a,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 k=0;w>0;)w%2&&(k+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*k})),p}return Dk}var Fk,DL;function Xue(){if(DL)return Fk;DL=1;var e=_t();Fk=t;function t(n,s){return e.map(s,function(a){var o=n.inEdges(a);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:a,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:a}})}return Fk}var Bk,FL;function Zue(){if(FL)return Bk;FL=1;var e=_t();Bk=t;function t(a,o){var i={};e.forEach(a,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(a){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&&a.push(f)}}for(;a.length;){var d=a.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(a,o){var i=0,c=0;a.weight&&(i+=a.barycenter*a.weight,c+=a.weight),o.weight&&(i+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=i/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return Bk}var qk,BL;function Jue(){if(BL)return qk;BL=1;var e=_t(),t=In();qk=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(a(!!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 k={vs:e.flatten(f,!0)};return m&&(k.barycenter=p/m,k.weight=m),k}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 a(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 qk}var Uk,qL;function Que(){if(qL)return Uk;qL=1;var e=_t(),t=Xue(),n=Zue(),s=Jue();Uk=a;function a(c,d,h,f){var p=c.children(d),m=c.node(d),w=m?m.borderLeft:void 0,k=m?m.borderRight:void 0,b={};w&&(p=e.filter(p,function(T){return T!==w&&T!==k}));var v=t(c,p);e.forEach(v,function(T){if(c.children(T.v).length){var $=a(c,T.v,h,f);b[T.v]=$,e.has($,"barycenter")&&i(T,$)}});var N=n(v,h);o(N,b);var j=s(N,f);if(w&&(j.vs=e.flatten([w,j.vs,k],!0),c.predecessors(w).length)){var S=c.node(c.predecessors(w)[0]),_=c.node(c.predecessors(k)[0]);e.has(j,"barycenter")||(j.barycenter=0,j.weight=0),j.barycenter=(j.barycenter*j.weight+S.order+_.order)/(j.weight+2),j.weight+=2}return j}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 Uk}var Wk,UL;function ede(){if(UL)return Wk;UL=1;var e=_t(),t=Js().Graph;Wk=n;function n(a,o,i){var c=s(a),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return a.node(h)});return e.forEach(a.nodes(),function(h){var f=a.node(h),p=a.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(a[i](h),function(m){var w=m.v===h?m.w:m.v,k=d.edge(w,h),b=e.isUndefined(k)?0:k.weight;d.setEdge(w,h,{weight:a.edge(m).weight+b})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function s(a){for(var o;a.hasNode(o=e.uniqueId("_root")););return o}return Wk}var Hk,WL;function tde(){if(WL)return Hk;WL=1;var e=_t();Hk=t;function t(n,s,a){var o={},i;e.forEach(a,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 Hk}var zk,HL;function nde(){if(HL)return zk;HL=1;var e=_t(),t=Kue(),n=Yue(),s=Que(),a=ede(),o=tde(),i=Js().Graph,c=In();zk=d;function d(m){var w=c.maxRank(m),k=h(m,e.range(1,w+1),"inEdges"),b=h(m,e.range(w-1,-1,-1),"outEdges"),v=t(m);p(m,v);for(var N=Number.POSITIVE_INFINITY,j,S=0,_=0;_<4;++S,++_){f(S%2?k:b,S%4>=2),v=c.buildLayerMatrix(m);var T=n(m,v);T<N&&(_=0,j=e.cloneDeep(v),N=T)}p(m,j)}function h(m,w,k){return e.map(w,function(b){return a(m,b,k)})}function f(m,w){var k=new i;e.forEach(m,function(b){var v=b.graph().root,N=s(b,v,k,w);e.forEach(N.vs,function(j,S){b.node(j).order=S}),o(b,k,N.vs)})}function p(m,w){e.forEach(w,function(k){e.forEach(k,function(b,v){m.node(b).order=v})})}return zk}var Vk,zL;function sde(){if(zL)return Vk;zL=1;var e=_t(),t=Js().Graph,n=In();Vk={positionX:k,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(N,j){var S={};function _(T,$){var M=0,O=0,I=T.length,F=e.last($);return e.forEach($,function(L,A){var q=o(N,L),E=q?N.node(q).order:I;(q||L===F)&&(e.forEach($.slice(O,A+1),function(D){e.forEach(N.predecessors(D),function(P){var z=N.node(P),G=z.order;(G<M||E<G)&&!(z.dummy&&N.node(D).dummy)&&i(S,P,D)})}),O=A+1,M=E)}),$}return e.reduce(j,_),S}function a(N,j){var S={};function _($,M,O,I,F){var L;e.forEach(e.range(M,O),function(A){L=$[A],N.node(L).dummy&&e.forEach(N.predecessors(L),function(q){var E=N.node(q);E.dummy&&(E.order<I||E.order>F)&&i(S,q,L)})})}function T($,M){var O=-1,I,F=0;return e.forEach(M,function(L,A){if(N.node(L).dummy==="border"){var q=N.predecessors(L);q.length&&(I=N.node(q[0]).order,_(M,F,A,O,I),F=A,O=I)}_(M,F,M.length,I,$.length)}),M}return e.reduce(j,T),S}function o(N,j){if(N.node(j).dummy)return e.find(N.predecessors(j),function(S){return N.node(S).dummy})}function i(N,j,S){if(j>S){var _=j;j=S,S=_}var T=N[j];T||(N[j]=T={}),T[S]=!0}function c(N,j,S){if(j>S){var _=j;j=S,S=_}return e.has(N[j],S)}function d(N,j,S,_){var T={},$={},M={};return e.forEach(j,function(O){e.forEach(O,function(I,F){T[I]=I,$[I]=I,M[I]=F})}),e.forEach(j,function(O){var I=-1;e.forEach(O,function(F){var L=_(F);if(L.length){L=e.sortBy(L,function(P){return M[P]});for(var A=(L.length-1)/2,q=Math.floor(A),E=Math.ceil(A);q<=E;++q){var D=L[q];$[F]===F&&I<M[D]&&!c(S,F,D)&&($[D]=F,$[F]=T[F]=T[D],I=M[D])}}})}),{root:T,align:$}}function h(N,j,S,_,T){var $={},M=f(N,j,S,T),O=T?"borderLeft":"borderRight";function I(A,q){for(var E=M.nodes(),D=E.pop(),P={};D;)P[D]?A(D):(P[D]=!0,E.push(D),E=E.concat(q(D))),D=E.pop()}function F(A){$[A]=M.inEdges(A).reduce(function(q,E){return Math.max(q,$[E.v]+M.edge(E))},0)}function L(A){var q=M.outEdges(A).reduce(function(D,P){return Math.min(D,$[P.w]-M.edge(P))},Number.POSITIVE_INFINITY),E=N.node(A);q!==Number.POSITIVE_INFINITY&&E.borderType!==O&&($[A]=Math.max($[A],q))}return I(F,M.predecessors.bind(M)),I(L,M.successors.bind(M)),e.forEach(_,function(A){$[A]=$[S[A]]}),$}function f(N,j,S,_){var T=new t,$=N.graph(),M=b($.nodesep,$.edgesep,_);return e.forEach(j,function(O){var I;e.forEach(O,function(F){var L=S[F];if(T.setNode(L),I){var A=S[I],q=T.edge(A,L);T.setEdge(A,L,Math.max(M(N,F,I),q||0))}I=F})}),T}function p(N,j){return e.minBy(e.values(j),function(S){var _=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(S,function($,M){var O=v(N,M)/2;_=Math.max($+O,_),T=Math.min($-O,T)}),_-T})}function m(N,j){var S=e.values(j),_=e.min(S),T=e.max(S);e.forEach(["u","d"],function($){e.forEach(["l","r"],function(M){var O=$+M,I=N[O],F;if(I!==j){var L=e.values(I);F=M==="l"?_-e.min(L):T-e.max(L),F&&(N[O]=e.mapValues(I,function(A){return A+F}))}})})}function w(N,j){return e.mapValues(N.ul,function(S,_){if(j)return N[j.toLowerCase()][_];var T=e.sortBy(e.map(N,_));return(T[1]+T[2])/2})}function k(N){var j=n.buildLayerMatrix(N),S=e.merge(s(N,j),a(N,j)),_={},T;e.forEach(["u","d"],function(M){T=M==="u"?j:e.values(j).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(T=e.map(T,function(A){return e.values(A).reverse()}));var I=(M==="u"?N.predecessors:N.successors).bind(N),F=d(N,T,S,I),L=h(N,T,F.root,F.align,O==="r");O==="r"&&(L=e.mapValues(L,function(A){return-A})),_[M+O]=L})});var $=p(N,_);return m(_,$),w(_,N.graph().align)}function b(N,j,S){return function(_,T,$){var M=_.node(T),O=_.node($),I=0,F;if(I+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":F=-M.width/2;break;case"r":F=M.width/2;break}if(F&&(I+=S?F:-F),F=0,I+=(M.dummy?j:N)/2,I+=(O.dummy?j:N)/2,I+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":F=O.width/2;break;case"r":F=-O.width/2;break}return F&&(I+=S?F:-F),F=0,I}}function v(N,j){return N.node(j).width}return Vk}var Gk,VL;function rde(){if(VL)return Gk;VL=1;var e=_t(),t=In(),n=sde().positionX;Gk=s;function s(o){o=t.asNonCompoundGraph(o),a(o),e.forEach(n(o),function(i,c){o.node(c).x=i})}function a(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 Gk}var Kk,GL;function ade(){if(GL)return Kk;GL=1;var e=_t(),t=Bue(),n=que(),s=Wue(),a=In().normalizeRanks,o=Hue(),i=In().removeEmptyRanks,c=zue(),d=Vue(),h=Gue(),f=nde(),p=rde(),m=In(),w=Js().Graph;Kk=k;function k(U,Y){var X=Y&&Y.debugTiming?m.time:m.notime;X("layout",function(){var Z=X(" buildLayoutGraph",function(){return I(U)});X(" runLayout",function(){b(Z,X)}),X(" updateInputGraph",function(){v(U,Z)})})}function b(U,Y){Y(" makeSpaceForEdgeLabels",function(){F(U)}),Y(" removeSelfEdges",function(){V(U)}),Y(" acyclic",function(){t.run(U)}),Y(" nestingGraph.run",function(){c.run(U)}),Y(" rank",function(){s(m.asNonCompoundGraph(U))}),Y(" injectEdgeLabelProxies",function(){L(U)}),Y(" removeEmptyRanks",function(){i(U)}),Y(" nestingGraph.cleanup",function(){c.cleanup(U)}),Y(" normalizeRanks",function(){a(U)}),Y(" assignRankMinMax",function(){A(U)}),Y(" removeEdgeLabelProxies",function(){q(U)}),Y(" normalize.run",function(){n.run(U)}),Y(" parentDummyChains",function(){o(U)}),Y(" addBorderSegments",function(){d(U)}),Y(" order",function(){f(U)}),Y(" insertSelfEdges",function(){H(U)}),Y(" adjustCoordinateSystem",function(){h.adjust(U)}),Y(" position",function(){p(U)}),Y(" positionSelfEdges",function(){B(U)}),Y(" removeBorderNodes",function(){G(U)}),Y(" normalize.undo",function(){n.undo(U)}),Y(" fixupEdgeLabelCoords",function(){P(U)}),Y(" undoCoordinateSystem",function(){h.undo(U)}),Y(" translateGraph",function(){E(U)}),Y(" assignNodeIntersects",function(){D(U)}),Y(" reversePoints",function(){z(U)}),Y(" acyclic.undo",function(){t.undo(U)})}function v(U,Y){e.forEach(U.nodes(),function(X){var Z=U.node(X),J=Y.node(X);Z&&(Z.x=J.x,Z.y=J.y,Y.children(X).length&&(Z.width=J.width,Z.height=J.height))}),e.forEach(U.edges(),function(X){var Z=U.edge(X),J=Y.edge(X);Z.points=J.points,e.has(J,"x")&&(Z.x=J.x,Z.y=J.y)}),U.graph().width=Y.graph().width,U.graph().height=Y.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],j={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],_=["width","height"],T={width:0,height:0},$=["minlen","weight","width","height","labeloffset"],M={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function I(U){var Y=new w({multigraph:!0,compound:!0}),X=ee(U.graph());return Y.setGraph(e.merge({},j,W(X,N),e.pick(X,S))),e.forEach(U.nodes(),function(Z){var J=ee(U.node(Z));Y.setNode(Z,e.defaults(W(J,_),T)),Y.setParent(Z,U.parent(Z))}),e.forEach(U.edges(),function(Z){var J=ee(U.edge(Z));Y.setEdge(Z,e.merge({},M,W(J,$),e.pick(J,O)))}),Y}function F(U){var Y=U.graph();Y.ranksep/=2,e.forEach(U.edges(),function(X){var Z=U.edge(X);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function L(U){e.forEach(U.edges(),function(Y){var X=U.edge(Y);if(X.width&&X.height){var Z=U.node(Y.v),J=U.node(Y.w),te={rank:(J.rank-Z.rank)/2+Z.rank,e:Y};m.addDummyNode(U,"edge-proxy",te,"_ep")}})}function A(U){var Y=0;e.forEach(U.nodes(),function(X){var Z=U.node(X);Z.borderTop&&(Z.minRank=U.node(Z.borderTop).rank,Z.maxRank=U.node(Z.borderBottom).rank,Y=e.max(Y,Z.maxRank))}),U.graph().maxRank=Y}function q(U){e.forEach(U.nodes(),function(Y){var X=U.node(Y);X.dummy==="edge-proxy"&&(U.edge(X.e).labelRank=X.rank,U.removeNode(Y))})}function E(U){var Y=Number.POSITIVE_INFINITY,X=0,Z=Number.POSITIVE_INFINITY,J=0,te=U.graph(),ce=te.marginx||0,he=te.marginy||0;function le(re){var ae=re.x,de=re.y,_e=re.width,fe=re.height;Y=Math.min(Y,ae-_e/2),X=Math.max(X,ae+_e/2),Z=Math.min(Z,de-fe/2),J=Math.max(J,de+fe/2)}e.forEach(U.nodes(),function(re){le(U.node(re))}),e.forEach(U.edges(),function(re){var ae=U.edge(re);e.has(ae,"x")&&le(ae)}),Y-=ce,Z-=he,e.forEach(U.nodes(),function(re){var ae=U.node(re);ae.x-=Y,ae.y-=Z}),e.forEach(U.edges(),function(re){var ae=U.edge(re);e.forEach(ae.points,function(de){de.x-=Y,de.y-=Z}),e.has(ae,"x")&&(ae.x-=Y),e.has(ae,"y")&&(ae.y-=Z)}),te.width=X-Y+ce,te.height=J-Z+he}function D(U){e.forEach(U.edges(),function(Y){var X=U.edge(Y),Z=U.node(Y.v),J=U.node(Y.w),te,ce;X.points?(te=X.points[0],ce=X.points[X.points.length-1]):(X.points=[],te=J,ce=Z),X.points.unshift(m.intersectRect(Z,te)),X.points.push(m.intersectRect(J,ce))})}function P(U){e.forEach(U.edges(),function(Y){var X=U.edge(Y);if(e.has(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(U){e.forEach(U.edges(),function(Y){var X=U.edge(Y);X.reversed&&X.points.reverse()})}function G(U){e.forEach(U.nodes(),function(Y){if(U.children(Y).length){var X=U.node(Y),Z=U.node(X.borderTop),J=U.node(X.borderBottom),te=U.node(e.last(X.borderLeft)),ce=U.node(e.last(X.borderRight));X.width=Math.abs(ce.x-te.x),X.height=Math.abs(J.y-Z.y),X.x=te.x+X.width/2,X.y=Z.y+X.height/2}}),e.forEach(U.nodes(),function(Y){U.node(Y).dummy==="border"&&U.removeNode(Y)})}function V(U){e.forEach(U.edges(),function(Y){if(Y.v===Y.w){var X=U.node(Y.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:Y,label:U.edge(Y)}),U.removeEdge(Y)}})}function H(U){var Y=m.buildLayerMatrix(U);e.forEach(Y,function(X){var Z=0;e.forEach(X,function(J,te){var ce=U.node(J);ce.order=te+Z,e.forEach(ce.selfEdges,function(he){m.addDummyNode(U,"selfedge",{width:he.label.width,height:he.label.height,rank:ce.rank,order:te+ ++Z,e:he.e,label:he.label},"_se")}),delete ce.selfEdges})})}function B(U){e.forEach(U.nodes(),function(Y){var X=U.node(Y);if(X.dummy==="selfedge"){var Z=U.node(X.e.v),J=Z.x+Z.width/2,te=Z.y,ce=X.x-J,he=Z.height/2;U.setEdge(X.e,X.label),U.removeNode(Y),X.label.points=[{x:J+2*ce/3,y:te-he},{x:J+5*ce/6,y:te-he},{x:J+ce,y:te},{x:J+5*ce/6,y:te+he},{x:J+2*ce/3,y:te+he}],X.label.x=X.x,X.label.y=X.y}})}function W(U,Y){return e.mapValues(e.pick(U,Y),Number)}function ee(U){var Y={};return e.forEach(U,function(X,Z){Y[Z.toLowerCase()]=X}),Y}return Kk}var Yk,KL;function ode(){if(KL)return Yk;KL=1;var e=_t(),t=In(),n=Js().Graph;Yk={debugOrdering:s};function s(a){var o=t.buildLayerMatrix(a),i=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(c){i.setNode(c,{label:c}),i.setParent(c,"layer"+a.node(c).rank)}),e.forEach(a.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 Yk}var Xk,YL;function ide(){return YL||(YL=1,Xk="0.8.5"),Xk}var Zk,XL;function lde(){return XL||(XL=1,Zk={graphlib:Js(),layout:ade(),debug:ode(),util:{time:In().time,notime:In().notime},version:ide()}),Zk}var cde=lde();const ZL=H1(cde);function ude(e,t,n){const s=Lp(e,a=>!t.has(a.id)&&n(a.id)!=null);if(s.size===0)return e;for(const a of s.values())a.sort((o,i)=>o.id.localeCompare(i.id));return e.map(a=>{var h;if(t.has(a.id)||n(a.id))return a;const o=s.get(Qn(a));if(!o)return a;const i=(h=a.data)==null?void 0:h.parentId,c=o.find(f=>f.id===i)??o[0],d=n(c.id);return{...a,position:{x:a.position.x+d.x-c.position.x,y:a.position.y+d.y-c.position.y}}})}function dde(e,t,n,s,a,o,i){const c=S=>Nu(S,s,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:_,h:T}=Ff(S,s);return{cw:_,ch:T}},f=i!=null&&i.width>0&&i.height>0,p=Lp(e,S=>d(S.id)!=null),m=new Set;for(const[S,_]of p)_.every(T=>a.has(T.id)&&!n.has(T.id))&&m.add(S);const w=new Map,k=[];for(const S of e){const _=d(S.id);if(!_)continue;const{w:T,h:$}=c(S.id),M=Qn(S);m.has(M)?(w.get(M)??w.set(M,[]).get(M)).push(S):k.push({sid:M,x:_.x,y:_.y,w:T,h:$,...h(S.id)})}if(w.size===0||f&&k.length===0)return[];const b=Pf,v=(S,_,T,$)=>k.some(M=>S<M.x+M.w+G0&&M.x<S+T+G0&&_<M.y+M.h+b&&M.y<_+$+b),N=mP(e,s),j=[];for(const S of[...w.keys()].sort()){const _=w.get(S);let T=1/0,$=1/0,M=-1/0,O=-1/0,I=-1/0,F=-1/0;for(const G of _){const V=d(G.id),{w:H,h:B}=c(G.id),{cw:W,ch:ee}=h(G.id);T=Math.min(T,V.x),$=Math.min($,V.y),M=Math.max(M,V.x+H),O=Math.max(O,V.y+B),I=Math.max(I,V.x+W),F=Math.max(F,V.y+ee)}const L=M-T,A=O-$,q=new Map;for(const G of k)q.set(G.sid,Math.min(q.get(G.sid)??1/0,G.x));const E=[...new Set([...q.values()].map(G=>Math.round(G)))].sort((G,V)=>G-V),D=E.length?E:[T],P=[0,...k.map(G=>G.y+G.h+b)].sort((G,V)=>G-V);let z=null;if(f){let G=1/0,V=1/0,H=-1/0,B=-1/0;for(const Z of k)G=Math.min(G,Z.x),V=Math.min(V,Z.y),H=Math.max(H,Z.x+Z.cw),B=Math.max(B,Z.y+Z.ch);const W=(Z,J)=>{const te=i.width/(Math.max(H,Z+I-T)-Math.min(G,Z)+Df),ce=i.height/(Math.max(B,J+F-$)-Math.min(V,J));return[Math.min(gP,te,ce),Math.min(te,ce),Math.max(te,ce)]},ee=(Z,J)=>{for(let te=0;te<Z.length;te++){if(Z[te]>J[te]+1e-9)return!0;if(Z[te]<J[te]-1e-9)return!1}return!1},U=Math.round(H+Df+N),Y=[...new Set([...P,V])].sort((Z,J)=>Z-J);let X=null;for(const Z of[...D,U])for(const J of Y){if(v(Z,J,L,A))continue;const te=W(Z,J);(X===null||ee(te,X))&&(X=te,z={x:Z,y:J})}z&&z.x===T&&z.y===$&&(z=null)}else e:for(const G of D)for(const V of P){if(V>=$)break;if(!v(G,V,L,A)){z={x:G,y:V};break e}}if(z){const G=z.x-T,V=z.y-$;for(const H of _){const B=d(H.id);t.set(H.id,{x:B.x+G,y:B.y+V})}j.push(S)}for(const G of _){const V=d(G.id),{w:H,h:B}=c(G.id);k.push({sid:S,x:V.x,y:V.y,w:H,h:B,...h(G.id)})}}return j}function hde(e,t,n,s,a,o){const i=m=>Nu(m,s,a),c=new Map(e.map(m=>[m.id,Qn(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:k,h:b}=i(m);d.push({x:w.x,y:w.y,w:k,h:b,sid:c.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:k,h:b}=i(m),v=c.get(m)??"_default";if(n.has(m)){d.push({x:w.x,y:w.y,w:k,h:b,sid:v});continue}let N=w.y;for(let j=0;j<d.length+1;j++){const S=d.find(_=>{const T=_.sid===v?af:pP,$=_.sid===v?af:Pf;return w.x<_.x+_.w+T&&_.x<w.x+k+T&&N<_.y+_.h+$&&_.y<N+b+$});if(!S)break;N=S.y+S.h+(S.sid===v?af:Pf)}N!==w.y&&(t.set(m,{x:w.x,y:N}),p.push(m)),d.push({x:w.x,y:N,w:k,h:b,sid:v})}return p}function fde(e,t,n,s,a,o=!1,i){const d=pP+1,h=Pf+1,f=8,p=1.75,m=200,w=.7,k=.01,b=A=>Nu(A,s,i),v=A=>n.get(A)??t.get(A),N=Lp(e,A=>v(A.id)!=null),j=[],S=new Set,_=new Set,T=a.size===0;for(const A of[...N.keys()].sort()){const q=N.get(A);let E=1/0,D=1/0,P=-1/0,z=-1/0,G=!1;for(const W of q){const ee=v(W.id),{w:U,h:Y}=b(W.id);E=Math.min(E,ee.x),D=Math.min(D,ee.y),P=Math.max(P,ee.x+U),z=Math.max(z,ee.y+Y),n.has(W.id)&&(G=!0)}const V=P-E,H=z-D;_.add(A);const B=a.get(A);B&&(V>B.w+f||H>B.h+f)&&S.add(A),a.set(A,{w:V,h:H}),j.push({sid:A,members:q.map(W=>W.id),x:E,y:D,w:V,h:H,anchored:G,mass:1})}for(const A of[...a.keys()])_.has(A)||a.delete(A);if(o||T)return[];let $=!1;for(let A=0;A<j.length&&!$;A++)for(let q=A+1;q<j.length;q++){const E=j[A],D=j[q];if(!(E.anchored&&D.anchored)&&Math.abs(E.x+E.w/2-(D.x+D.w/2))<(E.w+D.w)/2+d&&Math.abs(E.y+E.h/2-(D.y+D.h/2))<(E.h+D.h)/2+h){$=!0;break}}if(S.size===0&&!$)return[];if(S.size>0)for(const A of j)S.has(A.sid)&&(A.mass=8);else for(const A of j)A.mass=Math.max(1,A.w*A.h/(ju*fP));const M=new Map(j.map(A=>[A.sid,A.x])),O=new Map(j.map(A=>[A.sid,A.y])),I=new Map(j.map(A=>[A.sid,Math.min(0,A.x)])),F=new Map(j.map(A=>[A.sid,Math.min(0,A.y)]));for(let A=0;A<m;A++){const q=new Map,E=new Map;let D=0;for(let P=0;P<j.length;P++)for(let z=P+1;z<j.length;z++){const G=j[P],V=j[z];if(G.anchored&&V.anchored)continue;const H=G.x+G.w/2,B=G.y+G.h/2,W=V.x+V.w/2,ee=V.y+V.h/2,U=(G.w+V.w)/2+d-Math.abs(H-W),Y=(G.h+V.h)/2+h-Math.abs(B-ee);if(U<=0||Y<=0)continue;const X=(Te,at)=>!Te.anchored&&!(at<0&&Te.x<=I.get(Te.sid)),Z=(Te,at)=>!Te.anchored&&!(at<0&&Te.y<=F.get(Te.sid)),J=(Te,at,Je)=>{const Ve=Te===at,be=Ve?G.sid<V.sid?-1:1:Math.sign(Te-at);return Je(G,be)||Je(V,-be)?be:Ve&&(Je(G,-be)||Je(V,be))?-be:0},te=J(H,W,X),ce=J(B,ee,Z),he=te!==0,le=ce!==0;if(!he&&!le)continue;const re=he&&(!le||U*p<Y),[ae,de,_e,fe]=re?[te,U,q,X]:[ce,Y,E,Z],ye=fe(G,ae),ke=fe(V,-ae),Ne=G.mass,ge=V.mass,Me=ye?ke?ge/(Ne+ge):1:0,Ie=ke?ye?Ne/(Ne+ge):1:0,We=de*w;_e.set(G.sid,(_e.get(G.sid)??0)+ae*We*Me),_e.set(V.sid,(_e.get(V.sid)??0)-ae*We*Ie),D+=We}for(const P of j)P.anchored||(P.x=Math.max(I.get(P.sid),P.x+(q.get(P.sid)??0)),P.y=Math.max(F.get(P.sid),P.y+(E.get(P.sid)??0)));if(D<k)break}const L=[];for(const A of j){const q=A.x-M.get(A.sid),E=A.y-O.get(A.sid);if(!(Math.abs(q)<1&&Math.abs(E)<1)){for(const D of A.members){if(n.has(D))continue;const P=t.get(D);P&&t.set(D,{x:P.x+q,y:P.y+E})}L.push(A.sid)}}return L}function pde(e,t,n,s,a,o){const i=new ZL.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(N=>!a.has(N)),d=new Set(c);for(const N of c){const{w:j,h:S}=Nu(N,s,o);i.setNode(N,{width:j,height:S})}for(const N of t)d.has(N.source)&&d.has(N.target)&&i.setEdge(N.source,N.target);ZL.layout(i);const h=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const N of c){const j=i.node(N);if(!j)continue;const{w:S,h:_}=Ff(N,s),T=Nu(N,s,o),$=j.x-T.w/2,M=j.y-T.h/2;h.set(N,{x:$,y:M}),$<f&&(f=$),M<p&&(p=M),$+S>m&&(m=$+S),M+_>w&&(w=M+_)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,j]of h)h.set(N,{x:j.x-f,y:j.y-p});const k=Number.isFinite(m)?m-f:0,b=Number.isFinite(w)?w-p:0;let v=null;for(const N of e){const j=a.get(N);if(!j)continue;const{w:S,h:_}=Ff(N,s);v=v===null?{minX:j.x,minY:j.y,maxX:j.x+S,maxY:j.y+_}:{minX:Math.min(v.minX,j.x),minY:Math.min(v.minY,j.y),maxX:Math.max(v.maxX,j.x+S),maxY:Math.max(v.maxY,j.y+_)}}return{positions:h,width:k,height:b,pinnedBox:v}}function d6(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,c=Lp(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...pde(c.get(f).map(p=>p.id),t,s,o,a,i)})),gap:mP(e,o)}}const h6=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Df,mde=e=>e.reduce((t,n)=>t+n.height,0)+xl*Math.max(0,e.length-1);function k1(e,t,n,s){const a=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+xl;return h},o=[];for(let d=0;d<e.length;d++){let h=-xl;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+xl)}o.sort((d,h)=>d-h);const i=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;a(o[p]).length<=d?f=p:h=p+1}return a(o[h])};let c=[e];if(n>0&&s>0){const d=f=>RX(f.reduce((p,m)=>p+h6(m),0)+t*(f.length-1),Math.max(...f.map(mde)),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 gde(e,t,n,s,a){if(!(s.width>0&&s.height>0&&a.width>0&&a.height>0))return!1;const{laid:o,gap:i}=d6(e,t,n);return o.length<2?!1:k1(o,i,s.width,s.height).length!==k1(o,i,a.width,a.height).length}function yde(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=d6(e,t,n),i=k1(a,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of i){const f=h6(h);let p=0;for(const{positions:m,height:w,pinnedBox:k}of h){for(const[v,N]of m)c.set(v,{x:N.x+d,y:N.y+p});let b=p+w;k&&k.maxY>b&&k.minX<d+f&&d<k.maxX&&(b=k.maxY),p=b+xl}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 hf(e,t,n){return!t.has(e)||n.has(e)}function wde(e,t,n,s){return!t.has(e)&&hf(e,n,s)}function xde(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function JL(e,t,n,s){n.set(e,t),s.delete(e)}const vde=300,QL=130,bde=160,eI=new WeakMap;function kde(e,t){let n=eI.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:rG(e.agents.values()),groups:vp(e.agents.values())},eI.set(e,n));const{byId:s,branches:a,groups:o}=n;return i=>{let c=s.get(i.id);if(!c){const d=i.kind==="root"?a.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 MN(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 jde(e,t){const n=i=>Qn(i),s=new Map;for(const i of e){const c=n(i),d=i.position.x+(i.width??ju),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 a=[];for(const[i,c]of[...s].sort((d,h)=>d[1].minX-h[1].minX)){const d=a[a.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:i,top:c.minY})):a.push({maxX:c.maxX,sessions:[{sid:i,top:c.minY}]})}const o=new Map;for(const i of a)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 Nde(e,t){var s;let n=0;for(let a=t.parentId;a!=null&&n<e.agents.size;a=(s=e.agents.get(a))==null?void 0:s.parentId)n++;return n}function Sde(e,t,n,s,a,o,i,c,d,h,f,p,m,w,k,b,v,N,j,S){var G,V,H,B;const _=[],T=[],$=kde(e,N);for(const W of e.agents.values()){if(!v.has(W.id))continue;const ee=W.exitAt!=null,U=b!=null&&!b.has(W.id),Y=[ee?"rf-exiting":"",U?"rf-spotlit-out":"",k.has(W.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(W.id);if(_.push({id:W.id,type:"agent",position:{x:0,y:0},data:$(W),className:Y,ariaLabel:gV(W,t,k.has(W.id)),...X?{width:X.width,height:X.height}:null}),W.parentId&&v.has(W.parentId)){const te=xu(W.sessionId),ce=ee,he=k.size>0&&(k.has(W.id)||k.has(W.parentId)),le=b!=null&&!b.has(W.id)&&!b.has(W.parentId),re=W.state==="active"?2:1.5,ae=he?re+1.5:re,de=ce?.2:le?.12:1,_e=["sess-edge",W.state==="active"?"sess-live":"sess-idle",ce?"rf-edge-exiting":"",he?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${W.parentId}->${W.id}`,source:W.parentId,target:W.id,animated:(W.state==="active"||he)&&!ce,type:"smoothstep",style:{"--session-hue":te,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:de,transition:"var(--edge-transition)"},className:_e})}const Z=W.kind==="root"?Ep(W):null,J=Z?Z.key:null;if(Z&&J&&!KV(J)){const te=kj(W.id),ce=xu(W.sessionId),he=o.get(te);_.push({id:te,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,canvasSessionId:$(W).canvasSessionId,parentId:W.id,note:Z,noteKey:J,hue:ce},className:U?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Z.kind==="recap"?`Claude Code's recap for ${W.label}`:`${W.label}: ${no(Z.kind)}`,...he?{width:he.width,height:he.height}:null}),T.push({id:`e:recap:${W.id}`,source:te,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ce}})}}const M=MN(e),O=S.size>0&&!(d&&j);O||S.clear();const I=_.filter(W=>W.data.provider==="codex"&&W.data.parentId).map(W=>`${W.id}:${Qn(W)}:${W.data.parentId}`).sort().join("|"),F=`${m}${I?`#codex:${I}`:""}#lanes:${LX(M)}${O?"#held":""}`,L=new Set(_.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(f.keys()))j&&JV(W)&&!L.has(W)&&!a.has(W)&&(f.delete(W),p.delete(W));const A=_.filter(W=>wde(W.id,a,f,p));if(A.length>0||F!==w.current){if(A.length>0){for(const ee of A)S.delete(ee.id);const W=ude(yde(_,T,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:M}),a,ee=>hf(ee,f,p)?void 0:f.get(ee));for(const ee of W)hf(ee.id,f,p)&&JL(ee.id,ee.position,f,p);dde(_,f,a,o,new Set(A.filter(ee=>ee.type!=="recapNote").map(ee=>ee.id)),M,{width:n,height:s});for(const ee of A){if(ee.type!=="recapNote")continue;const U=(G=ee.data)==null?void 0:G.parentId;if(!U)continue;const Y=a.get(U)??(hf(U,f,p)?void 0:f.get(U));if(!Y)continue;const X=((V=o.get(ee.id))==null?void 0:V.width)??vde,Z=((H=o.get(ee.id))==null?void 0:H.height)??QL,J=((B=o.get(U))==null?void 0:B.height)??QL;JL(ee.id,{x:Y.x-bde-X,y:Y.y+(J-Z)/2},f,p)}}hde(_,f,a,o,M,O?S:void 0),w.current=F}const q=fde(_,f,a,o,i,!d||h,M);q.length>0&&c(q);const E=Wie(e.agents.values());j&&Hh(f,E),Hh(p,E),j&&Hh(a,E),Hh(o,Uie(e.agents.values()));const D=[];let P=!1;for(const W of _){let ee=a.get(W.id)??f.get(W.id);ee||(ee=xde(W.id,f,p),P=!0),D.push({...W,position:ee})}return P&&(w.current=""),{nodes:jde(D,W=>{if(W.type==="recapNote")return-1;const ee=e.agents.get(W.id);return ee?Nde(e,ee):0}),edges:T}}function _de(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Cde(e,t,n){var i;if(e.length===0)return null;const s=_de(e),a=t?s.findIndex(c=>c.id===t):-1,o=a===-1?n===1?0:s.length-1:(a+n+s.length)%s.length;return((i=s[o])==null?void 0:i.id)??null}const Ede=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function Tde(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Ede.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Ade=new Set(["","BODY","HTML","#DOCUMENT"]);function Rde(e){return!e||Ko(e)?!1:!Ade.has(String(e.tagName??"").toUpperCase())}const f6="react-flow__node";function $N(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,f6))===!0}function p6(e){try{const t=document.querySelector(`.${f6}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Zo=null,dl=null;const j1=new Set,N1=()=>{for(const e of j1)e()},Mde=e=>(j1.add(e),()=>{j1.delete(e)}),tI=()=>Zo,$de=90;function m6(e){!dl||e!=null&&dl.at.id!==e||(clearTimeout(dl.timer),dl=null)}function g6(e,t,n="pointer"){m6();const s={id:e,anchor:t,by:n};if(Zo||n==="focus"){Zo=s,N1();return}dl={at:s,timer:setTimeout(()=>{dl=null,Zo=s,N1()},$de)}}function io(e){m6(e),!(!Zo||e!=null&&Zo.id!==e)&&(Zo=null,N1())}function Lde({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=y.useSyncExternalStore(Mde,tI,tI),o=a?e(a.id):void 0,i=a&&!o?t(a.id):void 0,c=a!=null&&(!o&&!i||!a.anchor.isConnected);return y.useEffect(()=>{c&&a&&io(a.id)},[c,a]),!a||c?null:o?r.jsx(Ode,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(Ide,{r:i,anchor:a.anchor,bounds:s},a.id):null}function y6(e,t){const n=y.useRef(null),s=y.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=Yj(e.getBoundingClientRect(),{width:a.offsetWidth,height:a.offsetHeight},t());a.style.top=`${o.top}px`,a.style.left=`${o.left}px`,a.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,a.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{s()}),n}function Ide({r:e,anchor:t,bounds:n}){const s=y6(t,n),a=Nr(3e4),o=e.note,i=o.kind==="recap",c=Af(o.at,a);return xt.createPortal(r.jsxs("div",{ref:s,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsxs("span",{className:"recap-peek-mark",children:[r.jsx(Ef,{recap:i}),no(o.kind)]}),r.jsx("span",{className:"node-peek-time",title:c.title,children:c.label})]}),e.sessionLabel&&r.jsx("div",{className:"node-peek-kind",children:r.jsxs("span",{children:[Tp(o)," · ",e.sessionLabel]})}),r.jsx("p",{className:"recap-peek-text",children:o.text}),o.reply&&r.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function Ode({a:e,anchor:t,parentLabel:n,bounds:s}){const a=y6(t,s),o=Nr(1e3),i=_p(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(b=>!b.endedAt).length,h=On(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Mn(e.waiting),m=g4(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",k=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${wt(f)} tok`:null,h>0?`${nt(h)}${El(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return xt.createPortal(r.jsxs("div",{ref:a,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsx("span",{className:"node-peek-name",title:e.label,children:e.label}),r.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Rl(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":I0(yl(e)),children:[r.jsx(D4,{kind:I0(yl(e))}),Tl(yl(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:jp(e.model,e.effort)}):null]}),e.kind==="root"&&i.face&&r.jsx("p",{className:"node-peek-title",title:i.face,children:i.face}),e.kind==="root"&&e.waiting&&r.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&r.jsx(Sj,{}),r.jsxs("span",{className:"node-peek-said",title:_f(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:Rl(e.waiting.since,void 0,o)})}),_f(e.waiting)]})]}),m&&r.jsxs("p",{className:"node-peek-blind",children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),m.label]}),r.jsxs("p",{className:"node-peek-facts",children:[k,c>0&&r.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&r.jsx("p",{className:"node-peek-branch",children:R4(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Pde(e){const t=e.minZoom??Goe,n=e.maxZoom??Koe,s=e.fill??.9,a=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,k,b,v,N,j)=>{let S=w+(k-v*p)/2-b*p;const _=N*p+S,T=(N+j)*p+S;return j*p<=k?_<w?S+=w-_:T>w+k&&(S-=T-(w+k)):S+=w-_,S};return{x:m(a,i,d.x,d.width,h.x,h.width),y:m(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Dde(e){let t=1/0,n=1/0,s=-1/0,a=-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),a=Math.max(a,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:s-t,height:a-n}:null}function Rn(e){const t=y.useRef(e);return t.current=e,t}const S1=80,_1=.86;function w6(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 a=s.getBoundingClientRect();a.width>0&&a.left>t.left&&(n=Math.min(n,a.left))}return Math.max(0,t.right-n)}function Fde({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,c]=y.useState(0);y.useEffect(()=>{const p=w6(e.current);c(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const d=Rn(i),h=t.w>0?Math.max(0,(t.w-i-S1*2)*_1):0,f=t.h>0?Math.max(0,(t.h-S1*2)*_1):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const nI=1e-6;function cu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function sI(e,t,n){return Math.abs(e[2]-t[2])<=nI*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=nI*n}function Bde(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 qde(e,t,n){const s=e(0),a=e(.5),o=e(1);if(!cu(s)||!cu(a)||!cu(o))return!1;const i=Math.max(t[2],n[2]);return sI(s,t,i)&&sI(o,n,i)}function Ude(e){return(t,n)=>{const s=e(t,n),a=qde(s,t,n)?s:Bde(t,n);let o=cu(t)?t:n;return i=>{const c=a(i);return cu(c)&&(o=c),o}}}function Wde(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const rI=new WeakSet,x6=420;function Hde(){const e=Il(),t=Ft(),n=y.useCallback((h,f)=>{if(!Wde(h))return;if(T0({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||rI.has(f)||(rI.add(f),f.interpolate(Ude(f.interpolate())))};return h(t.getState().d3Zoom),t.subscribe(f=>h(f.d3Zoom))},[t]);const s=y.useRef(null),a=y.useRef(0),o=y.useRef(0),i=y.useCallback((h,f)=>{const p=++a.current;return o.current=Date.now(),n(h,f),s.current=T0({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),c=y.useCallback((h=500)=>{const f=S1,p=1,m=.2,w=_1;try{const k=document.querySelector(".canvas-wrap"),b=Array.from(document.querySelectorAll(".react-flow__node")).filter(D=>D.offsetWidth>0);if(!k||b.length===0)return;const v=k.getBoundingClientRect(),N=e.getViewport();if(!Number.isFinite(N.zoom)||N.zoom<=0)return;const j=new Map(e.getNodes().map(D=>[D.id,D])),S=b.flatMap(D=>{const P=j.get(D.dataset.id??"");if(!P)return[];const z=P.positionAbsolute??P.position,G=P.width??D.offsetWidth,V=P.height??D.offsetHeight;return G>0&&V>0?[{left:z.x,right:z.x+G,top:z.y,bottom:z.y+V}]:[]});if(S.length===0)return;const _=Math.min(...S.map(D=>D.left)),T=Math.max(...S.map(D=>D.right)),$=Math.min(...S.map(D=>D.top)),M=Math.max(...S.map(D=>D.bottom)),O=T-_,I=M-$;if(!(O>0&&I>0))return;const F=w6(k),L=D=>Math.max(m,Math.min(p,(v.width-F-f*2)/(O+D)*w,(v.height-f*2)/I*w)),A=Voe(L(x6),L(0),e5(Pj[Dj()])),q={x:f-_*A,y:(v.height>v.width-F?f:Math.max(f,(v.height-I*A)/2))-$*A,zoom:A},E=i(q,h);window.setTimeout(()=>{var D;try{if(((D=s.current)==null?void 0:D.target)===q&&(s.current=null),a.current!==E)return;const P=e.getViewport();(Math.abs(P.zoom-A)>.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:a,lastFitTimeRef:o}}const zde=450;function Vde({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:s,railInsetRef:a,moveCamera:o,disableAutoFit:i,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(k=>{const b=e.current,v=t.current.agents.get(k);if(!b||!v)return;const N=MN(t.current),j=(O,I)=>{const F=n.current.get(O.id);if(!F)return null;const L=I&&N.has(O.id)?x6:0;return{x:O.position.x,y:O.position.y,width:F.width+L,height:F.height}},S=s.current.find(O=>O.id===k),_=S?j(S,!1):null;if(!_)return;const T=[];for(const O of s.current){if(O.type!=="agent"&&O.type!=="recapNote"||Qn(O)!==Qn(S))continue;const I=j(O,O.type==="agent");I&&T.push(I)}const $=b.getBoundingClientRect(),M=Pde({pane:{width:$.width,height:$.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:Dde(T)??_,anchor:_});io(),i(),c.current={id:k,at:Date.now()},o(M,zde)},[o,i]);d.current=p;const m=y.useCallback(k=>{const b=s.current.filter(S=>S.type==="agent"),v=Cde(b.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,k),N=v?b.find(S=>S.id===v):void 0;if(!N)return;const j=$N(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}j&&p6(N.id)},30)},[h,p]),w=y.useCallback(k=>{h(k,!1),window.setTimeout(()=>{try{p(k)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function Gde({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:s}){const a=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:a,peekLabel:o,peekRecap:i,peekBounds:c}}function Kde(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,o]of e.positions)n.set(a,o),t.has(a)&&s.set(a,o);return{positions:n,pinned:s,restored:new Set(n.keys())}}function aI(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Yde(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 a=aI(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:aI(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function Xde(e,t){const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function Zde(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 ed="agent-dag.layout",td="agent-dag.layoutFrame",nd="agent-dag.viewport";function Jde(){return Yde(Ye(ed))}function kl(e,t){Ze(ed,Xde(e,t))}function Qde(){return Zde(Ye(td))}function v6(e){Ze(td,JSON.stringify(e))}function ehe(){return dz(Ye(nd))}function the(e){Ze(nd,JSON.stringify(e))}function nhe(){return{layout:Ye(ed),frame:Ye(td),viewport:Ye(nd)}}function she(e){const t=(n,s)=>s===null?Ys(n):Ze(n,s);t(ed,e.layout),t(td,e.frame),t(nd,e.viewport)}function b6(){Ys(ed),Ys(nd),Ys(td)}function rhe({fitLeft:e,moveCamera:t,currentViewport:n}){const s=y.useState(()=>Kde(Jde()))[0],a=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(Qde)[0],p=y.useRef(f),[m,w]=y.useState(!1),[k,b]=y.useState(""),v=y.useState(()=>kX(I=>{w(I),I||b(F=>F===sT?F:"")}))[0];y.useEffect(()=>()=>v.close(),[v]),y.useEffect(()=>{if(typeof document>"u")return;const I=()=>document.hidden?v.hold("hidden"):v.release("hidden");return document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},[v]);const N=y.useRef(null),j=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:c}),S=y.useCallback(()=>{v.open(v.snapshot??mX(j(),nhe(),n())),b(vX),a.current.clear(),o.current.clear(),c.current="",b6(),h(I=>I+1),N.current!=null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{N.current=null,kl(o.current,a.current),p.current&&v6(p.current),e(500)},80)},[e,n,v]),_=y.useCallback(()=>{const I=v.take();return I?(N.current!=null&&window.clearTimeout(N.current),N.current=null,gX(I,j()),she(I.stored),h(F=>F+1),I.viewport&&t(I.viewport,500),b(sT),!0):!1},[t,v]),T=y.useCallback(()=>v.close(),[v]),$=y.useCallback(I=>v.hold(I),[v]),M=y.useCallback(I=>v.release(I),[v]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,lastLayoutSigRef:c,layoutEpoch:d,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:m,said:k,undo:_,dismiss:T,hold:$,release:M}}}function ahe(e,t){const{positionsRef:n,pinnedRef:s}=t,a=y.useRef(null);y.useEffect(()=>(a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{kl(n.current,s.current)},1500),()=>{a.current!=null&&window.clearTimeout(a.current)}),[e])}function ohe({nodes:e,edges:t,settled:n,dragging:s,availableWidth:a,availableHeight:o,layout:i,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:m,focusAgentRef:w,autoFitDisabledRef:k}){const{lastLayoutFrameRef:b,pinnedRef:v,positionsRef:N,provisionalRef:j,lastLayoutSigRef:S,setLayoutEpoch:_}=i,{applyViewport:T,fitLeft:$,cameraEpochRef:M,lastFitTimeRef:O}=c;y.useEffect(()=>{if(!n||s)return;const I={width:a,height:o};if(!(I.width>0&&I.height>0))return;const F=b.current;if(b.current=I,v6(I),!F||F.width===I.width&&F.height===I.height)return;const L={direction:"LR",pinned:v.current,measured:h.current,lanes:MN(f.current)},A=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!gde(e,t,L,F,I)){const D=M.current,P=window.setTimeout(()=>{var z;M.current===D&&(k.current?A&&((z=p.current)==null?void 0:z.id)===A&&w.current(A):$(500))},80);return()=>window.clearTimeout(P)}const q=A??m.current,E=q?v.current.get(q)??N.current.get(q):void 0;for(const D of Array.from(N.current.keys()))v.current.has(D)||N.current.delete(D);j.current.clear(),S.current="",_(D=>D+1),window.setTimeout(()=>{if(kl(N.current,v.current),k.current){if(A){w.current(A);return}const D=q?v.current.get(q)??N.current.get(q):void 0;if(E&&D&&(D.x!==E.x||D.y!==E.y)){const P=d.getViewport();M.current+=1,T({x:P.x-(D.x-E.x)*P.zoom,y:P.y-(D.y-E.y)*P.zoom,zoom:P.zoom},0),O.current=Date.now()}return}$(500)},80)},[a,o,n,s,$,d,T])}function ihe(e,t,n,s,a){const o=[];for(const i of e)!Ip(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const LN="agent-dag.removedNodes";function lhe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(LN))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function Jk(e,t){try{e==null||e.setItem(LN,JSON.stringify([...t]))}catch{}}function k6(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),s=new Set(t),a=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=>a(o.id)||a(o.sessionId??o.id)}function che(e,t){if(t.size===0)return new Set;const n=[...e],s=k6(n,t);return new Set(n.filter(s).map(a=>a.id))}function uhe(e,t,n){const s=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),a=k6(e.map(s),n),o=e.filter(c=>!a(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 dhe(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 hhe(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function fhe(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 phe(e,t,n){let s=null;for(const a of t)e.has(a)||(s??(s=new Map(e)),s.set(a,n));for(const a of e.keys())t.has(a)||(s??(s=new Map(e)),s.delete(a));return s??e}function mhe(e,t,n,s){if(n.size===0)return[];let a=1/0;for(const i of s.values())i<a&&(a=i);const o=new Set;for(const i of t){const c=e.get(i);if(!c)continue;const d=fhe(c);if(d<=a)continue;const h=[],f=new Set,p=w=>{var k;for(let b=w;b&&!f.has(b);b=(k=e.get(b))==null?void 0:k.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 rp="sessionGroup";function ghe(e,t){var s,a;if(e.type===rp)return"transparent";if(Mn((s=e.data)==null?void 0:s.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(a=e.data)==null?void 0:a.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const zh=Ho;function yhe(e){const t=new Map;for(const s of e){const a=s.data;if(!(a!=null&&a.sessionId)||a.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(Qn(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(Qn(s),{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+zh*2,i=a.maxY-a.minY+zh*2;n.push({id:`group:${s}`,type:rp,position:{x:a.minX-zh,y:a.minY-zh},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 whe(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let a=t;for(;a;){const i=e.agents.get(a);if(!(i!=null&&i.parentId)||s.has(i.parentId))break;s.add(i.parentId),a=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 xhe(e,t){const n=new Set;for(const s of t){const a=whe(e,s);if(a)for(const o of a)n.add(o)}return n.size>0?n:null}function vhe({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:a}){return y.useMemo(()=>ihe(e.current.agents.values(),t,n,s,a),[e.current,e.current.revision,t,s,a,n])}function bhe({stateRef:e,now:t,availableWidth:n,availableHeight:s,layout:a,measuredRef:o,onBubble:i,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:m,removedNodes:w,removedAgentIds:k,dragTick:b,dragPatchRef:v,dragMoveTick:N}){const{pinnedRef:j,positionsRef:S,provisionalRef:_,lastLayoutSigRef:T,restoredLayout:$,layoutEpoch:M}=a,O=y.useMemo(()=>xhe(e.current,f),[e.current,e.current.revision,f]),I=y.useMemo(()=>{const P=TZ(e.current,t);for(const z of k)P.delete(z);return P},[e.current,e.current.revision,t,k]),F=y.useRef(new Map),L=QV(),{nodes:A,edges:q}=y.useMemo(()=>{const P=Sde(e.current,t,n,s,j.current,o.current,F.current,i,c,d,S.current,_.current,h,T,f,O,I,p,m,$.restored);return uhe(P.nodes,P.edges,w)},[e.current,e.current.revision,t,n,s,c,d,h,f,O,I,p,b,L,w,M,m]),E=y.useMemo(()=>yhe(A),[A]),D=y.useMemo(()=>{const P=[...E,...A],z=v.current;return!z||z.size===0?P:P.map(G=>{const V=z.get(G.id);return V?{...G,position:V}:G})},[E,A,N]);return{spotlightSet:O,visibleAgentIds:I,nodes:A,edges:q,allNodes:D}}function khe(e,t,n){const s=e.x*t.zoom+t.x,a=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&&a<n.height}function jhe({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 a of n)if(s=!0,khe(a,t,e))return!1;return s}function Nhe({layoutSig:e,rf:t,stateRef:n,measuredRef:s,pinnedRef:a,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 k=n.current,b=Date.now(),v=[];for(const j of k.agents.values())Ip(j,b)&&v.push({id:j.id});if(v.length===0)return;const N=[];for(const{id:j}of v){const S=s.current.get(j),_=a.current.get(j)??o.current.get(j);!S||!_||N.push({x:_.x,y:_.y,width:S.width,height:S.height})}jhe({pane:i.current,viewport:t.getViewport(),boxes:N})&&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 She({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:a,primarySelectedId:o}){const[i,c]=y.useState(()=>lhe(gr())),[d,h]=y.useState(null),f=y.useMemo(()=>che(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=y.useCallback(j=>{const S=e.current.agents.get(j);S&&(c(_=>{const T=new Set(_);return T.add(j),Jk(gr(),T),T}),h({id:j,label:S.label}),t.current.delete(j),n.current.delete(j),a())},[a]),m=y.useCallback(()=>{o&&p(o)},[o,p]),w=d&&i.has(d.id)?d:null;y.useEffect(()=>{var j;d&&((j=s.current)==null||j.focus())},[d]);const k=y.useCallback(j=>{const S=[...j];c(_=>{let T=null;for(const $ of S)_.has($)||(T??(T=new Set(_)),T.add($));return T?(Jk(gr(),T),T):_});for(const _ of S)t.current.delete(_),n.current.delete(_)},[]),b=y.useCallback(j=>{const S=[...j];c(_=>{const T=dhe(_,S);return T!==_&&Jk(gr(),T),T})},[]),v=y.useCallback(()=>{b([...i]),h(null)},[b,i]),N=y.useCallback(()=>{c(new Set),h(null),Ys(LN)},[]);return{removedNodes:i,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:k,bringBack:b,bringBackAll:v,forgetRemovals:N}}function _he({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:a}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=phe(o.current,s,Date.now());const i=[...hhe(t,n),...mhe(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const j6=[0,5,15,30,60],IN="agent-dag.hide-finished-after",N6="agent-dag.hide-finished-turns",Che=300,Ehe=1e4;function ON(e){const t=Number(e);return j6.includes(t)?t:0}function The(e){return e===0?"Never":`${e} min`}let Jo=null;const Zc=new Set;function S6(){for(const e of Zc)e()}function oI(){return Jo===null&&(Jo=ON(Ye(IN))),Jo}function Ahe(e){const t=ON(String(e));Jo!==t&&(Jo=t,Ze(IN,String(t)),S6())}function iI(e){if(e.key!==IN)return;const t=ON(e.newValue);t!==Jo&&(Jo=t,S6())}function Rhe(e){var t;return Zc.add(e),Zc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",iI)),()=>{var n;Zc.delete(e),Zc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",iI))}}function Mhe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(N6))??"{}");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 lI(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,Che);try{e==null||e.setItem(N6,JSON.stringify(Object.fromEntries(n)))}catch{}}function _6(e){const t=new Map;for(const s of e){let a=t.get(s.sessionId);a||(a={endedAt:0,live:!1},t.set(s.sessionId,a)),s.kind==="root"&&Mn(s.waiting)&&(a.live=!0),s.state==="done"&&s.endedAt!=null?a.endedAt=Math.max(a.endedAt,s.endedAt):a.live=!0}const n=new Map;for(const[s,a]of t)!a.live&&a.endedAt>0&&n.set(s,a.endedAt);return n}function $he(e,{afterMs:t,now:n,removed:s,handled:a,keep:o}){if(t<=0)return[];const i=[];for(const[c,d]of _6(e))n-d<t||s.has(c)||c===o||a.get(c)!==d&&i.push({id:c,endedAt:d});return i}function Lhe(e,t,n,s){const a=[...t].filter(c=>!n.has(c));if(a.length===0)return e;const o=_6(s);let i=null;for(const c of a){const d=o.get(c);d==null||e.get(c)===d||(i??(i=new Map(e)),i.set(c,d))}return i??e}function C6(){return y.useSyncExternalStore(Rhe,oI,oI)}function Ihe({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=C6(),[i]=y.useState(()=>Mhe(gr())),c=y.useRef(i),d=y.useRef(t);y.useEffect(()=>{const h=Lhe(c.current,d.current,t,e.current.agents.values());d.current=t,h!==c.current&&(c.current=h,lI(gr(),h))},[t]),y.useEffect(()=>{if(!a||o===0)return;const h=()=>{const p=$he(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:k}of p)m.set(w,k);c.current=m,lI(gr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,Ehe);return()=>window.clearInterval(f)},[a,o,t,s,n])}function Ohe({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${$t}`:$t,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const E6=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),T6=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Phe=Object.freeze([...new Set([...Object.values(E6),...Object.values(T6)])]),C1=new Map;function cI(e){return C1.get(e)??e}async function Dhe(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!C1.has(n))try{const s=await t(n),a=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!a.startsWith("image/"))return;C1.set(n,`data:${a};base64,${Fhe(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function Fhe(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Bhe({stateRef:e,waitingSessions:t,live:n}){const s=y.useMemo(()=>tV(e.current.agents.values()),[e.current,e.current.revision]),a=y.useRef(null);y.useEffect(()=>{n&&Dhe(Phe)},[n]),y.useEffect(()=>{const o=Ohe({waiting:t.length,running:s,connected:n}),i=a.current;a.current=o,(i==null?void 0:i.title)!==o.title&&(document.title=o.title),(i==null?void 0:i.icon)!==o.icon&&A6(o.icon)},[t.length,s,n])}function A6(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=cI(E6[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=cI(T6[e]))}const qhe=1200,Uhe=1e3;function Qk(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<qhe?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<Uhe}function Whe({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const c=y.useState(()=>ehe())[0];y.useEffect(()=>{if(!c)return;const k=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(k)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(k=>({hasSourceEvent:!!k,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:k=>{io(),Qk(p(k))&&(n.current+=1),Qk(p(k))&&s()},onMove:(k,b)=>{var v;a(),Qk(p(k))&&s(),(v=o.current)==null||v.style.setProperty("--zoom",String(b.zoom)),i(b.zoom)==="detail"&&io(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>the(b),250)}}}function Hhe({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:s,detailShown:a,focusAgent:o,draggingRef:i,lodRef:c}){const d=y.useRef(o);d.current=o;const[h]=y.useState(()=>xP({focus:b=>d.current(b),setTimeout:(b,v)=>window.setTimeout(b,v),clearTimeout:b=>window.clearTimeout(b)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(b,v)=>{if(v.type==="sessionGroup"){h.cancel(),e();return}const N=v.type==="recapNote"?v.data.parentId:v.id;t(N,b.shiftKey,!1),!b.shiftKey&&(n&&s(!1),Bu()?h.hold(N):a?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),io(),e()},onNodeDoubleClick:(b,v)=>{if(v.type!=="agent"&&v.type!=="recapNote")return;h.cancel();const N=v.type==="recapNote"?v.data.parentId:v.id;t(N,!1),window.setTimeout(()=>{try{o(N)}catch{}},80)},onNodeMouseEnter:(b,v)=>{v.type!=="agent"&&v.type!=="recapNote"||i.current||c.current==null||c.current==="detail"||g6(v.id,b.currentTarget)},onNodeMouseLeave:(b,v)=>io(v.id)}}function zhe({settleAt:e,now:t,take:n,schedule:s,cancel:a}){let o=null;const i=()=>{o!=null&&a(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 Vhe(e){const t=y.useRef(null),n=y.useRef(null),[s,a]=y.useState({w:0,h:0});return y.useEffect(()=>{const o=n.current;if(!o||typeof ResizeObserver>"u")return;const i=zhe({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(d,h)=>a(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},a({w:o.clientWidth,h:o.clientHeight}),()=>{c.disconnect(),i.dispose()}},[]),{canvasRef:n,canvasSize:s,paneSizeRef:t}}function Ghe(e){const t=Ft(),n=y.useRef(new Map),s=y.useRef(0),a=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 k of t.getState().nodeInternals.values()){if(k.type===rp)continue;const b=k.width,v=k.height;if(b==null||v==null)continue;const N=a.current.get(k.id);(!N||Math.abs(N.width-b)>4||Math.abs(N.height-v)>4)&&(a.current.set(k.id,{width:b,height:v}),n.current.set(k.id,{width:b,height:v}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const k of document.querySelectorAll(".react-flow__node[data-id]")){if(k.classList.contains(`react-flow__node-${rp}`))continue;const b=k.getAttribute("data-id");if(!b)continue;const v=k.offsetWidth,N=k.offsetHeight;if(!v||!N)continue;const j=n.current.get(b);(!j||Math.abs(j.width-v)>4||Math.abs(j.height-N)>4)&&(n.current.set(b,{width:v,height:N}),w=!0)}w&&d(k=>k+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 Khe(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Yhe(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},s=a=>{e.current=performance.now()-t<250?a.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 ap=[{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:"integrations",label:"Integrations",note:"Trackers the deck reads your work from, such as Jira. Read only."},{id:"data",label:"Data",note:"What the deck keeps on this device."},{id:"radar",label:"Radar",note:"Automatic monitoring of Claude telemetry, off unless you turn it on."},{id:"about",label:"About",note:"The version you are running, and where to say what you think of it."}];function Xhe(e,t){return e!=="none"||t==="integrations"?ap:ap.filter(n=>n.id!=="integrations")}const uI="settings-tab-";function Zhe(e,t){return e!=null&&e.startsWith(uI)?e===`${uI}${t}`?null:t:null}const Jhe={open:!1,section:"general"};function Qhe(e,t){return{open:!0,section:t??e.section}}function za(e,t){return()=>{e(),t()}}function efe(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function tfe(e){return Vu(e)?"⌘,":"Ctrl+,"}function nfe(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 sd={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"}},ta=Object.keys(sd);function E1(e){return ta[(ta.indexOf(e)+1)%ta.length]}const R6="agent-dag.theme";function sfe(e,t=!1){return typeof e=="string"&&Object.hasOwn(sd,e)?e:"rider-black"}function rfe(){return sfe(Ye(R6))}function afe({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:s,providersRef:a,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:m,focusAgent:w,stepAgent:k,focusSession:b,requestClear:v,handleRelayout:N,undoRearrange:j,handleFit:S,togglePause:_,toggleSessionList:T,toggleAccountsPanel:$,setDetailOpen:M,setUsageHistoryOpen:O,setUsagePanelOpen:I,setMachinePanelOpen:F,setBrowserWatchOpen:L,setKeyHelpOpen:A,setTheme:q,openSettings:E,openIntegrationRef:D}){y.useEffect(()=>{const P=z=>{var ee,U;const G=z.target,V={tagName:G==null?void 0:G.tagName,isContentEditable:G==null?void 0:G.isContentEditable,role:(ee=G==null?void 0:G.getAttribute)==null?void 0:ee.call(G,"role"),type:G==null?void 0:G.type,pointerFocused:G!=null&&G===e.current};if(z.key==="Escape"){const Y=jV({overlayOpen:vn.depth()>0,typing:Ko(V)});Y==="dismiss"?vn.dismissTop():Y==="blur"?G==null||G.blur():(Rde(V)&&(G==null||G.blur()),p());return}if(z.key===","&&efe(z)){if(Ko(V)||nf({appModal:c.current,dialogDepth:vn.dialogDepth()}))return;z.preventDefault(),z.repeat||E();return}if(jX(z)){if(Ko(V)||nf({appModal:c.current,dialogDepth:vn.dialogDepth()}))return;!z.repeat&&j()&&z.preventDefault();return}if(Cp(z))return;const H=$N(G)?(U=G==null?void 0:G.getAttribute)==null?void 0:U.call(G,"data-id"):null,B=H&&t.current.some(Y=>Y.id===H)?H:null,W=Tde(z,B);if(W.kind==="activate"){z.preventDefault(),m(W.nodeId,W.additive);return}if(W.kind!=="node"&&!X4(z.key,B0())){if($V({key:z.key,sheetOpen:i.current,target:V})){z.repeat||A(!1);return}if(!(W.nodeId==null&&RV(V,z.key))&&!MV({key:z.key,modalOpen:nf({appModal:c.current,dialogDepth:vn.dialogDepth()}),sheetOpen:i.current})&&!(z.repeat&&!/^[ jkJK]$/.test(z.key))){if(z.key===" "&&(z.preventDefault(),z.repeat||_()),(z.key==="c"||z.key==="C")&&v("shortcut"),(z.key==="r"||z.key==="R")&&N(),(z.key==="f"||z.key==="F")&&S(),(z.key==="z"||z.key==="Z")&&s.current&&w(s.current),z.key==="Delete"&&h.current(),(z.key==="l"||z.key==="L")&&T(),z.key==="d"||z.key==="D")if(s.current)M(Y=>!Y);else{const Y=$0(n.current.agents.values());Y.length>0?b(Y[0].id):k(1)}if((z.key==="h"||z.key==="H")&&O(Y=>!Y),(z.key==="u"||z.key==="U")&&I(Y=>!Y),(z.key==="a"||z.key==="A")&&a.current.claude&&$(),(z.key==="j"||z.key==="J")&&k(1),(z.key==="k"||z.key==="K")&&k(-1),z.key==="w"||z.key==="W"){const Y=eV($0(n.current.agents.values()),d.current);Y&&(d.current=Y.id,b(Y.id))}(z.key==="t"||z.key==="T")&&q(E1),(z.key==="m"||z.key==="M")&&o.current!==null&&f.current(z.shiftKey),(z.key==="s"||z.key==="S")&&F(Y=>!Y),(z.key==="b"||z.key==="B")&&L(Y=>!Y),(z.key==="v"||z.key==="V")&&E("sounds"),(z.key==="i"||z.key==="I")&&(D==null||D.current("jira")),z.key==="?"&&A(Y=>!Y)}}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[v,N,j,S,p,m,k,b,w,_])}function ofe(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function ife({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:s,detailShown:a,primarySelectedId:o,canvasRef:i}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{ofe()&&h()};return{toggles:c,sessionList:d(ea(!e,c.sessionList)),usage:d(ea(!t,c.usage)),machine:d(ea(!n,c.machine)),accounts:d(ea(!s,c.accounts)),detail:d(ea(!a,()=>{var h,f;o&&p6(o),Pn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function lfe({nodes:e,stateRef:t,pinnedRef:n,positionsRef:s,draggingRef:a,dragPatchRef:o,setDragging:i,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:m,trackTrashDrag:w,endTrashDrag:k,removeNode:b}){const v=y.useRef(null);return{onNodeDragStart:(_,T)=>{var $,M;if(T){if(io(),h(),a.current=!0,o.current=new Map,i(!0),f(),p(),T.type==="sessionGroup"){const O=($=T.data)==null?void 0:$.sessionId,I=new Map,F=new Map;if(O)for(const A of e)!A.data||Qn(A)!==O||(I.set(A.id,{x:A.position.x,y:A.position.y}),F.set(A.id,n.current.get(A.id)));v.current={sessionId:O,start:{x:T.position.x,y:T.position.y},members:I,pinsBefore:F};const L=O?t.current.agents.get(O):void 0;m(L?L.label:null);return}m(T.type==="agent"?((M=t.current.agents.get(T.id))==null?void 0:M.label)??"":null),n.current.set(T.id,{x:T.position.x,y:T.position.y})}},onNodeDrag:(_,T)=>{var $;if(T){if(f(),(T.type==="agent"||T.type==="sessionGroup")&&w(_),T.type==="sessionGroup"){const M=v.current;if(!M)return;const O=T.position.x-M.start.x,I=T.position.y-M.start.y;for(const[L,A]of M.members){const q={x:A.x+O,y:A.y+I};n.current.set(L,q),s.current.set(L,q)}const F=o.current;if(F){for(const[L,A]of M.members)F.set(L,{x:A.x+O,y:A.y+I});F.set(T.id,{x:T.position.x,y:T.position.y})}c(L=>L+1);return}n.current.set(T.id,{x:T.position.x,y:T.position.y}),s.current.set(T.id,{x:T.position.x,y:T.position.y}),($=o.current)==null||$.set(T.id,{x:T.position.x,y:T.position.y}),c(M=>M+1)}},onNodeDragStop:(_,T)=>{f();const $=k(_,(T==null?void 0:T.type)==="agent"||(T==null?void 0:T.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),d(M=>M+1),!T){v.current=null,kl(s.current,n.current);return}if(T.type==="sessionGroup"){const M=v.current;if(M&&$&&M.sessionId){for(const[O,I]of M.members){const F=M.pinsBefore.get(O);F?n.current.set(O,F):n.current.delete(O),s.current.set(O,I)}v.current=null,b(M.sessionId);return}if(M){const O=T.position.x-M.start.x,I=T.position.y-M.start.y;for(const[F,L]of M.members){const A={x:L.x+O,y:L.y+I};n.current.set(F,A),s.current.set(F,A)}}v.current=null,kl(s.current,n.current),d(O=>O+1);return}if(n.current.set(T.id,{x:T.position.x,y:T.position.y}),s.current.set(T.id,{x:T.position.x,y:T.position.y}),$){b(T.id);return}kl(s.current,n.current)}}}function cfe(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 M6({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)},[]),r.jsx("div",{className:"empty-symbol","aria-hidden":"true","data-active":e&&t,children:r.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m6 8 4 4-4 4"}),r.jsx("path",{className:"empty-cursor",d:"M13 16h5"})]})})}function ufe({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(M6,{}),r.jsxs("h2",{children:["Too many ",$t," tabs are open"]}),r.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",r.jsx("code",{children:$t})," tabs are holding them. Close one and this tab connects on its own."]})]})})}function dfe({live:e,everConnected:t,providers:n,workspace:s,onTour:a,reservedRight:o=0}){const i=!e;return r.jsx("div",{className:"empty-stage",style:{right:o},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(M6,{active:e}),i?r.jsxs(r.Fragment,{children:[r.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),r.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",r.jsx("code",{children:$t}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):hfe(n,s),!i&&r.jsxs("div",{className:"empty-actions",role:"group","aria-label":"Explore ccdeck",children:[r.jsx("button",{type:"button",className:"btn empty-tour",onClick:a,children:"Take the tour"}),r.jsx(Tu,{film:"tour",action:!0})]})]})})}function hfe(e,t){const n=cfe(t);return r.jsxs(r.Fragment,{children:[r.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?r.jsxs("p",{children:[n.lead," ",r.jsx("code",{children:n.workspace}),n.tail]}):r.jsxs("p",{children:["Run ",r.jsx("code",{children:"claude"})," or ",r.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."]}),r.jsxs("details",{className:"empty-help",children:[r.jsx("summary",{children:"Session not showing up?"}),ZJ(e).map(s=>r.jsx("p",{className:"hint-row",children:s.spans.map((a,o)=>a.code?r.jsx("code",{children:a.text},o):r.jsx("span",{children:a.text},o))},s.provider))]})]})}const ffe=1;function pfe(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 mfe(e,t,n){const s=e.agents.get(t);if(!s)return null;const a=[];for(const o of e.agents.values())o.sessionId===t&&a.push(o);return{schemaVersion:ffe,exportedAt:n,sessionId:t,label:s.label,cwd:s.cwd,startedAt:s.startedAt,endedAt:s.endedAt,model:s.model,agents:a.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(pfe)}))}}function gfe(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${$t}-${n}-${Of(t,8)}.json`}const $6={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},yfe={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 wfe({cat:e}){return r.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:r.jsx("path",{d:yfe[e]})})}const op={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},L6=$4;function xfe({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var v;const c=`${e.synthetic?"≥ ":""}${Rl(e.startedAt,e.endedAt,t)}`,d=On(e),h=d.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[N,j]of e.toolCountByName??[]){const S=L6(N);p.set(S,(p.get(S)??0)+j)}const m=e.toolErrorCount??0,w=e.tools.filter(N=>!N.endedAt).length,k=Array.from(p.entries()).sort((N,j)=>j[1]-N[1]),b=p.has("mcp")?IG(((v=e.toolCountByName)==null?void 0:v.keys())??[]):null;return r.jsxs(r.Fragment,{children:[r.jsxs("header",{className:"detail-hero",children:[r.jsxs("div",{className:"hero-line",children:[r.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),r.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),r.jsxs("div",{className:"hero-meta",children:[r.jsx("span",{className:"hero-meta-item",children:Sp(e)}),r.jsx("span",{className:"hero-sep",children:"·"}),r.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&(()=>{const N=wj(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":kp(e.model),title:N.length>0?`${bu(e.model,e.effort)}
105
+ spend on this panel also covers:
106
+ ${N.join(`
107
+ `)}`:bu(e.model,e.effort),children:[jp(e.model,e.effort),N.length>0?` +${N.length}`:""]})]})})()]}),h&&r.jsxs("div",{className:"hero-cost",children:[r.jsxs("div",{className:"hero-cost-headline",children:[r.jsx("span",{className:"hero-cost-value",children:nt(d.total)}),r.jsx("span",{className:"hero-cost-label",children:"spend"})]}),r.jsx(Uj,{cost:d})]}),r.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&r.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),a&&r.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>a(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&r.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; ${kn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${kn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(nK,{agent:e}),(()=>{const N=Ep(e);if(!N)return null;const j=Af(N.at,t),S=N.kind==="recap"?"Recap":no(N.kind).replace(/^./,_=>_.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[S," ",r.jsx("span",{className:"section-count",title:j.title,children:j.label})]}),r.jsx("p",{className:"detail-recap",title:Tp(N),children:N.text}),N.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",N.reply,"”"]})]})})(),(()=>{const N=qu(e.plan);return!N||!e.plan?null:r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Plan"," ",r.jsxs("span",{className:"section-count","aria-hidden":!0,children:[N.done,"/",N.total]}),r.jsxs("span",{className:"vis-hidden",children:[N.done," of ",N.total," done"]})]}),e.plan.note&&r.jsx("p",{className:"detail-plan-note",children:e.plan.note}),r.jsx("ol",{className:"plan-list",children:e.plan.items.map((j,S)=>r.jsxs("li",{className:"plan-item","data-status":j.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),r.jsxs("span",{className:"vis-hidden",children:[jfe[j.status],": "]}),r.jsx("span",{className:"plan-text",children:j.status==="in_progress"&&j.active?j.active:j.text}),j.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},j.id??`${S}:${j.text}`))})]})})(),e.tools.length>0&&r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Activity"}),r.jsxs("div",{className:"activity-row",children:[r.jsxs("div",{className:"activity-counters",children:[r.jsxs("span",{className:"ac-item",children:[r.jsx("b",{children:e.toolCount})," calls"]}),w>0&&r.jsxs("span",{className:"ac-item ac-live",children:[r.jsx("b",{children:w})," live"]}),m>0&&r.jsxs("span",{className:"ac-item ac-err",children:[r.jsx("b",{children:m})," err"]})]}),r.jsx("div",{className:"cat-strip",children:k.map(([N,j])=>{const S=N==="mcp"?b:null,_=S==null?void 0:S.hue,T=`${j} ${op[N]} call${j===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${N}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${T}, all to ${S.label}`:T,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:$6[N]}),r.jsx("span",{className:"cat-name",children:op[N]}),r.jsx("span",{className:"cat-count",children:j}),S&&r.jsx("span",{className:"cat-server",children:S.label})]},N)})})]})]}),f>0&&r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Tokens"}),r.jsxs("div",{className:"tokens-grid",children:[r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"in"}),r.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:wt(e.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"out"}),r.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:wt(e.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache r"}),r.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:wt(e.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache c"}),r.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:wt(e.usage.cacheCreateTokens)})]})]})]}),r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Identity"}),r.jsxs("div",{children:[e.cwd&&r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"cwd"}),r.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"session"}),r.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"parent"}),r.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Prompts ",r.jsx("span",{className:"section-count",children:G3(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:vfe(e.prompts).reverse().map(({pr:N,key:j})=>{const S=Af(N.at,t),_=xp(N.text);return _?r.jsxs("details",{className:"prompt-entry prompt-injected",children:[r.jsxs("summary",{children:[r.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&r.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},j):r.jsxs("div",{className:"prompt-entry",children:[r.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("div",{className:"prompt-text",children:N.text})]},j)})})]}),r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Tool calls ",r.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&r.jsx("div",{className:"empty",children:"No tool calls yet."}),r.jsx("div",{children:e.tools.slice().reverse().map(N=>r.jsx(kfe,{t:N,onClick:()=>n(e.id,N.id)},N.id))})]})]})}function vfe(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 bfe={inflight:"in-flight",done:"done",err:"error"};function kfe({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=b4(e,"…");return r.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[r.jsxs("span",{className:"name",children:[r.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:bfe[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const jfe={completed:"done",in_progress:"now",pending:"to do"};function Nfe(e,t){const n=mfe(e,t,new Date().toISOString());if(!n)return;const s=JSON.stringify(n,null,2),a=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=gfe(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Sfe({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){nn("detail-panel");const c=Dn();return r.jsxs("aside",{className:"detail","aria-label":"Detail",children:[r.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:a,children:"×"}),r.jsx(xfe,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:d=>Nfe(o.current,d),onRemove:i,singleKeys:c})]})}const _fe=450,Cfe=400,Efe=100,Vh=8,Tfe={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},Fc=8;let Zr=null,dI=-1/0;function Afe(e,t,n){return n||e-t<Cfe}function Rfe(e,t,n,s,a=null){const o=Math.max(Fc,((a==null?void 0:a.left)??0)+Fc),i=Math.min(window.innerWidth,(a==null?void 0:a.right)??1/0)-n-Fc,c=p=>Math.max(o,Math.min(p,i)),d=p=>Math.max(Fc,Math.min(p,window.innerHeight-s-Fc)),h=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+Vh,top:d(h)}:e==="left"?{left:t.left-Vh-n,top:d(h)}:e==="above"?{left:c(f),top:t.top-Vh-s}:{left:c(f),top:t.bottom+Vh}}const Mfe={chrome:"",dialog:" hint-over-dialog"};function zl(e,t="chrome"){const[n,s]=y.useState(null),a=y.useRef(void 0),o=y.useRef(void 0),i=y.useRef(null),c=y.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),s(w=>(w&&(dI=performance.now()),null))},[]),d=y.useCallback((w,k,b)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const v=Zr!==null,N=Afe(performance.now(),dI,v),j=()=>{var _;Zr&&Zr!==c&&Zr(),Zr=c;const S=t==="dialog"?((_=w.closest('[role="dialog"]'))==null?void 0:_.getBoundingClientRect())??null:null;s({spec:k,box:w.getBoundingClientRect(),within:S,instant:N})};b||N?j():a.current=window.setTimeout(j,_fe)},[c,t]),h=y.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(c,Efe)},[c]),f=n!==null;y.useEffect(()=>{if(!f)return;const w=vn.push(c,0,"popover");return window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{w(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0),Zr===c&&(Zr=null)}},[f,c]),y.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),Zr===c&&(Zr=null)},[c]),y.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:k,height:b}=w.getBoundingClientRect(),v=Rfe(e,n.box,k,b,n.within);w.style.left=`${v.left}px`,w.style.top=`${v.top}px`,w.style.visibility="visible"},[n,e]);const p=y.useCallback(w=>({onPointerEnter:k=>{w&&k.pointerType==="mouse"&&d(k.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:c,onFocus:k=>{w&&k.currentTarget.matches(":focus-visible")&&d(k.currentTarget,w,!0)},onBlur:c}),[d,h,c]),m=n&&xt.createPortal(r.jsxs("span",{ref:i,className:Tfe[e]+Mfe[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:[r.jsxs("span",{className:"hint-head",children:[r.jsx("span",{className:"hint-label",children:n.spec.label}),n.spec.keys&&r.jsx("kbd",{className:"hint-key",children:n.spec.keys})]}),n.spec.detail&&r.jsx("span",{className:"hint-detail",children:n.spec.detail})]}),document.body);return{bind:p,node:m}}const I6="(max-width: 640px)";function T1(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(I6).matches}catch{return!1}}function O6(e,t){return e&&(t||!e.single)?e:void 0}function $fe(e,t,n){var i;const s=(i=O6(e.key,t))==null?void 0:i.cap,a=e.hint??e.label;return s!=null||e.detail!=null||a!==e.label||!n?{label:a,keys:s,detail:e.detail}:null}const P6={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},Lfe={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},Ife={vertical:"ArrowDown",horizontal:"ArrowRight"},Ofe={vertical:"ArrowUp",horizontal:"ArrowLeft"};function D6(e,t){const[n,s]=y.useState(0),a=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===Ife[t]?h=(d+1)%c.length:i.key===Ofe[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:a,setCurrent:s,onKeyDown:o}}let ol=null;function PN(e){y.useLayoutEffect(()=>{var a,o;ol&&document.activeElement===document.body&&((o=(a=e.current)==null?void 0:a.querySelector(`[data-rail-item="${ol}"]`))==null||o.focus()),ol=null;const t=i=>{var d;const c=(d=i.target.dataset)==null?void 0:d.railItem;c&&(ol=c)},n=i=>{var c;(c=e.current)!=null&&c.contains(i.relatedTarget)||(ol=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 DN({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var h;const i=Dn(),c=a.bind($fe(e,i,o!=="stripe")),d=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:P6[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=O6(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"&&r.jsx("span",{className:"rail-word",children:o==="dock"?e.short:e.label}),e.badge!=null&&e.badge>0&&r.jsx("span",{className:"rail-badge","aria-hidden":!0,children:e.badge})]})}function hI({side:e,label:t,groups:n}){const s=zl(e==="left"?"right":"left"),a=n.filter(d=>d.length>0),o=D6(a.flat().length,"vertical"),i=y.useRef(null);PN(i);let c=0;return r.jsxs("div",{ref:i,className:Lfe[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[a.map((d,h)=>r.jsx("div",{className:"rail-group",children:d.map(f=>{const p=c++;return r.jsx(DN,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},h)),s.node]})}const Gh="dock-more",fI="dock-more-menu";function Pfe({items:e,tabbable:t,onFocusIndex:n,index:s}){const[a,o]=y.useState(null),i=a!==null,c=e.reduce((h,f)=>h+(f.badge??0),0),d=h=>()=>{var f;(f=document.getElementById(Gh))==null||f.focus(),o(null),h.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:Gh,type:"button","data-rail-item":"more",className:P6.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?fI: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:[r.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:[r.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),r.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),r.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),r.jsx("span",{className:"rail-word",children:"More"}),c>0&&r.jsx("span",{className:"rail-badge","aria-hidden":!0,children:c})]}),i&&r.jsx(Up,{anchorId:Gh,id:fI,className:"ap-pop",role:"menu",labelledBy:Gh,start:a,onClose:()=>o(null),children:e.map(h=>r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item","data-rail-item":h.id,onFocus:()=>{ol=h.id},onClick:d(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function Dfe({items:e,more:t}){const n=zl("above"),s=D6(e.length+1,"horizontal"),a=y.useRef(null);return PN(a),r.jsxs("div",{ref:a,className:"edge-dock",role:"toolbar","aria-label":"Panels and tools",onKeyDown:s.onKeyDown,children:[e.map((o,i)=>r.jsx(DN,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(Pfe,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function Ffe({items:e,side:t="below"}){const n=zl(t),s=y.useRef(null);return PN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(DN,{item:a,index:o,tabbable:!0,onFocusIndex:Bfe,hint:n,variant:"bar"},a.id)),n.node]})}function Bfe(){}function qfe(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}
108
+ ${t} unread`:n}function Ufe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:s,toggleAccountsPanel:a,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:c,setMachinePanelOpen:d,setUsageHistoryOpen:h,watchOn:f,watchUnseen:p,setBrowserWatchOpen:m,setTrafficRadarOpen:w,radioOpen:k,setRadioOpen:b,openToolActivity:v,openSettings:N,onFeedback:j,toggles:S,integrations:_=[]}){const T=tfe(zu()),$={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(cne,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:S.sessionList},M={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(une,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:S.accounts},O={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(dne,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(E=>!E),buttonRef:S.usage},I={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:r.jsx(fne,{}),kind:"panel",open:c,controls:"system-panel",onPress:()=>d(E=>!E),buttonRef:S.machine},F={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(hne,{}),kind:"dialog",onPress:()=>h(E=>!E)},L={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:qfe(f,p),glyph:r.jsx(mne,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(E=>!E),badge:p},A={id:"settings",label:"Settings",short:"Settings",key:{cap:T,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(gne,{}),kind:"dialog",onPress:()=>N()},q={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(yne,{}),kind:"dialog",onPress:j};return{left:e.claude?[M,$]:[$],right:[[O,I],[F,...v?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(kne,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>v()}]:[],L,...w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(pne,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[]],...b?[[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(bne,{}),kind:"panel",open:k,controls:"radio-panel",detail:"Explore stations around the world",onPress:()=>b(E=>!E)}]]:[]],utilities:[A,q],integrations:_.map(({provider:E,onPress:D})=>({id:`integration-${E.kind}`,label:E.label,short:E.label,ariaLabel:E.label,detail:E.detail,key:E.shortcut?{cap:E.shortcut.toUpperCase(),aria:E.shortcut.toUpperCase(),single:!0}:void 0,glyph:r.jsx(E.Glyph,{}),kind:"dialog",onPress:D}))}}const ip=[{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 F6(e){return ip.find(t=>t.value===e)??ip[0]}const A1=3,e0=120,B6=1e4,q6=200,Wfe="Write something first.";function pI(e){return e.trim()!==""}function Hfe(e){var o;const t=e.trim();if(t==="")return"";const n=mI(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=t0(s).length>=A1?t0(s):t0(n);return Vfe(a.length>=A1?a:mI(t))}function zfe(e,t){const n=Hfe(t);return n.length>=A1?n:`${F6(e).label}: ${n}`}function mI(e){return e.replace(/\s+/g," ").trim()}function t0(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Vfe(e){if(e.length<=e0)return e;const t=e.slice(0,e0-1),n=t.lastIndexOf(" ");return`${(n>=e0/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Gfe({kind:e,body:t,contact:n}){const s={kind:e,title:zfe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function Kfe(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 Yfe={darwin:"macOS",win32:"Windows",linux:"Linux"};function Xfe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=Yfe[n]??n;return s?`${a} · ${s}`:a}function Zfe(e){return e?`ccdeck ${e.appVersion} · ${Xfe(e.platform)}`:null}const Jfe="sent with it",Qfe="Your ccdeck version and system are sent with it.",epe="Add details",tpe="How to reach you",npe="Email or GitHub @name",spe="Only if you would like an answer.",rpe=["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 ape(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function FN(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function ope(e){return Vu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function ipe(e){return[...e].length===1}const U6="Thanks — feedback sent.";function gI(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 lpe(e){return e==="sending"?"Sending…":e==="sent"?U6:""}const yI=1400,cpe=160,W6=y.createContext({values:{}});function H6(){return y.useContext(W6)}function upe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const wI=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function xI({def:e,existing:t,busy:n,error:s,onSubmit:a,onCancel:o}){var O,I;const i=y.useId(),[c,d]=y.useState(()=>Object.fromEntries(e.fields.map(F=>{var L,A,q;return[F.name,F.secret?"":((L=F.initial)==null?void 0:L.call(F,t))??(F.type==="choice"?((q=(A=F.options)==null?void 0:A[0])==null?void 0:q.value)??"":"")]}))),[h,f]=y.useState((t==null?void 0:t.name)??""),p=y.useRef(null),m=y.useRef(null),w=!!t,k=y.useRef(c),b=e.fields.filter(F=>F.type==="choice").every(F=>c[F.name]===k.current[F.name]),v=w&&t.tokenSaved&&b;y.useEffect(()=>{var F;(F=(w?m:p).current)==null||F.focus()},[w]);const N=(F,L)=>d(A=>({...A,[F]:L})),j=F=>{if(F.preventDefault(),n)return;const L={};for(const A of e.fields)wI(A,c)&&(L[A.name]=(c[A.name]??"").trim());a(L,h.trim()),d(A=>Object.fromEntries(Object.entries(A).map(([q,E])=>{var D;return[q,(D=e.fields.find(P=>P.name===q))!=null&&D.secret?"":E]})))},S=y.useMemo(()=>{const F=c.baseUrl??"";try{return F?new URL(/^[a-z]+:\/\//i.test(F)?F:`https://${F}`).host:""}catch{return""}},[c.baseUrl]),_=y.useMemo(()=>({values:c,existing:t}),[c,t]),T=e.fields.filter(F=>wI(F,c)),$=(O=T.find(F=>!F.secret&&F.type!=="choice"))==null?void 0:O.name,M=(I=T.find(F=>F.secret))==null?void 0:I.name;return r.jsx(W6.Provider,{value:_,children:r.jsxs("form",{className:"ig-form",onSubmit:j,"aria-labelledby":`${i}-title`,noValidate:!0,children:[r.jsx("h4",{className:"ig-form-title",id:`${i}-title`,children:w?`Edit ${t.name}`:`Connect ${e.label}`}),T.map(F=>{const L=upe(F,c),A=(s==null?void 0:s.field)===L.name,q=[L.hint?`${i}-${L.name}-hint`:"",A?`${i}-error`:""].filter(Boolean).join(" ")||void 0;if(L.type==="choice")return r.jsxs("fieldset",{className:"fb-kinds","aria-invalid":A||void 0,children:[r.jsx("legend",{className:"vis-hidden",children:L.label}),(L.options??[]).map(P=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:`${i}-${L.name}`,value:P.value,checked:c[L.name]===P.value,onChange:()=>N(L.name,P.value),onKeyDown:z=>{FN(z.nativeEvent)&&z.preventDefault()}}),P.label]},P.value))]},L.name);const E=L.name===M?m:L.name===$?p:void 0,D=L.secret&&v;return r.jsxs("label",{className:"fb-field",children:[r.jsxs("span",{className:"fb-field-label",children:[L.label,L.optional&&r.jsx("span",{className:"fb-optional",children:" optional"})]}),r.jsx("input",{ref:E,className:`ap-manage-input ig-input${L.secret?" ig-mono":""}`,type:L.type,inputMode:L.type==="url"?"url":L.type==="email"?"email":void 0,autoComplete:L.autoComplete??"off",spellCheck:!1,value:c[L.name]??"",onChange:P=>N(L.name,P.target.value),placeholder:D?"Saved. Leave blank to keep it":L.placeholder,"aria-invalid":A||void 0,"aria-describedby":q}),L.hint&&r.jsx("span",{className:"ig-hint",id:`${i}-${L.name}-hint`,children:L.hint})]},L.name)}),r.jsx("div",{className:"ig-help",children:e.tokenHelp}),r.jsxs("label",{className:"fb-field",children:[r.jsxs("span",{className:"fb-field-label",children:["Name ",r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,value:h,onChange:F=>f(F.target.value),placeholder:S||e.label})]}),s&&r.jsxs("p",{className:"ig-form-error",id:`${i}-error`,role:"alert",children:[s.message,s.detail&&r.jsxs("span",{className:"ig-form-detail",children:[" ",e.label," said: ",s.detail]}),s.kind==="rate-limit"&&s.retryAfter?r.jsxs("span",{children:[" Try again in ",s.retryAfter," s."]}):null]}),r.jsxs("div",{className:"ig-form-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:o,children:"Cancel"}),r.jsx("button",{type:"submit",className:"btn primary","aria-busy":n,children:n?"Checking…":w?"Save":"Connect"})]})]})})}const dpe="https://id.atlassian.com/manage-profile/security/api-tokens",hpe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",fpe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",ppe=[{scope:"read:jira-work",why:"issues, comments, search"},{scope:"read:jira-user",why:"your account and avatars"},{scope:"read:board-scope:jira-software",why:"boards and backlogs"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters"},{scope:"read:sprint:jira-software",why:"sprints"},{scope:"read:epic:jira-software",why:"epic names and colours"},{scope:"read:issue-details:jira",why:"issue lists"},{scope:"read:jql:jira",why:"filtered lists"}];function mpe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),s=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!s||!n.hostname.includes(".")&&!s?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function gpe(){const{values:e}=H6(),t=e.deployment==="cloud",n=t?null:mpe(e.baseUrl??"");let s="";try{s=n?new URL(n).host:""}catch{}return r.jsxs(r.Fragment,{children:[t?r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["Make one at ",r.jsx("a",{href:dpe,target:"_blank",rel:"noreferrer noopener",children:"id.atlassian.com → Security → API tokens"}),". A classic token reads Jira as you. A token ",r.jsx("em",{children:"with scopes"})," works too: the deck finds your site’s api.atlassian.com address itself, and needs these read scopes:"]}),r.jsx("ul",{className:"ig-scopes",children:ppe.map(a=>r.jsxs("li",{children:[r.jsx("code",{children:a.scope})," ",r.jsx("span",{children:a.why})]},a.scope))}),r.jsx("p",{children:r.jsx("a",{href:hpe,target:"_blank",rel:"noreferrer noopener",children:"How Atlassian API tokens work"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["In Jira, open your avatar → ",r.jsx("strong",{children:"Profile"})," → ",r.jsx("strong",{children:"Personal Access Tokens"})," → ",r.jsx("strong",{children:"Create token"}),n&&r.jsxs(r.Fragment,{children:[" (",r.jsxs("a",{href:n,target:"_blank",rel:"noreferrer noopener",children:["open it on ",s]}),")"]}),". The token reads what your account can read. Give it an expiry you are comfortable with. Needs Jira 8.14 or newer."]}),r.jsx("p",{children:r.jsx("a",{href:fpe,target:"_blank",rel:"noreferrer noopener",children:"How personal access tokens work"})})]}),r.jsx("p",{className:"ig-dim",children:"The deck only reads: it sends Jira nothing but GET requests, keeps the token on this machine, and never shows it again."})]})}function n0(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const s=(t??"").trim()||"https://gitlab.com";let a;try{a=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(s)?s:`https://${s}`)}catch{return null}return a.protocol!=="https:"&&a.protocol!=="http:"||!a.hostname.includes(".")&&a.hostname!=="localhost"?null:`${a.origin}${a.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function s0({href:e,children:t}){return e?r.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",r.jsx(Wj,{})]}):null}function z6({kind:e,baseUrl:t}){const{values:n}=H6();if(e==="github")return r.jsxs("div",{className:"fg-token-help",children:[r.jsx("p",{children:"A personal access token. Either kind works:"}),r.jsxs("ul",{children:[r.jsxs("li",{children:[r.jsx("strong",{children:"Classic"})," — the ",r.jsx("code",{children:"repo"})," and ",r.jsx("code",{children:"read:org"})," scopes."," ",r.jsx(s0,{href:n0("github"),children:"Make one"})]}),r.jsxs("li",{children:[r.jsx("strong",{children:"Fine-grained"})," — the repositories you want to see, with read-only access to Actions, Checks, Commit statuses, Contents, Issues, Metadata and Pull requests. Contents is for branches and commits; the panel never opens your files."," ",r.jsx(s0,{href:n0("github",null,"fine-grained"),children:"Make one"})]})]}),r.jsx("p",{children:"An organization may have to approve a fine-grained token, or a classic one be authorized for its single sign-on, before its repositories show."})]});const s=n0("gitlab",t??(n.where==="self"?n.baseUrl:null));return r.jsxs("div",{className:"fg-token-help",children:[r.jsxs("p",{children:["A personal access token with the ",r.jsx("code",{children:"read_api"})," scope, and nothing more."," ",r.jsx(s0,{href:s,children:`Make one on ${s?new URL(s).host:"GitLab"}`})]}),r.jsx("p",{children:"GitLab tokens expire. When this one does, the panel says so and brings you back here."})]})}const V6={name:"token",label:"Personal access token",type:"password",secret:!0,placeholder:"Paste the token"},ype=[V6],vI=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},wpe=[{name:"where",label:"Which GitLab",type:"choice",options:[{value:"cloud",label:"GitLab.com"},{value:"self",label:"Self-managed"}],initial:e=>vI(e)?"self":"cloud"},{name:"baseUrl",label:"GitLab URL",type:"url",placeholder:"https://gitlab.example.com",hint:"The address you open GitLab at, with its path if it has one. https only.",when:{field:"where",is:["self"]},initial:e=>vI(e)?e.baseUrl:""},V6],xpe=y.createElement(z6,{kind:"github"}),vpe=y.createElement(z6,{kind:"gitlab"}),bpe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},kpe={kind:"jira",label:"Jira",Glyph:Nne,shortcut:"I",detail:"Your board, sprint first",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:bpe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:y.createElement(gpe)},jpe={kind:"github",label:"GitHub",Glyph:Sne,detail:"Branches, pull requests, Actions",blurb:"github.com, read-only, with a personal access token.",fields:ype,tokenHelp:xpe},Npe={kind:"gitlab",label:"GitLab",Glyph:_ne,detail:"Branches, merge requests, pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:wpe,tokenHelp:vpe},R1={jira:kpe,github:jpe,gitlab:Npe},G6=()=>Object.values(R1).filter(e=>!!e);function K6(e){return(Object.hasOwn(R1,e)?R1[e]:void 0)??null}function pm(e,t){const n=s=>typeof t=="string"?t:t(s);return y.lazy(()=>e().catch(s=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,s),{default:a=>r.jsx(Spe,{name:n(a),onClose:a.onClose})})))}function Spe({name:e,onClose:t}){const n=y.useRef(null),s=pt(t,{focusRef:n}),a=gt(t);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.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."]}),r.jsxs("div",{className:"dm-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),r.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}const Y6=()=>Fl(()=>import("./IntegrationModal-BnnBr0a3.js"),[]);function _pe(){Y6().catch(()=>{})}const Cpe=pm(Y6,e=>{var t;return((t=K6(e.kind))==null?void 0:t.label)??"The tracker"});function Epe({onClose:e}){return y.useEffect(()=>vn.push(e,0,"dialog"),[e]),null}function Tpe(e){return r.jsx(y.Suspense,{fallback:r.jsx(Epe,{onClose:e.onClose}),children:r.jsx(Cpe,{...e})})}class wr extends Error{constructor(n,s,a={}){super(s);Ua(this,"kind");Ua(this,"status");Ua(this,"retryAfter");Ua(this,"field");Ua(this,"detail");this.name="IntegrationFailure",this.kind=n,Object.assign(this,a)}}async function X6(e){try{const t=await e.json(),n=t==null?void 0:t.error;if(n&&typeof n.kind=="string"&&typeof n.message=="string")return new wr(n.kind,n.message,{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail})}catch{}return new wr(e.status===401?"auth":"upstream",`The deck answered ${e.status}.`)}async function rd(e,t={}){const{timeoutMs:n=3e4,...s}=t,a=new AbortController,o=window.setTimeout(()=>a.abort(),n),i=s.signal,c=()=>a.abort();i==null||i.addEventListener("abort",c,{once:!0});let d;try{d=await fetch(e,{...s,signal:a.signal,headers:s.body?{"Content-Type":"application/json",...s.headers??{}}:s.headers})}catch(h){throw i!=null&&i.aborted?h:new wr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),i==null||i.removeEventListener("abort",c)}if(!d.ok)throw await X6(d);return d.json()}const Z6=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function dke(e){const t=Z6(e);return(n,s)=>fetch(`${t}${n.replace(/^\/+/,"")}`,s)}function hke(e){const t=Z6(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function fke(e){const t=new URLSearchParams;for(const[s,a]of Object.entries(e))a===void 0||a===""||a===!1||t.set(s,a===!0?"1":String(a));const n=t.toString();return n?`?${n}`:""}async function pke(e,t,{signal:n,timeoutMs:s=45e3}={}){const a=new AbortController,o=window.setTimeout(()=>a.abort(),s),i=()=>a.abort();n==null||n.addEventListener("abort",i,{once:!0});let c;try{c=await e(t,{signal:a.signal,headers:{Accept:"application/json"}})}catch(d){throw n!=null&&n.aborted?d:new wr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),n==null||n.removeEventListener("abort",i)}if(!c.ok)throw await X6(c);try{return await c.json()}catch{throw new wr("upstream","The deck answered with something that is not JSON.")}}let ra={connections:null,providers:[],error:""};const hl=new Set;let Kh=null,Bc=null,jl=null,bI=0;const Ape=5e3,Rpe=3;function lp(e){ra={...ra,...e},hl.forEach(t=>t(ra))}function BN(){return Bc||(Bc=(async()=>{try{const e=await rd("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new wr("upstream","The deck answered with something that is not the list of connections.");lp({connections:t,providers:n,error:""})}catch(e){lp({error:e instanceof Error?e.message:"Could not read the connections."}),ra.connections===null&&hl.size>0&&jl===null&&bI<Rpe&&(jl=window.setTimeout(()=>{jl=null,BN()},Ape*2**bI++))}finally{Bc=null}})(),Bc)}function Mpe(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function kI(){Mpe(ra)&&BN()}function qN(e){const t=ra.connections??[],n=t.findIndex(s=>s.id===e.id);lp({connections:n<0?[...t,e]:t.map(s=>s.id===e.id?e:s)})}function $pe(e){lp({connections:(ra.connections??[]).filter(t=>t.id!==e)})}function ad(){const[e,t]=y.useState(ra);return y.useEffect(()=>{hl.add(t),t(ra);const n=()=>{document.visibilityState==="visible"&&kI()};return hl.size===1&&(BN(),Kh=window.setInterval(kI,6e4),document.addEventListener("visibilitychange",n)),()=>{hl.delete(t),hl.size===0&&(Kh!==null&&window.clearInterval(Kh),Kh=null,jl!==null&&window.clearTimeout(jl),jl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function J6(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function UN(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function od(e,t){return UN(e).has(t)}function Lpe(e,t){return od(e,t)&&J6(e,t).length>0}function Q6(e){return UN(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function Ipe(e,t,n){const s=await rd("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return qN(s.connection),s.connection}async function Ope(e,t){const n=await rd(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return qN(n.connection),n}async function Ppe(e){const t=await rd(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return qN(t.connection),t.connection}async function Dpe(e){await rd(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),$pe(e)}function Fpe(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function Bpe(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let M1=null;function qpe(e){M1=e}function Upe(){const e=M1;return M1=null,e}function Wpe({widths:e,room:t,gap:n,more:s}){let a=0,o=0;for(let i=0;i<e.length;i++){a+=(i>0?n:0)+e[i];const c=i+1<e.length?n+s:0;if(a+c>t)break;o=i+1}return o}function eF(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const Hpe=20;function zpe(e,t=Hpe){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 Vpe(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),a=t%60;return a===0?n(s,"hour"):`${n(s,"hour")} ${n(a,"minute")}`}function Gpe(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${Vpe(n)} ${s}; go to session`}function Kpe(e){const t=Al(e),n=v4(e,t);return n?`${t}
110
+ ${n}`:t}const Ype=new Set(["idle","checking","current","downloading","ready","error"]);function jI(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Ype.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 Xpe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function tF(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Ll="Restart to update",nF=3e4;function sF(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 Zpe(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 ${Ll} comes first`}}function rF(e,t=!1){return{text:t?"Restarting…":Ll,label:t?void 0:`${Ll} 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 Jpe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function aF(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=sF(n),a=`Use ${Ll} 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. ${a}`;case"update_not_ready":return`Nothing restarted: the app no longer has v${t} ready. When it has one, ${Ll} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${nF/1e3} seconds. ${a}`;case"refused":return`Nothing restarted: the deck turned the request down. ${a}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${a}`}}const Qpe="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",r0="click for what's new";function eme(e){if(e.checkDisabled)return`${Qpe} · ${r0}`;if(e.checking)return`Asking npm for the newest release… · ${r0}`;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 · ${r0}, and to check npm now`}function tme(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 nme(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 oF(e){return e?`${e.kind}:${e.to}`:""}function sme(e,t){return e!=null&&t!==oF(e)}function rme({readyAppUpdate:e,notice:t,noticeOpen:n,version:s,chipVersion:a,versionChecking:o,now:i,openReleaseNotes:c,showNotice:d,loadVersion:h,restartToUpdate:f,updateRestarting:p=!1}){return r.jsx(r.Fragment,{children:e?(()=>{const m=Zpe(tF()??a,e.version),w=f&&rF(e.version,p);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":m.label,title:m.title,children:[m.text,r.jsx("span",{className:"v-dot","aria-hidden":!0})]}),w&&r.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?r.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":nme({...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,r.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const m={running:a,latest:s==null?void 0:s.latest,latestPending:s==null?void 0:s.latestPending,checkedAgo:s!=null&&s.checkedAt?Tf(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?Tf(i-s.checkFailedAt):null,checkDisabled:s==null?void 0:s.checkDisabled,checking:o};return r.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":tme(m),title:eme(m),children:["v",m.running]})})()})}function ame({live:e,paused:t,pauseGate:n}){const s=Dn();return r.jsx("span",{className:"status",children:(()=>{const a=vK({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:s});return a.resting?null:r.jsx("span",{className:`pill ${a.tone}`,title:a.title,children:r.jsxs("span",{className:"pill-box",children:[r.jsx("span",{className:"pill-widest","aria-hidden":!0,children:a.widest}),r.jsx("span",{className:"pill-label",children:a.label})]})})})()})}function ome(e,t){return`${e.label} — ${eF(e.waiting)} · ${qf(e.waiting.since,void 0,t)}`}function iF(e,t){const n=e.slice(0,6).map(s=>ome(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
111
+ `)}function ime({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=Dn(),i=zl("below"),c=e.slice(a),d=e.length;return r.jsxs(r.Fragment,{children:[r.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?iF(c,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:d})," waiting"]}),i.node]})}function NI({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:zpe(e.label)}),r.jsx("span",{className:"we-wait",children:qf(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",eF(e.waiting)]})]})}const lme=12,cme=2e3,ume=4;function dme({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=Dn(),c=zl("below"),d=y.useRef(null),h=y.useRef(null),[f,p]=y.useState(0),m=e.map(v=>v.id).join(`
112
+ `);y.useLayoutEffect(()=>{const v=d.current,N=h.current;if(!v||!N)return;const j=()=>{const _=Array.from(N.children),T=_.pop();p(Wpe({widths:_.map($=>$.getBoundingClientRect().width),room:v.clientWidth-lme,gap:ume,more:(T==null?void 0:T.getBoundingClientRect().width)??0}))};if(j(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(j);return S.observe(v),S.observe(N),()=>S.disconnect()},[m]);const w=e.slice(0,f),k=e.slice(f);y.useEffect(()=>{a(w.length)},[w.length,a]);const b=v=>{t.current=v,n(v)};return r.jsxs("div",{className:"wait-names",ref:d,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(v=>r.jsx("li",{"data-fresh":s-v.waiting.since<cme||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>b(v.id),"aria-label":Gpe(v.label,v.waiting,s-v.waiting.since),...c.bind({label:v.label,detail:Kpe(v.waiting)}),children:r.jsx(NI,{w:v,now:s})})},v.id)),w.length>0&&k.length>0&&r.jsx("li",{children:r.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${k.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:iF(k,s)}),children:["+",k.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(v=>r.jsx("span",{className:"wait-entry",children:r.jsx(NI,{w:v,now:s})},v.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),c.node]})}const $1={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 hme(e){return e==="on"?`Notifications on. ${$1.on}.`:e==="blocked"?`${$1.blocked}.`:""}function fme({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:$1[e],children:e==="on"?"notifications on":"notifications blocked"})}function pme({versionCheck:e,welcome:t,desktopUpdate:n,pause:s,announcements:a,notify:o,waitingSessions:i,waitingCursorRef:c,focusSession:d,live:h,now:f,incidents:p,queueNamed:m}){const{version:w,notice:k,noticeOpen:b,showNotice:v,versionChecking:N,loadVersion:j}=e,{chipVersion:S,openReleaseNotes:_}=t,{readyAppUpdate:T,desktopUpdateRestarting:$,desktopUpdateFailure:M,askDesktopUpdateRestart:O}=n,I=y.useRef(!1);y.useEffect(()=>{$||!I.current||(I.current=!1,M&&_())},[$,M,_]);const F=z=>{I.current=!0,O(z)},{paused:L,pauseGate:A}=s,{blockedSaid:q,watchSaid:E,incidentSaid:D}=a,{notifySaid:P}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:LJ,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:IJ,width:19,height:16,alt:""}),r.jsx("h1",{children:$t}),r.jsx(rme,{readyAppUpdate:T,notice:k,noticeOpen:b,version:w,chipVersion:S,versionChecking:N,now:f,openReleaseNotes:_,showNotice:v,loadVersion:j,restartToUpdate:F,updateRestarting:$})]}),r.jsx(ame,{live:h,paused:L,pauseGate:A}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:q}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:E}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:D}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:hme(P)}),r.jsx(OJ,{incidents:p}),i.length>0&&r.jsx(ime,{waitingSessions:i,waitingCursorRef:c,focusSession:d,now:f,named:m}),P&&r.jsx(fme,{notifySaid:P})]})}function mme({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=Dn(),i=On(e),c=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),d=e.state==="active"&&!e.synthetic?yj(i.total,c):null,h=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${kn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
113
+ ${nt(i.total)} spent${d?` · ${d}`:""}`:""}`,onClick:()=>{try{s(e.id)}catch{}},children:[r.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),r.jsx("span",{className:"selected-label",children:e.label}),i.total>0&&r.jsxs("span",{className:"selected-cost",children:[nt(i.total),d?r.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&r.jsxs("span",{className:"selected-extra",children:["+",h]}),r.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),a()},children:"×"})]})}function gme({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:s,toggleCat:a}){return r.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 r.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>a(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${op[o]} tools`,children:[r.jsx(wfe,{cat:o}),r.jsx("span",{className:"cat-name",children:op[o]})]},o)})})}const yme=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function wme(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(yme)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function xme({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const a=Dn();return r.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[r.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})}),r.jsxs("span",{className:"drag-trash-copy",children:[r.jsx("span",{className:"drag-trash-text",children:t==="over"?r.jsxs(r.Fragment,{children:["Release to remove ",r.jsx("strong",{className:"drag-trash-name",children:s||"this card"})]}):"Drop here to remove from the board"}),r.jsx("span",{className:"drag-trash-hint",children:t==="over"?`${kn("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function vme({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:a,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:k,lodRef:b}=a,{markCanvasInput:v}=o,{peekAgent:N,peekLabel:j,peekRecap:S,peekBounds:_}=c;return r.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:wme,onPointerDownCapture:v,onPointerUpCapture:v,onWheelCapture:v,onFocusCapture:T=>{const $=T.target;if(!$N($)||b.current==null||b.current==="detail")return;const M=$.getAttribute("data-id");M&&i.current.agents.has(M)&&$.matches(":focus-visible")&&g6(M,$,"focus")},onBlurCapture:T=>{var M,O;const $=(O=(M=T.target).getAttribute)==null?void 0:O.call(M,"data-id");$&&io($)},children:[d,Ja(p)&&r.jsx(xme,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(Lde,{agentFor:N,recapFor:S,labelFor:j,bounds:_})]})}function bme({restarting:e,restartMode:t,live:n,paused:s}){return r.jsxs("div",{className:"conn-banner",role:"alert",children:[r.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${$t}…`:(()=>{const a=wK({connected:n,paused:s});return r.jsxs(r.Fragment,{children:[`Lost connection to the ${$t} server. Reconnecting…`,a&&r.jsx("span",{className:"conn-sub",children:a})]})})()]})}function kme({oldName:e,version:t,dismissOldName:n}){return r.jsxs("div",{className:"ver-banner",role:"status",children:[r.jsx("span",{className:"ver-dot"}),r.jsxs("strong",{children:[e," still works — the deck is called ",$t," now."]}),t!=null&&t.renameFix?r.jsx("span",{className:"ver-sub",children:t.renameFix}):null,r.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const lF="Thanks — that helps.",jme=Array.from({length:11},(e,t)=>t);function Nme(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Sme=6;function _me(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 a=()=>s.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);a();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return o==null||o.observe(n),()=>{o==null||o.disconnect(),s.style.removeProperty("--rating-h")}},[e]),t}function Cme(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Eme({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const c=_me(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,Pn(((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)&&Cme(),m()};return e==="thanks"?r.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||i(!1)},children:[r.jsx("span",{className:"ver-dot"}),r.jsx("strong",{children:lF}),t!==null&&t<=Sme?r.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,r.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(a),children:"×"})]}):r.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[r.jsx("span",{className:"ver-dot"}),r.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),r.jsx("span",{className:"rating-scale",children:jme.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":Nme(m),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(m)},children:m},m))}),r.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),r.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(s),children:"Not now"})]})}const Tme=3e4;function Ame({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Rme({bundle:e,running:t,pending:n,lastTried:s}){return t?Ame({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Mme(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function $me({asked:e,reported:t}){return t?t!==e:!1}function cF(e){const t=e.thresholdMs??Tme;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 Lme(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 Ime(e,t){return e?t==null?"auto when idle":`auto in ${Lme(t)}`:"auto-restart off"}function SI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Ome(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 Pme(e){const t=cF(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 L1={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 Dme({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:a,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:m}){var w,k,b;return r.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[r.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...$n(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
114
+
115
+ 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&&r.jsx("span",{className:"ver-sub",children:f.clause}),r.jsxs("label",{className:"ver-auto",children:[r.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:r.jsx("span",{className:"switch-knob"})}),r.jsx("span",{"aria-hidden":!0,children:Ime(c,p)})]})]}):r.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."})]}):r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:[$t," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&s!=="failed"&&r.jsx("button",{type:"button",className:"ver-act",onClick:a,...$n(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)&&r.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...$n(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"?r.jsxs("span",{className:"ver-sub fail",title:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?r.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":L1.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Gt(L1,t.upgradeBlocked)??"cannot install from here"}):null,r.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[r.jsx("code",{children:t==null?void 0:t.command}),r.jsx("span",{className:"ver-cmd-hint",children:i?"copied":"copy"})]})]}),r.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Fme({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:a,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:k,restartCopy:b,restartFuseMs:v}=e,{version:N,notice:j,noticeOpen:S,dismissNotice:_}=t,{upgradeState:T,startUpgrade:$,copyCommand:M,cmdCopied:O}=n,{oldName:I,oldNameOpen:F,dismissOldName:L}=s,{ratingPhase:A,ratingScore:q,answerRating:E,rateLater:D,closeRating:P,holdThanks:z}=a,G=w?r.jsxs("div",{className:"ver-banner done",role:"status",children:[r.jsx("span",{className:"ver-dot"}),r.jsxs("strong",{children:["Restarted — now running v",w,"."]}),r.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?r.jsx(bme,{restarting:p,restartMode:m,live:c,paused:d}):S&&j?r.jsx(Dme,{notice:j,version:N,dismissNotice:_,upgradeState:T,startUpgrade:$,copyCommand:M,cmdCopied:O,autoRestart:h,toggleAutoRestart:f,askRestart:k,restartCopy:b,restartFuseMs:v,restarting:p}):F&&I?r.jsx(kme,{oldName:I,version:N,dismissOldName:L}):A!=="hidden"?r.jsx(Eme,{phase:A,score:q,onAnswer:E,onLater:D,onClose:P,onFeedback:o,onHold:z}):null;return r.jsxs(r.Fragment,{children:[G,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:A==="thanks"?lF:""})]})}function Bme(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function qme(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 Ume(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Wme(e,t){const n=Ume(e),s=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==null),a="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:a,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. ${a}`,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:a,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:a,confirm:"Clear everything"}}function Hme({agentCount:e,onConfirm:t,onCancel:n}){const s=y.useRef(null),a=pt(n,{focusRef:s,layer:bV}),o=gt(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(qme(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Wme(e,i);return r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:"status-dot err","aria-hidden":!0}),r.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsxs("dl",{className:"cc-plan",children:[r.jsx("dt",{children:"Goes"}),r.jsx("dd",{children:d.map(m=>r.jsx("span",{children:m},m))}),r.jsx("dt",{children:"Stays"}),r.jsx("dd",{children:h.length>0?h.map(m=>r.jsx("span",{children:m},m)):r.jsx("span",{children:"nothing"})})]}),f&&r.jsx("p",{className:"cc-final",children:f}),r.jsxs("div",{className:"cc-actions",children:[r.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),r.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}function zme({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),ip.map(n=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:s=>{FN(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const uF="fb-details";function Vme({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":uF,onClick:t,children:[epe,r.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:r.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function Gme({open:e,contact:t,onContact:n}){const s=y.useId();return r.jsx("div",{id:uF,className:"fb-details","data-open":e||void 0,children:r.jsx("div",{className:"fb-details-clip",children:r.jsxs("div",{className:"fb-details-body",children:[r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[tpe,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:q6,autoComplete:"email",placeholder:npe,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{FN(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:spe})]}),r.jsx("div",{className:"fb-where",children:rpe.map(a=>r.jsx("p",{children:a},a))})]})})})}const zo=3,Kme=5*1024*1024,Yme=12*1024*1024,I1=8192,Xme=64*1024,Zme=256*1024,Jme=.92,Qme=640,dF=.9,ege=.85,tge=6,nge=512*1024,cp={png:"image/png",jpeg:"image/jpeg"},sge={png:"png",jpeg:"jpg"},rge=[137,80,78,71,13,10,26,10],age=[255,216,255];function hF(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(rge)?"png":t(age)?"jpeg":null}function oge(e){const t=hF(e);return t==="png"?ige(e):t==="jpeg"?cge(e):null}function ige(e){const t=[73,72,68,82];if(e.length<24||!t.every((s,a)=>e[12+a]===s))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function lge(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function cge(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(lge(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 _I(e,t){return e.bytes>t||e.width>I1||e.height>I1}function uge(e){return Math.min(Kme,Yme-Xme-e)}function fF(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function dge(e,t){const n=I1/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*dF:1;return fF(e,Math.min(1,n,s))}async function hge(e,t,n){let s=dge(e,t),a=e.format;for(let o=0;o<tge;o++){const i=await n(s,a,a==="jpeg"?Jme:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=fF(s,Math.min(ege,Math.sqrt(t/i.size)*dF)),Math.max(s.width,s.height)<Qme)return null}return null}async function fge(e,t,n){const s=new Uint8Array(await e.slice(0,nge).arrayBuffer()),a=hF(s);if(!a)return{ok:!1,problem:"type"};if(t<Zme)return{ok:!1,problem:"no_room"};const o=e.type===cp[a]?e:new Blob([e],{type:cp[a]}),i=oge(s);if(i&&!_I({...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:a};if(!_I(d,t))return{ok:!0,blob:o,resized:null};const h=await hge(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 pge(e){return({width:t,height:n},s,a)=>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)},cp[s],a)})}const mge=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:pge(t),release:()=>t.close()}};function gge(e){return e.includes("Files")}function yge({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function wge(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function xge(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,a)=>{const o=s.type===cp.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${sge[o]}`)}),{method:"POST",body:n}}const vge="Add screenshot",CI="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",bge="A screenshot can show emails, costs and paths. Crop out what should not be seen.",EI="Three images at most. Remove one to add another.",kge="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function jge(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function Nge(e,t){const n=`${e} of ${zo}`;return t>0?`${n} · ${t} resized to fit`:n}function Sge(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function _ge(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Cge(e,t){const n=_ge(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 pF="image/png,image/jpeg";function mF({className:e="fb-glyph"}){return r.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:[r.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),r.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),r.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Ege({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=zo;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:CI,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx(mF,{}),vge]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:CI}),r.jsx("input",{ref:n,type:"file",accept:pF,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function Tge({images:e,addRef:t}){const n=y.useRef(new Map),s=y.useRef(null),a=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=Nge(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(wge(d.map(w=>w.id),m)??"add"),e.remove(m)}function p(m){var w;o.current=m,(w=a.current)==null||w.click()}return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),r.jsx("input",{ref:a,type:"file",accept:pF,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&&r.jsxs("div",{className:"fb-shots",children:[r.jsxs("div",{className:"fb-shots-row",children:[r.jsx("ul",{className:"fb-shots-list",children:d.map((m,w)=>r.jsxs("li",{className:"fb-shot","data-fitting":m.blob?void 0:!0,children:[r.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":jge(w,m.name,m.resized),onClick:()=>p(m.id),children:[r.jsx("img",{className:"fb-shot-img",src:m.url,alt:""}),m.blob?r.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):r.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),r.jsx("button",{ref:k=>{k?n.current.set(m.id,k):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:r.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:r.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},m.id))}),r.jsx("span",{className:"fb-shots-count",children:h})]}),r.jsx("p",{className:"fb-hint",children:bge})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Age(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 Rge(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function Mge(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function $ge(e){const[t,n]=y.useState(()=>Age((e==null?void 0:e.ready)??[],1)),[s,a]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(A=>{A&&o.current++,a(q=>A?{problem:A,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),k=y.useRef([]),b=y.useRef(0),v=y.useCallback(A=>{h.current=A(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const A of h.current)URL.revokeObjectURL(A.url)}),[]);const N=y.useCallback(async(A,q)=>{const E=h.current.reduce((ee,U)=>{var Y;return ee+(U.id===(q==null?void 0:q.id)?0:((Y=U.blob)==null?void 0:Y.size)??0)},0),D=(q==null?void 0:q.id)??++p.current,P=URL.createObjectURL(A),z={id:D,name:A.name||"image",url:P,blob:null,resized:null},G=b.current;w.current.set(D,A);let V=!1;const H=()=>{V||(V=!0,v(ee=>Rge(ee,z,q!==void 0)))},B=await fge(A,uge(E),async ee=>(H(),mge(ee))).catch(()=>({ok:!1,problem:"unreadable"})),W=h.current.some(ee=>ee.id===D);return!m.current||b.current!==G||!W&&(V||q)?(URL.revokeObjectURL(P),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(D),""):(w.current.delete(D),B.ok?(H(),q&&URL.revokeObjectURL(q.url),v(ee=>ee.map(U=>U.id===D?{...U,blob:B.blob,resized:B.resized}:U)),""):(URL.revokeObjectURL(P),V&&v(ee=>Mge(ee,D,q)),Cge(B.problem,A.name||"image")))},[v]),j=y.useCallback(async A=>{i("");const q=b.current,E=[];let D=0,P=0;for(const G of A){if(!m.current||b.current!==q)return;const V=k.current.indexOf(G);if(V!==-1&&k.current.splice(V,1),h.current.length>=zo){D++;continue}const H=h.current.length,B=await N(G);B&&E.push(B),h.current.length>H&&P++}if(!m.current||b.current!==q)return;D>0&&E.push(P===0&&E.length===0?EI:Sge(D)),i(E.join(" "));const z=h.current.length;P>0&&d(`${P===1?"Image":`${P} images`} added, ${z} of ${zo}.`)},[N,i]),S=y.useCallback(async(A,q)=>{i("");const E=h.current.find(z=>z.id===A);if(!E)return j([q]);const D=await N(q,E);if(!m.current)return;i(D);const P=h.current.findIndex(z=>z.id===A);!D&&P!==-1&&d(`Image ${P+1} replaced, ${h.current.length} of ${zo}.`)},[j,N,i]),_=y.useCallback(A=>{const q=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===q?A():void 0).catch(()=>{})},[]),T=y.useCallback(A=>{A.length!==0&&(k.current.push(...A),_(()=>j(A)))},[j,_]);y.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const $=y.useCallback((A,q)=>{const E=q[0];E&&_(()=>S(A,E))},[_,S]),M=y.useCallback(A=>{const q=h.current.find(E=>E.id===A);q&&(URL.revokeObjectURL(q.url),w.current.delete(A),v(E=>E.filter(D=>D.id!==A)),i(""),d(`Image removed, ${h.current.length} of ${zo}.`))},[v,i]),O=y.useCallback(()=>i(EI),[i]),I=y.useCallback(async()=>{const A=o.current;return await f.current,o.current!==A?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),F=y.useCallback(()=>({ready:h.current.flatMap(A=>A.blob&&!w.current.has(A.id)?[{name:A.name,blob:A.blob,resized:A.resized}]:[]),waiting:[...w.current.values(),...k.current]}),[]),L=y.useCallback(()=>{b.current++;for(const A of h.current)URL.revokeObjectURL(A.url);w.current.clear(),k.current=[],v(()=>[]),i("")},[v,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:T,replace:$,remove:M,sayFull:O,ready:I,kept:F,clear:L}}function Lge(){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(Kfe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function Ige(e){const[t,n]=y.useState({state:"idle"}),s=y.useRef(!1),a=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=a.current)==null?void 0:c.abort()},[]);async function o(c){if(!bn(s.current))return;s.current=!0;const{signal:d}=a.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:kge});return}const f=await fetch("/api/feedback",{...xge(Gfe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:gI(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:gI(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 Oge(e,t){const[n,s]=y.useState(!1),a=y.useRef(t);return a.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),yI),i=window.setTimeout(()=>a.current(),yI+cpe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const a0="agent-dag.feedbackDrafts",TI=4;function Pge({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Dge(e){return JSON.stringify([e.kind,e.body])}function Fge(e){return e.ready.length+e.waiting.length}function gF(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Bge(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 qge="Discard",Uge="Confirm discard",Wge="Clear the message, the screenshots and the contact",AI="Press again to clear this draft. It cannot be brought back.",Hge={ready:[],waiting:[]};function zge(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:a,images:o}=t;return!ip.some(i=>i.value===n)||typeof s!="string"||s.length>B6||typeof a!="string"||a.length>q6||typeof o!="number"||!Number.isInteger(o)||o<0||o>zo?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function Vge(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(a0),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-TI)){const h=zge(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(a0):o.setItem(a0,JSON.stringify(i))}catch{}}function a(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??Hge,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=Fge(i.images);if(!gF({body:i.body,contact:i.contact,images:d},c)){a(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<=TI)break;h.delete(f)}s()},forget:a}}function Gge(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const O1=Vge(Gge),Kge=4e3;function Yge(e,t,n,s,a){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:a};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||O1.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(()=>{a&&O1.forget(e)},[a,e])}const RI="draft";function Xge(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Kge);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=oi({armedFor:t?RI:null,target:RI,armedAt:s.current,now:o,gapMs:ai});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:a}}function yF({onClose:e,initialKind:t,initialBody:n}){const s=y.useRef(null),a=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=pt(e,{focusRef:s}),w=gt(e),k=Pge({initialKind:t,initialBody:n}),b=Dge(k),[v]=y.useState(()=>O1.read(b)),[N,j]=y.useState((v==null?void 0:v.kind)??k.kind),[S,_]=y.useState((v==null?void 0:v.body)??k.body),[T,$]=y.useState((v==null?void 0:v.contact)??""),[M,O]=y.useState((v==null?void 0:v.imagesLost)??0),[I,F]=y.useState(!1),[L,A]=y.useState(!1),[q,E]=y.useState(!1),D=$ge(v==null?void 0:v.images),P=Zfe(Lge()),{outcome:z,sending:G,send:V,clearFailure:H}=Ige(D),B=z.state==="sent",W=Oge(B,e);Yge(b,k,{kind:N,body:S,contact:T},D,B);const ee=gF({body:S,contact:T,images:D.shots.length},k),U=Xge(()=>{var ge;j(k.kind),_(k.body),$(""),O(0),A(!1),D.clear(),H(),(ge=s.current)==null||ge.focus()}),Y=F6(N),X=L&&!pI(S),Z=M>0&&D.shots.length===0,J=[X&&"fb-body-error",Z&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[te,ce]=ope(zu());y.useEffect(()=>{var Ie,We;const ge=i.current;if(!ge)return;const Me=ge.contains(document.activeElement)||Pn(((Ie=document.activeElement)==null?void 0:Ie.tagName)??null);ge.inert=B,B&&Me&&((We=a.current)==null||We.focus())},[B]),y.useEffect(()=>{var Te,at;const ge=c.current;if(!ge)return;const Me=h.current;if(G){const Je=document.activeElement,Ve=Je!=null&&(ge.contains(Je)||Je===Me);f.current=Ve?Je:null,ge.inert=!0,Me&&(Me.inert=!0),f.current&&((Te=d.current)==null||Te.focus());return}ge.inert=!1,Me&&(Me.inert=!1);const Ie=f.current;f.current=null;const We=document.activeElement===d.current||Pn(((at=document.activeElement)==null?void 0:at.tagName)??null);!B&&Ie&&We&&Ie.focus()},[G,B]);function he(ge){var Me;if(ge.preventDefault(),!pI(S)){A(!0),(Me=s.current)==null||Me.focus();return}V({kind:N,body:S,contact:T})}const le=!B&&!G,re=ge=>gge(Array.from(ge.dataTransfer.types));function ae(ge){!re(ge)||!le||(ge.preventDefault(),p.current++,E(!0))}function de(ge){re(ge)&&(ge.preventDefault(),ge.dataTransfer.dropEffect=le?"copy":"none")}function _e(ge){re(ge)&&(p.current=Math.max(0,p.current-1),p.current===0&&E(!1))}function fe(ge){re(ge)&&(ge.preventDefault(),p.current=0,E(!1),le&&D.add(Array.from(ge.dataTransfer.files)))}function ye(ge){ge.target!==ge.currentTarget||!re(ge)||(ge.preventDefault(),ge.dataTransfer.dropEffect="none")}function ke(ge){re(ge)&&ge.preventDefault()}function Ne(ge){if(!le)return;const Me=Array.from(ge.clipboardData.files),Ie=ge.target,We=Ie instanceof HTMLTextAreaElement||Ie instanceof HTMLInputElement,Te=Array.from(ge.clipboardData.types).includes("text/plain");yge({files:Me.length,hasText:Te,intoTextField:We})&&(ge.preventDefault(),D.add(Me))}return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ye,onDrop:ke,"data-leaving":W||void 0,children:r.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:ge=>ge.stopPropagation(),onDragEnter:ae,onDragOver:de,onDragLeave:_e,onDrop:fe,onPaste:Ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:a,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsx("p",{className:"vis-hidden",role:"status",children:U.armed?AI:lpe(z.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:he,onKeyDown:ge=>{ape(ge.nativeEvent)&&(ge.preventDefault(),ge.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:c,className:"modal-body fb-body",children:[r.jsx(zme,{kind:N,onChange:j}),r.jsxs("div",{className:"fb-compose",children:[r.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:Y.question}),r.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:B6,rows:5,placeholder:Y.placeholder,onChange:ge=>_(ge.target.value),"aria-invalid":X||void 0,"aria-describedby":J,required:!0}),X&&r.jsx("p",{id:"fb-body-error",className:"fb-error",children:Wfe}),r.jsx(Tge,{images:D,addRef:o}),Z&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Bge(M)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(Ege,{images:D,buttonRef:o}),r.jsx(Vme,{open:I,onToggle:()=>F(ge=>!ge)})]}),r.jsx(Gme,{open:I,contact:T,onContact:$})]}),r.jsx("p",{className:"fb-facts",children:P?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:P})," — ",Jfe]}):Qfe}),z.state==="failed"&&r.jsx("p",{className:"fb-error",role:"alert",children:z.message})]}),r.jsxs("div",{className:"fb-foot",children:[ee&&r.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${U.armed?" armed":""}`,onKeyDown:ge=>{ge.repeat&&ge.preventDefault()},onClick:U.press,title:U.armed?AI:Wge,children:U.armed?Uge:qge}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":ipe(te)||void 0,children:te}),r.jsx("kbd",{children:ce})," to send"]}),r.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),r.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...$n(G),children:r.jsxs("span",{className:"fb-send-label",children:[r.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),r.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),B&&r.jsxs("div",{className:"fb-done",children:[r.jsx(Zf,{}),r.jsx("p",{className:"fb-done-line",children:U6})]})]}),r.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":q||void 0,children:r.jsxs("div",{className:"fb-drop-frame",children:[r.jsx(mF,{className:"fb-drop-glyph"}),r.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),r.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const wF="Press Esc first if a key does nothing.",o0=[{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:"I",action:"Jira, once it is connected in Settings › Integrations",binds:["i","I"],integration:"jira"},{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:[]}]}],Zge=/ \([A-Z?]\)/g;function xF(e,t=()=>!0){const n=s=>s.integration===void 0||t(s.integration);return e&&o0.every(s=>s.rows.every(n))?o0:o0.map(s=>({...s,rows:s.rows.filter(n).filter(a=>e||a.chord||!a.binds.some(Y4)).map(a=>e?a:{...a,action:a.action.replace(Zge,"")})})).filter(s=>s.rows.length>0)}const Jge="Single-key shortcuts are off.",vF="Settings › Keyboard",Qge=`Single-key shortcuts can be turned off in ${vF}.`;function eye({onClose:e,onTour:t,onSettings:n}){const s=pt(e),a=gt(e),o=Vu(zu()),i=Dn(),c=ad(),d=xF(i,h=>od(c,h));return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal key-help",onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[!i&&r.jsxs("div",{className:"kh-off",children:[r.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[r.jsx("strong",{children:Jge})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:vF}),". Everything below still works."]}),n&&r.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),t&&r.jsxs("div",{className:"guide-door",children:[r.jsx("span",{children:"Eight pictures of what the deck shows."}),r.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),r.jsx("div",{className:"shortcuts",children:d.map(h=>r.jsxs(y.Fragment,{children:[r.jsx("h3",{className:"kh-group",children:h.title}),h.rows.map(f=>r.jsxs("div",{className:"sc",children:[r.jsx("kbd",{children:o&&f.macCap?f.macCap:f.cap}),r.jsx("span",{children:f.action})]},`${h.title}:${f.cap}:${f.action}`))]},h.title))}),i&&r.jsxs("p",{className:"kh-foot",children:[wF," ",Qge]})]})]})})}function tye(e,t){return`${e}#${t}`}function nye(e,{lan:t,now:n,closed:s}){if(t===void 0)return[];const a=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=tye(i.key,i.since);if(s.has(c)||Jte(i.key,o.email,t,n))continue;const d=o.email??"";a.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 a}function sye(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 bF({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function rye(e){return e===1?"Account needs your attention":"Accounts need your attention"}function aye(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const oye="Login expired",iye="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.",lye="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function cye(e,t){const n=(e??[]).filter(a=>a&&typeof a.fp=="string"&&!t.has(a.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((a,o)=>(a.at??0)-(o.at??0));return{request:s[0],waiting:s.length-1}}function uye({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:o,onLater:i}){const c=y.useRef(null),d=pt(i,{focusRef:c}),h=gt(i),f=ao(n,"accept"),p=ao(n,"dismiss");return r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.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:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("i",{className:"ap-pulse","aria-hidden":!0}),r.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:i,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[r.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",r.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",rN(e.at,s)]}),r.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."}),r.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",r.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&&r.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.`}),r.jsxs("div",{className:"lan-ask-acts",children:[r.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"}),r.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:a,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function dye(e){const t=y.useRef(!1),n=hye(e),s=bF({rows:n?1:0,ours:t.current,dialogs:vn.dialogDepth()});return t.current=s,s?n:null}function hye({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=cye(e,t.current);return o?r.jsx(uye,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void s("accept",o.fp),onDecline:()=>void s("dismiss",o.fp),onLater:()=>a(o.fp)},o.fp):null}function fye({rows:e,onSignIn:t,onLater:n,firstRef:s}){const a=e.length===1?e[0]:null;return r.jsxs("section",{className:"modal-body",children:[a?r.jsxs(r.Fragment,{children:[r.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",r.jsx("strong",{className:"reauth-name",children:a.name}),a.alias?r.jsxs("span",{className:"reauth-alias",children:[" (",a.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),r.jsx("p",{className:"reauth-note",children:iye})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:aye(e.length)}),r.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>r.jsxs("li",{className:"reauth-row",children:[r.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?r.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),r.jsx("span",{className:"reauth-what",children:oye}),r.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))}),r.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),r.jsxs("div",{className:"reauth-acts",children:[r.jsx("button",{type:"button",className:"btn",title:lye,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function pye({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),a=pt(n,{focusRef:s}),o=gt(n);return r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:rye(e.length)})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),r.jsx(fye,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function mye({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=vn.dialogDepth()+(c?1:0),f=t!=null||bF({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?r.jsx(ED,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(pye,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const gye={"//":["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.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
116
+
117
+ Update every paired deck: an older deck still sends the login it is using, and the decks paired with it still take it. To send it anyway, as before, turn on Send the login this deck is using too in the Local network dialog. Not covered yet: a paired deck that already holds a copy of that login, from before this deck switched to it, can still renew it first and sign this deck out. Auto-switch can also still move a deck onto a login another paired deck is using, if the deck already holds a copy of it.`}],"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.
118
+
119
+ 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.
120
+
121
+ 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.
122
+
123
+ 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.
124
+
125
+ 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.
126
+
127
+ 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".
128
+
129
+ **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.
130
+
131
+ \`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.
132
+
133
+ **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.
134
+
135
+ 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.
136
+
137
+ 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.
138
+
139
+ 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.
140
+
141
+ 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.
142
+
143
+ 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.
144
+
145
+ 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.
146
+
147
+ What you are reading is the first version that does not.
148
+
149
+ 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.
150
+
151
+ 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.
152
+
153
+ 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.
154
+
155
+ 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.
156
+
157
+ 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.
158
+
159
+ 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.
160
+
161
+ The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
162
+
163
+ **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.
164
+
165
+ 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.
166
+
167
+ \`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.
168
+
169
+ 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.
170
+
171
+ **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.
172
+
173
+ **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.
174
+
175
+ **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.
176
+
177
+ **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.
178
+
179
+ **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.
180
+
181
+ **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.
182
+
183
+ 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.
184
+
185
+ 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.
186
+
187
+ 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.
188
+
189
+ 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.
190
+
191
+ 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.
192
+
193
+ 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.
194
+
195
+ 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.
196
+
197
+ 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.
198
+
199
+ 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.
200
+
201
+ 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.
202
+
203
+ 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.
204
+
205
+ 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.
206
+
207
+ 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.
208
+
209
+ 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.
210
+
211
+ 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.
212
+
213
+ 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.
214
+
215
+ 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.
216
+
217
+ 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.
218
+
219
+ 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.
220
+
221
+ 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.
222
+
223
+ 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.
224
+
225
+ 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.
226
+
227
+ 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.
228
+
229
+ 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.
230
+
231
+ 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.
232
+
233
+ 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.
234
+
235
+ 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.
236
+
237
+ 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.
238
+
239
+ 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.
240
+
241
+ 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.
242
+
243
+ 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.
244
+
245
+ 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.
246
+
247
+ 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.
248
+
249
+ 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.
250
+
251
+ 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.
252
+
253
+ 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.
254
+
255
+ 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.
256
+
257
+ 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.
258
+
259
+ 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.
260
+
261
+ 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".
262
+
263
+ 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.
264
+
265
+ 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.
266
+
267
+ 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.
268
+
269
+ 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.
270
+
271
+ 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.
272
+
273
+ 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.
274
+
275
+ 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.
276
+
277
+ 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.
278
+
279
+ 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.
280
+
281
+ 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.
282
+
283
+ 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.
284
+
285
+ 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.
286
+
287
+ 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.
288
+
289
+ 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.
290
+
291
+ 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.
292
+
293
+ 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.
294
+
295
+ 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.
296
+
297
+ 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.
298
+
299
+ 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.
300
+
301
+ 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.
302
+
303
+ 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.
304
+
305
+ 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.
306
+
307
+ 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.
308
+
309
+ 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.
310
+
311
+ 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.`}]},WN="agent-dag.releaseNotesSeen";function MI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function ci(e,t){const n=MI(e),s=MI(t);for(let a=0;a<Math.max(n.length,s.length);a++){const o=(n[a]??0)-(s[a]??0);if(o!==0)return o<0?-1:1}return 0}function lo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function yye(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 wye(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!lo(n)||!Array.isArray(s))continue;const a=s.filter(yye);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>ci(s.version,n.version))}const $I=wye(gye);function kF(e,t,n){return e.filter(s=>ci(s.version,n)<=0&&(t===null||ci(s.version,t)>0))}function xye(e,t){return e.filter(n=>ci(n.version,t)===0)}function vye(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 bye({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&&lo(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 a=n[0].version;if(!lo(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=ci(a,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 kye=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function jye(e){const t=kye.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Nye(e){if(!e)return null;let t=null;try{t=e.getItem(WN)}catch{return null}return lo(t)?t:null}function Sye(e){if(!e)return!1;try{return e.getItem(WN),!0}catch{return!1}}function _ye(e,t){if(!e)return!1;try{return e.setItem(WN,t),!0}catch{return!1}}const jF="agent-dag.tourSeen";function Cye(e){if(!e)return!1;try{return e.getItem(jF)==="1"}catch{return!1}}function Eye(e){if(!e)return!1;try{return e.setItem(jF,"1"),!0}catch{return!1}}function Tye({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 Aye({stored:e,running:t,notes:n,remembers:s=!0}){if(!lo(t))return{show:[],record:null,reason:"no-version"};if(!lo(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=xye(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=ci(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const o=kF(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Rye(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 NF(e,t=!0){const n=[];let s="";const a=()=>{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){a(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=Rye(e,o);if(i>0){a(),n.push({kind:"bold",kids:NF(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return a(),n}function co(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function mke(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function gke(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 Mye(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function yke(e){return!Number.isFinite(e)||e<=0?"empty":Qr(e)}function wke(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,a)=>s+a.programVisits,0)}))}function $ye(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 xke(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],a=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(a>0?`, and ${a} more`:"")+". The watch continues on the profiles it can read."}}const n=Mye(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 Lye="Check for updates",SF="Ask npm now whether a newer ccdeck is out.",LI="Checking…",Iye="Couldn't reach npm. Try again.",Oye="Couldn't reach the deck. Try again.",_F="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",Pye="The deck looks again in five minutes.";function Dye(e,t,n,s){const a=s?t.npx:n?Gt(t,n):void 0;return a?`${e} is out, but ${a}`:`${e} is out. Run:`}const Tn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Fo=e=>Tn(e,{tone:"note"});function II(e,t){return $ye(e,t)??"just now"}function Fye(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?Fo(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?Fo("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?Fo(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?Fo(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?Fo("The app's last update check failed. Try Check for updates again."):Fo("The app keeps itself up to date. Check for updates here.")}function Bye(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 a=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:Dye(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(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function qye(e){const t=e.version;if(e.unreachable)return Tn(Oye,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Tn(Iye,{tone:"warn",age:e.answered?null:`Last tried ${II(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. ${Pye}`);const a=t!=null&&t.checkedAt?II(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:a?`Checked ${a}.`:null})}return Tn("",{age:a?`Last checked ${a}.`:null})}function Uye(e,t){var a,o;const n=e.version;if((a=e.app)!=null&&a.inApp&&(n!=null&&n.checkDisabled)){const i=Fye(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(LI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Fo(_F)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:Bye(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(LI)}:{canCheck:!0,checking:!1,line:qye(e)}}const CF=450;async function Wye(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(CF)]);return n?"answered":"unreachable"}async function Hye(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,CF))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const P1="Eight pictures of what the deck shows.",OI="Restart the deck. Sessions, settings and pairings come back as they were.";function zye(e){var $;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Nr(3e4),[s,a]=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:k,running:b,onHandOff:v}=e,N=Uye({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:co(),update:k.appUpdate,version:tF(),menu:sF()}},L1);if(!N)return null;const j=co()&&(($=p.version)==null?void 0:$.checkDisabled);return{state:N,check:async()=>{var O;if(!bn(o.current||t)||j&&((O=k.appUpdate)==null?void 0:O.status)==="checking")return;o.current=!0,a(!0);const M=j?await Hye():await Wye(p.loadVersion);o.current=!1,a(!1),c(M==="unreachable"),h(!0)},act:M=>{if(M.kind==="copy")return void m.copyCommand();v(),p.showNotice(),M.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:j?"Ask the desktop app whether a newer ccdeck is out.":SF}}function Vye({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=zl("above","dialog"),a=zye(n),o=y.useId(),i=(a==null?void 0:a.state.canCheck)??!1,d=((h=a==null?void 0:a.state.line.action)==null?void 0:h.kind)==="install"||((f=a==null?void 0:a.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!a?null:r.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&r.jsxs("div",{className:"rn-acts",children:[e&&r.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...s.bind({label:P1}),children:[r.jsx(wne,{}),"Take the tour"]}),a&&i&&r.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void a.check(),"aria-busy":a.state.checking||void 0,"aria-describedby":`${o}-check`,...s.bind({label:a.checkWhy}),children:[r.jsx(xne,{}),Lye]}),d&&r.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:OI}),children:[r.jsx(vne,{}),"Restart"]})]}),a&&r.jsx(Gye,{line:a.state.line,onAct:a.act,bindHint:s.bind,whyId:`${o}-act`}),r.jsx("span",{hidden:!0,id:`${o}-tour`,children:P1}),r.jsx("span",{hidden:!0,id:`${o}-check`,children:(a==null?void 0:a.checkWhy)??SF}),r.jsx("span",{hidden:!0,id:`${o}-restart`,children:OI}),s.node]})}function Gye({line:e,onAct:t,bindHint:n,whyId:s}){const{action:a}=e,o=a&&r.jsx(Kye,{action:a,onAct:t,bindHint:n,whyId:s});return r.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[r.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&r.jsx("span",{className:"rn-update-age",children:e.age}),e.command?r.jsxs("span",{className:"rn-update-cmd",children:[r.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function Kye({action:e,onAct:t,bindHint:n,whyId:s}){const a=e.kind==="copy"?null:e.why;return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:a?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":a&&s?s:void 0,...a&&n?n({label:a}):{},children:e.label}),a&&s&&r.jsx("span",{hidden:!0,id:s,children:a})]})}function Yye({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const m=pt(a),w=gt(a),k=vye(e);return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),k&&r.jsx("span",{className:"modal-tool-id",children:k})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[(i||h)&&r.jsxs("div",{className:"rn-update",children:[i&&d&&r.jsxs("div",{className:"guide-door",children:[r.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),r.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Ll})]}),r.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),r.jsx("p",{className:"modal-note",children:bye({since:t,running:n,firstRun:s,entries:e})}),r.jsx(Vye,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(b=>r.jsxs("section",{className:"modal-section",children:[r.jsxs("h3",{className:"rn-version",children:["v",b.version]}),r.jsx("ul",{className:"rn-notes",children:b.notes.map((v,N)=>{const{icon:j,rest:S}=jye(v.title);return r.jsxs("li",{className:"rn-note",children:[r.jsxs("p",{className:"rn-note-title",children:[j&&r.jsx("span",{className:"rn-note-icon",children:j}),S]}),r.jsx("p",{className:"rn-note-body",children:EF(NF(v.body))})]},N)})})]},b.version))]})]})})}function EF(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?r.jsx("code",{className:"rn-code",children:t.text},n):r.jsx("strong",{className:"rn-strong",children:EF(t.kids)},n))}function Xye({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>Zye(e,t),[e,e.revision,t]),a=y.useRef(null),o=pt(n,{focusRef:a}),i=gt(n);return s?r.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:r.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),r.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),r.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),r.jsx("button",{type:"button",ref:a,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("section",{className:"ss-hero",children:[r.jsxs("div",{className:"ss-hero-left",children:[r.jsx("div",{className:"ss-cost-label",children:kP}),r.jsx("div",{className:"ss-cost",children:nt(s.cost.total)}),s.modelChips.length>0&&r.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>r.jsx("span",{className:"model-chip","data-family":kp(c),title:c,children:ro(c)},c))})]}),r.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&r.jsxs(r.Fragment,{children:[r.jsx(Uj,{cost:s.cost,size:"lg"}),r.jsxs("div",{className:"ss-cost-legend",children:[r.jsxs("span",{className:"ssl ssl-in",children:["input ",r.jsx("b",{children:nt(s.cost.input)})]}),r.jsxs("span",{className:"ssl ssl-out",children:["output ",r.jsx("b",{children:nt(s.cost.output)})]}),r.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",r.jsx("b",{children:nt(s.cost.cacheRead)})]}),r.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",r.jsx("b",{children:nt(s.cost.cacheWrite)})]})]})]})})]}),r.jsxs("section",{className:"ss-stats",children:[r.jsx(nl,{label:"agents",value:s.agentCount}),r.jsx(nl,{label:"subagents",value:s.subagentCount}),r.jsx(nl,{label:"tool calls",value:s.toolCount}),r.jsx(nl,{label:"prompts",value:s.promptCount}),r.jsx(nl,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&r.jsx(nl,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&r.jsxs("section",{className:"modal-section",children:[r.jsx("h4",{children:"Most-used tools"}),r.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>r.jsxs("div",{className:"ss-tt",children:[r.jsx("span",{className:"ss-tt-name",children:c}),r.jsx("span",{className:"ss-tt-bar",children:r.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),r.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&r.jsxs("section",{className:"modal-section",children:[r.jsx("h4",{children:"Opening prompt"}),r.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function nl({label:e,value:t,tone:n}){return r.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[r.jsx("div",{className:"ss-stat-value",children:t}),r.jsx("div",{className:"ss-stat-label",children:e})]})}function Zye(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 a={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,k=0;for(const S of s){const _=On(S);a.input+=_.input,a.output+=_.output,a.cacheRead+=_.cacheRead,a.cacheWrite+=_.cacheWrite,a.total+=_.total;for(const $ of p4(S))o.add($);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const T=G3(S.prompts);d+=T.length,!m&&T.length>0&&(m=T[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[$,M]of S.toolCountByName??[])i.set($,(i.get($)??0)+M);w=Math.min(w,S.startedAt),k=Math.max(k,S.endedAt??Date.now())}const b=Math.max(0,k-w),v=Math.floor(b/1e3),N=v<60?`${v}s`:v<3600?`${Math.floor(v/60)}m ${String(v%60).padStart(2,"0")}s`:`${Math.floor(v/3600)}h ${Math.floor(v%3600/60)}m`,j=Array.from(i.entries()).sort((S,_)=>_[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:N,cost:a,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:j,firstPrompt:m}}function qt({id:e,title:t,note:n,noteId:s,aside:a,list:o=!0,settingId:i,className:c,children:d}){const h=c?`settings-group ${c}`:"settings-group",f=o?r.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?r.jsx("div",{className:h,"data-setting":i,children:f}):r.jsxs("section",{className:h,"aria-labelledby":e,"data-setting":i,children:[r.jsxs("div",{className:"settings-caption",children:[r.jsxs("div",{className:"settings-caption-text",children:[r.jsx("h3",{id:e,children:t}),n&&r.jsx("p",{className:"settings-caption-note",id:s,children:n})]}),a]}),f]})}function ut({name:e,nameId:t,note:n,noteId:s,control:a,as:o="label",settingId:i,className:c,children:d}){const h=o;return r.jsxs(h,{className:c?`settings-row ${c}`:"settings-row","data-setting":i,children:[r.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&r.jsx("span",{className:"settings-row-note",id:s,children:n}),a!==void 0&&r.jsx("span",{className:"settings-row-control",children:a}),d]})}function TF(e,t){const[n,s]=y.useState(null),[a,o]=y.useState(!1),[i,c]=y.useState(""),d=y.useRef(!1),h=p=>typeof p=="boolean"?p:t;return 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&&s(h((w=m.prefs)==null?void 0:w[e]))}).catch(()=>{p&&c("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[e]),{enabled:n,busy:a,error:i,change:async()=>{if(!(n===null||!bn(d.current))){d.current=!0,o(!0),c("");try{const p=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:!n})});if(!p.ok)throw new Error;const m=await p.json();if(!m.ok)throw new Error;s(h(m.prefs[e]))}catch{c("Could not save this setting. Try again.")}finally{d.current=!1,o(!1)}}}}}function PI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=TF(t,!0);return r.jsxs(qt,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[r.jsx(ut,{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:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":`Restore unfinished ${e} sessions`,"aria-checked":s.enabled===!0,...$n(s.busy,s.enabled===null),onClick:()=>{s.change()},children:r.jsx("span",{className:"switch-knob"})})}),s.error&&r.jsx("p",{role:"alert",children:s.error}),e==="Claude"&&r.jsx(Jye,{})]})}function Jye(){const e=TF("continueStopped",!1);return r.jsxs(r.Fragment,{children:[r.jsx(ut,{settingId:"claude-continue-stopped",name:"Continue stopped background sessions",note:"When a background session stops on an expired login or a usage limit, continue it once a working login with room is active. Once per stop; a session that stops again right after waits for you.",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":"Continue stopped background sessions automatically","aria-checked":e.enabled===!0,...$n(e.busy,e.enabled===null),onClick:()=>{e.change()},children:r.jsx("span",{className:"switch-knob"})})}),e.error&&r.jsx("p",{role:"alert",children:e.error})]})}const AF="agent-dag.character",ff=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Qye(e){return e==="fox"||e==="penguin"?e:"deck"}function ewe(){return Qye(Ye(AF))}const twe="With no deck tab open, get a notification wherever a sound would have played.",nwe="With the ccdeck window closed, get a notification wherever a sound would have played.";function swe(e){return e?nwe:twe}const rwe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",RF=[{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"},{kind:"notifyStopped",label:"Sessions stopped on login or limit",title:"When Claude Code sessions stop on an expired login or a usage limit — once for all of them, with what to type to resume"},{kind:"notifyElsewhere",label:"Login active on another deck",title:"When a paired deck is on the same Claude login as this one — when one renews it, the other is signed out"}],awe="For the Claude and Codex accounts you're on, whether or not the deck is open.",owe="Held off for this run too.",DI="Get notified when you're away from this tab.";function iwe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:DI};case"default":return{status:null,ask:!0,ok:!1,note:DI};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 MF="section:";function $F(e){return e.id.startsWith(MF)}const lwe={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],integrations:["jira","atlassian","tracker","issues","connect","token","board","sprint"],data:["privacy","local data"],radar:["telemetry","collector","monitoring"],about:["information"]},cwe={done:"Turn finished","needs-input":"Claude is asking"},uwe={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},dwe={notifySwap:["auto-switch","switch account","swap","alerts"],notifyQuota:["quota","limit","rate limit","usage","alerts"],notifyReset:["quota","limit","window","available","alerts"],notifyStopped:["stopped","login","expired","usage limit","continue","alerts"],notifyElsewhere:["login","signed out","local network","another deck","same account","alerts"]},HN=e=>{var t;return((t=ap.find(n=>n.id===e))==null?void 0:t.label)??e};function hwe(e){return{id:`${MF}${e}`,section:e,label:HN(e),keywords:lwe[e]}}function fwe(){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:"claude-continue-stopped",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Continue stopped background sessions",keywords:["claude","continue","background","stopped","login","usage limit","automatically"]},{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"]},...ta.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:sd[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",...ff.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"]},...RF.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:dwe[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...lu.map(t=>({id:`tone-${t}`,section:"sounds",label:cwe[t],keywords:uwe[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"]}],integrations:[{id:"integrations-add",section:"integrations",label:"Add integration",keywords:["connect","jira","jira cloud","jira server","data center","api token","personal access token","pat"]},{id:"integrations-connections",section:"integrations",label:"Connections",keywords:["disconnect","reconnect","test connection","edit","token","expired","jira"]}],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"]}],radar:[{id:"radar-enabled",section:"radar",label:"Monitor automatically",keywords:["telemetry","collector","monitoring","traffic","background","automatic","radar"]}],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 ap.flatMap(({id:t})=>[hwe(t),...e[t]])}const D1=fwe();function pwe(e,t="all"){return e&&t==="all"?D1:D1.filter(n=>(e||!n.claudeOnly)&&(n.section!=="integrations"||t==="all"||t==="connections"&&n.id!=="integrations-add"))}function LF(e){if($F(e))return"Section";const t=HN(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function mwe(e){return`${e.label}, ${LF(e).replace(/ › /g,", ")}`}function Jc(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function Yh(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 gwe(e,t){const n=Jc(e.label);if(n.startsWith(t))return 0;if(Yh(n,t))return 1;const s=e.keywords.map(Jc);if(s.some(i=>Yh(i,t)))return 2;const a=[Jc(HN(e.section)),...e.group?[Jc(e.group)]:[]];if(a.some(i=>Yh(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(c=>i.some(d=>Yh(d,c))))return 4}return null}const ywe=12;function wwe(e,t=D1){const n=Jc(e);return n?t.map((s,a)=>({entry:s,at:a,score:gwe(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,ywe).map(s=>s.entry):[]}function IF(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function xwe(e,t,n,s){if(e==="Escape")return t!==""?{kind:"clear"}:{kind:"pass"};if(n===0)return{kind:"pass"};const a=Math.min(Math.max(s,0),n-1);return e==="ArrowDown"?{kind:"move",index:(a+1)%n}:e==="ArrowUp"?{kind:"move",index:(a-1+n)%n}:e==="Enter"?{kind:"open",index:a}:{kind:"pass"}}const vwe="Hide finished sessions after",bwe="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 kwe(){const e=C6();return r.jsx(qt,{id:"settings-board-caption",title:"Board",children:r.jsx(ut,{settingId:"hide-finished",name:vwe,nameId:"settings-hide-finished-label",note:bwe,noteId:"settings-hide-finished-note",control:r.jsx("select",{className:"sm-select",value:e,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:t=>Ahe(Number(t.target.value)),children:j6.map(t=>r.jsx("option",{value:t,children:The(t)},t))})})})}const jwe="Accounts and auto-switch",Nwe="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",Swe="Local network",_we="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",Cwe="Browser Watch",Ewe="Whether something drove your browser while you were away, and what the deck does about it.";function Twe({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(qt,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(i0,{settingId:"accounts",name:jwe,note:Nwe,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(i0,{settingId:"local-network",name:Swe,note:_we,onOpen:n.localNetwork,cap:null}),r.jsx(i0,{settingId:"browser-watch",name:Cwe,note:Ewe,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function i0({settingId:e,name:t,note:n,onOpen:s,cap:a,dialog:o=!1}){const i=`settings-${e}`;return r.jsx(ut,{as:"div",settingId:e,name:t,nameId:`${i}-name`,note:n,control:r.jsxs(r.Fragment,{children:[a&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a.title,children:a.key}),r.jsx("button",{type:"button",className:"btn",id:`${i}-open`,"aria-labelledby":`${i}-open ${i}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":a?a.key:void 0,onClick:s,children:"Open"})]})})}const Awe="Single-key shortcuts",Rwe="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 Mwe(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function $we(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function Lwe({singleKeys:e,onToggleSingleKeys:t}){const n=Vu(zu()),[s,a]=y.useState(""),o=y.useId(),i=ad(),c=xF(e,d=>od(i,d)).map(d=>({...d,rows:d.rows.filter(h=>$we(h,s))})).filter(d=>d.rows.length>0);return r.jsxs(r.Fragment,{children:[r.jsx(qt,{children:r.jsx(ut,{settingId:"single-keys",name:Awe,nameId:"settings-single-keys-label",note:Rwe,noteId:"settings-single-keys-note",control:r.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:r.jsx("span",{className:"switch-knob"})})})}),r.jsxs("div",{className:"settings-filter",children:[r.jsx("label",{className:"vis-hidden",htmlFor:o,children:"Filter shortcuts"}),r.jsx("input",{id:o,type:"search",className:"settings-filter-field",placeholder:"Filter shortcuts",autoComplete:"off",spellCheck:!1,value:s,onChange:d=>a(d.target.value),onKeyDown:d=>{j4(d.key)&&s&&(d.stopPropagation(),a(""))}})]}),c.map(d=>{const h=`settings-keys-${d.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return r.jsx(qt,{id:h,title:d.title,className:"settings-keys",children:d.rows.map(f=>r.jsx(ut,{as:"div",name:Mwe(f),control:r.jsx("kbd",{className:"settings-key",children:n&&f.macCap?f.macCap:f.cap})},`${f.cap}:${f.action}`))},d.title)}),c.length===0&&r.jsxs("p",{className:"settings-empty",role:"status",children:["No shortcut matches “",s.trim(),"”."]}),s.trim()===""&&r.jsx("p",{className:"settings-foot",children:wF})]})}function Iwe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const c=iwe(s),d=co(),h=e&&!n&&!d,f=y.useRef(null),p=ea(!c.ask,f);return r.jsxs(r.Fragment,{children:[r.jsxs(qt,{id:"sm-closed-caption",title:"While the deck is closed",children:[r.jsx(ut,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?rwe:swe(d),noteId:"sm-notify-note",control:r.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:r.jsx("span",{className:"switch-knob"})})}),h&&r.jsx(ut,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:c.note,control:c.ask?r.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),a()},children:"Enable"}):r.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&r.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:r.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})})]}),r.jsx(qt,{id:"sm-accounts-caption",title:"Accounts",note:n?owe:awe,children:RF.map(({kind:m,label:w,title:k})=>r.jsx(ut,{settingId:m,name:w,nameId:`sm-${m}-label`,note:k,noteId:`sm-${m}-note`,control:r.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:r.jsx("span",{className:"switch-knob"})})},m))})]})}function OF({section:e}){return r.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==="radar"&&r.jsx(r.Fragment,{children:r.jsx("path",{d:"M11.8 7a4.8 4.8 0 1 1-4.8-4.8M9.7 7A2.7 2.7 0 1 1 7 4.3M7 7l4.8-4.8"})}),e==="reading"&&r.jsx(r.Fragment,{children:r.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),r.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),r.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),r.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),r.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),r.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="appearance"&&r.jsxs(r.Fragment,{children:[r.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"}),r.jsx("path",{d:"M4.3 6.7h.01M5.7 4.4h.01M8.4 4.2h.01"})]}),e==="keyboard"&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"1.5",y:"3.5",width:"11",height:"7",rx:"1.4"}),r.jsx("path",{d:"M4 5.9h.01M6 5.9h.01M8 5.9h.01M10 5.9h.01M4.6 8.2h4.8"})]}),e==="data"&&r.jsxs(r.Fragment,{children:[r.jsx("ellipse",{cx:"7",cy:"3.6",rx:"4.6",ry:"1.7"}),r.jsx("path",{d:"M2.4 3.6v6.8c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7V3.6"}),r.jsx("path",{d:"M2.4 7c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7"})]}),e==="integrations"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5.1 1.6v2.6M8.9 1.6v2.6"}),r.jsx("path",{d:"M3.4 4.2h7.2v2.3a3.6 3.6 0 0 1-7.2 0z"}),r.jsx("path",{d:"M7 10.1v2.3"})]}),e==="about"&&r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5.4"}),r.jsx("path",{d:"M7 6.4v3.4M7 4.4h.01"})]}),e==="notifications"&&r.jsxs(r.Fragment,{children:[r.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"}),r.jsx("path",{d:"M2.2 9.1h9.6"}),r.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const Owe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function Pwe(e){return Owe.find(t=>e(t))}const Dwe=4400;function Fwe(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function Bwe({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[a,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=Pwe(v=>MediaRecorder.isTypeSupported(v)),k=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=k,k.ondataavailable=v=>{v.data.size&&b.push(v.data)},k.onerror=()=>t("Recording failed. Please try again."),k.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const v=i.current===k;if(v&&(i.current=null),o(!1),!v||!b.length)return;const N=Fwe(k.mimeType),j=new File(b,N.name,{type:N.type});n(()=>s(j))},k.start(200),o(!0),c.current=setTimeout(h,Dwe)}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:a,startRecording:f,stopRecording:h}}function qwe({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[a,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"),[k,b]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const v=()=>{b(window.speechSynthesis.getVoices())};return v(),window.speechSynthesis.addEventListener("voiceschanged",v),()=>window.speechSynthesis.removeEventListener("voiceschanged",v)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:v=>{const N=v.currentTarget.parentElement;e&&N&&!N.open&&v.preventDefault()},children:[r.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),r.jsx("span",{className:"settings-row-note",children:"Create from text"}),r.jsx("span",{className:"settings-row-control",children:r.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:r.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),r.jsxs("div",{className:"sm-voice-fields",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Name"}),r.jsx("input",{className:"ap-manage-input",value:a,maxLength:80,onChange:v=>o(v.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:v=>c(v.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:d,onChange:v=>h(v.target.value),children:[r.jsx("option",{value:"",children:"System default"}),k.map(v=>r.jsx("option",{value:v.voiceURI,children:v.name},v.voiceURI))]})]}),r.jsxs("div",{className:"sm-voice-pair",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Rate"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:v=>p(v.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Pitch"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:m,onChange:v=>w(v.target.value)})]})]}),r.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:a,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(m)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function Uwe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=v1(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),k=y.useRef(0),b=y.useRef(new Map),v=y.useRef(null),N=y.useRef(null);y.useEffect(()=>{if(!m)return;const M=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(M)},[m]);const j=async M=>{c("");try{await M()}catch(O){c(O instanceof Error?O.message:"Custom audio could not be saved.")}},S=(M,O)=>{const I=Date.now(),F=oi({armedFor:m,target:M,armedAt:k.current,now:I,gapMs:ai});if(F==="arm"){w(M),k.current=I;return}if(F==="ignore")return;w(null);const L=oie(e.map(A=>A.id),M);j(async()=>{var q;await o(M);const A=document.activeElement;A!==O&&!Pn((A==null?void 0:A.tagName)??null)||(q=L?b.current.get(L):v.current)==null||q.focus()})},{recording:_,startRecording:T,stopRecording:$}=Bwe({full:f,setCustomError:c,runCustom:j,onImportCustom:t});return r.jsxs(qt,{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:r.jsxs("span",{className:"settings-caption-count",children:[d," of ",x1]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&r.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),r.jsx(ut,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:r.jsx("button",{ref:v,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var M;f||(M=N.current)==null||M.click()},children:"Choose file"}),children:r.jsx("input",{ref:N,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:M=>{var I;const O=(I=M.target.files)==null?void 0:I[0];M.currentTarget.value="",O&&!f&&j(()=>t(O))}})}),r.jsx(ut,{as:"div",settingId:"custom-record",name:"Record a clip",note:_?"Recording…":"Up to 5 seconds",control:_?r.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:$,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void T(),children:"Record"})}),r.jsx(qwe,{full:f,fullProps:p,runCustom:j,onCreateVoice:n}),e.map(M=>r.jsxs("div",{className:"sm-custom-item",children:[r.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${M.name}`,defaultValue:M.name,maxLength:80,onBlur:O=>{if(!O.target.value.trim()){O.target.value=M.name;return}j(()=>s(M.id,O.target.value))},onKeyDown:O=>{O.key==="Enter"&&O.currentTarget.blur()}}),r.jsx("span",{children:M.kind==="audio"?`${M.duration.toFixed(1)}s`:"Voice"}),r.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${M.name}`,onClick:()=>a(M.id),children:"Play"}),r.jsx("button",{type:"button",ref:O=>{O?b.current.set(M.id,O):b.current.delete(M.id)},className:`btn sm-custom-icon${m===M.id?" armed":""}`,onKeyDown:O=>{O.repeat&&O.preventDefault()},onClick:O=>S(M.id,O.currentTarget),"aria-label":m===M.id?`Confirm deleting ${M.name}`:`Delete ${M.name}`,title:m===M.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===M.id?"Confirm":"Delete"})]},M.id)),i&&r.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const Wwe="A tone when a turn finishes, and when Claude asks for something.";function Hwe({soundOn:e,onToggleSound:t}){const n=y.useId(),s=Dn(),a=y.useId();return r.jsx(qt,{children:r.jsx(ut,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:Wwe,noteId:a,control:r.jsxs(r.Fragment,{children:[s&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press M anywhere to mute or unmute",children:"M"}),r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,"aria-describedby":a,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:r.jsx("span",{className:"switch-knob"})})]})})})}const F1="custom:";function FI(e){return`${F1}${e}`}function zwe(e){return e.startsWith(F1)?e.slice(F1.length):null}function Vwe({id:e,label:t="Volume",value:n,step:s=hN,onLevel:a,"aria-describedby":o}){return r.jsxs("div",{className:"sm-row",children:[r.jsx("label",{htmlFor:e,children:t}),r.jsx("input",{id:e,type:"range",min:df,max:tp,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-df)/(tp-df)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const BI={done:"Turn finished","needs-input":"Claude is asking"},Gwe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Kwe({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:a,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=a[e];return r.jsxs(qt,{id:`sm-name-${e}`,title:BI[e],note:Gwe[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${BI[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:[r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]}),children:[r.jsx(Vwe,{id:f,value:t.level,onLevel:w=>o(e,w)}),r.jsxs("div",{className:"sm-row",children:[r.jsx("label",{htmlFor:p,children:"Tone"}),r.jsxs("select",{id:p,className:"sm-select",value:m?FI(m):t.figure,onChange:w=>{const k=w.target.value,b=zwe(k);b!==null?h(e,b):(d(e),i(e,k))},children:[dN[e].map(w=>r.jsx("option",{value:w.id,children:w.label},w.id)),s.length>0&&r.jsx("optgroup",{label:"Custom",children:s.map(w=>r.jsx("option",{value:FI(w.id),children:w.name},w.id))})]})]})]})}const Ywe="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Xwe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:a,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:k,onDeleteCustom:b}){var S;const v=rie(d),N=((S=c.find(_=>_.id===v))==null?void 0:S.name)??"the same custom sound",j=v?`Both tones use “${N}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(Hwe,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:Ywe}),!e&&r.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."}),r.jsx("div",{className:"sm-tones",children:lu.map(_=>r.jsx(Kwe,{chime:_,tone:n[_],soundOn:e,customAssets:c,customSelections:d,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},_))}),j&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:j}),r.jsx("p",{className:"vis-hidden",role:"status",children:j}),r.jsx(Uwe,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:k,onDeleteCustom:b})]})}let Qo={enabled:null,busy:!1,error:""};const pf=new Set;let qc=null,aa=null,l0=!1,mf=0;const fl=e=>{Qo={...Qo,...e},pf.forEach(t=>t(Qo))};async function B1(){if(l0||Qo.busy)return;l0=!0;const e=mf,t=new AbortController;aa=t;let n=!1;const s=setTimeout(()=>{n=!0,t.abort()},5e3);try{const a=await fetch("/api/system/traffic-radar/settings",{signal:t.signal}),o=await a.json();if(!a.ok||!o.ok||typeof o.enabled!="boolean")throw new Error;e===mf&&!t.signal.aborted&&fl({enabled:o.enabled,error:""})}catch{e===mf&&(n||!t.signal.aborted)&&fl({error:"Could not read Radar settings. Try again."})}finally{clearTimeout(s),l0=!1,aa===t&&(aa=null)}}async function Zwe(e){if(Qo.busy)return;mf++,aa==null||aa.abort(),fl({busy:!0,error:""});const t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{const s=await fetch("/api/system/traffic-radar/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e}),signal:t.signal}),a=await s.json();if(!s.ok||!a.ok||typeof a.enabled!="boolean")throw new Error;fl({enabled:a.enabled})}catch{fl({error:"Could not save Radar settings. Try again."})}finally{clearTimeout(n),fl({busy:!1})}}function Jwe(){const[e,t]=y.useState(Qo);return y.useEffect(()=>(pf.add(t),t(Qo),qc||(B1(),qc=setInterval(()=>void B1(),1e4)),()=>{pf.delete(t),pf.size||(qc&&clearInterval(qc),qc=null,aa==null||aa.abort())}),[]),e}const Qwe="Monitor automatically",exe="Off by default. On, Radar finds Claude Code's collector and watches its telemetry in the background, even while Radar is closed. Turning it off stops monitoring.";function txe({onOpen:e}){const{enabled:t,busy:n,error:s}=Jwe();return r.jsxs(qt,{children:[r.jsx(ut,{settingId:"radar-enabled",name:Qwe,nameId:"radar-enabled-label",note:exe,noteId:"radar-enabled-note",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":t===!0,"aria-labelledby":"radar-enabled-label","aria-describedby":"radar-enabled-note","aria-busy":n||t===null,onClick:()=>{!n&&t!==null&&Zwe(!t)},children:r.jsx("span",{className:"switch-knob"})})}),t===null&&!s&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:"Reading Radar settings…"}),r.jsx(ut,{as:"div",name:"Radar",nameId:"settings-radar-open-name",note:"Claude's telemetry configuration and the connections it was seen making.",control:r.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:"Open"})}),s&&r.jsxs("div",{className:"settings-row",role:"alert",children:[r.jsx("span",{className:"settings-row-name",children:s}),r.jsx("span",{className:"settings-row-control",children:r.jsx("button",{type:"button",className:"btn","aria-busy":n,onClick:()=>void B1(),children:"Retry"})})]})]})}const nxe="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function sxe(){const[e,t]=y.useState(null),[n,s]=y.useState(""),[a,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,v=window.setTimeout(()=>b.abort(),12e3);try{const N=await fetch("/api/tool-audit/storage",{signal:b.signal}),j=await N.json();if(!N.ok||!j.ok)throw new Error;p.current&&t(j)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(v),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,v)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let N=!1;const j=new AbortController,S=window.setTimeout(()=>j.abort(),15e3);try{const _=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:v}),signal:j.signal}),T=await _.json();if(!_.ok||!T.ok)throw new Error;N=!0,p.current&&(c(null),h(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${v} 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),N&&m())}},k=i!==null&&r.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":"Confirm",children:[r.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.`}),r.jsxs("div",{children:[r.jsx("button",{type:"button",className:"btn danger","aria-busy":a,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]});return r.jsxs(qt,{id:"tool-history-settings-title",title:"Tool history",note:nxe,className:"ta-settings",children:[e?r.jsxs(r.Fragment,{children:[r.jsx(ut,{settingId:"tool-history-retention",name:"Keep history",nameId:"ta-keep-label",note:"Calls older than this are deleted.",control:r.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:e.retentionDays,"aria-busy":a,onChange:b=>{if(f.current)return;const v=Number(b.target.value);v<e.retentionDays?c(v):w("retention",v)},children:[30,60,90].map(b=>r.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&k,r.jsx(ut,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${OZ(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:IZ(e.bytes)}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Refresh"})]})}),r.jsx(ut,{as:"div",settingId:"tool-history-clear",name:"Clear history",note:"Deletes every recorded call on this device. New calls are still recorded.",control:r.jsx("button",{type:"button",className:"btn danger","aria-busy":a,onClick:()=>{f.current||c("clear")},children:"Clear…"})}),i==="clear"&&k,!e.storageOk&&r.jsx(ut,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):r.jsx(ut,{as:"div",name:a?"Reading storage…":"Storage size unavailable."}),n&&r.jsxs("div",{className:"settings-row",role:"alert",children:[r.jsx("span",{className:"settings-row-name",children:n}),r.jsx("span",{className:"settings-row-control",children:r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Retry"})})]}),d&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:d})]})}const q1="agent-dag.integrations.active",zN=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,rxe=32e3;function qI(e,t){const n=Ye(zN(e,t));if(!n)return{};try{const s=JSON.parse(n);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function vke(e,t){return{read(n,s){const a=qI(e,t)[n];return s(a)?a:void 0},write(n,s){const a=qI(e,t);s===void 0?delete a[n]:a[n]=s;const o=JSON.stringify(a);o.length<=rxe&&Ze(zN(e,t),o)}}}function axe(e,t){Ys(zN(e,t))}function bke(e){const t=Ye(q1);if(!t)return null;try{const n=JSON.parse(t),s=n&&typeof n=="object"?n[e]:null;return typeof s=="string"&&s.length<=80?s:null}catch{return null}}function kke(e,t){let n={};try{const s=Ye(q1),a=s?JSON.parse(s):{};a&&typeof a=="object"&&!Array.isArray(a)&&(n=Object.fromEntries(Object.entries(a).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,Ze(q1,JSON.stringify(n))}function oxe({src:e,name:t,size:n=20,className:s=""}){const[a,o]=y.useState(!1);y.useEffect(()=>o(!1),[e]);const i={width:n,height:n};return!e||a?r.jsx("span",{className:`ig-avatar ig-avatar-initials ${s}`.trim(),"data-large":n>=28||void 0,style:i,"aria-hidden":!0,children:Bpe(t)}):r.jsx("img",{className:`ig-avatar ${s}`.trim(),style:i,src:e,alt:"","aria-hidden":!0,referrerPolicy:"no-referrer",loading:"lazy",decoding:"async",draggable:!1,onError:()=>o(!0)})}function UI(e){const t=e.meta??{},n=[];if(t.deploymentType==="Cloud"?n.push("Jira Cloud"):t.deploymentType&&n.push(`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`),t.checkedAt){const s=new Date(String(t.checkedAt));Number.isNaN(s.getTime())||n.push(`checked ${s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}`)}return n.join(" · ")}function ixe(){const e=ad(),{connections:t,error:n}=e,[s,a]=y.useState(null),[o,i]=y.useState(null),c=y.useRef(null),[d,h]=y.useState(null),[f,p]=y.useState([]),[m,w]=y.useState(null),k=y.useRef(0),[b,v]=y.useState(null),N=y.useRef(null),j=y.useRef(new Map);y.useEffect(()=>{const E=Upe();E&&(v(E),a({mode:"edit",id:E}))},[]),y.useEffect(()=>{var E,D;!b||!t||(D=(E=j.current.get(b))==null?void 0:E.scrollIntoView)==null||D.call(E,{block:"nearest"})},[b,t]),y.useEffect(()=>{if(!m)return;const E=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(E)},[m]);const S=(E,D,P)=>p(z=>[...z.filter(G=>G.id!==E),{id:E,tone:D,text:P}]),_=E=>p(D=>D.filter(P=>P.id!==E)),T=async(E,D)=>{if(!c.current){c.current=E,i(E);try{await D()}finally{c.current=null,i(null)}}},$=E=>(D,P)=>void T("form",async()=>{h(null);try{const z=await Ipe(E,D,P||void 0);a(null),S(z.id,"ok",`Connected as ${z.account.name||z.account.login}.`),v(z.id)}catch(z){h(z instanceof wr?z:new wr("upstream","The connection could not be saved."))}}),M=E=>(D,P)=>void T("form",async()=>{h(null);try{const{connection:z,validated:G}=await Ope(E.id,{name:P,input:D});a(null),S(z.id,"ok",G?`Saved and checked: signed in as ${z.account.name||z.account.login}.`:"Saved.")}catch(z){h(z instanceof wr?z:new wr("upstream","The change could not be saved."))}}),O=E=>void T(`test:${E.id}`,async()=>{_(E.id);try{const D=await Ppe(E.id);S(E.id,"ok",`Working: signed in as ${D.account.name||D.account.login}.`)}catch(D){S(E.id,"err",D instanceof Error?D.message:"The test failed.")}}),I=(E,D)=>{const P=Date.now(),z=oi({armedFor:m,target:E.id,armedAt:k.current,now:P,gapMs:ai});if(z==="arm"){w(E.id),k.current=P;return}z!=="ignore"&&(w(null),T(`delete:${E.id}`,async()=>{var G;try{await Dpe(E.id),axe(E.kind,E.id),_(E.id),(s==null?void 0:s.mode)==="edit"&&s.id===E.id&&a(null);const V=document.activeElement;(V===D||Pn((V==null?void 0:V.tagName)??null))&&((G=N.current??document.getElementById("settings-tab-integrations"))==null||G.focus())}catch(V){S(E.id,"err",V instanceof Error?V.message:"Disconnect failed.")}}))},F=t??[],L=UN(e),A=G6().filter(E=>L.has(E.kind)),q=Q6(e);return r.jsxs(r.Fragment,{children:[q==="all"&&r.jsx(qt,{id:"integrations-add-title",title:"Add integration",note:"Browse your work in a tracker beside your agents. Tokens stay on this machine: they are never shown again, never logged, and never shared with paired decks.",settingId:"integrations-add",children:(s==null?void 0:s.mode)==="add"?(()=>{const E=A.find(D=>D.kind===s.kind);return E?r.jsx("div",{className:"settings-row ig-form-row",children:r.jsx(xI,{def:E,busy:o==="form",error:d,onSubmit:$(s.kind),onCancel:()=>{a(null),h(null),requestAnimationFrame(()=>{var D;return(D=N.current)==null?void 0:D.focus()})}})}):null})():(s==null?void 0:s.mode)==="pick"?r.jsxs(r.Fragment,{children:[A.map(E=>r.jsx(ut,{as:"div",name:r.jsxs("span",{className:"ig-provider-name",children:[r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(E.Glyph,{})}),E.label]}),note:E.blurb,control:r.jsxs("button",{type:"button",className:"btn primary",onClick:()=>{h(null),a({mode:"add",kind:E.kind})},children:["Connect ",E.label]})},E.kind)),r.jsx(ut,{as:"div",name:"More trackers",note:"Further providers will appear here as the deck learns them.",control:r.jsx("button",{type:"button",className:"btn",onClick:()=>{a(null),requestAnimationFrame(()=>{var E;return(E=N.current)==null?void 0:E.focus()})},children:"Cancel"})})]}):r.jsx(ut,{as:"div",name:"Connect a tracker",note:A.map(E=>E.label).join(", "),control:r.jsx("button",{ref:N,type:"button",className:"btn",onClick:()=>a({mode:"pick"}),children:"Add integration"})})}),r.jsxs(qt,{id:"integrations-list-title",title:"Connections",aside:r.jsx("span",{className:"settings-caption-count",children:F.length}),settingId:"integrations-connections",children:[t===null&&!n&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:"Reading connections…"}),n&&r.jsx("p",{className:"settings-row settings-row-status ig-error",role:"alert",children:n}),t!==null&&F.length===0&&r.jsx("p",{className:"settings-row settings-row-status",children:A.length>0?"Nothing connected yet. A tracker you add gets its own button on the left edge, under Accounts and Session list.":"Nothing connected."}),F.map(E=>{var B;const D=K6(E.kind),P=!od(e,E.kind),z=!P&&(s==null?void 0:s.mode)==="edit"&&s.id===E.id,G=f.find(W=>W.id===E.id),V=Array.isArray((B=E.meta)==null?void 0:B.warnings)?E.meta.warnings.filter(W=>typeof W=="string"):[],H=m===E.id;return r.jsxs("div",{className:"settings-row ig-conn","data-focused":b===E.id||void 0,ref:W=>{W?j.current.set(E.id,W):j.current.delete(E.id)},children:[r.jsxs("div",{className:"ig-conn-head",children:[r.jsx(oxe,{src:E.account.avatarUrl,name:E.account.name||E.account.login||E.name,size:32}),r.jsxs("div",{className:"ig-conn-text",children:[r.jsx("span",{className:"ig-conn-name",children:E.name}),r.jsxs("span",{className:"ig-conn-line",children:[(D==null?void 0:D.label)??E.kind," · ",r.jsx("span",{className:"ig-mono",children:Fpe(E)})]}),r.jsxs("span",{className:"ig-conn-line",children:[E.account.name||E.account.login?r.jsxs(r.Fragment,{children:["Signed in as ",E.account.name,E.account.login&&E.account.login!==E.account.name?r.jsxs(r.Fragment,{children:[" (",r.jsx("span",{className:"ig-mono",children:E.account.login}),")"]}):null]}):"No account read yet",!E.tokenSaved&&r.jsxs(r.Fragment,{children:[" · ",r.jsx("span",{className:"ig-bad",children:"no token saved"})]})]}),UI(E)&&r.jsx("span",{className:"ig-conn-line ig-dim",children:UI(E)}),P&&r.jsxs("span",{className:"ig-stranded",children:[(D==null?void 0:D.label)??E.kind," is not available on this deck. Disconnect deletes this connection and its saved token."]})]}),!z&&r.jsxs("div",{className:"ig-conn-actions",children:[!P&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"btn","aria-busy":o===`test:${E.id}`,onClick:()=>O(E),"aria-label":`Test ${E.name}`,children:o===`test:${E.id}`?"Testing…":"Test"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{h(null),a({mode:"edit",id:E.id})},"aria-label":`Edit ${E.name}`,children:"Edit"})]}),r.jsx("button",{type:"button",className:`btn danger${H?" armed":""}`,"aria-busy":o===`delete:${E.id}`,onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:W=>I(E,W.currentTarget),"aria-label":H?`Confirm disconnecting ${E.name}`:`Disconnect ${E.name}`,title:H?"Press again to disconnect. The saved token is deleted from this machine.":"Disconnect and delete the saved token",children:H?"Confirm":"Disconnect"})]})]}),V.length>0&&r.jsx("ul",{className:"ig-warnings",children:V.map(W=>r.jsx("li",{children:W},W))}),G&&r.jsx("p",{className:"ig-note","data-tone":G.tone,role:G.tone==="err"?"alert":"status",children:G.text}),z&&D&&r.jsx(xI,{def:D,existing:E,busy:o==="form",error:d,onSubmit:M(E),onCancel:()=>{a(null),h(null)}})]},E.id)})]})]})}function lxe({theme:e}){return r.jsx("span",{className:"appearance-preview","data-swatch":e,children:r.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[r.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),r.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),r.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),r.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),r.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),r.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),r.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),r.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),r.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),r.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function cxe({theme:e,onTheme:t,singleKeys:n}){const s=a=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a.key))return;a.preventDefault();const o=(d=a.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(ta.indexOf(o??e)+(a.key==="ArrowLeft"||a.key==="ArrowUp"?-1:1)+ta.length)%ta.length;t(ta[c]),(h=a.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return r.jsx(qt,{id:"appearance-theme-caption",title:"Theme",list:!1,settingId:"theme",aside:n&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"}),children:r.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:ta.map(a=>r.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":a,"data-setting":`theme-${a}`,"aria-checked":e===a,tabIndex:e===a?0:-1,onClick:()=>t(a),children:[r.jsx(lxe,{theme:a}),r.jsxs("span",{className:"appearance-theme-name",children:[sd[a].name,r.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:r.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},a))})})}const uxe=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],dxe=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function WI(){return r.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:r.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 hxe({textSize:e,density:t,onTextSize:n,onDensity:s}){const a=e!=="default"||t!=="default";return r.jsx("button",{type:"button",className:"btn",disabled:!a,onClick:()=>{n("default"),s("default")},children:"Reset to defaults"})}function fxe({textSize:e,density:t,onTextSize:n,onDensity:s}){return r.jsxs(r.Fragment,{children:[r.jsxs("fieldset",{className:"reading-group",children:[r.jsx("legend",{children:"Text size"}),r.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),r.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":hT.length,"--reading-selected":hT.indexOf(e)},children:uxe.map(([a,o,i])=>r.jsxs("label",{className:"reading-choice","data-size":a,children:[r.jsx("input",{type:"radio",name:"text-size","aria-label":`${o} ${i}`,value:a,checked:e===a,onChange:()=>n(a)}),r.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),r.jsxs("span",{className:"reading-label",children:[r.jsx("strong",{children:o}),r.jsx("small",{children:i})]}),r.jsx(WI,{})]},a))})]}),r.jsxs("fieldset",{className:"reading-group",children:[r.jsx("legend",{children:"Density"}),r.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),r.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":fT.length,"--reading-selected":fT.indexOf(t)},children:dxe.map(([a,o,i])=>r.jsxs("label",{className:"reading-choice",children:[r.jsx("input",{type:"radio",name:"density","aria-label":`${o} ${i} spacing`,value:a,checked:t===a,onChange:()=>s(a)}),r.jsxs("span",{className:"reading-density-sample","data-density":a,"aria-hidden":"true",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),r.jsxs("span",{className:"reading-label",children:[r.jsx("strong",{children:o}),r.jsx("small",{children:i})]}),r.jsx(WI,{})]},a))})]}),r.jsxs(qt,{id:"reading-preview-title",title:"Preview",children:[r.jsxs("div",{className:"reading-preview-row",children:[r.jsxs("div",{children:[r.jsx("strong",{children:"Frontend session"}),r.jsx("span",{children:"Waiting for your review"})]}),r.jsx("span",{className:"reading-preview-time",children:"4m"})]}),r.jsxs("div",{className:"reading-preview-row",children:[r.jsxs("div",{children:[r.jsx("strong",{children:"API integration"}),r.jsx("span",{children:"Working · 3 tool calls"})]}),r.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),r.jsx("p",{className:"settings-foot",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const pxe="AGPL-3.0-only",mxe="GNU Affero General Public License, version 3 only.",gxe="https://github.com/BarganConstantin/ccdeck",yxe="What changed in each release, newest first.",wxe="Tell the people who make ccdeck what works and what does not.";function xxe(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 vxe(e,t){return lo(e)&&lo(t)&&ci(e,t)<0}function bxe(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${$t} 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:`${$t} v${t.to} is out — you are on v${t.from}.`}:null}function kxe({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:c="3.45.0"}){const d=(e==null?void 0:e.running)??c,h=bxe(n,t);return r.jsxs(r.Fragment,{children:[r.jsxs(qt,{id:"settings-about-caption",title:$t,children:[r.jsx(ut,{as:"div",settingId:"version",name:"Version",note:vxe(c,e==null?void 0:e.running)?xxe(c):void 0,control:r.jsx("span",{className:"settings-read",children:d})}),h&&r.jsx(jxe,{offer:h,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(ut,{as:"div",settingId:"whats-new",name:"What's new",note:yxe,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),r.jsx(ut,{as:"div",settingId:"licence",name:"Licence",note:mxe,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:pxe}),r.jsxs("a",{className:"settings-link",href:gxe,target:"_blank",rel:"noreferrer",children:["Source",r.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),r.jsxs(qt,{id:"settings-about-help-caption",title:"Tour and feedback",children:[r.jsx(ut,{as:"div",settingId:"tour",name:"Take the tour",note:P1,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),r.jsx(ut,{as:"div",settingId:"feedback",name:"Send feedback",note:wxe,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function jxe({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:a}){if(e.kind==="notice")return r.jsx(ut,{as:"div",name:e.name,note:e.note,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:a,children:"Update…"})});const o=rF(e.to,t),i=n&&n.version===e.to?aF(n.failure,n.version):"";return r.jsx(ut,{as:"div",name:e.name,note:e.note,control:r.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:r.jsx("span",{className:"settings-row-said",role:"status",children:i})})}const Nxe="Update when idle",Sxe="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.",_xe=`${_F} 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.`,Cxe="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.",Exe="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 Txe(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 Axe={plain:Sxe,"checks-off":_xe,"no-restart":Cxe};function Rxe({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=co()}){const a=Txe(n,s);return r.jsx(qt,{id:"settings-updates-caption",title:"Updates",children:a==="app"?r.jsx(ut,{as:"div",settingId:"auto-update",name:"Updates",note:Exe}):r.jsx(ut,{settingId:"auto-update",name:Nxe,nameId:"settings-auto-update-label",note:Axe[a],noteId:"settings-auto-update-note",control:r.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:r.jsx("span",{className:"switch-knob"})})})})}function Mxe({character:e,onCharacter:t}){const n=y.useRef([]);function s(a,o){var c;const i=Dp(a,o,ff.length,"vertical");i.kind==="select"&&(a.preventDefault(),t(ff[i.index].id),(c=n.current[i.index])==null||c.focus())}return r.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:ff.map((a,o)=>r.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===a.id,tabIndex:e===a.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(a.id),onKeyDown:i=>s(i,o),children:[r.jsx("span",{className:"character-preview",children:r.jsx(uP,{character:a.id,act:null,facing:"right"})}),r.jsx("span",{children:a.name}),r.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:r.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},a.id))})}const $xe="Stands beside the minimap. Press it to play the radio.";function Lxe({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return r.jsxs(qt,{id:"appearance-character-caption",title:"Character",list:!1,children:[r.jsx("div",{className:"settings-list",children:r.jsx(ut,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:$xe,noteId:"appearance-character-note",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:r.jsx("span",{className:"switch-knob"})})})}),r.jsx(Mxe,{character:n,onCharacter:s})]})}const HI="settings-search-field",PF="settings-search-results",U1=e=>`settings-result-${e}`;function Ixe({inputRef:e,query:t,onQuery:n,results:s,active:a,onActive:o,onOpen:i}){const c=t.trim()!=="",d=c&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=xwe(f.key,t,c?s.length:0,a);p.kind!=="pass"&&(f.preventDefault(),p.kind==="move"?o(p.index):p.kind==="open"?i(s[p.index]):(f.stopPropagation(),n("")))};return r.jsxs("div",{className:"settings-search",children:[r.jsx("label",{className:"vis-hidden",htmlFor:HI,children:"Search settings"}),r.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:[r.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),r.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),r.jsx("input",{ref:e,id:HI,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?PF:void 0,"aria-activedescendant":d?U1(Math.min(a,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:h})]})}function Oxe({query:e,results:t,active:n,onOpen:s}){const a=IF(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(U1(n)))==null?void 0:o.scrollIntoView)==null||i.call(o,{block:"nearest"})},[n]),r.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[r.jsx("div",{className:"settings-pane-head",children:r.jsxs("div",{className:"settings-pane-heading",children:[r.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:"Search"}),r.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:a})]})}),t.length>0&&r.jsx("div",{className:"settings-group",children:r.jsx("div",{className:"settings-list",id:PF,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:U1(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":mwe(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[r.jsx(OF,{section:o.section}),r.jsxs("span",{className:"settings-result-text",children:[r.jsx("span",{className:"settings-result-name",children:o.label}),r.jsx("span",{className:"settings-result-place",children:LF(o)})]})]},o.id))})})]})}function Pxe({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?IF(t,e):""})}const Dxe=1500,Fxe=3e3,Bxe=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function qxe(e){if(e.matches(Cf)&&!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(Cf)).filter(s=>N4({disabled:s.disabled,tabIndex:s.tabIndex,rendered:Bxe(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function Uxe(e,t,n){const[s,a]=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,v;a(null);const k=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:k?"start":"center"}),(b=qxe(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(v=i.current)==null||v.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)},Dxe)},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(),a(null)},Fxe);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function Wxe({section:e,onSection:t,onClose:n,providers:s,sound:a,tones:o,customTones:i,notify:c,appearance:d,versionCheck:h,desktopUpdate:f,restart:p,doors:m}){const w=y.useRef(null),k=pt(n,{focusRef:w}),b=gt(n),v=y.useRef([]),N=Q6(ad()),j=Xhe(N,e),S=Math.max(0,j.findIndex(be=>be.id===e)),[_,T]=y.useState(""),[$,M]=y.useState(0),O=y.useRef(null),I=y.useRef(null),F=_.trim()!=="",L=y.useMemo(()=>wwe(_,pwe(s.claude,N)),[_,s.claude,N]),A=Uxe(I,!F,e),q=be=>{T(be),M(0)},E=be=>{q(""),t(be)},D=be=>{q(""),t(be.section),$F(be)||A(be.id)};y.useEffect(()=>{const be=Oe=>{var ot,Qe;if(!nfe(Oe))return;const ze=k.current,st=Oe.target;!ze||!(st===document.body||st===document.documentElement||st&&ze.contains(st))||(Oe.preventDefault(),(ot=O.current)==null||ot.focus(),(Qe=O.current)==null||Qe.select())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[k]),y.useEffect(()=>{var be,Oe,ze,st;Zhe((be=document.activeElement)==null?void 0:be.id,e)&&((Oe=w.current)==null||Oe.focus()),(st=(ze=w.current)==null?void 0:ze.scrollIntoView)==null||st.call(ze,{block:"nearest",inline:"nearest"})},[e]);const{theme:P,setTheme:z,characterEnabled:G,setCharacterEnabled:V,character:H,setCharacter:B}=d,W=Dn(),ee=be=>{var ze;const Oe=Dp(be,S,j.length,"vertical");Oe.kind!=="pass"&&(be.preventDefault(),q(""),t(j[Oe.index].id),(ze=v.current[Oe.index])==null||ze.focus())},U=be=>{var st;if(be.key===" "){be.stopPropagation();return}if(X4(be.key,W))return;const Oe=be.target;if(Ko(Oe)||Oe.tagName==="SELECT"||be.key!=="t"&&be.key!=="T"||be.ctrlKey||be.metaKey||be.altKey)return;be.preventDefault(),be.stopPropagation();const ze=E1(Oe.dataset.themeChoice??P);z(E1),Oe.getAttribute("role")==="radio"&&((st=be.currentTarget.querySelector(`[role="radio"][data-theme-choice="${ze}"]`))==null||st.focus())},{soundOn:Y,toggleSound:X}=a,{tonePrefs:Z,previewTone:J,changeTone:te}=o,{customSelections:ce,customAssets:he,clearCustomOnly:le,selectCustomTone:re,importNotificationAudio:ae,createNotificationVoice:de,renameCustomAsset:_e,deleteCustomAsset:fe,previewCustomAsset:ye}=i,{notifyPermission:ke,notifyOn:Ne,notifyVetoed:ge,toggleNotify:Me,notifySupported:Ie,askForNotifications:We,accountNotify:Te,toggleAccountNotify:at}=c,Je=(()=>{switch(e){case"radar":return r.jsx(txe,{onOpen:m.radar});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(cxe,{theme:P,onTheme:z,singleKeys:W}),r.jsx(Lxe,{characterEnabled:G,character:H,onCharacter:B,onToggleCharacter:()=>V(be=>!be)})]});case"reading":return r.jsx(fxe,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return r.jsx(Lwe,{singleKeys:W,onToggleSingleKeys:()=>fK(!W)});case"notifications":return r.jsx(Iwe,{notifyOn:Ne,onToggleNotify:Me,notifyVetoed:ge,notifyPermission:Ie?ke:"unsupported",onAskNotify:We,accountNotify:Te,onToggleAccountNotify:at});case"sounds":return r.jsx(Xwe,{soundOn:Y===!0,onToggleSound:X,prefs:Z,claudeHere:s.claude,onLevel:(be,Oe)=>te(be,{level:Oe}),onFigure:(be,Oe)=>te(be,{figure:Oe}),onPreview:be=>J(be),customAssets:he,customSelections:ce,onBuiltInSelected:le,onCustomSelected:re,onImportCustom:ae,onCreateVoice:de,onRenameCustom:_e,onPreviewCustom:ye,onDeleteCustom:fe});case"integrations":return r.jsx(ixe,{});case"data":return r.jsx(sxe,{});case"about":return r.jsx(kxe,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:be=>{f.askDesktopUpdateRestart(be)},doors:m});default:return r.jsxs(r.Fragment,{children:[r.jsx(kwe,{}),r.jsx(PI,{provider:"Codex"}),s.claude&&r.jsx(PI,{provider:"Claude"}),r.jsx(Rxe,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),r.jsx(Twe,{claudeHere:s.claude,singleKeys:W,doors:m})]})}})(),Ve=e==="reading"?r.jsx(hxe,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return r.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:r.jsxs("div",{ref:k,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:be=>be.stopPropagation(),onKeyDown:U,children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),r.jsxs("div",{className:"settings-body",children:[r.jsxs("div",{className:"settings-side",children:[r.jsx(Ixe,{inputRef:O,query:_,onQuery:q,results:L,active:$,onActive:M,onOpen:D}),r.jsx(Pxe,{query:_,count:L.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:ee,children:j.map((be,Oe)=>r.jsxs("button",{ref:ze=>{v.current[Oe]=ze,be.id===e&&(w.current=ze)},type:"button",role:"tab",id:`settings-tab-${be.id}`,className:"settings-tab","aria-selected":be.id===e,"aria-controls":"settings-pane",tabIndex:be.id===e?0:-1,onClick:()=>E(be.id),children:[r.jsx(OF,{section:be.id}),r.jsx("span",{className:"settings-tab-label",children:be.label})]},be.id))})]}),r.jsxs("div",{ref:I,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:F||void 0,children:[r.jsxs("div",{className:"settings-pane-head",children:[r.jsxs("div",{className:"settings-pane-heading",children:[r.jsx("h2",{className:"settings-pane-title",children:j[S].label}),r.jsx("p",{className:"settings-pane-note",children:j[S].note})]}),Ve]}),Je]},e),F&&r.jsx(Oxe,{query:_,results:L,active:$,onOpen:D})]})]})})}function Hxe({tool:e,onClose:t}){const n=pt(t),s=gt(t),a=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=Uz(e.name,i,c);return{input:f.input.map((p,m)=>r.jsx(zI,{block:p},m)),response:f.response.map((p,m)=>r.jsx(zI,{block:p},m)),copyInput:rE(e.name,"input",i),copyResponse:rE(e.name,"response",c)}},[e.name,i,c]);return r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:`status-dot ${a}`,"aria-hidden":!0}),r.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),r.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("span",{className:"modal-dur",children:b4(e,"in-flight…")}),r.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("section",{className:"modal-body",children:[d&&r.jsx("div",{className:"modal-section",children:r.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("div",{className:"tm-head",children:[r.jsx("h4",{children:"Input"}),r.jsx(VI,{text:h.copyInput,what:"input"})]}),h.input]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("div",{className:"tm-head",children:[r.jsxs("h4",{children:["Response ",a==="err"&&r.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&r.jsx(VI,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const zxe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function zI({block:e}){const[t,n]=y.useState(!1);if(e.inline)return r.jsxs("p",{className:"tm-inline",children:[e.label&&r.jsx("span",{className:"tm-label",children:e.label}),r.jsx("code",{children:e.text})]});const s=y.useMemo(()=>Iz(e),[e]),{shown:a}=K3(s,t),o=Oz(s,t);return r.jsxs("div",{className:"tm-block",children:[e.label&&r.jsx("span",{className:"tm-label",children:e.label}),r.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?a.map((i,c)=>r.jsxs("span",{className:i.tone?zxe[i.tone]:void 0,children:[i.text,c<a.length-1?`
312
+ `:""]},c)):a.map(i=>i.text).join(`
313
+ `)}),o&&r.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function VI({text:e,what:t}){const[n,s]=y.useState(!1),a=y.useRef(!0);return y.useEffect(()=>()=>{a.current=!1},[]),r.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void ho(e).then(o=>{!o||!a.current||(s(!0),window.setTimeout(()=>{a.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const Vxe=pm(()=>Fl(()=>import("./UsageHistoryModal-DAhplVju.js"),[]),"Usage history"),Gxe=pm(()=>Fl(()=>import("./BrowserWatchModal-Cbzf3TWa.js"),[]),"Browser Watch"),Kxe=pm(()=>Fl(()=>import("./TrafficRadar-D1gZCIwX.js"),[]),"Telemetry Radar");function Yxe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:a,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:k,menus:b,sound:v,tones:N,customTones:j,notify:S,panelDoors:_}){const{openedTool:T,setOpenedToolKey:$,usageHistoryOpen:M,setUsageHistoryOpen:O,browserWatchOpen:I,setBrowserWatchOpen:F,contextAgent:L,setContextFor:A,summaryFor:q,setSummaryFor:E,keyHelpOpen:D,setKeyHelpOpen:P,feedbackOpen:z,setFeedbackOpen:G,feedbackPrefill:V,setFeedbackPrefill:H,openFeedback:B}=e,{trafficRadarOpen:W,setTrafficRadarOpen:ee}=e,{tourOpen:U,openTour:Y,closeTour:X,releaseNotes:Z,closeReleaseNotes:J,chipVersion:te,openReleaseNotes:ce}=t,{desktopUpdateRestarting:he,desktopUpdateFailure:le,readyAppUpdate:re,askDesktopUpdateRestart:ae}=n,{version:de,showNotice:_e}=s,{askRestart:fe}=a,{clearConfirmOpen:ye,setClearConfirmOpen:ke,requestClear:Ne}=d,{setWatchOn:ge,markWatchSeen:Me}=h,{setWatchSaid:Ie}=f,{palette:We}=p,{settingsOpen:Te,settingsSection:at,showSection:Je,closeSettings:Ve,openSettings:be}=b;return r.jsxs(r.Fragment,{children:[T&&r.jsx(Hxe,{tool:T,onClose:()=>$(null)}),M&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(Vxe,{providers:m,onClose:()=>O(!1)})}),I&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(Gxe,{onClose:()=>F(!1),onSeen:Oe=>{Ie(""),Me(Oe)},onWatching:ge,palette:We})}),L&&r.jsx(DV,{agent:L,onClose:()=>A(null)}),W&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(Kxe,{sessions:[...w.current.agents.values()].filter(Oe=>Oe.kind==="root"&&Oe.provider!=="codex").map(Oe=>({id:Oe.sessionId,label:_p(Oe.sessionName,Oe.sessionTitle).face??Oe.cwdBasename??Oe.label,project:Oe.cwdBasename??Oe.label,workspace:Oe.cwd})),onClose:()=>ee(!1)})}),z&&r.jsx(yF,{initialKind:V==null?void 0:V.initialKind,initialBody:V==null?void 0:V.initialBody,onClose:()=>{G(!1),H(null)}}),q&&r.jsx(Xye,{state:w.current,sessionId:q,onClose:()=>E(null)}),Te&&r.jsx(Wxe,{section:at,onSection:Je,onClose:Ve,providers:m,sound:v,tones:N,customTones:j,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:za(Ve,ce),update:za(Ve,()=>{ce(),_e()}),tour:za(Ve,Y),feedback:za(Ve,()=>B()),accounts:za(Ve,_.accounts),localNetwork:za(Ve,_.localNetwork),browserWatch:za(Ve,()=>F(!0)),radar:za(Ve,()=>ee(!0))}}),Z&&r.jsx(Yye,{entries:Z.entries,since:Z.since,firstRun:Z.firstRun,running:te,onClose:J,onTour:()=>{J(),Y()},updateVersion:re==null?void 0:re.version,updateBusy:he,updateFailure:le&&(!re||re.version===le.version)?aF(le.failure,le.version):void 0,onUpdateRestart:re?()=>{ae(re.version)}:void 0,onRestart:!re&&(de!=null&&de.canRestart)?()=>{J(),fe()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:a,desktopUpdate:n,running:te,onHandOff:J}}),r.jsx(Xxe,{lanPairs:i,attention:c}),D&&r.jsx(eye,{onClose:()=>P(!1),onTour:()=>{P(!1),Y()},onSettings:()=>{P(!1),be("keyboard")}}),U&&r.jsx(MD,{title:"What the deck shows you",steps:are,onClose:X}),ye&&r.jsx(Hme,{agentCount:k,onConfirm:()=>Ne("confirmation"),onCancel:()=>ke(!1)})]})}function Xxe({lanPairs:e,attention:t}){const n=dye(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(mye,{...t,pairing:n!=null})]})}const Zxe=10,DF=500,FF=4e3,Jxe=[/ResizeObserver loop/i,/^Script error\.?$/i],GI=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,Qxe=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function eve(e,t){const n=typeof e=="string"?e.split(`
314
+ `):[],s=n.some(o=>/^\s*at\s/.test(o)),a=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(Qxe)??[]:[]);return a.length?a.every(o=>GI.test(o)):typeof t=="string"&&GI.test(t)}const up=String.raw`[^\s\\/:'"\`<>|?*;,]`,tve=String.raw`${up}(?:[^\\/\r\n:'"\`<>|?*;,]*${up})?[\\/]`,nve=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Uc=String.raw`(?:${tve})*(?:${nve})?`,sve=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Uc}|[A-Za-z]:[\\/]${Uc}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Uc}|/(?=${up})${Uc}|(?<!:)//(?=${up})${Uc})`,rve=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,ave=new Set([".claude",".codex"]);function ove(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?ave.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const ive=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function lve(e,t,n){return n?"<deck>":`${t}://<host>`}const KI=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,BF=String.raw`${KI}(?:\.${KI}){3}`,c0=String.raw`[0-9A-Fa-f]{1,4}`,YI=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${c0}:){7})(?:(?:${c0})?:)+(?:${BF}|${c0})?`,XI=String.raw`%[\w-]+(?:\.[\w-]+)*`,ZI=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,cve=String.raw`(?<![\w:.%-])(?:\[(?!${ZI}\])${YI}(?:${XI})?\]|(?!${ZI}(?::\d{1,5})?(?![\w:%]|\.\d))${YI}(?:${XI})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${BF}(?![\w-]|\.\d)`,u0=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,uve=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${u0}|${u0}(?=:\d{1,5}(?![\w:-]|\.\w))|${u0}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function JI(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(sve,"g"),ove).replace(new RegExp(rve,"g"),"<project>").replace(new RegExp(ive,"g"),lve).replace(new RegExp(cve,"g"),"<host>").replace(new RegExp(uve,"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,}|github_pat_[A-Za-z0-9_]{20,}|gl(?:pat|dt|rt|cbt|ptt|ft|imt|agent|oas|soat)-[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 qF=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function dve(e,t,n=qF){const s=String(e??"").slice(0,DF).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,FF):void 0})}function hve(e,t=window,n=qF){let s=0;const a=new Set,o=(d,h,f)=>{const p=String(d??"").slice(0,DF).trim();!e()||!p||s>=Zxe||a.has(p)||Jxe.some(m=>m.test(p))||eve(h,f)||(a.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,FF):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 fve=12;function pve(e,t){const n=[JI(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const a=s.split(`
315
+ `).slice(0,fve).join(`
316
+ `);n.push("",JI(a).trim())}return n.join(`
317
+ `)}class mve extends y.Component{constructor(){super(...arguments);Ua(this,"state",{error:null,componentStack:null,reportOpen:!1});Ua(this,"onKey",n=>{j4(n.key)&&vn.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}),dve(n.message,n.stack),A6("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:a}=this.state;return n?r.jsxs("div",{className:"error-fallback",children:[r.jsxs("div",{className:"error-fallback-card",role:"alert",children:[r.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),r.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."}),r.jsxs("div",{className:"error-fallback-actions",children:[r.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),a&&r.jsx(yF,{initialKind:"bug",initialBody:pve(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const gve=1e3;function yve(e={}){const t=Math.max(1,Math.floor(e.limit??gve)),n=e.protect;let s=!1,a=[],o=new Set,i=0,c=0,d=null;return{get paused(){return s},get size(){return a.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(a.push(h),n!=null&&n(h)&&o.add(h),a.length>t){let k=0;if(o.size<a.length)for(;o.has(a[k]);)k++;const[b]=a.splice(k,1);o.delete(b),i++}return!1},setPaused(h){if(s=h,h)return[];const f=a;return a=[],o=new Set,i=0,f}}}function wve(e){const t=y.useState(()=>yve({protect:o=>Qz(e.current,o)}))[0],[n,s]=y.useState(!1),a=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&D9(e.current);for(const c of i)e.current=i4(e.current,c);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const W1={kind:"assumed",claude:!0,codex:!0};function xve(e){if(!e||typeof e!="object")return W1;const t=e.providers;if(!t||typeof t!="object")return W1;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function vve(e){const[t,n]=y.useState(null),[s,a]=y.useState(W1);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(a(xve(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Rn(s);return{workspace:t,providers:s,providersRef:o}}const UF=3*6e4,bve=2e4;function kve({fetchReport:e,visible:t,now:n,onReport:s}){let a=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(a=n(),s(c))};return{tick:i,wake:async()=>{t()&&n()-a>=UF&&await i()},stop:()=>{o=!1}}}async function jve(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(bve)});return e.ok?await e.json():null}catch{return null}}function Nve(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const s=kve({fetchReport:jve,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,UF),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const Sve={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},_ve={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Cve={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Eve={claude:"Claude",codex:"Codex"},Tve=new Set(["status.claude.com","status.openai.com"]),Ave=30*6e4,Rve=10*6e4;function Mve(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Tve.has(t.hostname)?t:null}catch{return null}}function QI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function $ve(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Lve(e,t){if(!e||typeof e!="object")return null;const n=Gt(Sve,e.state),s=Gt(Eve,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>Ave)return null;const a=Mve(e.statusPageUrl);if(!a)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>Rve,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 ${a.hostname} at ${QI(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${$ve(t-e.checkedAt)}`,"Opens the status page"],d=i?QI(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Gt(_ve,e.state)??n,shortWords:Gt(Cve,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:a.href,host:a.hostname,stale:i,detail:c.filter(Boolean).join(`
318
+ `)}}function Ive(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Lve(n,t)).filter(n=>n!==null)}function Ove(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const Pve="The providers' status pages report no incident.";function Dve({version:e,loadVersion:t}){var h;const[n,s]=y.useState(!1),a=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Mme(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(bn(i.current||a==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[a,t]);y.useEffect(()=>{if(a!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[a,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await ho(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:a,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const eO="agent-dag.browserWatch.seenMs";function Fve(e,t){return e.filter(n=>n.startMs>t)}function Bve(){const[e,t]=y.useState(()=>Number(Ye(eO))||0),[n,s]=y.useState([]),[a,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(()=>Fve(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ze(eO,String(d))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const WF="agent-dag.character-enabled",HF="agent-dag.fm-volume",qve=1,tO="agent-dag.fm-source",jke=[{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 Uve(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 Wve(e){return e!=="0"}function Hve(){return Wve(Ye(WF))}function zve(e){return u5(e,qve)}function Vve(){return zve(Ye(HF))}const zF=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function nO(e){const t={};for(const n of zF)t[n]=e(n);return t}function Gve(e){return t=>e[t]??""}function Kve(e,t){return zF.every(n=>e[n]===t[n])}function Yve(e,t){let n=null,s=0;function a(){s++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:a,run(o){a();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 sO(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Xve(){const[e,t]=y.useState(YZ),[n,s]=y.useState(XZ),[a,o]=y.useState(rfe),i=y.useRef(a),[c]=y.useState(()=>Yve(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(N=>{const j=typeof N=="function"?N(i.current):N;j!==i.current&&(i.current=j,c.run(()=>xt.flushSync(()=>o(j))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(Hve),[p,m]=y.useState(ewe),[w,k]=y.useState(()=>nO(sO)),b=y.useMemo(()=>Gve(w),[w]),v=y.useCallback(N=>ghe(N,b),[b]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,Ze(Y0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,Ze(X0,n)},[n]),y.useEffect(()=>{const N=j=>{j.storageArea===gr()&&((j.key===Y0||j.key===null)&&t(Fj(j.newValue)),(j.key===X0||j.key===null)&&s(CP(j.newValue)))};return window.addEventListener("storage",N),()=>window.removeEventListener("storage",N)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=a,document.documentElement.dataset.colorScheme=sd[a].colorScheme,Ze(R6,a),k(N=>{const j=nO(sO);return Kve(N,j)?N:j})},[a]),y.useEffect(()=>{Ze(WF,h?"1":"0")},[h]),y.useEffect(()=>{Ze(AF,p)},[p]),y.useEffect(()=>{const N=document.querySelector('meta[name="theme-color"]'),j=w["--panel"];N&&j&&N.setAttribute("content",j)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:a,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:v}}function Zve(e){const t=y.useRef(null),[n,s]=y.useState(!1),[a,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(L6(f.name));return Object.keys($6).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(k=>k.getBoundingClientRect()),w=RZ(p,m,8);s(k=>k===w?k: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:a,toggleCat:c,catBarRef:t,catBarOccluded:n}}function Jve(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const s=new Set,a=()=>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,a())};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,k=w.figure){if(!n||n.state!=="running")return!1;const b=b1(m,k),v=xie(w.level,b),N=n.currentTime;for(const j of b.notes){const S=n.createOscillator(),_=n.createGain();S.type=b.type??"sine",S.frequency.value=j.hz;const T=N+j.at,$=T+j.ms/1e3;_.gain.setValueAtTime(TA,T),_.gain.exponentialRampToValueAtTime(v,T+vie),_.gain.exponentialRampToValueAtTime(TA,$),S.connect(_).connect(n.destination),S.start(T),S.stop($+.02)}return!0}async function d(m,w){var v;if(!e.loadCustom)return"unavailable";let k;try{k=await e.loadCustom(m)}catch{return"unavailable"}if(!k)return"missing";if(k.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const N=new SpeechSynthesisUtterance(k.text),j=window.speechSynthesis.getVoices();N.voice=j.find(S=>S.voiceURI===k.voiceURI)??null,N.rate=k.rate,N.pitch=k.pitch,N.volume=bie(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(N),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(k.bytes.slice(0))}catch{return"broken"}try{const N=n.createBufferSource(),j=n.createGain();return N.buffer=b,j.gain.setValueAtTime(kie(k.normalizationGain,w.level),n.currentTime),N.connect(j).connect(n.destination),s.add(N),(v=N.addEventListener)==null||v.call(N,"ended",()=>s.delete(N)),N.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var v,N;if(!w&&!e.enabled())return!1;const k=Tie((v=e.prefs)==null?void 0:v.call(e),m),b=((N=e.customSelection)==null?void 0:N.call(e)[m])??null;return b&&e.loadCustom?(d(b,k).then(j=>{var S;j==="played"||j==="locked"||((j==="missing"||j==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),c(m,{...k,figure:Zn},Zn))}),!0):!n||n.state!=="running"?!1:c(m,k)}function f(m,w=li){return d(m,{level:Xp(w),figure:Zn}),!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:a,get context(){return n}}}function Qve({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){y.useEffect(()=>{const o=Jve({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:pie,onCustomFailure:(h,f)=>a.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 ebe(){const[e,t]=y.useState(Vve),[n,s]=y.useState(()=>MK(Ye($E))),[a,o]=y.useState(()=>RK(Ye(LE))),[i,c]=y.useState(()=>$K(Ye(tO),n,Uve)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ze(HF,String(e))},[e]),y.useEffect(()=>{Ze(LE,a?"1":"0")},[a]),y.useEffect(()=>{Ze($E,JSON.stringify(n))},[n]),y.useEffect(()=>{Ze(tO,i)},[i]);const m=y.useCallback((N,j=!1)=>{s(S=>{const _=S.find(T=>T.id===N.id);return _?!j||!N.radio||!_.radio||_.url===N.url&&JSON.stringify(_.radio)===JSON.stringify(N.radio)?S:S.map(T=>T.id===N.id?{...T,url:N.url,radio:N.radio}:T):[...S,N]}),h(S=>{if(!S.has(N.id))return S;const _=new Set(S);return _.delete(N.id),_})},[]),w=y.useCallback((N,j)=>{const S=j.trim();!S||S.length>eP||s(_=>_.map(T=>T.id===N?{...T,name:S}:T))},[]),k=y.useCallback(N=>{s(j=>j.filter(S=>S.id!==N)),c(j=>LK(j,N)),h(j=>{if(!j.has(N))return j;const S=new Set(j);return S.delete(N),S})},[]),b=y.useCallback((N,j=!1)=>{const S=IE(N),_=d.has(S);N===i&&!_&&!j||(_&&h(T=>{const $=new Set(T);return $.delete(S),$}),c(N),p(T=>T+1))},[i,d]),v=y.useCallback((N,j)=>{const S=IE(N);h(_=>{if(_.has(S)===j)return _;const $=new Set(_);return j?$.add(S):$.delete(S),$})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:k,pickFmSource:b,markFmStationAvailability:v}}function tbe(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!co())return;let k=!1;const b=c.current;return fetch("/api/desktop-update").then(v=>v.ok?v.json():null).then(v=>{if(k||c.current!==b)return;const N=jI(v);N&&n(N)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Xpe(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async k=>{if(!bn(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,a(!0),i(null);const v=N=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,a(!1),i({failure:N,version:k}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!N.ok)return v(Jpe(await N.json().catch(()=>null)))}catch{return v("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>v("timeout"),nF))},[]),w=y.useCallback(k=>{if(co())try{const b=jI(JSON.parse(k));b&&(c.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,a(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const Xh="agent-dag.autoRestart",rO="agent-dag.bundleReloadedFor";function nbe({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ye(Xh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const F=!c;h.current=!0,Ys(Xh),d(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(L=>L.ok?L.json():null).then(L=>{var A;L!=null&&L.ok&&d(((A=L.prefs)==null?void 0:A.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,k]=y.useState("restart"),[b,v]=y.useState(null),N=y.useRef(!1),j=y.useRef(null),S=y.useRef(0),_=y.useRef(null),T=y.useCallback(async F=>{if(!bn(N.current))return;const L=(F==null?void 0:F.upgrade)===!0,A=(F==null?void 0:F.whenIdle)===!0;N.current=!0,j.current=o;const q=++S.current,E=()=>{k(L?"npx":"restart"),m(!0)};A||E();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(A?{upgrade:L,whenIdle:A}:{upgrade:L})});D=A&&P.status===409}catch{}if(D){N.current=!1,_.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}A&&E(),window.setTimeout(()=>{if(S.current===q&&N.current){N.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},L?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const F=SI(t.current.agents.values())>0,L=Pme({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:F,idleSince:_.current,now:e});_.current=L.idleSince,L.restart&&T({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,T]);const $=SI(t.current.agents.values()),M=Ome($,i),O=cF({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:$>0,idleSince:_.current,now:e});y.useEffect(()=>{const F=n==null?void 0:n.running;let L=null,A=null;try{L=window.sessionStorage.getItem("agent-dag.restartPending"),A=window.sessionStorage.getItem(rO)}catch{return}const q=Rme({bundle:"3.45.0",running:F,pending:L,lastTried:A});if(q==="reload"){try{window.sessionStorage.setItem(rO,F??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1),v(F??null);const E=window.setTimeout(()=>v(null),6e3);return()=>window.clearTimeout(E)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&$me({asked:j.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1)}},[p,o]);const I=y.useCallback(F=>{var L,A;if(!h.current){const q=Ye(Xh)==="0";Ys(Xh),q&&((L=F.prefs)==null?void 0:L.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((A=F.prefs)==null?void 0:A.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:T,restartCopy:M,restartFuseMs:O,loadAutoRestartPrefs:I}}function sbe(){const[e,t]=y.useState([]),n=y.useRef(new Set),[s,a]=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(WT(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?f1:RD))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!s){a(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(WT(m.pending,m.aliases)):t(w=>w.filter(k=>k.fp!==f))}catch{}finally{a(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 rbe=6e4;function abe({enabled:e,lanStatus:t,now:n}){const[s,a]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&a(N.accounts)},[]),f=y.useCallback(async N=>{try{const j=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);j.ok&&h(await j.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let N=Date.now();const j=()=>{document.visibilityState!=="visible"||Date.now()-N<rbe||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",j),window.addEventListener("focus",j),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("focus",j)}},[e,f]);const p=y.useMemo(()=>e?nye(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(N=>{N.length&&i(j=>new Set([...j,...N]))},[]),k=y.useCallback(()=>{const N=m.current;N.length&&(w(N.map(j=>j.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(j=>({key:j.key,since:j.since}))})}).catch(()=>{}))},[w]),b=y.useRef(c);b.current=c;const v=y.useCallback(N=>{const j=b.current;w(sye(j?[j,...m.current]:m.current,N))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:v,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:k}}const VF=288,obe=VF;function ibe(e,t,n){return e?"session-list":t||n?"accounts":null}function lbe(e){return e==="session-list"?obe:e==="accounts"?VF:0}const cbe=240,ube=20;function dbe(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Bu()?0:performance.now()+cbe+ube)},[e]),t}const GF="agent-dag.sessionListOpen",KF="agent-dag.accountsPanelOpen";function hbe(){return Ye(GF)==="1"}function fbe(e){Ze(GF,e?"1":"0")}function pbe(){const e=Ye(KF);return e===null?!0:e==="1"}function mbe(){const e=y.useRef(!1),t=y.useRef(!1),[n,s]=y.useState(()=>{const k=hbe();return k&&T1()?(e.current=!0,!1):k});y.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;fbe(n)},[n]);const a=y.useRef(!1),[o,i]=y.useState(()=>{const k=pbe();return k&&n?(a.current=!0,!1):k&&T1()?(t.current=!0,!1):k});y.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&a.current||Ze(KF,o?"1":"0")},[o]),y.useEffect(()=>{!n&&a.current&&(a.current=!1,i(!0))},[n]);const c=y.useCallback(()=>{s(k=>(k||i(b=>(b&&(a.current=!0),!1)),!k))},[]),d=y.useCallback(()=>{a.current=!1,i(k=>(k||s(!1),!k))},[]),h=y.useCallback(()=>{a.current=!1,i(k=>(k||s(!1),!0))},[]),f=y.useCallback(()=>s(!1),[]),p=y.useCallback(()=>{a.current=!1,s(!1)},[]),m=y.useCallback(()=>i(!1),[]),w=ibe(n,o,a.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:w,toggleSessionList:c,toggleAccountsPanel:d,openAccountsPanel:h,closeSessionList:f,closeSessionListToCanvas:p,closeAccountsPanel:m}}const YF="agent-dag.detailOpen",XF="agent-dag.usagePanelOpen",ZF="agent-dag.systemPanelOpen";function gbe(){return Ye(YF)==="1"}function ybe(e){Ze(YF,e?"1":"0")}function wbe(){const e=Ye(XF);return e===null?!0:e==="1"}function xbe(e){Ze(XF,e?"1":"0")}function vbe(){const e=Ye(ZF);return e===null?!0:e==="1"}function bbe(e){Ze(ZF,e?"1":"0")}function kbe(){const[e,t]=y.useState(gbe);y.useEffect(()=>{ybe(e)},[e]);const[n,s]=y.useState(wbe);y.useEffect(()=>{xbe(n)},[n]);const a=y.useRef(!1),[o,i]=y.useState(()=>{const c=vbe();return c&&n&&T1()?(a.current=!0,!1):c});return y.useEffect(()=>{if(o)a.current=!1;else if(a.current)return;bbe(o)},[o]),nn("usage-panel",n),nn("machine-panel",o),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:s,machinePanelOpen:o,setMachinePanelOpen:i}}const jbe={permission:"your permission",asked:"your answer"},Nbe="No sessions are waiting for you.";function Sbe(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?jbe[s]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${a}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${a}.`}function d0(e,t,n=Nbe){return t!==""?t:e===""?"":n}function _be({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=y.useState(""),o=Sbe(e);y.useEffect(()=>{a(m=>d0(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>d0(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=Ove(n);return y.useEffect(()=>{f(m=>d0(m,p,Pve))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Cbe="/icon-192.png",JF=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0,notifyElsewhere:!0});function aO(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:JF[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped"),notifyElsewhere:t("notifyElsewhere")}}function Ebe({waitingSessions:e,liveSince:t,focusSession:n}){const[s,a]=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(JF),w=y.useCallback(O=>{const I=!p[O];m(F=>({...F,[O]:I})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[O]:I})}).then(F=>F.ok?F.json():null).then(F=>{F!=null&&F.ok&&m(aO(F.prefs))}).catch(()=>{})},[p]),k=y.useRef(()=>{}),b=y.useRef(new Set),v=Rn(e),N=y.useCallback(()=>{const O=!c;d(O),O&&(b.current=Th(v.current)),O&&typeof Notification<"u"&&Notification.permission==="default"&&k.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:O})}).then(I=>I.ok?I.json():null).then(I=>{var F;I!=null&&I.ok&&(d(((F=I.prefs)==null?void 0:F.notifications)===!0),f(I.notificationsVetoed===!0))}).catch(()=>{})},[c]),j=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const I=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(I)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(O=>{const I=O;a(I),I==="granted"?i("on"):I==="denied"&&i("blocked")})},[]);k.current=S;const _=y.useRef(null),T=e.map(O=>Np(O.id,O.waiting)).join("|");y.useEffect(()=>{aV(_.current,s)&&(_.current=s,b.current=Th(e))},[s]);const $=y.useRef(!1);y.useEffect(()=>{oV($.current,t)&&($.current=!0,b.current=Th(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!iV(_.current,t))return;const O=typeof document>"u"||!document.hidden,I=sV(e,b.current,O,c);for(const F of I)try{const L=new Notification(F.title,{body:F.body,tag:F.key,icon:Cbe});L.onclick=()=>{window.focus(),n(F.sessionId),L.close()}}catch{}b.current=O?Th(e):rV(e,I,b.current)},[T,t]);const M=y.useCallback(O=>{var I;d(((I=O.prefs)==null?void 0:I.notifications)===!0),f(O.notificationsVetoed===!0),m(aO(O.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:j,askForNotifications:S,loadNotifyPrefs:M,accountNotify:p,toggleAccountNotify:w}}function Tbe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Rn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||s||a!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function Abe({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=y.useState(null),o=y.useCallback((A,q)=>a({agentId:A,toolId:q}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(A=>h(A),[]),[p,m]=y.useState(!1),[w,k]=y.useState(!1),[b,v]=y.useState(!1),[N,j]=y.useState(!1),[S,_]=y.useState(!1),[T,$]=y.useState(null),M=y.useCallback(A=>{$(A??null),_(!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 O=s?Yz(e.current.agents,s.agentId,s.toolId):null,I=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:F,modalOpenRef:L}=Tbe({openedTool:O,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:N});return{setOpenedToolKey:a,openTool:o,openedTool:O,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:I,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:k,browserWatchOpen:b,setBrowserWatchOpen:v,trafficRadarOpen:N,setTrafficRadarOpen:j,feedbackOpen:S,setFeedbackOpen:_,feedbackPrefill:T,setFeedbackPrefill:$,openFeedback:M,keyHelpOpenRef:F,modalOpenRef:L}}function Rbe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:a,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=cj(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",b6(),o(),i(),c()},[c,i,o]),m=Rn(h),w=y.useCallback(k=>{const b=Bme(k,{confirmOpen:m.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const oO="agent-dag.oldNameNoticeDismissed";function Mbe(e){const[t,n]=y.useState(()=>Ye(oO)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==$t?e.invokedAs:null,a=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),Ze(oO,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const $be=300*1e3,Lbe=1800*1e3,Ibe=8e3,Obe=3e4;function iO(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function Pbe({modalOpenRef:e}){const t=y.useCallback(()=>nf({appModal:e.current,dialogDepth:vn.dialogDepth()}),[e]),[n,s]=y.useState("hidden"),[a,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const k=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const N=await fetch("/api/rating").then(j=>j.ok?j.json():null).catch(()=>null);w||!N||s(j=>j==="thanks"?j:N.ask===!0?"asking":"hidden")},b=window.setTimeout(k,$be),v=window.setInterval(k,Lbe);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(v)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?Obe:Ibe;let k=0;const b=()=>{t()?k=window.setTimeout(b,w):s("hidden")};return k=window.setTimeout(b,w),()=>window.clearTimeout(k)},[n,a,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),iO({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),iO({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function Dbe({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=y.useState(()=>nie(Ye)),i=Rn(a),[c,d]=y.useState([]),h=y.useCallback(j=>{o(S=>{const _={...S,[j]:null};return i.current=_,_}),Ys(iu[j])},[]),f=y.useCallback((j,S)=>{const _=i.current[j];S&&_!==S||(h(j),t(T=>{const $={...T,[j]:{...T[j],figure:Zn}};return n.current=$,$}),Ze(np[j],Zn))},[h]),p=Rn(f);y.useEffect(()=>{let j=!0;return fie().then(S=>{if(!j)return;d(S);const _=new Set(S.map(T=>T.id));for(const T of lu){const $=i.current[T];$&&!_.has($)&&p.current(T,$)}},()=>{}),()=>{j=!1}},[]);const m=y.useCallback((j,S)=>{if(!c.some(T=>T.id===S))return;const _={...i.current,[j]:S};i.current=_,o(_),Ze(iu[j],S),s(j,!0)},[c,s]),w=y.useCallback(async j=>{var $;const S=v1(c.length);if(S)throw new Error(S);const _=window.AudioContext??window.webkitAudioContext;if(!_)throw new Error("This browser cannot decode audio files.");const T=new _;try{const M=await lie(j,I=>T.decodeAudioData(I));await CA(M);const O=Iu(M);d(I=>[...I.filter(F=>F.id!==O.id),O])}finally{($=T.close)==null||$.call(T)}},[c.length]),k=y.useCallback(async j=>{const S=v1(c.length);if(S)throw new Error(S);const _=cie(j);await CA(_);const T=Iu(_);d($=>[...$.filter(M=>M.id!==T.id),T])},[c.length]),b=y.useCallback(async(j,S)=>{const _=c.find($=>$.id===j),T=S.trim().slice(0,80);!_||!T||T===_.name||(await mie(j,T),d($=>$.map(M=>M.id===j?{...M,name:T}:M)))},[c]),v=y.useCallback(async j=>{await gie(j),d($=>$.filter(M=>M.id!==j));const S=i.current,_=sie(S,j);i.current=_,o(_);const T=lu.filter($=>S[$]===j);for(const $ of T)Ys(iu[$]),Ze(np[$],Zn);T.length>0&&t($=>{const M={...$};for(const O of T)M[O]={...M[O],figure:Zn};return n.current=M,M})},[]),N=y.useCallback(j=>{var T,$;const S=lu.find(M=>i.current[M]===j),_=S?n.current[S].level:li;(T=e.current)==null||T.unlock(),($=e.current)==null||$.previewCustom(j,_)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:k,renameCustomAsset:b,deleteCustomAsset:v,previewCustomAsset:N}}function Fbe(e){const[t,n]=y.useState(()=>Eie(Ye)),s=Rn(t),a=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),a.current!==null&&clearTimeout(a.current),a.current=null,!d){(f=e.current)==null||f.play(c,!0);return}a.current=setTimeout(()=>{var p;a.current=null,(p=e.current)==null||p.play(c,!0)},jie)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:Xp(d.level??h[c].level),figure:l5(c,d.figure??h[c].figure)};return Ze(d5[c],String(f.level)),Ze(np[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const Bbe=15e3;function qbe(e){return e.visibilityState==="visible"&&e.hasFocus()}function Ube(e,t){return t||e===!0}function Wbe(){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 Hbe(){y.useEffect(()=>{const e=Wbe();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=qbe(document);Ube(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,Bbe);return window.addEventListener("focus",s),window.addEventListener("blur",s),document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",a),()=>{window.clearInterval(o),window.removeEventListener("focus",s),window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",a),a()}},[])}function zbe({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let s=!0;return fetch("/api/prefs").then(a=>a.ok?a.json():null).then(a=>{!s||!(a!=null&&a.ok)||(e(a),t(a),n(a))}).catch(()=>{}),()=>{s=!1}},[])}const h0="agent-dag.versionNoticeDismissed",Vbe=15*6e4;function Gbe(e){const[t,n]=y.useState(null),[s,a]=y.useState(()=>Ye(h0)??""),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(v=>v.ok?v.json():null).then(v=>(v&&n(v),v??null)).catch(()=>null).finally(()=>{b&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=Vbe)},[d]);y.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),v=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",v),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",v)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=oF(f),m=sme(f,s),w=y.useCallback(()=>{a(""),Ze(h0,"")},[]),k=y.useCallback(()=>{f&&(a(p),Ze(h0,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:k,versionChecking:i,loadVersion:d}}function Kbe({version:e,readyAppUpdate:t}){const[n,s]=y.useState(!1),a=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 v=gr(),N=Nye(v),j=Aye({stored:N,running:(e==null?void 0:e.running)??null,notes:$I,remembers:Sye(v)});if(j.reason==="no-version")return;h.current=!0,j.record&&_ye(v,j.record);let S=!0;return(async()=>{var O;let T=Cye(v);if(co())try{const I=await fetch("/api/prefs");if(!I.ok)throw new Error("desktop tour preferences unavailable");const F=await I.json();if(!(F!=null&&F.ok))throw new Error("desktop tour preferences unavailable");const L=((O=F.prefs)==null?void 0:O.tourSeen)===!0;T&&!L&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||L}catch{T=!0}if(!S)return;const $=Tye({tourSeen:T,decision:j}),M=j.show.length?{entries:j.show,since:N,firstRun:!1}:null;$.tour&&s(!0),$.notes==="now"?i(M):$.notes==="after"&&(a.current=M)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.45.0",p=y.useMemo(()=>kF($I,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),k=y.useCallback(()=>i(null),[]),b=y.useCallback(()=>{s(!1),Eye(gr()),co()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const v=a.current;a.current=null,v&&i(v)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:k,chipVersion:f,openReleaseNotes:m}}function Ybe(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),a=y.useRef(!1);return a.current=e===!0&&!n,y.useEffect(()=>hve(()=>a.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function Xbe(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ye("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})},[]),a=y.useCallback(c=>{s()},[s]),o=Rn(a),i=Rn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function Zbe(){const[e,t]=y.useState(Jhe),n=y.useCallback(o=>{t(i=>Qhe(i,o))},[]),s=y.useCallback(()=>t(o=>({...o,open:!1})),[]),a=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:s,showSection:a}}const Jbe="agent-dag.autoFitDisabled";function Qbe(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{Ys(Jbe)},[]);const a=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:a,enableAutoFitAndRefit:o}}function eke(){return r.jsx(lj,{children:r.jsx(mve,{children:r.jsx(tke,{})})})}function tke(){var Fr;const e=Il(),t=y.useState(cj)[0],n=y.useRef(t),[,s]=y.useState(0),a=y.useCallback(()=>s(vt=>vt+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=kbe(),{selectedIds:p,primarySelectedId:m,selectAgent:w,clearSelection:k,pruneSelectionToBoard:b}=Vie(n,i),{sessionListOpen:v,accountsPanelOpen:N,panel:j,toggleSessionList:S,toggleAccountsPanel:_,openAccountsPanel:T,closeSessionList:$,closeSessionListToCanvas:M,closeAccountsPanel:O}=mbe(),I=ll(N,200),F=ll(v,200),L=ZC(v,F),A=ll(c,130),q=ll(h,130),E=y.useRef(null),D=Xbe(E),{activateSoundRef:P,soundOnRef:z}=D,G=Fbe(E),{setTonePrefs:V,tonePrefsRef:H,previewTone:B}=G,W=Dbe({chimesRef:E,setTonePrefs:V,tonePrefsRef:H,previewTone:B}),{customSelectionsRef:ee,fallbackCustomRef:U}=W,Y=Zbe(),{openSettings:X}=Y;Qve({chimesRef:E,soundOnRef:z,tonePrefsRef:H,customSelectionsRef:ee,fallbackCustomRef:U});const Z=wve(n),{pauseGate:J,paused:te,togglePause:ce}=Z,he=y.useRef(()=>{}),{live:le,tabCapped:re,everConnected:ae,liveSince:de}=Oie({stateRef:n,rerender:a,pauseGate:J,chimesRef:E,desktopUpdateRef:he}),_e=Gbe(le),{version:fe,notice:ye,noticeOpen:ke,loadVersion:Ne}=_e,ge=tbe(le),{readyAppUpdate:Me,onDesktopUpdateEvent:Ie}=ge;he.current=Ie,Hbe();const We=Kbe({version:fe,readyAppUpdate:Me}),{tourOpen:Te,openTour:at,releaseNotes:Je}=We,{workspace:Ve,providers:be,providersRef:Oe}=vve(le),ze=lbe(j==="accounts"&&!be.claude?null:j),st=dbe(ze),ot=ZC(N,I)&&be.claude,[Qe,we]=y.useState(!1),Fe=y.useCallback(()=>{T(),we(!0)},[T]);y.useEffect(()=>{N||we(!1)},[N]);const Xe=y.useCallback(()=>we(!1),[]),He=Mbe(fe),ht=Dve({version:fe,loadVersion:Ne}),{upgradeFailure:Ct}=ht,mt=Abe({stateRef:n,tourOpen:Te,releaseNotes:Je}),Et=Pbe({modalOpenRef:mt.modalOpenRef}),{openTool:Ot,setSummaryFor:js,setContextFor:tr,openContext:Ns,setKeyHelpOpen:es,setUsageHistoryOpen:Pt,setBrowserWatchOpen:Ss,keyHelpOpenRef:pn,modalOpenRef:Fn}=mt,Ce=Ybe(),Pe=Bve(),{watchOn:Ke,watchUnseen:jt}=Pe,Nt=ad(),[Xt,ts]=y.useState(null),pa=y.useCallback(()=>ts(null),[]),Bn=G6().filter(vt=>Lpe(Nt,vt.kind)),qn=Rn(vt=>{const Ca=Bn.find(_m=>_m.kind===vt);Ca&&ts(Ca.kind)}),_s=y.useCallback(vt=>{qpe(vt),X("integrations")},[X]),rn=Bn.length>0;y.useEffect(()=>{rn&&_pe()},[rn]);const ma=sbe(),[nr,Zt]=y.useState(0),{presentCats:ns,hiddenCats:Un,toggleCat:sr,catBarRef:rr,catBarOccluded:ft}=Zve(n),ga=y.useRef(null),[Cs,_r]=y.useState(0),Tt=Gie({stateRef:n,rerender:a,pruneSelectionToBoard:b,setContextFor:tr,setSummaryFor:js});QG({stateRef:n,now:Tt,enabled:be.claude});const Cr=Nve(be.claude||be.codex),ar=Ive(Cr,Tt),Es=abe({enabled:be.claude,lanStatus:ma.lanStatus,now:Tt}),Jt=nbe({now:Tt,stateRef:n,version:fe,notice:ye,noticeOpen:ke,upgradeFailure:Ct,paused:Z.paused}),{askRestart:Er,loadAutoRestartPrefs:mn}=Jt,ya=Xve(),{setTheme:Vl,palette:Gl}=ya,Tr=ebe(),Ts=Hde(),{applyViewport:or,moveCamera:Ar,fitLeft:Rr,cameraEpochRef:pi,lastFitTimeRef:Mr}=Ts,As=rhe(Ts),{pinnedRef:me,positionsRef:Be,lastLayoutSigRef:dt,handleRelayout:At,rearrangeUndo:rt}=As,$r=y.useRef(null),mo=y.useRef(()=>{}),wa=de!==null,xa=y.useRef(0),Lr=y.useCallback(()=>{xa.current=Date.now()},[]),{canvasRef:Rs,canvasSize:Kl,paneSizeRef:mi}=Vhe(st),Ms=Qbe(Rr),{autoFitDisabledRef:$s,disableAutoFit:ss}=Ms,Ir=y.useRef(!1),{measuredRef:Wn,measuredVersionRef:ir,sizeVersion:mm,domSizeVersion:id}=Ghe(Ir),{removedNodes:Or,removedAgentIds:va,removeNode:ld,removeSelectedNode:go,removalNotice:Yl,hideSessions:gm,bringBack:Pr,bringBackAll:yo,forgetRemovals:ba}=She({stateRef:n,pinnedRef:me,positionsRef:Be,canvasRef:Rs,clearSelection:k,primarySelectedId:m});Ihe({stateRef:n,removedNodes:Or,hideSessions:gm,ready:wa,keepSessionId:m?((Fr=n.current.agents.get(m))==null?void 0:Fr.sessionId)??m:null});const ka=vhe({stateRef:n,now:Tt,removedAgentIds:va,sizeVersion:mm,domSizeVersion:id});ahe(ka,As),Nhe({layoutSig:ka,rf:e,stateRef:n,measuredRef:Wn,pinnedRef:me,positionsRef:Be,paneSizeRef:mi,lastInteractRef:xa,autoFitDisabledRef:$s,lastFitTimeRef:Mr,fitLeft:Rr});const cd=Khe(),{bubbling:ym,endBubble:Xl,onBubble:gi}=Uoe(),[wo,ud]=y.useState(!1),Ls=Boe(),{beginTrashDrag:Zl,trackTrashDrag:yi,endTrashDrag:dd}=Ls,xo=Yoe({stateRef:n,measuredRef:Wn,measuredVersionRef:ir,canvasRef:Rs}),{lodRef:wi,applyZoom:hd}=xo,cn=Whe({applyViewport:or,lastFitTimeRef:Mr,cameraEpochRef:pi,disableAutoFit:ss,markInteract:Lr,canvasRef:Rs,applyZoom:hd}),rs=m?n.current.agents.get(m):null,vo=o&&rs!=null,as=ife({sessionListShown:L,usageShown:Ja(A),machineShown:Ja(q),accountsShown:ot,detailShown:vo,primarySelectedId:m,canvasRef:Rs}),{railInsetRef:xi,availableWidth:vi,availableHeight:bi}=Fde({canvasRef:Rs,canvasSize:Kl,machinePhase:q,usagePhase:A,usagePanelOpen:c,detailShown:vo}),ja=bhe({stateRef:n,now:Tt,availableWidth:vi,availableHeight:bi,layout:As,measuredRef:Wn,onBubble:gi,settled:cd,dragging:wo,layoutSig:ka,selectedIds:p,openContext:Ns,historyReplayed:wa,removedNodes:Or,removedAgentIds:va,dragTick:nr,dragPatchRef:ga,dragMoveTick:Cs}),{nodes:Na,edges:fd}=ja,Jl=Rn(m);ohe({nodes:Na,edges:fd,settled:cd,dragging:wo,availableWidth:vi,availableHeight:bi,layout:As,camera:Ts,rf:e,measuredRef:Wn,stateRef:n,lastFocusRef:$r,primarySelectedIdRef:Jl,focusAgentRef:mo,autoFitDisabledRef:$s});const pd=Rbe({stateRef:n,pinnedRef:me,measuredRef:Wn,positionsRef:Be,lastLayoutSigRef:dt,forgetRemovals:ba,clearSelection:k,rerender:a,modalOpenRef:Fn}),{requestClear:md}=pd,Ql=lfe({nodes:Na,stateRef:n,pinnedRef:me,positionsRef:Be,draggingRef:Ir,dragPatchRef:ga,setDragging:ud,setDragMoveTick:_r,setDragTick:Zt,endBubble:Xl,markInteract:Lr,disableAutoFit:ss,beginTrashDrag:Zl,trackTrashDrag:yi,endTrashDrag:dd,removeNode:ld}),wm=y.useCallback(()=>Rr(500),[Rr]),ec=Rn(Na),{focusAgent:ki,stepAgent:xm,focusSession:Sa}=Vde({canvasRef:Rs,stateRef:n,measuredRef:Wn,nodesRef:ec,railInsetRef:xi,moveCamera:Ar,disableAutoFit:ss,lastFocusRef:$r,focusAgentRef:mo,selectAgent:w,primarySelectedIdRef:Jl}),gd=Hhe({clearSelection:k,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:vo,focusAgent:ki,draggingRef:Ir,lodRef:wi}),vm=Gde({nodesRef:ec,stateRef:n,canvasRef:Rs,railInsetRef:xi}),bm=Rn(go),tc=y.useRef(null),ji=y.useCallback(vt=>{va.has(vt)&&Pr([vt]),Sa(vt)},[va,Pr,Sa]),nc=Yhe();afe({pointerFocusRef:nc,nodesRef:ec,stateRef:n,primarySelectedIdRef:Jl,providersRef:Oe,soundOnRef:z,keyHelpOpenRef:pn,modalOpenRef:Fn,waitingCursorRef:tc,removeSelectedRef:bm,activateSoundRef:P,clearSelection:k,selectAgent:w,focusAgent:ki,stepAgent:xm,focusSession:Sa,requestClear:md,handleRelayout:At,undoRearrange:rt.undo,handleFit:wm,togglePause:ce,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:i,setUsageHistoryOpen:Pt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Ss,setKeyHelpOpen:es,setTheme:Vl,openSettings:X,openIntegrationRef:qn});const yd=n.current.agents.size,_a=y.useMemo(()=>$0(n.current.agents.values()),[n.current,n.current.revision]);_he({stateRef:n,waitingSessions:_a,removedAgentIds:va,removedNodes:Or,bringBack:Pr}),Bhe({stateRef:n,waitingSessions:_a,live:le});const wd=_be({waitingSessions:_a,watchUnseen:jt,incidents:ar}),Ni=Ebe({waitingSessions:_a,liveSince:de,focusSession:Sa}),{loadNotifyPrefs:km}=Ni;zbe({loadAutoRestartPrefs:mn,loadNotifyPrefs:km,loadReportsPrefs:Ce.loadReportsPrefs});const Dr=Pp(I6),[xd,vd]=y.useState(!1),[jm,sc]=y.useState(!1),Nm=y.useCallback(()=>sc(!1),[]),rc=y.useCallback(vt=>{const Ca=n.current.agents.get(vt);return Ca?Ca.label||Ca.cwdBasename||"session":null},[]),bo=y.useCallback(vt=>{sc(!1),ji(vt)},[ji]),Sm=y.useCallback(()=>vd(!1),[]),Hn=Ufe({providers:be,sessionListOpen:v,toggleSessionList:S,accountsPanelOpen:N,toggleAccountsPanel:_,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Pt,watchOn:Ke,watchUnseen:jt,setBrowserWatchOpen:Ss,setTrafficRadarOpen:mt.setTrafficRadarOpen,openSettings:X,onFeedback:mt.openFeedback,radioOpen:xd,setRadioOpen:vd,openToolActivity:()=>sc(!0),toggles:as.toggles,integrations:Bn.map(vt=>({provider:vt,onPress:()=>ts(vt.kind)}))}),[bd,kd]=y.useState(0),jd=y.useCallback(vt=>{ji(vt),Dr&&M()},[ji,Dr,M]),Nd=y.useCallback(()=>{v||S(),requestAnimationFrame(()=>{var vt;return(vt=document.querySelector("#session-list .sl-row"))==null?void 0:vt.focus()})},[v,S]);return r.jsxs("div",{className:"app",children:[r.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),r.jsxs("header",{className:"topbar",children:[r.jsx(vZ,{}),r.jsx(pme,{versionCheck:_e,welcome:We,desktopUpdate:ge,pause:Z,announcements:wd,notify:Ni,waitingSessions:_a,waitingCursorRef:tc,focusSession:Sa,live:le,now:Tt,incidents:ar,queueNamed:Dr?0:bd}),!Dr&&r.jsx(dme,{waitingSessions:_a,waitingCursorRef:tc,focusSession:Sa,now:Tt,onFit:kd,onMore:Nd}),rs&&r.jsx(mme,{selected:rs,now:Tt,selectedIds:p,focusAgent:ki,clearSelection:k}),!Dr&&r.jsx("div",{className:"actions",children:r.jsx(Ffe,{items:Hn.utilities})})]}),Dr?r.jsx(Dfe,{items:[...Hn.left,...Hn.right[0],Hn.utilities[0]],more:[...Hn.right.slice(1).flat(),...Hn.integrations,Hn.utilities[1]]}):r.jsx(hI,{side:"left",label:"Left column",groups:[Hn.left,Hn.integrations]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Yl?`${Yl.label} removed from the board.`:""}),r.jsx(Fme,{restart:Jt,versionCheck:_e,upgrade:ht,oldNameNotice:He,rating:Et,onFeedback:mt.openFeedback,everConnected:ae,live:le,paused:te}),(L||ot)&&r.jsxs($oe,{width:ze,children:[ot&&r.jsx(Moe,{leaving:JC(N,I),onReport:mt.openFeedback,onRoster:Es.observe,onClose:()=>{as.accounts(),O()},lanWanted:Qe,onLanShown:Xe}),L&&r.jsx(LZ,{leaving:JC(v,F),state:n.current,now:Tt,selectedIds:p,onSelect:jd,onClose:()=>{as.sessionList(),$()},removedIds:va,onBringBackAll:yo})]}),r.jsxs(vme,{canvasRef:Rs,bubbling:ym,dragging:wo,trash:Ls,zoom:xo,viewport:cn,stateRef:n,peek:vm,children:[yd===0&&(!le&&re?r.jsx(ufe,{reservedRight:xi.current}):r.jsx(dfe,{live:le,everConnected:ae,providers:be,workspace:Ve,onTour:at,reservedRight:xi.current})),(ns.length>1||Un.size>0)&&r.jsx(gme,{catBarRef:rr,catBarOccluded:ft,presentCats:ns,hiddenCats:Un,toggleCat:sr}),r.jsx(xZ,{graph:ja,layout:As,viewport:cn,clicks:gd,drag:Ql,appearance:ya,fm:Tr,radioOpen:xd,onRadioClose:Sm,autoFit:Ms,pause:Z,stateRef:n,measuredRef:Wn,hiddenCats:Un,now:Tt,openTool:Ot,focusAgent:ki,requestClear:md,setKeyHelpOpen:es})]}),!Dr&&r.jsx(hI,{side:"right",label:"Right panels",groups:Hn.right}),jm&&r.jsx(yJ,{onClose:Nm,sessionLabel:rc,onOpenSession:bo}),Xt&&r.jsx(Tpe,{kind:Xt,connections:od(Nt,Xt)?J6(Nt,Xt):[],onClose:pa,onReconnect:_s}),Ja(A)&&r.jsx(SQ,{state:n.current,now:Tt,providers:be,incidents:ar,liveSince:de,leaving:A==="leaving",onClose:()=>{as.usage(),d(!1)}}),Ja(q)&&r.jsx(uee,{usageOpen:c,leaving:q==="leaving",onClose:()=>{as.machine(),f(!1)}}),o&&rs?r.jsx(Sfe,{selected:rs,now:Tt,openTool:Ot,setSummaryFor:js,stateRef:n,removeSelectedNode:go,onClose:()=>{as.detail(),i(!1)}}):null,r.jsx(Yxe,{dialogs:mt,welcome:We,desktopUpdate:ge,versionCheck:_e,restart:Jt,upgrade:ht,lanPairs:ma,attention:Es,clearFlow:pd,watchBadge:Pe,announcements:wd,appearance:ya,providers:be,stateRef:n,agentCount:yd,menus:Y,sound:D,tones:G,customTones:W,notify:Ni,panelDoors:{accounts:T,localNetwork:Fe}})]})}try{zV(window.localStorage)}catch{}const nke=lB.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);nke.render(r.jsx(eke,{}));export{cX as $,Up as A,nt as B,Q0 as C,gT as D,e1 as E,wt as F,ro as G,ea as H,wr as I,cke as J,uke as K,$u as L,lke as M,Pn as N,oie as O,mke as P,wke as Q,PP as R,$ye as S,gke as T,yke as U,Mye as V,xke as W,Rp as X,pe as Y,oi as Z,ao as _,y as a,jke as a0,Mj as a1,$l as a2,HK as a3,ike as a4,ake as a5,oke as a6,Mp as a7,_V as a8,Vwe as a9,qve as aa,rke as ab,uX as ac,pke as b,Fpe as c,oxe as d,ho as e,Tf as f,$n as g,pt as h,gt as i,r as j,nn as k,bke as l,vn as m,vke as n,hke as o,dke as p,fke as q,Ye as r,bn as s,Dp as t,Pp as u,xt as v,Ze as w,K6 as x,kke as y,BP as z};