ccdeck 3.22.5 → 3.22.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();var gu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ff={exports:{}},fl={},pf={exports:{}},Ze={};/**
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();var yu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pf={exports:{}},pl={},mf={exports:{}},Ze={};/**
2
2
  * @license React
3
3
  * react.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Sb;function HR(){if(Sb)return Ze;Sb=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"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=m&&P[m]||P["@@iterator"],typeof P=="function"?P:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,_={};function S(P,G,de){this.props=P,this.context=G,this.refs=_,this.updater=de||v}S.prototype.isReactComponent={},S.prototype.setState=function(P,G){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,G,"setState")},S.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function x(){}x.prototype=S.prototype;function N(P,G,de){this.props=P,this.context=G,this.refs=_,this.updater=de||v}var E=N.prototype=new x;E.constructor=N,j(E,S.prototype),E.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,I={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function F(P,G,de){var W,U={},J=null,V=null;if(G!=null)for(W in G.ref!==void 0&&(V=G.ref),G.key!==void 0&&(J=""+G.key),G)R.call(G,W)&&!$.hasOwnProperty(W)&&(U[W]=G[W]);var ie=arguments.length-2;if(ie===1)U.children=de;else if(1<ie){for(var pe=Array(ie),me=0;me<ie;me++)pe[me]=arguments[me+2];U.children=pe}if(P&&P.defaultProps)for(W in ie=P.defaultProps,ie)U[W]===void 0&&(U[W]=ie[W]);return{$$typeof:e,type:P,key:J,ref:V,props:U,_owner:I.current}}function O(P,G){return{$$typeof:e,type:P.type,key:G,ref:P.ref,props:P.props,_owner:P._owner}}function M(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function L(P){var G={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(de){return G[de]})}var H=/\/+/g;function B(P,G){return typeof P=="object"&&P!==null&&P.key!=null?L(""+P.key):G.toString(36)}function A(P,G,de,W,U){var J=typeof P;(J==="undefined"||J==="boolean")&&(P=null);var V=!1;if(P===null)V=!0;else switch(J){case"string":case"number":V=!0;break;case"object":switch(P.$$typeof){case e:case t:V=!0}}if(V)return V=P,U=U(V),P=W===""?"."+B(V,0):W,C(U)?(de="",P!=null&&(de=P.replace(H,"$&/")+"/"),A(U,G,de,"",function(me){return me})):U!=null&&(M(U)&&(U=O(U,de+(!U.key||V&&V.key===U.key?"":(""+U.key).replace(H,"$&/")+"/")+P)),G.push(U)),1;if(V=0,W=W===""?".":W+":",C(P))for(var ie=0;ie<P.length;ie++){J=P[ie];var pe=W+B(J,ie);V+=A(J,G,de,pe,U)}else if(pe=y(P),typeof pe=="function")for(P=pe.call(P),ie=0;!(J=P.next()).done;)J=J.value,pe=W+B(J,ie++),V+=A(J,G,de,pe,U);else if(J==="object")throw G=String(P),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");return V}function Q(P,G,de){if(P==null)return P;var W=[],U=0;return A(P,W,"","",function(J){return G.call(de,J,U++)}),W}function K(P){if(P._status===-1){var G=P._result;G=G(),G.then(function(de){(P._status===0||P._status===-1)&&(P._status=1,P._result=de)},function(de){(P._status===0||P._status===-1)&&(P._status=2,P._result=de)}),P._status===-1&&(P._status=0,P._result=G)}if(P._status===1)return P._result.default;throw P._result}var ee={current:null},Z={transition:null},D={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:Z,ReactCurrentOwner:I};function Y(){throw Error("act(...) is not supported in production builds of React.")}return Ze.Children={map:Q,forEach:function(P,G,de){Q(P,function(){G.apply(this,arguments)},de)},count:function(P){var G=0;return Q(P,function(){G++}),G},toArray:function(P){return Q(P,function(G){return G})||[]},only:function(P){if(!M(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Ze.Component=S,Ze.Fragment=n,Ze.Profiler=a,Ze.PureComponent=N,Ze.StrictMode=s,Ze.Suspense=h,Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,Ze.act=Y,Ze.cloneElement=function(P,G,de){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var W=j({},P.props),U=P.key,J=P.ref,V=P._owner;if(G!=null){if(G.ref!==void 0&&(J=G.ref,V=I.current),G.key!==void 0&&(U=""+G.key),P.type&&P.type.defaultProps)var ie=P.type.defaultProps;for(pe in G)R.call(G,pe)&&!$.hasOwnProperty(pe)&&(W[pe]=G[pe]===void 0&&ie!==void 0?ie[pe]:G[pe])}var pe=arguments.length-2;if(pe===1)W.children=de;else if(1<pe){ie=Array(pe);for(var me=0;me<pe;me++)ie[me]=arguments[me+2];W.children=ie}return{$$typeof:e,type:P.type,key:U,ref:J,props:W,_owner:V}},Ze.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:l,_context:P},P.Consumer=P},Ze.createElement=F,Ze.createFactory=function(P){var G=F.bind(null,P);return G.type=P,G},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(P){return{$$typeof:d,render:P}},Ze.isValidElement=M,Ze.lazy=function(P){return{$$typeof:f,_payload:{_status:-1,_result:P},_init:K}},Ze.memo=function(P,G){return{$$typeof:p,type:P,compare:G===void 0?null:G}},Ze.startTransition=function(P){var G=Z.transition;Z.transition={};try{P()}finally{Z.transition=G}},Ze.unstable_act=Y,Ze.useCallback=function(P,G){return ee.current.useCallback(P,G)},Ze.useContext=function(P){return ee.current.useContext(P)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(P){return ee.current.useDeferredValue(P)},Ze.useEffect=function(P,G){return ee.current.useEffect(P,G)},Ze.useId=function(){return ee.current.useId()},Ze.useImperativeHandle=function(P,G,de){return ee.current.useImperativeHandle(P,G,de)},Ze.useInsertionEffect=function(P,G){return ee.current.useInsertionEffect(P,G)},Ze.useLayoutEffect=function(P,G){return ee.current.useLayoutEffect(P,G)},Ze.useMemo=function(P,G){return ee.current.useMemo(P,G)},Ze.useReducer=function(P,G,de){return ee.current.useReducer(P,G,de)},Ze.useRef=function(P){return ee.current.useRef(P)},Ze.useState=function(P){return ee.current.useState(P)},Ze.useSyncExternalStore=function(P,G,de){return ee.current.useSyncExternalStore(P,G,de)},Ze.useTransition=function(){return ee.current.useTransition()},Ze.version="18.3.1",Ze}var jb;function Ul(){return jb||(jb=1,pf.exports=HR()),pf.exports}/**
9
+ */var Sb;function HR(){if(Sb)return Ze;Sb=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"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=m&&P[m]||P["@@iterator"],typeof P=="function"?P:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,_={};function S(P,G,de){this.props=P,this.context=G,this.refs=_,this.updater=de||v}S.prototype.isReactComponent={},S.prototype.setState=function(P,G){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,G,"setState")},S.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function x(){}x.prototype=S.prototype;function N(P,G,de){this.props=P,this.context=G,this.refs=_,this.updater=de||v}var E=N.prototype=new x;E.constructor=N,j(E,S.prototype),E.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,I={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function F(P,G,de){var W,U={},J=null,V=null;if(G!=null)for(W in G.ref!==void 0&&(V=G.ref),G.key!==void 0&&(J=""+G.key),G)R.call(G,W)&&!$.hasOwnProperty(W)&&(U[W]=G[W]);var ie=arguments.length-2;if(ie===1)U.children=de;else if(1<ie){for(var pe=Array(ie),me=0;me<ie;me++)pe[me]=arguments[me+2];U.children=pe}if(P&&P.defaultProps)for(W in ie=P.defaultProps,ie)U[W]===void 0&&(U[W]=ie[W]);return{$$typeof:e,type:P,key:J,ref:V,props:U,_owner:I.current}}function O(P,G){return{$$typeof:e,type:P.type,key:G,ref:P.ref,props:P.props,_owner:P._owner}}function M(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function L(P){var G={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(de){return G[de]})}var H=/\/+/g;function B(P,G){return typeof P=="object"&&P!==null&&P.key!=null?L(""+P.key):G.toString(36)}function A(P,G,de,W,U){var J=typeof P;(J==="undefined"||J==="boolean")&&(P=null);var V=!1;if(P===null)V=!0;else switch(J){case"string":case"number":V=!0;break;case"object":switch(P.$$typeof){case e:case t:V=!0}}if(V)return V=P,U=U(V),P=W===""?"."+B(V,0):W,C(U)?(de="",P!=null&&(de=P.replace(H,"$&/")+"/"),A(U,G,de,"",function(me){return me})):U!=null&&(M(U)&&(U=O(U,de+(!U.key||V&&V.key===U.key?"":(""+U.key).replace(H,"$&/")+"/")+P)),G.push(U)),1;if(V=0,W=W===""?".":W+":",C(P))for(var ie=0;ie<P.length;ie++){J=P[ie];var pe=W+B(J,ie);V+=A(J,G,de,pe,U)}else if(pe=y(P),typeof pe=="function")for(P=pe.call(P),ie=0;!(J=P.next()).done;)J=J.value,pe=W+B(J,ie++),V+=A(J,G,de,pe,U);else if(J==="object")throw G=String(P),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");return V}function Q(P,G,de){if(P==null)return P;var W=[],U=0;return A(P,W,"","",function(J){return G.call(de,J,U++)}),W}function K(P){if(P._status===-1){var G=P._result;G=G(),G.then(function(de){(P._status===0||P._status===-1)&&(P._status=1,P._result=de)},function(de){(P._status===0||P._status===-1)&&(P._status=2,P._result=de)}),P._status===-1&&(P._status=0,P._result=G)}if(P._status===1)return P._result.default;throw P._result}var ee={current:null},Z={transition:null},D={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:Z,ReactCurrentOwner:I};function Y(){throw Error("act(...) is not supported in production builds of React.")}return Ze.Children={map:Q,forEach:function(P,G,de){Q(P,function(){G.apply(this,arguments)},de)},count:function(P){var G=0;return Q(P,function(){G++}),G},toArray:function(P){return Q(P,function(G){return G})||[]},only:function(P){if(!M(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Ze.Component=S,Ze.Fragment=n,Ze.Profiler=a,Ze.PureComponent=N,Ze.StrictMode=s,Ze.Suspense=h,Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,Ze.act=Y,Ze.cloneElement=function(P,G,de){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var W=j({},P.props),U=P.key,J=P.ref,V=P._owner;if(G!=null){if(G.ref!==void 0&&(J=G.ref,V=I.current),G.key!==void 0&&(U=""+G.key),P.type&&P.type.defaultProps)var ie=P.type.defaultProps;for(pe in G)R.call(G,pe)&&!$.hasOwnProperty(pe)&&(W[pe]=G[pe]===void 0&&ie!==void 0?ie[pe]:G[pe])}var pe=arguments.length-2;if(pe===1)W.children=de;else if(1<pe){ie=Array(pe);for(var me=0;me<pe;me++)ie[me]=arguments[me+2];W.children=ie}return{$$typeof:e,type:P.type,key:U,ref:J,props:W,_owner:V}},Ze.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:l,_context:P},P.Consumer=P},Ze.createElement=F,Ze.createFactory=function(P){var G=F.bind(null,P);return G.type=P,G},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(P){return{$$typeof:d,render:P}},Ze.isValidElement=M,Ze.lazy=function(P){return{$$typeof:f,_payload:{_status:-1,_result:P},_init:K}},Ze.memo=function(P,G){return{$$typeof:p,type:P,compare:G===void 0?null:G}},Ze.startTransition=function(P){var G=Z.transition;Z.transition={};try{P()}finally{Z.transition=G}},Ze.unstable_act=Y,Ze.useCallback=function(P,G){return ee.current.useCallback(P,G)},Ze.useContext=function(P){return ee.current.useContext(P)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(P){return ee.current.useDeferredValue(P)},Ze.useEffect=function(P,G){return ee.current.useEffect(P,G)},Ze.useId=function(){return ee.current.useId()},Ze.useImperativeHandle=function(P,G,de){return ee.current.useImperativeHandle(P,G,de)},Ze.useInsertionEffect=function(P,G){return ee.current.useInsertionEffect(P,G)},Ze.useLayoutEffect=function(P,G){return ee.current.useLayoutEffect(P,G)},Ze.useMemo=function(P,G){return ee.current.useMemo(P,G)},Ze.useReducer=function(P,G,de){return ee.current.useReducer(P,G,de)},Ze.useRef=function(P){return ee.current.useRef(P)},Ze.useState=function(P){return ee.current.useState(P)},Ze.useSyncExternalStore=function(P,G,de){return ee.current.useSyncExternalStore(P,G,de)},Ze.useTransition=function(){return ee.current.useTransition()},Ze.version="18.3.1",Ze}var jb;function Wl(){return jb||(jb=1,mf.exports=HR()),mf.exports}/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Eb;function GR(){if(Eb)return fl;Eb=1;var e=Ul(),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,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,h,p){var f,m={},y=null,v=null;p!==void 0&&(y=""+p),h.key!==void 0&&(y=""+h.key),h.ref!==void 0&&(v=h.ref);for(f in h)s.call(h,f)&&!l.hasOwnProperty(f)&&(m[f]=h[f]);if(d&&d.defaultProps)for(f in h=d.defaultProps,h)m[f]===void 0&&(m[f]=h[f]);return{$$typeof:t,type:d,key:y,ref:v,props:m,_owner:a.current}}return fl.Fragment=n,fl.jsx=c,fl.jsxs=c,fl}var Cb;function VR(){return Cb||(Cb=1,ff.exports=GR()),ff.exports}var i=VR(),yu={},mf={exports:{}},yn={},gf={exports:{}},yf={};/**
17
+ */var Eb;function GR(){if(Eb)return pl;Eb=1;var e=Wl(),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,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,h,p){var f,m={},y=null,v=null;p!==void 0&&(y=""+p),h.key!==void 0&&(y=""+h.key),h.ref!==void 0&&(v=h.ref);for(f in h)s.call(h,f)&&!l.hasOwnProperty(f)&&(m[f]=h[f]);if(d&&d.defaultProps)for(f in h=d.defaultProps,h)m[f]===void 0&&(m[f]=h[f]);return{$$typeof:t,type:d,key:y,ref:v,props:m,_owner:a.current}}return pl.Fragment=n,pl.jsx=c,pl.jsxs=c,pl}var Cb;function VR(){return Cb||(Cb=1,pf.exports=GR()),pf.exports}var i=VR(),wu={},gf={exports:{}},yn={},yf={exports:{}},wf={};/**
18
18
  * @license React
19
19
  * scheduler.production.min.js
20
20
  *
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */var Tb;function YR(){return Tb||(Tb=1,(function(e){function t(Z,D){var Y=Z.length;Z.push(D);e:for(;0<Y;){var P=Y-1>>>1,G=Z[P];if(0<a(G,D))Z[P]=D,Z[Y]=G,Y=P;else break e}}function n(Z){return Z.length===0?null:Z[0]}function s(Z){if(Z.length===0)return null;var D=Z[0],Y=Z.pop();if(Y!==D){Z[0]=Y;e:for(var P=0,G=Z.length,de=G>>>1;P<de;){var W=2*(P+1)-1,U=Z[W],J=W+1,V=Z[J];if(0>a(U,Y))J<G&&0>a(V,U)?(Z[P]=V,Z[J]=Y,P=J):(Z[P]=U,Z[W]=Y,P=W);else if(J<G&&0>a(V,Y))Z[P]=V,Z[J]=Y,P=J;else break e}}return D}function a(Z,D){var Y=Z.sortIndex-D.sortIndex;return Y!==0?Y:Z.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var h=[],p=[],f=1,m=null,y=3,v=!1,j=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(Z){for(var D=n(p);D!==null;){if(D.callback===null)s(p);else if(D.startTime<=Z)s(p),D.sortIndex=D.expirationTime,t(h,D);else break;D=n(p)}}function C(Z){if(_=!1,E(Z),!j)if(n(h)!==null)j=!0,K(R);else{var D=n(p);D!==null&&ee(C,D.startTime-Z)}}function R(Z,D){j=!1,_&&(_=!1,x(F),F=-1),v=!0;var Y=y;try{for(E(D),m=n(h);m!==null&&(!(m.expirationTime>D)||Z&&!L());){var P=m.callback;if(typeof P=="function"){m.callback=null,y=m.priorityLevel;var G=P(m.expirationTime<=D);D=e.unstable_now(),typeof G=="function"?m.callback=G:m===n(h)&&s(h),E(D)}else s(h);m=n(h)}if(m!==null)var de=!0;else{var W=n(p);W!==null&&ee(C,W.startTime-D),de=!1}return de}finally{m=null,y=Y,v=!1}}var I=!1,$=null,F=-1,O=5,M=-1;function L(){return!(e.unstable_now()-M<O)}function H(){if($!==null){var Z=e.unstable_now();M=Z;var D=!0;try{D=$(!0,Z)}finally{D?B():(I=!1,$=null)}}else I=!1}var B;if(typeof N=="function")B=function(){N(H)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,Q=A.port2;A.port1.onmessage=H,B=function(){Q.postMessage(null)}}else B=function(){S(H,0)};function K(Z){$=Z,I||(I=!0,B())}function ee(Z,D){F=S(function(){Z(e.unstable_now())},D)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){j||v||(j=!0,K(R))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(h)},e.unstable_next=function(Z){switch(y){case 1:case 2:case 3:var D=3;break;default:D=y}var Y=y;y=D;try{return Z()}finally{y=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,D){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var Y=y;y=Z;try{return D()}finally{y=Y}},e.unstable_scheduleCallback=function(Z,D,Y){var P=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?P+Y:P):Y=P,Z){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=Y+G,Z={id:f++,callback:D,priorityLevel:Z,startTime:Y,expirationTime:G,sortIndex:-1},Y>P?(Z.sortIndex=Y,t(p,Z),n(h)===null&&Z===n(p)&&(_?(x(F),F=-1):_=!0,ee(C,Y-P))):(Z.sortIndex=G,t(h,Z),j||v||(j=!0,K(R))),Z},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(Z){var D=y;return function(){var Y=y;y=D;try{return Z.apply(this,arguments)}finally{y=Y}}}})(yf)),yf}var Ab;function KR(){return Ab||(Ab=1,gf.exports=YR()),gf.exports}/**
25
+ */var Tb;function YR(){return Tb||(Tb=1,(function(e){function t(Z,D){var Y=Z.length;Z.push(D);e:for(;0<Y;){var P=Y-1>>>1,G=Z[P];if(0<a(G,D))Z[P]=D,Z[Y]=G,Y=P;else break e}}function n(Z){return Z.length===0?null:Z[0]}function s(Z){if(Z.length===0)return null;var D=Z[0],Y=Z.pop();if(Y!==D){Z[0]=Y;e:for(var P=0,G=Z.length,de=G>>>1;P<de;){var W=2*(P+1)-1,U=Z[W],J=W+1,V=Z[J];if(0>a(U,Y))J<G&&0>a(V,U)?(Z[P]=V,Z[J]=Y,P=J):(Z[P]=U,Z[W]=Y,P=W);else if(J<G&&0>a(V,Y))Z[P]=V,Z[J]=Y,P=J;else break e}}return D}function a(Z,D){var Y=Z.sortIndex-D.sortIndex;return Y!==0?Y:Z.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var h=[],p=[],f=1,m=null,y=3,v=!1,j=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(Z){for(var D=n(p);D!==null;){if(D.callback===null)s(p);else if(D.startTime<=Z)s(p),D.sortIndex=D.expirationTime,t(h,D);else break;D=n(p)}}function C(Z){if(_=!1,E(Z),!j)if(n(h)!==null)j=!0,K(R);else{var D=n(p);D!==null&&ee(C,D.startTime-Z)}}function R(Z,D){j=!1,_&&(_=!1,x(F),F=-1),v=!0;var Y=y;try{for(E(D),m=n(h);m!==null&&(!(m.expirationTime>D)||Z&&!L());){var P=m.callback;if(typeof P=="function"){m.callback=null,y=m.priorityLevel;var G=P(m.expirationTime<=D);D=e.unstable_now(),typeof G=="function"?m.callback=G:m===n(h)&&s(h),E(D)}else s(h);m=n(h)}if(m!==null)var de=!0;else{var W=n(p);W!==null&&ee(C,W.startTime-D),de=!1}return de}finally{m=null,y=Y,v=!1}}var I=!1,$=null,F=-1,O=5,M=-1;function L(){return!(e.unstable_now()-M<O)}function H(){if($!==null){var Z=e.unstable_now();M=Z;var D=!0;try{D=$(!0,Z)}finally{D?B():(I=!1,$=null)}}else I=!1}var B;if(typeof N=="function")B=function(){N(H)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,Q=A.port2;A.port1.onmessage=H,B=function(){Q.postMessage(null)}}else B=function(){S(H,0)};function K(Z){$=Z,I||(I=!0,B())}function ee(Z,D){F=S(function(){Z(e.unstable_now())},D)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Z){Z.callback=null},e.unstable_continueExecution=function(){j||v||(j=!0,K(R))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(h)},e.unstable_next=function(Z){switch(y){case 1:case 2:case 3:var D=3;break;default:D=y}var Y=y;y=D;try{return Z()}finally{y=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,D){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var Y=y;y=Z;try{return D()}finally{y=Y}},e.unstable_scheduleCallback=function(Z,D,Y){var P=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?P+Y:P):Y=P,Z){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=Y+G,Z={id:f++,callback:D,priorityLevel:Z,startTime:Y,expirationTime:G,sortIndex:-1},Y>P?(Z.sortIndex=Y,t(p,Z),n(h)===null&&Z===n(p)&&(_?(x(F),F=-1):_=!0,ee(C,Y-P))):(Z.sortIndex=G,t(h,Z),j||v||(j=!0,K(R))),Z},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(Z){var D=y;return function(){var Y=y;y=D;try{return Z.apply(this,arguments)}finally{y=Y}}}})(wf)),wf}var Ab;function KR(){return Ab||(Ab=1,yf.exports=YR()),yf.exports}/**
26
26
  * @license React
27
27
  * react-dom.production.min.js
28
28
  *
@@ -30,14 +30,14 @@
30
30
  *
31
31
  * This source code is licensed under the MIT license found in the
32
32
  * LICENSE file in the root directory of this source tree.
33
- */var Rb;function XR(){if(Rb)return yn;Rb=1;var e=Ul(),t=KR();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,u=1;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,a={};function l(r,o){c(r,o),c(r+"Capture",o)}function c(r,o){for(a[r]=o,r=0;r<o.length;r++)s.add(o[r])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[: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={},m={};function y(r){return h.call(m,r)?!0:h.call(f,r)?!1:p.test(r)?m[r]=!0:(f[r]=!0,!1)}function v(r,o,u,g){if(u!==null&&u.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return g?!1:u!==null?!u.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function j(r,o,u,g){if(o===null||typeof o>"u"||v(r,o,u,g))return!0;if(g)return!1;if(u!==null)switch(u.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function _(r,o,u,g,w,k,T){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=g,this.attributeNamespace=w,this.mustUseProperty=u,this.propertyName=r,this.type=o,this.sanitizeURL=k,this.removeEmptyString=T}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){S[r]=new _(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];S[o]=new _(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){S[r]=new _(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){S[r]=new _(r,2,!1,r,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(r){S[r]=new _(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){S[r]=new _(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){S[r]=new _(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){S[r]=new _(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){S[r]=new _(r,5,!1,r.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function N(r){return r[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(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){S[r]=new _(r,1,!1,r.toLowerCase(),null,!1,!1)}),S.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){S[r]=new _(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,o,u,g){var w=S.hasOwnProperty(o)?S[o]:null;(w!==null?w.type!==0:g||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(j(o,u,w,g)&&(u=null),g||w===null?y(o)&&(u===null?r.removeAttribute(o):r.setAttribute(o,""+u)):w.mustUseProperty?r[w.propertyName]=u===null?w.type===3?!1:"":u:(o=w.attributeName,g=w.attributeNamespace,u===null?r.removeAttribute(o):(w=w.type,u=w===3||w===4&&u===!0?"":""+u,g?r.setAttributeNS(g,o,u):r.setAttribute(o,u))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),I=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),L=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),Z=Symbol.iterator;function D(r){return r===null||typeof r!="object"?null:(r=Z&&r[Z]||r["@@iterator"],typeof r=="function"?r:null)}var Y=Object.assign,P;function G(r){if(P===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);P=o&&o[1]||""}return`
33
+ */var Rb;function XR(){if(Rb)return yn;Rb=1;var e=Wl(),t=KR();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,u=1;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,a={};function l(r,o){c(r,o),c(r+"Capture",o)}function c(r,o){for(a[r]=o,r=0;r<o.length;r++)s.add(o[r])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,p=/^[: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={},m={};function y(r){return h.call(m,r)?!0:h.call(f,r)?!1:p.test(r)?m[r]=!0:(f[r]=!0,!1)}function v(r,o,u,g){if(u!==null&&u.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return g?!1:u!==null?!u.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function j(r,o,u,g){if(o===null||typeof o>"u"||v(r,o,u,g))return!0;if(g)return!1;if(u!==null)switch(u.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function _(r,o,u,g,w,k,T){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=g,this.attributeNamespace=w,this.mustUseProperty=u,this.propertyName=r,this.type=o,this.sanitizeURL=k,this.removeEmptyString=T}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){S[r]=new _(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];S[o]=new _(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){S[r]=new _(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){S[r]=new _(r,2,!1,r,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(r){S[r]=new _(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){S[r]=new _(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){S[r]=new _(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){S[r]=new _(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){S[r]=new _(r,5,!1,r.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function N(r){return r[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(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(x,N);S[o]=new _(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){S[r]=new _(r,1,!1,r.toLowerCase(),null,!1,!1)}),S.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){S[r]=new _(r,1,!1,r.toLowerCase(),null,!0,!0)});function E(r,o,u,g){var w=S.hasOwnProperty(o)?S[o]:null;(w!==null?w.type!==0:g||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(j(o,u,w,g)&&(u=null),g||w===null?y(o)&&(u===null?r.removeAttribute(o):r.setAttribute(o,""+u)):w.mustUseProperty?r[w.propertyName]=u===null?w.type===3?!1:"":u:(o=w.attributeName,g=w.attributeNamespace,u===null?r.removeAttribute(o):(w=w.type,u=w===3||w===4&&u===!0?"":""+u,g?r.setAttributeNS(g,o,u):r.setAttribute(o,u))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),I=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),L=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),Z=Symbol.iterator;function D(r){return r===null||typeof r!="object"?null:(r=Z&&r[Z]||r["@@iterator"],typeof r=="function"?r:null)}var Y=Object.assign,P;function G(r){if(P===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);P=o&&o[1]||""}return`
34
34
  `+P+r}var de=!1;function W(r,o){if(!r||de)return"";de=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(ue){var g=ue}Reflect.construct(r,[],o)}else{try{o.call()}catch(ue){g=ue}r.call(o.prototype)}else{try{throw Error()}catch(ue){g=ue}r()}}catch(ue){if(ue&&g&&typeof ue.stack=="string"){for(var w=ue.stack.split(`
35
35
  `),k=g.stack.split(`
36
36
  `),T=w.length-1,X=k.length-1;1<=T&&0<=X&&w[T]!==k[X];)X--;for(;1<=T&&0<=X;T--,X--)if(w[T]!==k[X]){if(T!==1||X!==1)do if(T--,X--,0>X||w[T]!==k[X]){var te=`
37
- `+w[T].replace(" at new "," at ");return r.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",r.displayName)),te}while(1<=T&&0<=X);break}}}finally{de=!1,Error.prepareStackTrace=u}return(r=r?r.displayName||r.name:"")?G(r):""}function U(r){switch(r.tag){case 5:return G(r.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return r=W(r.type,!1),r;case 11:return r=W(r.type.render,!1),r;case 1:return r=W(r.type,!0),r;default:return""}}function J(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case $:return"Fragment";case I:return"Portal";case O:return"Profiler";case F:return"StrictMode";case B:return"Suspense";case A:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case L:return(r.displayName||"Context")+".Consumer";case M:return(r._context.displayName||"Context")+".Provider";case H:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Q:return o=r.displayName||null,o!==null?o:J(r.type)||"Memo";case K:o=r._payload,r=r._init;try{return J(r(o))}catch{}}return null}function V(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return J(o);case 8:return o===F?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ie(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function pe(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function me(r){var o=pe(r)?"checked":"value",u=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),g=""+r[o];if(!r.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var w=u.get,k=u.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return w.call(this)},set:function(T){g=""+T,k.call(this,T)}}),Object.defineProperty(r,o,{enumerable:u.enumerable}),{getValue:function(){return g},setValue:function(T){g=""+T},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Ie(r){r._valueTracker||(r._valueTracker=me(r))}function Le(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var u=o.getValue(),g="";return r&&(g=pe(r)?r.checked?"true":"false":r.value),r=g,r!==u?(o.setValue(r),!0):!1}function ce(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function xe(r,o){var u=o.checked;return Y({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??r._wrapperState.initialChecked})}function ye(r,o){var u=o.defaultValue==null?"":o.defaultValue,g=o.checked!=null?o.checked:o.defaultChecked;u=ie(o.value!=null?o.value:u),r._wrapperState={initialChecked:g,initialValue:u,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function ze(r,o){o=o.checked,o!=null&&E(r,"checked",o,!1)}function ke(r,o){ze(r,o);var u=ie(o.value),g=o.type;if(u!=null)g==="number"?(u===0&&r.value===""||r.value!=u)&&(r.value=""+u):r.value!==""+u&&(r.value=""+u);else if(g==="submit"||g==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?Ye(r,o.type,u):o.hasOwnProperty("defaultValue")&&Ye(r,o.type,ie(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function je(r,o,u){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var g=o.type;if(!(g!=="submit"&&g!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,u||o===r.value||(r.value=o),r.defaultValue=o}u=r.name,u!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,u!==""&&(r.name=u)}function Ye(r,o,u){(o!=="number"||ce(r.ownerDocument)!==r)&&(u==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+u&&(r.defaultValue=""+u))}var it=Array.isArray;function Ne(r,o,u,g){if(r=r.options,o){o={};for(var w=0;w<u.length;w++)o["$"+u[w]]=!0;for(u=0;u<r.length;u++)w=o.hasOwnProperty("$"+r[u].value),r[u].selected!==w&&(r[u].selected=w),w&&g&&(r[u].defaultSelected=!0)}else{for(u=""+ie(u),o=null,w=0;w<r.length;w++){if(r[w].value===u){r[w].selected=!0,g&&(r[w].defaultSelected=!0);return}o!==null||r[w].disabled||(o=r[w])}o!==null&&(o.selected=!0)}}function He(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return Y({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Xe(r,o){var u=o.value;if(u==null){if(u=o.children,o=o.defaultValue,u!=null){if(o!=null)throw Error(n(92));if(it(u)){if(1<u.length)throw Error(n(93));u=u[0]}o=u}o==null&&(o=""),u=o}r._wrapperState={initialValue:ie(u)}}function he(r,o){var u=ie(o.value),g=ie(o.defaultValue);u!=null&&(u=""+u,u!==r.value&&(r.value=u),o.defaultValue==null&&r.defaultValue!==u&&(r.defaultValue=u)),g!=null&&(r.defaultValue=""+g)}function ge(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function Se(r){switch(r){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 Fe(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?Se(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var et,xt=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,u,g,w){MSApp.execUnsafeLocalFunction(function(){return r(o,u,g,w)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(et=et||document.createElement("div"),et.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=et.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function ht(r,o){if(o){var u=r.firstChild;if(u&&u===r.lastChild&&u.nodeType===3){u.nodeValue=o;return}}r.textContent=o}var ne={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},De=["Webkit","ms","Moz","O"];Object.keys(ne).forEach(function(r){De.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),ne[o]=ne[r]})});function Oe(r,o,u){return o==null||typeof o=="boolean"||o===""?"":u||typeof o!="number"||o===0||ne.hasOwnProperty(r)&&ne[r]?(""+o).trim():o+"px"}function Te(r,o){r=r.style;for(var u in o)if(o.hasOwnProperty(u)){var g=u.indexOf("--")===0,w=Oe(u,o[u],g);u==="float"&&(u="cssFloat"),g?r.setProperty(u,w):r[u]=w}}var Ce=Y({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 lt(r,o){if(o){if(Ce[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function ut(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){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 Re=null;function mt(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var ft=null,bt=null,Xn=null;function Tn(r){if(r=Zi(r)){if(typeof ft!="function")throw Error(n(280));var o=r.stateNode;o&&(o=Rc(o),ft(r.stateNode,r.type,o))}}function ln(r){bt?Xn?Xn.push(r):Xn=[r]:bt=r}function eo(){if(bt){var r=bt,o=Xn;if(Xn=bt=null,Tn(r),o)for(r=0;r<o.length;r++)Tn(o[r])}}function us(r,o){return r(o)}function Or(){}var Qn=!1;function to(r,o,u){if(Qn)return r(o,u);Qn=!0;try{return us(r,o,u)}finally{Qn=!1,(bt!==null||Xn!==null)&&(Or(),eo())}}function Pr(r,o){var u=r.stateNode;if(u===null)return null;var g=Rc(u);if(g===null)return null;u=g[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(r=r.type,g=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!g;break e;default:r=!1}if(r)return null;if(u&&typeof u!="function")throw Error(n(231,o,typeof u));return u}var Qs=!1;if(d)try{var Lr={};Object.defineProperty(Lr,"passive",{get:function(){Qs=!0}}),window.addEventListener("test",Lr,Lr),window.removeEventListener("test",Lr,Lr)}catch{Qs=!1}function An(r,o,u,g,w,k,T,X,te){var ue=Array.prototype.slice.call(arguments,3);try{o.apply(u,ue)}catch(ve){this.onError(ve)}}var Dr=!1,ds=null,qt=!1,wr=null,Zs={onError:function(r){Dr=!0,ds=r}};function wi(r,o,u,g,w,k,T,X,te){Dr=!1,ds=null,An.apply(Zs,arguments)}function no(r,o,u,g,w,k,T,X,te){if(wi.apply(this,arguments),Dr){if(Dr){var ue=ds;Dr=!1,ds=null}else throw Error(n(198));qt||(qt=!0,wr=ue)}}function Rn(r){var o=r,u=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(u=o.return),r=o.return;while(r)}return o.tag===3?u:null}function Js(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function ea(r){if(Rn(r)!==r)throw Error(n(188))}function ta(r){var o=r.alternate;if(!o){if(o=Rn(r),o===null)throw Error(n(188));return o!==r?null:r}for(var u=r,g=o;;){var w=u.return;if(w===null)break;var k=w.alternate;if(k===null){if(g=w.return,g!==null){u=g;continue}break}if(w.child===k.child){for(k=w.child;k;){if(k===u)return ea(w),r;if(k===g)return ea(w),o;k=k.sibling}throw Error(n(188))}if(u.return!==g.return)u=w,g=k;else{for(var T=!1,X=w.child;X;){if(X===u){T=!0,u=w,g=k;break}if(X===g){T=!0,g=w,u=k;break}X=X.sibling}if(!T){for(X=k.child;X;){if(X===u){T=!0,u=k,g=w;break}if(X===g){T=!0,g=k,u=w;break}X=X.sibling}if(!T)throw Error(n(189))}}if(u.alternate!==g)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?r:o}function na(r){return r=ta(r),r!==null?ra(r):null}function ra(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=ra(r);if(o!==null)return o;r=r.sibling}return null}var sa=t.unstable_scheduleCallback,ro=t.unstable_cancelCallback,aa=t.unstable_shouldYield,vi=t.unstable_requestPaint,dt=t.unstable_now,so=t.unstable_getCurrentPriorityLevel,oa=t.unstable_ImmediatePriority,qr=t.unstable_UserBlockingPriority,Fr=t.unstable_NormalPriority,Br=t.unstable_LowPriority,ia=t.unstable_IdlePriority,zr=null,It=null;function la(r){if(It&&typeof It.onCommitFiberRoot=="function")try{It.onCommitFiberRoot(zr,r,void 0,(r.current.flags&128)===128)}catch{}}var cn=Math.clz32?Math.clz32:oc,ac=Math.log,Wd=Math.LN2;function oc(r){return r>>>=0,r===0?32:31-(ac(r)/Wd|0)|0}var vr=64,ao=4194304;function hs(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Xt(r,o){var u=r.pendingLanes;if(u===0)return 0;var g=0,w=r.suspendedLanes,k=r.pingedLanes,T=u&268435455;if(T!==0){var X=T&~w;X!==0?g=hs(X):(k&=T,k!==0&&(g=hs(k)))}else T=u&~w,T!==0?g=hs(T):k!==0&&(g=hs(k));if(g===0)return 0;if(o!==0&&o!==g&&(o&w)===0&&(w=g&-g,k=o&-o,w>=k||w===16&&(k&4194240)!==0))return o;if((g&4)!==0&&(g|=u&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=g;0<o;)u=31-cn(o),w=1<<u,g|=r[u],o&=~w;return g}function oo(r,o){switch(r){case 1:case 2:case 4:return o+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 o+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 Hd(r,o){for(var u=r.suspendedLanes,g=r.pingedLanes,w=r.expirationTimes,k=r.pendingLanes;0<k;){var T=31-cn(k),X=1<<T,te=w[T];te===-1?((X&u)===0||(X&g)!==0)&&(w[T]=oo(X,o)):te<=o&&(r.expiredLanes|=X),k&=~X}}function ca(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Et(){var r=vr;return vr<<=1,(vr&4194240)===0&&(vr=64),r}function xi(r){for(var o=[],u=0;31>u;u++)o.push(r);return o}function rn(r,o,u){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-cn(o),r[o]=u}function io(r,o){var u=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var g=r.eventTimes;for(r=r.expirationTimes;0<u;){var w=31-cn(u),k=1<<w;o[w]=0,g[w]=-1,r[w]=-1,u&=~k}}function lo(r,o){var u=r.entangledLanes|=o;for(r=r.entanglements;u;){var g=31-cn(u),w=1<<g;w&o|r[g]&o&&(r[g]|=o),u&=~w}}var at=0;function Zn(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var ua,bi,ic,ki,_i,xr=!1,da=[],Jn=null,xn=null,Mn=null,fs=new Map,ps=new Map,er=[],lc="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 Qt(r,o){switch(r){case"focusin":case"focusout":Jn=null;break;case"dragenter":case"dragleave":xn=null;break;case"mouseover":case"mouseout":Mn=null;break;case"pointerover":case"pointerout":fs.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":ps.delete(o.pointerId)}}function br(r,o,u,g,w,k){return r===null||r.nativeEvent!==k?(r={blockedOn:o,domEventName:u,eventSystemFlags:g,nativeEvent:k,targetContainers:[w]},o!==null&&(o=Zi(o),o!==null&&bi(o)),r):(r.eventSystemFlags|=g,o=r.targetContainers,w!==null&&o.indexOf(w)===-1&&o.push(w),r)}function co(r,o,u,g,w){switch(o){case"focusin":return Jn=br(Jn,r,o,u,g,w),!0;case"dragenter":return xn=br(xn,r,o,u,g,w),!0;case"mouseover":return Mn=br(Mn,r,o,u,g,w),!0;case"pointerover":var k=w.pointerId;return fs.set(k,br(fs.get(k)||null,r,o,u,g,w)),!0;case"gotpointercapture":return k=w.pointerId,ps.set(k,br(ps.get(k)||null,r,o,u,g,w)),!0}return!1}function uo(r){var o=Ta(r.target);if(o!==null){var u=Rn(o);if(u!==null){if(o=u.tag,o===13){if(o=Js(u),o!==null){r.blockedOn=o,_i(r.priority,function(){ic(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){r.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}r.blockedOn=null}function ho(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var u=Wr(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(u===null){u=r.nativeEvent;var g=new u.constructor(u.type,u);Re=g,u.target.dispatchEvent(g),Re=null}else return o=Zi(u),o!==null&&bi(o),r.blockedOn=u,!1;o.shift()}return!0}function ms(r,o,u){ho(r)&&u.delete(o)}function cc(){xr=!1,Jn!==null&&ho(Jn)&&(Jn=null),xn!==null&&ho(xn)&&(xn=null),Mn!==null&&ho(Mn)&&(Mn=null),fs.forEach(ms),ps.forEach(ms)}function un(r,o){r.blockedOn===o&&(r.blockedOn=null,xr||(xr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,cc)))}function ha(r){function o(w){return un(w,r)}if(0<da.length){un(da[0],r);for(var u=1;u<da.length;u++){var g=da[u];g.blockedOn===r&&(g.blockedOn=null)}}for(Jn!==null&&un(Jn,r),xn!==null&&un(xn,r),Mn!==null&&un(Mn,r),fs.forEach(o),ps.forEach(o),u=0;u<er.length;u++)g=er[u],g.blockedOn===r&&(g.blockedOn=null);for(;0<er.length&&(u=er[0],u.blockedOn===null);)uo(u),u.blockedOn===null&&er.shift()}var Ur=C.ReactCurrentBatchConfig,fo=!0;function Gd(r,o,u,g){var w=at,k=Ur.transition;Ur.transition=null;try{at=1,Ni(r,o,u,g)}finally{at=w,Ur.transition=k}}function uc(r,o,u,g){var w=at,k=Ur.transition;Ur.transition=null;try{at=4,Ni(r,o,u,g)}finally{at=w,Ur.transition=k}}function Ni(r,o,u,g){if(fo){var w=Wr(r,o,u,g);if(w===null)Xi(r,o,g,In,u),Qt(r,g);else if(co(w,r,o,u,g))g.stopPropagation();else if(Qt(r,g),o&4&&-1<lc.indexOf(r)){for(;w!==null;){var k=Zi(w);if(k!==null&&ua(k),k=Wr(r,o,u,g),k===null&&Xi(r,o,g,In,u),k===w)break;w=k}w!==null&&g.stopPropagation()}else Xi(r,o,g,null,u)}}var In=null;function Wr(r,o,u,g){if(In=null,r=mt(g),r=Ta(r),r!==null)if(o=Rn(r),o===null)r=null;else if(u=o.tag,u===13){if(r=Js(o),r!==null)return r;r=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return In=r,null}function Si(r){switch(r){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(so()){case oa:return 1;case qr:return 4;case Fr:case Br:return 16;case ia:return 536870912;default:return 16}default:return 16}}var $n=null,bn=null,po=null;function kn(){if(po)return po;var r,o=bn,u=o.length,g,w="value"in $n?$n.value:$n.textContent,k=w.length;for(r=0;r<u&&o[r]===w[r];r++);var T=u-r;for(g=1;g<=T&&o[u-g]===w[k-g];g++);return po=w.slice(r,1<g?1-g:void 0)}function gs(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function ys(){return!0}function ji(){return!1}function Ft(r){function o(u,g,w,k,T){this._reactName=u,this._targetInst=w,this.type=g,this.nativeEvent=k,this.target=T,this.currentTarget=null;for(var X in r)r.hasOwnProperty(X)&&(u=r[X],this[X]=u?u(k):k[X]);return this.isDefaultPrevented=(k.defaultPrevented!=null?k.defaultPrevented:k.returnValue===!1)?ys:ji,this.isPropagationStopped=ji,this}return Y(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=ys)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=ys)},persist:function(){},isPersistent:ys}),o}var kr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mo=Ft(kr),Hr=Y({},kr,{view:0,detail:0}),dc=Ft(Hr),fa,go,On,pa=Y({},Hr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ga,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==On&&(On&&r.type==="mousemove"?(fa=r.screenX-On.screenX,go=r.screenY-On.screenY):go=fa=0,On=r),fa)},movementY:function(r){return"movementY"in r?r.movementY:go}}),Ei=Ft(pa),Ci=Y({},pa,{dataTransfer:0}),Vd=Ft(Ci),Ti=Y({},Hr,{relatedTarget:0}),_r=Ft(Ti),hc=Y({},kr,{animationName:0,elapsedTime:0,pseudoElement:0}),Yd=Ft(hc),fc=Y({},kr,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),pc=Ft(fc),Kd=Y({},kr,{data:0}),sn=Ft(Kd),Xd={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ai={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"},ws={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ma(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=ws[r])?!!o[r]:!1}function ga(){return ma}var Ri=Y({},Hr,{key:function(r){if(r.key){var o=Xd[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=gs(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Ai[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ga,charCode:function(r){return r.type==="keypress"?gs(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?gs(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),mc=Ft(Ri),yo=Y({},pa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Mi=Ft(yo),Qd=Y({},Hr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ga}),Zd=Ft(Qd),gc=Y({},kr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Jd=Ft(gc),eh=Y({},pa,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Ii=Ft(eh),Nr=[9,13,27,32],ya=d&&"CompositionEvent"in window,vs=null;d&&"documentMode"in document&&(vs=document.documentMode);var th=d&&"TextEvent"in window&&!vs,yc=d&&(!ya||vs&&8<vs&&11>=vs),$i=" ",wc=!1;function vc(r,o){switch(r){case"keyup":return Nr.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Oi(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Gr=!1;function Sr(r,o){switch(r){case"compositionend":return Oi(o);case"keypress":return o.which!==32?null:(wc=!0,$i);case"textInput":return r=o.data,r===$i&&wc?null:r;default:return null}}function nh(r,o){if(Gr)return r==="compositionend"||!ya&&vc(r,o)?(r=kn(),po=bn=$n=null,Gr=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return yc&&o.locale!=="ko"?null:o.data;default:return null}}var xc={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 bc(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!xc[r.type]:o==="textarea"}function wa(r,o,u,g){ln(g),o=js(o,"onChange"),0<o.length&&(u=new mo("onChange","change",null,u,g),r.push({event:u,listeners:o}))}var va=null,$t=null;function Pi(r){ot(r,0)}function xa(r){var o=_o(r);if(Le(o))return r}function kc(r,o){if(r==="change")return o}var Li=!1;if(d){var ba;if(d){var xs="oninput"in document;if(!xs){var wo=document.createElement("div");wo.setAttribute("oninput","return;"),xs=typeof wo.oninput=="function"}ba=xs}else ba=!1;Li=ba&&(!document.documentMode||9<document.documentMode)}function Di(){va&&(va.detachEvent("onpropertychange",ka),$t=va=null)}function ka(r){if(r.propertyName==="value"&&xa($t)){var o=[];wa(o,$t,r,mt(r)),to(Pi,o)}}function _c(r,o,u){r==="focusin"?(Di(),va=o,$t=u,va.attachEvent("onpropertychange",ka)):r==="focusout"&&Di()}function qi(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return xa($t)}function Fi(r,o){if(r==="click")return xa(o)}function Nc(r,o){if(r==="input"||r==="change")return xa(o)}function Zt(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var dn=typeof Object.is=="function"?Object.is:Zt;function bs(r,o){if(dn(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var u=Object.keys(r),g=Object.keys(o);if(u.length!==g.length)return!1;for(g=0;g<u.length;g++){var w=u[g];if(!h.call(o,w)||!dn(r[w],o[w]))return!1}return!0}function Sc(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function jc(r,o){var u=Sc(r);r=0;for(var g;u;){if(u.nodeType===3){if(g=r+u.textContent.length,r<=o&&g>=o)return{node:u,offset:o-r};r=g}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Sc(u)}}function Bi(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?Bi(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function _a(){for(var r=window,o=ce();o instanceof r.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)r=o.contentWindow;else break;o=ce(r.document)}return o}function zi(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function Vr(r){var o=_a(),u=r.focusedElem,g=r.selectionRange;if(o!==u&&u&&u.ownerDocument&&Bi(u.ownerDocument.documentElement,u)){if(g!==null&&zi(u)){if(o=g.start,r=g.end,r===void 0&&(r=o),"selectionStart"in u)u.selectionStart=o,u.selectionEnd=Math.min(r,u.value.length);else if(r=(o=u.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var w=u.textContent.length,k=Math.min(g.start,w);g=g.end===void 0?k:Math.min(g.end,w),!r.extend&&k>g&&(w=g,g=k,k=w),w=jc(u,k);var T=jc(u,g);w&&T&&(r.rangeCount!==1||r.anchorNode!==w.node||r.anchorOffset!==w.offset||r.focusNode!==T.node||r.focusOffset!==T.offset)&&(o=o.createRange(),o.setStart(w.node,w.offset),r.removeAllRanges(),k>g?(r.addRange(o),r.extend(T.node,T.offset)):(o.setEnd(T.node,T.offset),r.addRange(o)))}}for(o=[],r=u;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u<o.length;u++)r=o[u],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var Ui=d&&"documentMode"in document&&11>=document.documentMode,tr=null,Na=null,Sa=null,vo=!1;function Wi(r,o,u){var g=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;vo||tr==null||tr!==ce(g)||(g=tr,"selectionStart"in g&&zi(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Sa&&bs(Sa,g)||(Sa=g,g=js(Na,"onSelect"),0<g.length&&(o=new mo("onSelect","select",null,o,u),r.push({event:o,listeners:g}),o.target=tr)))}function xo(r,o){var u={};return u[r.toLowerCase()]=o.toLowerCase(),u["Webkit"+r]="webkit"+o,u["Moz"+r]="moz"+o,u}var ks={animationend:xo("Animation","AnimationEnd"),animationiteration:xo("Animation","AnimationIteration"),animationstart:xo("Animation","AnimationStart"),transitionend:xo("Transition","TransitionEnd")},bo={},ja={};d&&(ja=document.createElement("div").style,"AnimationEvent"in window||(delete ks.animationend.animation,delete ks.animationiteration.animation,delete ks.animationstart.animation),"TransitionEvent"in window||delete ks.transitionend.transition);function _s(r){if(bo[r])return bo[r];if(!ks[r])return r;var o=ks[r],u;for(u in o)if(o.hasOwnProperty(u)&&u in ja)return bo[r]=o[u];return r}var Ec=_s("animationend"),Hi=_s("animationiteration"),Gi=_s("animationstart"),Vi=_s("transitionend"),Yi=new Map,q="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 z(r,o){Yi.set(r,o),l(o,[r])}for(var se=0;se<q.length;se++){var oe=q[se],Ee=oe.toLowerCase(),Me=oe[0].toUpperCase()+oe.slice(1);z(Ee,"on"+Me)}z(Ec,"onAnimationEnd"),z(Hi,"onAnimationIteration"),z(Gi,"onAnimationStart"),z("dblclick","onDoubleClick"),z("focusin","onFocus"),z("focusout","onBlur"),z(Vi,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var We="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(" "),rt=new Set("cancel close invalid load scroll toggle".split(" ").concat(We));function gt(r,o,u){var g=r.type||"unknown-event";r.currentTarget=u,no(g,o,void 0,r),r.currentTarget=null}function ot(r,o){o=(o&4)!==0;for(var u=0;u<r.length;u++){var g=r[u],w=g.event;g=g.listeners;e:{var k=void 0;if(o)for(var T=g.length-1;0<=T;T--){var X=g[T],te=X.instance,ue=X.currentTarget;if(X=X.listener,te!==k&&w.isPropagationStopped())break e;gt(w,X,ue),k=te}else for(T=0;T<g.length;T++){if(X=g[T],te=X.instance,ue=X.currentTarget,X=X.listener,te!==k&&w.isPropagationStopped())break e;gt(w,X,ue),k=te}}}if(qt)throw r=wr,qt=!1,wr=null,r}function Qe(r,o){var u=o[lh];u===void 0&&(u=o[lh]=new Set);var g=r+"__bubble";u.has(g)||(Ki(o,r,2,!1),u.add(g))}function Ns(r,o,u){var g=0;o&&(g|=4),Ki(u,r,g,o)}var Ea="_reactListening"+Math.random().toString(36).slice(2);function Ca(r){if(!r[Ea]){r[Ea]=!0,s.forEach(function(u){u!=="selectionchange"&&(rt.has(u)||Ns(u,!1,r),Ns(u,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Ea]||(o[Ea]=!0,Ns("selectionchange",!1,o))}}function Ki(r,o,u,g){switch(Si(o)){case 1:var w=Gd;break;case 4:w=uc;break;default:w=Ni}u=w.bind(null,o,u,r),w=void 0,!Qs||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(w=!0),g?w!==void 0?r.addEventListener(o,u,{capture:!0,passive:w}):r.addEventListener(o,u,!0):w!==void 0?r.addEventListener(o,u,{passive:w}):r.addEventListener(o,u,!1)}function Xi(r,o,u,g,w){var k=g;if((o&1)===0&&(o&2)===0&&g!==null)e:for(;;){if(g===null)return;var T=g.tag;if(T===3||T===4){var X=g.stateNode.containerInfo;if(X===w||X.nodeType===8&&X.parentNode===w)break;if(T===4)for(T=g.return;T!==null;){var te=T.tag;if((te===3||te===4)&&(te=T.stateNode.containerInfo,te===w||te.nodeType===8&&te.parentNode===w))return;T=T.return}for(;X!==null;){if(T=Ta(X),T===null)return;if(te=T.tag,te===5||te===6){g=k=T;continue e}X=X.parentNode}}g=g.return}to(function(){var ue=k,ve=mt(u),be=[];e:{var we=Yi.get(r);if(we!==void 0){var Ae=mo,Pe=r;switch(r){case"keypress":if(gs(u)===0)break e;case"keydown":case"keyup":Ae=mc;break;case"focusin":Pe="focus",Ae=_r;break;case"focusout":Pe="blur",Ae=_r;break;case"beforeblur":case"afterblur":Ae=_r;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ae=Ei;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ae=Vd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ae=Zd;break;case Ec:case Hi:case Gi:Ae=Yd;break;case Vi:Ae=Jd;break;case"scroll":Ae=dc;break;case"wheel":Ae=Ii;break;case"copy":case"cut":case"paste":Ae=pc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ae=Mi}var qe=(o&4)!==0,jt=!qe&&r==="scroll",ae=qe?we!==null?we+"Capture":null:we;qe=[];for(var re=ue,le;re!==null;){le=re;var _e=le.stateNode;if(le.tag===5&&_e!==null&&(le=_e,ae!==null&&(_e=Pr(re,ae),_e!=null&&qe.push(Ss(re,_e,le)))),jt)break;re=re.return}0<qe.length&&(we=new Ae(we,Pe,null,u,ve),be.push({event:we,listeners:qe}))}}if((o&7)===0){e:{if(we=r==="mouseover"||r==="pointerover",Ae=r==="mouseout"||r==="pointerout",we&&u!==Re&&(Pe=u.relatedTarget||u.fromElement)&&(Ta(Pe)||Pe[Yr]))break e;if((Ae||we)&&(we=ve.window===ve?ve:(we=ve.ownerDocument)?we.defaultView||we.parentWindow:window,Ae?(Pe=u.relatedTarget||u.toElement,Ae=ue,Pe=Pe?Ta(Pe):null,Pe!==null&&(jt=Rn(Pe),Pe!==jt||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(Ae=null,Pe=ue),Ae!==Pe)){if(qe=Ei,_e="onMouseLeave",ae="onMouseEnter",re="mouse",(r==="pointerout"||r==="pointerover")&&(qe=Mi,_e="onPointerLeave",ae="onPointerEnter",re="pointer"),jt=Ae==null?we:_o(Ae),le=Pe==null?we:_o(Pe),we=new qe(_e,re+"leave",Ae,u,ve),we.target=jt,we.relatedTarget=le,_e=null,Ta(ve)===ue&&(qe=new qe(ae,re+"enter",Pe,u,ve),qe.target=le,qe.relatedTarget=jt,_e=qe),jt=_e,Ae&&Pe)t:{for(qe=Ae,ae=Pe,re=0,le=qe;le;le=Pn(le))re++;for(le=0,_e=ae;_e;_e=Pn(_e))le++;for(;0<re-le;)qe=Pn(qe),re--;for(;0<le-re;)ae=Pn(ae),le--;for(;re--;){if(qe===ae||ae!==null&&qe===ae.alternate)break t;qe=Pn(qe),ae=Pn(ae)}qe=null}else qe=null;Ae!==null&&Es(be,we,Ae,qe,!1),Pe!==null&&jt!==null&&Es(be,jt,Pe,qe,!0)}}e:{if(we=ue?_o(ue):window,Ae=we.nodeName&&we.nodeName.toLowerCase(),Ae==="select"||Ae==="input"&&we.type==="file")var Be=kc;else if(bc(we))if(Li)Be=Nc;else{Be=qi;var Ge=_c}else(Ae=we.nodeName)&&Ae.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Be=Fi);if(Be&&(Be=Be(r,ue))){wa(be,Be,u,ve);break e}Ge&&Ge(r,we,ue),r==="focusout"&&(Ge=we._wrapperState)&&Ge.controlled&&we.type==="number"&&Ye(we,"number",we.value)}switch(Ge=ue?_o(ue):window,r){case"focusin":(bc(Ge)||Ge.contentEditable==="true")&&(tr=Ge,Na=ue,Sa=null);break;case"focusout":Sa=Na=tr=null;break;case"mousedown":vo=!0;break;case"contextmenu":case"mouseup":case"dragend":vo=!1,Wi(be,u,ve);break;case"selectionchange":if(Ui)break;case"keydown":case"keyup":Wi(be,u,ve)}var Ve;if(ya)e:{switch(r){case"compositionstart":var Ke="onCompositionStart";break e;case"compositionend":Ke="onCompositionEnd";break e;case"compositionupdate":Ke="onCompositionUpdate";break e}Ke=void 0}else Gr?vc(r,u)&&(Ke="onCompositionEnd"):r==="keydown"&&u.keyCode===229&&(Ke="onCompositionStart");Ke&&(yc&&u.locale!=="ko"&&(Gr||Ke!=="onCompositionStart"?Ke==="onCompositionEnd"&&Gr&&(Ve=kn()):($n=ve,bn="value"in $n?$n.value:$n.textContent,Gr=!0)),Ge=js(ue,Ke),0<Ge.length&&(Ke=new sn(Ke,r,null,u,ve),be.push({event:Ke,listeners:Ge}),Ve?Ke.data=Ve:(Ve=Oi(u),Ve!==null&&(Ke.data=Ve)))),(Ve=th?Sr(r,u):nh(r,u))&&(ue=js(ue,"onBeforeInput"),0<ue.length&&(ve=new sn("onBeforeInput","beforeinput",null,u,ve),be.push({event:ve,listeners:ue}),ve.data=Ve))}ot(be,o)})}function Ss(r,o,u){return{instance:r,listener:o,currentTarget:u}}function js(r,o){for(var u=o+"Capture",g=[];r!==null;){var w=r,k=w.stateNode;w.tag===5&&k!==null&&(w=k,k=Pr(r,u),k!=null&&g.unshift(Ss(r,k,w)),k=Pr(r,o),k!=null&&g.push(Ss(r,k,w))),r=r.return}return g}function Pn(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Es(r,o,u,g,w){for(var k=o._reactName,T=[];u!==null&&u!==g;){var X=u,te=X.alternate,ue=X.stateNode;if(te!==null&&te===g)break;X.tag===5&&ue!==null&&(X=ue,w?(te=Pr(u,k),te!=null&&T.unshift(Ss(u,te,X))):w||(te=Pr(u,k),te!=null&&T.push(Ss(u,te,X)))),u=u.return}T.length!==0&&r.push({event:o,listeners:T})}var Ct=/\r\n?/g,Cc=/\u0000|\uFFFD/g;function Wx(r){return(typeof r=="string"?r:""+r).replace(Ct,`
38
- `).replace(Cc,"")}function Tc(r,o,u){if(o=Wx(o),Wx(r)!==o&&u)throw Error(n(425))}function Ac(){}var rh=null,sh=null;function ah(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var oh=typeof setTimeout=="function"?setTimeout:void 0,aR=typeof clearTimeout=="function"?clearTimeout:void 0,Hx=typeof Promise=="function"?Promise:void 0,oR=typeof queueMicrotask=="function"?queueMicrotask:typeof Hx<"u"?function(r){return Hx.resolve(null).then(r).catch(iR)}:oh;function iR(r){setTimeout(function(){throw r})}function ih(r,o){var u=o,g=0;do{var w=u.nextSibling;if(r.removeChild(u),w&&w.nodeType===8)if(u=w.data,u==="/$"){if(g===0){r.removeChild(w),ha(o);return}g--}else u!=="$"&&u!=="$?"&&u!=="$!"||g++;u=w}while(u);ha(o)}function Cs(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function Gx(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="$"||u==="$!"||u==="$?"){if(o===0)return r;o--}else u==="/$"&&o++}r=r.previousSibling}return null}var ko=Math.random().toString(36).slice(2),jr="__reactFiber$"+ko,Qi="__reactProps$"+ko,Yr="__reactContainer$"+ko,lh="__reactEvents$"+ko,lR="__reactListeners$"+ko,cR="__reactHandles$"+ko;function Ta(r){var o=r[jr];if(o)return o;for(var u=r.parentNode;u;){if(o=u[Yr]||u[jr]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(r=Gx(r);r!==null;){if(u=r[jr])return u;r=Gx(r)}return o}r=u,u=r.parentNode}return null}function Zi(r){return r=r[jr]||r[Yr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function _o(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function Rc(r){return r[Qi]||null}var ch=[],No=-1;function Ts(r){return{current:r}}function yt(r){0>No||(r.current=ch[No],ch[No]=null,No--)}function pt(r,o){No++,ch[No]=r.current,r.current=o}var As={},Jt=Ts(As),hn=Ts(!1),Aa=As;function So(r,o){var u=r.type.contextTypes;if(!u)return As;var g=r.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===o)return g.__reactInternalMemoizedMaskedChildContext;var w={},k;for(k in u)w[k]=o[k];return g&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=w),w}function fn(r){return r=r.childContextTypes,r!=null}function Mc(){yt(hn),yt(Jt)}function Vx(r,o,u){if(Jt.current!==As)throw Error(n(168));pt(Jt,o),pt(hn,u)}function Yx(r,o,u){var g=r.stateNode;if(o=o.childContextTypes,typeof g.getChildContext!="function")return u;g=g.getChildContext();for(var w in g)if(!(w in o))throw Error(n(108,V(r)||"Unknown",w));return Y({},u,g)}function Ic(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||As,Aa=Jt.current,pt(Jt,r),pt(hn,hn.current),!0}function Kx(r,o,u){var g=r.stateNode;if(!g)throw Error(n(169));u?(r=Yx(r,o,Aa),g.__reactInternalMemoizedMergedChildContext=r,yt(hn),yt(Jt),pt(Jt,r)):yt(hn),pt(hn,u)}var Kr=null,$c=!1,uh=!1;function Xx(r){Kr===null?Kr=[r]:Kr.push(r)}function uR(r){$c=!0,Xx(r)}function Rs(){if(!uh&&Kr!==null){uh=!0;var r=0,o=at;try{var u=Kr;for(at=1;r<u.length;r++){var g=u[r];do g=g(!0);while(g!==null)}Kr=null,$c=!1}catch(w){throw Kr!==null&&(Kr=Kr.slice(r+1)),sa(oa,Rs),w}finally{at=o,uh=!1}}return null}var jo=[],Eo=0,Oc=null,Pc=0,Ln=[],Dn=0,Ra=null,Xr=1,Qr="";function Ma(r,o){jo[Eo++]=Pc,jo[Eo++]=Oc,Oc=r,Pc=o}function Qx(r,o,u){Ln[Dn++]=Xr,Ln[Dn++]=Qr,Ln[Dn++]=Ra,Ra=r;var g=Xr;r=Qr;var w=32-cn(g)-1;g&=~(1<<w),u+=1;var k=32-cn(o)+w;if(30<k){var T=w-w%5;k=(g&(1<<T)-1).toString(32),g>>=T,w-=T,Xr=1<<32-cn(o)+w|u<<w|g,Qr=k+r}else Xr=1<<k|u<<w|g,Qr=r}function dh(r){r.return!==null&&(Ma(r,1),Qx(r,1,0))}function hh(r){for(;r===Oc;)Oc=jo[--Eo],jo[Eo]=null,Pc=jo[--Eo],jo[Eo]=null;for(;r===Ra;)Ra=Ln[--Dn],Ln[Dn]=null,Qr=Ln[--Dn],Ln[Dn]=null,Xr=Ln[--Dn],Ln[Dn]=null}var _n=null,Nn=null,wt=!1,nr=null;function Zx(r,o){var u=zn(5,null,null,0);u.elementType="DELETED",u.stateNode=o,u.return=r,o=r.deletions,o===null?(r.deletions=[u],r.flags|=16):o.push(u)}function Jx(r,o){switch(r.tag){case 5:var u=r.type;return o=o.nodeType!==1||u.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,_n=r,Nn=Cs(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,_n=r,Nn=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(u=Ra!==null?{id:Xr,overflow:Qr}:null,r.memoizedState={dehydrated:o,treeContext:u,retryLane:1073741824},u=zn(18,null,null,0),u.stateNode=o,u.return=r,r.child=u,_n=r,Nn=null,!0):!1;default:return!1}}function fh(r){return(r.mode&1)!==0&&(r.flags&128)===0}function ph(r){if(wt){var o=Nn;if(o){var u=o;if(!Jx(r,o)){if(fh(r))throw Error(n(418));o=Cs(u.nextSibling);var g=_n;o&&Jx(r,o)?Zx(g,u):(r.flags=r.flags&-4097|2,wt=!1,_n=r)}}else{if(fh(r))throw Error(n(418));r.flags=r.flags&-4097|2,wt=!1,_n=r}}}function e0(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;_n=r}function Lc(r){if(r!==_n)return!1;if(!wt)return e0(r),wt=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!ah(r.type,r.memoizedProps)),o&&(o=Nn)){if(fh(r))throw t0(),Error(n(418));for(;o;)Zx(r,o),o=Cs(o.nextSibling)}if(e0(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="/$"){if(o===0){Nn=Cs(r.nextSibling);break e}o--}else u!=="$"&&u!=="$!"&&u!=="$?"||o++}r=r.nextSibling}Nn=null}}else Nn=_n?Cs(r.stateNode.nextSibling):null;return!0}function t0(){for(var r=Nn;r;)r=Cs(r.nextSibling)}function Co(){Nn=_n=null,wt=!1}function mh(r){nr===null?nr=[r]:nr.push(r)}var dR=C.ReactCurrentBatchConfig;function Ji(r,o,u){if(r=u.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(u._owner){if(u=u._owner,u){if(u.tag!==1)throw Error(n(309));var g=u.stateNode}if(!g)throw Error(n(147,r));var w=g,k=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===k?o.ref:(o=function(T){var X=w.refs;T===null?delete X[k]:X[k]=T},o._stringRef=k,o)}if(typeof r!="string")throw Error(n(284));if(!u._owner)throw Error(n(290,r))}return r}function Dc(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function n0(r){var o=r._init;return o(r._payload)}function r0(r){function o(ae,re){if(r){var le=ae.deletions;le===null?(ae.deletions=[re],ae.flags|=16):le.push(re)}}function u(ae,re){if(!r)return null;for(;re!==null;)o(ae,re),re=re.sibling;return null}function g(ae,re){for(ae=new Map;re!==null;)re.key!==null?ae.set(re.key,re):ae.set(re.index,re),re=re.sibling;return ae}function w(ae,re){return ae=qs(ae,re),ae.index=0,ae.sibling=null,ae}function k(ae,re,le){return ae.index=le,r?(le=ae.alternate,le!==null?(le=le.index,le<re?(ae.flags|=2,re):le):(ae.flags|=2,re)):(ae.flags|=1048576,re)}function T(ae){return r&&ae.alternate===null&&(ae.flags|=2),ae}function X(ae,re,le,_e){return re===null||re.tag!==6?(re=of(le,ae.mode,_e),re.return=ae,re):(re=w(re,le),re.return=ae,re)}function te(ae,re,le,_e){var Be=le.type;return Be===$?ve(ae,re,le.props.children,_e,le.key):re!==null&&(re.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===K&&n0(Be)===re.type)?(_e=w(re,le.props),_e.ref=Ji(ae,re,le),_e.return=ae,_e):(_e=lu(le.type,le.key,le.props,null,ae.mode,_e),_e.ref=Ji(ae,re,le),_e.return=ae,_e)}function ue(ae,re,le,_e){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=lf(le,ae.mode,_e),re.return=ae,re):(re=w(re,le.children||[]),re.return=ae,re)}function ve(ae,re,le,_e,Be){return re===null||re.tag!==7?(re=Fa(le,ae.mode,_e,Be),re.return=ae,re):(re=w(re,le),re.return=ae,re)}function be(ae,re,le){if(typeof re=="string"&&re!==""||typeof re=="number")return re=of(""+re,ae.mode,le),re.return=ae,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case R:return le=lu(re.type,re.key,re.props,null,ae.mode,le),le.ref=Ji(ae,null,re),le.return=ae,le;case I:return re=lf(re,ae.mode,le),re.return=ae,re;case K:var _e=re._init;return be(ae,_e(re._payload),le)}if(it(re)||D(re))return re=Fa(re,ae.mode,le,null),re.return=ae,re;Dc(ae,re)}return null}function we(ae,re,le,_e){var Be=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Be!==null?null:X(ae,re,""+le,_e);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case R:return le.key===Be?te(ae,re,le,_e):null;case I:return le.key===Be?ue(ae,re,le,_e):null;case K:return Be=le._init,we(ae,re,Be(le._payload),_e)}if(it(le)||D(le))return Be!==null?null:ve(ae,re,le,_e,null);Dc(ae,le)}return null}function Ae(ae,re,le,_e,Be){if(typeof _e=="string"&&_e!==""||typeof _e=="number")return ae=ae.get(le)||null,X(re,ae,""+_e,Be);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case R:return ae=ae.get(_e.key===null?le:_e.key)||null,te(re,ae,_e,Be);case I:return ae=ae.get(_e.key===null?le:_e.key)||null,ue(re,ae,_e,Be);case K:var Ge=_e._init;return Ae(ae,re,le,Ge(_e._payload),Be)}if(it(_e)||D(_e))return ae=ae.get(le)||null,ve(re,ae,_e,Be,null);Dc(re,_e)}return null}function Pe(ae,re,le,_e){for(var Be=null,Ge=null,Ve=re,Ke=re=0,Ut=null;Ve!==null&&Ke<le.length;Ke++){Ve.index>Ke?(Ut=Ve,Ve=null):Ut=Ve.sibling;var st=we(ae,Ve,le[Ke],_e);if(st===null){Ve===null&&(Ve=Ut);break}r&&Ve&&st.alternate===null&&o(ae,Ve),re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st,Ve=Ut}if(Ke===le.length)return u(ae,Ve),wt&&Ma(ae,Ke),Be;if(Ve===null){for(;Ke<le.length;Ke++)Ve=be(ae,le[Ke],_e),Ve!==null&&(re=k(Ve,re,Ke),Ge===null?Be=Ve:Ge.sibling=Ve,Ge=Ve);return wt&&Ma(ae,Ke),Be}for(Ve=g(ae,Ve);Ke<le.length;Ke++)Ut=Ae(Ve,ae,Ke,le[Ke],_e),Ut!==null&&(r&&Ut.alternate!==null&&Ve.delete(Ut.key===null?Ke:Ut.key),re=k(Ut,re,Ke),Ge===null?Be=Ut:Ge.sibling=Ut,Ge=Ut);return r&&Ve.forEach(function(Fs){return o(ae,Fs)}),wt&&Ma(ae,Ke),Be}function qe(ae,re,le,_e){var Be=D(le);if(typeof Be!="function")throw Error(n(150));if(le=Be.call(le),le==null)throw Error(n(151));for(var Ge=Be=null,Ve=re,Ke=re=0,Ut=null,st=le.next();Ve!==null&&!st.done;Ke++,st=le.next()){Ve.index>Ke?(Ut=Ve,Ve=null):Ut=Ve.sibling;var Fs=we(ae,Ve,st.value,_e);if(Fs===null){Ve===null&&(Ve=Ut);break}r&&Ve&&Fs.alternate===null&&o(ae,Ve),re=k(Fs,re,Ke),Ge===null?Be=Fs:Ge.sibling=Fs,Ge=Fs,Ve=Ut}if(st.done)return u(ae,Ve),wt&&Ma(ae,Ke),Be;if(Ve===null){for(;!st.done;Ke++,st=le.next())st=be(ae,st.value,_e),st!==null&&(re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st);return wt&&Ma(ae,Ke),Be}for(Ve=g(ae,Ve);!st.done;Ke++,st=le.next())st=Ae(Ve,ae,Ke,st.value,_e),st!==null&&(r&&st.alternate!==null&&Ve.delete(st.key===null?Ke:st.key),re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st);return r&&Ve.forEach(function(WR){return o(ae,WR)}),wt&&Ma(ae,Ke),Be}function jt(ae,re,le,_e){if(typeof le=="object"&&le!==null&&le.type===$&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case R:e:{for(var Be=le.key,Ge=re;Ge!==null;){if(Ge.key===Be){if(Be=le.type,Be===$){if(Ge.tag===7){u(ae,Ge.sibling),re=w(Ge,le.props.children),re.return=ae,ae=re;break e}}else if(Ge.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===K&&n0(Be)===Ge.type){u(ae,Ge.sibling),re=w(Ge,le.props),re.ref=Ji(ae,Ge,le),re.return=ae,ae=re;break e}u(ae,Ge);break}else o(ae,Ge);Ge=Ge.sibling}le.type===$?(re=Fa(le.props.children,ae.mode,_e,le.key),re.return=ae,ae=re):(_e=lu(le.type,le.key,le.props,null,ae.mode,_e),_e.ref=Ji(ae,re,le),_e.return=ae,ae=_e)}return T(ae);case I:e:{for(Ge=le.key;re!==null;){if(re.key===Ge)if(re.tag===4&&re.stateNode.containerInfo===le.containerInfo&&re.stateNode.implementation===le.implementation){u(ae,re.sibling),re=w(re,le.children||[]),re.return=ae,ae=re;break e}else{u(ae,re);break}else o(ae,re);re=re.sibling}re=lf(le,ae.mode,_e),re.return=ae,ae=re}return T(ae);case K:return Ge=le._init,jt(ae,re,Ge(le._payload),_e)}if(it(le))return Pe(ae,re,le,_e);if(D(le))return qe(ae,re,le,_e);Dc(ae,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,re!==null&&re.tag===6?(u(ae,re.sibling),re=w(re,le),re.return=ae,ae=re):(u(ae,re),re=of(le,ae.mode,_e),re.return=ae,ae=re),T(ae)):u(ae,re)}return jt}var To=r0(!0),s0=r0(!1),qc=Ts(null),Fc=null,Ao=null,gh=null;function yh(){gh=Ao=Fc=null}function wh(r){var o=qc.current;yt(qc),r._currentValue=o}function vh(r,o,u){for(;r!==null;){var g=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,g!==null&&(g.childLanes|=o)):g!==null&&(g.childLanes&o)!==o&&(g.childLanes|=o),r===u)break;r=r.return}}function Ro(r,o){Fc=r,gh=Ao=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(pn=!0),r.firstContext=null)}function qn(r){var o=r._currentValue;if(gh!==r)if(r={context:r,memoizedValue:o,next:null},Ao===null){if(Fc===null)throw Error(n(308));Ao=r,Fc.dependencies={lanes:0,firstContext:r}}else Ao=Ao.next=r;return o}var Ia=null;function xh(r){Ia===null?Ia=[r]:Ia.push(r)}function a0(r,o,u,g){var w=o.interleaved;return w===null?(u.next=u,xh(o)):(u.next=w.next,w.next=u),o.interleaved=u,Zr(r,g)}function Zr(r,o){r.lanes|=o;var u=r.alternate;for(u!==null&&(u.lanes|=o),u=r,r=r.return;r!==null;)r.childLanes|=o,u=r.alternate,u!==null&&(u.childLanes|=o),u=r,r=r.return;return u.tag===3?u.stateNode:null}var Ms=!1;function bh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function o0(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Jr(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function Is(r,o,u){var g=r.updateQueue;if(g===null)return null;if(g=g.shared,(nt&2)!==0){var w=g.pending;return w===null?o.next=o:(o.next=w.next,w.next=o),g.pending=o,Zr(r,u)}return w=g.interleaved,w===null?(o.next=o,xh(g)):(o.next=w.next,w.next=o),g.interleaved=o,Zr(r,u)}function Bc(r,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194240)!==0)){var g=o.lanes;g&=r.pendingLanes,u|=g,o.lanes=u,lo(r,u)}}function i0(r,o){var u=r.updateQueue,g=r.alternate;if(g!==null&&(g=g.updateQueue,u===g)){var w=null,k=null;if(u=u.firstBaseUpdate,u!==null){do{var T={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};k===null?w=k=T:k=k.next=T,u=u.next}while(u!==null);k===null?w=k=o:k=k.next=o}else w=k=o;u={baseState:g.baseState,firstBaseUpdate:w,lastBaseUpdate:k,shared:g.shared,effects:g.effects},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=o:r.next=o,u.lastBaseUpdate=o}function zc(r,o,u,g){var w=r.updateQueue;Ms=!1;var k=w.firstBaseUpdate,T=w.lastBaseUpdate,X=w.shared.pending;if(X!==null){w.shared.pending=null;var te=X,ue=te.next;te.next=null,T===null?k=ue:T.next=ue,T=te;var ve=r.alternate;ve!==null&&(ve=ve.updateQueue,X=ve.lastBaseUpdate,X!==T&&(X===null?ve.firstBaseUpdate=ue:X.next=ue,ve.lastBaseUpdate=te))}if(k!==null){var be=w.baseState;T=0,ve=ue=te=null,X=k;do{var we=X.lane,Ae=X.eventTime;if((g&we)===we){ve!==null&&(ve=ve.next={eventTime:Ae,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Pe=r,qe=X;switch(we=o,Ae=u,qe.tag){case 1:if(Pe=qe.payload,typeof Pe=="function"){be=Pe.call(Ae,be,we);break e}be=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=qe.payload,we=typeof Pe=="function"?Pe.call(Ae,be,we):Pe,we==null)break e;be=Y({},be,we);break e;case 2:Ms=!0}}X.callback!==null&&X.lane!==0&&(r.flags|=64,we=w.effects,we===null?w.effects=[X]:we.push(X))}else Ae={eventTime:Ae,lane:we,tag:X.tag,payload:X.payload,callback:X.callback,next:null},ve===null?(ue=ve=Ae,te=be):ve=ve.next=Ae,T|=we;if(X=X.next,X===null){if(X=w.shared.pending,X===null)break;we=X,X=we.next,we.next=null,w.lastBaseUpdate=we,w.shared.pending=null}}while(!0);if(ve===null&&(te=be),w.baseState=te,w.firstBaseUpdate=ue,w.lastBaseUpdate=ve,o=w.shared.interleaved,o!==null){w=o;do T|=w.lane,w=w.next;while(w!==o)}else k===null&&(w.shared.lanes=0);Pa|=T,r.lanes=T,r.memoizedState=be}}function l0(r,o,u){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var g=r[o],w=g.callback;if(w!==null){if(g.callback=null,g=u,typeof w!="function")throw Error(n(191,w));w.call(g)}}}var el={},Er=Ts(el),tl=Ts(el),nl=Ts(el);function $a(r){if(r===el)throw Error(n(174));return r}function kh(r,o){switch(pt(nl,o),pt(tl,r),pt(Er,el),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Fe(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=Fe(o,r)}yt(Er),pt(Er,o)}function Mo(){yt(Er),yt(tl),yt(nl)}function c0(r){$a(nl.current);var o=$a(Er.current),u=Fe(o,r.type);o!==u&&(pt(tl,r),pt(Er,u))}function _h(r){tl.current===r&&(yt(Er),yt(tl))}var kt=Ts(0);function Uc(r){for(var o=r;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||u.data==="$?"||u.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Nh=[];function Sh(){for(var r=0;r<Nh.length;r++)Nh[r]._workInProgressVersionPrimary=null;Nh.length=0}var Wc=C.ReactCurrentDispatcher,jh=C.ReactCurrentBatchConfig,Oa=0,_t=null,Ot=null,Bt=null,Hc=!1,rl=!1,sl=0,hR=0;function en(){throw Error(n(321))}function Eh(r,o){if(o===null)return!1;for(var u=0;u<o.length&&u<r.length;u++)if(!dn(r[u],o[u]))return!1;return!0}function Ch(r,o,u,g,w,k){if(Oa=k,_t=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,Wc.current=r===null||r.memoizedState===null?gR:yR,r=u(g,w),rl){k=0;do{if(rl=!1,sl=0,25<=k)throw Error(n(301));k+=1,Bt=Ot=null,o.updateQueue=null,Wc.current=wR,r=u(g,w)}while(rl)}if(Wc.current=Yc,o=Ot!==null&&Ot.next!==null,Oa=0,Bt=Ot=_t=null,Hc=!1,o)throw Error(n(300));return r}function Th(){var r=sl!==0;return sl=0,r}function Cr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bt===null?_t.memoizedState=Bt=r:Bt=Bt.next=r,Bt}function Fn(){if(Ot===null){var r=_t.alternate;r=r!==null?r.memoizedState:null}else r=Ot.next;var o=Bt===null?_t.memoizedState:Bt.next;if(o!==null)Bt=o,Ot=r;else{if(r===null)throw Error(n(310));Ot=r,r={memoizedState:Ot.memoizedState,baseState:Ot.baseState,baseQueue:Ot.baseQueue,queue:Ot.queue,next:null},Bt===null?_t.memoizedState=Bt=r:Bt=Bt.next=r}return Bt}function al(r,o){return typeof o=="function"?o(r):o}function Ah(r){var o=Fn(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var g=Ot,w=g.baseQueue,k=u.pending;if(k!==null){if(w!==null){var T=w.next;w.next=k.next,k.next=T}g.baseQueue=w=k,u.pending=null}if(w!==null){k=w.next,g=g.baseState;var X=T=null,te=null,ue=k;do{var ve=ue.lane;if((Oa&ve)===ve)te!==null&&(te=te.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),g=ue.hasEagerState?ue.eagerState:r(g,ue.action);else{var be={lane:ve,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};te===null?(X=te=be,T=g):te=te.next=be,_t.lanes|=ve,Pa|=ve}ue=ue.next}while(ue!==null&&ue!==k);te===null?T=g:te.next=X,dn(g,o.memoizedState)||(pn=!0),o.memoizedState=g,o.baseState=T,o.baseQueue=te,u.lastRenderedState=g}if(r=u.interleaved,r!==null){w=r;do k=w.lane,_t.lanes|=k,Pa|=k,w=w.next;while(w!==r)}else w===null&&(u.lanes=0);return[o.memoizedState,u.dispatch]}function Rh(r){var o=Fn(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var g=u.dispatch,w=u.pending,k=o.memoizedState;if(w!==null){u.pending=null;var T=w=w.next;do k=r(k,T.action),T=T.next;while(T!==w);dn(k,o.memoizedState)||(pn=!0),o.memoizedState=k,o.baseQueue===null&&(o.baseState=k),u.lastRenderedState=k}return[k,g]}function u0(){}function d0(r,o){var u=_t,g=Fn(),w=o(),k=!dn(g.memoizedState,w);if(k&&(g.memoizedState=w,pn=!0),g=g.queue,Mh(p0.bind(null,u,g,r),[r]),g.getSnapshot!==o||k||Bt!==null&&Bt.memoizedState.tag&1){if(u.flags|=2048,ol(9,f0.bind(null,u,g,w,o),void 0,null),zt===null)throw Error(n(349));(Oa&30)!==0||h0(u,o,w)}return w}function h0(r,o,u){r.flags|=16384,r={getSnapshot:o,value:u},o=_t.updateQueue,o===null?(o={lastEffect:null,stores:null},_t.updateQueue=o,o.stores=[r]):(u=o.stores,u===null?o.stores=[r]:u.push(r))}function f0(r,o,u,g){o.value=u,o.getSnapshot=g,m0(o)&&g0(r)}function p0(r,o,u){return u(function(){m0(o)&&g0(r)})}function m0(r){var o=r.getSnapshot;r=r.value;try{var u=o();return!dn(r,u)}catch{return!0}}function g0(r){var o=Zr(r,1);o!==null&&or(o,r,1,-1)}function y0(r){var o=Cr();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:r},o.queue=r,r=r.dispatch=mR.bind(null,_t,r),[o.memoizedState,r]}function ol(r,o,u,g){return r={tag:r,create:o,destroy:u,deps:g,next:null},o=_t.updateQueue,o===null?(o={lastEffect:null,stores:null},_t.updateQueue=o,o.lastEffect=r.next=r):(u=o.lastEffect,u===null?o.lastEffect=r.next=r:(g=u.next,u.next=r,r.next=g,o.lastEffect=r)),r}function w0(){return Fn().memoizedState}function Gc(r,o,u,g){var w=Cr();_t.flags|=r,w.memoizedState=ol(1|o,u,void 0,g===void 0?null:g)}function Vc(r,o,u,g){var w=Fn();g=g===void 0?null:g;var k=void 0;if(Ot!==null){var T=Ot.memoizedState;if(k=T.destroy,g!==null&&Eh(g,T.deps)){w.memoizedState=ol(o,u,k,g);return}}_t.flags|=r,w.memoizedState=ol(1|o,u,k,g)}function v0(r,o){return Gc(8390656,8,r,o)}function Mh(r,o){return Vc(2048,8,r,o)}function x0(r,o){return Vc(4,2,r,o)}function b0(r,o){return Vc(4,4,r,o)}function k0(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function _0(r,o,u){return u=u!=null?u.concat([r]):null,Vc(4,4,k0.bind(null,o,r),u)}function Ih(){}function N0(r,o){var u=Fn();o=o===void 0?null:o;var g=u.memoizedState;return g!==null&&o!==null&&Eh(o,g[1])?g[0]:(u.memoizedState=[r,o],r)}function S0(r,o){var u=Fn();o=o===void 0?null:o;var g=u.memoizedState;return g!==null&&o!==null&&Eh(o,g[1])?g[0]:(r=r(),u.memoizedState=[r,o],r)}function j0(r,o,u){return(Oa&21)===0?(r.baseState&&(r.baseState=!1,pn=!0),r.memoizedState=u):(dn(u,o)||(u=Et(),_t.lanes|=u,Pa|=u,r.baseState=!0),o)}function fR(r,o){var u=at;at=u!==0&&4>u?u:4,r(!0);var g=jh.transition;jh.transition={};try{r(!1),o()}finally{at=u,jh.transition=g}}function E0(){return Fn().memoizedState}function pR(r,o,u){var g=Ls(r);if(u={lane:g,action:u,hasEagerState:!1,eagerState:null,next:null},C0(r))T0(o,u);else if(u=a0(r,o,u,g),u!==null){var w=on();or(u,r,g,w),A0(u,o,g)}}function mR(r,o,u){var g=Ls(r),w={lane:g,action:u,hasEagerState:!1,eagerState:null,next:null};if(C0(r))T0(o,w);else{var k=r.alternate;if(r.lanes===0&&(k===null||k.lanes===0)&&(k=o.lastRenderedReducer,k!==null))try{var T=o.lastRenderedState,X=k(T,u);if(w.hasEagerState=!0,w.eagerState=X,dn(X,T)){var te=o.interleaved;te===null?(w.next=w,xh(o)):(w.next=te.next,te.next=w),o.interleaved=w;return}}catch{}finally{}u=a0(r,o,w,g),u!==null&&(w=on(),or(u,r,g,w),A0(u,o,g))}}function C0(r){var o=r.alternate;return r===_t||o!==null&&o===_t}function T0(r,o){rl=Hc=!0;var u=r.pending;u===null?o.next=o:(o.next=u.next,u.next=o),r.pending=o}function A0(r,o,u){if((u&4194240)!==0){var g=o.lanes;g&=r.pendingLanes,u|=g,o.lanes=u,lo(r,u)}}var Yc={readContext:qn,useCallback:en,useContext:en,useEffect:en,useImperativeHandle:en,useInsertionEffect:en,useLayoutEffect:en,useMemo:en,useReducer:en,useRef:en,useState:en,useDebugValue:en,useDeferredValue:en,useTransition:en,useMutableSource:en,useSyncExternalStore:en,useId:en,unstable_isNewReconciler:!1},gR={readContext:qn,useCallback:function(r,o){return Cr().memoizedState=[r,o===void 0?null:o],r},useContext:qn,useEffect:v0,useImperativeHandle:function(r,o,u){return u=u!=null?u.concat([r]):null,Gc(4194308,4,k0.bind(null,o,r),u)},useLayoutEffect:function(r,o){return Gc(4194308,4,r,o)},useInsertionEffect:function(r,o){return Gc(4,2,r,o)},useMemo:function(r,o){var u=Cr();return o=o===void 0?null:o,r=r(),u.memoizedState=[r,o],r},useReducer:function(r,o,u){var g=Cr();return o=u!==void 0?u(o):o,g.memoizedState=g.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},g.queue=r,r=r.dispatch=pR.bind(null,_t,r),[g.memoizedState,r]},useRef:function(r){var o=Cr();return r={current:r},o.memoizedState=r},useState:y0,useDebugValue:Ih,useDeferredValue:function(r){return Cr().memoizedState=r},useTransition:function(){var r=y0(!1),o=r[0];return r=fR.bind(null,r[1]),Cr().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,u){var g=_t,w=Cr();if(wt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=o(),zt===null)throw Error(n(349));(Oa&30)!==0||h0(g,o,u)}w.memoizedState=u;var k={value:u,getSnapshot:o};return w.queue=k,v0(p0.bind(null,g,k,r),[r]),g.flags|=2048,ol(9,f0.bind(null,g,k,u,o),void 0,null),u},useId:function(){var r=Cr(),o=zt.identifierPrefix;if(wt){var u=Qr,g=Xr;u=(g&~(1<<32-cn(g)-1)).toString(32)+u,o=":"+o+"R"+u,u=sl++,0<u&&(o+="H"+u.toString(32)),o+=":"}else u=hR++,o=":"+o+"r"+u.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},yR={readContext:qn,useCallback:N0,useContext:qn,useEffect:Mh,useImperativeHandle:_0,useInsertionEffect:x0,useLayoutEffect:b0,useMemo:S0,useReducer:Ah,useRef:w0,useState:function(){return Ah(al)},useDebugValue:Ih,useDeferredValue:function(r){var o=Fn();return j0(o,Ot.memoizedState,r)},useTransition:function(){var r=Ah(al)[0],o=Fn().memoizedState;return[r,o]},useMutableSource:u0,useSyncExternalStore:d0,useId:E0,unstable_isNewReconciler:!1},wR={readContext:qn,useCallback:N0,useContext:qn,useEffect:Mh,useImperativeHandle:_0,useInsertionEffect:x0,useLayoutEffect:b0,useMemo:S0,useReducer:Rh,useRef:w0,useState:function(){return Rh(al)},useDebugValue:Ih,useDeferredValue:function(r){var o=Fn();return Ot===null?o.memoizedState=r:j0(o,Ot.memoizedState,r)},useTransition:function(){var r=Rh(al)[0],o=Fn().memoizedState;return[r,o]},useMutableSource:u0,useSyncExternalStore:d0,useId:E0,unstable_isNewReconciler:!1};function rr(r,o){if(r&&r.defaultProps){o=Y({},o),r=r.defaultProps;for(var u in r)o[u]===void 0&&(o[u]=r[u]);return o}return o}function $h(r,o,u,g){o=r.memoizedState,u=u(g,o),u=u==null?o:Y({},o,u),r.memoizedState=u,r.lanes===0&&(r.updateQueue.baseState=u)}var Kc={isMounted:function(r){return(r=r._reactInternals)?Rn(r)===r:!1},enqueueSetState:function(r,o,u){r=r._reactInternals;var g=on(),w=Ls(r),k=Jr(g,w);k.payload=o,u!=null&&(k.callback=u),o=Is(r,k,w),o!==null&&(or(o,r,w,g),Bc(o,r,w))},enqueueReplaceState:function(r,o,u){r=r._reactInternals;var g=on(),w=Ls(r),k=Jr(g,w);k.tag=1,k.payload=o,u!=null&&(k.callback=u),o=Is(r,k,w),o!==null&&(or(o,r,w,g),Bc(o,r,w))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var u=on(),g=Ls(r),w=Jr(u,g);w.tag=2,o!=null&&(w.callback=o),o=Is(r,w,g),o!==null&&(or(o,r,g,u),Bc(o,r,g))}};function R0(r,o,u,g,w,k,T){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(g,k,T):o.prototype&&o.prototype.isPureReactComponent?!bs(u,g)||!bs(w,k):!0}function M0(r,o,u){var g=!1,w=As,k=o.contextType;return typeof k=="object"&&k!==null?k=qn(k):(w=fn(o)?Aa:Jt.current,g=o.contextTypes,k=(g=g!=null)?So(r,w):As),o=new o(u,k),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Kc,r.stateNode=o,o._reactInternals=r,g&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=w,r.__reactInternalMemoizedMaskedChildContext=k),o}function I0(r,o,u,g){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,g),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,g),o.state!==r&&Kc.enqueueReplaceState(o,o.state,null)}function Oh(r,o,u,g){var w=r.stateNode;w.props=u,w.state=r.memoizedState,w.refs={},bh(r);var k=o.contextType;typeof k=="object"&&k!==null?w.context=qn(k):(k=fn(o)?Aa:Jt.current,w.context=So(r,k)),w.state=r.memoizedState,k=o.getDerivedStateFromProps,typeof k=="function"&&($h(r,o,k,u),w.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(o=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),o!==w.state&&Kc.enqueueReplaceState(w,w.state,null),zc(r,u,w,g),w.state=r.memoizedState),typeof w.componentDidMount=="function"&&(r.flags|=4194308)}function Io(r,o){try{var u="",g=o;do u+=U(g),g=g.return;while(g);var w=u}catch(k){w=`
37
+ `+w[T].replace(" at new "," at ");return r.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",r.displayName)),te}while(1<=T&&0<=X);break}}}finally{de=!1,Error.prepareStackTrace=u}return(r=r?r.displayName||r.name:"")?G(r):""}function U(r){switch(r.tag){case 5:return G(r.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return r=W(r.type,!1),r;case 11:return r=W(r.type.render,!1),r;case 1:return r=W(r.type,!0),r;default:return""}}function J(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case $:return"Fragment";case I:return"Portal";case O:return"Profiler";case F:return"StrictMode";case B:return"Suspense";case A:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case L:return(r.displayName||"Context")+".Consumer";case M:return(r._context.displayName||"Context")+".Provider";case H:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Q:return o=r.displayName||null,o!==null?o:J(r.type)||"Memo";case K:o=r._payload,r=r._init;try{return J(r(o))}catch{}}return null}function V(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return J(o);case 8:return o===F?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ie(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function pe(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function me(r){var o=pe(r)?"checked":"value",u=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),g=""+r[o];if(!r.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var w=u.get,k=u.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return w.call(this)},set:function(T){g=""+T,k.call(this,T)}}),Object.defineProperty(r,o,{enumerable:u.enumerable}),{getValue:function(){return g},setValue:function(T){g=""+T},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Ie(r){r._valueTracker||(r._valueTracker=me(r))}function Le(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var u=o.getValue(),g="";return r&&(g=pe(r)?r.checked?"true":"false":r.value),r=g,r!==u?(o.setValue(r),!0):!1}function ce(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function xe(r,o){var u=o.checked;return Y({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??r._wrapperState.initialChecked})}function ye(r,o){var u=o.defaultValue==null?"":o.defaultValue,g=o.checked!=null?o.checked:o.defaultChecked;u=ie(o.value!=null?o.value:u),r._wrapperState={initialChecked:g,initialValue:u,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function ze(r,o){o=o.checked,o!=null&&E(r,"checked",o,!1)}function ke(r,o){ze(r,o);var u=ie(o.value),g=o.type;if(u!=null)g==="number"?(u===0&&r.value===""||r.value!=u)&&(r.value=""+u):r.value!==""+u&&(r.value=""+u);else if(g==="submit"||g==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?Ye(r,o.type,u):o.hasOwnProperty("defaultValue")&&Ye(r,o.type,ie(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function je(r,o,u){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var g=o.type;if(!(g!=="submit"&&g!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,u||o===r.value||(r.value=o),r.defaultValue=o}u=r.name,u!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,u!==""&&(r.name=u)}function Ye(r,o,u){(o!=="number"||ce(r.ownerDocument)!==r)&&(u==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+u&&(r.defaultValue=""+u))}var it=Array.isArray;function Ne(r,o,u,g){if(r=r.options,o){o={};for(var w=0;w<u.length;w++)o["$"+u[w]]=!0;for(u=0;u<r.length;u++)w=o.hasOwnProperty("$"+r[u].value),r[u].selected!==w&&(r[u].selected=w),w&&g&&(r[u].defaultSelected=!0)}else{for(u=""+ie(u),o=null,w=0;w<r.length;w++){if(r[w].value===u){r[w].selected=!0,g&&(r[w].defaultSelected=!0);return}o!==null||r[w].disabled||(o=r[w])}o!==null&&(o.selected=!0)}}function He(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return Y({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Xe(r,o){var u=o.value;if(u==null){if(u=o.children,o=o.defaultValue,u!=null){if(o!=null)throw Error(n(92));if(it(u)){if(1<u.length)throw Error(n(93));u=u[0]}o=u}o==null&&(o=""),u=o}r._wrapperState={initialValue:ie(u)}}function he(r,o){var u=ie(o.value),g=ie(o.defaultValue);u!=null&&(u=""+u,u!==r.value&&(r.value=u),o.defaultValue==null&&r.defaultValue!==u&&(r.defaultValue=u)),g!=null&&(r.defaultValue=""+g)}function ge(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function Se(r){switch(r){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 Fe(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?Se(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var et,xt=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,u,g,w){MSApp.execUnsafeLocalFunction(function(){return r(o,u,g,w)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(et=et||document.createElement("div"),et.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=et.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function ht(r,o){if(o){var u=r.firstChild;if(u&&u===r.lastChild&&u.nodeType===3){u.nodeValue=o;return}}r.textContent=o}var ne={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},De=["Webkit","ms","Moz","O"];Object.keys(ne).forEach(function(r){De.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),ne[o]=ne[r]})});function Oe(r,o,u){return o==null||typeof o=="boolean"||o===""?"":u||typeof o!="number"||o===0||ne.hasOwnProperty(r)&&ne[r]?(""+o).trim():o+"px"}function Te(r,o){r=r.style;for(var u in o)if(o.hasOwnProperty(u)){var g=u.indexOf("--")===0,w=Oe(u,o[u],g);u==="float"&&(u="cssFloat"),g?r.setProperty(u,w):r[u]=w}}var Ce=Y({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 lt(r,o){if(o){if(Ce[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function ut(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){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 Re=null;function mt(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var ft=null,bt=null,Xn=null;function Tn(r){if(r=Ji(r)){if(typeof ft!="function")throw Error(n(280));var o=r.stateNode;o&&(o=Mc(o),ft(r.stateNode,r.type,o))}}function ln(r){bt?Xn?Xn.push(r):Xn=[r]:bt=r}function to(){if(bt){var r=bt,o=Xn;if(Xn=bt=null,Tn(r),o)for(r=0;r<o.length;r++)Tn(o[r])}}function ds(r,o){return r(o)}function Or(){}var Qn=!1;function no(r,o,u){if(Qn)return r(o,u);Qn=!0;try{return ds(r,o,u)}finally{Qn=!1,(bt!==null||Xn!==null)&&(Or(),to())}}function Pr(r,o){var u=r.stateNode;if(u===null)return null;var g=Mc(u);if(g===null)return null;u=g[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(r=r.type,g=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!g;break e;default:r=!1}if(r)return null;if(u&&typeof u!="function")throw Error(n(231,o,typeof u));return u}var Zs=!1;if(d)try{var Lr={};Object.defineProperty(Lr,"passive",{get:function(){Zs=!0}}),window.addEventListener("test",Lr,Lr),window.removeEventListener("test",Lr,Lr)}catch{Zs=!1}function An(r,o,u,g,w,k,T,X,te){var ue=Array.prototype.slice.call(arguments,3);try{o.apply(u,ue)}catch(ve){this.onError(ve)}}var Dr=!1,hs=null,qt=!1,wr=null,Js={onError:function(r){Dr=!0,hs=r}};function vi(r,o,u,g,w,k,T,X,te){Dr=!1,hs=null,An.apply(Js,arguments)}function ro(r,o,u,g,w,k,T,X,te){if(vi.apply(this,arguments),Dr){if(Dr){var ue=hs;Dr=!1,hs=null}else throw Error(n(198));qt||(qt=!0,wr=ue)}}function Rn(r){var o=r,u=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(u=o.return),r=o.return;while(r)}return o.tag===3?u:null}function ea(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function ta(r){if(Rn(r)!==r)throw Error(n(188))}function na(r){var o=r.alternate;if(!o){if(o=Rn(r),o===null)throw Error(n(188));return o!==r?null:r}for(var u=r,g=o;;){var w=u.return;if(w===null)break;var k=w.alternate;if(k===null){if(g=w.return,g!==null){u=g;continue}break}if(w.child===k.child){for(k=w.child;k;){if(k===u)return ta(w),r;if(k===g)return ta(w),o;k=k.sibling}throw Error(n(188))}if(u.return!==g.return)u=w,g=k;else{for(var T=!1,X=w.child;X;){if(X===u){T=!0,u=w,g=k;break}if(X===g){T=!0,g=w,u=k;break}X=X.sibling}if(!T){for(X=k.child;X;){if(X===u){T=!0,u=k,g=w;break}if(X===g){T=!0,g=k,u=w;break}X=X.sibling}if(!T)throw Error(n(189))}}if(u.alternate!==g)throw Error(n(190))}if(u.tag!==3)throw Error(n(188));return u.stateNode.current===u?r:o}function ra(r){return r=na(r),r!==null?sa(r):null}function sa(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=sa(r);if(o!==null)return o;r=r.sibling}return null}var aa=t.unstable_scheduleCallback,so=t.unstable_cancelCallback,oa=t.unstable_shouldYield,xi=t.unstable_requestPaint,dt=t.unstable_now,ao=t.unstable_getCurrentPriorityLevel,ia=t.unstable_ImmediatePriority,qr=t.unstable_UserBlockingPriority,Fr=t.unstable_NormalPriority,Br=t.unstable_LowPriority,la=t.unstable_IdlePriority,zr=null,It=null;function ca(r){if(It&&typeof It.onCommitFiberRoot=="function")try{It.onCommitFiberRoot(zr,r,void 0,(r.current.flags&128)===128)}catch{}}var cn=Math.clz32?Math.clz32:ic,oc=Math.log,Hd=Math.LN2;function ic(r){return r>>>=0,r===0?32:31-(oc(r)/Hd|0)|0}var vr=64,oo=4194304;function fs(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Xt(r,o){var u=r.pendingLanes;if(u===0)return 0;var g=0,w=r.suspendedLanes,k=r.pingedLanes,T=u&268435455;if(T!==0){var X=T&~w;X!==0?g=fs(X):(k&=T,k!==0&&(g=fs(k)))}else T=u&~w,T!==0?g=fs(T):k!==0&&(g=fs(k));if(g===0)return 0;if(o!==0&&o!==g&&(o&w)===0&&(w=g&-g,k=o&-o,w>=k||w===16&&(k&4194240)!==0))return o;if((g&4)!==0&&(g|=u&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=g;0<o;)u=31-cn(o),w=1<<u,g|=r[u],o&=~w;return g}function io(r,o){switch(r){case 1:case 2:case 4:return o+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 o+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 Gd(r,o){for(var u=r.suspendedLanes,g=r.pingedLanes,w=r.expirationTimes,k=r.pendingLanes;0<k;){var T=31-cn(k),X=1<<T,te=w[T];te===-1?((X&u)===0||(X&g)!==0)&&(w[T]=io(X,o)):te<=o&&(r.expiredLanes|=X),k&=~X}}function ua(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Et(){var r=vr;return vr<<=1,(vr&4194240)===0&&(vr=64),r}function bi(r){for(var o=[],u=0;31>u;u++)o.push(r);return o}function rn(r,o,u){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-cn(o),r[o]=u}function lo(r,o){var u=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var g=r.eventTimes;for(r=r.expirationTimes;0<u;){var w=31-cn(u),k=1<<w;o[w]=0,g[w]=-1,r[w]=-1,u&=~k}}function co(r,o){var u=r.entangledLanes|=o;for(r=r.entanglements;u;){var g=31-cn(u),w=1<<g;w&o|r[g]&o&&(r[g]|=o),u&=~w}}var at=0;function Zn(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var da,ki,lc,_i,Ni,xr=!1,ha=[],Jn=null,xn=null,Mn=null,ps=new Map,ms=new Map,er=[],cc="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 Qt(r,o){switch(r){case"focusin":case"focusout":Jn=null;break;case"dragenter":case"dragleave":xn=null;break;case"mouseover":case"mouseout":Mn=null;break;case"pointerover":case"pointerout":ps.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":ms.delete(o.pointerId)}}function br(r,o,u,g,w,k){return r===null||r.nativeEvent!==k?(r={blockedOn:o,domEventName:u,eventSystemFlags:g,nativeEvent:k,targetContainers:[w]},o!==null&&(o=Ji(o),o!==null&&ki(o)),r):(r.eventSystemFlags|=g,o=r.targetContainers,w!==null&&o.indexOf(w)===-1&&o.push(w),r)}function uo(r,o,u,g,w){switch(o){case"focusin":return Jn=br(Jn,r,o,u,g,w),!0;case"dragenter":return xn=br(xn,r,o,u,g,w),!0;case"mouseover":return Mn=br(Mn,r,o,u,g,w),!0;case"pointerover":var k=w.pointerId;return ps.set(k,br(ps.get(k)||null,r,o,u,g,w)),!0;case"gotpointercapture":return k=w.pointerId,ms.set(k,br(ms.get(k)||null,r,o,u,g,w)),!0}return!1}function ho(r){var o=Aa(r.target);if(o!==null){var u=Rn(o);if(u!==null){if(o=u.tag,o===13){if(o=ea(u),o!==null){r.blockedOn=o,Ni(r.priority,function(){lc(u)});return}}else if(o===3&&u.stateNode.current.memoizedState.isDehydrated){r.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}r.blockedOn=null}function fo(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var u=Wr(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(u===null){u=r.nativeEvent;var g=new u.constructor(u.type,u);Re=g,u.target.dispatchEvent(g),Re=null}else return o=Ji(u),o!==null&&ki(o),r.blockedOn=u,!1;o.shift()}return!0}function gs(r,o,u){fo(r)&&u.delete(o)}function uc(){xr=!1,Jn!==null&&fo(Jn)&&(Jn=null),xn!==null&&fo(xn)&&(xn=null),Mn!==null&&fo(Mn)&&(Mn=null),ps.forEach(gs),ms.forEach(gs)}function un(r,o){r.blockedOn===o&&(r.blockedOn=null,xr||(xr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,uc)))}function fa(r){function o(w){return un(w,r)}if(0<ha.length){un(ha[0],r);for(var u=1;u<ha.length;u++){var g=ha[u];g.blockedOn===r&&(g.blockedOn=null)}}for(Jn!==null&&un(Jn,r),xn!==null&&un(xn,r),Mn!==null&&un(Mn,r),ps.forEach(o),ms.forEach(o),u=0;u<er.length;u++)g=er[u],g.blockedOn===r&&(g.blockedOn=null);for(;0<er.length&&(u=er[0],u.blockedOn===null);)ho(u),u.blockedOn===null&&er.shift()}var Ur=C.ReactCurrentBatchConfig,po=!0;function Vd(r,o,u,g){var w=at,k=Ur.transition;Ur.transition=null;try{at=1,Si(r,o,u,g)}finally{at=w,Ur.transition=k}}function dc(r,o,u,g){var w=at,k=Ur.transition;Ur.transition=null;try{at=4,Si(r,o,u,g)}finally{at=w,Ur.transition=k}}function Si(r,o,u,g){if(po){var w=Wr(r,o,u,g);if(w===null)Qi(r,o,g,In,u),Qt(r,g);else if(uo(w,r,o,u,g))g.stopPropagation();else if(Qt(r,g),o&4&&-1<cc.indexOf(r)){for(;w!==null;){var k=Ji(w);if(k!==null&&da(k),k=Wr(r,o,u,g),k===null&&Qi(r,o,g,In,u),k===w)break;w=k}w!==null&&g.stopPropagation()}else Qi(r,o,g,null,u)}}var In=null;function Wr(r,o,u,g){if(In=null,r=mt(g),r=Aa(r),r!==null)if(o=Rn(r),o===null)r=null;else if(u=o.tag,u===13){if(r=ea(o),r!==null)return r;r=null}else if(u===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return In=r,null}function ji(r){switch(r){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(ao()){case ia:return 1;case qr:return 4;case Fr:case Br:return 16;case la:return 536870912;default:return 16}default:return 16}}var $n=null,bn=null,mo=null;function kn(){if(mo)return mo;var r,o=bn,u=o.length,g,w="value"in $n?$n.value:$n.textContent,k=w.length;for(r=0;r<u&&o[r]===w[r];r++);var T=u-r;for(g=1;g<=T&&o[u-g]===w[k-g];g++);return mo=w.slice(r,1<g?1-g:void 0)}function ys(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function ws(){return!0}function Ei(){return!1}function Ft(r){function o(u,g,w,k,T){this._reactName=u,this._targetInst=w,this.type=g,this.nativeEvent=k,this.target=T,this.currentTarget=null;for(var X in r)r.hasOwnProperty(X)&&(u=r[X],this[X]=u?u(k):k[X]);return this.isDefaultPrevented=(k.defaultPrevented!=null?k.defaultPrevented:k.returnValue===!1)?ws:Ei,this.isPropagationStopped=Ei,this}return Y(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var u=this.nativeEvent;u&&(u.preventDefault?u.preventDefault():typeof u.returnValue!="unknown"&&(u.returnValue=!1),this.isDefaultPrevented=ws)},stopPropagation:function(){var u=this.nativeEvent;u&&(u.stopPropagation?u.stopPropagation():typeof u.cancelBubble!="unknown"&&(u.cancelBubble=!0),this.isPropagationStopped=ws)},persist:function(){},isPersistent:ws}),o}var kr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},go=Ft(kr),Hr=Y({},kr,{view:0,detail:0}),hc=Ft(Hr),pa,yo,On,ma=Y({},Hr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ya,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==On&&(On&&r.type==="mousemove"?(pa=r.screenX-On.screenX,yo=r.screenY-On.screenY):yo=pa=0,On=r),pa)},movementY:function(r){return"movementY"in r?r.movementY:yo}}),Ci=Ft(ma),Ti=Y({},ma,{dataTransfer:0}),Yd=Ft(Ti),Ai=Y({},Hr,{relatedTarget:0}),_r=Ft(Ai),fc=Y({},kr,{animationName:0,elapsedTime:0,pseudoElement:0}),Kd=Ft(fc),pc=Y({},kr,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),mc=Ft(pc),Xd=Y({},kr,{data:0}),sn=Ft(Xd),Qd={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ri={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"},vs={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ga(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=vs[r])?!!o[r]:!1}function ya(){return ga}var Mi=Y({},Hr,{key:function(r){if(r.key){var o=Qd[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=ys(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?Ri[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ya,charCode:function(r){return r.type==="keypress"?ys(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?ys(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),gc=Ft(Mi),wo=Y({},ma,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ii=Ft(wo),Zd=Y({},Hr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ya}),Jd=Ft(Zd),yc=Y({},kr,{propertyName:0,elapsedTime:0,pseudoElement:0}),eh=Ft(yc),th=Y({},ma,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),$i=Ft(th),Nr=[9,13,27,32],wa=d&&"CompositionEvent"in window,xs=null;d&&"documentMode"in document&&(xs=document.documentMode);var nh=d&&"TextEvent"in window&&!xs,wc=d&&(!wa||xs&&8<xs&&11>=xs),Oi=" ",vc=!1;function xc(r,o){switch(r){case"keyup":return Nr.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pi(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Gr=!1;function Sr(r,o){switch(r){case"compositionend":return Pi(o);case"keypress":return o.which!==32?null:(vc=!0,Oi);case"textInput":return r=o.data,r===Oi&&vc?null:r;default:return null}}function rh(r,o){if(Gr)return r==="compositionend"||!wa&&xc(r,o)?(r=kn(),mo=bn=$n=null,Gr=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return wc&&o.locale!=="ko"?null:o.data;default:return null}}var bc={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 kc(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!bc[r.type]:o==="textarea"}function va(r,o,u,g){ln(g),o=Es(o,"onChange"),0<o.length&&(u=new go("onChange","change",null,u,g),r.push({event:u,listeners:o}))}var xa=null,$t=null;function Li(r){ot(r,0)}function ba(r){var o=No(r);if(Le(o))return r}function _c(r,o){if(r==="change")return o}var Di=!1;if(d){var ka;if(d){var bs="oninput"in document;if(!bs){var vo=document.createElement("div");vo.setAttribute("oninput","return;"),bs=typeof vo.oninput=="function"}ka=bs}else ka=!1;Di=ka&&(!document.documentMode||9<document.documentMode)}function qi(){xa&&(xa.detachEvent("onpropertychange",_a),$t=xa=null)}function _a(r){if(r.propertyName==="value"&&ba($t)){var o=[];va(o,$t,r,mt(r)),no(Li,o)}}function Nc(r,o,u){r==="focusin"?(qi(),xa=o,$t=u,xa.attachEvent("onpropertychange",_a)):r==="focusout"&&qi()}function Fi(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return ba($t)}function Bi(r,o){if(r==="click")return ba(o)}function Sc(r,o){if(r==="input"||r==="change")return ba(o)}function Zt(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var dn=typeof Object.is=="function"?Object.is:Zt;function ks(r,o){if(dn(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var u=Object.keys(r),g=Object.keys(o);if(u.length!==g.length)return!1;for(g=0;g<u.length;g++){var w=u[g];if(!h.call(o,w)||!dn(r[w],o[w]))return!1}return!0}function jc(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Ec(r,o){var u=jc(r);r=0;for(var g;u;){if(u.nodeType===3){if(g=r+u.textContent.length,r<=o&&g>=o)return{node:u,offset:o-r};r=g}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=jc(u)}}function zi(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?zi(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function Na(){for(var r=window,o=ce();o instanceof r.HTMLIFrameElement;){try{var u=typeof o.contentWindow.location.href=="string"}catch{u=!1}if(u)r=o.contentWindow;else break;o=ce(r.document)}return o}function Ui(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function Vr(r){var o=Na(),u=r.focusedElem,g=r.selectionRange;if(o!==u&&u&&u.ownerDocument&&zi(u.ownerDocument.documentElement,u)){if(g!==null&&Ui(u)){if(o=g.start,r=g.end,r===void 0&&(r=o),"selectionStart"in u)u.selectionStart=o,u.selectionEnd=Math.min(r,u.value.length);else if(r=(o=u.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var w=u.textContent.length,k=Math.min(g.start,w);g=g.end===void 0?k:Math.min(g.end,w),!r.extend&&k>g&&(w=g,g=k,k=w),w=Ec(u,k);var T=Ec(u,g);w&&T&&(r.rangeCount!==1||r.anchorNode!==w.node||r.anchorOffset!==w.offset||r.focusNode!==T.node||r.focusOffset!==T.offset)&&(o=o.createRange(),o.setStart(w.node,w.offset),r.removeAllRanges(),k>g?(r.addRange(o),r.extend(T.node,T.offset)):(o.setEnd(T.node,T.offset),r.addRange(o)))}}for(o=[],r=u;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u<o.length;u++)r=o[u],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var Wi=d&&"documentMode"in document&&11>=document.documentMode,tr=null,Sa=null,ja=null,xo=!1;function Hi(r,o,u){var g=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;xo||tr==null||tr!==ce(g)||(g=tr,"selectionStart"in g&&Ui(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),ja&&ks(ja,g)||(ja=g,g=Es(Sa,"onSelect"),0<g.length&&(o=new go("onSelect","select",null,o,u),r.push({event:o,listeners:g}),o.target=tr)))}function bo(r,o){var u={};return u[r.toLowerCase()]=o.toLowerCase(),u["Webkit"+r]="webkit"+o,u["Moz"+r]="moz"+o,u}var _s={animationend:bo("Animation","AnimationEnd"),animationiteration:bo("Animation","AnimationIteration"),animationstart:bo("Animation","AnimationStart"),transitionend:bo("Transition","TransitionEnd")},ko={},Ea={};d&&(Ea=document.createElement("div").style,"AnimationEvent"in window||(delete _s.animationend.animation,delete _s.animationiteration.animation,delete _s.animationstart.animation),"TransitionEvent"in window||delete _s.transitionend.transition);function Ns(r){if(ko[r])return ko[r];if(!_s[r])return r;var o=_s[r],u;for(u in o)if(o.hasOwnProperty(u)&&u in Ea)return ko[r]=o[u];return r}var Cc=Ns("animationend"),Gi=Ns("animationiteration"),Vi=Ns("animationstart"),Yi=Ns("transitionend"),Ki=new Map,q="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 z(r,o){Ki.set(r,o),l(o,[r])}for(var se=0;se<q.length;se++){var oe=q[se],Ee=oe.toLowerCase(),Me=oe[0].toUpperCase()+oe.slice(1);z(Ee,"on"+Me)}z(Cc,"onAnimationEnd"),z(Gi,"onAnimationIteration"),z(Vi,"onAnimationStart"),z("dblclick","onDoubleClick"),z("focusin","onFocus"),z("focusout","onBlur"),z(Yi,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var We="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(" "),rt=new Set("cancel close invalid load scroll toggle".split(" ").concat(We));function gt(r,o,u){var g=r.type||"unknown-event";r.currentTarget=u,ro(g,o,void 0,r),r.currentTarget=null}function ot(r,o){o=(o&4)!==0;for(var u=0;u<r.length;u++){var g=r[u],w=g.event;g=g.listeners;e:{var k=void 0;if(o)for(var T=g.length-1;0<=T;T--){var X=g[T],te=X.instance,ue=X.currentTarget;if(X=X.listener,te!==k&&w.isPropagationStopped())break e;gt(w,X,ue),k=te}else for(T=0;T<g.length;T++){if(X=g[T],te=X.instance,ue=X.currentTarget,X=X.listener,te!==k&&w.isPropagationStopped())break e;gt(w,X,ue),k=te}}}if(qt)throw r=wr,qt=!1,wr=null,r}function Qe(r,o){var u=o[ch];u===void 0&&(u=o[ch]=new Set);var g=r+"__bubble";u.has(g)||(Xi(o,r,2,!1),u.add(g))}function Ss(r,o,u){var g=0;o&&(g|=4),Xi(u,r,g,o)}var Ca="_reactListening"+Math.random().toString(36).slice(2);function Ta(r){if(!r[Ca]){r[Ca]=!0,s.forEach(function(u){u!=="selectionchange"&&(rt.has(u)||Ss(u,!1,r),Ss(u,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Ca]||(o[Ca]=!0,Ss("selectionchange",!1,o))}}function Xi(r,o,u,g){switch(ji(o)){case 1:var w=Vd;break;case 4:w=dc;break;default:w=Si}u=w.bind(null,o,u,r),w=void 0,!Zs||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(w=!0),g?w!==void 0?r.addEventListener(o,u,{capture:!0,passive:w}):r.addEventListener(o,u,!0):w!==void 0?r.addEventListener(o,u,{passive:w}):r.addEventListener(o,u,!1)}function Qi(r,o,u,g,w){var k=g;if((o&1)===0&&(o&2)===0&&g!==null)e:for(;;){if(g===null)return;var T=g.tag;if(T===3||T===4){var X=g.stateNode.containerInfo;if(X===w||X.nodeType===8&&X.parentNode===w)break;if(T===4)for(T=g.return;T!==null;){var te=T.tag;if((te===3||te===4)&&(te=T.stateNode.containerInfo,te===w||te.nodeType===8&&te.parentNode===w))return;T=T.return}for(;X!==null;){if(T=Aa(X),T===null)return;if(te=T.tag,te===5||te===6){g=k=T;continue e}X=X.parentNode}}g=g.return}no(function(){var ue=k,ve=mt(u),be=[];e:{var we=Ki.get(r);if(we!==void 0){var Ae=go,Pe=r;switch(r){case"keypress":if(ys(u)===0)break e;case"keydown":case"keyup":Ae=gc;break;case"focusin":Pe="focus",Ae=_r;break;case"focusout":Pe="blur",Ae=_r;break;case"beforeblur":case"afterblur":Ae=_r;break;case"click":if(u.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ae=Ci;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ae=Yd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ae=Jd;break;case Cc:case Gi:case Vi:Ae=Kd;break;case Yi:Ae=eh;break;case"scroll":Ae=hc;break;case"wheel":Ae=$i;break;case"copy":case"cut":case"paste":Ae=mc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ae=Ii}var qe=(o&4)!==0,jt=!qe&&r==="scroll",ae=qe?we!==null?we+"Capture":null:we;qe=[];for(var re=ue,le;re!==null;){le=re;var _e=le.stateNode;if(le.tag===5&&_e!==null&&(le=_e,ae!==null&&(_e=Pr(re,ae),_e!=null&&qe.push(js(re,_e,le)))),jt)break;re=re.return}0<qe.length&&(we=new Ae(we,Pe,null,u,ve),be.push({event:we,listeners:qe}))}}if((o&7)===0){e:{if(we=r==="mouseover"||r==="pointerover",Ae=r==="mouseout"||r==="pointerout",we&&u!==Re&&(Pe=u.relatedTarget||u.fromElement)&&(Aa(Pe)||Pe[Yr]))break e;if((Ae||we)&&(we=ve.window===ve?ve:(we=ve.ownerDocument)?we.defaultView||we.parentWindow:window,Ae?(Pe=u.relatedTarget||u.toElement,Ae=ue,Pe=Pe?Aa(Pe):null,Pe!==null&&(jt=Rn(Pe),Pe!==jt||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(Ae=null,Pe=ue),Ae!==Pe)){if(qe=Ci,_e="onMouseLeave",ae="onMouseEnter",re="mouse",(r==="pointerout"||r==="pointerover")&&(qe=Ii,_e="onPointerLeave",ae="onPointerEnter",re="pointer"),jt=Ae==null?we:No(Ae),le=Pe==null?we:No(Pe),we=new qe(_e,re+"leave",Ae,u,ve),we.target=jt,we.relatedTarget=le,_e=null,Aa(ve)===ue&&(qe=new qe(ae,re+"enter",Pe,u,ve),qe.target=le,qe.relatedTarget=jt,_e=qe),jt=_e,Ae&&Pe)t:{for(qe=Ae,ae=Pe,re=0,le=qe;le;le=Pn(le))re++;for(le=0,_e=ae;_e;_e=Pn(_e))le++;for(;0<re-le;)qe=Pn(qe),re--;for(;0<le-re;)ae=Pn(ae),le--;for(;re--;){if(qe===ae||ae!==null&&qe===ae.alternate)break t;qe=Pn(qe),ae=Pn(ae)}qe=null}else qe=null;Ae!==null&&Cs(be,we,Ae,qe,!1),Pe!==null&&jt!==null&&Cs(be,jt,Pe,qe,!0)}}e:{if(we=ue?No(ue):window,Ae=we.nodeName&&we.nodeName.toLowerCase(),Ae==="select"||Ae==="input"&&we.type==="file")var Be=_c;else if(kc(we))if(Di)Be=Sc;else{Be=Fi;var Ge=Nc}else(Ae=we.nodeName)&&Ae.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Be=Bi);if(Be&&(Be=Be(r,ue))){va(be,Be,u,ve);break e}Ge&&Ge(r,we,ue),r==="focusout"&&(Ge=we._wrapperState)&&Ge.controlled&&we.type==="number"&&Ye(we,"number",we.value)}switch(Ge=ue?No(ue):window,r){case"focusin":(kc(Ge)||Ge.contentEditable==="true")&&(tr=Ge,Sa=ue,ja=null);break;case"focusout":ja=Sa=tr=null;break;case"mousedown":xo=!0;break;case"contextmenu":case"mouseup":case"dragend":xo=!1,Hi(be,u,ve);break;case"selectionchange":if(Wi)break;case"keydown":case"keyup":Hi(be,u,ve)}var Ve;if(wa)e:{switch(r){case"compositionstart":var Ke="onCompositionStart";break e;case"compositionend":Ke="onCompositionEnd";break e;case"compositionupdate":Ke="onCompositionUpdate";break e}Ke=void 0}else Gr?xc(r,u)&&(Ke="onCompositionEnd"):r==="keydown"&&u.keyCode===229&&(Ke="onCompositionStart");Ke&&(wc&&u.locale!=="ko"&&(Gr||Ke!=="onCompositionStart"?Ke==="onCompositionEnd"&&Gr&&(Ve=kn()):($n=ve,bn="value"in $n?$n.value:$n.textContent,Gr=!0)),Ge=Es(ue,Ke),0<Ge.length&&(Ke=new sn(Ke,r,null,u,ve),be.push({event:Ke,listeners:Ge}),Ve?Ke.data=Ve:(Ve=Pi(u),Ve!==null&&(Ke.data=Ve)))),(Ve=nh?Sr(r,u):rh(r,u))&&(ue=Es(ue,"onBeforeInput"),0<ue.length&&(ve=new sn("onBeforeInput","beforeinput",null,u,ve),be.push({event:ve,listeners:ue}),ve.data=Ve))}ot(be,o)})}function js(r,o,u){return{instance:r,listener:o,currentTarget:u}}function Es(r,o){for(var u=o+"Capture",g=[];r!==null;){var w=r,k=w.stateNode;w.tag===5&&k!==null&&(w=k,k=Pr(r,u),k!=null&&g.unshift(js(r,k,w)),k=Pr(r,o),k!=null&&g.push(js(r,k,w))),r=r.return}return g}function Pn(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function Cs(r,o,u,g,w){for(var k=o._reactName,T=[];u!==null&&u!==g;){var X=u,te=X.alternate,ue=X.stateNode;if(te!==null&&te===g)break;X.tag===5&&ue!==null&&(X=ue,w?(te=Pr(u,k),te!=null&&T.unshift(js(u,te,X))):w||(te=Pr(u,k),te!=null&&T.push(js(u,te,X)))),u=u.return}T.length!==0&&r.push({event:o,listeners:T})}var Ct=/\r\n?/g,Tc=/\u0000|\uFFFD/g;function Wx(r){return(typeof r=="string"?r:""+r).replace(Ct,`
38
+ `).replace(Tc,"")}function Ac(r,o,u){if(o=Wx(o),Wx(r)!==o&&u)throw Error(n(425))}function Rc(){}var sh=null,ah=null;function oh(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var ih=typeof setTimeout=="function"?setTimeout:void 0,aR=typeof clearTimeout=="function"?clearTimeout:void 0,Hx=typeof Promise=="function"?Promise:void 0,oR=typeof queueMicrotask=="function"?queueMicrotask:typeof Hx<"u"?function(r){return Hx.resolve(null).then(r).catch(iR)}:ih;function iR(r){setTimeout(function(){throw r})}function lh(r,o){var u=o,g=0;do{var w=u.nextSibling;if(r.removeChild(u),w&&w.nodeType===8)if(u=w.data,u==="/$"){if(g===0){r.removeChild(w),fa(o);return}g--}else u!=="$"&&u!=="$?"&&u!=="$!"||g++;u=w}while(u);fa(o)}function Ts(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function Gx(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="$"||u==="$!"||u==="$?"){if(o===0)return r;o--}else u==="/$"&&o++}r=r.previousSibling}return null}var _o=Math.random().toString(36).slice(2),jr="__reactFiber$"+_o,Zi="__reactProps$"+_o,Yr="__reactContainer$"+_o,ch="__reactEvents$"+_o,lR="__reactListeners$"+_o,cR="__reactHandles$"+_o;function Aa(r){var o=r[jr];if(o)return o;for(var u=r.parentNode;u;){if(o=u[Yr]||u[jr]){if(u=o.alternate,o.child!==null||u!==null&&u.child!==null)for(r=Gx(r);r!==null;){if(u=r[jr])return u;r=Gx(r)}return o}r=u,u=r.parentNode}return null}function Ji(r){return r=r[jr]||r[Yr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function No(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function Mc(r){return r[Zi]||null}var uh=[],So=-1;function As(r){return{current:r}}function yt(r){0>So||(r.current=uh[So],uh[So]=null,So--)}function pt(r,o){So++,uh[So]=r.current,r.current=o}var Rs={},Jt=As(Rs),hn=As(!1),Ra=Rs;function jo(r,o){var u=r.type.contextTypes;if(!u)return Rs;var g=r.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===o)return g.__reactInternalMemoizedMaskedChildContext;var w={},k;for(k in u)w[k]=o[k];return g&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=w),w}function fn(r){return r=r.childContextTypes,r!=null}function Ic(){yt(hn),yt(Jt)}function Vx(r,o,u){if(Jt.current!==Rs)throw Error(n(168));pt(Jt,o),pt(hn,u)}function Yx(r,o,u){var g=r.stateNode;if(o=o.childContextTypes,typeof g.getChildContext!="function")return u;g=g.getChildContext();for(var w in g)if(!(w in o))throw Error(n(108,V(r)||"Unknown",w));return Y({},u,g)}function $c(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Rs,Ra=Jt.current,pt(Jt,r),pt(hn,hn.current),!0}function Kx(r,o,u){var g=r.stateNode;if(!g)throw Error(n(169));u?(r=Yx(r,o,Ra),g.__reactInternalMemoizedMergedChildContext=r,yt(hn),yt(Jt),pt(Jt,r)):yt(hn),pt(hn,u)}var Kr=null,Oc=!1,dh=!1;function Xx(r){Kr===null?Kr=[r]:Kr.push(r)}function uR(r){Oc=!0,Xx(r)}function Ms(){if(!dh&&Kr!==null){dh=!0;var r=0,o=at;try{var u=Kr;for(at=1;r<u.length;r++){var g=u[r];do g=g(!0);while(g!==null)}Kr=null,Oc=!1}catch(w){throw Kr!==null&&(Kr=Kr.slice(r+1)),aa(ia,Ms),w}finally{at=o,dh=!1}}return null}var Eo=[],Co=0,Pc=null,Lc=0,Ln=[],Dn=0,Ma=null,Xr=1,Qr="";function Ia(r,o){Eo[Co++]=Lc,Eo[Co++]=Pc,Pc=r,Lc=o}function Qx(r,o,u){Ln[Dn++]=Xr,Ln[Dn++]=Qr,Ln[Dn++]=Ma,Ma=r;var g=Xr;r=Qr;var w=32-cn(g)-1;g&=~(1<<w),u+=1;var k=32-cn(o)+w;if(30<k){var T=w-w%5;k=(g&(1<<T)-1).toString(32),g>>=T,w-=T,Xr=1<<32-cn(o)+w|u<<w|g,Qr=k+r}else Xr=1<<k|u<<w|g,Qr=r}function hh(r){r.return!==null&&(Ia(r,1),Qx(r,1,0))}function fh(r){for(;r===Pc;)Pc=Eo[--Co],Eo[Co]=null,Lc=Eo[--Co],Eo[Co]=null;for(;r===Ma;)Ma=Ln[--Dn],Ln[Dn]=null,Qr=Ln[--Dn],Ln[Dn]=null,Xr=Ln[--Dn],Ln[Dn]=null}var _n=null,Nn=null,wt=!1,nr=null;function Zx(r,o){var u=zn(5,null,null,0);u.elementType="DELETED",u.stateNode=o,u.return=r,o=r.deletions,o===null?(r.deletions=[u],r.flags|=16):o.push(u)}function Jx(r,o){switch(r.tag){case 5:var u=r.type;return o=o.nodeType!==1||u.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,_n=r,Nn=Ts(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,_n=r,Nn=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(u=Ma!==null?{id:Xr,overflow:Qr}:null,r.memoizedState={dehydrated:o,treeContext:u,retryLane:1073741824},u=zn(18,null,null,0),u.stateNode=o,u.return=r,r.child=u,_n=r,Nn=null,!0):!1;default:return!1}}function ph(r){return(r.mode&1)!==0&&(r.flags&128)===0}function mh(r){if(wt){var o=Nn;if(o){var u=o;if(!Jx(r,o)){if(ph(r))throw Error(n(418));o=Ts(u.nextSibling);var g=_n;o&&Jx(r,o)?Zx(g,u):(r.flags=r.flags&-4097|2,wt=!1,_n=r)}}else{if(ph(r))throw Error(n(418));r.flags=r.flags&-4097|2,wt=!1,_n=r}}}function e0(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;_n=r}function Dc(r){if(r!==_n)return!1;if(!wt)return e0(r),wt=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!oh(r.type,r.memoizedProps)),o&&(o=Nn)){if(ph(r))throw t0(),Error(n(418));for(;o;)Zx(r,o),o=Ts(o.nextSibling)}if(e0(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var u=r.data;if(u==="/$"){if(o===0){Nn=Ts(r.nextSibling);break e}o--}else u!=="$"&&u!=="$!"&&u!=="$?"||o++}r=r.nextSibling}Nn=null}}else Nn=_n?Ts(r.stateNode.nextSibling):null;return!0}function t0(){for(var r=Nn;r;)r=Ts(r.nextSibling)}function To(){Nn=_n=null,wt=!1}function gh(r){nr===null?nr=[r]:nr.push(r)}var dR=C.ReactCurrentBatchConfig;function el(r,o,u){if(r=u.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(u._owner){if(u=u._owner,u){if(u.tag!==1)throw Error(n(309));var g=u.stateNode}if(!g)throw Error(n(147,r));var w=g,k=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===k?o.ref:(o=function(T){var X=w.refs;T===null?delete X[k]:X[k]=T},o._stringRef=k,o)}if(typeof r!="string")throw Error(n(284));if(!u._owner)throw Error(n(290,r))}return r}function qc(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function n0(r){var o=r._init;return o(r._payload)}function r0(r){function o(ae,re){if(r){var le=ae.deletions;le===null?(ae.deletions=[re],ae.flags|=16):le.push(re)}}function u(ae,re){if(!r)return null;for(;re!==null;)o(ae,re),re=re.sibling;return null}function g(ae,re){for(ae=new Map;re!==null;)re.key!==null?ae.set(re.key,re):ae.set(re.index,re),re=re.sibling;return ae}function w(ae,re){return ae=Fs(ae,re),ae.index=0,ae.sibling=null,ae}function k(ae,re,le){return ae.index=le,r?(le=ae.alternate,le!==null?(le=le.index,le<re?(ae.flags|=2,re):le):(ae.flags|=2,re)):(ae.flags|=1048576,re)}function T(ae){return r&&ae.alternate===null&&(ae.flags|=2),ae}function X(ae,re,le,_e){return re===null||re.tag!==6?(re=lf(le,ae.mode,_e),re.return=ae,re):(re=w(re,le),re.return=ae,re)}function te(ae,re,le,_e){var Be=le.type;return Be===$?ve(ae,re,le.props.children,_e,le.key):re!==null&&(re.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===K&&n0(Be)===re.type)?(_e=w(re,le.props),_e.ref=el(ae,re,le),_e.return=ae,_e):(_e=cu(le.type,le.key,le.props,null,ae.mode,_e),_e.ref=el(ae,re,le),_e.return=ae,_e)}function ue(ae,re,le,_e){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=cf(le,ae.mode,_e),re.return=ae,re):(re=w(re,le.children||[]),re.return=ae,re)}function ve(ae,re,le,_e,Be){return re===null||re.tag!==7?(re=Ba(le,ae.mode,_e,Be),re.return=ae,re):(re=w(re,le),re.return=ae,re)}function be(ae,re,le){if(typeof re=="string"&&re!==""||typeof re=="number")return re=lf(""+re,ae.mode,le),re.return=ae,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case R:return le=cu(re.type,re.key,re.props,null,ae.mode,le),le.ref=el(ae,null,re),le.return=ae,le;case I:return re=cf(re,ae.mode,le),re.return=ae,re;case K:var _e=re._init;return be(ae,_e(re._payload),le)}if(it(re)||D(re))return re=Ba(re,ae.mode,le,null),re.return=ae,re;qc(ae,re)}return null}function we(ae,re,le,_e){var Be=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Be!==null?null:X(ae,re,""+le,_e);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case R:return le.key===Be?te(ae,re,le,_e):null;case I:return le.key===Be?ue(ae,re,le,_e):null;case K:return Be=le._init,we(ae,re,Be(le._payload),_e)}if(it(le)||D(le))return Be!==null?null:ve(ae,re,le,_e,null);qc(ae,le)}return null}function Ae(ae,re,le,_e,Be){if(typeof _e=="string"&&_e!==""||typeof _e=="number")return ae=ae.get(le)||null,X(re,ae,""+_e,Be);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case R:return ae=ae.get(_e.key===null?le:_e.key)||null,te(re,ae,_e,Be);case I:return ae=ae.get(_e.key===null?le:_e.key)||null,ue(re,ae,_e,Be);case K:var Ge=_e._init;return Ae(ae,re,le,Ge(_e._payload),Be)}if(it(_e)||D(_e))return ae=ae.get(le)||null,ve(re,ae,_e,Be,null);qc(re,_e)}return null}function Pe(ae,re,le,_e){for(var Be=null,Ge=null,Ve=re,Ke=re=0,Ut=null;Ve!==null&&Ke<le.length;Ke++){Ve.index>Ke?(Ut=Ve,Ve=null):Ut=Ve.sibling;var st=we(ae,Ve,le[Ke],_e);if(st===null){Ve===null&&(Ve=Ut);break}r&&Ve&&st.alternate===null&&o(ae,Ve),re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st,Ve=Ut}if(Ke===le.length)return u(ae,Ve),wt&&Ia(ae,Ke),Be;if(Ve===null){for(;Ke<le.length;Ke++)Ve=be(ae,le[Ke],_e),Ve!==null&&(re=k(Ve,re,Ke),Ge===null?Be=Ve:Ge.sibling=Ve,Ge=Ve);return wt&&Ia(ae,Ke),Be}for(Ve=g(ae,Ve);Ke<le.length;Ke++)Ut=Ae(Ve,ae,Ke,le[Ke],_e),Ut!==null&&(r&&Ut.alternate!==null&&Ve.delete(Ut.key===null?Ke:Ut.key),re=k(Ut,re,Ke),Ge===null?Be=Ut:Ge.sibling=Ut,Ge=Ut);return r&&Ve.forEach(function(Bs){return o(ae,Bs)}),wt&&Ia(ae,Ke),Be}function qe(ae,re,le,_e){var Be=D(le);if(typeof Be!="function")throw Error(n(150));if(le=Be.call(le),le==null)throw Error(n(151));for(var Ge=Be=null,Ve=re,Ke=re=0,Ut=null,st=le.next();Ve!==null&&!st.done;Ke++,st=le.next()){Ve.index>Ke?(Ut=Ve,Ve=null):Ut=Ve.sibling;var Bs=we(ae,Ve,st.value,_e);if(Bs===null){Ve===null&&(Ve=Ut);break}r&&Ve&&Bs.alternate===null&&o(ae,Ve),re=k(Bs,re,Ke),Ge===null?Be=Bs:Ge.sibling=Bs,Ge=Bs,Ve=Ut}if(st.done)return u(ae,Ve),wt&&Ia(ae,Ke),Be;if(Ve===null){for(;!st.done;Ke++,st=le.next())st=be(ae,st.value,_e),st!==null&&(re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st);return wt&&Ia(ae,Ke),Be}for(Ve=g(ae,Ve);!st.done;Ke++,st=le.next())st=Ae(Ve,ae,Ke,st.value,_e),st!==null&&(r&&st.alternate!==null&&Ve.delete(st.key===null?Ke:st.key),re=k(st,re,Ke),Ge===null?Be=st:Ge.sibling=st,Ge=st);return r&&Ve.forEach(function(WR){return o(ae,WR)}),wt&&Ia(ae,Ke),Be}function jt(ae,re,le,_e){if(typeof le=="object"&&le!==null&&le.type===$&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case R:e:{for(var Be=le.key,Ge=re;Ge!==null;){if(Ge.key===Be){if(Be=le.type,Be===$){if(Ge.tag===7){u(ae,Ge.sibling),re=w(Ge,le.props.children),re.return=ae,ae=re;break e}}else if(Ge.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===K&&n0(Be)===Ge.type){u(ae,Ge.sibling),re=w(Ge,le.props),re.ref=el(ae,Ge,le),re.return=ae,ae=re;break e}u(ae,Ge);break}else o(ae,Ge);Ge=Ge.sibling}le.type===$?(re=Ba(le.props.children,ae.mode,_e,le.key),re.return=ae,ae=re):(_e=cu(le.type,le.key,le.props,null,ae.mode,_e),_e.ref=el(ae,re,le),_e.return=ae,ae=_e)}return T(ae);case I:e:{for(Ge=le.key;re!==null;){if(re.key===Ge)if(re.tag===4&&re.stateNode.containerInfo===le.containerInfo&&re.stateNode.implementation===le.implementation){u(ae,re.sibling),re=w(re,le.children||[]),re.return=ae,ae=re;break e}else{u(ae,re);break}else o(ae,re);re=re.sibling}re=cf(le,ae.mode,_e),re.return=ae,ae=re}return T(ae);case K:return Ge=le._init,jt(ae,re,Ge(le._payload),_e)}if(it(le))return Pe(ae,re,le,_e);if(D(le))return qe(ae,re,le,_e);qc(ae,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,re!==null&&re.tag===6?(u(ae,re.sibling),re=w(re,le),re.return=ae,ae=re):(u(ae,re),re=lf(le,ae.mode,_e),re.return=ae,ae=re),T(ae)):u(ae,re)}return jt}var Ao=r0(!0),s0=r0(!1),Fc=As(null),Bc=null,Ro=null,yh=null;function wh(){yh=Ro=Bc=null}function vh(r){var o=Fc.current;yt(Fc),r._currentValue=o}function xh(r,o,u){for(;r!==null;){var g=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,g!==null&&(g.childLanes|=o)):g!==null&&(g.childLanes&o)!==o&&(g.childLanes|=o),r===u)break;r=r.return}}function Mo(r,o){Bc=r,yh=Ro=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(pn=!0),r.firstContext=null)}function qn(r){var o=r._currentValue;if(yh!==r)if(r={context:r,memoizedValue:o,next:null},Ro===null){if(Bc===null)throw Error(n(308));Ro=r,Bc.dependencies={lanes:0,firstContext:r}}else Ro=Ro.next=r;return o}var $a=null;function bh(r){$a===null?$a=[r]:$a.push(r)}function a0(r,o,u,g){var w=o.interleaved;return w===null?(u.next=u,bh(o)):(u.next=w.next,w.next=u),o.interleaved=u,Zr(r,g)}function Zr(r,o){r.lanes|=o;var u=r.alternate;for(u!==null&&(u.lanes|=o),u=r,r=r.return;r!==null;)r.childLanes|=o,u=r.alternate,u!==null&&(u.childLanes|=o),u=r,r=r.return;return u.tag===3?u.stateNode:null}var Is=!1;function kh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function o0(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Jr(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function $s(r,o,u){var g=r.updateQueue;if(g===null)return null;if(g=g.shared,(nt&2)!==0){var w=g.pending;return w===null?o.next=o:(o.next=w.next,w.next=o),g.pending=o,Zr(r,u)}return w=g.interleaved,w===null?(o.next=o,bh(g)):(o.next=w.next,w.next=o),g.interleaved=o,Zr(r,u)}function zc(r,o,u){if(o=o.updateQueue,o!==null&&(o=o.shared,(u&4194240)!==0)){var g=o.lanes;g&=r.pendingLanes,u|=g,o.lanes=u,co(r,u)}}function i0(r,o){var u=r.updateQueue,g=r.alternate;if(g!==null&&(g=g.updateQueue,u===g)){var w=null,k=null;if(u=u.firstBaseUpdate,u!==null){do{var T={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};k===null?w=k=T:k=k.next=T,u=u.next}while(u!==null);k===null?w=k=o:k=k.next=o}else w=k=o;u={baseState:g.baseState,firstBaseUpdate:w,lastBaseUpdate:k,shared:g.shared,effects:g.effects},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=o:r.next=o,u.lastBaseUpdate=o}function Uc(r,o,u,g){var w=r.updateQueue;Is=!1;var k=w.firstBaseUpdate,T=w.lastBaseUpdate,X=w.shared.pending;if(X!==null){w.shared.pending=null;var te=X,ue=te.next;te.next=null,T===null?k=ue:T.next=ue,T=te;var ve=r.alternate;ve!==null&&(ve=ve.updateQueue,X=ve.lastBaseUpdate,X!==T&&(X===null?ve.firstBaseUpdate=ue:X.next=ue,ve.lastBaseUpdate=te))}if(k!==null){var be=w.baseState;T=0,ve=ue=te=null,X=k;do{var we=X.lane,Ae=X.eventTime;if((g&we)===we){ve!==null&&(ve=ve.next={eventTime:Ae,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Pe=r,qe=X;switch(we=o,Ae=u,qe.tag){case 1:if(Pe=qe.payload,typeof Pe=="function"){be=Pe.call(Ae,be,we);break e}be=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=qe.payload,we=typeof Pe=="function"?Pe.call(Ae,be,we):Pe,we==null)break e;be=Y({},be,we);break e;case 2:Is=!0}}X.callback!==null&&X.lane!==0&&(r.flags|=64,we=w.effects,we===null?w.effects=[X]:we.push(X))}else Ae={eventTime:Ae,lane:we,tag:X.tag,payload:X.payload,callback:X.callback,next:null},ve===null?(ue=ve=Ae,te=be):ve=ve.next=Ae,T|=we;if(X=X.next,X===null){if(X=w.shared.pending,X===null)break;we=X,X=we.next,we.next=null,w.lastBaseUpdate=we,w.shared.pending=null}}while(!0);if(ve===null&&(te=be),w.baseState=te,w.firstBaseUpdate=ue,w.lastBaseUpdate=ve,o=w.shared.interleaved,o!==null){w=o;do T|=w.lane,w=w.next;while(w!==o)}else k===null&&(w.shared.lanes=0);La|=T,r.lanes=T,r.memoizedState=be}}function l0(r,o,u){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var g=r[o],w=g.callback;if(w!==null){if(g.callback=null,g=u,typeof w!="function")throw Error(n(191,w));w.call(g)}}}var tl={},Er=As(tl),nl=As(tl),rl=As(tl);function Oa(r){if(r===tl)throw Error(n(174));return r}function _h(r,o){switch(pt(rl,o),pt(nl,r),pt(Er,tl),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:Fe(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=Fe(o,r)}yt(Er),pt(Er,o)}function Io(){yt(Er),yt(nl),yt(rl)}function c0(r){Oa(rl.current);var o=Oa(Er.current),u=Fe(o,r.type);o!==u&&(pt(nl,r),pt(Er,u))}function Nh(r){nl.current===r&&(yt(Er),yt(nl))}var kt=As(0);function Wc(r){for(var o=r;o!==null;){if(o.tag===13){var u=o.memoizedState;if(u!==null&&(u=u.dehydrated,u===null||u.data==="$?"||u.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Sh=[];function jh(){for(var r=0;r<Sh.length;r++)Sh[r]._workInProgressVersionPrimary=null;Sh.length=0}var Hc=C.ReactCurrentDispatcher,Eh=C.ReactCurrentBatchConfig,Pa=0,_t=null,Ot=null,Bt=null,Gc=!1,sl=!1,al=0,hR=0;function en(){throw Error(n(321))}function Ch(r,o){if(o===null)return!1;for(var u=0;u<o.length&&u<r.length;u++)if(!dn(r[u],o[u]))return!1;return!0}function Th(r,o,u,g,w,k){if(Pa=k,_t=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,Hc.current=r===null||r.memoizedState===null?gR:yR,r=u(g,w),sl){k=0;do{if(sl=!1,al=0,25<=k)throw Error(n(301));k+=1,Bt=Ot=null,o.updateQueue=null,Hc.current=wR,r=u(g,w)}while(sl)}if(Hc.current=Kc,o=Ot!==null&&Ot.next!==null,Pa=0,Bt=Ot=_t=null,Gc=!1,o)throw Error(n(300));return r}function Ah(){var r=al!==0;return al=0,r}function Cr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bt===null?_t.memoizedState=Bt=r:Bt=Bt.next=r,Bt}function Fn(){if(Ot===null){var r=_t.alternate;r=r!==null?r.memoizedState:null}else r=Ot.next;var o=Bt===null?_t.memoizedState:Bt.next;if(o!==null)Bt=o,Ot=r;else{if(r===null)throw Error(n(310));Ot=r,r={memoizedState:Ot.memoizedState,baseState:Ot.baseState,baseQueue:Ot.baseQueue,queue:Ot.queue,next:null},Bt===null?_t.memoizedState=Bt=r:Bt=Bt.next=r}return Bt}function ol(r,o){return typeof o=="function"?o(r):o}function Rh(r){var o=Fn(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var g=Ot,w=g.baseQueue,k=u.pending;if(k!==null){if(w!==null){var T=w.next;w.next=k.next,k.next=T}g.baseQueue=w=k,u.pending=null}if(w!==null){k=w.next,g=g.baseState;var X=T=null,te=null,ue=k;do{var ve=ue.lane;if((Pa&ve)===ve)te!==null&&(te=te.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),g=ue.hasEagerState?ue.eagerState:r(g,ue.action);else{var be={lane:ve,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};te===null?(X=te=be,T=g):te=te.next=be,_t.lanes|=ve,La|=ve}ue=ue.next}while(ue!==null&&ue!==k);te===null?T=g:te.next=X,dn(g,o.memoizedState)||(pn=!0),o.memoizedState=g,o.baseState=T,o.baseQueue=te,u.lastRenderedState=g}if(r=u.interleaved,r!==null){w=r;do k=w.lane,_t.lanes|=k,La|=k,w=w.next;while(w!==r)}else w===null&&(u.lanes=0);return[o.memoizedState,u.dispatch]}function Mh(r){var o=Fn(),u=o.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=r;var g=u.dispatch,w=u.pending,k=o.memoizedState;if(w!==null){u.pending=null;var T=w=w.next;do k=r(k,T.action),T=T.next;while(T!==w);dn(k,o.memoizedState)||(pn=!0),o.memoizedState=k,o.baseQueue===null&&(o.baseState=k),u.lastRenderedState=k}return[k,g]}function u0(){}function d0(r,o){var u=_t,g=Fn(),w=o(),k=!dn(g.memoizedState,w);if(k&&(g.memoizedState=w,pn=!0),g=g.queue,Ih(p0.bind(null,u,g,r),[r]),g.getSnapshot!==o||k||Bt!==null&&Bt.memoizedState.tag&1){if(u.flags|=2048,il(9,f0.bind(null,u,g,w,o),void 0,null),zt===null)throw Error(n(349));(Pa&30)!==0||h0(u,o,w)}return w}function h0(r,o,u){r.flags|=16384,r={getSnapshot:o,value:u},o=_t.updateQueue,o===null?(o={lastEffect:null,stores:null},_t.updateQueue=o,o.stores=[r]):(u=o.stores,u===null?o.stores=[r]:u.push(r))}function f0(r,o,u,g){o.value=u,o.getSnapshot=g,m0(o)&&g0(r)}function p0(r,o,u){return u(function(){m0(o)&&g0(r)})}function m0(r){var o=r.getSnapshot;r=r.value;try{var u=o();return!dn(r,u)}catch{return!0}}function g0(r){var o=Zr(r,1);o!==null&&or(o,r,1,-1)}function y0(r){var o=Cr();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:r},o.queue=r,r=r.dispatch=mR.bind(null,_t,r),[o.memoizedState,r]}function il(r,o,u,g){return r={tag:r,create:o,destroy:u,deps:g,next:null},o=_t.updateQueue,o===null?(o={lastEffect:null,stores:null},_t.updateQueue=o,o.lastEffect=r.next=r):(u=o.lastEffect,u===null?o.lastEffect=r.next=r:(g=u.next,u.next=r,r.next=g,o.lastEffect=r)),r}function w0(){return Fn().memoizedState}function Vc(r,o,u,g){var w=Cr();_t.flags|=r,w.memoizedState=il(1|o,u,void 0,g===void 0?null:g)}function Yc(r,o,u,g){var w=Fn();g=g===void 0?null:g;var k=void 0;if(Ot!==null){var T=Ot.memoizedState;if(k=T.destroy,g!==null&&Ch(g,T.deps)){w.memoizedState=il(o,u,k,g);return}}_t.flags|=r,w.memoizedState=il(1|o,u,k,g)}function v0(r,o){return Vc(8390656,8,r,o)}function Ih(r,o){return Yc(2048,8,r,o)}function x0(r,o){return Yc(4,2,r,o)}function b0(r,o){return Yc(4,4,r,o)}function k0(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function _0(r,o,u){return u=u!=null?u.concat([r]):null,Yc(4,4,k0.bind(null,o,r),u)}function $h(){}function N0(r,o){var u=Fn();o=o===void 0?null:o;var g=u.memoizedState;return g!==null&&o!==null&&Ch(o,g[1])?g[0]:(u.memoizedState=[r,o],r)}function S0(r,o){var u=Fn();o=o===void 0?null:o;var g=u.memoizedState;return g!==null&&o!==null&&Ch(o,g[1])?g[0]:(r=r(),u.memoizedState=[r,o],r)}function j0(r,o,u){return(Pa&21)===0?(r.baseState&&(r.baseState=!1,pn=!0),r.memoizedState=u):(dn(u,o)||(u=Et(),_t.lanes|=u,La|=u,r.baseState=!0),o)}function fR(r,o){var u=at;at=u!==0&&4>u?u:4,r(!0);var g=Eh.transition;Eh.transition={};try{r(!1),o()}finally{at=u,Eh.transition=g}}function E0(){return Fn().memoizedState}function pR(r,o,u){var g=Ds(r);if(u={lane:g,action:u,hasEagerState:!1,eagerState:null,next:null},C0(r))T0(o,u);else if(u=a0(r,o,u,g),u!==null){var w=on();or(u,r,g,w),A0(u,o,g)}}function mR(r,o,u){var g=Ds(r),w={lane:g,action:u,hasEagerState:!1,eagerState:null,next:null};if(C0(r))T0(o,w);else{var k=r.alternate;if(r.lanes===0&&(k===null||k.lanes===0)&&(k=o.lastRenderedReducer,k!==null))try{var T=o.lastRenderedState,X=k(T,u);if(w.hasEagerState=!0,w.eagerState=X,dn(X,T)){var te=o.interleaved;te===null?(w.next=w,bh(o)):(w.next=te.next,te.next=w),o.interleaved=w;return}}catch{}finally{}u=a0(r,o,w,g),u!==null&&(w=on(),or(u,r,g,w),A0(u,o,g))}}function C0(r){var o=r.alternate;return r===_t||o!==null&&o===_t}function T0(r,o){sl=Gc=!0;var u=r.pending;u===null?o.next=o:(o.next=u.next,u.next=o),r.pending=o}function A0(r,o,u){if((u&4194240)!==0){var g=o.lanes;g&=r.pendingLanes,u|=g,o.lanes=u,co(r,u)}}var Kc={readContext:qn,useCallback:en,useContext:en,useEffect:en,useImperativeHandle:en,useInsertionEffect:en,useLayoutEffect:en,useMemo:en,useReducer:en,useRef:en,useState:en,useDebugValue:en,useDeferredValue:en,useTransition:en,useMutableSource:en,useSyncExternalStore:en,useId:en,unstable_isNewReconciler:!1},gR={readContext:qn,useCallback:function(r,o){return Cr().memoizedState=[r,o===void 0?null:o],r},useContext:qn,useEffect:v0,useImperativeHandle:function(r,o,u){return u=u!=null?u.concat([r]):null,Vc(4194308,4,k0.bind(null,o,r),u)},useLayoutEffect:function(r,o){return Vc(4194308,4,r,o)},useInsertionEffect:function(r,o){return Vc(4,2,r,o)},useMemo:function(r,o){var u=Cr();return o=o===void 0?null:o,r=r(),u.memoizedState=[r,o],r},useReducer:function(r,o,u){var g=Cr();return o=u!==void 0?u(o):o,g.memoizedState=g.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},g.queue=r,r=r.dispatch=pR.bind(null,_t,r),[g.memoizedState,r]},useRef:function(r){var o=Cr();return r={current:r},o.memoizedState=r},useState:y0,useDebugValue:$h,useDeferredValue:function(r){return Cr().memoizedState=r},useTransition:function(){var r=y0(!1),o=r[0];return r=fR.bind(null,r[1]),Cr().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,u){var g=_t,w=Cr();if(wt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=o(),zt===null)throw Error(n(349));(Pa&30)!==0||h0(g,o,u)}w.memoizedState=u;var k={value:u,getSnapshot:o};return w.queue=k,v0(p0.bind(null,g,k,r),[r]),g.flags|=2048,il(9,f0.bind(null,g,k,u,o),void 0,null),u},useId:function(){var r=Cr(),o=zt.identifierPrefix;if(wt){var u=Qr,g=Xr;u=(g&~(1<<32-cn(g)-1)).toString(32)+u,o=":"+o+"R"+u,u=al++,0<u&&(o+="H"+u.toString(32)),o+=":"}else u=hR++,o=":"+o+"r"+u.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},yR={readContext:qn,useCallback:N0,useContext:qn,useEffect:Ih,useImperativeHandle:_0,useInsertionEffect:x0,useLayoutEffect:b0,useMemo:S0,useReducer:Rh,useRef:w0,useState:function(){return Rh(ol)},useDebugValue:$h,useDeferredValue:function(r){var o=Fn();return j0(o,Ot.memoizedState,r)},useTransition:function(){var r=Rh(ol)[0],o=Fn().memoizedState;return[r,o]},useMutableSource:u0,useSyncExternalStore:d0,useId:E0,unstable_isNewReconciler:!1},wR={readContext:qn,useCallback:N0,useContext:qn,useEffect:Ih,useImperativeHandle:_0,useInsertionEffect:x0,useLayoutEffect:b0,useMemo:S0,useReducer:Mh,useRef:w0,useState:function(){return Mh(ol)},useDebugValue:$h,useDeferredValue:function(r){var o=Fn();return Ot===null?o.memoizedState=r:j0(o,Ot.memoizedState,r)},useTransition:function(){var r=Mh(ol)[0],o=Fn().memoizedState;return[r,o]},useMutableSource:u0,useSyncExternalStore:d0,useId:E0,unstable_isNewReconciler:!1};function rr(r,o){if(r&&r.defaultProps){o=Y({},o),r=r.defaultProps;for(var u in r)o[u]===void 0&&(o[u]=r[u]);return o}return o}function Oh(r,o,u,g){o=r.memoizedState,u=u(g,o),u=u==null?o:Y({},o,u),r.memoizedState=u,r.lanes===0&&(r.updateQueue.baseState=u)}var Xc={isMounted:function(r){return(r=r._reactInternals)?Rn(r)===r:!1},enqueueSetState:function(r,o,u){r=r._reactInternals;var g=on(),w=Ds(r),k=Jr(g,w);k.payload=o,u!=null&&(k.callback=u),o=$s(r,k,w),o!==null&&(or(o,r,w,g),zc(o,r,w))},enqueueReplaceState:function(r,o,u){r=r._reactInternals;var g=on(),w=Ds(r),k=Jr(g,w);k.tag=1,k.payload=o,u!=null&&(k.callback=u),o=$s(r,k,w),o!==null&&(or(o,r,w,g),zc(o,r,w))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var u=on(),g=Ds(r),w=Jr(u,g);w.tag=2,o!=null&&(w.callback=o),o=$s(r,w,g),o!==null&&(or(o,r,g,u),zc(o,r,g))}};function R0(r,o,u,g,w,k,T){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(g,k,T):o.prototype&&o.prototype.isPureReactComponent?!ks(u,g)||!ks(w,k):!0}function M0(r,o,u){var g=!1,w=Rs,k=o.contextType;return typeof k=="object"&&k!==null?k=qn(k):(w=fn(o)?Ra:Jt.current,g=o.contextTypes,k=(g=g!=null)?jo(r,w):Rs),o=new o(u,k),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Xc,r.stateNode=o,o._reactInternals=r,g&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=w,r.__reactInternalMemoizedMaskedChildContext=k),o}function I0(r,o,u,g){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(u,g),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(u,g),o.state!==r&&Xc.enqueueReplaceState(o,o.state,null)}function Ph(r,o,u,g){var w=r.stateNode;w.props=u,w.state=r.memoizedState,w.refs={},kh(r);var k=o.contextType;typeof k=="object"&&k!==null?w.context=qn(k):(k=fn(o)?Ra:Jt.current,w.context=jo(r,k)),w.state=r.memoizedState,k=o.getDerivedStateFromProps,typeof k=="function"&&(Oh(r,o,k,u),w.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(o=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),o!==w.state&&Xc.enqueueReplaceState(w,w.state,null),Uc(r,u,w,g),w.state=r.memoizedState),typeof w.componentDidMount=="function"&&(r.flags|=4194308)}function $o(r,o){try{var u="",g=o;do u+=U(g),g=g.return;while(g);var w=u}catch(k){w=`
39
39
  Error generating stack: `+k.message+`
40
- `+k.stack}return{value:r,source:o,stack:w,digest:null}}function Ph(r,o,u){return{value:r,source:null,stack:u??null,digest:o??null}}function Lh(r,o){try{console.error(o.value)}catch(u){setTimeout(function(){throw u})}}var vR=typeof WeakMap=="function"?WeakMap:Map;function $0(r,o,u){u=Jr(-1,u),u.tag=3,u.payload={element:null};var g=o.value;return u.callback=function(){nu||(nu=!0,Zh=g),Lh(r,o)},u}function O0(r,o,u){u=Jr(-1,u),u.tag=3;var g=r.type.getDerivedStateFromError;if(typeof g=="function"){var w=o.value;u.payload=function(){return g(w)},u.callback=function(){Lh(r,o)}}var k=r.stateNode;return k!==null&&typeof k.componentDidCatch=="function"&&(u.callback=function(){Lh(r,o),typeof g!="function"&&(Os===null?Os=new Set([this]):Os.add(this));var T=o.stack;this.componentDidCatch(o.value,{componentStack:T!==null?T:""})}),u}function P0(r,o,u){var g=r.pingCache;if(g===null){g=r.pingCache=new vR;var w=new Set;g.set(o,w)}else w=g.get(o),w===void 0&&(w=new Set,g.set(o,w));w.has(u)||(w.add(u),r=IR.bind(null,r,o,u),o.then(r,r))}function L0(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function D0(r,o,u,g,w){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,u.flags|=131072,u.flags&=-52805,u.tag===1&&(u.alternate===null?u.tag=17:(o=Jr(-1,1),o.tag=2,Is(u,o,1))),u.lanes|=1),r):(r.flags|=65536,r.lanes=w,r)}var xR=C.ReactCurrentOwner,pn=!1;function an(r,o,u,g){o.child=r===null?s0(o,null,u,g):To(o,r.child,u,g)}function q0(r,o,u,g,w){u=u.render;var k=o.ref;return Ro(o,w),g=Ch(r,o,u,g,k,w),u=Th(),r!==null&&!pn?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,es(r,o,w)):(wt&&u&&dh(o),o.flags|=1,an(r,o,g,w),o.child)}function F0(r,o,u,g,w){if(r===null){var k=u.type;return typeof k=="function"&&!af(k)&&k.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(o.tag=15,o.type=k,B0(r,o,k,g,w)):(r=lu(u.type,null,g,o,o.mode,w),r.ref=o.ref,r.return=o,o.child=r)}if(k=r.child,(r.lanes&w)===0){var T=k.memoizedProps;if(u=u.compare,u=u!==null?u:bs,u(T,g)&&r.ref===o.ref)return es(r,o,w)}return o.flags|=1,r=qs(k,g),r.ref=o.ref,r.return=o,o.child=r}function B0(r,o,u,g,w){if(r!==null){var k=r.memoizedProps;if(bs(k,g)&&r.ref===o.ref)if(pn=!1,o.pendingProps=g=k,(r.lanes&w)!==0)(r.flags&131072)!==0&&(pn=!0);else return o.lanes=r.lanes,es(r,o,w)}return Dh(r,o,u,g,w)}function z0(r,o,u){var g=o.pendingProps,w=g.children,k=r!==null?r.memoizedState:null;if(g.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},pt(Oo,Sn),Sn|=u;else{if((u&1073741824)===0)return r=k!==null?k.baseLanes|u:u,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,pt(Oo,Sn),Sn|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=k!==null?k.baseLanes:u,pt(Oo,Sn),Sn|=g}else k!==null?(g=k.baseLanes|u,o.memoizedState=null):g=u,pt(Oo,Sn),Sn|=g;return an(r,o,w,u),o.child}function U0(r,o){var u=o.ref;(r===null&&u!==null||r!==null&&r.ref!==u)&&(o.flags|=512,o.flags|=2097152)}function Dh(r,o,u,g,w){var k=fn(u)?Aa:Jt.current;return k=So(o,k),Ro(o,w),u=Ch(r,o,u,g,k,w),g=Th(),r!==null&&!pn?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,es(r,o,w)):(wt&&g&&dh(o),o.flags|=1,an(r,o,u,w),o.child)}function W0(r,o,u,g,w){if(fn(u)){var k=!0;Ic(o)}else k=!1;if(Ro(o,w),o.stateNode===null)Qc(r,o),M0(o,u,g),Oh(o,u,g,w),g=!0;else if(r===null){var T=o.stateNode,X=o.memoizedProps;T.props=X;var te=T.context,ue=u.contextType;typeof ue=="object"&&ue!==null?ue=qn(ue):(ue=fn(u)?Aa:Jt.current,ue=So(o,ue));var ve=u.getDerivedStateFromProps,be=typeof ve=="function"||typeof T.getSnapshotBeforeUpdate=="function";be||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(X!==g||te!==ue)&&I0(o,T,g,ue),Ms=!1;var we=o.memoizedState;T.state=we,zc(o,g,T,w),te=o.memoizedState,X!==g||we!==te||hn.current||Ms?(typeof ve=="function"&&($h(o,u,ve,g),te=o.memoizedState),(X=Ms||R0(o,u,X,g,we,te,ue))?(be||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(o.flags|=4194308)):(typeof T.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=g,o.memoizedState=te),T.props=g,T.state=te,T.context=ue,g=X):(typeof T.componentDidMount=="function"&&(o.flags|=4194308),g=!1)}else{T=o.stateNode,o0(r,o),X=o.memoizedProps,ue=o.type===o.elementType?X:rr(o.type,X),T.props=ue,be=o.pendingProps,we=T.context,te=u.contextType,typeof te=="object"&&te!==null?te=qn(te):(te=fn(u)?Aa:Jt.current,te=So(o,te));var Ae=u.getDerivedStateFromProps;(ve=typeof Ae=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(X!==be||we!==te)&&I0(o,T,g,te),Ms=!1,we=o.memoizedState,T.state=we,zc(o,g,T,w);var Pe=o.memoizedState;X!==be||we!==Pe||hn.current||Ms?(typeof Ae=="function"&&($h(o,u,Ae,g),Pe=o.memoizedState),(ue=Ms||R0(o,u,ue,g,we,Pe,te)||!1)?(ve||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(g,Pe,te),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(g,Pe,te)),typeof T.componentDidUpdate=="function"&&(o.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof T.componentDidUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),o.memoizedProps=g,o.memoizedState=Pe),T.props=g,T.state=Pe,T.context=te,g=ue):(typeof T.componentDidUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),g=!1)}return qh(r,o,u,g,k,w)}function qh(r,o,u,g,w,k){U0(r,o);var T=(o.flags&128)!==0;if(!g&&!T)return w&&Kx(o,u,!1),es(r,o,k);g=o.stateNode,xR.current=o;var X=T&&typeof u.getDerivedStateFromError!="function"?null:g.render();return o.flags|=1,r!==null&&T?(o.child=To(o,r.child,null,k),o.child=To(o,null,X,k)):an(r,o,X,k),o.memoizedState=g.state,w&&Kx(o,u,!0),o.child}function H0(r){var o=r.stateNode;o.pendingContext?Vx(r,o.pendingContext,o.pendingContext!==o.context):o.context&&Vx(r,o.context,!1),kh(r,o.containerInfo)}function G0(r,o,u,g,w){return Co(),mh(w),o.flags|=256,an(r,o,u,g),o.child}var Fh={dehydrated:null,treeContext:null,retryLane:0};function Bh(r){return{baseLanes:r,cachePool:null,transitions:null}}function V0(r,o,u){var g=o.pendingProps,w=kt.current,k=!1,T=(o.flags&128)!==0,X;if((X=T)||(X=r!==null&&r.memoizedState===null?!1:(w&2)!==0),X?(k=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(w|=1),pt(kt,w&1),r===null)return ph(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(T=g.children,r=g.fallback,k?(g=o.mode,k=o.child,T={mode:"hidden",children:T},(g&1)===0&&k!==null?(k.childLanes=0,k.pendingProps=T):k=cu(T,g,0,null),r=Fa(r,g,u,null),k.return=o,r.return=o,k.sibling=r,o.child=k,o.child.memoizedState=Bh(u),o.memoizedState=Fh,r):zh(o,T));if(w=r.memoizedState,w!==null&&(X=w.dehydrated,X!==null))return bR(r,o,T,g,X,w,u);if(k){k=g.fallback,T=o.mode,w=r.child,X=w.sibling;var te={mode:"hidden",children:g.children};return(T&1)===0&&o.child!==w?(g=o.child,g.childLanes=0,g.pendingProps=te,o.deletions=null):(g=qs(w,te),g.subtreeFlags=w.subtreeFlags&14680064),X!==null?k=qs(X,k):(k=Fa(k,T,u,null),k.flags|=2),k.return=o,g.return=o,g.sibling=k,o.child=g,g=k,k=o.child,T=r.child.memoizedState,T=T===null?Bh(u):{baseLanes:T.baseLanes|u,cachePool:null,transitions:T.transitions},k.memoizedState=T,k.childLanes=r.childLanes&~u,o.memoizedState=Fh,g}return k=r.child,r=k.sibling,g=qs(k,{mode:"visible",children:g.children}),(o.mode&1)===0&&(g.lanes=u),g.return=o,g.sibling=null,r!==null&&(u=o.deletions,u===null?(o.deletions=[r],o.flags|=16):u.push(r)),o.child=g,o.memoizedState=null,g}function zh(r,o){return o=cu({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function Xc(r,o,u,g){return g!==null&&mh(g),To(o,r.child,null,u),r=zh(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function bR(r,o,u,g,w,k,T){if(u)return o.flags&256?(o.flags&=-257,g=Ph(Error(n(422))),Xc(r,o,T,g)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(k=g.fallback,w=o.mode,g=cu({mode:"visible",children:g.children},w,0,null),k=Fa(k,w,T,null),k.flags|=2,g.return=o,k.return=o,g.sibling=k,o.child=g,(o.mode&1)!==0&&To(o,r.child,null,T),o.child.memoizedState=Bh(T),o.memoizedState=Fh,k);if((o.mode&1)===0)return Xc(r,o,T,null);if(w.data==="$!"){if(g=w.nextSibling&&w.nextSibling.dataset,g)var X=g.dgst;return g=X,k=Error(n(419)),g=Ph(k,g,void 0),Xc(r,o,T,g)}if(X=(T&r.childLanes)!==0,pn||X){if(g=zt,g!==null){switch(T&-T){case 4:w=2;break;case 16:w=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:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(g.suspendedLanes|T))!==0?0:w,w!==0&&w!==k.retryLane&&(k.retryLane=w,Zr(r,w),or(g,r,w,-1))}return sf(),g=Ph(Error(n(421))),Xc(r,o,T,g)}return w.data==="$?"?(o.flags|=128,o.child=r.child,o=$R.bind(null,r),w._reactRetry=o,null):(r=k.treeContext,Nn=Cs(w.nextSibling),_n=o,wt=!0,nr=null,r!==null&&(Ln[Dn++]=Xr,Ln[Dn++]=Qr,Ln[Dn++]=Ra,Xr=r.id,Qr=r.overflow,Ra=o),o=zh(o,g.children),o.flags|=4096,o)}function Y0(r,o,u){r.lanes|=o;var g=r.alternate;g!==null&&(g.lanes|=o),vh(r.return,o,u)}function Uh(r,o,u,g,w){var k=r.memoizedState;k===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:g,tail:u,tailMode:w}:(k.isBackwards=o,k.rendering=null,k.renderingStartTime=0,k.last=g,k.tail=u,k.tailMode=w)}function K0(r,o,u){var g=o.pendingProps,w=g.revealOrder,k=g.tail;if(an(r,o,g.children,u),g=kt.current,(g&2)!==0)g=g&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Y0(r,u,o);else if(r.tag===19)Y0(r,u,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}g&=1}if(pt(kt,g),(o.mode&1)===0)o.memoizedState=null;else switch(w){case"forwards":for(u=o.child,w=null;u!==null;)r=u.alternate,r!==null&&Uc(r)===null&&(w=u),u=u.sibling;u=w,u===null?(w=o.child,o.child=null):(w=u.sibling,u.sibling=null),Uh(o,!1,w,u,k);break;case"backwards":for(u=null,w=o.child,o.child=null;w!==null;){if(r=w.alternate,r!==null&&Uc(r)===null){o.child=w;break}r=w.sibling,w.sibling=u,u=w,w=r}Uh(o,!0,u,null,k);break;case"together":Uh(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function Qc(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function es(r,o,u){if(r!==null&&(o.dependencies=r.dependencies),Pa|=o.lanes,(u&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,u=qs(r,r.pendingProps),o.child=u,u.return=o;r.sibling!==null;)r=r.sibling,u=u.sibling=qs(r,r.pendingProps),u.return=o;u.sibling=null}return o.child}function kR(r,o,u){switch(o.tag){case 3:H0(o),Co();break;case 5:c0(o);break;case 1:fn(o.type)&&Ic(o);break;case 4:kh(o,o.stateNode.containerInfo);break;case 10:var g=o.type._context,w=o.memoizedProps.value;pt(qc,g._currentValue),g._currentValue=w;break;case 13:if(g=o.memoizedState,g!==null)return g.dehydrated!==null?(pt(kt,kt.current&1),o.flags|=128,null):(u&o.child.childLanes)!==0?V0(r,o,u):(pt(kt,kt.current&1),r=es(r,o,u),r!==null?r.sibling:null);pt(kt,kt.current&1);break;case 19:if(g=(u&o.childLanes)!==0,(r.flags&128)!==0){if(g)return K0(r,o,u);o.flags|=128}if(w=o.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),pt(kt,kt.current),g)break;return null;case 22:case 23:return o.lanes=0,z0(r,o,u)}return es(r,o,u)}var X0,Wh,Q0,Z0;X0=function(r,o){for(var u=o.child;u!==null;){if(u.tag===5||u.tag===6)r.appendChild(u.stateNode);else if(u.tag!==4&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===o)break;for(;u.sibling===null;){if(u.return===null||u.return===o)return;u=u.return}u.sibling.return=u.return,u=u.sibling}},Wh=function(){},Q0=function(r,o,u,g){var w=r.memoizedProps;if(w!==g){r=o.stateNode,$a(Er.current);var k=null;switch(u){case"input":w=xe(r,w),g=xe(r,g),k=[];break;case"select":w=Y({},w,{value:void 0}),g=Y({},g,{value:void 0}),k=[];break;case"textarea":w=He(r,w),g=He(r,g),k=[];break;default:typeof w.onClick!="function"&&typeof g.onClick=="function"&&(r.onclick=Ac)}lt(u,g);var T;u=null;for(ue in w)if(!g.hasOwnProperty(ue)&&w.hasOwnProperty(ue)&&w[ue]!=null)if(ue==="style"){var X=w[ue];for(T in X)X.hasOwnProperty(T)&&(u||(u={}),u[T]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(a.hasOwnProperty(ue)?k||(k=[]):(k=k||[]).push(ue,null));for(ue in g){var te=g[ue];if(X=w!=null?w[ue]:void 0,g.hasOwnProperty(ue)&&te!==X&&(te!=null||X!=null))if(ue==="style")if(X){for(T in X)!X.hasOwnProperty(T)||te&&te.hasOwnProperty(T)||(u||(u={}),u[T]="");for(T in te)te.hasOwnProperty(T)&&X[T]!==te[T]&&(u||(u={}),u[T]=te[T])}else u||(k||(k=[]),k.push(ue,u)),u=te;else ue==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,X=X?X.__html:void 0,te!=null&&X!==te&&(k=k||[]).push(ue,te)):ue==="children"?typeof te!="string"&&typeof te!="number"||(k=k||[]).push(ue,""+te):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(a.hasOwnProperty(ue)?(te!=null&&ue==="onScroll"&&Qe("scroll",r),k||X===te||(k=[])):(k=k||[]).push(ue,te))}u&&(k=k||[]).push("style",u);var ue=k;(o.updateQueue=ue)&&(o.flags|=4)}},Z0=function(r,o,u,g){u!==g&&(o.flags|=4)};function il(r,o){if(!wt)switch(r.tailMode){case"hidden":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?r.tail=null:u.sibling=null;break;case"collapsed":u=r.tail;for(var g=null;u!==null;)u.alternate!==null&&(g=u),u=u.sibling;g===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:g.sibling=null}}function tn(r){var o=r.alternate!==null&&r.alternate.child===r.child,u=0,g=0;if(o)for(var w=r.child;w!==null;)u|=w.lanes|w.childLanes,g|=w.subtreeFlags&14680064,g|=w.flags&14680064,w.return=r,w=w.sibling;else for(w=r.child;w!==null;)u|=w.lanes|w.childLanes,g|=w.subtreeFlags,g|=w.flags,w.return=r,w=w.sibling;return r.subtreeFlags|=g,r.childLanes=u,o}function _R(r,o,u){var g=o.pendingProps;switch(hh(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return tn(o),null;case 1:return fn(o.type)&&Mc(),tn(o),null;case 3:return g=o.stateNode,Mo(),yt(hn),yt(Jt),Sh(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(r===null||r.child===null)&&(Lc(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,nr!==null&&(tf(nr),nr=null))),Wh(r,o),tn(o),null;case 5:_h(o);var w=$a(nl.current);if(u=o.type,r!==null&&o.stateNode!=null)Q0(r,o,u,g,w),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!g){if(o.stateNode===null)throw Error(n(166));return tn(o),null}if(r=$a(Er.current),Lc(o)){g=o.stateNode,u=o.type;var k=o.memoizedProps;switch(g[jr]=o,g[Qi]=k,r=(o.mode&1)!==0,u){case"dialog":Qe("cancel",g),Qe("close",g);break;case"iframe":case"object":case"embed":Qe("load",g);break;case"video":case"audio":for(w=0;w<We.length;w++)Qe(We[w],g);break;case"source":Qe("error",g);break;case"img":case"image":case"link":Qe("error",g),Qe("load",g);break;case"details":Qe("toggle",g);break;case"input":ye(g,k),Qe("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!k.multiple},Qe("invalid",g);break;case"textarea":Xe(g,k),Qe("invalid",g)}lt(u,k),w=null;for(var T in k)if(k.hasOwnProperty(T)){var X=k[T];T==="children"?typeof X=="string"?g.textContent!==X&&(k.suppressHydrationWarning!==!0&&Tc(g.textContent,X,r),w=["children",X]):typeof X=="number"&&g.textContent!==""+X&&(k.suppressHydrationWarning!==!0&&Tc(g.textContent,X,r),w=["children",""+X]):a.hasOwnProperty(T)&&X!=null&&T==="onScroll"&&Qe("scroll",g)}switch(u){case"input":Ie(g),je(g,k,!0);break;case"textarea":Ie(g),ge(g);break;case"select":case"option":break;default:typeof k.onClick=="function"&&(g.onclick=Ac)}g=w,o.updateQueue=g,g!==null&&(o.flags|=4)}else{T=w.nodeType===9?w:w.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Se(u)),r==="http://www.w3.org/1999/xhtml"?u==="script"?(r=T.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof g.is=="string"?r=T.createElement(u,{is:g.is}):(r=T.createElement(u),u==="select"&&(T=r,g.multiple?T.multiple=!0:g.size&&(T.size=g.size))):r=T.createElementNS(r,u),r[jr]=o,r[Qi]=g,X0(r,o,!1,!1),o.stateNode=r;e:{switch(T=ut(u,g),u){case"dialog":Qe("cancel",r),Qe("close",r),w=g;break;case"iframe":case"object":case"embed":Qe("load",r),w=g;break;case"video":case"audio":for(w=0;w<We.length;w++)Qe(We[w],r);w=g;break;case"source":Qe("error",r),w=g;break;case"img":case"image":case"link":Qe("error",r),Qe("load",r),w=g;break;case"details":Qe("toggle",r),w=g;break;case"input":ye(r,g),w=xe(r,g),Qe("invalid",r);break;case"option":w=g;break;case"select":r._wrapperState={wasMultiple:!!g.multiple},w=Y({},g,{value:void 0}),Qe("invalid",r);break;case"textarea":Xe(r,g),w=He(r,g),Qe("invalid",r);break;default:w=g}lt(u,w),X=w;for(k in X)if(X.hasOwnProperty(k)){var te=X[k];k==="style"?Te(r,te):k==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&xt(r,te)):k==="children"?typeof te=="string"?(u!=="textarea"||te!=="")&&ht(r,te):typeof te=="number"&&ht(r,""+te):k!=="suppressContentEditableWarning"&&k!=="suppressHydrationWarning"&&k!=="autoFocus"&&(a.hasOwnProperty(k)?te!=null&&k==="onScroll"&&Qe("scroll",r):te!=null&&E(r,k,te,T))}switch(u){case"input":Ie(r),je(r,g,!1);break;case"textarea":Ie(r),ge(r);break;case"option":g.value!=null&&r.setAttribute("value",""+ie(g.value));break;case"select":r.multiple=!!g.multiple,k=g.value,k!=null?Ne(r,!!g.multiple,k,!1):g.defaultValue!=null&&Ne(r,!!g.multiple,g.defaultValue,!0);break;default:typeof w.onClick=="function"&&(r.onclick=Ac)}switch(u){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return tn(o),null;case 6:if(r&&o.stateNode!=null)Z0(r,o,r.memoizedProps,g);else{if(typeof g!="string"&&o.stateNode===null)throw Error(n(166));if(u=$a(nl.current),$a(Er.current),Lc(o)){if(g=o.stateNode,u=o.memoizedProps,g[jr]=o,(k=g.nodeValue!==u)&&(r=_n,r!==null))switch(r.tag){case 3:Tc(g.nodeValue,u,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Tc(g.nodeValue,u,(r.mode&1)!==0)}k&&(o.flags|=4)}else g=(u.nodeType===9?u:u.ownerDocument).createTextNode(g),g[jr]=o,o.stateNode=g}return tn(o),null;case 13:if(yt(kt),g=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(wt&&Nn!==null&&(o.mode&1)!==0&&(o.flags&128)===0)t0(),Co(),o.flags|=98560,k=!1;else if(k=Lc(o),g!==null&&g.dehydrated!==null){if(r===null){if(!k)throw Error(n(318));if(k=o.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(n(317));k[jr]=o}else Co(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;tn(o),k=!1}else nr!==null&&(tf(nr),nr=null),k=!0;if(!k)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=u,o):(g=g!==null,g!==(r!==null&&r.memoizedState!==null)&&g&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(kt.current&1)!==0?Pt===0&&(Pt=3):sf())),o.updateQueue!==null&&(o.flags|=4),tn(o),null);case 4:return Mo(),Wh(r,o),r===null&&Ca(o.stateNode.containerInfo),tn(o),null;case 10:return wh(o.type._context),tn(o),null;case 17:return fn(o.type)&&Mc(),tn(o),null;case 19:if(yt(kt),k=o.memoizedState,k===null)return tn(o),null;if(g=(o.flags&128)!==0,T=k.rendering,T===null)if(g)il(k,!1);else{if(Pt!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(T=Uc(r),T!==null){for(o.flags|=128,il(k,!1),g=T.updateQueue,g!==null&&(o.updateQueue=g,o.flags|=4),o.subtreeFlags=0,g=u,u=o.child;u!==null;)k=u,r=g,k.flags&=14680066,T=k.alternate,T===null?(k.childLanes=0,k.lanes=r,k.child=null,k.subtreeFlags=0,k.memoizedProps=null,k.memoizedState=null,k.updateQueue=null,k.dependencies=null,k.stateNode=null):(k.childLanes=T.childLanes,k.lanes=T.lanes,k.child=T.child,k.subtreeFlags=0,k.deletions=null,k.memoizedProps=T.memoizedProps,k.memoizedState=T.memoizedState,k.updateQueue=T.updateQueue,k.type=T.type,r=T.dependencies,k.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),u=u.sibling;return pt(kt,kt.current&1|2),o.child}r=r.sibling}k.tail!==null&&dt()>Po&&(o.flags|=128,g=!0,il(k,!1),o.lanes=4194304)}else{if(!g)if(r=Uc(T),r!==null){if(o.flags|=128,g=!0,u=r.updateQueue,u!==null&&(o.updateQueue=u,o.flags|=4),il(k,!0),k.tail===null&&k.tailMode==="hidden"&&!T.alternate&&!wt)return tn(o),null}else 2*dt()-k.renderingStartTime>Po&&u!==1073741824&&(o.flags|=128,g=!0,il(k,!1),o.lanes=4194304);k.isBackwards?(T.sibling=o.child,o.child=T):(u=k.last,u!==null?u.sibling=T:o.child=T,k.last=T)}return k.tail!==null?(o=k.tail,k.rendering=o,k.tail=o.sibling,k.renderingStartTime=dt(),o.sibling=null,u=kt.current,pt(kt,g?u&1|2:u&1),o):(tn(o),null);case 22:case 23:return rf(),g=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==g&&(o.flags|=8192),g&&(o.mode&1)!==0?(Sn&1073741824)!==0&&(tn(o),o.subtreeFlags&6&&(o.flags|=8192)):tn(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function NR(r,o){switch(hh(o),o.tag){case 1:return fn(o.type)&&Mc(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return Mo(),yt(hn),yt(Jt),Sh(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return _h(o),null;case 13:if(yt(kt),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));Co()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return yt(kt),null;case 4:return Mo(),null;case 10:return wh(o.type._context),null;case 22:case 23:return rf(),null;case 24:return null;default:return null}}var Zc=!1,nn=!1,SR=typeof WeakSet=="function"?WeakSet:Set,$e=null;function $o(r,o){var u=r.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(g){Nt(r,o,g)}else u.current=null}function Hh(r,o,u){try{u()}catch(g){Nt(r,o,g)}}var J0=!1;function jR(r,o){if(rh=fo,r=_a(),zi(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var g=u.getSelection&&u.getSelection();if(g&&g.rangeCount!==0){u=g.anchorNode;var w=g.anchorOffset,k=g.focusNode;g=g.focusOffset;try{u.nodeType,k.nodeType}catch{u=null;break e}var T=0,X=-1,te=-1,ue=0,ve=0,be=r,we=null;t:for(;;){for(var Ae;be!==u||w!==0&&be.nodeType!==3||(X=T+w),be!==k||g!==0&&be.nodeType!==3||(te=T+g),be.nodeType===3&&(T+=be.nodeValue.length),(Ae=be.firstChild)!==null;)we=be,be=Ae;for(;;){if(be===r)break t;if(we===u&&++ue===w&&(X=T),we===k&&++ve===g&&(te=T),(Ae=be.nextSibling)!==null)break;be=we,we=be.parentNode}be=Ae}u=X===-1||te===-1?null:{start:X,end:te}}else u=null}u=u||{start:0,end:0}}else u=null;for(sh={focusedElem:r,selectionRange:u},fo=!1,$e=o;$e!==null;)if(o=$e,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,$e=r;else for(;$e!==null;){o=$e;try{var Pe=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var qe=Pe.memoizedProps,jt=Pe.memoizedState,ae=o.stateNode,re=ae.getSnapshotBeforeUpdate(o.elementType===o.type?qe:rr(o.type,qe),jt);ae.__reactInternalSnapshotBeforeUpdate=re}break;case 3:var le=o.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(_e){Nt(o,o.return,_e)}if(r=o.sibling,r!==null){r.return=o.return,$e=r;break}$e=o.return}return Pe=J0,J0=!1,Pe}function ll(r,o,u){var g=o.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var w=g=g.next;do{if((w.tag&r)===r){var k=w.destroy;w.destroy=void 0,k!==void 0&&Hh(o,u,k)}w=w.next}while(w!==g)}}function Jc(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var u=o=o.next;do{if((u.tag&r)===r){var g=u.create;u.destroy=g()}u=u.next}while(u!==o)}}function Gh(r){var o=r.ref;if(o!==null){var u=r.stateNode;switch(r.tag){case 5:r=u;break;default:r=u}typeof o=="function"?o(r):o.current=r}}function eb(r){var o=r.alternate;o!==null&&(r.alternate=null,eb(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[jr],delete o[Qi],delete o[lh],delete o[lR],delete o[cR])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function tb(r){return r.tag===5||r.tag===3||r.tag===4}function nb(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||tb(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Vh(r,o,u){var g=r.tag;if(g===5||g===6)r=r.stateNode,o?u.nodeType===8?u.parentNode.insertBefore(r,o):u.insertBefore(r,o):(u.nodeType===8?(o=u.parentNode,o.insertBefore(r,u)):(o=u,o.appendChild(r)),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=Ac));else if(g!==4&&(r=r.child,r!==null))for(Vh(r,o,u),r=r.sibling;r!==null;)Vh(r,o,u),r=r.sibling}function Yh(r,o,u){var g=r.tag;if(g===5||g===6)r=r.stateNode,o?u.insertBefore(r,o):u.appendChild(r);else if(g!==4&&(r=r.child,r!==null))for(Yh(r,o,u),r=r.sibling;r!==null;)Yh(r,o,u),r=r.sibling}var Gt=null,sr=!1;function $s(r,o,u){for(u=u.child;u!==null;)rb(r,o,u),u=u.sibling}function rb(r,o,u){if(It&&typeof It.onCommitFiberUnmount=="function")try{It.onCommitFiberUnmount(zr,u)}catch{}switch(u.tag){case 5:nn||$o(u,o);case 6:var g=Gt,w=sr;Gt=null,$s(r,o,u),Gt=g,sr=w,Gt!==null&&(sr?(r=Gt,u=u.stateNode,r.nodeType===8?r.parentNode.removeChild(u):r.removeChild(u)):Gt.removeChild(u.stateNode));break;case 18:Gt!==null&&(sr?(r=Gt,u=u.stateNode,r.nodeType===8?ih(r.parentNode,u):r.nodeType===1&&ih(r,u),ha(r)):ih(Gt,u.stateNode));break;case 4:g=Gt,w=sr,Gt=u.stateNode.containerInfo,sr=!0,$s(r,o,u),Gt=g,sr=w;break;case 0:case 11:case 14:case 15:if(!nn&&(g=u.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){w=g=g.next;do{var k=w,T=k.destroy;k=k.tag,T!==void 0&&((k&2)!==0||(k&4)!==0)&&Hh(u,o,T),w=w.next}while(w!==g)}$s(r,o,u);break;case 1:if(!nn&&($o(u,o),g=u.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=u.memoizedProps,g.state=u.memoizedState,g.componentWillUnmount()}catch(X){Nt(u,o,X)}$s(r,o,u);break;case 21:$s(r,o,u);break;case 22:u.mode&1?(nn=(g=nn)||u.memoizedState!==null,$s(r,o,u),nn=g):$s(r,o,u);break;default:$s(r,o,u)}}function sb(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var u=r.stateNode;u===null&&(u=r.stateNode=new SR),o.forEach(function(g){var w=OR.bind(null,r,g);u.has(g)||(u.add(g),g.then(w,w))})}}function ar(r,o){var u=o.deletions;if(u!==null)for(var g=0;g<u.length;g++){var w=u[g];try{var k=r,T=o,X=T;e:for(;X!==null;){switch(X.tag){case 5:Gt=X.stateNode,sr=!1;break e;case 3:Gt=X.stateNode.containerInfo,sr=!0;break e;case 4:Gt=X.stateNode.containerInfo,sr=!0;break e}X=X.return}if(Gt===null)throw Error(n(160));rb(k,T,w),Gt=null,sr=!1;var te=w.alternate;te!==null&&(te.return=null),w.return=null}catch(ue){Nt(w,o,ue)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)ab(o,r),o=o.sibling}function ab(r,o){var u=r.alternate,g=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(ar(o,r),Tr(r),g&4){try{ll(3,r,r.return),Jc(3,r)}catch(qe){Nt(r,r.return,qe)}try{ll(5,r,r.return)}catch(qe){Nt(r,r.return,qe)}}break;case 1:ar(o,r),Tr(r),g&512&&u!==null&&$o(u,u.return);break;case 5:if(ar(o,r),Tr(r),g&512&&u!==null&&$o(u,u.return),r.flags&32){var w=r.stateNode;try{ht(w,"")}catch(qe){Nt(r,r.return,qe)}}if(g&4&&(w=r.stateNode,w!=null)){var k=r.memoizedProps,T=u!==null?u.memoizedProps:k,X=r.type,te=r.updateQueue;if(r.updateQueue=null,te!==null)try{X==="input"&&k.type==="radio"&&k.name!=null&&ze(w,k),ut(X,T);var ue=ut(X,k);for(T=0;T<te.length;T+=2){var ve=te[T],be=te[T+1];ve==="style"?Te(w,be):ve==="dangerouslySetInnerHTML"?xt(w,be):ve==="children"?ht(w,be):E(w,ve,be,ue)}switch(X){case"input":ke(w,k);break;case"textarea":he(w,k);break;case"select":var we=w._wrapperState.wasMultiple;w._wrapperState.wasMultiple=!!k.multiple;var Ae=k.value;Ae!=null?Ne(w,!!k.multiple,Ae,!1):we!==!!k.multiple&&(k.defaultValue!=null?Ne(w,!!k.multiple,k.defaultValue,!0):Ne(w,!!k.multiple,k.multiple?[]:"",!1))}w[Qi]=k}catch(qe){Nt(r,r.return,qe)}}break;case 6:if(ar(o,r),Tr(r),g&4){if(r.stateNode===null)throw Error(n(162));w=r.stateNode,k=r.memoizedProps;try{w.nodeValue=k}catch(qe){Nt(r,r.return,qe)}}break;case 3:if(ar(o,r),Tr(r),g&4&&u!==null&&u.memoizedState.isDehydrated)try{ha(o.containerInfo)}catch(qe){Nt(r,r.return,qe)}break;case 4:ar(o,r),Tr(r);break;case 13:ar(o,r),Tr(r),w=r.child,w.flags&8192&&(k=w.memoizedState!==null,w.stateNode.isHidden=k,!k||w.alternate!==null&&w.alternate.memoizedState!==null||(Qh=dt())),g&4&&sb(r);break;case 22:if(ve=u!==null&&u.memoizedState!==null,r.mode&1?(nn=(ue=nn)||ve,ar(o,r),nn=ue):ar(o,r),Tr(r),g&8192){if(ue=r.memoizedState!==null,(r.stateNode.isHidden=ue)&&!ve&&(r.mode&1)!==0)for($e=r,ve=r.child;ve!==null;){for(be=$e=ve;$e!==null;){switch(we=$e,Ae=we.child,we.tag){case 0:case 11:case 14:case 15:ll(4,we,we.return);break;case 1:$o(we,we.return);var Pe=we.stateNode;if(typeof Pe.componentWillUnmount=="function"){g=we,u=we.return;try{o=g,Pe.props=o.memoizedProps,Pe.state=o.memoizedState,Pe.componentWillUnmount()}catch(qe){Nt(g,u,qe)}}break;case 5:$o(we,we.return);break;case 22:if(we.memoizedState!==null){lb(be);continue}}Ae!==null?(Ae.return=we,$e=Ae):lb(be)}ve=ve.sibling}e:for(ve=null,be=r;;){if(be.tag===5){if(ve===null){ve=be;try{w=be.stateNode,ue?(k=w.style,typeof k.setProperty=="function"?k.setProperty("display","none","important"):k.display="none"):(X=be.stateNode,te=be.memoizedProps.style,T=te!=null&&te.hasOwnProperty("display")?te.display:null,X.style.display=Oe("display",T))}catch(qe){Nt(r,r.return,qe)}}}else if(be.tag===6){if(ve===null)try{be.stateNode.nodeValue=ue?"":be.memoizedProps}catch(qe){Nt(r,r.return,qe)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===r)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===r)break e;for(;be.sibling===null;){if(be.return===null||be.return===r)break e;ve===be&&(ve=null),be=be.return}ve===be&&(ve=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:ar(o,r),Tr(r),g&4&&sb(r);break;case 21:break;default:ar(o,r),Tr(r)}}function Tr(r){var o=r.flags;if(o&2){try{e:{for(var u=r.return;u!==null;){if(tb(u)){var g=u;break e}u=u.return}throw Error(n(160))}switch(g.tag){case 5:var w=g.stateNode;g.flags&32&&(ht(w,""),g.flags&=-33);var k=nb(r);Yh(r,k,w);break;case 3:case 4:var T=g.stateNode.containerInfo,X=nb(r);Vh(r,X,T);break;default:throw Error(n(161))}}catch(te){Nt(r,r.return,te)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function ER(r,o,u){$e=r,ob(r)}function ob(r,o,u){for(var g=(r.mode&1)!==0;$e!==null;){var w=$e,k=w.child;if(w.tag===22&&g){var T=w.memoizedState!==null||Zc;if(!T){var X=w.alternate,te=X!==null&&X.memoizedState!==null||nn;X=Zc;var ue=nn;if(Zc=T,(nn=te)&&!ue)for($e=w;$e!==null;)T=$e,te=T.child,T.tag===22&&T.memoizedState!==null?cb(w):te!==null?(te.return=T,$e=te):cb(w);for(;k!==null;)$e=k,ob(k),k=k.sibling;$e=w,Zc=X,nn=ue}ib(r)}else(w.subtreeFlags&8772)!==0&&k!==null?(k.return=w,$e=k):ib(r)}}function ib(r){for(;$e!==null;){var o=$e;if((o.flags&8772)!==0){var u=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:nn||Jc(5,o);break;case 1:var g=o.stateNode;if(o.flags&4&&!nn)if(u===null)g.componentDidMount();else{var w=o.elementType===o.type?u.memoizedProps:rr(o.type,u.memoizedProps);g.componentDidUpdate(w,u.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var k=o.updateQueue;k!==null&&l0(o,k,g);break;case 3:var T=o.updateQueue;if(T!==null){if(u=null,o.child!==null)switch(o.child.tag){case 5:u=o.child.stateNode;break;case 1:u=o.child.stateNode}l0(o,T,u)}break;case 5:var X=o.stateNode;if(u===null&&o.flags&4){u=X;var te=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&u.focus();break;case"img":te.src&&(u.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var ue=o.alternate;if(ue!==null){var ve=ue.memoizedState;if(ve!==null){var be=ve.dehydrated;be!==null&&ha(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}nn||o.flags&512&&Gh(o)}catch(we){Nt(o,o.return,we)}}if(o===r){$e=null;break}if(u=o.sibling,u!==null){u.return=o.return,$e=u;break}$e=o.return}}function lb(r){for(;$e!==null;){var o=$e;if(o===r){$e=null;break}var u=o.sibling;if(u!==null){u.return=o.return,$e=u;break}$e=o.return}}function cb(r){for(;$e!==null;){var o=$e;try{switch(o.tag){case 0:case 11:case 15:var u=o.return;try{Jc(4,o)}catch(te){Nt(o,u,te)}break;case 1:var g=o.stateNode;if(typeof g.componentDidMount=="function"){var w=o.return;try{g.componentDidMount()}catch(te){Nt(o,w,te)}}var k=o.return;try{Gh(o)}catch(te){Nt(o,k,te)}break;case 5:var T=o.return;try{Gh(o)}catch(te){Nt(o,T,te)}}}catch(te){Nt(o,o.return,te)}if(o===r){$e=null;break}var X=o.sibling;if(X!==null){X.return=o.return,$e=X;break}$e=o.return}}var CR=Math.ceil,eu=C.ReactCurrentDispatcher,Kh=C.ReactCurrentOwner,Bn=C.ReactCurrentBatchConfig,nt=0,zt=null,Tt=null,Vt=0,Sn=0,Oo=Ts(0),Pt=0,cl=null,Pa=0,tu=0,Xh=0,ul=null,mn=null,Qh=0,Po=1/0,ts=null,nu=!1,Zh=null,Os=null,ru=!1,Ps=null,su=0,dl=0,Jh=null,au=-1,ou=0;function on(){return(nt&6)!==0?dt():au!==-1?au:au=dt()}function Ls(r){return(r.mode&1)===0?1:(nt&2)!==0&&Vt!==0?Vt&-Vt:dR.transition!==null?(ou===0&&(ou=Et()),ou):(r=at,r!==0||(r=window.event,r=r===void 0?16:Si(r.type)),r)}function or(r,o,u,g){if(50<dl)throw dl=0,Jh=null,Error(n(185));rn(r,u,g),((nt&2)===0||r!==zt)&&(r===zt&&((nt&2)===0&&(tu|=u),Pt===4&&Ds(r,Vt)),gn(r,g),u===1&&nt===0&&(o.mode&1)===0&&(Po=dt()+500,$c&&Rs()))}function gn(r,o){var u=r.callbackNode;Hd(r,o);var g=Xt(r,r===zt?Vt:0);if(g===0)u!==null&&ro(u),r.callbackNode=null,r.callbackPriority=0;else if(o=g&-g,r.callbackPriority!==o){if(u!=null&&ro(u),o===1)r.tag===0?uR(db.bind(null,r)):Xx(db.bind(null,r)),oR(function(){(nt&6)===0&&Rs()}),u=null;else{switch(Zn(g)){case 1:u=oa;break;case 4:u=qr;break;case 16:u=Fr;break;case 536870912:u=ia;break;default:u=Fr}u=vb(u,ub.bind(null,r))}r.callbackPriority=o,r.callbackNode=u}}function ub(r,o){if(au=-1,ou=0,(nt&6)!==0)throw Error(n(327));var u=r.callbackNode;if(Lo()&&r.callbackNode!==u)return null;var g=Xt(r,r===zt?Vt:0);if(g===0)return null;if((g&30)!==0||(g&r.expiredLanes)!==0||o)o=iu(r,g);else{o=g;var w=nt;nt|=2;var k=fb();(zt!==r||Vt!==o)&&(ts=null,Po=dt()+500,Da(r,o));do try{RR();break}catch(X){hb(r,X)}while(!0);yh(),eu.current=k,nt=w,Tt!==null?o=0:(zt=null,Vt=0,o=Pt)}if(o!==0){if(o===2&&(w=ca(r),w!==0&&(g=w,o=ef(r,w))),o===1)throw u=cl,Da(r,0),Ds(r,g),gn(r,dt()),u;if(o===6)Ds(r,g);else{if(w=r.current.alternate,(g&30)===0&&!TR(w)&&(o=iu(r,g),o===2&&(k=ca(r),k!==0&&(g=k,o=ef(r,k))),o===1))throw u=cl,Da(r,0),Ds(r,g),gn(r,dt()),u;switch(r.finishedWork=w,r.finishedLanes=g,o){case 0:case 1:throw Error(n(345));case 2:qa(r,mn,ts);break;case 3:if(Ds(r,g),(g&130023424)===g&&(o=Qh+500-dt(),10<o)){if(Xt(r,0)!==0)break;if(w=r.suspendedLanes,(w&g)!==g){on(),r.pingedLanes|=r.suspendedLanes&w;break}r.timeoutHandle=oh(qa.bind(null,r,mn,ts),o);break}qa(r,mn,ts);break;case 4:if(Ds(r,g),(g&4194240)===g)break;for(o=r.eventTimes,w=-1;0<g;){var T=31-cn(g);k=1<<T,T=o[T],T>w&&(w=T),g&=~k}if(g=w,g=dt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*CR(g/1960))-g,10<g){r.timeoutHandle=oh(qa.bind(null,r,mn,ts),g);break}qa(r,mn,ts);break;case 5:qa(r,mn,ts);break;default:throw Error(n(329))}}}return gn(r,dt()),r.callbackNode===u?ub.bind(null,r):null}function ef(r,o){var u=ul;return r.current.memoizedState.isDehydrated&&(Da(r,o).flags|=256),r=iu(r,o),r!==2&&(o=mn,mn=u,o!==null&&tf(o)),r}function tf(r){mn===null?mn=r:mn.push.apply(mn,r)}function TR(r){for(var o=r;;){if(o.flags&16384){var u=o.updateQueue;if(u!==null&&(u=u.stores,u!==null))for(var g=0;g<u.length;g++){var w=u[g],k=w.getSnapshot;w=w.value;try{if(!dn(k(),w))return!1}catch{return!1}}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Ds(r,o){for(o&=~Xh,o&=~tu,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var u=31-cn(o),g=1<<u;r[u]=-1,o&=~g}}function db(r){if((nt&6)!==0)throw Error(n(327));Lo();var o=Xt(r,0);if((o&1)===0)return gn(r,dt()),null;var u=iu(r,o);if(r.tag!==0&&u===2){var g=ca(r);g!==0&&(o=g,u=ef(r,g))}if(u===1)throw u=cl,Da(r,0),Ds(r,o),gn(r,dt()),u;if(u===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,qa(r,mn,ts),gn(r,dt()),null}function nf(r,o){var u=nt;nt|=1;try{return r(o)}finally{nt=u,nt===0&&(Po=dt()+500,$c&&Rs())}}function La(r){Ps!==null&&Ps.tag===0&&(nt&6)===0&&Lo();var o=nt;nt|=1;var u=Bn.transition,g=at;try{if(Bn.transition=null,at=1,r)return r()}finally{at=g,Bn.transition=u,nt=o,(nt&6)===0&&Rs()}}function rf(){Sn=Oo.current,yt(Oo)}function Da(r,o){r.finishedWork=null,r.finishedLanes=0;var u=r.timeoutHandle;if(u!==-1&&(r.timeoutHandle=-1,aR(u)),Tt!==null)for(u=Tt.return;u!==null;){var g=u;switch(hh(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&Mc();break;case 3:Mo(),yt(hn),yt(Jt),Sh();break;case 5:_h(g);break;case 4:Mo();break;case 13:yt(kt);break;case 19:yt(kt);break;case 10:wh(g.type._context);break;case 22:case 23:rf()}u=u.return}if(zt=r,Tt=r=qs(r.current,null),Vt=Sn=o,Pt=0,cl=null,Xh=tu=Pa=0,mn=ul=null,Ia!==null){for(o=0;o<Ia.length;o++)if(u=Ia[o],g=u.interleaved,g!==null){u.interleaved=null;var w=g.next,k=u.pending;if(k!==null){var T=k.next;k.next=w,g.next=T}u.pending=g}Ia=null}return r}function hb(r,o){do{var u=Tt;try{if(yh(),Wc.current=Yc,Hc){for(var g=_t.memoizedState;g!==null;){var w=g.queue;w!==null&&(w.pending=null),g=g.next}Hc=!1}if(Oa=0,Bt=Ot=_t=null,rl=!1,sl=0,Kh.current=null,u===null||u.return===null){Pt=1,cl=o,Tt=null;break}e:{var k=r,T=u.return,X=u,te=o;if(o=Vt,X.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ue=te,ve=X,be=ve.tag;if((ve.mode&1)===0&&(be===0||be===11||be===15)){var we=ve.alternate;we?(ve.updateQueue=we.updateQueue,ve.memoizedState=we.memoizedState,ve.lanes=we.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Ae=L0(T);if(Ae!==null){Ae.flags&=-257,D0(Ae,T,X,k,o),Ae.mode&1&&P0(k,ue,o),o=Ae,te=ue;var Pe=o.updateQueue;if(Pe===null){var qe=new Set;qe.add(te),o.updateQueue=qe}else Pe.add(te);break e}else{if((o&1)===0){P0(k,ue,o),sf();break e}te=Error(n(426))}}else if(wt&&X.mode&1){var jt=L0(T);if(jt!==null){(jt.flags&65536)===0&&(jt.flags|=256),D0(jt,T,X,k,o),mh(Io(te,X));break e}}k=te=Io(te,X),Pt!==4&&(Pt=2),ul===null?ul=[k]:ul.push(k),k=T;do{switch(k.tag){case 3:k.flags|=65536,o&=-o,k.lanes|=o;var ae=$0(k,te,o);i0(k,ae);break e;case 1:X=te;var re=k.type,le=k.stateNode;if((k.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Os===null||!Os.has(le)))){k.flags|=65536,o&=-o,k.lanes|=o;var _e=O0(k,X,o);i0(k,_e);break e}}k=k.return}while(k!==null)}mb(u)}catch(Be){o=Be,Tt===u&&u!==null&&(Tt=u=u.return);continue}break}while(!0)}function fb(){var r=eu.current;return eu.current=Yc,r===null?Yc:r}function sf(){(Pt===0||Pt===3||Pt===2)&&(Pt=4),zt===null||(Pa&268435455)===0&&(tu&268435455)===0||Ds(zt,Vt)}function iu(r,o){var u=nt;nt|=2;var g=fb();(zt!==r||Vt!==o)&&(ts=null,Da(r,o));do try{AR();break}catch(w){hb(r,w)}while(!0);if(yh(),nt=u,eu.current=g,Tt!==null)throw Error(n(261));return zt=null,Vt=0,Pt}function AR(){for(;Tt!==null;)pb(Tt)}function RR(){for(;Tt!==null&&!aa();)pb(Tt)}function pb(r){var o=wb(r.alternate,r,Sn);r.memoizedProps=r.pendingProps,o===null?mb(r):Tt=o,Kh.current=null}function mb(r){var o=r;do{var u=o.alternate;if(r=o.return,(o.flags&32768)===0){if(u=_R(u,o,Sn),u!==null){Tt=u;return}}else{if(u=NR(u,o),u!==null){u.flags&=32767,Tt=u;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Pt=6,Tt=null;return}}if(o=o.sibling,o!==null){Tt=o;return}Tt=o=r}while(o!==null);Pt===0&&(Pt=5)}function qa(r,o,u){var g=at,w=Bn.transition;try{Bn.transition=null,at=1,MR(r,o,u,g)}finally{Bn.transition=w,at=g}return null}function MR(r,o,u,g){do Lo();while(Ps!==null);if((nt&6)!==0)throw Error(n(327));u=r.finishedWork;var w=r.finishedLanes;if(u===null)return null;if(r.finishedWork=null,r.finishedLanes=0,u===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var k=u.lanes|u.childLanes;if(io(r,k),r===zt&&(Tt=zt=null,Vt=0),(u.subtreeFlags&2064)===0&&(u.flags&2064)===0||ru||(ru=!0,vb(Fr,function(){return Lo(),null})),k=(u.flags&15990)!==0,(u.subtreeFlags&15990)!==0||k){k=Bn.transition,Bn.transition=null;var T=at;at=1;var X=nt;nt|=4,Kh.current=null,jR(r,u),ab(u,r),Vr(sh),fo=!!rh,sh=rh=null,r.current=u,ER(u),vi(),nt=X,at=T,Bn.transition=k}else r.current=u;if(ru&&(ru=!1,Ps=r,su=w),k=r.pendingLanes,k===0&&(Os=null),la(u.stateNode),gn(r,dt()),o!==null)for(g=r.onRecoverableError,u=0;u<o.length;u++)w=o[u],g(w.value,{componentStack:w.stack,digest:w.digest});if(nu)throw nu=!1,r=Zh,Zh=null,r;return(su&1)!==0&&r.tag!==0&&Lo(),k=r.pendingLanes,(k&1)!==0?r===Jh?dl++:(dl=0,Jh=r):dl=0,Rs(),null}function Lo(){if(Ps!==null){var r=Zn(su),o=Bn.transition,u=at;try{if(Bn.transition=null,at=16>r?16:r,Ps===null)var g=!1;else{if(r=Ps,Ps=null,su=0,(nt&6)!==0)throw Error(n(331));var w=nt;for(nt|=4,$e=r.current;$e!==null;){var k=$e,T=k.child;if(($e.flags&16)!==0){var X=k.deletions;if(X!==null){for(var te=0;te<X.length;te++){var ue=X[te];for($e=ue;$e!==null;){var ve=$e;switch(ve.tag){case 0:case 11:case 15:ll(8,ve,k)}var be=ve.child;if(be!==null)be.return=ve,$e=be;else for(;$e!==null;){ve=$e;var we=ve.sibling,Ae=ve.return;if(eb(ve),ve===ue){$e=null;break}if(we!==null){we.return=Ae,$e=we;break}$e=Ae}}}var Pe=k.alternate;if(Pe!==null){var qe=Pe.child;if(qe!==null){Pe.child=null;do{var jt=qe.sibling;qe.sibling=null,qe=jt}while(qe!==null)}}$e=k}}if((k.subtreeFlags&2064)!==0&&T!==null)T.return=k,$e=T;else e:for(;$e!==null;){if(k=$e,(k.flags&2048)!==0)switch(k.tag){case 0:case 11:case 15:ll(9,k,k.return)}var ae=k.sibling;if(ae!==null){ae.return=k.return,$e=ae;break e}$e=k.return}}var re=r.current;for($e=re;$e!==null;){T=$e;var le=T.child;if((T.subtreeFlags&2064)!==0&&le!==null)le.return=T,$e=le;else e:for(T=re;$e!==null;){if(X=$e,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:Jc(9,X)}}catch(Be){Nt(X,X.return,Be)}if(X===T){$e=null;break e}var _e=X.sibling;if(_e!==null){_e.return=X.return,$e=_e;break e}$e=X.return}}if(nt=w,Rs(),It&&typeof It.onPostCommitFiberRoot=="function")try{It.onPostCommitFiberRoot(zr,r)}catch{}g=!0}return g}finally{at=u,Bn.transition=o}}return!1}function gb(r,o,u){o=Io(u,o),o=$0(r,o,1),r=Is(r,o,1),o=on(),r!==null&&(rn(r,1,o),gn(r,o))}function Nt(r,o,u){if(r.tag===3)gb(r,r,u);else for(;o!==null;){if(o.tag===3){gb(o,r,u);break}else if(o.tag===1){var g=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Os===null||!Os.has(g))){r=Io(u,r),r=O0(o,r,1),o=Is(o,r,1),r=on(),o!==null&&(rn(o,1,r),gn(o,r));break}}o=o.return}}function IR(r,o,u){var g=r.pingCache;g!==null&&g.delete(o),o=on(),r.pingedLanes|=r.suspendedLanes&u,zt===r&&(Vt&u)===u&&(Pt===4||Pt===3&&(Vt&130023424)===Vt&&500>dt()-Qh?Da(r,0):Xh|=u),gn(r,o)}function yb(r,o){o===0&&((r.mode&1)===0?o=1:(o=ao,ao<<=1,(ao&130023424)===0&&(ao=4194304)));var u=on();r=Zr(r,o),r!==null&&(rn(r,o,u),gn(r,u))}function $R(r){var o=r.memoizedState,u=0;o!==null&&(u=o.retryLane),yb(r,u)}function OR(r,o){var u=0;switch(r.tag){case 13:var g=r.stateNode,w=r.memoizedState;w!==null&&(u=w.retryLane);break;case 19:g=r.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(o),yb(r,u)}var wb;wb=function(r,o,u){if(r!==null)if(r.memoizedProps!==o.pendingProps||hn.current)pn=!0;else{if((r.lanes&u)===0&&(o.flags&128)===0)return pn=!1,kR(r,o,u);pn=(r.flags&131072)!==0}else pn=!1,wt&&(o.flags&1048576)!==0&&Qx(o,Pc,o.index);switch(o.lanes=0,o.tag){case 2:var g=o.type;Qc(r,o),r=o.pendingProps;var w=So(o,Jt.current);Ro(o,u),w=Ch(null,o,g,r,w,u);var k=Th();return o.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,fn(g)?(k=!0,Ic(o)):k=!1,o.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,bh(o),w.updater=Kc,o.stateNode=w,w._reactInternals=o,Oh(o,g,r,u),o=qh(null,o,g,!0,k,u)):(o.tag=0,wt&&k&&dh(o),an(null,o,w,u),o=o.child),o;case 16:g=o.elementType;e:{switch(Qc(r,o),r=o.pendingProps,w=g._init,g=w(g._payload),o.type=g,w=o.tag=LR(g),r=rr(g,r),w){case 0:o=Dh(null,o,g,r,u);break e;case 1:o=W0(null,o,g,r,u);break e;case 11:o=q0(null,o,g,r,u);break e;case 14:o=F0(null,o,g,rr(g.type,r),u);break e}throw Error(n(306,g,""))}return o;case 0:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),Dh(r,o,g,w,u);case 1:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),W0(r,o,g,w,u);case 3:e:{if(H0(o),r===null)throw Error(n(387));g=o.pendingProps,k=o.memoizedState,w=k.element,o0(r,o),zc(o,g,null,u);var T=o.memoizedState;if(g=T.element,k.isDehydrated)if(k={element:g,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},o.updateQueue.baseState=k,o.memoizedState=k,o.flags&256){w=Io(Error(n(423)),o),o=G0(r,o,g,u,w);break e}else if(g!==w){w=Io(Error(n(424)),o),o=G0(r,o,g,u,w);break e}else for(Nn=Cs(o.stateNode.containerInfo.firstChild),_n=o,wt=!0,nr=null,u=s0(o,null,g,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Co(),g===w){o=es(r,o,u);break e}an(r,o,g,u)}o=o.child}return o;case 5:return c0(o),r===null&&ph(o),g=o.type,w=o.pendingProps,k=r!==null?r.memoizedProps:null,T=w.children,ah(g,w)?T=null:k!==null&&ah(g,k)&&(o.flags|=32),U0(r,o),an(r,o,T,u),o.child;case 6:return r===null&&ph(o),null;case 13:return V0(r,o,u);case 4:return kh(o,o.stateNode.containerInfo),g=o.pendingProps,r===null?o.child=To(o,null,g,u):an(r,o,g,u),o.child;case 11:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),q0(r,o,g,w,u);case 7:return an(r,o,o.pendingProps,u),o.child;case 8:return an(r,o,o.pendingProps.children,u),o.child;case 12:return an(r,o,o.pendingProps.children,u),o.child;case 10:e:{if(g=o.type._context,w=o.pendingProps,k=o.memoizedProps,T=w.value,pt(qc,g._currentValue),g._currentValue=T,k!==null)if(dn(k.value,T)){if(k.children===w.children&&!hn.current){o=es(r,o,u);break e}}else for(k=o.child,k!==null&&(k.return=o);k!==null;){var X=k.dependencies;if(X!==null){T=k.child;for(var te=X.firstContext;te!==null;){if(te.context===g){if(k.tag===1){te=Jr(-1,u&-u),te.tag=2;var ue=k.updateQueue;if(ue!==null){ue=ue.shared;var ve=ue.pending;ve===null?te.next=te:(te.next=ve.next,ve.next=te),ue.pending=te}}k.lanes|=u,te=k.alternate,te!==null&&(te.lanes|=u),vh(k.return,u,o),X.lanes|=u;break}te=te.next}}else if(k.tag===10)T=k.type===o.type?null:k.child;else if(k.tag===18){if(T=k.return,T===null)throw Error(n(341));T.lanes|=u,X=T.alternate,X!==null&&(X.lanes|=u),vh(T,u,o),T=k.sibling}else T=k.child;if(T!==null)T.return=k;else for(T=k;T!==null;){if(T===o){T=null;break}if(k=T.sibling,k!==null){k.return=T.return,T=k;break}T=T.return}k=T}an(r,o,w.children,u),o=o.child}return o;case 9:return w=o.type,g=o.pendingProps.children,Ro(o,u),w=qn(w),g=g(w),o.flags|=1,an(r,o,g,u),o.child;case 14:return g=o.type,w=rr(g,o.pendingProps),w=rr(g.type,w),F0(r,o,g,w,u);case 15:return B0(r,o,o.type,o.pendingProps,u);case 17:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),Qc(r,o),o.tag=1,fn(g)?(r=!0,Ic(o)):r=!1,Ro(o,u),M0(o,g,w),Oh(o,g,w,u),qh(null,o,g,!0,r,u);case 19:return K0(r,o,u);case 22:return z0(r,o,u)}throw Error(n(156,o.tag))};function vb(r,o){return sa(r,o)}function PR(r,o,u,g){this.tag=r,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(r,o,u,g){return new PR(r,o,u,g)}function af(r){return r=r.prototype,!(!r||!r.isReactComponent)}function LR(r){if(typeof r=="function")return af(r)?1:0;if(r!=null){if(r=r.$$typeof,r===H)return 11;if(r===Q)return 14}return 2}function qs(r,o){var u=r.alternate;return u===null?(u=zn(r.tag,o,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=o,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&14680064,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,o=r.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u}function lu(r,o,u,g,w,k){var T=2;if(g=r,typeof r=="function")af(r)&&(T=1);else if(typeof r=="string")T=5;else e:switch(r){case $:return Fa(u.children,w,k,o);case F:T=8,w|=8;break;case O:return r=zn(12,u,o,w|2),r.elementType=O,r.lanes=k,r;case B:return r=zn(13,u,o,w),r.elementType=B,r.lanes=k,r;case A:return r=zn(19,u,o,w),r.elementType=A,r.lanes=k,r;case ee:return cu(u,w,k,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case M:T=10;break e;case L:T=9;break e;case H:T=11;break e;case Q:T=14;break e;case K:T=16,g=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=zn(T,u,o,w),o.elementType=r,o.type=g,o.lanes=k,o}function Fa(r,o,u,g){return r=zn(7,r,g,o),r.lanes=u,r}function cu(r,o,u,g){return r=zn(22,r,g,o),r.elementType=ee,r.lanes=u,r.stateNode={isHidden:!1},r}function of(r,o,u){return r=zn(6,r,null,o),r.lanes=u,r}function lf(r,o,u){return o=zn(4,r.children!==null?r.children:[],r.key,o),o.lanes=u,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function DR(r,o,u,g,w){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=xi(0),this.expirationTimes=xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xi(0),this.identifierPrefix=g,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function cf(r,o,u,g,w,k,T,X,te){return r=new DR(r,o,u,X,te),o===1?(o=1,k===!0&&(o|=8)):o=0,k=zn(3,null,null,o),r.current=k,k.stateNode=r,k.memoizedState={element:g,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},bh(k),r}function qR(r,o,u){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:g==null?null:""+g,children:r,containerInfo:o,implementation:u}}function xb(r){if(!r)return As;r=r._reactInternals;e:{if(Rn(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(fn(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var u=r.type;if(fn(u))return Yx(r,u,o)}return o}function bb(r,o,u,g,w,k,T,X,te){return r=cf(u,g,!0,r,w,k,T,X,te),r.context=xb(null),u=r.current,g=on(),w=Ls(u),k=Jr(g,w),k.callback=o??null,Is(u,k,w),r.current.lanes=w,rn(r,w,g),gn(r,g),r}function uu(r,o,u,g){var w=o.current,k=on(),T=Ls(w);return u=xb(u),o.context===null?o.context=u:o.pendingContext=u,o=Jr(k,T),o.payload={element:r},g=g===void 0?null:g,g!==null&&(o.callback=g),r=Is(w,o,T),r!==null&&(or(r,w,T,k),Bc(r,w,T)),T}function du(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function kb(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u<o?u:o}}function uf(r,o){kb(r,o),(r=r.alternate)&&kb(r,o)}function FR(){return null}var _b=typeof reportError=="function"?reportError:function(r){console.error(r)};function df(r){this._internalRoot=r}hu.prototype.render=df.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));uu(r,o,null,null)},hu.prototype.unmount=df.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;La(function(){uu(null,r,null,null)}),o[Yr]=null}};function hu(r){this._internalRoot=r}hu.prototype.unstable_scheduleHydration=function(r){if(r){var o=ki();r={blockedOn:null,target:r,priority:o};for(var u=0;u<er.length&&o!==0&&o<er[u].priority;u++);er.splice(u,0,r),u===0&&uo(r)}};function hf(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function fu(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Nb(){}function BR(r,o,u,g,w){if(w){if(typeof g=="function"){var k=g;g=function(){var ue=du(T);k.call(ue)}}var T=bb(o,g,r,0,null,!1,!1,"",Nb);return r._reactRootContainer=T,r[Yr]=T.current,Ca(r.nodeType===8?r.parentNode:r),La(),T}for(;w=r.lastChild;)r.removeChild(w);if(typeof g=="function"){var X=g;g=function(){var ue=du(te);X.call(ue)}}var te=cf(r,0,!1,null,null,!1,!1,"",Nb);return r._reactRootContainer=te,r[Yr]=te.current,Ca(r.nodeType===8?r.parentNode:r),La(function(){uu(o,te,u,g)}),te}function pu(r,o,u,g,w){var k=u._reactRootContainer;if(k){var T=k;if(typeof w=="function"){var X=w;w=function(){var te=du(T);X.call(te)}}uu(o,T,r,w)}else T=BR(u,o,r,w,g);return du(T)}ua=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var u=hs(o.pendingLanes);u!==0&&(lo(o,u|1),gn(o,dt()),(nt&6)===0&&(Po=dt()+500,Rs()))}break;case 13:La(function(){var g=Zr(r,1);if(g!==null){var w=on();or(g,r,1,w)}}),uf(r,1)}},bi=function(r){if(r.tag===13){var o=Zr(r,134217728);if(o!==null){var u=on();or(o,r,134217728,u)}uf(r,134217728)}},ic=function(r){if(r.tag===13){var o=Ls(r),u=Zr(r,o);if(u!==null){var g=on();or(u,r,o,g)}uf(r,o)}},ki=function(){return at},_i=function(r,o){var u=at;try{return at=r,o()}finally{at=u}},ft=function(r,o,u){switch(o){case"input":if(ke(r,u),o=u.name,u.type==="radio"&&o!=null){for(u=r;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<u.length;o++){var g=u[o];if(g!==r&&g.form===r.form){var w=Rc(g);if(!w)throw Error(n(90));Le(g),ke(g,w)}}}break;case"textarea":he(r,u);break;case"select":o=u.value,o!=null&&Ne(r,!!u.multiple,o,!1)}},us=nf,Or=La;var zR={usingClientEntryPoint:!1,Events:[Zi,_o,Rc,ln,eo,nf]},hl={findFiberByHostInstance:Ta,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},UR={bundleType:hl.bundleType,version:hl.version,rendererPackageName:hl.rendererPackageName,rendererConfig:hl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=na(r),r===null?null:r.stateNode},findFiberByHostInstance:hl.findFiberByHostInstance||FR,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 mu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mu.isDisabled&&mu.supportsFiber)try{zr=mu.inject(UR),It=mu}catch{}}return yn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zR,yn.createPortal=function(r,o){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!hf(o))throw Error(n(200));return qR(r,o,null,u)},yn.createRoot=function(r,o){if(!hf(r))throw Error(n(299));var u=!1,g="",w=_b;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(w=o.onRecoverableError)),o=cf(r,1,!1,null,null,u,!1,g,w),r[Yr]=o.current,Ca(r.nodeType===8?r.parentNode:r),new df(o)},yn.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=na(o),r=r===null?null:r.stateNode,r},yn.flushSync=function(r){return La(r)},yn.hydrate=function(r,o,u){if(!fu(o))throw Error(n(200));return pu(null,r,o,!0,u)},yn.hydrateRoot=function(r,o,u){if(!hf(r))throw Error(n(405));var g=u!=null&&u.hydratedSources||null,w=!1,k="",T=_b;if(u!=null&&(u.unstable_strictMode===!0&&(w=!0),u.identifierPrefix!==void 0&&(k=u.identifierPrefix),u.onRecoverableError!==void 0&&(T=u.onRecoverableError)),o=bb(o,null,r,1,u??null,w,!1,k,T),r[Yr]=o.current,Ca(r),g)for(r=0;r<g.length;r++)u=g[r],w=u._getVersion,w=w(u._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[u,w]:o.mutableSourceEagerHydrationData.push(u,w);return new hu(o)},yn.render=function(r,o,u){if(!fu(o))throw Error(n(200));return pu(null,r,o,!1,u)},yn.unmountComponentAtNode=function(r){if(!fu(r))throw Error(n(40));return r._reactRootContainer?(La(function(){pu(null,null,r,!1,function(){r._reactRootContainer=null,r[Yr]=null})}),!0):!1},yn.unstable_batchedUpdates=nf,yn.unstable_renderSubtreeIntoContainer=function(r,o,u,g){if(!fu(u))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return pu(r,o,u,!1,g)},yn.version="18.3.1-next-f1338f8080-20240426",yn}var Mb;function SC(){if(Mb)return mf.exports;Mb=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(),mf.exports=XR(),mf.exports}var Ib;function QR(){if(Ib)return yu;Ib=1;var e=SC();return yu.createRoot=e.createRoot,yu.hydrateRoot=e.hydrateRoot,yu}var ZR=QR(),b=Ul();const fe=Bv(b);function Kt(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=Kt(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var wf={exports:{}},vf={},xf={exports:{}},bf={};/**
40
+ `+k.stack}return{value:r,source:o,stack:w,digest:null}}function Lh(r,o,u){return{value:r,source:null,stack:u??null,digest:o??null}}function Dh(r,o){try{console.error(o.value)}catch(u){setTimeout(function(){throw u})}}var vR=typeof WeakMap=="function"?WeakMap:Map;function $0(r,o,u){u=Jr(-1,u),u.tag=3,u.payload={element:null};var g=o.value;return u.callback=function(){ru||(ru=!0,Jh=g),Dh(r,o)},u}function O0(r,o,u){u=Jr(-1,u),u.tag=3;var g=r.type.getDerivedStateFromError;if(typeof g=="function"){var w=o.value;u.payload=function(){return g(w)},u.callback=function(){Dh(r,o)}}var k=r.stateNode;return k!==null&&typeof k.componentDidCatch=="function"&&(u.callback=function(){Dh(r,o),typeof g!="function"&&(Ps===null?Ps=new Set([this]):Ps.add(this));var T=o.stack;this.componentDidCatch(o.value,{componentStack:T!==null?T:""})}),u}function P0(r,o,u){var g=r.pingCache;if(g===null){g=r.pingCache=new vR;var w=new Set;g.set(o,w)}else w=g.get(o),w===void 0&&(w=new Set,g.set(o,w));w.has(u)||(w.add(u),r=IR.bind(null,r,o,u),o.then(r,r))}function L0(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function D0(r,o,u,g,w){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,u.flags|=131072,u.flags&=-52805,u.tag===1&&(u.alternate===null?u.tag=17:(o=Jr(-1,1),o.tag=2,$s(u,o,1))),u.lanes|=1),r):(r.flags|=65536,r.lanes=w,r)}var xR=C.ReactCurrentOwner,pn=!1;function an(r,o,u,g){o.child=r===null?s0(o,null,u,g):Ao(o,r.child,u,g)}function q0(r,o,u,g,w){u=u.render;var k=o.ref;return Mo(o,w),g=Th(r,o,u,g,k,w),u=Ah(),r!==null&&!pn?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,es(r,o,w)):(wt&&u&&hh(o),o.flags|=1,an(r,o,g,w),o.child)}function F0(r,o,u,g,w){if(r===null){var k=u.type;return typeof k=="function"&&!of(k)&&k.defaultProps===void 0&&u.compare===null&&u.defaultProps===void 0?(o.tag=15,o.type=k,B0(r,o,k,g,w)):(r=cu(u.type,null,g,o,o.mode,w),r.ref=o.ref,r.return=o,o.child=r)}if(k=r.child,(r.lanes&w)===0){var T=k.memoizedProps;if(u=u.compare,u=u!==null?u:ks,u(T,g)&&r.ref===o.ref)return es(r,o,w)}return o.flags|=1,r=Fs(k,g),r.ref=o.ref,r.return=o,o.child=r}function B0(r,o,u,g,w){if(r!==null){var k=r.memoizedProps;if(ks(k,g)&&r.ref===o.ref)if(pn=!1,o.pendingProps=g=k,(r.lanes&w)!==0)(r.flags&131072)!==0&&(pn=!0);else return o.lanes=r.lanes,es(r,o,w)}return qh(r,o,u,g,w)}function z0(r,o,u){var g=o.pendingProps,w=g.children,k=r!==null?r.memoizedState:null;if(g.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},pt(Po,Sn),Sn|=u;else{if((u&1073741824)===0)return r=k!==null?k.baseLanes|u:u,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,pt(Po,Sn),Sn|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=k!==null?k.baseLanes:u,pt(Po,Sn),Sn|=g}else k!==null?(g=k.baseLanes|u,o.memoizedState=null):g=u,pt(Po,Sn),Sn|=g;return an(r,o,w,u),o.child}function U0(r,o){var u=o.ref;(r===null&&u!==null||r!==null&&r.ref!==u)&&(o.flags|=512,o.flags|=2097152)}function qh(r,o,u,g,w){var k=fn(u)?Ra:Jt.current;return k=jo(o,k),Mo(o,w),u=Th(r,o,u,g,k,w),g=Ah(),r!==null&&!pn?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~w,es(r,o,w)):(wt&&g&&hh(o),o.flags|=1,an(r,o,u,w),o.child)}function W0(r,o,u,g,w){if(fn(u)){var k=!0;$c(o)}else k=!1;if(Mo(o,w),o.stateNode===null)Zc(r,o),M0(o,u,g),Ph(o,u,g,w),g=!0;else if(r===null){var T=o.stateNode,X=o.memoizedProps;T.props=X;var te=T.context,ue=u.contextType;typeof ue=="object"&&ue!==null?ue=qn(ue):(ue=fn(u)?Ra:Jt.current,ue=jo(o,ue));var ve=u.getDerivedStateFromProps,be=typeof ve=="function"||typeof T.getSnapshotBeforeUpdate=="function";be||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(X!==g||te!==ue)&&I0(o,T,g,ue),Is=!1;var we=o.memoizedState;T.state=we,Uc(o,g,T,w),te=o.memoizedState,X!==g||we!==te||hn.current||Is?(typeof ve=="function"&&(Oh(o,u,ve,g),te=o.memoizedState),(X=Is||R0(o,u,X,g,we,te,ue))?(be||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(o.flags|=4194308)):(typeof T.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=g,o.memoizedState=te),T.props=g,T.state=te,T.context=ue,g=X):(typeof T.componentDidMount=="function"&&(o.flags|=4194308),g=!1)}else{T=o.stateNode,o0(r,o),X=o.memoizedProps,ue=o.type===o.elementType?X:rr(o.type,X),T.props=ue,be=o.pendingProps,we=T.context,te=u.contextType,typeof te=="object"&&te!==null?te=qn(te):(te=fn(u)?Ra:Jt.current,te=jo(o,te));var Ae=u.getDerivedStateFromProps;(ve=typeof Ae=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(X!==be||we!==te)&&I0(o,T,g,te),Is=!1,we=o.memoizedState,T.state=we,Uc(o,g,T,w);var Pe=o.memoizedState;X!==be||we!==Pe||hn.current||Is?(typeof Ae=="function"&&(Oh(o,u,Ae,g),Pe=o.memoizedState),(ue=Is||R0(o,u,ue,g,we,Pe,te)||!1)?(ve||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(g,Pe,te),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(g,Pe,te)),typeof T.componentDidUpdate=="function"&&(o.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof T.componentDidUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),o.memoizedProps=g,o.memoizedState=Pe),T.props=g,T.state=Pe,T.context=te,g=ue):(typeof T.componentDidUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||X===r.memoizedProps&&we===r.memoizedState||(o.flags|=1024),g=!1)}return Fh(r,o,u,g,k,w)}function Fh(r,o,u,g,w,k){U0(r,o);var T=(o.flags&128)!==0;if(!g&&!T)return w&&Kx(o,u,!1),es(r,o,k);g=o.stateNode,xR.current=o;var X=T&&typeof u.getDerivedStateFromError!="function"?null:g.render();return o.flags|=1,r!==null&&T?(o.child=Ao(o,r.child,null,k),o.child=Ao(o,null,X,k)):an(r,o,X,k),o.memoizedState=g.state,w&&Kx(o,u,!0),o.child}function H0(r){var o=r.stateNode;o.pendingContext?Vx(r,o.pendingContext,o.pendingContext!==o.context):o.context&&Vx(r,o.context,!1),_h(r,o.containerInfo)}function G0(r,o,u,g,w){return To(),gh(w),o.flags|=256,an(r,o,u,g),o.child}var Bh={dehydrated:null,treeContext:null,retryLane:0};function zh(r){return{baseLanes:r,cachePool:null,transitions:null}}function V0(r,o,u){var g=o.pendingProps,w=kt.current,k=!1,T=(o.flags&128)!==0,X;if((X=T)||(X=r!==null&&r.memoizedState===null?!1:(w&2)!==0),X?(k=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(w|=1),pt(kt,w&1),r===null)return mh(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(T=g.children,r=g.fallback,k?(g=o.mode,k=o.child,T={mode:"hidden",children:T},(g&1)===0&&k!==null?(k.childLanes=0,k.pendingProps=T):k=uu(T,g,0,null),r=Ba(r,g,u,null),k.return=o,r.return=o,k.sibling=r,o.child=k,o.child.memoizedState=zh(u),o.memoizedState=Bh,r):Uh(o,T));if(w=r.memoizedState,w!==null&&(X=w.dehydrated,X!==null))return bR(r,o,T,g,X,w,u);if(k){k=g.fallback,T=o.mode,w=r.child,X=w.sibling;var te={mode:"hidden",children:g.children};return(T&1)===0&&o.child!==w?(g=o.child,g.childLanes=0,g.pendingProps=te,o.deletions=null):(g=Fs(w,te),g.subtreeFlags=w.subtreeFlags&14680064),X!==null?k=Fs(X,k):(k=Ba(k,T,u,null),k.flags|=2),k.return=o,g.return=o,g.sibling=k,o.child=g,g=k,k=o.child,T=r.child.memoizedState,T=T===null?zh(u):{baseLanes:T.baseLanes|u,cachePool:null,transitions:T.transitions},k.memoizedState=T,k.childLanes=r.childLanes&~u,o.memoizedState=Bh,g}return k=r.child,r=k.sibling,g=Fs(k,{mode:"visible",children:g.children}),(o.mode&1)===0&&(g.lanes=u),g.return=o,g.sibling=null,r!==null&&(u=o.deletions,u===null?(o.deletions=[r],o.flags|=16):u.push(r)),o.child=g,o.memoizedState=null,g}function Uh(r,o){return o=uu({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function Qc(r,o,u,g){return g!==null&&gh(g),Ao(o,r.child,null,u),r=Uh(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function bR(r,o,u,g,w,k,T){if(u)return o.flags&256?(o.flags&=-257,g=Lh(Error(n(422))),Qc(r,o,T,g)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(k=g.fallback,w=o.mode,g=uu({mode:"visible",children:g.children},w,0,null),k=Ba(k,w,T,null),k.flags|=2,g.return=o,k.return=o,g.sibling=k,o.child=g,(o.mode&1)!==0&&Ao(o,r.child,null,T),o.child.memoizedState=zh(T),o.memoizedState=Bh,k);if((o.mode&1)===0)return Qc(r,o,T,null);if(w.data==="$!"){if(g=w.nextSibling&&w.nextSibling.dataset,g)var X=g.dgst;return g=X,k=Error(n(419)),g=Lh(k,g,void 0),Qc(r,o,T,g)}if(X=(T&r.childLanes)!==0,pn||X){if(g=zt,g!==null){switch(T&-T){case 4:w=2;break;case 16:w=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:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(g.suspendedLanes|T))!==0?0:w,w!==0&&w!==k.retryLane&&(k.retryLane=w,Zr(r,w),or(g,r,w,-1))}return af(),g=Lh(Error(n(421))),Qc(r,o,T,g)}return w.data==="$?"?(o.flags|=128,o.child=r.child,o=$R.bind(null,r),w._reactRetry=o,null):(r=k.treeContext,Nn=Ts(w.nextSibling),_n=o,wt=!0,nr=null,r!==null&&(Ln[Dn++]=Xr,Ln[Dn++]=Qr,Ln[Dn++]=Ma,Xr=r.id,Qr=r.overflow,Ma=o),o=Uh(o,g.children),o.flags|=4096,o)}function Y0(r,o,u){r.lanes|=o;var g=r.alternate;g!==null&&(g.lanes|=o),xh(r.return,o,u)}function Wh(r,o,u,g,w){var k=r.memoizedState;k===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:g,tail:u,tailMode:w}:(k.isBackwards=o,k.rendering=null,k.renderingStartTime=0,k.last=g,k.tail=u,k.tailMode=w)}function K0(r,o,u){var g=o.pendingProps,w=g.revealOrder,k=g.tail;if(an(r,o,g.children,u),g=kt.current,(g&2)!==0)g=g&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Y0(r,u,o);else if(r.tag===19)Y0(r,u,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}g&=1}if(pt(kt,g),(o.mode&1)===0)o.memoizedState=null;else switch(w){case"forwards":for(u=o.child,w=null;u!==null;)r=u.alternate,r!==null&&Wc(r)===null&&(w=u),u=u.sibling;u=w,u===null?(w=o.child,o.child=null):(w=u.sibling,u.sibling=null),Wh(o,!1,w,u,k);break;case"backwards":for(u=null,w=o.child,o.child=null;w!==null;){if(r=w.alternate,r!==null&&Wc(r)===null){o.child=w;break}r=w.sibling,w.sibling=u,u=w,w=r}Wh(o,!0,u,null,k);break;case"together":Wh(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function Zc(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function es(r,o,u){if(r!==null&&(o.dependencies=r.dependencies),La|=o.lanes,(u&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,u=Fs(r,r.pendingProps),o.child=u,u.return=o;r.sibling!==null;)r=r.sibling,u=u.sibling=Fs(r,r.pendingProps),u.return=o;u.sibling=null}return o.child}function kR(r,o,u){switch(o.tag){case 3:H0(o),To();break;case 5:c0(o);break;case 1:fn(o.type)&&$c(o);break;case 4:_h(o,o.stateNode.containerInfo);break;case 10:var g=o.type._context,w=o.memoizedProps.value;pt(Fc,g._currentValue),g._currentValue=w;break;case 13:if(g=o.memoizedState,g!==null)return g.dehydrated!==null?(pt(kt,kt.current&1),o.flags|=128,null):(u&o.child.childLanes)!==0?V0(r,o,u):(pt(kt,kt.current&1),r=es(r,o,u),r!==null?r.sibling:null);pt(kt,kt.current&1);break;case 19:if(g=(u&o.childLanes)!==0,(r.flags&128)!==0){if(g)return K0(r,o,u);o.flags|=128}if(w=o.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),pt(kt,kt.current),g)break;return null;case 22:case 23:return o.lanes=0,z0(r,o,u)}return es(r,o,u)}var X0,Hh,Q0,Z0;X0=function(r,o){for(var u=o.child;u!==null;){if(u.tag===5||u.tag===6)r.appendChild(u.stateNode);else if(u.tag!==4&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===o)break;for(;u.sibling===null;){if(u.return===null||u.return===o)return;u=u.return}u.sibling.return=u.return,u=u.sibling}},Hh=function(){},Q0=function(r,o,u,g){var w=r.memoizedProps;if(w!==g){r=o.stateNode,Oa(Er.current);var k=null;switch(u){case"input":w=xe(r,w),g=xe(r,g),k=[];break;case"select":w=Y({},w,{value:void 0}),g=Y({},g,{value:void 0}),k=[];break;case"textarea":w=He(r,w),g=He(r,g),k=[];break;default:typeof w.onClick!="function"&&typeof g.onClick=="function"&&(r.onclick=Rc)}lt(u,g);var T;u=null;for(ue in w)if(!g.hasOwnProperty(ue)&&w.hasOwnProperty(ue)&&w[ue]!=null)if(ue==="style"){var X=w[ue];for(T in X)X.hasOwnProperty(T)&&(u||(u={}),u[T]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(a.hasOwnProperty(ue)?k||(k=[]):(k=k||[]).push(ue,null));for(ue in g){var te=g[ue];if(X=w!=null?w[ue]:void 0,g.hasOwnProperty(ue)&&te!==X&&(te!=null||X!=null))if(ue==="style")if(X){for(T in X)!X.hasOwnProperty(T)||te&&te.hasOwnProperty(T)||(u||(u={}),u[T]="");for(T in te)te.hasOwnProperty(T)&&X[T]!==te[T]&&(u||(u={}),u[T]=te[T])}else u||(k||(k=[]),k.push(ue,u)),u=te;else ue==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,X=X?X.__html:void 0,te!=null&&X!==te&&(k=k||[]).push(ue,te)):ue==="children"?typeof te!="string"&&typeof te!="number"||(k=k||[]).push(ue,""+te):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(a.hasOwnProperty(ue)?(te!=null&&ue==="onScroll"&&Qe("scroll",r),k||X===te||(k=[])):(k=k||[]).push(ue,te))}u&&(k=k||[]).push("style",u);var ue=k;(o.updateQueue=ue)&&(o.flags|=4)}},Z0=function(r,o,u,g){u!==g&&(o.flags|=4)};function ll(r,o){if(!wt)switch(r.tailMode){case"hidden":o=r.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?r.tail=null:u.sibling=null;break;case"collapsed":u=r.tail;for(var g=null;u!==null;)u.alternate!==null&&(g=u),u=u.sibling;g===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:g.sibling=null}}function tn(r){var o=r.alternate!==null&&r.alternate.child===r.child,u=0,g=0;if(o)for(var w=r.child;w!==null;)u|=w.lanes|w.childLanes,g|=w.subtreeFlags&14680064,g|=w.flags&14680064,w.return=r,w=w.sibling;else for(w=r.child;w!==null;)u|=w.lanes|w.childLanes,g|=w.subtreeFlags,g|=w.flags,w.return=r,w=w.sibling;return r.subtreeFlags|=g,r.childLanes=u,o}function _R(r,o,u){var g=o.pendingProps;switch(fh(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return tn(o),null;case 1:return fn(o.type)&&Ic(),tn(o),null;case 3:return g=o.stateNode,Io(),yt(hn),yt(Jt),jh(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(r===null||r.child===null)&&(Dc(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,nr!==null&&(nf(nr),nr=null))),Hh(r,o),tn(o),null;case 5:Nh(o);var w=Oa(rl.current);if(u=o.type,r!==null&&o.stateNode!=null)Q0(r,o,u,g,w),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!g){if(o.stateNode===null)throw Error(n(166));return tn(o),null}if(r=Oa(Er.current),Dc(o)){g=o.stateNode,u=o.type;var k=o.memoizedProps;switch(g[jr]=o,g[Zi]=k,r=(o.mode&1)!==0,u){case"dialog":Qe("cancel",g),Qe("close",g);break;case"iframe":case"object":case"embed":Qe("load",g);break;case"video":case"audio":for(w=0;w<We.length;w++)Qe(We[w],g);break;case"source":Qe("error",g);break;case"img":case"image":case"link":Qe("error",g),Qe("load",g);break;case"details":Qe("toggle",g);break;case"input":ye(g,k),Qe("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!k.multiple},Qe("invalid",g);break;case"textarea":Xe(g,k),Qe("invalid",g)}lt(u,k),w=null;for(var T in k)if(k.hasOwnProperty(T)){var X=k[T];T==="children"?typeof X=="string"?g.textContent!==X&&(k.suppressHydrationWarning!==!0&&Ac(g.textContent,X,r),w=["children",X]):typeof X=="number"&&g.textContent!==""+X&&(k.suppressHydrationWarning!==!0&&Ac(g.textContent,X,r),w=["children",""+X]):a.hasOwnProperty(T)&&X!=null&&T==="onScroll"&&Qe("scroll",g)}switch(u){case"input":Ie(g),je(g,k,!0);break;case"textarea":Ie(g),ge(g);break;case"select":case"option":break;default:typeof k.onClick=="function"&&(g.onclick=Rc)}g=w,o.updateQueue=g,g!==null&&(o.flags|=4)}else{T=w.nodeType===9?w:w.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Se(u)),r==="http://www.w3.org/1999/xhtml"?u==="script"?(r=T.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof g.is=="string"?r=T.createElement(u,{is:g.is}):(r=T.createElement(u),u==="select"&&(T=r,g.multiple?T.multiple=!0:g.size&&(T.size=g.size))):r=T.createElementNS(r,u),r[jr]=o,r[Zi]=g,X0(r,o,!1,!1),o.stateNode=r;e:{switch(T=ut(u,g),u){case"dialog":Qe("cancel",r),Qe("close",r),w=g;break;case"iframe":case"object":case"embed":Qe("load",r),w=g;break;case"video":case"audio":for(w=0;w<We.length;w++)Qe(We[w],r);w=g;break;case"source":Qe("error",r),w=g;break;case"img":case"image":case"link":Qe("error",r),Qe("load",r),w=g;break;case"details":Qe("toggle",r),w=g;break;case"input":ye(r,g),w=xe(r,g),Qe("invalid",r);break;case"option":w=g;break;case"select":r._wrapperState={wasMultiple:!!g.multiple},w=Y({},g,{value:void 0}),Qe("invalid",r);break;case"textarea":Xe(r,g),w=He(r,g),Qe("invalid",r);break;default:w=g}lt(u,w),X=w;for(k in X)if(X.hasOwnProperty(k)){var te=X[k];k==="style"?Te(r,te):k==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&xt(r,te)):k==="children"?typeof te=="string"?(u!=="textarea"||te!=="")&&ht(r,te):typeof te=="number"&&ht(r,""+te):k!=="suppressContentEditableWarning"&&k!=="suppressHydrationWarning"&&k!=="autoFocus"&&(a.hasOwnProperty(k)?te!=null&&k==="onScroll"&&Qe("scroll",r):te!=null&&E(r,k,te,T))}switch(u){case"input":Ie(r),je(r,g,!1);break;case"textarea":Ie(r),ge(r);break;case"option":g.value!=null&&r.setAttribute("value",""+ie(g.value));break;case"select":r.multiple=!!g.multiple,k=g.value,k!=null?Ne(r,!!g.multiple,k,!1):g.defaultValue!=null&&Ne(r,!!g.multiple,g.defaultValue,!0);break;default:typeof w.onClick=="function"&&(r.onclick=Rc)}switch(u){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return tn(o),null;case 6:if(r&&o.stateNode!=null)Z0(r,o,r.memoizedProps,g);else{if(typeof g!="string"&&o.stateNode===null)throw Error(n(166));if(u=Oa(rl.current),Oa(Er.current),Dc(o)){if(g=o.stateNode,u=o.memoizedProps,g[jr]=o,(k=g.nodeValue!==u)&&(r=_n,r!==null))switch(r.tag){case 3:Ac(g.nodeValue,u,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Ac(g.nodeValue,u,(r.mode&1)!==0)}k&&(o.flags|=4)}else g=(u.nodeType===9?u:u.ownerDocument).createTextNode(g),g[jr]=o,o.stateNode=g}return tn(o),null;case 13:if(yt(kt),g=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(wt&&Nn!==null&&(o.mode&1)!==0&&(o.flags&128)===0)t0(),To(),o.flags|=98560,k=!1;else if(k=Dc(o),g!==null&&g.dehydrated!==null){if(r===null){if(!k)throw Error(n(318));if(k=o.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(n(317));k[jr]=o}else To(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;tn(o),k=!1}else nr!==null&&(nf(nr),nr=null),k=!0;if(!k)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=u,o):(g=g!==null,g!==(r!==null&&r.memoizedState!==null)&&g&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(kt.current&1)!==0?Pt===0&&(Pt=3):af())),o.updateQueue!==null&&(o.flags|=4),tn(o),null);case 4:return Io(),Hh(r,o),r===null&&Ta(o.stateNode.containerInfo),tn(o),null;case 10:return vh(o.type._context),tn(o),null;case 17:return fn(o.type)&&Ic(),tn(o),null;case 19:if(yt(kt),k=o.memoizedState,k===null)return tn(o),null;if(g=(o.flags&128)!==0,T=k.rendering,T===null)if(g)ll(k,!1);else{if(Pt!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(T=Wc(r),T!==null){for(o.flags|=128,ll(k,!1),g=T.updateQueue,g!==null&&(o.updateQueue=g,o.flags|=4),o.subtreeFlags=0,g=u,u=o.child;u!==null;)k=u,r=g,k.flags&=14680066,T=k.alternate,T===null?(k.childLanes=0,k.lanes=r,k.child=null,k.subtreeFlags=0,k.memoizedProps=null,k.memoizedState=null,k.updateQueue=null,k.dependencies=null,k.stateNode=null):(k.childLanes=T.childLanes,k.lanes=T.lanes,k.child=T.child,k.subtreeFlags=0,k.deletions=null,k.memoizedProps=T.memoizedProps,k.memoizedState=T.memoizedState,k.updateQueue=T.updateQueue,k.type=T.type,r=T.dependencies,k.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),u=u.sibling;return pt(kt,kt.current&1|2),o.child}r=r.sibling}k.tail!==null&&dt()>Lo&&(o.flags|=128,g=!0,ll(k,!1),o.lanes=4194304)}else{if(!g)if(r=Wc(T),r!==null){if(o.flags|=128,g=!0,u=r.updateQueue,u!==null&&(o.updateQueue=u,o.flags|=4),ll(k,!0),k.tail===null&&k.tailMode==="hidden"&&!T.alternate&&!wt)return tn(o),null}else 2*dt()-k.renderingStartTime>Lo&&u!==1073741824&&(o.flags|=128,g=!0,ll(k,!1),o.lanes=4194304);k.isBackwards?(T.sibling=o.child,o.child=T):(u=k.last,u!==null?u.sibling=T:o.child=T,k.last=T)}return k.tail!==null?(o=k.tail,k.rendering=o,k.tail=o.sibling,k.renderingStartTime=dt(),o.sibling=null,u=kt.current,pt(kt,g?u&1|2:u&1),o):(tn(o),null);case 22:case 23:return sf(),g=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==g&&(o.flags|=8192),g&&(o.mode&1)!==0?(Sn&1073741824)!==0&&(tn(o),o.subtreeFlags&6&&(o.flags|=8192)):tn(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function NR(r,o){switch(fh(o),o.tag){case 1:return fn(o.type)&&Ic(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return Io(),yt(hn),yt(Jt),jh(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return Nh(o),null;case 13:if(yt(kt),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));To()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return yt(kt),null;case 4:return Io(),null;case 10:return vh(o.type._context),null;case 22:case 23:return sf(),null;case 24:return null;default:return null}}var Jc=!1,nn=!1,SR=typeof WeakSet=="function"?WeakSet:Set,$e=null;function Oo(r,o){var u=r.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(g){Nt(r,o,g)}else u.current=null}function Gh(r,o,u){try{u()}catch(g){Nt(r,o,g)}}var J0=!1;function jR(r,o){if(sh=po,r=Na(),Ui(r)){if("selectionStart"in r)var u={start:r.selectionStart,end:r.selectionEnd};else e:{u=(u=r.ownerDocument)&&u.defaultView||window;var g=u.getSelection&&u.getSelection();if(g&&g.rangeCount!==0){u=g.anchorNode;var w=g.anchorOffset,k=g.focusNode;g=g.focusOffset;try{u.nodeType,k.nodeType}catch{u=null;break e}var T=0,X=-1,te=-1,ue=0,ve=0,be=r,we=null;t:for(;;){for(var Ae;be!==u||w!==0&&be.nodeType!==3||(X=T+w),be!==k||g!==0&&be.nodeType!==3||(te=T+g),be.nodeType===3&&(T+=be.nodeValue.length),(Ae=be.firstChild)!==null;)we=be,be=Ae;for(;;){if(be===r)break t;if(we===u&&++ue===w&&(X=T),we===k&&++ve===g&&(te=T),(Ae=be.nextSibling)!==null)break;be=we,we=be.parentNode}be=Ae}u=X===-1||te===-1?null:{start:X,end:te}}else u=null}u=u||{start:0,end:0}}else u=null;for(ah={focusedElem:r,selectionRange:u},po=!1,$e=o;$e!==null;)if(o=$e,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,$e=r;else for(;$e!==null;){o=$e;try{var Pe=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var qe=Pe.memoizedProps,jt=Pe.memoizedState,ae=o.stateNode,re=ae.getSnapshotBeforeUpdate(o.elementType===o.type?qe:rr(o.type,qe),jt);ae.__reactInternalSnapshotBeforeUpdate=re}break;case 3:var le=o.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(_e){Nt(o,o.return,_e)}if(r=o.sibling,r!==null){r.return=o.return,$e=r;break}$e=o.return}return Pe=J0,J0=!1,Pe}function cl(r,o,u){var g=o.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var w=g=g.next;do{if((w.tag&r)===r){var k=w.destroy;w.destroy=void 0,k!==void 0&&Gh(o,u,k)}w=w.next}while(w!==g)}}function eu(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var u=o=o.next;do{if((u.tag&r)===r){var g=u.create;u.destroy=g()}u=u.next}while(u!==o)}}function Vh(r){var o=r.ref;if(o!==null){var u=r.stateNode;switch(r.tag){case 5:r=u;break;default:r=u}typeof o=="function"?o(r):o.current=r}}function eb(r){var o=r.alternate;o!==null&&(r.alternate=null,eb(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[jr],delete o[Zi],delete o[ch],delete o[lR],delete o[cR])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function tb(r){return r.tag===5||r.tag===3||r.tag===4}function nb(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||tb(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Yh(r,o,u){var g=r.tag;if(g===5||g===6)r=r.stateNode,o?u.nodeType===8?u.parentNode.insertBefore(r,o):u.insertBefore(r,o):(u.nodeType===8?(o=u.parentNode,o.insertBefore(r,u)):(o=u,o.appendChild(r)),u=u._reactRootContainer,u!=null||o.onclick!==null||(o.onclick=Rc));else if(g!==4&&(r=r.child,r!==null))for(Yh(r,o,u),r=r.sibling;r!==null;)Yh(r,o,u),r=r.sibling}function Kh(r,o,u){var g=r.tag;if(g===5||g===6)r=r.stateNode,o?u.insertBefore(r,o):u.appendChild(r);else if(g!==4&&(r=r.child,r!==null))for(Kh(r,o,u),r=r.sibling;r!==null;)Kh(r,o,u),r=r.sibling}var Gt=null,sr=!1;function Os(r,o,u){for(u=u.child;u!==null;)rb(r,o,u),u=u.sibling}function rb(r,o,u){if(It&&typeof It.onCommitFiberUnmount=="function")try{It.onCommitFiberUnmount(zr,u)}catch{}switch(u.tag){case 5:nn||Oo(u,o);case 6:var g=Gt,w=sr;Gt=null,Os(r,o,u),Gt=g,sr=w,Gt!==null&&(sr?(r=Gt,u=u.stateNode,r.nodeType===8?r.parentNode.removeChild(u):r.removeChild(u)):Gt.removeChild(u.stateNode));break;case 18:Gt!==null&&(sr?(r=Gt,u=u.stateNode,r.nodeType===8?lh(r.parentNode,u):r.nodeType===1&&lh(r,u),fa(r)):lh(Gt,u.stateNode));break;case 4:g=Gt,w=sr,Gt=u.stateNode.containerInfo,sr=!0,Os(r,o,u),Gt=g,sr=w;break;case 0:case 11:case 14:case 15:if(!nn&&(g=u.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){w=g=g.next;do{var k=w,T=k.destroy;k=k.tag,T!==void 0&&((k&2)!==0||(k&4)!==0)&&Gh(u,o,T),w=w.next}while(w!==g)}Os(r,o,u);break;case 1:if(!nn&&(Oo(u,o),g=u.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=u.memoizedProps,g.state=u.memoizedState,g.componentWillUnmount()}catch(X){Nt(u,o,X)}Os(r,o,u);break;case 21:Os(r,o,u);break;case 22:u.mode&1?(nn=(g=nn)||u.memoizedState!==null,Os(r,o,u),nn=g):Os(r,o,u);break;default:Os(r,o,u)}}function sb(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var u=r.stateNode;u===null&&(u=r.stateNode=new SR),o.forEach(function(g){var w=OR.bind(null,r,g);u.has(g)||(u.add(g),g.then(w,w))})}}function ar(r,o){var u=o.deletions;if(u!==null)for(var g=0;g<u.length;g++){var w=u[g];try{var k=r,T=o,X=T;e:for(;X!==null;){switch(X.tag){case 5:Gt=X.stateNode,sr=!1;break e;case 3:Gt=X.stateNode.containerInfo,sr=!0;break e;case 4:Gt=X.stateNode.containerInfo,sr=!0;break e}X=X.return}if(Gt===null)throw Error(n(160));rb(k,T,w),Gt=null,sr=!1;var te=w.alternate;te!==null&&(te.return=null),w.return=null}catch(ue){Nt(w,o,ue)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)ab(o,r),o=o.sibling}function ab(r,o){var u=r.alternate,g=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(ar(o,r),Tr(r),g&4){try{cl(3,r,r.return),eu(3,r)}catch(qe){Nt(r,r.return,qe)}try{cl(5,r,r.return)}catch(qe){Nt(r,r.return,qe)}}break;case 1:ar(o,r),Tr(r),g&512&&u!==null&&Oo(u,u.return);break;case 5:if(ar(o,r),Tr(r),g&512&&u!==null&&Oo(u,u.return),r.flags&32){var w=r.stateNode;try{ht(w,"")}catch(qe){Nt(r,r.return,qe)}}if(g&4&&(w=r.stateNode,w!=null)){var k=r.memoizedProps,T=u!==null?u.memoizedProps:k,X=r.type,te=r.updateQueue;if(r.updateQueue=null,te!==null)try{X==="input"&&k.type==="radio"&&k.name!=null&&ze(w,k),ut(X,T);var ue=ut(X,k);for(T=0;T<te.length;T+=2){var ve=te[T],be=te[T+1];ve==="style"?Te(w,be):ve==="dangerouslySetInnerHTML"?xt(w,be):ve==="children"?ht(w,be):E(w,ve,be,ue)}switch(X){case"input":ke(w,k);break;case"textarea":he(w,k);break;case"select":var we=w._wrapperState.wasMultiple;w._wrapperState.wasMultiple=!!k.multiple;var Ae=k.value;Ae!=null?Ne(w,!!k.multiple,Ae,!1):we!==!!k.multiple&&(k.defaultValue!=null?Ne(w,!!k.multiple,k.defaultValue,!0):Ne(w,!!k.multiple,k.multiple?[]:"",!1))}w[Zi]=k}catch(qe){Nt(r,r.return,qe)}}break;case 6:if(ar(o,r),Tr(r),g&4){if(r.stateNode===null)throw Error(n(162));w=r.stateNode,k=r.memoizedProps;try{w.nodeValue=k}catch(qe){Nt(r,r.return,qe)}}break;case 3:if(ar(o,r),Tr(r),g&4&&u!==null&&u.memoizedState.isDehydrated)try{fa(o.containerInfo)}catch(qe){Nt(r,r.return,qe)}break;case 4:ar(o,r),Tr(r);break;case 13:ar(o,r),Tr(r),w=r.child,w.flags&8192&&(k=w.memoizedState!==null,w.stateNode.isHidden=k,!k||w.alternate!==null&&w.alternate.memoizedState!==null||(Zh=dt())),g&4&&sb(r);break;case 22:if(ve=u!==null&&u.memoizedState!==null,r.mode&1?(nn=(ue=nn)||ve,ar(o,r),nn=ue):ar(o,r),Tr(r),g&8192){if(ue=r.memoizedState!==null,(r.stateNode.isHidden=ue)&&!ve&&(r.mode&1)!==0)for($e=r,ve=r.child;ve!==null;){for(be=$e=ve;$e!==null;){switch(we=$e,Ae=we.child,we.tag){case 0:case 11:case 14:case 15:cl(4,we,we.return);break;case 1:Oo(we,we.return);var Pe=we.stateNode;if(typeof Pe.componentWillUnmount=="function"){g=we,u=we.return;try{o=g,Pe.props=o.memoizedProps,Pe.state=o.memoizedState,Pe.componentWillUnmount()}catch(qe){Nt(g,u,qe)}}break;case 5:Oo(we,we.return);break;case 22:if(we.memoizedState!==null){lb(be);continue}}Ae!==null?(Ae.return=we,$e=Ae):lb(be)}ve=ve.sibling}e:for(ve=null,be=r;;){if(be.tag===5){if(ve===null){ve=be;try{w=be.stateNode,ue?(k=w.style,typeof k.setProperty=="function"?k.setProperty("display","none","important"):k.display="none"):(X=be.stateNode,te=be.memoizedProps.style,T=te!=null&&te.hasOwnProperty("display")?te.display:null,X.style.display=Oe("display",T))}catch(qe){Nt(r,r.return,qe)}}}else if(be.tag===6){if(ve===null)try{be.stateNode.nodeValue=ue?"":be.memoizedProps}catch(qe){Nt(r,r.return,qe)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===r)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===r)break e;for(;be.sibling===null;){if(be.return===null||be.return===r)break e;ve===be&&(ve=null),be=be.return}ve===be&&(ve=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:ar(o,r),Tr(r),g&4&&sb(r);break;case 21:break;default:ar(o,r),Tr(r)}}function Tr(r){var o=r.flags;if(o&2){try{e:{for(var u=r.return;u!==null;){if(tb(u)){var g=u;break e}u=u.return}throw Error(n(160))}switch(g.tag){case 5:var w=g.stateNode;g.flags&32&&(ht(w,""),g.flags&=-33);var k=nb(r);Kh(r,k,w);break;case 3:case 4:var T=g.stateNode.containerInfo,X=nb(r);Yh(r,X,T);break;default:throw Error(n(161))}}catch(te){Nt(r,r.return,te)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function ER(r,o,u){$e=r,ob(r)}function ob(r,o,u){for(var g=(r.mode&1)!==0;$e!==null;){var w=$e,k=w.child;if(w.tag===22&&g){var T=w.memoizedState!==null||Jc;if(!T){var X=w.alternate,te=X!==null&&X.memoizedState!==null||nn;X=Jc;var ue=nn;if(Jc=T,(nn=te)&&!ue)for($e=w;$e!==null;)T=$e,te=T.child,T.tag===22&&T.memoizedState!==null?cb(w):te!==null?(te.return=T,$e=te):cb(w);for(;k!==null;)$e=k,ob(k),k=k.sibling;$e=w,Jc=X,nn=ue}ib(r)}else(w.subtreeFlags&8772)!==0&&k!==null?(k.return=w,$e=k):ib(r)}}function ib(r){for(;$e!==null;){var o=$e;if((o.flags&8772)!==0){var u=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:nn||eu(5,o);break;case 1:var g=o.stateNode;if(o.flags&4&&!nn)if(u===null)g.componentDidMount();else{var w=o.elementType===o.type?u.memoizedProps:rr(o.type,u.memoizedProps);g.componentDidUpdate(w,u.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var k=o.updateQueue;k!==null&&l0(o,k,g);break;case 3:var T=o.updateQueue;if(T!==null){if(u=null,o.child!==null)switch(o.child.tag){case 5:u=o.child.stateNode;break;case 1:u=o.child.stateNode}l0(o,T,u)}break;case 5:var X=o.stateNode;if(u===null&&o.flags&4){u=X;var te=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&u.focus();break;case"img":te.src&&(u.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var ue=o.alternate;if(ue!==null){var ve=ue.memoizedState;if(ve!==null){var be=ve.dehydrated;be!==null&&fa(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}nn||o.flags&512&&Vh(o)}catch(we){Nt(o,o.return,we)}}if(o===r){$e=null;break}if(u=o.sibling,u!==null){u.return=o.return,$e=u;break}$e=o.return}}function lb(r){for(;$e!==null;){var o=$e;if(o===r){$e=null;break}var u=o.sibling;if(u!==null){u.return=o.return,$e=u;break}$e=o.return}}function cb(r){for(;$e!==null;){var o=$e;try{switch(o.tag){case 0:case 11:case 15:var u=o.return;try{eu(4,o)}catch(te){Nt(o,u,te)}break;case 1:var g=o.stateNode;if(typeof g.componentDidMount=="function"){var w=o.return;try{g.componentDidMount()}catch(te){Nt(o,w,te)}}var k=o.return;try{Vh(o)}catch(te){Nt(o,k,te)}break;case 5:var T=o.return;try{Vh(o)}catch(te){Nt(o,T,te)}}}catch(te){Nt(o,o.return,te)}if(o===r){$e=null;break}var X=o.sibling;if(X!==null){X.return=o.return,$e=X;break}$e=o.return}}var CR=Math.ceil,tu=C.ReactCurrentDispatcher,Xh=C.ReactCurrentOwner,Bn=C.ReactCurrentBatchConfig,nt=0,zt=null,Tt=null,Vt=0,Sn=0,Po=As(0),Pt=0,ul=null,La=0,nu=0,Qh=0,dl=null,mn=null,Zh=0,Lo=1/0,ts=null,ru=!1,Jh=null,Ps=null,su=!1,Ls=null,au=0,hl=0,ef=null,ou=-1,iu=0;function on(){return(nt&6)!==0?dt():ou!==-1?ou:ou=dt()}function Ds(r){return(r.mode&1)===0?1:(nt&2)!==0&&Vt!==0?Vt&-Vt:dR.transition!==null?(iu===0&&(iu=Et()),iu):(r=at,r!==0||(r=window.event,r=r===void 0?16:ji(r.type)),r)}function or(r,o,u,g){if(50<hl)throw hl=0,ef=null,Error(n(185));rn(r,u,g),((nt&2)===0||r!==zt)&&(r===zt&&((nt&2)===0&&(nu|=u),Pt===4&&qs(r,Vt)),gn(r,g),u===1&&nt===0&&(o.mode&1)===0&&(Lo=dt()+500,Oc&&Ms()))}function gn(r,o){var u=r.callbackNode;Gd(r,o);var g=Xt(r,r===zt?Vt:0);if(g===0)u!==null&&so(u),r.callbackNode=null,r.callbackPriority=0;else if(o=g&-g,r.callbackPriority!==o){if(u!=null&&so(u),o===1)r.tag===0?uR(db.bind(null,r)):Xx(db.bind(null,r)),oR(function(){(nt&6)===0&&Ms()}),u=null;else{switch(Zn(g)){case 1:u=ia;break;case 4:u=qr;break;case 16:u=Fr;break;case 536870912:u=la;break;default:u=Fr}u=vb(u,ub.bind(null,r))}r.callbackPriority=o,r.callbackNode=u}}function ub(r,o){if(ou=-1,iu=0,(nt&6)!==0)throw Error(n(327));var u=r.callbackNode;if(Do()&&r.callbackNode!==u)return null;var g=Xt(r,r===zt?Vt:0);if(g===0)return null;if((g&30)!==0||(g&r.expiredLanes)!==0||o)o=lu(r,g);else{o=g;var w=nt;nt|=2;var k=fb();(zt!==r||Vt!==o)&&(ts=null,Lo=dt()+500,qa(r,o));do try{RR();break}catch(X){hb(r,X)}while(!0);wh(),tu.current=k,nt=w,Tt!==null?o=0:(zt=null,Vt=0,o=Pt)}if(o!==0){if(o===2&&(w=ua(r),w!==0&&(g=w,o=tf(r,w))),o===1)throw u=ul,qa(r,0),qs(r,g),gn(r,dt()),u;if(o===6)qs(r,g);else{if(w=r.current.alternate,(g&30)===0&&!TR(w)&&(o=lu(r,g),o===2&&(k=ua(r),k!==0&&(g=k,o=tf(r,k))),o===1))throw u=ul,qa(r,0),qs(r,g),gn(r,dt()),u;switch(r.finishedWork=w,r.finishedLanes=g,o){case 0:case 1:throw Error(n(345));case 2:Fa(r,mn,ts);break;case 3:if(qs(r,g),(g&130023424)===g&&(o=Zh+500-dt(),10<o)){if(Xt(r,0)!==0)break;if(w=r.suspendedLanes,(w&g)!==g){on(),r.pingedLanes|=r.suspendedLanes&w;break}r.timeoutHandle=ih(Fa.bind(null,r,mn,ts),o);break}Fa(r,mn,ts);break;case 4:if(qs(r,g),(g&4194240)===g)break;for(o=r.eventTimes,w=-1;0<g;){var T=31-cn(g);k=1<<T,T=o[T],T>w&&(w=T),g&=~k}if(g=w,g=dt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*CR(g/1960))-g,10<g){r.timeoutHandle=ih(Fa.bind(null,r,mn,ts),g);break}Fa(r,mn,ts);break;case 5:Fa(r,mn,ts);break;default:throw Error(n(329))}}}return gn(r,dt()),r.callbackNode===u?ub.bind(null,r):null}function tf(r,o){var u=dl;return r.current.memoizedState.isDehydrated&&(qa(r,o).flags|=256),r=lu(r,o),r!==2&&(o=mn,mn=u,o!==null&&nf(o)),r}function nf(r){mn===null?mn=r:mn.push.apply(mn,r)}function TR(r){for(var o=r;;){if(o.flags&16384){var u=o.updateQueue;if(u!==null&&(u=u.stores,u!==null))for(var g=0;g<u.length;g++){var w=u[g],k=w.getSnapshot;w=w.value;try{if(!dn(k(),w))return!1}catch{return!1}}}if(u=o.child,o.subtreeFlags&16384&&u!==null)u.return=o,o=u;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function qs(r,o){for(o&=~Qh,o&=~nu,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var u=31-cn(o),g=1<<u;r[u]=-1,o&=~g}}function db(r){if((nt&6)!==0)throw Error(n(327));Do();var o=Xt(r,0);if((o&1)===0)return gn(r,dt()),null;var u=lu(r,o);if(r.tag!==0&&u===2){var g=ua(r);g!==0&&(o=g,u=tf(r,g))}if(u===1)throw u=ul,qa(r,0),qs(r,o),gn(r,dt()),u;if(u===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,Fa(r,mn,ts),gn(r,dt()),null}function rf(r,o){var u=nt;nt|=1;try{return r(o)}finally{nt=u,nt===0&&(Lo=dt()+500,Oc&&Ms())}}function Da(r){Ls!==null&&Ls.tag===0&&(nt&6)===0&&Do();var o=nt;nt|=1;var u=Bn.transition,g=at;try{if(Bn.transition=null,at=1,r)return r()}finally{at=g,Bn.transition=u,nt=o,(nt&6)===0&&Ms()}}function sf(){Sn=Po.current,yt(Po)}function qa(r,o){r.finishedWork=null,r.finishedLanes=0;var u=r.timeoutHandle;if(u!==-1&&(r.timeoutHandle=-1,aR(u)),Tt!==null)for(u=Tt.return;u!==null;){var g=u;switch(fh(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&Ic();break;case 3:Io(),yt(hn),yt(Jt),jh();break;case 5:Nh(g);break;case 4:Io();break;case 13:yt(kt);break;case 19:yt(kt);break;case 10:vh(g.type._context);break;case 22:case 23:sf()}u=u.return}if(zt=r,Tt=r=Fs(r.current,null),Vt=Sn=o,Pt=0,ul=null,Qh=nu=La=0,mn=dl=null,$a!==null){for(o=0;o<$a.length;o++)if(u=$a[o],g=u.interleaved,g!==null){u.interleaved=null;var w=g.next,k=u.pending;if(k!==null){var T=k.next;k.next=w,g.next=T}u.pending=g}$a=null}return r}function hb(r,o){do{var u=Tt;try{if(wh(),Hc.current=Kc,Gc){for(var g=_t.memoizedState;g!==null;){var w=g.queue;w!==null&&(w.pending=null),g=g.next}Gc=!1}if(Pa=0,Bt=Ot=_t=null,sl=!1,al=0,Xh.current=null,u===null||u.return===null){Pt=1,ul=o,Tt=null;break}e:{var k=r,T=u.return,X=u,te=o;if(o=Vt,X.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ue=te,ve=X,be=ve.tag;if((ve.mode&1)===0&&(be===0||be===11||be===15)){var we=ve.alternate;we?(ve.updateQueue=we.updateQueue,ve.memoizedState=we.memoizedState,ve.lanes=we.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Ae=L0(T);if(Ae!==null){Ae.flags&=-257,D0(Ae,T,X,k,o),Ae.mode&1&&P0(k,ue,o),o=Ae,te=ue;var Pe=o.updateQueue;if(Pe===null){var qe=new Set;qe.add(te),o.updateQueue=qe}else Pe.add(te);break e}else{if((o&1)===0){P0(k,ue,o),af();break e}te=Error(n(426))}}else if(wt&&X.mode&1){var jt=L0(T);if(jt!==null){(jt.flags&65536)===0&&(jt.flags|=256),D0(jt,T,X,k,o),gh($o(te,X));break e}}k=te=$o(te,X),Pt!==4&&(Pt=2),dl===null?dl=[k]:dl.push(k),k=T;do{switch(k.tag){case 3:k.flags|=65536,o&=-o,k.lanes|=o;var ae=$0(k,te,o);i0(k,ae);break e;case 1:X=te;var re=k.type,le=k.stateNode;if((k.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Ps===null||!Ps.has(le)))){k.flags|=65536,o&=-o,k.lanes|=o;var _e=O0(k,X,o);i0(k,_e);break e}}k=k.return}while(k!==null)}mb(u)}catch(Be){o=Be,Tt===u&&u!==null&&(Tt=u=u.return);continue}break}while(!0)}function fb(){var r=tu.current;return tu.current=Kc,r===null?Kc:r}function af(){(Pt===0||Pt===3||Pt===2)&&(Pt=4),zt===null||(La&268435455)===0&&(nu&268435455)===0||qs(zt,Vt)}function lu(r,o){var u=nt;nt|=2;var g=fb();(zt!==r||Vt!==o)&&(ts=null,qa(r,o));do try{AR();break}catch(w){hb(r,w)}while(!0);if(wh(),nt=u,tu.current=g,Tt!==null)throw Error(n(261));return zt=null,Vt=0,Pt}function AR(){for(;Tt!==null;)pb(Tt)}function RR(){for(;Tt!==null&&!oa();)pb(Tt)}function pb(r){var o=wb(r.alternate,r,Sn);r.memoizedProps=r.pendingProps,o===null?mb(r):Tt=o,Xh.current=null}function mb(r){var o=r;do{var u=o.alternate;if(r=o.return,(o.flags&32768)===0){if(u=_R(u,o,Sn),u!==null){Tt=u;return}}else{if(u=NR(u,o),u!==null){u.flags&=32767,Tt=u;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Pt=6,Tt=null;return}}if(o=o.sibling,o!==null){Tt=o;return}Tt=o=r}while(o!==null);Pt===0&&(Pt=5)}function Fa(r,o,u){var g=at,w=Bn.transition;try{Bn.transition=null,at=1,MR(r,o,u,g)}finally{Bn.transition=w,at=g}return null}function MR(r,o,u,g){do Do();while(Ls!==null);if((nt&6)!==0)throw Error(n(327));u=r.finishedWork;var w=r.finishedLanes;if(u===null)return null;if(r.finishedWork=null,r.finishedLanes=0,u===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var k=u.lanes|u.childLanes;if(lo(r,k),r===zt&&(Tt=zt=null,Vt=0),(u.subtreeFlags&2064)===0&&(u.flags&2064)===0||su||(su=!0,vb(Fr,function(){return Do(),null})),k=(u.flags&15990)!==0,(u.subtreeFlags&15990)!==0||k){k=Bn.transition,Bn.transition=null;var T=at;at=1;var X=nt;nt|=4,Xh.current=null,jR(r,u),ab(u,r),Vr(ah),po=!!sh,ah=sh=null,r.current=u,ER(u),xi(),nt=X,at=T,Bn.transition=k}else r.current=u;if(su&&(su=!1,Ls=r,au=w),k=r.pendingLanes,k===0&&(Ps=null),ca(u.stateNode),gn(r,dt()),o!==null)for(g=r.onRecoverableError,u=0;u<o.length;u++)w=o[u],g(w.value,{componentStack:w.stack,digest:w.digest});if(ru)throw ru=!1,r=Jh,Jh=null,r;return(au&1)!==0&&r.tag!==0&&Do(),k=r.pendingLanes,(k&1)!==0?r===ef?hl++:(hl=0,ef=r):hl=0,Ms(),null}function Do(){if(Ls!==null){var r=Zn(au),o=Bn.transition,u=at;try{if(Bn.transition=null,at=16>r?16:r,Ls===null)var g=!1;else{if(r=Ls,Ls=null,au=0,(nt&6)!==0)throw Error(n(331));var w=nt;for(nt|=4,$e=r.current;$e!==null;){var k=$e,T=k.child;if(($e.flags&16)!==0){var X=k.deletions;if(X!==null){for(var te=0;te<X.length;te++){var ue=X[te];for($e=ue;$e!==null;){var ve=$e;switch(ve.tag){case 0:case 11:case 15:cl(8,ve,k)}var be=ve.child;if(be!==null)be.return=ve,$e=be;else for(;$e!==null;){ve=$e;var we=ve.sibling,Ae=ve.return;if(eb(ve),ve===ue){$e=null;break}if(we!==null){we.return=Ae,$e=we;break}$e=Ae}}}var Pe=k.alternate;if(Pe!==null){var qe=Pe.child;if(qe!==null){Pe.child=null;do{var jt=qe.sibling;qe.sibling=null,qe=jt}while(qe!==null)}}$e=k}}if((k.subtreeFlags&2064)!==0&&T!==null)T.return=k,$e=T;else e:for(;$e!==null;){if(k=$e,(k.flags&2048)!==0)switch(k.tag){case 0:case 11:case 15:cl(9,k,k.return)}var ae=k.sibling;if(ae!==null){ae.return=k.return,$e=ae;break e}$e=k.return}}var re=r.current;for($e=re;$e!==null;){T=$e;var le=T.child;if((T.subtreeFlags&2064)!==0&&le!==null)le.return=T,$e=le;else e:for(T=re;$e!==null;){if(X=$e,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:eu(9,X)}}catch(Be){Nt(X,X.return,Be)}if(X===T){$e=null;break e}var _e=X.sibling;if(_e!==null){_e.return=X.return,$e=_e;break e}$e=X.return}}if(nt=w,Ms(),It&&typeof It.onPostCommitFiberRoot=="function")try{It.onPostCommitFiberRoot(zr,r)}catch{}g=!0}return g}finally{at=u,Bn.transition=o}}return!1}function gb(r,o,u){o=$o(u,o),o=$0(r,o,1),r=$s(r,o,1),o=on(),r!==null&&(rn(r,1,o),gn(r,o))}function Nt(r,o,u){if(r.tag===3)gb(r,r,u);else for(;o!==null;){if(o.tag===3){gb(o,r,u);break}else if(o.tag===1){var g=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Ps===null||!Ps.has(g))){r=$o(u,r),r=O0(o,r,1),o=$s(o,r,1),r=on(),o!==null&&(rn(o,1,r),gn(o,r));break}}o=o.return}}function IR(r,o,u){var g=r.pingCache;g!==null&&g.delete(o),o=on(),r.pingedLanes|=r.suspendedLanes&u,zt===r&&(Vt&u)===u&&(Pt===4||Pt===3&&(Vt&130023424)===Vt&&500>dt()-Zh?qa(r,0):Qh|=u),gn(r,o)}function yb(r,o){o===0&&((r.mode&1)===0?o=1:(o=oo,oo<<=1,(oo&130023424)===0&&(oo=4194304)));var u=on();r=Zr(r,o),r!==null&&(rn(r,o,u),gn(r,u))}function $R(r){var o=r.memoizedState,u=0;o!==null&&(u=o.retryLane),yb(r,u)}function OR(r,o){var u=0;switch(r.tag){case 13:var g=r.stateNode,w=r.memoizedState;w!==null&&(u=w.retryLane);break;case 19:g=r.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(o),yb(r,u)}var wb;wb=function(r,o,u){if(r!==null)if(r.memoizedProps!==o.pendingProps||hn.current)pn=!0;else{if((r.lanes&u)===0&&(o.flags&128)===0)return pn=!1,kR(r,o,u);pn=(r.flags&131072)!==0}else pn=!1,wt&&(o.flags&1048576)!==0&&Qx(o,Lc,o.index);switch(o.lanes=0,o.tag){case 2:var g=o.type;Zc(r,o),r=o.pendingProps;var w=jo(o,Jt.current);Mo(o,u),w=Th(null,o,g,r,w,u);var k=Ah();return o.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,fn(g)?(k=!0,$c(o)):k=!1,o.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,kh(o),w.updater=Xc,o.stateNode=w,w._reactInternals=o,Ph(o,g,r,u),o=Fh(null,o,g,!0,k,u)):(o.tag=0,wt&&k&&hh(o),an(null,o,w,u),o=o.child),o;case 16:g=o.elementType;e:{switch(Zc(r,o),r=o.pendingProps,w=g._init,g=w(g._payload),o.type=g,w=o.tag=LR(g),r=rr(g,r),w){case 0:o=qh(null,o,g,r,u);break e;case 1:o=W0(null,o,g,r,u);break e;case 11:o=q0(null,o,g,r,u);break e;case 14:o=F0(null,o,g,rr(g.type,r),u);break e}throw Error(n(306,g,""))}return o;case 0:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),qh(r,o,g,w,u);case 1:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),W0(r,o,g,w,u);case 3:e:{if(H0(o),r===null)throw Error(n(387));g=o.pendingProps,k=o.memoizedState,w=k.element,o0(r,o),Uc(o,g,null,u);var T=o.memoizedState;if(g=T.element,k.isDehydrated)if(k={element:g,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},o.updateQueue.baseState=k,o.memoizedState=k,o.flags&256){w=$o(Error(n(423)),o),o=G0(r,o,g,u,w);break e}else if(g!==w){w=$o(Error(n(424)),o),o=G0(r,o,g,u,w);break e}else for(Nn=Ts(o.stateNode.containerInfo.firstChild),_n=o,wt=!0,nr=null,u=s0(o,null,g,u),o.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(To(),g===w){o=es(r,o,u);break e}an(r,o,g,u)}o=o.child}return o;case 5:return c0(o),r===null&&mh(o),g=o.type,w=o.pendingProps,k=r!==null?r.memoizedProps:null,T=w.children,oh(g,w)?T=null:k!==null&&oh(g,k)&&(o.flags|=32),U0(r,o),an(r,o,T,u),o.child;case 6:return r===null&&mh(o),null;case 13:return V0(r,o,u);case 4:return _h(o,o.stateNode.containerInfo),g=o.pendingProps,r===null?o.child=Ao(o,null,g,u):an(r,o,g,u),o.child;case 11:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),q0(r,o,g,w,u);case 7:return an(r,o,o.pendingProps,u),o.child;case 8:return an(r,o,o.pendingProps.children,u),o.child;case 12:return an(r,o,o.pendingProps.children,u),o.child;case 10:e:{if(g=o.type._context,w=o.pendingProps,k=o.memoizedProps,T=w.value,pt(Fc,g._currentValue),g._currentValue=T,k!==null)if(dn(k.value,T)){if(k.children===w.children&&!hn.current){o=es(r,o,u);break e}}else for(k=o.child,k!==null&&(k.return=o);k!==null;){var X=k.dependencies;if(X!==null){T=k.child;for(var te=X.firstContext;te!==null;){if(te.context===g){if(k.tag===1){te=Jr(-1,u&-u),te.tag=2;var ue=k.updateQueue;if(ue!==null){ue=ue.shared;var ve=ue.pending;ve===null?te.next=te:(te.next=ve.next,ve.next=te),ue.pending=te}}k.lanes|=u,te=k.alternate,te!==null&&(te.lanes|=u),xh(k.return,u,o),X.lanes|=u;break}te=te.next}}else if(k.tag===10)T=k.type===o.type?null:k.child;else if(k.tag===18){if(T=k.return,T===null)throw Error(n(341));T.lanes|=u,X=T.alternate,X!==null&&(X.lanes|=u),xh(T,u,o),T=k.sibling}else T=k.child;if(T!==null)T.return=k;else for(T=k;T!==null;){if(T===o){T=null;break}if(k=T.sibling,k!==null){k.return=T.return,T=k;break}T=T.return}k=T}an(r,o,w.children,u),o=o.child}return o;case 9:return w=o.type,g=o.pendingProps.children,Mo(o,u),w=qn(w),g=g(w),o.flags|=1,an(r,o,g,u),o.child;case 14:return g=o.type,w=rr(g,o.pendingProps),w=rr(g.type,w),F0(r,o,g,w,u);case 15:return B0(r,o,o.type,o.pendingProps,u);case 17:return g=o.type,w=o.pendingProps,w=o.elementType===g?w:rr(g,w),Zc(r,o),o.tag=1,fn(g)?(r=!0,$c(o)):r=!1,Mo(o,u),M0(o,g,w),Ph(o,g,w,u),Fh(null,o,g,!0,r,u);case 19:return K0(r,o,u);case 22:return z0(r,o,u)}throw Error(n(156,o.tag))};function vb(r,o){return aa(r,o)}function PR(r,o,u,g){this.tag=r,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zn(r,o,u,g){return new PR(r,o,u,g)}function of(r){return r=r.prototype,!(!r||!r.isReactComponent)}function LR(r){if(typeof r=="function")return of(r)?1:0;if(r!=null){if(r=r.$$typeof,r===H)return 11;if(r===Q)return 14}return 2}function Fs(r,o){var u=r.alternate;return u===null?(u=zn(r.tag,o,r.key,r.mode),u.elementType=r.elementType,u.type=r.type,u.stateNode=r.stateNode,u.alternate=r,r.alternate=u):(u.pendingProps=o,u.type=r.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=r.flags&14680064,u.childLanes=r.childLanes,u.lanes=r.lanes,u.child=r.child,u.memoizedProps=r.memoizedProps,u.memoizedState=r.memoizedState,u.updateQueue=r.updateQueue,o=r.dependencies,u.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},u.sibling=r.sibling,u.index=r.index,u.ref=r.ref,u}function cu(r,o,u,g,w,k){var T=2;if(g=r,typeof r=="function")of(r)&&(T=1);else if(typeof r=="string")T=5;else e:switch(r){case $:return Ba(u.children,w,k,o);case F:T=8,w|=8;break;case O:return r=zn(12,u,o,w|2),r.elementType=O,r.lanes=k,r;case B:return r=zn(13,u,o,w),r.elementType=B,r.lanes=k,r;case A:return r=zn(19,u,o,w),r.elementType=A,r.lanes=k,r;case ee:return uu(u,w,k,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case M:T=10;break e;case L:T=9;break e;case H:T=11;break e;case Q:T=14;break e;case K:T=16,g=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=zn(T,u,o,w),o.elementType=r,o.type=g,o.lanes=k,o}function Ba(r,o,u,g){return r=zn(7,r,g,o),r.lanes=u,r}function uu(r,o,u,g){return r=zn(22,r,g,o),r.elementType=ee,r.lanes=u,r.stateNode={isHidden:!1},r}function lf(r,o,u){return r=zn(6,r,null,o),r.lanes=u,r}function cf(r,o,u){return o=zn(4,r.children!==null?r.children:[],r.key,o),o.lanes=u,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function DR(r,o,u,g,w){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=bi(0),this.expirationTimes=bi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bi(0),this.identifierPrefix=g,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function uf(r,o,u,g,w,k,T,X,te){return r=new DR(r,o,u,X,te),o===1?(o=1,k===!0&&(o|=8)):o=0,k=zn(3,null,null,o),r.current=k,k.stateNode=r,k.memoizedState={element:g,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},kh(k),r}function qR(r,o,u){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:g==null?null:""+g,children:r,containerInfo:o,implementation:u}}function xb(r){if(!r)return Rs;r=r._reactInternals;e:{if(Rn(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(fn(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var u=r.type;if(fn(u))return Yx(r,u,o)}return o}function bb(r,o,u,g,w,k,T,X,te){return r=uf(u,g,!0,r,w,k,T,X,te),r.context=xb(null),u=r.current,g=on(),w=Ds(u),k=Jr(g,w),k.callback=o??null,$s(u,k,w),r.current.lanes=w,rn(r,w,g),gn(r,g),r}function du(r,o,u,g){var w=o.current,k=on(),T=Ds(w);return u=xb(u),o.context===null?o.context=u:o.pendingContext=u,o=Jr(k,T),o.payload={element:r},g=g===void 0?null:g,g!==null&&(o.callback=g),r=$s(w,o,T),r!==null&&(or(r,w,T,k),zc(r,w,T)),T}function hu(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function kb(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var u=r.retryLane;r.retryLane=u!==0&&u<o?u:o}}function df(r,o){kb(r,o),(r=r.alternate)&&kb(r,o)}function FR(){return null}var _b=typeof reportError=="function"?reportError:function(r){console.error(r)};function hf(r){this._internalRoot=r}fu.prototype.render=hf.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));du(r,o,null,null)},fu.prototype.unmount=hf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;Da(function(){du(null,r,null,null)}),o[Yr]=null}};function fu(r){this._internalRoot=r}fu.prototype.unstable_scheduleHydration=function(r){if(r){var o=_i();r={blockedOn:null,target:r,priority:o};for(var u=0;u<er.length&&o!==0&&o<er[u].priority;u++);er.splice(u,0,r),u===0&&ho(r)}};function ff(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function pu(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Nb(){}function BR(r,o,u,g,w){if(w){if(typeof g=="function"){var k=g;g=function(){var ue=hu(T);k.call(ue)}}var T=bb(o,g,r,0,null,!1,!1,"",Nb);return r._reactRootContainer=T,r[Yr]=T.current,Ta(r.nodeType===8?r.parentNode:r),Da(),T}for(;w=r.lastChild;)r.removeChild(w);if(typeof g=="function"){var X=g;g=function(){var ue=hu(te);X.call(ue)}}var te=uf(r,0,!1,null,null,!1,!1,"",Nb);return r._reactRootContainer=te,r[Yr]=te.current,Ta(r.nodeType===8?r.parentNode:r),Da(function(){du(o,te,u,g)}),te}function mu(r,o,u,g,w){var k=u._reactRootContainer;if(k){var T=k;if(typeof w=="function"){var X=w;w=function(){var te=hu(T);X.call(te)}}du(o,T,r,w)}else T=BR(u,o,r,w,g);return hu(T)}da=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var u=fs(o.pendingLanes);u!==0&&(co(o,u|1),gn(o,dt()),(nt&6)===0&&(Lo=dt()+500,Ms()))}break;case 13:Da(function(){var g=Zr(r,1);if(g!==null){var w=on();or(g,r,1,w)}}),df(r,1)}},ki=function(r){if(r.tag===13){var o=Zr(r,134217728);if(o!==null){var u=on();or(o,r,134217728,u)}df(r,134217728)}},lc=function(r){if(r.tag===13){var o=Ds(r),u=Zr(r,o);if(u!==null){var g=on();or(u,r,o,g)}df(r,o)}},_i=function(){return at},Ni=function(r,o){var u=at;try{return at=r,o()}finally{at=u}},ft=function(r,o,u){switch(o){case"input":if(ke(r,u),o=u.name,u.type==="radio"&&o!=null){for(u=r;u.parentNode;)u=u.parentNode;for(u=u.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<u.length;o++){var g=u[o];if(g!==r&&g.form===r.form){var w=Mc(g);if(!w)throw Error(n(90));Le(g),ke(g,w)}}}break;case"textarea":he(r,u);break;case"select":o=u.value,o!=null&&Ne(r,!!u.multiple,o,!1)}},ds=rf,Or=Da;var zR={usingClientEntryPoint:!1,Events:[Ji,No,Mc,ln,to,rf]},fl={findFiberByHostInstance:Aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},UR={bundleType:fl.bundleType,version:fl.version,rendererPackageName:fl.rendererPackageName,rendererConfig:fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=ra(r),r===null?null:r.stateNode},findFiberByHostInstance:fl.findFiberByHostInstance||FR,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 gu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gu.isDisabled&&gu.supportsFiber)try{zr=gu.inject(UR),It=gu}catch{}}return yn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zR,yn.createPortal=function(r,o){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ff(o))throw Error(n(200));return qR(r,o,null,u)},yn.createRoot=function(r,o){if(!ff(r))throw Error(n(299));var u=!1,g="",w=_b;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(w=o.onRecoverableError)),o=uf(r,1,!1,null,null,u,!1,g,w),r[Yr]=o.current,Ta(r.nodeType===8?r.parentNode:r),new hf(o)},yn.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=ra(o),r=r===null?null:r.stateNode,r},yn.flushSync=function(r){return Da(r)},yn.hydrate=function(r,o,u){if(!pu(o))throw Error(n(200));return mu(null,r,o,!0,u)},yn.hydrateRoot=function(r,o,u){if(!ff(r))throw Error(n(405));var g=u!=null&&u.hydratedSources||null,w=!1,k="",T=_b;if(u!=null&&(u.unstable_strictMode===!0&&(w=!0),u.identifierPrefix!==void 0&&(k=u.identifierPrefix),u.onRecoverableError!==void 0&&(T=u.onRecoverableError)),o=bb(o,null,r,1,u??null,w,!1,k,T),r[Yr]=o.current,Ta(r),g)for(r=0;r<g.length;r++)u=g[r],w=u._getVersion,w=w(u._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[u,w]:o.mutableSourceEagerHydrationData.push(u,w);return new fu(o)},yn.render=function(r,o,u){if(!pu(o))throw Error(n(200));return mu(null,r,o,!1,u)},yn.unmountComponentAtNode=function(r){if(!pu(r))throw Error(n(40));return r._reactRootContainer?(Da(function(){mu(null,null,r,!1,function(){r._reactRootContainer=null,r[Yr]=null})}),!0):!1},yn.unstable_batchedUpdates=rf,yn.unstable_renderSubtreeIntoContainer=function(r,o,u,g){if(!pu(u))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return mu(r,o,u,!1,g)},yn.version="18.3.1-next-f1338f8080-20240426",yn}var Mb;function SC(){if(Mb)return gf.exports;Mb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),gf.exports=XR(),gf.exports}var Ib;function QR(){if(Ib)return wu;Ib=1;var e=SC();return wu.createRoot=e.createRoot,wu.hydrateRoot=e.hydrateRoot,wu}var ZR=QR(),b=Wl();const fe=zv(b);function Kt(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=Kt(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var vf={exports:{}},xf={},bf={exports:{}},kf={};/**
41
41
  * @license React
42
42
  * use-sync-external-store-shim.production.js
43
43
  *
@@ -45,7 +45,7 @@ Error generating stack: `+k.message+`
45
45
  *
46
46
  * This source code is licensed under the MIT license found in the
47
47
  * LICENSE file in the root directory of this source tree.
48
- */var $b;function JR(){if($b)return bf;$b=1;var e=Ul();function t(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function d(m,y){var v=y(),j=s({inst:{value:v,getSnapshot:y}}),_=j[0].inst,S=j[1];return l(function(){_.value=v,_.getSnapshot=y,h(_)&&S({inst:_})},[m,v,y]),a(function(){return h(_)&&S({inst:_}),m(function(){h(_)&&S({inst:_})})},[m]),c(v),v}function h(m){var y=m.getSnapshot;m=m.value;try{var v=y();return!n(m,v)}catch{return!0}}function p(m,y){return y()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:d;return bf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,bf}var Ob;function eM(){return Ob||(Ob=1,xf.exports=JR()),xf.exports}/**
48
+ */var $b;function JR(){if($b)return kf;$b=1;var e=Wl();function t(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function d(m,y){var v=y(),j=s({inst:{value:v,getSnapshot:y}}),_=j[0].inst,S=j[1];return l(function(){_.value=v,_.getSnapshot=y,h(_)&&S({inst:_})},[m,v,y]),a(function(){return h(_)&&S({inst:_}),m(function(){h(_)&&S({inst:_})})},[m]),c(v),v}function h(m){var y=m.getSnapshot;m=m.value;try{var v=y();return!n(m,v)}catch{return!0}}function p(m,y){return y()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:d;return kf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,kf}var Ob;function eM(){return Ob||(Ob=1,bf.exports=JR()),bf.exports}/**
49
49
  * @license React
50
50
  * use-sync-external-store-shim/with-selector.production.js
51
51
  *
@@ -53,32 +53,32 @@ Error generating stack: `+k.message+`
53
53
  *
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
- */var Pb;function tM(){if(Pb)return vf;Pb=1;var e=Ul(),t=eM();function n(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,l=e.useRef,c=e.useEffect,d=e.useMemo,h=e.useDebugValue;return vf.useSyncExternalStoreWithSelector=function(p,f,m,y,v){var j=l(null);if(j.current===null){var _={hasValue:!1,value:null};j.current=_}else _=j.current;j=d(function(){function x(I){if(!N){if(N=!0,E=I,I=y(I),v!==void 0&&_.hasValue){var $=_.value;if(v($,I))return C=$}return C=I}if($=C,s(E,I))return $;var F=y(I);return v!==void 0&&v($,F)?(E=I,$):(E=I,C=F)}var N=!1,E,C,R=m===void 0?null:m;return[function(){return x(f())},R===null?void 0:function(){return x(R())}]},[f,m,y,v]);var S=a(p,j[0],j[1]);return c(function(){_.hasValue=!0,_.value=S},[S]),h(S),S},vf}var Lb;function nM(){return Lb||(Lb=1,wf.exports=tM()),wf.exports}var rM=nM();const sM=Bv(rM),aM={},Db=e=>{let t;const n=new Set,s=(f,m)=>{const y=typeof f=="function"?f(t):f;if(!Object.is(y,t)){const v=t;t=m??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(j=>j(t,v))}},a=()=>t,h={setState:s,getState:a,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(aM?"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()}},p=t=e(s,a,h);return h},oM=e=>e?Db(e):Db,{useDebugValue:iM}=fe,{useSyncExternalStoreWithSelector:lM}=sM,cM=e=>e;function jC(e,t=cM,n){const s=lM(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return iM(s),s}const qb=(e,t)=>{const n=oM(e),s=(a,l=t)=>jC(n,a,l);return Object.assign(s,n),s},uM=(e,t)=>e?qb(e,t):qb;function Dt(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 dM={value:()=>{}};function pd(){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 Fu(n)}function Fu(e){this._=e}function hM(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}})}Fu.prototype=pd.prototype={constructor:Fu,on:function(e,t){var n=this._,s=hM(e+"",n),a,l=-1,c=s.length;if(arguments.length<2){for(;++l<c;)if((a=(e=s[l]).type)&&(a=fM(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<c;)if(a=(e=s[l]).type)n[a]=Fb(n[a],e.name,t);else if(t==null)for(a in n)n[a]=Fb(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 Fu(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),s=0,a,l;s<a;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,a=l.length;s<a;++s)l[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,l=s.length;a<l;++a)s[a].value.apply(t,n)}};function fM(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function Fb(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=dM,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var ov="http://www.w3.org/1999/xhtml";const Bb={svg:"http://www.w3.org/2000/svg",xhtml:ov,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function md(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Bb.hasOwnProperty(t)?{space:Bb[t],local:e}:e}function pM(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ov&&t.documentElement.namespaceURI===ov?t.createElement(e):t.createElementNS(n,e)}}function mM(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function EC(e){var t=md(e);return(t.local?mM:pM)(t)}function gM(){}function zv(e){return e==null?gM:function(){return this.querySelector(e)}}function yM(e){typeof e!="function"&&(e=zv(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=new Array(c),h,p,f=0;f<c;++f)(h=l[f])&&(p=e.call(h,h.__data__,f,l))&&("__data__"in h&&(p.__data__=h.__data__),d[f]=p);return new Cn(s,this._parents)}function wM(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vM(){return[]}function CC(e){return e==null?vM:function(){return this.querySelectorAll(e)}}function xM(e){return function(){return wM(e.apply(this,arguments))}}function bM(e){typeof e=="function"?e=xM(e):e=CC(e);for(var t=this._groups,n=t.length,s=[],a=[],l=0;l<n;++l)for(var c=t[l],d=c.length,h,p=0;p<d;++p)(h=c[p])&&(s.push(e.call(h,h.__data__,p,c)),a.push(h));return new Cn(s,a)}function TC(e){return function(){return this.matches(e)}}function AC(e){return function(t){return t.matches(e)}}var kM=Array.prototype.find;function _M(e){return function(){return kM.call(this.children,e)}}function NM(){return this.firstElementChild}function SM(e){return this.select(e==null?NM:_M(typeof e=="function"?e:AC(e)))}var jM=Array.prototype.filter;function EM(){return Array.from(this.children)}function CM(e){return function(){return jM.call(this.children,e)}}function TM(e){return this.selectAll(e==null?EM:CM(typeof e=="function"?e:AC(e)))}function AM(e){typeof e!="function"&&(e=TC(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=[],h,p=0;p<c;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&d.push(h);return new Cn(s,this._parents)}function RC(e){return new Array(e.length)}function RM(){return new Cn(this._enter||this._groups.map(RC),this._parents)}function Yu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yu.prototype={constructor:Yu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function MM(e){return function(){return e}}function IM(e,t,n,s,a,l){for(var c=0,d,h=t.length,p=l.length;c<p;++c)(d=t[c])?(d.__data__=l[c],s[c]=d):n[c]=new Yu(e,l[c]);for(;c<h;++c)(d=t[c])&&(a[c]=d)}function $M(e,t,n,s,a,l,c){var d,h,p=new Map,f=t.length,m=l.length,y=new Array(f),v;for(d=0;d<f;++d)(h=t[d])&&(y[d]=v=c.call(h,h.__data__,d,t)+"",p.has(v)?a[d]=h:p.set(v,h));for(d=0;d<m;++d)v=c.call(e,l[d],d,l)+"",(h=p.get(v))?(s[d]=h,h.__data__=l[d],p.delete(v)):n[d]=new Yu(e,l[d]);for(d=0;d<f;++d)(h=t[d])&&p.get(y[d])===h&&(a[d]=h)}function OM(e){return e.__data__}function PM(e,t){if(!arguments.length)return Array.from(this,OM);var n=t?$M:IM,s=this._parents,a=this._groups;typeof e!="function"&&(e=MM(e));for(var l=a.length,c=new Array(l),d=new Array(l),h=new Array(l),p=0;p<l;++p){var f=s[p],m=a[p],y=m.length,v=LM(e.call(f,f&&f.__data__,p,s)),j=v.length,_=d[p]=new Array(j),S=c[p]=new Array(j),x=h[p]=new Array(y);n(f,m,_,S,x,v,t);for(var N=0,E=0,C,R;N<j;++N)if(C=_[N]){for(N>=E&&(E=N+1);!(R=S[E])&&++E<j;);C._next=R||null}}return c=new Cn(c,s),c._enter=d,c._exit=h,c}function LM(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function DM(){return new Cn(this._exit||this._groups.map(RC),this._parents)}function qM(e,t,n){var s=this.enter(),a=this,l=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?l.remove():n(l),s&&a?s.merge(a).order():a}function FM(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,a=n.length,l=s.length,c=Math.min(a,l),d=new Array(a),h=0;h<c;++h)for(var p=n[h],f=s[h],m=p.length,y=d[h]=new Array(m),v,j=0;j<m;++j)(v=p[j]||f[j])&&(y[j]=v);for(;h<a;++h)d[h]=n[h];return new Cn(d,this._parents)}function BM(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],a=s.length-1,l=s[a],c;--a>=0;)(c=s[a])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function zM(e){e||(e=UM);function t(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var n=this._groups,s=n.length,a=new Array(s),l=0;l<s;++l){for(var c=n[l],d=c.length,h=a[l]=new Array(d),p,f=0;f<d;++f)(p=c[f])&&(h[f]=p);h.sort(t)}return new Cn(a,this._parents).order()}function UM(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function WM(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function HM(){return Array.from(this)}function GM(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,l=s.length;a<l;++a){var c=s[a];if(c)return c}return null}function VM(){let e=0;for(const t of this)++e;return e}function YM(){return!this.node()}function KM(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],l=0,c=a.length,d;l<c;++l)(d=a[l])&&e.call(d,d.__data__,l,a);return this}function XM(e){return function(){this.removeAttribute(e)}}function QM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ZM(e,t){return function(){this.setAttribute(e,t)}}function JM(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eI(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tI(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 nI(e,t){var n=md(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?QM:XM:typeof t=="function"?n.local?tI:eI:n.local?JM:ZM)(n,t))}function MC(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rI(e){return function(){this.style.removeProperty(e)}}function sI(e,t,n){return function(){this.style.setProperty(e,t,n)}}function aI(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function oI(e,t,n){return arguments.length>1?this.each((t==null?rI:typeof t=="function"?aI:sI)(e,t,n??"")):ni(this.node(),e)}function ni(e,t){return e.style.getPropertyValue(t)||MC(e).getComputedStyle(e,null).getPropertyValue(t)}function iI(e){return function(){delete this[e]}}function lI(e,t){return function(){this[e]=t}}function cI(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uI(e,t){return arguments.length>1?this.each((t==null?iI:typeof t=="function"?cI:lI)(e,t)):this.node()[e]}function IC(e){return e.trim().split(/^|\s+/)}function Uv(e){return e.classList||new $C(e)}function $C(e){this._node=e,this._names=IC(e.getAttribute("class")||"")}$C.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 OC(e,t){for(var n=Uv(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function PC(e,t){for(var n=Uv(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function dI(e){return function(){OC(this,e)}}function hI(e){return function(){PC(this,e)}}function fI(e,t){return function(){(t.apply(this,arguments)?OC:PC)(this,e)}}function pI(e,t){var n=IC(e+"");if(arguments.length<2){for(var s=Uv(this.node()),a=-1,l=n.length;++a<l;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?fI:t?dI:hI)(n,t))}function mI(){this.textContent=""}function gI(e){return function(){this.textContent=e}}function yI(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function wI(e){return arguments.length?this.each(e==null?mI:(typeof e=="function"?yI:gI)(e)):this.node().textContent}function vI(){this.innerHTML=""}function xI(e){return function(){this.innerHTML=e}}function bI(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function kI(e){return arguments.length?this.each(e==null?vI:(typeof e=="function"?bI:xI)(e)):this.node().innerHTML}function _I(){this.nextSibling&&this.parentNode.appendChild(this)}function NI(){return this.each(_I)}function SI(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jI(){return this.each(SI)}function EI(e){var t=typeof e=="function"?e:EC(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function CI(){return null}function TI(e,t){var n=typeof e=="function"?e:EC(e),s=t==null?CI:typeof t=="function"?t:zv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function AI(){var e=this.parentNode;e&&e.removeChild(this)}function RI(){return this.each(AI)}function MI(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function II(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $I(e){return this.select(e?II:MI)}function OI(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PI(e){return function(t){e.call(this,t,this.__data__)}}function LI(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 DI(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,a=t.length,l;n<a;++n)l=t[n],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++s]=l;++s?t.length=s:delete this.__on}}}function qI(e,t,n){return function(){var s=this.__on,a,l=PI(t);if(s){for(var c=0,d=s.length;c<d;++c)if((a=s[c]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=n),a.value=t;return}}this.addEventListener(e.type,l,n),a={type:e.type,name:e.name,value:t,listener:l,options:n},s?s.push(a):this.__on=[a]}}function FI(e,t,n){var s=LI(e+""),a,l=s.length,c;if(arguments.length<2){var d=this.node().__on;if(d){for(var h=0,p=d.length,f;h<p;++h)for(a=0,f=d[h];a<l;++a)if((c=s[a]).type===f.type&&c.name===f.name)return f.value}return}for(d=t?qI:DI,a=0;a<l;++a)this.each(d(s[a],t,n));return this}function LC(e,t,n){var s=MC(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 BI(e,t){return function(){return LC(this,e,t)}}function zI(e,t){return function(){return LC(this,e,t.apply(this,arguments))}}function UI(e,t){return this.each((typeof t=="function"?zI:BI)(e,t))}function*WI(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,l=s.length,c;a<l;++a)(c=s[a])&&(yield c)}var DC=[null];function Cn(e,t){this._groups=e,this._parents=t}function Wl(){return new Cn([[document.documentElement]],DC)}function HI(){return this}Cn.prototype=Wl.prototype={constructor:Cn,select:yM,selectAll:bM,selectChild:SM,selectChildren:TM,filter:AM,data:PM,enter:RM,exit:DM,join:qM,merge:FM,selection:HI,order:BM,sort:zM,call:WM,nodes:HM,node:GM,size:VM,empty:YM,each:KM,attr:nI,style:oI,property:uI,classed:pI,text:wI,html:kI,raise:NI,lower:jI,append:EI,insert:TI,remove:RI,clone:$I,datum:OI,on:FI,dispatch:UI,[Symbol.iterator]:WI};function Wn(e){return typeof e=="string"?new Cn([[document.querySelector(e)]],[document.documentElement]):new Cn([[e]],DC)}function GI(e){let t;for(;t=e.sourceEvent;)e=t;return e}function lr(e,t){if(e=GI(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 VI={passive:!1},Al={capture:!0,passive:!1};function kf(e){e.stopImmediatePropagation()}function Qo(e){e.preventDefault(),e.stopImmediatePropagation()}function qC(e){var t=e.document.documentElement,n=Wn(e).on("dragstart.drag",Qo,Al);"onselectstart"in t?n.on("selectstart.drag",Qo,Al):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function FC(e,t){var n=e.document.documentElement,s=Wn(e).on("dragstart.drag",null);t&&(s.on("click.drag",Qo,Al),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 wu=e=>()=>e;function iv(e,{sourceEvent:t,subject:n,target:s,identifier:a,active:l,x:c,y:d,dx:h,dy:p,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:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:f}})}iv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function YI(e){return!e.ctrlKey&&!e.button}function KI(){return this.parentNode}function XI(e,t){return t??{x:e.x,y:e.y}}function QI(){return navigator.maxTouchPoints||"ontouchstart"in this}function ZI(){var e=YI,t=KI,n=XI,s=QI,a={},l=pd("start","drag","end"),c=0,d,h,p,f,m=0;function y(C){C.on("mousedown.drag",v).filter(s).on("touchstart.drag",S).on("touchmove.drag",x,VI).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(C,R){if(!(f||!e.call(this,C,R))){var I=E(this,t.call(this,C,R),C,R,"mouse");I&&(Wn(C.view).on("mousemove.drag",j,Al).on("mouseup.drag",_,Al),qC(C.view),kf(C),p=!1,d=C.clientX,h=C.clientY,I("start",C))}}function j(C){if(Qo(C),!p){var R=C.clientX-d,I=C.clientY-h;p=R*R+I*I>m}a.mouse("drag",C)}function _(C){Wn(C.view).on("mousemove.drag mouseup.drag",null),FC(C.view,p),Qo(C),a.mouse("end",C)}function S(C,R){if(e.call(this,C,R)){var I=C.changedTouches,$=t.call(this,C,R),F=I.length,O,M;for(O=0;O<F;++O)(M=E(this,$,C,R,I[O].identifier,I[O]))&&(kf(C),M("start",C,I[O]))}}function x(C){var R=C.changedTouches,I=R.length,$,F;for($=0;$<I;++$)(F=a[R[$].identifier])&&(Qo(C),F("drag",C,R[$]))}function N(C){var R=C.changedTouches,I=R.length,$,F;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),$=0;$<I;++$)(F=a[R[$].identifier])&&(kf(C),F("end",C,R[$]))}function E(C,R,I,$,F,O){var M=l.copy(),L=lr(O||I,R),H,B,A;if((A=n.call(C,new iv("beforestart",{sourceEvent:I,target:y,identifier:F,active:c,x:L[0],y:L[1],dx:0,dy:0,dispatch:M}),$))!=null)return H=A.x-L[0]||0,B=A.y-L[1]||0,function Q(K,ee,Z){var D=L,Y;switch(K){case"start":a[F]=Q,Y=c++;break;case"end":delete a[F],--c;case"drag":L=lr(Z||ee,R),Y=c;break}M.call(K,C,new iv(K,{sourceEvent:ee,subject:A,target:y,identifier:F,active:Y,x:L[0]+H,y:L[1]+B,dx:L[0]-D[0],dy:L[1]-D[1],dispatch:M}),$)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:wu(!!C),y):e},y.container=function(C){return arguments.length?(t=typeof C=="function"?C:wu(C),y):t},y.subject=function(C){return arguments.length?(n=typeof C=="function"?C:wu(C),y):n},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:wu(!!C),y):s},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Wv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function BC(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function Hl(){}var Rl=.7,Ku=1/Rl,Zo="\\s*([+-]?\\d+)\\s*",Ml="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",JI=/^#([0-9a-f]{3,8})$/,e$=new RegExp(`^rgb\\(${Zo},${Zo},${Zo}\\)$`),t$=new RegExp(`^rgb\\(${Mr},${Mr},${Mr}\\)$`),n$=new RegExp(`^rgba\\(${Zo},${Zo},${Zo},${Ml}\\)$`),r$=new RegExp(`^rgba\\(${Mr},${Mr},${Mr},${Ml}\\)$`),s$=new RegExp(`^hsl\\(${Ml},${Mr},${Mr}\\)$`),a$=new RegExp(`^hsla\\(${Ml},${Mr},${Mr},${Ml}\\)$`),zb={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};Wv(Hl,Il,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ub,formatHex:Ub,formatHex8:o$,formatHsl:i$,formatRgb:Wb,toString:Wb});function Ub(){return this.rgb().formatHex()}function o$(){return this.rgb().formatHex8()}function i$(){return zC(this).formatHsl()}function Wb(){return this.rgb().formatRgb()}function Il(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=JI.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hb(t):n===3?new wn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?vu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?vu(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=e$.exec(e))?new wn(t[1],t[2],t[3],1):(t=t$.exec(e))?new wn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=n$.exec(e))?vu(t[1],t[2],t[3],t[4]):(t=r$.exec(e))?vu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=s$.exec(e))?Yb(t[1],t[2]/100,t[3]/100,1):(t=a$.exec(e))?Yb(t[1],t[2]/100,t[3]/100,t[4]):zb.hasOwnProperty(e)?Hb(zb[e]):e==="transparent"?new wn(NaN,NaN,NaN,0):null}function Hb(e){return new wn(e>>16&255,e>>8&255,e&255,1)}function vu(e,t,n,s){return s<=0&&(e=t=n=NaN),new wn(e,t,n,s)}function l$(e){return e instanceof Hl||(e=Il(e)),e?(e=e.rgb(),new wn(e.r,e.g,e.b,e.opacity)):new wn}function lv(e,t,n,s){return arguments.length===1?l$(e):new wn(e,t,n,s??1)}function wn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Wv(wn,lv,BC(Hl,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new wn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Rl:Math.pow(Rl,e),new wn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new wn(Ga(this.r),Ga(this.g),Ga(this.b),Xu(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:Gb,formatHex:Gb,formatHex8:c$,formatRgb:Vb,toString:Vb}));function Gb(){return`#${Wa(this.r)}${Wa(this.g)}${Wa(this.b)}`}function c$(){return`#${Wa(this.r)}${Wa(this.g)}${Wa(this.b)}${Wa((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vb(){const e=Xu(this.opacity);return`${e===1?"rgb(":"rgba("}${Ga(this.r)}, ${Ga(this.g)}, ${Ga(this.b)}${e===1?")":`, ${e})`}`}function Xu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ga(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wa(e){return e=Ga(e),(e<16?"0":"")+e.toString(16)}function Yb(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new cr(e,t,n,s)}function zC(e){if(e instanceof cr)return new cr(e.h,e.s,e.l,e.opacity);if(e instanceof Hl||(e=Il(e)),!e)return new cr;if(e instanceof cr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,a=Math.min(t,n,s),l=Math.max(t,n,s),c=NaN,d=l-a,h=(l+a)/2;return d?(t===l?c=(n-s)/d+(n<s)*6:n===l?c=(s-t)/d+2:c=(t-n)/d+4,d/=h<.5?l+a:2-l-a,c*=60):d=h>0&&h<1?0:c,new cr(c,d,h,e.opacity)}function u$(e,t,n,s){return arguments.length===1?zC(e):new cr(e,t,n,s??1)}function cr(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Wv(cr,u$,BC(Hl,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new cr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Rl:Math.pow(Rl,e),new cr(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 wn(_f(e>=240?e-240:e+120,a,s),_f(e,a,s),_f(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new cr(Kb(this.h),xu(this.s),xu(this.l),Xu(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=Xu(this.opacity);return`${e===1?"hsl(":"hsla("}${Kb(this.h)}, ${xu(this.s)*100}%, ${xu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Kb(e){return e=(e||0)%360,e<0?e+360:e}function xu(e){return Math.max(0,Math.min(1,e||0))}function _f(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const UC=e=>()=>e;function d$(e,t){return function(n){return e+n*t}}function h$(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 f$(e){return(e=+e)==1?WC:function(t,n){return n-t?h$(t,n,e):UC(isNaN(t)?n:t)}}function WC(e,t){var n=t-e;return n?d$(e,n):UC(isNaN(e)?t:e)}const Xb=(function e(t){var n=f$(t);function s(a,l){var c=n((a=lv(a)).r,(l=lv(l)).r),d=n(a.g,l.g),h=n(a.b,l.b),p=WC(a.opacity,l.opacity);return function(f){return a.r=c(f),a.g=d(f),a.b=h(f),a.opacity=p(f),a+""}}return s.gamma=e,s})(1);function Us(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var cv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Nf=new RegExp(cv.source,"g");function p$(e){return function(){return e}}function m$(e){return function(t){return e(t)+""}}function g$(e,t){var n=cv.lastIndex=Nf.lastIndex=0,s,a,l,c=-1,d=[],h=[];for(e=e+"",t=t+"";(s=cv.exec(e))&&(a=Nf.exec(t));)(l=a.index)>n&&(l=t.slice(n,l),d[c]?d[c]+=l:d[++c]=l),(s=s[0])===(a=a[0])?d[c]?d[c]+=a:d[++c]=a:(d[++c]=null,h.push({i:c,x:Us(s,a)})),n=Nf.lastIndex;return n<t.length&&(l=t.slice(n),d[c]?d[c]+=l:d[++c]=l),d.length<2?h[0]?m$(h[0].x):p$(t):(t=h.length,function(p){for(var f=0,m;f<t;++f)d[(m=h[f]).i]=m.x(p);return d.join("")})}var Qb=180/Math.PI,uv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function HC(e,t,n,s,a,l){var c,d,h;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(h=e*n+t*s)&&(n-=e*h,s-=t*h),(d=Math.sqrt(n*n+s*s))&&(n/=d,s/=d,h/=d),e*s<t*n&&(e=-e,t=-t,h=-h,c=-c),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*Qb,skewX:Math.atan(h)*Qb,scaleX:c,scaleY:d}}var bu;function y$(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?uv:HC(t.a,t.b,t.c,t.d,t.e,t.f)}function w$(e){return e==null||(bu||(bu=document.createElementNS("http://www.w3.org/2000/svg","g")),bu.setAttribute("transform",e),!(e=bu.transform.baseVal.consolidate()))?uv:(e=e.matrix,HC(e.a,e.b,e.c,e.d,e.e,e.f))}function GC(e,t,n,s){function a(p){return p.length?p.pop()+" ":""}function l(p,f,m,y,v,j){if(p!==m||f!==y){var _=v.push("translate(",null,t,null,n);j.push({i:_-4,x:Us(p,m)},{i:_-2,x:Us(f,y)})}else(m||y)&&v.push("translate("+m+t+y+n)}function c(p,f,m,y){p!==f?(p-f>180?f+=360:f-p>180&&(p+=360),y.push({i:m.push(a(m)+"rotate(",null,s)-2,x:Us(p,f)})):f&&m.push(a(m)+"rotate("+f+s)}function d(p,f,m,y){p!==f?y.push({i:m.push(a(m)+"skewX(",null,s)-2,x:Us(p,f)}):f&&m.push(a(m)+"skewX("+f+s)}function h(p,f,m,y,v,j){if(p!==m||f!==y){var _=v.push(a(v)+"scale(",null,",",null,")");j.push({i:_-4,x:Us(p,m)},{i:_-2,x:Us(f,y)})}else(m!==1||y!==1)&&v.push(a(v)+"scale("+m+","+y+")")}return function(p,f){var m=[],y=[];return p=e(p),f=e(f),l(p.translateX,p.translateY,f.translateX,f.translateY,m,y),c(p.rotate,f.rotate,m,y),d(p.skewX,f.skewX,m,y),h(p.scaleX,p.scaleY,f.scaleX,f.scaleY,m,y),p=f=null,function(v){for(var j=-1,_=y.length,S;++j<_;)m[(S=y[j]).i]=S.x(v);return m.join("")}}}var v$=GC(y$,"px, ","px)","deg)"),x$=GC(w$,", ",")",")"),b$=1e-12;function Zb(e){return((e=Math.exp(e))+1/e)/2}function k$(e){return((e=Math.exp(e))-1/e)/2}function _$(e){return((e=Math.exp(2*e))-1)/(e+1)}const N$=(function e(t,n,s){function a(l,c){var d=l[0],h=l[1],p=l[2],f=c[0],m=c[1],y=c[2],v=f-d,j=m-h,_=v*v+j*j,S,x;if(_<b$)x=Math.log(y/p)/t,S=function($){return[d+$*v,h+$*j,p*Math.exp(t*$*x)]};else{var N=Math.sqrt(_),E=(y*y-p*p+s*_)/(2*p*n*N),C=(y*y-p*p-s*_)/(2*y*n*N),R=Math.log(Math.sqrt(E*E+1)-E),I=Math.log(Math.sqrt(C*C+1)-C);x=(I-R)/t,S=function($){var F=$*x,O=Zb(R),M=p/(n*N)*(O*_$(t*F+R)-k$(R));return[d+M*v,h+M*j,p*O/Zb(t*F+R)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return a.rho=function(l){var c=Math.max(.001,+l),d=c*c,h=d*d;return e(c,d,h)},a})(Math.SQRT2,2,4);var ri=0,_l=0,pl=0,VC=1e3,Qu,Nl,Zu=0,Ya=0,gd=0,$l=typeof performance=="object"&&performance.now?performance:Date,YC=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Hv(){return Ya||(YC(S$),Ya=$l.now()+gd)}function S$(){Ya=0}function Ju(){this._call=this._time=this._next=null}Ju.prototype=KC.prototype={constructor:Ju,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Hv():+n)+(t==null?0:+t),!this._next&&Nl!==this&&(Nl?Nl._next=this:Qu=this,Nl=this),this._call=e,this._time=n,dv()},stop:function(){this._call&&(this._call=null,this._time=1/0,dv())}};function KC(e,t,n){var s=new Ju;return s.restart(e,t,n),s}function j$(){Hv(),++ri;for(var e=Qu,t;e;)(t=Ya-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ri}function Jb(){Ya=(Zu=$l.now())+gd,ri=_l=0;try{j$()}finally{ri=0,C$(),Ya=0}}function E$(){var e=$l.now(),t=e-Zu;t>VC&&(gd-=t,Zu=e)}function C$(){for(var e,t=Qu,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:Qu=n);Nl=e,dv(s)}function dv(e){if(!ri){_l&&(_l=clearTimeout(_l));var t=e-Ya;t>24?(e<1/0&&(_l=setTimeout(Jb,e-$l.now()-gd)),pl&&(pl=clearInterval(pl))):(pl||(Zu=$l.now(),pl=setInterval(E$,VC)),ri=1,YC(Jb))}}function ek(e,t,n){var s=new Ju;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var T$=pd("start","end","cancel","interrupt"),A$=[],XC=0,tk=1,hv=2,Bu=3,nk=4,fv=5,zu=6;function yd(e,t,n,s,a,l){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;R$(e,n,{name:t,index:s,group:a,on:T$,tween:A$,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:XC})}function Gv(e,t){var n=gr(e,t);if(n.state>XC)throw new Error("too late; already scheduled");return n}function Ir(e,t){var n=gr(e,t);if(n.state>Bu)throw new Error("too late; already running");return n}function gr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function R$(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=KC(l,0,n.time);function l(p){n.state=tk,n.timer.restart(c,n.delay,n.time),n.delay<=p&&c(p-n.delay)}function c(p){var f,m,y,v;if(n.state!==tk)return h();for(f in s)if(v=s[f],v.name===n.name){if(v.state===Bu)return ek(c);v.state===nk?(v.state=zu,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete s[f]):+f<t&&(v.state=zu,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete s[f])}if(ek(function(){n.state===Bu&&(n.state=nk,n.timer.restart(d,n.delay,n.time),d(p))}),n.state=hv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===hv){for(n.state=Bu,a=new Array(y=n.tween.length),f=0,m=-1;f<y;++f)(v=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(a[++m]=v);a.length=m+1}}function d(p){for(var f=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(h),n.state=fv,1),m=-1,y=a.length;++m<y;)a[m].call(e,f);n.state===fv&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=zu,n.timer.stop(),delete s[t];for(var p in s)return;delete e.__transition}}function Uu(e,t){var n=e.__transition,s,a,l=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((s=n[c]).name!==t){l=!1;continue}a=s.state>hv&&s.state<fv,s.state=zu,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[c]}l&&delete e.__transition}}function M$(e){return this.each(function(){Uu(this,e)})}function I$(e,t){var n,s;return function(){var a=Ir(this,e),l=a.tween;if(l!==n){s=n=l;for(var c=0,d=s.length;c<d;++c)if(s[c].name===t){s=s.slice(),s.splice(c,1);break}}a.tween=s}}function $$(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var l=Ir(this,e),c=l.tween;if(c!==s){a=(s=c).slice();for(var d={name:t,value:n},h=0,p=a.length;h<p;++h)if(a[h].name===t){a[h]=d;break}h===p&&a.push(d)}l.tween=a}}function O$(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=gr(this.node(),n).tween,a=0,l=s.length,c;a<l;++a)if((c=s[a]).name===e)return c.value;return null}return this.each((t==null?I$:$$)(n,e,t))}function Vv(e,t,n){var s=e._id;return e.each(function(){var a=Ir(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return gr(a,s).value[t]}}function QC(e,t){var n;return(typeof t=="number"?Us:t instanceof Il?Xb:(n=Il(t))?(t=n,Xb):g$)(e,t)}function P$(e){return function(){this.removeAttribute(e)}}function L$(e){return function(){this.removeAttributeNS(e.space,e.local)}}function D$(e,t,n){var s,a=n+"",l;return function(){var c=this.getAttribute(e);return c===a?null:c===s?l:l=t(s=c,n)}}function q$(e,t,n){var s,a=n+"",l;return function(){var c=this.getAttributeNS(e.space,e.local);return c===a?null:c===s?l:l=t(s=c,n)}}function F$(e,t,n){var s,a,l;return function(){var c,d=n(this),h;return d==null?void this.removeAttribute(e):(c=this.getAttribute(e),h=d+"",c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d)))}}function B$(e,t,n){var s,a,l;return function(){var c,d=n(this),h;return d==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),h=d+"",c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d)))}}function z$(e,t){var n=md(e),s=n==="transform"?x$:QC;return this.attrTween(e,typeof t=="function"?(n.local?B$:F$)(n,s,Vv(this,"attr."+e,t)):t==null?(n.local?L$:P$)(n):(n.local?q$:D$)(n,s,t))}function U$(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function W$(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function H$(e,t){var n,s;function a(){var l=t.apply(this,arguments);return l!==s&&(n=(s=l)&&W$(e,l)),n}return a._value=t,a}function G$(e,t){var n,s;function a(){var l=t.apply(this,arguments);return l!==s&&(n=(s=l)&&U$(e,l)),n}return a._value=t,a}function V$(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=md(e);return this.tween(n,(s.local?H$:G$)(s,t))}function Y$(e,t){return function(){Gv(this,e).delay=+t.apply(this,arguments)}}function K$(e,t){return t=+t,function(){Gv(this,e).delay=t}}function X$(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Y$:K$)(t,e)):gr(this.node(),t).delay}function Q$(e,t){return function(){Ir(this,e).duration=+t.apply(this,arguments)}}function Z$(e,t){return t=+t,function(){Ir(this,e).duration=t}}function J$(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Q$:Z$)(t,e)):gr(this.node(),t).duration}function eO(e,t){if(typeof t!="function")throw new Error;return function(){Ir(this,e).ease=t}}function tO(e){var t=this._id;return arguments.length?this.each(eO(t,e)):gr(this.node(),t).ease}function nO(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ir(this,e).ease=n}}function rO(e){if(typeof e!="function")throw new Error;return this.each(nO(this._id,e))}function sO(e){typeof e!="function"&&(e=TC(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=[],h,p=0;p<c;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&d.push(h);return new os(s,this._parents,this._name,this._id)}function aO(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,a=n.length,l=Math.min(s,a),c=new Array(s),d=0;d<l;++d)for(var h=t[d],p=n[d],f=h.length,m=c[d]=new Array(f),y,v=0;v<f;++v)(y=h[v]||p[v])&&(m[v]=y);for(;d<s;++d)c[d]=t[d];return new os(c,this._parents,this._name,this._id)}function oO(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 iO(e,t,n){var s,a,l=oO(t)?Gv:Ir;return function(){var c=l(this,e),d=c.on;d!==s&&(a=(s=d).copy()).on(t,n),c.on=a}}function lO(e,t){var n=this._id;return arguments.length<2?gr(this.node(),n).on.on(e):this.each(iO(n,e,t))}function cO(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function uO(){return this.on("end.remove",cO(this._id))}function dO(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zv(e));for(var s=this._groups,a=s.length,l=new Array(a),c=0;c<a;++c)for(var d=s[c],h=d.length,p=l[c]=new Array(h),f,m,y=0;y<h;++y)(f=d[y])&&(m=e.call(f,f.__data__,y,d))&&("__data__"in f&&(m.__data__=f.__data__),p[y]=m,yd(p[y],t,n,y,p,gr(f,n)));return new os(l,this._parents,t,n)}function hO(e){var t=this._name,n=this._id;typeof e!="function"&&(e=CC(e));for(var s=this._groups,a=s.length,l=[],c=[],d=0;d<a;++d)for(var h=s[d],p=h.length,f,m=0;m<p;++m)if(f=h[m]){for(var y=e.call(f,f.__data__,m,h),v,j=gr(f,n),_=0,S=y.length;_<S;++_)(v=y[_])&&yd(v,t,n,_,y,j);l.push(y),c.push(f)}return new os(l,c,t,n)}var fO=Wl.prototype.constructor;function pO(){return new fO(this._groups,this._parents)}function mO(e,t){var n,s,a;return function(){var l=ni(this,e),c=(this.style.removeProperty(e),ni(this,e));return l===c?null:l===n&&c===s?a:a=t(n=l,s=c)}}function ZC(e){return function(){this.style.removeProperty(e)}}function gO(e,t,n){var s,a=n+"",l;return function(){var c=ni(this,e);return c===a?null:c===s?l:l=t(s=c,n)}}function yO(e,t,n){var s,a,l;return function(){var c=ni(this,e),d=n(this),h=d+"";return d==null&&(h=d=(this.style.removeProperty(e),ni(this,e))),c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d))}}function wO(e,t){var n,s,a,l="style."+t,c="end."+l,d;return function(){var h=Ir(this,e),p=h.on,f=h.value[l]==null?d||(d=ZC(t)):void 0;(p!==n||a!==f)&&(s=(n=p).copy()).on(c,a=f),h.on=s}}function vO(e,t,n){var s=(e+="")=="transform"?v$:QC;return t==null?this.styleTween(e,mO(e,s)).on("end.style."+e,ZC(e)):typeof t=="function"?this.styleTween(e,yO(e,s,Vv(this,"style."+e,t))).each(wO(this._id,e)):this.styleTween(e,gO(e,s,t),n).on("end.style."+e,null)}function xO(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function bO(e,t,n){var s,a;function l(){var c=t.apply(this,arguments);return c!==a&&(s=(a=c)&&xO(e,c,n)),s}return l._value=t,l}function kO(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,bO(e,t,n??""))}function _O(e){return function(){this.textContent=e}}function NO(e){return function(){var t=e(this);this.textContent=t??""}}function SO(e){return this.tween("text",typeof e=="function"?NO(Vv(this,"text",e)):_O(e==null?"":e+""))}function jO(e){return function(t){this.textContent=e.call(this,t)}}function EO(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&jO(a)),t}return s._value=e,s}function CO(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,EO(e))}function TO(){for(var e=this._name,t=this._id,n=JC(),s=this._groups,a=s.length,l=0;l<a;++l)for(var c=s[l],d=c.length,h,p=0;p<d;++p)if(h=c[p]){var f=gr(h,t);yd(h,e,n,p,c,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new os(s,this._parents,e,n)}function AO(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(l,c){var d={value:c},h={value:function(){--a===0&&l()}};n.each(function(){var p=Ir(this,s),f=p.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(d),t._.interrupt.push(d),t._.end.push(h)),p.on=t}),a===0&&l()})}var RO=0;function os(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function JC(){return++RO}var ns=Wl.prototype;os.prototype={constructor:os,select:dO,selectAll:hO,selectChild:ns.selectChild,selectChildren:ns.selectChildren,filter:sO,merge:aO,selection:pO,transition:TO,call:ns.call,nodes:ns.nodes,node:ns.node,size:ns.size,empty:ns.empty,each:ns.each,on:lO,attr:z$,attrTween:V$,style:vO,styleTween:kO,text:SO,textTween:CO,remove:uO,tween:O$,delay:X$,duration:J$,ease:tO,easeVarying:rO,end:AO,[Symbol.iterator]:ns[Symbol.iterator]};function MO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var IO={time:null,delay:0,duration:250,ease:MO};function $O(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 OO(e){var t,n;e instanceof os?(t=e._id,e=e._name):(t=JC(),(n=IO).time=Hv(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,l=0;l<a;++l)for(var c=s[l],d=c.length,h,p=0;p<d;++p)(h=c[p])&&yd(h,e,t,p,c,n||$O(h,t));return new os(s,this._parents,e,t)}Wl.prototype.interrupt=M$;Wl.prototype.transition=OO;const ku=e=>()=>e;function PO(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 rs(e,t,n){this.k=e,this.x=t,this.y=n}rs.prototype={constructor:rs,scale:function(e){return e===1?this:new rs(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new rs(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 ss=new rs(1,0,0);rs.prototype;function Sf(e){e.stopImmediatePropagation()}function ml(e){e.preventDefault(),e.stopImmediatePropagation()}function LO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DO(){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 rk(){return this.__zoom||ss}function qO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FO(){return navigator.maxTouchPoints||"ontouchstart"in this}function BO(e,t,n){var s=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],l=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function eT(){var e=LO,t=DO,n=BO,s=qO,a=FO,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,h=N$,p=pd("start","zoom","end"),f,m,y,v=500,j=150,_=0,S=10;function x(A){A.property("__zoom",rk).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",M).filter(a).on("touchstart.zoom",L).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(A,Q,K,ee){var Z=A.selection?A.selection():A;Z.property("__zoom",rk),A!==Z?R(A,Q,K,ee):Z.interrupt().each(function(){I(this,arguments).event(ee).start().zoom(null,typeof Q=="function"?Q.apply(this,arguments):Q).end()})},x.scaleBy=function(A,Q,K,ee){x.scaleTo(A,function(){var Z=this.__zoom.k,D=typeof Q=="function"?Q.apply(this,arguments):Q;return Z*D},K,ee)},x.scaleTo=function(A,Q,K,ee){x.transform(A,function(){var Z=t.apply(this,arguments),D=this.__zoom,Y=K==null?C(Z):typeof K=="function"?K.apply(this,arguments):K,P=D.invert(Y),G=typeof Q=="function"?Q.apply(this,arguments):Q;return n(E(N(D,G),Y,P),Z,c)},K,ee)},x.translateBy=function(A,Q,K,ee){x.transform(A,function(){return n(this.__zoom.translate(typeof Q=="function"?Q.apply(this,arguments):Q,typeof K=="function"?K.apply(this,arguments):K),t.apply(this,arguments),c)},null,ee)},x.translateTo=function(A,Q,K,ee,Z){x.transform(A,function(){var D=t.apply(this,arguments),Y=this.__zoom,P=ee==null?C(D):typeof ee=="function"?ee.apply(this,arguments):ee;return n(ss.translate(P[0],P[1]).scale(Y.k).translate(typeof Q=="function"?-Q.apply(this,arguments):-Q,typeof K=="function"?-K.apply(this,arguments):-K),D,c)},ee,Z)};function N(A,Q){return Q=Math.max(l[0],Math.min(l[1],Q)),Q===A.k?A:new rs(Q,A.x,A.y)}function E(A,Q,K){var ee=Q[0]-K[0]*A.k,Z=Q[1]-K[1]*A.k;return ee===A.x&&Z===A.y?A:new rs(A.k,ee,Z)}function C(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function R(A,Q,K,ee){A.on("start.zoom",function(){I(this,arguments).event(ee).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(ee).end()}).tween("zoom",function(){var Z=this,D=arguments,Y=I(Z,D).event(ee),P=t.apply(Z,D),G=K==null?C(P):typeof K=="function"?K.apply(Z,D):K,de=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),W=Z.__zoom,U=typeof Q=="function"?Q.apply(Z,D):Q,J=h(W.invert(G).concat(de/W.k),U.invert(G).concat(de/U.k));return function(V){if(V===1)V=U;else{var ie=J(V),pe=de/ie[2];V=new rs(pe,G[0]-ie[0]*pe,G[1]-ie[1]*pe)}Y.zoom(null,V)}})}function I(A,Q,K){return!K&&A.__zooming||new $(A,Q)}function $(A,Q){this.that=A,this.args=Q,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,Q),this.taps=0}$.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,Q){return this.mouse&&A!=="mouse"&&(this.mouse[1]=Q.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=Q.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=Q.invert(this.touch1[0])),this.that.__zoom=Q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var Q=Wn(this.that).datum();p.call(A,this.that,new PO(A,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:p}),Q)}};function F(A,...Q){if(!e.apply(this,arguments))return;var K=I(this,Q).event(A),ee=this.__zoom,Z=Math.max(l[0],Math.min(l[1],ee.k*Math.pow(2,s.apply(this,arguments)))),D=lr(A);if(K.wheel)(K.mouse[0][0]!==D[0]||K.mouse[0][1]!==D[1])&&(K.mouse[1]=ee.invert(K.mouse[0]=D)),clearTimeout(K.wheel);else{if(ee.k===Z)return;K.mouse=[D,ee.invert(D)],Uu(this),K.start()}ml(A),K.wheel=setTimeout(Y,j),K.zoom("mouse",n(E(N(ee,Z),K.mouse[0],K.mouse[1]),K.extent,c));function Y(){K.wheel=null,K.end()}}function O(A,...Q){if(y||!e.apply(this,arguments))return;var K=A.currentTarget,ee=I(this,Q,!0).event(A),Z=Wn(A.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",de,!0),D=lr(A,K),Y=A.clientX,P=A.clientY;qC(A.view),Sf(A),ee.mouse=[D,this.__zoom.invert(D)],Uu(this),ee.start();function G(W){if(ml(W),!ee.moved){var U=W.clientX-Y,J=W.clientY-P;ee.moved=U*U+J*J>_}ee.event(W).zoom("mouse",n(E(ee.that.__zoom,ee.mouse[0]=lr(W,K),ee.mouse[1]),ee.extent,c))}function de(W){Z.on("mousemove.zoom mouseup.zoom",null),FC(W.view,ee.moved),ml(W),ee.event(W).end()}}function M(A,...Q){if(e.apply(this,arguments)){var K=this.__zoom,ee=lr(A.changedTouches?A.changedTouches[0]:A,this),Z=K.invert(ee),D=K.k*(A.shiftKey?.5:2),Y=n(E(N(K,D),ee,Z),t.apply(this,Q),c);ml(A),d>0?Wn(this).transition().duration(d).call(R,Y,ee,A):Wn(this).call(x.transform,Y,ee,A)}}function L(A,...Q){if(e.apply(this,arguments)){var K=A.touches,ee=K.length,Z=I(this,Q,A.changedTouches.length===ee).event(A),D,Y,P,G;for(Sf(A),Y=0;Y<ee;++Y)P=K[Y],G=lr(P,this),G=[G,this.__zoom.invert(G),P.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==G[2]&&(Z.touch1=G,Z.taps=0):(Z.touch0=G,D=!0,Z.taps=1+!!f);f&&(f=clearTimeout(f)),D&&(Z.taps<2&&(m=G[0],f=setTimeout(function(){f=null},v)),Uu(this),Z.start())}}function H(A,...Q){if(this.__zooming){var K=I(this,Q).event(A),ee=A.changedTouches,Z=ee.length,D,Y,P,G;for(ml(A),D=0;D<Z;++D)Y=ee[D],P=lr(Y,this),K.touch0&&K.touch0[2]===Y.identifier?K.touch0[0]=P:K.touch1&&K.touch1[2]===Y.identifier&&(K.touch1[0]=P);if(Y=K.that.__zoom,K.touch1){var de=K.touch0[0],W=K.touch0[1],U=K.touch1[0],J=K.touch1[1],V=(V=U[0]-de[0])*V+(V=U[1]-de[1])*V,ie=(ie=J[0]-W[0])*ie+(ie=J[1]-W[1])*ie;Y=N(Y,Math.sqrt(V/ie)),P=[(de[0]+U[0])/2,(de[1]+U[1])/2],G=[(W[0]+J[0])/2,(W[1]+J[1])/2]}else if(K.touch0)P=K.touch0[0],G=K.touch0[1];else return;K.zoom("touch",n(E(Y,P,G),K.extent,c))}}function B(A,...Q){if(this.__zooming){var K=I(this,Q).event(A),ee=A.changedTouches,Z=ee.length,D,Y;for(Sf(A),y&&clearTimeout(y),y=setTimeout(function(){y=null},v),D=0;D<Z;++D)Y=ee[D],K.touch0&&K.touch0[2]===Y.identifier?delete K.touch0:K.touch1&&K.touch1[2]===Y.identifier&&delete K.touch1;if(K.touch1&&!K.touch0&&(K.touch0=K.touch1,delete K.touch1),K.touch0)K.touch0[1]=this.__zoom.invert(K.touch0[0]);else if(K.end(),K.taps===2&&(Y=lr(Y,this),Math.hypot(m[0]-Y[0],m[1]-Y[1])<S)){var P=Wn(this).on("dblclick.zoom");P&&P.apply(this,arguments)}}}return x.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:ku(+A),x):s},x.filter=function(A){return arguments.length?(e=typeof A=="function"?A:ku(!!A),x):e},x.touchable=function(A){return arguments.length?(a=typeof A=="function"?A:ku(!!A),x):a},x.extent=function(A){return arguments.length?(t=typeof A=="function"?A:ku([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),x):t},x.scaleExtent=function(A){return arguments.length?(l[0]=+A[0],l[1]=+A[1],x):[l[0],l[1]]},x.translateExtent=function(A){return arguments.length?(c[0][0]=+A[0][0],c[1][0]=+A[1][0],c[0][1]=+A[0][1],c[1][1]=+A[1][1],x):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},x.constrain=function(A){return arguments.length?(n=A,x):n},x.duration=function(A){return arguments.length?(d=+A,x):d},x.interpolate=function(A){return arguments.length?(h=A,x):h},x.on=function(){var A=p.on.apply(p,arguments);return A===p?x:A},x.clickDistance=function(A){return arguments.length?(_=(A=+A)*A,x):Math.sqrt(_)},x.tapDistance=function(A){return arguments.length?(S=+A,x):S},x}var Yv=SC();const wd=b.createContext(null),zO=wd.Provider,is={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.`},tT=is.error001();function ct(e,t){const n=b.useContext(wd);if(n===null)throw new Error(tT);return jC(n,e,t)}const Rt=()=>{const e=b.useContext(wd);if(e===null)throw new Error(tT);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},UO=e=>e.userSelectionActive?"none":"all";function Kv({position:e,children:t,className:n,style:s,...a}){const l=ct(UO),c=`${e}`.split("-");return fe.createElement("div",{className:Kt(["react-flow__panel",n,...c]),style:{...s,pointerEvents:l},...a},t)}function WO({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:fe.createElement(Kv,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},fe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const HO=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:d=2,children:h,className:p,...f})=>{const m=b.useRef(null),[y,v]=b.useState({x:0,y:0,width:0,height:0}),j=Kt(["react-flow__edge-textwrapper",p]);return b.useEffect(()=>{if(m.current){const _=m.current.getBBox();v({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),typeof n>"u"||!n?null:fe.createElement("g",{transform:`translate(${e-y.width/2} ${t-y.height/2})`,className:j,visibility:y.width?"visible":"hidden",...f},a&&fe.createElement("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:d,ry:d}),fe.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},n),h)};var GO=b.memo(HO);const Xv=e=>({width:e.offsetWidth,height:e.offsetHeight}),si=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qv=(e={x:0,y:0},t)=>({x:si(e.x,t[0][0],t[1][0]),y:si(e.y,t[0][1],t[1][1])}),sk=(e,t,n)=>e<t?si(Math.abs(e-t),1,50)/50:e>n?-si(Math.abs(e-n),1,50)/50:0,nT=(e,t)=>{const n=sk(e.x,35,t.width-35)*20,s=sk(e.y,35,t.height-35)*20;return[n,s]},rT=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},sT=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ol=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),aT=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),ak=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),VO=(e,t)=>aT(sT(Ol(e),Ol(t))),pv=(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)},YO=e=>Hn(e.width)&&Hn(e.height)&&Hn(e.x)&&Hn(e.y),Hn=e=>!isNaN(e)&&isFinite(e),St=Symbol.for("internals"),oT=["Enter"," ","Escape"],KO=(e,t)=>{},XO=e=>"nativeEvent"in e;function mv(e){var a,l;const t=XO(e)?e.nativeEvent:e,n=((l=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:l[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 iT=e=>"clientX"in e,Gs=(e,t)=>{var l,c;const n=iT(e),s=n?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,a=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},ed=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Gl=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v=20})=>fe.createElement(fe.Fragment,null,fe.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),v&&fe.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),a&&Hn(n)&&Hn(s)?fe.createElement(GO,{x:n,y:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p}):null);Gl.displayName="BaseEdge";function gl(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(l=>l.id===e);a&&n(s,{...a})}}function lT({sourceX:e,sourceY:t,targetX:n,targetY:s}){const a=Math.abs(n-e)/2,l=n<e?n+a:n-a,c=Math.abs(s-t)/2,d=s<t?s+c:s-c;return[l,d,a,c]}function cT({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d}){const h=e*.125+a*.375+c*.375+n*.125,p=t*.125+l*.375+d*.375+s*.125,f=Math.abs(h-e),m=Math.abs(p-t);return[h,p,f,m]}var Ka;(function(e){e.Strict="strict",e.Loose="loose"})(Ka||(Ka={}));var Ha;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ha||(Ha={}));var Pl;(function(e){e.Partial="partial",e.Full="full"})(Pl||(Pl={}));var Hs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Hs||(Hs={}));var td;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(td||(td={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));function ok({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===Ue.Left||e===Ue.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function uT({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top}){const[c,d]=ok({pos:n,x1:e,y1:t,x2:s,y2:a}),[h,p]=ok({pos:l,x1:s,y1:a,x2:e,y2:t}),[f,m,y,v]=cT({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:p});return[`M${e},${t} C${c},${d} ${h},${p} ${s},${a}`,f,m,y,v]}const Zv=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:_})=>{const[S,x,N]=uT({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l});return fe.createElement(Gl,{path:S,labelX:x,labelY:N,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:_})});Zv.displayName="SimpleBezierEdge";const ik={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},QO=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.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},lk=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ZO({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:s=Ue.Top,center:a,offset:l}){const c=ik[t],d=ik[s],h={x:e.x+c.x*l,y:e.y+c.y*l},p={x:n.x+d.x*l,y:n.y+d.y*l},f=QO({source:h,sourcePosition:t,target:p}),m=f.x!==0?"x":"y",y=f[m];let v=[],j,_;const S={x:0,y:0},x={x:0,y:0},[N,E,C,R]=lT({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[m]*d[m]===-1){j=a.x??N,_=a.y??E;const $=[{x:j,y:h.y},{x:j,y:p.y}],F=[{x:h.x,y:_},{x:p.x,y:_}];c[m]===y?v=m==="x"?$:F:v=m==="x"?F:$}else{const $=[{x:h.x,y:p.y}],F=[{x:p.x,y:h.y}];if(m==="x"?v=c.x===y?F:$:v=c.y===y?$:F,t===s){const B=Math.abs(e[m]-n[m]);if(B<=l){const A=Math.min(l-1,l-B);c[m]===y?S[m]=(h[m]>e[m]?-1:1)*A:x[m]=(p[m]>n[m]?-1:1)*A}}if(t!==s){const B=m==="x"?"y":"x",A=c[m]===d[B],Q=h[B]>p[B],K=h[B]<p[B];(c[m]===1&&(!A&&Q||A&&K)||c[m]!==1&&(!A&&K||A&&Q))&&(v=m==="x"?$:F)}const O={x:h.x+S.x,y:h.y+S.y},M={x:p.x+x.x,y:p.y+x.y},L=Math.max(Math.abs(O.x-v[0].x),Math.abs(M.x-v[0].x)),H=Math.max(Math.abs(O.y-v[0].y),Math.abs(M.y-v[0].y));L>=H?(j=(O.x+M.x)/2,_=v[0].y):(j=v[0].x,_=(O.y+M.y)/2)}return[[e,{x:h.x+S.x,y:h.y+S.y},...v,{x:p.x+x.x,y:p.y+x.y},n],j,_,C,R]}function JO(e,t,n,s){const a=Math.min(lk(e,t)/2,lk(t,n)/2,s),{x:l,y:c}=t;if(e.x===l&&l===n.x||e.y===c&&c===n.y)return`L${l} ${c}`;if(e.y===c){const p=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${l+a*p},${c}Q ${l},${c} ${l},${c+a*f}`}const d=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${l},${c+a*h}Q ${l},${c} ${l+a*d},${c}`}function gv({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top,borderRadius:c=5,centerX:d,centerY:h,offset:p=20}){const[f,m,y,v,j]=ZO({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:l,center:{x:d,y:h},offset:p});return[f.reduce((S,x,N)=>{let E="";return N>0&&N<f.length-1?E=JO(f[N-1],x,f[N+1],c):E=`${N===0?"M":"L"}${x.x} ${x.y}`,S+=E,S},""),m,y,v,j]}const vd=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,sourcePosition:m=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[x,N,E]=gv({sourceX:e,sourceY:t,sourcePosition:m,targetX:n,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return fe.createElement(Gl,{path:x,labelX:N,labelY:E,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:v,markerStart:j,interactionWidth:S})});vd.displayName="SmoothStepEdge";const Jv=b.memo(e=>{var t;return fe.createElement(vd,{...e,pathOptions:b.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Jv.displayName="StepEdge";function eP({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,l,c,d]=lT({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,l,c,d]}const ex=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v})=>{const[j,_,S]=eP({sourceX:e,sourceY:t,targetX:n,targetY:s});return fe.createElement(Gl,{path:j,labelX:_,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v})});ex.displayName="StraightEdge";function _u(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ck({pos:e,x1:t,y1:n,x2:s,y2:a,c:l}){switch(e){case Ue.Left:return[t-_u(t-s,l),n];case Ue.Right:return[t+_u(s-t,l),n];case Ue.Top:return[t,n-_u(n-a,l)];case Ue.Bottom:return[t,n+_u(a-n,l)]}}function dT({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top,curvature:c=.25}){const[d,h]=ck({pos:n,x1:e,y1:t,x2:s,y2:a,c}),[p,f]=ck({pos:l,x1:s,y1:a,x2:e,y2:t,c}),[m,y,v,j]=cT({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:d,sourceControlY:h,targetControlX:p,targetControlY:f});return[`M${e},${t} C${d},${h} ${p},${f} ${s},${a}`,m,y,v,j]}const nd=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[x,N,E]=dT({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return fe.createElement(Gl,{path:x,labelX:N,labelY:E,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:S})});nd.displayName="BezierEdge";const tx=b.createContext(null),tP=tx.Provider;tx.Consumer;const nP=()=>b.useContext(tx),rP=e=>"id"in e&&"source"in e&&"target"in e,sP=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,yv=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,aP=(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)),oP=(e,t)=>{if(!e.source||!e.target)return t;let n;return rP(e)?n={...e}:n={...e,id:sP(e)},aP(n,t)?t:t.concat(n)},wv=({x:e,y:t},[n,s,a],l,[c,d])=>{const h={x:(e-n)/a,y:(t-s)/a};return l?{x:c*Math.round(h.x/c),y:d*Math.round(h.y/d)}:h},hT=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),Va=(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}},xd=(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:l,y:c}=Va(a,t).positionAbsolute;return sT(s,Ol({x:l,y:c,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return aT(n)},fT=(e,t,[n,s,a]=[0,0,1],l=!1,c=!1,d=[0,0])=>{const h={x:(t.x-n)/a,y:(t.y-s)/a,width:t.width/a,height:t.height/a},p=[];return e.forEach(f=>{const{width:m,height:y,selectable:v=!0,hidden:j=!1}=f;if(c&&!v||j)return!1;const{positionAbsolute:_}=Va(f,d),S={x:_.x,y:_.y,width:m||0,height:y||0},x=pv(h,S),N=typeof m>"u"||typeof y>"u"||m===null||y===null,E=l&&x>0,C=(m||0)*(y||0);(N||E||x>=C||f.dragging)&&p.push(f)}),p},pT=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},mT=(e,t,n,s,a,l=.1)=>{const c=t/(e.width*(1+l)),d=n/(e.height*(1+l)),h=Math.min(c,d),p=si(h,s,a),f=e.x+e.width/2,m=e.y+e.height/2,y=t/2-f*p,v=n/2-m*p;return{x:y,y:v,zoom:p}},Ua=(e,t=0)=>e.transition().duration(t);function uk(e,t,n,s){return(t[n]||[]).reduce((a,l)=>{var c,d;return`${e.id}-${l.id}-${n}`!==s&&a.push({id:l.id||null,type:n,nodeId:e.id,x:(((c=e.positionAbsolute)==null?void 0:c.x)??0)+l.x+l.width/2,y:(((d=e.positionAbsolute)==null?void 0:d.y)??0)+l.y+l.height/2}),a},[])}function iP(e,t,n,s,a,l){const{x:c,y:d}=Gs(e),p=t.elementsFromPoint(c,d).find(j=>j.classList.contains("react-flow__handle"));if(p){const j=p.getAttribute("data-nodeid");if(j){const _=nx(void 0,p),S=p.getAttribute("data-handleid"),x=l({nodeId:j,id:S,type:_});if(x){const N=a.find(E=>E.nodeId===j&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:j,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:x}}}}let f=[],m=1/0;if(a.forEach(j=>{const _=Math.sqrt((j.x-n.x)**2+(j.y-n.y)**2);if(_<=s){const S=l(j);_<=m&&(_<m?f=[{handle:j,validHandleResult:S}]:_===m&&f.push({handle:j,validHandleResult:S}),m=_)}}),!f.length)return{handle:null,validHandleResult:gT()};if(f.length===1)return f[0];const y=f.some(({validHandleResult:j})=>j.isValid),v=f.some(({handle:j})=>j.type==="target");return f.find(({handle:j,validHandleResult:_})=>v?j.type==="target":y?_.isValid:!0)||f[0]}const lP={source:null,target:null,sourceHandle:null,targetHandle:null},gT=()=>({handleDomNode:null,isValid:!1,connection:lP,endHandle:null});function yT(e,t,n,s,a,l,c){const d=a==="target",h=c.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...gT(),handleDomNode:h};if(h){const f=nx(void 0,h),m=h.getAttribute("data-nodeid"),y=h.getAttribute("data-handleid"),v=h.classList.contains("connectable"),j=h.classList.contains("connectableend"),_={source:d?m:n,sourceHandle:d?y:s,target:d?n:m,targetHandle:d?s:y};p.connection=_,v&&j&&(t===Ka.Strict?d&&f==="source"||!d&&f==="target":m!==n||y!==s)&&(p.endHandle={nodeId:m,handleId:y,type:f},p.isValid=l(_))}return p}function cP({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,l)=>{if(l[St]){const{handleBounds:c}=l[St];let d=[],h=[];c&&(d=uk(l,c,"source",`${t}-${n}-${s}`),h=uk(l,c,"target",`${t}-${n}-${s}`)),a.push(...d,...h)}return a},[])}function nx(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function jf(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function uP(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function wT({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:l,setState:c,isValidConnection:d,edgeUpdaterType:h,onReconnectEnd:p}){const f=rT(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:v,connectionRadius:j,onConnectStart:_,panBy:S,getNodes:x,cancelConnection:N}=l();let E=0,C;const{x:R,y:I}=Gs(e),$=f==null?void 0:f.elementFromPoint(R,I),F=nx(h,$),O=y==null?void 0:y.getBoundingClientRect();if(!O||!F)return;let M,L=Gs(e,O),H=!1,B=null,A=!1,Q=null;const K=cP({nodes:x(),nodeId:n,handleId:t,handleType:F}),ee=()=>{if(!v)return;const[Y,P]=nT(L,O);S({x:Y,y:P}),E=requestAnimationFrame(ee)};c({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:F,connectionStartHandle:{nodeId:n,handleId:t,type:F},connectionEndHandle:null}),_==null||_(e,{nodeId:n,handleId:t,handleType:F});function Z(Y){const{transform:P}=l();L=Gs(Y,O);const{handle:G,validHandleResult:de}=iP(Y,f,wv(L,P,!1,[1,1]),j,K,W=>yT(W,m,n,t,a?"target":"source",d,f));if(C=G,H||(ee(),H=!0),Q=de.handleDomNode,B=de.connection,A=de.isValid,c({connectionPosition:C&&A?hT({x:C.x,y:C.y},P):L,connectionStatus:uP(!!C,A),connectionEndHandle:de.endHandle}),!C&&!A&&!Q)return jf(M);B.source!==B.target&&Q&&(jf(M),M=Q,Q.classList.add("connecting","react-flow__handle-connecting"),Q.classList.toggle("valid",A),Q.classList.toggle("react-flow__handle-valid",A))}function D(Y){var P,G;(C||Q)&&B&&A&&(s==null||s(B)),(G=(P=l()).onConnectEnd)==null||G.call(P,Y),h&&(p==null||p(Y)),jf(M),N(),cancelAnimationFrame(E),H=!1,A=!1,B=null,Q=null,f.removeEventListener("mousemove",Z),f.removeEventListener("mouseup",D),f.removeEventListener("touchmove",Z),f.removeEventListener("touchend",D)}f.addEventListener("mousemove",Z),f.addEventListener("mouseup",D),f.addEventListener("touchmove",Z),f.addEventListener("touchend",D)}const dk=()=>!0,dP=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),hP=(e,t,n)=>s=>{const{connectionStartHandle:a,connectionEndHandle:l,connectionClickStartHandle:c}=s;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n,clickConnecting:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.handleId)===t&&(c==null?void 0:c.type)===n}},vT=b.forwardRef(({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:c,onConnect:d,children:h,className:p,onMouseDown:f,onTouchStart:m,...y},v)=>{var O,M;const j=c||null,_=e==="target",S=Rt(),x=nP(),{connectOnClick:N,noPanClassName:E}=ct(dP,Dt),{connecting:C,clickConnecting:R}=ct(hP(x,j,e),Dt);x||(M=(O=S.getState()).onError)==null||M.call(O,"010",is.error010());const I=L=>{const{defaultEdgeOptions:H,onConnect:B,hasDefaultEdges:A}=S.getState(),Q={...H,...L};if(A){const{edges:K,setEdges:ee}=S.getState();ee(oP(Q,K))}B==null||B(Q),d==null||d(Q)},$=L=>{if(!x)return;const H=iT(L);a&&(H&&L.button===0||!H)&&wT({event:L,handleId:j,nodeId:x,onConnect:I,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:n||S.getState().isValidConnection||dk}),H?f==null||f(L):m==null||m(L)},F=L=>{const{onClickConnectStart:H,onClickConnectEnd:B,connectionClickStartHandle:A,connectionMode:Q,isValidConnection:K}=S.getState();if(!x||!A&&!a)return;if(!A){H==null||H(L,{nodeId:x,handleId:j,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:x,type:e,handleId:j}});return}const ee=rT(L.target),Z=n||K||dk,{connection:D,isValid:Y}=yT({nodeId:x,id:j,type:e},Q,A.nodeId,A.handleId||null,A.type,Z,ee);Y&&I(D),B==null||B(L),S.setState({connectionClickStartHandle:null})};return fe.createElement("div",{"data-handleid":j,"data-nodeid":x,"data-handlepos":t,"data-id":`${x}-${j}-${e}`,className:Kt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,p,{source:!_,target:_,connectable:s,connectablestart:a,connectableend:l,connecting:R,connectionindicator:s&&(a&&!C||l&&C)}]),onMouseDown:$,onTouchStart:$,onClick:N?F:void 0,ref:v,...y},h)});vT.displayName="Handle";var ai=b.memo(vT);const xT=({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:s=Ue.Bottom})=>fe.createElement(fe.Fragment,null,fe.createElement(ai,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,fe.createElement(ai,{type:"source",position:s,isConnectable:t}));xT.displayName="DefaultNode";var vv=b.memo(xT);const bT=({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom})=>fe.createElement(fe.Fragment,null,e==null?void 0:e.label,fe.createElement(ai,{type:"source",position:n,isConnectable:t}));bT.displayName="InputNode";var kT=b.memo(bT);const _T=({data:e,isConnectable:t,targetPosition:n=Ue.Top})=>fe.createElement(fe.Fragment,null,fe.createElement(ai,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);_T.displayName="OutputNode";var NT=b.memo(_T);const rx=()=>null;rx.displayName="GroupNode";const fP=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Nu=e=>e.id;function pP(e,t){return Dt(e.selectedNodes.map(Nu),t.selectedNodes.map(Nu))&&Dt(e.selectedEdges.map(Nu),t.selectedEdges.map(Nu))}const ST=b.memo(({onSelectionChange:e})=>{const t=Rt(),{selectedNodes:n,selectedEdges:s}=ct(fP,pP);return b.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(l=>l(a))},[n,s,e]),null});ST.displayName="SelectionListener";const mP=e=>!!e.onSelectionChange;function gP({onSelectionChange:e}){const t=ct(mP);return e||t?fe.createElement(ST,{onSelectionChange:e}):null}const yP=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 Do(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Je(e,t,n){b.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const wP=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:l,onConnectEnd:c,onClickConnectStart:d,onClickConnectEnd:h,nodesDraggable:p,nodesConnectable:f,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:v,elevateNodesOnSelect:j,minZoom:_,maxZoom:S,nodeExtent:x,onNodesChange:N,onEdgesChange:E,elementsSelectable:C,connectionMode:R,snapGrid:I,snapToGrid:$,translateExtent:F,connectOnClick:O,defaultEdgeOptions:M,fitView:L,fitViewOptions:H,onNodesDelete:B,onEdgesDelete:A,onNodeDrag:Q,onNodeDragStart:K,onNodeDragStop:ee,onSelectionDrag:Z,onSelectionDragStart:D,onSelectionDragStop:Y,noPanClassName:P,nodeOrigin:G,rfId:de,autoPanOnConnect:W,autoPanOnNodeDrag:U,onError:J,connectionRadius:V,isValidConnection:ie,nodeDragThreshold:pe})=>{const{setNodes:me,setEdges:Ie,setDefaultNodesAndEdges:Le,setMinZoom:ce,setMaxZoom:xe,setTranslateExtent:ye,setNodeExtent:ze,reset:ke}=ct(yP,Dt),je=Rt();return b.useEffect(()=>{const Ye=s==null?void 0:s.map(it=>({...it,...M}));return Le(n,Ye),()=>{ke()}},[]),Je("defaultEdgeOptions",M,je.setState),Je("connectionMode",R,je.setState),Je("onConnect",a,je.setState),Je("onConnectStart",l,je.setState),Je("onConnectEnd",c,je.setState),Je("onClickConnectStart",d,je.setState),Je("onClickConnectEnd",h,je.setState),Je("nodesDraggable",p,je.setState),Je("nodesConnectable",f,je.setState),Je("nodesFocusable",m,je.setState),Je("edgesFocusable",y,je.setState),Je("edgesUpdatable",v,je.setState),Je("elementsSelectable",C,je.setState),Je("elevateNodesOnSelect",j,je.setState),Je("snapToGrid",$,je.setState),Je("snapGrid",I,je.setState),Je("onNodesChange",N,je.setState),Je("onEdgesChange",E,je.setState),Je("connectOnClick",O,je.setState),Je("fitViewOnInit",L,je.setState),Je("fitViewOnInitOptions",H,je.setState),Je("onNodesDelete",B,je.setState),Je("onEdgesDelete",A,je.setState),Je("onNodeDrag",Q,je.setState),Je("onNodeDragStart",K,je.setState),Je("onNodeDragStop",ee,je.setState),Je("onSelectionDrag",Z,je.setState),Je("onSelectionDragStart",D,je.setState),Je("onSelectionDragStop",Y,je.setState),Je("noPanClassName",P,je.setState),Je("nodeOrigin",G,je.setState),Je("rfId",de,je.setState),Je("autoPanOnConnect",W,je.setState),Je("autoPanOnNodeDrag",U,je.setState),Je("onError",J,je.setState),Je("connectionRadius",V,je.setState),Je("isValidConnection",ie,je.setState),Je("nodeDragThreshold",pe,je.setState),Do(e,me),Do(t,Ie),Do(_,ce),Do(S,xe),Do(F,ye),Do(x,ze),null},hk={display:"none"},vP={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},jT="react-flow__node-desc",ET="react-flow__edge-desc",xP="react-flow__aria-live",bP=e=>e.ariaLiveMessage;function kP({rfId:e}){const t=ct(bP);return fe.createElement("div",{id:`${xP}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vP},t)}function _P({rfId:e,disableKeyboardA11y:t}){return fe.createElement(fe.Fragment,null,fe.createElement("div",{id:`${jT}-${e}`,style:hk},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),fe.createElement("div",{id:`${ET}-${e}`,style:hk},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&fe.createElement(kP,{rfId:e}))}var Ll=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=b.useState(!1),a=b.useRef(!1),l=b.useRef(new Set([])),[c,d]=b.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),f=p.reduce((m,y)=>m.concat(...y),[]);return[p,f]}return[[],[]]},[e]);return b.useEffect(()=>{const h=typeof document<"u"?document:null,p=(t==null?void 0:t.target)||h;if(e!==null){const f=v=>{if(a.current=v.ctrlKey||v.metaKey||v.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&mv(v))return!1;const _=pk(v.code,d);l.current.add(v[_]),fk(c,l.current,!1)&&(v.preventDefault(),s(!0))},m=v=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&mv(v))return!1;const _=pk(v.code,d);fk(c,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(v[_]),v.key==="Meta"&&l.current.clear(),a.current=!1},y=()=>{l.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",f),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",f),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),n};function fk(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function pk(e,t){return t.includes(e)?"code":"key"}function CT(e,t,n,s){var d,h;const a=e.parentNode||e.parentId;if(!a)return n;const l=t.get(a),c=Va(l,s);return CT(l,t,{x:(n.x??0)+c.x,y:(n.y??0)+c.y,z:(((d=l[St])==null?void 0:d.z)??0)>(n.z??0)?((h=l[St])==null?void 0:h.z)??0:n.z??0},s)}function TT(e,t,n){e.forEach(s=>{var l;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:c,y:d,z:h}=CT(s,e,{...s.position,z:((l=s[St])==null?void 0:l.z)??0},t);s.positionAbsolute={x:c,y:d},s[St].z=h,n!=null&&n[s.id]&&(s[St].isParent=!0)}})}function Ef(e,t,n,s){const a=new Map,l={},c=s?1e3:0;return e.forEach(d=>{var v;const h=(Hn(d.zIndex)?d.zIndex:0)+(d.selected?c:0),p=t.get(d.id),f={...d,positionAbsolute:{x:d.position.x,y:d.position.y}},m=d.parentNode||d.parentId;m&&(l[m]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==d.type;Object.defineProperty(f,St,{enumerable:!1,value:{handleBounds:y||(v=p==null?void 0:p[St])==null?void 0:v.handleBounds,z:h}}),a.set(d.id,f)}),TT(a,n,l),a}function AT(e,t={}){const{getNodes:n,width:s,height:a,minZoom:l,maxZoom:c,d3Zoom:d,d3Selection:h,fitViewOnInitDone:p,fitViewOnInit:f,nodeOrigin:m}=e(),y=t.initial&&!p&&f;if(d&&h&&(y||!t.initial)){const j=n().filter(S=>{var N;const x=t.includeHiddenNodes?S.width&&S.height:!S.hidden;return(N=t.nodes)!=null&&N.length?x&&t.nodes.some(E=>E.id===S.id):x}),_=j.every(S=>S.width&&S.height);if(j.length>0&&_){const S=xd(j,m),{x,y:N,zoom:E}=mT(S,s,a,t.minZoom??l,t.maxZoom??c,t.padding??.1),C=ss.translate(x,N).scale(E);return typeof t.duration=="number"&&t.duration>0?d.transform(Ua(h,t.duration),C):d.transform(h,C),!0}}return!1}function NP(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[St]:s[St],selected:n.selected})}),new Map(t)}function SP(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function Su({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:l,onNodesChange:c,onEdgesChange:d,hasDefaultNodes:h,hasDefaultEdges:p}=n();e!=null&&e.length&&(h&&s({nodeInternals:NP(e,a)}),c==null||c(e)),t!=null&&t.length&&(p&&s({edges:SP(t,l)}),d==null||d(t))}const qo=()=>{},jP={zoomIn:qo,zoomOut:qo,zoomTo:qo,getZoom:()=>1,setViewport:qo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:qo,fitBounds:qo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},EP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),CP=()=>{const e=Rt(),{d3Zoom:t,d3Selection:n}=ct(EP,Dt);return b.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Ua(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Ua(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,l)=>t.scaleTo(Ua(n,l==null?void 0:l.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,l)=>{const[c,d,h]=e.getState().transform,p=ss.translate(a.x??c,a.y??d).scale(a.zoom??h);t.transform(Ua(n,l==null?void 0:l.duration),p)},getViewport:()=>{const[a,l,c]=e.getState().transform;return{x:a,y:l,zoom:c}},fitView:a=>AT(e.getState,a),setCenter:(a,l,c)=>{const{width:d,height:h,maxZoom:p}=e.getState(),f=typeof(c==null?void 0:c.zoom)<"u"?c.zoom:p,m=d/2-a*f,y=h/2-l*f,v=ss.translate(m,y).scale(f);t.transform(Ua(n,c==null?void 0:c.duration),v)},fitBounds:(a,l)=>{const{width:c,height:d,minZoom:h,maxZoom:p}=e.getState(),{x:f,y:m,zoom:y}=mT(a,c,d,h,p,(l==null?void 0:l.padding)??.1),v=ss.translate(f,m).scale(y);t.transform(Ua(n,l==null?void 0:l.duration),v)},project:a=>{const{transform:l,snapToGrid:c,snapGrid:d}=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"),wv(a,l,c,d)},screenToFlowPosition:a=>{const{transform:l,snapToGrid:c,snapGrid:d,domNode:h}=e.getState();if(!h)return a;const{x:p,y:f}=h.getBoundingClientRect(),m={x:a.x-p,y:a.y-f};return wv(m,l,c,d)},flowToScreenPosition:a=>{const{transform:l,domNode:c}=e.getState();if(!c)return a;const{x:d,y:h}=c.getBoundingClientRect(),p=hT(a,l);return{x:p.x+d,y:p.y+h}},viewportInitialized:!0}:jP,[t,n])};function Vl(){const e=CP(),t=Rt(),n=b.useCallback(()=>t.getState().getNodes().map(_=>({..._})),[]),s=b.useCallback(_=>t.getState().nodeInternals.get(_),[]),a=b.useCallback(()=>{const{edges:_=[]}=t.getState();return _.map(S=>({...S}))},[]),l=b.useCallback(_=>{const{edges:S=[]}=t.getState();return S.find(x=>x.id===_)},[]),c=b.useCallback(_=>{const{getNodes:S,setNodes:x,hasDefaultNodes:N,onNodesChange:E}=t.getState(),C=S(),R=typeof _=="function"?_(C):_;if(N)x(R);else if(E){const I=R.length===0?C.map($=>({type:"remove",id:$.id})):R.map($=>({item:$,type:"reset"}));E(I)}},[]),d=b.useCallback(_=>{const{edges:S=[],setEdges:x,hasDefaultEdges:N,onEdgesChange:E}=t.getState(),C=typeof _=="function"?_(S):_;if(N)x(C);else if(E){const R=C.length===0?S.map(I=>({type:"remove",id:I.id})):C.map(I=>({item:I,type:"reset"}));E(R)}},[]),h=b.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:x,setNodes:N,hasDefaultNodes:E,onNodesChange:C}=t.getState();if(E){const I=[...x(),...S];N(I)}else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),p=b.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:x=[],setEdges:N,hasDefaultEdges:E,onEdgesChange:C}=t.getState();if(E)N([...x,...S]);else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),f=b.useCallback(()=>{const{getNodes:_,edges:S=[],transform:x}=t.getState(),[N,E,C]=x;return{nodes:_().map(R=>({...R})),edges:S.map(R=>({...R})),viewport:{x:N,y:E,zoom:C}}},[]),m=b.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:x,getNodes:N,edges:E,hasDefaultNodes:C,hasDefaultEdges:R,onNodesDelete:I,onEdgesDelete:$,onNodesChange:F,onEdgesChange:O}=t.getState(),M=(_||[]).map(Q=>Q.id),L=(S||[]).map(Q=>Q.id),H=N().reduce((Q,K)=>{const ee=K.parentNode||K.parentId,Z=!M.includes(K.id)&&ee&&Q.find(Y=>Y.id===ee);return(typeof K.deletable=="boolean"?K.deletable:!0)&&(M.includes(K.id)||Z)&&Q.push(K),Q},[]),B=E.filter(Q=>typeof Q.deletable=="boolean"?Q.deletable:!0),A=B.filter(Q=>L.includes(Q.id));if(H||A){const Q=pT(H,B),K=[...A,...Q],ee=K.reduce((Z,D)=>(Z.includes(D.id)||Z.push(D.id),Z),[]);if((R||C)&&(R&&t.setState({edges:E.filter(Z=>!ee.includes(Z.id))}),C&&(H.forEach(Z=>{x.delete(Z.id)}),t.setState({nodeInternals:new Map(x)}))),ee.length>0&&($==null||$(K),O&&O(ee.map(Z=>({id:Z,type:"remove"})))),H.length>0&&(I==null||I(H),F)){const Z=H.map(D=>({id:D.id,type:"remove"}));F(Z)}}},[]),y=b.useCallback(_=>{const S=YO(_),x=S?null:t.getState().nodeInternals.get(_.id);return!S&&!x?[null,null,S]:[S?_:ak(x),x,S]},[]),v=b.useCallback((_,S=!0,x)=>{const[N,E,C]=y(_);return N?(x||t.getState().getNodes()).filter(R=>{if(!C&&(R.id===E.id||!R.positionAbsolute))return!1;const I=ak(R),$=pv(I,N);return S&&$>0||$>=N.width*N.height}):[]},[]),j=b.useCallback((_,S,x=!0)=>{const[N]=y(_);if(!N)return!1;const E=pv(N,S);return x&&E>0||E>=N.width*N.height},[]);return b.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:l,setNodes:c,setEdges:d,addNodes:h,addEdges:p,toObject:f,deleteElements:m,getIntersectingNodes:v,isNodeIntersecting:j}),[e,n,s,a,l,c,d,h,p,f,m,v,j])}const TP={actInsideInputWithModifier:!1};var AP=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Rt(),{deleteElements:s}=Vl(),a=Ll(e,TP),l=Ll(t);b.useEffect(()=>{if(a){const{edges:c,getNodes:d}=n.getState(),h=d().filter(f=>f.selected),p=c.filter(f=>f.selected);s({nodes:h,edges:p}),n.setState({nodesSelectionActive:!1})}},[a]),b.useEffect(()=>{n.setState({multiSelectionActive:l})},[l])};function RP(e){const t=Rt();b.useEffect(()=>{let n;const s=()=>{var l,c;if(!e.current)return;const a=Xv(e.current);(a.height===0||a.width===0)&&((c=(l=t.getState()).onError)==null||c.call(l,"004",is.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 sx={position:"absolute",width:"100%",height:"100%",top:0,left:0},MP=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,ju=e=>({x:e.x,y:e.y,zoom:e.k}),Fo=(e,t)=>e.target.closest(`.${t}`),mk=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),gk=e=>{const t=e.ctrlKey&&ed()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},IP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),$P=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:l=!0,panOnScroll:c=!1,panOnScrollSpeed:d=.5,panOnScrollMode:h=Ha.Free,zoomOnDoubleClick:p=!0,elementsSelectable:f,panOnDrag:m=!0,defaultViewport:y,translateExtent:v,minZoom:j,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:x=!0,children:N,noWheelClassName:E,noPanClassName:C})=>{const R=b.useRef(),I=Rt(),$=b.useRef(!1),F=b.useRef(!1),O=b.useRef(null),M=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:H,d3ZoomHandler:B,userSelectionActive:A}=ct(IP,Dt),Q=Ll(S),K=b.useRef(0),ee=b.useRef(!1),Z=b.useRef();return RP(O),b.useEffect(()=>{if(O.current){const D=O.current.getBoundingClientRect(),Y=eT().scaleExtent([j,_]).translateExtent(v),P=Wn(O.current).call(Y),G=ss.translate(y.x,y.y).scale(si(y.zoom,j,_)),de=[[0,0],[D.width,D.height]],W=Y.constrain()(G,de,v);Y.transform(P,W),Y.wheelDelta(gk),I.setState({d3Zoom:Y,d3Selection:P,d3ZoomHandler:P.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:O.current.closest(".react-flow")})}},[]),b.useEffect(()=>{H&&L&&(c&&!Q&&!A?H.on("wheel.zoom",D=>{if(Fo(D,E))return!1;D.preventDefault(),D.stopImmediatePropagation();const Y=H.property("__zoom").k||1;if(D.ctrlKey&&l){const ie=lr(D),pe=gk(D),me=Y*Math.pow(2,pe);L.scaleTo(H,me,ie,D);return}const P=D.deltaMode===1?20:1;let G=h===Ha.Vertical?0:D.deltaX*P,de=h===Ha.Horizontal?0:D.deltaY*P;!ed()&&D.shiftKey&&h!==Ha.Vertical&&(G=D.deltaY*P,de=0),L.translateBy(H,-(G/Y)*d,-(de/Y)*d,{internal:!0});const W=ju(H.property("__zoom")),{onViewportChangeStart:U,onViewportChange:J,onViewportChangeEnd:V}=I.getState();clearTimeout(Z.current),ee.current||(ee.current=!0,t==null||t(D,W),U==null||U(W)),ee.current&&(e==null||e(D,W),J==null||J(W),Z.current=setTimeout(()=>{n==null||n(D,W),V==null||V(W),ee.current=!1},150))},{passive:!1}):typeof B<"u"&&H.on("wheel.zoom",function(D,Y){if(!x&&D.type==="wheel"&&!D.ctrlKey||Fo(D,E))return null;D.preventDefault(),B.call(this,D,Y)},{passive:!1}))},[A,c,h,H,L,B,Q,l,x,E,t,e,n]),b.useEffect(()=>{L&&L.on("start",D=>{var G,de;if(!D.sourceEvent||D.sourceEvent.internal)return null;K.current=(G=D.sourceEvent)==null?void 0:G.button;const{onViewportChangeStart:Y}=I.getState(),P=ju(D.transform);$.current=!0,M.current=P,((de=D.sourceEvent)==null?void 0:de.type)==="mousedown"&&I.setState({paneDragging:!0}),Y==null||Y(P),t==null||t(D.sourceEvent,P)})},[L,t]),b.useEffect(()=>{L&&(A&&!$.current?L.on("zoom",null):A||L.on("zoom",D=>{var P;const{onViewportChange:Y}=I.getState();if(I.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),F.current=!!(s&&mk(m,K.current??0)),(e||Y)&&!((P=D.sourceEvent)!=null&&P.internal)){const G=ju(D.transform);Y==null||Y(G),e==null||e(D.sourceEvent,G)}}))},[A,L,e,m,s]),b.useEffect(()=>{L&&L.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:Y}=I.getState();if($.current=!1,I.setState({paneDragging:!1}),s&&mk(m,K.current??0)&&!F.current&&s(D.sourceEvent),F.current=!1,(n||Y)&&MP(M.current,D.transform)){const P=ju(D.transform);M.current=P,clearTimeout(R.current),R.current=setTimeout(()=>{Y==null||Y(P),n==null||n(D.sourceEvent,P)},c?150:0)}})},[L,c,m,n,s]),b.useEffect(()=>{L&&L.filter(D=>{const Y=Q||a,P=l&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(Fo(D,"react-flow__node")||Fo(D,"react-flow__edge")))return!0;if(!m&&!Y&&!c&&!p&&!l||A||!p&&D.type==="dblclick"||Fo(D,E)&&D.type==="wheel"||Fo(D,C)&&(D.type!=="wheel"||c&&D.type==="wheel"&&!Q)||!l&&D.ctrlKey&&D.type==="wheel"||!Y&&!c&&!P&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const G=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&G})},[A,L,a,l,c,p,m,f,Q]),fe.createElement("div",{className:"react-flow__renderer",ref:O,style:sx},N)},OP=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function PP(){const{userSelectionActive:e,userSelectionRect:t}=ct(OP,Dt);return e&&t?fe.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function yk(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,l=t.position.y+t.height-s.height;if(a>0||l>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),l>0&&(s.style.height+=l),t.position.x<0){const c=Math.abs(t.position.x);s.position.x=s.position.x-c,s.style.width+=c,t.position.x=0}if(t.position.y<0){const c=Math.abs(t.position.y);s.position.y=s.position.y-c,s.style.height+=c,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function LP(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 l=e.filter(d=>d.id===a.id);if(l.length===0)return s.push(a),s;const c={...a};for(const d of l)if(d)switch(d.type){case"select":{c.selected=d.selected;break}case"position":{typeof d.position<"u"&&(c.position=d.position),typeof d.positionAbsolute<"u"&&(c.positionAbsolute=d.positionAbsolute),typeof d.dragging<"u"&&(c.dragging=d.dragging),c.expandParent&&yk(s,c);break}case"dimensions":{typeof d.dimensions<"u"&&(c.width=d.dimensions.width,c.height=d.dimensions.height),typeof d.updateStyle<"u"&&(c.style={...c.style||{},...d.dimensions}),typeof d.resizing=="boolean"&&(c.resizing=d.resizing),c.expandParent&&yk(s,c);break}case"remove":return s}return s.push(c),s},n)}function DP(e,t){return LP(e,t)}const Ws=(e,t)=>({id:e,type:"select",selected:t});function Vo(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Ws(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Ws(s.id,!1))),n},[])}const Cf=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},qP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),RT=b.memo(({isSelecting:e,selectionMode:t=Pl.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:f,children:m})=>{const y=b.useRef(null),v=Rt(),j=b.useRef(0),_=b.useRef(0),S=b.useRef(),{userSelectionActive:x,elementsSelectable:N,dragging:E}=ct(qP,Dt),C=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,_.current=0},R=B=>{l==null||l(B),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},I=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}c==null||c(B)},$=d?B=>d(B):void 0,F=B=>{const{resetSelectedElements:A,domNode:Q}=v.getState();if(S.current=Q==null?void 0:Q.getBoundingClientRect(),!N||!e||B.button!==0||B.target!==y.current||!S.current)return;const{x:K,y:ee}=Gs(B,S.current);A(),v.setState({userSelectionRect:{width:0,height:0,startX:K,startY:ee,x:K,y:ee}}),s==null||s(B)},O=B=>{const{userSelectionRect:A,nodeInternals:Q,edges:K,transform:ee,onNodesChange:Z,onEdgesChange:D,nodeOrigin:Y,getNodes:P}=v.getState();if(!e||!S.current||!A)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const G=Gs(B,S.current),de=A.startX??0,W=A.startY??0,U={...A,x:G.x<de?G.x:de,y:G.y<W?G.y:W,width:Math.abs(G.x-de),height:Math.abs(G.y-W)},J=P(),V=fT(Q,U,ee,t===Pl.Partial,!0,Y),ie=pT(V,K).map(me=>me.id),pe=V.map(me=>me.id);if(j.current!==pe.length){j.current=pe.length;const me=Vo(J,pe);me.length&&(Z==null||Z(me))}if(_.current!==ie.length){_.current=ie.length;const me=Vo(K,ie);me.length&&(D==null||D(me))}v.setState({userSelectionRect:U})},M=B=>{if(B.button!==0)return;const{userSelectionRect:A}=v.getState();!x&&A&&B.target===y.current&&(R==null||R(B)),v.setState({nodesSelectionActive:j.current>0}),C(),a==null||a(B)},L=B=>{x&&(v.setState({nodesSelectionActive:j.current>0}),a==null||a(B)),C()},H=N&&(e||x);return fe.createElement("div",{className:Kt(["react-flow__pane",{dragging:E,selection:e}]),onClick:H?void 0:Cf(R,y),onContextMenu:Cf(I,y),onWheel:Cf($,y),onMouseEnter:H?void 0:h,onMouseDown:H?F:void 0,onMouseMove:H?O:p,onMouseUp:H?M:void 0,onMouseLeave:H?L:f,ref:y,style:sx},m,fe.createElement(PP,null))});RT.displayName="Pane";function MT(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:MT(s,t):!1}function wk(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 FP(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!MT(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var l,c;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((l=a.positionAbsolute)==null?void 0:l.x)??0),y:n.y-(((c=a.positionAbsolute)==null?void 0:c.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 BP(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function IT(e,t,n,s,a=[0,0],l){const c=BP(e,e.extent||s);let d=c;const h=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(h&&e.width&&e.height){const m=n.get(h),{x:y,y:v}=Va(m,a).positionAbsolute;d=m&&Hn(y)&&Hn(v)&&Hn(m.width)&&Hn(m.height)?[[y+e.width*a[0],v+e.height*a[1]],[y+m.width-e.width+e.width*a[0],v+m.height-e.height+e.height*a[1]]]:d}else l==null||l("005",is.error005()),d=c;else if(e.extent&&h&&e.extent!=="parent"){const m=n.get(h),{x:y,y:v}=Va(m,a).positionAbsolute;d=[[e.extent[0][0]+y,e.extent[0][1]+v],[e.extent[1][0]+y,e.extent[1][1]+v]]}let p={x:0,y:0};if(h){const m=n.get(h);p=Va(m,a).positionAbsolute}const f=d&&d!=="parent"?Qv(t,d):t;return{position:{x:f.x-p.x,y:f.y-p.y},positionAbsolute:f}}function Tf({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 vk=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const l=Array.from(a),c=t.getBoundingClientRect(),d={x:c.width*s[0],y:c.height*s[1]};return l.map(h=>{const p=h.getBoundingClientRect();return{id:h.getAttribute("data-handleid"),position:h.getAttribute("data-handlepos"),x:(p.left-c.left-d.x)/n,y:(p.top-c.top-d.y)/n,...Xv(h)}})};function yl(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function xv({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:l,multiSelectionActive:c,nodeInternals:d,onError:h}=t.getState(),p=d.get(e);if(!p){h==null||h("012",is.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(n||p.selected&&c)&&(l({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):a([e])}function zP(){const e=Rt();return b.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,snapToGrid:l}=e.getState(),c=n.touches?n.touches[0].clientX:n.clientX,d=n.touches?n.touches[0].clientY:n.clientY,h={x:(c-s[0])/s[2],y:(d-s[1])/s[2]};return{xSnapped:l?a[0]*Math.round(h.x/a[0]):h.x,ySnapped:l?a[1]*Math.round(h.y/a[1]):h.y,...h}},[])}function Af(e){return(t,n,s)=>e==null?void 0:e(t,s)}function $T({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:l,selectNodesOnDrag:c}){const d=Rt(),[h,p]=b.useState(!1),f=b.useRef([]),m=b.useRef({x:null,y:null}),y=b.useRef(0),v=b.useRef(null),j=b.useRef({x:0,y:0}),_=b.useRef(null),S=b.useRef(!1),x=b.useRef(!1),N=b.useRef(!1),E=zP();return b.useEffect(()=>{if(e!=null&&e.current){const C=Wn(e.current),R=({x:F,y:O})=>{const{nodeInternals:M,onNodeDrag:L,onSelectionDrag:H,updateNodePositions:B,nodeExtent:A,snapGrid:Q,snapToGrid:K,nodeOrigin:ee,onError:Z}=d.getState();m.current={x:F,y:O};let D=!1,Y={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&A){const G=xd(f.current,ee);Y=Ol(G)}if(f.current=f.current.map(G=>{const de={x:F-G.distance.x,y:O-G.distance.y};K&&(de.x=Q[0]*Math.round(de.x/Q[0]),de.y=Q[1]*Math.round(de.y/Q[1]));const W=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];f.current.length>1&&A&&!G.extent&&(W[0][0]=G.positionAbsolute.x-Y.x+A[0][0],W[1][0]=G.positionAbsolute.x+(G.width??0)-Y.x2+A[1][0],W[0][1]=G.positionAbsolute.y-Y.y+A[0][1],W[1][1]=G.positionAbsolute.y+(G.height??0)-Y.y2+A[1][1]);const U=IT(G,de,M,W,ee,Z);return D=D||G.position.x!==U.position.x||G.position.y!==U.position.y,G.position=U.position,G.positionAbsolute=U.positionAbsolute,G}),!D)return;B(f.current,!0,!0),p(!0);const P=a?L:Af(H);if(P&&_.current){const[G,de]=Tf({nodeId:a,dragItems:f.current,nodeInternals:M});P(_.current,G,de)}},I=()=>{if(!v.current)return;const[F,O]=nT(j.current,v.current);if(F!==0||O!==0){const{transform:M,panBy:L}=d.getState();m.current.x=(m.current.x??0)-F/M[2],m.current.y=(m.current.y??0)-O/M[2],L({x:F,y:O})&&R(m.current)}y.current=requestAnimationFrame(I)},$=F=>{var ee;const{nodeInternals:O,multiSelectionActive:M,nodesDraggable:L,unselectNodesAndEdges:H,onNodeDragStart:B,onSelectionDragStart:A}=d.getState();x.current=!0;const Q=a?B:Af(A);(!c||!l)&&!M&&a&&((ee=O.get(a))!=null&&ee.selected||H()),a&&l&&c&&xv({id:a,store:d,nodeRef:e});const K=E(F);if(m.current=K,f.current=FP(O,L,K,a),Q&&f.current){const[Z,D]=Tf({nodeId:a,dragItems:f.current,nodeInternals:O});Q(F.sourceEvent,Z,D)}};if(t)C.on(".drag",null);else{const F=ZI().on("start",O=>{const{domNode:M,nodeDragThreshold:L}=d.getState();L===0&&$(O),N.current=!1;const H=E(O);m.current=H,v.current=(M==null?void 0:M.getBoundingClientRect())||null,j.current=Gs(O.sourceEvent,v.current)}).on("drag",O=>{var B,A;const M=E(O),{autoPanOnNodeDrag:L,nodeDragThreshold:H}=d.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!S.current&&x.current&&L&&(S.current=!0,I()),!x.current){const Q=M.xSnapped-(((B=m==null?void 0:m.current)==null?void 0:B.x)??0),K=M.ySnapped-(((A=m==null?void 0:m.current)==null?void 0:A.y)??0);Math.sqrt(Q*Q+K*K)>H&&$(O)}(m.current.x!==M.xSnapped||m.current.y!==M.ySnapped)&&f.current&&x.current&&(_.current=O.sourceEvent,j.current=Gs(O.sourceEvent,v.current),R(M))}}).on("end",O=>{if(!(!x.current||N.current)&&(p(!1),S.current=!1,x.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:M,nodeInternals:L,onNodeDragStop:H,onSelectionDragStop:B}=d.getState(),A=a?H:Af(B);if(M(f.current,!1,!1),A){const[Q,K]=Tf({nodeId:a,dragItems:f.current,nodeInternals:L});A(O.sourceEvent,Q,K)}}}).filter(O=>{const M=O.target;return!O.button&&(!n||!wk(M,`.${n}`,e))&&(!s||wk(M,s,e))});return C.call(F),()=>{C.on(".drag",null)}}}},[e,t,n,s,l,d,a,c,E]),h}function OT(){const e=Rt();return b.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:l,getNodes:c,snapToGrid:d,snapGrid:h,onError:p,nodesDraggable:f}=e.getState(),m=c().filter(N=>N.selected&&(N.draggable||f&&typeof N.draggable>"u")),y=d?h[0]:5,v=d?h[1]:5,j=n.isShiftPressed?4:1,_=n.x*y*j,S=n.y*v*j,x=m.map(N=>{if(N.positionAbsolute){const E={x:N.positionAbsolute.x+_,y:N.positionAbsolute.y+S};d&&(E.x=h[0]*Math.round(E.x/h[0]),E.y=h[1]*Math.round(E.y/h[1]));const{positionAbsolute:C,position:R}=IT(N,E,s,a,void 0,p);N.position=R,N.positionAbsolute=C}return N});l(x,!0,!1)},[])}const Jo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var wl=e=>{const t=({id:n,type:s,data:a,xPos:l,yPos:c,xPosOrigin:d,yPosOrigin:h,selected:p,onClick:f,onMouseEnter:m,onMouseMove:y,onMouseLeave:v,onContextMenu:j,onDoubleClick:_,style:S,className:x,isDraggable:N,isSelectable:E,isConnectable:C,isFocusable:R,selectNodesOnDrag:I,sourcePosition:$,targetPosition:F,hidden:O,resizeObserver:M,dragHandle:L,zIndex:H,isParent:B,noDragClassName:A,noPanClassName:Q,initialized:K,disableKeyboardA11y:ee,ariaLabel:Z,rfId:D,hasHandleBounds:Y})=>{const P=Rt(),G=b.useRef(null),de=b.useRef(null),W=b.useRef($),U=b.useRef(F),J=b.useRef(s),V=E||N||f||m||y||v,ie=OT(),pe=yl(n,P.getState,m),me=yl(n,P.getState,y),Ie=yl(n,P.getState,v),Le=yl(n,P.getState,j),ce=yl(n,P.getState,_),xe=ke=>{const{nodeDragThreshold:je}=P.getState();if(E&&(!I||!N||je>0)&&xv({id:n,store:P,nodeRef:G}),f){const Ye=P.getState().nodeInternals.get(n);Ye&&f(ke,{...Ye})}},ye=ke=>{if(!mv(ke)&&!ee)if(oT.includes(ke.key)&&E){const je=ke.key==="Escape";xv({id:n,store:P,unselect:je,nodeRef:G})}else N&&p&&Object.prototype.hasOwnProperty.call(Jo,ke.key)&&(P.setState({ariaLiveMessage:`Moved selected node ${ke.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~c}`}),ie({x:Jo[ke.key].x,y:Jo[ke.key].y,isShiftPressed:ke.shiftKey}))};b.useEffect(()=>()=>{de.current&&(M==null||M.unobserve(de.current),de.current=null)},[]),b.useEffect(()=>{if(G.current&&!O){const ke=G.current;(!K||!Y||de.current!==ke)&&(de.current&&(M==null||M.unobserve(de.current)),M==null||M.observe(ke),de.current=ke)}},[O,K,Y]),b.useEffect(()=>{const ke=J.current!==s,je=W.current!==$,Ye=U.current!==F;G.current&&(ke||je||Ye)&&(ke&&(J.current=s),je&&(W.current=$),Ye&&(U.current=F),P.getState().updateNodeDimensions([{id:n,nodeElement:G.current,forceUpdate:!0}]))},[n,s,$,F]);const ze=$T({nodeRef:G,disabled:O||!N,noDragClassName:A,handleSelector:L,nodeId:n,isSelectable:E,selectNodesOnDrag:I});return O?null:fe.createElement("div",{className:Kt(["react-flow__node",`react-flow__node-${s}`,{[Q]:N},x,{selected:p,selectable:E,parent:B,dragging:ze}]),ref:G,style:{zIndex:H,transform:`translate(${d}px,${h}px)`,pointerEvents:V?"all":"none",visibility:K?"visible":"hidden",...S},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:pe,onMouseMove:me,onMouseLeave:Ie,onContextMenu:Le,onClick:xe,onDoubleClick:ce,onKeyDown:R?ye:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":ee?void 0:`${jT}-${D}`,"aria-label":Z},fe.createElement(tP,{value:n},fe.createElement(e,{id:n,data:a,type:s,xPos:l,yPos:c,selected:p,isConnectable:C,sourcePosition:$,targetPosition:F,dragging:ze,dragHandle:L,zIndex:H})))};return t.displayName="NodeWrapper",b.memo(t)};const UP=e=>{const t=e.getNodes().filter(n=>n.selected);return{...xd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function WP({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Rt(),{width:a,height:l,x:c,y:d,transformString:h,userSelectionActive:p}=ct(UP,Dt),f=OT(),m=b.useRef(null);if(b.useEffect(()=>{var j;n||(j=m.current)==null||j.focus({preventScroll:!0})},[n]),$T({nodeRef:m}),p||!a||!l)return null;const y=e?j=>{const _=s.getState().getNodes().filter(S=>S.selected);e(j,_)}:void 0,v=j=>{Object.prototype.hasOwnProperty.call(Jo,j.key)&&f({x:Jo[j.key].x,y:Jo[j.key].y,isShiftPressed:j.shiftKey})};return fe.createElement("div",{className:Kt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:h}},fe.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:a,height:l,top:d,left:c}}))}var HP=b.memo(WP);const GP=e=>e.nodesSelectionActive,PT=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,deleteKeyCode:d,onMove:h,onMoveStart:p,onMoveEnd:f,selectionKeyCode:m,selectionOnDrag:y,selectionMode:v,onSelectionStart:j,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:N,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:M,defaultViewport:L,translateExtent:H,minZoom:B,maxZoom:A,preventScrolling:Q,onSelectionContextMenu:K,noWheelClassName:ee,noPanClassName:Z,disableKeyboardA11y:D})=>{const Y=ct(GP),P=Ll(m),G=Ll(x),de=G||M,W=G||I,U=P||y&&de!==!0;return AP({deleteKeyCode:d,multiSelectionKeyCode:S}),fe.createElement($P,{onMove:h,onMoveStart:p,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:W,panOnScrollSpeed:$,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:!P&&de,defaultViewport:L,translateExtent:H,minZoom:B,maxZoom:A,zoomActivationKeyCode:N,preventScrolling:Q,noWheelClassName:ee,noPanClassName:Z},fe.createElement(RT,{onSelectionStart:j,onSelectionEnd:_,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:de,isSelecting:!!U,selectionMode:v},e,Y&&fe.createElement(HP,{onSelectionContextMenu:K,noPanClassName:Z,disableKeyboardA11y:D})))};PT.displayName="FlowRenderer";var VP=b.memo(PT);function YP(e){return ct(b.useCallback(n=>e?fT(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function KP(e){const t={input:wl(e.input||kT),default:wl(e.default||vv),output:wl(e.output||NT),group:wl(e.group||rx)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,l)=>(a[l]=wl(e[l]||vv),a),n);return{...t,...s}}const XP=({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]},QP=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),LT=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:l,onError:c}=ct(QP,Dt),d=YP(e.onlyRenderVisibleElements),h=b.useRef(),p=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(m=>{const y=m.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));l(y)});return h.current=f,f},[]);return b.useEffect(()=>()=>{var f;(f=h==null?void 0:h.current)==null||f.disconnect()},[]),fe.createElement("div",{className:"react-flow__nodes",style:sx},d.map(f=>{var R,I,$;let m=f.type||"default";e.nodeTypes[m]||(c==null||c("003",is.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),j=!!(f.selectable||a&&typeof f.selectable>"u"),_=!!(f.connectable||n&&typeof f.connectable>"u"),S=!!(f.focusable||s&&typeof f.focusable>"u"),x=e.nodeExtent?Qv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(x==null?void 0:x.x)??0,E=(x==null?void 0:x.y)??0,C=XP({x:N,y:E,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return fe.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:m,data:f.data,sourcePosition:f.sourcePosition||Ue.Bottom,targetPosition:f.targetPosition||Ue.Top,hidden:f.hidden,xPos:N,yPos:E,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:v,isSelectable:j,isConnectable:_,isFocusable:S,resizeObserver:p,dragHandle:f.dragHandle,zIndex:((R=f[St])==null?void 0:R.z)??0,isParent:!!((I=f[St])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!(($=f[St])!=null&&$.handleBounds)})}))};LT.displayName="NodeRenderer";var ZP=b.memo(LT);const JP=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,e3=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,xk="react-flow__edgeupdater",bk=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:l,onMouseOut:c,type:d})=>fe.createElement("circle",{onMouseDown:a,onMouseEnter:l,onMouseOut:c,className:Kt([xk,`${xk}-${d}`]),cx:JP(t,s,e),cy:e3(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),t3=()=>!0;var Bo=e=>{const t=({id:n,className:s,type:a,data:l,onClick:c,onEdgeDoubleClick:d,selected:h,animated:p,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:_,style:S,source:x,target:N,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:$,targetPosition:F,elementsSelectable:O,hidden:M,sourceHandleId:L,targetHandleId:H,onContextMenu:B,onMouseEnter:A,onMouseMove:Q,onMouseLeave:K,reconnectRadius:ee,onReconnect:Z,onReconnectStart:D,onReconnectEnd:Y,markerEnd:P,markerStart:G,rfId:de,ariaLabel:W,isFocusable:U,isReconnectable:J,pathOptions:V,interactionWidth:ie,disableKeyboardA11y:pe})=>{const me=b.useRef(null),[Ie,Le]=b.useState(!1),[ce,xe]=b.useState(!1),ye=Rt(),ze=b.useMemo(()=>`url('#${yv(G,de)}')`,[G,de]),ke=b.useMemo(()=>`url('#${yv(P,de)}')`,[P,de]);if(M)return null;const je=ne=>{var ut;const{edges:De,addSelectedEdges:Oe,unselectNodesAndEdges:Te,multiSelectionActive:Ce}=ye.getState(),lt=De.find(Re=>Re.id===n);lt&&(O&&(ye.setState({nodesSelectionActive:!1}),lt.selected&&Ce?(Te({nodes:[],edges:[lt]}),(ut=me.current)==null||ut.blur()):Oe([n])),c&&c(ne,lt))},Ye=gl(n,ye.getState,d),it=gl(n,ye.getState,B),Ne=gl(n,ye.getState,A),He=gl(n,ye.getState,Q),Xe=gl(n,ye.getState,K),he=(ne,De)=>{if(ne.button!==0)return;const{edges:Oe,isValidConnection:Te}=ye.getState(),Ce=De?N:x,lt=(De?H:L)||null,ut=De?"target":"source",Re=Te||t3,mt=De,ft=Oe.find(Tn=>Tn.id===n);xe(!0),D==null||D(ne,ft,ut);const bt=Tn=>{xe(!1),Y==null||Y(Tn,ft,ut)};wT({event:ne,handleId:lt,nodeId:Ce,onConnect:Tn=>Z==null?void 0:Z(ft,Tn),isTarget:mt,getState:ye.getState,setState:ye.setState,isValidConnection:Re,edgeUpdaterType:ut,onReconnectEnd:bt})},ge=ne=>he(ne,!0),Se=ne=>he(ne,!1),Fe=()=>Le(!0),et=()=>Le(!1),xt=!O&&!c,ht=ne=>{var De;if(!pe&&oT.includes(ne.key)&&O){const{unselectNodesAndEdges:Oe,addSelectedEdges:Te,edges:Ce}=ye.getState();ne.key==="Escape"?((De=me.current)==null||De.blur(),Oe({edges:[Ce.find(ut=>ut.id===n)]})):Te([n])}};return fe.createElement("g",{className:Kt(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:h,animated:p,inactive:xt,updating:Ie}]),onClick:je,onDoubleClick:Ye,onContextMenu:it,onMouseEnter:Ne,onMouseMove:He,onMouseLeave:Xe,onKeyDown:U?ht:void 0,tabIndex:U?0:void 0,role:U?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${x} to ${N}`,"aria-describedby":U?`${ET}-${de}`:void 0,ref:me},!ce&&fe.createElement(e,{id:n,source:x,target:N,selected:h,animated:p,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:_,data:l,style:S,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:$,targetPosition:F,sourceHandleId:L,targetHandleId:H,markerStart:ze,markerEnd:ke,pathOptions:V,interactionWidth:ie}),J&&fe.createElement(fe.Fragment,null,(J==="source"||J===!0)&&fe.createElement(bk,{position:$,centerX:E,centerY:C,radius:ee,onMouseDown:ge,onMouseEnter:Fe,onMouseOut:et,type:"source"}),(J==="target"||J===!0)&&fe.createElement(bk,{position:F,centerX:R,centerY:I,radius:ee,onMouseDown:Se,onMouseEnter:Fe,onMouseOut:et,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function n3(e){const t={default:Bo(e.default||nd),straight:Bo(e.bezier||ex),step:Bo(e.step||Jv),smoothstep:Bo(e.step||vd),simplebezier:Bo(e.simplebezier||Zv)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,l)=>(a[l]=Bo(e[l]||nd),a),n);return{...t,...s}}function kk(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,l=(n==null?void 0:n.width)||t.width,c=(n==null?void 0:n.height)||t.height;switch(e){case Ue.Top:return{x:s+l/2,y:a};case Ue.Right:return{x:s+l,y:a+c/2};case Ue.Bottom:return{x:s+l/2,y:a+c};case Ue.Left:return{x:s,y:a+c/2}}}function _k(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const r3=(e,t,n,s,a,l)=>{const c=kk(n,e,t),d=kk(l,s,a);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y}};function s3({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,targetHeight:l,width:c,height:d,transform:h}){const p={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+l)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const f=Ol({x:(0-h[0])/h[2],y:(0-h[1])/h[2],width:c/h[2],height:d/h[2]}),m=Math.max(0,Math.min(f.x2,p.x2)-Math.max(f.x,p.x)),y=Math.max(0,Math.min(f.y2,p.y2)-Math.max(f.y,p.y));return Math.ceil(m*y)>0}function Nk(e){var s,a,l,c,d;const t=((s=e==null?void 0:e[St])==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((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.x)||0,y:((d=e==null?void 0:e.positionAbsolute)==null?void 0:d.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const a3=[{level:0,isMaxLevel:!0,edges:[]}];function o3(e,t,n=!1){let s=-1;const a=e.reduce((c,d)=>{var f,m;const h=Hn(d.zIndex);let p=h?d.zIndex:0;if(n){const y=t.get(d.target),v=t.get(d.source),j=d.selected||(y==null?void 0:y.selected)||(v==null?void 0:v.selected),_=Math.max(((f=v==null?void 0:v[St])==null?void 0:f.z)||0,((m=y==null?void 0:y[St])==null?void 0:m.z)||0,1e3);p=(h?d.zIndex:0)+(j?_:0)}return c[p]?c[p].push(d):c[p]=[d],s=p>s?p:s,c},{}),l=Object.entries(a).map(([c,d])=>{const h=+c;return{edges:d,level:h,isMaxLevel:h===s}});return l.length===0?a3:l}function i3(e,t,n){const s=ct(b.useCallback(a=>e?a.edges.filter(l=>{const c=t.get(l.source),d=t.get(l.target);return(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&(d==null?void 0:d.width)&&(d==null?void 0:d.height)&&s3({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:d.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:d.width,targetHeight:d.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return o3(s,t,n)}const l3=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),c3=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Sk={[td.Arrow]:l3,[td.ArrowClosed]:c3};function u3(e){const t=Rt();return b.useMemo(()=>{var a,l;return Object.prototype.hasOwnProperty.call(Sk,e)?Sk[e]:((l=(a=t.getState()).onError)==null||l.call(a,"009",is.error009(e)),null)},[e])}const d3=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:d="auto-start-reverse"})=>{const h=u3(t);return h?fe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:d,refX:"0",refY:"0"},fe.createElement(h,{color:n,strokeWidth:c})):null},h3=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((a,l)=>([l.markerStart,l.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const d=yv(c,t);s.includes(d)||(a.push({id:d,color:c.color||e,...c}),s.push(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))},DT=({defaultColor:e,rfId:t})=>{const n=ct(b.useCallback(h3({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((l,c)=>l.id!==a[c].id)));return fe.createElement("defs",null,n.map(s=>fe.createElement(d3,{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})))};DT.displayName="MarkerDefinitions";var f3=b.memo(DT);const p3=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}),qT=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:l,onEdgeContextMenu:c,onEdgeMouseEnter:d,onEdgeMouseMove:h,onEdgeMouseLeave:p,onEdgeClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:_,children:S,disableKeyboardA11y:x})=>{const{edgesFocusable:N,edgesUpdatable:E,elementsSelectable:C,width:R,height:I,connectionMode:$,nodeInternals:F,onError:O}=ct(p3,Dt),M=i3(t,F,n);return R?fe.createElement(fe.Fragment,null,M.map(({level:L,edges:H,isMaxLevel:B})=>fe.createElement("svg",{key:L,style:{zIndex:L},width:R,height:I,className:"react-flow__edges react-flow__container"},B&&fe.createElement(f3,{defaultColor:e,rfId:s}),fe.createElement("g",null,H.map(A=>{const[Q,K,ee]=Nk(F.get(A.source)),[Z,D,Y]=Nk(F.get(A.target));if(!ee||!Y)return null;let P=A.type||"default";a[P]||(O==null||O("011",is.error011(P)),P="default");const G=a[P]||a.default,de=$===Ka.Strict?D.target:(D.target??[]).concat(D.source??[]),W=_k(K.source,A.sourceHandle),U=_k(de,A.targetHandle),J=(W==null?void 0:W.position)||Ue.Bottom,V=(U==null?void 0:U.position)||Ue.Top,ie=!!(A.focusable||N&&typeof A.focusable>"u"),pe=A.reconnectable||A.updatable,me=typeof y<"u"&&(pe||E&&typeof pe>"u");if(!W||!U)return O==null||O("008",is.error008(W,A)),null;const{sourceX:Ie,sourceY:Le,targetX:ce,targetY:xe}=r3(Q,W,J,Z,U,V);return fe.createElement(G,{key:A.id,id:A.id,className:Kt([A.className,l]),type:P,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:Ie,sourceY:Le,targetX:ce,targetY:xe,sourcePosition:J,targetPosition:V,elementsSelectable:C,onContextMenu:c,onMouseEnter:d,onMouseMove:h,onMouseLeave:p,onClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:_,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ie,isReconnectable:me,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:x})})))),S):null};qT.displayName="EdgeRenderer";var m3=b.memo(qT);const g3=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function y3({children:e}){const t=ct(g3);return fe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function w3(e){const t=Vl(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const v3={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top},FT=({nodeId:e,handleType:t,style:n,type:s=Hs.Bezier,CustomComponent:a,connectionStatus:l})=>{var I,$,F;const{fromNode:c,handleId:d,toX:h,toY:p,connectionMode:f}=ct(b.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),Dt),m=(I=c==null?void 0:c[St])==null?void 0:I.handleBounds;let y=m==null?void 0:m[t];if(f===Ka.Loose&&(y=y||(m==null?void 0:m[t==="source"?"target":"source"])),!c||!y)return null;const v=d?y.find(O=>O.id===d):y[0],j=v?v.x+v.width/2:(c.width??0)/2,_=v?v.y+v.height/2:c.height??0,S=((($=c.positionAbsolute)==null?void 0:$.x)??0)+j,x=(((F=c.positionAbsolute)==null?void 0:F.y)??0)+_,N=v==null?void 0:v.position,E=N?v3[N]:null;if(!N||!E)return null;if(a)return fe.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:c,fromHandle:v,fromX:S,fromY:x,toX:h,toY:p,fromPosition:N,toPosition:E,connectionStatus:l});let C="";const R={sourceX:S,sourceY:x,sourcePosition:N,targetX:h,targetY:p,targetPosition:E};return s===Hs.Bezier?[C]=dT(R):s===Hs.Step?[C]=gv({...R,borderRadius:0}):s===Hs.SmoothStep?[C]=gv(R):s===Hs.SimpleBezier?[C]=uT(R):C=`M${S},${x} ${h},${p}`,fe.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};FT.displayName="ConnectionLine";const x3=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function b3({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:l,nodesConnectable:c,width:d,height:h,connectionStatus:p}=ct(x3,Dt);return!(a&&l&&d&&c)?null:fe.createElement("svg",{style:e,width:d,height:h,className:"react-flow__edges react-flow__connectionline react-flow__container"},fe.createElement("g",{className:Kt(["react-flow__connection",p])},fe.createElement(FT,{nodeId:a,handleType:l,style:t,type:n,CustomComponent:s,connectionStatus:p})))}function jk(e,t){return b.useRef(null),Rt(),b.useMemo(()=>t(e),[e])}const BT=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:l,onNodeClick:c,onEdgeClick:d,onNodeDoubleClick:h,onEdgeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,onSelectionContextMenu:j,onSelectionStart:_,onSelectionEnd:S,connectionLineType:x,connectionLineStyle:N,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:R,selectionOnDrag:I,selectionMode:$,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:M,deleteKeyCode:L,onlyRenderVisibleElements:H,elementsSelectable:B,selectNodesOnDrag:A,defaultViewport:Q,translateExtent:K,minZoom:ee,maxZoom:Z,preventScrolling:D,defaultMarkerColor:Y,zoomOnScroll:P,zoomOnPinch:G,panOnScroll:de,panOnScrollSpeed:W,panOnScrollMode:U,zoomOnDoubleClick:J,panOnDrag:V,onPaneClick:ie,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:ce,onEdgeContextMenu:xe,onEdgeMouseEnter:ye,onEdgeMouseMove:ze,onEdgeMouseLeave:ke,onReconnect:je,onReconnectStart:Ye,onReconnectEnd:it,reconnectRadius:Ne,noDragClassName:He,noWheelClassName:Xe,noPanClassName:he,elevateEdgesOnSelect:ge,disableKeyboardA11y:Se,nodeOrigin:Fe,nodeExtent:et,rfId:xt})=>{const ht=jk(e,KP),ne=jk(t,n3);return w3(l),fe.createElement(VP,{onPaneClick:ie,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:Ie,onPaneContextMenu:ce,onPaneScroll:Le,deleteKeyCode:L,selectionKeyCode:R,selectionOnDrag:I,selectionMode:$,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:M,elementsSelectable:B,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:P,zoomOnPinch:G,zoomOnDoubleClick:J,panOnScroll:de,panOnScrollSpeed:W,panOnScrollMode:U,panOnDrag:V,defaultViewport:Q,translateExtent:K,minZoom:ee,maxZoom:Z,onSelectionContextMenu:j,preventScrolling:D,noDragClassName:He,noWheelClassName:Xe,noPanClassName:he,disableKeyboardA11y:Se},fe.createElement(y3,null,fe.createElement(m3,{edgeTypes:ne,onEdgeClick:d,onEdgeDoubleClick:p,onlyRenderVisibleElements:H,onEdgeContextMenu:xe,onEdgeMouseEnter:ye,onEdgeMouseMove:ze,onEdgeMouseLeave:ke,onReconnect:je,onReconnectStart:Ye,onReconnectEnd:it,reconnectRadius:Ne,defaultMarkerColor:Y,noPanClassName:he,elevateEdgesOnSelect:!!ge,disableKeyboardA11y:Se,rfId:xt},fe.createElement(b3,{style:N,type:x,component:E,containerStyle:C})),fe.createElement("div",{className:"react-flow__edgelabel-renderer"}),fe.createElement(ZP,{nodeTypes:ht,onNodeClick:c,onNodeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,selectNodesOnDrag:A,onlyRenderVisibleElements:H,noPanClassName:he,noDragClassName:He,disableKeyboardA11y:Se,nodeOrigin:Fe,nodeExtent:et,rfId:xt})))};BT.displayName="GraphView";var k3=b.memo(BT);const bv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Bs={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:bv,nodeExtent:bv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Ka.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:KO,isValidConnection:void 0},_3=()=>uM((e,t)=>({...Bs,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:l}=t();e({nodeInternals:Ef(n,s,a,l)})},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",l=typeof s<"u",c=a?Ef(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:l?s:[],hasDefaultNodes:a,hasDefaultEdges:l})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:a,fitViewOnInit:l,fitViewOnInitDone:c,fitViewOnInitOptions:d,domNode:h,nodeOrigin:p}=t(),f=h==null?void 0:h.querySelector(".react-flow__viewport");if(!f)return;const m=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(m.transform),v=n.reduce((_,S)=>{const x=a.get(S.id);if(x!=null&&x.hidden)a.set(x.id,{...x,[St]:{...x[St],handleBounds:void 0}});else if(x){const N=Xv(S.nodeElement);!!(N.width&&N.height&&(x.width!==N.width||x.height!==N.height||S.forceUpdate))&&(a.set(x.id,{...x,[St]:{...x[St],handleBounds:{source:vk(".source",S.nodeElement,y,p),target:vk(".target",S.nodeElement,y,p)}},...N}),_.push({id:x.id,type:"dimensions",dimensions:N}))}return _},[]);TT(a,p);const j=c||l&&!c&&AT(t,{initial:!0,...d});e({nodeInternals:new Map(a),fitViewOnInitDone:j}),(v==null?void 0:v.length)>0&&(s==null||s(v))},updateNodePositions:(n,s=!0,a=!1)=>{const{triggerNodeChanges:l}=t(),c=n.map(d=>{const h={id:d.id,type:"position",dragging:a};return s&&(h.positionAbsolute=d.positionAbsolute,h.position=d.position),h});l(c)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:l,nodeOrigin:c,getNodes:d,elevateNodesOnSelect:h}=t();if(n!=null&&n.length){if(l){const p=DP(n,d()),f=Ef(p,a,c,h);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:l}=t();let c,d=null;s?c=n.map(h=>Ws(h,!0)):(c=Vo(l(),n),d=Vo(a,[])),Su({changedNodes:c,changedEdges:d,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:l}=t();let c,d=null;s?c=n.map(h=>Ws(h,!0)):(c=Vo(a,n),d=Vo(l(),[])),Su({changedNodes:d,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:l}=t(),c=n||l(),d=s||a,h=c.map(f=>(f.selected=!1,Ws(f.id,!1))),p=d.map(f=>Ws(f.id,!1));Su({changedNodes:h,changedEdges:p,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(),l=s().filter(d=>d.selected).map(d=>Ws(d.id,!1)),c=n.filter(d=>d.selected).map(d=>Ws(d.id,!1));Su({changedNodes:l,changedEdges:c,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Qv(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:l,d3Zoom:c,d3Selection:d,translateExtent:h}=t();if(!c||!d||!n.x&&!n.y)return!1;const p=ss.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[a,l]],m=c==null?void 0:c.constrain()(p,f,h);return c.transform(d,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:Bs.connectionNodeId,connectionHandleId:Bs.connectionHandleId,connectionHandleType:Bs.connectionHandleType,connectionStatus:Bs.connectionStatus,connectionStartHandle:Bs.connectionStartHandle,connectionEndHandle:Bs.connectionEndHandle}),reset:()=>e({...Bs})}),Object.is),ax=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=_3()),fe.createElement(zO,{value:t.current},e)};ax.displayName="ReactFlowProvider";const zT=({children:e})=>b.useContext(wd)?fe.createElement(fe.Fragment,null,e):fe.createElement(ax,null,e);zT.displayName="ReactFlowWrapper";const N3={input:kT,default:vv,output:NT,group:rx},S3={default:nd,straight:ex,step:Jv,smoothstep:vd,simplebezier:Zv},j3=[0,0],E3=[15,15],C3={x:0,y:0,zoom:1},T3={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},UT=b.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:l=N3,edgeTypes:c=S3,onNodeClick:d,onEdgeClick:h,onInit:p,onMove:f,onMoveStart:m,onMoveEnd:y,onConnect:v,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:x,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,onNodeDragStart:$,onNodeDrag:F,onNodeDragStop:O,onNodesDelete:M,onEdgesDelete:L,onSelectionChange:H,onSelectionDragStart:B,onSelectionDrag:A,onSelectionDragStop:Q,onSelectionContextMenu:K,onSelectionStart:ee,onSelectionEnd:Z,connectionMode:D=Ka.Strict,connectionLineType:Y=Hs.Bezier,connectionLineStyle:P,connectionLineComponent:G,connectionLineContainerStyle:de,deleteKeyCode:W="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:J=!1,selectionMode:V=Pl.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:pe=ed()?"Meta":"Control",zoomActivationKeyCode:me=ed()?"Meta":"Control",snapToGrid:Ie=!1,snapGrid:Le=E3,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:xe=!0,nodesDraggable:ye,nodesConnectable:ze,nodesFocusable:ke,nodeOrigin:je=j3,edgesFocusable:Ye,edgesUpdatable:it,elementsSelectable:Ne,defaultViewport:He=C3,minZoom:Xe=.5,maxZoom:he=2,translateExtent:ge=bv,preventScrolling:Se=!0,nodeExtent:Fe,defaultMarkerColor:et="#b1b1b7",zoomOnScroll:xt=!0,zoomOnPinch:ht=!0,panOnScroll:ne=!1,panOnScrollSpeed:De=.5,panOnScrollMode:Oe=Ha.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ce=!0,onPaneClick:lt,onPaneMouseEnter:ut,onPaneMouseMove:Re,onPaneMouseLeave:mt,onPaneScroll:ft,onPaneContextMenu:bt,children:Xn,onEdgeContextMenu:Tn,onEdgeDoubleClick:ln,onEdgeMouseEnter:eo,onEdgeMouseMove:us,onEdgeMouseLeave:Or,onEdgeUpdate:Qn,onEdgeUpdateStart:to,onEdgeUpdateEnd:Pr,onReconnect:Qs,onReconnectStart:Lr,onReconnectEnd:An,reconnectRadius:Dr=10,edgeUpdaterRadius:ds=10,onNodesChange:qt,onEdgesChange:wr,noDragClassName:Zs="nodrag",noWheelClassName:wi="nowheel",noPanClassName:no="nopan",fitView:Rn=!1,fitViewOptions:Js,connectOnClick:ea=!0,attributionPosition:ta,proOptions:na,defaultEdgeOptions:ra,elevateNodesOnSelect:sa=!0,elevateEdgesOnSelect:ro=!1,disableKeyboardA11y:aa=!1,autoPanOnConnect:vi=!0,autoPanOnNodeDrag:dt=!0,connectionRadius:so=20,isValidConnection:oa,onError:qr,style:Fr,id:Br,nodeDragThreshold:ia,...zr},It)=>{const la=Br||"1";return fe.createElement("div",{...zr,style:{...Fr,...T3},ref:It,className:Kt(["react-flow",a]),"data-testid":"rf__wrapper",id:Br},fe.createElement(zT,null,fe.createElement(k3,{onInit:p,onMove:f,onMoveStart:m,onMoveEnd:y,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,nodeTypes:l,edgeTypes:c,connectionLineType:Y,connectionLineStyle:P,connectionLineComponent:G,connectionLineContainerStyle:de,selectionKeyCode:U,selectionOnDrag:J,selectionMode:V,deleteKeyCode:W,multiSelectionKeyCode:pe,panActivationKeyCode:ie,zoomActivationKeyCode:me,onlyRenderVisibleElements:ce,selectNodesOnDrag:xe,defaultViewport:He,translateExtent:ge,minZoom:Xe,maxZoom:he,preventScrolling:Se,zoomOnScroll:xt,zoomOnPinch:ht,zoomOnDoubleClick:Te,panOnScroll:ne,panOnScrollSpeed:De,panOnScrollMode:Oe,panOnDrag:Ce,onPaneClick:lt,onPaneMouseEnter:ut,onPaneMouseMove:Re,onPaneMouseLeave:mt,onPaneScroll:ft,onPaneContextMenu:bt,onSelectionContextMenu:K,onSelectionStart:ee,onSelectionEnd:Z,onEdgeContextMenu:Tn,onEdgeDoubleClick:ln,onEdgeMouseEnter:eo,onEdgeMouseMove:us,onEdgeMouseLeave:Or,onReconnect:Qs??Qn,onReconnectStart:Lr??to,onReconnectEnd:An??Pr,reconnectRadius:Dr??ds,defaultMarkerColor:et,noDragClassName:Zs,noWheelClassName:wi,noPanClassName:no,elevateEdgesOnSelect:ro,rfId:la,disableKeyboardA11y:aa,nodeOrigin:je,nodeExtent:Fe}),fe.createElement(wP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:v,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:x,nodesDraggable:ye,nodesConnectable:ze,nodesFocusable:ke,edgesFocusable:Ye,edgesUpdatable:it,elementsSelectable:Ne,elevateNodesOnSelect:sa,minZoom:Xe,maxZoom:he,nodeExtent:Fe,onNodesChange:qt,onEdgesChange:wr,snapToGrid:Ie,snapGrid:Le,connectionMode:D,translateExtent:ge,connectOnClick:ea,defaultEdgeOptions:ra,fitView:Rn,fitViewOptions:Js,onNodesDelete:M,onEdgesDelete:L,onNodeDragStart:$,onNodeDrag:F,onNodeDragStop:O,onSelectionDrag:A,onSelectionDragStart:B,onSelectionDragStop:Q,noPanClassName:no,nodeOrigin:je,rfId:la,autoPanOnConnect:vi,autoPanOnNodeDrag:dt,onError:qr,connectionRadius:so,isValidConnection:oa,nodeDragThreshold:ia}),fe.createElement(gP,{onSelectionChange:H}),Xn,fe.createElement(WO,{proOptions:na,position:ta}),fe.createElement(_P,{rfId:la,disableKeyboardA11y:aa})))});UT.displayName="ReactFlow";const A3=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function WT(){return ct(A3,Dt)}const HT=({id:e,x:t,y:n,width:s,height:a,style:l,color:c,strokeColor:d,strokeWidth:h,className:p,borderRadius:f,shapeRendering:m,onClick:y,selected:v})=>{const{background:j,backgroundColor:_}=l||{},S=c||j||_;return fe.createElement("rect",{className:Kt(["react-flow__minimap-node",{selected:v},p]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:S,stroke:d,strokeWidth:h,shapeRendering:m,onClick:y?x=>y(x,e):void 0})};HT.displayName="MiniMapNode";var R3=b.memo(HT);const M3=e=>e.nodeOrigin,I3=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Rf=e=>e instanceof Function?e:()=>e;function $3({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:l=R3,onClick:c}){const d=ct(I3,Dt),h=ct(M3),p=Rf(t),f=Rf(e),m=Rf(n),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return fe.createElement(fe.Fragment,null,d.map(v=>{const{x:j,y:_}=Va(v,h).positionAbsolute;return fe.createElement(l,{key:v.id,x:j,y:_,width:v.width,height:v.height,style:v.style,selected:v.selected,className:m(v),color:p(v),borderRadius:s,strokeColor:f(v),strokeWidth:a,shapeRendering:y,onClick:c,id:v.id})}))}var O3=b.memo($3);const P3=200,L3=150,D3=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?VO(xd(t,e.nodeOrigin),n):n,rfId:e.rfId}},q3="react-flow__minimap-desc";function GT({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:c=2,nodeComponent:d,maskColor:h="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:f=1,position:m="bottom-right",onClick:y,onNodeClick:v,pannable:j=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:x=!1,zoomStep:N=10,offsetScale:E=5}){const C=Rt(),R=b.useRef(null),{boundingRect:I,viewBB:$,rfId:F}=ct(D3,Dt),O=(e==null?void 0:e.width)??P3,M=(e==null?void 0:e.height)??L3,L=I.width/O,H=I.height/M,B=Math.max(L,H),A=B*O,Q=B*M,K=E*B,ee=I.x-(A-I.width)/2-K,Z=I.y-(Q-I.height)/2-K,D=A+K*2,Y=Q+K*2,P=`${q3}-${F}`,G=b.useRef(0);G.current=B,b.useEffect(()=>{if(R.current){const U=Wn(R.current),J=pe=>{const{transform:me,d3Selection:Ie,d3Zoom:Le}=C.getState();if(pe.sourceEvent.type!=="wheel"||!Ie||!Le)return;const ce=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*N,xe=me[2]*Math.pow(2,ce);Le.scaleTo(Ie,xe)},V=pe=>{const{transform:me,d3Selection:Ie,d3Zoom:Le,translateExtent:ce,width:xe,height:ye}=C.getState();if(pe.sourceEvent.type!=="mousemove"||!Ie||!Le)return;const ze=G.current*Math.max(1,me[2])*(x?-1:1),ke={x:me[0]-pe.sourceEvent.movementX*ze,y:me[1]-pe.sourceEvent.movementY*ze},je=[[0,0],[xe,ye]],Ye=ss.translate(ke.x,ke.y).scale(me[2]),it=Le.constrain()(Ye,je,ce);Le.transform(Ie,it)},ie=eT().on("zoom",j?V:null).on("zoom.wheel",_?J:null);return U.call(ie),()=>{U.on("zoom",null)}}},[j,_,x,N]);const de=y?U=>{const J=lr(U);y(U,{x:J[0],y:J[1]})}:void 0,W=v?(U,J)=>{const V=C.getState().nodeInternals.get(J);v(U,V)}:void 0;return fe.createElement(Kv,{position:m,style:e,className:Kt(["react-flow__minimap",t]),"data-testid":"rf__minimap"},fe.createElement("svg",{width:O,height:M,viewBox:`${ee} ${Z} ${D} ${Y}`,role:"img","aria-labelledby":P,ref:R,onClick:de},S&&fe.createElement("title",{id:P},S),fe.createElement(O3,{onClick:W,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:d}),fe.createElement("path",{className:"react-flow__minimap-mask",d:`M${ee-K},${Z-K}h${D+K*2}v${Y+K*2}h${-D-K*2}z
57
- M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:f,pointerEvents:"none"})))}GT.displayName="MiniMap";var F3=b.memo(GT);function B3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},fe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function z3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},fe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function U3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},fe.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function W3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function H3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Rr=({children:e,className:t,...n})=>fe.createElement("button",{type:"button",className:Kt(["react-flow__controls-button",t]),...n},e);Rr.displayName="ControlButton";const G3=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),VT=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:l,onZoomOut:c,onFitView:d,onInteractiveChange:h,className:p,children:f,position:m="bottom-left"})=>{const y=Rt(),[v,j]=b.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:x}=ct(G3,Dt),{zoomIn:N,zoomOut:E,fitView:C}=Vl();if(b.useEffect(()=>{j(!0)},[]),!v)return null;const R=()=>{N(),l==null||l()},I=()=>{E(),c==null||c()},$=()=>{C(a),d==null||d()},F=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return fe.createElement(Kv,{className:Kt(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},t&&fe.createElement(fe.Fragment,null,fe.createElement(Rr,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},fe.createElement(B3,null)),fe.createElement(Rr,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},fe.createElement(z3,null))),n&&fe.createElement(Rr,{className:"react-flow__controls-fitview",onClick:$,title:"fit view","aria-label":"fit view"},fe.createElement(U3,null)),s&&fe.createElement(Rr,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},_?fe.createElement(H3,null):fe.createElement(W3,null)),f)};VT.displayName="Controls";var V3=b.memo(VT),fr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(fr||(fr={}));function Y3({color:e,dimensions:t,lineWidth:n}){return fe.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function K3({color:e,radius:t}){return fe.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const X3={[fr.Dots]:"#91919a",[fr.Lines]:"#eee",[fr.Cross]:"#e2e2e2"},Q3={[fr.Dots]:1,[fr.Lines]:1,[fr.Cross]:6},Z3=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function YT({id:e,variant:t=fr.Dots,gap:n=20,size:s,lineWidth:a=1,offset:l=2,color:c,style:d,className:h}){const p=b.useRef(null),{transform:f,patternId:m}=ct(Z3,Dt),y=c||X3[t],v=s||Q3[t],j=t===fr.Dots,_=t===fr.Cross,S=Array.isArray(n)?n:[n,n],x=[S[0]*f[2]||1,S[1]*f[2]||1],N=v*f[2],E=_?[N,N]:x,C=j?[N/l,N/l]:[E[0]/l,E[1]/l];return fe.createElement("svg",{className:Kt(["react-flow__background",h]),style:{...d,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},fe.createElement("pattern",{id:m+e,x:f[0]%x[0],y:f[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},j?fe.createElement(K3,{color:y,radius:N/l}):fe.createElement(Y3,{dimensions:E,color:y,lineWidth:a})),fe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}YT.displayName="Background";var J3=b.memo(YT);const e4=["us-gov","global","apac","us","eu","jp","au"],t4=new RegExp(`^(?:(?:${e4.join("|")})\\.)?anthropic\\.`,"i");function Yl(e){return e.replace(t4,"")}const n4=["command","cmd","file_path","path","url","pattern","notebook_path"],Ek=120,Mf=e=>e.length>Ek?`${e.slice(0,Ek-1)}…`:e;function r4(e){if(typeof e=="string")return e.trim()?Mf(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of n4){const s=t[n];if(typeof s=="string"&&s.trim())return Mf(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return Mf(a)}}return null}function KT(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function ox(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 s4(e){const t=ox(e),n={inputTokens:Number(e.input_tokens??0),outputTokens:Number(e.output_tokens??0),cacheReadTokens:Number(e.cache_read_input_tokens??e.cached_input_tokens??0),cacheCreateTokens:Number(e.cache_creation_input_tokens??e.cache_write_input_tokens??0),cacheCreate1hTokens:t.cacheCreate1hTokens,cacheCreate5mTokens:t.cacheCreate5mTokens};return typeof e.reasoning_output_tokens=="number"&&(n.reasoningOutputTokens=Number(e.reasoning_output_tokens)),n}function a4(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||(t[n]=s4(s));return Object.keys(t).length?t:void 0}function XT(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),...ox(n)};for(const s of Object.values(n)){const a=XT(s,t+1);if(a)return a}return null}const o4=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function QT(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&o4.test(Yl(n.model)))return n.model;for(const s of Object.values(n)){const a=QT(s,t+1);if(a)return a}return null}function kv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function Vs(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t[t.length-1]}function Ck(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function Kl(e,t){return`${e}::${t}`}function rd(e){return e.agent_type??e.subagent_type??"subagent"}function Cl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Yo(e,t,n,s){const a=t;let l=e.agents.get(a);return l||(l={id:a,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:KT()},e.agents.set(a,l),l)}function ZT(e,t,n,s){const a=Kl(t,n),l=e.agents.get(a);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=Vs(s.cwd));const c=rd(s);return c&&(l.label==="subagent"||!l.label)&&(l.label=c),l}function i4(e,t,n){const s=t.session_id??"unknown",a=Cl(t);if(a){const h=ZT(e,s,a,t);if(h)return h}const l=e.activeSubagentStack.get(s),c=l&&l.length>0?l[l.length-1]:null;if(c){const h=e.agents.get(Kl(s,c));if(h)return!h.cwd&&t.cwd&&(h.cwd=t.cwd,h.cwdBasename=Vs(t.cwd)),h}const d=Yo(e,s,n,t.hook_event_name!=="SessionStart");return!d.cwd&&t.cwd&&(d.cwd=t.cwd,d.cwdBasename=Vs(t.cwd)),d.label==="session"&&t.cwd&&(d.label=Vs(t.cwd)??"session"),d}function l4(e,t,n,s,a){const l=Kl(t,n),c=Yo(e,t,a,!0);let d=e.agents.get(l);if(d){!d.cwd&&s.cwd&&(d.cwd=s.cwd,d.cwdBasename=Vs(s.cwd));const h=rd(s);return h&&(d.label==="subagent"||!d.label)&&(d.label=h),d}return d={id:l,sessionId:t,label:rd(s),kind:"subagent",parentId:c.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:Vs(s.cwd),toolCount:0,childCount:0,usage:KT()},e.agents.set(l,d),c.childCount+=1,d}function c4(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function u4(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)}}function Eu(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const Tk=200,d4=25;function h4(e,t){const n=t.tools;if(n.length>Tk){const s=n.splice(0,n.length-Tk);for(const a of s)e.toolIndex.get(a.id)===a&&(e.toolIndex.delete(a.id),e.toolOwner.delete(a.id))}for(let s=n.length-d4-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function f4(e,t,n){const s=e.toolIndex.get(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}const Ak=2e3;function p4(e,t,n){for(let s=e.prompts.length-1;s>=0;s--){const a=e.prompts[s];if(a.at<t-Ak)return!1;if(a.text===n&&a.at<=t+Ak)return!0}return!1}function JT(e,t){for(const n of t.tools)e.toolIndex.get(n.id)===n&&e.toolIndex.delete(n.id),e.toolOwner.get(n.id)===t.id&&e.toolOwner.delete(n.id)}function Xl(e,t){return t&&(e.revision+=1),t}function m4(e,t,n,s){if(e.agents.size<=n)return!1;const a=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>s,l=[],c=new Map;for(const[p,f]of e.agents){if(f.parentId!=null){const m=c.get(f.parentId);m?m.push(p):c.set(f.parentId,[p])}a(f)&&l.push({id:p,endedAt:f.endedAt})}if(l.length===0)return!1;l.sort((p,f)=>p.endedAt-f.endedAt);let d=0;const h=p=>{const f=e.agents.get(p);f&&(JT(e,f),e.agents.delete(p),d++)};for(const p of l){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const f=(c.get(p.id)??[]).map(m=>e.agents.get(m)).filter(m=>m!=null);if(!f.some(m=>!a(m))){for(const m of f)h(m.id);h(p.id)}}return Xl(e,d>0)}function g4(e,t,n,s){const a=new Map;for(const[p,f]of e.agents){let m=a.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1,closed:!1},a.set(f.sessionId,m)),m.ids.push(p),f.kind==="root"&&f.closedAt!=null&&(m.closed=!0),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...a.values()].filter(p=>!p.live&&p.endedAt>0&&t-p.endedAt>s).sort((p,f)=>p.closed===f.closed?p.endedAt-f.endedAt:p.closed?-1:1);let d=[...a.values()].filter(p=>!p.live).length-n;if(d<=0)return!1;let h=!1;for(const p of l){if(d<=0)break;for(const f of p.ids){const m=e.agents.get(f);m&&JT(e,m),e.agents.delete(f)}d--,h=!0}return Xl(e,h)}function y4(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&&e.toolIndex.has(a)}function w4(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 Xl(e,t)}function v4(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.provider==="codex")continue;const l=e.agents.get(a.sessionId),c=(l==null?void 0:l.lastEventAt)??(l==null?void 0:l.startedAt);for(const d of a.tools){const h=Math.max(d.startedAt,c??d.startedAt);d.endedAt==null&&t-h>n&&(d.endedAt=h,d.ok=!1,d.errorPreview=d.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"session ended before this call returned",e.toolIndex.delete(d.id),e.toolOwner.delete(d.id),s=!0)}}return Xl(e,s)}const Rk=90*6e4;function x4(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.kind!=="root")continue;const l=a.lastEventAt??a.startedAt;if(!(t-l<=n)){a.waiting&&(a.waiting=null,s=!0),a.closedAt==null&&(a.closedAt=l),a.state==="active"&&(a.state="done",a.endedAt=l,a.reaped=!0,s=!0);for(const c of e.agents.values())c.sessionId!==a.sessionId||c.kind==="root"||c.state!=="active"||(c.state="done",c.endedAt=l,s=!0);e.activeSubagentStack.delete(a.sessionId)}}return Xl(e,s)}function b4(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const k4=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed"]);function _4(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 N4=3e4;function S4(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>N4)&&!(e.startedAt>t))return{name:e.name,preview:r4(e.input)??""}}function j4(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const l=_4(e,t),c={kind:n,message:s,since:a};l!=null&&l.explicitSubagentId&&(c.subagentId=l.explicitSubagentId);const d=S4(l,a);return d&&(c.tool=d),c}function E4(e,t,n){if(e.kind==="idle")return!0;const s=Cl(t);return s==null?!0:e.subagentId!=null&&Kl(n,s)===e.subagentId}function Mk(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,l=s.hook_event_name??"Unknown";if(l==="__clear")return{...kv(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const c=s.session_id??"unknown";if(!k4.has(l)){const f=e.agents.get(c);f!=null&&f.waiting&&E4(f.waiting,s,c)&&(f.waiting=null)}const d=e.agents.get(c);if(d&&a>(d.lastEventAt??0)&&(d.lastEventAt=a,d.reaped&&(d.reaped=!1,d.state="active",d.endedAt=void 0,d.closedAt=void 0)),typeof s.model_context_window=="number"&&s.model_context_window>0){const f=e.agents.get(c);f&&(f.contextWindow=s.model_context_window)}if(typeof s.approval_policy=="string"&&s.approval_policy){const f=e.agents.get(c);f&&(f.approvalPolicy=s.approval_policy)}if(typeof s.context_tokens=="number"&&s.context_tokens>=0){const f=e.agents.get(c);f&&(f.context={...f.context??Ck(),currentContextTokens:s.context_tokens})}if(l==="ModelObserved"){const f=typeof s.model=="string"?s.model:null;if(f){const y=e.agents.get(c);y&&(y.model=f)}const m=s.subagentModels;if(m&&typeof m=="object")for(const[y,v]of Object.entries(m)){if(typeof v!="string")continue;const j=`${c}::${y}`,_=e.agents.get(j);_&&(_.model=v)}return e}if(l==="ContextObserved"){const f=s.context??null;if(f){const m=e.agents.get(c);if(m){const y=m.context??Ck(),v=(_,S)=>typeof f[_]=="number"?f[_]:S,j=Array.isArray(f.memoryFiles)?f.memoryFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:null;m.context={msgsUser:v("msgsUser",y.msgsUser),msgsAssistant:v("msgsAssistant",y.msgsAssistant),toolUses:v("toolUses",y.toolUses),toolResults:v("toolResults",y.toolResults),systemReminders:v("systemReminders",y.systemReminders),currentContextTokens:v("currentContextTokens",y.currentContextTokens),memoryFiles:j??y.memoryFiles}}}return e}if(l==="SessionNamed"){const f=e.agents.get(c);if(f){const m=typeof s.sessionName=="string"?s.sessionName.trim():"",y=typeof s.sessionTitle=="string"?s.sessionTitle.trim():"";m&&(f.sessionName=m),y&&(f.sessionTitle=y);const v=f.sessionName??"";f.sessionTitle&&v&&f.sessionTitle.toLowerCase()===v.toLowerCase()&&(f.sessionTitle=void 0)}return e}if(l==="OutputObserved"){const f=s.kind==="thinking"||s.kind==="text"||s.kind==="tool_use"?s.kind:null,m=typeof s.at=="number"&&Number.isFinite(s.at)?s.at:a;if(!f)return e;const y=e.agents.get(c);if(!y||y.lastOutputAt!=null&&m<=y.lastOutputAt)return e;if(y.lastOutputAt=m,f!=="tool_use"){const v=(y.outputs??[]).filter(j=>m-j<C4);v.push(m),y.outputs=v.length>Ik?v.slice(-Ik):v}return e.revision+=1,e}if(l==="UsageObserved"){const f=s.usage??null;if(f){const m=e.agents.get(c);if(m){m.usage.inputTokens=Number(f.input_tokens??0),m.usage.outputTokens=Number(f.output_tokens??0),m.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),m.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??f.cache_write_input_tokens??0);const y=ox(f);m.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,m.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof f.reasoning_output_tokens=="number"&&(m.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)),m.usageByModel=a4(s.usageByModel)}}return e}const h=i4(e,s,a);h.provider||(h.provider=s.provider==="codex"?"codex":"claude");const p=QT(s);switch(p&&(h.model=p),l){case"SessionStart":{const f=Yo(e,c,a,!1);f.synthetic=!1,f.state="active",f.closedAt=void 0,f.startedAt=f.startedAt||a,!f.cwd&&s.cwd&&(f.cwd=s.cwd,f.cwdBasename=Vs(s.cwd)),f.label==="session"&&s.cwd&&(f.label=Vs(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===c&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<a&&(y.exitAt=a);const f=Yo(e,c,a,!1);f.state="active",f.endedAt=void 0,f.closedAt=void 0,f.exitAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&!p4(f,a,m)&&(f.prompts.push({at:a,text:m}),f.firstPrompt||(f.firstPrompt=Eu(m,120)));break}case"PreToolUse":{const f=s.tool_use_id?f4(e,h,s.tool_use_id):null;if(f){s.tool_name&&f.name==="?"&&(f.name=s.tool_name),f.endedAt==null&&!f.trimmed&&s.tool_input!==void 0&&(f.input=s.tool_input,f.inputPreview=Eu(s.tool_input));break}const m=s.tool_use_id??`${h.id}:${h.toolCount}`,y=Cl(s),v={id:m,name:s.tool_name??"?",input:s.tool_input,inputPreview:Eu(s.tool_input),agentId:h.id,explicitSubagentId:y?Kl(c,y):void 0,startedAt:a};h.tools.push(v),h.toolCount+=1,h.state="active",e.toolIndex.set(m,v),e.toolOwner.set(m,h.id),h4(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const f=s.tool_use_id;if(!f)break;let m=e.toolIndex.get(f),y=!1;if(!m)for(const j of e.agents.values()){const _=j.tools.find(S=>S.id===f);if(_){m=_,y=!0;break}}if(!m||m.outcomeApplied)break;m.outcomeApplied=!0,m.outcomeGap=void 0,m.endedAt=a,m.ok=l==="PostToolUse",m.trimmed||(m.response=s.tool_response),l==="PostToolUseFailure"?m.errorPreview=Eu(s.tool_response):y&&(m.errorPreview=void 0);const v=XT(s.tool_response);v&&(m.usage=v),e.toolIndex.delete(f),e.toolOwner.delete(f);break}case"SubagentStart":{const f=Cl(s);if(!f)break;const m=l4(e,c,f,s,a);m.state="active",m.startedAt=m.startedAt||a,m.exitAt=void 0,m.endedAt=void 0;const y=rd(s);y&&(m.label=y),c4(e,c,f);break}case"SubagentStop":{const f=Cl(s);if(!f)break;const m=ZT(e,c,f,s);if(!m)break;m.state="done",m.endedAt=a,u4(e,c,f);break}case"Stop":case"SessionEnd":{const f=Yo(e,c,a,!1);f.state="done",f.endedAt=a;for(const m of f.provider==="codex"?[]:f.tools)m.endedAt==null&&(m.endedAt=a,m.ok=!1,m.errorPreview=m.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"the turn ended before this call returned",e.toolIndex.delete(m.id),e.toolOwner.delete(m.id));l==="SessionEnd"&&(f.closedAt=a),e.activeSubagentStack.delete(c);break}case"Notification":{const f=b4(s.notification_type);if(!f)break;const m=Yo(e,c,a,!1),y=typeof s.message=="string"?s.message:"",v=m.waiting;m.waiting=v&&v.kind===f&&v.message===y?{...v,since:Math.min(v.since,a)}:j4(e,c,f,y,a);break}}return e}const C4=6e4,Ik=64;function ix(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const T4={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},A4=[{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\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:T4},{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[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]deep[-_]research/i,rates:{input:10,output:40,cacheRead:2.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini[-_]deep[-_]research/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}];function R4(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function di(e,t=Date.now()){if(!e)return null;const n=Yl(e);for(const s of A4)if(s.match.test(n))return typeof s.rates=="function"?s.rates(t):s.rates;return null}function e2(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),l=s+a,c=t.cacheWrite1h??t.cacheWrite;return{tokens5m:l,tokens1h:n,usd5m:l*t.cacheWrite/1e6,usd1h:n*c/1e6}}function t2(e,t,n=Date.now()){if(!R4(t))return e.inputTokens;const s=di(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 lx(e,t,n=Date.now()){const s=di(t,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const a=t2(e,t,n)*s.input/1e6,l=e.outputTokens*s.output/1e6,c=e.cacheReadTokens*s.cacheRead/1e6,d=e2(e,s),h=d.usd5m+d.usd1h;return{input:a,output:l,cacheRead:c,cacheWrite:h,total:a+l+c+h}}const $k=2e5,M4=1e6,I4=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],$4=[{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function O4(e){if(!e)return $k;const t=Yl(e);for(const n of I4)if(n.test(t))return M4;for(const n of $4)if(n.match.test(t))return n.window;return $k}function n2(e,t){return typeof e=="number"&&e>0?e:O4(t)}const Go="not priced";function tt(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=(e*100).toFixed(e<.1?1:0);if(Number(t)<100)return`${t}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function cx(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${tt(s)}/min`:`${tt(n*3600)}/hr`}function P4(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),n}function L4(e,t){let n=0,s=0,a=0,l=0,c=0,d=0;for(const m of t)n+=m.inputTokens,s+=m.outputTokens,a+=m.cacheReadTokens,l+=m.cacheCreateTokens,c+=m.cacheCreate1hTokens??0,d+=m.cacheCreate5mTokens??0;const h=(m,y)=>Math.max(0,m-y),p={inputTokens:h(e.inputTokens,n),outputTokens:h(e.outputTokens,s),cacheReadTokens:h(e.cacheReadTokens,a),cacheCreateTokens:h(e.cacheCreateTokens,l)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(p.cacheCreate1hTokens=h(e.cacheCreate1hTokens??0,c),p.cacheCreate5mTokens=h(e.cacheCreate5mTokens??0,d)),p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreateTokens>0?p:null}function Ql(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const s=n.map(l=>({model:l,usage:t[l]})),a=L4(e.usage,s.map(l=>l.usage));if(a){const l=s.findIndex(c=>c.model===e.model);l>=0?s[l]={model:s[l].model,usage:P4(s[l].usage,a)}:s.push({model:e.model,usage:a})}return s}function En(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Ql(e)){const a=lx(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 _v(e,t=Date.now()){let n=0;for(const s of Ql(e))di(s.model,t)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function r2(e){const t=[];for(const n of Ql(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 s2(e){return r2(e).filter(t=>t!==e.model)}const D4=new Set(["untrusted","on-request","on-failure"]);function q4(e){return typeof e!="string"||!e?null:D4.has(e)?!0:e==="never"?!1:null}function F4(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=q4(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."}
56
+ */var Pb;function tM(){if(Pb)return xf;Pb=1;var e=Wl(),t=eM();function n(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,l=e.useRef,c=e.useEffect,d=e.useMemo,h=e.useDebugValue;return xf.useSyncExternalStoreWithSelector=function(p,f,m,y,v){var j=l(null);if(j.current===null){var _={hasValue:!1,value:null};j.current=_}else _=j.current;j=d(function(){function x(I){if(!N){if(N=!0,E=I,I=y(I),v!==void 0&&_.hasValue){var $=_.value;if(v($,I))return C=$}return C=I}if($=C,s(E,I))return $;var F=y(I);return v!==void 0&&v($,F)?(E=I,$):(E=I,C=F)}var N=!1,E,C,R=m===void 0?null:m;return[function(){return x(f())},R===null?void 0:function(){return x(R())}]},[f,m,y,v]);var S=a(p,j[0],j[1]);return c(function(){_.hasValue=!0,_.value=S},[S]),h(S),S},xf}var Lb;function nM(){return Lb||(Lb=1,vf.exports=tM()),vf.exports}var rM=nM();const sM=zv(rM),aM={},Db=e=>{let t;const n=new Set,s=(f,m)=>{const y=typeof f=="function"?f(t):f;if(!Object.is(y,t)){const v=t;t=m??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(j=>j(t,v))}},a=()=>t,h={setState:s,getState:a,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(aM?"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()}},p=t=e(s,a,h);return h},oM=e=>e?Db(e):Db,{useDebugValue:iM}=fe,{useSyncExternalStoreWithSelector:lM}=sM,cM=e=>e;function jC(e,t=cM,n){const s=lM(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return iM(s),s}const qb=(e,t)=>{const n=oM(e),s=(a,l=t)=>jC(n,a,l);return Object.assign(s,n),s},uM=(e,t)=>e?qb(e,t):qb;function Dt(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 dM={value:()=>{}};function md(){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 Bu(n)}function Bu(e){this._=e}function hM(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}})}Bu.prototype=md.prototype={constructor:Bu,on:function(e,t){var n=this._,s=hM(e+"",n),a,l=-1,c=s.length;if(arguments.length<2){for(;++l<c;)if((a=(e=s[l]).type)&&(a=fM(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<c;)if(a=(e=s[l]).type)n[a]=Fb(n[a],e.name,t);else if(t==null)for(a in n)n[a]=Fb(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 Bu(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),s=0,a,l;s<a;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,a=l.length;s<a;++s)l[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,l=s.length;a<l;++a)s[a].value.apply(t,n)}};function fM(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function Fb(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=dM,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var iv="http://www.w3.org/1999/xhtml";const Bb={svg:"http://www.w3.org/2000/svg",xhtml:iv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Bb.hasOwnProperty(t)?{space:Bb[t],local:e}:e}function pM(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===iv&&t.documentElement.namespaceURI===iv?t.createElement(e):t.createElementNS(n,e)}}function mM(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function EC(e){var t=gd(e);return(t.local?mM:pM)(t)}function gM(){}function Uv(e){return e==null?gM:function(){return this.querySelector(e)}}function yM(e){typeof e!="function"&&(e=Uv(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=new Array(c),h,p,f=0;f<c;++f)(h=l[f])&&(p=e.call(h,h.__data__,f,l))&&("__data__"in h&&(p.__data__=h.__data__),d[f]=p);return new Cn(s,this._parents)}function wM(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vM(){return[]}function CC(e){return e==null?vM:function(){return this.querySelectorAll(e)}}function xM(e){return function(){return wM(e.apply(this,arguments))}}function bM(e){typeof e=="function"?e=xM(e):e=CC(e);for(var t=this._groups,n=t.length,s=[],a=[],l=0;l<n;++l)for(var c=t[l],d=c.length,h,p=0;p<d;++p)(h=c[p])&&(s.push(e.call(h,h.__data__,p,c)),a.push(h));return new Cn(s,a)}function TC(e){return function(){return this.matches(e)}}function AC(e){return function(t){return t.matches(e)}}var kM=Array.prototype.find;function _M(e){return function(){return kM.call(this.children,e)}}function NM(){return this.firstElementChild}function SM(e){return this.select(e==null?NM:_M(typeof e=="function"?e:AC(e)))}var jM=Array.prototype.filter;function EM(){return Array.from(this.children)}function CM(e){return function(){return jM.call(this.children,e)}}function TM(e){return this.selectAll(e==null?EM:CM(typeof e=="function"?e:AC(e)))}function AM(e){typeof e!="function"&&(e=TC(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=[],h,p=0;p<c;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&d.push(h);return new Cn(s,this._parents)}function RC(e){return new Array(e.length)}function RM(){return new Cn(this._enter||this._groups.map(RC),this._parents)}function Ku(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ku.prototype={constructor:Ku,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 MM(e){return function(){return e}}function IM(e,t,n,s,a,l){for(var c=0,d,h=t.length,p=l.length;c<p;++c)(d=t[c])?(d.__data__=l[c],s[c]=d):n[c]=new Ku(e,l[c]);for(;c<h;++c)(d=t[c])&&(a[c]=d)}function $M(e,t,n,s,a,l,c){var d,h,p=new Map,f=t.length,m=l.length,y=new Array(f),v;for(d=0;d<f;++d)(h=t[d])&&(y[d]=v=c.call(h,h.__data__,d,t)+"",p.has(v)?a[d]=h:p.set(v,h));for(d=0;d<m;++d)v=c.call(e,l[d],d,l)+"",(h=p.get(v))?(s[d]=h,h.__data__=l[d],p.delete(v)):n[d]=new Ku(e,l[d]);for(d=0;d<f;++d)(h=t[d])&&p.get(y[d])===h&&(a[d]=h)}function OM(e){return e.__data__}function PM(e,t){if(!arguments.length)return Array.from(this,OM);var n=t?$M:IM,s=this._parents,a=this._groups;typeof e!="function"&&(e=MM(e));for(var l=a.length,c=new Array(l),d=new Array(l),h=new Array(l),p=0;p<l;++p){var f=s[p],m=a[p],y=m.length,v=LM(e.call(f,f&&f.__data__,p,s)),j=v.length,_=d[p]=new Array(j),S=c[p]=new Array(j),x=h[p]=new Array(y);n(f,m,_,S,x,v,t);for(var N=0,E=0,C,R;N<j;++N)if(C=_[N]){for(N>=E&&(E=N+1);!(R=S[E])&&++E<j;);C._next=R||null}}return c=new Cn(c,s),c._enter=d,c._exit=h,c}function LM(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function DM(){return new Cn(this._exit||this._groups.map(RC),this._parents)}function qM(e,t,n){var s=this.enter(),a=this,l=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?l.remove():n(l),s&&a?s.merge(a).order():a}function FM(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,a=n.length,l=s.length,c=Math.min(a,l),d=new Array(a),h=0;h<c;++h)for(var p=n[h],f=s[h],m=p.length,y=d[h]=new Array(m),v,j=0;j<m;++j)(v=p[j]||f[j])&&(y[j]=v);for(;h<a;++h)d[h]=n[h];return new Cn(d,this._parents)}function BM(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],a=s.length-1,l=s[a],c;--a>=0;)(c=s[a])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function zM(e){e||(e=UM);function t(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var n=this._groups,s=n.length,a=new Array(s),l=0;l<s;++l){for(var c=n[l],d=c.length,h=a[l]=new Array(d),p,f=0;f<d;++f)(p=c[f])&&(h[f]=p);h.sort(t)}return new Cn(a,this._parents).order()}function UM(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function WM(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function HM(){return Array.from(this)}function GM(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,l=s.length;a<l;++a){var c=s[a];if(c)return c}return null}function VM(){let e=0;for(const t of this)++e;return e}function YM(){return!this.node()}function KM(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],l=0,c=a.length,d;l<c;++l)(d=a[l])&&e.call(d,d.__data__,l,a);return this}function XM(e){return function(){this.removeAttribute(e)}}function QM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ZM(e,t){return function(){this.setAttribute(e,t)}}function JM(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eI(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tI(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 nI(e,t){var n=gd(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?QM:XM:typeof t=="function"?n.local?tI:eI:n.local?JM:ZM)(n,t))}function MC(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rI(e){return function(){this.style.removeProperty(e)}}function sI(e,t,n){return function(){this.style.setProperty(e,t,n)}}function aI(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function oI(e,t,n){return arguments.length>1?this.each((t==null?rI:typeof t=="function"?aI:sI)(e,t,n??"")):ri(this.node(),e)}function ri(e,t){return e.style.getPropertyValue(t)||MC(e).getComputedStyle(e,null).getPropertyValue(t)}function iI(e){return function(){delete this[e]}}function lI(e,t){return function(){this[e]=t}}function cI(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uI(e,t){return arguments.length>1?this.each((t==null?iI:typeof t=="function"?cI:lI)(e,t)):this.node()[e]}function IC(e){return e.trim().split(/^|\s+/)}function Wv(e){return e.classList||new $C(e)}function $C(e){this._node=e,this._names=IC(e.getAttribute("class")||"")}$C.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 OC(e,t){for(var n=Wv(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function PC(e,t){for(var n=Wv(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function dI(e){return function(){OC(this,e)}}function hI(e){return function(){PC(this,e)}}function fI(e,t){return function(){(t.apply(this,arguments)?OC:PC)(this,e)}}function pI(e,t){var n=IC(e+"");if(arguments.length<2){for(var s=Wv(this.node()),a=-1,l=n.length;++a<l;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?fI:t?dI:hI)(n,t))}function mI(){this.textContent=""}function gI(e){return function(){this.textContent=e}}function yI(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function wI(e){return arguments.length?this.each(e==null?mI:(typeof e=="function"?yI:gI)(e)):this.node().textContent}function vI(){this.innerHTML=""}function xI(e){return function(){this.innerHTML=e}}function bI(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function kI(e){return arguments.length?this.each(e==null?vI:(typeof e=="function"?bI:xI)(e)):this.node().innerHTML}function _I(){this.nextSibling&&this.parentNode.appendChild(this)}function NI(){return this.each(_I)}function SI(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jI(){return this.each(SI)}function EI(e){var t=typeof e=="function"?e:EC(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function CI(){return null}function TI(e,t){var n=typeof e=="function"?e:EC(e),s=t==null?CI:typeof t=="function"?t:Uv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function AI(){var e=this.parentNode;e&&e.removeChild(this)}function RI(){return this.each(AI)}function MI(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function II(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $I(e){return this.select(e?II:MI)}function OI(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PI(e){return function(t){e.call(this,t,this.__data__)}}function LI(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 DI(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,a=t.length,l;n<a;++n)l=t[n],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++s]=l;++s?t.length=s:delete this.__on}}}function qI(e,t,n){return function(){var s=this.__on,a,l=PI(t);if(s){for(var c=0,d=s.length;c<d;++c)if((a=s[c]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=n),a.value=t;return}}this.addEventListener(e.type,l,n),a={type:e.type,name:e.name,value:t,listener:l,options:n},s?s.push(a):this.__on=[a]}}function FI(e,t,n){var s=LI(e+""),a,l=s.length,c;if(arguments.length<2){var d=this.node().__on;if(d){for(var h=0,p=d.length,f;h<p;++h)for(a=0,f=d[h];a<l;++a)if((c=s[a]).type===f.type&&c.name===f.name)return f.value}return}for(d=t?qI:DI,a=0;a<l;++a)this.each(d(s[a],t,n));return this}function LC(e,t,n){var s=MC(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 BI(e,t){return function(){return LC(this,e,t)}}function zI(e,t){return function(){return LC(this,e,t.apply(this,arguments))}}function UI(e,t){return this.each((typeof t=="function"?zI:BI)(e,t))}function*WI(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,l=s.length,c;a<l;++a)(c=s[a])&&(yield c)}var DC=[null];function Cn(e,t){this._groups=e,this._parents=t}function Hl(){return new Cn([[document.documentElement]],DC)}function HI(){return this}Cn.prototype=Hl.prototype={constructor:Cn,select:yM,selectAll:bM,selectChild:SM,selectChildren:TM,filter:AM,data:PM,enter:RM,exit:DM,join:qM,merge:FM,selection:HI,order:BM,sort:zM,call:WM,nodes:HM,node:GM,size:VM,empty:YM,each:KM,attr:nI,style:oI,property:uI,classed:pI,text:wI,html:kI,raise:NI,lower:jI,append:EI,insert:TI,remove:RI,clone:$I,datum:OI,on:FI,dispatch:UI,[Symbol.iterator]:WI};function Wn(e){return typeof e=="string"?new Cn([[document.querySelector(e)]],[document.documentElement]):new Cn([[e]],DC)}function GI(e){let t;for(;t=e.sourceEvent;)e=t;return e}function lr(e,t){if(e=GI(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 VI={passive:!1},Rl={capture:!0,passive:!1};function _f(e){e.stopImmediatePropagation()}function Zo(e){e.preventDefault(),e.stopImmediatePropagation()}function qC(e){var t=e.document.documentElement,n=Wn(e).on("dragstart.drag",Zo,Rl);"onselectstart"in t?n.on("selectstart.drag",Zo,Rl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function FC(e,t){var n=e.document.documentElement,s=Wn(e).on("dragstart.drag",null);t&&(s.on("click.drag",Zo,Rl),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 vu=e=>()=>e;function lv(e,{sourceEvent:t,subject:n,target:s,identifier:a,active:l,x:c,y:d,dx:h,dy:p,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:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:f}})}lv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function YI(e){return!e.ctrlKey&&!e.button}function KI(){return this.parentNode}function XI(e,t){return t??{x:e.x,y:e.y}}function QI(){return navigator.maxTouchPoints||"ontouchstart"in this}function ZI(){var e=YI,t=KI,n=XI,s=QI,a={},l=md("start","drag","end"),c=0,d,h,p,f,m=0;function y(C){C.on("mousedown.drag",v).filter(s).on("touchstart.drag",S).on("touchmove.drag",x,VI).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(C,R){if(!(f||!e.call(this,C,R))){var I=E(this,t.call(this,C,R),C,R,"mouse");I&&(Wn(C.view).on("mousemove.drag",j,Rl).on("mouseup.drag",_,Rl),qC(C.view),_f(C),p=!1,d=C.clientX,h=C.clientY,I("start",C))}}function j(C){if(Zo(C),!p){var R=C.clientX-d,I=C.clientY-h;p=R*R+I*I>m}a.mouse("drag",C)}function _(C){Wn(C.view).on("mousemove.drag mouseup.drag",null),FC(C.view,p),Zo(C),a.mouse("end",C)}function S(C,R){if(e.call(this,C,R)){var I=C.changedTouches,$=t.call(this,C,R),F=I.length,O,M;for(O=0;O<F;++O)(M=E(this,$,C,R,I[O].identifier,I[O]))&&(_f(C),M("start",C,I[O]))}}function x(C){var R=C.changedTouches,I=R.length,$,F;for($=0;$<I;++$)(F=a[R[$].identifier])&&(Zo(C),F("drag",C,R[$]))}function N(C){var R=C.changedTouches,I=R.length,$,F;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),$=0;$<I;++$)(F=a[R[$].identifier])&&(_f(C),F("end",C,R[$]))}function E(C,R,I,$,F,O){var M=l.copy(),L=lr(O||I,R),H,B,A;if((A=n.call(C,new lv("beforestart",{sourceEvent:I,target:y,identifier:F,active:c,x:L[0],y:L[1],dx:0,dy:0,dispatch:M}),$))!=null)return H=A.x-L[0]||0,B=A.y-L[1]||0,function Q(K,ee,Z){var D=L,Y;switch(K){case"start":a[F]=Q,Y=c++;break;case"end":delete a[F],--c;case"drag":L=lr(Z||ee,R),Y=c;break}M.call(K,C,new lv(K,{sourceEvent:ee,subject:A,target:y,identifier:F,active:Y,x:L[0]+H,y:L[1]+B,dx:L[0]-D[0],dy:L[1]-D[1],dispatch:M}),$)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:vu(!!C),y):e},y.container=function(C){return arguments.length?(t=typeof C=="function"?C:vu(C),y):t},y.subject=function(C){return arguments.length?(n=typeof C=="function"?C:vu(C),y):n},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:vu(!!C),y):s},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Hv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function BC(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function Gl(){}var Ml=.7,Xu=1/Ml,Jo="\\s*([+-]?\\d+)\\s*",Il="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",JI=/^#([0-9a-f]{3,8})$/,e$=new RegExp(`^rgb\\(${Jo},${Jo},${Jo}\\)$`),t$=new RegExp(`^rgb\\(${Mr},${Mr},${Mr}\\)$`),n$=new RegExp(`^rgba\\(${Jo},${Jo},${Jo},${Il}\\)$`),r$=new RegExp(`^rgba\\(${Mr},${Mr},${Mr},${Il}\\)$`),s$=new RegExp(`^hsl\\(${Il},${Mr},${Mr}\\)$`),a$=new RegExp(`^hsla\\(${Il},${Mr},${Mr},${Il}\\)$`),zb={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};Hv(Gl,$l,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ub,formatHex:Ub,formatHex8:o$,formatHsl:i$,formatRgb:Wb,toString:Wb});function Ub(){return this.rgb().formatHex()}function o$(){return this.rgb().formatHex8()}function i$(){return zC(this).formatHsl()}function Wb(){return this.rgb().formatRgb()}function $l(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=JI.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hb(t):n===3?new wn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?xu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?xu(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=e$.exec(e))?new wn(t[1],t[2],t[3],1):(t=t$.exec(e))?new wn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=n$.exec(e))?xu(t[1],t[2],t[3],t[4]):(t=r$.exec(e))?xu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=s$.exec(e))?Yb(t[1],t[2]/100,t[3]/100,1):(t=a$.exec(e))?Yb(t[1],t[2]/100,t[3]/100,t[4]):zb.hasOwnProperty(e)?Hb(zb[e]):e==="transparent"?new wn(NaN,NaN,NaN,0):null}function Hb(e){return new wn(e>>16&255,e>>8&255,e&255,1)}function xu(e,t,n,s){return s<=0&&(e=t=n=NaN),new wn(e,t,n,s)}function l$(e){return e instanceof Gl||(e=$l(e)),e?(e=e.rgb(),new wn(e.r,e.g,e.b,e.opacity)):new wn}function cv(e,t,n,s){return arguments.length===1?l$(e):new wn(e,t,n,s??1)}function wn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Hv(wn,cv,BC(Gl,{brighter(e){return e=e==null?Xu:Math.pow(Xu,e),new wn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ml:Math.pow(Ml,e),new wn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new wn(Va(this.r),Va(this.g),Va(this.b),Qu(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:Gb,formatHex:Gb,formatHex8:c$,formatRgb:Vb,toString:Vb}));function Gb(){return`#${Ha(this.r)}${Ha(this.g)}${Ha(this.b)}`}function c$(){return`#${Ha(this.r)}${Ha(this.g)}${Ha(this.b)}${Ha((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vb(){const e=Qu(this.opacity);return`${e===1?"rgb(":"rgba("}${Va(this.r)}, ${Va(this.g)}, ${Va(this.b)}${e===1?")":`, ${e})`}`}function Qu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Va(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ha(e){return e=Va(e),(e<16?"0":"")+e.toString(16)}function Yb(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new cr(e,t,n,s)}function zC(e){if(e instanceof cr)return new cr(e.h,e.s,e.l,e.opacity);if(e instanceof Gl||(e=$l(e)),!e)return new cr;if(e instanceof cr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,a=Math.min(t,n,s),l=Math.max(t,n,s),c=NaN,d=l-a,h=(l+a)/2;return d?(t===l?c=(n-s)/d+(n<s)*6:n===l?c=(s-t)/d+2:c=(t-n)/d+4,d/=h<.5?l+a:2-l-a,c*=60):d=h>0&&h<1?0:c,new cr(c,d,h,e.opacity)}function u$(e,t,n,s){return arguments.length===1?zC(e):new cr(e,t,n,s??1)}function cr(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Hv(cr,u$,BC(Gl,{brighter(e){return e=e==null?Xu:Math.pow(Xu,e),new cr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ml:Math.pow(Ml,e),new cr(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 wn(Nf(e>=240?e-240:e+120,a,s),Nf(e,a,s),Nf(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new cr(Kb(this.h),bu(this.s),bu(this.l),Qu(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=Qu(this.opacity);return`${e===1?"hsl(":"hsla("}${Kb(this.h)}, ${bu(this.s)*100}%, ${bu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Kb(e){return e=(e||0)%360,e<0?e+360:e}function bu(e){return Math.max(0,Math.min(1,e||0))}function Nf(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 UC=e=>()=>e;function d$(e,t){return function(n){return e+n*t}}function h$(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 f$(e){return(e=+e)==1?WC:function(t,n){return n-t?h$(t,n,e):UC(isNaN(t)?n:t)}}function WC(e,t){var n=t-e;return n?d$(e,n):UC(isNaN(e)?t:e)}const Xb=(function e(t){var n=f$(t);function s(a,l){var c=n((a=cv(a)).r,(l=cv(l)).r),d=n(a.g,l.g),h=n(a.b,l.b),p=WC(a.opacity,l.opacity);return function(f){return a.r=c(f),a.g=d(f),a.b=h(f),a.opacity=p(f),a+""}}return s.gamma=e,s})(1);function Ws(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var uv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Sf=new RegExp(uv.source,"g");function p$(e){return function(){return e}}function m$(e){return function(t){return e(t)+""}}function g$(e,t){var n=uv.lastIndex=Sf.lastIndex=0,s,a,l,c=-1,d=[],h=[];for(e=e+"",t=t+"";(s=uv.exec(e))&&(a=Sf.exec(t));)(l=a.index)>n&&(l=t.slice(n,l),d[c]?d[c]+=l:d[++c]=l),(s=s[0])===(a=a[0])?d[c]?d[c]+=a:d[++c]=a:(d[++c]=null,h.push({i:c,x:Ws(s,a)})),n=Sf.lastIndex;return n<t.length&&(l=t.slice(n),d[c]?d[c]+=l:d[++c]=l),d.length<2?h[0]?m$(h[0].x):p$(t):(t=h.length,function(p){for(var f=0,m;f<t;++f)d[(m=h[f]).i]=m.x(p);return d.join("")})}var Qb=180/Math.PI,dv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function HC(e,t,n,s,a,l){var c,d,h;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(h=e*n+t*s)&&(n-=e*h,s-=t*h),(d=Math.sqrt(n*n+s*s))&&(n/=d,s/=d,h/=d),e*s<t*n&&(e=-e,t=-t,h=-h,c=-c),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*Qb,skewX:Math.atan(h)*Qb,scaleX:c,scaleY:d}}var ku;function y$(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dv:HC(t.a,t.b,t.c,t.d,t.e,t.f)}function w$(e){return e==null||(ku||(ku=document.createElementNS("http://www.w3.org/2000/svg","g")),ku.setAttribute("transform",e),!(e=ku.transform.baseVal.consolidate()))?dv:(e=e.matrix,HC(e.a,e.b,e.c,e.d,e.e,e.f))}function GC(e,t,n,s){function a(p){return p.length?p.pop()+" ":""}function l(p,f,m,y,v,j){if(p!==m||f!==y){var _=v.push("translate(",null,t,null,n);j.push({i:_-4,x:Ws(p,m)},{i:_-2,x:Ws(f,y)})}else(m||y)&&v.push("translate("+m+t+y+n)}function c(p,f,m,y){p!==f?(p-f>180?f+=360:f-p>180&&(p+=360),y.push({i:m.push(a(m)+"rotate(",null,s)-2,x:Ws(p,f)})):f&&m.push(a(m)+"rotate("+f+s)}function d(p,f,m,y){p!==f?y.push({i:m.push(a(m)+"skewX(",null,s)-2,x:Ws(p,f)}):f&&m.push(a(m)+"skewX("+f+s)}function h(p,f,m,y,v,j){if(p!==m||f!==y){var _=v.push(a(v)+"scale(",null,",",null,")");j.push({i:_-4,x:Ws(p,m)},{i:_-2,x:Ws(f,y)})}else(m!==1||y!==1)&&v.push(a(v)+"scale("+m+","+y+")")}return function(p,f){var m=[],y=[];return p=e(p),f=e(f),l(p.translateX,p.translateY,f.translateX,f.translateY,m,y),c(p.rotate,f.rotate,m,y),d(p.skewX,f.skewX,m,y),h(p.scaleX,p.scaleY,f.scaleX,f.scaleY,m,y),p=f=null,function(v){for(var j=-1,_=y.length,S;++j<_;)m[(S=y[j]).i]=S.x(v);return m.join("")}}}var v$=GC(y$,"px, ","px)","deg)"),x$=GC(w$,", ",")",")"),b$=1e-12;function Zb(e){return((e=Math.exp(e))+1/e)/2}function k$(e){return((e=Math.exp(e))-1/e)/2}function _$(e){return((e=Math.exp(2*e))-1)/(e+1)}const N$=(function e(t,n,s){function a(l,c){var d=l[0],h=l[1],p=l[2],f=c[0],m=c[1],y=c[2],v=f-d,j=m-h,_=v*v+j*j,S,x;if(_<b$)x=Math.log(y/p)/t,S=function($){return[d+$*v,h+$*j,p*Math.exp(t*$*x)]};else{var N=Math.sqrt(_),E=(y*y-p*p+s*_)/(2*p*n*N),C=(y*y-p*p-s*_)/(2*y*n*N),R=Math.log(Math.sqrt(E*E+1)-E),I=Math.log(Math.sqrt(C*C+1)-C);x=(I-R)/t,S=function($){var F=$*x,O=Zb(R),M=p/(n*N)*(O*_$(t*F+R)-k$(R));return[d+M*v,h+M*j,p*O/Zb(t*F+R)]}}return S.duration=x*1e3*t/Math.SQRT2,S}return a.rho=function(l){var c=Math.max(.001,+l),d=c*c,h=d*d;return e(c,d,h)},a})(Math.SQRT2,2,4);var si=0,Nl=0,ml=0,VC=1e3,Zu,Sl,Ju=0,Ka=0,yd=0,Ol=typeof performance=="object"&&performance.now?performance:Date,YC=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gv(){return Ka||(YC(S$),Ka=Ol.now()+yd)}function S$(){Ka=0}function ed(){this._call=this._time=this._next=null}ed.prototype=KC.prototype={constructor:ed,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gv():+n)+(t==null?0:+t),!this._next&&Sl!==this&&(Sl?Sl._next=this:Zu=this,Sl=this),this._call=e,this._time=n,hv()},stop:function(){this._call&&(this._call=null,this._time=1/0,hv())}};function KC(e,t,n){var s=new ed;return s.restart(e,t,n),s}function j$(){Gv(),++si;for(var e=Zu,t;e;)(t=Ka-e._time)>=0&&e._call.call(void 0,t),e=e._next;--si}function Jb(){Ka=(Ju=Ol.now())+yd,si=Nl=0;try{j$()}finally{si=0,C$(),Ka=0}}function E$(){var e=Ol.now(),t=e-Ju;t>VC&&(yd-=t,Ju=e)}function C$(){for(var e,t=Zu,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:Zu=n);Sl=e,hv(s)}function hv(e){if(!si){Nl&&(Nl=clearTimeout(Nl));var t=e-Ka;t>24?(e<1/0&&(Nl=setTimeout(Jb,e-Ol.now()-yd)),ml&&(ml=clearInterval(ml))):(ml||(Ju=Ol.now(),ml=setInterval(E$,VC)),si=1,YC(Jb))}}function ek(e,t,n){var s=new ed;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var T$=md("start","end","cancel","interrupt"),A$=[],XC=0,tk=1,fv=2,zu=3,nk=4,pv=5,Uu=6;function wd(e,t,n,s,a,l){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;R$(e,n,{name:t,index:s,group:a,on:T$,tween:A$,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:XC})}function Vv(e,t){var n=gr(e,t);if(n.state>XC)throw new Error("too late; already scheduled");return n}function Ir(e,t){var n=gr(e,t);if(n.state>zu)throw new Error("too late; already running");return n}function gr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function R$(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=KC(l,0,n.time);function l(p){n.state=tk,n.timer.restart(c,n.delay,n.time),n.delay<=p&&c(p-n.delay)}function c(p){var f,m,y,v;if(n.state!==tk)return h();for(f in s)if(v=s[f],v.name===n.name){if(v.state===zu)return ek(c);v.state===nk?(v.state=Uu,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete s[f]):+f<t&&(v.state=Uu,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete s[f])}if(ek(function(){n.state===zu&&(n.state=nk,n.timer.restart(d,n.delay,n.time),d(p))}),n.state=fv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===fv){for(n.state=zu,a=new Array(y=n.tween.length),f=0,m=-1;f<y;++f)(v=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(a[++m]=v);a.length=m+1}}function d(p){for(var f=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(h),n.state=pv,1),m=-1,y=a.length;++m<y;)a[m].call(e,f);n.state===pv&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=Uu,n.timer.stop(),delete s[t];for(var p in s)return;delete e.__transition}}function Wu(e,t){var n=e.__transition,s,a,l=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((s=n[c]).name!==t){l=!1;continue}a=s.state>fv&&s.state<pv,s.state=Uu,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[c]}l&&delete e.__transition}}function M$(e){return this.each(function(){Wu(this,e)})}function I$(e,t){var n,s;return function(){var a=Ir(this,e),l=a.tween;if(l!==n){s=n=l;for(var c=0,d=s.length;c<d;++c)if(s[c].name===t){s=s.slice(),s.splice(c,1);break}}a.tween=s}}function $$(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var l=Ir(this,e),c=l.tween;if(c!==s){a=(s=c).slice();for(var d={name:t,value:n},h=0,p=a.length;h<p;++h)if(a[h].name===t){a[h]=d;break}h===p&&a.push(d)}l.tween=a}}function O$(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=gr(this.node(),n).tween,a=0,l=s.length,c;a<l;++a)if((c=s[a]).name===e)return c.value;return null}return this.each((t==null?I$:$$)(n,e,t))}function Yv(e,t,n){var s=e._id;return e.each(function(){var a=Ir(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return gr(a,s).value[t]}}function QC(e,t){var n;return(typeof t=="number"?Ws:t instanceof $l?Xb:(n=$l(t))?(t=n,Xb):g$)(e,t)}function P$(e){return function(){this.removeAttribute(e)}}function L$(e){return function(){this.removeAttributeNS(e.space,e.local)}}function D$(e,t,n){var s,a=n+"",l;return function(){var c=this.getAttribute(e);return c===a?null:c===s?l:l=t(s=c,n)}}function q$(e,t,n){var s,a=n+"",l;return function(){var c=this.getAttributeNS(e.space,e.local);return c===a?null:c===s?l:l=t(s=c,n)}}function F$(e,t,n){var s,a,l;return function(){var c,d=n(this),h;return d==null?void this.removeAttribute(e):(c=this.getAttribute(e),h=d+"",c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d)))}}function B$(e,t,n){var s,a,l;return function(){var c,d=n(this),h;return d==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),h=d+"",c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d)))}}function z$(e,t){var n=gd(e),s=n==="transform"?x$:QC;return this.attrTween(e,typeof t=="function"?(n.local?B$:F$)(n,s,Yv(this,"attr."+e,t)):t==null?(n.local?L$:P$)(n):(n.local?q$:D$)(n,s,t))}function U$(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function W$(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function H$(e,t){var n,s;function a(){var l=t.apply(this,arguments);return l!==s&&(n=(s=l)&&W$(e,l)),n}return a._value=t,a}function G$(e,t){var n,s;function a(){var l=t.apply(this,arguments);return l!==s&&(n=(s=l)&&U$(e,l)),n}return a._value=t,a}function V$(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=gd(e);return this.tween(n,(s.local?H$:G$)(s,t))}function Y$(e,t){return function(){Vv(this,e).delay=+t.apply(this,arguments)}}function K$(e,t){return t=+t,function(){Vv(this,e).delay=t}}function X$(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Y$:K$)(t,e)):gr(this.node(),t).delay}function Q$(e,t){return function(){Ir(this,e).duration=+t.apply(this,arguments)}}function Z$(e,t){return t=+t,function(){Ir(this,e).duration=t}}function J$(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Q$:Z$)(t,e)):gr(this.node(),t).duration}function eO(e,t){if(typeof t!="function")throw new Error;return function(){Ir(this,e).ease=t}}function tO(e){var t=this._id;return arguments.length?this.each(eO(t,e)):gr(this.node(),t).ease}function nO(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ir(this,e).ease=n}}function rO(e){if(typeof e!="function")throw new Error;return this.each(nO(this._id,e))}function sO(e){typeof e!="function"&&(e=TC(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var l=t[a],c=l.length,d=s[a]=[],h,p=0;p<c;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&d.push(h);return new os(s,this._parents,this._name,this._id)}function aO(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,a=n.length,l=Math.min(s,a),c=new Array(s),d=0;d<l;++d)for(var h=t[d],p=n[d],f=h.length,m=c[d]=new Array(f),y,v=0;v<f;++v)(y=h[v]||p[v])&&(m[v]=y);for(;d<s;++d)c[d]=t[d];return new os(c,this._parents,this._name,this._id)}function oO(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 iO(e,t,n){var s,a,l=oO(t)?Vv:Ir;return function(){var c=l(this,e),d=c.on;d!==s&&(a=(s=d).copy()).on(t,n),c.on=a}}function lO(e,t){var n=this._id;return arguments.length<2?gr(this.node(),n).on.on(e):this.each(iO(n,e,t))}function cO(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function uO(){return this.on("end.remove",cO(this._id))}function dO(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Uv(e));for(var s=this._groups,a=s.length,l=new Array(a),c=0;c<a;++c)for(var d=s[c],h=d.length,p=l[c]=new Array(h),f,m,y=0;y<h;++y)(f=d[y])&&(m=e.call(f,f.__data__,y,d))&&("__data__"in f&&(m.__data__=f.__data__),p[y]=m,wd(p[y],t,n,y,p,gr(f,n)));return new os(l,this._parents,t,n)}function hO(e){var t=this._name,n=this._id;typeof e!="function"&&(e=CC(e));for(var s=this._groups,a=s.length,l=[],c=[],d=0;d<a;++d)for(var h=s[d],p=h.length,f,m=0;m<p;++m)if(f=h[m]){for(var y=e.call(f,f.__data__,m,h),v,j=gr(f,n),_=0,S=y.length;_<S;++_)(v=y[_])&&wd(v,t,n,_,y,j);l.push(y),c.push(f)}return new os(l,c,t,n)}var fO=Hl.prototype.constructor;function pO(){return new fO(this._groups,this._parents)}function mO(e,t){var n,s,a;return function(){var l=ri(this,e),c=(this.style.removeProperty(e),ri(this,e));return l===c?null:l===n&&c===s?a:a=t(n=l,s=c)}}function ZC(e){return function(){this.style.removeProperty(e)}}function gO(e,t,n){var s,a=n+"",l;return function(){var c=ri(this,e);return c===a?null:c===s?l:l=t(s=c,n)}}function yO(e,t,n){var s,a,l;return function(){var c=ri(this,e),d=n(this),h=d+"";return d==null&&(h=d=(this.style.removeProperty(e),ri(this,e))),c===h?null:c===s&&h===a?l:(a=h,l=t(s=c,d))}}function wO(e,t){var n,s,a,l="style."+t,c="end."+l,d;return function(){var h=Ir(this,e),p=h.on,f=h.value[l]==null?d||(d=ZC(t)):void 0;(p!==n||a!==f)&&(s=(n=p).copy()).on(c,a=f),h.on=s}}function vO(e,t,n){var s=(e+="")=="transform"?v$:QC;return t==null?this.styleTween(e,mO(e,s)).on("end.style."+e,ZC(e)):typeof t=="function"?this.styleTween(e,yO(e,s,Yv(this,"style."+e,t))).each(wO(this._id,e)):this.styleTween(e,gO(e,s,t),n).on("end.style."+e,null)}function xO(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function bO(e,t,n){var s,a;function l(){var c=t.apply(this,arguments);return c!==a&&(s=(a=c)&&xO(e,c,n)),s}return l._value=t,l}function kO(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,bO(e,t,n??""))}function _O(e){return function(){this.textContent=e}}function NO(e){return function(){var t=e(this);this.textContent=t??""}}function SO(e){return this.tween("text",typeof e=="function"?NO(Yv(this,"text",e)):_O(e==null?"":e+""))}function jO(e){return function(t){this.textContent=e.call(this,t)}}function EO(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&jO(a)),t}return s._value=e,s}function CO(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,EO(e))}function TO(){for(var e=this._name,t=this._id,n=JC(),s=this._groups,a=s.length,l=0;l<a;++l)for(var c=s[l],d=c.length,h,p=0;p<d;++p)if(h=c[p]){var f=gr(h,t);wd(h,e,n,p,c,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new os(s,this._parents,e,n)}function AO(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(l,c){var d={value:c},h={value:function(){--a===0&&l()}};n.each(function(){var p=Ir(this,s),f=p.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(d),t._.interrupt.push(d),t._.end.push(h)),p.on=t}),a===0&&l()})}var RO=0;function os(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function JC(){return++RO}var ns=Hl.prototype;os.prototype={constructor:os,select:dO,selectAll:hO,selectChild:ns.selectChild,selectChildren:ns.selectChildren,filter:sO,merge:aO,selection:pO,transition:TO,call:ns.call,nodes:ns.nodes,node:ns.node,size:ns.size,empty:ns.empty,each:ns.each,on:lO,attr:z$,attrTween:V$,style:vO,styleTween:kO,text:SO,textTween:CO,remove:uO,tween:O$,delay:X$,duration:J$,ease:tO,easeVarying:rO,end:AO,[Symbol.iterator]:ns[Symbol.iterator]};function MO(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var IO={time:null,delay:0,duration:250,ease:MO};function $O(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 OO(e){var t,n;e instanceof os?(t=e._id,e=e._name):(t=JC(),(n=IO).time=Gv(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,l=0;l<a;++l)for(var c=s[l],d=c.length,h,p=0;p<d;++p)(h=c[p])&&wd(h,e,t,p,c,n||$O(h,t));return new os(s,this._parents,e,t)}Hl.prototype.interrupt=M$;Hl.prototype.transition=OO;const _u=e=>()=>e;function PO(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 rs(e,t,n){this.k=e,this.x=t,this.y=n}rs.prototype={constructor:rs,scale:function(e){return e===1?this:new rs(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new rs(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 ss=new rs(1,0,0);rs.prototype;function jf(e){e.stopImmediatePropagation()}function gl(e){e.preventDefault(),e.stopImmediatePropagation()}function LO(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DO(){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 rk(){return this.__zoom||ss}function qO(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FO(){return navigator.maxTouchPoints||"ontouchstart"in this}function BO(e,t,n){var s=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],l=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function eT(){var e=LO,t=DO,n=BO,s=qO,a=FO,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,h=N$,p=md("start","zoom","end"),f,m,y,v=500,j=150,_=0,S=10;function x(A){A.property("__zoom",rk).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",M).filter(a).on("touchstart.zoom",L).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(A,Q,K,ee){var Z=A.selection?A.selection():A;Z.property("__zoom",rk),A!==Z?R(A,Q,K,ee):Z.interrupt().each(function(){I(this,arguments).event(ee).start().zoom(null,typeof Q=="function"?Q.apply(this,arguments):Q).end()})},x.scaleBy=function(A,Q,K,ee){x.scaleTo(A,function(){var Z=this.__zoom.k,D=typeof Q=="function"?Q.apply(this,arguments):Q;return Z*D},K,ee)},x.scaleTo=function(A,Q,K,ee){x.transform(A,function(){var Z=t.apply(this,arguments),D=this.__zoom,Y=K==null?C(Z):typeof K=="function"?K.apply(this,arguments):K,P=D.invert(Y),G=typeof Q=="function"?Q.apply(this,arguments):Q;return n(E(N(D,G),Y,P),Z,c)},K,ee)},x.translateBy=function(A,Q,K,ee){x.transform(A,function(){return n(this.__zoom.translate(typeof Q=="function"?Q.apply(this,arguments):Q,typeof K=="function"?K.apply(this,arguments):K),t.apply(this,arguments),c)},null,ee)},x.translateTo=function(A,Q,K,ee,Z){x.transform(A,function(){var D=t.apply(this,arguments),Y=this.__zoom,P=ee==null?C(D):typeof ee=="function"?ee.apply(this,arguments):ee;return n(ss.translate(P[0],P[1]).scale(Y.k).translate(typeof Q=="function"?-Q.apply(this,arguments):-Q,typeof K=="function"?-K.apply(this,arguments):-K),D,c)},ee,Z)};function N(A,Q){return Q=Math.max(l[0],Math.min(l[1],Q)),Q===A.k?A:new rs(Q,A.x,A.y)}function E(A,Q,K){var ee=Q[0]-K[0]*A.k,Z=Q[1]-K[1]*A.k;return ee===A.x&&Z===A.y?A:new rs(A.k,ee,Z)}function C(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function R(A,Q,K,ee){A.on("start.zoom",function(){I(this,arguments).event(ee).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(ee).end()}).tween("zoom",function(){var Z=this,D=arguments,Y=I(Z,D).event(ee),P=t.apply(Z,D),G=K==null?C(P):typeof K=="function"?K.apply(Z,D):K,de=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),W=Z.__zoom,U=typeof Q=="function"?Q.apply(Z,D):Q,J=h(W.invert(G).concat(de/W.k),U.invert(G).concat(de/U.k));return function(V){if(V===1)V=U;else{var ie=J(V),pe=de/ie[2];V=new rs(pe,G[0]-ie[0]*pe,G[1]-ie[1]*pe)}Y.zoom(null,V)}})}function I(A,Q,K){return!K&&A.__zooming||new $(A,Q)}function $(A,Q){this.that=A,this.args=Q,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,Q),this.taps=0}$.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,Q){return this.mouse&&A!=="mouse"&&(this.mouse[1]=Q.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=Q.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=Q.invert(this.touch1[0])),this.that.__zoom=Q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var Q=Wn(this.that).datum();p.call(A,this.that,new PO(A,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:p}),Q)}};function F(A,...Q){if(!e.apply(this,arguments))return;var K=I(this,Q).event(A),ee=this.__zoom,Z=Math.max(l[0],Math.min(l[1],ee.k*Math.pow(2,s.apply(this,arguments)))),D=lr(A);if(K.wheel)(K.mouse[0][0]!==D[0]||K.mouse[0][1]!==D[1])&&(K.mouse[1]=ee.invert(K.mouse[0]=D)),clearTimeout(K.wheel);else{if(ee.k===Z)return;K.mouse=[D,ee.invert(D)],Wu(this),K.start()}gl(A),K.wheel=setTimeout(Y,j),K.zoom("mouse",n(E(N(ee,Z),K.mouse[0],K.mouse[1]),K.extent,c));function Y(){K.wheel=null,K.end()}}function O(A,...Q){if(y||!e.apply(this,arguments))return;var K=A.currentTarget,ee=I(this,Q,!0).event(A),Z=Wn(A.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",de,!0),D=lr(A,K),Y=A.clientX,P=A.clientY;qC(A.view),jf(A),ee.mouse=[D,this.__zoom.invert(D)],Wu(this),ee.start();function G(W){if(gl(W),!ee.moved){var U=W.clientX-Y,J=W.clientY-P;ee.moved=U*U+J*J>_}ee.event(W).zoom("mouse",n(E(ee.that.__zoom,ee.mouse[0]=lr(W,K),ee.mouse[1]),ee.extent,c))}function de(W){Z.on("mousemove.zoom mouseup.zoom",null),FC(W.view,ee.moved),gl(W),ee.event(W).end()}}function M(A,...Q){if(e.apply(this,arguments)){var K=this.__zoom,ee=lr(A.changedTouches?A.changedTouches[0]:A,this),Z=K.invert(ee),D=K.k*(A.shiftKey?.5:2),Y=n(E(N(K,D),ee,Z),t.apply(this,Q),c);gl(A),d>0?Wn(this).transition().duration(d).call(R,Y,ee,A):Wn(this).call(x.transform,Y,ee,A)}}function L(A,...Q){if(e.apply(this,arguments)){var K=A.touches,ee=K.length,Z=I(this,Q,A.changedTouches.length===ee).event(A),D,Y,P,G;for(jf(A),Y=0;Y<ee;++Y)P=K[Y],G=lr(P,this),G=[G,this.__zoom.invert(G),P.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==G[2]&&(Z.touch1=G,Z.taps=0):(Z.touch0=G,D=!0,Z.taps=1+!!f);f&&(f=clearTimeout(f)),D&&(Z.taps<2&&(m=G[0],f=setTimeout(function(){f=null},v)),Wu(this),Z.start())}}function H(A,...Q){if(this.__zooming){var K=I(this,Q).event(A),ee=A.changedTouches,Z=ee.length,D,Y,P,G;for(gl(A),D=0;D<Z;++D)Y=ee[D],P=lr(Y,this),K.touch0&&K.touch0[2]===Y.identifier?K.touch0[0]=P:K.touch1&&K.touch1[2]===Y.identifier&&(K.touch1[0]=P);if(Y=K.that.__zoom,K.touch1){var de=K.touch0[0],W=K.touch0[1],U=K.touch1[0],J=K.touch1[1],V=(V=U[0]-de[0])*V+(V=U[1]-de[1])*V,ie=(ie=J[0]-W[0])*ie+(ie=J[1]-W[1])*ie;Y=N(Y,Math.sqrt(V/ie)),P=[(de[0]+U[0])/2,(de[1]+U[1])/2],G=[(W[0]+J[0])/2,(W[1]+J[1])/2]}else if(K.touch0)P=K.touch0[0],G=K.touch0[1];else return;K.zoom("touch",n(E(Y,P,G),K.extent,c))}}function B(A,...Q){if(this.__zooming){var K=I(this,Q).event(A),ee=A.changedTouches,Z=ee.length,D,Y;for(jf(A),y&&clearTimeout(y),y=setTimeout(function(){y=null},v),D=0;D<Z;++D)Y=ee[D],K.touch0&&K.touch0[2]===Y.identifier?delete K.touch0:K.touch1&&K.touch1[2]===Y.identifier&&delete K.touch1;if(K.touch1&&!K.touch0&&(K.touch0=K.touch1,delete K.touch1),K.touch0)K.touch0[1]=this.__zoom.invert(K.touch0[0]);else if(K.end(),K.taps===2&&(Y=lr(Y,this),Math.hypot(m[0]-Y[0],m[1]-Y[1])<S)){var P=Wn(this).on("dblclick.zoom");P&&P.apply(this,arguments)}}}return x.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:_u(+A),x):s},x.filter=function(A){return arguments.length?(e=typeof A=="function"?A:_u(!!A),x):e},x.touchable=function(A){return arguments.length?(a=typeof A=="function"?A:_u(!!A),x):a},x.extent=function(A){return arguments.length?(t=typeof A=="function"?A:_u([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),x):t},x.scaleExtent=function(A){return arguments.length?(l[0]=+A[0],l[1]=+A[1],x):[l[0],l[1]]},x.translateExtent=function(A){return arguments.length?(c[0][0]=+A[0][0],c[1][0]=+A[1][0],c[0][1]=+A[0][1],c[1][1]=+A[1][1],x):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},x.constrain=function(A){return arguments.length?(n=A,x):n},x.duration=function(A){return arguments.length?(d=+A,x):d},x.interpolate=function(A){return arguments.length?(h=A,x):h},x.on=function(){var A=p.on.apply(p,arguments);return A===p?x:A},x.clickDistance=function(A){return arguments.length?(_=(A=+A)*A,x):Math.sqrt(_)},x.tapDistance=function(A){return arguments.length?(S=+A,x):S},x}var ls=SC();const vd=b.createContext(null),zO=vd.Provider,is={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.`},tT=is.error001();function ct(e,t){const n=b.useContext(vd);if(n===null)throw new Error(tT);return jC(n,e,t)}const Rt=()=>{const e=b.useContext(vd);if(e===null)throw new Error(tT);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},UO=e=>e.userSelectionActive?"none":"all";function Kv({position:e,children:t,className:n,style:s,...a}){const l=ct(UO),c=`${e}`.split("-");return fe.createElement("div",{className:Kt(["react-flow__panel",n,...c]),style:{...s,pointerEvents:l},...a},t)}function WO({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:fe.createElement(Kv,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},fe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const HO=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:d=2,children:h,className:p,...f})=>{const m=b.useRef(null),[y,v]=b.useState({x:0,y:0,width:0,height:0}),j=Kt(["react-flow__edge-textwrapper",p]);return b.useEffect(()=>{if(m.current){const _=m.current.getBBox();v({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),typeof n>"u"||!n?null:fe.createElement("g",{transform:`translate(${e-y.width/2} ${t-y.height/2})`,className:j,visibility:y.width?"visible":"hidden",...f},a&&fe.createElement("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:d,ry:d}),fe.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},n),h)};var GO=b.memo(HO);const Xv=e=>({width:e.offsetWidth,height:e.offsetHeight}),ai=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Qv=(e={x:0,y:0},t)=>({x:ai(e.x,t[0][0],t[1][0]),y:ai(e.y,t[0][1],t[1][1])}),sk=(e,t,n)=>e<t?ai(Math.abs(e-t),1,50)/50:e>n?-ai(Math.abs(e-n),1,50)/50:0,nT=(e,t)=>{const n=sk(e.x,35,t.width-35)*20,s=sk(e.y,35,t.height-35)*20;return[n,s]},rT=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},sT=(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)}),Pl=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),aT=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),ak=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),VO=(e,t)=>aT(sT(Pl(e),Pl(t))),mv=(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)},YO=e=>Hn(e.width)&&Hn(e.height)&&Hn(e.x)&&Hn(e.y),Hn=e=>!isNaN(e)&&isFinite(e),St=Symbol.for("internals"),oT=["Enter"," ","Escape"],KO=(e,t)=>{},XO=e=>"nativeEvent"in e;function gv(e){var a,l;const t=XO(e)?e.nativeEvent:e,n=((l=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:l[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 iT=e=>"clientX"in e,Vs=(e,t)=>{var l,c;const n=iT(e),s=n?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,a=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},td=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Vl=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v=20})=>fe.createElement(fe.Fragment,null,fe.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),v&&fe.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),a&&Hn(n)&&Hn(s)?fe.createElement(GO,{x:n,y:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p}):null);Vl.displayName="BaseEdge";function yl(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(l=>l.id===e);a&&n(s,{...a})}}function lT({sourceX:e,sourceY:t,targetX:n,targetY:s}){const a=Math.abs(n-e)/2,l=n<e?n+a:n-a,c=Math.abs(s-t)/2,d=s<t?s+c:s-c;return[l,d,a,c]}function cT({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d}){const h=e*.125+a*.375+c*.375+n*.125,p=t*.125+l*.375+d*.375+s*.125,f=Math.abs(h-e),m=Math.abs(p-t);return[h,p,f,m]}var Xa;(function(e){e.Strict="strict",e.Loose="loose"})(Xa||(Xa={}));var Ga;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ga||(Ga={}));var Ll;(function(e){e.Partial="partial",e.Full="full"})(Ll||(Ll={}));var Gs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Gs||(Gs={}));var nd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nd||(nd={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));function ok({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===Ue.Left||e===Ue.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function uT({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top}){const[c,d]=ok({pos:n,x1:e,y1:t,x2:s,y2:a}),[h,p]=ok({pos:l,x1:s,y1:a,x2:e,y2:t}),[f,m,y,v]=cT({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:p});return[`M${e},${t} C${c},${d} ${h},${p} ${s},${a}`,f,m,y,v]}const Zv=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:_})=>{const[S,x,N]=uT({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l});return fe.createElement(Vl,{path:S,labelX:x,labelY:N,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:_})});Zv.displayName="SimpleBezierEdge";const ik={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},QO=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.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},lk=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ZO({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:s=Ue.Top,center:a,offset:l}){const c=ik[t],d=ik[s],h={x:e.x+c.x*l,y:e.y+c.y*l},p={x:n.x+d.x*l,y:n.y+d.y*l},f=QO({source:h,sourcePosition:t,target:p}),m=f.x!==0?"x":"y",y=f[m];let v=[],j,_;const S={x:0,y:0},x={x:0,y:0},[N,E,C,R]=lT({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[m]*d[m]===-1){j=a.x??N,_=a.y??E;const $=[{x:j,y:h.y},{x:j,y:p.y}],F=[{x:h.x,y:_},{x:p.x,y:_}];c[m]===y?v=m==="x"?$:F:v=m==="x"?F:$}else{const $=[{x:h.x,y:p.y}],F=[{x:p.x,y:h.y}];if(m==="x"?v=c.x===y?F:$:v=c.y===y?$:F,t===s){const B=Math.abs(e[m]-n[m]);if(B<=l){const A=Math.min(l-1,l-B);c[m]===y?S[m]=(h[m]>e[m]?-1:1)*A:x[m]=(p[m]>n[m]?-1:1)*A}}if(t!==s){const B=m==="x"?"y":"x",A=c[m]===d[B],Q=h[B]>p[B],K=h[B]<p[B];(c[m]===1&&(!A&&Q||A&&K)||c[m]!==1&&(!A&&K||A&&Q))&&(v=m==="x"?$:F)}const O={x:h.x+S.x,y:h.y+S.y},M={x:p.x+x.x,y:p.y+x.y},L=Math.max(Math.abs(O.x-v[0].x),Math.abs(M.x-v[0].x)),H=Math.max(Math.abs(O.y-v[0].y),Math.abs(M.y-v[0].y));L>=H?(j=(O.x+M.x)/2,_=v[0].y):(j=v[0].x,_=(O.y+M.y)/2)}return[[e,{x:h.x+S.x,y:h.y+S.y},...v,{x:p.x+x.x,y:p.y+x.y},n],j,_,C,R]}function JO(e,t,n,s){const a=Math.min(lk(e,t)/2,lk(t,n)/2,s),{x:l,y:c}=t;if(e.x===l&&l===n.x||e.y===c&&c===n.y)return`L${l} ${c}`;if(e.y===c){const p=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${l+a*p},${c}Q ${l},${c} ${l},${c+a*f}`}const d=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${l},${c+a*h}Q ${l},${c} ${l+a*d},${c}`}function yv({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top,borderRadius:c=5,centerX:d,centerY:h,offset:p=20}){const[f,m,y,v,j]=ZO({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:l,center:{x:d,y:h},offset:p});return[f.reduce((S,x,N)=>{let E="";return N>0&&N<f.length-1?E=JO(f[N-1],x,f[N+1],c):E=`${N===0?"M":"L"}${x.x} ${x.y}`,S+=E,S},""),m,y,v,j]}const xd=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,sourcePosition:m=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[x,N,E]=yv({sourceX:e,sourceY:t,sourcePosition:m,targetX:n,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return fe.createElement(Vl,{path:x,labelX:N,labelY:E,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:v,markerStart:j,interactionWidth:S})});xd.displayName="SmoothStepEdge";const Jv=b.memo(e=>{var t;return fe.createElement(xd,{...e,pathOptions:b.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Jv.displayName="StepEdge";function eP({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,l,c,d]=lT({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,l,c,d]}const ex=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v})=>{const[j,_,S]=eP({sourceX:e,sourceY:t,targetX:n,targetY:s});return fe.createElement(Vl,{path:j,labelX:_,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,style:f,markerEnd:m,markerStart:y,interactionWidth:v})});ex.displayName="StraightEdge";function Nu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ck({pos:e,x1:t,y1:n,x2:s,y2:a,c:l}){switch(e){case Ue.Left:return[t-Nu(t-s,l),n];case Ue.Right:return[t+Nu(s-t,l),n];case Ue.Top:return[t,n-Nu(n-a,l)];case Ue.Bottom:return[t,n+Nu(a-n,l)]}}function dT({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:s,targetY:a,targetPosition:l=Ue.Top,curvature:c=.25}){const[d,h]=ck({pos:n,x1:e,y1:t,x2:s,y2:a,c}),[p,f]=ck({pos:l,x1:s,y1:a,x2:e,y2:t,c}),[m,y,v,j]=cT({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:d,sourceControlY:h,targetControlX:p,targetControlY:f});return[`M${e},${t} C${d},${h} ${p},${f} ${s},${a}`,m,y,v,j]}const rd=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[x,N,E]=dT({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return fe.createElement(Vl,{path:x,labelX:N,labelY:E,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:j,interactionWidth:S})});rd.displayName="BezierEdge";const tx=b.createContext(null),tP=tx.Provider;tx.Consumer;const nP=()=>b.useContext(tx),rP=e=>"id"in e&&"source"in e&&"target"in e,sP=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,wv=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,aP=(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)),oP=(e,t)=>{if(!e.source||!e.target)return t;let n;return rP(e)?n={...e}:n={...e,id:sP(e)},aP(n,t)?t:t.concat(n)},vv=({x:e,y:t},[n,s,a],l,[c,d])=>{const h={x:(e-n)/a,y:(t-s)/a};return l?{x:c*Math.round(h.x/c),y:d*Math.round(h.y/d)}:h},hT=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),Ya=(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}},bd=(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:l,y:c}=Ya(a,t).positionAbsolute;return sT(s,Pl({x:l,y:c,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return aT(n)},fT=(e,t,[n,s,a]=[0,0,1],l=!1,c=!1,d=[0,0])=>{const h={x:(t.x-n)/a,y:(t.y-s)/a,width:t.width/a,height:t.height/a},p=[];return e.forEach(f=>{const{width:m,height:y,selectable:v=!0,hidden:j=!1}=f;if(c&&!v||j)return!1;const{positionAbsolute:_}=Ya(f,d),S={x:_.x,y:_.y,width:m||0,height:y||0},x=mv(h,S),N=typeof m>"u"||typeof y>"u"||m===null||y===null,E=l&&x>0,C=(m||0)*(y||0);(N||E||x>=C||f.dragging)&&p.push(f)}),p},pT=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},mT=(e,t,n,s,a,l=.1)=>{const c=t/(e.width*(1+l)),d=n/(e.height*(1+l)),h=Math.min(c,d),p=ai(h,s,a),f=e.x+e.width/2,m=e.y+e.height/2,y=t/2-f*p,v=n/2-m*p;return{x:y,y:v,zoom:p}},Wa=(e,t=0)=>e.transition().duration(t);function uk(e,t,n,s){return(t[n]||[]).reduce((a,l)=>{var c,d;return`${e.id}-${l.id}-${n}`!==s&&a.push({id:l.id||null,type:n,nodeId:e.id,x:(((c=e.positionAbsolute)==null?void 0:c.x)??0)+l.x+l.width/2,y:(((d=e.positionAbsolute)==null?void 0:d.y)??0)+l.y+l.height/2}),a},[])}function iP(e,t,n,s,a,l){const{x:c,y:d}=Vs(e),p=t.elementsFromPoint(c,d).find(j=>j.classList.contains("react-flow__handle"));if(p){const j=p.getAttribute("data-nodeid");if(j){const _=nx(void 0,p),S=p.getAttribute("data-handleid"),x=l({nodeId:j,id:S,type:_});if(x){const N=a.find(E=>E.nodeId===j&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:j,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:x}}}}let f=[],m=1/0;if(a.forEach(j=>{const _=Math.sqrt((j.x-n.x)**2+(j.y-n.y)**2);if(_<=s){const S=l(j);_<=m&&(_<m?f=[{handle:j,validHandleResult:S}]:_===m&&f.push({handle:j,validHandleResult:S}),m=_)}}),!f.length)return{handle:null,validHandleResult:gT()};if(f.length===1)return f[0];const y=f.some(({validHandleResult:j})=>j.isValid),v=f.some(({handle:j})=>j.type==="target");return f.find(({handle:j,validHandleResult:_})=>v?j.type==="target":y?_.isValid:!0)||f[0]}const lP={source:null,target:null,sourceHandle:null,targetHandle:null},gT=()=>({handleDomNode:null,isValid:!1,connection:lP,endHandle:null});function yT(e,t,n,s,a,l,c){const d=a==="target",h=c.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...gT(),handleDomNode:h};if(h){const f=nx(void 0,h),m=h.getAttribute("data-nodeid"),y=h.getAttribute("data-handleid"),v=h.classList.contains("connectable"),j=h.classList.contains("connectableend"),_={source:d?m:n,sourceHandle:d?y:s,target:d?n:m,targetHandle:d?s:y};p.connection=_,v&&j&&(t===Xa.Strict?d&&f==="source"||!d&&f==="target":m!==n||y!==s)&&(p.endHandle={nodeId:m,handleId:y,type:f},p.isValid=l(_))}return p}function cP({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,l)=>{if(l[St]){const{handleBounds:c}=l[St];let d=[],h=[];c&&(d=uk(l,c,"source",`${t}-${n}-${s}`),h=uk(l,c,"target",`${t}-${n}-${s}`)),a.push(...d,...h)}return a},[])}function nx(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Ef(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function uP(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function wT({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:l,setState:c,isValidConnection:d,edgeUpdaterType:h,onReconnectEnd:p}){const f=rT(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:v,connectionRadius:j,onConnectStart:_,panBy:S,getNodes:x,cancelConnection:N}=l();let E=0,C;const{x:R,y:I}=Vs(e),$=f==null?void 0:f.elementFromPoint(R,I),F=nx(h,$),O=y==null?void 0:y.getBoundingClientRect();if(!O||!F)return;let M,L=Vs(e,O),H=!1,B=null,A=!1,Q=null;const K=cP({nodes:x(),nodeId:n,handleId:t,handleType:F}),ee=()=>{if(!v)return;const[Y,P]=nT(L,O);S({x:Y,y:P}),E=requestAnimationFrame(ee)};c({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:F,connectionStartHandle:{nodeId:n,handleId:t,type:F},connectionEndHandle:null}),_==null||_(e,{nodeId:n,handleId:t,handleType:F});function Z(Y){const{transform:P}=l();L=Vs(Y,O);const{handle:G,validHandleResult:de}=iP(Y,f,vv(L,P,!1,[1,1]),j,K,W=>yT(W,m,n,t,a?"target":"source",d,f));if(C=G,H||(ee(),H=!0),Q=de.handleDomNode,B=de.connection,A=de.isValid,c({connectionPosition:C&&A?hT({x:C.x,y:C.y},P):L,connectionStatus:uP(!!C,A),connectionEndHandle:de.endHandle}),!C&&!A&&!Q)return Ef(M);B.source!==B.target&&Q&&(Ef(M),M=Q,Q.classList.add("connecting","react-flow__handle-connecting"),Q.classList.toggle("valid",A),Q.classList.toggle("react-flow__handle-valid",A))}function D(Y){var P,G;(C||Q)&&B&&A&&(s==null||s(B)),(G=(P=l()).onConnectEnd)==null||G.call(P,Y),h&&(p==null||p(Y)),Ef(M),N(),cancelAnimationFrame(E),H=!1,A=!1,B=null,Q=null,f.removeEventListener("mousemove",Z),f.removeEventListener("mouseup",D),f.removeEventListener("touchmove",Z),f.removeEventListener("touchend",D)}f.addEventListener("mousemove",Z),f.addEventListener("mouseup",D),f.addEventListener("touchmove",Z),f.addEventListener("touchend",D)}const dk=()=>!0,dP=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),hP=(e,t,n)=>s=>{const{connectionStartHandle:a,connectionEndHandle:l,connectionClickStartHandle:c}=s;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n,clickConnecting:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.handleId)===t&&(c==null?void 0:c.type)===n}},vT=b.forwardRef(({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:l=!0,id:c,onConnect:d,children:h,className:p,onMouseDown:f,onTouchStart:m,...y},v)=>{var O,M;const j=c||null,_=e==="target",S=Rt(),x=nP(),{connectOnClick:N,noPanClassName:E}=ct(dP,Dt),{connecting:C,clickConnecting:R}=ct(hP(x,j,e),Dt);x||(M=(O=S.getState()).onError)==null||M.call(O,"010",is.error010());const I=L=>{const{defaultEdgeOptions:H,onConnect:B,hasDefaultEdges:A}=S.getState(),Q={...H,...L};if(A){const{edges:K,setEdges:ee}=S.getState();ee(oP(Q,K))}B==null||B(Q),d==null||d(Q)},$=L=>{if(!x)return;const H=iT(L);a&&(H&&L.button===0||!H)&&wT({event:L,handleId:j,nodeId:x,onConnect:I,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:n||S.getState().isValidConnection||dk}),H?f==null||f(L):m==null||m(L)},F=L=>{const{onClickConnectStart:H,onClickConnectEnd:B,connectionClickStartHandle:A,connectionMode:Q,isValidConnection:K}=S.getState();if(!x||!A&&!a)return;if(!A){H==null||H(L,{nodeId:x,handleId:j,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:x,type:e,handleId:j}});return}const ee=rT(L.target),Z=n||K||dk,{connection:D,isValid:Y}=yT({nodeId:x,id:j,type:e},Q,A.nodeId,A.handleId||null,A.type,Z,ee);Y&&I(D),B==null||B(L),S.setState({connectionClickStartHandle:null})};return fe.createElement("div",{"data-handleid":j,"data-nodeid":x,"data-handlepos":t,"data-id":`${x}-${j}-${e}`,className:Kt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,p,{source:!_,target:_,connectable:s,connectablestart:a,connectableend:l,connecting:R,connectionindicator:s&&(a&&!C||l&&C)}]),onMouseDown:$,onTouchStart:$,onClick:N?F:void 0,ref:v,...y},h)});vT.displayName="Handle";var oi=b.memo(vT);const xT=({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:s=Ue.Bottom})=>fe.createElement(fe.Fragment,null,fe.createElement(oi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,fe.createElement(oi,{type:"source",position:s,isConnectable:t}));xT.displayName="DefaultNode";var xv=b.memo(xT);const bT=({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom})=>fe.createElement(fe.Fragment,null,e==null?void 0:e.label,fe.createElement(oi,{type:"source",position:n,isConnectable:t}));bT.displayName="InputNode";var kT=b.memo(bT);const _T=({data:e,isConnectable:t,targetPosition:n=Ue.Top})=>fe.createElement(fe.Fragment,null,fe.createElement(oi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);_T.displayName="OutputNode";var NT=b.memo(_T);const rx=()=>null;rx.displayName="GroupNode";const fP=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Su=e=>e.id;function pP(e,t){return Dt(e.selectedNodes.map(Su),t.selectedNodes.map(Su))&&Dt(e.selectedEdges.map(Su),t.selectedEdges.map(Su))}const ST=b.memo(({onSelectionChange:e})=>{const t=Rt(),{selectedNodes:n,selectedEdges:s}=ct(fP,pP);return b.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(l=>l(a))},[n,s,e]),null});ST.displayName="SelectionListener";const mP=e=>!!e.onSelectionChange;function gP({onSelectionChange:e}){const t=ct(mP);return e||t?fe.createElement(ST,{onSelectionChange:e}):null}const yP=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 qo(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Je(e,t,n){b.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const wP=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:l,onConnectEnd:c,onClickConnectStart:d,onClickConnectEnd:h,nodesDraggable:p,nodesConnectable:f,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:v,elevateNodesOnSelect:j,minZoom:_,maxZoom:S,nodeExtent:x,onNodesChange:N,onEdgesChange:E,elementsSelectable:C,connectionMode:R,snapGrid:I,snapToGrid:$,translateExtent:F,connectOnClick:O,defaultEdgeOptions:M,fitView:L,fitViewOptions:H,onNodesDelete:B,onEdgesDelete:A,onNodeDrag:Q,onNodeDragStart:K,onNodeDragStop:ee,onSelectionDrag:Z,onSelectionDragStart:D,onSelectionDragStop:Y,noPanClassName:P,nodeOrigin:G,rfId:de,autoPanOnConnect:W,autoPanOnNodeDrag:U,onError:J,connectionRadius:V,isValidConnection:ie,nodeDragThreshold:pe})=>{const{setNodes:me,setEdges:Ie,setDefaultNodesAndEdges:Le,setMinZoom:ce,setMaxZoom:xe,setTranslateExtent:ye,setNodeExtent:ze,reset:ke}=ct(yP,Dt),je=Rt();return b.useEffect(()=>{const Ye=s==null?void 0:s.map(it=>({...it,...M}));return Le(n,Ye),()=>{ke()}},[]),Je("defaultEdgeOptions",M,je.setState),Je("connectionMode",R,je.setState),Je("onConnect",a,je.setState),Je("onConnectStart",l,je.setState),Je("onConnectEnd",c,je.setState),Je("onClickConnectStart",d,je.setState),Je("onClickConnectEnd",h,je.setState),Je("nodesDraggable",p,je.setState),Je("nodesConnectable",f,je.setState),Je("nodesFocusable",m,je.setState),Je("edgesFocusable",y,je.setState),Je("edgesUpdatable",v,je.setState),Je("elementsSelectable",C,je.setState),Je("elevateNodesOnSelect",j,je.setState),Je("snapToGrid",$,je.setState),Je("snapGrid",I,je.setState),Je("onNodesChange",N,je.setState),Je("onEdgesChange",E,je.setState),Je("connectOnClick",O,je.setState),Je("fitViewOnInit",L,je.setState),Je("fitViewOnInitOptions",H,je.setState),Je("onNodesDelete",B,je.setState),Je("onEdgesDelete",A,je.setState),Je("onNodeDrag",Q,je.setState),Je("onNodeDragStart",K,je.setState),Je("onNodeDragStop",ee,je.setState),Je("onSelectionDrag",Z,je.setState),Je("onSelectionDragStart",D,je.setState),Je("onSelectionDragStop",Y,je.setState),Je("noPanClassName",P,je.setState),Je("nodeOrigin",G,je.setState),Je("rfId",de,je.setState),Je("autoPanOnConnect",W,je.setState),Je("autoPanOnNodeDrag",U,je.setState),Je("onError",J,je.setState),Je("connectionRadius",V,je.setState),Je("isValidConnection",ie,je.setState),Je("nodeDragThreshold",pe,je.setState),qo(e,me),qo(t,Ie),qo(_,ce),qo(S,xe),qo(F,ye),qo(x,ze),null},hk={display:"none"},vP={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},jT="react-flow__node-desc",ET="react-flow__edge-desc",xP="react-flow__aria-live",bP=e=>e.ariaLiveMessage;function kP({rfId:e}){const t=ct(bP);return fe.createElement("div",{id:`${xP}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vP},t)}function _P({rfId:e,disableKeyboardA11y:t}){return fe.createElement(fe.Fragment,null,fe.createElement("div",{id:`${jT}-${e}`,style:hk},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),fe.createElement("div",{id:`${ET}-${e}`,style:hk},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&fe.createElement(kP,{rfId:e}))}var Dl=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=b.useState(!1),a=b.useRef(!1),l=b.useRef(new Set([])),[c,d]=b.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),f=p.reduce((m,y)=>m.concat(...y),[]);return[p,f]}return[[],[]]},[e]);return b.useEffect(()=>{const h=typeof document<"u"?document:null,p=(t==null?void 0:t.target)||h;if(e!==null){const f=v=>{if(a.current=v.ctrlKey||v.metaKey||v.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&gv(v))return!1;const _=pk(v.code,d);l.current.add(v[_]),fk(c,l.current,!1)&&(v.preventDefault(),s(!0))},m=v=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&gv(v))return!1;const _=pk(v.code,d);fk(c,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(v[_]),v.key==="Meta"&&l.current.clear(),a.current=!1},y=()=>{l.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",f),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",f),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),n};function fk(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function pk(e,t){return t.includes(e)?"code":"key"}function CT(e,t,n,s){var d,h;const a=e.parentNode||e.parentId;if(!a)return n;const l=t.get(a),c=Ya(l,s);return CT(l,t,{x:(n.x??0)+c.x,y:(n.y??0)+c.y,z:(((d=l[St])==null?void 0:d.z)??0)>(n.z??0)?((h=l[St])==null?void 0:h.z)??0:n.z??0},s)}function TT(e,t,n){e.forEach(s=>{var l;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:c,y:d,z:h}=CT(s,e,{...s.position,z:((l=s[St])==null?void 0:l.z)??0},t);s.positionAbsolute={x:c,y:d},s[St].z=h,n!=null&&n[s.id]&&(s[St].isParent=!0)}})}function Cf(e,t,n,s){const a=new Map,l={},c=s?1e3:0;return e.forEach(d=>{var v;const h=(Hn(d.zIndex)?d.zIndex:0)+(d.selected?c:0),p=t.get(d.id),f={...d,positionAbsolute:{x:d.position.x,y:d.position.y}},m=d.parentNode||d.parentId;m&&(l[m]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==d.type;Object.defineProperty(f,St,{enumerable:!1,value:{handleBounds:y||(v=p==null?void 0:p[St])==null?void 0:v.handleBounds,z:h}}),a.set(d.id,f)}),TT(a,n,l),a}function AT(e,t={}){const{getNodes:n,width:s,height:a,minZoom:l,maxZoom:c,d3Zoom:d,d3Selection:h,fitViewOnInitDone:p,fitViewOnInit:f,nodeOrigin:m}=e(),y=t.initial&&!p&&f;if(d&&h&&(y||!t.initial)){const j=n().filter(S=>{var N;const x=t.includeHiddenNodes?S.width&&S.height:!S.hidden;return(N=t.nodes)!=null&&N.length?x&&t.nodes.some(E=>E.id===S.id):x}),_=j.every(S=>S.width&&S.height);if(j.length>0&&_){const S=bd(j,m),{x,y:N,zoom:E}=mT(S,s,a,t.minZoom??l,t.maxZoom??c,t.padding??.1),C=ss.translate(x,N).scale(E);return typeof t.duration=="number"&&t.duration>0?d.transform(Wa(h,t.duration),C):d.transform(h,C),!0}}return!1}function NP(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[St]:s[St],selected:n.selected})}),new Map(t)}function SP(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function ju({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:l,onNodesChange:c,onEdgesChange:d,hasDefaultNodes:h,hasDefaultEdges:p}=n();e!=null&&e.length&&(h&&s({nodeInternals:NP(e,a)}),c==null||c(e)),t!=null&&t.length&&(p&&s({edges:SP(t,l)}),d==null||d(t))}const Fo=()=>{},jP={zoomIn:Fo,zoomOut:Fo,zoomTo:Fo,getZoom:()=>1,setViewport:Fo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Fo,fitBounds:Fo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},EP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),CP=()=>{const e=Rt(),{d3Zoom:t,d3Selection:n}=ct(EP,Dt);return b.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Wa(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Wa(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,l)=>t.scaleTo(Wa(n,l==null?void 0:l.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,l)=>{const[c,d,h]=e.getState().transform,p=ss.translate(a.x??c,a.y??d).scale(a.zoom??h);t.transform(Wa(n,l==null?void 0:l.duration),p)},getViewport:()=>{const[a,l,c]=e.getState().transform;return{x:a,y:l,zoom:c}},fitView:a=>AT(e.getState,a),setCenter:(a,l,c)=>{const{width:d,height:h,maxZoom:p}=e.getState(),f=typeof(c==null?void 0:c.zoom)<"u"?c.zoom:p,m=d/2-a*f,y=h/2-l*f,v=ss.translate(m,y).scale(f);t.transform(Wa(n,c==null?void 0:c.duration),v)},fitBounds:(a,l)=>{const{width:c,height:d,minZoom:h,maxZoom:p}=e.getState(),{x:f,y:m,zoom:y}=mT(a,c,d,h,p,(l==null?void 0:l.padding)??.1),v=ss.translate(f,m).scale(y);t.transform(Wa(n,l==null?void 0:l.duration),v)},project:a=>{const{transform:l,snapToGrid:c,snapGrid:d}=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"),vv(a,l,c,d)},screenToFlowPosition:a=>{const{transform:l,snapToGrid:c,snapGrid:d,domNode:h}=e.getState();if(!h)return a;const{x:p,y:f}=h.getBoundingClientRect(),m={x:a.x-p,y:a.y-f};return vv(m,l,c,d)},flowToScreenPosition:a=>{const{transform:l,domNode:c}=e.getState();if(!c)return a;const{x:d,y:h}=c.getBoundingClientRect(),p=hT(a,l);return{x:p.x+d,y:p.y+h}},viewportInitialized:!0}:jP,[t,n])};function Yl(){const e=CP(),t=Rt(),n=b.useCallback(()=>t.getState().getNodes().map(_=>({..._})),[]),s=b.useCallback(_=>t.getState().nodeInternals.get(_),[]),a=b.useCallback(()=>{const{edges:_=[]}=t.getState();return _.map(S=>({...S}))},[]),l=b.useCallback(_=>{const{edges:S=[]}=t.getState();return S.find(x=>x.id===_)},[]),c=b.useCallback(_=>{const{getNodes:S,setNodes:x,hasDefaultNodes:N,onNodesChange:E}=t.getState(),C=S(),R=typeof _=="function"?_(C):_;if(N)x(R);else if(E){const I=R.length===0?C.map($=>({type:"remove",id:$.id})):R.map($=>({item:$,type:"reset"}));E(I)}},[]),d=b.useCallback(_=>{const{edges:S=[],setEdges:x,hasDefaultEdges:N,onEdgesChange:E}=t.getState(),C=typeof _=="function"?_(S):_;if(N)x(C);else if(E){const R=C.length===0?S.map(I=>({type:"remove",id:I.id})):C.map(I=>({item:I,type:"reset"}));E(R)}},[]),h=b.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:x,setNodes:N,hasDefaultNodes:E,onNodesChange:C}=t.getState();if(E){const I=[...x(),...S];N(I)}else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),p=b.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:x=[],setEdges:N,hasDefaultEdges:E,onEdgesChange:C}=t.getState();if(E)N([...x,...S]);else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),f=b.useCallback(()=>{const{getNodes:_,edges:S=[],transform:x}=t.getState(),[N,E,C]=x;return{nodes:_().map(R=>({...R})),edges:S.map(R=>({...R})),viewport:{x:N,y:E,zoom:C}}},[]),m=b.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:x,getNodes:N,edges:E,hasDefaultNodes:C,hasDefaultEdges:R,onNodesDelete:I,onEdgesDelete:$,onNodesChange:F,onEdgesChange:O}=t.getState(),M=(_||[]).map(Q=>Q.id),L=(S||[]).map(Q=>Q.id),H=N().reduce((Q,K)=>{const ee=K.parentNode||K.parentId,Z=!M.includes(K.id)&&ee&&Q.find(Y=>Y.id===ee);return(typeof K.deletable=="boolean"?K.deletable:!0)&&(M.includes(K.id)||Z)&&Q.push(K),Q},[]),B=E.filter(Q=>typeof Q.deletable=="boolean"?Q.deletable:!0),A=B.filter(Q=>L.includes(Q.id));if(H||A){const Q=pT(H,B),K=[...A,...Q],ee=K.reduce((Z,D)=>(Z.includes(D.id)||Z.push(D.id),Z),[]);if((R||C)&&(R&&t.setState({edges:E.filter(Z=>!ee.includes(Z.id))}),C&&(H.forEach(Z=>{x.delete(Z.id)}),t.setState({nodeInternals:new Map(x)}))),ee.length>0&&($==null||$(K),O&&O(ee.map(Z=>({id:Z,type:"remove"})))),H.length>0&&(I==null||I(H),F)){const Z=H.map(D=>({id:D.id,type:"remove"}));F(Z)}}},[]),y=b.useCallback(_=>{const S=YO(_),x=S?null:t.getState().nodeInternals.get(_.id);return!S&&!x?[null,null,S]:[S?_:ak(x),x,S]},[]),v=b.useCallback((_,S=!0,x)=>{const[N,E,C]=y(_);return N?(x||t.getState().getNodes()).filter(R=>{if(!C&&(R.id===E.id||!R.positionAbsolute))return!1;const I=ak(R),$=mv(I,N);return S&&$>0||$>=N.width*N.height}):[]},[]),j=b.useCallback((_,S,x=!0)=>{const[N]=y(_);if(!N)return!1;const E=mv(N,S);return x&&E>0||E>=N.width*N.height},[]);return b.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:l,setNodes:c,setEdges:d,addNodes:h,addEdges:p,toObject:f,deleteElements:m,getIntersectingNodes:v,isNodeIntersecting:j}),[e,n,s,a,l,c,d,h,p,f,m,v,j])}const TP={actInsideInputWithModifier:!1};var AP=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Rt(),{deleteElements:s}=Yl(),a=Dl(e,TP),l=Dl(t);b.useEffect(()=>{if(a){const{edges:c,getNodes:d}=n.getState(),h=d().filter(f=>f.selected),p=c.filter(f=>f.selected);s({nodes:h,edges:p}),n.setState({nodesSelectionActive:!1})}},[a]),b.useEffect(()=>{n.setState({multiSelectionActive:l})},[l])};function RP(e){const t=Rt();b.useEffect(()=>{let n;const s=()=>{var l,c;if(!e.current)return;const a=Xv(e.current);(a.height===0||a.width===0)&&((c=(l=t.getState()).onError)==null||c.call(l,"004",is.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 sx={position:"absolute",width:"100%",height:"100%",top:0,left:0},MP=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Eu=e=>({x:e.x,y:e.y,zoom:e.k}),Bo=(e,t)=>e.target.closest(`.${t}`),mk=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),gk=e=>{const t=e.ctrlKey&&td()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},IP=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),$P=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:l=!0,panOnScroll:c=!1,panOnScrollSpeed:d=.5,panOnScrollMode:h=Ga.Free,zoomOnDoubleClick:p=!0,elementsSelectable:f,panOnDrag:m=!0,defaultViewport:y,translateExtent:v,minZoom:j,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:x=!0,children:N,noWheelClassName:E,noPanClassName:C})=>{const R=b.useRef(),I=Rt(),$=b.useRef(!1),F=b.useRef(!1),O=b.useRef(null),M=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:H,d3ZoomHandler:B,userSelectionActive:A}=ct(IP,Dt),Q=Dl(S),K=b.useRef(0),ee=b.useRef(!1),Z=b.useRef();return RP(O),b.useEffect(()=>{if(O.current){const D=O.current.getBoundingClientRect(),Y=eT().scaleExtent([j,_]).translateExtent(v),P=Wn(O.current).call(Y),G=ss.translate(y.x,y.y).scale(ai(y.zoom,j,_)),de=[[0,0],[D.width,D.height]],W=Y.constrain()(G,de,v);Y.transform(P,W),Y.wheelDelta(gk),I.setState({d3Zoom:Y,d3Selection:P,d3ZoomHandler:P.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:O.current.closest(".react-flow")})}},[]),b.useEffect(()=>{H&&L&&(c&&!Q&&!A?H.on("wheel.zoom",D=>{if(Bo(D,E))return!1;D.preventDefault(),D.stopImmediatePropagation();const Y=H.property("__zoom").k||1;if(D.ctrlKey&&l){const ie=lr(D),pe=gk(D),me=Y*Math.pow(2,pe);L.scaleTo(H,me,ie,D);return}const P=D.deltaMode===1?20:1;let G=h===Ga.Vertical?0:D.deltaX*P,de=h===Ga.Horizontal?0:D.deltaY*P;!td()&&D.shiftKey&&h!==Ga.Vertical&&(G=D.deltaY*P,de=0),L.translateBy(H,-(G/Y)*d,-(de/Y)*d,{internal:!0});const W=Eu(H.property("__zoom")),{onViewportChangeStart:U,onViewportChange:J,onViewportChangeEnd:V}=I.getState();clearTimeout(Z.current),ee.current||(ee.current=!0,t==null||t(D,W),U==null||U(W)),ee.current&&(e==null||e(D,W),J==null||J(W),Z.current=setTimeout(()=>{n==null||n(D,W),V==null||V(W),ee.current=!1},150))},{passive:!1}):typeof B<"u"&&H.on("wheel.zoom",function(D,Y){if(!x&&D.type==="wheel"&&!D.ctrlKey||Bo(D,E))return null;D.preventDefault(),B.call(this,D,Y)},{passive:!1}))},[A,c,h,H,L,B,Q,l,x,E,t,e,n]),b.useEffect(()=>{L&&L.on("start",D=>{var G,de;if(!D.sourceEvent||D.sourceEvent.internal)return null;K.current=(G=D.sourceEvent)==null?void 0:G.button;const{onViewportChangeStart:Y}=I.getState(),P=Eu(D.transform);$.current=!0,M.current=P,((de=D.sourceEvent)==null?void 0:de.type)==="mousedown"&&I.setState({paneDragging:!0}),Y==null||Y(P),t==null||t(D.sourceEvent,P)})},[L,t]),b.useEffect(()=>{L&&(A&&!$.current?L.on("zoom",null):A||L.on("zoom",D=>{var P;const{onViewportChange:Y}=I.getState();if(I.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),F.current=!!(s&&mk(m,K.current??0)),(e||Y)&&!((P=D.sourceEvent)!=null&&P.internal)){const G=Eu(D.transform);Y==null||Y(G),e==null||e(D.sourceEvent,G)}}))},[A,L,e,m,s]),b.useEffect(()=>{L&&L.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:Y}=I.getState();if($.current=!1,I.setState({paneDragging:!1}),s&&mk(m,K.current??0)&&!F.current&&s(D.sourceEvent),F.current=!1,(n||Y)&&MP(M.current,D.transform)){const P=Eu(D.transform);M.current=P,clearTimeout(R.current),R.current=setTimeout(()=>{Y==null||Y(P),n==null||n(D.sourceEvent,P)},c?150:0)}})},[L,c,m,n,s]),b.useEffect(()=>{L&&L.filter(D=>{const Y=Q||a,P=l&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(Bo(D,"react-flow__node")||Bo(D,"react-flow__edge")))return!0;if(!m&&!Y&&!c&&!p&&!l||A||!p&&D.type==="dblclick"||Bo(D,E)&&D.type==="wheel"||Bo(D,C)&&(D.type!=="wheel"||c&&D.type==="wheel"&&!Q)||!l&&D.ctrlKey&&D.type==="wheel"||!Y&&!c&&!P&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const G=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&G})},[A,L,a,l,c,p,m,f,Q]),fe.createElement("div",{className:"react-flow__renderer",ref:O,style:sx},N)},OP=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function PP(){const{userSelectionActive:e,userSelectionRect:t}=ct(OP,Dt);return e&&t?fe.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function yk(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,l=t.position.y+t.height-s.height;if(a>0||l>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),l>0&&(s.style.height+=l),t.position.x<0){const c=Math.abs(t.position.x);s.position.x=s.position.x-c,s.style.width+=c,t.position.x=0}if(t.position.y<0){const c=Math.abs(t.position.y);s.position.y=s.position.y-c,s.style.height+=c,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function LP(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 l=e.filter(d=>d.id===a.id);if(l.length===0)return s.push(a),s;const c={...a};for(const d of l)if(d)switch(d.type){case"select":{c.selected=d.selected;break}case"position":{typeof d.position<"u"&&(c.position=d.position),typeof d.positionAbsolute<"u"&&(c.positionAbsolute=d.positionAbsolute),typeof d.dragging<"u"&&(c.dragging=d.dragging),c.expandParent&&yk(s,c);break}case"dimensions":{typeof d.dimensions<"u"&&(c.width=d.dimensions.width,c.height=d.dimensions.height),typeof d.updateStyle<"u"&&(c.style={...c.style||{},...d.dimensions}),typeof d.resizing=="boolean"&&(c.resizing=d.resizing),c.expandParent&&yk(s,c);break}case"remove":return s}return s.push(c),s},n)}function DP(e,t){return LP(e,t)}const Hs=(e,t)=>({id:e,type:"select",selected:t});function Yo(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Hs(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Hs(s.id,!1))),n},[])}const Tf=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},qP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),RT=b.memo(({isSelecting:e,selectionMode:t=Ll.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:f,children:m})=>{const y=b.useRef(null),v=Rt(),j=b.useRef(0),_=b.useRef(0),S=b.useRef(),{userSelectionActive:x,elementsSelectable:N,dragging:E}=ct(qP,Dt),C=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,_.current=0},R=B=>{l==null||l(B),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},I=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}c==null||c(B)},$=d?B=>d(B):void 0,F=B=>{const{resetSelectedElements:A,domNode:Q}=v.getState();if(S.current=Q==null?void 0:Q.getBoundingClientRect(),!N||!e||B.button!==0||B.target!==y.current||!S.current)return;const{x:K,y:ee}=Vs(B,S.current);A(),v.setState({userSelectionRect:{width:0,height:0,startX:K,startY:ee,x:K,y:ee}}),s==null||s(B)},O=B=>{const{userSelectionRect:A,nodeInternals:Q,edges:K,transform:ee,onNodesChange:Z,onEdgesChange:D,nodeOrigin:Y,getNodes:P}=v.getState();if(!e||!S.current||!A)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const G=Vs(B,S.current),de=A.startX??0,W=A.startY??0,U={...A,x:G.x<de?G.x:de,y:G.y<W?G.y:W,width:Math.abs(G.x-de),height:Math.abs(G.y-W)},J=P(),V=fT(Q,U,ee,t===Ll.Partial,!0,Y),ie=pT(V,K).map(me=>me.id),pe=V.map(me=>me.id);if(j.current!==pe.length){j.current=pe.length;const me=Yo(J,pe);me.length&&(Z==null||Z(me))}if(_.current!==ie.length){_.current=ie.length;const me=Yo(K,ie);me.length&&(D==null||D(me))}v.setState({userSelectionRect:U})},M=B=>{if(B.button!==0)return;const{userSelectionRect:A}=v.getState();!x&&A&&B.target===y.current&&(R==null||R(B)),v.setState({nodesSelectionActive:j.current>0}),C(),a==null||a(B)},L=B=>{x&&(v.setState({nodesSelectionActive:j.current>0}),a==null||a(B)),C()},H=N&&(e||x);return fe.createElement("div",{className:Kt(["react-flow__pane",{dragging:E,selection:e}]),onClick:H?void 0:Tf(R,y),onContextMenu:Tf(I,y),onWheel:Tf($,y),onMouseEnter:H?void 0:h,onMouseDown:H?F:void 0,onMouseMove:H?O:p,onMouseUp:H?M:void 0,onMouseLeave:H?L:f,ref:y,style:sx},m,fe.createElement(PP,null))});RT.displayName="Pane";function MT(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:MT(s,t):!1}function wk(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 FP(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!MT(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var l,c;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((l=a.positionAbsolute)==null?void 0:l.x)??0),y:n.y-(((c=a.positionAbsolute)==null?void 0:c.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 BP(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function IT(e,t,n,s,a=[0,0],l){const c=BP(e,e.extent||s);let d=c;const h=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(h&&e.width&&e.height){const m=n.get(h),{x:y,y:v}=Ya(m,a).positionAbsolute;d=m&&Hn(y)&&Hn(v)&&Hn(m.width)&&Hn(m.height)?[[y+e.width*a[0],v+e.height*a[1]],[y+m.width-e.width+e.width*a[0],v+m.height-e.height+e.height*a[1]]]:d}else l==null||l("005",is.error005()),d=c;else if(e.extent&&h&&e.extent!=="parent"){const m=n.get(h),{x:y,y:v}=Ya(m,a).positionAbsolute;d=[[e.extent[0][0]+y,e.extent[0][1]+v],[e.extent[1][0]+y,e.extent[1][1]+v]]}let p={x:0,y:0};if(h){const m=n.get(h);p=Ya(m,a).positionAbsolute}const f=d&&d!=="parent"?Qv(t,d):t;return{position:{x:f.x-p.x,y:f.y-p.y},positionAbsolute:f}}function Af({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 vk=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const l=Array.from(a),c=t.getBoundingClientRect(),d={x:c.width*s[0],y:c.height*s[1]};return l.map(h=>{const p=h.getBoundingClientRect();return{id:h.getAttribute("data-handleid"),position:h.getAttribute("data-handlepos"),x:(p.left-c.left-d.x)/n,y:(p.top-c.top-d.y)/n,...Xv(h)}})};function wl(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function bv({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:l,multiSelectionActive:c,nodeInternals:d,onError:h}=t.getState(),p=d.get(e);if(!p){h==null||h("012",is.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(n||p.selected&&c)&&(l({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):a([e])}function zP(){const e=Rt();return b.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,snapToGrid:l}=e.getState(),c=n.touches?n.touches[0].clientX:n.clientX,d=n.touches?n.touches[0].clientY:n.clientY,h={x:(c-s[0])/s[2],y:(d-s[1])/s[2]};return{xSnapped:l?a[0]*Math.round(h.x/a[0]):h.x,ySnapped:l?a[1]*Math.round(h.y/a[1]):h.y,...h}},[])}function Rf(e){return(t,n,s)=>e==null?void 0:e(t,s)}function $T({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:l,selectNodesOnDrag:c}){const d=Rt(),[h,p]=b.useState(!1),f=b.useRef([]),m=b.useRef({x:null,y:null}),y=b.useRef(0),v=b.useRef(null),j=b.useRef({x:0,y:0}),_=b.useRef(null),S=b.useRef(!1),x=b.useRef(!1),N=b.useRef(!1),E=zP();return b.useEffect(()=>{if(e!=null&&e.current){const C=Wn(e.current),R=({x:F,y:O})=>{const{nodeInternals:M,onNodeDrag:L,onSelectionDrag:H,updateNodePositions:B,nodeExtent:A,snapGrid:Q,snapToGrid:K,nodeOrigin:ee,onError:Z}=d.getState();m.current={x:F,y:O};let D=!1,Y={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&A){const G=bd(f.current,ee);Y=Pl(G)}if(f.current=f.current.map(G=>{const de={x:F-G.distance.x,y:O-G.distance.y};K&&(de.x=Q[0]*Math.round(de.x/Q[0]),de.y=Q[1]*Math.round(de.y/Q[1]));const W=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];f.current.length>1&&A&&!G.extent&&(W[0][0]=G.positionAbsolute.x-Y.x+A[0][0],W[1][0]=G.positionAbsolute.x+(G.width??0)-Y.x2+A[1][0],W[0][1]=G.positionAbsolute.y-Y.y+A[0][1],W[1][1]=G.positionAbsolute.y+(G.height??0)-Y.y2+A[1][1]);const U=IT(G,de,M,W,ee,Z);return D=D||G.position.x!==U.position.x||G.position.y!==U.position.y,G.position=U.position,G.positionAbsolute=U.positionAbsolute,G}),!D)return;B(f.current,!0,!0),p(!0);const P=a?L:Rf(H);if(P&&_.current){const[G,de]=Af({nodeId:a,dragItems:f.current,nodeInternals:M});P(_.current,G,de)}},I=()=>{if(!v.current)return;const[F,O]=nT(j.current,v.current);if(F!==0||O!==0){const{transform:M,panBy:L}=d.getState();m.current.x=(m.current.x??0)-F/M[2],m.current.y=(m.current.y??0)-O/M[2],L({x:F,y:O})&&R(m.current)}y.current=requestAnimationFrame(I)},$=F=>{var ee;const{nodeInternals:O,multiSelectionActive:M,nodesDraggable:L,unselectNodesAndEdges:H,onNodeDragStart:B,onSelectionDragStart:A}=d.getState();x.current=!0;const Q=a?B:Rf(A);(!c||!l)&&!M&&a&&((ee=O.get(a))!=null&&ee.selected||H()),a&&l&&c&&bv({id:a,store:d,nodeRef:e});const K=E(F);if(m.current=K,f.current=FP(O,L,K,a),Q&&f.current){const[Z,D]=Af({nodeId:a,dragItems:f.current,nodeInternals:O});Q(F.sourceEvent,Z,D)}};if(t)C.on(".drag",null);else{const F=ZI().on("start",O=>{const{domNode:M,nodeDragThreshold:L}=d.getState();L===0&&$(O),N.current=!1;const H=E(O);m.current=H,v.current=(M==null?void 0:M.getBoundingClientRect())||null,j.current=Vs(O.sourceEvent,v.current)}).on("drag",O=>{var B,A;const M=E(O),{autoPanOnNodeDrag:L,nodeDragThreshold:H}=d.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!S.current&&x.current&&L&&(S.current=!0,I()),!x.current){const Q=M.xSnapped-(((B=m==null?void 0:m.current)==null?void 0:B.x)??0),K=M.ySnapped-(((A=m==null?void 0:m.current)==null?void 0:A.y)??0);Math.sqrt(Q*Q+K*K)>H&&$(O)}(m.current.x!==M.xSnapped||m.current.y!==M.ySnapped)&&f.current&&x.current&&(_.current=O.sourceEvent,j.current=Vs(O.sourceEvent,v.current),R(M))}}).on("end",O=>{if(!(!x.current||N.current)&&(p(!1),S.current=!1,x.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:M,nodeInternals:L,onNodeDragStop:H,onSelectionDragStop:B}=d.getState(),A=a?H:Rf(B);if(M(f.current,!1,!1),A){const[Q,K]=Af({nodeId:a,dragItems:f.current,nodeInternals:L});A(O.sourceEvent,Q,K)}}}).filter(O=>{const M=O.target;return!O.button&&(!n||!wk(M,`.${n}`,e))&&(!s||wk(M,s,e))});return C.call(F),()=>{C.on(".drag",null)}}}},[e,t,n,s,l,d,a,c,E]),h}function OT(){const e=Rt();return b.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:l,getNodes:c,snapToGrid:d,snapGrid:h,onError:p,nodesDraggable:f}=e.getState(),m=c().filter(N=>N.selected&&(N.draggable||f&&typeof N.draggable>"u")),y=d?h[0]:5,v=d?h[1]:5,j=n.isShiftPressed?4:1,_=n.x*y*j,S=n.y*v*j,x=m.map(N=>{if(N.positionAbsolute){const E={x:N.positionAbsolute.x+_,y:N.positionAbsolute.y+S};d&&(E.x=h[0]*Math.round(E.x/h[0]),E.y=h[1]*Math.round(E.y/h[1]));const{positionAbsolute:C,position:R}=IT(N,E,s,a,void 0,p);N.position=R,N.positionAbsolute=C}return N});l(x,!0,!1)},[])}const ei={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var vl=e=>{const t=({id:n,type:s,data:a,xPos:l,yPos:c,xPosOrigin:d,yPosOrigin:h,selected:p,onClick:f,onMouseEnter:m,onMouseMove:y,onMouseLeave:v,onContextMenu:j,onDoubleClick:_,style:S,className:x,isDraggable:N,isSelectable:E,isConnectable:C,isFocusable:R,selectNodesOnDrag:I,sourcePosition:$,targetPosition:F,hidden:O,resizeObserver:M,dragHandle:L,zIndex:H,isParent:B,noDragClassName:A,noPanClassName:Q,initialized:K,disableKeyboardA11y:ee,ariaLabel:Z,rfId:D,hasHandleBounds:Y})=>{const P=Rt(),G=b.useRef(null),de=b.useRef(null),W=b.useRef($),U=b.useRef(F),J=b.useRef(s),V=E||N||f||m||y||v,ie=OT(),pe=wl(n,P.getState,m),me=wl(n,P.getState,y),Ie=wl(n,P.getState,v),Le=wl(n,P.getState,j),ce=wl(n,P.getState,_),xe=ke=>{const{nodeDragThreshold:je}=P.getState();if(E&&(!I||!N||je>0)&&bv({id:n,store:P,nodeRef:G}),f){const Ye=P.getState().nodeInternals.get(n);Ye&&f(ke,{...Ye})}},ye=ke=>{if(!gv(ke)&&!ee)if(oT.includes(ke.key)&&E){const je=ke.key==="Escape";bv({id:n,store:P,unselect:je,nodeRef:G})}else N&&p&&Object.prototype.hasOwnProperty.call(ei,ke.key)&&(P.setState({ariaLiveMessage:`Moved selected node ${ke.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~c}`}),ie({x:ei[ke.key].x,y:ei[ke.key].y,isShiftPressed:ke.shiftKey}))};b.useEffect(()=>()=>{de.current&&(M==null||M.unobserve(de.current),de.current=null)},[]),b.useEffect(()=>{if(G.current&&!O){const ke=G.current;(!K||!Y||de.current!==ke)&&(de.current&&(M==null||M.unobserve(de.current)),M==null||M.observe(ke),de.current=ke)}},[O,K,Y]),b.useEffect(()=>{const ke=J.current!==s,je=W.current!==$,Ye=U.current!==F;G.current&&(ke||je||Ye)&&(ke&&(J.current=s),je&&(W.current=$),Ye&&(U.current=F),P.getState().updateNodeDimensions([{id:n,nodeElement:G.current,forceUpdate:!0}]))},[n,s,$,F]);const ze=$T({nodeRef:G,disabled:O||!N,noDragClassName:A,handleSelector:L,nodeId:n,isSelectable:E,selectNodesOnDrag:I});return O?null:fe.createElement("div",{className:Kt(["react-flow__node",`react-flow__node-${s}`,{[Q]:N},x,{selected:p,selectable:E,parent:B,dragging:ze}]),ref:G,style:{zIndex:H,transform:`translate(${d}px,${h}px)`,pointerEvents:V?"all":"none",visibility:K?"visible":"hidden",...S},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:pe,onMouseMove:me,onMouseLeave:Ie,onContextMenu:Le,onClick:xe,onDoubleClick:ce,onKeyDown:R?ye:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":ee?void 0:`${jT}-${D}`,"aria-label":Z},fe.createElement(tP,{value:n},fe.createElement(e,{id:n,data:a,type:s,xPos:l,yPos:c,selected:p,isConnectable:C,sourcePosition:$,targetPosition:F,dragging:ze,dragHandle:L,zIndex:H})))};return t.displayName="NodeWrapper",b.memo(t)};const UP=e=>{const t=e.getNodes().filter(n=>n.selected);return{...bd(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function WP({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Rt(),{width:a,height:l,x:c,y:d,transformString:h,userSelectionActive:p}=ct(UP,Dt),f=OT(),m=b.useRef(null);if(b.useEffect(()=>{var j;n||(j=m.current)==null||j.focus({preventScroll:!0})},[n]),$T({nodeRef:m}),p||!a||!l)return null;const y=e?j=>{const _=s.getState().getNodes().filter(S=>S.selected);e(j,_)}:void 0,v=j=>{Object.prototype.hasOwnProperty.call(ei,j.key)&&f({x:ei[j.key].x,y:ei[j.key].y,isShiftPressed:j.shiftKey})};return fe.createElement("div",{className:Kt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:h}},fe.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:a,height:l,top:d,left:c}}))}var HP=b.memo(WP);const GP=e=>e.nodesSelectionActive,PT=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,deleteKeyCode:d,onMove:h,onMoveStart:p,onMoveEnd:f,selectionKeyCode:m,selectionOnDrag:y,selectionMode:v,onSelectionStart:j,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:N,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:M,defaultViewport:L,translateExtent:H,minZoom:B,maxZoom:A,preventScrolling:Q,onSelectionContextMenu:K,noWheelClassName:ee,noPanClassName:Z,disableKeyboardA11y:D})=>{const Y=ct(GP),P=Dl(m),G=Dl(x),de=G||M,W=G||I,U=P||y&&de!==!0;return AP({deleteKeyCode:d,multiSelectionKeyCode:S}),fe.createElement($P,{onMove:h,onMoveStart:p,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:W,panOnScrollSpeed:$,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:!P&&de,defaultViewport:L,translateExtent:H,minZoom:B,maxZoom:A,zoomActivationKeyCode:N,preventScrolling:Q,noWheelClassName:ee,noPanClassName:Z},fe.createElement(RT,{onSelectionStart:j,onSelectionEnd:_,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:de,isSelecting:!!U,selectionMode:v},e,Y&&fe.createElement(HP,{onSelectionContextMenu:K,noPanClassName:Z,disableKeyboardA11y:D})))};PT.displayName="FlowRenderer";var VP=b.memo(PT);function YP(e){return ct(b.useCallback(n=>e?fT(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function KP(e){const t={input:vl(e.input||kT),default:vl(e.default||xv),output:vl(e.output||NT),group:vl(e.group||rx)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,l)=>(a[l]=vl(e[l]||xv),a),n);return{...t,...s}}const XP=({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]},QP=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),LT=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:l,onError:c}=ct(QP,Dt),d=YP(e.onlyRenderVisibleElements),h=b.useRef(),p=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(m=>{const y=m.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));l(y)});return h.current=f,f},[]);return b.useEffect(()=>()=>{var f;(f=h==null?void 0:h.current)==null||f.disconnect()},[]),fe.createElement("div",{className:"react-flow__nodes",style:sx},d.map(f=>{var R,I,$;let m=f.type||"default";e.nodeTypes[m]||(c==null||c("003",is.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),j=!!(f.selectable||a&&typeof f.selectable>"u"),_=!!(f.connectable||n&&typeof f.connectable>"u"),S=!!(f.focusable||s&&typeof f.focusable>"u"),x=e.nodeExtent?Qv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(x==null?void 0:x.x)??0,E=(x==null?void 0:x.y)??0,C=XP({x:N,y:E,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return fe.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:m,data:f.data,sourcePosition:f.sourcePosition||Ue.Bottom,targetPosition:f.targetPosition||Ue.Top,hidden:f.hidden,xPos:N,yPos:E,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:v,isSelectable:j,isConnectable:_,isFocusable:S,resizeObserver:p,dragHandle:f.dragHandle,zIndex:((R=f[St])==null?void 0:R.z)??0,isParent:!!((I=f[St])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!(($=f[St])!=null&&$.handleBounds)})}))};LT.displayName="NodeRenderer";var ZP=b.memo(LT);const JP=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,e3=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,xk="react-flow__edgeupdater",bk=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:l,onMouseOut:c,type:d})=>fe.createElement("circle",{onMouseDown:a,onMouseEnter:l,onMouseOut:c,className:Kt([xk,`${xk}-${d}`]),cx:JP(t,s,e),cy:e3(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),t3=()=>!0;var zo=e=>{const t=({id:n,className:s,type:a,data:l,onClick:c,onEdgeDoubleClick:d,selected:h,animated:p,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:_,style:S,source:x,target:N,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:$,targetPosition:F,elementsSelectable:O,hidden:M,sourceHandleId:L,targetHandleId:H,onContextMenu:B,onMouseEnter:A,onMouseMove:Q,onMouseLeave:K,reconnectRadius:ee,onReconnect:Z,onReconnectStart:D,onReconnectEnd:Y,markerEnd:P,markerStart:G,rfId:de,ariaLabel:W,isFocusable:U,isReconnectable:J,pathOptions:V,interactionWidth:ie,disableKeyboardA11y:pe})=>{const me=b.useRef(null),[Ie,Le]=b.useState(!1),[ce,xe]=b.useState(!1),ye=Rt(),ze=b.useMemo(()=>`url('#${wv(G,de)}')`,[G,de]),ke=b.useMemo(()=>`url('#${wv(P,de)}')`,[P,de]);if(M)return null;const je=ne=>{var ut;const{edges:De,addSelectedEdges:Oe,unselectNodesAndEdges:Te,multiSelectionActive:Ce}=ye.getState(),lt=De.find(Re=>Re.id===n);lt&&(O&&(ye.setState({nodesSelectionActive:!1}),lt.selected&&Ce?(Te({nodes:[],edges:[lt]}),(ut=me.current)==null||ut.blur()):Oe([n])),c&&c(ne,lt))},Ye=yl(n,ye.getState,d),it=yl(n,ye.getState,B),Ne=yl(n,ye.getState,A),He=yl(n,ye.getState,Q),Xe=yl(n,ye.getState,K),he=(ne,De)=>{if(ne.button!==0)return;const{edges:Oe,isValidConnection:Te}=ye.getState(),Ce=De?N:x,lt=(De?H:L)||null,ut=De?"target":"source",Re=Te||t3,mt=De,ft=Oe.find(Tn=>Tn.id===n);xe(!0),D==null||D(ne,ft,ut);const bt=Tn=>{xe(!1),Y==null||Y(Tn,ft,ut)};wT({event:ne,handleId:lt,nodeId:Ce,onConnect:Tn=>Z==null?void 0:Z(ft,Tn),isTarget:mt,getState:ye.getState,setState:ye.setState,isValidConnection:Re,edgeUpdaterType:ut,onReconnectEnd:bt})},ge=ne=>he(ne,!0),Se=ne=>he(ne,!1),Fe=()=>Le(!0),et=()=>Le(!1),xt=!O&&!c,ht=ne=>{var De;if(!pe&&oT.includes(ne.key)&&O){const{unselectNodesAndEdges:Oe,addSelectedEdges:Te,edges:Ce}=ye.getState();ne.key==="Escape"?((De=me.current)==null||De.blur(),Oe({edges:[Ce.find(ut=>ut.id===n)]})):Te([n])}};return fe.createElement("g",{className:Kt(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:h,animated:p,inactive:xt,updating:Ie}]),onClick:je,onDoubleClick:Ye,onContextMenu:it,onMouseEnter:Ne,onMouseMove:He,onMouseLeave:Xe,onKeyDown:U?ht:void 0,tabIndex:U?0:void 0,role:U?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${x} to ${N}`,"aria-describedby":U?`${ET}-${de}`:void 0,ref:me},!ce&&fe.createElement(e,{id:n,source:x,target:N,selected:h,animated:p,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:_,data:l,style:S,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:$,targetPosition:F,sourceHandleId:L,targetHandleId:H,markerStart:ze,markerEnd:ke,pathOptions:V,interactionWidth:ie}),J&&fe.createElement(fe.Fragment,null,(J==="source"||J===!0)&&fe.createElement(bk,{position:$,centerX:E,centerY:C,radius:ee,onMouseDown:ge,onMouseEnter:Fe,onMouseOut:et,type:"source"}),(J==="target"||J===!0)&&fe.createElement(bk,{position:F,centerX:R,centerY:I,radius:ee,onMouseDown:Se,onMouseEnter:Fe,onMouseOut:et,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function n3(e){const t={default:zo(e.default||rd),straight:zo(e.bezier||ex),step:zo(e.step||Jv),smoothstep:zo(e.step||xd),simplebezier:zo(e.simplebezier||Zv)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,l)=>(a[l]=zo(e[l]||rd),a),n);return{...t,...s}}function kk(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,l=(n==null?void 0:n.width)||t.width,c=(n==null?void 0:n.height)||t.height;switch(e){case Ue.Top:return{x:s+l/2,y:a};case Ue.Right:return{x:s+l,y:a+c/2};case Ue.Bottom:return{x:s+l/2,y:a+c};case Ue.Left:return{x:s,y:a+c/2}}}function _k(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const r3=(e,t,n,s,a,l)=>{const c=kk(n,e,t),d=kk(l,s,a);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y}};function s3({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,targetHeight:l,width:c,height:d,transform:h}){const p={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+l)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const f=Pl({x:(0-h[0])/h[2],y:(0-h[1])/h[2],width:c/h[2],height:d/h[2]}),m=Math.max(0,Math.min(f.x2,p.x2)-Math.max(f.x,p.x)),y=Math.max(0,Math.min(f.y2,p.y2)-Math.max(f.y,p.y));return Math.ceil(m*y)>0}function Nk(e){var s,a,l,c,d;const t=((s=e==null?void 0:e[St])==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((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.x)||0,y:((d=e==null?void 0:e.positionAbsolute)==null?void 0:d.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const a3=[{level:0,isMaxLevel:!0,edges:[]}];function o3(e,t,n=!1){let s=-1;const a=e.reduce((c,d)=>{var f,m;const h=Hn(d.zIndex);let p=h?d.zIndex:0;if(n){const y=t.get(d.target),v=t.get(d.source),j=d.selected||(y==null?void 0:y.selected)||(v==null?void 0:v.selected),_=Math.max(((f=v==null?void 0:v[St])==null?void 0:f.z)||0,((m=y==null?void 0:y[St])==null?void 0:m.z)||0,1e3);p=(h?d.zIndex:0)+(j?_:0)}return c[p]?c[p].push(d):c[p]=[d],s=p>s?p:s,c},{}),l=Object.entries(a).map(([c,d])=>{const h=+c;return{edges:d,level:h,isMaxLevel:h===s}});return l.length===0?a3:l}function i3(e,t,n){const s=ct(b.useCallback(a=>e?a.edges.filter(l=>{const c=t.get(l.source),d=t.get(l.target);return(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&(d==null?void 0:d.width)&&(d==null?void 0:d.height)&&s3({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:d.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:d.width,targetHeight:d.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return o3(s,t,n)}const l3=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),c3=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Sk={[nd.Arrow]:l3,[nd.ArrowClosed]:c3};function u3(e){const t=Rt();return b.useMemo(()=>{var a,l;return Object.prototype.hasOwnProperty.call(Sk,e)?Sk[e]:((l=(a=t.getState()).onError)==null||l.call(a,"009",is.error009(e)),null)},[e])}const d3=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:d="auto-start-reverse"})=>{const h=u3(t);return h?fe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:d,refX:"0",refY:"0"},fe.createElement(h,{color:n,strokeWidth:c})):null},h3=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((a,l)=>([l.markerStart,l.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const d=wv(c,t);s.includes(d)||(a.push({id:d,color:c.color||e,...c}),s.push(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))},DT=({defaultColor:e,rfId:t})=>{const n=ct(b.useCallback(h3({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((l,c)=>l.id!==a[c].id)));return fe.createElement("defs",null,n.map(s=>fe.createElement(d3,{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})))};DT.displayName="MarkerDefinitions";var f3=b.memo(DT);const p3=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}),qT=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:l,onEdgeContextMenu:c,onEdgeMouseEnter:d,onEdgeMouseMove:h,onEdgeMouseLeave:p,onEdgeClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:_,children:S,disableKeyboardA11y:x})=>{const{edgesFocusable:N,edgesUpdatable:E,elementsSelectable:C,width:R,height:I,connectionMode:$,nodeInternals:F,onError:O}=ct(p3,Dt),M=i3(t,F,n);return R?fe.createElement(fe.Fragment,null,M.map(({level:L,edges:H,isMaxLevel:B})=>fe.createElement("svg",{key:L,style:{zIndex:L},width:R,height:I,className:"react-flow__edges react-flow__container"},B&&fe.createElement(f3,{defaultColor:e,rfId:s}),fe.createElement("g",null,H.map(A=>{const[Q,K,ee]=Nk(F.get(A.source)),[Z,D,Y]=Nk(F.get(A.target));if(!ee||!Y)return null;let P=A.type||"default";a[P]||(O==null||O("011",is.error011(P)),P="default");const G=a[P]||a.default,de=$===Xa.Strict?D.target:(D.target??[]).concat(D.source??[]),W=_k(K.source,A.sourceHandle),U=_k(de,A.targetHandle),J=(W==null?void 0:W.position)||Ue.Bottom,V=(U==null?void 0:U.position)||Ue.Top,ie=!!(A.focusable||N&&typeof A.focusable>"u"),pe=A.reconnectable||A.updatable,me=typeof y<"u"&&(pe||E&&typeof pe>"u");if(!W||!U)return O==null||O("008",is.error008(W,A)),null;const{sourceX:Ie,sourceY:Le,targetX:ce,targetY:xe}=r3(Q,W,J,Z,U,V);return fe.createElement(G,{key:A.id,id:A.id,className:Kt([A.className,l]),type:P,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:Ie,sourceY:Le,targetX:ce,targetY:xe,sourcePosition:J,targetPosition:V,elementsSelectable:C,onContextMenu:c,onMouseEnter:d,onMouseMove:h,onMouseLeave:p,onClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:_,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ie,isReconnectable:me,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:x})})))),S):null};qT.displayName="EdgeRenderer";var m3=b.memo(qT);const g3=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function y3({children:e}){const t=ct(g3);return fe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function w3(e){const t=Yl(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const v3={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top},FT=({nodeId:e,handleType:t,style:n,type:s=Gs.Bezier,CustomComponent:a,connectionStatus:l})=>{var I,$,F;const{fromNode:c,handleId:d,toX:h,toY:p,connectionMode:f}=ct(b.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),Dt),m=(I=c==null?void 0:c[St])==null?void 0:I.handleBounds;let y=m==null?void 0:m[t];if(f===Xa.Loose&&(y=y||(m==null?void 0:m[t==="source"?"target":"source"])),!c||!y)return null;const v=d?y.find(O=>O.id===d):y[0],j=v?v.x+v.width/2:(c.width??0)/2,_=v?v.y+v.height/2:c.height??0,S=((($=c.positionAbsolute)==null?void 0:$.x)??0)+j,x=(((F=c.positionAbsolute)==null?void 0:F.y)??0)+_,N=v==null?void 0:v.position,E=N?v3[N]:null;if(!N||!E)return null;if(a)return fe.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:c,fromHandle:v,fromX:S,fromY:x,toX:h,toY:p,fromPosition:N,toPosition:E,connectionStatus:l});let C="";const R={sourceX:S,sourceY:x,sourcePosition:N,targetX:h,targetY:p,targetPosition:E};return s===Gs.Bezier?[C]=dT(R):s===Gs.Step?[C]=yv({...R,borderRadius:0}):s===Gs.SmoothStep?[C]=yv(R):s===Gs.SimpleBezier?[C]=uT(R):C=`M${S},${x} ${h},${p}`,fe.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};FT.displayName="ConnectionLine";const x3=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function b3({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:l,nodesConnectable:c,width:d,height:h,connectionStatus:p}=ct(x3,Dt);return!(a&&l&&d&&c)?null:fe.createElement("svg",{style:e,width:d,height:h,className:"react-flow__edges react-flow__connectionline react-flow__container"},fe.createElement("g",{className:Kt(["react-flow__connection",p])},fe.createElement(FT,{nodeId:a,handleType:l,style:t,type:n,CustomComponent:s,connectionStatus:p})))}function jk(e,t){return b.useRef(null),Rt(),b.useMemo(()=>t(e),[e])}const BT=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:l,onNodeClick:c,onEdgeClick:d,onNodeDoubleClick:h,onEdgeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,onSelectionContextMenu:j,onSelectionStart:_,onSelectionEnd:S,connectionLineType:x,connectionLineStyle:N,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:R,selectionOnDrag:I,selectionMode:$,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:M,deleteKeyCode:L,onlyRenderVisibleElements:H,elementsSelectable:B,selectNodesOnDrag:A,defaultViewport:Q,translateExtent:K,minZoom:ee,maxZoom:Z,preventScrolling:D,defaultMarkerColor:Y,zoomOnScroll:P,zoomOnPinch:G,panOnScroll:de,panOnScrollSpeed:W,panOnScrollMode:U,zoomOnDoubleClick:J,panOnDrag:V,onPaneClick:ie,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:ce,onEdgeContextMenu:xe,onEdgeMouseEnter:ye,onEdgeMouseMove:ze,onEdgeMouseLeave:ke,onReconnect:je,onReconnectStart:Ye,onReconnectEnd:it,reconnectRadius:Ne,noDragClassName:He,noWheelClassName:Xe,noPanClassName:he,elevateEdgesOnSelect:ge,disableKeyboardA11y:Se,nodeOrigin:Fe,nodeExtent:et,rfId:xt})=>{const ht=jk(e,KP),ne=jk(t,n3);return w3(l),fe.createElement(VP,{onPaneClick:ie,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:Ie,onPaneContextMenu:ce,onPaneScroll:Le,deleteKeyCode:L,selectionKeyCode:R,selectionOnDrag:I,selectionMode:$,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:F,panActivationKeyCode:O,zoomActivationKeyCode:M,elementsSelectable:B,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:P,zoomOnPinch:G,zoomOnDoubleClick:J,panOnScroll:de,panOnScrollSpeed:W,panOnScrollMode:U,panOnDrag:V,defaultViewport:Q,translateExtent:K,minZoom:ee,maxZoom:Z,onSelectionContextMenu:j,preventScrolling:D,noDragClassName:He,noWheelClassName:Xe,noPanClassName:he,disableKeyboardA11y:Se},fe.createElement(y3,null,fe.createElement(m3,{edgeTypes:ne,onEdgeClick:d,onEdgeDoubleClick:p,onlyRenderVisibleElements:H,onEdgeContextMenu:xe,onEdgeMouseEnter:ye,onEdgeMouseMove:ze,onEdgeMouseLeave:ke,onReconnect:je,onReconnectStart:Ye,onReconnectEnd:it,reconnectRadius:Ne,defaultMarkerColor:Y,noPanClassName:he,elevateEdgesOnSelect:!!ge,disableKeyboardA11y:Se,rfId:xt},fe.createElement(b3,{style:N,type:x,component:E,containerStyle:C})),fe.createElement("div",{className:"react-flow__edgelabel-renderer"}),fe.createElement(ZP,{nodeTypes:ht,onNodeClick:c,onNodeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,selectNodesOnDrag:A,onlyRenderVisibleElements:H,noPanClassName:he,noDragClassName:He,disableKeyboardA11y:Se,nodeOrigin:Fe,nodeExtent:et,rfId:xt})))};BT.displayName="GraphView";var k3=b.memo(BT);const kv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zs={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:kv,nodeExtent:kv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Xa.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:KO,isValidConnection:void 0},_3=()=>uM((e,t)=>({...zs,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:l}=t();e({nodeInternals:Cf(n,s,a,l)})},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",l=typeof s<"u",c=a?Cf(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:l?s:[],hasDefaultNodes:a,hasDefaultEdges:l})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:a,fitViewOnInit:l,fitViewOnInitDone:c,fitViewOnInitOptions:d,domNode:h,nodeOrigin:p}=t(),f=h==null?void 0:h.querySelector(".react-flow__viewport");if(!f)return;const m=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(m.transform),v=n.reduce((_,S)=>{const x=a.get(S.id);if(x!=null&&x.hidden)a.set(x.id,{...x,[St]:{...x[St],handleBounds:void 0}});else if(x){const N=Xv(S.nodeElement);!!(N.width&&N.height&&(x.width!==N.width||x.height!==N.height||S.forceUpdate))&&(a.set(x.id,{...x,[St]:{...x[St],handleBounds:{source:vk(".source",S.nodeElement,y,p),target:vk(".target",S.nodeElement,y,p)}},...N}),_.push({id:x.id,type:"dimensions",dimensions:N}))}return _},[]);TT(a,p);const j=c||l&&!c&&AT(t,{initial:!0,...d});e({nodeInternals:new Map(a),fitViewOnInitDone:j}),(v==null?void 0:v.length)>0&&(s==null||s(v))},updateNodePositions:(n,s=!0,a=!1)=>{const{triggerNodeChanges:l}=t(),c=n.map(d=>{const h={id:d.id,type:"position",dragging:a};return s&&(h.positionAbsolute=d.positionAbsolute,h.position=d.position),h});l(c)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:l,nodeOrigin:c,getNodes:d,elevateNodesOnSelect:h}=t();if(n!=null&&n.length){if(l){const p=DP(n,d()),f=Cf(p,a,c,h);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:l}=t();let c,d=null;s?c=n.map(h=>Hs(h,!0)):(c=Yo(l(),n),d=Yo(a,[])),ju({changedNodes:c,changedEdges:d,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:l}=t();let c,d=null;s?c=n.map(h=>Hs(h,!0)):(c=Yo(a,n),d=Yo(l(),[])),ju({changedNodes:d,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:l}=t(),c=n||l(),d=s||a,h=c.map(f=>(f.selected=!1,Hs(f.id,!1))),p=d.map(f=>Hs(f.id,!1));ju({changedNodes:h,changedEdges:p,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(),l=s().filter(d=>d.selected).map(d=>Hs(d.id,!1)),c=n.filter(d=>d.selected).map(d=>Hs(d.id,!1));ju({changedNodes:l,changedEdges:c,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Qv(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:l,d3Zoom:c,d3Selection:d,translateExtent:h}=t();if(!c||!d||!n.x&&!n.y)return!1;const p=ss.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[a,l]],m=c==null?void 0:c.constrain()(p,f,h);return c.transform(d,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:zs.connectionNodeId,connectionHandleId:zs.connectionHandleId,connectionHandleType:zs.connectionHandleType,connectionStatus:zs.connectionStatus,connectionStartHandle:zs.connectionStartHandle,connectionEndHandle:zs.connectionEndHandle}),reset:()=>e({...zs})}),Object.is),ax=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=_3()),fe.createElement(zO,{value:t.current},e)};ax.displayName="ReactFlowProvider";const zT=({children:e})=>b.useContext(vd)?fe.createElement(fe.Fragment,null,e):fe.createElement(ax,null,e);zT.displayName="ReactFlowWrapper";const N3={input:kT,default:xv,output:NT,group:rx},S3={default:rd,straight:ex,step:Jv,smoothstep:xd,simplebezier:Zv},j3=[0,0],E3=[15,15],C3={x:0,y:0,zoom:1},T3={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},UT=b.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:l=N3,edgeTypes:c=S3,onNodeClick:d,onEdgeClick:h,onInit:p,onMove:f,onMoveStart:m,onMoveEnd:y,onConnect:v,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:x,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,onNodeDragStart:$,onNodeDrag:F,onNodeDragStop:O,onNodesDelete:M,onEdgesDelete:L,onSelectionChange:H,onSelectionDragStart:B,onSelectionDrag:A,onSelectionDragStop:Q,onSelectionContextMenu:K,onSelectionStart:ee,onSelectionEnd:Z,connectionMode:D=Xa.Strict,connectionLineType:Y=Gs.Bezier,connectionLineStyle:P,connectionLineComponent:G,connectionLineContainerStyle:de,deleteKeyCode:W="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:J=!1,selectionMode:V=Ll.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:pe=td()?"Meta":"Control",zoomActivationKeyCode:me=td()?"Meta":"Control",snapToGrid:Ie=!1,snapGrid:Le=E3,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:xe=!0,nodesDraggable:ye,nodesConnectable:ze,nodesFocusable:ke,nodeOrigin:je=j3,edgesFocusable:Ye,edgesUpdatable:it,elementsSelectable:Ne,defaultViewport:He=C3,minZoom:Xe=.5,maxZoom:he=2,translateExtent:ge=kv,preventScrolling:Se=!0,nodeExtent:Fe,defaultMarkerColor:et="#b1b1b7",zoomOnScroll:xt=!0,zoomOnPinch:ht=!0,panOnScroll:ne=!1,panOnScrollSpeed:De=.5,panOnScrollMode:Oe=Ga.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ce=!0,onPaneClick:lt,onPaneMouseEnter:ut,onPaneMouseMove:Re,onPaneMouseLeave:mt,onPaneScroll:ft,onPaneContextMenu:bt,children:Xn,onEdgeContextMenu:Tn,onEdgeDoubleClick:ln,onEdgeMouseEnter:to,onEdgeMouseMove:ds,onEdgeMouseLeave:Or,onEdgeUpdate:Qn,onEdgeUpdateStart:no,onEdgeUpdateEnd:Pr,onReconnect:Zs,onReconnectStart:Lr,onReconnectEnd:An,reconnectRadius:Dr=10,edgeUpdaterRadius:hs=10,onNodesChange:qt,onEdgesChange:wr,noDragClassName:Js="nodrag",noWheelClassName:vi="nowheel",noPanClassName:ro="nopan",fitView:Rn=!1,fitViewOptions:ea,connectOnClick:ta=!0,attributionPosition:na,proOptions:ra,defaultEdgeOptions:sa,elevateNodesOnSelect:aa=!0,elevateEdgesOnSelect:so=!1,disableKeyboardA11y:oa=!1,autoPanOnConnect:xi=!0,autoPanOnNodeDrag:dt=!0,connectionRadius:ao=20,isValidConnection:ia,onError:qr,style:Fr,id:Br,nodeDragThreshold:la,...zr},It)=>{const ca=Br||"1";return fe.createElement("div",{...zr,style:{...Fr,...T3},ref:It,className:Kt(["react-flow",a]),"data-testid":"rf__wrapper",id:Br},fe.createElement(zT,null,fe.createElement(k3,{onInit:p,onMove:f,onMoveStart:m,onMoveEnd:y,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:N,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,nodeTypes:l,edgeTypes:c,connectionLineType:Y,connectionLineStyle:P,connectionLineComponent:G,connectionLineContainerStyle:de,selectionKeyCode:U,selectionOnDrag:J,selectionMode:V,deleteKeyCode:W,multiSelectionKeyCode:pe,panActivationKeyCode:ie,zoomActivationKeyCode:me,onlyRenderVisibleElements:ce,selectNodesOnDrag:xe,defaultViewport:He,translateExtent:ge,minZoom:Xe,maxZoom:he,preventScrolling:Se,zoomOnScroll:xt,zoomOnPinch:ht,zoomOnDoubleClick:Te,panOnScroll:ne,panOnScrollSpeed:De,panOnScrollMode:Oe,panOnDrag:Ce,onPaneClick:lt,onPaneMouseEnter:ut,onPaneMouseMove:Re,onPaneMouseLeave:mt,onPaneScroll:ft,onPaneContextMenu:bt,onSelectionContextMenu:K,onSelectionStart:ee,onSelectionEnd:Z,onEdgeContextMenu:Tn,onEdgeDoubleClick:ln,onEdgeMouseEnter:to,onEdgeMouseMove:ds,onEdgeMouseLeave:Or,onReconnect:Zs??Qn,onReconnectStart:Lr??no,onReconnectEnd:An??Pr,reconnectRadius:Dr??hs,defaultMarkerColor:et,noDragClassName:Js,noWheelClassName:vi,noPanClassName:ro,elevateEdgesOnSelect:so,rfId:ca,disableKeyboardA11y:oa,nodeOrigin:je,nodeExtent:Fe}),fe.createElement(wP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:v,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:x,nodesDraggable:ye,nodesConnectable:ze,nodesFocusable:ke,edgesFocusable:Ye,edgesUpdatable:it,elementsSelectable:Ne,elevateNodesOnSelect:aa,minZoom:Xe,maxZoom:he,nodeExtent:Fe,onNodesChange:qt,onEdgesChange:wr,snapToGrid:Ie,snapGrid:Le,connectionMode:D,translateExtent:ge,connectOnClick:ta,defaultEdgeOptions:sa,fitView:Rn,fitViewOptions:ea,onNodesDelete:M,onEdgesDelete:L,onNodeDragStart:$,onNodeDrag:F,onNodeDragStop:O,onSelectionDrag:A,onSelectionDragStart:B,onSelectionDragStop:Q,noPanClassName:ro,nodeOrigin:je,rfId:ca,autoPanOnConnect:xi,autoPanOnNodeDrag:dt,onError:qr,connectionRadius:ao,isValidConnection:ia,nodeDragThreshold:la}),fe.createElement(gP,{onSelectionChange:H}),Xn,fe.createElement(WO,{proOptions:ra,position:na}),fe.createElement(_P,{rfId:ca,disableKeyboardA11y:oa})))});UT.displayName="ReactFlow";const A3=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function WT(){return ct(A3,Dt)}const HT=({id:e,x:t,y:n,width:s,height:a,style:l,color:c,strokeColor:d,strokeWidth:h,className:p,borderRadius:f,shapeRendering:m,onClick:y,selected:v})=>{const{background:j,backgroundColor:_}=l||{},S=c||j||_;return fe.createElement("rect",{className:Kt(["react-flow__minimap-node",{selected:v},p]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:S,stroke:d,strokeWidth:h,shapeRendering:m,onClick:y?x=>y(x,e):void 0})};HT.displayName="MiniMapNode";var R3=b.memo(HT);const M3=e=>e.nodeOrigin,I3=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Mf=e=>e instanceof Function?e:()=>e;function $3({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:l=R3,onClick:c}){const d=ct(I3,Dt),h=ct(M3),p=Mf(t),f=Mf(e),m=Mf(n),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return fe.createElement(fe.Fragment,null,d.map(v=>{const{x:j,y:_}=Ya(v,h).positionAbsolute;return fe.createElement(l,{key:v.id,x:j,y:_,width:v.width,height:v.height,style:v.style,selected:v.selected,className:m(v),color:p(v),borderRadius:s,strokeColor:f(v),strokeWidth:a,shapeRendering:y,onClick:c,id:v.id})}))}var O3=b.memo($3);const P3=200,L3=150,D3=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?VO(bd(t,e.nodeOrigin),n):n,rfId:e.rfId}},q3="react-flow__minimap-desc";function GT({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",nodeBorderRadius:l=5,nodeStrokeWidth:c=2,nodeComponent:d,maskColor:h="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:f=1,position:m="bottom-right",onClick:y,onNodeClick:v,pannable:j=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:x=!1,zoomStep:N=10,offsetScale:E=5}){const C=Rt(),R=b.useRef(null),{boundingRect:I,viewBB:$,rfId:F}=ct(D3,Dt),O=(e==null?void 0:e.width)??P3,M=(e==null?void 0:e.height)??L3,L=I.width/O,H=I.height/M,B=Math.max(L,H),A=B*O,Q=B*M,K=E*B,ee=I.x-(A-I.width)/2-K,Z=I.y-(Q-I.height)/2-K,D=A+K*2,Y=Q+K*2,P=`${q3}-${F}`,G=b.useRef(0);G.current=B,b.useEffect(()=>{if(R.current){const U=Wn(R.current),J=pe=>{const{transform:me,d3Selection:Ie,d3Zoom:Le}=C.getState();if(pe.sourceEvent.type!=="wheel"||!Ie||!Le)return;const ce=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*N,xe=me[2]*Math.pow(2,ce);Le.scaleTo(Ie,xe)},V=pe=>{const{transform:me,d3Selection:Ie,d3Zoom:Le,translateExtent:ce,width:xe,height:ye}=C.getState();if(pe.sourceEvent.type!=="mousemove"||!Ie||!Le)return;const ze=G.current*Math.max(1,me[2])*(x?-1:1),ke={x:me[0]-pe.sourceEvent.movementX*ze,y:me[1]-pe.sourceEvent.movementY*ze},je=[[0,0],[xe,ye]],Ye=ss.translate(ke.x,ke.y).scale(me[2]),it=Le.constrain()(Ye,je,ce);Le.transform(Ie,it)},ie=eT().on("zoom",j?V:null).on("zoom.wheel",_?J:null);return U.call(ie),()=>{U.on("zoom",null)}}},[j,_,x,N]);const de=y?U=>{const J=lr(U);y(U,{x:J[0],y:J[1]})}:void 0,W=v?(U,J)=>{const V=C.getState().nodeInternals.get(J);v(U,V)}:void 0;return fe.createElement(Kv,{position:m,style:e,className:Kt(["react-flow__minimap",t]),"data-testid":"rf__minimap"},fe.createElement("svg",{width:O,height:M,viewBox:`${ee} ${Z} ${D} ${Y}`,role:"img","aria-labelledby":P,ref:R,onClick:de},S&&fe.createElement("title",{id:P},S),fe.createElement(O3,{onClick:W,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:l,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:d}),fe.createElement("path",{className:"react-flow__minimap-mask",d:`M${ee-K},${Z-K}h${D+K*2}v${Y+K*2}h${-D-K*2}z
57
+ M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:f,pointerEvents:"none"})))}GT.displayName="MiniMap";var F3=b.memo(GT);function B3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},fe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function z3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},fe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function U3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},fe.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function W3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function H3(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Rr=({children:e,className:t,...n})=>fe.createElement("button",{type:"button",className:Kt(["react-flow__controls-button",t]),...n},e);Rr.displayName="ControlButton";const G3=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),VT=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:l,onZoomOut:c,onFitView:d,onInteractiveChange:h,className:p,children:f,position:m="bottom-left"})=>{const y=Rt(),[v,j]=b.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:x}=ct(G3,Dt),{zoomIn:N,zoomOut:E,fitView:C}=Yl();if(b.useEffect(()=>{j(!0)},[]),!v)return null;const R=()=>{N(),l==null||l()},I=()=>{E(),c==null||c()},$=()=>{C(a),d==null||d()},F=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return fe.createElement(Kv,{className:Kt(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},t&&fe.createElement(fe.Fragment,null,fe.createElement(Rr,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},fe.createElement(B3,null)),fe.createElement(Rr,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},fe.createElement(z3,null))),n&&fe.createElement(Rr,{className:"react-flow__controls-fitview",onClick:$,title:"fit view","aria-label":"fit view"},fe.createElement(U3,null)),s&&fe.createElement(Rr,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},_?fe.createElement(H3,null):fe.createElement(W3,null)),f)};VT.displayName="Controls";var V3=b.memo(VT),fr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(fr||(fr={}));function Y3({color:e,dimensions:t,lineWidth:n}){return fe.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function K3({color:e,radius:t}){return fe.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const X3={[fr.Dots]:"#91919a",[fr.Lines]:"#eee",[fr.Cross]:"#e2e2e2"},Q3={[fr.Dots]:1,[fr.Lines]:1,[fr.Cross]:6},Z3=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function YT({id:e,variant:t=fr.Dots,gap:n=20,size:s,lineWidth:a=1,offset:l=2,color:c,style:d,className:h}){const p=b.useRef(null),{transform:f,patternId:m}=ct(Z3,Dt),y=c||X3[t],v=s||Q3[t],j=t===fr.Dots,_=t===fr.Cross,S=Array.isArray(n)?n:[n,n],x=[S[0]*f[2]||1,S[1]*f[2]||1],N=v*f[2],E=_?[N,N]:x,C=j?[N/l,N/l]:[E[0]/l,E[1]/l];return fe.createElement("svg",{className:Kt(["react-flow__background",h]),style:{...d,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},fe.createElement("pattern",{id:m+e,x:f[0]%x[0],y:f[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},j?fe.createElement(K3,{color:y,radius:N/l}):fe.createElement(Y3,{dimensions:E,color:y,lineWidth:a})),fe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}YT.displayName="Background";var J3=b.memo(YT);const e4=["us-gov","global","apac","us","eu","jp","au"],t4=new RegExp(`^(?:(?:${e4.join("|")})\\.)?anthropic\\.`,"i");function Kl(e){return e.replace(t4,"")}const n4=["command","cmd","file_path","path","url","pattern","notebook_path"],Ek=120,If=e=>e.length>Ek?`${e.slice(0,Ek-1)}…`:e;function r4(e){if(typeof e=="string")return e.trim()?If(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of n4){const s=t[n];if(typeof s=="string"&&s.trim())return If(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return If(a)}}return null}function KT(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function ox(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 s4(e){const t=ox(e),n={inputTokens:Number(e.input_tokens??0),outputTokens:Number(e.output_tokens??0),cacheReadTokens:Number(e.cache_read_input_tokens??e.cached_input_tokens??0),cacheCreateTokens:Number(e.cache_creation_input_tokens??e.cache_write_input_tokens??0),cacheCreate1hTokens:t.cacheCreate1hTokens,cacheCreate5mTokens:t.cacheCreate5mTokens};return typeof e.reasoning_output_tokens=="number"&&(n.reasoningOutputTokens=Number(e.reasoning_output_tokens)),n}function a4(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e))!n||!s||typeof s!="object"||(t[n]=s4(s));return Object.keys(t).length?t:void 0}function XT(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),...ox(n)};for(const s of Object.values(n)){const a=XT(s,t+1);if(a)return a}return null}const o4=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function QT(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&o4.test(Kl(n.model)))return n.model;for(const s of Object.values(n)){const a=QT(s,t+1);if(a)return a}return null}function _v(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function Ys(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t[t.length-1]}function Ck(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function Xl(e,t){return`${e}::${t}`}function sd(e){return e.agent_type??e.subagent_type??"subagent"}function Tl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Ko(e,t,n,s){const a=t;let l=e.agents.get(a);return l||(l={id:a,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:KT()},e.agents.set(a,l),l)}function ZT(e,t,n,s){const a=Xl(t,n),l=e.agents.get(a);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=Ys(s.cwd));const c=sd(s);return c&&(l.label==="subagent"||!l.label)&&(l.label=c),l}function i4(e,t,n){const s=t.session_id??"unknown",a=Tl(t);if(a){const h=ZT(e,s,a,t);if(h)return h}const l=e.activeSubagentStack.get(s),c=l&&l.length>0?l[l.length-1]:null;if(c){const h=e.agents.get(Xl(s,c));if(h)return!h.cwd&&t.cwd&&(h.cwd=t.cwd,h.cwdBasename=Ys(t.cwd)),h}const d=Ko(e,s,n,t.hook_event_name!=="SessionStart");return!d.cwd&&t.cwd&&(d.cwd=t.cwd,d.cwdBasename=Ys(t.cwd)),d.label==="session"&&t.cwd&&(d.label=Ys(t.cwd)??"session"),d}function l4(e,t,n,s,a){const l=Xl(t,n),c=Ko(e,t,a,!0);let d=e.agents.get(l);if(d){!d.cwd&&s.cwd&&(d.cwd=s.cwd,d.cwdBasename=Ys(s.cwd));const h=sd(s);return h&&(d.label==="subagent"||!d.label)&&(d.label=h),d}return d={id:l,sessionId:t,label:sd(s),kind:"subagent",parentId:c.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:Ys(s.cwd),toolCount:0,childCount:0,usage:KT()},e.agents.set(l,d),c.childCount+=1,d}function c4(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function u4(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)}}function Cu(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const Tk=200,d4=25;function h4(e,t){const n=t.tools;if(n.length>Tk){const s=n.splice(0,n.length-Tk);for(const a of s)e.toolIndex.get(a.id)===a&&(e.toolIndex.delete(a.id),e.toolOwner.delete(a.id))}for(let s=n.length-d4-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function f4(e,t,n){const s=e.toolIndex.get(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}const Ak=2e3;function p4(e,t,n){for(let s=e.prompts.length-1;s>=0;s--){const a=e.prompts[s];if(a.at<t-Ak)return!1;if(a.text===n&&a.at<=t+Ak)return!0}return!1}function JT(e,t){for(const n of t.tools)e.toolIndex.get(n.id)===n&&e.toolIndex.delete(n.id),e.toolOwner.get(n.id)===t.id&&e.toolOwner.delete(n.id)}function Ql(e,t){return t&&(e.revision+=1),t}function m4(e,t,n,s){if(e.agents.size<=n)return!1;const a=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>s,l=[],c=new Map;for(const[p,f]of e.agents){if(f.parentId!=null){const m=c.get(f.parentId);m?m.push(p):c.set(f.parentId,[p])}a(f)&&l.push({id:p,endedAt:f.endedAt})}if(l.length===0)return!1;l.sort((p,f)=>p.endedAt-f.endedAt);let d=0;const h=p=>{const f=e.agents.get(p);f&&(JT(e,f),e.agents.delete(p),d++)};for(const p of l){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const f=(c.get(p.id)??[]).map(m=>e.agents.get(m)).filter(m=>m!=null);if(!f.some(m=>!a(m))){for(const m of f)h(m.id);h(p.id)}}return Ql(e,d>0)}function g4(e,t,n,s){const a=new Map;for(const[p,f]of e.agents){let m=a.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1,closed:!1},a.set(f.sessionId,m)),m.ids.push(p),f.kind==="root"&&f.closedAt!=null&&(m.closed=!0),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...a.values()].filter(p=>!p.live&&p.endedAt>0&&t-p.endedAt>s).sort((p,f)=>p.closed===f.closed?p.endedAt-f.endedAt:p.closed?-1:1);let d=[...a.values()].filter(p=>!p.live).length-n;if(d<=0)return!1;let h=!1;for(const p of l){if(d<=0)break;for(const f of p.ids){const m=e.agents.get(f);m&&JT(e,m),e.agents.delete(f)}d--,h=!0}return Ql(e,h)}function y4(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&&e.toolIndex.has(a)}function w4(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 Ql(e,t)}function v4(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.provider==="codex")continue;const l=e.agents.get(a.sessionId),c=(l==null?void 0:l.lastEventAt)??(l==null?void 0:l.startedAt);for(const d of a.tools){const h=Math.max(d.startedAt,c??d.startedAt);d.endedAt==null&&t-h>n&&(d.endedAt=h,d.ok=!1,d.errorPreview=d.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"session ended before this call returned",e.toolIndex.delete(d.id),e.toolOwner.delete(d.id),s=!0)}}return Ql(e,s)}const Rk=90*6e4;function x4(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.kind!=="root")continue;const l=a.lastEventAt??a.startedAt;if(!(t-l<=n)){a.waiting&&(a.waiting=null,s=!0),a.closedAt==null&&(a.closedAt=l),a.state==="active"&&(a.state="done",a.endedAt=l,a.reaped=!0,s=!0);for(const c of e.agents.values())c.sessionId!==a.sessionId||c.kind==="root"||c.state!=="active"||(c.state="done",c.endedAt=l,s=!0);e.activeSubagentStack.delete(a.sessionId)}}return Ql(e,s)}function b4(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const k4=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed"]);function _4(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 N4=3e4;function S4(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>N4)&&!(e.startedAt>t))return{name:e.name,preview:r4(e.input)??""}}function j4(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const l=_4(e,t),c={kind:n,message:s,since:a};l!=null&&l.explicitSubagentId&&(c.subagentId=l.explicitSubagentId);const d=S4(l,a);return d&&(c.tool=d),c}function E4(e,t,n){if(e.kind==="idle")return!0;const s=Tl(t);return s==null?!0:e.subagentId!=null&&Xl(n,s)===e.subagentId}function Mk(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,l=s.hook_event_name??"Unknown";if(l==="__clear")return{..._v(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const c=s.session_id??"unknown";if(!k4.has(l)){const f=e.agents.get(c);f!=null&&f.waiting&&E4(f.waiting,s,c)&&(f.waiting=null)}const d=e.agents.get(c);if(d&&a>(d.lastEventAt??0)&&(d.lastEventAt=a,d.reaped&&(d.reaped=!1,d.state="active",d.endedAt=void 0,d.closedAt=void 0)),typeof s.model_context_window=="number"&&s.model_context_window>0){const f=e.agents.get(c);f&&(f.contextWindow=s.model_context_window)}if(typeof s.approval_policy=="string"&&s.approval_policy){const f=e.agents.get(c);f&&(f.approvalPolicy=s.approval_policy)}if(typeof s.context_tokens=="number"&&s.context_tokens>=0){const f=e.agents.get(c);f&&(f.context={...f.context??Ck(),currentContextTokens:s.context_tokens})}if(l==="ModelObserved"){const f=typeof s.model=="string"?s.model:null;if(f){const y=e.agents.get(c);y&&(y.model=f)}const m=s.subagentModels;if(m&&typeof m=="object")for(const[y,v]of Object.entries(m)){if(typeof v!="string")continue;const j=`${c}::${y}`,_=e.agents.get(j);_&&(_.model=v)}return e}if(l==="ContextObserved"){const f=s.context??null;if(f){const m=e.agents.get(c);if(m){const y=m.context??Ck(),v=(_,S)=>typeof f[_]=="number"?f[_]:S,j=Array.isArray(f.memoryFiles)?f.memoryFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:null;m.context={msgsUser:v("msgsUser",y.msgsUser),msgsAssistant:v("msgsAssistant",y.msgsAssistant),toolUses:v("toolUses",y.toolUses),toolResults:v("toolResults",y.toolResults),systemReminders:v("systemReminders",y.systemReminders),currentContextTokens:v("currentContextTokens",y.currentContextTokens),memoryFiles:j??y.memoryFiles}}}return e}if(l==="SessionNamed"){const f=e.agents.get(c);if(f){const m=typeof s.sessionName=="string"?s.sessionName.trim():"",y=typeof s.sessionTitle=="string"?s.sessionTitle.trim():"";m&&(f.sessionName=m),y&&(f.sessionTitle=y);const v=f.sessionName??"";f.sessionTitle&&v&&f.sessionTitle.toLowerCase()===v.toLowerCase()&&(f.sessionTitle=void 0)}return e}if(l==="OutputObserved"){const f=s.kind==="thinking"||s.kind==="text"||s.kind==="tool_use"?s.kind:null,m=typeof s.at=="number"&&Number.isFinite(s.at)?s.at:a;if(!f)return e;const y=e.agents.get(c);if(!y||y.lastOutputAt!=null&&m<=y.lastOutputAt)return e;if(y.lastOutputAt=m,f!=="tool_use"){const v=(y.outputs??[]).filter(j=>m-j<C4);v.push(m),y.outputs=v.length>Ik?v.slice(-Ik):v}return e.revision+=1,e}if(l==="UsageObserved"){const f=s.usage??null;if(f){const m=e.agents.get(c);if(m){m.usage.inputTokens=Number(f.input_tokens??0),m.usage.outputTokens=Number(f.output_tokens??0),m.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),m.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??f.cache_write_input_tokens??0);const y=ox(f);m.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,m.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof f.reasoning_output_tokens=="number"&&(m.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)),m.usageByModel=a4(s.usageByModel)}}return e}const h=i4(e,s,a);h.provider||(h.provider=s.provider==="codex"?"codex":"claude");const p=QT(s);switch(p&&(h.model=p),l){case"SessionStart":{const f=Ko(e,c,a,!1);f.synthetic=!1,f.state="active",f.closedAt=void 0,f.startedAt=f.startedAt||a,!f.cwd&&s.cwd&&(f.cwd=s.cwd,f.cwdBasename=Ys(s.cwd)),f.label==="session"&&s.cwd&&(f.label=Ys(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===c&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<a&&(y.exitAt=a);const f=Ko(e,c,a,!1);f.state="active",f.endedAt=void 0,f.closedAt=void 0,f.exitAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&!p4(f,a,m)&&(f.prompts.push({at:a,text:m}),f.firstPrompt||(f.firstPrompt=Cu(m,120)));break}case"PreToolUse":{const f=s.tool_use_id?f4(e,h,s.tool_use_id):null;if(f){s.tool_name&&f.name==="?"&&(f.name=s.tool_name),f.endedAt==null&&!f.trimmed&&s.tool_input!==void 0&&(f.input=s.tool_input,f.inputPreview=Cu(s.tool_input));break}const m=s.tool_use_id??`${h.id}:${h.toolCount}`,y=Tl(s),v={id:m,name:s.tool_name??"?",input:s.tool_input,inputPreview:Cu(s.tool_input),agentId:h.id,explicitSubagentId:y?Xl(c,y):void 0,startedAt:a};h.tools.push(v),h.toolCount+=1,h.state="active",e.toolIndex.set(m,v),e.toolOwner.set(m,h.id),h4(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const f=s.tool_use_id;if(!f)break;let m=e.toolIndex.get(f),y=!1;if(!m)for(const j of e.agents.values()){const _=j.tools.find(S=>S.id===f);if(_){m=_,y=!0;break}}if(!m||m.outcomeApplied)break;m.outcomeApplied=!0,m.outcomeGap=void 0,m.endedAt=a,m.ok=l==="PostToolUse",m.trimmed||(m.response=s.tool_response),l==="PostToolUseFailure"?m.errorPreview=Cu(s.tool_response):y&&(m.errorPreview=void 0);const v=XT(s.tool_response);v&&(m.usage=v),e.toolIndex.delete(f),e.toolOwner.delete(f);break}case"SubagentStart":{const f=Tl(s);if(!f)break;const m=l4(e,c,f,s,a);m.state="active",m.startedAt=m.startedAt||a,m.exitAt=void 0,m.endedAt=void 0;const y=sd(s);y&&(m.label=y),c4(e,c,f);break}case"SubagentStop":{const f=Tl(s);if(!f)break;const m=ZT(e,c,f,s);if(!m)break;m.state="done",m.endedAt=a,u4(e,c,f);break}case"Stop":case"SessionEnd":{const f=Ko(e,c,a,!1);f.state="done",f.endedAt=a;for(const m of f.provider==="codex"?[]:f.tools)m.endedAt==null&&(m.endedAt=a,m.ok=!1,m.errorPreview=m.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"the turn ended before this call returned",e.toolIndex.delete(m.id),e.toolOwner.delete(m.id));l==="SessionEnd"&&(f.closedAt=a),e.activeSubagentStack.delete(c);break}case"Notification":{const f=b4(s.notification_type);if(!f)break;const m=Ko(e,c,a,!1),y=typeof s.message=="string"?s.message:"",v=m.waiting;m.waiting=v&&v.kind===f&&v.message===y?{...v,since:Math.min(v.since,a)}:j4(e,c,f,y,a);break}}return e}const C4=6e4,Ik=64;function ix(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const T4={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},A4=[{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\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:T4},{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[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]deep[-_]research/i,rates:{input:10,output:40,cacheRead:2.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini[-_]deep[-_]research/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}];function R4(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function hi(e,t=Date.now()){if(!e)return null;const n=Kl(e);for(const s of A4)if(s.match.test(n))return typeof s.rates=="function"?s.rates(t):s.rates;return null}function e2(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),l=s+a,c=t.cacheWrite1h??t.cacheWrite;return{tokens5m:l,tokens1h:n,usd5m:l*t.cacheWrite/1e6,usd1h:n*c/1e6}}function t2(e,t,n=Date.now()){if(!R4(t))return e.inputTokens;const s=hi(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 lx(e,t,n=Date.now()){const s=hi(t,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const a=t2(e,t,n)*s.input/1e6,l=e.outputTokens*s.output/1e6,c=e.cacheReadTokens*s.cacheRead/1e6,d=e2(e,s),h=d.usd5m+d.usd1h;return{input:a,output:l,cacheRead:c,cacheWrite:h,total:a+l+c+h}}const $k=2e5,M4=1e6,I4=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],$4=[{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function O4(e){if(!e)return $k;const t=Kl(e);for(const n of I4)if(n.test(t))return M4;for(const n of $4)if(n.match.test(t))return n.window;return $k}function n2(e,t){return typeof e=="number"&&e>0?e:O4(t)}const Vo="not priced";function tt(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=(e*100).toFixed(e<.1?1:0);if(Number(t)<100)return`${t}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function cx(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${tt(s)}/min`:`${tt(n*3600)}/hr`}function P4(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),n}function L4(e,t){let n=0,s=0,a=0,l=0,c=0,d=0;for(const m of t)n+=m.inputTokens,s+=m.outputTokens,a+=m.cacheReadTokens,l+=m.cacheCreateTokens,c+=m.cacheCreate1hTokens??0,d+=m.cacheCreate5mTokens??0;const h=(m,y)=>Math.max(0,m-y),p={inputTokens:h(e.inputTokens,n),outputTokens:h(e.outputTokens,s),cacheReadTokens:h(e.cacheReadTokens,a),cacheCreateTokens:h(e.cacheCreateTokens,l)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(p.cacheCreate1hTokens=h(e.cacheCreate1hTokens??0,c),p.cacheCreate5mTokens=h(e.cacheCreate5mTokens??0,d)),p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreateTokens>0?p:null}function Zl(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(l=>({model:l,usage:t[l]})),a=L4(e.usage,s.map(l=>l.usage));if(a){const l=s.findIndex(c=>c.model===e.model);l>=0?s[l]={model:s[l].model,usage:P4(s[l].usage,a)}:s.push({model:e.model,usage:a})}return s}function En(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Zl(e)){const a=lx(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 Nv(e,t=Date.now()){let n=0;for(const s of Zl(e))hi(s.model,t)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function r2(e){const t=[];for(const n of Zl(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 s2(e){return r2(e).filter(t=>t!==e.model)}const D4=new Set(["untrusted","on-request","on-failure"]);function q4(e){return typeof e!="string"||!e?null:D4.has(e)?!0:e==="never"?!1:null}function F4(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=q4(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."}
58
58
 
59
- 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 Ok(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Ys(e){const t=Yl(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=Ok(n[1]),l=n[2].replace(/[-_]/g,".");return`${a} ${l}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const a=s[1].replace(/[-_]/g,"."),l=s[2].split(/[-_]/).filter(Boolean).map(Ok);return[`GPT-${a}`,...l].join(" ")}return e}function bd(e){const t=Yl(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Zl(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function B4(e){const t=[];for(const n of e)n.kind==="root"&&Zl(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 z4(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function kd(e,t){return`${e}@${t.since}`}function a2(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 U4(e){const t=e.message||"Needs your permission",n=a2(e,t);return n?`${t}
60
- Likely on: ${n}`:t}function W4(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const l of e){if(!Zl(l.waiting))continue;const c=kd(l.id,l.waiting);t.has(c)||a.push({key:c,title:l.label,body:U4(l.waiting),sessionId:l.id})}return a}function H4(e,t,n){const s=new Set;for(const l of e)s.add(kd(l.id,l.waiting));const a=new Set;for(const l of n)s.has(l)&&a.add(l);for(const l of t)a.add(l.key);return a}function Pk(e){return new Set(e.map(t=>kd(t.id,t.waiting)))}function G4(e,t){return e!==t}function At(e){const t=Math.round(e);return t<1e3?`${t}`:t<1e6?`${(t/1e3).toFixed(1)}k`:t<1e9?`${(t/1e6).toFixed(2)}M`:`${(t/1e9).toFixed(2)}B`}function sd(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 l=Math.floor(a/60),c=a%60;return`${l}m ${String(c).padStart(2,"0")}s`}function o2(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 i2(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 V4=1;function Y4(){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){const l={dismiss:s,layer:a,seq:t++};return e.push(l),()=>{const c=e.indexOf(l);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}}}const ad=Y4();function K4(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Lk(e){return String(e.tagName??"").toUpperCase()==="BODY"}function X4(e,t){return!e||!e.isConnected||Lk(e)?!1:t==null||Lk(t)}const Dk="a[href], button, input, select, textarea, [tabindex]";function Q4(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function Z4(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function J4({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 ux(e){return e.ctrlKey||e.metaKey||e.altKey}const eL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),tL=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),nL=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function l2(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function dx(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=l2(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!eL.has(String(e.type??"text").toLowerCase())}function rL(e){if(!e)return!1;if(dx(e)||tL.has(l2(e)))return!0;const t=typeof e.role=="string"?e.role.trim().toLowerCase():"";return t!==""&&t.split(/\s+/).some(n=>nL.has(n))}function sL({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function c2(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Dk))return Q4({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&Z4({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Dk)!=null})}):[]}function aL(e,t){const n=c2(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 Ht(e,t={}){const{focusRef:n,layer:s}=t,a=b.useRef(null),l=b.useRef(e);l.current=e;const c=b.useRef(null);c.current===null&&(c.current=()=>l.current());const d=c.current;return b.useEffect(()=>ad.push(d,s),[d,s]),b.useEffect(()=>{var p;const h=document.activeElement;return(p=(n==null?void 0:n.current)??c2(a.current)[0])==null||p.focus(),()=>{X4(h,document.activeElement)&&h.focus()}},[]),b.useEffect(()=>{const h=p=>{var _;if(p.key!=="Tab"||ux(p))return;const f=a.current;if(!f)return;const m=document.activeElement;if(!(m!=null&&f.contains(m))&&!ad.isTop(d))return;const v=aL(f,m),j=J4({count:v.length,index:m?v.indexOf(m):-1,shiftKey:p.shiftKey});j.kind!=="allow"&&(p.preventDefault(),j.kind==="focus"&&((_=v[j.index])==null||_.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[d]),a}function oL(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 Un(e){return e.toLocaleString()}function iL(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const lL=60;function cL(e,t=lL){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 uL({agent:e,onClose:t}){var y;const n=b.useRef(null),s=Ht(t,{focusRef:n}),a=e.context,l=e.usage,c=(a==null?void 0:a.currentContextTokens)??0,d=n2(e.contextWindow,e.model),h=Math.min(100,c/d*100),p=En(e),f=l.inputTokens+l.cacheReadTokens+l.cacheCreateTokens,m=oL(e.provider);return i.jsx("div",{className:"ctx-modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:s,className:"ctx-modal",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[i.jsxs("header",{className:"ctx-modal-head",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),i.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),i.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("section",{className:"ctx-window-row",children:[i.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:i.jsx("div",{className:"ctx-window-fill",style:{width:`${h}%`}})}),i.jsxs("div",{className:"ctx-window-meta",children:[i.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),i.jsxs("span",{children:[Un(c)," / ",Un(d)," tok (",m.windowScope,")"]})]})]}),i.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),i.jsxs("div",{className:"ctx-grid",children:[i.jsx(ir,{label:"input tokens",val:Un(l.inputTokens)}),i.jsx(ir,{label:"output tokens",val:Un(l.outputTokens)}),i.jsx(ir,{label:"cache reads",val:Un(l.cacheReadTokens)}),i.jsx(ir,{label:"cache writes",val:Un(l.cacheCreateTokens)}),i.jsx(ir,{label:"cumulative total",val:Un(f)}),i.jsx(ir,{label:"estimated cost",val:tt(p.total),accent:!0})]}),i.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?i.jsxs("div",{className:"ctx-grid",children:[i.jsx(ir,{label:"user messages",val:Un((a==null?void 0:a.msgsUser)??0)}),i.jsx(ir,{label:"assistant messages",val:Un((a==null?void 0:a.msgsAssistant)??0)}),i.jsx(ir,{label:"tool uses",val:Un((a==null?void 0:a.toolUses)??0)}),i.jsx(ir,{label:"tool results",val:Un((a==null?void 0:a.toolResults)??0)}),i.jsx(ir,{label:"system-reminders",val:Un((a==null?void 0:a.systemReminders)??0)})]}):i.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),i.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((y=a==null?void 0:a.memoryFiles)==null?void 0:y.length)??0)===0?i.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):i.jsx("ul",{className:"ctx-md-list",children:a.memoryFiles.map(v=>i.jsxs("li",{children:[i.jsx("span",{className:"ctx-md-path",title:v.path,children:cL(v.path)}),i.jsx("span",{className:"ctx-md-size",children:iL(v.bytes)})]},v.path))})]})})}function ir({label:e,val:t,accent:n}){return i.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[i.jsx("span",{className:"ctx-row-label",children:e}),i.jsx("span",{className:"ctx-row-val",children:t})]})}function dL({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const l=n2(n,t),c=Math.min(1,e/l),d=s/2-3,h=s/2,p=2*Math.PI*d,f=p*c,m=c>.9?"var(--err)":c>.7?"var(--inflight)":"var(--accent)";return i.jsx("button",{type:"button",className:"ctx-donut",onClick:a,title:`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(c*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:i.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[i.jsx("circle",{cx:h,cy:h,r:d,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),i.jsx("circle",{cx:h,cy:h,r:d,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${p-f}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),i.jsx("text",{x:h,y:h+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function qk(e,t){const n=di(t);if(!n)return`model: ${t}
59
+ 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 Ok(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Ks(e){const t=Kl(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=Ok(n[1]),l=n[2].replace(/[-_]/g,".");return`${a} ${l}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const a=s[1].replace(/[-_]/g,"."),l=s[2].split(/[-_]/).filter(Boolean).map(Ok);return[`GPT-${a}`,...l].join(" ")}return e}function kd(e){const t=Kl(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Jl(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function B4(e){const t=[];for(const n of e)n.kind==="root"&&Jl(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 z4(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function _d(e,t){return`${e}@${t.since}`}function a2(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 U4(e){const t=e.message||"Needs your permission",n=a2(e,t);return n?`${t}
60
+ Likely on: ${n}`:t}function W4(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const l of e){if(!Jl(l.waiting))continue;const c=_d(l.id,l.waiting);t.has(c)||a.push({key:c,title:l.label,body:U4(l.waiting),sessionId:l.id})}return a}function H4(e,t,n){const s=new Set;for(const l of e)s.add(_d(l.id,l.waiting));const a=new Set;for(const l of n)s.has(l)&&a.add(l);for(const l of t)a.add(l.key);return a}function Pk(e){return new Set(e.map(t=>_d(t.id,t.waiting)))}function G4(e,t){return e!==t}function At(e){const t=Math.round(e);return t<1e3?`${t}`:t<1e6?`${(t/1e3).toFixed(1)}k`:t<1e9?`${(t/1e6).toFixed(2)}M`:`${(t/1e9).toFixed(2)}B`}function ad(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 l=Math.floor(a/60),c=a%60;return`${l}m ${String(c).padStart(2,"0")}s`}function o2(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 i2(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 V4=1;function Y4(){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){const l={dismiss:s,layer:a,seq:t++};return e.push(l),()=>{const c=e.indexOf(l);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}}}const od=Y4();function K4(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Lk(e){return String(e.tagName??"").toUpperCase()==="BODY"}function X4(e,t){return!e||!e.isConnected||Lk(e)?!1:t==null||Lk(t)}const Dk="a[href], button, input, select, textarea, [tabindex]";function Q4(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function Z4(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function J4({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 ux(e){return e.ctrlKey||e.metaKey||e.altKey}const eL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),tL=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),nL=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function l2(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function dx(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=l2(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!eL.has(String(e.type??"text").toLowerCase())}function rL(e){if(!e)return!1;if(dx(e)||tL.has(l2(e)))return!0;const t=typeof e.role=="string"?e.role.trim().toLowerCase():"";return t!==""&&t.split(/\s+/).some(n=>nL.has(n))}function sL({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function c2(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Dk))return Q4({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&Z4({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Dk)!=null})}):[]}function aL(e,t){const n=c2(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 Ht(e,t={}){const{focusRef:n,layer:s}=t,a=b.useRef(null),l=b.useRef(e);l.current=e;const c=b.useRef(null);c.current===null&&(c.current=()=>l.current());const d=c.current;return b.useEffect(()=>od.push(d,s),[d,s]),b.useEffect(()=>{var p;const h=document.activeElement;return(p=(n==null?void 0:n.current)??c2(a.current)[0])==null||p.focus(),()=>{X4(h,document.activeElement)&&h.focus()}},[]),b.useEffect(()=>{const h=p=>{var _;if(p.key!=="Tab"||ux(p))return;const f=a.current;if(!f)return;const m=document.activeElement;if(!(m!=null&&f.contains(m))&&!od.isTop(d))return;const v=aL(f,m),j=J4({count:v.length,index:m?v.indexOf(m):-1,shiftKey:p.shiftKey});j.kind!=="allow"&&(p.preventDefault(),j.kind==="focus"&&((_=v[j.index])==null||_.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[d]),a}function oL(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 Un(e){return e.toLocaleString()}function iL(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const lL=60;function cL(e,t=lL){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 uL({agent:e,onClose:t}){var y;const n=b.useRef(null),s=Ht(t,{focusRef:n}),a=e.context,l=e.usage,c=(a==null?void 0:a.currentContextTokens)??0,d=n2(e.contextWindow,e.model),h=Math.min(100,c/d*100),p=En(e),f=l.inputTokens+l.cacheReadTokens+l.cacheCreateTokens,m=oL(e.provider);return i.jsx("div",{className:"ctx-modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:s,className:"ctx-modal",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[i.jsxs("header",{className:"ctx-modal-head",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),i.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),i.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("section",{className:"ctx-window-row",children:[i.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:i.jsx("div",{className:"ctx-window-fill",style:{width:`${h}%`}})}),i.jsxs("div",{className:"ctx-window-meta",children:[i.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),i.jsxs("span",{children:[Un(c)," / ",Un(d)," tok (",m.windowScope,")"]})]})]}),i.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),i.jsxs("div",{className:"ctx-grid",children:[i.jsx(ir,{label:"input tokens",val:Un(l.inputTokens)}),i.jsx(ir,{label:"output tokens",val:Un(l.outputTokens)}),i.jsx(ir,{label:"cache reads",val:Un(l.cacheReadTokens)}),i.jsx(ir,{label:"cache writes",val:Un(l.cacheCreateTokens)}),i.jsx(ir,{label:"cumulative total",val:Un(f)}),i.jsx(ir,{label:"estimated cost",val:tt(p.total),accent:!0})]}),i.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?i.jsxs("div",{className:"ctx-grid",children:[i.jsx(ir,{label:"user messages",val:Un((a==null?void 0:a.msgsUser)??0)}),i.jsx(ir,{label:"assistant messages",val:Un((a==null?void 0:a.msgsAssistant)??0)}),i.jsx(ir,{label:"tool uses",val:Un((a==null?void 0:a.toolUses)??0)}),i.jsx(ir,{label:"tool results",val:Un((a==null?void 0:a.toolResults)??0)}),i.jsx(ir,{label:"system-reminders",val:Un((a==null?void 0:a.systemReminders)??0)})]}):i.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),i.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((y=a==null?void 0:a.memoryFiles)==null?void 0:y.length)??0)===0?i.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):i.jsx("ul",{className:"ctx-md-list",children:a.memoryFiles.map(v=>i.jsxs("li",{children:[i.jsx("span",{className:"ctx-md-path",title:v.path,children:cL(v.path)}),i.jsx("span",{className:"ctx-md-size",children:iL(v.bytes)})]},v.path))})]})})}function ir({label:e,val:t,accent:n}){return i.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[i.jsx("span",{className:"ctx-row-label",children:e}),i.jsx("span",{className:"ctx-row-val",children:t})]})}function dL({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const l=n2(n,t),c=Math.min(1,e/l),d=s/2-3,h=s/2,p=2*Math.PI*d,f=p*c,m=c>.9?"var(--err)":c>.7?"var(--inflight)":"var(--accent)";return i.jsx("button",{type:"button",className:"ctx-donut",onClick:a,title:`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(c*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:i.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[i.jsx("circle",{cx:h,cy:h,r:d,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),i.jsx("circle",{cx:h,cy:h,r:d,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${p-f}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),i.jsx("text",{x:h,y:h+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function qk(e,t){const n=hi(t);if(!n)return`model: ${t}
61
61
  no published rate in this build — the tokens are counted, the dollars are not`;const s=f=>f.toLocaleString(),a=f=>`$${f}/MTok`,l=lx(e,t),c=e2(e,n),d=c.tokens1h>0?[`cache w5m${s(c.tokens5m).padStart(14)} × ${a(n.cacheWrite).padEnd(11)} = ${tt(c.usd5m)}`,`cache w1h${s(c.tokens1h).padStart(14)} × ${a(n.cacheWrite1h??n.cacheWrite).padEnd(11)} = ${tt(c.usd1h)}`]:[`cache w ${s(c.tokens5m).padStart(14)} × ${a(n.cacheWrite).padEnd(11)} = ${tt(c.usd5m)}`],h=t2(e,t),p=h===e.inputTokens?"input":"uncached";return[`model: ${t}`,`${p.padEnd(9)}${s(h).padStart(14)} × ${a(n.input).padEnd(11)} = ${tt(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${a(n.output).padEnd(11)} = ${tt(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${a(n.cacheRead).padEnd(11)} = ${tt(l.cacheRead)}`,...d,"─────────────────────────────────────────",`total = ${tt(l.total)}`].join(`
62
- `)}function Fk(e){const t=Ql(e);return t.length<=1?qk(e.usage,e.model):[...t.map(n=>qk(n.usage,n.model)),"═════════════════════════════════════════",`all models = ${tt(En(e).total)}`].join(`
62
+ `)}function Fk(e){const t=Zl(e);return t.length<=1?qk(e.usage,e.model):[...t.map(n=>qk(n.usage,n.model)),"═════════════════════════════════════════",`all models = ${tt(En(e).total)}`].join(`
63
63
  `)}function hL({data:e,selected:t}){var v,j;const n=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),a=e.tools.filter(_=>!_.endedAt).length,l=e.tools.filter(_=>_.ok===!1).length,c=ix(e.sessionId),d=((v=e.context)==null?void 0:v.currentContextTokens)??0,h=e.kind==="root"&&d>0,p=e.sessionTitle?e.cwd?`${e.cwd}
64
64
  ${e.sessionTitle}`:e.sessionTitle:e.cwd,f=s2(e),m=f.length>0?`${e.model}
65
65
  spend on this card also covers:
66
66
  ${f.join(`
67
- `)}`:e.model,y=i2(e.sessionName,e.sessionTitle);return i.jsxs("div",{className:s,style:{"--session-hue":c},children:[i.jsx("span",{className:"accent-stripe"}),i.jsx(ai,{type:"target",position:Ue.Left,style:{background:"transparent",border:"none"}}),i.jsxs("div",{className:"head",children:[i.jsxs("div",{className:"title",children:[i.jsx(fL,{state:e.state}),i.jsx("span",{className:"label",title:p,children:e.label}),e.synthetic&&i.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),i.jsxs("div",{className:"head-right",children:[h&&e.onOpenContext&&i.jsx(dL,{currentContextTokens:d,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),i.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:sd(e.startedAt,e.endedAt,n)})]})]}),i.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&i.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?i.jsxs("span",{className:"model-chip","data-family":bd(e.model),title:m,children:[Ys(e.model),f.length>0?` +${f.length}`:""]}):e.provider==="codex"?i.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&y.face&&i.jsx("div",{className:"session-name",title:y.tooltip,children:y.face}),e.waiting&&i.jsx(gL,{waiting:e.waiting,now:n}),(()=>{const _=F4(e);return _?i.jsxs("div",{className:"approval-blind-row",title:_.detail,children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),i.jsx("span",{className:"approval-blind-said",children:_.label})]}):null})(),(e.tools.length>0||(((j=e.outputs)==null?void 0:j.length)??0)>0)&&i.jsx(yL,{tools:e.tools,outputs:e.outputs,now:n}),i.jsxs("div",{className:"meta",children:[i.jsxs("span",{children:[i.jsx("b",{children:e.toolCount})," tools"]}),l>0&&i.jsxs("span",{className:"failed-meta",title:`${l} tool ${l===1?"call":"calls"} returned an error`,children:[i.jsx("b",{children:l})," err"]}),a>0&&i.jsxs("span",{className:"inflight-meta",children:[i.jsx("b",{children:a})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&i.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[i.jsx("b",{children:At(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{const _=di(e.model),S=En(e),x=_v(e);if(!_&&S.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:i.jsx("span",{className:"cost-unpriced",title:Fk(e),children:Go});if(S.total<=0)return null;const N=Math.max(0,((e.endedAt??n)-e.startedAt)/1e3),E=e.state==="active"?cx(S.total,N):null,C=Fk(e)+(E?`
68
- burn: ${E}`:"");return i.jsx("span",{className:"cost-meta",title:C,children:i.jsxs("b",{children:[tt(S.total),x>0?"+":""]})})})()]}),i.jsx(ai,{type:"source",position:Ue.Right,style:{background:"transparent",border:"none"}})]})}function od(e){return e==="active"?"live":e==="done"?"done":"err"}function fL({state:e}){return i.jsx("span",{className:`state-pill state-${e}`,children:od(e)})}function Dl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function pL(e,t){const n=a2(e,t);return n?`Likely on: ${n}`:null}function mL(e){return e.kind==="idle"?"Your turn":Dl(e)}function gL({waiting:e,now:t}){const n=Zl(e),s=Dl(e);return i.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
69
- Blocked for ${sd(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?i.jsx("span",{className:"ap-pulse","aria-hidden":!0}):i.jsx("span",{className:"waiting-dot","aria-hidden":!0}),i.jsx("span",{className:"waiting-said",children:mL(e)}),i.jsx("b",{children:sd(e.since,void 0,t)})]})}function yL({tools:e,outputs:t,now:n}){const c=new Array(24).fill(0);let d=0;const h=E=>{const C=n-E;if(C<0||C>=6e4)return;const R=23-Math.floor(C/2500);R>=0&&R<24&&(c[R]+=1,d+=1)};for(const E of e)h(E.startedAt);for(const E of t??[])h(E);const p=2,f=Math.max(0,...c),m=132,y=14,v=m/24,j=f/(2500/1e3),_=e.filter(E=>n-E.startedAt>=0&&n-E.startedAt<6e4).length,S=d-_,x=[_>0?`${_} tool ${_===1?"call":"calls"}`:"",S>0?`${S} ${S===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),N=d===0?"nothing in the last 60s":`${x.join(" · ")} in last 60s · peak ${j.toFixed(1)}/s`;return i.jsxs("div",{className:"tool-spark-row",title:N,children:[i.jsx("svg",{className:"tool-spark",width:m,height:y,viewBox:`0 0 ${m} ${y}`,"aria-hidden":!0,children:c.map((E,C)=>{const R=E===0?1.5:Math.max(1.5,Math.min(1,E/p)*y),I=C===23&&E>0,F=`tool-spark-bar${E>0?" active":""}${I?" latest":""}`;return i.jsx("rect",{x:C*v+.4,y:y-R,width:Math.max(.5,v-1),height:R,rx:.8,className:F},I?`landed:${E}`:C)})}),i.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function wL(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function If(e){return e!=="gone"}function $f(e,t){const[n,s]=b.useState(()=>e?"here":"gone"),a=b.useRef(null);return b.useEffect(()=>{s(l=>wL(e,l))},[e]),b.useEffect(()=>{if(n==="leaving")return a.current=window.setTimeout(()=>s("gone"),t),()=>{a.current!=null&&window.clearTimeout(a.current)}},[n,t]),b.useEffect(()=>{n==="entering"&&s("here")},[n]),n}function Bk(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function vL({tool:e,onClose:t}){const n=Ht(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),i.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),i.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",children:o2(e,"in-flight…")}),i.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("section",{className:"modal-body",children:[e.trimmed&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h4",{children:"Input"}),i.jsx("pre",{children:Bk(e.input??e.inputPreview)})]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("h4",{children:["Response ",s==="err"&&i.jsx("span",{className:"err-tag",children:"error"})]}),i.jsx("pre",{children:e.endedAt==null?"(waiting…)":Bk(e.response??e.errorPreview)})]})]})]})})}const Cu=18,zk=26,xL=12;function bL(e){return kL(e.nodeInternals.values())}function kL(e){const t=new Map;for(const a of e){if(a.type!=="agent")continue;const l=a.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||a.width==null||a.height==null)continue;const c=a.position.x,d=a.position.y,h=c+a.width,p=d+a.height,f=t.get(l.sessionId);f?(f.minX=Math.min(f.minX,c),f.minY=Math.min(f.minY,d),f.maxX=Math.max(f.maxX,h),f.maxY=Math.max(f.maxY,p),l.kind==="root"&&(f.label=Hk(l)??f.label),l.kind==="root"&&(f.name=Gk(l))):t.set(l.sessionId,{minX:c,minY:d,maxX:h,maxY:p,label:Hk(l)??l.sessionId,name:Gk(l)})}const n=new Map;for(const a of t.values())n.set(a.label,(n.get(a.label)??0)+1);const s=[];for(const[a,l]of t){const c=(n.get(l.label)??0)>1;s.push({sessionId:a,...SL(l.label,l.name,a,c),x:l.minX-Cu,y:l.minY-Cu-zk,w:l.maxX-l.minX+Cu*2,h:l.maxY-l.minY+Cu*2+zk})}return s}const Nv=" · ",_L=32,NL=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function Uk(e){return NL.test(e)?2:1}function Wk(e,t=_L){const n=[...e];let s=0;for(const c of n)s+=Uk(c);if(s<=t)return e;const a=[];let l=0;for(const c of n){const d=Uk(c);if(l+d>t-1)break;a.push(c),l+=d}for(;a.length&&/[\s\-_.:/]/.test(a[a.length-1]);)a.pop();return`${a.join("")}…`}function SL(e,t,n,s){const a=(t==null?void 0:t.trim())??"",l=s?jL(n):void 0,c=[e,a||void 0,l].filter(Boolean);return{label:Wk(e),name:a?Wk(a):void 0,shortId:l,fullLabel:c.join(Nv)}}function jL(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function Hk(e){if(e.kind==="root")return e.label}function Gk(e){if(e.kind==="root")return i2(e.sessionName,e.sessionTitle).face}function EL({onFit:e}){const{x:t,y:n,zoom:s}=WT(),a=Vl(),l=ct(bL,CL);if(l.length<=1)return null;const c=h=>{try{const p=a.getNodes().filter(f=>{const m=f.data;return(m==null?void 0:m.sessionId)===h});if(p.length===0)return;a.fitView({padding:.3,duration:500,nodes:p}),e==null||e()}catch{}},d={transform:`translate(${t}px, ${n}px) scale(${s})`};return i.jsx("div",{className:"session-clusters",style:d,children:l.map(h=>{const p=ix(h.sessionId),f={position:"absolute",left:h.x,top:h.y,width:h.w,height:h.h,"--session-hue":p},m={position:"absolute",left:h.x+16,top:h.y-xL,transform:`scale(${Math.min(1,s)/(s||1)})`,transformOrigin:"left top","--session-hue":p};return i.jsxs(fe.Fragment,{children:[i.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),i.jsxs("button",{type:"button",className:"cluster-label",style:m,title:`Fit view to ${h.fullLabel}
70
- drag the wrapper to move the whole session`,onClick:()=>c(h.sessionId),children:[h.label,h.name?i.jsxs(i.Fragment,{children:[Nv,i.jsx("span",{className:"cluster-label-name",children:h.name})]}):null,h.shortId?i.jsx("span",{className:"cluster-label-id",children:Nv+h.shortId}):null]})]},h.sessionId)})})}function CL(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.fullLabel!==a.fullLabel||s.x!==a.x||s.y!==a.y||s.w!==a.w||s.h!==a.h)return!1}return!0}function TL({data:e}){return i.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const Jl={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"}},AL=Object.fromEntries(Object.entries(Jl).map(([e,t])=>[e,t.category])),RL=Object.fromEntries(Object.entries(Jl).map(([e,t])=>[e,t.emoji])),ML=Object.fromEntries(Object.entries(Jl).map(([e,t])=>[e,t.label])),IL=new Set(Object.keys(Jl)),$L=new Set(Object.entries(Jl).filter(([,e])=>e.shell).map(([e])=>e)),Vk={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",...AL};function u2(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(Vk,e)?Vk[e]:"other"}const OL=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,PL=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function LL(e){if(typeof e!="string"||!e)return null;const t=OL.exec(e);if(t){const s=DL(t[2]);if(s.trim())return s}const n=PL.exec(e);return n?n[1]:null}function DL(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
71
- `:n==="r"?"\r":n==="t"?" ":n)}const d2=600,qL=4,FL=36,Sv=16,BL=60,zL=6,Yk=220,Kk=96,UL=28,Xk={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:"📡",...RL};function Qk(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(Xk,e)?Xk[e]:"✨"}const Zk={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 h2(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return h2(n[1]);for(;;){const l=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;t=t.slice(l[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 WL(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=LL(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(a=>/^(-Command|-c)$/i.test(a));if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const HL=new Set(["Bash","PowerShell",...$L]),GL=IL;function VL(e,t){return GL.has(e)||e.startsWith("mcp__")?Math.max(Kk,34+t.length*7.5):Kk}function YL(e,t){if(!HL.has(e))return null;const n=WL(t);if(!n)return null;const s=h2(n);return s?{emoji:Object.hasOwn(Zk,s)?Zk[s]:"⚙️",label:s,category:"shell",detail:n}:null}const KL=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Jk={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:"🗄️"},e1={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 XL(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function QL(e){const t=e.toLowerCase();if(Object.hasOwn(e1,t))return e1[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const n=t.lastIndexOf(".");if(n>0&&n<t.length-1){const s=t.slice(n+1);if(Object.hasOwn(Jk,s))return Jk[s]}return"📄"}function ZL(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 JL(e,t){if(!KL.has(e))return null;const n=ZL(e,t);if(!n)return null;const s=XL(n);return s?{emoji:e==="LS"?"📂":QL(s),label:s,category:"file",detail:n}:null}const t1={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 hx(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 e5(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 f2(e){const t=e.toLowerCase();return Object.hasOwn(t1,t)?t1[t]:void 0}function t5(e,t){const n=hx(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const l=f2(s);return{emoji:(l==null?void 0:l.emoji)??"🔌",label:a,category:"mcp",detail:l?`${l.name} · ${a}`:`${s} · ${a}`}}function n5(e,t){return YL(e,t)??JL(e,t)??t5(e)}const n1=ML,r1=18;function r5(e){const t=[...e];return t.length<=r1?e:t.slice(0,r1-1).join("")+"…"}function p2(e){const t=hx(e);if(t){const s=f2(t.server);return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:r5(t.server),hue:e5(t.server)}}const n=Object.hasOwn(n1,e)?n1[e]:"";return n?{emoji:Qk(e),label:n}:{emoji:Qk(e),label:e}}function s5(e){let t=null,n="";for(const s of e){const a=hx(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:p2(n)}function a5(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function o5(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/d2)}function i5(e,t){const n=[],s=new Set;for(let a=e.length-1;a>=0&&n.length<t;a--){const l=e[a];s.has(l.id)||(s.add(l.id),n.push(l))}return n.reverse()}function l5(e,t,n,s,a,l){const c=[];for(const d of e.values()){if(!t.has(d.id)||d.exitAt!=null&&l-d.exitAt>d2)continue;const h=s.get(d.id)??n.get(d.id);if(!h)continue;const p=i5(d.tools,qL);if(p.length===0)continue;const f=d.exitAt??null,m=a.get(d.id),y=Math.max((m==null?void 0:m.width)??Yk,Yk),v=(m==null?void 0:m.height)??130,j=h.x,_=h.y,S=j+y,x=_+v/2;p.forEach((N,E)=>{const C=E*FL,R=j+y+BL,I=_+zL+C,$=o5(l,f),F=N.inputPreview??"",O=a5(N),M=$<.999,L=p2(N.name);c.push({id:`${d.id}::${N.id}`,toolId:N.id,agentId:d.id,toolName:N.name,name:L.label,emoji:L.emoji,status:O,category:u2(N.name),mcpHue:L.hue,inputPreview:F,fade:$,fading:M,worldX:R,worldY:I,anchorX:S,anchorY:x,spawnDx:S-R,spawnDy:x-(I+Sv)});const H=n5(N.name,N.input);if(H){const B=VL(N.name,L.label),A=R+B+UL,Q=I,K=R+B,ee=I+Sv;c.push({id:`sub:${d.id}::${N.id}`,toolId:N.id,agentId:d.id,toolName:N.name,name:H.label,emoji:H.emoji,isSub:!0,status:O,category:H.category,inputPreview:H.detail??F,fade:$,fading:M,worldX:A,worldY:Q,anchorX:K,anchorY:ee,spawnDx:K-A,spawnDy:0})}})}return c}function c5({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:l,hiddenCategories:c,now:d,onOpenTool:h}){const p=l5(e,t,n,s,a,d),f=c&&c.size>0?p.filter(m=>!c.has(m.category)):p;return i.jsx(u5,{bursts:f,spotlight:l,onOpenTool:h})}function u5({bursts:e,spotlight:t,onOpenTool:n}){const{x:s,y:a,zoom:l}=WT();return i.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[i.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const d=c.anchorX*l+s,h=c.anchorY*l+a,p=(c.worldX+6)*l+s,f=(c.worldY+Sv)*l+a,m=Math.max(1,p-d),y=Math.min(1,Math.abs(f-h)/m),v=d+m*(.55-.22*y),j=t!=null&&!t.has(c.agentId),_=c.fade*(j?.14:1);return i.jsx("path",{d:`M ${d} ${h} Q ${v} ${h}, ${p} ${f}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const d=c.worldX*l+s,h=c.worldY*l+a,p={left:`${d}px`,top:`${h}px`,transform:`scale(${l})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},f=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,m=c.inputPreview?`${f} · ${c.inputPreview}`:f,y=n!=null,v=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=t!=null&&!t.has(c.agentId)?" dim":"";return i.jsx("div",{className:"tool-burst-wrap",style:p,children:i.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${y?" clickable":""}${c.isSub?" sub":""}${_}`,style:v,title:m,onClick:y?()=>n(c.toolId):void 0,children:[i.jsx("span",{className:"tb-emoji",children:c.emoji}),i.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&i.jsx("span",{className:"tb-spin"}),c.status==="done"&&i.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&i.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function d5(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,a=0,l=0;for(const c of e){const d=En(c);t.input+=d.input,t.output+=d.output,t.cacheRead+=d.cacheRead,t.cacheWrite+=d.cacheWrite,t.total+=d.total,n+=c.usage.inputTokens,s+=c.usage.outputTokens,a+=c.usage.cacheReadTokens,l+=c.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:a,cacheCreateTokens:l,sum:n+s}}const h5="spend on this board",f5="on this board",s1=`Everything on the board right now, and only that.
67
+ `)}`:e.model,y=i2(e.sessionName,e.sessionTitle);return i.jsxs("div",{className:s,style:{"--session-hue":c},children:[i.jsx("span",{className:"accent-stripe"}),i.jsx(oi,{type:"target",position:Ue.Left,style:{background:"transparent",border:"none"}}),i.jsxs("div",{className:"head",children:[i.jsxs("div",{className:"title",children:[i.jsx(fL,{state:e.state}),i.jsx("span",{className:"label",title:p,children:e.label}),e.synthetic&&i.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),i.jsxs("div",{className:"head-right",children:[h&&e.onOpenContext&&i.jsx(dL,{currentContextTokens:d,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),i.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:ad(e.startedAt,e.endedAt,n)})]})]}),i.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&i.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?i.jsxs("span",{className:"model-chip","data-family":kd(e.model),title:m,children:[Ks(e.model),f.length>0?` +${f.length}`:""]}):e.provider==="codex"?i.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&y.face&&i.jsx("div",{className:"session-name",title:y.tooltip,children:y.face}),e.waiting&&i.jsx(gL,{waiting:e.waiting,now:n}),(()=>{const _=F4(e);return _?i.jsxs("div",{className:"approval-blind-row",title:_.detail,children:[i.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),i.jsx("span",{className:"approval-blind-said",children:_.label})]}):null})(),(e.tools.length>0||(((j=e.outputs)==null?void 0:j.length)??0)>0)&&i.jsx(yL,{tools:e.tools,outputs:e.outputs,now:n}),i.jsxs("div",{className:"meta",children:[i.jsxs("span",{children:[i.jsx("b",{children:e.toolCount})," tools"]}),l>0&&i.jsxs("span",{className:"failed-meta",title:`${l} tool ${l===1?"call":"calls"} returned an error`,children:[i.jsx("b",{children:l})," err"]}),a>0&&i.jsxs("span",{className:"inflight-meta",children:[i.jsx("b",{children:a})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&i.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[i.jsx("b",{children:At(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{const _=hi(e.model),S=En(e),x=Nv(e);if(!_&&S.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:i.jsx("span",{className:"cost-unpriced",title:Fk(e),children:Vo});if(S.total<=0)return null;const N=Math.max(0,((e.endedAt??n)-e.startedAt)/1e3),E=e.state==="active"?cx(S.total,N):null,C=Fk(e)+(E?`
68
+ burn: ${E}`:"");return i.jsx("span",{className:"cost-meta",title:C,children:i.jsxs("b",{children:[tt(S.total),x>0?"+":""]})})})()]}),i.jsx(oi,{type:"source",position:Ue.Right,style:{background:"transparent",border:"none"}})]})}function id(e){return e==="active"?"live":e==="done"?"done":"err"}function fL({state:e}){return i.jsx("span",{className:`state-pill state-${e}`,children:id(e)})}function ql(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function pL(e,t){const n=a2(e,t);return n?`Likely on: ${n}`:null}function mL(e){return e.kind==="idle"?"Your turn":ql(e)}function gL({waiting:e,now:t}){const n=Jl(e),s=ql(e);return i.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
69
+ Blocked for ${ad(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?i.jsx("span",{className:"ap-pulse","aria-hidden":!0}):i.jsx("span",{className:"waiting-dot","aria-hidden":!0}),i.jsx("span",{className:"waiting-said",children:mL(e)}),i.jsx("b",{children:ad(e.since,void 0,t)})]})}function yL({tools:e,outputs:t,now:n}){const c=new Array(24).fill(0);let d=0;const h=E=>{const C=n-E;if(C<0||C>=6e4)return;const R=23-Math.floor(C/2500);R>=0&&R<24&&(c[R]+=1,d+=1)};for(const E of e)h(E.startedAt);for(const E of t??[])h(E);const p=2,f=Math.max(0,...c),m=132,y=14,v=m/24,j=f/(2500/1e3),_=e.filter(E=>n-E.startedAt>=0&&n-E.startedAt<6e4).length,S=d-_,x=[_>0?`${_} tool ${_===1?"call":"calls"}`:"",S>0?`${S} ${S===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),N=d===0?"nothing in the last 60s":`${x.join(" · ")} in last 60s · peak ${j.toFixed(1)}/s`;return i.jsxs("div",{className:"tool-spark-row",title:N,children:[i.jsx("svg",{className:"tool-spark",width:m,height:y,viewBox:`0 0 ${m} ${y}`,"aria-hidden":!0,children:c.map((E,C)=>{const R=E===0?1.5:Math.max(1.5,Math.min(1,E/p)*y),I=C===23&&E>0,F=`tool-spark-bar${E>0?" active":""}${I?" latest":""}`;return i.jsx("rect",{x:C*v+.4,y:y-R,width:Math.max(.5,v-1),height:R,rx:.8,className:F},I?`landed:${E}`:C)})}),i.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function wL(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function $f(e){return e!=="gone"}function Of(e,t){const[n,s]=b.useState(()=>e?"here":"gone"),a=b.useRef(null);return b.useEffect(()=>{s(l=>wL(e,l))},[e]),b.useEffect(()=>{if(n==="leaving")return a.current=window.setTimeout(()=>s("gone"),t),()=>{a.current!=null&&window.clearTimeout(a.current)}},[n,t]),b.useEffect(()=>{n==="entering"&&s("here")},[n]),n}function Bk(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function vL({tool:e,onClose:t}){const n=Ht(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal",onClick:a=>a.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),i.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),i.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",children:o2(e,"in-flight…")}),i.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("section",{className:"modal-body",children:[e.trimmed&&i.jsx("div",{className:"modal-section",children:i.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h4",{children:"Input"}),i.jsx("pre",{children:Bk(e.input??e.inputPreview)})]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("h4",{children:["Response ",s==="err"&&i.jsx("span",{className:"err-tag",children:"error"})]}),i.jsx("pre",{children:e.endedAt==null?"(waiting…)":Bk(e.response??e.errorPreview)})]})]})]})})}const Tu=18,zk=26,xL=12;function bL(e){return kL(e.nodeInternals.values())}function kL(e){const t=new Map;for(const a of e){if(a.type!=="agent")continue;const l=a.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||a.width==null||a.height==null)continue;const c=a.position.x,d=a.position.y,h=c+a.width,p=d+a.height,f=t.get(l.sessionId);f?(f.minX=Math.min(f.minX,c),f.minY=Math.min(f.minY,d),f.maxX=Math.max(f.maxX,h),f.maxY=Math.max(f.maxY,p),l.kind==="root"&&(f.label=Hk(l)??f.label),l.kind==="root"&&(f.name=Gk(l))):t.set(l.sessionId,{minX:c,minY:d,maxX:h,maxY:p,label:Hk(l)??l.sessionId,name:Gk(l)})}const n=new Map;for(const a of t.values())n.set(a.label,(n.get(a.label)??0)+1);const s=[];for(const[a,l]of t){const c=(n.get(l.label)??0)>1;s.push({sessionId:a,...SL(l.label,l.name,a,c),x:l.minX-Tu,y:l.minY-Tu-zk,w:l.maxX-l.minX+Tu*2,h:l.maxY-l.minY+Tu*2+zk})}return s}const Sv=" · ",_L=32,NL=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function Uk(e){return NL.test(e)?2:1}function Wk(e,t=_L){const n=[...e];let s=0;for(const c of n)s+=Uk(c);if(s<=t)return e;const a=[];let l=0;for(const c of n){const d=Uk(c);if(l+d>t-1)break;a.push(c),l+=d}for(;a.length&&/[\s\-_.:/]/.test(a[a.length-1]);)a.pop();return`${a.join("")}…`}function SL(e,t,n,s){const a=(t==null?void 0:t.trim())??"",l=s?jL(n):void 0,c=[e,a||void 0,l].filter(Boolean);return{label:Wk(e),name:a?Wk(a):void 0,shortId:l,fullLabel:c.join(Sv)}}function jL(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function Hk(e){if(e.kind==="root")return e.label}function Gk(e){if(e.kind==="root")return i2(e.sessionName,e.sessionTitle).face}function EL({onFit:e}){const{x:t,y:n,zoom:s}=WT(),a=Yl(),l=ct(bL,CL);if(l.length<=1)return null;const c=h=>{try{const p=a.getNodes().filter(f=>{const m=f.data;return(m==null?void 0:m.sessionId)===h});if(p.length===0)return;a.fitView({padding:.3,duration:500,nodes:p}),e==null||e()}catch{}},d={transform:`translate(${t}px, ${n}px) scale(${s})`};return i.jsx("div",{className:"session-clusters",style:d,children:l.map(h=>{const p=ix(h.sessionId),f={position:"absolute",left:h.x,top:h.y,width:h.w,height:h.h,"--session-hue":p},m={position:"absolute",left:h.x+16,top:h.y-xL,transform:`scale(${Math.min(1,s)/(s||1)})`,transformOrigin:"left top","--session-hue":p};return i.jsxs(fe.Fragment,{children:[i.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),i.jsxs("button",{type:"button",className:"cluster-label",style:m,title:`Fit view to ${h.fullLabel}
70
+ drag the wrapper to move the whole session`,onClick:()=>c(h.sessionId),children:[h.label,h.name?i.jsxs(i.Fragment,{children:[Sv,i.jsx("span",{className:"cluster-label-name",children:h.name})]}):null,h.shortId?i.jsx("span",{className:"cluster-label-id",children:Sv+h.shortId}):null]})]},h.sessionId)})})}function CL(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.fullLabel!==a.fullLabel||s.x!==a.x||s.y!==a.y||s.w!==a.w||s.h!==a.h)return!1}return!0}function TL({data:e}){return i.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const ec={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"}},AL=Object.fromEntries(Object.entries(ec).map(([e,t])=>[e,t.category])),RL=Object.fromEntries(Object.entries(ec).map(([e,t])=>[e,t.emoji])),ML=Object.fromEntries(Object.entries(ec).map(([e,t])=>[e,t.label])),IL=new Set(Object.keys(ec)),$L=new Set(Object.entries(ec).filter(([,e])=>e.shell).map(([e])=>e)),Vk={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",...AL};function u2(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(Vk,e)?Vk[e]:"other"}const OL=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,PL=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function LL(e){if(typeof e!="string"||!e)return null;const t=OL.exec(e);if(t){const s=DL(t[2]);if(s.trim())return s}const n=PL.exec(e);return n?n[1]:null}function DL(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
71
+ `:n==="r"?"\r":n==="t"?" ":n)}const d2=600,qL=4,FL=36,jv=16,BL=60,zL=6,Yk=220,Kk=96,UL=28,Xk={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:"📡",...RL};function Qk(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(Xk,e)?Xk[e]:"✨"}const Zk={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 h2(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return h2(n[1]);for(;;){const l=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;t=t.slice(l[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 WL(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=LL(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(a=>/^(-Command|-c)$/i.test(a));if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const HL=new Set(["Bash","PowerShell",...$L]),GL=IL;function VL(e,t){return GL.has(e)||e.startsWith("mcp__")?Math.max(Kk,34+t.length*7.5):Kk}function YL(e,t){if(!HL.has(e))return null;const n=WL(t);if(!n)return null;const s=h2(n);return s?{emoji:Object.hasOwn(Zk,s)?Zk[s]:"⚙️",label:s,category:"shell",detail:n}:null}const KL=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Jk={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:"🗄️"},e1={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 XL(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function QL(e){const t=e.toLowerCase();if(Object.hasOwn(e1,t))return e1[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const n=t.lastIndexOf(".");if(n>0&&n<t.length-1){const s=t.slice(n+1);if(Object.hasOwn(Jk,s))return Jk[s]}return"📄"}function ZL(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 JL(e,t){if(!KL.has(e))return null;const n=ZL(e,t);if(!n)return null;const s=XL(n);return s?{emoji:e==="LS"?"📂":QL(s),label:s,category:"file",detail:n}:null}const t1={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 hx(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 e5(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 f2(e){const t=e.toLowerCase();return Object.hasOwn(t1,t)?t1[t]:void 0}function t5(e,t){const n=hx(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const l=f2(s);return{emoji:(l==null?void 0:l.emoji)??"🔌",label:a,category:"mcp",detail:l?`${l.name} · ${a}`:`${s} · ${a}`}}function n5(e,t){return YL(e,t)??JL(e,t)??t5(e)}const n1=ML,r1=18;function r5(e){const t=[...e];return t.length<=r1?e:t.slice(0,r1-1).join("")+"…"}function p2(e){const t=hx(e);if(t){const s=f2(t.server);return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:r5(t.server),hue:e5(t.server)}}const n=Object.hasOwn(n1,e)?n1[e]:"";return n?{emoji:Qk(e),label:n}:{emoji:Qk(e),label:e}}function s5(e){let t=null,n="";for(const s of e){const a=hx(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:p2(n)}function a5(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function o5(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/d2)}function i5(e,t){const n=[],s=new Set;for(let a=e.length-1;a>=0&&n.length<t;a--){const l=e[a];s.has(l.id)||(s.add(l.id),n.push(l))}return n.reverse()}function l5(e,t,n,s,a,l){const c=[];for(const d of e.values()){if(!t.has(d.id)||d.exitAt!=null&&l-d.exitAt>d2)continue;const h=s.get(d.id)??n.get(d.id);if(!h)continue;const p=i5(d.tools,qL);if(p.length===0)continue;const f=d.exitAt??null,m=a.get(d.id),y=Math.max((m==null?void 0:m.width)??Yk,Yk),v=(m==null?void 0:m.height)??130,j=h.x,_=h.y,S=j+y,x=_+v/2;p.forEach((N,E)=>{const C=E*FL,R=j+y+BL,I=_+zL+C,$=o5(l,f),F=N.inputPreview??"",O=a5(N),M=$<.999,L=p2(N.name);c.push({id:`${d.id}::${N.id}`,toolId:N.id,agentId:d.id,toolName:N.name,name:L.label,emoji:L.emoji,status:O,category:u2(N.name),mcpHue:L.hue,inputPreview:F,fade:$,fading:M,worldX:R,worldY:I,anchorX:S,anchorY:x,spawnDx:S-R,spawnDy:x-(I+jv)});const H=n5(N.name,N.input);if(H){const B=VL(N.name,L.label),A=R+B+UL,Q=I,K=R+B,ee=I+jv;c.push({id:`sub:${d.id}::${N.id}`,toolId:N.id,agentId:d.id,toolName:N.name,name:H.label,emoji:H.emoji,isSub:!0,status:O,category:H.category,inputPreview:H.detail??F,fade:$,fading:M,worldX:A,worldY:Q,anchorX:K,anchorY:ee,spawnDx:K-A,spawnDy:0})}})}return c}function c5({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:l,hiddenCategories:c,now:d,onOpenTool:h}){const p=l5(e,t,n,s,a,d),f=c&&c.size>0?p.filter(m=>!c.has(m.category)):p;return i.jsx(u5,{bursts:f,spotlight:l,onOpenTool:h})}function u5({bursts:e,spotlight:t,onOpenTool:n}){const{x:s,y:a,zoom:l}=WT();return i.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[i.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const d=c.anchorX*l+s,h=c.anchorY*l+a,p=(c.worldX+6)*l+s,f=(c.worldY+jv)*l+a,m=Math.max(1,p-d),y=Math.min(1,Math.abs(f-h)/m),v=d+m*(.55-.22*y),j=t!=null&&!t.has(c.agentId),_=c.fade*(j?.14:1);return i.jsx("path",{d:`M ${d} ${h} Q ${v} ${h}, ${p} ${f}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const d=c.worldX*l+s,h=c.worldY*l+a,p={left:`${d}px`,top:`${h}px`,transform:`scale(${l})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},f=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,m=c.inputPreview?`${f} · ${c.inputPreview}`:f,y=n!=null,v=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=t!=null&&!t.has(c.agentId)?" dim":"";return i.jsx("div",{className:"tool-burst-wrap",style:p,children:i.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${y?" clickable":""}${c.isSub?" sub":""}${_}`,style:v,title:m,onClick:y?()=>n(c.toolId):void 0,children:[i.jsx("span",{className:"tb-emoji",children:c.emoji}),i.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&i.jsx("span",{className:"tb-spin"}),c.status==="done"&&i.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&i.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function d5(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,a=0,l=0;for(const c of e){const d=En(c);t.input+=d.input,t.output+=d.output,t.cacheRead+=d.cacheRead,t.cacheWrite+=d.cacheWrite,t.total+=d.total,n+=c.usage.inputTokens,s+=c.usage.outputTokens,a+=c.usage.cacheReadTokens,l+=c.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:a,cacheCreateTokens:l,sum:n+s}}const h5="spend on this board",f5="on this board",s1=`Everything on the board right now, and only that.
72
72
  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.
73
- Press H for the totals ccusage reads off the logs on disk, which do not forget.`,m2="session spend";function fx({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(l,c,d)=>{if(l<=0)return null;const h=l/n*100;return i.jsx("span",{className:`cb-seg ${c}`,style:{width:`${h}%`},title:`${d}: ${tt(l)} (${h.toFixed(0)}%)`},c)},a=t==="lg";return i.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")]})}function p5({state:e,sessionId:t,onClose:n}){const s=b.useMemo(()=>m5(e,t),[e,t]),a=b.useRef(null),l=Ht(n,{focusRef:a});return s?i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:l,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),i.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),i.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),i.jsx("button",{type:"button",ref:a,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body",children:[i.jsxs("section",{className:"ss-hero",children:[i.jsxs("div",{className:"ss-hero-left",children:[i.jsx("div",{className:"ss-cost-label",children:m2}),i.jsx("div",{className:"ss-cost",children:tt(s.cost.total)}),s.modelChips.length>0&&i.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>i.jsx("span",{className:"model-chip","data-family":bd(c),title:c,children:Ys(c)},c))})]}),i.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&i.jsxs(i.Fragment,{children:[i.jsx(fx,{cost:s.cost,size:"lg"}),i.jsxs("div",{className:"ss-cost-legend",children:[i.jsxs("span",{className:"ssl ssl-in",children:["input ",i.jsx("b",{children:tt(s.cost.input)})]}),i.jsxs("span",{className:"ssl ssl-out",children:["output ",i.jsx("b",{children:tt(s.cost.output)})]}),i.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",i.jsx("b",{children:tt(s.cost.cacheRead)})]}),i.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",i.jsx("b",{children:tt(s.cost.cacheWrite)})]})]})]})})]}),i.jsxs("section",{className:"ss-stats",children:[i.jsx(zo,{label:"agents",value:s.agentCount}),i.jsx(zo,{label:"subagents",value:s.subagentCount}),i.jsx(zo,{label:"tool calls",value:s.toolCount}),i.jsx(zo,{label:"prompts",value:s.promptCount}),i.jsx(zo,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&i.jsx(zo,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Most-used tools"}),i.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>i.jsxs("div",{className:"ss-tt",children:[i.jsx("span",{className:"ss-tt-name",children:c}),i.jsx("span",{className:"ss-tt-bar",children:i.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),i.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Opening prompt"}),i.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function zo({label:e,value:t,tone:n}){return i.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[i.jsx("div",{className:"ss-stat-value",children:t}),i.jsx("div",{className:"ss-stat-label",children:e})]})}function m5(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const E of e.agents.values())E.sessionId===t&&s.push(E);if(s.length===0)return null;const a={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,c=new Map;let d=0,h=0,p=0,f=0,m=0,y,v=1/0,j=0;for(const E of s){const C=En(E);a.input+=C.input,a.output+=C.output,a.cacheRead+=C.cacheRead,a.cacheWrite+=C.cacheWrite,a.total+=C.total;for(const R of r2(E))l.add(R);E.model&&l.add(E.model),E.kind==="subagent"&&m++,h+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),p+=E.usage.inputTokens+E.usage.outputTokens,d+=E.toolCount,v=Math.min(v,E.startedAt),j=Math.max(j,E.endedAt??Date.now());for(const R of E.tools)c.set(R.name,(c.get(R.name)??0)+1),R.ok===!1&&f++}const _=Math.max(0,j-v),S=Math.floor(_/1e3),x=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,N=Array.from(c.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:x,cost:a,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:d,promptCount:h,tokensSum:p,errCount:f,topTools:N,firstPrompt:y}}function a1(e){return e.waiting?Zl(e.waiting)?0:1:e.state==="active"?2:3}function g5(e,t){const n=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let a=s.toolCount,l=En(s).total,c=s.endedAt??s.startedAt;for(const d of e.agents.values()){if(d.sessionId!==s.sessionId||d.kind==="root")continue;a+=d.toolCount,l+=En(d).total;const h=d.endedAt??d.startedAt;h>c&&(c=h)}n.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,waiting:s.waiting,modelId:s.model,toolCount:a,cost:l,startedAt:s.startedAt,lastActivity:c})}return n.sort((s,a)=>{const l=a1(s),c=a1(a);return l!==c?l-c:s.waiting&&a.waiting?s.waiting.since-a.waiting.since:a.lastActivity-s.lastActivity}),n}function o1(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 l=Math.floor(a/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function y5({state:e,now:t,selectedIds:n,onSelect:s,onClose:a}){const l=b.useMemo(()=>g5(e),[e,e.revision,t]),c=l.filter(h=>h.state==="active").length,d=l.filter(h=>Zl(h.waiting)).length;return i.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[i.jsxs("div",{className:"sl-header",children:[i.jsxs("h2",{children:["Sessions ",i.jsx("span",{className:"sl-count",children:l.length})]}),d>0&&i.jsxs("span",{className:"sl-waiting-count",children:[d," waiting"]}),c>0&&i.jsxs("span",{className:"sl-live-count",children:[c," live"]}),i.jsx("button",{className:"glyph-btn sl-close",onClick:a,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),i.jsxs("div",{className:"sl-rows",children:[l.length===0&&i.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(h=>{const p=n.has(h.sessionId);return i.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>s(h.sessionId),title:`Focus ${h.label}`,children:[i.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:od(h.state)}),i.jsxs("div",{className:"sl-row-body",children:[i.jsxs("div",{className:"sl-row-head",children:[i.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&i.jsx("span",{className:"model-chip","data-family":bd(h.modelId),title:h.modelId,children:Ys(h.modelId)})]}),i.jsxs("div",{className:"sl-row-meta",children:[i.jsxs("span",{title:"tool calls",children:[i.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&i.jsx("span",{className:"sl-cost",title:m2,children:i.jsx("b",{children:tt(h.cost)})}),h.waiting?i.jsxs("span",{className:"sl-waiting",title:[Dl(h.waiting),pL(h.waiting,Dl(h.waiting)),`Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`].filter(Boolean).join(`
74
- `),children:["waiting ",o1(h.waiting.since,void 0,t),h.waiting.tool&&i.jsxs("span",{className:"sl-waiting-tool",children:[" · ",h.waiting.tool.name]})]}):i.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:o1(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]})]})]},h.sessionId)})]})]})}const w5=e=>1-Math.pow(1-e,5),g2=420;function v5(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 x5(e,t,n,s=g2){return n>=s?t:n<=0?e:e+(t-e)*w5(n/s)}function b5(e,t,n,s={}){const a=s.now??(()=>performance.now()),l=s.raf??(v=>requestAnimationFrame(v)),c=s.cancel??(v=>cancelAnimationFrame(v)),d=s.reducedMotion??(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches),h=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(d()||h()||!v5(e,t))return n(t),()=>{};const p=a();let f=0,m=!0;const y=()=>{if(!m)return;const v=a()-p;n(x5(e,t,v)),v<g2&&(f=l(y))};return f=l(y),()=>{m=!1,f&&c(f)}}const jv={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function i1(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId)continue;const a=En(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})}return n}function k5(e,t){if(!e)return jv;const n={...jv};for(const[s,a]of t){const l=e.get(s);if(!l)continue;const c={cost:a.cost-l.cost,inputTokens:a.inputTokens-l.inputTokens,outputTokens:a.outputTokens-l.outputTokens,cacheReadTokens:a.cacheReadTokens-l.cacheReadTokens,cacheCreateTokens:a.cacheCreateTokens-l.cacheCreateTokens};c.cost<0||c.inputTokens<0||c.outputTokens<0||c.cost===0&&c.inputTokens===0&&c.outputTokens===0&&c.cacheReadTokens===0&&c.cacheCreateTokens===0||(n.cost+=c.cost,n.inputTokens+=Math.max(0,c.inputTokens),n.outputTokens+=Math.max(0,c.outputTokens),n.cacheReadTokens+=Math.max(0,c.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,c.cacheCreateTokens),n.sessions+=1)}return n}function Ev(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const _d=[{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 _5(e,t,n=_d.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 N5(e,t=new Date){return e==="today"?Ev(1,t):e==="month"?Ev(t.getDate(),t):"20200101"}const jn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Wu=e=>typeof e=="string"?e:"";function y2(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 l of a){const c=Wu(l==null?void 0:l.modelName);if(!c)continue;let d=n.get(c);d||(d={model:c,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(c,d)),d.cost+=jn(l==null?void 0:l.cost),d.inputTokens+=jn(l==null?void 0:l.inputTokens),d.outputTokens+=jn(l==null?void 0:l.outputTokens),d.cacheReadTokens+=jn(l==null?void 0:l.cacheReadTokens),d.cacheCreateTokens+=jn(l==null?void 0:l.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const S5=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function j5(e){var t;return((t=S5.exec(e))==null?void 0:t[0])??e}function E5(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=[];for(const a of n){const l=Wu(a==null?void 0:a.period);if(!l)continue;const c=j5(l),d=a==null?void 0:a.metadata,h=typeof(d==null?void 0:d.lastActivity)=="string"?Date.parse(d.lastActivity):NaN;s.push({sessionId:c,label:t.get(c)??null,agent:Wu(a==null?void 0:a.agent)||"claude",cost:jn(a==null?void 0:a.totalCost),tokens:jn(a==null?void 0:a.totalTokens),models:Array.isArray(a==null?void 0:a.modelsUsed)?a.modelsUsed.map(Wu).filter(Boolean):[],lastActivityMs:Number.isFinite(h)?h:null})}return s.sort((a,l)=>l.cost-a.cost||l.tokens-a.tokens)}function w2(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const h=jn(t.cacheReadTokens),p=jn(t.cacheCreationTokens),f=jn(t.inputTokens),m=jn(t.outputTokens);return{cost:jn(t.totalCost),inputTokens:f,outputTokens:m,cacheReadTokens:h,cacheCreateTokens:p,tokens:jn(t.totalTokens)||f+m+h+p}}const n=y2(e),s=h=>n.reduce((p,f)=>p+h(f),0),a=s(h=>h.inputTokens),l=s(h=>h.outputTokens),c=s(h=>h.cacheReadTokens),d=s(h=>h.cacheCreateTokens);return{cost:s(h=>h.cost),inputTokens:a,outputTokens:l,cacheReadTokens:c,cacheCreateTokens:d,tokens:a+l+c+d}}function C5(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 l1(e,t){var n;return((n=_d.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function T5(e,t,n){const s=e!=null,a=w2(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 A5="1",c1="agent-dag.schema",R5=["agent-dag.layout","agent-dag.viewport"];function hi(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function M5(e,t=A5){let n=null;try{n=e.getItem(c1)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of R5)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(c1,t)}catch{}return s}const Wt="ccdeck";function v2(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 Cv(e){return v2(Math.floor(e/1e3))}function x2(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),a=Math.floor(n%86400/3600),l=Math.floor(n%3600/60);return s>0?`${s}d ${a}h`:a>0?`${a}h ${l}m`:`${l}m`}function I5(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function $5(e,t,n){const s=new Date(e),a=Cv(t-e);return{label:I5(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Ks(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Nd(e){return e==null}const Tv="self";function dr(e,t=!1){const n=Ks(e?Tv:null,Tv);return{disabled:t||n.disabled,"aria-busy":n.busy}}function hr(e){return Nd(e?Tv:null)}function O5(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function P5(e){return e==null||e==="BODY"||e==="HTML"}const b2="agent-dag.usagePeriod";function L5(){const e=hi(b2);return _d.some(t=>t.key===e)?e:"today"}function D5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(b2,e)}catch{}}const k2="agent-dag.usageSessionsOpen";function q5(){return hi(k2)==="1"}function F5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(k2,e?"1":"0")}catch{}}function u1(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 B5(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":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"}const Of="__unknown__";function z5(e,t,n,s){const a=Math.max(0,t-s),l=Math.max(0,n-a);if(l<120)return null;const c=Math.min(100,l/n*100),d=e-c;if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,p=l>0?e/l:0,f=p>0?h/p:1/0,m={label:`${Math.round(d)}% ahead`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(f<a&&f<86400){const y=Math.floor(f/3600),v=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${v}m`:`${v}m`}return m}return{label:`${Math.round(-d)}% reserve`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Ba({pct:e,label:t,reset:n,resetAt:s,windowSec:a,limitReached:l,nowSec:c}){const d=Math.min(100,Math.max(0,e)),p=l||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",f=d===0?"< 1%":`${d}%`,m=d===0?2:d,y=s?x2(s,c):null,v=s&&a?z5(d,s,a,c):null;return i.jsxs("div",{className:"qb-row",children:[i.jsxs("div",{className:"qb-meta",children:[i.jsxs("span",{className:"qb-label",children:[t,l&&i.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),i.jsx("span",{className:"qb-pct",style:{color:p},children:f})]}),i.jsxs("div",{className:"qb-track",children:[i.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:p,opacity:d===0?.4:1}}),v&&i.jsx("div",{className:"qb-pace-marker",style:{left:`${v.expectedPct}%`,background:v.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(v.expectedPct)}% by now`})]}),i.jsxs("div",{className:"qb-reset-row",children:[y?i.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):n?i.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&i.jsx("span",{className:"qb-pace",style:{color:v.color},children:v.runsOutIn?`runs out in ${v.runsOutIn}`:v.label})]})]})}const U5=6e4;function W5(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useRef(null),c=b.useRef(!1),d=async(p=!1)=>{if(!(p&&!hr(c.current))){p&&(c.current=!0,a(!0));try{const m=await fetch(p?"/api/quota?refresh=1":"/api/quota");m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,a(!1))}}};return b.useEffect(()=>{if(e)return d(!0),l.current=window.setInterval(()=>d(!1),U5),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&d(!0)}}}function H5(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 G5(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const _2=6e4,d1=6e4;function V5(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useRef(null),c=b.useRef(!1),d=async(p=!1)=>{if(!(p&&!hr(c.current))){p&&(c.current=!0,a(!0));try{const m=await fetch(p?"/api/codex-quota?refresh=1":"/api/codex-quota");m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,a(!1))}}};return b.useEffect(()=>{if(e)return d(!0),l.current=window.setInterval(()=>d(!1),_2),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&d(!0)}}}function Y5(e){const[t,n]=b.useState(null),s=b.useRef(null),a=async()=>{try{const l=await fetch("/api/codex-usage");l.ok&&n(await l.json())}catch{}};return b.useEffect(()=>{if(e)return a(),s.current=window.setInterval(a,_2),()=>{s.current!=null&&window.clearInterval(s.current)}},[e]),{data:t}}function K5(e,t,n){const[s,a]=b.useState(null),[l,c]=b.useState(!1),[d,h]=b.useState(0),p=b.useRef(0);b.useEffect(()=>{const m=()=>document.visibilityState==="visible",y=()=>{m()&&h(_=>_+1)},v=window.setInterval(y,d1),j=()=>{m()&&Date.now()-p.current>=d1&&h(_=>_+1)};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",j)}},[]);const f=b.useRef(t);return b.useEffect(()=>{let m=!0;const y=t!==f.current;f.current=t;const v=e,j=N5(v);return c(!0),fetch(`/api/ccusage?since=${j}${y?"&refresh=1":""}`).then(_=>_.ok?_.json():null).then(_=>{!m||!(_!=null&&_.ok)||(p.current=Date.now(),a({period:v,data:_,baseline:n()}))}).catch(()=>{}).finally(()=>{m&&c(!1)}),()=>{m=!1}},[e,t,d]),{...C5(s,e),loading:l}}function vl(e){const[t,n]=b.useState(e),s=b.useRef(e),a=b.useRef(!0);return b.useEffect(()=>{s.current=t},[t]),b.useEffect(()=>{if(a.current){a.current=!1,s.current=e,n(e);return}return b5(s.current,e,c=>{s.current=c,n(c)})},[e]),t}function X5({state:e,now:t,providers:n,leaving:s,onClose:a}){var Xe,he;const{quota:l,loading:c,refresh:d}=W5(n.claude),{data:h,loading:p,refresh:f}=V5(n.codex),{data:m}=Y5(n.codex),[y,v]=b.useState(()=>Math.floor(Date.now()/1e3));b.useEffect(()=>{const ge=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ge)},[]);const{byModel:j,totalCost:_,totalTokens:S,burnRate:x}=b.useMemo(()=>{const ge=new Map;for(const ne of e.agents.values())for(const De of Ql(ne)){const Oe=De.model??Of,Te=lx(De.usage,De.model),Ce=ge.get(Oe);Ce?(Ce.inputTokens+=De.usage.inputTokens,Ce.outputTokens+=De.usage.outputTokens,Ce.cacheReadTokens+=De.usage.cacheReadTokens,Ce.cacheCreateTokens+=De.usage.cacheCreateTokens,Ce.cost.total+=Te.total,Ce.cost.input+=Te.input,Ce.cost.output+=Te.output,Ce.cost.cacheRead+=Te.cacheRead,Ce.cost.cacheWrite+=Te.cacheWrite,Ce.agentCount++):ge.set(Oe,{model:Oe,inputTokens:De.usage.inputTokens,outputTokens:De.usage.outputTokens,cacheReadTokens:De.usage.cacheReadTokens,cacheCreateTokens:De.usage.cacheCreateTokens,cost:{...Te},agentCount:1,priced:di(De.model)!=null})}const Se=Array.from(ge.values()).sort((ne,De)=>De.cost.total-ne.cost.total||De.inputTokens+De.outputTokens-(ne.inputTokens+ne.outputTokens));let Fe=0,et=0;for(const ne of e.agents.values()){if(ne.state!=="active")continue;const De=En(ne);Fe+=De.total,et=Math.max(et,((ne.endedAt??t)-ne.startedAt)/1e3)}const xt=et>0?cx(Fe,et):null,ht=d5(e.agents.values());return{byModel:Se,totalCost:ht.cost,totalTokens:ht,burnRate:xt}},[e,e.revision,t]),N=b.useMemo(()=>{const ge=[];for(const Se of e.agents.values()){if(Se.kind!=="root")continue;let Fe=En(Se).total,et=Se.usage.inputTokens,xt=Se.usage.outputTokens,ht=_v(Se);for(const ne of e.agents.values())ne.sessionId!==Se.sessionId||ne.kind==="root"||(Fe+=En(ne).total,et+=ne.usage.inputTokens,xt+=ne.usage.outputTokens,ht+=_v(ne));ge.push({sessionId:Se.sessionId,label:Se.label||Se.cwdBasename||"session",state:Se.state,cost:Fe,inputTokens:et,outputTokens:xt,unpricedTokens:ht})}return ge.sort((Se,Fe)=>Fe.cost-Se.cost||Fe.inputTokens+Fe.outputTokens-(Se.inputTokens+Se.outputTokens)).slice(0,12)},[e,e.revision]),[E,C]=b.useState(L5);b.useEffect(()=>{D5(E)},[E]);const[R,I]=b.useState(q5);b.useEffect(()=>{F5(R)},[R]);const $=b.useRef([]),[F,O]=b.useState(0),M=b.useRef(()=>new Map);M.current=()=>i1(e.agents.values(),t);const L=b.useCallback(()=>M.current(),[]),{data:H,shown:B,stale:A,loading:Q,baseline:K}=K5(E,F,L),ee=H!=null,Z=Q&&A,D=b.useMemo(()=>{const ge=new Map;for(const Se of e.agents.values()){if(Se.kind!=="root"||!Se.sessionId)continue;const Fe=Se.label||Se.cwdBasename;Fe&&ge.set(Se.sessionId,Fe)}return ge},[e,e.revision]),Y=b.useMemo(()=>{const ge=new Map;for(const Se of e.agents.values())Se.kind!=="root"||!Se.sessionId||ge.set(Se.sessionId,Se.state);return ge},[e,e.revision]),P=b.useMemo(()=>ee?y2(H):[],[H,ee]),G=b.useMemo(()=>{if(!ee)return[];const ge=E5(H,D).slice(0,12),Se=new Map;for(const Fe of ge)Fe.label&&Se.set(Fe.label,(Se.get(Fe.label)??0)+1);return ge.map(Fe=>Fe.label&&(Se.get(Fe.label)??0)>1?{...Fe,label:`${Fe.label} ${Fe.sessionId.slice(0,4)}`}:Fe)},[H,ee,D]),de=b.useMemo(()=>w2(H),[H]),W=l1(B,E),U=A?" up-stale":"",J=b.useMemo(()=>ee?k5(K,i1(e.agents.values(),t)):jv,[e,e.revision,K,ee,t]),V=T5(H,{...S,cost:_},J),ie=V.hasCost,pe=V.tokenSum,me=vl(V.cost),Ie=vl(V.inputTokens),Le=vl(V.outputTokens),ce=vl(V.cacheReadTokens),xe=vl(V.cacheCreateTokens),ye=j.filter(ge=>ge.cost.total>0||ge.inputTokens+ge.outputTokens>0),ze=N.filter(ge=>ge.cost>0||ge.inputTokens+ge.outputTokens>0),ke=ee?P.some(ge=>ge.cost<=0&&ge.tokens>0):ye.some(ge=>!ge.priced),je=c||p,Ye=u1(l==null?void 0:l.fetchedAt,y),it=u1(h==null?void 0:h.fetchedAt,y),Ne=()=>{d(),f(),O(ge=>ge+1)},He=n.claude&&n.codex?"Refresh Claude + Codex quota":n.codex?"Refresh Codex quota":"Refresh Claude quota";return i.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[i.jsxs("div",{className:"up-header",children:[i.jsx("h2",{children:"Usage"}),x&&i.jsx("span",{className:"up-rate",children:x}),i.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&i.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Ne,...dr(je),"aria-label":He,title:He,children:je?"…":"↻"}),i.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:a,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Claude quota",Ye&&!c&&i.jsx("span",{className:"up-section-age",title:B5(l==null?void 0:l.source),children:Ye})]}),l!=null&&l.ok?i.jsxs("div",{className:"up-quota-bars",children:[l.session5hPct!=null&&i.jsx(Ba,{label:"5-hour window",pct:l.session5hPct,reset:l.session5hReset,resetAt:l.session5hResetAt,windowSec:l.session5hWindowSec,nowSec:y}),l.week7dPct!=null&&i.jsx(Ba,{label:"7-day window",pct:l.week7dPct,reset:l.week7dReset,resetAt:l.week7dResetAt,windowSec:l.week7dWindowSec,nowSec:y}),l.weekSonnetPct!=null&&i.jsx(Ba,{label:"Sonnet (7d)",pct:l.weekSonnetPct,nowSec:y}),l.weekOpusPct!=null&&i.jsx(Ba,{label:"Opus (7d)",pct:l.weekOpusPct,nowSec:y})]}):(l==null?void 0:l.ok)===!1?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:l.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:H5(l.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),n.codex&&i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Codex quota",(h==null?void 0:h.ok)&&h.planLabel&&i.jsx("span",{className:"up-plan-badge",children:h.planLabel}),it&&!p&&i.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:it})]}),h!=null&&h.ok?i.jsxs("div",{className:"up-quota-bars",children:[(Xe=h.windows)==null?void 0:Xe.map(ge=>i.jsx(Ba,{label:ge.label,pct:ge.pct,reset:ge.reset??void 0,resetAt:ge.resetAt??void 0,windowSec:ge.windowSec??void 0,limitReached:h.limitReached&&ge.pct>=100,nowSec:y},ge.id)),(he=h.extraWindows)==null?void 0:he.map(ge=>i.jsx(Ba,{label:ge.label,pct:ge.pct,reset:ge.reset??void 0,resetAt:ge.resetAt??void 0,windowSec:ge.windowSec??void 0,nowSec:y},ge.id)),h.creditLimit&&i.jsx(Ba,{label:`spend cap · $${Math.round(h.creditLimit.used)} of $${Math.round(h.creditLimit.limit)}`,pct:h.creditLimit.usedPct,reset:h.creditLimit.reset??void 0,resetAt:h.creditLimit.resetAt??void 0,limitReached:h.spendControlReached,nowSec:y}),h.creditsBalance&&!h.creditsUnlimited&&i.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",h.creditsBalance,h.overageReached&&" · overage limit reached"]}),h.creditsUnlimited&&i.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),h.resetCredits&&h.resetCredits.availableCount>0&&i.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Wt} only reports them`,children:[h.resetCredits.availableCount," rate-limit reset",h.resetCredits.availableCount!==1?"s":""," available",h.resetCredits.nextExpiryAt&&` · expires ${new Date(h.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),h.promo&&i.jsx("div",{className:"up-quota-sub",children:h.promo}),h.partial&&i.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(h==null?void 0:h.ok)===!1?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:G5(h.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(m==null?void 0:m.ok)&&m.window7d&&m.window7d.sessionCount>0&&i.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${m.window5h?`
75
- last 5h: ${At(m.window5h.totalTokens)} tokens · ${m.window5h.sessionCount} session${m.window5h.sessionCount!==1?"s":""}`:""}`,children:[At(m.window7d.totalTokens)," tokens · ",m.window7d.sessionCount," session",m.window7d.sessionCount!==1?"s":""," (7d)"]})]}),ee&&i.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":Z||void 0,onKeyDown:ge=>{var et;const Se=$.current.indexOf(ge.target);if(Se<0)return;const Fe=_5(ge.key,Se);Fe!==null&&(ge.preventDefault(),(et=$.current[Fe])==null||et.focus())},children:_d.map((ge,Se)=>i.jsx("button",{type:"button",ref:Fe=>{$.current[Se]=Fe},tabIndex:E===ge.key?0:-1,"aria-pressed":E===ge.key,"data-pending":E===ge.key&&Z?"":void 0,title:E===ge.key&&Z?`Reading ${ge.noun} from the transcripts on this machine…`:ge.hint,className:"uh-range-btn",onClick:()=>C(ge.key),children:ge.label},ge.key))}),ee&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Z?`Reading ${l1(E,E)}…`:""}),pe>0?i.jsxs(i.Fragment,{children:[ie&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`up-total${U}`,title:ee?void 0:s1,children:[i.jsx("span",{className:"up-total-value",children:tt(me)}),i.jsx("span",{className:"up-total-label",children:ee?W:h5})]}),V.showCostBar&&i.jsx(fx,{cost:_})]}),i.jsxs("div",{className:`up-tokens-row${U}`,title:ee?void 0:s1,children:[i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"in"}),At(Ie)]}),i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"out"}),At(Le)]}),V.cacheReadTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache r"}),At(ce)]}),V.cacheCreateTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache c"}),At(xe)]}),!ie&&i.jsx("span",{className:"up-tok up-scope",children:f5})]}),(ee?P.length:ye.length)>0&&i.jsxs("section",{className:`up-section${U}`,children:[i.jsx("h3",{className:"up-section-title",children:"By model"}),i.jsxs("table",{className:"up-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Model"}),i.jsx("th",{children:"Tokens"}),i.jsx("th",{children:"Cost"})]})}),i.jsx("tbody",{children:ee?P.map(ge=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:ge.model,children:Ys(ge.model)}),i.jsx("td",{className:"up-num",children:At(ge.tokens)}),ge.cost>0?i.jsx("td",{className:"up-num up-cost-val",children:tt(ge.cost)}):i.jsx("td",{className:"up-num up-unpriced",children:Go})]},ge.model)):ye.map(ge=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:ge.model===Of?"no model reported yet":ge.model,children:ge.model===Of?"unknown":Ys(ge.model)}),i.jsx("td",{className:"up-num",children:At(ge.inputTokens+ge.outputTokens)}),ge.priced?i.jsx("td",{className:"up-num up-cost-val",children:tt(ge.cost.total)}):i.jsx("td",{className:"up-num up-unpriced",children:Go})]},ge.model))})]})]}),ee&&G.length===0&&de.tokens>0&&i.jsxs("section",{className:"up-section",children:[i.jsx("h3",{className:"up-section-title",children:"By session"}),i.jsxs("div",{className:"up-hint",children:["No session is dated ",W," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(ee?G.length:ze.length)>0&&(()=>{const ge=ee?G.length:ze.length;return i.jsxs("section",{className:`up-section${U}`,children:[i.jsx("h3",{className:"up-section-title",children:i.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":R,"aria-controls":"up-sessions",title:R?"Hide the per-session breakdown":`Show the per-session breakdown — ${ge} session${ge===1?"":"s"}`,onClick:()=>I(Se=>!Se),children:["By session",ee&&i.jsxs("span",{className:"up-section-age",title:`Sessions with activity ${W}, each showing what that session has cost since it started.
76
- A session that began earlier brings its whole total with it, so these rows can add up to more than the figure above.`,children:["active ",W]}),i.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),i.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!R,children:[ee&&G.map(Se=>{const Fe=Y.get(Se.sessionId);return i.jsxs("div",{className:"up-session-row",children:[Fe?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`sl-dot state-${Fe}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:od(Fe)})]}):i.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),i.jsx("span",{className:`up-session-label${Se.label?"":" up-session-id"}`,title:Se.label?`${Se.label}
77
- ${Se.sessionId}`:Se.sessionId,children:Se.label??Se.sessionId.slice(0,8)}),i.jsx("span",{className:"up-session-tokens",children:At(Se.tokens)}),Se.cost>0?i.jsx("span",{className:"up-session-cost",title:Se.models.join(", ")||void 0,children:tt(Se.cost)}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Go})]},Se.sessionId)}),!ee&&ze.map(Se=>i.jsxs("div",{className:"up-session-row",children:[i.jsx("span",{className:`sl-dot state-${Se.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:od(Se.state)}),i.jsx("span",{className:"up-session-label",children:Se.label}),i.jsx("span",{className:"up-session-tokens",children:At(Se.inputTokens+Se.outputTokens)}),Se.cost>0?i.jsxs("span",{className:"up-session-cost",title:Se.unpricedTokens>0?`${At(Se.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[tt(Se.cost),Se.unpricedTokens>0?"+":""]}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Go})]},Se.sessionId))]})]})})(),ke&&i.jsxs("div",{className:"up-hint",children:["“",Go,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):i.jsx("div",{className:"up-empty",children:ee?i.jsxs(i.Fragment,{children:["No usage ",W,".",i.jsx("br",{}),"Try a longer period."]}):i.jsxs(i.Fragment,{children:["No usage data yet.",i.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}const Yt={l:30,r:6,t:6,b:2},zs={l:0,r:0,t:2,b:1},Sd=104,Q5=64;function ur(e,t=100,n=Sd,s=Yt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function N2(e,t,n,s=100,a=Sd,l=Yt){if(!e.length)return"";const c=e[e.length-1].t-e[0].t,d=f=>{const m=t-l.l-l.r;return l.l+(c>0?m*(f-e[0].t)/c:m/2)};let h="",p=null;for(const f of e){const m=p&&f.t-p.t<=n*2?"L":"M";h+=`${m}${d(f.t).toFixed(1)} ${ur(f.v,s,a,l).toFixed(1)}`,p=f}return h}function S2(e,t,n,s=100,a=Sd,l=Yt){if(e.length<2)return"";const c=a-l.b,d=e[e.length-1].t-e[0].t,h=t-l.l-l.r,p=v=>l.l+(d>0?h*(v-e[0].t)/d:h/2);let f="",m=[];const y=()=>{if(m.length>=2){let v=`M${p(m[0].t).toFixed(1)} ${c}`;for(const j of m)v+=`L${p(j.t).toFixed(1)} ${ur(j.v,s,a,l).toFixed(1)}`;f+=`${v}L${p(m[m.length-1].t).toFixed(1)} ${c}Z`}m=[]};for(const v of e)m.length&&v.t-m[m.length-1].t>n*2&&y(),m.push(v);return y(),f}function Z5(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 j2(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function J5(e,t,n=s=>Tl(s)){const s=e.filter(c=>c.v>0);if(!e.length)return null;if(!s.length)return"never held back";const a=s.length*(t/6e4),l=s[s.length-1];return`held back for ${a===1?"1 minute":`${a} minutes`}, last at ${n(l.t)}`}function Tl(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function px(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 eD({group:e,title:t,onClose:n}){const s=Ht(n),[a,l]=b.useState(null);b.useEffect(()=>{let p=!0;const f=async()=>{try{const y=await fetch(`/api/system/history?group=${e}`);if(!y.ok)return;const v=await y.json();p&&(v!=null&&v.ok)&&l(v)}catch{}};f();const m=window.setInterval(f,2e4);return()=>{p=!1,window.clearInterval(m)}},[e]);const c=(a==null?void 0:a.series)??[],[d,h]=b.useMemo(()=>{let p=1/0,f=0;for(const m of c)m.points.length&&(p=Math.min(p,m.points[0].t),f=Math.max(f,m.points[m.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(a==null?void 0:a.sinceMs)??0):(a==null?void 0:a.sinceMs)??0,f]},[c,a==null?void 0:a.sinceMs]);return Yv.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:s,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),a&&d>0&&i.jsxs("span",{className:"hist-since",children:["since ",Tl(d)," · ",px(d,h||Date.now())]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsx("div",{className:"hist-body",children:a==null?i.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?i.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>i.jsx(tD,{series:p,stepMs:a.stepMs},p.label))})]})}),document.body)}function tD({series:e,stepMs:t}){const n=b.useRef(null),[s,a]=b.useState(560),[l,c]=b.useState(null);b.useEffect(()=>{const $=n.current;if(!$||typeof ResizeObserver>"u")return;const F=new ResizeObserver(([O])=>a(Math.max(160,O.contentRect.width)));return F.observe($),()=>F.disconnect()},[]);const{points:d,unit:h,warnAt:p,critAt:f,label:m,top:y,restsAtZero:v}=e,j=v?Q5:Sd,{now:_,peak:S}=Z5(d),x=h==="C"?"°C":h,N=m==="Throttling"?J5(d,t):null,E=l!=null?d[l]:null,C=d.length>1?d[d.length-1].t-d[0].t:0,R=$=>{const F=s-Yt.l-Yt.r;return Yt.l+(C>0?F*($-d[0].t)/C:F/2)},I=$=>{if(d.length<2)return;const F=$.currentTarget.getBoundingClientRect(),O=($.clientX-F.left-Yt.l)/Math.max(1,F.width-Yt.l-Yt.r),M=d[0].t+C*Math.max(0,Math.min(1,O));let L=0;for(let H=1;H<d.length;H++)Math.abs(d[H].t-M)<Math.abs(d[L].t-M)&&(L=H);c(L)};return i.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[i.jsxs("div",{className:"hist-head",children:[i.jsx("span",{className:"hist-label",children:m}),i.jsxs("span",{className:"hist-stats",children:[_!=null&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:_}),i.jsxs("span",{children:[x," now"]})]}),S!=null&&i.jsxs(i.Fragment,{children:[i.jsx("b",{className:j2(S,p,f),children:S}),i.jsxs("span",{children:[x," peak"]})]})]})]}),i.jsx("div",{className:"hist-plot",ref:n,children:i.jsxs("svg",{className:"hist-chart",width:"100%",height:j,viewBox:`0 0 ${s} ${j}`,preserveAspectRatio:"none",role:"img","aria-label":_==null?`${m}: nothing measured yet`:`${m}: ${_}${x} now, peak ${S}${x}, over ${px(d[0].t,d[d.length-1].t)}`,onPointerMove:I,onPointerLeave:()=>c(null),children:[[["warn",p],["hot",f]].map(([$,F])=>F==null||F>y?null:i.jsxs("g",{children:[i.jsx("line",{className:`hist-rule ${$}`,x1:Yt.l,x2:s-Yt.r,y1:ur(F,y,j),y2:ur(F,y,j)}),i.jsx("text",{className:`hist-rule-tag ${$}`,x:2,y:ur(F,y,j)+3,children:F})]},$)),i.jsx("line",{className:"hist-floor",x1:Yt.l,x2:s-Yt.r,y1:j-Yt.b,y2:j-Yt.b}),i.jsx("path",{className:"hist-area",d:S2(d,s,t,y,j)}),i.jsx("path",{className:"hist-line",d:N2(d,s,t,y,j)}),d.length===1&&i.jsx("circle",{className:"hist-dot",cx:R(d[0].t),cy:ur(d[0].v,y,j),r:3}),E&&i.jsxs("g",{children:[i.jsx("line",{className:"hist-cross",x1:R(E.t),x2:R(E.t),y1:Yt.t,y2:j-Yt.b}),i.jsx("circle",{className:"hist-dot",cx:R(E.t),cy:ur(E.v,y,j),r:3})]})]})}),i.jsx("div",{className:"hist-axis",children:E?i.jsxs("span",{className:"hist-at",children:[Tl(E.t)," — ",i.jsx("b",{children:E.v}),x]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:d.length?Tl(d[0].t):""}),i.jsx("span",{children:d.length?Tl(d[d.length-1].t):""})]})}),N&&i.jsx("div",{className:"hist-note",children:N})]})}const nD="thermal:Throttling";function rD(e){var n,s,a,l;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 c of((a=e.thermal)==null?void 0:a.celsius)??[])t[`thermal:${c.label}`]=c.celsius;return(l=e.thermal)!=null&&l.throttle&&(t[nD]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function Hu(e,t){return t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Tu(e,t){return Number.isInteger(e)?t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`:Hu(e,t)}const h1=["cores","memory","load","thermal"],za=116,Ar=24,sD=60,aD=6e4;function oD(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function iD(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function lD(e,t=sD){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function cD({sys:e}){const[t,n]=b.useState({});b.useEffect(()=>{let c=!0;const d=async()=>{const p=await Promise.all(h1.map(async f=>{try{const m=await fetch(`/api/system/history?group=${f}`);return m.ok?[f,await m.json()]:[f,null]}catch{return[f,null]}}));c&&n(f=>{const m={...f};for(const[y,v]of p)v!=null&&v.ok&&(m[y]=v);return m})};d();const h=setInterval(()=>void d(),aD);return()=>{c=!1,clearInterval(h)}},[]);const s=b.useMemo(()=>rD(e),[e]),a=b.useMemo(()=>h1.flatMap(c=>{const d=t[c];return d?d.series.filter(oD).map(h=>({series:lD(h),stepMs:d.stepMs})):[]}),[t]),l=b.useMemo(()=>{let c=1/0,d=-1/0;for(const{series:h}of a){const p=h.points;p.length&&(c=Math.min(c,p[0].t),d=Math.max(d,p[p.length-1].t))}return Number.isFinite(c)?px(c,d):"less than a minute"},[a]);return Object.keys(s).length?i.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${l}`,children:a.map(({series:c,stepMs:d})=>i.jsx(uD,{series:c,stepMs:d,now:s[c.key],span:l},c.key))}):null}function uD({series:e,stepMs:t,now:n,span:s}){var v;const{points:a,top:l,unit:c,warnAt:d,critAt:h}=e,p=iD(e),f=n??((v=a[a.length-1])==null?void 0:v.v),m=f==null?"":j2(f,d,h),y=Math.max(...a.map(j=>j.v));return i.jsxs("div",{className:`pl-cell${m?` ${m}`:""}`,title:[`${p} · peak ${Hu(y,c)} over the last ${s}`,d!=null?`over ${Tu(d,c)} is uncomfortable`:"",h!=null?`over ${Tu(h,c)} the machine acts`:""].filter(Boolean).join(" · "),children:[i.jsxs("div",{className:"pl-cell-head",children:[i.jsx("span",{className:"pl-cell-label",children:p}),i.jsx("span",{className:"pl-cell-now",children:f==null?"—":Hu(f,c)})]}),i.jsxs("svg",{className:"pl-spark",width:za,height:Ar,viewBox:`0 0 ${za} ${Ar}`,preserveAspectRatio:"none","aria-hidden":!0,children:[i.jsx("line",{className:"pl-spark-floor",x1:0,x2:za,y1:Ar-zs.b,y2:Ar-zs.b}),i.jsx("path",{className:"pl-spark-area",d:S2(a,za,t,l,Ar,zs)}),d!=null&&i.jsx("line",{className:"pl-rule warn",x1:0,x2:za,y1:ur(d,l,Ar,zs),y2:ur(d,l,Ar,zs)}),h!=null&&i.jsx("line",{className:"pl-rule hot",x1:0,x2:za,y1:ur(h,l,Ar,zs),y2:ur(h,l,Ar,zs)}),i.jsx("path",{className:"pl-spark-line",d:N2(a,za,t,l,Ar,zs)})]}),i.jsxs("span",{className:"vis-hidden",children:["peak ",Hu(y,c)," over the last ",s,d!=null&&`, uncomfortable over ${Tu(d,c)}`,h!=null&&`, the machine acts over ${Tu(h,c)}`]})]})}const dD={key:"cpu",dir:"desc"};function hD(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function fD(e,t){const n=t.dir==="asc"?1:-1,s=l=>t.key==="cpu"?l.cpu:t.key==="mem"?l.mem:t.key==="rss"?l.rssBytes:t.key==="threads"?l.threads:l.uptimeSec,a=(l,c)=>{if(t.key==="name")return n*l.name.localeCompare(c.name,void 0,{sensitivity:"base"});if(t.key==="user"){const p=l.user??"",f=c.user??"";return!p||!f?p===f?0:p?-1:1:n*p.localeCompare(f,void 0,{sensitivity:"base"})}const d=s(l),h=s(c);return d==null||h==null?d==null?h==null?0:1:-1:n*(d-h)};return[...e].sort((l,c)=>a(l,c)||(c.cpu??-1)-(l.cpu??-1)||c.mem-l.mem||l.pid-c.pid)}function pD(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}const mD=4e3;function gD(){const[e,t]=b.useState(null);return b.useEffect(()=>{let n=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes?detail=1");if(!l.ok)return;const c=await l.json();n&&(c!=null&&c.ok)&&t({procs:c.procs??[],total:c.total??0})}catch{}};s();const a=window.setInterval(s,mD);return()=>{n=!1,window.clearInterval(a)}},[]),e}function yD(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB"];let n=e/1024,s=0;for(;n>=1024&&s<t.length-1;)n/=1024,s++;return`${n>=100?n.toFixed(0):n.toFixed(1)} ${t[s]}`}function wD(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 vD({sys:e,onClose:t}){const n=Ht(t),[s,a]=b.useState(dD),l=gD(),c=l?fD(l.procs,s):null;return Yv.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal pl-modal",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),l&&i.jsxs("span",{className:"pl-count",children:[c.length," of ",l.total," running"]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("div",{className:"pl-split",children:[i.jsx("div",{className:"pl-body",children:c==null?i.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):c.length===0?i.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):i.jsxs("table",{className:"sd-procs pl-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx(Uo,{col:"cpu",label:"cpu",sort:s,onSort:a}),i.jsx(Uo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:s,onSort:a}),i.jsx(Uo,{col:"threads",label:"threads",sort:s,onSort:a}),i.jsx(Uo,{col:"uptime",label:"up",sort:s,onSort:a}),i.jsx(Uo,{col:"user",label:"user",sort:s,onSort:a}),i.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),i.jsx(Uo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:s,onSort:a})]})}),i.jsx("tbody",{children:c.map(d=>i.jsxs("tr",{children:[i.jsx("td",{className:"sd-num",children:d.cpu==null?"—":d.cpu.toFixed(0)}),i.jsx("td",{className:"sd-num sd-dim",title:`${d.mem.toFixed(1)}% of installed memory`,children:yD(d.rssBytes)}),i.jsx("td",{className:"sd-num sd-dim",children:d.threads??"—"}),i.jsx("td",{className:"sd-num sd-dim",children:wD(d.uptimeSec)}),i.jsx("td",{className:"sd-dim pl-user",children:d.user??"—"}),i.jsx("td",{className:"sd-num sd-dim pl-pid",children:d.pid}),i.jsxs("td",{className:"pl-name",children:[d.name,d.cmd&&i.jsxs("span",{className:"pl-cmd",title:d.cmd,children:[" ",d.cmd]})]})]},d.pid))})]})}),i.jsx(cD,{sys:e})]})]})}),document.body)}function Uo({col:e,label:t,note:n,sort:s,onSort:a}){const l=pD(s,e);return i.jsx("th",{scope:"col","aria-sort":l,children:i.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
73
+ Press H for the totals ccusage reads off the logs on disk, which do not forget.`,m2="session spend";function fx({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(l,c,d)=>{if(l<=0)return null;const h=l/n*100;return i.jsx("span",{className:`cb-seg ${c}`,style:{width:`${h}%`},title:`${d}: ${tt(l)} (${h.toFixed(0)}%)`},c)},a=t==="lg";return i.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")]})}function p5({state:e,sessionId:t,onClose:n}){const s=b.useMemo(()=>m5(e,t),[e,t]),a=b.useRef(null),l=Ht(n,{focusRef:a});return s?i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:l,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),i.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),i.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),i.jsx("button",{type:"button",ref:a,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body",children:[i.jsxs("section",{className:"ss-hero",children:[i.jsxs("div",{className:"ss-hero-left",children:[i.jsx("div",{className:"ss-cost-label",children:m2}),i.jsx("div",{className:"ss-cost",children:tt(s.cost.total)}),s.modelChips.length>0&&i.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>i.jsx("span",{className:"model-chip","data-family":kd(c),title:c,children:Ks(c)},c))})]}),i.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&i.jsxs(i.Fragment,{children:[i.jsx(fx,{cost:s.cost,size:"lg"}),i.jsxs("div",{className:"ss-cost-legend",children:[i.jsxs("span",{className:"ssl ssl-in",children:["input ",i.jsx("b",{children:tt(s.cost.input)})]}),i.jsxs("span",{className:"ssl ssl-out",children:["output ",i.jsx("b",{children:tt(s.cost.output)})]}),i.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",i.jsx("b",{children:tt(s.cost.cacheRead)})]}),i.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",i.jsx("b",{children:tt(s.cost.cacheWrite)})]})]})]})})]}),i.jsxs("section",{className:"ss-stats",children:[i.jsx(Uo,{label:"agents",value:s.agentCount}),i.jsx(Uo,{label:"subagents",value:s.subagentCount}),i.jsx(Uo,{label:"tool calls",value:s.toolCount}),i.jsx(Uo,{label:"prompts",value:s.promptCount}),i.jsx(Uo,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&i.jsx(Uo,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Most-used tools"}),i.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>i.jsxs("div",{className:"ss-tt",children:[i.jsx("span",{className:"ss-tt-name",children:c}),i.jsx("span",{className:"ss-tt-bar",children:i.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),i.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&i.jsxs("section",{className:"modal-section",children:[i.jsx("h4",{children:"Opening prompt"}),i.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Uo({label:e,value:t,tone:n}){return i.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[i.jsx("div",{className:"ss-stat-value",children:t}),i.jsx("div",{className:"ss-stat-label",children:e})]})}function m5(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const E of e.agents.values())E.sessionId===t&&s.push(E);if(s.length===0)return null;const a={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,c=new Map;let d=0,h=0,p=0,f=0,m=0,y,v=1/0,j=0;for(const E of s){const C=En(E);a.input+=C.input,a.output+=C.output,a.cacheRead+=C.cacheRead,a.cacheWrite+=C.cacheWrite,a.total+=C.total;for(const R of r2(E))l.add(R);E.model&&l.add(E.model),E.kind==="subagent"&&m++,h+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),p+=E.usage.inputTokens+E.usage.outputTokens,d+=E.toolCount,v=Math.min(v,E.startedAt),j=Math.max(j,E.endedAt??Date.now());for(const R of E.tools)c.set(R.name,(c.get(R.name)??0)+1),R.ok===!1&&f++}const _=Math.max(0,j-v),S=Math.floor(_/1e3),x=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,N=Array.from(c.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:x,cost:a,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:d,promptCount:h,tokensSum:p,errCount:f,topTools:N,firstPrompt:y}}function a1(e){return e.waiting?Jl(e.waiting)?0:1:e.state==="active"?2:3}function g5(e,t){const n=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let a=s.toolCount,l=En(s).total,c=s.endedAt??s.startedAt;for(const d of e.agents.values()){if(d.sessionId!==s.sessionId||d.kind==="root")continue;a+=d.toolCount,l+=En(d).total;const h=d.endedAt??d.startedAt;h>c&&(c=h)}n.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,waiting:s.waiting,modelId:s.model,toolCount:a,cost:l,startedAt:s.startedAt,lastActivity:c})}return n.sort((s,a)=>{const l=a1(s),c=a1(a);return l!==c?l-c:s.waiting&&a.waiting?s.waiting.since-a.waiting.since:a.lastActivity-s.lastActivity}),n}function o1(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 l=Math.floor(a/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function y5({state:e,now:t,selectedIds:n,onSelect:s,onClose:a}){const l=b.useMemo(()=>g5(e),[e,e.revision,t]),c=l.filter(h=>h.state==="active").length,d=l.filter(h=>Jl(h.waiting)).length;return i.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[i.jsxs("div",{className:"sl-header",children:[i.jsxs("h2",{children:["Sessions ",i.jsx("span",{className:"sl-count",children:l.length})]}),d>0&&i.jsxs("span",{className:"sl-waiting-count",children:[d," waiting"]}),c>0&&i.jsxs("span",{className:"sl-live-count",children:[c," live"]}),i.jsx("button",{className:"glyph-btn sl-close",onClick:a,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),i.jsxs("div",{className:"sl-rows",children:[l.length===0&&i.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(h=>{const p=n.has(h.sessionId);return i.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>s(h.sessionId),title:`Focus ${h.label}`,children:[i.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:id(h.state)}),i.jsxs("div",{className:"sl-row-body",children:[i.jsxs("div",{className:"sl-row-head",children:[i.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&i.jsx("span",{className:"model-chip","data-family":kd(h.modelId),title:h.modelId,children:Ks(h.modelId)})]}),i.jsxs("div",{className:"sl-row-meta",children:[i.jsxs("span",{title:"tool calls",children:[i.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&i.jsx("span",{className:"sl-cost",title:m2,children:i.jsx("b",{children:tt(h.cost)})}),h.waiting?i.jsxs("span",{className:"sl-waiting",title:[ql(h.waiting),pL(h.waiting,ql(h.waiting)),`Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`].filter(Boolean).join(`
74
+ `),children:["waiting ",o1(h.waiting.since,void 0,t),h.waiting.tool&&i.jsxs("span",{className:"sl-waiting-tool",children:[" · ",h.waiting.tool.name]})]}):i.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:o1(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]})]})]},h.sessionId)})]})]})}const w5=e=>1-Math.pow(1-e,5),g2=420;function v5(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 x5(e,t,n,s=g2){return n>=s?t:n<=0?e:e+(t-e)*w5(n/s)}function b5(e,t,n,s={}){const a=s.now??(()=>performance.now()),l=s.raf??(v=>requestAnimationFrame(v)),c=s.cancel??(v=>cancelAnimationFrame(v)),d=s.reducedMotion??(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches),h=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(d()||h()||!v5(e,t))return n(t),()=>{};const p=a();let f=0,m=!0;const y=()=>{if(!m)return;const v=a()-p;n(x5(e,t,v)),v<g2&&(f=l(y))};return f=l(y),()=>{m=!1,f&&c(f)}}const Ev={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function i1(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId)continue;const a=En(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})}return n}function k5(e,t){if(!e)return Ev;const n={...Ev};for(const[s,a]of t){const l=e.get(s);if(!l)continue;const c={cost:a.cost-l.cost,inputTokens:a.inputTokens-l.inputTokens,outputTokens:a.outputTokens-l.outputTokens,cacheReadTokens:a.cacheReadTokens-l.cacheReadTokens,cacheCreateTokens:a.cacheCreateTokens-l.cacheCreateTokens};c.cost<0||c.inputTokens<0||c.outputTokens<0||c.cost===0&&c.inputTokens===0&&c.outputTokens===0&&c.cacheReadTokens===0&&c.cacheCreateTokens===0||(n.cost+=c.cost,n.inputTokens+=Math.max(0,c.inputTokens),n.outputTokens+=Math.max(0,c.outputTokens),n.cacheReadTokens+=Math.max(0,c.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,c.cacheCreateTokens),n.sessions+=1)}return n}function Cv(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const Nd=[{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 _5(e,t,n=Nd.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 N5(e,t=new Date){return e==="today"?Cv(1,t):e==="month"?Cv(t.getDate(),t):"20200101"}const jn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Hu=e=>typeof e=="string"?e:"";function y2(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 l of a){const c=Hu(l==null?void 0:l.modelName);if(!c)continue;let d=n.get(c);d||(d={model:c,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(c,d)),d.cost+=jn(l==null?void 0:l.cost),d.inputTokens+=jn(l==null?void 0:l.inputTokens),d.outputTokens+=jn(l==null?void 0:l.outputTokens),d.cacheReadTokens+=jn(l==null?void 0:l.cacheReadTokens),d.cacheCreateTokens+=jn(l==null?void 0:l.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const S5=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function j5(e){var t;return((t=S5.exec(e))==null?void 0:t[0])??e}function E5(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=[];for(const a of n){const l=Hu(a==null?void 0:a.period);if(!l)continue;const c=j5(l),d=a==null?void 0:a.metadata,h=typeof(d==null?void 0:d.lastActivity)=="string"?Date.parse(d.lastActivity):NaN;s.push({sessionId:c,label:t.get(c)??null,agent:Hu(a==null?void 0:a.agent)||"claude",cost:jn(a==null?void 0:a.totalCost),tokens:jn(a==null?void 0:a.totalTokens),models:Array.isArray(a==null?void 0:a.modelsUsed)?a.modelsUsed.map(Hu).filter(Boolean):[],lastActivityMs:Number.isFinite(h)?h:null})}return s.sort((a,l)=>l.cost-a.cost||l.tokens-a.tokens)}function w2(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const h=jn(t.cacheReadTokens),p=jn(t.cacheCreationTokens),f=jn(t.inputTokens),m=jn(t.outputTokens);return{cost:jn(t.totalCost),inputTokens:f,outputTokens:m,cacheReadTokens:h,cacheCreateTokens:p,tokens:jn(t.totalTokens)||f+m+h+p}}const n=y2(e),s=h=>n.reduce((p,f)=>p+h(f),0),a=s(h=>h.inputTokens),l=s(h=>h.outputTokens),c=s(h=>h.cacheReadTokens),d=s(h=>h.cacheCreateTokens);return{cost:s(h=>h.cost),inputTokens:a,outputTokens:l,cacheReadTokens:c,cacheCreateTokens:d,tokens:a+l+c+d}}function C5(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 l1(e,t){var n;return((n=Nd.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function T5(e,t,n){const s=e!=null,a=w2(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 A5="1",c1="agent-dag.schema",R5=["agent-dag.layout","agent-dag.viewport"];function fi(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function M5(e,t=A5){let n=null;try{n=e.getItem(c1)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of R5)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(c1,t)}catch{}return s}const Wt="ccdeck";function v2(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 Tv(e){return v2(Math.floor(e/1e3))}function x2(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),a=Math.floor(n%86400/3600),l=Math.floor(n%3600/60);return s>0?`${s}d ${a}h`:a>0?`${a}h ${l}m`:`${l}m`}function I5(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function $5(e,t,n){const s=new Date(e),a=Tv(t-e);return{label:I5(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Xs(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Sd(e){return e==null}const Av="self";function dr(e,t=!1){const n=Xs(e?Av:null,Av);return{disabled:t||n.disabled,"aria-busy":n.busy}}function hr(e){return Sd(e?Av:null)}function O5(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function P5(e){return e==null||e==="BODY"||e==="HTML"}const b2="agent-dag.usagePeriod";function L5(){const e=fi(b2);return Nd.some(t=>t.key===e)?e:"today"}function D5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(b2,e)}catch{}}const k2="agent-dag.usageSessionsOpen";function q5(){return fi(k2)==="1"}function F5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(k2,e?"1":"0")}catch{}}function u1(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 B5(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":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"}const Pf="__unknown__";function z5(e,t,n,s){const a=Math.max(0,t-s),l=Math.max(0,n-a);if(l<120)return null;const c=Math.min(100,l/n*100),d=e-c;if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,p=l>0?e/l:0,f=p>0?h/p:1/0,m={label:`${Math.round(d)}% ahead`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(f<a&&f<86400){const y=Math.floor(f/3600),v=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${v}m`:`${v}m`}return m}return{label:`${Math.round(-d)}% reserve`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function za({pct:e,label:t,reset:n,resetAt:s,windowSec:a,limitReached:l,nowSec:c}){const d=Math.min(100,Math.max(0,e)),p=l||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",f=d===0?"< 1%":`${d}%`,m=d===0?2:d,y=s?x2(s,c):null,v=s&&a?z5(d,s,a,c):null;return i.jsxs("div",{className:"qb-row",children:[i.jsxs("div",{className:"qb-meta",children:[i.jsxs("span",{className:"qb-label",children:[t,l&&i.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),i.jsx("span",{className:"qb-pct",style:{color:p},children:f})]}),i.jsxs("div",{className:"qb-track",children:[i.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:p,opacity:d===0?.4:1}}),v&&i.jsx("div",{className:"qb-pace-marker",style:{left:`${v.expectedPct}%`,background:v.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(v.expectedPct)}% by now`})]}),i.jsxs("div",{className:"qb-reset-row",children:[y?i.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):n?i.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&i.jsx("span",{className:"qb-pace",style:{color:v.color},children:v.runsOutIn?`runs out in ${v.runsOutIn}`:v.label})]})]})}const U5=6e4;function W5(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useRef(null),c=b.useRef(!1),d=async(p=!1)=>{if(!(p&&!hr(c.current))){p&&(c.current=!0,a(!0));try{const m=await fetch(p?"/api/quota?refresh=1":"/api/quota");m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,a(!1))}}};return b.useEffect(()=>{if(e)return d(!0),l.current=window.setInterval(()=>d(!1),U5),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&d(!0)}}}function H5(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 G5(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const _2=6e4,d1=6e4;function V5(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useRef(null),c=b.useRef(!1),d=async(p=!1)=>{if(!(p&&!hr(c.current))){p&&(c.current=!0,a(!0));try{const m=await fetch(p?"/api/codex-quota?refresh=1":"/api/codex-quota");m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,a(!1))}}};return b.useEffect(()=>{if(e)return d(!0),l.current=window.setInterval(()=>d(!1),_2),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&d(!0)}}}function Y5(e){const[t,n]=b.useState(null),s=b.useRef(null),a=async()=>{try{const l=await fetch("/api/codex-usage");l.ok&&n(await l.json())}catch{}};return b.useEffect(()=>{if(e)return a(),s.current=window.setInterval(a,_2),()=>{s.current!=null&&window.clearInterval(s.current)}},[e]),{data:t}}function K5(e,t,n){const[s,a]=b.useState(null),[l,c]=b.useState(!1),[d,h]=b.useState(0),p=b.useRef(0);b.useEffect(()=>{const m=()=>document.visibilityState==="visible",y=()=>{m()&&h(_=>_+1)},v=window.setInterval(y,d1),j=()=>{m()&&Date.now()-p.current>=d1&&h(_=>_+1)};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",j)}},[]);const f=b.useRef(t);return b.useEffect(()=>{let m=!0;const y=t!==f.current;f.current=t;const v=e,j=N5(v);return c(!0),fetch(`/api/ccusage?since=${j}${y?"&refresh=1":""}`).then(_=>_.ok?_.json():null).then(_=>{!m||!(_!=null&&_.ok)||(p.current=Date.now(),a({period:v,data:_,baseline:n()}))}).catch(()=>{}).finally(()=>{m&&c(!1)}),()=>{m=!1}},[e,t,d]),{...C5(s,e),loading:l}}function xl(e){const[t,n]=b.useState(e),s=b.useRef(e),a=b.useRef(!0);return b.useEffect(()=>{s.current=t},[t]),b.useEffect(()=>{if(a.current){a.current=!1,s.current=e,n(e);return}return b5(s.current,e,c=>{s.current=c,n(c)})},[e]),t}function X5({state:e,now:t,providers:n,leaving:s,onClose:a}){var Xe,he;const{quota:l,loading:c,refresh:d}=W5(n.claude),{data:h,loading:p,refresh:f}=V5(n.codex),{data:m}=Y5(n.codex),[y,v]=b.useState(()=>Math.floor(Date.now()/1e3));b.useEffect(()=>{const ge=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ge)},[]);const{byModel:j,totalCost:_,totalTokens:S,burnRate:x}=b.useMemo(()=>{const ge=new Map;for(const ne of e.agents.values())for(const De of Zl(ne)){const Oe=De.model??Pf,Te=lx(De.usage,De.model),Ce=ge.get(Oe);Ce?(Ce.inputTokens+=De.usage.inputTokens,Ce.outputTokens+=De.usage.outputTokens,Ce.cacheReadTokens+=De.usage.cacheReadTokens,Ce.cacheCreateTokens+=De.usage.cacheCreateTokens,Ce.cost.total+=Te.total,Ce.cost.input+=Te.input,Ce.cost.output+=Te.output,Ce.cost.cacheRead+=Te.cacheRead,Ce.cost.cacheWrite+=Te.cacheWrite,Ce.agentCount++):ge.set(Oe,{model:Oe,inputTokens:De.usage.inputTokens,outputTokens:De.usage.outputTokens,cacheReadTokens:De.usage.cacheReadTokens,cacheCreateTokens:De.usage.cacheCreateTokens,cost:{...Te},agentCount:1,priced:hi(De.model)!=null})}const Se=Array.from(ge.values()).sort((ne,De)=>De.cost.total-ne.cost.total||De.inputTokens+De.outputTokens-(ne.inputTokens+ne.outputTokens));let Fe=0,et=0;for(const ne of e.agents.values()){if(ne.state!=="active")continue;const De=En(ne);Fe+=De.total,et=Math.max(et,((ne.endedAt??t)-ne.startedAt)/1e3)}const xt=et>0?cx(Fe,et):null,ht=d5(e.agents.values());return{byModel:Se,totalCost:ht.cost,totalTokens:ht,burnRate:xt}},[e,e.revision,t]),N=b.useMemo(()=>{const ge=[];for(const Se of e.agents.values()){if(Se.kind!=="root")continue;let Fe=En(Se).total,et=Se.usage.inputTokens,xt=Se.usage.outputTokens,ht=Nv(Se);for(const ne of e.agents.values())ne.sessionId!==Se.sessionId||ne.kind==="root"||(Fe+=En(ne).total,et+=ne.usage.inputTokens,xt+=ne.usage.outputTokens,ht+=Nv(ne));ge.push({sessionId:Se.sessionId,label:Se.label||Se.cwdBasename||"session",state:Se.state,cost:Fe,inputTokens:et,outputTokens:xt,unpricedTokens:ht})}return ge.sort((Se,Fe)=>Fe.cost-Se.cost||Fe.inputTokens+Fe.outputTokens-(Se.inputTokens+Se.outputTokens)).slice(0,12)},[e,e.revision]),[E,C]=b.useState(L5);b.useEffect(()=>{D5(E)},[E]);const[R,I]=b.useState(q5);b.useEffect(()=>{F5(R)},[R]);const $=b.useRef([]),[F,O]=b.useState(0),M=b.useRef(()=>new Map);M.current=()=>i1(e.agents.values(),t);const L=b.useCallback(()=>M.current(),[]),{data:H,shown:B,stale:A,loading:Q,baseline:K}=K5(E,F,L),ee=H!=null,Z=Q&&A,D=b.useMemo(()=>{const ge=new Map;for(const Se of e.agents.values()){if(Se.kind!=="root"||!Se.sessionId)continue;const Fe=Se.label||Se.cwdBasename;Fe&&ge.set(Se.sessionId,Fe)}return ge},[e,e.revision]),Y=b.useMemo(()=>{const ge=new Map;for(const Se of e.agents.values())Se.kind!=="root"||!Se.sessionId||ge.set(Se.sessionId,Se.state);return ge},[e,e.revision]),P=b.useMemo(()=>ee?y2(H):[],[H,ee]),G=b.useMemo(()=>{if(!ee)return[];const ge=E5(H,D).slice(0,12),Se=new Map;for(const Fe of ge)Fe.label&&Se.set(Fe.label,(Se.get(Fe.label)??0)+1);return ge.map(Fe=>Fe.label&&(Se.get(Fe.label)??0)>1?{...Fe,label:`${Fe.label} ${Fe.sessionId.slice(0,4)}`}:Fe)},[H,ee,D]),de=b.useMemo(()=>w2(H),[H]),W=l1(B,E),U=A?" up-stale":"",J=b.useMemo(()=>ee?k5(K,i1(e.agents.values(),t)):Ev,[e,e.revision,K,ee,t]),V=T5(H,{...S,cost:_},J),ie=V.hasCost,pe=V.tokenSum,me=xl(V.cost),Ie=xl(V.inputTokens),Le=xl(V.outputTokens),ce=xl(V.cacheReadTokens),xe=xl(V.cacheCreateTokens),ye=j.filter(ge=>ge.cost.total>0||ge.inputTokens+ge.outputTokens>0),ze=N.filter(ge=>ge.cost>0||ge.inputTokens+ge.outputTokens>0),ke=ee?P.some(ge=>ge.cost<=0&&ge.tokens>0):ye.some(ge=>!ge.priced),je=c||p,Ye=u1(l==null?void 0:l.fetchedAt,y),it=u1(h==null?void 0:h.fetchedAt,y),Ne=()=>{d(),f(),O(ge=>ge+1)},He=n.claude&&n.codex?"Refresh Claude + Codex quota":n.codex?"Refresh Codex quota":"Refresh Claude quota";return i.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[i.jsxs("div",{className:"up-header",children:[i.jsx("h2",{children:"Usage"}),x&&i.jsx("span",{className:"up-rate",children:x}),i.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&i.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Ne,...dr(je),"aria-label":He,title:He,children:je?"…":"↻"}),i.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:a,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Claude quota",Ye&&!c&&i.jsx("span",{className:"up-section-age",title:B5(l==null?void 0:l.source),children:Ye})]}),l!=null&&l.ok?i.jsxs("div",{className:"up-quota-bars",children:[l.session5hPct!=null&&i.jsx(za,{label:"5-hour window",pct:l.session5hPct,reset:l.session5hReset,resetAt:l.session5hResetAt,windowSec:l.session5hWindowSec,nowSec:y}),l.week7dPct!=null&&i.jsx(za,{label:"7-day window",pct:l.week7dPct,reset:l.week7dReset,resetAt:l.week7dResetAt,windowSec:l.week7dWindowSec,nowSec:y}),l.weekSonnetPct!=null&&i.jsx(za,{label:"Sonnet (7d)",pct:l.weekSonnetPct,nowSec:y}),l.weekOpusPct!=null&&i.jsx(za,{label:"Opus (7d)",pct:l.weekOpusPct,nowSec:y})]}):(l==null?void 0:l.ok)===!1?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:l.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:H5(l.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),n.codex&&i.jsxs("section",{className:"up-section up-quota-section",children:[i.jsxs("h3",{className:"up-section-title",children:["Codex quota",(h==null?void 0:h.ok)&&h.planLabel&&i.jsx("span",{className:"up-plan-badge",children:h.planLabel}),it&&!p&&i.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:it})]}),h!=null&&h.ok?i.jsxs("div",{className:"up-quota-bars",children:[(Xe=h.windows)==null?void 0:Xe.map(ge=>i.jsx(za,{label:ge.label,pct:ge.pct,reset:ge.reset??void 0,resetAt:ge.resetAt??void 0,windowSec:ge.windowSec??void 0,limitReached:h.limitReached&&ge.pct>=100,nowSec:y},ge.id)),(he=h.extraWindows)==null?void 0:he.map(ge=>i.jsx(za,{label:ge.label,pct:ge.pct,reset:ge.reset??void 0,resetAt:ge.resetAt??void 0,windowSec:ge.windowSec??void 0,nowSec:y},ge.id)),h.creditLimit&&i.jsx(za,{label:`spend cap · $${Math.round(h.creditLimit.used)} of $${Math.round(h.creditLimit.limit)}`,pct:h.creditLimit.usedPct,reset:h.creditLimit.reset??void 0,resetAt:h.creditLimit.resetAt??void 0,limitReached:h.spendControlReached,nowSec:y}),h.creditsBalance&&!h.creditsUnlimited&&i.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",h.creditsBalance,h.overageReached&&" · overage limit reached"]}),h.creditsUnlimited&&i.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),h.resetCredits&&h.resetCredits.availableCount>0&&i.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Wt} only reports them`,children:[h.resetCredits.availableCount," rate-limit reset",h.resetCredits.availableCount!==1?"s":""," available",h.resetCredits.nextExpiryAt&&` · expires ${new Date(h.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),h.promo&&i.jsx("div",{className:"up-quota-sub",children:h.promo}),h.partial&&i.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(h==null?void 0:h.ok)===!1?i.jsxs("div",{className:"up-quota-na",children:[i.jsx("span",{children:"Quota unavailable."}),i.jsx("span",{className:"up-quota-hint",children:G5(h.reason)})]}):i.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(m==null?void 0:m.ok)&&m.window7d&&m.window7d.sessionCount>0&&i.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${m.window5h?`
75
+ last 5h: ${At(m.window5h.totalTokens)} tokens · ${m.window5h.sessionCount} session${m.window5h.sessionCount!==1?"s":""}`:""}`,children:[At(m.window7d.totalTokens)," tokens · ",m.window7d.sessionCount," session",m.window7d.sessionCount!==1?"s":""," (7d)"]})]}),ee&&i.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":Z||void 0,onKeyDown:ge=>{var et;const Se=$.current.indexOf(ge.target);if(Se<0)return;const Fe=_5(ge.key,Se);Fe!==null&&(ge.preventDefault(),(et=$.current[Fe])==null||et.focus())},children:Nd.map((ge,Se)=>i.jsx("button",{type:"button",ref:Fe=>{$.current[Se]=Fe},tabIndex:E===ge.key?0:-1,"aria-pressed":E===ge.key,"data-pending":E===ge.key&&Z?"":void 0,title:E===ge.key&&Z?`Reading ${ge.noun} from the transcripts on this machine…`:ge.hint,className:"uh-range-btn",onClick:()=>C(ge.key),children:ge.label},ge.key))}),ee&&i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Z?`Reading ${l1(E,E)}…`:""}),pe>0?i.jsxs(i.Fragment,{children:[ie&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`up-total${U}`,title:ee?void 0:s1,children:[i.jsx("span",{className:"up-total-value",children:tt(me)}),i.jsx("span",{className:"up-total-label",children:ee?W:h5})]}),V.showCostBar&&i.jsx(fx,{cost:_})]}),i.jsxs("div",{className:`up-tokens-row${U}`,title:ee?void 0:s1,children:[i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"in"}),At(Ie)]}),i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"out"}),At(Le)]}),V.cacheReadTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache r"}),At(ce)]}),V.cacheCreateTokens>0&&i.jsxs("span",{className:"up-tok",children:[i.jsx("span",{className:"up-k",children:"cache c"}),At(xe)]}),!ie&&i.jsx("span",{className:"up-tok up-scope",children:f5})]}),(ee?P.length:ye.length)>0&&i.jsxs("section",{className:`up-section${U}`,children:[i.jsx("h3",{className:"up-section-title",children:"By model"}),i.jsxs("table",{className:"up-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Model"}),i.jsx("th",{children:"Tokens"}),i.jsx("th",{children:"Cost"})]})}),i.jsx("tbody",{children:ee?P.map(ge=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:ge.model,children:Ks(ge.model)}),i.jsx("td",{className:"up-num",children:At(ge.tokens)}),ge.cost>0?i.jsx("td",{className:"up-num up-cost-val",children:tt(ge.cost)}):i.jsx("td",{className:"up-num up-unpriced",children:Vo})]},ge.model)):ye.map(ge=>i.jsxs("tr",{children:[i.jsx("td",{className:"up-model-name",title:ge.model===Pf?"no model reported yet":ge.model,children:ge.model===Pf?"unknown":Ks(ge.model)}),i.jsx("td",{className:"up-num",children:At(ge.inputTokens+ge.outputTokens)}),ge.priced?i.jsx("td",{className:"up-num up-cost-val",children:tt(ge.cost.total)}):i.jsx("td",{className:"up-num up-unpriced",children:Vo})]},ge.model))})]})]}),ee&&G.length===0&&de.tokens>0&&i.jsxs("section",{className:"up-section",children:[i.jsx("h3",{className:"up-section-title",children:"By session"}),i.jsxs("div",{className:"up-hint",children:["No session is dated ",W," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(ee?G.length:ze.length)>0&&(()=>{const ge=ee?G.length:ze.length;return i.jsxs("section",{className:`up-section${U}`,children:[i.jsx("h3",{className:"up-section-title",children:i.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":R,"aria-controls":"up-sessions",title:R?"Hide the per-session breakdown":`Show the per-session breakdown — ${ge} session${ge===1?"":"s"}`,onClick:()=>I(Se=>!Se),children:["By session",ee&&i.jsxs("span",{className:"up-section-age",title:`Sessions with activity ${W}, each showing what that session has cost since it started.
76
+ A session that began earlier brings its whole total with it, so these rows can add up to more than the figure above.`,children:["active ",W]}),i.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),i.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!R,children:[ee&&G.map(Se=>{const Fe=Y.get(Se.sessionId);return i.jsxs("div",{className:"up-session-row",children:[Fe?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`sl-dot state-${Fe}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:id(Fe)})]}):i.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),i.jsx("span",{className:`up-session-label${Se.label?"":" up-session-id"}`,title:Se.label?`${Se.label}
77
+ ${Se.sessionId}`:Se.sessionId,children:Se.label??Se.sessionId.slice(0,8)}),i.jsx("span",{className:"up-session-tokens",children:At(Se.tokens)}),Se.cost>0?i.jsx("span",{className:"up-session-cost",title:Se.models.join(", ")||void 0,children:tt(Se.cost)}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Vo})]},Se.sessionId)}),!ee&&ze.map(Se=>i.jsxs("div",{className:"up-session-row",children:[i.jsx("span",{className:`sl-dot state-${Se.state}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:id(Se.state)}),i.jsx("span",{className:"up-session-label",children:Se.label}),i.jsx("span",{className:"up-session-tokens",children:At(Se.inputTokens+Se.outputTokens)}),Se.cost>0?i.jsxs("span",{className:"up-session-cost",title:Se.unpricedTokens>0?`${At(Se.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[tt(Se.cost),Se.unpricedTokens>0?"+":""]}):i.jsx("span",{className:"up-session-cost up-unpriced",children:Vo})]},Se.sessionId))]})]})})(),ke&&i.jsxs("div",{className:"up-hint",children:["“",Vo,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):i.jsx("div",{className:"up-empty",children:ee?i.jsxs(i.Fragment,{children:["No usage ",W,".",i.jsx("br",{}),"Try a longer period."]}):i.jsxs(i.Fragment,{children:["No usage data yet.",i.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}const Yt={l:30,r:6,t:6,b:2},Us={l:0,r:0,t:2,b:1},jd=104,Q5=64;function ur(e,t=100,n=jd,s=Yt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function N2(e,t,n,s=100,a=jd,l=Yt){if(!e.length)return"";const c=e[e.length-1].t-e[0].t,d=f=>{const m=t-l.l-l.r;return l.l+(c>0?m*(f-e[0].t)/c:m/2)};let h="",p=null;for(const f of e){const m=p&&f.t-p.t<=n*2?"L":"M";h+=`${m}${d(f.t).toFixed(1)} ${ur(f.v,s,a,l).toFixed(1)}`,p=f}return h}function S2(e,t,n,s=100,a=jd,l=Yt){if(e.length<2)return"";const c=a-l.b,d=e[e.length-1].t-e[0].t,h=t-l.l-l.r,p=v=>l.l+(d>0?h*(v-e[0].t)/d:h/2);let f="",m=[];const y=()=>{if(m.length>=2){let v=`M${p(m[0].t).toFixed(1)} ${c}`;for(const j of m)v+=`L${p(j.t).toFixed(1)} ${ur(j.v,s,a,l).toFixed(1)}`;f+=`${v}L${p(m[m.length-1].t).toFixed(1)} ${c}Z`}m=[]};for(const v of e)m.length&&v.t-m[m.length-1].t>n*2&&y(),m.push(v);return y(),f}function Z5(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 j2(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function J5(e,t,n=s=>Al(s)){const s=e.filter(c=>c.v>0);if(!e.length)return null;if(!s.length)return"never held back";const a=s.length*(t/6e4),l=s[s.length-1];return`held back for ${a===1?"1 minute":`${a} minutes`}, last at ${n(l.t)}`}function Al(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function px(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 eD({group:e,title:t,onClose:n}){const s=Ht(n),[a,l]=b.useState(null);b.useEffect(()=>{let p=!0;const f=async()=>{try{const y=await fetch(`/api/system/history?group=${e}`);if(!y.ok)return;const v=await y.json();p&&(v!=null&&v.ok)&&l(v)}catch{}};f();const m=window.setInterval(f,2e4);return()=>{p=!1,window.clearInterval(m)}},[e]);const c=(a==null?void 0:a.series)??[],[d,h]=b.useMemo(()=>{let p=1/0,f=0;for(const m of c)m.points.length&&(p=Math.min(p,m.points[0].t),f=Math.max(f,m.points[m.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(a==null?void 0:a.sinceMs)??0):(a==null?void 0:a.sinceMs)??0,f]},[c,a==null?void 0:a.sinceMs]);return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:s,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),a&&d>0&&i.jsxs("span",{className:"hist-since",children:["since ",Al(d)," · ",px(d,h||Date.now())]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsx("div",{className:"hist-body",children:a==null?i.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?i.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>i.jsx(tD,{series:p,stepMs:a.stepMs},p.label))})]})}),document.body)}function tD({series:e,stepMs:t}){const n=b.useRef(null),[s,a]=b.useState(560),[l,c]=b.useState(null);b.useEffect(()=>{const $=n.current;if(!$||typeof ResizeObserver>"u")return;const F=new ResizeObserver(([O])=>a(Math.max(160,O.contentRect.width)));return F.observe($),()=>F.disconnect()},[]);const{points:d,unit:h,warnAt:p,critAt:f,label:m,top:y,restsAtZero:v}=e,j=v?Q5:jd,{now:_,peak:S}=Z5(d),x=h==="C"?"°C":h,N=m==="Throttling"?J5(d,t):null,E=l!=null?d[l]:null,C=d.length>1?d[d.length-1].t-d[0].t:0,R=$=>{const F=s-Yt.l-Yt.r;return Yt.l+(C>0?F*($-d[0].t)/C:F/2)},I=$=>{if(d.length<2)return;const F=$.currentTarget.getBoundingClientRect(),O=($.clientX-F.left-Yt.l)/Math.max(1,F.width-Yt.l-Yt.r),M=d[0].t+C*Math.max(0,Math.min(1,O));let L=0;for(let H=1;H<d.length;H++)Math.abs(d[H].t-M)<Math.abs(d[L].t-M)&&(L=H);c(L)};return i.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[i.jsxs("div",{className:"hist-head",children:[i.jsx("span",{className:"hist-label",children:m}),i.jsxs("span",{className:"hist-stats",children:[_!=null&&i.jsxs(i.Fragment,{children:[i.jsx("b",{children:_}),i.jsxs("span",{children:[x," now"]})]}),S!=null&&i.jsxs(i.Fragment,{children:[i.jsx("b",{className:j2(S,p,f),children:S}),i.jsxs("span",{children:[x," peak"]})]})]})]}),i.jsx("div",{className:"hist-plot",ref:n,children:i.jsxs("svg",{className:"hist-chart",width:"100%",height:j,viewBox:`0 0 ${s} ${j}`,preserveAspectRatio:"none",role:"img","aria-label":_==null?`${m}: nothing measured yet`:`${m}: ${_}${x} now, peak ${S}${x}, over ${px(d[0].t,d[d.length-1].t)}`,onPointerMove:I,onPointerLeave:()=>c(null),children:[[["warn",p],["hot",f]].map(([$,F])=>F==null||F>y?null:i.jsxs("g",{children:[i.jsx("line",{className:`hist-rule ${$}`,x1:Yt.l,x2:s-Yt.r,y1:ur(F,y,j),y2:ur(F,y,j)}),i.jsx("text",{className:`hist-rule-tag ${$}`,x:2,y:ur(F,y,j)+3,children:F})]},$)),i.jsx("line",{className:"hist-floor",x1:Yt.l,x2:s-Yt.r,y1:j-Yt.b,y2:j-Yt.b}),i.jsx("path",{className:"hist-area",d:S2(d,s,t,y,j)}),i.jsx("path",{className:"hist-line",d:N2(d,s,t,y,j)}),d.length===1&&i.jsx("circle",{className:"hist-dot",cx:R(d[0].t),cy:ur(d[0].v,y,j),r:3}),E&&i.jsxs("g",{children:[i.jsx("line",{className:"hist-cross",x1:R(E.t),x2:R(E.t),y1:Yt.t,y2:j-Yt.b}),i.jsx("circle",{className:"hist-dot",cx:R(E.t),cy:ur(E.v,y,j),r:3})]})]})}),i.jsx("div",{className:"hist-axis",children:E?i.jsxs("span",{className:"hist-at",children:[Al(E.t)," — ",i.jsx("b",{children:E.v}),x]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:d.length?Al(d[0].t):""}),i.jsx("span",{children:d.length?Al(d[d.length-1].t):""})]})}),N&&i.jsx("div",{className:"hist-note",children:N})]})}const nD="thermal:Throttling";function rD(e){var n,s,a,l;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 c of((a=e.thermal)==null?void 0:a.celsius)??[])t[`thermal:${c.label}`]=c.celsius;return(l=e.thermal)!=null&&l.throttle&&(t[nD]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function Gu(e,t){return t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Au(e,t){return Number.isInteger(e)?t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`:Gu(e,t)}const h1=["cores","memory","load","thermal"],Ua=116,Ar=24,sD=60,aD=6e4;function oD(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function iD(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function lD(e,t=sD){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function cD({sys:e}){const[t,n]=b.useState({});b.useEffect(()=>{let c=!0;const d=async()=>{const p=await Promise.all(h1.map(async f=>{try{const m=await fetch(`/api/system/history?group=${f}`);return m.ok?[f,await m.json()]:[f,null]}catch{return[f,null]}}));c&&n(f=>{const m={...f};for(const[y,v]of p)v!=null&&v.ok&&(m[y]=v);return m})};d();const h=setInterval(()=>void d(),aD);return()=>{c=!1,clearInterval(h)}},[]);const s=b.useMemo(()=>rD(e),[e]),a=b.useMemo(()=>h1.flatMap(c=>{const d=t[c];return d?d.series.filter(oD).map(h=>({series:lD(h),stepMs:d.stepMs})):[]}),[t]),l=b.useMemo(()=>{let c=1/0,d=-1/0;for(const{series:h}of a){const p=h.points;p.length&&(c=Math.min(c,p[0].t),d=Math.max(d,p[p.length-1].t))}return Number.isFinite(c)?px(c,d):"less than a minute"},[a]);return Object.keys(s).length?i.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${l}`,children:a.map(({series:c,stepMs:d})=>i.jsx(uD,{series:c,stepMs:d,now:s[c.key],span:l},c.key))}):null}function uD({series:e,stepMs:t,now:n,span:s}){var v;const{points:a,top:l,unit:c,warnAt:d,critAt:h}=e,p=iD(e),f=n??((v=a[a.length-1])==null?void 0:v.v),m=f==null?"":j2(f,d,h),y=Math.max(...a.map(j=>j.v));return i.jsxs("div",{className:`pl-cell${m?` ${m}`:""}`,title:[`${p} · peak ${Gu(y,c)} over the last ${s}`,d!=null?`over ${Au(d,c)} is uncomfortable`:"",h!=null?`over ${Au(h,c)} the machine acts`:""].filter(Boolean).join(" · "),children:[i.jsxs("div",{className:"pl-cell-head",children:[i.jsx("span",{className:"pl-cell-label",children:p}),i.jsx("span",{className:"pl-cell-now",children:f==null?"—":Gu(f,c)})]}),i.jsxs("svg",{className:"pl-spark",width:Ua,height:Ar,viewBox:`0 0 ${Ua} ${Ar}`,preserveAspectRatio:"none","aria-hidden":!0,children:[i.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ua,y1:Ar-Us.b,y2:Ar-Us.b}),i.jsx("path",{className:"pl-spark-area",d:S2(a,Ua,t,l,Ar,Us)}),d!=null&&i.jsx("line",{className:"pl-rule warn",x1:0,x2:Ua,y1:ur(d,l,Ar,Us),y2:ur(d,l,Ar,Us)}),h!=null&&i.jsx("line",{className:"pl-rule hot",x1:0,x2:Ua,y1:ur(h,l,Ar,Us),y2:ur(h,l,Ar,Us)}),i.jsx("path",{className:"pl-spark-line",d:N2(a,Ua,t,l,Ar,Us)})]}),i.jsxs("span",{className:"vis-hidden",children:["peak ",Gu(y,c)," over the last ",s,d!=null&&`, uncomfortable over ${Au(d,c)}`,h!=null&&`, the machine acts over ${Au(h,c)}`]})]})}const dD={key:"cpu",dir:"desc"};function hD(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function fD(e,t){const n=t.dir==="asc"?1:-1,s=l=>t.key==="cpu"?l.cpu:t.key==="mem"?l.mem:t.key==="rss"?l.rssBytes:t.key==="threads"?l.threads:l.uptimeSec,a=(l,c)=>{if(t.key==="name")return n*l.name.localeCompare(c.name,void 0,{sensitivity:"base"});if(t.key==="user"){const p=l.user??"",f=c.user??"";return!p||!f?p===f?0:p?-1:1:n*p.localeCompare(f,void 0,{sensitivity:"base"})}const d=s(l),h=s(c);return d==null||h==null?d==null?h==null?0:1:-1:n*(d-h)};return[...e].sort((l,c)=>a(l,c)||(c.cpu??-1)-(l.cpu??-1)||c.mem-l.mem||l.pid-c.pid)}function pD(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}const mD=4e3;function gD(){const[e,t]=b.useState(null);return b.useEffect(()=>{let n=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes?detail=1");if(!l.ok)return;const c=await l.json();n&&(c!=null&&c.ok)&&t({procs:c.procs??[],total:c.total??0})}catch{}};s();const a=window.setInterval(s,mD);return()=>{n=!1,window.clearInterval(a)}},[]),e}function yD(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB"];let n=e/1024,s=0;for(;n>=1024&&s<t.length-1;)n/=1024,s++;return`${n>=100?n.toFixed(0):n.toFixed(1)} ${t[s]}`}function wD(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 vD({sys:e,onClose:t}){const n=Ht(t),[s,a]=b.useState(dD),l=gD(),c=l?fD(l.procs,s):null;return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal pl-modal",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[i.jsxs("div",{className:"modal-head",children:[i.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),l&&i.jsxs("span",{className:"pl-count",children:[c.length," of ",l.total," running"]}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),i.jsxs("div",{className:"pl-split",children:[i.jsx("div",{className:"pl-body",children:c==null?i.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):c.length===0?i.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):i.jsxs("table",{className:"sd-procs pl-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx(Wo,{col:"cpu",label:"cpu",sort:s,onSort:a}),i.jsx(Wo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:s,onSort:a}),i.jsx(Wo,{col:"threads",label:"threads",sort:s,onSort:a}),i.jsx(Wo,{col:"uptime",label:"up",sort:s,onSort:a}),i.jsx(Wo,{col:"user",label:"user",sort:s,onSort:a}),i.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),i.jsx(Wo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:s,onSort:a})]})}),i.jsx("tbody",{children:c.map(d=>i.jsxs("tr",{children:[i.jsx("td",{className:"sd-num",children:d.cpu==null?"—":d.cpu.toFixed(0)}),i.jsx("td",{className:"sd-num sd-dim",title:`${d.mem.toFixed(1)}% of installed memory`,children:yD(d.rssBytes)}),i.jsx("td",{className:"sd-num sd-dim",children:d.threads??"—"}),i.jsx("td",{className:"sd-num sd-dim",children:wD(d.uptimeSec)}),i.jsx("td",{className:"sd-dim pl-user",children:d.user??"—"}),i.jsx("td",{className:"sd-num sd-dim pl-pid",children:d.pid}),i.jsxs("td",{className:"pl-name",children:[d.name,d.cmd&&i.jsxs("span",{className:"pl-cmd",title:d.cmd,children:[" ",d.cmd]})]})]},d.pid))})]})}),i.jsx(cD,{sys:e})]})]})}),document.body)}function Wo({col:e,label:t,note:n,sort:s,onSort:a}){const l=pD(s,e);return i.jsx("th",{scope:"col","aria-sort":l,children:i.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
78
78
 
79
- ${n}`:`Sort by ${t}`,onClick:()=>a(hD(s,e)),children:[t,i.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:l==="none"?"":l==="ascending"?"↑":"↓"})]})})}const xD=3e3;function bD(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function kD(e,t,n=Date.now()){const s=Math.max(0,Math.min(100,100-e));return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${_D(t.lastMs,n)}`:"running at full speed, and never held back"}}function _D(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 xl(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function ND(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 SD(){const[e,t]=b.useState(null),n=b.useRef(null);return b.useEffect(()=>{let s=!0;const a=async()=>{if(document.visibilityState!=="hidden")try{const h=await fetch("/api/system");if(!h.ok)return;const p=await h.json();s&&(p!=null&&p.ok)&&t(p)}catch{}},l=()=>{n.current==null&&(a(),n.current=window.setInterval(a,xD))},c=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},d=()=>{if(document.visibilityState==="hidden"){c();return}l(),a()};return l(),document.addEventListener("visibilitychange",d),()=>{s=!1,c(),document.removeEventListener("visibilitychange",d)}},[]),e}function f1({usageOpen:e,leaving:t,sub:n,onClose:s,children:a}){return i.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-label":"Machine detail",children:[i.jsxs("div",{className:"sd-head",children:[i.jsx("span",{className:"sd-title",children:"This machine"}),n&&i.jsx("span",{className:"sd-sub",children:n}),i.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),a]})}function jD({usageOpen:e,leaving:t,onClose:n}){const s=SD();if(!s||s.cpu==null||!s.memory)return i.jsx(f1,{usageOpen:e,leaving:t,onClose:n,children:i.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:a,swap:l,perCore:c,loadavg:d,cores:h,uptimeSec:p,platform:f,thermal:m}=s,y=a?a.total-a.available:0,v=f==="win32"?"Commit":"Swap",j=l&&l.total>0?l.used/l.total*100:0;return i.jsxs(f1,{usageOpen:e,leaving:t,sub:`up ${ND(p)} · ${h} cores`,onClose:n,children:[c&&c.length>0&&i.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:i.jsx(Gu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:i.jsx("div",{className:"sd-cores",style:{"--n":c.length},children:c.map((_,S)=>i.jsx("span",{className:"sd-core",title:`core ${S+1}: ${_}%`,children:i.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,_)/100})`}})},S))})})}),i.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:i.jsxs(Gu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&i.jsx(id,{label:"Physical",value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:xl(y)})," of ",xl(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${xl(a.available)} available`}),l&&l.total>0&&i.jsx(id,{label:v,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:xl(l.used)})," of ",xl(l.total)]}),pct:j,tone:j>=90?"warn":"calm",note:j>=50?"paging to disk":void 0})]})}),d&&i.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:i.jsxs(Gu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[i.jsx("div",{className:"sd-load",children:d.map((_,S)=>i.jsxs("span",{className:`sd-load-item${_>h?" over":""}`,children:[i.jsx("b",{children:_.toFixed(2)}),i.jsx("span",{children:["1m","5m","15m"][S]})]},S))}),i.jsx("div",{className:"sd-note",children:d[0]>h?`${(d[0]/h).toFixed(1)}× more work queued than cores to run it`:`within ${h} cores`})]})}),i.jsx(ED,{thermal:m}),i.jsx(CD,{sys:s})]})}function Gu({group:e,title:t,action:n,label:s,children:a}){const[l,c]=b.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"sd-open",onClick:()=>c(!0),title:n,"aria-label":n,children:[i.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",i.jsx("i",{className:"sd-row-more",children:"›"})]}),a]}),l&&i.jsx(eD,{group:e,title:t,onClose:()=>c(!1)})]})}function ED({thermal:e}){if(!e)return null;const t=e.throttle?kD(e.throttle.speedLimit,e.heldBack):null;return i.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:i.jsxs(Gu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>i.jsx(id,{label:n.label,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:bD(n.celsius,n.warnAt,n.critAt)},n.label)),t&&i.jsx(id,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function CD({sys:e}){const[t,n]=b.useState(!1);return i.jsxs("div",{className:"sd-section",children:[i.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Show every process the deck is watching",children:i.jsxs("span",{className:"sd-door-plate",children:[i.jsxs("span",{className:"sd-door-name",children:["Busiest processes",i.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),i.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&i.jsx(vD,{sys:e,onClose:()=>n(!1)})]})}function id({label:e,value:t,pct:n,tone:s="calm",note:a}){return i.jsxs("div",{className:"sd-row",children:[i.jsxs("div",{className:"sd-row-head",children:[i.jsx("span",{className:"sd-row-label",children:e}),i.jsx("span",{className:"sd-row-val",children:t})]}),i.jsx("span",{className:"sd-track",children:i.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),a&&i.jsx("div",{className:"sd-note",children:a})]})}const p1=18,TD=1100,Wo=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},AD=Array.from({length:p1},(e,t)=>{const n=-72+144*t/(p1-1)+(Wo(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+Wo(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+Wo(t,3)*260),delay:Math.round(Wo(t,4)*90),dur:760+Math.round(Wo(t,5)*260),scale:.8+Wo(t,6)*.45,hue:t%4,round:t%3===0}});function m1({anchor:e}){var a;const[t,n]=b.useState(null),s=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return b.useEffect(()=>{if(s)return;const l=e.current;if(!l)return;const c=l.getBoundingClientRect();n({x:c.left+c.width/2,y:c.top+c.height/2});const d=window.setTimeout(()=>n(null),TD);return()=>window.clearTimeout(d)},[e,s]),s||!t?null:Yv.createPortal(i.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:AD.map((l,c)=>i.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},c))}),document.body)}const E2=new Set(["awaiting_url","awaiting_code","registering"]);function RD(e){return e!=null&&E2.has(e)}function C2(e){return e!=null&&e!=="done"&&!E2.has(e)}const MD="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",ID="the sign-in did not complete";function $D({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?MD:ID)}}const OD="done";function PD(){let e=!1;return{shouldAnnounce(t){return t!==OD?(e=!1,!1):e?!1:(e=!0,!0)}}}function mx(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const LD={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 ${Wt}`,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"},DD={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},qD=`claude-swap could not read the login keychain — start ${Wt} from a Terminal window rather than a background service`;function Av(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(oi(e)))return qD;const n=mx(DD,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function oi(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const FD={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"},BD="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 zD(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const UD="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",WD="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",HD=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),GD=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,VD=/[\\/]_npx[\\/]/i,YD=`the copy of ccusage ${Wt} installed for itself`;function KD(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function XD(e,t){const n=QD(e,t),s=KD(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 ${bl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${bl(n)}`;case"managed":return`${YD} failed to run: ${bl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${bl(n)}`:`the ccusage this deck found on your PATH failed to run: ${bl(n)}`;default:return n}}const bl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function QD(e,t){const n=oi(e);if(HD(n)){if(VD.test(n))return WD;if(GD.test(n))return UD}if(zD(n))return BD;const s=mx(FD,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Ko(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&C2(e.state))return e.error;const n=mx(LD,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function ZD(e,t,n){if(n<=0||ux(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function T2(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 JD(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}`,l=[];return n.alias&&s&&l.push(s),s&&(t.get(s.toLowerCase())??0)>1&&l.push(n.org||`slot ${n.num}`),{num:n.num,label:a,sub:l.length?l.join(" · "):null}})}function e6(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 t6(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 n6(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],a=n("imported");a&&s.push(`${a} of ${t} imported`);const l=n("healed");l&&s.push(`${l} had a dead token replaced`);const c=n("updated");c&&s.push(`${c} updated`);const d=n("present");d&&s.push(`${d} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const r6=1500,Au=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],g1="aa-panel",y1=e=>`aa-tab-${e}`;async function kl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Rv=fe.forwardRef((e,t)=>i.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[i.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),i.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Rv.displayName="SuccessMark";function s6({onClose:e,onChanged:t}){const[n,s]=b.useState("login"),[a,l]=b.useState(null),[c,d]=b.useState(""),[h,p]=b.useState(""),[f,m]=b.useState(!1),[y,v]=b.useState(null),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(null),C=b.useRef(""),R=b.useRef(!1),I=b.useRef(!1),$=b.useRef(null),F=b.useRef(null),O=b.useRef(null),M=b.useRef(null),L=b.useRef([]),H=b.useRef(!1),B=b.useCallback(()=>{R.current&&kl({action:"login-cancel"}).catch(()=>{}),e()},[e]),A=Ht(B,{focusRef:O}),Q=b.useCallback(async()=>{if(!hr(I.current))return;I.current=!0,m(!0),v(null),R.current=!0;const U=await kl({action:"login"}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Ko(U,"could not start the sign-in"));return}l(U)},[]);b.useEffect(()=>{if(!RD(a==null?void 0:a.state))return;const U=window.setInterval(async()=>{try{const J=await fetch("/api/claude-accounts/login");J.ok&&l(await J.json())}catch{}},r6);return()=>window.clearInterval(U)},[a]);const K=b.useRef(t);K.current=t;const ee=b.useState(PD)[0];b.useEffect(()=>{var U;(a==null?void 0:a.state)==="awaiting_code"&&((U=$.current)==null||U.focus()),ee.shouldAnnounce(a==null?void 0:a.state)&&K.current()},[a==null?void 0:a.state,ee]),b.useEffect(()=>{var U;n==="paste"&&!H.current&&((U=F.current)==null||U.focus()),H.current=!1},[n]);const Z=b.useCallback(U=>{var V;const J=ZD(U,Au.findIndex(ie=>ie.id===n),Au.length);J.kind!=="pass"&&(U.preventDefault(),H.current=!0,s(Au[J.index].id),(V=L.current[J.index])==null||V.focus())},[n]),D=b.useCallback(async()=>{var J;if(!hr(I.current))return;I.current=!0,m(!0),v(null);const U=await kl({action:"login-code",code:c}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Ko(U,"the code was not accepted")),U!=null&&U.state&&l(U),(J=$.current)==null||J.select();return}d(""),l(U)},[c,a]),Y=b.useCallback(async()=>{if(!hr(I.current))return;I.current=!0,m(!0),v(null);const U=await kl({action:"import",blob:h}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Ko(U,"the import failed"));return}C.current=h,p(""),E(null),_(U.results??[]),t()},[h,t]),P=b.useCallback(async U=>{const J=`${U.email}|${U.org??""}`;if(!hr(I.current)||!C.current)return;I.current=!0,m(!0),x(J),E(null);const V=await kl({action:"import",blob:C.current,force:!0,only:{email:U.email,org:U.org??""}}).catch(()=>null);if(I.current=!1,m(!1),x(null),!(V!=null&&V.ok)){E({key:J,text:Ko(V,"that account could not be updated")});return}const ie=(V.results??[])[0];ie&&_(pe=>pe&&pe.map(me=>`${me.email}|${me.org??""}`===J?ie:me)),t()},[t]),G=(a==null?void 0:a.state)==="done"?a.account:null,de=C2(a==null?void 0:a.state)||!!(y&&R.current&&!f),W=$D({state:a==null?void 0:a.state,serverError:a==null?void 0:a.error,localError:y});return i.jsx("div",{className:"modal-backdrop",onClick:B,role:"presentation",children:i.jsxs("div",{ref:A,className:"modal aa-modal",onClick:U=>U.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Z,children:Au.map((U,J)=>i.jsx("button",{type:"button",role:"tab",id:y1(U.id),ref:V=>{L.current[J]=V},"aria-selected":n===U.id,"aria-controls":g1,tabIndex:n===U.id?0:-1,className:`aa-tab${n===U.id?" on":""}`,onClick:()=>{H.current=!1,s(U.id)},children:U.label},U.id))})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:B,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body aa-body",id:g1,role:"tabpanel","aria-labelledby":y1(n),children:n==="login"?G?i.jsxs("div",{className:"aa-done",children:[i.jsx(Rv,{ref:M}),i.jsx(m1,{anchor:M}),i.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),i.jsxs("p",{className:"aa-note",children:[i.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),i.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(a==null?void 0:a.state)==="awaiting_code"||(a==null?void 0:a.state)==="registering"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"1 · Approve in the browser"}),i.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),i.jsx("a",{className:"aa-link",href:a.url??"#",target:"_blank",rel:"noreferrer noopener",children:a.url})]}),i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),i.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:$,type:"text",value:c,onChange:U=>d(U.target.value),onKeyDown:U=>{U.key==="Enter"&&c.trim()&&!f&&D()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:a.state==="registering"}),i.jsx("button",{type:"button",className:"btn primary",...dr(f,!c.trim()||a.state==="registering"),onClick:D,children:a.state==="registering"?"registering…":"Continue"})]}),(y||a.error)&&i.jsx("p",{className:"aa-err",children:y??a.error}),i.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):de?i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:W.title}),i.jsx("p",{className:"aa-err",children:W.message}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{R.current=!1,l(null),v(null),Q()},children:"Try again"})]}):f||R.current?i.jsx("div",{className:"aa-step",children:i.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):i.jsxs("div",{className:"aa-step aa-primer",children:[i.jsx("h4",{children:"Sign in to Anthropic"}),i.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),i.jsx("div",{className:"aa-actions",children:i.jsx("button",{type:"button",ref:O,className:"btn primary",onClick:Q,children:"Open the sign-in page"})})]}):j?(()=>{const U=j.filter(J=>J.state==="imported").length;return i.jsxs("div",{className:"aa-done",children:[i.jsx(Rv,{ref:M}),U>0&&i.jsx(m1,{anchor:M}),i.jsx("h4",{children:n6(j)}),j.length>0&&i.jsx("ul",{className:"aa-results",children:j.map(J=>{const V=`${J.email}|${J.org??""}`;return i.jsxs("li",{className:`aa-result ${J.state}`,children:[i.jsx("span",{className:"aa-result-who",children:J.email||(J.num?`slot ${J.num}`:"an account")}),i.jsx("span",{className:"aa-result-what",children:t6(J.state)}),J.state==="present"&&i.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":S===V,title:`Overwrite the stored login for ${J.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>P(J),children:S===V?"updating…":"update anyway"}),(N==null?void 0:N.key)===V&&i.jsx("span",{className:"aa-result-err",children:N.text})]},V)})}),i.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",i.jsx("strong",{children:" update anyway"}),"."]}),i.jsxs("div",{className:"aa-actions",children:[i.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{C.current="",E(null),_(null)},children:"Import another"})]})]})})():i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"Paste an account shared from another deck"}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:F,type:"text",value:h,onChange:U=>p(U.target.value),onKeyDown:U=>{U.key==="Enter"&&h.trim()&&!f&&Y()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),i.jsx("button",{type:"button",className:"btn primary",...dr(f,!h.trim()),onClick:Y,children:f?"importing…":"Import"})]}),y&&i.jsx("p",{className:"aa-err",children:y}),i.jsxs("p",{className:"aa-note",children:["Use ",i.jsx("strong",{children:"share"})," on one account in the other deck, or ",i.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})})}async function a6(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const o6=1800;function i6({accounts:e,onClose:t,copyText:n}){const[s,a]=b.useState([]),[l,c]=b.useState(null),[d,h]=b.useState(!1),[p,f]=b.useState(null),[m,y]=b.useState(!1),[v,j]=b.useState(()=>Math.floor(Date.now()/1e3)),_=b.useRef(null),S=b.useRef(!1),x=Ht(t,{focusRef:_});b.useEffect(()=>{if(!l)return;j(Math.floor(Date.now()/1e3));const M=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(M)},[l]);const N=JD(e),E=e.filter(M=>!s.includes(M.num)).map(M=>M.num),C=E.length===e.length,R=M=>a(L=>L.includes(M)?L.filter(H=>H!==M):[...L,M]),I=b.useCallback(async()=>{if(!hr(S.current)||!E.length)return;S.current=!0,h(!0),f(null),y(!1);const M=await a6({action:"share",accounts:E}).catch(()=>null);if(S.current=!1,h(!1),!(M!=null&&M.ok)){f(Ko(M,"the share could not be made"));return}c({blob:M.blob,expiresAt:M.expiresAt,shared:M.shared??[],failed:M.failed??[]})},[e,E]),$=l?T2(l.expiresAt,v):null,F=($==null?void 0:$.tone)==="gone",O=(l==null?void 0:l.shared.length)??0;return i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:x,className:"modal sa-modal",onClick:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("h3",{children:"Share accounts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body sa-body",children:l?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:F?"This share has expired":O===1?"1 account, ready to paste":`${O} accounts, ready to paste`}),i.jsx("code",{className:`ap-share-blob${F?" sa-dead":""}`,children:l.blob}),i.jsxs("div",{className:"ap-share-foot",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",ref:_,onClick:async()=>{if(F){c(null),I();return}await n(l.blob)&&(y(!0),window.setTimeout(()=>y(!1),o6))},children:F?"make a new share":m?"copied":`copy ${O===1?"the share":"all "+O}`}),i.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[i.jsx("span",{className:"ap-share-warn",children:O===1?"this is the password":`this is ${O} passwords`})," · ",i.jsx("span",{className:`ap-share-expiry ${$==null?void 0:$.tone}`,children:$==null?void 0:$.text})]})]}),l.failed.length>0&&i.jsxs("div",{className:"sa-failed",role:"alert",children:[i.jsx("p",{className:"sa-failed-head",children:l.failed.length===1?"One account is not in this bundle:":`${l.failed.length} accounts are not in this bundle:`}),i.jsx("ul",{className:"sa-list",children:l.failed.map(M=>{var H;const L=!!(M.email&&((H=M.detail)!=null&&H.includes(M.email)));return i.jsxs("li",{children:[!L&&i.jsx("span",{className:"sa-who",children:M.email||`account ${M.num}`}),i.jsx("span",{className:"sa-why",children:M.detail||"could not be exported"})]},`${M.num}-${M.email}`)})})]}),i.jsx("p",{className:"sa-note",children:F?i.jsx(i.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):i.jsxs(i.Fragment,{children:["Paste it into the other deck with ",i.jsx("strong",{children:"+"})," → ",i.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>{c(null),y(!1)},children:"Pick again"}),i.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:"Nothing to share"}),i.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",i.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),i.jsx("div",{className:"sa-actions",children:i.jsx("button",{type:"button",className:"btn primary",ref:_,onClick:t,children:"Close"})})]}):i.jsxs("div",{className:"sa-step",children:[i.jsxs("h4",{children:["Which accounts go to the other ",Wt,"?"]}),i.jsx("p",{className:`sa-count${E.length?"":" empty"}`,children:e6(E.length)}),i.jsx("ul",{className:"sa-list sa-pick",children:N.map(M=>i.jsx("li",{children:i.jsxs("label",{className:"sa-row",children:[i.jsx("input",{type:"checkbox",checked:E.includes(M.num),onChange:()=>R(M.num)}),i.jsx("span",{className:"sa-who",children:M.label}),M.sub&&i.jsx("span",{className:"sa-sub",children:M.sub})]})},M.num))}),p&&i.jsx("p",{className:"aa-err",children:p}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>a(C?e.map(M=>M.num):[]),children:C?"Clear all":"Select all"}),i.jsx("button",{type:"button",className:"btn primary",ref:_,...dr(d,!E.length),onClick:I,children:d?"making the share…":E.length===0?"Share":E.length===1?"Share 1 account":`Share ${E.length} accounts`})]})]})})]})})}function l6(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((a,l)=>a-l).map(a=>{const l=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:l,label:l==="here"?`slot ${a}`:`slot ${a} · ${l}`}})}function c6(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}}function u6(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function d6(e,t,n){var a;const s=((a=e.find(l=>l.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 h6(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 w1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function v1(e){const t=e.filter(d=>!w1(d)),n=e.filter(d=>w1(d)),s=t.length?t:n,a=t.length?n:[],l=s.reduce((d,h)=>d&&d.pct>=h.pct?d:h,null);let c=null;for(const d of a)l&&d.pct<=l.pct||(!c||d.pct>c.pct)&&(c=d);return{shown:s,rest:a,fuller:c,peak:c??l}}function f6(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function p6(e,t,n,s){const a=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,l=n===1?"the other window":`the other ${n} windows`;return`${a} ${s?"Hide":"Show"} ${l}.`}const m6="\0";function gx(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${m6}${n}`}function g6(e,t){const n=gx(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function y6(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(gx)),s=e.filter(a=>n.has(a));return s.length===e.length?e:s}const w6=64;function v6(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const x6=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function x1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function b6(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=oi(t.body);return{text:Av(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function b1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}function A2({title:e,steps:t,finish:n,aside:s,onClose:a}){const l=b.useRef(null),c=Ht(a,{focusRef:l}),[d,h]=b.useState(0),p=d===t.length-1,f=t[d],m=j=>h(Math.max(0,Math.min(t.length-1,j))),y=j=>{j.key!=="ArrowRight"&&j.key!=="ArrowLeft"||(j.preventDefault(),j.stopPropagation(),m(j.key==="ArrowRight"?d+1:d-1))},v=()=>{if(!p){m(d+1);return}n?n.act():a()};return i.jsx("div",{className:"modal-backdrop",onClick:a,role:"presentation",children:i.jsxs("div",{ref:c,className:"modal guide",onClick:j=>j.stopPropagation(),onKeyDown:y,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),i.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("div",{className:"guide-stage",children:f.art},d),i.jsx("p",{className:"guide-line","aria-live":"polite",children:f.line}),i.jsx("p",{className:"guide-tip",children:f.tip??""}),i.jsxs("div",{className:"guide-foot",children:[i.jsx("div",{className:"guide-dots",children:t.map((j,_)=>i.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${_+1} of ${t.length}`,"aria-current":_===d?"step":void 0,onClick:()=>m(_)},_))}),p&&s&&i.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),d>0&&i.jsx("button",{type:"button",className:"btn",onClick:()=>m(d-1),children:"Back"}),i.jsx("button",{ref:l,type:"button",className:"btn primary",onClick:v,children:p?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})})}const Mv={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Vn({children:e}){return i.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Gn({x:e,y:t=34,w:n=176,h:s=132,label:a}){return i.jsxs(i.Fragment,{children:[a&&i.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),i.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function pr({x:e,y:t,email:n,state:s,tone:a,bars:l}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:Mv[a]}),i.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),i.jsx("text",{x:e+12,y:t+16,className:`ga-s ${Mv[a]}`,children:s}),l==null?void 0:l.map((c,d)=>i.jsxs("g",{children:[i.jsx("text",{x:e,y:t+40+d*18,className:"ga-s",children:d?"7d":"5h"}),i.jsx("rect",{x:e+22,y:t+35+d*18,width:96,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:e+22,y:t+35+d*18,width:96*c/100,height:4,rx:2,className:"ga-accent"}),i.jsxs("text",{x:e+148,y:t+40+d*18,className:"ga-s ga-accent",textAnchor:"end",children:[c,"%"]})]},d))]})}function R2({x:e,y:t,on:n}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),i.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Ru({x:e,y:t,name:n,here:s=!0}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:s?"ga-ok":"ga-dim"}),i.jsx("text",{x:e+12,y:t,className:s?"ga-t":"ga-s",children:n})]})}function k1({x:e,y:t,on:n}){return n?i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),i.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):i.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function _1({x:e,y:t,d:n}){return i.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function yx({x:e,y:t}){return i.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function wx(){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{r:9,className:"ga-key-bed"}),i.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[i.jsx("circle",{cx:4.6,cy:7,r:2.6}),i.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Xo({x:e,y:t,w:n,title:s,sub:a,tone:l}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),i.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:Mv[l]}),i.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),i.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function ei({x:e,y:t,label:n,live:s}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),i.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function ld({x:e,y:t}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),i.jsx(R2,{x:e+118,y:t-13,on:!0})]})}function k6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),i.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),i.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),i.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),i.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),i.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),i.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),i.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),i.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),i.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),i.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),i.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),i.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),i.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),i.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),i.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),i.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),i.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),i.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),i.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),i.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function _6(){return i.jsxs(Vn,{children:[i.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),i.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),i.jsx(Xo,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),i.jsx(Xo,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),i.jsx(Xo,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),i.jsx(Xo,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),i.jsx(ei,{x:326,y:28,label:"Read"}),i.jsx(ei,{x:380,y:28,label:"Grep",live:!0}),i.jsx(ei,{x:326,y:90,label:"Bash",live:!0})]})}function N1({x:e,y:t,label:n,pct:s,note:a}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-s",children:n}),i.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[s,"%"]}),i.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:e,y:t+7,width:194*s/100,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:e,y:t+26,className:"ga-s",children:a})]})}function N6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),i.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),i.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),i.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),i.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),i.jsx(N1,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),i.jsx(N1,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function S6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),i.jsx(Xo,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),i.jsx(yx,{x:156,y:106}),i.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),i.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),i.jsx(Gn,{x:200,y:22,w:226,h:160}),i.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),i.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),i.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),i.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),i.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),i.jsx(ei,{x:214,y:122,label:"Read"}),i.jsx(ei,{x:266,y:122,label:"Edit"}),i.jsx(ei,{x:318,y:122,label:"Bash",live:!0}),i.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),i.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function j6(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,y:20,w:412,h:160}),i.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),i.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),i.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>i.jsxs("g",{children:[i.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),i.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),i.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),i.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),i.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),i.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),i.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),i.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),i.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),i.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),i.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),i.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function E6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),i.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),i.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[i.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),i.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),i.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),i.jsx("path",{d:"M210 100H238",className:"ga-arc"}),i.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),i.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),i.jsx("g",{className:"ga-pop",children:i.jsx(Xo,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function C6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,y:16,w:232,h:170}),i.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),i.jsx(_1,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),i.jsx(_1,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),i.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),i.jsx(pr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),i.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),i.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),i.jsx(pr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),i.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),i.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),i.jsx(yx,{x:221,y:161}),i.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),i.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),i.jsx(Gn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),i.jsx("g",{className:"ga-pop",children:i.jsx(pr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function T6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(ld,{x:28,y:60}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(pr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(pr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(ld,{x:264,y:60}),i.jsx(pr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),i.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:i.jsx(wx,{})})]})}const A6=[{art:i.jsx(k6,{}),line:"Sessions waiting on you rise to the top, longest wait first.",tip:"A tone and a system notification when one stops to ask. The bell in the topbar."},{art:i.jsx(_6,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:i.jsx(S6,{}),line:"Click any node: its prompt, every tool call, tokens and timing."},{art:i.jsx(N6,{}),line:"What each session costs, and how much quota is left."},{art:i.jsx(j6,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:i.jsx(C6,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:i.jsx(T6,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Local network is the last section of the Claude accounts panel."},{art:i.jsx(E6,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function R6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),i.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),i.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),i.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(pr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function M6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(ld,{x:28,y:60}),i.jsx(Ru,{x:28,y:92,name:"Ana's MacBook"}),i.jsx(Ru,{x:28,y:114,name:"Dorin's PC"}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(ld,{x:264,y:60}),i.jsx(Ru,{x:264,y:92,name:"Your MacBook"}),i.jsx(Ru,{x:264,y:114,name:"Dorin's PC"}),i.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),i.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function I6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),i.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),i.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),i.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),i.jsx(k1,{x:106,y:88,on:!0}),i.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),i.jsx(k1,{x:106,y:112}),i.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),i.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),i.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),i.jsx(R2,{x:304,y:157,on:!0}),i.jsx(yx,{x:115,y:97})]})}function $6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(pr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),i.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:i.jsx(wx,{})})]})}const O6=[{art:i.jsx(R6,{}),line:"A login can expire on one machine while it still works on another."},{art:i.jsx(M6,{}),line:"Turn this on, on both machines. They find each other and pair.",tip:"Not showing up? The + in the section reaches a machine by address or invite."},{art:i.jsx(I6,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:i.jsx($6,{}),line:"An expired login is copied from a paired machine within a minute."}];function P6(){return i.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),i.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),i.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),i.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),i.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),i.jsx("g",{transform:"translate(116 13)",children:i.jsx(wx,{})})]})}async function Pf(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const L6={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."},D6={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function S1(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Lt(n,t)}function q6({status:e,manual:t,onClose:n,onChanged:s}){var ee,Z;const a=b.useRef(null),l=Ht(n,{focusRef:a}),[c,d]=b.useState(""),[h,p]=b.useState(""),[f,m]=b.useState(null),[y,v]=b.useState(null),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(()=>Date.now());b.useEffect(()=>{const D=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval(D)},[]);const C=b.useRef(!0);b.useEffect(()=>()=>{C.current=!1},[]);const R=b.useRef(null),I=b.useCallback(D=>Nd(R.current)?(R.current=D,_(D),!0):!1,[]),$=b.useCallback(()=>{R.current=null,C.current&&_(null)},[]),F=D=>{const Y=Ks(j,D);return{disabled:Y.disabled,"aria-busy":Y.busy}},O=D=>(f==null?void 0:f.field)===D?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},M=D=>m(Y=>Y&&Y.field===D?null:Y),L=b.useCallback(async()=>{const D=K6(c);if(!D){m({text:F6(c),field:"addr"});return}const Y=`${D.addr}:${D.port}`,P=e.peers.find(G=>G.addr===D.addr&&G.port===D.port&&G.paired);if(P){m({text:`Already paired with ${P.name} at that address.`,field:"addr"});return}if(t.includes(Y)){m({text:"This deck already calls that address.",field:"addr"});return}if(I("add"))try{const G=await Pf("/api/prefs",{lan:{manual:[...t,Y]}});if(!C.current)return;G!=null&&G.ok?(m(null),d(""),s(),n()):m({text:Lt("add that address",G),field:"addr"})}catch{C.current&&m({text:Lt("add that address",null),field:"addr"})}finally{$()}},[c,t,e.peers,s,n,I,$]),H=b.useCallback(async D=>{if(!I(`invite:${D}`))return;const Y=D==="make"?"make an invite":"cancel that invite";try{const P=await Pf("/api/lan/invite",{action:D});if(!C.current)return;P!=null&&P.ok?(m(null),v(null),s()):m({text:S1(D6,P,Y)})}catch{C.current&&m({text:Lt(Y,null)})}finally{$()}},[s,I,$]),B=b.useCallback(async()=>{const D=h.trim();if(!(!D||!I("join"))){x(null);try{const Y=await Pf("/api/lan/invite",{action:"join",token:D});if(!C.current)return;Y!=null&&Y.ok?(p(""),m(null),s(),n()):(Y==null?void 0:Y.reason)==="unreachable"&&Array.isArray(Y.tried)&&Y.tried.length?(x(Y.tried),m(null)):(x(null),m({text:S1(L6,Y,"use that invite"),field:"join"}))}catch{C.current&&m({text:Lt("use that invite",null),field:"join"})}finally{$()}}},[h,s,n,I,$]),A=b.useCallback(async(D,Y)=>{try{await navigator.clipboard.writeText(D),v(Y),window.setTimeout(()=>{C.current&&v(P=>P===Y?null:P)},1600)}catch{m({text:"Could not copy it — select the text and copy it by hand."})}},[]),Q=e.invite&&e.invite.expiresAt>N?e.invite:null,K=((ee=e.reach)==null?void 0:ee.steps)??[];return i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:l,className:"modal lan-add",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[f&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:f.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),((Z=e.reach)==null?void 0:Z.blocked)&&i.jsxs("div",{className:"ap-lan-reach",children:[i.jsx("p",{className:"lan-warn",children:e.reach.text}),i.jsx("p",{className:"lan-note",children:"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."}),K.length>0&&i.jsxs("details",{className:"ap-lan-reach-fix",children:[i.jsx("summary",{children:"or let them find this deck on their own"}),i.jsxs("p",{className:"lan-note",children:["Run this in PowerShell ",i.jsx("strong",{children:"as Administrator"}),", then restart the deck.",e.reach.category==="Public"&&i.jsx(i.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."})]}),i.jsx("pre",{className:"ap-lan-cmd",children:i.jsx("code",{children:K.join(`
79
+ ${n}`:`Sort by ${t}`,onClick:()=>a(hD(s,e)),children:[t,i.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:l==="none"?"":l==="ascending"?"↑":"↓"})]})})}const xD=3e3;function bD(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function kD(e,t,n=Date.now()){const s=Math.max(0,Math.min(100,100-e));return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${_D(t.lastMs,n)}`:"running at full speed, and never held back"}}function _D(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 bl(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function ND(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 SD(){const[e,t]=b.useState(null),n=b.useRef(null);return b.useEffect(()=>{let s=!0;const a=async()=>{if(document.visibilityState!=="hidden")try{const h=await fetch("/api/system");if(!h.ok)return;const p=await h.json();s&&(p!=null&&p.ok)&&t(p)}catch{}},l=()=>{n.current==null&&(a(),n.current=window.setInterval(a,xD))},c=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},d=()=>{if(document.visibilityState==="hidden"){c();return}l(),a()};return l(),document.addEventListener("visibilitychange",d),()=>{s=!1,c(),document.removeEventListener("visibilitychange",d)}},[]),e}function f1({usageOpen:e,leaving:t,sub:n,onClose:s,children:a}){return i.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-label":"Machine detail",children:[i.jsxs("div",{className:"sd-head",children:[i.jsx("span",{className:"sd-title",children:"This machine"}),n&&i.jsx("span",{className:"sd-sub",children:n}),i.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),a]})}function jD({usageOpen:e,leaving:t,onClose:n}){const s=SD();if(!s||s.cpu==null||!s.memory)return i.jsx(f1,{usageOpen:e,leaving:t,onClose:n,children:i.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:a,swap:l,perCore:c,loadavg:d,cores:h,uptimeSec:p,platform:f,thermal:m}=s,y=a?a.total-a.available:0,v=f==="win32"?"Commit":"Swap",j=l&&l.total>0?l.used/l.total*100:0;return i.jsxs(f1,{usageOpen:e,leaving:t,sub:`up ${ND(p)} · ${h} cores`,onClose:n,children:[c&&c.length>0&&i.jsx("div",{className:"sd-section",role:"group","aria-label":"Cores",children:i.jsx(Vu,{group:"cores",title:"Core history",action:"Show core history",label:"Cores",children:i.jsx("div",{className:"sd-cores",style:{"--n":c.length},children:c.map((_,S)=>i.jsx("span",{className:"sd-core",title:`core ${S+1}: ${_}%`,children:i.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,_)/100})`}})},S))})})}),i.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:i.jsxs(Vu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a&&i.jsx(ld,{label:"Physical",value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:bl(y)})," of ",bl(a.total)]}),pct:a.usedPct,tone:a.usedPct>=90?"warn":"calm",note:`${bl(a.available)} available`}),l&&l.total>0&&i.jsx(ld,{label:v,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:bl(l.used)})," of ",bl(l.total)]}),pct:j,tone:j>=90?"warn":"calm",note:j>=50?"paging to disk":void 0})]})}),d&&i.jsx("div",{className:"sd-section",role:"group","aria-label":"Load average",children:i.jsxs(Vu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",children:[i.jsx("div",{className:"sd-load",children:d.map((_,S)=>i.jsxs("span",{className:`sd-load-item${_>h?" over":""}`,children:[i.jsx("b",{children:_.toFixed(2)}),i.jsx("span",{children:["1m","5m","15m"][S]})]},S))}),i.jsx("div",{className:"sd-note",children:d[0]>h?`${(d[0]/h).toFixed(1)}× more work queued than cores to run it`:`within ${h} cores`})]})}),i.jsx(ED,{thermal:m}),i.jsx(CD,{sys:s})]})}function Vu({group:e,title:t,action:n,label:s,children:a}){const[l,c]=b.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"sd-open",onClick:()=>c(!0),title:n,"aria-label":n,children:[i.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[s," ",i.jsx("i",{className:"sd-row-more",children:"›"})]}),a]}),l&&i.jsx(eD,{group:e,title:t,onClose:()=>c(!1)})]})}function ED({thermal:e}){if(!e)return null;const t=e.throttle?kD(e.throttle.speedLimit,e.heldBack):null;return i.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:i.jsxs(Vu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>i.jsx(ld,{label:n.label,value:i.jsxs(i.Fragment,{children:[i.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius,tone:bD(n.celsius,n.warnAt,n.critAt)},n.label)),t&&i.jsx(ld,{label:"Throttling",value:t.value,pct:t.pct,tone:t.tone,note:t.note})]})})}function CD({sys:e}){const[t,n]=b.useState(!1);return i.jsxs("div",{className:"sd-section",children:[i.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Show every process the deck is watching",children:i.jsxs("span",{className:"sd-door-plate",children:[i.jsxs("span",{className:"sd-door-name",children:["Busiest processes",i.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),i.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&i.jsx(vD,{sys:e,onClose:()=>n(!1)})]})}function ld({label:e,value:t,pct:n,tone:s="calm",note:a}){return i.jsxs("div",{className:"sd-row",children:[i.jsxs("div",{className:"sd-row-head",children:[i.jsx("span",{className:"sd-row-label",children:e}),i.jsx("span",{className:"sd-row-val",children:t})]}),i.jsx("span",{className:"sd-track",children:i.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}})}),a&&i.jsx("div",{className:"sd-note",children:a})]})}const p1=18,TD=1100,Ho=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},AD=Array.from({length:p1},(e,t)=>{const n=-72+144*t/(p1-1)+(Ho(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+Ho(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+Ho(t,3)*260),delay:Math.round(Ho(t,4)*90),dur:760+Math.round(Ho(t,5)*260),scale:.8+Ho(t,6)*.45,hue:t%4,round:t%3===0}});function m1({anchor:e}){var a;const[t,n]=b.useState(null),s=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return b.useEffect(()=>{if(s)return;const l=e.current;if(!l)return;const c=l.getBoundingClientRect();n({x:c.left+c.width/2,y:c.top+c.height/2});const d=window.setTimeout(()=>n(null),TD);return()=>window.clearTimeout(d)},[e,s]),s||!t?null:ls.createPortal(i.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:AD.map((l,c)=>i.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},c))}),document.body)}const E2=new Set(["awaiting_url","awaiting_code","registering"]);function RD(e){return e!=null&&E2.has(e)}function C2(e){return e!=null&&e!=="done"&&!E2.has(e)}const MD="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",ID="the sign-in did not complete";function $D({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?MD:ID)}}const OD="done";function PD(){let e=!1;return{shouldAnnounce(t){return t!==OD?(e=!1,!1):e?!1:(e=!0,!0)}}}function mx(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const LD={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 ${Wt}`,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"},DD={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},qD=`claude-swap could not read the login keychain — start ${Wt} from a Terminal window rather than a background service`;function Rv(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ii(e)))return qD;const n=mx(DD,e==null?void 0:e.reason);return n||(e==null?void 0:e.reason)||t}function ii(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const FD={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"},BD="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 zD(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const UD="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",WD="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",HD=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),GD=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,VD=/[\\/]_npx[\\/]/i,YD=`the copy of ccusage ${Wt} installed for itself`;function KD(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function XD(e,t){const n=QD(e,t),s=KD(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 ${kl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${kl(n)}`;case"managed":return`${YD} failed to run: ${kl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${kl(n)}`:`the ccusage this deck found on your PATH failed to run: ${kl(n)}`;default:return n}}const kl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function QD(e,t){const n=ii(e);if(HD(n)){if(VD.test(n))return WD;if(GD.test(n))return UD}if(zD(n))return BD;const s=mx(FD,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Xo(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&C2(e.state))return e.error;const n=mx(LD,e==null?void 0:e.reason);return n||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function ZD(e,t,n){if(n<=0||ux(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:s===-1?0:(s+1)%n};case"ArrowLeft":return{kind:"select",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function T2(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 JD(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}`,l=[];return n.alias&&s&&l.push(s),s&&(t.get(s.toLowerCase())??0)>1&&l.push(n.org||`slot ${n.num}`),{num:n.num,label:a,sub:l.length?l.join(" · "):null}})}function e6(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 t6(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 n6(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(f=>f.state===p).length,s=[],a=n("imported");a&&s.push(`${a} of ${t} imported`);const l=n("healed");l&&s.push(`${l} had a dead token replaced`);const c=n("updated");c&&s.push(`${c} updated`);const d=n("present");d&&s.push(`${d} already here`);const h=n("failed");return h&&s.push(`${h} did not arrive`),`${s.join(", ")}.`}const r6=1500,Ru=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],g1="aa-panel",y1=e=>`aa-tab-${e}`;async function _l(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Mv=fe.forwardRef((e,t)=>i.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[i.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),i.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Mv.displayName="SuccessMark";function s6({onClose:e,onChanged:t}){const[n,s]=b.useState("login"),[a,l]=b.useState(null),[c,d]=b.useState(""),[h,p]=b.useState(""),[f,m]=b.useState(!1),[y,v]=b.useState(null),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(null),C=b.useRef(""),R=b.useRef(!1),I=b.useRef(!1),$=b.useRef(null),F=b.useRef(null),O=b.useRef(null),M=b.useRef(null),L=b.useRef([]),H=b.useRef(!1),B=b.useCallback(()=>{R.current&&_l({action:"login-cancel"}).catch(()=>{}),e()},[e]),A=Ht(B,{focusRef:O}),Q=b.useCallback(async()=>{if(!hr(I.current))return;I.current=!0,m(!0),v(null),R.current=!0;const U=await _l({action:"login"}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Xo(U,"could not start the sign-in"));return}l(U)},[]);b.useEffect(()=>{if(!RD(a==null?void 0:a.state))return;const U=window.setInterval(async()=>{try{const J=await fetch("/api/claude-accounts/login");J.ok&&l(await J.json())}catch{}},r6);return()=>window.clearInterval(U)},[a]);const K=b.useRef(t);K.current=t;const ee=b.useState(PD)[0];b.useEffect(()=>{var U;(a==null?void 0:a.state)==="awaiting_code"&&((U=$.current)==null||U.focus()),ee.shouldAnnounce(a==null?void 0:a.state)&&K.current()},[a==null?void 0:a.state,ee]),b.useEffect(()=>{var U;n==="paste"&&!H.current&&((U=F.current)==null||U.focus()),H.current=!1},[n]);const Z=b.useCallback(U=>{var V;const J=ZD(U,Ru.findIndex(ie=>ie.id===n),Ru.length);J.kind!=="pass"&&(U.preventDefault(),H.current=!0,s(Ru[J.index].id),(V=L.current[J.index])==null||V.focus())},[n]),D=b.useCallback(async()=>{var J;if(!hr(I.current))return;I.current=!0,m(!0),v(null);const U=await _l({action:"login-code",code:c}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Xo(U,"the code was not accepted")),U!=null&&U.state&&l(U),(J=$.current)==null||J.select();return}d(""),l(U)},[c,a]),Y=b.useCallback(async()=>{if(!hr(I.current))return;I.current=!0,m(!0),v(null);const U=await _l({action:"import",blob:h}).catch(()=>null);if(I.current=!1,m(!1),!(U!=null&&U.ok)){v(Xo(U,"the import failed"));return}C.current=h,p(""),E(null),_(U.results??[]),t()},[h,t]),P=b.useCallback(async U=>{const J=`${U.email}|${U.org??""}`;if(!hr(I.current)||!C.current)return;I.current=!0,m(!0),x(J),E(null);const V=await _l({action:"import",blob:C.current,force:!0,only:{email:U.email,org:U.org??""}}).catch(()=>null);if(I.current=!1,m(!1),x(null),!(V!=null&&V.ok)){E({key:J,text:Xo(V,"that account could not be updated")});return}const ie=(V.results??[])[0];ie&&_(pe=>pe&&pe.map(me=>`${me.email}|${me.org??""}`===J?ie:me)),t()},[t]),G=(a==null?void 0:a.state)==="done"?a.account:null,de=C2(a==null?void 0:a.state)||!!(y&&R.current&&!f),W=$D({state:a==null?void 0:a.state,serverError:a==null?void 0:a.error,localError:y});return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:B,role:"presentation",children:i.jsxs("div",{ref:A,className:"modal aa-modal",onClick:U=>U.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Z,children:Ru.map((U,J)=>i.jsx("button",{type:"button",role:"tab",id:y1(U.id),ref:V=>{L.current[J]=V},"aria-selected":n===U.id,"aria-controls":g1,tabIndex:n===U.id?0:-1,className:`aa-tab${n===U.id?" on":""}`,onClick:()=>{H.current=!1,s(U.id)},children:U.label},U.id))})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:B,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body aa-body",id:g1,role:"tabpanel","aria-labelledby":y1(n),children:n==="login"?G?i.jsxs("div",{className:"aa-done",children:[i.jsx(Mv,{ref:M}),i.jsx(m1,{anchor:M}),i.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),i.jsxs("p",{className:"aa-note",children:[i.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),i.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(a==null?void 0:a.state)==="awaiting_code"||(a==null?void 0:a.state)==="registering"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"1 · Approve in the browser"}),i.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),i.jsx("a",{className:"aa-link",href:a.url??"#",target:"_blank",rel:"noreferrer noopener",children:a.url})]}),i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),i.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:$,type:"text",value:c,onChange:U=>d(U.target.value),onKeyDown:U=>{U.key==="Enter"&&c.trim()&&!f&&D()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:a.state==="registering"}),i.jsx("button",{type:"button",className:"btn primary",...dr(f,!c.trim()||a.state==="registering"),onClick:D,children:a.state==="registering"?"registering…":"Continue"})]}),(y||a.error)&&i.jsx("p",{className:"aa-err",children:y??a.error}),i.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):de?i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:W.title}),i.jsx("p",{className:"aa-err",children:W.message}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{R.current=!1,l(null),v(null),Q()},children:"Try again"})]}):f||R.current?i.jsx("div",{className:"aa-step",children:i.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):i.jsxs("div",{className:"aa-step aa-primer",children:[i.jsx("h4",{children:"Sign in to Anthropic"}),i.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),i.jsx("div",{className:"aa-actions",children:i.jsx("button",{type:"button",ref:O,className:"btn primary",onClick:Q,children:"Open the sign-in page"})})]}):j?(()=>{const U=j.filter(J=>J.state==="imported").length;return i.jsxs("div",{className:"aa-done",children:[i.jsx(Mv,{ref:M}),U>0&&i.jsx(m1,{anchor:M}),i.jsx("h4",{children:n6(j)}),j.length>0&&i.jsx("ul",{className:"aa-results",children:j.map(J=>{const V=`${J.email}|${J.org??""}`;return i.jsxs("li",{className:`aa-result ${J.state}`,children:[i.jsx("span",{className:"aa-result-who",children:J.email||(J.num?`slot ${J.num}`:"an account")}),i.jsx("span",{className:"aa-result-what",children:t6(J.state)}),J.state==="present"&&i.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":S===V,title:`Overwrite the stored login for ${J.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>P(J),children:S===V?"updating…":"update anyway"}),(N==null?void 0:N.key)===V&&i.jsx("span",{className:"aa-result-err",children:N.text})]},V)})}),i.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",i.jsx("strong",{children:" update anyway"}),"."]}),i.jsxs("div",{className:"aa-actions",children:[i.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),i.jsx("button",{type:"button",className:"btn",onClick:()=>{C.current="",E(null),_(null)},children:"Import another"})]})]})})():i.jsxs("div",{className:"aa-step",children:[i.jsx("h4",{children:"Paste an account shared from another deck"}),i.jsxs("div",{className:"aa-field",children:[i.jsx("input",{ref:F,type:"text",value:h,onChange:U=>p(U.target.value),onKeyDown:U=>{U.key==="Enter"&&h.trim()&&!f&&Y()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),i.jsx("button",{type:"button",className:"btn primary",...dr(f,!h.trim()),onClick:Y,children:f?"importing…":"Import"})]}),y&&i.jsx("p",{className:"aa-err",children:y}),i.jsxs("p",{className:"aa-note",children:["Use ",i.jsx("strong",{children:"share"})," on one account in the other deck, or ",i.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})}),document.body)}async function a6(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const o6=1800;function i6({accounts:e,onClose:t,copyText:n}){const[s,a]=b.useState([]),[l,c]=b.useState(null),[d,h]=b.useState(!1),[p,f]=b.useState(null),[m,y]=b.useState(!1),[v,j]=b.useState(()=>Math.floor(Date.now()/1e3)),_=b.useRef(null),S=b.useRef(!1),x=Ht(t,{focusRef:_});b.useEffect(()=>{if(!l)return;j(Math.floor(Date.now()/1e3));const M=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(M)},[l]);const N=JD(e),E=e.filter(M=>!s.includes(M.num)).map(M=>M.num),C=E.length===e.length,R=M=>a(L=>L.includes(M)?L.filter(H=>H!==M):[...L,M]),I=b.useCallback(async()=>{if(!hr(S.current)||!E.length)return;S.current=!0,h(!0),f(null),y(!1);const M=await a6({action:"share",accounts:E}).catch(()=>null);if(S.current=!1,h(!1),!(M!=null&&M.ok)){f(Xo(M,"the share could not be made"));return}c({blob:M.blob,expiresAt:M.expiresAt,shared:M.shared??[],failed:M.failed??[]})},[e,E]),$=l?T2(l.expiresAt,v):null,F=($==null?void 0:$.tone)==="gone",O=(l==null?void 0:l.shared.length)??0;return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:i.jsxs("div",{ref:x,className:"modal sa-modal",onClick:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("h3",{children:"Share accounts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsx("section",{className:"modal-body sa-body",children:l?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:F?"This share has expired":O===1?"1 account, ready to paste":`${O} accounts, ready to paste`}),i.jsx("code",{className:`ap-share-blob${F?" sa-dead":""}`,children:l.blob}),i.jsxs("div",{className:"ap-share-foot",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",ref:_,onClick:async()=>{if(F){c(null),I();return}await n(l.blob)&&(y(!0),window.setTimeout(()=>y(!1),o6))},children:F?"make a new share":m?"copied":`copy ${O===1?"the share":"all "+O}`}),i.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[i.jsx("span",{className:"ap-share-warn",children:O===1?"this is the password":`this is ${O} passwords`})," · ",i.jsx("span",{className:`ap-share-expiry ${$==null?void 0:$.tone}`,children:$==null?void 0:$.text})]})]}),l.failed.length>0&&i.jsxs("div",{className:"sa-failed",role:"alert",children:[i.jsx("p",{className:"sa-failed-head",children:l.failed.length===1?"One account is not in this bundle:":`${l.failed.length} accounts are not in this bundle:`}),i.jsx("ul",{className:"sa-list",children:l.failed.map(M=>{var H;const L=!!(M.email&&((H=M.detail)!=null&&H.includes(M.email)));return i.jsxs("li",{children:[!L&&i.jsx("span",{className:"sa-who",children:M.email||`account ${M.num}`}),i.jsx("span",{className:"sa-why",children:M.detail||"could not be exported"})]},`${M.num}-${M.email}`)})})]}),i.jsx("p",{className:"sa-note",children:F?i.jsx(i.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):i.jsxs(i.Fragment,{children:["Paste it into the other deck with ",i.jsx("strong",{children:"+"})," → ",i.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>{c(null),y(!1)},children:"Pick again"}),i.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?i.jsxs("div",{className:"sa-step",children:[i.jsx("h4",{children:"Nothing to share"}),i.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",i.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),i.jsx("div",{className:"sa-actions",children:i.jsx("button",{type:"button",className:"btn primary",ref:_,onClick:t,children:"Close"})})]}):i.jsxs("div",{className:"sa-step",children:[i.jsxs("h4",{children:["Which accounts go to the other ",Wt,"?"]}),i.jsx("p",{className:`sa-count${E.length?"":" empty"}`,children:e6(E.length)}),i.jsx("ul",{className:"sa-list sa-pick",children:N.map(M=>i.jsx("li",{children:i.jsxs("label",{className:"sa-row",children:[i.jsx("input",{type:"checkbox",checked:E.includes(M.num),onChange:()=>R(M.num)}),i.jsx("span",{className:"sa-who",children:M.label}),M.sub&&i.jsx("span",{className:"sa-sub",children:M.sub})]})},M.num))}),p&&i.jsx("p",{className:"aa-err",children:p}),i.jsxs("div",{className:"sa-actions",children:[i.jsx("button",{type:"button",className:"btn",onClick:()=>a(C?e.map(M=>M.num):[]),children:C?"Clear all":"Select all"}),i.jsx("button",{type:"button",className:"btn primary",ref:_,...dr(d,!E.length),onClick:I,children:d?"making the share…":E.length===0?"Share":E.length===1?"Share 1 account":`Share ${E.length} accounts`})]})]})})]})}),document.body)}function l6(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((a,l)=>a-l).map(a=>{const l=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:l,label:l==="here"?`slot ${a}`:`slot ${a} · ${l}`}})}function c6(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}}function u6(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function d6(e,t,n){var a;const s=((a=e.find(l=>l.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 h6(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 w1(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function v1(e){const t=e.filter(d=>!w1(d)),n=e.filter(d=>w1(d)),s=t.length?t:n,a=t.length?n:[],l=s.reduce((d,h)=>d&&d.pct>=h.pct?d:h,null);let c=null;for(const d of a)l&&d.pct<=l.pct||(!c||d.pct>c.pct)&&(c=d);return{shown:s,rest:a,fuller:c,peak:c??l}}function f6(e,t,n){return e<1?null:t?"fewer":n?`${n.label} ${Math.round(n.pct)}%`:`${e} more`}function p6(e,t,n,s){const a=e==null?"No usage has been collected for this account yet.":`${Math.round(e)}% left on ${t??"the window that runs out first"}, which is the one that runs out first.`,l=n===1?"the other window":`the other ${n} windows`;return`${a} ${s?"Hide":"Show"} ${l}.`}const m6="\0";function gx(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${m6}${n}`}function g6(e,t){const n=gx(t);return e.includes(n)?e.filter(s=>s!==n):[...e,n]}function y6(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(gx)),s=e.filter(a=>n.has(a));return s.length===e.length?e:s}const w6=64;function v6(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const x6=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function x1(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function b6(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=ii(t.body);return{text:Rv(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function b1(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}function A2({title:e,steps:t,finish:n,aside:s,onClose:a}){const l=b.useRef(null),c=Ht(a,{focusRef:l}),[d,h]=b.useState(0),p=d===t.length-1,f=t[d],m=j=>h(Math.max(0,Math.min(t.length-1,j))),y=j=>{j.key!=="ArrowRight"&&j.key!=="ArrowLeft"||(j.preventDefault(),j.stopPropagation(),m(j.key==="ArrowRight"?d+1:d-1))},v=()=>{if(!p){m(d+1);return}n?n.act():a()};return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:a,role:"presentation",children:i.jsxs("div",{ref:c,className:"modal guide",onClick:j=>j.stopPropagation(),onKeyDown:y,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),i.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("div",{className:"guide-stage",children:f.art},d),i.jsx("p",{className:"guide-line","aria-live":"polite",children:f.line}),i.jsx("p",{className:"guide-tip",children:f.tip??""}),i.jsxs("div",{className:"guide-foot",children:[i.jsx("div",{className:"guide-dots",children:t.map((j,_)=>i.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${_+1} of ${t.length}`,"aria-current":_===d?"step":void 0,onClick:()=>m(_)},_))}),p&&s&&i.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),d>0&&i.jsx("button",{type:"button",className:"btn",onClick:()=>m(d-1),children:"Back"}),i.jsx("button",{ref:l,type:"button",className:"btn primary",onClick:v,children:p?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const Iv={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Vn({children:e}){return i.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Gn({x:e,y:t=34,w:n=176,h:s=132,label:a}){return i.jsxs(i.Fragment,{children:[a&&i.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),i.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function pr({x:e,y:t,email:n,state:s,tone:a,bars:l}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:Iv[a]}),i.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),i.jsx("text",{x:e+12,y:t+16,className:`ga-s ${Iv[a]}`,children:s}),l==null?void 0:l.map((c,d)=>i.jsxs("g",{children:[i.jsx("text",{x:e,y:t+40+d*18,className:"ga-s",children:d?"7d":"5h"}),i.jsx("rect",{x:e+22,y:t+35+d*18,width:96,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:e+22,y:t+35+d*18,width:96*c/100,height:4,rx:2,className:"ga-accent"}),i.jsxs("text",{x:e+148,y:t+40+d*18,className:"ga-s ga-accent",textAnchor:"end",children:[c,"%"]})]},d))]})}function R2({x:e,y:t,on:n}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),i.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Mu({x:e,y:t,name:n,here:s=!0}){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:e+3,cy:t-4,r:3,className:s?"ga-ok":"ga-dim"}),i.jsx("text",{x:e+12,y:t,className:s?"ga-t":"ga-s",children:n})]})}function k1({x:e,y:t,on:n}){return n?i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),i.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):i.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function _1({x:e,y:t,d:n}){return i.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function yx({x:e,y:t}){return i.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function wx(){return i.jsxs(i.Fragment,{children:[i.jsx("circle",{r:9,className:"ga-key-bed"}),i.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[i.jsx("circle",{cx:4.6,cy:7,r:2.6}),i.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Qo({x:e,y:t,w:n,title:s,sub:a,tone:l}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),i.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:Iv[l]}),i.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),i.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function ti({x:e,y:t,label:n,live:s}){return i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),i.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function cd({x:e,y:t}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),i.jsx(R2,{x:e+118,y:t-13,on:!0})]})}function k6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),i.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),i.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),i.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),i.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),i.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),i.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),i.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),i.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),i.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),i.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),i.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),i.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),i.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),i.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),i.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),i.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),i.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),i.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),i.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),i.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function _6(){return i.jsxs(Vn,{children:[i.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),i.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),i.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),i.jsx(Qo,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),i.jsx(Qo,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),i.jsx(Qo,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),i.jsx(Qo,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),i.jsx(ti,{x:326,y:28,label:"Read"}),i.jsx(ti,{x:380,y:28,label:"Grep",live:!0}),i.jsx(ti,{x:326,y:90,label:"Bash",live:!0})]})}function N1({x:e,y:t,label:n,pct:s,note:a}){return i.jsxs(i.Fragment,{children:[i.jsx("text",{x:e,y:t,className:"ga-s",children:n}),i.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[s,"%"]}),i.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:e,y:t+7,width:194*s/100,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:e,y:t+26,className:"ga-s",children:a})]})}function N6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),i.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),i.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),i.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),i.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),i.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),i.jsx(N1,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),i.jsx(N1,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function S6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),i.jsx(Qo,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),i.jsx(yx,{x:156,y:106}),i.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),i.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),i.jsx(Gn,{x:200,y:22,w:226,h:160}),i.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),i.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),i.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),i.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),i.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),i.jsx(ti,{x:214,y:122,label:"Read"}),i.jsx(ti,{x:266,y:122,label:"Edit"}),i.jsx(ti,{x:318,y:122,label:"Bash",live:!0}),i.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),i.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function j6(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,y:20,w:412,h:160}),i.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),i.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),i.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),i.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>i.jsxs("g",{children:[i.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),i.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),i.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),i.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),i.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),i.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),i.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),i.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),i.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),i.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),i.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),i.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),i.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),i.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function E6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),i.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),i.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),i.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[i.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),i.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),i.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),i.jsx("path",{d:"M210 100H238",className:"ga-arc"}),i.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),i.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),i.jsx("g",{className:"ga-pop",children:i.jsx(Qo,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function C6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,y:16,w:232,h:170}),i.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),i.jsx(_1,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),i.jsx(_1,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),i.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),i.jsx(pr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),i.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),i.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),i.jsx(pr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),i.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),i.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),i.jsx(yx,{x:221,y:161}),i.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),i.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),i.jsx(Gn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),i.jsx("g",{className:"ga-pop",children:i.jsx(pr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function T6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(cd,{x:28,y:60}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(pr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(pr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(cd,{x:264,y:60}),i.jsx(pr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),i.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:i.jsx(wx,{})})]})}const A6=[{art:i.jsx(k6,{}),line:"Sessions waiting on you rise to the top, longest wait first.",tip:"A tone and a system notification when one stops to ask. The bell in the topbar."},{art:i.jsx(_6,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:i.jsx(S6,{}),line:"Click any node: its prompt, every tool call, tokens and timing."},{art:i.jsx(N6,{}),line:"What each session costs, and how much quota is left."},{art:i.jsx(j6,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:i.jsx(C6,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:i.jsx(T6,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Local network is the last section of the Claude accounts panel."},{art:i.jsx(E6,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function R6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),i.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),i.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),i.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(pr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function M6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx(cd,{x:28,y:60}),i.jsx(Mu,{x:28,y:92,name:"Ana's MacBook"}),i.jsx(Mu,{x:28,y:114,name:"Dorin's PC"}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(cd,{x:264,y:60}),i.jsx(Mu,{x:264,y:92,name:"Your MacBook"}),i.jsx(Mu,{x:264,y:114,name:"Dorin's PC"}),i.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),i.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),i.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function I6(){return i.jsxs(Vn,{children:[i.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),i.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),i.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),i.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),i.jsx(k1,{x:106,y:88,on:!0}),i.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),i.jsx(k1,{x:106,y:112}),i.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),i.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),i.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),i.jsx(R2,{x:304,y:157,on:!0}),i.jsx(yx,{x:115,y:97})]})}function $6(){return i.jsxs(Vn,{children:[i.jsx(Gn,{x:14,label:"THIS MACHINE"}),i.jsx("g",{className:"ga-swap-out",children:i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),i.jsx("g",{className:"ga-swap-in",children:i.jsx(pr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),i.jsx(Gn,{x:250,label:"ANOTHER MACHINE"}),i.jsx(pr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),i.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),i.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:i.jsx(wx,{})})]})}const O6=[{art:i.jsx(R6,{}),line:"A login can expire on one machine while it still works on another."},{art:i.jsx(M6,{}),line:"Turn this on, on both machines. They find each other and pair.",tip:"Not showing up? The + in the section reaches a machine by address or invite."},{art:i.jsx(I6,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:i.jsx($6,{}),line:"An expired login is copied from a paired machine within a minute."}];function P6(){return i.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[i.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),i.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),i.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),i.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),i.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),i.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),i.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),i.jsx("g",{transform:"translate(116 13)",children:i.jsx(wx,{})})]})}async function Lf(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const L6={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."},D6={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function S1(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Lt(n,t)}function q6({status:e,manual:t,onClose:n,onChanged:s}){var ee,Z;const a=b.useRef(null),l=Ht(n,{focusRef:a}),[c,d]=b.useState(""),[h,p]=b.useState(""),[f,m]=b.useState(null),[y,v]=b.useState(null),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(()=>Date.now());b.useEffect(()=>{const D=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval(D)},[]);const C=b.useRef(!0);b.useEffect(()=>()=>{C.current=!1},[]);const R=b.useRef(null),I=b.useCallback(D=>Sd(R.current)?(R.current=D,_(D),!0):!1,[]),$=b.useCallback(()=>{R.current=null,C.current&&_(null)},[]),F=D=>{const Y=Xs(j,D);return{disabled:Y.disabled,"aria-busy":Y.busy}},O=D=>(f==null?void 0:f.field)===D?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},M=D=>m(Y=>Y&&Y.field===D?null:Y),L=b.useCallback(async()=>{const D=K6(c);if(!D){m({text:F6(c),field:"addr"});return}const Y=`${D.addr}:${D.port}`,P=e.peers.find(G=>G.addr===D.addr&&G.port===D.port&&G.paired);if(P){m({text:`Already paired with ${P.name} at that address.`,field:"addr"});return}if(t.includes(Y)){m({text:"This deck already calls that address.",field:"addr"});return}if(I("add"))try{const G=await Lf("/api/prefs",{lan:{manual:[...t,Y]}});if(!C.current)return;G!=null&&G.ok?(m(null),d(""),s(),n()):m({text:Lt("add that address",G),field:"addr"})}catch{C.current&&m({text:Lt("add that address",null),field:"addr"})}finally{$()}},[c,t,e.peers,s,n,I,$]),H=b.useCallback(async D=>{if(!I(`invite:${D}`))return;const Y=D==="make"?"make an invite":"cancel that invite";try{const P=await Lf("/api/lan/invite",{action:D});if(!C.current)return;P!=null&&P.ok?(m(null),v(null),s()):m({text:S1(D6,P,Y)})}catch{C.current&&m({text:Lt(Y,null)})}finally{$()}},[s,I,$]),B=b.useCallback(async()=>{const D=h.trim();if(!(!D||!I("join"))){x(null);try{const Y=await Lf("/api/lan/invite",{action:"join",token:D});if(!C.current)return;Y!=null&&Y.ok?(p(""),m(null),s(),n()):(Y==null?void 0:Y.reason)==="unreachable"&&Array.isArray(Y.tried)&&Y.tried.length?(x(Y.tried),m(null)):(x(null),m({text:S1(L6,Y,"use that invite"),field:"join"}))}catch{C.current&&m({text:Lt("use that invite",null),field:"join"})}finally{$()}}},[h,s,n,I,$]),A=b.useCallback(async(D,Y)=>{try{await navigator.clipboard.writeText(D),v(Y),window.setTimeout(()=>{C.current&&v(P=>P===Y?null:P)},1600)}catch{m({text:"Could not copy it — select the text and copy it by hand."})}},[]),Q=e.invite&&e.invite.expiresAt>N?e.invite:null,K=((ee=e.reach)==null?void 0:ee.steps)??[];return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:l,className:"modal lan-add",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[f&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:f.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),((Z=e.reach)==null?void 0:Z.blocked)&&i.jsxs("div",{className:"ap-lan-reach",children:[i.jsx("p",{className:"lan-warn",children:e.reach.text}),i.jsx("p",{className:"lan-note",children:"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."}),K.length>0&&i.jsxs("details",{className:"ap-lan-reach-fix",children:[i.jsx("summary",{children:"or let them find this deck on their own"}),i.jsxs("p",{className:"lan-note",children:["Run this in PowerShell ",i.jsx("strong",{children:"as Administrator"}),", then restart the deck.",e.reach.category==="Public"&&i.jsx(i.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."})]}),i.jsx("pre",{className:"ap-lan-cmd",children:i.jsx("code",{children:K.join(`
80
80
  `)})}),i.jsx("button",{type:"button",className:"ap-manage-btn",...F("copy:fix"),onClick:()=>void A(K.join(`
81
- `),"fix"),title:"Copy these lines, then paste them into an elevated PowerShell",children:y==="fix"?"copied":"copy command"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"By address"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{ref:a,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:c,placeholder:"192.168.1.5:54340",spellCheck:!1,...O("addr"),onChange:D=>{d(D.target.value),M("addr")},onKeyDown:D=>{D.key==="Enter"&&L()}}),c.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...F("add"),onClick:()=>void L(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),i.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."})]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:["With an invite",!Q&&i.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...F("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:j==="invite:make"?"making…":"make one to send"})]}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:h,placeholder:"paste one you were sent",spellCheck:!1,...O("join"),onChange:D=>{p(D.target.value),x(null),M("join")},onKeyDown:D=>{D.key==="Enter"&&B()}}),h.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...F("join"),onClick:()=>void B(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:j==="join"?"joining…":"join"})]}),i.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),S&&i.jsxs("div",{className:"ap-lan-tried",children:[i.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),S.map(D=>i.jsxs("span",{className:"ap-lan-tried-row",children:[i.jsx("code",{className:"ap-lan-code",children:D.addr}),i.jsx("span",{className:"ap-lan-bad",children:D.why})]},D.addr))]}),Q&&i.jsxs("div",{className:"ap-lan-invite",children:[i.jsxs("div",{className:"ap-lan-invite-head",children:[i.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),i.jsxs("span",{className:"ap-lan-invite-left",children:[Q6(Q.expiresAt,N)," left"]})]}),i.jsx("code",{className:"ap-lan-token",children:Q.token}),i.jsxs("div",{className:"ap-lan-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...F("copy:invite"),onClick:()=>void A(Q.token,"invite"),title:"Copy it, and send it however you already talk to them",children:y==="invite"?"copied":"copy"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...F("invite:withdraw"),onClick:()=>void H("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),i.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})})}function F6(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}".`}const B6=1e3;function z6(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=as(e,t);return`${n} · ${s==="now"?"just now":s}`}function U6(){return i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),i.jsx("path",{d:"M8.4 3.6l2 2"})]})}function W6({row:e,source:t,status:n,accounts:s,now:a,busy:l,onClose:c,onRename:d,onCheck:h,onVerb:p,onSettings:f}){var ke,je,Ye,it;const m=b.useRef(null),y=Ht(c,{focusRef:m}),[v,j]=b.useState(null),[_,S]=b.useState(null),[x,N]=b.useState(!1),E=b.useRef(0),[C,R]=b.useState(!1),[I,$]=b.useState(!1),F=b.useRef(null),O=b.useRef(!0);b.useEffect(()=>()=>{O.current=!1},[]);const M=v!=null;b.useEffect(()=>{var Ne;M&&((Ne=F.current)==null||Ne.select())},[M]),b.useEffect(()=>{if(!x)return;const Ne=window.setTimeout(()=>N(!1),4e3);return()=>window.clearTimeout(Ne)},[x]);const L=Ne=>{const He=Ks(l,Ne);return{disabled:He.disabled,"aria-busy":He.busy}},H=async Ne=>{const He=await Ne();return O.current&&S(He),He==null},{peer:B,stranger:A}=t,Q=e.kind==="paired",K=e.self??e.name,ee=e.kind!=="dialling",Z=e.kind==="dialling"?null:e.fp,D=B?B.addr?`${B.addr}:${B.port}`:"":A?A.port?`${A.addr}:${A.port}`:A.addr:e.addr,Y=(B==null?void 0:B.about)??null,P=((ke=n.about)==null?void 0:ke.version)??null,G=async Ne=>{const He=Ne.trim()===K?"":Ne;await H(()=>d(He))&&j(null)},de=async()=>{if(Z)try{if(await navigator.clipboard.writeText(Z),!O.current)return;R(!0),window.setTimeout(()=>{O.current&&R(!1)},1600)}catch{O.current&&S("Could not copy it — select the fingerprint and copy it by hand.")}},W=Q?B!=null&&B.waiting?B.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":B!=null&&B.offers?"not said — it runs an older version":"not reached yet":"shown once paired",U=(()=>{if(!(Y!=null&&Y.version))return null;const Ne=P?sq(Y.version,P):null;return Ne==null?Y.version:Ne===0?`${Y.version} · same as this deck`:`${Y.version} · ${Ne<0?"older":"newer"} than this deck's ${P}`})(),J=B?M2(B.last,a):null,V=(je=B==null?void 0:B.last)!=null&&je.error&&J&&J.text!==B.last.error?B.last.error:null,ie=((Ye=B==null?void 0:B.last)==null?void 0:Ye.done)??[],pe=[];pe.push({label:"Address",value:D?i.jsx("code",{className:"ap-lan-code",children:D}):"none here — it calls this deck",tone:D?void 0:"quiet"}),pe.push({label:"Reached",value:B?B.waiting?"it calls this deck · one-way":B.manual?"by an address added here":"found on this network":e.kind==="nearby"?"heard on this network":"asked this deck to pair"}),e.kind!=="dialling"&&(pe.push({label:"Paired",value:Q?B!=null&&B.pairedAt?z6(B.pairedAt,a):"before this deck kept the date":e.kind==="declined"&&A?`no · you said no ${xx(A.at,a)}`:"not yet",tone:Q&&!(B!=null&&B.pairedAt)?"quiet":"meta"}),Y?(pe.push({label:"Deck",value:U??"not said",tone:U?"meta":"quiet"}),pe.push({label:"System",value:Y.os?[Y.os,Y.arch].filter(Boolean).join(" · "):"not said",tone:Y.os?"meta":"quiet"})):pe.push({label:"Version, OS",value:W,tone:"quiet"})),pe.push({label:"Fingerprint",value:Z?i.jsxs("span",{className:"lan-fp",children:[i.jsx("code",{className:"ap-lan-code",children:Z}),i.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void de(),"aria-label":C?"Fingerprint copied":"Copy the fingerprint",children:C?"copied":"copy"})]}):"not known — nothing has answered there",tone:Z?void 0:"quiet"}),(Q||e.kind==="dialling")&&pe.push({label:"Last round",value:J?i.jsxs(i.Fragment,{children:[J.text.replace(/ · now$/," · just now"),V&&i.jsx("span",{className:"lan-fact-raw",children:V}),ie.length>0&&i.jsx("ul",{className:"lan-done",children:ie.map(Ne=>i.jsxs("li",{"data-ok":Ne.ok,children:[Ne.email," ",i.jsx("span",{className:"lan-done-what",children:Ne.ok?"arrived":"did not arrive"})]},`${Ne.email}:${Ne.action}`))})]}):"not asked yet",tone:(J==null?void 0:J.tone)==="bad"?"bad":J?void 0:"quiet"});const me=new Map(s.map(Ne=>[Ne.key,Ne])),Ie=new Set(n.shared??[]),Le=(n.shared??[]).map(Ne=>me.get(Ne)).filter(Ne=>!!Ne),ce=Le.filter(Ne=>!Ne.alive),xe=Le.length-ce.length,ye=(B==null?void 0:B.offers)??null,ze=ye&&(B!=null&&B.last)&&B.last.at-ye.at>B6?as(ye.at,a):null;return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:y,className:"modal lan-peer","data-tone":e.tone,onClick:Ne=>Ne.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[i.jsxs("header",{className:"modal-head lan-peer-head",children:[i.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsxs("div",{className:"lan-peer-id",children:[M?i.jsxs("form",{className:"lan-peer-edit",onSubmit:Ne=>{Ne.preventDefault(),G(v??"")},children:[i.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),i.jsx("input",{ref:F,className:"ap-manage-input lan-peer-input",value:v??"",maxLength:48,placeholder:K,"aria-label":"Name for this deck, shown on this deck only",onChange:Ne=>j(Ne.target.value)}),i.jsx("button",{type:"submit",className:"ap-manage-btn",...L(`alias:${e.fp}`),children:"save"}),i.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>j(null),children:"cancel"})]}):i.jsxs("span",{className:"lan-peer-title",children:[i.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),ee&&i.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{S(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:i.jsx(U6,{})})]}),i.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&i.jsxs(i.Fragment,{children:["calls itself ",i.jsx("span",{className:"lan-peer-self",children:e.self}),M&&i.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...L(`alias:${e.fp}`),onClick:()=>void G(""),children:"use this name"}),i.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&i.jsx("span",{"aria-hidden":!0,children:" · "})]}),i.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{ref:m,type:"button",className:"glyph-btn",onClick:c,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:_}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>S(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Connection"}),i.jsx("dl",{className:"lan-facts",children:pe.map(Ne=>i.jsxs("div",{className:"lan-fact","data-tone":Ne.tone,children:[i.jsx("dt",{children:Ne.label}),i.jsx("dd",{children:Ne.value})]},Ne.label))}),(B==null?void 0:B.waiting)&&i.jsx("p",{className:"lan-note",children:e.hint})]}),Q&&i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:["From ",e.name]}),ze&&i.jsxs("p",{className:"lan-stale",children:["Last told us ",ze==="now"?"just now":ze," — the last round did not get through, so this may have changed."]}),B!=null&&B.waiting?i.jsx("p",{className:"lan-empty",children:"Not known. This deck never asks it — it calls in — so what it offers only shows once this deck can reach it."}):ye?ye.accounts.length===0?i.jsx("p",{className:"lan-empty",children:"Nothing. Nobody at that deck has chosen a login to share."}):i.jsx("ul",{className:"lan-offers",role:"list",children:ye.accounts.map(Ne=>{const He=aq(Ne,me.get(Ne.key)??null,Ie.has(Ne.key));return i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":He.tone,children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there",children:He.there}),i.jsx("span",{className:"lan-offer-here",children:He.here}),He.note&&i.jsx("span",{className:"lan-offer-note",children:He.note})]},Ne.key)})}):i.jsx("p",{className:"lan-empty",children:(it=B==null?void 0:B.last)!=null&&it.error?"Not known — the last attempt to ask it did not get through.":"Not asked yet. The next round asks it."})]}),Q&&i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"From this deck"}),Le.length===0?i.jsx("p",{className:"lan-empty",children:"Nothing. No login on this deck is chosen to share."}):i.jsxs(i.Fragment,{children:[ce.length>0&&i.jsx("ul",{className:"lan-offers",role:"list",children:ce.map(Ne=>i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":"bad",children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there"}),i.jsx("span",{className:"lan-offer-here",children:"expired here"}),i.jsx("span",{className:"lan-offer-note",children:"offered to every paired deck and gives them nothing — sign in again"})]},Ne.key))}),xe>0&&i.jsxs("button",{type:"button",className:"ap-lan-word lan-more","aria-expanded":I,onClick:()=>$(Ne=>!Ne),children:[xe===1?"1 login works here":`${xe} logins work here`,i.jsx("span",{className:"lan-more-mark","aria-hidden":!0,children:I?"−":"+"})]}),I&&xe>0&&i.jsx("ul",{className:"lan-offers",role:"list",children:Le.filter(Ne=>Ne.alive).map(Ne=>i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":"ok",children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there"}),i.jsx("span",{className:"lan-offer-here",children:"works here"})]},Ne.key))})]}),i.jsx("p",{className:"lan-scope",children:"Every paired deck gets this list, the ones here now and any paired later."}),i.jsx("button",{type:"button",className:"ap-lan-word lan-peer-settings",onClick:f,children:"Change what this deck offers"})]})]}),i.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&i.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),Q&&!(B!=null&&B.waiting)&&i.jsx("button",{type:"button",className:"btn",...L(`check:${e.fp}`),onClick:()=>void H(h),title:"Ask this deck now instead of waiting for the next round",children:l===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&i.jsx("button",{type:"button",className:`btn danger lan-peer-verb${x?" armed":""}`,...L(`unpair:${e.fp}`),onKeyDown:Ne=>{Ne.repeat&&Ne.preventDefault()},onClick:()=>{if(!x){N(!0),E.current=Date.now();return}Date.now()-E.current<$2||(N(!1),H(p))},"aria-label":x?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:x?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:l===`unpair:${e.fp}`?"Unpairing…":x?"Unpair — sure?":"Unpair"}),e.kind==="nearby"&&i.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...L(`accept:${e.fp}`),onClick:()=>void H(p),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:l===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...L(`drop:${e.fp}`),onClick:()=>void H(p),title:"Stop trying this address. Nothing was ever paired here.",children:l===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...L(`allow:${e.fp}`),onClick:()=>void H(p),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:l===`allow:${e.fp}`?"Allowing…":"Let it ask again"})]})]})})}function H6({status:e,accounts:t,onClose:n,onChanged:s}){const a=Ht(n),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),m=b.useRef(null),y=C=>{const R=Ks(p,C);return{disabled:R.disabled,"aria-busy":R.busy}},v=b.useRef(null),j=b.useRef(!0);b.useEffect(()=>()=>{j.current=!1},[]),b.useEffect(()=>{v.current&&X6(v.current,e.shared??[])&&(v.current=null)},[e.shared]);const _=b.useCallback(async(C,R,I="write")=>{m.current=I,f(I);try{const F=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:C})})).json().catch(()=>null);return j.current?(F!=null&&F.ok?h(null):h(Lt(R,F)),s(),(F==null?void 0:F.ok)===!0):!1}catch{return j.current&&h(Lt(R,null)),!1}finally{m.current=null,j.current&&f(null)}},[s]),S=b.useCallback(async()=>{if(l!=null&&l!==(e.name??"")){if(!await _({name:l},"save the name","name"))return;j.current&&c(null)}n()},[l,e.name,_,n]),x=new Set(v.current??e.shared??[]),N=e.autoAsk!==!1,E=e.autoAccept!==!1;return i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal lan-modal",onClick:C=>C.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[d&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:d}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>h(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Name"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("span",{className:"ap-lan-label",children:"appear as"}),i.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:C=>c(C.target.value),onKeyDown:C=>{C.key!=="Enter"||l==null||(_({name:l},"save the name","name"),c(null))}}),l!=null&&l!==(e.name??"")&&i.jsx("button",{type:"button",className:"ap-manage-btn",...y("name"),onClick:()=>{_({name:l},"save the name","name"),c(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Share these accounts"}),i.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&i.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(C=>i.jsxs("label",{className:"ap-lan-pick",title:C.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[i.jsx("input",{type:"checkbox",checked:x.has(C.key),onChange:R=>{const I=new Set(v.current??e.shared??[]);R.target.checked?I.add(C.key):I.delete(C.key),v.current=[...I],_({shared:[...I]},R.target.checked?"share that account":"stop sharing that account")}}),i.jsx("span",{className:"ap-lan-pick-name",children:C.email}),!C.alive&&i.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},C.key))]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Pairing"}),i.jsxs("div",{className:"lan-switches",children:[i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),i.jsx("button",{type:"button",className:`ap-auto-state${N?" live":""}`,role:"switch","aria-checked":N,"aria-label":"Ask every deck this one finds",...y("ask"),onClick:()=>void _({autoAsk:!N},N?"stop asking automatically":"ask every deck this one finds","ask"),title:N?"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."})]}),i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),i.jsx("button",{type:"button",className:`ap-auto-state${E?" live":""}`,role:"switch","aria-checked":E,"aria-label":"Say yes to every deck that asks",...y("accept"),onClick:()=>void _({autoAccept:!E},E?"stop accepting automatically":"accept every deck that asks","accept"),title:E?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here."})]})]}),E?null:N?i.jsx("p",{className:"lan-note",children:"This deck asks; somebody on the other machine still has to say yes. A request coming the other way waits in the panel for you."}):i.jsxs("p",{className:"lan-note",children:["Nothing pairs on its own. You press ",i.jsx("strong",{children:"ask"})," on a deck you find, and ",i.jsx("strong",{children:"accept"})," on one that asks. A deck you said no to is never asked about again either way."]})]})]}),i.jsxs("footer",{className:"lan-setup-foot",children:[i.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),i.jsx("button",{type:"button",className:"btn primary",...y("name"),onClick:()=>void S(),children:"Done"})]})]})})}function as(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 vx={"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"}},G6={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 V6(e){var s;const t=Y6[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&G6[n]||e}const Y6={"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 M2(e,t){if(!e)return null;if(e.error)return vx[e.error]??{text:V6(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${as(e.at,t)}`,tone:"idle"};const s=n.filter(l=>l.ok),a=s.length===1?"login":"logins";return s.length===n.length?{text:`${s.length} ${a} arrived · ${as(e.at,t)}`,tone:"ok"}:{text:`${s.length} of ${n.length} logins arrived · ${as(e.at,t)}`,tone:"bad"}}const Iv=5e3,I2=6e4,$2=400;function K6(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 Lt(e,t){return t==null?`Could not ${e} — the deck did not answer.`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}function X6(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Q6(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function O2(e,t){var n,s;return(n=e.last)!=null&&n.error&&!vx[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<cd||e.lastSeen!=null&&t-e.lastSeen<cd)}const cd=95e3;function Z6(e,t){const n=[],s=[];for(const a of e??[])(O2(a,t)?n:s).push(a);return{online:n,offline:s}}function J6(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(v=>v.paired!==!1||v.met);if(!s.length)return{text:"no deck paired yet",tone:"idle"};const a=s.filter(v=>v.waiting),l=s.filter(v=>!v.waiting),c=a.filter(v=>{var j;return!((j=v.last)!=null&&j.error)&&v.lastSeen!=null&&t-v.lastSeen<cd}),{online:d,offline:h}=Z6(l,t),p=[...h,...a.filter(v=>!c.includes(v))],f=d.length+c.length,m=d.filter(v=>{var j;return((j=v.last)==null?void 0:j.error)==="waiting for the other deck to accept this one"});if(f&&m.length===f)return{text:f===1?"1 deck found · waiting for them to accept":`${f} decks found · waiting for them to accept`,tone:"wait"};if(!f)return{text:p.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${p.length} decks`,tone:"bad"};const y=f===1?"1 deck ready":`${f} decks ready`;return{text:p.length?`${y} · ${p.length} away`:y,tone:"ok"}}function eq(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=as(e,t);return s==="now"?"checked just now":`checked ${s}`}function xx(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 tq(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=t-e<cd;return{text:n?"online · one-way, it calls in":`one-way · last online ${as(e,t)}`,here:n}}function j1(e,t,n){return t?"online":e.lastSeen!=null?`last online ${as(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function nq(e,t){var y,v,j,_,S;if(!e)return[];const n=[],s=new Set,a=(x,N)=>x.name.localeCompare(N.name,void 0,{numeric:!0}),l=e.aliases??{},c=(x,N)=>{const E=x?l[x]:void 0;return E&&E!==N?{name:E,self:N}:{name:N}};for(const x of e.pending??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);n.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.addr??"",kind:"asks",state:`wants to pair · ${xx(x.at,t)}`,tone:"wait",here:!0,hint:`${N.name} at ${x.addr} is waiting for an answer.`})}const d=[],h=[];for(const x of e.peers??[]){const N=x.peerFp??x.fp;if(!N||s.has(N))continue;s.add(N);const E=M2(x.last,t),C=O2(x,t),R=x.addr?`${x.addr}:${x.port}`:"";if(!x.paired&&x.manual&&!x.met){h.push({fp:R,name:R||x.name||N,addr:x.addr??"",kind:"dialling",state:E?E.text.replace(/ · .*$/,""):"trying…",tone:E?E.tone:"idle",here:!1,hint:(y=x.last)!=null&&y.error?`Nothing has answered at ${R} yet — ${x.last.error}.`:`Dialling ${R} until something answers.`});continue}const I=x.waiting?tq(x.lastSeen,t):null,$=I?I.here:C,F=!I&&E?$?`online · ${E.text.replace(/ · .*$/,"")}`:`${E.text.replace(/ · .*$/,"")} · ${j1(x,$,t)}`:I?I.text:j1(x,$,t),O=(v=x.last)!=null&&v.error?vx[x.last.error]:null,M=!I&&$&&!((j=x.last)!=null&&j.error)&&!(((_=x.last)==null?void 0:_.done)??[]).length,L=x.manual&&!x.met?{name:R}:c(N,x.name||N);d.push({fp:N,name:L.name,...L.self?{self:L.self}:{},addr:x.addr??"",kind:"paired",state:F,quiet:M,tone:O?O.tone==="bad"?"bad":"wait":E?E.tone:$?"ok":"idle",here:I?I.here:C,hint:I?`${L.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. ${x.lastSeen==null?"It has not called since this deck started.":`It last called ${as(x.lastSeen,t)}.`} Add its address with the + at the top of this section to reach it either way.`:`${L.name}${R?` at ${R}`:""}${(S=x.last)!=null&&S.error?` — ${x.last.error}`:""}`})}n.push(...d.sort(a),...h.sort(a));const p=[];for(const x of e.strangers??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);p.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.addr??"",kind:"nearby",state:"not paired yet",tone:"idle",here:!0,hint:`${N.name} at ${x.addr} is on this network and nothing is shared with it.`})}n.push(...p.sort(a));const f=[];for(const x of e.declined??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);f.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.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.`})}n.push(...f.sort(a));const m=new Map;for(const x of n)m.set(x.name,(m.get(x.name)??0)+1);for(const x of n)(m.get(x.name)??0)<2||!x.addr||(x.state=x.quiet||!x.state?x.addr:`${x.addr} · ${x.state}`,x.quiet=!1);return n}function E1(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function rq(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 sq(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 l=Number(n[a])-Number(s[a]);if(l)return Math.sign(l)}return 0}function aq(e,t,n){const s=t?t.alive?"works here":"expired here":"not on this deck";if(!e.alive){const a=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:a,tone:a?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:"ok"}:n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"share it to repair",tone:"bad"}:{there:"works there",here:s,note:"arrives next round",tone:"wait"}}async function Ho(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function oq({accounts:e,onChanged:t}){const[n,s]=b.useState(null),[a,l]=b.useState([]),[c,d]=b.useState(null),[h,p]=b.useState(!1),[f,m]=b.useState(null),y=b.useRef(0),[v,j]=b.useState(!1),[_,S]=b.useState(!1),[x,N]=b.useState(!1),[E,C]=b.useState(null),R=b.useRef(null),I=b.useCallback(ce=>Nd(R.current)?(R.current=ce,d(ce),!0):!1,[]),$=b.useCallback(()=>{R.current=null,L.current&&d(null)},[]),F=ce=>{const xe=Ks(c,ce);return{disabled:xe.disabled,"aria-busy":xe.busy}},[O,M]=b.useState(()=>Date.now()),L=b.useRef(!0),H=b.useRef(Iv),B=b.useCallback(async()=>{var ce,xe;try{const[ye,ze]=await Promise.all([fetch("/api/lan").then(ke=>ke.json()),fetch("/api/prefs").then(ke=>ke.json())]);if(!L.current)return;ye!=null&&ye.ok&&s(ye),ze!=null&&ze.ok&&l(Array.isArray((xe=(ce=ze.prefs)==null?void 0:ce.lan)==null?void 0:xe.manual)?ze.prefs.lan.manual:[]),H.current=(ye==null?void 0:ye.enabled)===!0?Iv:I2}catch{}},[]);b.useEffect(()=>{L.current=!0;let ce=0;const xe=async()=>{M(Date.now()),await B(),L.current&&(ce=window.setTimeout(xe,H.current))};return xe(),()=>{L.current=!1,window.clearTimeout(ce)}},[B]);const A=b.useCallback(async()=>{const ce=(n==null?void 0:n.enabled)===!0;if(I("switch"))try{const xe=await Ho("/api/prefs",{lan:{enabled:!ce}});if(!L.current)return;xe!=null&&xe.ok?(C(null),ce||p(!0)):C(Lt(ce?"turn this off":"turn this on",xe)),await B()}catch{L.current&&C(Lt(ce?"turn this off":"turn this on",null))}finally{$()}},[n==null?void 0:n.enabled,B,I,$]),Q=b.useCallback(async(ce,xe,ye)=>{if(!I(`${ce}:${xe}`))return null;let ze=null;try{const ke=await Ho("/api/lan/peer",{action:ce,fp:xe});if(!L.current)return null;ke!=null&&ke.ok?(s(ke),C(null)):(ze=Lt(ye,ke),C(ze)),await B()}catch{ze=Lt(ye,null),L.current&&C(ze)}finally{$()}return ze},[B,I,$]),K=b.useCallback(async ce=>{if(!I(`drop:${ce}`))return null;let xe=null;try{const ye=await Ho("/api/prefs",{lan:{manual:a.filter(ze=>ze!==ce)}});if(!L.current)return null;ye!=null&&ye.ok?(C(null),t()):(xe=Lt("stop dialling that address",ye),C(xe)),await B()}catch{xe=Lt("stop dialling that address",null),L.current&&C(xe)}finally{$()}return xe},[a,B,t,I,$]),[ee,Z]=b.useState(null),D=b.useCallback(async(ce,xe)=>{if(!I(`alias:${ce}`))return"Something else is still being saved. Try again in a moment.";try{const ye=await Ho("/api/lan/peer",{action:"alias",fp:ce,name:xe});return L.current?ye!=null&&ye.ok?(s(ye),null):Lt("rename that deck",ye):null}catch{return Lt("rename that deck",null)}finally{$()}},[I,$]),Y=b.useCallback(async ce=>{if(!I(`check:${ce}`))return null;try{const xe=await Ho("/api/lan/sync",{fp:ce});return L.current?xe!=null&&xe.ok?(s(xe),t(),null):(xe==null?void 0:xe.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.":Lt("check that deck",xe):null}catch{return Lt("check that deck",null)}finally{$()}},[I,$,t]),P=b.useCallback(async()=>{if(I("check"))try{const ce=await Ho("/api/lan/sync",{});if(!L.current)return;ce!=null&&ce.ok?(s(ce),C(null)):C(Lt("check the other decks",ce)),t()}catch{L.current&&C(Lt("check the other decks",null))}finally{$()}},[I,$,t]),G=(n==null?void 0:n.enabled)===!0,de=nq(n,O),W=ee?de.find(ce=>ce.fp===ee)??null:null;b.useEffect(()=>{ee&&n&&!W&&Z(null)},[ee,n,W]);const U=de.filter(ce=>ce.kind==="asks"),J=de.filter(ce=>ce.kind!=="asks"),V=J.filter(ce=>ce.here),ie=J.filter(ce=>!ce.here),pe=ie.filter(ce=>ce.tone==="bad").length,me=x||V.length===0,Ie=J6(n,O),Le=J.filter(ce=>ce.kind==="paired").length;return i.jsxs("div",{className:"ap-auto ap-lan",children:[i.jsxs("div",{className:"ap-auto-head",children:[i.jsx("h3",{className:"ap-auto-title",children:"Local network"}),G&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>j(!0),"aria-label":"Add a deck",title:"Reach a deck that has not turned up on its own — by address, or with an invite",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),G&&Le>0&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...F("check"),onClick:()=>void P(),"aria-label":c==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),i.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),G&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...F("setup"),onClick:()=>p(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),i.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),i.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),i.jsx("button",{type:"button",className:`ap-auto-state${G?" live":""}`,role:"switch","aria-checked":G,"aria-label":"Local network sync",...F("switch"),onClick:()=>void A(),title:G?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins"})]}),!G&&i.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>S(!0),title:"Four pictures: what this does, and what to do on each machine",children:[i.jsx(P6,{}),i.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),i.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),i.jsx("p",{className:`ap-lan-status ${Ie.tone}`,role:"status",children:Ie.tone==="ok"?"":Ie.text}),E&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:E}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>C(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),G&&i.jsxs(i.Fragment,{children:[U.length>0&&i.jsx("div",{className:"ap-lan-asks",role:"alert",children:U.map(ce=>i.jsxs("div",{className:"ap-lan-ask",children:[i.jsxs("span",{className:"ap-lan-ask-what",children:[i.jsx("strong",{className:"ap-lan-peer-name",children:ce.name})," at ",i.jsx("code",{className:"ap-lan-code",children:ce.addr})," wants to pair"]}),i.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",i.jsx("code",{className:"ap-lan-code",children:ce.fp})]}),i.jsxs("span",{className:"ap-lan-ask-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...F(`accept:${ce.fp}`),onClick:()=>void Q("accept",ce.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${ce.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...F(`dismiss:${ce.fp}`),onClick:()=>void Q("dismiss",ce.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},ce.fp))}),(me?[...V,...ie]:V).length>0&&i.jsx("ul",{className:"ap-lan-here",children:(me?[...V,...ie]:V).map((ce,xe)=>i.jsxs("li",{className:"ap-lan-who","data-tone":ce.tone,children:[i.jsx("i",{className:ce.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsx("span",{className:"ap-lan-who-name","aria-hidden":!0,children:ce.name}),i.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${xe}`,onClick:()=>Z(ce.fp),children:i.jsxs("span",{className:"vis-hidden",children:[ce.name,", details"]})}),i.jsx("span",{id:`lan-who-state-${xe}`,className:ce.quiet?"vis-hidden":"ap-lan-who-when",children:ce.state}),ce.kind==="nearby"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`accept:${ce.fp}`),onClick:()=>void Q("accept",ce.fp,"reach that deck"),"aria-label":`Ask ${ce.name} to pair`,title:`Send ${ce.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${ce.fp}.`,children:"ask"}),ce.kind==="paired"&&i.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${f===ce.fp?" armed":""}`,...F(`unpair:${ce.fp}`),onClick:()=>{if(f!==ce.fp){m(ce.fp),y.current=Date.now(),window.setTimeout(()=>m(ye=>ye===ce.fp?null:ye),4e3);return}Date.now()-y.current<$2||(m(null),Q("unpair",ce.fp,"unpair that deck"))},"aria-label":f===ce.fp?`Confirm unpairing ${ce.name}`:`Unpair ${ce.name}`,title:f===ce.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:f===ce.fp?"sure?":"unpair"}),ce.kind==="dialling"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`drop:${ce.fp}`),onClick:()=>void K(ce.fp),"aria-label":`Stop dialling ${ce.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),ce.kind==="declined"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`allow:${ce.fp}`),onClick:()=>void Q("allow",ce.fp,"let that deck ask again"),"aria-label":`Let ${ce.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${ce.kind}:${ce.fp}`))}),(V.length>0&&ie.length>0||G&&Le>0)&&i.jsxs("div",{className:"ap-lan-tail",children:[V.length>0&&ie.length>0&&i.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":x,onClick:()=>N(ce=>!ce),title:x?"Show only the decks that are on":`Show the ${ie.length} deck${ie.length===1?"":"s"} that are not answering right now`,children:[i.jsx("span",{className:`ap-lan-chev${x?" open":""}`,"aria-hidden":!0,children:"›"}),x?"fewer":`${ie.length} more`,!x&&pe>0&&i.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",pe," not answering"]})]}),G&&Le>0&&i.jsx("span",{className:"ap-lan-checked",children:eq(n==null?void 0:n.checkedAt,O,c==="check")})]}),J.length===0&&U.length===0&&i.jsxs(i.Fragment,{children:[i.jsxs("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, ",i.jsx("strong",{children:"+"})," at the top of this section reaches one by address or by invite."]}),i.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>S(!0),children:"How it works"})]})]}),v&&n&&i.jsx(q6,{status:n,manual:a,onClose:()=>j(!1),onChanged:()=>{B(),t()}}),_&&i.jsx(A2,{title:"How Local network works",steps:O6,finish:G?void 0:{label:"Turn it on",act:()=>{S(!1),A()}},onClose:()=>S(!1)}),h&&n&&i.jsx(H6,{status:{...n,manualRows:a},accounts:e,manual:a,onClose:()=>p(!1),onChanged:()=>{B(),t()}}),W&&n&&i.jsx(W6,{row:W,source:rq(n,W),status:n,accounts:e,now:O,busy:c,onClose:()=>Z(null),onRename:ce=>D(W.fp,ce),onCheck:()=>Y(W.fp),onVerb:()=>{switch(W.kind){case"paired":return Q("unpair",W.fp,"unpair that deck");case"nearby":return Q("accept",W.fp,"reach that deck");case"declined":return Q("allow",W.fp,"let that deck ask again");case"dialling":return K(W.fp);default:return Promise.resolve(null)}},onSettings:()=>{Z(null),p(!0)}})]})}const C1=15e3,iq=8e3,Lf=1800,lq=3e4,cq=[70,80,85,90,95];function T1(e,t){return v2(t-Math.floor(e/1e3))}function uq(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 dq(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 hq(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 A1(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}function R1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",a=e.resetAt?x2(e.resetAt,t):null;return i.jsxs("div",{className:"ap-lane",children:[i.jsx("span",{className:"ap-lane-label",children:e.label}),i.jsx("div",{className:"ap-lane-track",children:i.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),i.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),i.jsx("span",{className:"ap-lane-reset",children:a?`resets ${a}`:""})]})}async function M1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function fq({onClose:e,leaving:t}){var Se,Fe,et,xt,ht;const[n,s]=b.useState(null),[a,l]=b.useState(null),[c,d]=b.useState(null),[h,p]=b.useState(!1),[f,m]=b.useState(null),[y,v]=b.useState(()=>Math.floor(Date.now()/1e3)),j=b.useRef(null),[_,S]=b.useState(null),[x,N]=b.useState(!1),[E,C]=b.useState(""),[R,I]=b.useState(null),[$,F]=b.useState(null),[O,M]=b.useState(null),[L,H]=b.useState(!1),[B,A]=b.useState(!1),[Q,K]=b.useState(null),[ee,Z]=b.useState(null),[D,Y]=b.useState(null),[P,G]=b.useState(null),[de,W]=b.useState(!1),[U,J]=b.useState([]),V=b.useRef(null),ie=b.useCallback(ne=>Nd(V.current)?(V.current=ne,d(ne),!0):!1,[]),pe=b.useCallback(()=>{V.current=null,d(null)},[]),me=(ne,De=!1)=>{const Oe=Ks(c,ne);return{disabled:Oe.disabled,"aria-busy":Oe.busy||De}},Ie=b.useCallback(ne=>{window.requestAnimationFrame(()=>{var De;if(P5(((De=document.activeElement)==null?void 0:De.tagName)??null))for(const Oe of O5(ne)){const Te=document.querySelector(Oe);if(Te){Te.focus();return}}})},[]),Le=b.useCallback(async(ne=!1)=>{ne&&p(!0);const De=new AbortController,Oe=window.setTimeout(()=>De.abort(),lq);try{const[Te,Ce]=await Promise.all([fetch(`/api/claude-accounts${ne?"?refresh=1":""}`,{signal:De.signal}),fetch("/api/cswap-auto",{signal:De.signal})]);if(Te.ok){const ut=await Te.json();s(ut),J(Re=>y6(Re,ut.accounts))}Ce.ok&&l(await Ce.json());const lt=b6([await x1(Te),await x1(Ce)]);m(ut=>b1(ut,lt))}catch{m(Te=>b1(Te,x6))}finally{window.clearTimeout(Oe),ne&&p(!1)}},[]),ce=b.useCallback(async(ne,De)=>{if(!ie(De))return null;m(null);try{const Te=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)})).json().catch(()=>null);return Te!=null&&Te.ok||m({text:Av(Te,"command failed"),raw:oi(Te)}),Te}catch{return m({text:"server unreachable"}),null}finally{pe()}},[ie,pe]),xe=b.useCallback(async(ne,De)=>{if(!ie(De))return null;m(null);try{const Te=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)})).json().catch(()=>null);return Te!=null&&Te.ok||m({text:Ko(Te,"command failed")}),Te}catch{return m({text:"server unreachable"}),null}finally{pe()}},[ie,pe]);b.useEffect(()=>(Le(!0),j.current=window.setInterval(()=>Le(!1),C1),()=>{j.current!=null&&window.clearInterval(j.current)}),[Le]),b.useEffect(()=>{const ne=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ne)},[]);const ye=((Se=a==null?void 0:a.settings["autoswitch.threshold"])==null?void 0:Se.value)??"90",ze=P??ye,ke=h6(ze,ye),je=(Fe=n==null?void 0:n.accounts)==null?void 0:Fe.find(ne=>ne.active),Ye=((et=v1((je==null?void 0:je.lanes)??[]).peak)==null?void 0:et.pct)??null,it=Ye!=null&&Ye>=Number(ye)-15,Ne=async ne=>{if(ie(`switch-${ne}`)){m(null);try{const Oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ne})})).json().catch(()=>null);Oe!=null&&Oe.ok||m({text:Av(Oe,"the switch failed"),raw:oi(Oe)}),await Le(!0)}catch{m({text:"server unreachable"})}finally{pe(),Ie(ne)}}},He=async(ne,De)=>{const{commit:Oe,alias:Te}=v6(E,De);if(Oe){const Ce=await xe({action:"alias",account:ne,alias:Te},`alias-${ne}`);if(await Le(!0),!(Ce!=null&&Ce.ok))return;C(Te)}I(ne),window.setTimeout(()=>I(Ce=>Ce===ne?null:Ce),Lf)},Xe=async(ne,De)=>{const Oe=await xe({action:"move",account:ne,slot:De},`move-${ne}`),Te=c6({menuFor:_,shareFor:(O==null?void 0:O.num)??null},ne,Oe);if(await Le(!0),Te){S(Te.menuFor),F(Te.confirmRemove),Te.shareFor==null&&(M(null),A(!1)),K(Te.swapNote);const Ce=Te.swapNote;Ce&&window.setTimeout(()=>K(lt=>lt===Ce?null:lt),iq),Z(null),Ie(Te.menuFor)}return Oe},he=async(ne,De,Oe)=>{if(Oe.sends){const Te=await Xe(ne,De);if(!(Te!=null&&Te.ok))return}Y(ne),window.setTimeout(()=>Y(Te=>Te===ne?null:Te),Lf)},ge=async(ne,De)=>{if(De.sends){const Oe=await ce({action:"setting",key:"autoswitch.threshold",value:ne},"threshold");if(await Le(!0),!(Oe!=null&&Oe.ok))return;G(null)}W(!0),window.setTimeout(()=>W(!1),Lf)};return i.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",children:[i.jsxs("div",{className:"ap-header",children:[i.jsx("h2",{children:"Claude accounts"}),i.jsxs("div",{className:"ap-header-right",children:[i.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>N(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),(((xt=n==null?void 0:n.accounts)==null?void 0:xt.length)??0)>0&&i.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>H(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Wt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),i.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),i.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Le(!0),...me("reload",h),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),i.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})})]})]}),n==null?f?i.jsxs("div",{className:"ap-empty",role:"alert",children:[i.jsx("span",{title:f.raw||void 0,children:f.text}),i.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",C1/1e3," seconds."]}),i.jsx("button",{type:"button",className:"ap-fix",disabled:h,onClick:()=>Le(!0),children:h?"trying…":"try again"})]}):i.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"ap-list",children:(ht=n.accounts)==null?void 0:ht.map(ne=>{const{shown:De,rest:Oe,fuller:Te,peak:Ce}=v1(ne.lanes),lt=U.includes(gx(ne)),ut=f6(Oe.length,lt,Te);return i.jsxs("li",{className:`ap-account${ne.active?" active":""}`,children:[i.jsxs("div",{className:"ap-account-head",children:[i.jsx("span",{className:"ap-num",children:ne.num}),ne.alias&&i.jsx("span",{className:"ap-alias",title:ne.alias,children:ne.alias}),i.jsx("span",{className:"ap-email",title:ne.email??void 0,children:ne.email}),i.jsx("button",{type:"button",id:`ap-more-${ne.num}`,className:`ap-more${_===ne.num?" on":""}`,"aria-label":`Manage account ${ne.num}`,"aria-expanded":_===ne.num,"aria-controls":_===ne.num?`ap-manage-${ne.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(_===ne.num?null:ne.num),C(ne.alias??""),F(null),M(null),A(!1),K(null),I(null),Z(null),Y(null)},children:"⋯"}),ne.active&&i.jsx("span",{className:"ap-badge-active",children:"active"}),ne.disabled&&i.jsx("span",{className:"ap-badge-held",children:"held out"}),!ne.active&&!ne.disabled&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...me(`switch-${ne.num}`),onClick:()=>Ne(ne.num),title:`Switch to ${ne.alias??ne.email}`,children:c===`switch-${ne.num}`?"…":"switch"})]}),i.jsx("div",{className:"ap-lanes",id:`ap-lanes-${ne.num}`,children:De.length?i.jsxs(i.Fragment,{children:[De.map(Re=>i.jsx(R1,{lane:Re,nowSec:y},Re.id)),lt&&Oe.map(Re=>i.jsx(R1,{lane:Re,nowSec:y},Re.id))]}):i.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),i.jsxs("div",{className:"ap-meta",children:[ne.staleCopy&&(()=>{const Re=dq(ne.repair??null,y);return i.jsx("span",{className:"ap-stale-copy",title:Re.hint,children:Re.text})})(),ne.stopped&&(()=>{const Re=A1(ne.collector??null);return i.jsx("span",{className:"ap-stopped",title:(Re==null?void 0:Re.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.",children:(Re==null?void 0:Re.text)??"not collecting"})})(),ne.stopped&&(()=>{var mt;const Re=(mt=A1(ne.collector??null))==null?void 0:mt.fix;return Re?i.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account puts its login in this slot.",children:Re}):null})(),ne.error&&(()=>{const Re=hq(ne.error);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"ap-err",title:Re.hint,children:Re.text}),Re.fixable&&i.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),ut&&i.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":lt,"aria-controls":`ap-lanes-${ne.num}`,title:p6(ne.headroom,(Ce==null?void 0:Ce.label)??null,Oe.length,lt),onClick:()=>J(Re=>g6(Re,ne)),children:ut}),(((a==null?void 0:a.enabled)||(a==null?void 0:a.external))&&!ne.active||ne.disabled)&&i.jsx("button",{type:"button",className:"ap-rotate",...me(`rot-${ne.num}`),onClick:()=>ce({action:"account",account:ne.num,enabled:ne.disabled},`rot-${ne.num}`).then(()=>Le(!0)),title:ne.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:ne.disabled?"put back":"hold out"}),ne.fetchedAt?i.jsxs("span",{className:`ap-age${ne.stale&&!ne.stopped&&!ne.error?" 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 ",T1(ne.fetchedAt,y),uq(ne.nextAt,y)]}):i.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),_===ne.num&&i.jsxs("div",{className:"ap-manage",id:`ap-manage-${ne.num}`,role:"group","aria-label":`Manage account ${ne.num}`,children:[i.jsxs("div",{className:"ap-manage-name",children:[i.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${ne.num}`,children:"Alias"}),i.jsx("input",{id:`ap-alias-${ne.num}`,className:"ap-manage-input",type:"text",value:E,onChange:Re=>C(Re.target.value),onKeyDown:Re=>{Re.key==="Enter"&&He(ne.num,ne.alias)},maxLength:w6,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`alias-${ne.num}`),onClick:()=>He(ne.num,ne.alias),title:"A short name to show instead of the email",children:R===ne.num?"saved":"save"})]}),(()=>{const Re=l6((n.accounts??[]).map(bt=>bt.num),ne.num),mt=u6(Re,ee,ne.num),ft=d6(Re,mt,ne.num);return i.jsxs("div",{className:"ap-manage-slot",children:[i.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${ne.num}`,children:"Slot"}),i.jsx("span",{className:"ap-field",children:i.jsx("select",{id:`ap-slot-${ne.num}`,value:String(mt),...me(`move-${ne.num}`),onChange:bt=>Z(Number(bt.target.value)),children:Re.map(bt=>i.jsx("option",{value:bt.slot,children:bt.label},bt.slot))})}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`move-${ne.num}`),title:ft.title,onClick:()=>he(ne.num,mt,ft),children:D===ne.num?ft.done:ft.label})]})})(),i.jsxs("div",{className:"ap-manage-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ne.num}`),title:`Copy this account to another ${Wt}. 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:async()=>{A(!1);const Re=await xe({action:"share",account:ne.num},`share-${ne.num}`);Re!=null&&Re.ok&&M({num:ne.num,blob:Re.blob,expiresAt:Re.expiresAt})},children:"share"}),i.jsx("button",{type:"button",className:`ap-manage-btn danger${$===ne.num?" armed":""}`,...me(`rm-${ne.num}`),title:$===ne.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if($!==ne.num){F(ne.num),window.setTimeout(()=>F(Re=>Re===ne.num?null:Re),4e3);return}F(null),xe({action:"remove",account:ne.num},`rm-${ne.num}`).then(()=>{S(null),Le(!0),Ie(null)})},children:$===ne.num?"confirm":"remove"})]}),(Q==null?void 0:Q.at)===ne.num&&(()=>{var ft;const Re=(ft=n.accounts)==null?void 0:ft.find(bt=>bt.num===Q.displaced),mt=(Re==null?void 0:Re.alias)??(Re==null?void 0:Re.email)??"the account that was there";return i.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${Q.at} was taken, so the two accounts traded places: ${mt} now holds slot ${Q.displaced}.`,children:["swapped with slot ",Q.displaced]})})(),(O==null?void 0:O.num)===ne.num&&(()=>{const Re=T2(O.expiresAt,y),mt=Re.tone==="gone";return i.jsxs("div",{className:`ap-share${mt?" expired":""}`,children:[i.jsx("code",{className:"ap-share-blob",children:O.blob}),i.jsxs("div",{className:"ap-share-foot",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ne.num}`),onClick:async()=>{if(mt){A(!1);const ft=await xe({action:"share",account:ne.num},`share-${ne.num}`);ft!=null&&ft.ok&&M({num:ne.num,blob:ft.blob,expiresAt:ft.expiresAt});return}await M1(O.blob)&&(A(!0),window.setTimeout(()=>A(!1),1800))},children:mt?"make a new share":B?"copied":"copy"}),i.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[i.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",i.jsx("span",{className:`ap-share-expiry ${Re.tone}`,children:Re.text})]})]})]})})()]})]},ne.num)})}),(a==null?void 0:a.ok)&&i.jsxs("div",{className:"ap-auto",children:[i.jsxs("div",{className:"ap-auto-head",children:[i.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),i.jsxs("span",{className:"ap-auto-ctl",children:[Ye!=null&&i.jsxs("span",{className:`ap-auto-now${it?" near":""}`,title:`The active account has used ${Math.round(Ye)}% of its limit. Auto-switch trips at ${ye}%.`,children:[Math.round(Ye),"%"]}),i.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:i.jsx("select",{"aria-label":"Switch threshold",value:ze,...me("threshold"),onChange:ne=>G(ne.target.value),children:cq.map(ne=>i.jsxs("option",{value:ne,children:[ne,"%"]},ne))})}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me("threshold"),title:ke.title,onClick:()=>ge(ze,ke),children:de?ke.done:ke.label}),i.jsx("button",{type:"button",className:`ap-auto-state${a.enabled?" live":""}`,role:"switch","aria-checked":a.enabled,"aria-label":"Auto-switch",...me("enable"),onClick:()=>ce({action:"enable",enabled:!a.enabled},"enable").then(()=>Le(!0)),title:a.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit"})]})]}),a.external&&i.jsxs("p",{className:"ap-auto-note",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",i.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",a.enabled?" — this toggle takes over when you stop it.":"."]}),a.lastTick&&i.jsx("div",{className:"ap-auto-foot",children:i.jsxs("span",{className:"ap-auto-result",children:["checked ",T1(a.lastTick.at,y)]})})]}),f&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",title:f.raw||void 0,children:f.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"These numbers only update while this panel is open."}),i.jsx(oq,{accounts:((n==null?void 0:n.accounts)??[]).map(ne=>({key:`${String(ne.email??"").trim().toLowerCase()}@@${ne.orgUuid??""}`,email:ne.email??"",alive:ne.alive===!0})),onChanged:()=>Le(!0)})]}):i.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"claude-swap isn't installed."}),i.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&i.jsx("code",{className:"ap-cmd",children:n.hint}),i.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",i.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"No accounts added yet."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",i.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"Couldn't read the account store."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),x&&i.jsx(s6,{onClose:()=>N(!1),onChanged:()=>Le(!0)}),L&&i.jsx(i6,{accounts:((n==null?void 0:n.accounts)??[]).map(ne=>({num:ne.num,email:ne.email,alias:ne.alias,org:ne.org})),onClose:()=>H(!1),copyText:M1})]})}const pq=3e4;function mq({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function gq({bundle:e,running:t,pending:n,lastTried:s}){return t?mq({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function yq(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function wq({asked:e,reported:t}){return t?t!==e:!1}function P2(e){const t=e.thresholdMs??pq;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 vq(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 xq(e,t){return e?t==null?"auto when idle":`auto in ${vq(t)}`:"auto-restart off"}function I1(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function bq(e){return e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function kq(e){const t=P2(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}}async function L2(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 _q(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Nq(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 Sq(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function jq(e,t){const n=Sq(e),s=n?`removes ${n} on the canvas`:null,a=d=>`This ${s?`${s} and ${d}`:d}`;if(!t)return{note:`${a("deletes 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. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${a("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const d=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${a(`leaves the event log alone: ${d}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${a("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const l=t.decks-1,c=l===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${a(`deletes the event log ${l===1?"1 other running deck shares":`${l} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${c} This cannot be undone.`,confirm:"Clear everything"}}function Eq({agentCount:e,onConfirm:t,onCancel:n}){const s=b.useRef(null),a=Ht(n,{focusRef:s,layer:V4}),[l,c]=b.useState(null);b.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||c(Nq(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:d,confirm:h}=jq(e,l);return i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"status-dot err","aria-hidden":!0}),i.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:d}),i.jsxs("div",{className:"cc-actions",children:[i.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Cq="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",Tq=[{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:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Aq({onClose:e,onTour:t}){const n=Ht(e);return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal key-help",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:Cq}),t&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),i.jsx("div",{className:"shortcuts",children:Tq.map(s=>i.jsxs(b.Fragment,{children:[i.jsx("h3",{className:"kh-group",children:s.title}),s.rows.map(a=>i.jsxs("div",{className:"sc",children:[i.jsx("kbd",{children:a.cap}),i.jsx("span",{children:a.action})]},`${s.title}:${a.cap}:${a.action}`))]},s.title))})]})]})})}const Rq=["done","needs-input"],Mq=[{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}]}],Iq=[{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}]}],bx={done:Mq,"needs-input":Iq},ii="two";function $v(e,t){const n=bx[e];return n.find(s=>s.id===t)??n.find(s=>s.id===ii)??n[0]}function D2(e,t){return bx[e].some(s=>s.id===t)?t:ii}$v("done",ii).notes,$v("needs-input",ii).notes;const $1=.04,$q=.24,Vu=0,ud=100,Ov=5,ql=50;function Fl(e){if(!Number.isFinite(e))return ql;const t=Math.round(e/Ov)*Ov;return Math.min(ud,Math.max(Vu,t))}function Oq(e){if(e==null)return ql;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Fl(Number(t)):ql}function Pq(e){const t=Fl(e),n=$1+($q-$1)*(t/ud);return Math.round(n*1e4)/1e4}function Lq(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(Pq(e)*s*1e4)/1e4}const Dq=160,qq="agent-dag.soundLevel.done",Fq="agent-dag.soundLevel.needs-input",Bq="agent-dag.soundFigure.done",zq="agent-dag.soundFigure.needs-input",q2={done:qq,"needs-input":Fq},F2={done:Bq,"needs-input":zq},Pv={done:{level:ql,figure:ii},"needs-input":{level:ql,figure:ii}};function Uq(e){const t=n=>({level:Oq(e(q2[n])),figure:D2(n,e(F2[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const Wq={Stop:"done",Notification:"needs-input"};function Hq(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:Wq[n]??null}function Gq(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const a=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",l=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,a())};function c(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(l,()=>{}),s=!0,l()}catch{}}function d(h,p=!1){var j;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((j=e.prefs)==null?void 0:j.call(e))??Pv)[h]??Pv[h],m=$v(h,f.figure),y=Lq(f.level,m),v=n.currentTime;for(const _ of m.notes){const S=n.createOscillator(),x=n.createGain();S.type=m.type??"sine",S.frequency.value=_.hz;const N=v+_.at,E=N+_.ms/1e3;x.gain.setValueAtTime(1e-4,N),x.gain.exponentialRampToValueAtTime(y,N+.012),x.gain.exponentialRampToValueAtTime(1e-4,E),S.connect(x).connect(n.destination),S.start(N),S.stop(E+.02)}return!0}return{unlock:c,play:d,state:a,get context(){return n}}}const Vq="Notify me when a session needs my attention.",Yq="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",O1="Get notified when you're away from this tab.";function Kq(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:O1};case"default":return{status:null,ask:!0,ok:!1,note:O1};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 P1={done:"Turn finished","needs-input":"Claude is asking"},Xq={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Qq({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:a,onFigure:l,onPreview:c,openerRef:d,notifyOn:h,onToggleNotify:p,notifyVetoed:f,notifyPermission:m,onAskNotify:y}){const v=Kq(m),j=h&&!f,_=Ht(e),S=b.useRef(e);return S.current=e,b.useEffect(()=>{const x=N=>{var C,R;const E=N.target;E&&((C=_.current)!=null&&C.contains(E)||(R=d.current)!=null&&R.contains(E)||S.current())};return window.addEventListener("pointerdown",x,!0),()=>window.removeEventListener("pointerdown",x,!0)},[_,d]),i.jsxs("div",{ref:_,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[i.jsxs("div",{className:"sm-switches",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),i.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"sm-toggle",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:i.jsx("span",{className:"sm-toggle-knob"})})]}),i.jsxs("div",{className:"sm-setting",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications"}),i.jsx("button",{type:"button",role:"switch","aria-checked":h,"aria-labelledby":"sm-notify-label",className:"sm-toggle",onClick:p,title:"A system notification when a session blocks on you",children:i.jsx("span",{className:"sm-toggle-knob"})})]}),i.jsx("p",{className:"sm-note",children:f?Yq:Vq})]})]}),j&&i.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[i.jsxs("div",{className:"sm-channel-head",children:[i.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),v.ask?i.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:y,children:"Enable"}):i.jsxs("span",{className:"sm-channel-state","data-ok":v.ok||void 0,children:[v.ok&&i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),v.status]})]}),i.jsx("p",{className:"sm-note",children:v.note})]}),!t&&i.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),i.jsx("div",{className:"sm-tones",children:Rq.map(x=>{const N=s[x],E=`sm-level-${x}`,C=`sm-figure-${x}`;return i.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${x}`,children:[i.jsxs("div",{className:"sm-tone-head",children:[i.jsx("h3",{className:"sm-tone-name",id:`sm-name-${x}`,children:P1[x]}),i.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(x),"aria-label":`Hear the ${P1[x].toLowerCase()} tone`,title:t?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":t?void 0:"sm-preview-note",children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:i.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:E,children:"Volume"}),i.jsx("input",{id:E,type:"range",min:Vu,max:ud,step:Ov,value:N.level,onChange:R=>a(x,Number(R.target.value)),style:{"--sm-level":`${(N.level-Vu)/(ud-Vu)*100}%`}}),i.jsxs("span",{className:"sm-read",children:[N.level,"%"]})]}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:C,children:"Tone"}),i.jsx("select",{id:C,className:"sm-select",value:N.figure,onChange:R=>l(x,R.target.value),children:bx[x].map(R=>i.jsx("option",{value:R.id,children:R.label},R.id))})]}),i.jsx("p",{className:"sm-note",children:Xq[x]})]},x)})}),i.jsxs("p",{className:"sm-foot",children:[i.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const Zq=15e3;function Jq(e){return e.visibilityState==="visible"&&e.hasFocus()}function eF(e,t){return t||e===!0}function tF(){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)}`}const nF={"//":["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."],"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.
81
+ `),"fix"),title:"Copy these lines, then paste them into an elevated PowerShell",children:y==="fix"?"copied":"copy command"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"By address"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{ref:a,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:c,placeholder:"192.168.1.5:54340",spellCheck:!1,...O("addr"),onChange:D=>{d(D.target.value),M("addr")},onKeyDown:D=>{D.key==="Enter"&&L()}}),c.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...F("add"),onClick:()=>void L(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),i.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."})]}),i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:["With an invite",!Q&&i.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...F("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:j==="invite:make"?"making…":"make one to send"})]}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:h,placeholder:"paste one you were sent",spellCheck:!1,...O("join"),onChange:D=>{p(D.target.value),x(null),M("join")},onKeyDown:D=>{D.key==="Enter"&&B()}}),h.trim()!==""&&i.jsx("button",{type:"button",className:"ap-manage-btn",...F("join"),onClick:()=>void B(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:j==="join"?"joining…":"join"})]}),i.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),S&&i.jsxs("div",{className:"ap-lan-tried",children:[i.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),S.map(D=>i.jsxs("span",{className:"ap-lan-tried-row",children:[i.jsx("code",{className:"ap-lan-code",children:D.addr}),i.jsx("span",{className:"ap-lan-bad",children:D.why})]},D.addr))]}),Q&&i.jsxs("div",{className:"ap-lan-invite",children:[i.jsxs("div",{className:"ap-lan-invite-head",children:[i.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),i.jsxs("span",{className:"ap-lan-invite-left",children:[Q6(Q.expiresAt,N)," left"]})]}),i.jsx("code",{className:"ap-lan-token",children:Q.token}),i.jsxs("div",{className:"ap-lan-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...F("copy:invite"),onClick:()=>void A(Q.token,"invite"),title:"Copy it, and send it however you already talk to them",children:y==="invite"?"copied":"copy"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...F("invite:withdraw"),onClick:()=>void H("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),i.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function F6(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}".`}const B6=1e3;function z6(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=as(e,t);return`${n} · ${s==="now"?"just now":s}`}function U6(){return i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),i.jsx("path",{d:"M8.4 3.6l2 2"})]})}function W6({row:e,source:t,status:n,accounts:s,now:a,busy:l,onClose:c,onRename:d,onCheck:h,onVerb:p,onSettings:f}){var ke,je,Ye,it;const m=b.useRef(null),y=Ht(c,{focusRef:m}),[v,j]=b.useState(null),[_,S]=b.useState(null),[x,N]=b.useState(!1),E=b.useRef(0),[C,R]=b.useState(!1),[I,$]=b.useState(!1),F=b.useRef(null),O=b.useRef(!0);b.useEffect(()=>()=>{O.current=!1},[]);const M=v!=null;b.useEffect(()=>{var Ne;M&&((Ne=F.current)==null||Ne.select())},[M]),b.useEffect(()=>{if(!x)return;const Ne=window.setTimeout(()=>N(!1),4e3);return()=>window.clearTimeout(Ne)},[x]);const L=Ne=>{const He=Xs(l,Ne);return{disabled:He.disabled,"aria-busy":He.busy}},H=async Ne=>{const He=await Ne();return O.current&&S(He),He==null},{peer:B,stranger:A}=t,Q=e.kind==="paired",K=e.self??e.name,ee=e.kind!=="dialling",Z=e.kind==="dialling"?null:e.fp,D=B?B.addr?`${B.addr}:${B.port}`:"":A?A.port?`${A.addr}:${A.port}`:A.addr:e.addr,Y=(B==null?void 0:B.about)??null,P=((ke=n.about)==null?void 0:ke.version)??null,G=async Ne=>{const He=Ne.trim()===K?"":Ne;await H(()=>d(He))&&j(null)},de=async()=>{if(Z)try{if(await navigator.clipboard.writeText(Z),!O.current)return;R(!0),window.setTimeout(()=>{O.current&&R(!1)},1600)}catch{O.current&&S("Could not copy it — select the fingerprint and copy it by hand.")}},W=Q?B!=null&&B.waiting?B.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":B!=null&&B.offers?"not said — it runs an older version":"not reached yet":"shown once paired",U=(()=>{if(!(Y!=null&&Y.version))return null;const Ne=P?sq(Y.version,P):null;return Ne==null?Y.version:Ne===0?`${Y.version} · same as this deck`:`${Y.version} · ${Ne<0?"older":"newer"} than this deck's ${P}`})(),J=B?M2(B.last,a):null,V=(je=B==null?void 0:B.last)!=null&&je.error&&J&&J.text!==B.last.error?B.last.error:null,ie=((Ye=B==null?void 0:B.last)==null?void 0:Ye.done)??[],pe=[];pe.push({label:"Address",value:D?i.jsx("code",{className:"ap-lan-code",children:D}):"none here — it calls this deck",tone:D?void 0:"quiet"}),pe.push({label:"Reached",value:B?B.waiting?"it calls this deck · one-way":B.manual?"by an address added here":"found on this network":e.kind==="nearby"?"heard on this network":"asked this deck to pair"}),e.kind!=="dialling"&&(pe.push({label:"Paired",value:Q?B!=null&&B.pairedAt?z6(B.pairedAt,a):"before this deck kept the date":e.kind==="declined"&&A?`no · you said no ${xx(A.at,a)}`:"not yet",tone:Q&&!(B!=null&&B.pairedAt)?"quiet":"meta"}),Y?(pe.push({label:"Deck",value:U??"not said",tone:U?"meta":"quiet"}),pe.push({label:"System",value:Y.os?[Y.os,Y.arch].filter(Boolean).join(" · "):"not said",tone:Y.os?"meta":"quiet"})):pe.push({label:"Version, OS",value:W,tone:"quiet"})),pe.push({label:"Fingerprint",value:Z?i.jsxs("span",{className:"lan-fp",children:[i.jsx("code",{className:"ap-lan-code",children:Z}),i.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void de(),"aria-label":C?"Fingerprint copied":"Copy the fingerprint",children:C?"copied":"copy"})]}):"not known — nothing has answered there",tone:Z?void 0:"quiet"}),(Q||e.kind==="dialling")&&pe.push({label:"Last round",value:J?i.jsxs(i.Fragment,{children:[J.text.replace(/ · now$/," · just now"),V&&i.jsx("span",{className:"lan-fact-raw",children:V}),ie.length>0&&i.jsx("ul",{className:"lan-done",children:ie.map(Ne=>i.jsxs("li",{"data-ok":Ne.ok,children:[Ne.email," ",i.jsx("span",{className:"lan-done-what",children:Ne.ok?"arrived":"did not arrive"})]},`${Ne.email}:${Ne.action}`))})]}):"not asked yet",tone:(J==null?void 0:J.tone)==="bad"?"bad":J?void 0:"quiet"});const me=new Map(s.map(Ne=>[Ne.key,Ne])),Ie=new Set(n.shared??[]),Le=(n.shared??[]).map(Ne=>me.get(Ne)).filter(Ne=>!!Ne),ce=Le.filter(Ne=>!Ne.alive),xe=Le.length-ce.length,ye=(B==null?void 0:B.offers)??null,ze=ye&&(B!=null&&B.last)&&B.last.at-ye.at>B6?as(ye.at,a):null;return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:y,className:"modal lan-peer","data-tone":e.tone,onClick:Ne=>Ne.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[i.jsxs("header",{className:"modal-head lan-peer-head",children:[i.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsxs("div",{className:"lan-peer-id",children:[M?i.jsxs("form",{className:"lan-peer-edit",onSubmit:Ne=>{Ne.preventDefault(),G(v??"")},children:[i.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),i.jsx("input",{ref:F,className:"ap-manage-input lan-peer-input",value:v??"",maxLength:48,placeholder:K,"aria-label":"Name for this deck, shown on this deck only",onChange:Ne=>j(Ne.target.value)}),i.jsx("button",{type:"submit",className:"ap-manage-btn",...L(`alias:${e.fp}`),children:"save"}),i.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>j(null),children:"cancel"})]}):i.jsxs("span",{className:"lan-peer-title",children:[i.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),ee&&i.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{S(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:i.jsx(U6,{})})]}),i.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&i.jsxs(i.Fragment,{children:["calls itself ",i.jsx("span",{className:"lan-peer-self",children:e.self}),M&&i.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...L(`alias:${e.fp}`),onClick:()=>void G(""),children:"use this name"}),i.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&i.jsx("span",{"aria-hidden":!0,children:" · "})]}),i.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{ref:m,type:"button",className:"glyph-btn",onClick:c,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:_}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>S(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Connection"}),i.jsx("dl",{className:"lan-facts",children:pe.map(Ne=>i.jsxs("div",{className:"lan-fact","data-tone":Ne.tone,children:[i.jsx("dt",{children:Ne.label}),i.jsx("dd",{children:Ne.value})]},Ne.label))}),(B==null?void 0:B.waiting)&&i.jsx("p",{className:"lan-note",children:e.hint})]}),Q&&i.jsxs("div",{className:"modal-section",children:[i.jsxs("h3",{className:"lan-h",children:["From ",e.name]}),ze&&i.jsxs("p",{className:"lan-stale",children:["Last told us ",ze==="now"?"just now":ze," — the last round did not get through, so this may have changed."]}),B!=null&&B.waiting?i.jsx("p",{className:"lan-empty",children:"Not known. This deck never asks it — it calls in — so what it offers only shows once this deck can reach it."}):ye?ye.accounts.length===0?i.jsx("p",{className:"lan-empty",children:"Nothing. Nobody at that deck has chosen a login to share."}):i.jsx("ul",{className:"lan-offers",role:"list",children:ye.accounts.map(Ne=>{const He=aq(Ne,me.get(Ne.key)??null,Ie.has(Ne.key));return i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":He.tone,children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there",children:He.there}),i.jsx("span",{className:"lan-offer-here",children:He.here}),He.note&&i.jsx("span",{className:"lan-offer-note",children:He.note})]},Ne.key)})}):i.jsx("p",{className:"lan-empty",children:(it=B==null?void 0:B.last)!=null&&it.error?"Not known — the last attempt to ask it did not get through.":"Not asked yet. The next round asks it."})]}),Q&&i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"From this deck"}),Le.length===0?i.jsx("p",{className:"lan-empty",children:"Nothing. No login on this deck is chosen to share."}):i.jsxs(i.Fragment,{children:[ce.length>0&&i.jsx("ul",{className:"lan-offers",role:"list",children:ce.map(Ne=>i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":"bad",children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there"}),i.jsx("span",{className:"lan-offer-here",children:"expired here"}),i.jsx("span",{className:"lan-offer-note",children:"offered to every paired deck and gives them nothing — sign in again"})]},Ne.key))}),xe>0&&i.jsxs("button",{type:"button",className:"ap-lan-word lan-more","aria-expanded":I,onClick:()=>$(Ne=>!Ne),children:[xe===1?"1 login works here":`${xe} logins work here`,i.jsx("span",{className:"lan-more-mark","aria-hidden":!0,children:I?"−":"+"})]}),I&&xe>0&&i.jsx("ul",{className:"lan-offers",role:"list",children:Le.filter(Ne=>Ne.alive).map(Ne=>i.jsxs("li",{role:"listitem",className:"lan-offer","data-tone":"ok",children:[i.jsx("span",{className:"lan-offer-email",children:Ne.email}),i.jsx("span",{className:"lan-offer-there"}),i.jsx("span",{className:"lan-offer-here",children:"works here"})]},Ne.key))})]}),i.jsx("p",{className:"lan-scope",children:"Every paired deck gets this list, the ones here now and any paired later."}),i.jsx("button",{type:"button",className:"ap-lan-word lan-peer-settings",onClick:f,children:"Change what this deck offers"})]})]}),i.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&i.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),Q&&!(B!=null&&B.waiting)&&i.jsx("button",{type:"button",className:"btn",...L(`check:${e.fp}`),onClick:()=>void H(h),title:"Ask this deck now instead of waiting for the next round",children:l===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&i.jsx("button",{type:"button",className:`btn danger lan-peer-verb${x?" armed":""}`,...L(`unpair:${e.fp}`),onKeyDown:Ne=>{Ne.repeat&&Ne.preventDefault()},onClick:()=>{if(!x){N(!0),E.current=Date.now();return}Date.now()-E.current<$2||(N(!1),H(p))},"aria-label":x?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:x?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:l===`unpair:${e.fp}`?"Unpairing…":x?"Unpair — sure?":"Unpair"}),e.kind==="nearby"&&i.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...L(`accept:${e.fp}`),onClick:()=>void H(p),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:l===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...L(`drop:${e.fp}`),onClick:()=>void H(p),title:"Stop trying this address. Nothing was ever paired here.",children:l===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&i.jsx("button",{type:"button",className:"btn lan-peer-verb",...L(`allow:${e.fp}`),onClick:()=>void H(p),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:l===`allow:${e.fp}`?"Allowing…":"Let it ask again"})]})]})}),document.body)}function H6({status:e,accounts:t,onClose:n,onChanged:s}){const a=Ht(n),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),m=b.useRef(null),y=C=>{const R=Xs(p,C);return{disabled:R.disabled,"aria-busy":R.busy}},v=b.useRef(null),j=b.useRef(!0);b.useEffect(()=>()=>{j.current=!1},[]),b.useEffect(()=>{v.current&&X6(v.current,e.shared??[])&&(v.current=null)},[e.shared]);const _=b.useCallback(async(C,R,I="write")=>{m.current=I,f(I);try{const F=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:C})})).json().catch(()=>null);return j.current?(F!=null&&F.ok?h(null):h(Lt(R,F)),s(),(F==null?void 0:F.ok)===!0):!1}catch{return j.current&&h(Lt(R,null)),!1}finally{m.current=null,j.current&&f(null)}},[s]),S=b.useCallback(async()=>{if(l!=null&&l!==(e.name??"")){if(!await _({name:l},"save the name","name"))return;j.current&&c(null)}n()},[l,e.name,_,n]),x=new Set(v.current??e.shared??[]),N=e.autoAsk!==!1,E=e.autoAccept!==!1;return ls.createPortal(i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal lan-modal",onClick:C=>C.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[d&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:d}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>h(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Name"}),i.jsxs("div",{className:"ap-lan-row",children:[i.jsx("span",{className:"ap-lan-label",children:"appear as"}),i.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:C=>c(C.target.value),onKeyDown:C=>{C.key!=="Enter"||l==null||(_({name:l},"save the name","name"),c(null))}}),l!=null&&l!==(e.name??"")&&i.jsx("button",{type:"button",className:"ap-manage-btn",...y("name"),onClick:()=>{_({name:l},"save the name","name"),c(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Share these accounts"}),i.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&i.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(C=>i.jsxs("label",{className:"ap-lan-pick",title:C.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[i.jsx("input",{type:"checkbox",checked:x.has(C.key),onChange:R=>{const I=new Set(v.current??e.shared??[]);R.target.checked?I.add(C.key):I.delete(C.key),v.current=[...I],_({shared:[...I]},R.target.checked?"share that account":"stop sharing that account")}}),i.jsx("span",{className:"ap-lan-pick-name",children:C.email}),!C.alive&&i.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},C.key))]})]}),i.jsxs("div",{className:"modal-section",children:[i.jsx("h3",{className:"lan-h",children:"Pairing"}),i.jsxs("div",{className:"lan-switches",children:[i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),i.jsx("button",{type:"button",className:`ap-auto-state${N?" live":""}`,role:"switch","aria-checked":N,"aria-label":"Ask every deck this one finds",...y("ask"),onClick:()=>void _({autoAsk:!N},N?"stop asking automatically":"ask every deck this one finds","ask"),title:N?"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."})]}),i.jsxs("div",{className:"lan-switch",children:[i.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),i.jsx("button",{type:"button",className:`ap-auto-state${E?" live":""}`,role:"switch","aria-checked":E,"aria-label":"Say yes to every deck that asks",...y("accept"),onClick:()=>void _({autoAccept:!E},E?"stop accepting automatically":"accept every deck that asks","accept"),title:E?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here."})]})]}),E?null:N?i.jsx("p",{className:"lan-note",children:"This deck asks; somebody on the other machine still has to say yes. A request coming the other way waits in the panel for you."}):i.jsxs("p",{className:"lan-note",children:["Nothing pairs on its own. You press ",i.jsx("strong",{children:"ask"})," on a deck you find, and ",i.jsx("strong",{children:"accept"})," on one that asks. A deck you said no to is never asked about again either way."]})]})]}),i.jsxs("footer",{className:"lan-setup-foot",children:[i.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),i.jsx("button",{type:"button",className:"btn primary",...y("name"),onClick:()=>void S(),children:"Done"})]})]})}),document.body)}function as(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 vx={"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"}},G6={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 V6(e){var s;const t=Y6[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&G6[n]||e}const Y6={"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 M2(e,t){if(!e)return null;if(e.error)return vx[e.error]??{text:V6(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${as(e.at,t)}`,tone:"idle"};const s=n.filter(l=>l.ok),a=s.length===1?"login":"logins";return s.length===n.length?{text:`${s.length} ${a} arrived · ${as(e.at,t)}`,tone:"ok"}:{text:`${s.length} of ${n.length} logins arrived · ${as(e.at,t)}`,tone:"bad"}}const $v=5e3,I2=6e4,$2=400;function K6(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 Lt(e,t){return t==null?`Could not ${e} — the deck did not answer.`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}function X6(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Q6(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function O2(e,t){var n,s;return(n=e.last)!=null&&n.error&&!vx[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<ud||e.lastSeen!=null&&t-e.lastSeen<ud)}const ud=95e3;function Z6(e,t){const n=[],s=[];for(const a of e??[])(O2(a,t)?n:s).push(a);return{online:n,offline:s}}function J6(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(v=>v.paired!==!1||v.met);if(!s.length)return{text:"no deck paired yet",tone:"idle"};const a=s.filter(v=>v.waiting),l=s.filter(v=>!v.waiting),c=a.filter(v=>{var j;return!((j=v.last)!=null&&j.error)&&v.lastSeen!=null&&t-v.lastSeen<ud}),{online:d,offline:h}=Z6(l,t),p=[...h,...a.filter(v=>!c.includes(v))],f=d.length+c.length,m=d.filter(v=>{var j;return((j=v.last)==null?void 0:j.error)==="waiting for the other deck to accept this one"});if(f&&m.length===f)return{text:f===1?"1 deck found · waiting for them to accept":`${f} decks found · waiting for them to accept`,tone:"wait"};if(!f)return{text:p.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${p.length} decks`,tone:"bad"};const y=f===1?"1 deck ready":`${f} decks ready`;return{text:p.length?`${y} · ${p.length} away`:y,tone:"ok"}}function eq(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=as(e,t);return s==="now"?"checked just now":`checked ${s}`}function xx(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 tq(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=t-e<ud;return{text:n?"online · one-way, it calls in":`one-way · last online ${as(e,t)}`,here:n}}function j1(e,t,n){return t?"online":e.lastSeen!=null?`last online ${as(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function nq(e,t){var y,v,j,_,S;if(!e)return[];const n=[],s=new Set,a=(x,N)=>x.name.localeCompare(N.name,void 0,{numeric:!0}),l=e.aliases??{},c=(x,N)=>{const E=x?l[x]:void 0;return E&&E!==N?{name:E,self:N}:{name:N}};for(const x of e.pending??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);n.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.addr??"",kind:"asks",state:`wants to pair · ${xx(x.at,t)}`,tone:"wait",here:!0,hint:`${N.name} at ${x.addr} is waiting for an answer.`})}const d=[],h=[];for(const x of e.peers??[]){const N=x.peerFp??x.fp;if(!N||s.has(N))continue;s.add(N);const E=M2(x.last,t),C=O2(x,t),R=x.addr?`${x.addr}:${x.port}`:"";if(!x.paired&&x.manual&&!x.met){h.push({fp:R,name:R||x.name||N,addr:x.addr??"",kind:"dialling",state:E?E.text.replace(/ · .*$/,""):"trying…",tone:E?E.tone:"idle",here:!1,hint:(y=x.last)!=null&&y.error?`Nothing has answered at ${R} yet — ${x.last.error}.`:`Dialling ${R} until something answers.`});continue}const I=x.waiting?tq(x.lastSeen,t):null,$=I?I.here:C,F=!I&&E?$?`online · ${E.text.replace(/ · .*$/,"")}`:`${E.text.replace(/ · .*$/,"")} · ${j1(x,$,t)}`:I?I.text:j1(x,$,t),O=(v=x.last)!=null&&v.error?vx[x.last.error]:null,M=!I&&$&&!((j=x.last)!=null&&j.error)&&!(((_=x.last)==null?void 0:_.done)??[]).length,L=x.manual&&!x.met?{name:R}:c(N,x.name||N);d.push({fp:N,name:L.name,...L.self?{self:L.self}:{},addr:x.addr??"",kind:"paired",state:F,quiet:M,tone:O?O.tone==="bad"?"bad":"wait":E?E.tone:$?"ok":"idle",here:I?I.here:C,hint:I?`${L.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. ${x.lastSeen==null?"It has not called since this deck started.":`It last called ${as(x.lastSeen,t)}.`} Add its address with the + at the top of this section to reach it either way.`:`${L.name}${R?` at ${R}`:""}${(S=x.last)!=null&&S.error?` — ${x.last.error}`:""}`})}n.push(...d.sort(a),...h.sort(a));const p=[];for(const x of e.strangers??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);p.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.addr??"",kind:"nearby",state:"not paired yet",tone:"idle",here:!0,hint:`${N.name} at ${x.addr} is on this network and nothing is shared with it.`})}n.push(...p.sort(a));const f=[];for(const x of e.declined??[]){if(!(x!=null&&x.fp)||s.has(x.fp))continue;s.add(x.fp);const N=c(x.fp,x.name||x.fp);f.push({fp:x.fp,name:N.name,...N.self?{self:N.self}:{},addr:x.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.`})}n.push(...f.sort(a));const m=new Map;for(const x of n)m.set(x.name,(m.get(x.name)??0)+1);for(const x of n)(m.get(x.name)??0)<2||!x.addr||(x.state=x.quiet||!x.state?x.addr:`${x.addr} · ${x.state}`,x.quiet=!1);return n}function E1(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function rq(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 sq(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 l=Number(n[a])-Number(s[a]);if(l)return Math.sign(l)}return 0}function aq(e,t,n){const s=t?t.alive?"works here":"expired here":"not on this deck";if(!e.alive){const a=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:a,tone:a?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:"ok"}:n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"share it to repair",tone:"bad"}:{there:"works there",here:s,note:"arrives next round",tone:"wait"}}async function Go(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function oq({accounts:e,onChanged:t}){const[n,s]=b.useState(null),[a,l]=b.useState([]),[c,d]=b.useState(null),[h,p]=b.useState(!1),[f,m]=b.useState(null),y=b.useRef(0),[v,j]=b.useState(!1),[_,S]=b.useState(!1),[x,N]=b.useState(!1),[E,C]=b.useState(null),R=b.useRef(null),I=b.useCallback(ce=>Sd(R.current)?(R.current=ce,d(ce),!0):!1,[]),$=b.useCallback(()=>{R.current=null,L.current&&d(null)},[]),F=ce=>{const xe=Xs(c,ce);return{disabled:xe.disabled,"aria-busy":xe.busy}},[O,M]=b.useState(()=>Date.now()),L=b.useRef(!0),H=b.useRef($v),B=b.useCallback(async()=>{var ce,xe;try{const[ye,ze]=await Promise.all([fetch("/api/lan").then(ke=>ke.json()),fetch("/api/prefs").then(ke=>ke.json())]);if(!L.current)return;ye!=null&&ye.ok&&s(ye),ze!=null&&ze.ok&&l(Array.isArray((xe=(ce=ze.prefs)==null?void 0:ce.lan)==null?void 0:xe.manual)?ze.prefs.lan.manual:[]),H.current=(ye==null?void 0:ye.enabled)===!0?$v:I2}catch{}},[]);b.useEffect(()=>{L.current=!0;let ce=0;const xe=async()=>{M(Date.now()),await B(),L.current&&(ce=window.setTimeout(xe,H.current))};return xe(),()=>{L.current=!1,window.clearTimeout(ce)}},[B]);const A=b.useCallback(async()=>{const ce=(n==null?void 0:n.enabled)===!0;if(I("switch"))try{const xe=await Go("/api/prefs",{lan:{enabled:!ce}});if(!L.current)return;xe!=null&&xe.ok?(C(null),ce||p(!0)):C(Lt(ce?"turn this off":"turn this on",xe)),await B()}catch{L.current&&C(Lt(ce?"turn this off":"turn this on",null))}finally{$()}},[n==null?void 0:n.enabled,B,I,$]),Q=b.useCallback(async(ce,xe,ye)=>{if(!I(`${ce}:${xe}`))return null;let ze=null;try{const ke=await Go("/api/lan/peer",{action:ce,fp:xe});if(!L.current)return null;ke!=null&&ke.ok?(s(ke),C(null)):(ze=Lt(ye,ke),C(ze)),await B()}catch{ze=Lt(ye,null),L.current&&C(ze)}finally{$()}return ze},[B,I,$]),K=b.useCallback(async ce=>{if(!I(`drop:${ce}`))return null;let xe=null;try{const ye=await Go("/api/prefs",{lan:{manual:a.filter(ze=>ze!==ce)}});if(!L.current)return null;ye!=null&&ye.ok?(C(null),t()):(xe=Lt("stop dialling that address",ye),C(xe)),await B()}catch{xe=Lt("stop dialling that address",null),L.current&&C(xe)}finally{$()}return xe},[a,B,t,I,$]),[ee,Z]=b.useState(null),D=b.useCallback(async(ce,xe)=>{if(!I(`alias:${ce}`))return"Something else is still being saved. Try again in a moment.";try{const ye=await Go("/api/lan/peer",{action:"alias",fp:ce,name:xe});return L.current?ye!=null&&ye.ok?(s(ye),null):Lt("rename that deck",ye):null}catch{return Lt("rename that deck",null)}finally{$()}},[I,$]),Y=b.useCallback(async ce=>{if(!I(`check:${ce}`))return null;try{const xe=await Go("/api/lan/sync",{fp:ce});return L.current?xe!=null&&xe.ok?(s(xe),t(),null):(xe==null?void 0:xe.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.":Lt("check that deck",xe):null}catch{return Lt("check that deck",null)}finally{$()}},[I,$,t]),P=b.useCallback(async()=>{if(I("check"))try{const ce=await Go("/api/lan/sync",{});if(!L.current)return;ce!=null&&ce.ok?(s(ce),C(null)):C(Lt("check the other decks",ce)),t()}catch{L.current&&C(Lt("check the other decks",null))}finally{$()}},[I,$,t]),G=(n==null?void 0:n.enabled)===!0,de=nq(n,O),W=ee?de.find(ce=>ce.fp===ee)??null:null;b.useEffect(()=>{ee&&n&&!W&&Z(null)},[ee,n,W]);const U=de.filter(ce=>ce.kind==="asks"),J=de.filter(ce=>ce.kind!=="asks"),V=J.filter(ce=>ce.here),ie=J.filter(ce=>!ce.here),pe=ie.filter(ce=>ce.tone==="bad").length,me=x||V.length===0,Ie=J6(n,O),Le=J.filter(ce=>ce.kind==="paired").length;return i.jsxs("div",{className:"ap-auto ap-lan",children:[i.jsxs("div",{className:"ap-auto-head",children:[i.jsx("h3",{className:"ap-auto-title",children:"Local network"}),G&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>j(!0),"aria-label":"Add a deck",title:"Reach a deck that has not turned up on its own — by address, or with an invite",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),G&&Le>0&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...F("check"),onClick:()=>void P(),"aria-label":c==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),i.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),G&&i.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...F("setup"),onClick:()=>p(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),i.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),i.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),i.jsx("button",{type:"button",className:`ap-auto-state${G?" live":""}`,role:"switch","aria-checked":G,"aria-label":"Local network sync",...F("switch"),onClick:()=>void A(),title:G?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins"})]}),!G&&i.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>S(!0),title:"Four pictures: what this does, and what to do on each machine",children:[i.jsx(P6,{}),i.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),i.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),i.jsx("p",{className:`ap-lan-status ${Ie.tone}`,role:"status",children:Ie.tone==="ok"?"":Ie.text}),E&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",children:E}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>C(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),G&&i.jsxs(i.Fragment,{children:[U.length>0&&i.jsx("div",{className:"ap-lan-asks",role:"alert",children:U.map(ce=>i.jsxs("div",{className:"ap-lan-ask",children:[i.jsxs("span",{className:"ap-lan-ask-what",children:[i.jsx("strong",{className:"ap-lan-peer-name",children:ce.name})," at ",i.jsx("code",{className:"ap-lan-code",children:ce.addr})," wants to pair"]}),i.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",i.jsx("code",{className:"ap-lan-code",children:ce.fp})]}),i.jsxs("span",{className:"ap-lan-ask-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...F(`accept:${ce.fp}`),onClick:()=>void Q("accept",ce.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${ce.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),i.jsx("button",{type:"button",className:"ap-manage-btn",...F(`dismiss:${ce.fp}`),onClick:()=>void Q("dismiss",ce.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},ce.fp))}),(me?[...V,...ie]:V).length>0&&i.jsx("ul",{className:"ap-lan-here",children:(me?[...V,...ie]:V).map((ce,xe)=>i.jsxs("li",{className:"ap-lan-who","data-tone":ce.tone,children:[i.jsx("i",{className:ce.here?"ap-pulse":"ap-dot","aria-hidden":!0}),i.jsx("span",{className:"ap-lan-who-name","aria-hidden":!0,children:ce.name}),i.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${xe}`,onClick:()=>Z(ce.fp),children:i.jsxs("span",{className:"vis-hidden",children:[ce.name,", details"]})}),i.jsx("span",{id:`lan-who-state-${xe}`,className:ce.quiet?"vis-hidden":"ap-lan-who-when",children:ce.state}),ce.kind==="nearby"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`accept:${ce.fp}`),onClick:()=>void Q("accept",ce.fp,"reach that deck"),"aria-label":`Ask ${ce.name} to pair`,title:`Send ${ce.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${ce.fp}.`,children:"ask"}),ce.kind==="paired"&&i.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${f===ce.fp?" armed":""}`,...F(`unpair:${ce.fp}`),onClick:()=>{if(f!==ce.fp){m(ce.fp),y.current=Date.now(),window.setTimeout(()=>m(ye=>ye===ce.fp?null:ye),4e3);return}Date.now()-y.current<$2||(m(null),Q("unpair",ce.fp,"unpair that deck"))},"aria-label":f===ce.fp?`Confirm unpairing ${ce.name}`:`Unpair ${ce.name}`,title:f===ce.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:f===ce.fp?"sure?":"unpair"}),ce.kind==="dialling"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`drop:${ce.fp}`),onClick:()=>void K(ce.fp),"aria-label":`Stop dialling ${ce.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),ce.kind==="declined"&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...F(`allow:${ce.fp}`),onClick:()=>void Q("allow",ce.fp,"let that deck ask again"),"aria-label":`Let ${ce.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${ce.kind}:${ce.fp}`))}),(V.length>0&&ie.length>0||G&&Le>0)&&i.jsxs("div",{className:"ap-lan-tail",children:[V.length>0&&ie.length>0&&i.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":x,onClick:()=>N(ce=>!ce),title:x?"Show only the decks that are on":`Show the ${ie.length} deck${ie.length===1?"":"s"} that are not answering right now`,children:[i.jsx("span",{className:`ap-lan-chev${x?" open":""}`,"aria-hidden":!0,children:"›"}),x?"fewer":`${ie.length} more`,!x&&pe>0&&i.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",pe," not answering"]})]}),G&&Le>0&&i.jsx("span",{className:"ap-lan-checked",children:eq(n==null?void 0:n.checkedAt,O,c==="check")})]}),J.length===0&&U.length===0&&i.jsxs(i.Fragment,{children:[i.jsxs("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, ",i.jsx("strong",{children:"+"})," at the top of this section reaches one by address or by invite."]}),i.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>S(!0),children:"How it works"})]})]}),v&&n&&i.jsx(q6,{status:n,manual:a,onClose:()=>j(!1),onChanged:()=>{B(),t()}}),_&&i.jsx(A2,{title:"How Local network works",steps:O6,finish:G?void 0:{label:"Turn it on",act:()=>{S(!1),A()}},onClose:()=>S(!1)}),h&&n&&i.jsx(H6,{status:{...n,manualRows:a},accounts:e,manual:a,onClose:()=>p(!1),onChanged:()=>{B(),t()}}),W&&n&&i.jsx(W6,{row:W,source:rq(n,W),status:n,accounts:e,now:O,busy:c,onClose:()=>Z(null),onRename:ce=>D(W.fp,ce),onCheck:()=>Y(W.fp),onVerb:()=>{switch(W.kind){case"paired":return Q("unpair",W.fp,"unpair that deck");case"nearby":return Q("accept",W.fp,"reach that deck");case"declined":return Q("allow",W.fp,"let that deck ask again");case"dialling":return K(W.fp);default:return Promise.resolve(null)}},onSettings:()=>{Z(null),p(!0)}})]})}const C1=15e3,iq=8e3,Df=1800,lq=3e4,cq=[70,80,85,90,95];function T1(e,t){return v2(t-Math.floor(e/1e3))}function uq(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 dq(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 hq(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 A1(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}function R1({lane:e,nowSec:t}){const n=Math.min(100,Math.max(0,e.pct)),s=n>=90?"var(--err)":n>=70?"var(--warn)":"var(--accent)",a=e.resetAt?x2(e.resetAt,t):null;return i.jsxs("div",{className:"ap-lane",children:[i.jsx("span",{className:"ap-lane-label",children:e.label}),i.jsx("div",{className:"ap-lane-track",children:i.jsx("div",{className:"ap-lane-fill",style:{width:`${n===0?1.5:n}%`,background:s,opacity:n===0?.4:1}})}),i.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[n,"%"]}),i.jsx("span",{className:"ap-lane-reset",children:a?`resets ${a}`:""})]})}async function M1(e){var n;let t=!1;try{t=await Promise.race([((n=navigator.clipboard)==null?void 0:n.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),500))])}catch{t=!1}if(t)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),t=document.execCommand("copy"),s.remove()}catch{t=!1}return t}function fq({onClose:e,leaving:t}){var Se,Fe,et,xt,ht;const[n,s]=b.useState(null),[a,l]=b.useState(null),[c,d]=b.useState(null),[h,p]=b.useState(!1),[f,m]=b.useState(null),[y,v]=b.useState(()=>Math.floor(Date.now()/1e3)),j=b.useRef(null),[_,S]=b.useState(null),[x,N]=b.useState(!1),[E,C]=b.useState(""),[R,I]=b.useState(null),[$,F]=b.useState(null),[O,M]=b.useState(null),[L,H]=b.useState(!1),[B,A]=b.useState(!1),[Q,K]=b.useState(null),[ee,Z]=b.useState(null),[D,Y]=b.useState(null),[P,G]=b.useState(null),[de,W]=b.useState(!1),[U,J]=b.useState([]),V=b.useRef(null),ie=b.useCallback(ne=>Sd(V.current)?(V.current=ne,d(ne),!0):!1,[]),pe=b.useCallback(()=>{V.current=null,d(null)},[]),me=(ne,De=!1)=>{const Oe=Xs(c,ne);return{disabled:Oe.disabled,"aria-busy":Oe.busy||De}},Ie=b.useCallback(ne=>{window.requestAnimationFrame(()=>{var De;if(P5(((De=document.activeElement)==null?void 0:De.tagName)??null))for(const Oe of O5(ne)){const Te=document.querySelector(Oe);if(Te){Te.focus();return}}})},[]),Le=b.useCallback(async(ne=!1)=>{ne&&p(!0);const De=new AbortController,Oe=window.setTimeout(()=>De.abort(),lq);try{const[Te,Ce]=await Promise.all([fetch(`/api/claude-accounts${ne?"?refresh=1":""}`,{signal:De.signal}),fetch("/api/cswap-auto",{signal:De.signal})]);if(Te.ok){const ut=await Te.json();s(ut),J(Re=>y6(Re,ut.accounts))}Ce.ok&&l(await Ce.json());const lt=b6([await x1(Te),await x1(Ce)]);m(ut=>b1(ut,lt))}catch{m(Te=>b1(Te,x6))}finally{window.clearTimeout(Oe),ne&&p(!1)}},[]),ce=b.useCallback(async(ne,De)=>{if(!ie(De))return null;m(null);try{const Te=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)})).json().catch(()=>null);return Te!=null&&Te.ok||m({text:Rv(Te,"command failed"),raw:ii(Te)}),Te}catch{return m({text:"server unreachable"}),null}finally{pe()}},[ie,pe]),xe=b.useCallback(async(ne,De)=>{if(!ie(De))return null;m(null);try{const Te=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)})).json().catch(()=>null);return Te!=null&&Te.ok||m({text:Xo(Te,"command failed")}),Te}catch{return m({text:"server unreachable"}),null}finally{pe()}},[ie,pe]);b.useEffect(()=>(Le(!0),j.current=window.setInterval(()=>Le(!1),C1),()=>{j.current!=null&&window.clearInterval(j.current)}),[Le]),b.useEffect(()=>{const ne=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ne)},[]);const ye=((Se=a==null?void 0:a.settings["autoswitch.threshold"])==null?void 0:Se.value)??"90",ze=P??ye,ke=h6(ze,ye),je=(Fe=n==null?void 0:n.accounts)==null?void 0:Fe.find(ne=>ne.active),Ye=((et=v1((je==null?void 0:je.lanes)??[]).peak)==null?void 0:et.pct)??null,it=Ye!=null&&Ye>=Number(ye)-15,Ne=async ne=>{if(ie(`switch-${ne}`)){m(null);try{const Oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ne})})).json().catch(()=>null);Oe!=null&&Oe.ok||m({text:Rv(Oe,"the switch failed"),raw:ii(Oe)}),await Le(!0)}catch{m({text:"server unreachable"})}finally{pe(),Ie(ne)}}},He=async(ne,De)=>{const{commit:Oe,alias:Te}=v6(E,De);if(Oe){const Ce=await xe({action:"alias",account:ne,alias:Te},`alias-${ne}`);if(await Le(!0),!(Ce!=null&&Ce.ok))return;C(Te)}I(ne),window.setTimeout(()=>I(Ce=>Ce===ne?null:Ce),Df)},Xe=async(ne,De)=>{const Oe=await xe({action:"move",account:ne,slot:De},`move-${ne}`),Te=c6({menuFor:_,shareFor:(O==null?void 0:O.num)??null},ne,Oe);if(await Le(!0),Te){S(Te.menuFor),F(Te.confirmRemove),Te.shareFor==null&&(M(null),A(!1)),K(Te.swapNote);const Ce=Te.swapNote;Ce&&window.setTimeout(()=>K(lt=>lt===Ce?null:lt),iq),Z(null),Ie(Te.menuFor)}return Oe},he=async(ne,De,Oe)=>{if(Oe.sends){const Te=await Xe(ne,De);if(!(Te!=null&&Te.ok))return}Y(ne),window.setTimeout(()=>Y(Te=>Te===ne?null:Te),Df)},ge=async(ne,De)=>{if(De.sends){const Oe=await ce({action:"setting",key:"autoswitch.threshold",value:ne},"threshold");if(await Le(!0),!(Oe!=null&&Oe.ok))return;G(null)}W(!0),window.setTimeout(()=>W(!1),Df)};return i.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",children:[i.jsxs("div",{className:"ap-header",children:[i.jsx("h2",{children:"Claude accounts"}),i.jsxs("div",{className:"ap-header-right",children:[i.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>N(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),(((xt=n==null?void 0:n.accounts)==null?void 0:xt.length)??0)>0&&i.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>H(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Wt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),i.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),i.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>Le(!0),...me("reload",h),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),i.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:i.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})})]})]}),n==null?f?i.jsxs("div",{className:"ap-empty",role:"alert",children:[i.jsx("span",{title:f.raw||void 0,children:f.text}),i.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",C1/1e3," seconds."]}),i.jsx("button",{type:"button",className:"ap-fix",disabled:h,onClick:()=>Le(!0),children:h?"trying…":"try again"})]}):i.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?i.jsxs(i.Fragment,{children:[i.jsx("ul",{className:"ap-list",children:(ht=n.accounts)==null?void 0:ht.map(ne=>{const{shown:De,rest:Oe,fuller:Te,peak:Ce}=v1(ne.lanes),lt=U.includes(gx(ne)),ut=f6(Oe.length,lt,Te);return i.jsxs("li",{className:`ap-account${ne.active?" active":""}`,children:[i.jsxs("div",{className:"ap-account-head",children:[i.jsx("span",{className:"ap-num",children:ne.num}),ne.alias&&i.jsx("span",{className:"ap-alias",title:ne.alias,children:ne.alias}),i.jsx("span",{className:"ap-email",title:ne.email??void 0,children:ne.email}),i.jsx("button",{type:"button",id:`ap-more-${ne.num}`,className:`ap-more${_===ne.num?" on":""}`,"aria-label":`Manage account ${ne.num}`,"aria-expanded":_===ne.num,"aria-controls":_===ne.num?`ap-manage-${ne.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(_===ne.num?null:ne.num),C(ne.alias??""),F(null),M(null),A(!1),K(null),I(null),Z(null),Y(null)},children:"⋯"}),ne.active&&i.jsx("span",{className:"ap-badge-active",children:"active"}),ne.disabled&&i.jsx("span",{className:"ap-badge-held",children:"held out"}),!ne.active&&!ne.disabled&&i.jsx("button",{type:"button",className:"ap-manage-btn ap-switch",...me(`switch-${ne.num}`),onClick:()=>Ne(ne.num),title:`Switch to ${ne.alias??ne.email}`,children:c===`switch-${ne.num}`?"…":"switch"})]}),i.jsx("div",{className:"ap-lanes",id:`ap-lanes-${ne.num}`,children:De.length?i.jsxs(i.Fragment,{children:[De.map(Re=>i.jsx(R1,{lane:Re,nowSec:y},Re.id)),lt&&Oe.map(Re=>i.jsx(R1,{lane:Re,nowSec:y},Re.id))]}):i.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),i.jsxs("div",{className:"ap-meta",children:[ne.staleCopy&&(()=>{const Re=dq(ne.repair??null,y);return i.jsx("span",{className:"ap-stale-copy",title:Re.hint,children:Re.text})})(),ne.stopped&&(()=>{const Re=A1(ne.collector??null);return i.jsx("span",{className:"ap-stopped",title:(Re==null?void 0:Re.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.",children:(Re==null?void 0:Re.text)??"not collecting"})})(),ne.stopped&&(()=>{var mt;const Re=(mt=A1(ne.collector??null))==null?void 0:mt.fix;return Re?i.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account puts its login in this slot.",children:Re}):null})(),ne.error&&(()=>{const Re=hq(ne.error);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"ap-err",title:Re.hint,children:Re.text}),Re.fixable&&i.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),ut&&i.jsx("button",{type:"button",className:"ap-lanes-more","aria-expanded":lt,"aria-controls":`ap-lanes-${ne.num}`,title:p6(ne.headroom,(Ce==null?void 0:Ce.label)??null,Oe.length,lt),onClick:()=>J(Re=>g6(Re,ne)),children:ut}),(((a==null?void 0:a.enabled)||(a==null?void 0:a.external))&&!ne.active||ne.disabled)&&i.jsx("button",{type:"button",className:"ap-rotate",...me(`rot-${ne.num}`),onClick:()=>ce({action:"account",account:ne.num,enabled:ne.disabled},`rot-${ne.num}`).then(()=>Le(!0)),title:ne.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:ne.disabled?"put back":"hold out"}),ne.fetchedAt?i.jsxs("span",{className:`ap-age${ne.stale&&!ne.stopped&&!ne.error?" 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 ",T1(ne.fetchedAt,y),uq(ne.nextAt,y)]}):i.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),_===ne.num&&i.jsxs("div",{className:"ap-manage",id:`ap-manage-${ne.num}`,role:"group","aria-label":`Manage account ${ne.num}`,children:[i.jsxs("div",{className:"ap-manage-name",children:[i.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${ne.num}`,children:"Alias"}),i.jsx("input",{id:`ap-alias-${ne.num}`,className:"ap-manage-input",type:"text",value:E,onChange:Re=>C(Re.target.value),onKeyDown:Re=>{Re.key==="Enter"&&He(ne.num,ne.alias)},maxLength:w6,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`alias-${ne.num}`),onClick:()=>He(ne.num,ne.alias),title:"A short name to show instead of the email",children:R===ne.num?"saved":"save"})]}),(()=>{const Re=l6((n.accounts??[]).map(bt=>bt.num),ne.num),mt=u6(Re,ee,ne.num),ft=d6(Re,mt,ne.num);return i.jsxs("div",{className:"ap-manage-slot",children:[i.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${ne.num}`,children:"Slot"}),i.jsx("span",{className:"ap-field",children:i.jsx("select",{id:`ap-slot-${ne.num}`,value:String(mt),...me(`move-${ne.num}`),onChange:bt=>Z(Number(bt.target.value)),children:Re.map(bt=>i.jsx("option",{value:bt.slot,children:bt.label},bt.slot))})}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`move-${ne.num}`),title:ft.title,onClick:()=>he(ne.num,mt,ft),children:D===ne.num?ft.done:ft.label})]})})(),i.jsxs("div",{className:"ap-manage-acts",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ne.num}`),title:`Copy this account to another ${Wt}. 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:async()=>{A(!1);const Re=await xe({action:"share",account:ne.num},`share-${ne.num}`);Re!=null&&Re.ok&&M({num:ne.num,blob:Re.blob,expiresAt:Re.expiresAt})},children:"share"}),i.jsx("button",{type:"button",className:`ap-manage-btn danger${$===ne.num?" armed":""}`,...me(`rm-${ne.num}`),title:$===ne.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if($!==ne.num){F(ne.num),window.setTimeout(()=>F(Re=>Re===ne.num?null:Re),4e3);return}F(null),xe({action:"remove",account:ne.num},`rm-${ne.num}`).then(()=>{S(null),Le(!0),Ie(null)})},children:$===ne.num?"confirm":"remove"})]}),(Q==null?void 0:Q.at)===ne.num&&(()=>{var ft;const Re=(ft=n.accounts)==null?void 0:ft.find(bt=>bt.num===Q.displaced),mt=(Re==null?void 0:Re.alias)??(Re==null?void 0:Re.email)??"the account that was there";return i.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${Q.at} was taken, so the two accounts traded places: ${mt} now holds slot ${Q.displaced}.`,children:["swapped with slot ",Q.displaced]})})(),(O==null?void 0:O.num)===ne.num&&(()=>{const Re=T2(O.expiresAt,y),mt=Re.tone==="gone";return i.jsxs("div",{className:`ap-share${mt?" expired":""}`,children:[i.jsx("code",{className:"ap-share-blob",children:O.blob}),i.jsxs("div",{className:"ap-share-foot",children:[i.jsx("button",{type:"button",className:"ap-manage-btn",...me(`share-${ne.num}`),onClick:async()=>{if(mt){A(!1);const ft=await xe({action:"share",account:ne.num},`share-${ne.num}`);ft!=null&&ft.ok&&M({num:ne.num,blob:ft.blob,expiresAt:ft.expiresAt});return}await M1(O.blob)&&(A(!0),window.setTimeout(()=>A(!1),1800))},children:mt?"make a new share":B?"copied":"copy"}),i.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[i.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",i.jsx("span",{className:`ap-share-expiry ${Re.tone}`,children:Re.text})]})]})]})})()]})]},ne.num)})}),(a==null?void 0:a.ok)&&i.jsxs("div",{className:"ap-auto",children:[i.jsxs("div",{className:"ap-auto-head",children:[i.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),i.jsxs("span",{className:"ap-auto-ctl",children:[Ye!=null&&i.jsxs("span",{className:`ap-auto-now${it?" near":""}`,title:`The active account has used ${Math.round(Ye)}% of its limit. Auto-switch trips at ${ye}%.`,children:[Math.round(Ye),"%"]}),i.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:i.jsx("select",{"aria-label":"Switch threshold",value:ze,...me("threshold"),onChange:ne=>G(ne.target.value),children:cq.map(ne=>i.jsxs("option",{value:ne,children:[ne,"%"]},ne))})}),i.jsx("button",{type:"button",className:"ap-manage-btn",...me("threshold"),title:ke.title,onClick:()=>ge(ze,ke),children:de?ke.done:ke.label}),i.jsx("button",{type:"button",className:`ap-auto-state${a.enabled?" live":""}`,role:"switch","aria-checked":a.enabled,"aria-label":"Auto-switch",...me("enable"),onClick:()=>ce({action:"enable",enabled:!a.enabled},"enable").then(()=>Le(!0)),title:a.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit"})]})]}),a.external&&i.jsxs("p",{className:"ap-auto-note",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",i.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",a.enabled?" — this toggle takes over when you stop it.":"."]}),a.lastTick&&i.jsx("div",{className:"ap-auto-foot",children:i.jsxs("span",{className:"ap-auto-result",children:["checked ",T1(a.lastTick.at,y)]})})]}),f&&i.jsxs("div",{className:"ap-failure",role:"alert",children:[i.jsx("span",{className:"ap-failure-text",title:f.raw||void 0,children:f.text}),i.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),i.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"These numbers only update while this panel is open."}),i.jsx(oq,{accounts:((n==null?void 0:n.accounts)??[]).map(ne=>({key:`${String(ne.email??"").trim().toLowerCase()}@@${ne.orgUuid??""}`,email:ne.email??"",alive:ne.alive===!0})),onChanged:()=>Le(!0)})]}):i.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"claude-swap isn't installed."}),i.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&i.jsx("code",{className:"ap-cmd",children:n.hint}),i.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",i.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"No accounts added yet."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",i.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"Couldn't read the account store."}),i.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),x&&i.jsx(s6,{onClose:()=>N(!1),onChanged:()=>Le(!0)}),L&&i.jsx(i6,{accounts:((n==null?void 0:n.accounts)??[]).map(ne=>({num:ne.num,email:ne.email,alias:ne.alias,org:ne.org})),onClose:()=>H(!1),copyText:M1})]})}const pq=3e4;function mq({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function gq({bundle:e,running:t,pending:n,lastTried:s}){return t?mq({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function yq(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function wq({asked:e,reported:t}){return t?t!==e:!1}function P2(e){const t=e.thresholdMs??pq;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 vq(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 xq(e,t){return e?t==null?"auto when idle":`auto in ${vq(t)}`:"auto-restart off"}function I1(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function bq(e){return e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function kq(e){const t=P2(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}}async function L2(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 _q(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Nq(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 Sq(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function jq(e,t){const n=Sq(e),s=n?`removes ${n} on the canvas`:null,a=d=>`This ${s?`${s} and ${d}`:d}`;if(!t)return{note:`${a("deletes 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. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.path)return{note:`${a("leaves nothing on disk — this deck keeps no event log")}. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};if(!t.mine){const d=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,h=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{note:`${a(`leaves the event log alone: ${d}${h}`)}. Clearing here empties this canvas only — restart this deck and the log replays back onto it. Layout, pins and selection go with it.`,confirm:"Clear this canvas"}}if(t.decks<=1)return{note:`${a("deletes this deck's event log")} — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone.`,confirm:"Clear everything"};const l=t.decks-1,c=l===1?"That deck keeps what is on its canvas until it restarts, and then it is gone there too.":"Those decks keep what is on their canvases until they restart, and then it is gone there too.";return{note:`${a(`deletes the event log ${l===1?"1 other running deck shares":`${l} other running decks share`} with this one`)} — every session recorded in it, not just the ones drawn here. ${c} This cannot be undone.`,confirm:"Clear everything"}}function Eq({agentCount:e,onConfirm:t,onCancel:n}){const s=b.useRef(null),a=Ht(n,{focusRef:s,layer:V4}),[l,c]=b.useState(null);b.useEffect(()=>{let p=!1;return fetch("/api/clear").then(f=>f.ok?f.json():null).then(f=>{p||c(Nq(f))}).catch(()=>{}),()=>{p=!0}},[]);const{note:d,confirm:h}=jq(e,l);return i.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"status-dot err","aria-hidden":!0}),i.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:d}),i.jsxs("div",{className:"cc-actions",children:[i.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const Cq="One-key shortcuts run when nothing on the page has focus. A focused control keeps its own keys — this sheet included, which takes the keyboard while it is open — so Esc is the way back to the canvas.",Tq=[{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:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function Aq({onClose:e,onTour:t}){const n=Ht(e);return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:n,className:"modal key-help",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsx("div",{className:"modal-title",children:i.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:Cq}),t&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),i.jsx("div",{className:"shortcuts",children:Tq.map(s=>i.jsxs(b.Fragment,{children:[i.jsx("h3",{className:"kh-group",children:s.title}),s.rows.map(a=>i.jsxs("div",{className:"sc",children:[i.jsx("kbd",{children:a.cap}),i.jsx("span",{children:a.action})]},`${s.title}:${a.cap}:${a.action}`))]},s.title))})]})]})})}const Rq=["done","needs-input"],Mq=[{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}]}],Iq=[{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}]}],bx={done:Mq,"needs-input":Iq},li="two";function Ov(e,t){const n=bx[e];return n.find(s=>s.id===t)??n.find(s=>s.id===li)??n[0]}function D2(e,t){return bx[e].some(s=>s.id===t)?t:li}Ov("done",li).notes,Ov("needs-input",li).notes;const $1=.04,$q=.24,Yu=0,dd=100,Pv=5,Fl=50;function Bl(e){if(!Number.isFinite(e))return Fl;const t=Math.round(e/Pv)*Pv;return Math.min(dd,Math.max(Yu,t))}function Oq(e){if(e==null)return Fl;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Bl(Number(t)):Fl}function Pq(e){const t=Bl(e),n=$1+($q-$1)*(t/dd);return Math.round(n*1e4)/1e4}function Lq(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(Pq(e)*s*1e4)/1e4}const Dq=160,qq="agent-dag.soundLevel.done",Fq="agent-dag.soundLevel.needs-input",Bq="agent-dag.soundFigure.done",zq="agent-dag.soundFigure.needs-input",q2={done:qq,"needs-input":Fq},F2={done:Bq,"needs-input":zq},Lv={done:{level:Fl,figure:li},"needs-input":{level:Fl,figure:li}};function Uq(e){const t=n=>({level:Oq(e(q2[n])),figure:D2(n,e(F2[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const Wq={Stop:"done",Notification:"needs-input"};function Hq(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:Wq[n]??null}function Gq(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,s=!1;const a=()=>e.enabled()?s&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",l=()=>{var h;return(h=e.onState)==null?void 0:h.call(e,a())};function c(){var h;if(!(!t||s))try{n=n??new t,(h=n.resume)==null||h.call(n).then(l,()=>{}),s=!0,l()}catch{}}function d(h,p=!1){var j;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const f=(((j=e.prefs)==null?void 0:j.call(e))??Lv)[h]??Lv[h],m=Ov(h,f.figure),y=Lq(f.level,m),v=n.currentTime;for(const _ of m.notes){const S=n.createOscillator(),x=n.createGain();S.type=m.type??"sine",S.frequency.value=_.hz;const N=v+_.at,E=N+_.ms/1e3;x.gain.setValueAtTime(1e-4,N),x.gain.exponentialRampToValueAtTime(y,N+.012),x.gain.exponentialRampToValueAtTime(1e-4,E),S.connect(x).connect(n.destination),S.start(N),S.stop(E+.02)}return!0}return{unlock:c,play:d,state:a,get context(){return n}}}const Vq="Notify me when a session needs my attention.",Yq="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",O1="Get notified when you're away from this tab.";function Kq(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:O1};case"default":return{status:null,ask:!0,ok:!1,note:O1};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 P1={done:"Turn finished","needs-input":"Claude is asking"},Xq={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Qq({onClose:e,soundOn:t,onToggleSound:n,prefs:s,onLevel:a,onFigure:l,onPreview:c,openerRef:d,notifyOn:h,onToggleNotify:p,notifyVetoed:f,notifyPermission:m,onAskNotify:y}){const v=Kq(m),j=h&&!f,_=Ht(e),S=b.useRef(e);return S.current=e,b.useEffect(()=>{const x=N=>{var C,R;const E=N.target;E&&((C=_.current)!=null&&C.contains(E)||(R=d.current)!=null&&R.contains(E)||S.current())};return window.addEventListener("pointerdown",x,!0),()=>window.removeEventListener("pointerdown",x,!0)},[_,d]),i.jsxs("div",{ref:_,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[i.jsxs("div",{className:"sm-switches",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),i.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"sm-toggle",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:i.jsx("span",{className:"sm-toggle-knob"})})]}),i.jsxs("div",{className:"sm-setting",children:[i.jsxs("label",{className:"sm-switch",children:[i.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications"}),i.jsx("button",{type:"button",role:"switch","aria-checked":h,"aria-labelledby":"sm-notify-label",className:"sm-toggle",onClick:p,title:"A system notification when a session blocks on you",children:i.jsx("span",{className:"sm-toggle-knob"})})]}),i.jsx("p",{className:"sm-note",children:f?Yq:Vq})]})]}),j&&i.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[i.jsxs("div",{className:"sm-channel-head",children:[i.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),v.ask?i.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:y,children:"Enable"}):i.jsxs("span",{className:"sm-channel-state","data-ok":v.ok||void 0,children:[v.ok&&i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:i.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),v.status]})]}),i.jsx("p",{className:"sm-note",children:v.note})]}),!t&&i.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),i.jsx("div",{className:"sm-tones",children:Rq.map(x=>{const N=s[x],E=`sm-level-${x}`,C=`sm-figure-${x}`;return i.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${x}`,children:[i.jsxs("div",{className:"sm-tone-head",children:[i.jsx("h3",{className:"sm-tone-name",id:`sm-name-${x}`,children:P1[x]}),i.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(x),"aria-label":`Hear the ${P1[x].toLowerCase()} tone`,title:t?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":t?void 0:"sm-preview-note",children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:i.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:E,children:"Volume"}),i.jsx("input",{id:E,type:"range",min:Yu,max:dd,step:Pv,value:N.level,onChange:R=>a(x,Number(R.target.value)),style:{"--sm-level":`${(N.level-Yu)/(dd-Yu)*100}%`}}),i.jsxs("span",{className:"sm-read",children:[N.level,"%"]})]}),i.jsxs("div",{className:"sm-row",children:[i.jsx("label",{htmlFor:C,children:"Tone"}),i.jsx("select",{id:C,className:"sm-select",value:N.figure,onChange:R=>l(x,R.target.value),children:bx[x].map(R=>i.jsx("option",{value:R.id,children:R.label},R.id))})]}),i.jsx("p",{className:"sm-note",children:Xq[x]})]},x)})}),i.jsxs("p",{className:"sm-foot",children:[i.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const Zq=15e3;function Jq(e){return e.visibilityState==="visible"&&e.hasFocus()}function eF(e,t){return t||e===!0}function tF(){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)}`}const nF={"//":["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."],"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.
82
82
 
83
83
  \`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.
84
84
 
@@ -258,17 +258,17 @@ While it is open it polls this machine once every few seconds, and it stops the
258
258
 
259
259
  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.
260
260
 
261
- 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.`}]},kx="agent-dag.releaseNotesSeen";function L1(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function li(e,t){const n=L1(e),s=L1(t);for(let a=0;a<Math.max(n.length,s.length);a++){const l=(n[a]??0)-(s[a]??0);if(l!==0)return l<0?-1:1}return 0}function ci(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function rF(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 sF(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!ci(n)||!Array.isArray(s))continue;const a=s.filter(rF);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>li(s.version,n.version))}const D1=sF(nF);function B2(e,t,n){return e.filter(s=>li(s.version,n)<=0&&(t===null||li(s.version,t)>0))}function aF(e,t){return e.filter(n=>li(n.version,t)===0)}function oF(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 iF({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 c=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${c} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&ci(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(!ci(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 l=li(a,t);return l<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:l>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 lF=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function cF(e){const t=lF.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function q1(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function uF(e){if(!e)return null;let t=null;try{t=e.getItem(kx)}catch{return null}return ci(t)?t:null}function dF(e){if(!e)return!1;try{return e.getItem(kx),!0}catch{return!1}}function hF(e,t){if(!e)return!1;try{return e.setItem(kx,t),!0}catch{return!1}}const z2="agent-dag.tourSeen";function fF(e){if(!e)return!1;try{return e.getItem(z2)==="1"}catch{return!1}}function pF(e){if(!e)return!1;try{return e.setItem(z2,"1"),!0}catch{return!1}}function mF({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 gF({stored:e,running:t,notes:n,remembers:s=!0}){if(!ci(t))return{show:[],record:null,reason:"no-version"};if(!ci(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const c=aF(n,t);return c.length?{show:c,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=li(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const l=B2(n,e,t);return l.length?{show:l,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function yF(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 U2(e,t=!0){const n=[];let s="";const a=()=>{s&&(n.push({kind:"text",text:s}),s="")};let l=0;for(;l<e.length;){if(e[l]==="`"){const c=e.indexOf("`",l+1);if(c>l+1){a(),n.push({kind:"code",text:e.slice(l+1,c)}),l=c+1;continue}}else if(t&&e.startsWith("**",l)){const c=yF(e,l);if(c>0){a(),n.push({kind:"bold",kids:U2(e.slice(l+2,c),!1)}),l=c+2;continue}}s+=e[l],l+=1}return a(),n}function wF({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:l}){const c=Ht(a),d=oF(e);return i.jsx("div",{className:"modal-backdrop",onClick:a,role:"presentation",children:i.jsxs("div",{ref:c,className:"modal release-notes",onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),d&&i.jsx("span",{className:"modal-tool-id",children:d})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:iF({since:t,running:n,firstRun:s,entries:e})}),l&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:l,children:"Take the tour"})]}),e.map(h=>i.jsxs("section",{className:"modal-section",children:[i.jsxs("h3",{className:"rn-version",children:["v",h.version]}),i.jsx("ul",{className:"rn-notes",children:h.notes.map((p,f)=>{const{icon:m,rest:y}=cF(p.title);return i.jsxs("li",{className:"rn-note",children:[i.jsxs("p",{className:"rn-note-title",children:[m&&i.jsx("span",{className:"rn-note-icon",children:m}),y]}),i.jsx("p",{className:"rn-note-body",children:W2(U2(p.body))})]},f)})})]},h.version))]})]})})}function W2(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?i.jsx("code",{className:"rn-code",children:t.text},n):i.jsx("strong",{className:"rn-strong",children:W2(t.kids)},n))}function vF(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function xF(e,t,n){var c;if(e.length===0)return null;const s=vF(e),a=t?s.findIndex(d=>d.id===t):-1,l=a===-1?n===1?0:s.length-1:(a+n+s.length)%s.length;return((c=s[l])==null?void 0:c.id)??null}const bF=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function kF(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:bF.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const _F=new Set(["","BODY","HTML","#DOCUMENT"]);function NF(e){return!e||dx(e)?!1:!_F.has(String(e.tagName??"").toUpperCase())}function Mu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function SF(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 jF(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`);return t}function EF(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let a=t;for(;a;){const c=e.agents.get(a);if(!(c!=null&&c.parentId)||s.has(c.parentId))break;s.add(c.parentId),a=c.parentId}let l=!0;for(;l;){l=!1;for(const c of e.agents.values())c.parentId&&s.has(c.parentId)&&!s.has(c.id)&&(s.add(c.id),l=!0)}return s}function CF(e,t){const n=new Set;for(const s of t){const a=EF(e,s);if(a)for(const l of a)n.add(l)}return n.size>0?n:null}function H2(e,t,n){return!t.has(e)||n.has(e)}function TF(e,t,n,s){return!t.has(e)&&H2(e,n,s)}function AF(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function RF(e,t,n,s){n.set(e,t),s.delete(e)}const MF=40,IF=120;function $F(e,t){let n=null,s=0,a=Number.NEGATIVE_INFINITY;const l=()=>{n=null,a=t.now(),e()},c=()=>{n!=null&&(t.clearTimeout(n),n=null)},d=(h,p,f)=>{if(n!=null){if(s<=h)return;c()}const m=Math.min(f,Math.max(0,h-p));s=h,n=t.setTimeout(l,m)};return{live(h=MF){const p=t.now(),f=Math.max(a+h,p);if(f<=p){c(),l();return}d(f,p,h)},replay(h=IF){c(),s=t.now()+h,n=t.setTimeout(l,h)},flush(){c(),l()},cancel(){c()}}}const OF=1e3;function PF(e={}){const t=Math.max(1,Math.floor(e.limit??OF)),n=e.protect;let s=!1,a=[],l=new Set,c=0,d=0,h=null;return{get paused(){return s},get size(){return a.length},get dropped(){return c},get overflowed(){return c>0},get through(){return d},accept(p){const f=typeof(p==null?void 0:p.seq)=="number"?p.seq:null,m=(p==null?void 0:p.epoch)??null,y=m!==null&&m!==h;y&&(h=m,d=0);const v=f!==null&&!y&&f<=d;if(f!==null&&f>d&&(d=f),!s)return!0;if(v)return!1;if(a.push(p),n!=null&&n(p)&&l.add(p),a.length>t){let j=0;if(l.size<a.length)for(;l.has(a[j]);)j++;const[_]=a.splice(j,1);l.delete(_),c++}return!1},setPaused(p){if(s=p,p)return[];const f=a;return a=[],l=new Set,c=0,f}}}const G2="agent-dag.theme";function LF(e){return e==="light"?"light":"dark"}function DF(){return LF(hi(G2))}function qF({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Wt}`:Wt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const Iu={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function $u(e,t){const a=c=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${c}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?a(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):a("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const FF=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent($u(Iu.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent($u(Iu.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent($u(Iu.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent($u(Iu.idle,"idle"))}`}),BF="No sessions are waiting for you.";function zF(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const s=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${s} are waiting for your permission.`}function UF(e,t){return t!==""?t:e===""?"":BF}function WF(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function HF(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function GF(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const F1={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function _x(e){const t=e.toLowerCase();return Object.hasOwn(F1,t)?F1[t]:t?t[0].toUpperCase()+t.slice(1):""}function VF(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function YF(e,t=[]){const n=t.length?VF(t.map(_x)):GF(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function KF(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 XF(e,t){const n=t.prefs??Pv,s=Fl(n.done.level),a=Fl(n["needs-input"].level),l=s===a?`${s}%`:`${s}% and ${a}%`,c=t.on?`Sound: on at ${l} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",d=e.codex?`
261
+ 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.`}]},kx="agent-dag.releaseNotesSeen";function L1(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function ci(e,t){const n=L1(e),s=L1(t);for(let a=0;a<Math.max(n.length,s.length);a++){const l=(n[a]??0)-(s[a]??0);if(l!==0)return l<0?-1:1}return 0}function ui(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function rF(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 sF(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!ui(n)||!Array.isArray(s))continue;const a=s.filter(rF);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>ci(s.version,n.version))}const D1=sF(nF);function B2(e,t,n){return e.filter(s=>ci(s.version,n)<=0&&(t===null||ci(s.version,t)>0))}function aF(e,t){return e.filter(n=>ci(n.version,t)===0)}function oF(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 iF({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 c=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${c} changed something you would notice. Clicking the version in the topbar brings this back.`}if(s&&ui(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(!ui(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 l=ci(a,t);return l<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:l>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 lF=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function cF(e){const t=lF.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function q1(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function uF(e){if(!e)return null;let t=null;try{t=e.getItem(kx)}catch{return null}return ui(t)?t:null}function dF(e){if(!e)return!1;try{return e.getItem(kx),!0}catch{return!1}}function hF(e,t){if(!e)return!1;try{return e.setItem(kx,t),!0}catch{return!1}}const z2="agent-dag.tourSeen";function fF(e){if(!e)return!1;try{return e.getItem(z2)==="1"}catch{return!1}}function pF(e){if(!e)return!1;try{return e.setItem(z2,"1"),!0}catch{return!1}}function mF({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 gF({stored:e,running:t,notes:n,remembers:s=!0}){if(!ui(t))return{show:[],record:null,reason:"no-version"};if(!ui(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const c=aF(n,t);return c.length?{show:c,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 l=B2(n,e,t);return l.length?{show:l,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function yF(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 U2(e,t=!0){const n=[];let s="";const a=()=>{s&&(n.push({kind:"text",text:s}),s="")};let l=0;for(;l<e.length;){if(e[l]==="`"){const c=e.indexOf("`",l+1);if(c>l+1){a(),n.push({kind:"code",text:e.slice(l+1,c)}),l=c+1;continue}}else if(t&&e.startsWith("**",l)){const c=yF(e,l);if(c>0){a(),n.push({kind:"bold",kids:U2(e.slice(l+2,c),!1)}),l=c+2;continue}}s+=e[l],l+=1}return a(),n}function wF({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:l}){const c=Ht(a),d=oF(e);return i.jsx("div",{className:"modal-backdrop",onClick:a,role:"presentation",children:i.jsxs("div",{ref:c,className:"modal release-notes",onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),d&&i.jsx("span",{className:"modal-tool-id",children:d})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsx("p",{className:"modal-note",children:iF({since:t,running:n,firstRun:s,entries:e})}),l&&i.jsxs("div",{className:"guide-door",children:[i.jsx("span",{children:"Eight pictures of what the deck shows."}),i.jsx("button",{type:"button",className:"btn",onClick:l,children:"Take the tour"})]}),e.map(h=>i.jsxs("section",{className:"modal-section",children:[i.jsxs("h3",{className:"rn-version",children:["v",h.version]}),i.jsx("ul",{className:"rn-notes",children:h.notes.map((p,f)=>{const{icon:m,rest:y}=cF(p.title);return i.jsxs("li",{className:"rn-note",children:[i.jsxs("p",{className:"rn-note-title",children:[m&&i.jsx("span",{className:"rn-note-icon",children:m}),y]}),i.jsx("p",{className:"rn-note-body",children:W2(U2(p.body))})]},f)})})]},h.version))]})]})})}function W2(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?i.jsx("code",{className:"rn-code",children:t.text},n):i.jsx("strong",{className:"rn-strong",children:W2(t.kids)},n))}function vF(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function xF(e,t,n){var c;if(e.length===0)return null;const s=vF(e),a=t?s.findIndex(d=>d.id===t):-1,l=a===-1?n===1?0:s.length-1:(a+n+s.length)%s.length;return((c=s[l])==null?void 0:c.id)??null}const bF=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function kF(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:bF.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const _F=new Set(["","BODY","HTML","#DOCUMENT"]);function NF(e){return!e||dx(e)?!1:!_F.has(String(e.tagName??"").toUpperCase())}function Iu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function SF(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 jF(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`);return t}function EF(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let a=t;for(;a;){const c=e.agents.get(a);if(!(c!=null&&c.parentId)||s.has(c.parentId))break;s.add(c.parentId),a=c.parentId}let l=!0;for(;l;){l=!1;for(const c of e.agents.values())c.parentId&&s.has(c.parentId)&&!s.has(c.id)&&(s.add(c.id),l=!0)}return s}function CF(e,t){const n=new Set;for(const s of t){const a=EF(e,s);if(a)for(const l of a)n.add(l)}return n.size>0?n:null}function H2(e,t,n){return!t.has(e)||n.has(e)}function TF(e,t,n,s){return!t.has(e)&&H2(e,n,s)}function AF(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function RF(e,t,n,s){n.set(e,t),s.delete(e)}const MF=40,IF=120;function $F(e,t){let n=null,s=0,a=Number.NEGATIVE_INFINITY;const l=()=>{n=null,a=t.now(),e()},c=()=>{n!=null&&(t.clearTimeout(n),n=null)},d=(h,p,f)=>{if(n!=null){if(s<=h)return;c()}const m=Math.min(f,Math.max(0,h-p));s=h,n=t.setTimeout(l,m)};return{live(h=MF){const p=t.now(),f=Math.max(a+h,p);if(f<=p){c(),l();return}d(f,p,h)},replay(h=IF){c(),s=t.now()+h,n=t.setTimeout(l,h)},flush(){c(),l()},cancel(){c()}}}const OF=1e3;function PF(e={}){const t=Math.max(1,Math.floor(e.limit??OF)),n=e.protect;let s=!1,a=[],l=new Set,c=0,d=0,h=null;return{get paused(){return s},get size(){return a.length},get dropped(){return c},get overflowed(){return c>0},get through(){return d},accept(p){const f=typeof(p==null?void 0:p.seq)=="number"?p.seq:null,m=(p==null?void 0:p.epoch)??null,y=m!==null&&m!==h;y&&(h=m,d=0);const v=f!==null&&!y&&f<=d;if(f!==null&&f>d&&(d=f),!s)return!0;if(v)return!1;if(a.push(p),n!=null&&n(p)&&l.add(p),a.length>t){let j=0;if(l.size<a.length)for(;l.has(a[j]);)j++;const[_]=a.splice(j,1);l.delete(_),c++}return!1},setPaused(p){if(s=p,p)return[];const f=a;return a=[],l=new Set,c=0,f}}}const G2="agent-dag.theme";function LF(e){return e==="light"?"light":"dark"}function DF(){return LF(fi(G2))}function qF({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Wt}`:Wt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const $u={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Ou(e,t){const a=c=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${c}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?a(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):a("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const FF=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent(Ou($u.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent(Ou($u.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Ou($u.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Ou($u.idle,"idle"))}`}),BF="No sessions are waiting for you.";function zF(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const s=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${s} are waiting for your permission.`}function UF(e,t){return t!==""?t:e===""?"":BF}function WF(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function HF(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function GF(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const F1={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function _x(e){const t=e.toLowerCase();return Object.hasOwn(F1,t)?F1[t]:t?t[0].toUpperCase()+t.slice(1):""}function VF(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function YF(e,t=[]){const n=t.length?VF(t.map(_x)):GF(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function KF(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 XF(e,t){const n=t.prefs??Lv,s=Bl(n.done.level),a=Bl(n["needs-input"].level),l=s===a?`${s}%`:`${s}% and ${a}%`,c=t.on?`Sound: on at ${l} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",d=e.codex?`
262
262
 
263
263
  Both CLIs get the finish tone. The second tone — Claude is waiting for you — has no Codex equivalent to fire on, so it only ever plays for Claude Code.`:"",h=t.on&&t.locked?`
264
264
 
265
265
  Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return c+d+h+`
266
266
 
267
- Click to set the volume and the sound of each tone, and to hear either one.`}function V2(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const a=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};a.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,a.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,a)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function QF(e){const t=V2([{agents:e}]);return t.length<2?null:t.map(n=>`${_x(n.id)} ${tt(n.cost)}`).join(" · ")}function B1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function ZF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Ou(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const JF=[7,14,30,90];function e8(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(WF)[0],c=b.useRef(!1),d=(h=!1)=>{if(h&&!hr(c.current))return;const p=l.begin();c.current=h;const f=e;a(!0);const y=`/api/ccusage?since=${Ev(f)}${h?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:f,resp:v})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(d(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>d(!0)}}function t8({onClose:e,providers:t}){var F;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:d,reload:h}=e8(n),p=b.useRef(null),f=Ht(e,{focusRef:p}),m=HF({loading:d,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((F=c.resp.days)==null?void 0:F.length)??0}}),y=m.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((O,M)=>Math.max(O,M.totalCost),0),[y]),j=b.useRef(null);b.useLayoutEffect(()=>{const O=j.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:_,totalTok:S,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let O=0,M=0,L=0,H=0;const B=new Map;for(const A of y){O+=A.totalCost,M+=A.totalTokens,L+=A.inputTokens+A.outputTokens,H+=A.cacheReadTokens;for(const Q of A.modelBreakdowns)B.set(Q.modelName,(B.get(Q.modelName)??0)+Q.cost)}return{totalCost:O,totalTok:M,inOut:L,cacheRead:H,modelCosts:B}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((O,M)=>M[1]-O[1]),[E]),R=b.useMemo(()=>V2(y),[y]),I=R.length>1,$=a?y.find(O=>O.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[i.jsxs("header",{className:"uh-head",children:[i.jsxs("div",{className:"uh-titlewrap",children:[i.jsx("div",{className:"uh-title",children:"Usage history"}),i.jsx("div",{className:"uh-sub",children:YF(t,R.map(O=>O.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:JF.map(O=>i.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),l(null)},children:[O,"d"]},O))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...dr(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?i.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[i.jsx("span",{className:"uh-wait-word",children:c?"running ccusage…":"running ccusage… (first run downloads the package)"}),i.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):m.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:oi(c.resp)||void 0,children:[XD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:h,...dr(d),children:d?"trying…":"Try again"})})]}):m.phase==="empty"?i.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Pu,{label:"total cost",val:tt(_),accent:!0}),i.jsx(Pu,{label:"tokens",val:At(S)}),i.jsx(Pu,{label:"input+output",val:At(x)}),i.jsx(Pu,{label:"cache reads",val:At(N)})]}),I&&i.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[i.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:R.map(O=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?O.cost/_*100:0}%`,background:B1(O.id)}},O.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(O=>i.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${At(O.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:B1(O.id)}}),_x(O.id),i.jsx("span",{className:"uh-agent-cost",children:tt(O.cost)}),i.jsx("span",{className:"uh-agent-share",children:ZF(O.cost,_)})]},O.id))})]}),i.jsx("div",{ref:j,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((O,M)=>{const L=v>0?O.totalCost/v*100:0,H=O.period===a,B=`${O.period}, ${tt(O.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${H?" sel":""}`,onClick:()=>l(H?null:O.period),"aria-pressed":H,"aria-label":B,title:`${O.period} · ${tt(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`,"--uh-i":M,"--uh-step":`${Math.min(10,200/Math.max(y.length,1))}ms`},children:[i.jsx("div",{className:"uh-bar",style:{height:`${Math.max(L,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((A,Q)=>Q.cost-A.cost).map(A=>{const Q=O.totalCost>0?A.cost/O.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Q}%`,background:Ou(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([O,M])=>i.jsxs("span",{className:"uh-legend-item",title:O,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O)}}),Ys(O)," ",i.jsx("span",{className:"uh-legend-cost",children:tt(M)})]},O))}),$&&i.jsxs("div",{className:"uh-detail",children:[i.jsxs("div",{className:"uh-detail-head",children:[i.jsx("span",{className:"uh-detail-date",children:$.period}),i.jsx("span",{className:"uh-detail-cost",children:tt($.totalCost)}),(()=>{var L,H;const M=QF($.agents)??((H=(L=$.metadata)==null?void 0:L.agents)!=null&&H.length?$.metadata.agents.join(" · "):null);return M?i.jsx("span",{className:"uh-detail-agents",title:M,children:M}):null})()]}),i.jsxs("div",{className:"uh-detail-mini",children:[i.jsx(Lu,{label:"input",val:At($.inputTokens)}),i.jsx(Lu,{label:"output",val:At($.outputTokens)}),i.jsx(Lu,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Lu,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((O,M)=>M.cost-O.cost).map(O=>{const M=$.totalCost>0?O.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Ou(O.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ys(O.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Ou(O.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:tt(O.cost)})]},O.modelName)})})]})]})]})})}function Pu({label:e,val:t,accent:n}){return i.jsxs("div",{className:"uh-stat",children:[i.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),i.jsx("span",{className:"uh-stat-label",children:e})]})}function Lu({label:e,val:t}){return i.jsxs("div",{className:"uh-ministat",children:[i.jsx("span",{className:"uh-ministat-val",children:t}),i.jsx("span",{className:"uh-ministat-label",children:e})]})}function n8(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(a=>{const l=a/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const z1=1e4,r8=12e3;function s8({browsers:e,findings:t,watching:n,palette:s,now:a=()=>Date.now()}){const l=b.useRef(null),c=b.useRef(null);return c.current={browsers:e,findings:t,watching:n},b.useEffect(()=>{var v;const d=l.current;if(!d)return;const h=d.getContext("2d");if(!h)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,m=!1;const y=()=>{var ee;if(m)return;const j=c.current;if(!j)return;const{browsers:_,findings:S,watching:x}=j,N=s["--accent"]||"#7dd3fc",E=s["--line"]||"#1f2229",C=s["--text-dim"]||"#6e727c",R=n8(s["--bg"]),I=R?42:26,$=R?.85:.65,F=a(),O=Math.min(window.devicePixelRatio||1,2),M=d.clientWidth,L=d.clientHeight;(d.width!==M*O||d.height!==L*O)&&(d.width=M*O,d.height=L*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,M,L);const H=M/2,B=L/2,A=Math.min(M,L)/2-6;h.strokeStyle=E,h.lineWidth=1,h.globalAlpha=R?1:.9;for(const Z of[.4,.7,1])h.beginPath(),h.arc(H,B,A*Z,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-A,B),h.lineTo(H+A,B),h.moveTo(H,B-A),h.lineTo(H,B+A),h.stroke(),h.globalAlpha=1;const K=(x&&!p?F%z1/z1:0)*Math.PI*2-Math.PI/2;if(x){const Z=(ee=h.createConicGradient)==null?void 0:ee.call(h,K-.85,H,B);Z&&(Z.addColorStop(0,"transparent"),Z.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Z.addColorStop(1,"transparent"),h.fillStyle=Z,h.beginPath(),h.moveTo(H,B),h.arc(H,B,A,K-.85,K),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=$,h.beginPath(),h.moveTo(H,B),h.lineTo(H+Math.cos(K)*A,B+Math.sin(K)*A),h.stroke(),h.globalAlpha=1}_.forEach((Z,D)=>{const Y=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,P=Z.lastReadMs===null?1:Math.min(1,(F-Z.lastReadMs)/12e4),G=A*(.42+P*.5),de=H+Math.cos(Y)*G,W=B+Math.sin(Y)*G,U=Math.abs((K-Y+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;h.beginPath(),h.arc(de,W,3+J*1.6,0,Math.PI*2),h.fillStyle=Z.running?N:C,h.globalAlpha=Z.running?.55+J*.45:.35,h.fill(),h.globalAlpha=1});for(const Z of S){const D=(F-Z.atMs)/r8;if(D<0||D>1)continue;const P=Math.max(0,_.findIndex(W=>W.key===Z.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos(P)*A*.6,de=B+Math.sin(P)*A*.6;h.beginPath(),h.arc(G,de,4+D*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-D)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{m=!0,cancelAnimationFrame(f)}},[a,s]),i.jsx("canvas",{ref:l,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const U1="agent-dag.browserWatch.seenMs";function a8(e,t){return e.filter(n=>n.startMs>t)}function o8(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function i8(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 Y2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function W1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function l8(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 c8(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 u8(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=Y2(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."}}function d8(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function h8(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function H1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function f8({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Ht(e),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),[m,y]=b.useState(!1),v=b.useRef(!1),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(!1),C=b.useRef(!1),[R,I]=b.useState(!1),[$,F]=b.useState(!1),[O,M]=b.useState(!1),[L,H]=b.useState(!1),[B,A]=b.useState(!1),[Q,K]=b.useState(()=>Date.now());b.useEffect(()=>{const V=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(V)},[]);const ee=b.useCallback(async V=>{var ie,pe;if(!(V&&!hr(v.current))){v.current=V,y(!0);try{const me=await fetch(`/api/browser-watch${V?"?refresh=1":""}`);if(!me.ok)throw new Error(`the deck answered ${me.status}`);const Ie=await me.json();c(Ie),C.current||_(((ie=Ie==null?void 0:Ie.settings)==null?void 0:ie.quietMinutes)??15),n(((pe=Ie==null?void 0:Ie.settings)==null?void 0:pe.enabled)===!0),h(null)}catch(me){h(me instanceof Error?me.message:String(me))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{ee(!1)},[ee]),b.useEffect(()=>{const V=setInterval(()=>{ee(!1)},1e4);return()=>clearInterval(V)},[ee]);const Z=b.useCallback(async V=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:V.host,startMs:V.startMs})})}finally{await ee(!1)}},[ee]),D=b.useCallback(async V=>{C.current=!0,E(!0);try{const ie=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)});if(!ie.ok)throw new Error(`the deck answered ${ie.status}`);await ee(!1),f(null)}catch(ie){f(ie instanceof Error?ie.message:String(ie))}finally{C.current=!1,E(!1)}},[ee]),Y=b.useRef(t);Y.current=t,b.useEffect(()=>()=>Y.current(Date.now()),[]);const P=b.useMemo(()=>{const V=[];for(const ie of(l==null?void 0:l.episodes)??[]){const pe=h8(ie.startMs),me=V[V.length-1];me&&me.label===pe?me.episodes.push(ie):V.push({label:pe,episodes:[ie]})}return V},[l]),G=Y2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(V=>!(V.installed&&V.profiles>0)),W=l?u8(l):null,U=G.reduce((V,ie)=>V+ie.profiles,0),J=l?o8(l.coverage.lastHumanMs,l.coverage.quietMs,Q):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:V=>V.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),i.jsx("span",{className:"modal-tool-id",children:l?`${U} ${U===1?"profile":"profiles"} · local only`:"local only"})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("button",{className:"glyph-btn",onClick:()=>void ee(!0),...dr(m),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:m?"…":"↻"}),i.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body bw-body",children:[!l&&!d&&i.jsxs("div",{className:"bw-loading",children:[i.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),i.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),d&&i.jsx("div",{className:"bw-state",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not read"}),i.jsx("span",{className:"bw-row-detail",children:d})]})}),l&&W&&i.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),l&&i.jsxs("div",{className:"bw-work",children:[i.jsxs("aside",{className:"bw-side",children:[i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",i.jsx("button",{className:"bw-help",onClick:()=>M(V=>!V),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(s8,{browsers:G.map(V=>{var ie;return{key:V.key,name:V.name,running:V.running,lastReadMs:((ie=l.profiles.find(pe=>pe.browser===V.key))==null?void 0:ie.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(V=>({browser:V.browser??null,atMs:V.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:l8(G,l.profiles).map(V=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:V.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:V.name})]},V.key))})]}),i.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),l.coverage.checkedMs>0&&i.jsxs("p",{className:"bw-since",children:["Last checked ",c8(l.coverage.checkedMs,Q),l.coverage.checks>0&&i.jsxs(i.Fragment,{children:[" · ",l.coverage.checks.toLocaleString("en-US")," ",l.coverage.checks===1?"check":"checks"]})]}),J!==null&&i.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",i8(J)]}),O&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Sweep"}),i.jsx("dd",{children:"one poll of every watched profile"}),i.jsx("dt",{children:"Dot"}),i.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),i.jsx("dt",{children:"Ring"}),i.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",i.jsx("button",{className:"bw-help",onClick:()=>H(V=>!V),"aria-expanded":L,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),L&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Running"}),i.jsx("dd",{children:"the browser has a process on this machine right now"}),i.jsx("dt",{children:"Connected"}),i.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),i.jsx("ul",{className:"bw-profiles",children:G.map(V=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${V.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:V.name}),i.jsx("span",{className:"bw-prof-state",children:V.running?"running":"idle"}),V.running&&V.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},V.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(V=>!V),"aria-expanded":B,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:B?"▾":"▸"})," ",de.length," not watched"]}),B&&i.jsxs("p",{className:"bw-rest",children:[de.map(V=>V.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(p8,{relay:l.relay})]}),i.jsxs("div",{className:"bw-main",children:[i.jsxs("section",{className:"bw-findings",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",l.episodes.length>0&&i.jsxs("span",{className:"bw-feed-count",children:[l.episodes.length," ",l.episodes.length===1?"episode":"episodes"]})]}),i.jsx("div",{className:"bw-eps",children:P.length===0?i.jsxs("div",{className:"bw-empty",children:[i.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),i.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",l.settings.quietMinutes," ",l.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!l.settings.enabled&&i.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):P.map(V=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:V.label}),V.episodes.map(ie=>{const pe=`${ie.host}-${ie.startMs}`,me=S===pe;return i.jsxs("div",{className:`bw-ep${me?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(me?null:pe),"aria-expanded":me,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:me?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:ie.host}),i.jsxs("span",{className:"bw-ep-meta",children:[d8(ie),H1(ie)&&i.jsxs(i.Fragment,{children:[" · ",H1(ie)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[ie.count," ",ie.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Z(ie),"aria-label":`Dismiss ${ie.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),me&&i.jsx("ul",{className:"bw-urls",children:ie.urls.map((Ie,Le)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ie.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ie.url})]},`${Ie.url}-${Ie.timeMs}-${Le}`))})]},pe)})]},V.label))})]}),i.jsxs("section",{className:"bw-feed",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",i.jsxs("span",{className:"bw-feed-count",children:[l.log.length," ",l.log.length===1?"event":"events"]})]}),i.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),i.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:l.log.length===0?i.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):l.log.map(V=>i.jsxs("div",{className:`bw-log-line ${V.level}${V.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(V.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),V.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:V.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:V.parts.profile,children:V.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[V.parts.value,V.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",V.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:V.text})]},`${V.atMs}-${V.level}-${V.text}`))})]})]})]}),l&&R&&i.jsxs("div",{className:"bw-settings",children:[i.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[i.jsx("span",{children:"Nobody browsing for"}),i.jsxs("select",{value:j??l.settings.quietMinutes,onChange:V=>{_(Number(V.target.value)),D({quietMinutes:Number(V.target.value)})},children:[i.jsx("option",{value:1,children:"1 min"}),i.jsx("option",{value:5,children:"5 min"}),i.jsx("option",{value:15,children:"15 min"}),i.jsx("option",{value:30,children:"30 min"}),i.jsx("option",{value:60,children:"60 min"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"When it finds one"}),i.jsx("select",{value:l.settings.reaction,onChange:V=>void D({reaction:V.target.value}),disabled:!l.settings.enabled,title:l.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(l.reactions??["notify"]).map(V=>i.jsx("option",{value:V,children:V==="notify"?"notify me":V==="close-tab"?"close the tab":"quit the browser"},V))})]}),i.jsxs("div",{className:"bw-settings-note",children:[i.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",i.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),i.jsxs("button",{className:"bw-why",onClick:()=>F(V=>!V),"aria-expanded":$,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:$?"▾":"▸"})," What Browser Watch can access"]}),$&&i.jsxs("dl",{className:"bw-access",children:[i.jsx("dt",{children:"Reads"}),i.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(l.coverage.startedMs).toLocaleString(),"."]}),i.jsx("dt",{children:"Keeps"}),i.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",i.jsx("code",{className:"bw-path",children:l.coverage.logPath}),", with every address written in full so you can check it yourself."]}),i.jsx("dt",{children:"Sends"}),i.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),i.jsx("dt",{children:"Never reads"}),i.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),p&&i.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),i.jsxs("span",{className:"bw-row-detail",children:[p," — the switches below show what is stored, not what you pressed."]}),i.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>f(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),l&&i.jsxs("footer",{className:"bw-status",children:[i.jsx("span",{className:`bw-mode-dot${l.settings.enabled?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-mode-word",children:W1(l,N).word},W1(l,N).kind),i.jsx("span",{className:"bw-status-text",children:l.coverage.archived===0?l.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${l.coverage.archived} ${l.coverage.archived===1?"episode":"episodes"} on disk`}),i.jsx("button",{className:`glyph-btn bw-gear${R?" on":""}`,onClick:()=>I(V=>!V),"aria-expanded":R,"aria-label":"Settings",title:"Settings",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),i.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),i.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[i.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),i.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":l.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void D({enabled:!l.settings.enabled}),title:l.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:i.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function p8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],d=b.useCallback(async()=>{await L2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),h=e.profiles.filter(f=>{var m;return(m=f.report)==null?void 0:m.present}),p=e.profiles.filter(f=>f.report===null);return i.jsxs("section",{className:"bw-sec",children:[i.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),i.jsx("p",{className:`bw-rc-verdict ${e.verdict}`,role:"status",children:e.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":e.verdict==="protected"?`The relay is black-holed in ${e.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),e.killswitch.foreign.length>0&&i.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",e.hostsPath,", and ccdeck will not touch it:",e.killswitch.foreign.map(f=>i.jsx("code",{className:"bw-path",children:f},f))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(f=>!f),"aria-expanded":t,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",e.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&i.jsxs("div",{className:"bw-rc-body",children:[h.length>0&&i.jsx("dl",{className:"bw-key",children:h.map(f=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[f.name,f.profile==="Default"?"":` · ${f.profile}`]}),i.jsxs("dd",{children:[f.report.enabled?"enabled":"installed but switched off",f.report.allUrls?", can act on every site":", limited to the sites it was granted",f.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",f.report.sensitiveApis.join(", ")]})]})]},`${f.browser}/${f.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(f=>f.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!e.hostsRead&&i.jsxs("p",{className:"bw-rc-note",children:[e.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),h.some(f=>f.report.allUrls)&&i.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",i.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),i.jsxs("div",{className:"bw-rc-cmd",children:[i.jsx("code",{children:c.command}),i.jsx("button",{className:"btn bw-rc-copy",onClick:d,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function m8(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,l)=>(a.at??0)-(l.at??0));return{request:s[0],waiting:s.length-1}}function g8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const d=b.useRef(null),h=Ht(c,{focusRef:d}),p=Ks(n,"accept"),f=Ks(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:h,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0}),i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:c,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("p",{className:"lan-ask-who",children:[i.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",i.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",xx(e.at,s)]}),i.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),i.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",i.jsx("code",{className:"ap-lan-code",children:e.fp})," — it should match the one on their screen."]}),t>0&&i.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),i.jsxs("div",{className:"lan-ask-acts",children:[i.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:l,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.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 Nx(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 Df,G1;function y8(){if(G1)return Df;G1=1;function e(){this.__data__=[],this.size=0}return Df=e,Df}var qf,V1;function fi(){if(V1)return qf;V1=1;function e(t,n){return t===n||t!==t&&n!==n}return qf=e,qf}var Ff,Y1;function jd(){if(Y1)return Ff;Y1=1;var e=fi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Ff=t,Ff}var Bf,K1;function w8(){if(K1)return Bf;K1=1;var e=jd(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var d=l.length-1;return c==d?l.pop():n.call(l,c,1),--this.size,!0}return Bf=s,Bf}var zf,X1;function v8(){if(X1)return zf;X1=1;var e=jd();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return zf=t,zf}var Uf,Q1;function x8(){if(Q1)return Uf;Q1=1;var e=jd();function t(n){return e(this.__data__,n)>-1}return Uf=t,Uf}var Wf,Z1;function b8(){if(Z1)return Wf;Z1=1;var e=jd();function t(n,s){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,s])):a[l][1]=s,this}return Wf=t,Wf}var Hf,J1;function Ed(){if(J1)return Hf;J1=1;var e=y8(),t=w8(),n=v8(),s=x8(),a=b8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Hf=l,Hf}var Gf,e_;function k8(){if(e_)return Gf;e_=1;var e=Ed();function t(){this.__data__=new e,this.size=0}return Gf=t,Gf}var Vf,t_;function _8(){if(t_)return Vf;t_=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Vf=e,Vf}var Yf,n_;function N8(){if(n_)return Yf;n_=1;function e(t){return this.__data__.get(t)}return Yf=e,Yf}var Kf,r_;function S8(){if(r_)return Kf;r_=1;function e(t){return this.__data__.has(t)}return Kf=e,Kf}var Xf,s_;function K2(){if(s_)return Xf;s_=1;var e=typeof gu=="object"&&gu&&gu.Object===Object&&gu;return Xf=e,Xf}var Qf,a_;function yr(){if(a_)return Qf;a_=1;var e=K2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Qf=n,Qf}var Zf,o_;function pi(){if(o_)return Zf;o_=1;var e=yr(),t=e.Symbol;return Zf=t,Zf}var Jf,i_;function j8(){if(i_)return Jf;i_=1;var e=pi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var d=n.call(c,a),h=c[a];try{c[a]=void 0;var p=!0}catch{}var f=s.call(c);return p&&(d?c[a]=h:delete c[a]),f}return Jf=l,Jf}var ep,l_;function E8(){if(l_)return ep;l_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ep=n,ep}var tp,c_;function Xa(){if(c_)return tp;c_=1;var e=pi(),t=j8(),n=E8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(d){return d==null?d===void 0?a:s:l&&l in Object(d)?t(d):n(d)}return tp=c,tp}var np,u_;function Yn(){if(u_)return np;u_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return np=e,np}var rp,d_;function ec(){if(d_)return rp;d_=1;var e=Xa(),t=Yn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(d){if(!t(d))return!1;var h=e(d);return h==s||h==a||h==n||h==l}return rp=c,rp}var sp,h_;function C8(){if(h_)return sp;h_=1;var e=yr(),t=e["__core-js_shared__"];return sp=t,sp}var ap,f_;function T8(){if(f_)return ap;f_=1;var e=C8(),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 ap=n,ap}var op,p_;function X2(){if(p_)return op;p_=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 op=n,op}var ip,m_;function A8(){if(m_)return ip;m_=1;var e=ec(),t=T8(),n=Yn(),s=X2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,d=Object.prototype,h=c.toString,p=d.hasOwnProperty,f=RegExp("^"+h.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var v=e(y)?f:l;return v.test(s(y))}return ip=m,ip}var lp,g_;function R8(){if(g_)return lp;g_=1;function e(t,n){return t==null?void 0:t[n]}return lp=e,lp}var cp,y_;function Qa(){if(y_)return cp;y_=1;var e=A8(),t=R8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return cp=n,cp}var up,w_;function Sx(){if(w_)return up;w_=1;var e=Qa(),t=yr(),n=e(t,"Map");return up=n,up}var dp,v_;function Cd(){if(v_)return dp;v_=1;var e=Qa(),t=e(Object,"create");return dp=t,dp}var hp,x_;function M8(){if(x_)return hp;x_=1;var e=Cd();function t(){this.__data__=e?e(null):{},this.size=0}return hp=t,hp}var fp,b_;function I8(){if(b_)return fp;b_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return fp=e,fp}var pp,k_;function $8(){if(k_)return pp;k_=1;var e=Cd(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var d=c[l];return d===t?void 0:d}return s.call(c,l)?c[l]:void 0}return pp=a,pp}var mp,__;function O8(){if(__)return mp;__=1;var e=Cd(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return mp=s,mp}var gp,N_;function P8(){if(N_)return gp;N_=1;var e=Cd(),t="__lodash_hash_undefined__";function n(s,a){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&a===void 0?t:a,this}return gp=n,gp}var yp,S_;function L8(){if(S_)return yp;S_=1;var e=M8(),t=I8(),n=$8(),s=O8(),a=P8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,yp=l,yp}var wp,j_;function D8(){if(j_)return wp;j_=1;var e=L8(),t=Ed(),n=Sx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return wp=s,wp}var vp,E_;function q8(){if(E_)return vp;E_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return vp=e,vp}var xp,C_;function Td(){if(C_)return xp;C_=1;var e=q8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return xp=t,xp}var bp,T_;function F8(){if(T_)return bp;T_=1;var e=Td();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return bp=t,bp}var kp,A_;function B8(){if(A_)return kp;A_=1;var e=Td();function t(n){return e(this,n).get(n)}return kp=t,kp}var _p,R_;function z8(){if(R_)return _p;R_=1;var e=Td();function t(n){return e(this,n).has(n)}return _p=t,_p}var Np,M_;function U8(){if(M_)return Np;M_=1;var e=Td();function t(n,s){var a=e(this,n),l=a.size;return a.set(n,s),this.size+=a.size==l?0:1,this}return Np=t,Np}var Sp,I_;function jx(){if(I_)return Sp;I_=1;var e=D8(),t=F8(),n=B8(),s=z8(),a=U8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Sp=l,Sp}var jp,$_;function W8(){if($_)return jp;$_=1;var e=Ed(),t=Sx(),n=jx(),s=200;function a(l,c){var d=this.__data__;if(d instanceof e){var h=d.__data__;if(!t||h.length<s-1)return h.push([l,c]),this.size=++d.size,this;d=this.__data__=new n(h)}return d.set(l,c),this.size=d.size,this}return jp=a,jp}var Ep,O_;function Ad(){if(O_)return Ep;O_=1;var e=Ed(),t=k8(),n=_8(),s=N8(),a=S8(),l=W8();function c(d){var h=this.__data__=new e(d);this.size=h.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,Ep=c,Ep}var Cp,P_;function Ex(){if(P_)return Cp;P_=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 Cp=e,Cp}var Tp,L_;function Q2(){if(L_)return Tp;L_=1;var e=Qa(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Tp=t,Tp}var Ap,D_;function Rd(){if(D_)return Ap;D_=1;var e=Q2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Ap=t,Ap}var Rp,q_;function Md(){if(q_)return Rp;q_=1;var e=Rd(),t=fi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d){var h=l[c];(!(s.call(l,c)&&t(h,d))||d===void 0&&!(c in l))&&e(l,c,d)}return Rp=a,Rp}var Mp,F_;function tc(){if(F_)return Mp;F_=1;var e=Md(),t=Rd();function n(s,a,l,c){var d=!l;l||(l={});for(var h=-1,p=a.length;++h<p;){var f=a[h],m=c?c(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),d?t(l,f,m):e(l,f,m)}return l}return Mp=n,Mp}var Ip,B_;function H8(){if(B_)return Ip;B_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Ip=e,Ip}var $p,z_;function $r(){if(z_)return $p;z_=1;function e(t){return t!=null&&typeof t=="object"}return $p=e,$p}var Op,U_;function G8(){if(U_)return Op;U_=1;var e=Xa(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Op=s,Op}var Pp,W_;function nc(){if(W_)return Pp;W_=1;var e=G8(),t=$r(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&s.call(c,"callee")&&!a.call(c,"callee")};return Pp=l,Pp}var Lp,H_;function Mt(){if(H_)return Lp;H_=1;var e=Array.isArray;return Lp=e,Lp}var Sl={exports:{}},Dp,G_;function V8(){if(G_)return Dp;G_=1;function e(){return!1}return Dp=e,Dp}Sl.exports;var V_;function mi(){return V_||(V_=1,(function(e,t){var n=yr(),s=V8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,d=c?n.Buffer:void 0,h=d?d.isBuffer:void 0,p=h||s;e.exports=p})(Sl,Sl.exports)),Sl.exports}var qp,Y_;function Id(){if(Y_)return qp;Y_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var l=typeof s;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return qp=n,qp}var Fp,K_;function Cx(){if(K_)return Fp;K_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Fp=t,Fp}var Bp,X_;function Y8(){if(X_)return Bp;X_=1;var e=Xa(),t=Cx(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",v="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",x="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",$="[object Uint8Array]",F="[object Uint8ClampedArray]",O="[object Uint16Array]",M="[object Uint32Array]",L={};L[N]=L[E]=L[C]=L[R]=L[I]=L[$]=L[F]=L[O]=L[M]=!0,L[s]=L[a]=L[S]=L[l]=L[x]=L[c]=L[d]=L[h]=L[p]=L[f]=L[m]=L[y]=L[v]=L[j]=L[_]=!1;function H(B){return n(B)&&t(B.length)&&!!L[e(B)]}return Bp=H,Bp}var zp,Q_;function $d(){if(Q_)return zp;Q_=1;function e(t){return function(n){return t(n)}}return zp=e,zp}var jl={exports:{}};jl.exports;var Z_;function Tx(){return Z_||(Z_=1,(function(e,t){var n=K2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,d=(function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}})();e.exports=d})(jl,jl.exports)),jl.exports}var Up,J_;function rc(){if(J_)return Up;J_=1;var e=Y8(),t=$d(),n=Tx(),s=n&&n.isTypedArray,a=s?t(s):e;return Up=a,Up}var Wp,eN;function Z2(){if(eN)return Wp;eN=1;var e=H8(),t=nc(),n=Mt(),s=mi(),a=Id(),l=rc(),c=Object.prototype,d=c.hasOwnProperty;function h(p,f){var m=n(p),y=!m&&t(p),v=!m&&!y&&s(p),j=!m&&!y&&!v&&l(p),_=m||y||v||j,S=_?e(p.length,String):[],x=S.length;for(var N in p)(f||d.call(p,N))&&!(_&&(N=="length"||v&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,x)))&&S.push(N);return S}return Wp=h,Wp}var Hp,tN;function Od(){if(tN)return Hp;tN=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Hp=t,Hp}var Gp,nN;function J2(){if(nN)return Gp;nN=1;function e(t,n){return function(s){return t(n(s))}}return Gp=e,Gp}var Vp,rN;function K8(){if(rN)return Vp;rN=1;var e=J2(),t=e(Object.keys,Object);return Vp=t,Vp}var Yp,sN;function Ax(){if(sN)return Yp;sN=1;var e=Od(),t=K8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var d in Object(l))s.call(l,d)&&d!="constructor"&&c.push(d);return c}return Yp=a,Yp}var Kp,aN;function ls(){if(aN)return Kp;aN=1;var e=ec(),t=Cx();function n(s){return s!=null&&t(s.length)&&!e(s)}return Kp=n,Kp}var Xp,oN;function Xs(){if(oN)return Xp;oN=1;var e=Z2(),t=Ax(),n=ls();function s(a){return n(a)?e(a):t(a)}return Xp=s,Xp}var Qp,iN;function X8(){if(iN)return Qp;iN=1;var e=tc(),t=Xs();function n(s,a){return s&&e(a,t(a),s)}return Qp=n,Qp}var Zp,lN;function Q8(){if(lN)return Zp;lN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Zp=e,Zp}var Jp,cN;function Z8(){if(cN)return Jp;cN=1;var e=Yn(),t=Od(),n=Q8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var d=t(c),h=[];for(var p in c)p=="constructor"&&(d||!a.call(c,p))||h.push(p);return h}return Jp=l,Jp}var em,uN;function Za(){if(uN)return em;uN=1;var e=Z2(),t=Z8(),n=ls();function s(a){return n(a)?e(a,!0):t(a)}return em=s,em}var tm,dN;function J8(){if(dN)return tm;dN=1;var e=tc(),t=Za();function n(s,a){return s&&e(a,t(a),s)}return tm=n,tm}var El={exports:{}};El.exports;var hN;function eA(){return hN||(hN=1,(function(e,t){var n=yr(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?n.Buffer:void 0,d=c?c.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var m=p.length,y=d?d(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(El,El.exports)),El.exports}var nm,fN;function tA(){if(fN)return nm;fN=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 nm=e,nm}var rm,pN;function nA(){if(pN)return rm;pN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var d=t[s];n(d,s,t)&&(c[l++]=d)}return c}return rm=e,rm}var sm,mN;function rA(){if(mN)return sm;mN=1;function e(){return[]}return sm=e,sm}var am,gN;function Rx(){if(gN)return am;gN=1;var e=nA(),t=rA(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(d){return s.call(c,d)}))}:t;return am=l,am}var om,yN;function eB(){if(yN)return om;yN=1;var e=tc(),t=Rx();function n(s,a){return e(s,t(s),a)}return om=n,om}var im,wN;function Mx(){if(wN)return im;wN=1;function e(t,n){for(var s=-1,a=n.length,l=t.length;++s<a;)t[l+s]=n[s];return t}return im=e,im}var lm,vN;function Pd(){if(vN)return lm;vN=1;var e=J2(),t=e(Object.getPrototypeOf,Object);return lm=t,lm}var cm,xN;function sA(){if(xN)return cm;xN=1;var e=Mx(),t=Pd(),n=Rx(),s=rA(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var d=[];c;)e(d,n(c)),c=t(c);return d}:s;return cm=l,cm}var um,bN;function tB(){if(bN)return um;bN=1;var e=tc(),t=sA();function n(s,a){return e(s,t(s),a)}return um=n,um}var dm,kN;function aA(){if(kN)return dm;kN=1;var e=Mx(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return dm=n,dm}var hm,_N;function oA(){if(_N)return hm;_N=1;var e=aA(),t=Rx(),n=Xs();function s(a){return e(a,n,t)}return hm=s,hm}var fm,NN;function nB(){if(NN)return fm;NN=1;var e=aA(),t=sA(),n=Za();function s(a){return e(a,n,t)}return fm=s,fm}var pm,SN;function rB(){if(SN)return pm;SN=1;var e=Qa(),t=yr(),n=e(t,"DataView");return pm=n,pm}var mm,jN;function sB(){if(jN)return mm;jN=1;var e=Qa(),t=yr(),n=e(t,"Promise");return mm=n,mm}var gm,EN;function iA(){if(EN)return gm;EN=1;var e=Qa(),t=yr(),n=e(t,"Set");return gm=n,gm}var ym,CN;function aB(){if(CN)return ym;CN=1;var e=Qa(),t=yr(),n=e(t,"WeakMap");return ym=n,ym}var wm,TN;function gi(){if(TN)return wm;TN=1;var e=rB(),t=Sx(),n=sB(),s=iA(),a=aB(),l=Xa(),c=X2(),d="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",v=c(e),j=c(t),_=c(n),S=c(s),x=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=d||n&&N(n.resolve())!=p||s&&N(new s)!=f||a&&N(new a)!=m)&&(N=function(E){var C=l(E),R=C==h?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case j:return d;case _:return p;case S:return f;case x:return m}return C}),wm=N,wm}var vm,AN;function oB(){if(AN)return vm;AN=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,l=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return vm=n,vm}var xm,RN;function lA(){if(RN)return xm;RN=1;var e=yr(),t=e.Uint8Array;return xm=t,xm}var bm,MN;function Ix(){if(MN)return bm;MN=1;var e=lA();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return bm=t,bm}var km,IN;function iB(){if(IN)return km;IN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return km=t,km}var _m,$N;function lB(){if($N)return _m;$N=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return _m=t,_m}var Nm,ON;function cB(){if(ON)return Nm;ON=1;var e=pi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return Nm=s,Nm}var Sm,PN;function cA(){if(PN)return Sm;PN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Sm=t,Sm}var jm,LN;function uB(){if(LN)return jm;LN=1;var e=Ix(),t=iB(),n=lB(),s=cB(),a=cA(),l="[object Boolean]",c="[object Date]",d="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",x="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]";function F(O,M,L){var H=O.constructor;switch(M){case v:return e(O);case l:case c:return new H(+O);case j:return t(O,L);case _:case S:case x:case N:case E:case C:case R:case I:case $:return a(O,L);case d:return new H;case h:case m:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return jm=F,jm}var Em,DN;function uA(){if(DN)return Em;DN=1;var e=Yn(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var l=new s;return s.prototype=void 0,l}})();return Em=n,Em}var Cm,qN;function dA(){if(qN)return Cm;qN=1;var e=uA(),t=Pd(),n=Od();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Cm=s,Cm}var Tm,FN;function dB(){if(FN)return Tm;FN=1;var e=gi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Tm=s,Tm}var Am,BN;function hB(){if(BN)return Am;BN=1;var e=dB(),t=$d(),n=Tx(),s=n&&n.isMap,a=s?t(s):e;return Am=a,Am}var Rm,zN;function fB(){if(zN)return Rm;zN=1;var e=gi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Rm=s,Rm}var Mm,UN;function pB(){if(UN)return Mm;UN=1;var e=fB(),t=$d(),n=Tx(),s=n&&n.isSet,a=s?t(s):e;return Mm=a,Mm}var Im,WN;function hA(){if(WN)return Im;WN=1;var e=Ad(),t=Ex(),n=Md(),s=X8(),a=J8(),l=eA(),c=tA(),d=eB(),h=tB(),p=oA(),f=nB(),m=gi(),y=oB(),v=uB(),j=dA(),_=Mt(),S=mi(),x=hB(),N=Yn(),E=pB(),C=Xs(),R=Za(),I=1,$=2,F=4,O="[object Arguments]",M="[object Array]",L="[object Boolean]",H="[object Date]",B="[object Error]",A="[object Function]",Q="[object GeneratorFunction]",K="[object Map]",ee="[object Number]",Z="[object Object]",D="[object RegExp]",Y="[object Set]",P="[object String]",G="[object Symbol]",de="[object WeakMap]",W="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",V="[object Float64Array]",ie="[object Int8Array]",pe="[object Int16Array]",me="[object Int32Array]",Ie="[object Uint8Array]",Le="[object Uint8ClampedArray]",ce="[object Uint16Array]",xe="[object Uint32Array]",ye={};ye[O]=ye[M]=ye[W]=ye[U]=ye[L]=ye[H]=ye[J]=ye[V]=ye[ie]=ye[pe]=ye[me]=ye[K]=ye[ee]=ye[Z]=ye[D]=ye[Y]=ye[P]=ye[G]=ye[Ie]=ye[Le]=ye[ce]=ye[xe]=!0,ye[B]=ye[A]=ye[de]=!1;function ze(ke,je,Ye,it,Ne,He){var Xe,he=je&I,ge=je&$,Se=je&F;if(Ye&&(Xe=Ne?Ye(ke,it,Ne,He):Ye(ke)),Xe!==void 0)return Xe;if(!N(ke))return ke;var Fe=_(ke);if(Fe){if(Xe=y(ke),!he)return c(ke,Xe)}else{var et=m(ke),xt=et==A||et==Q;if(S(ke))return l(ke,he);if(et==Z||et==O||xt&&!Ne){if(Xe=ge||xt?{}:j(ke),!he)return ge?h(ke,a(Xe,ke)):d(ke,s(Xe,ke))}else{if(!ye[et])return Ne?ke:{};Xe=v(ke,et,he)}}He||(He=new e);var ht=He.get(ke);if(ht)return ht;He.set(ke,Xe),E(ke)?ke.forEach(function(Oe){Xe.add(ze(Oe,je,Ye,Oe,ke,He))}):x(ke)&&ke.forEach(function(Oe,Te){Xe.set(Te,ze(Oe,je,Ye,Te,ke,He))});var ne=Se?ge?f:p:ge?R:C,De=Fe?void 0:ne(ke);return t(De||ke,function(Oe,Te){De&&(Te=Oe,Oe=ke[Te]),n(Xe,Te,ze(Oe,je,Ye,Te,ke,He))}),Xe}return Im=ze,Im}var $m,HN;function mB(){if(HN)return $m;HN=1;var e=hA(),t=4;function n(s){return e(s,t)}return $m=n,$m}var Om,GN;function $x(){if(GN)return Om;GN=1;function e(t){return function(){return t}}return Om=e,Om}var Pm,VN;function gB(){if(VN)return Pm;VN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),d=a(n),h=d.length;h--;){var p=d[t?h:++l];if(s(c[p],p,c)===!1)break}return n}}return Pm=e,Pm}var Lm,YN;function Ox(){if(YN)return Lm;YN=1;var e=gB(),t=e();return Lm=t,Lm}var Dm,KN;function Px(){if(KN)return Dm;KN=1;var e=Ox(),t=Xs();function n(s,a){return s&&e(s,a,t)}return Dm=n,Dm}var qm,XN;function yB(){if(XN)return qm;XN=1;var e=ls();function t(n,s){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,d=s?c:-1,h=Object(a);(s?d--:++d<c)&&l(h[d],d,h)!==!1;);return a}}return qm=t,qm}var Fm,QN;function Ld(){if(QN)return Fm;QN=1;var e=Px(),t=yB(),n=t(e);return Fm=n,Fm}var Bm,ZN;function Ja(){if(ZN)return Bm;ZN=1;function e(t){return t}return Bm=e,Bm}var zm,JN;function fA(){if(JN)return zm;JN=1;var e=Ja();function t(n){return typeof n=="function"?n:e}return zm=t,zm}var Um,eS;function pA(){if(eS)return Um;eS=1;var e=Ex(),t=Ld(),n=fA(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c))}return Um=a,Um}var Wm,tS;function mA(){return tS||(tS=1,Wm=pA()),Wm}var Hm,nS;function wB(){if(nS)return Hm;nS=1;var e=Ld();function t(n,s){var a=[];return e(n,function(l,c,d){s(l,c,d)&&a.push(l)}),a}return Hm=t,Hm}var Gm,rS;function vB(){if(rS)return Gm;rS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Gm=t,Gm}var Vm,sS;function xB(){if(sS)return Vm;sS=1;function e(t){return this.__data__.has(t)}return Vm=e,Vm}var Ym,aS;function gA(){if(aS)return Ym;aS=1;var e=jx(),t=vB(),n=xB();function s(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,Ym=s,Ym}var Km,oS;function bB(){if(oS)return Km;oS=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 Km=e,Km}var Xm,iS;function yA(){if(iS)return Xm;iS=1;function e(t,n){return t.has(n)}return Xm=e,Xm}var Qm,lS;function wA(){if(lS)return Qm;lS=1;var e=gA(),t=bB(),n=yA(),s=1,a=2;function l(c,d,h,p,f,m){var y=h&s,v=c.length,j=d.length;if(v!=j&&!(y&&j>v))return!1;var _=m.get(c),S=m.get(d);if(_&&S)return _==d&&S==c;var x=-1,N=!0,E=h&a?new e:void 0;for(m.set(c,d),m.set(d,c);++x<v;){var C=c[x],R=d[x];if(p)var I=y?p(R,C,x,d,c,m):p(C,R,x,c,d,m);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(d,function($,F){if(!n(E,F)&&(C===$||f(C,$,h,p,m)))return E.push(F)})){N=!1;break}}else if(!(C===R||f(C,R,h,p,m))){N=!1;break}}return m.delete(c),m.delete(d),N}return Qm=l,Qm}var Zm,cS;function kB(){if(cS)return Zm;cS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Zm=e,Zm}var Jm,uS;function Lx(){if(uS)return Jm;uS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Jm=e,Jm}var eg,dS;function _B(){if(dS)return eg;dS=1;var e=pi(),t=lA(),n=fi(),s=wA(),a=kB(),l=Lx(),c=1,d=2,h="[object Boolean]",p="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,$,F,O,M,L,H){switch(F){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!L(new t(I),new t($)));case h:case p:case y:return n(+I,+$);case f:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case m:var B=a;case j:var A=O&c;if(B||(B=l),I.size!=$.size&&!A)return!1;var Q=H.get(I);if(Q)return Q==$;O|=d,H.set(I,$);var K=s(B(I),B($),O,M,L,H);return H.delete(I),K;case S:if(C)return C.call(I)==C.call($)}return!1}return eg=R,eg}var tg,hS;function NB(){if(hS)return tg;hS=1;var e=oA(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d,h,p,f){var m=d&t,y=e(l),v=y.length,j=e(c),_=j.length;if(v!=_&&!m)return!1;for(var S=v;S--;){var x=y[S];if(!(m?x in c:s.call(c,x)))return!1}var N=f.get(l),E=f.get(c);if(N&&E)return N==c&&E==l;var C=!0;f.set(l,c),f.set(c,l);for(var R=m;++S<v;){x=y[S];var I=l[x],$=c[x];if(h)var F=m?h($,I,x,c,l,f):h(I,$,x,l,c,f);if(!(F===void 0?I===$||p(I,$,d,h,f):F)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var O=l.constructor,M=c.constructor;O!=M&&"constructor"in l&&"constructor"in c&&!(typeof O=="function"&&O instanceof O&&typeof M=="function"&&M instanceof M)&&(C=!1)}return f.delete(l),f.delete(c),C}return tg=a,tg}var ng,fS;function SB(){if(fS)return ng;fS=1;var e=Ad(),t=wA(),n=_B(),s=NB(),a=gi(),l=Mt(),c=mi(),d=rc(),h=1,p="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function j(_,S,x,N,E,C){var R=l(_),I=l(S),$=R?f:a(_),F=I?f:a(S);$=$==p?m:$,F=F==p?m:F;var O=$==m,M=F==m,L=$==F;if(L&&c(_)){if(!c(S))return!1;R=!0,O=!1}if(L&&!O)return C||(C=new e),R||d(_)?t(_,S,x,N,E,C):n(_,S,$,x,N,E,C);if(!(x&h)){var H=O&&v.call(_,"__wrapped__"),B=M&&v.call(S,"__wrapped__");if(H||B){var A=H?_.value():_,Q=B?S.value():S;return C||(C=new e),E(A,Q,x,N,C)}}return L?(C||(C=new e),s(_,S,x,N,E,C)):!1}return ng=j,ng}var rg,pS;function vA(){if(pS)return rg;pS=1;var e=SB(),t=$r();function n(s,a,l,c,d){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,d)}return rg=n,rg}var sg,mS;function jB(){if(mS)return sg;mS=1;var e=Ad(),t=vA(),n=1,s=2;function a(l,c,d,h){var p=d.length,f=p,m=!h;if(l==null)return!f;for(l=Object(l);p--;){var y=d[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<f;){y=d[p];var v=y[0],j=l[v],_=y[1];if(m&&y[2]){if(j===void 0&&!(v in l))return!1}else{var S=new e;if(h)var x=h(j,_,v,l,c,S);if(!(x===void 0?t(_,j,n|s,h,S):x))return!1}}return!0}return sg=a,sg}var ag,gS;function xA(){if(gS)return ag;gS=1;var e=Yn();function t(n){return n===n&&!e(n)}return ag=t,ag}var og,yS;function EB(){if(yS)return og;yS=1;var e=xA(),t=Xs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],d=s[c];a[l]=[c,d,e(d)]}return a}return og=n,og}var ig,wS;function bA(){if(wS)return ig;wS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ig=e,ig}var lg,vS;function CB(){if(vS)return lg;vS=1;var e=jB(),t=EB(),n=bA();function s(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return lg=s,lg}var cg,xS;function yi(){if(xS)return cg;xS=1;var e=Xa(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return cg=s,cg}var ug,bS;function Dx(){if(bS)return ug;bS=1;var e=Mt(),t=yi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var d=typeof l;return d=="number"||d=="symbol"||d=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return ug=a,ug}var dg,kS;function TB(){if(kS)return dg;kS=1;var e=jx(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,d=a?a.apply(this,c):c[0],h=l.cache;if(h.has(d))return h.get(d);var p=s.apply(this,c);return l.cache=h.set(d,p)||h,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,dg=n,dg}var hg,_S;function AB(){if(_S)return hg;_S=1;var e=TB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return hg=n,hg}var fg,NS;function RB(){if(NS)return fg;NS=1;var e=AB(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,d,h,p){l.push(h?p.replace(n,"$1"):d||c)}),l});return fg=s,fg}var pg,SS;function Dd(){if(SS)return pg;SS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=Array(a);++s<a;)l[s]=n(t[s],s,t);return l}return pg=e,pg}var mg,jS;function MB(){if(jS)return mg;jS=1;var e=pi(),t=Dd(),n=Mt(),s=yi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(d){if(typeof d=="string")return d;if(n(d))return t(d,c)+"";if(s(d))return l?l.call(d):"";var h=d+"";return h=="0"&&1/d==-1/0?"-0":h}return mg=c,mg}var gg,ES;function kA(){if(ES)return gg;ES=1;var e=MB();function t(n){return n==null?"":e(n)}return gg=t,gg}var yg,CS;function qd(){if(CS)return yg;CS=1;var e=Mt(),t=Dx(),n=RB(),s=kA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return yg=a,yg}var wg,TS;function sc(){if(TS)return wg;TS=1;var e=yi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return wg=t,wg}var vg,AS;function Fd(){if(AS)return vg;AS=1;var e=qd(),t=sc();function n(s,a){a=e(a,s);for(var l=0,c=a.length;s!=null&&l<c;)s=s[t(a[l++])];return l&&l==c?s:void 0}return vg=n,vg}var xg,RS;function IB(){if(RS)return xg;RS=1;var e=Fd();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return xg=t,xg}var bg,MS;function $B(){if(MS)return bg;MS=1;function e(t,n){return t!=null&&n in Object(t)}return bg=e,bg}var kg,IS;function _A(){if(IS)return kg;IS=1;var e=qd(),t=nc(),n=Mt(),s=Id(),a=Cx(),l=sc();function c(d,h,p){h=e(h,d);for(var f=-1,m=h.length,y=!1;++f<m;){var v=l(h[f]);if(!(y=d!=null&&p(d,v)))break;d=d[v]}return y||++f!=m?y:(m=d==null?0:d.length,!!m&&a(m)&&s(v,m)&&(n(d)||t(d)))}return kg=c,kg}var _g,$S;function NA(){if($S)return _g;$S=1;var e=$B(),t=_A();function n(s,a){return s!=null&&t(s,a,e)}return _g=n,_g}var Ng,OS;function OB(){if(OS)return Ng;OS=1;var e=vA(),t=IB(),n=NA(),s=Dx(),a=xA(),l=bA(),c=sc(),d=1,h=2;function p(f,m){return s(f)&&a(m)?l(c(f),m):function(y){var v=t(y,f);return v===void 0&&v===m?n(y,f):e(m,v,d|h)}}return Ng=p,Ng}var Sg,PS;function SA(){if(PS)return Sg;PS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Sg=e,Sg}var jg,LS;function PB(){if(LS)return jg;LS=1;var e=Fd();function t(n){return function(s){return e(s,n)}}return jg=t,jg}var Eg,DS;function LB(){if(DS)return Eg;DS=1;var e=SA(),t=PB(),n=Dx(),s=sc();function a(l){return n(l)?e(s(l)):t(l)}return Eg=a,Eg}var Cg,qS;function cs(){if(qS)return Cg;qS=1;var e=CB(),t=OB(),n=Ja(),s=Mt(),a=LB();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?s(c)?t(c[0],c[1]):e(c):a(c)}return Cg=l,Cg}var Tg,FS;function jA(){if(FS)return Tg;FS=1;var e=nA(),t=wB(),n=cs(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c,3))}return Tg=a,Tg}var Ag,BS;function DB(){if(BS)return Ag;BS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Ag=n,Ag}var Rg,zS;function EA(){if(zS)return Rg;zS=1;var e=DB(),t=_A();function n(s,a){return s!=null&&t(s,a,e)}return Rg=n,Rg}var Mg,US;function qB(){if(US)return Mg;US=1;var e=Ax(),t=gi(),n=nc(),s=Mt(),a=ls(),l=mi(),c=Od(),d=rc(),h="[object Map]",p="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||d(v)||n(v)))return!v.length;var j=t(v);if(j==h||j==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(m.call(v,_))return!1;return!0}return Mg=y,Mg}var Ig,WS;function CA(){if(WS)return Ig;WS=1;function e(t){return t===void 0}return Ig=e,Ig}var $g,HS;function TA(){if(HS)return $g;HS=1;var e=Ld(),t=ls();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(d,h,p){c[++l]=a(d,h,p)}),c}return $g=n,$g}var Og,GS;function AA(){if(GS)return Og;GS=1;var e=Dd(),t=cs(),n=TA(),s=Mt();function a(l,c){var d=s(l)?e:n;return d(l,t(c,3))}return Og=a,Og}var Pg,VS;function FB(){if(VS)return Pg;VS=1;function e(t,n,s,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(s=t[++l]);++l<c;)s=n(s,t[l],l,t);return s}return Pg=e,Pg}var Lg,YS;function BB(){if(YS)return Lg;YS=1;function e(t,n,s,a,l){return l(t,function(c,d,h){s=a?(a=!1,c):n(s,c,d,h)}),s}return Lg=e,Lg}var Dg,KS;function RA(){if(KS)return Dg;KS=1;var e=FB(),t=Ld(),n=cs(),s=BB(),a=Mt();function l(c,d,h){var p=a(c)?e:s,f=arguments.length<3;return p(c,n(d,4),h,f,t)}return Dg=l,Dg}var qg,XS;function zB(){if(XS)return qg;XS=1;var e=Xa(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return qg=a,qg}var Fg,QS;function UB(){if(QS)return Fg;QS=1;var e=SA(),t=e("length");return Fg=t,Fg}var Bg,ZS;function WB(){if(ZS)return Bg;ZS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",d=RegExp("["+c+e+a+l+"]");function h(p){return d.test(p)}return Bg=h,Bg}var zg,JS;function HB(){if(JS)return zg;JS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",d="["+a+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+d+"|"+h+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",j=p+"?",_="["+l+"]?",S="(?:"+v+"(?:"+[f,m,y].join("|")+")"+_+j+")*",x=_+j+S,N="(?:"+[f+d+"?",d,m,y,c].join("|")+")",E=RegExp(h+"(?="+h+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return zg=C,zg}var Ug,ej;function GB(){if(ej)return Ug;ej=1;var e=UB(),t=WB(),n=HB();function s(a){return t(a)?n(a):e(a)}return Ug=s,Ug}var Wg,tj;function VB(){if(tj)return Wg;tj=1;var e=Ax(),t=gi(),n=ls(),s=zB(),a=GB(),l="[object Map]",c="[object Set]";function d(h){if(h==null)return 0;if(n(h))return s(h)?a(h):h.length;var p=t(h);return p==l||p==c?h.size:e(h).length}return Wg=d,Wg}var Hg,nj;function YB(){if(nj)return Hg;nj=1;var e=Ex(),t=uA(),n=Px(),s=cs(),a=Pd(),l=Mt(),c=mi(),d=ec(),h=Yn(),p=rc();function f(m,y,v){var j=l(m),_=j||c(m)||p(m);if(y=s(y,4),v==null){var S=m&&m.constructor;_?v=j?new S:[]:h(m)?v=d(S)?t(a(m)):{}:v={}}return(_?e:n)(m,function(x,N,E){return y(v,x,N,E)}),v}return Hg=f,Hg}var Gg,rj;function KB(){if(rj)return Gg;rj=1;var e=pi(),t=nc(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Gg=a,Gg}var Vg,sj;function qx(){if(sj)return Vg;sj=1;var e=Mx(),t=KB();function n(s,a,l,c,d){var h=-1,p=s.length;for(l||(l=t),d||(d=[]);++h<p;){var f=s[h];a>0&&l(f)?a>1?n(f,a-1,l,c,d):e(d,f):c||(d[d.length]=f)}return d}return Vg=n,Vg}var Yg,aj;function XB(){if(aj)return Yg;aj=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 Yg=e,Yg}var Kg,oj;function MA(){if(oj)return Kg;oj=1;var e=XB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,d=-1,h=t(c.length-a,0),p=Array(h);++d<h;)p[d]=c[a+d];d=-1;for(var f=Array(a+1);++d<a;)f[d]=c[d];return f[a]=l(p),e(s,this,f)}}return Kg=n,Kg}var Xg,ij;function QB(){if(ij)return Xg;ij=1;var e=$x(),t=Q2(),n=Ja(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Xg=s,Xg}var Qg,lj;function ZB(){if(lj)return Qg;lj=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var d=n(),h=t-(d-c);if(c=d,h>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Qg=s,Qg}var Zg,cj;function IA(){if(cj)return Zg;cj=1;var e=QB(),t=ZB(),n=t(e);return Zg=n,Zg}var Jg,uj;function Bd(){if(uj)return Jg;uj=1;var e=Ja(),t=MA(),n=IA();function s(a,l){return n(t(a,l,e),a+"")}return Jg=s,Jg}var ey,dj;function $A(){if(dj)return ey;dj=1;function e(t,n,s,a){for(var l=t.length,c=s+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return ey=e,ey}var ty,hj;function JB(){if(hj)return ty;hj=1;function e(t){return t!==t}return ty=e,ty}var ny,fj;function ez(){if(fj)return ny;fj=1;function e(t,n,s){for(var a=s-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return ny=e,ny}var ry,pj;function tz(){if(pj)return ry;pj=1;var e=$A(),t=JB(),n=ez();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return ry=s,ry}var sy,mj;function nz(){if(mj)return sy;mj=1;var e=tz();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return sy=t,sy}var ay,gj;function rz(){if(gj)return ay;gj=1;function e(t,n,s){for(var a=-1,l=t==null?0:t.length;++a<l;)if(s(n,t[a]))return!0;return!1}return ay=e,ay}var oy,yj;function sz(){if(yj)return oy;yj=1;function e(){}return oy=e,oy}var iy,wj;function az(){if(wj)return iy;wj=1;var e=iA(),t=sz(),n=Lx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return iy=a,iy}var ly,vj;function oz(){if(vj)return ly;vj=1;var e=gA(),t=nz(),n=rz(),s=yA(),a=az(),l=Lx(),c=200;function d(h,p,f){var m=-1,y=t,v=h.length,j=!0,_=[],S=_;if(f)j=!1,y=n;else if(v>=c){var x=p?null:a(h);if(x)return l(x);j=!1,y=s,S=new e}else S=p?[]:_;e:for(;++m<v;){var N=h[m],E=p?p(N):N;if(N=f||N!==0?N:0,j&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;p&&S.push(E),_.push(N)}else y(S,E,f)||(S!==_&&S.push(E),_.push(N))}return _}return ly=d,ly}var cy,xj;function OA(){if(xj)return cy;xj=1;var e=ls(),t=$r();function n(s){return t(s)&&e(s)}return cy=n,cy}var uy,bj;function iz(){if(bj)return uy;bj=1;var e=qx(),t=Bd(),n=oz(),s=OA(),a=t(function(l){return n(e(l,1,s,!0))});return uy=a,uy}var dy,kj;function lz(){if(kj)return dy;kj=1;var e=Dd();function t(n,s){return e(s,function(a){return n[a]})}return dy=t,dy}var hy,_j;function PA(){if(_j)return hy;_j=1;var e=lz(),t=Xs();function n(s){return s==null?[]:e(s,t(s))}return hy=n,hy}var fy,Nj;function Kn(){if(Nj)return fy;Nj=1;var e;if(typeof Nx=="function")try{e={clone:mB(),constant:$x(),each:mA(),filter:jA(),has:EA(),isArray:Mt(),isEmpty:qB(),isFunction:ec(),isUndefined:CA(),keys:Xs(),map:AA(),reduce:RA(),size:VB(),transform:YB(),union:iz(),values:PA()}}catch{}return e||(e=window._),fy=e,fy}var py,Sj;function Fx(){if(Sj)return py;Sj=1;var e=Kn();py=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(m){return e.isEmpty(f._in[m])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},a.prototype.setNodes=function(f,m){var y=arguments,v=this;return e.each(f,function(j){y.length>1?v.setNode(j,m):v.setNode(j)}),this},a.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m: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 m=this;if(e.has(this._nodes,f)){var y=function(v){m.removeEdge(m._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){m.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==n)return m}},a.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},a.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},a.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},a.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},a.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var v={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(v[_]=S,S):S in v?v[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},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,m){var y=this,v=arguments;return e.reduce(f,function(j,_){return v.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},a.prototype.setEdge=function(){var f,m,y,v,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(v=arguments[1],j=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],j=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=d(this._isDirected,f,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=v),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[S]=j?v:this._defaultEdgeLabelFn(f,m,y);var x=h(this._isDirected,f,m,y);return f=x.v,m=x.w,Object.freeze(x),this._edgeObjs[S]=x,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=x,this._out[f][S]=x,this._edgeCount++,this},a.prototype.edge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y),j=this._edgeObjs[v];return j&&(f=j.v,m=j.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[m],f),c(this._sucs[f],m),delete this._in[m][v],delete this._out[f][v],this._edgeCount--),this},a.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var v=e.values(y);return m?e.filter(v,function(j){return j.v===m}):v}},a.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var v=e.values(y);return m?e.filter(v,function(j){return j.w===m}):v}},a.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function c(f,m){--f[m]||delete f[m]}function d(f,m,y,v){var j=""+m,_=""+y;if(!f&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(v)?t:v)}function h(f,m,y,v){var j=""+m,_=""+y;if(!f&&j>_){var S=j;j=_,_=S}var x={v:j,w:_};return v&&(x.name=v),x}function p(f,m){return d(f,m.v,m.w,m.name)}return py}var my,jj;function cz(){return jj||(jj=1,my="2.1.8"),my}var gy,Ej;function uz(){return Ej||(Ej=1,gy={Graph:Fx(),version:cz()}),gy}var yy,Cj;function dz(){if(Cj)return yy;Cj=1;var e=Kn(),t=Fx();yy={write:n,read:l};function n(c){var d={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(d.value=e.clone(c.graph())),d}function s(c){return e.map(c.nodes(),function(d){var h=c.node(d),p=c.parent(d),f={v:d};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function a(c){return e.map(c.edges(),function(d){var h=c.edge(d),p={v:d.v,w:d.w};return e.isUndefined(d.name)||(p.name=d.name),e.isUndefined(h)||(p.value=h),p})}function l(c){var d=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(h){d.setNode(h.v,h.value),h.parent&&d.setParent(h.v,h.parent)}),e.each(c.edges,function(h){d.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),d}return yy}var wy,Tj;function hz(){if(Tj)return wy;Tj=1;var e=Kn();wy=t;function t(n){var s={},a=[],l;function c(d){e.has(s,d)||(s[d]=!0,l.push(d),e.each(n.successors(d),c),e.each(n.predecessors(d),c))}return e.each(n.nodes(),function(d){l=[],c(d),l.length&&a.push(l)}),a}return wy}var vy,Aj;function LA(){if(Aj)return vy;Aj=1;var e=Kn();vy=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 l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:s}),this._decrease(c),!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,l=a+1,c=n;a<s.length&&(c=s[a].priority<s[c].priority?a:c,l<s.length&&(c=s[l].priority<s[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var s=this._arr,a=s[n].priority,l;n!==0&&(l=n>>1,!(s[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,s){var a=this._arr,l=this._keyIndices,c=a[n],d=a[s];a[n]=d,a[s]=c,l[d.key]=n,l[c.key]=s},vy}var xy,Rj;function DA(){if(Rj)return xy;Rj=1;var e=Kn(),t=LA();xy=s;var n=e.constant(1);function s(l,c,d,h){return a(l,String(c),d||n,h||function(p){return l.outEdges(p)})}function a(l,c,d,h){var p={},f=new t,m,y,v=function(j){var _=j.v!==m?j.v:j.w,S=p[_],x=d(j),N=y.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+x);N<S.distance&&(S.distance=N,S.predecessor=m,f.decrease(_,N))};for(l.nodes().forEach(function(j){var _=j===c?0:Number.POSITIVE_INFINITY;p[j]={distance:_},f.add(j,_)});f.size()>0&&(m=f.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(v);return p}return xy}var by,Mj;function fz(){if(Mj)return by;Mj=1;var e=DA(),t=Kn();by=n;function n(s,a,l){return t.transform(s.nodes(),function(c,d){c[d]=e(s,d,a,l)},{})}return by}var ky,Ij;function qA(){if(Ij)return ky;Ij=1;var e=Kn();ky=t;function t(n){var s=0,a=[],l={},c=[];function d(h){var p=l[h]={onStack:!0,lowlink:s,index:s++};if(a.push(h),n.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(d(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var f=[],m;do m=a.pop(),l[m].onStack=!1,f.push(m);while(h!==m);c.push(f)}}return n.nodes().forEach(function(h){e.has(l,h)||d(h)}),c}return ky}var _y,$j;function pz(){if($j)return _y;$j=1;var e=Kn(),t=qA();_y=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 _y}var Ny,Oj;function mz(){if(Oj)return Ny;Oj=1;var e=Kn();Ny=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(d){return a.outEdges(d)})}function s(a,l,c){var d={},h=a.nodes();return h.forEach(function(p){d[p]={},d[p][p]={distance:0},h.forEach(function(f){p!==f&&(d[p][f]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(f){var m=f.v===p?f.w:f.v,y=l(f);d[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=d[p];h.forEach(function(m){var y=d[m];h.forEach(function(v){var j=y[p],_=f[v],S=y[v],x=j.distance+_.distance;x<S.distance&&(S.distance=x,S.predecessor=_.predecessor)})})}),d}return Ny}var Sy,Pj;function FA(){if(Pj)return Sy;Pj=1;var e=Kn();Sy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function d(h){if(e.has(l,h))throw new n;e.has(a,h)||(l[h]=!0,a[h]=!0,e.each(s.predecessors(h),d),delete l[h],c.push(h))}if(e.each(s.sinks(),d),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,Sy}var jy,Lj;function gz(){if(Lj)return jy;Lj=1;var e=FA();jy=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return jy}var Ey,Dj;function BA(){if(Dj)return Ey;Dj=1;var e=Kn();Ey=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),d=[],h={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",h,c,d)}),d}function n(s,a,l,c,d,h){e.has(c,a)||(c[a]=!0,l||h.push(a),e.each(d(a),function(p){n(s,p,l,c,d,h)}),l&&h.push(a))}return Ey}var Cy,qj;function yz(){if(qj)return Cy;qj=1;var e=BA();Cy=t;function t(n,s){return e(n,s,"post")}return Cy}var Ty,Fj;function wz(){if(Fj)return Ty;Fj=1;var e=BA();Ty=t;function t(n,s){return e(n,s,"pre")}return Ty}var Ay,Bj;function vz(){if(Bj)return Ay;Bj=1;var e=Kn(),t=Fx(),n=LA();Ay=s;function s(a,l){var c=new t,d={},h=new n,p;function f(y){var v=y.v===p?y.w:y.v,j=h.priority(v);if(j!==void 0){var _=l(y);_<j&&(d[v]=p,h.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),h.decrease(a.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(d,p))c.setEdge(p,d[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(f)}return c}return Ay}var Ry,zj;function xz(){return zj||(zj=1,Ry={components:hz(),dijkstra:DA(),dijkstraAll:fz(),findCycles:pz(),floydWarshall:mz(),isAcyclic:gz(),postorder:yz(),preorder:wz(),prim:vz(),tarjan:qA(),topsort:FA()}),Ry}var My,Uj;function bz(){if(Uj)return My;Uj=1;var e=uz();return My={Graph:e.Graph,json:dz(),alg:xz(),version:e.version},My}var Iy,Wj;function mr(){if(Wj)return Iy;Wj=1;var e;if(typeof Nx=="function")try{e=bz()}catch{}return e||(e=window.graphlib),Iy=e,Iy}var $y,Hj;function kz(){if(Hj)return $y;Hj=1;var e=hA(),t=1,n=4;function s(a){return e(a,t|n)}return $y=s,$y}var Oy,Gj;function zd(){if(Gj)return Oy;Gj=1;var e=fi(),t=ls(),n=Id(),s=Yn();function a(l,c,d){if(!s(d))return!1;var h=typeof c;return(h=="number"?t(d)&&n(c,d.length):h=="string"&&c in d)?e(d[c],l):!1}return Oy=a,Oy}var Py,Vj;function _z(){if(Vj)return Py;Vj=1;var e=Bd(),t=fi(),n=zd(),s=Za(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(d,h){d=Object(d);var p=-1,f=h.length,m=f>2?h[2]:void 0;for(m&&n(h[0],h[1],m)&&(f=1);++p<f;)for(var y=h[p],v=s(y),j=-1,_=v.length;++j<_;){var S=v[j],x=d[S];(x===void 0||t(x,a[S])&&!l.call(d,S))&&(d[S]=y[S])}return d});return Py=c,Py}var Ly,Yj;function Nz(){if(Yj)return Ly;Yj=1;var e=cs(),t=ls(),n=Xs();function s(a){return function(l,c,d){var h=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(h[m],m,h)}}var f=a(l,c,d);return f>-1?h[p?l[f]:f]:void 0}}return Ly=s,Ly}var Dy,Kj;function Sz(){if(Kj)return Dy;Kj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Dy=t,Dy}var qy,Xj;function jz(){if(Xj)return qy;Xj=1;var e=Sz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return qy=n,qy}var Fy,Qj;function Ez(){if(Qj)return Fy;Qj=1;var e=jz(),t=Yn(),n=yi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?d(p.slice(2),m?2:8):a.test(p)?s:+p}return Fy=h,Fy}var By,Zj;function zA(){if(Zj)return By;Zj=1;var e=Ez(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return By=s,By}var zy,Jj;function Cz(){if(Jj)return zy;Jj=1;var e=zA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return zy=t,zy}var Uy,eE;function Tz(){if(eE)return Uy;eE=1;var e=$A(),t=cs(),n=Cz(),s=Math.max;function a(l,c,d){var h=l==null?0:l.length;if(!h)return-1;var p=d==null?0:n(d);return p<0&&(p=s(h+p,0)),e(l,t(c,3),p)}return Uy=a,Uy}var Wy,tE;function Az(){if(tE)return Wy;tE=1;var e=Nz(),t=Tz(),n=e(t);return Wy=n,Wy}var Hy,nE;function UA(){if(nE)return Hy;nE=1;var e=qx();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Hy=t,Hy}var Gy,rE;function Rz(){if(rE)return Gy;rE=1;var e=Ox(),t=fA(),n=Za();function s(a,l){return a==null?a:e(a,t(l),n)}return Gy=s,Gy}var Vy,sE;function Mz(){if(sE)return Vy;sE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Vy=e,Vy}var Yy,aE;function Iz(){if(aE)return Yy;aE=1;var e=Rd(),t=Px(),n=cs();function s(a,l){var c={};return l=n(l,3),t(a,function(d,h,p){e(c,h,l(d,h,p))}),c}return Yy=s,Yy}var Ky,oE;function Bx(){if(oE)return Ky;oE=1;var e=yi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var d=n[l],h=s(d);if(h!=null&&(p===void 0?h===h&&!e(h):a(h,p)))var p=h,f=d}return f}return Ky=t,Ky}var Xy,iE;function $z(){if(iE)return Xy;iE=1;function e(t,n){return t>n}return Xy=e,Xy}var Qy,lE;function Oz(){if(lE)return Qy;lE=1;var e=Bx(),t=$z(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return Qy=s,Qy}var Zy,cE;function WA(){if(cE)return Zy;cE=1;var e=Rd(),t=fi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Zy=n,Zy}var Jy,uE;function Pz(){if(uE)return Jy;uE=1;var e=Xa(),t=Pd(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,d=l.hasOwnProperty,h=c.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var m=t(f);if(m===null)return!0;var y=d.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==h}return Jy=p,Jy}var ew,dE;function HA(){if(dE)return ew;dE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return ew=e,ew}var tw,hE;function Lz(){if(hE)return tw;hE=1;var e=tc(),t=Za();function n(s){return e(s,t(s))}return tw=n,tw}var nw,fE;function Dz(){if(fE)return nw;fE=1;var e=WA(),t=eA(),n=cA(),s=tA(),a=dA(),l=nc(),c=Mt(),d=OA(),h=mi(),p=ec(),f=Yn(),m=Pz(),y=rc(),v=HA(),j=Lz();function _(S,x,N,E,C,R,I){var $=v(S,N),F=v(x,N),O=I.get(F);if(O){e(S,N,O);return}var M=R?R($,F,N+"",S,x,I):void 0,L=M===void 0;if(L){var H=c(F),B=!H&&h(F),A=!H&&!B&&y(F);M=F,H||B||A?c($)?M=$:d($)?M=s($):B?(L=!1,M=t(F,!0)):A?(L=!1,M=n(F,!0)):M=[]:m(F)||l(F)?(M=$,l($)?M=j($):(!f($)||p($))&&(M=a(F))):L=!1}L&&(I.set(F,M),C(M,F,E,R,I),I.delete(F)),e(S,N,M)}return nw=_,nw}var rw,pE;function qz(){if(pE)return rw;pE=1;var e=Ad(),t=WA(),n=Ox(),s=Dz(),a=Yn(),l=Za(),c=HA();function d(h,p,f,m,y){h!==p&&n(p,function(v,j){if(y||(y=new e),a(v))s(h,p,j,f,d,m,y);else{var _=m?m(c(h,j),v,j+"",h,p,y):void 0;_===void 0&&(_=v),t(h,j,_)}},l)}return rw=d,rw}var sw,mE;function Fz(){if(mE)return sw;mE=1;var e=Bd(),t=zd();function n(s){return e(function(a,l){var c=-1,d=l.length,h=d>1?l[d-1]:void 0,p=d>2?l[2]:void 0;for(h=s.length>3&&typeof h=="function"?(d--,h):void 0,p&&t(l[0],l[1],p)&&(h=d<3?void 0:h,d=1),a=Object(a);++c<d;){var f=l[c];f&&s(a,f,c,h)}return a})}return sw=n,sw}var aw,gE;function Bz(){if(gE)return aw;gE=1;var e=qz(),t=Fz(),n=t(function(s,a,l){e(s,a,l)});return aw=n,aw}var ow,yE;function GA(){if(yE)return ow;yE=1;function e(t,n){return t<n}return ow=e,ow}var iw,wE;function zz(){if(wE)return iw;wE=1;var e=Bx(),t=GA(),n=Ja();function s(a){return a&&a.length?e(a,n,t):void 0}return iw=s,iw}var lw,vE;function Uz(){if(vE)return lw;vE=1;var e=Bx(),t=cs(),n=GA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return lw=s,lw}var cw,xE;function Wz(){if(xE)return cw;xE=1;var e=yr(),t=function(){return e.Date.now()};return cw=t,cw}var uw,bE;function Hz(){if(bE)return uw;bE=1;var e=Md(),t=qd(),n=Id(),s=Yn(),a=sc();function l(c,d,h,p){if(!s(c))return c;d=t(d,c);for(var f=-1,m=d.length,y=m-1,v=c;v!=null&&++f<m;){var j=a(d[f]),_=h;if(j==="__proto__"||j==="constructor"||j==="prototype")return c;if(f!=y){var S=v[j];_=p?p(S,j,v):void 0,_===void 0&&(_=s(S)?S:n(d[f+1])?[]:{})}e(v,j,_),v=v[j]}return c}return uw=l,uw}var dw,kE;function Gz(){if(kE)return dw;kE=1;var e=Fd(),t=Hz(),n=qd();function s(a,l,c){for(var d=-1,h=l.length,p={};++d<h;){var f=l[d],m=e(a,f);c(m,f)&&t(p,n(f,a),m)}return p}return dw=s,dw}var hw,_E;function Vz(){if(_E)return hw;_E=1;var e=Gz(),t=NA();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return hw=n,hw}var fw,NE;function Yz(){if(NE)return fw;NE=1;var e=UA(),t=MA(),n=IA();function s(a){return n(t(a,void 0,e),a+"")}return fw=s,fw}var pw,SE;function Kz(){if(SE)return pw;SE=1;var e=Vz(),t=Yz(),n=t(function(s,a){return s==null?{}:e(s,a)});return pw=n,pw}var mw,jE;function Xz(){if(jE)return mw;jE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var d=-1,h=t(e((a-s)/(l||1)),0),p=Array(h);h--;)p[c?h:++d]=s,s+=l;return p}return mw=n,mw}var gw,EE;function Qz(){if(EE)return gw;EE=1;var e=Xz(),t=zd(),n=zA();function s(a){return function(l,c,d){return d&&typeof d!="number"&&t(l,c,d)&&(c=d=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),d=d===void 0?l<c?1:-1:n(d),e(l,c,d,a)}}return gw=s,gw}var yw,CE;function Zz(){if(CE)return yw;CE=1;var e=Qz(),t=e();return yw=t,yw}var ww,TE;function Jz(){if(TE)return ww;TE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return ww=e,ww}var vw,AE;function eU(){if(AE)return vw;AE=1;var e=yi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,d=e(n),h=s!==void 0,p=s===null,f=s===s,m=e(s);if(!p&&!m&&!d&&n>s||d&&h&&f&&!p&&!m||l&&h&&f||!a&&f||!c)return 1;if(!l&&!d&&!m&&n<s||m&&a&&c&&!l&&!d||p&&a&&c||!h&&c||!f)return-1}return 0}return vw=t,vw}var xw,RE;function tU(){if(RE)return xw;RE=1;var e=eU();function t(n,s,a){for(var l=-1,c=n.criteria,d=s.criteria,h=c.length,p=a.length;++l<h;){var f=e(c[l],d[l]);if(f){if(l>=p)return f;var m=a[l];return f*(m=="desc"?-1:1)}}return n.index-s.index}return xw=t,xw}var bw,ME;function nU(){if(ME)return bw;ME=1;var e=Dd(),t=Fd(),n=cs(),s=TA(),a=Jz(),l=$d(),c=tU(),d=Ja(),h=Mt();function p(f,m,y){m.length?m=e(m,function(_){return h(_)?function(S){return t(S,_.length===1?_[0]:_)}:_}):m=[d];var v=-1;m=e(m,l(n));var j=s(f,function(_,S,x){var N=e(m,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(j,function(_,S){return c(_,S,y)})}return bw=p,bw}var kw,IE;function rU(){if(IE)return kw;IE=1;var e=qx(),t=nU(),n=Bd(),s=zd(),a=n(function(l,c){if(l==null)return[];var d=c.length;return d>1&&s(l,c[0],c[1])?c=[]:d>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return kw=a,kw}var _w,$E;function sU(){if($E)return _w;$E=1;var e=kA(),t=0;function n(s){var a=++t;return e(s)+a}return _w=n,_w}var Nw,OE;function aU(){if(OE)return Nw;OE=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,d={};++a<l;){var h=a<c?n[a]:void 0;s(d,t[a],h)}return d}return Nw=e,Nw}var Sw,PE;function oU(){if(PE)return Sw;PE=1;var e=Md(),t=aU();function n(s,a){return t(s||[],a||[],e)}return Sw=n,Sw}var jw,LE;function vt(){if(LE)return jw;LE=1;var e;if(typeof Nx=="function")try{e={cloneDeep:kz(),constant:$x(),defaults:_z(),each:mA(),filter:jA(),find:Az(),flatten:UA(),forEach:pA(),forIn:Rz(),has:EA(),isUndefined:CA(),last:Mz(),map:AA(),mapValues:Iz(),max:Oz(),merge:Bz(),min:zz(),minBy:Uz(),now:Wz(),pick:Kz(),range:Zz(),reduce:RA(),sortBy:rU(),uniqueId:sU(),values:PA(),zipObject:oU()}}catch{}return e||(e=window._),jw=e,jw}var Ew,DE;function iU(){if(DE)return Ew;DE=1,Ew=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,l=a._prev;l!==a;)s.push(JSON.stringify(l,n)),l=l._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 Ew}var Cw,qE;function lU(){if(qE)return Cw;qE=1;var e=vt(),t=mr().Graph,n=iU();Cw=a;var s=e.constant(1);function a(p,f){if(p.nodeCount()<=1)return[];var m=d(p,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,f,m){for(var y=[],v=f[f.length-1],j=f[0],_;p.nodeCount();){for(;_=j.dequeue();)c(p,f,m,_);for(;_=v.dequeue();)c(p,f,m,_);if(p.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(c(p,f,m,_,!0));break}}}return y}function c(p,f,m,y,v){var j=v?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var S=p.edge(_),x=p.node(_.v);v&&j.push({v:_.v,w:_.w}),x.out-=S,h(f,m,x)}),e.forEach(p.outEdges(y.v),function(_){var S=p.edge(_),x=_.w,N=p.node(x);N.in-=S,h(f,m,N)}),p.removeNode(y.v),j}function d(p,f){var m=new t,y=0,v=0;e.forEach(p.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var x=m.edge(S.v,S.w)||0,N=f(S),E=x+N;m.setEdge(S.v,S.w,E),v=Math.max(v,m.node(S.v).out+=N),y=Math.max(y,m.node(S.w).in+=N)});var j=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(m.nodes(),function(S){h(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function h(p,f,m){m.out?m.in?p[m.out-m.in+f].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Cw}var Tw,FE;function cU(){if(FE)return Tw;FE=1;var e=vt(),t=lU();Tw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,d(l)):s(l);e.forEach(c,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function d(h){return function(p){return h.edge(p).weight}}}function s(l){var c=[],d={},h={};function p(f){e.has(h,f)||(h[f]=!0,d[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(d,m.w)?c.push(m):p(m.w)}),delete d[f])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var d=l.edge(c);if(d.reversed){l.removeEdge(c);var h=d.forwardName;delete d.reversed,delete d.forwardName,l.setEdge(c.w,c.v,d,h)}})}return Tw}var Aw,BE;function vn(){if(BE)return Aw;BE=1;var e=vt(),t=mr().Graph;Aw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:d,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:v,time:j,notime:_};function n(S,x,N,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return N.dummy=x,S.setNode(C,N),C}function s(S){var x=new t().setGraph(S.graph());return e.forEach(S.nodes(),function(N){x.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){var E=x.edge(N.v,N.w)||{weight:0,minlen:1},C=S.edge(N);x.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),x}function a(S){var x=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(N){S.children(N).length||x.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){x.setEdge(N,S.edge(N))}),x}function l(S){var x=e.map(S.nodes(),function(N){var E={};return e.forEach(S.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),x)}function c(S){var x=e.map(S.nodes(),function(N){var E={};return e.forEach(S.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),x)}function d(S,x){var N=S.x,E=S.y,C=x.x-N,R=x.y-E,I=S.width/2,$=S.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var F,O;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),F=$*C/R,O=$):(C<0&&(I=-I),F=I,O=I*R/C),{x:N+F,y:E+O}}function h(S){var x=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(N){var E=S.node(N),C=E.rank;e.isUndefined(C)||(x[C][E.order]=N)}),x}function p(S){var x=e.min(e.map(S.nodes(),function(N){return S.node(N).rank}));e.forEach(S.nodes(),function(N){var E=S.node(N);e.has(E,"rank")&&(E.rank-=x)})}function f(S){var x=e.min(e.map(S.nodes(),function(R){return S.node(R).rank})),N=[];e.forEach(S.nodes(),function(R){var I=S.node(R).rank-x;N[I]||(N[I]=[]),N[I].push(R)});var E=0,C=S.graph().nodeRankFactor;e.forEach(N,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function($){S.node($).rank+=E})})}function m(S,x,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(S,"border",C,x)}function y(S){return e.max(e.map(S.nodes(),function(x){var N=S.node(x).rank;if(!e.isUndefined(N))return N}))}function v(S,x){var N={lhs:[],rhs:[]};return e.forEach(S,function(E){x(E)?N.lhs.push(E):N.rhs.push(E)}),N}function j(S,x){var N=e.now();try{return x()}finally{console.log(S+" time: "+(e.now()-N)+"ms")}}function _(S,x){return x()}return Aw}var Rw,zE;function uU(){if(zE)return Rw;zE=1;var e=vt(),t=vn();Rw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var d=c.v,h=l.node(d).rank,p=c.w,f=l.node(p).rank,m=c.name,y=l.edge(c),v=y.labelRank;if(f!==h+1){l.removeEdge(c);var j,_,S;for(S=0,++h;h<f;++S,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:h},j=t.addDummyNode(l,"edge",_,"_d"),h===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(d,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),d=j;l.setEdge(d,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var d=l.node(c),h=d.edgeLabel,p;for(l.setEdge(d.edgeObj,h);d.dummy;)p=l.successors(c)[0],l.removeNode(c),h.points.push({x:d.x,y:d.y}),d.dummy==="edge-label"&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height),c=p,d=l.node(c)})}return Rw}var Mw,UE;function dd(){if(UE)return Mw;UE=1;var e=vt();Mw={longestPath:t,slack:n};function t(s){var a={};function l(c){var d=s.node(c);if(e.has(a,c))return d.rank;a[c]=!0;var h=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),d.rank=h}e.forEach(s.sources(),l)}function n(s,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return Mw}var Iw,WE;function VA(){if(WE)return Iw;WE=1;var e=vt(),t=mr().Graph,n=dd().slack;Iw=s;function s(d){var h=new t({directed:!1}),p=d.nodes()[0],f=d.nodeCount();h.setNode(p,{});for(var m,y;a(h,d)<f;)m=l(h,d),y=h.hasNode(m.v)?n(d,m):-n(d,m),c(h,d,y);return h}function a(d,h){function p(f){e.forEach(h.nodeEdges(f),function(m){var y=m.v,v=f===y?m.w:y;!d.hasNode(v)&&!n(h,m)&&(d.setNode(v,{}),d.setEdge(f,v,{}),p(v))})}return e.forEach(d.nodes(),p),d.nodeCount()}function l(d,h){return e.minBy(h.edges(),function(p){if(d.hasNode(p.v)!==d.hasNode(p.w))return n(h,p)})}function c(d,h,p){e.forEach(d.nodes(),function(f){h.node(f).rank+=p})}return Iw}var $w,HE;function dU(){if(HE)return $w;HE=1;var e=vt(),t=VA(),n=dd().slack,s=dd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=vn().simplify;$w=d,d.initLowLimValues=m,d.initCutValues=h,d.calcCutValue=f,d.leaveEdge=v,d.enterEdge=j,d.exchangeEdges=_;function d(E){E=c(E),s(E);var C=t(E);m(C),h(C,E);for(var R,I;R=v(C);)I=j(C,E,R),_(C,E,R,I)}function h(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){p(E,C,I)})}function p(E,C,R){var I=E.node(R),$=I.parent;E.edge(R,$).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),$=I.parent,F=!0,O=C.edge(R,$),M=0;return O||(F=!1,O=C.edge($,R)),M=O.weight,e.forEach(C.nodeEdges(R),function(L){var H=L.v===R,B=H?L.w:L.v;if(B!==$){var A=H===F,Q=C.edge(L).weight;if(M+=A?Q:-Q,x(E,R,B)){var K=E.edge(R,B).cutvalue;M+=A?-K:K}}}),M}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var F=R,O=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(M){e.has(C,M)||(R=y(E,C,R,M,I))}),O.low=F,O.lim=R++,$?O.parent=$:delete O.parent,R}function v(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function j(E,C,R){var I=R.v,$=R.w;C.hasEdge(I,$)||(I=R.w,$=R.v);var F=E.node(I),O=E.node($),M=F,L=!1;F.lim>O.lim&&(M=O,L=!0);var H=e.filter(C.edges(),function(B){return L===N(E,E.node(B.v),M)&&L!==N(E,E.node(B.w),M)});return e.minBy(H,function(B){return n(C,B)})}function _(E,C,R,I){var $=R.v,F=R.w;E.removeEdge($,F),E.setEdge(I.v,I.w,{}),m(E),h(E,C),S(E,C)}function S(E,C){var R=e.find(E.nodes(),function($){return!C.node($).parent}),I=a(E,R);I=I.slice(1),e.forEach(I,function($){var F=E.node($).parent,O=C.edge($,F),M=!1;O||(O=C.edge(F,$),M=!0),C.node($).rank=C.node(F).rank+(M?O.minlen:-O.minlen)})}function x(E,C,R){return E.hasEdge(C,R)}function N(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return $w}var Ow,GE;function hU(){if(GE)return Ow;GE=1;var e=dd(),t=e.longestPath,n=VA(),s=dU();Ow=a;function a(h){switch(h.graph().ranker){case"network-simplex":d(h);break;case"tight-tree":c(h);break;case"longest-path":l(h);break;default:d(h)}}var l=t;function c(h){t(h),n(h)}function d(h){s(h)}return Ow}var Pw,VE;function fU(){if(VE)return Pw;VE=1;var e=vt();Pw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var d=a.node(c),h=d.edgeObj,p=n(a,l,h.v,h.w),f=p.path,m=p.lca,y=0,v=f[y],j=!0;c!==h.w;){if(d=a.node(c),j){for(;(v=f[y])!==m&&a.node(v).maxRank<d.rank;)y++;v===m&&(j=!1)}if(!j){for(;y<f.length-1&&a.node(v=f[y+1]).minRank<=d.rank;)y++;v=f[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,d){var h=[],p=[],f=Math.min(l[c].low,l[d].low),m=Math.max(l[c].lim,l[d].lim),y,v;y=c;do y=a.parent(y),h.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(v=y,y=d;(y=a.parent(y))!==v;)p.push(y);return{path:h.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function d(h){var p=c;e.forEach(a.children(h),d),l[h]={low:p,lim:c++}}return e.forEach(a.children(),d),l}return Pw}var Lw,YE;function pU(){if(YE)return Lw;YE=1;var e=vt(),t=vn();Lw={run:n,cleanup:c};function n(d){var h=t.addDummyNode(d,"root",{},"_root"),p=a(d),f=e.max(e.values(p))-1,m=2*f+1;d.graph().nestingRoot=h,e.forEach(d.edges(),function(v){d.edge(v).minlen*=m});var y=l(d)+1;e.forEach(d.children(),function(v){s(d,h,m,y,f,p,v)}),d.graph().nodeRankFactor=m}function s(d,h,p,f,m,y,v){var j=d.children(v);if(!j.length){v!==h&&d.setEdge(h,v,{weight:0,minlen:p});return}var _=t.addBorderNode(d,"_bt"),S=t.addBorderNode(d,"_bb"),x=d.node(v);d.setParent(_,v),x.borderTop=_,d.setParent(S,v),x.borderBottom=S,e.forEach(j,function(N){s(d,h,p,f,m,y,N);var E=d.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?f:2*f,$=C!==R?1:m-y[v]+1;d.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),d.setEdge(R,S,{weight:I,minlen:$,nestingEdge:!0})}),d.parent(v)||d.setEdge(h,_,{weight:0,minlen:m+y[v]})}function a(d){var h={};function p(f,m){var y=d.children(f);y&&y.length&&e.forEach(y,function(v){p(v,m+1)}),h[f]=m}return e.forEach(d.children(),function(f){p(f,1)}),h}function l(d){return e.reduce(d.edges(),function(h,p){return h+d.edge(p).weight},0)}function c(d){var h=d.graph();d.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(d.edges(),function(p){var f=d.edge(p);f.nestingEdge&&d.removeEdge(p)})}return Lw}var Dw,KE;function mU(){if(KE)return Dw;KE=1;var e=vt(),t=vn();Dw=n;function n(a){function l(c){var d=a.children(c),h=a.node(c);if(d.length&&e.forEach(d,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(a,"borderLeft","_bl",c,h,p),s(a,"borderRight","_br",c,h,p)}}e.forEach(a.children(),l)}function s(a,l,c,d,h,p){var f={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=t.addDummyNode(a,"border",f,c);h[l][p]=y,a.setParent(y,d),m&&a.setEdge(m,y,{weight:1})}return Dw}var qw,XE;function gU(){if(XE)return qw;XE=1;var e=vt();qw={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(p),(f==="lr"||f==="rl")&&(d(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){a(p.node(f))}),e.forEach(p.edges(),function(f){a(p.edge(f))})}function a(p){var f=p.width;p.width=p.height,p.height=f}function l(p){e.forEach(p.nodes(),function(f){c(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function d(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return qw}var Fw,QE;function yU(){if(QE)return Fw;QE=1;var e=vt();Fw=t;function t(n){var s={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function d(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);c[f.rank].push(p),e.forEach(n.successors(p),d)}}var h=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(h,d),c}return Fw}var Bw,ZE;function wU(){if(ZE)return Bw;ZE=1;var e=vt();Bw=t;function t(s,a){for(var l=0,c=1;c<a.length;++c)l+=n(s,a[c-1],a[c]);return l}function n(s,a,l){for(var c=e.zipObject(l,e.map(l,function(y,v){return v})),d=e.flatten(e.map(a,function(y){return e.sortBy(e.map(s.outEdges(y),function(v){return{pos:c[v.w],weight:s.edge(v).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(d.forEach(function(y){var v=y.pos+h;f[v]+=y.weight;for(var j=0;v>0;)v%2&&(j+=f[v+1]),v=v-1>>1,f[v]+=y.weight;m+=y.weight*j})),m}return Bw}var zw,JE;function vU(){if(JE)return zw;JE=1;var e=vt();zw=t;function t(n,s){return e.map(s,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(d,h){var p=n.edge(h),f=n.node(h.v);return{sum:d.sum+p.weight*f.order,weight:d.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return zw}var Uw,eC;function xU(){if(eC)return Uw;eC=1;var e=vt();Uw=t;function t(a,l){var c={};e.forEach(a,function(h,p){var f=c[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=c[h.v],f=c[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(c[h.w]))});var d=e.filter(c,function(h){return!h.indegree});return n(d)}function n(a){var l=[];function c(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function d(p){return function(f){f.in.push(p),--f.indegree===0&&a.push(f)}}for(;a.length;){var h=a.pop();l.push(h),e.forEach(h.in.reverse(),c(h)),e.forEach(h.out,d(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(a,l){var c=0,d=0;a.weight&&(c+=a.barycenter*a.weight,d+=a.weight),l.weight&&(c+=l.barycenter*l.weight,d+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/d,a.weight=d,a.i=Math.min(l.i,a.i),l.merged=!0}return Uw}var Ww,tC;function bU(){if(tC)return Ww;tC=1;var e=vt(),t=vn();Ww=n;function n(l,c){var d=t.partition(l,function(_){return e.has(_,"barycenter")}),h=d.lhs,p=e.sortBy(d.rhs,function(_){return-_.i}),f=[],m=0,y=0,v=0;h.sort(a(!!c)),v=s(f,p,v),e.forEach(h,function(_){v+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,v=s(f,p,v)});var j={vs:e.flatten(f,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,c,d){for(var h;c.length&&(h=e.last(c)).i<=d;)c.pop(),l.push(h.vs),d++;return d}function a(l){return function(c,d){return c.barycenter<d.barycenter?-1:c.barycenter>d.barycenter?1:l?d.i-c.i:c.i-d.i}}return Ww}var Hw,nC;function kU(){if(nC)return Hw;nC=1;var e=vt(),t=vU(),n=xU(),s=bU();Hw=a;function a(d,h,p,f){var m=d.children(h),y=d.node(h),v=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};v&&(m=e.filter(m,function(R){return R!==v&&R!==j}));var S=t(d,m);e.forEach(S,function(R){if(d.children(R.v).length){var I=a(d,R.v,p,f);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(S,p);l(x,_);var N=s(x,f);if(v&&(N.vs=e.flatten([v,N.vs,j],!0),d.predecessors(v).length)){var E=d.node(d.predecessors(v)[0]),C=d.node(d.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(d,h){e.forEach(d,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function c(d,h){e.isUndefined(d.barycenter)?(d.barycenter=h.barycenter,d.weight=h.weight):(d.barycenter=(d.barycenter*d.weight+h.barycenter*h.weight)/(d.weight+h.weight),d.weight+=h.weight)}return Hw}var Gw,rC;function _U(){if(rC)return Gw;rC=1;var e=vt(),t=mr().Graph;Gw=n;function n(a,l,c){var d=s(a),h=new t({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var f=a.node(p),m=a.parent(p);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(h.setNode(p),h.setParent(p,m||d),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,j=h.edge(v,p),_=e.isUndefined(j)?0:j.weight;h.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),h}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Gw}var Vw,sC;function NU(){if(sC)return Vw;sC=1;var e=vt();Vw=t;function t(n,s,a){var l={},c;e.forEach(a,function(d){for(var h=n.parent(d),p,f;h;){if(p=n.parent(h),p?(f=l[p],l[p]=h):(f=c,c=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return Vw}var Yw,aC;function SU(){if(aC)return Yw;aC=1;var e=vt(),t=yU(),n=wU(),s=kU(),a=_U(),l=NU(),c=mr().Graph,d=vn();Yw=h;function h(y){var v=d.maxRank(y),j=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),S=t(y);m(y,S);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){f(E%2?j:_,E%4>=2),S=d.buildLayerMatrix(y);var R=n(y,S);R<x&&(C=0,N=e.cloneDeep(S),x=R)}m(y,N)}function p(y,v,j){return e.map(v,function(_){return a(y,_,j)})}function f(y,v){var j=new c;e.forEach(y,function(_){var S=_.graph().root,x=s(_,S,j,v);e.forEach(x.vs,function(N,E){_.node(N).order=E}),l(_,j,x.vs)})}function m(y,v){e.forEach(v,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return Yw}var Kw,oC;function jU(){if(oC)return Kw;oC=1;var e=vt(),t=mr().Graph,n=vn();Kw={positionX:j,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:d,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:v};function s(x,N){var E={};function C(R,I){var $=0,F=0,O=R.length,M=e.last(I);return e.forEach(I,function(L,H){var B=l(x,L),A=B?x.node(B).order:O;(B||L===M)&&(e.forEach(I.slice(F,H+1),function(Q){e.forEach(x.predecessors(Q),function(K){var ee=x.node(K),Z=ee.order;(Z<$||A<Z)&&!(ee.dummy&&x.node(Q).dummy)&&c(E,K,Q)})}),F=H+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,F,O,M){var L;e.forEach(e.range($,F),function(H){L=I[H],x.node(L).dummy&&e.forEach(x.predecessors(L),function(B){var A=x.node(B);A.dummy&&(A.order<O||A.order>M)&&c(E,B,L)})})}function R(I,$){var F=-1,O,M=0;return e.forEach($,function(L,H){if(x.node(L).dummy==="border"){var B=x.predecessors(L);B.length&&(O=x.node(B[0]).order,C($,M,H,F,O),M=H,F=O)}C($,M,$.length,O,I.length)}),$}return e.reduce(N,R),E}function l(x,N){if(x.node(N).dummy)return e.find(x.predecessors(N),function(E){return x.node(E).dummy})}function c(x,N,E){if(N>E){var C=N;N=E,E=C}var R=x[N];R||(x[N]=R={}),R[E]=!0}function d(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function h(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(F){e.forEach(F,function(O,M){R[O]=O,I[O]=O,$[O]=M})}),e.forEach(N,function(F){var O=-1;e.forEach(F,function(M){var L=C(M);if(L.length){L=e.sortBy(L,function(K){return $[K]});for(var H=(L.length-1)/2,B=Math.floor(H),A=Math.ceil(H);B<=A;++B){var Q=L[B];I[M]===M&&O<$[Q]&&!d(E,M,Q)&&(I[Q]=M,I[M]=R[M]=R[Q],O=$[Q])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=f(x,N,E,R),F=R?"borderLeft":"borderRight";function O(H,B){for(var A=$.nodes(),Q=A.pop(),K={};Q;)K[Q]?H(Q):(K[Q]=!0,A.push(Q),A=A.concat(B(Q))),Q=A.pop()}function M(H){I[H]=$.inEdges(H).reduce(function(B,A){return Math.max(B,I[A.v]+$.edge(A))},0)}function L(H){var B=$.outEdges(H).reduce(function(Q,K){return Math.min(Q,I[K.w]-$.edge(K))},Number.POSITIVE_INFINITY),A=x.node(H);B!==Number.POSITIVE_INFINITY&&A.borderType!==F&&(I[H]=Math.max(I[H],B))}return O(M,$.predecessors.bind($)),O(L,$.successors.bind($)),e.forEach(C,function(H){I[H]=I[E[H]]}),I}function f(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(F){var O;e.forEach(F,function(M){var L=E[M];if(R.setNode(L),O){var H=E[O],B=R.edge(H,L);R.setEdge(H,L,Math.max($(x,M,O),B||0))}O=M})}),R}function m(x,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,$){var F=S(x,$)/2;C=Math.max(I+F,C),R=Math.min(I-F,R)}),C-R})}function y(x,N){var E=e.values(N),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function($){var F=I+$,O=x[F],M;if(O!==N){var L=e.values(O);M=$==="l"?C-e.min(L):R-e.max(L),M&&(x[F]=e.mapValues(O,function(H){return H+M}))}})})}function v(x,N){return e.mapValues(x.ul,function(E,C){if(N)return x[N.toLowerCase()][C];var R=e.sortBy(e.map(x,C));return(R[1]+R[2])/2})}function j(x){var N=n.buildLayerMatrix(x),E=e.merge(s(x,N),a(x,N)),C={},R;e.forEach(["u","d"],function($){R=$==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(F){F==="r"&&(R=e.map(R,function(H){return e.values(H).reverse()}));var O=($==="u"?x.predecessors:x.successors).bind(x),M=h(x,R,E,O),L=p(x,R,M.root,M.align,F==="r");F==="r"&&(L=e.mapValues(L,function(H){return-H})),C[$+F]=L})});var I=m(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),F=C.node(I),O=0,M;if(O+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(O+=E?M:-M),M=0,O+=($.dummy?N:x)/2,O+=(F.dummy?N:x)/2,O+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":M=F.width/2;break;case"r":M=-F.width/2;break}return M&&(O+=E?M:-M),M=0,O}}function S(x,N){return x.node(N).width}return Kw}var Xw,iC;function EU(){if(iC)return Xw;iC=1;var e=vt(),t=vn(),n=jU().positionX;Xw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,d){l.node(d).x=c})}function a(l){var c=t.buildLayerMatrix(l),d=l.graph().ranksep,h=0;e.forEach(c,function(p){var f=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+f/2}),h+=f+d})}return Xw}var Qw,lC;function CU(){if(lC)return Qw;lC=1;var e=vt(),t=cU(),n=uU(),s=hU(),a=vn().normalizeRanks,l=fU(),c=vn().removeEmptyRanks,d=pU(),h=mU(),p=gU(),f=SU(),m=EU(),y=vn(),v=mr().Graph;Qw=j;function j(W,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var V=J(" buildLayoutGraph",function(){return O(W)});J(" runLayout",function(){_(V,J)}),J(" updateInputGraph",function(){S(W,V)})})}function _(W,U){U(" makeSpaceForEdgeLabels",function(){M(W)}),U(" removeSelfEdges",function(){D(W)}),U(" acyclic",function(){t.run(W)}),U(" nestingGraph.run",function(){d.run(W)}),U(" rank",function(){s(y.asNonCompoundGraph(W))}),U(" injectEdgeLabelProxies",function(){L(W)}),U(" removeEmptyRanks",function(){c(W)}),U(" nestingGraph.cleanup",function(){d.cleanup(W)}),U(" normalizeRanks",function(){a(W)}),U(" assignRankMinMax",function(){H(W)}),U(" removeEdgeLabelProxies",function(){B(W)}),U(" normalize.run",function(){n.run(W)}),U(" parentDummyChains",function(){l(W)}),U(" addBorderSegments",function(){h(W)}),U(" order",function(){f(W)}),U(" insertSelfEdges",function(){Y(W)}),U(" adjustCoordinateSystem",function(){p.adjust(W)}),U(" position",function(){m(W)}),U(" positionSelfEdges",function(){P(W)}),U(" removeBorderNodes",function(){Z(W)}),U(" normalize.undo",function(){n.undo(W)}),U(" fixupEdgeLabelCoords",function(){K(W)}),U(" undoCoordinateSystem",function(){p.undo(W)}),U(" translateGraph",function(){A(W)}),U(" assignNodeIntersects",function(){Q(W)}),U(" reversePoints",function(){ee(W)}),U(" acyclic.undo",function(){t.undo(W)})}function S(W,U){e.forEach(W.nodes(),function(J){var V=W.node(J),ie=U.node(J);V&&(V.x=ie.x,V.y=ie.y,U.children(J).length&&(V.width=ie.width,V.height=ie.height))}),e.forEach(W.edges(),function(J){var V=W.edge(J),ie=U.edge(J);V.points=ie.points,e.has(ie,"x")&&(V.x=ie.x,V.y=ie.y)}),W.graph().width=U.graph().width,W.graph().height=U.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},F=["labelpos"];function O(W){var U=new v({multigraph:!0,compound:!0}),J=de(W.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(W.nodes(),function(V){var ie=de(W.node(V));U.setNode(V,e.defaults(G(ie,C),R)),U.setParent(V,W.parent(V))}),e.forEach(W.edges(),function(V){var ie=de(W.edge(V));U.setEdge(V,e.merge({},$,G(ie,I),e.pick(ie,F)))}),U}function M(W){var U=W.graph();U.ranksep/=2,e.forEach(W.edges(),function(J){var V=W.edge(J);V.minlen*=2,V.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?V.width+=V.labeloffset:V.height+=V.labeloffset)})}function L(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(J.width&&J.height){var V=W.node(U.v),ie=W.node(U.w),pe={rank:(ie.rank-V.rank)/2+V.rank,e:U};y.addDummyNode(W,"edge-proxy",pe,"_ep")}})}function H(W){var U=0;e.forEach(W.nodes(),function(J){var V=W.node(J);V.borderTop&&(V.minRank=W.node(V.borderTop).rank,V.maxRank=W.node(V.borderBottom).rank,U=e.max(U,V.maxRank))}),W.graph().maxRank=U}function B(W){e.forEach(W.nodes(),function(U){var J=W.node(U);J.dummy==="edge-proxy"&&(W.edge(J.e).labelRank=J.rank,W.removeNode(U))})}function A(W){var U=Number.POSITIVE_INFINITY,J=0,V=Number.POSITIVE_INFINITY,ie=0,pe=W.graph(),me=pe.marginx||0,Ie=pe.marginy||0;function Le(ce){var xe=ce.x,ye=ce.y,ze=ce.width,ke=ce.height;U=Math.min(U,xe-ze/2),J=Math.max(J,xe+ze/2),V=Math.min(V,ye-ke/2),ie=Math.max(ie,ye+ke/2)}e.forEach(W.nodes(),function(ce){Le(W.node(ce))}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.has(xe,"x")&&Le(xe)}),U-=me,V-=Ie,e.forEach(W.nodes(),function(ce){var xe=W.node(ce);xe.x-=U,xe.y-=V}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.forEach(xe.points,function(ye){ye.x-=U,ye.y-=V}),e.has(xe,"x")&&(xe.x-=U),e.has(xe,"y")&&(xe.y-=V)}),pe.width=J-U+me,pe.height=ie-V+Ie}function Q(W){e.forEach(W.edges(),function(U){var J=W.edge(U),V=W.node(U.v),ie=W.node(U.w),pe,me;J.points?(pe=J.points[0],me=J.points[J.points.length-1]):(J.points=[],pe=ie,me=V),J.points.unshift(y.intersectRect(V,pe)),J.points.push(y.intersectRect(ie,me))})}function K(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ee(W){e.forEach(W.edges(),function(U){var J=W.edge(U);J.reversed&&J.points.reverse()})}function Z(W){e.forEach(W.nodes(),function(U){if(W.children(U).length){var J=W.node(U),V=W.node(J.borderTop),ie=W.node(J.borderBottom),pe=W.node(e.last(J.borderLeft)),me=W.node(e.last(J.borderRight));J.width=Math.abs(me.x-pe.x),J.height=Math.abs(ie.y-V.y),J.x=pe.x+J.width/2,J.y=V.y+J.height/2}}),e.forEach(W.nodes(),function(U){W.node(U).dummy==="border"&&W.removeNode(U)})}function D(W){e.forEach(W.edges(),function(U){if(U.v===U.w){var J=W.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:W.edge(U)}),W.removeEdge(U)}})}function Y(W){var U=y.buildLayerMatrix(W);e.forEach(U,function(J){var V=0;e.forEach(J,function(ie,pe){var me=W.node(ie);me.order=pe+V,e.forEach(me.selfEdges,function(Ie){y.addDummyNode(W,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:me.rank,order:pe+ ++V,e:Ie.e,label:Ie.label},"_se")}),delete me.selfEdges})})}function P(W){e.forEach(W.nodes(),function(U){var J=W.node(U);if(J.dummy==="selfedge"){var V=W.node(J.e.v),ie=V.x+V.width/2,pe=V.y,me=J.x-ie,Ie=V.height/2;W.setEdge(J.e,J.label),W.removeNode(U),J.label.points=[{x:ie+2*me/3,y:pe-Ie},{x:ie+5*me/6,y:pe-Ie},{x:ie+me,y:pe},{x:ie+5*me/6,y:pe+Ie},{x:ie+2*me/3,y:pe+Ie}],J.label.x=J.x,J.label.y=J.y}})}function G(W,U){return e.mapValues(e.pick(W,U),Number)}function de(W){var U={};return e.forEach(W,function(J,V){U[V.toLowerCase()]=J}),U}return Qw}var Zw,cC;function TU(){if(cC)return Zw;cC=1;var e=vt(),t=vn(),n=mr().Graph;Zw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(d){c.setNode(d,{label:d}),c.setParent(d,"layer"+a.node(d).rank)}),e.forEach(a.edges(),function(d){c.setEdge(d.v,d.w,{},d.name)}),e.forEach(l,function(d,h){var p="layer"+h;c.setNode(p,{rank:"same"}),e.reduce(d,function(f,m){return c.setEdge(f,m,{style:"invis"}),m})}),c}return Zw}var Jw,uC;function AU(){return uC||(uC=1,Jw="0.8.5"),Jw}var ev,dC;function RU(){return dC||(dC=1,ev={graphlib:mr(),layout:CU(),debug:TU(),util:{time:vn().time,notime:vn().notime},version:AU()}),ev}var MU=RU();const hC=Bv(MU),ui=240,hd=130,ti=74,Ud=72,fC=ti+Ud;function IU(e,t){var s;let n=ui;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??ui);return n}const YA=420,$U=2;function Bl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function OU(e,t){return((t==null?void 0:t.get(e))??0)>0?YA:0}function PU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function zl(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??ui)+OU(e,n),h:Math.max((s==null?void 0:s.height)??hd,PU(e,n))}}function LU(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function DU(e,t,n,s,a,l){const c=new hC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const d=e.filter(x=>!a.has(x)),h=new Set(d);for(const x of d){const{w:N,h:E}=zl(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)h.has(x.source)&&h.has(x.target)&&c.setEdge(x.source,x.target);hC.layout(c);const p=new Map;let f=1/0,m=1/0,y=-1/0,v=-1/0;for(const x of d){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd,I=zl(x,s,l),$=N.x-I.w/2,F=N.y-I.h/2;p.set(x,{x:$,y:F}),$<f&&(f=$),F<m&&(m=F),$+C>y&&(y=$+C),F+R>v&&(v=F+R)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[x,N]of p)p.set(x,{x:N.x-f,y:N.y-m});const j=Number.isFinite(y)?y-f:0,_=Number.isFinite(v)?v-m:0;let S=null;for(const x of e){const N=a.get(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??ui,R=(E==null?void 0:E.height)??hd;S=S===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+R}:{minX:Math.min(S.minX,N.x),minY:Math.min(S.minY,N.y),maxX:Math.max(S.maxX,N.x+C),maxY:Math.max(S.maxY,N.y+R)}}return{positions:p,width:j,height:_,pinnedBox:S}}function qU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,d=new Map;for(const x of e){const N=Bl(x),E=d.get(N);E?E.push(x.id):d.set(N,[x.id])}const p=Array.from(d.keys()).sort().map(x=>({sid:x,...DU(d.get(x),t,s,l,a,c)})),f=IU(e,l),m=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=x=>{const N=[[]];let E=0;for(const C of p)N.length<x&&E>0&&E+C.height>m&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+fC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+YA;let j=y(n.availableWidth?$U:1);j.length>1&&j.reduce((N,E)=>N+v(E),0)+f*(j.length-1)>(n.availableWidth??0)&&(j=y(1));const _=new Map;let S=0;for(const x of j){const N=v(x);let E=0;for(const{positions:C,height:R,pinnedBox:I}of x){for(const[F,O]of C)_.set(F,{x:O.x+S,y:O.y+E});let $=E+R;I&&I.maxY>$&&I.minX<S+N&&S<I.maxX&&($=I.maxY),E=$+fC}S+=N+f}return e.map(x=>{const N=a.get(x.id);if(N)return{...x,position:N};const E=_.get(x.id);return E?{...x,position:E}:x})}function FU(e,t,n,s,a){const c=ti+Ud,d=60,h=v=>zl(v,s,a),p=new Map(e.map(v=>[v.id,Bl(v)])),f=[],m=e.map(v=>({id:v.id,pos:n.get(v.id)??t.get(v.id)})).filter(v=>v.pos!=null).sort((v,j)=>v.pos.y-j.pos.y||v.pos.x-j.pos.x||v.id.localeCompare(j.id)),y=[];for(const{id:v,pos:j}of m){const{w:_,h:S}=h(v),x=p.get(v)??"_default";if(n.has(v)){f.push({x:j.x,y:j.y,w:_,h:S,sid:x});continue}let N=j.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===x?24:d,$=R.sid===x?24:c;return j.x<R.x+R.w+I&&R.x<j.x+_+I&&N<R.y+R.h+$&&R.y<N+S+$});if(!C)break;N=C.y+C.h+(C.sid===x?24:c)}N!==j.y&&(t.set(v,{x:j.x,y:N}),y.push(v)),f.push({x:j.x,y:N,w:_,h:S,sid:x})}return y}function BU(e,t,n,s,a,l){const c=_=>zl(_,s,l),d=_=>n.get(_)??t.get(_),h=new Map;for(const _ of e){if(!d(_.id))continue;const S=Bl(_),x=h.get(S);x?x.push(_):h.set(S,[_])}const p=new Set;for(const[_,S]of h)S.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const f=new Map,m=[];for(const _ of e){const S=d(_.id);if(!S)continue;const{w:x,h:N}=c(_.id),E=Bl(_);p.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:S.x,y:S.y,w:x,h:N})}if(f.size===0)return[];const y=ti+Ud,v=(_,S,x,N)=>m.some(E=>_<E.x+E.w+ti&&E.x<_+x+ti&&S<E.y+E.h+y&&E.y<S+N+y),j=[];for(const _ of[...f.keys()].sort()){const S=f.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const L of S){const H=d(L.id),{w:B,h:A}=c(L.id);x=Math.min(x,H.x),N=Math.min(N,H.y),E=Math.max(E,H.x+B),C=Math.max(C,H.y+A)}const R=E-x,I=C-N,$=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,H)=>L-H),F=$.length?$:[x],O=[0,...m.map(L=>L.y+L.h+y)].sort((L,H)=>L-H);let M=null;e:for(const L of F)for(const H of O){if(H>=N)break;if(!v(L,H,R,I)){M={x:L,y:H};break e}}if(M){const L=M.x-x,H=M.y-N;for(const B of S){const A=d(B.id);t.set(B.id,{x:A.x+L,y:A.y+H})}j.push(_)}for(const L of S){const H=d(L.id),{w:B,h:A}=c(L.id);m.push({x:H.x,y:H.y,w:B,h:A})}}return j}function zU(e,t,n,s,a,l=!1,c){const p=ti+Ud+1,f=8,m=1.75,y=200,v=.7,j=.01,_=M=>zl(M,s,c),S=M=>n.get(M)??t.get(M),x=new Map;for(const M of e){if(!S(M.id))continue;const L=Bl(M),H=x.get(L);H?H.push(M):x.set(L,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const L=x.get(M);let H=1/0,B=1/0,A=-1/0,Q=-1/0,K=!1;for(const Y of L){const P=S(Y.id),{w:G,h:de}=_(Y.id);H=Math.min(H,P.x),B=Math.min(B,P.y),A=Math.max(A,P.x+G),Q=Math.max(Q,P.y+de),n.has(Y.id)&&(K=!0)}const ee=A-H,Z=Q-B;C.add(M);const D=a.get(M);D&&(ee>D.w+f||Z>D.h+f)&&E.add(M),a.set(M,{w:ee,h:Z}),N.push({sid:M,members:L.map(Y=>Y.id),x:H,y:B,w:ee,h:Z,anchored:K,mass:1})}for(const M of[...a.keys()])C.has(M)||a.delete(M);if(l||R)return[];let I=!1;for(let M=0;M<N.length&&!I;M++)for(let L=M+1;L<N.length;L++){const H=N[M],B=N[L];if(!(H.anchored&&B.anchored)&&Math.abs(H.x+H.w/2-(B.x+B.w/2))<(H.w+B.w)/2+61&&Math.abs(H.y+H.h/2-(B.y+B.h/2))<(H.h+B.h)/2+p){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const M of N)E.has(M.sid)&&(M.mass=8);else for(const M of N)M.mass=Math.max(1,M.w*M.h/(ui*hd));const $=new Map(N.map(M=>[M.sid,M.x])),F=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const L=new Map,H=new Map;let B=0;for(let A=0;A<N.length;A++)for(let Q=A+1;Q<N.length;Q++){const K=N[A],ee=N[Q];if(K.anchored&&ee.anchored)continue;const Z=K.x+K.w/2,D=K.y+K.h/2,Y=ee.x+ee.w/2,P=ee.y+ee.h/2,G=(K.w+ee.w)/2+61-Math.abs(Z-Y),de=(K.h+ee.h)/2+p-Math.abs(D-P);if(G<=0||de<=0)continue;const W=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.x<=0),U=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.y<=0),J=(Xe,he,ge)=>{const Se=Xe===he,Fe=Se?K.sid<ee.sid?-1:1:Math.sign(Xe-he);return ge(K,Fe)||ge(ee,-Fe)?Fe:Se&&(ge(K,-Fe)||ge(ee,Fe))?-Fe:0},V=J(Z,Y,W),ie=J(D,P,U),pe=V!==0,me=ie!==0;if(!pe&&!me)continue;const Ie=pe&&(!me||G*m<de),[Le,ce,xe,ye]=Ie?[V,G,L,W]:[ie,de,H,U],ze=ye(K,Le),ke=ye(ee,-Le),je=K.mass,Ye=ee.mass,it=ze?ke?Ye/(je+Ye):1:0,Ne=ke?ze?je/(je+Ye):1:0,He=ce*v;xe.set(K.sid,(xe.get(K.sid)??0)+Le*He*it),xe.set(ee.sid,(xe.get(ee.sid)??0)-Le*He*Ne),B+=He}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(L.get(A.sid)??0)),A.y=Math.max(0,A.y+(H.get(A.sid)??0)));if(B<j)break}const O=[];for(const M of N){const L=M.x-$.get(M.sid),H=M.y-F.get(M.sid);if(!(Math.abs(L)<1&&Math.abs(H)<1)){for(const B of M.members){if(n.has(B))continue;const A=t.get(B);A&&t.set(B,{x:A.x+L,y:A.y+H})}O.push(M.sid)}}return O}const UU=600;function Lv(e,t){return!(e.exitAt!=null&&t-e.exitAt>UU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function WU(e,t){const n=new Set;for(const s of e.agents.values())Lv(s,t)&&n.add(s.id);return n}function HU(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 GU(e,t,n=0){if(!e)return!1;for(const s of t)if(HU(e,s,n))return!0;return!1}const KA="sessionGroup";function VU(e,t){var s;if(e.type===KA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const XA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function pC(e){const t={};for(const n of XA)t[n]=e(n);return t}function YU(e){return t=>e[t]??""}function KU(e,t){return XA.every(n=>e[n]===t[n])}function XU(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,l]of e.positions)n.set(a,l),t.has(a)&&s.set(a,l);return{positions:n,pinned:s}}const QU=1200,ZU=1e3;function mC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<QU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<ZU}function tv({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function JU(e,t,n){const s=e.x*t.zoom+t.x,a=e.y*t.zoom+t.y,l=(e.x+e.width)*t.zoom+t.x,c=(e.y+e.height)*t.zoom+t.y;return l>0&&s<n.width&&c>0&&a<n.height}function eW({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,JU(a,t,e))return!1;return s}const tW="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",nv="click for what's new";function nW(e){if(e.checkDisabled)return`${tW} · ${nv}`;if(e.checking)return`Asking npm for the newest release… · ${nv}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${nv}, and to check npm now`}function rW(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`:`${t} and check npm for a newer release`}function sW(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 aW(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."}}const Dv={kind:"assumed",claude:!0,codex:!0};function oW(e){if(!e||typeof e!="object")return Dv;const t=e.providers;if(!t||typeof t!="object")return Dv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function fd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const gC=99;function iW(e){const t=Math.max(0,Math.floor(e));return t>gC?`${gC}+`:String(t)}const lW="Pause the canvas";function cW(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${fd(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${fd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function uW(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 QA="paused · full",dW=(e,t)=>t>0?QA:e>0?`paused · ${iW(e)}`:"paused";function hW(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:dW(e.held,t),widest:QA,title:t>0?`Connected — the pause is full at ${fd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${fd(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function yC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const fW={agent:hL,sessionGroup:TL},ZA="react-flow__node";function wC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,ZA))===!0}function pW(e){try{const t=document.querySelector(`.${ZA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const mW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),gW=420;function yW(e){return e<.35?"far":e<.55?"mid":"full"}const Du=18,wW=200,vW=5*6e4,xW=6,bW=2*6e4,vC=400,zx="agent-dag.layout",Ux="agent-dag.viewport",JA="agent-dag.summariesDismissed",eR="agent-dag.sessionListOpen",tR="agent-dag.detailOpen",nR="agent-dag.usagePanelOpen",rR="agent-dag.systemPanelOpen",xC="agent-dag.accountsPanelOpen",rv="agent-dag.versionNoticeDismissed",bC="agent-dag.oldNameNoticeDismissed",kW=15*6e4,sv={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},qu="agent-dag.autoRestart",kC="agent-dag.bundleReloadedFor";function _W(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eR)==="1"}catch{return!1}}function NW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eR,e?"1":"0")}catch{}}function SW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tR)==="1"}catch{return!1}}function jW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tR,e?"1":"0")}catch{}}function EW(){const e=hi(nR);return e===null?!0:e==="1"}function CW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nR,e?"1":"0")}catch{}}function TW(){const e=hi(rR);return e===null?!0:e==="1"}function AW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(rR,e?"1":"0")}catch{}}function RW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(JA);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function _C(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(JA,JSON.stringify(n))}catch{}}function MW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(zx);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const a=Object.entries(n).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:a,pins:a.map(([l])=>l)}}return{positions:Object.entries(n.positions??{}).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function av(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;window.localStorage.setItem(zx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function IW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ux);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function $W(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ux,JSON.stringify(e))}catch{}}function NC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(zx)}catch{}try{window.localStorage.removeItem(Ux)}catch{}}}function OW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const a={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(c),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=d,h.download=`${Wt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(d),1e3)}const qv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Fv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},sR=u2;function PW(e,t,n,s,a,l,c,d,h,p,f,m,y,v,j,_,S,x){const N=[],E=[];for(const M of e.agents.values()){if(!S.has(M.id))continue;const L=M.exitAt!=null,H=_!=null&&!_.has(M.id),B=[L?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=l.get(M.id);if(N.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:t,onOpenContext:x},className:B,...A?{width:A.width,height:A.height}:null}),M.parentId&&S.has(M.parentId)){const Q=ix(M.sessionId),K=L,ee=j.size>0&&(j.has(M.id)||j.has(M.parentId)),Z=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,Y=ee?D+1.5:D,P=K?.2:Z?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",K?"rf-edge-exiting":"",ee?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||ee)&&!K,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:Y,opacity:P,transition:"var(--edge-transition)"},className:G})}}const C=new Map;for(const M of e.agents.values())M.tools.length>0&&C.set(M.id,Math.min(4,M.tools.length));const R=`${y}#lanes:${LU(C)}`,I=N.filter(M=>TF(M.id,a,f,m));if(I.length>0||R!==v.current){if(I.length>0){const M=qU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const L of M)H2(L.id,f,m)&&RF(L.id,L.position,f,m);BU(N,f,a,l,new Set(I.map(L=>L.id)),C)}FU(N,f,a,l,C),v.current=R}const $=zU(N,f,a,l,c,!h||p,C);$.length>0&&d($),Mu(f,e.agents),Mu(m,e.agents),Mu(a,e.agents),Mu(l,jF(e.agents.values()));const F=[];let O=!1;for(const M of N){let L=a.get(M.id)??f.get(M.id);L||(L=AF(M.id,f,m),O=!0),F.push({...M,position:L})}return O&&(v.current=""),{nodes:F,edges:E}}function LW(){return i.jsx(ax,{children:i.jsx(DW,{})})}function DW(){var Hi,Gi,Vi,Yi;const e=Vl(),t=Rt(),n=b.useState(kv)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(q=>q+1),[]),[c,d]=b.useState(()=>new Set),[h,p]=b.useState(null),[f,m]=b.useState(null),y=b.useCallback((q,z)=>{d(se=>{if(!z)return new Set([q]);const oe=new Set(se);return oe.has(q)?oe.delete(q):oe.add(q),oe}),p(se=>z&&se===q?se:q)},[]),v=b.useCallback(()=>{d(new Set),p(null)},[]),[j,_]=b.useState(null),[S,x]=b.useState(null),N=b.useCallback(q=>x(q),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,F]=b.useState(!1),O=b.useRef(null),M=b.useState(RW)[0],[L,H]=b.useState(_W);b.useEffect(()=>{NW(L)},[L]);const[B,A]=b.useState(SW);b.useEffect(()=>{jW(B)},[B]);const[Q,K]=b.useState(EW);b.useEffect(()=>{CW(Q)},[Q]);const[ee,Z]=b.useState(TW);b.useEffect(()=>{AW(ee)},[ee]);const[D,Y]=b.useState(()=>{try{const q=window.localStorage.getItem(xC);return q===null?!0:q==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(xC,D?"1":"0")}catch{}},[D]);const P=$f(D,200),G=$f(Q,130),de=$f(ee,130),[W,U]=b.useState(null);b.useEffect(()=>{let q=null;try{q=localStorage.getItem("agent-dag.sound")}catch{}U(q===null?!0:q==="on")},[]);const J=b.useCallback(()=>{U(q=>{var se;const z=q!==!0;try{localStorage.setItem("agent-dag.sound",z?"on":"off")}catch{}return z&&((se=Ye.current)==null||se.unlock()),z})},[]),V=b.useCallback(q=>{J()},[J]),ie=b.useRef(V);ie.current=V;const pe=b.useRef(W);pe.current=W;const[me,Ie]=b.useState(()=>Uq(hi)),Le=b.useRef(me);Le.current=me;const ce=b.useRef(null),xe=b.useCallback((q,z=!1)=>{var se,oe;if((se=Ye.current)==null||se.unlock(),ce.current!==null&&clearTimeout(ce.current),ce.current=null,!z){(oe=Ye.current)==null||oe.play(q,!0);return}ce.current=setTimeout(()=>{var Ee;ce.current=null,(Ee=Ye.current)==null||Ee.play(q,!0)},Dq)},[]),ye=b.useCallback((q,z)=>{Ie(se=>{const oe={level:Fl(z.level??se[q].level),figure:D2(q,z.figure??se[q].figure)};try{localStorage.setItem(q2[q],String(oe.level)),localStorage.setItem(F2[q],oe.figure)}catch{}return{...se,[q]:oe}}),xe(q,!0)},[xe]);b.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const[ze,ke]=b.useState(!1),je=b.useRef(null),Ye=b.useRef(null),[it,Ne]=b.useState("locked");b.useEffect(()=>{const q=Gq({enabled:()=>pe.current===!0,prefs:()=>Le.current,onState:Ne});Ye.current=q,Ne(q.state());const z=()=>q.unlock();return window.addEventListener("pointerdown",z,{once:!0,capture:!0}),window.addEventListener("keydown",z,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",z,{capture:!0}),window.removeEventListener("keydown",z,{capture:!0})}},[]);const[He,Xe]=b.useState(!1),[he,ge]=b.useState(null),[Se,Fe]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(rv)??""}catch{return""}}),[et,xt]=b.useState(!1),ht=b.useRef(0),[ne,De]=b.useState(!1),Oe=b.useCallback((q=!1)=>(q&&(ht.current=Date.now(),De(!0)),fetch(q?"/api/version?refresh=1":"/api/version").then(z=>z.ok?z.json():null).then(z=>{z&&ge(z)}).catch(()=>{}).finally(()=>{q&&De(!1)})),[]),Te=b.useCallback(()=>{Oe(Date.now()-ht.current>=kW)},[Oe]);b.useEffect(()=>{Oe();const q=window.setInterval(Te,5*6e4),z=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",z),()=>{window.clearInterval(q),document.removeEventListener("visibilitychange",z)}},[Oe,Te]),b.useEffect(()=>{He&&Oe()},[He,Oe]),b.useEffect(()=>{const q=tF();let z=null;const se=We=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:q,looking:We}),keepalive:!0}).catch(()=>{})},oe=()=>{const We=Jq(document);eF(z,We)&&se(We),z=We},Ee=()=>{z&&se(!1),z=!1};oe();const Me=window.setInterval(oe,Zq);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",Ee),()=>{window.clearInterval(Me),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",Ee),Ee()}},[]);const Ce=(he==null?void 0:he.notice)??null,[lt,ut]=b.useState(null),Re=b.useRef(!1);b.useEffect(()=>{if(Re.current)return;const q=q1(),z=uF(q),se=gF({stored:z,running:(he==null?void 0:he.running)??null,notes:D1,remembers:dF(q)});if(se.reason==="no-version")return;Re.current=!0,se.record&&hF(q,se.record);const oe=mF({tourSeen:fF(q),decision:se}),Ee=se.show.length?{entries:se.show,since:z,firstRun:!1}:null;oe.tour&&F(!0),oe.notes==="now"?ut(Ee):oe.notes==="after"&&(O.current=Ee)},[he==null?void 0:he.running]);const mt=(he==null?void 0:he.running)??"3.22.5",ft=b.useMemo(()=>B2(D1,null,mt),[mt]),bt=b.useCallback(()=>{ut({entries:ft,since:null,firstRun:!1})},[ft]),[Xn,Tn]=b.useState(null),[ln,eo]=b.useState(Dv);b.useEffect(()=>{let q=!1;return fetch("/api/health").then(z=>z.ok?z.json():null).then(z=>{q||(eo(oW(z)),!(!z||typeof z.workspace!="string")&&Tn(z.workspace))}).catch(()=>{}),()=>{q=!0}},[He]);const us=b.useRef(ln);us.current=ln;const Or=Ce?`${Ce.kind}:${Ce.to}`:"",Qn=Ce!=null&&Se!==Or,to=b.useCallback(()=>{Fe("");try{window.localStorage.setItem(rv,"")}catch{}},[]),Pr=b.useCallback(()=>{if(Ce){Fe(Or);try{window.localStorage.setItem(rv,Or)}catch{}}},[Ce,Or]),[Qs,Lr]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(bC)??""}catch{return""}}),An=he!=null&&he.invokedAs&&he.invokedAs!==Wt?he.invokedAs:null,Dr=An!=null&&Qs!==An,ds=b.useCallback(()=>{if(An){Lr(An);try{window.localStorage.setItem(bC,An)}catch{}}},[An]),qt=((Hi=he==null?void 0:he.upgrade)==null?void 0:Hi.state)??"idle",wr=yq(he==null?void 0:he.upgrade),Zs=b.useRef(!1),wi=b.useCallback(async()=>{if(hr(Zs.current||qt==="running")){Zs.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Oe(),Zs.current=!1}},[qt,Oe]);b.useEffect(()=>{if(qt!=="running")return;const q=window.setInterval(Oe,3e3);return()=>window.clearInterval(q)},[qt,Oe]);const no=b.useCallback(async()=>{const q=he==null?void 0:he.command;!q||!await L2(q)||(xt(!0),window.setTimeout(()=>xt(!1),1600))},[he==null?void 0:he.command]),Rn=b.useCallback(()=>{H(q=>(q||Y(!1),!q))},[]),Js=b.useCallback(()=>{Y(q=>(q||H(!1),!q))},[]),[ea,ta]=b.useState(!1),[na,ra]=b.useState(!1),[sa,ro]=b.useState(()=>{try{return Number(localStorage.getItem(U1))||0}catch{return 0}}),[aa,vi]=b.useState([]),[dt,so]=b.useState(!1);b.useEffect(()=>{let q=!0;const z=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var Ee;!q||!(oe!=null&&oe.ok)||(vi(oe.episodes??[]),so(((Ee=oe.settings)==null?void 0:Ee.enabled)===!0))}).catch(()=>{})};z();const se=setInterval(z,5*6e4);return()=>{q=!1,clearInterval(se)}},[]);const[oa,qr]=b.useState([]),Fr=b.useRef(new Set),[Br,ia]=b.useState(null);b.useEffect(()=>{let q=!0,z=0;const se=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>q?(oe!=null&&oe.ok&&qr(E1(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{q&&(z=window.setTimeout(se,(oe==null?void 0:oe.enabled)===!0?Iv:I2))})};return se(),()=>{q=!1,window.clearTimeout(z)}},[]);const zr=b.useCallback(async(q,z)=>{if(!Br){ia(q);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:q,fp:z})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?qr(E1(oe.pending,oe.aliases)):qr(Ee=>Ee.filter(Me=>Me.fp!==z))}catch{}finally{ia(null)}}},[Br]),It=b.useMemo(()=>a8(aa,sa).length,[aa,sa]),[la,cn]=b.useState(0),ac=b.useRef(null),[Wd,oc]=b.useState(!1),vr=b.useRef(null),[ao,hs]=b.useState(0),Xt=b.useState(()=>PF({protect:q=>y4(s.current,q)}))[0],[oo,Hd]=b.useState(!1),ca=b.useCallback(()=>{const q=Xt.paused&&Xt.dropped>0,z=Xt.setPaused(!Xt.paused);q&&w4(s.current);for(const se of z)s.current=Mk(s.current,se);Hd(Xt.paused)},[Xt]),[Et,xi]=b.useState(Date.now()),[rn,io]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(qu)!=="0"}catch{return!0}}),lo=b.useRef(!1),at=b.useCallback(()=>{const q=!rn;lo.current=!0;try{window.localStorage.removeItem(qu)}catch{}io(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&io(((se=z.prefs)==null?void 0:se.autoUpdate)!==!1)}).catch(()=>{})},[rn]),[Zn,ua]=b.useState(!1),[bi,ic]=b.useState("restart"),[ki,_i]=b.useState(null),xr=b.useRef(!1),da=b.useRef(null),Jn=b.useRef(0),xn=b.useCallback(async q=>{if(!hr(xr.current))return;const z=(q==null?void 0:q.upgrade)===!0;xr.current=!0,da.current=wr;const se=++Jn.current;ic(z?"npx":"restart"),ua(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Ce==null?void 0:Ce.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:z})})}catch{}window.setTimeout(()=>{if(Jn.current===se&&xr.current){xr.current=!1,ua(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},z?18e4:3e4)},[Ce==null?void 0:Ce.to,wr]),Mn=b.useRef(null);b.useEffect(()=>{const q=I1(s.current.agents.values())>0,z=kq({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:q,idleSince:Mn.current,now:Et});Mn.current=z.idleSince,z.restart&&xn()},[rn,Ce==null?void 0:Ce.kind,he==null?void 0:he.canRestart,Qn,Et,xn]);const fs=I1(s.current.agents.values()),ps=bq(fs),er=P2({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:fs>0,idleSince:Mn.current,now:Et});b.useEffect(()=>{const q=he==null?void 0:he.running;let z=null,se=null;try{z=window.sessionStorage.getItem("agent-dag.restartPending"),se=window.sessionStorage.getItem(kC)}catch{return}const oe=gq({bundle:"3.22.5",running:q,pending:z,lastTried:se});if(oe==="reload"){try{window.sessionStorage.setItem(kC,q??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1),_i(q??null);const Ee=window.setTimeout(()=>_i(null),6e3);return()=>window.clearTimeout(Ee)},[he==null?void 0:he.running]),b.useEffect(()=>{if(Zn&&wq({asked:da.current,reported:wr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,ua(!1)}},[Zn,wr]);const lc=b.useState(()=>XU(MW()))[0],Qt=b.useRef(lc.pinned),br=b.useRef(null),co=b.useState(()=>IW())[0],[uo,ho]=b.useState(()=>new Set),[ms,cc]=b.useState(DF),[un,ha]=b.useState(()=>pC(yC)),Ur=b.useMemo(()=>YU(un),[un]),fo=b.useCallback(q=>VU(q,Ur),[Ur]),Gd=b.useMemo(()=>({background:un["--panel"],border:`1px solid ${un["--line"]}`,borderRadius:8}),[un]),[uc,Ni]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=ms;try{window.localStorage.setItem(G2,ms)}catch{}ha(q=>{const z=pC(yC);return KU(q,z)?q:z})},[ms]);const In=b.useCallback((q,z)=>{if(tv({durationMs:z,documentHidden:document.hidden})){e.setViewport(q,{duration:z});return}const{d3Zoom:se,d3Selection:oe}=t.getState(),Ee=oe==null?void 0:oe.property("__zoom");if(se&&oe&&Ee&&Ee.k>0&&q.zoom>0){se.transform(oe,Ee.scale(q.zoom/Ee.k).translate((q.x-Ee.x)/q.zoom,(q.y-Ee.y)/q.zoom));return}e.setViewport(q,{duration:0})},[e,t]),Wr=b.useRef(null);b.useEffect(()=>{if(!co)return;const q=window.setTimeout(()=>{try{In(co,0)}catch{}bn.current=Date.now()},60);return()=>window.clearTimeout(q)},[In,co]);const Si=b.useRef(!0);b.useEffect(()=>{const q=new EventSource("/events"),z=$F(l,{now:()=>Date.now(),setTimeout:(se,oe)=>window.setTimeout(se,oe),clearTimeout:se=>window.clearTimeout(se)});return q.addEventListener("open",()=>{Xe(!0),Ni(!0)}),q.addEventListener("error",()=>Xe(!1)),q.addEventListener("replay-end",()=>{Si.current=!1,z.flush()}),q.addEventListener("hook",se=>{var oe;try{const Ee=JSON.parse(se.data);if(!Xt.accept(Ee))return;s.current=Mk(s.current,Ee);const Me=Ee.replay===!0||Si.current||Date.now()-Ee.receivedAt>3e4;Me?z.replay():z.live();const We=Hq(Ee,Me);We&&((oe=Ye.current)==null||oe.play(We))}catch{}}),()=>{q.close(),z.cancel()}},[l]),b.useEffect(()=>{const q=setInterval(()=>{const z=Date.now();xi(z);let se=v4(s.current,z,Rk);x4(s.current,z,Rk)&&(se=!0),m4(s.current,z,wW,vW)&&(se=!0),g4(s.current,z,xW,bW)&&(se=!0),d(oe=>SF(oe,s.current.agents)),p(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),x(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),_(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),se&&l()},250);return()=>clearInterval(q)},[l]);const $n=b.useRef(null),bn=b.useRef(0),po=420,kn=b.useCallback((q=500)=>{try{const Me=document.querySelector(".canvas-wrap"),We=Array.from(document.querySelectorAll(".react-flow__node")).filter(Ct=>Ct.offsetWidth>0);if(!Me||We.length===0)return;const rt=Me.getBoundingClientRect(),gt=e.getViewport();if(!Number.isFinite(gt.zoom)||gt.zoom<=0)return;const ot=Ct=>(Ct-rt.left-gt.x)/gt.zoom,Qe=Ct=>(Ct-rt.top-gt.y)/gt.zoom,Ns=We.map(Ct=>Ct.getBoundingClientRect()),Ea=Math.min(...Ns.map(Ct=>ot(Ct.left))),Ca=Math.max(...Ns.map(Ct=>ot(Ct.right))),Ki=Math.min(...Ns.map(Ct=>Qe(Ct.top))),Xi=Math.max(...Ns.map(Ct=>Qe(Ct.bottom))),Ss=Ca-Ea,js=Xi-Ki;if(!(Ss>0&&js>0))return;const Pn=Math.max(.2,Math.min(1,(rt.width-160)/(Ss+po)*.86,(rt.height-160)/js*.86)),Es={x:80-Ea*Pn,y:Math.max(80,(rt.height-js*Pn)/2)-Ki*Pn,zoom:Pn};In(Es,q),bn.current=Date.now(),Wr.current=tv({durationMs:q,documentHidden:document.hidden})?{target:Es,until:Date.now()+q+60}:null,window.setTimeout(()=>{var Ct;try{((Ct=Wr.current)==null?void 0:Ct.target)===Es&&(Wr.current=null);const Cc=e.getViewport();(Math.abs(Cc.zoom-Pn)>.01||Math.abs(Cc.x-Es.x)>2)&&In(Es,0)}catch{}},q+60)}catch{}},[e,In]);b.useEffect(()=>{const q=()=>{if(!document.hidden)return;const z=Wr.current;if(Wr.current=null,!(!z||Date.now()>z.until)){try{In(z.target,0)}catch{}bn.current=Date.now()}};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[In]);const gs=b.useRef(""),ys=b.useRef(null),ji=b.useRef(0),Ft=b.useCallback(()=>{ji.current=Date.now()},[]),kr=b.useRef(null),mo=b.useRef(0),Hr=b.useCallback(()=>{mo.current=Date.now()},[]),dc=b.useCallback(q=>({hasSourceEvent:!!q,at:Date.now(),lastDeckFitAt:bn.current,lastCanvasInputAt:mo.current}),[]),fa="agent-dag.autoFitDisabled",go=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(fa)==="1"}catch{return!1}})[0],On=b.useRef(go),[pa,Ei]=b.useState(go),Ci=b.useCallback(()=>{if(!On.current){On.current=!0,Ei(!0);try{window.localStorage.setItem(fa,"1")}catch{}}},[]),Vd=b.useCallback(()=>{On.current=!1,Ei(!1);try{window.localStorage.removeItem(fa)}catch{}kn(400)},[e,kn]);b.useEffect(()=>{const q=setInterval(()=>{if(On.current||Date.now()-ji.current<800)return;const z=s.current,se=Date.now(),oe=[];for(const Me of z.agents.values())Lv(Me,se)&&oe.push({id:Me.id});if(oe.length===0)return;const Ee=[];for(const{id:Me}of oe){const We=_r.current.get(Me),rt=Qt.current.get(Me)??sn.current.get(Me);!We||!rt||Ee.push({x:rt.x,y:rt.y,width:We.width,height:We.height})}eW({pane:kr.current,viewport:e.getViewport(),boxes:Ee})&&kn(600)},1500);return()=>clearInterval(q)},[e]);const Ti=b.useRef(!1),_r=b.useRef(new Map),hc=b.useRef(0),Yd=b.useCallback(q=>{const z=_r.current;let se=!1;for(const oe of q.nodeInternals.values()){const Ee=oe.width,Me=oe.height;if(Ee==null||Me==null)continue;const We=z.get(oe.id);We?(Math.abs(We.height-Me)>4||Math.abs(We.width-Ee)>4)&&(z.set(oe.id,{width:Ee,height:Me}),se=!0):(z.set(oe.id,{width:Ee,height:Me}),se=!0)}return se&&(hc.current+=1),hc.current},[]),fc=ct(Yd),[pc,Kd]=b.useState(0);b.useEffect(()=>{let q=0;const z=()=>{const oe=_r.current;let Ee=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const We=Me.getAttribute("data-id");if(!We)continue;const rt=Me.offsetWidth,gt=Me.offsetHeight;if(!rt||!gt)continue;const ot=oe.get(We);(!ot||Math.abs(ot.width-rt)>4||Math.abs(ot.height-gt)>4)&&(oe.set(We,{width:rt,height:gt}),Ee=!0)}Ee&&Kd(Me=>Me+1)};if(Ti.current)return;let se=0;return document.visibilityState==="hidden"?se=window.setTimeout(z,32):q=requestAnimationFrame(z),()=>{cancelAnimationFrame(q),window.clearTimeout(se)}});const sn=b.useRef(lc.positions),Xd=b.useRef(new Set),Ai=b.useRef(""),ws=b.useMemo(()=>{const q=[];for(const z of s.current.agents.values())Lv(z,Et)&&q.push(z.id+(z.parentId?`>${z.parentId}`:""));return q.sort(),`${q.join("|")}#sv${fc}.${pc}`},[s.current,s.current.revision,Et,fc,pc]),ma=b.useRef(null);b.useEffect(()=>(ma.current!=null&&window.clearTimeout(ma.current),ma.current=window.setTimeout(()=>{av(sn.current,Qt.current)},1500),()=>{ma.current!=null&&window.clearTimeout(ma.current)}),[ws]),b.useEffect(()=>{if(gs.current===ws)return;const q=gs.current;if(gs.current=ws,!q||On.current)return;Date.now()-bn.current>1200&&kn(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{On.current||kn(500)},280)},[ws,e,kn]);const ga=b.useMemo(()=>CF(s.current,c),[s.current,s.current.revision,c]),Ri=b.useMemo(()=>WU(s.current,Et),[s.current,s.current.revision,Et]),mc=b.useRef(null),[yo,Mi]=b.useState({w:0,h:0});b.useEffect(()=>{const q=mc.current;if(!q||typeof ResizeObserver>"u")return;const z=new ResizeObserver(se=>{var Ee;const oe=(Ee=se[0])==null?void 0:Ee.contentRect;oe&&(kr.current={width:oe.width,height:oe.height},Mi(Me=>Math.abs(Me.w-oe.width)>40||Math.abs(Me.h-oe.height)>40?{w:oe.width,h:oe.height}:Me))});return z.observe(q),kr.current={width:q.clientWidth,height:q.clientHeight},Mi({w:q.clientWidth,h:q.clientHeight}),()=>z.disconnect()},[]);const Qd=b.useCallback(q=>{var se,oe;const z=q.target;!(z!=null&&z.closest)||z.closest(mW)!==q.currentTarget||(q.preventDefault(),(oe=(se=document.activeElement)==null?void 0:se.blur)==null||oe.call(se))},[]),Zd=b.useRef(new Map),[gc,Jd]=b.useState(!1);b.useEffect(()=>{const q=window.setTimeout(()=>Jd(!0),2500);return()=>window.clearTimeout(q)},[]);const[eh,Ii]=b.useState(!1),Nr=b.useRef(null),[ya,vs]=b.useState(!1),[th,yc]=b.useState("full"),$i=b.useRef("full"),wc=b.useCallback(()=>{Nr.current&&(window.clearTimeout(Nr.current),Nr.current=null),Ii(!1)},[]),vc=b.useCallback(q=>{q.length!==0&&queueMicrotask(()=>{Ii(!0),Nr.current&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>Ii(!1),gW+80)})},[]);b.useEffect(()=>()=>{Nr.current&&window.clearTimeout(Nr.current)},[]);const Oi=yo.w>0?yo.w*.92:0,Gr=yo.h>0?yo.h:0,{nodes:Sr,edges:nh}=b.useMemo(()=>PW(s.current,Et,Oi,Gr,Qt.current,_r.current,Zd.current,vc,gc,ya,sn.current,Xd.current,ws,Ai,c,ga,Ri,N),[s.current,s.current.revision,Et,Oi,Gr,gc,ya,ws,c,ga,Ri,N,la]),xc=b.useMemo(()=>{const q=new Map;for(const se of Sr){const oe=se.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const Ee=se.width,Me=se.height;if(Ee==null||Me==null)continue;const We=se.position.x,rt=se.position.y,gt=We+Ee,ot=rt+Me,Qe=q.get(oe.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,We),Qe.minY=Math.min(Qe.minY,rt),Qe.maxX=Math.max(Qe.maxX,gt),Qe.maxY=Math.max(Qe.maxY,ot)):q.set(oe.sessionId,{minX:We,minY:rt,maxX:gt,maxY:ot})}const z=[];for(const[se,oe]of q){const Ee=oe.maxX-oe.minX+Du*2,Me=oe.maxY-oe.minY+Du*2;z.push({id:`group:${se}`,type:KA,position:{x:oe.minX-Du,y:oe.minY-Du},data:{sessionId:se,w:Ee,h:Me},width:Ee,height:Me,style:{width:Ee,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return z},[Sr,Et]),bc=b.useMemo(()=>{const q=[...xc,...Sr],z=vr.current;return!z||z.size===0?q:q.map(se=>{const oe=z.get(se.id);return oe?{...se,position:oe}:se})},[xc,Sr,ao]),wa=b.useMemo(()=>{const q=new Set;for(const z of s.current.agents.values())for(const se of z.tools)q.add(sR(se.name));return Object.keys(qv).filter(z=>q.has(z))},[s.current,s.current.revision]);b.useEffect(()=>{if(wa.length<=1){oc(!1);return}let q=0;const z=()=>{const se=ac.current;if(se&&!document.hidden){const oe=se.getBoundingClientRect(),Ee=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(We=>We.getBoundingClientRect()),Me=GU(oe,Ee,8);oc(We=>We===Me?We:Me)}q=window.setTimeout(z,300)};return z(),()=>window.clearTimeout(q)},[wa.length]);const va=b.useCallback(q=>{ho(z=>{const se=new Set(z);return se.has(q)?se.delete(q):se.add(q),se})},[]),$t=h?s.current.agents.get(h):null,Pi=f?Array.from(s.current.agents.values()).flatMap(q=>q.tools).find(q=>q.id===f)??null:null,xa=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=kv(),Qt.current.clear(),_r.current.clear(),sn.current.clear(),Ai.current="",NC(),v(),l()},[l,v]),kc=b.useRef(E);kc.current=E;const Li=b.useRef(R);Li.current=R;const ba=b.useRef(!1);ba.current=Pi!=null||ea||S!=null||$||j!=null||na||R||lt!=null;const xs=b.useCallback(q=>{const z=_q(q,{confirmOpen:kc.current,modalOpen:ba.current});z==="confirm"?C(!0):z==="clear"&&(C(!1),xa())},[xa]),wo=b.useCallback(()=>{Qt.current.clear(),sn.current.clear(),Ai.current="",NC(),l(),window.setTimeout(()=>kn(500),80)},[l,e,kn]),Di=b.useCallback(()=>kn(500),[kn]),ka=b.useRef(Sr);ka.current=Sr;const _c=b.useRef(h);_c.current=h;const qi=b.useCallback(q=>{const z=ka.current,se=xF(z.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),_c.current,q),oe=se?z.find(Me=>Me.id===se):void 0;if(!oe)return;const Ee=wC(document.activeElement);y(oe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[oe]})}catch{}bn.current=Date.now(),Ee&&pW(oe.id)},30)},[y,e]),Fi=b.useCallback(q=>{y(q,!1),window.setTimeout(()=>{try{const z=ka.current.find(se=>se.id===q);z&&e.fitView({padding:.3,duration:500,nodes:[z]}),bn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const q=z=>{var rt,gt;const se=z.target,oe={tagName:se==null?void 0:se.tagName,isContentEditable:se==null?void 0:se.isContentEditable,role:(rt=se==null?void 0:se.getAttribute)==null?void 0:rt.call(se,"role"),type:se==null?void 0:se.type};if(z.key==="Escape"){const ot=K4({overlayOpen:ad.depth()>0,typing:dx(oe)});ot==="dismiss"?ad.dismissTop():ot==="blur"?se==null||se.blur():(NF(oe)&&(se==null||se.blur()),v());return}if(ux(z))return;const Ee=wC(se)?(gt=se==null?void 0:se.getAttribute)==null?void 0:gt.call(se,"data-id"):null,Me=Ee&&ka.current.some(ot=>ot.id===Ee)?Ee:null,We=kF(z,Me);if(We.kind==="activate"){z.preventDefault(),y(We.nodeId,We.additive);return}We.kind!=="node"&&(We.nodeId==null&&rL(oe)||sL({key:z.key,modalOpen:ba.current,sheetOpen:Li.current})||(z.key===" "&&(z.preventDefault(),ca()),(z.key==="c"||z.key==="C")&&xs("shortcut"),(z.key==="r"||z.key==="R")&&wo(),(z.key==="f"||z.key==="F")&&Di(),(z.key==="l"||z.key==="L")&&Rn(),(z.key==="d"||z.key==="D")&&A(ot=>!ot),(z.key==="h"||z.key==="H")&&ta(ot=>!ot),(z.key==="u"||z.key==="U")&&K(ot=>!ot),(z.key==="a"||z.key==="A")&&us.current.claude&&Js(),(z.key==="j"||z.key==="J")&&qi(1),(z.key==="k"||z.key==="K")&&qi(-1),(z.key==="t"||z.key==="T")&&cc(ot=>ot==="dark"?"light":"dark"),(z.key==="m"||z.key==="M")&&us.current.claude&&pe.current!==null&&ie.current(z.shiftKey),z.key==="?"&&I(ot=>!ot)))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[xs,wo,Di,v,y,qi,ca]);const Nc=s.current.agents.size,Zt=b.useMemo(()=>B4(s.current.agents.values()),[s.current,s.current.revision]),dn=b.useMemo(()=>z4(s.current.agents.values()),[s.current,s.current.revision]),bs=b.useRef(null);b.useEffect(()=>{const q=qF({waiting:Zt.length,running:dn,connected:He}),z=bs.current;if(bs.current=q,(z==null?void 0:z.title)!==q.title&&(document.title=q.title),(z==null?void 0:z.icon)!==q.icon){const se=document.querySelector('link[rel="icon"]');se&&(se.href=FF[q.icon])}},[Zt.length,dn,He]);const[Sc,jc]=b.useState(""),Bi=zF(Zt);b.useEffect(()=>{jc(q=>UF(q,Bi))},[Bi]);const[_a,zi]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Vr,Ui]=b.useState(null),[tr,Na]=b.useState(!0),[Sa,vo]=b.useState(!1);b.useEffect(()=>{let q=!0;return fetch("/api/prefs").then(z=>z.ok?z.json():null).then(z=>{var se,oe,Ee;if(!(!q||!(z!=null&&z.ok))){if(!lo.current){let Me=!1;try{Me=window.localStorage.getItem(qu)==="0",window.localStorage.removeItem(qu)}catch{}Me&&((se=z.prefs)==null?void 0:se.autoUpdate)!==!1?(io(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):io(((oe=z.prefs)==null?void 0:oe.autoUpdate)!==!1)}Na(((Ee=z.prefs)==null?void 0:Ee.notifications)!==!1),vo(z.notificationsVetoed===!0)}}).catch(()=>{}),()=>{q=!1}},[]);const Wi=b.useRef(()=>{}),xo=b.useCallback(()=>{const q=!tr;Na(q),q&&typeof Notification<"u"&&Notification.permission==="default"&&Wi.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&(Na(((se=z.prefs)==null?void 0:se.notifications)!==!1),vo(z.notificationsVetoed===!0))}).catch(()=>{})},[tr]),ks=typeof Notification<"u";b.useEffect(()=>{if(!Vr)return;const z=setTimeout(()=>Ui(null),Vr==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[Vr]);const bo=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const z=q;zi(z),z==="granted"?Ui("on"):z==="denied"&&Ui("blocked")})},[]);Wi.current=bo;const ja=b.useRef(new Set),_s=b.useRef(null),Ec=Zt.map(q=>kd(q.id,q.waiting)).join("|");return b.useEffect(()=>{G4(_s.current,_a)&&(_s.current=_a,ja.current=Pk(Zt))},[_a]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||_s.current===null)return;const q=typeof document>"u"||!document.hidden,z=W4(Zt,ja.current,q,tr);for(const se of z)try{const oe=new Notification(se.title,{body:se.body,tag:se.key});oe.onclick=()=>{window.focus(),Fi(se.sessionId),oe.close()}}catch{}ja.current=q?Pk(Zt):H4(Zt,z,ja.current)},[Ec]),i.jsxs("div",{className:"app",children:[i.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"logo"}),i.jsx("h1",{children:Wt}),Ce?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{bt(),to()},"aria-haspopup":"dialog","aria-label":sW({...Ce,open:Qn}),title:Ce.kind==="restart"?`Running v${Ce.from}; v${Ce.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Ce.from}; v${Ce.to} is on npm · click for what's new`,children:["v",Ce.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const q={running:mt,latest:he==null?void 0:he.latest,latestPending:he==null?void 0:he.latestPending,checkedAgo:he!=null&&he.checkedAt?Cv(Et-he.checkedAt):null,checkDisabled:he==null?void 0:he.checkDisabled,checking:ne};return i.jsxs("button",{type:"button",className:ne?"v checking":"v",onClick:()=>{bt(),Oe(!0)},"aria-busy":ne||void 0,"aria-haspopup":"dialog","aria-label":rW(q),title:nW(q),children:["v",q.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const q=hW({connected:He,paused:oo,held:Xt.size,dropped:Xt.dropped});return q.resting?null:i.jsx("span",{className:`pill ${q.tone}`,title:q.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:q.widest}),i.jsx("span",{className:"pill-label",children:q.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Sc}),Zt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Fi(Zt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
268
- ${Zt.map(q=>` ${q.label}: ${Dl(q.waiting)} (${Cv(Et-q.waiting.since)})`).join(`
269
- `)}`,"aria-label":`${Zt.length} session${Zt.length===1?"":"s"} waiting for you`,children:[i.jsx("span",{className:"ap-pulse","aria-hidden":!0}),i.jsx("b",{children:Zt.length})," waiting"]}),Vr&&i.jsx("span",{className:Vr==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:Vr==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:Vr==="on"?"notifications on":"notifications blocked"})]}),$t&&(()=>{const q=En($t),z=Math.max(0,(($t.endedAt??Et)-$t.startedAt)/1e3),se=$t.state==="active"?cx(q.total,z):null,oe=c.size-1;return i.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${$t.label}`,onClick:()=>{try{const Ee=Sr.find(Me=>Me.id===$t.id);Ee&&e.fitView({padding:.35,duration:500,nodes:[Ee]}),bn.current=Date.now()}catch{}},children:[i.jsx("span",{className:`state-pill state-${$t.state}`,children:$t.state==="active"?"live":$t.state}),i.jsx("span",{className:"selected-label",children:$t.label}),q.total>0&&i.jsxs("span",{className:"selected-cost",children:[tt(q.total),se?i.jsxs("span",{className:"selected-rate",children:[" · ",se]}):null]}),oe>0&&i.jsxs("span",{className:"selected-extra",children:["+",oe]}),i.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:Ee=>{Ee.stopPropagation(),v()},children:"×"})]})})(),i.jsxs("div",{className:"actions",children:[i.jsxs("div",{className:"action-run",children:[i.jsx("button",{className:"btn icon-btn",onClick:Rn,title:`${L?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":L,"aria-controls":L?"session-list":void 0,children:"☰"}),i.jsx("button",{className:"btn icon-btn",onClick:()=>K(q=>!q),title:`${Q?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":Q,"aria-controls":Q?"usage-panel":void 0,children:"$"}),ln.claude&&i.jsx("button",{className:"btn icon-btn",onClick:Js,title:`${D?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":D,"aria-controls":D?"accounts-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),i.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>Z(q=>!q),title:`${ee?"Hide":"Show"} this machine — cores, memory, temperature`,"aria-label":"Toggle machine detail","aria-expanded":ee,"aria-controls":ee?"system-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),i.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>ta(q=>!q),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),i.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),i.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),i.jsxs("button",{className:`btn icon-btn bw-btn${It>0?" has-findings":dt?" watching":""}`,onClick:()=>ra(q=>!q),title:dt?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${dt?"watching":"not watching"}`+(It>0?`, ${It} unread`:""),"aria-haspopup":"dialog",children:[i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[i.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),dt||It>0?i.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):i.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),It>0&&i.jsx("span",{className:"bw-badge","aria-hidden":!0,children:It})]})]}),i.jsxs("div",{className:"action-run",children:[ln.claude&&W!==null&&i.jsxs("div",{className:"sound-slot",children:[i.jsx("button",{ref:je,className:"btn icon-btn",onClick:()=>ke(q=>!q),...dr(!1),title:XF(ln,{on:W===!0,locked:it==="locked",prefs:me}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":ze,"aria-controls":ze?"sound-menu":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),W?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),i.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M10 5.6l2.6 2.8"}),i.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),ze&&i.jsx(Qq,{onClose:()=>ke(!1),soundOn:W===!0,onToggleSound:J,prefs:me,onLevel:(q,z)=>ye(q,{level:z}),onFigure:(q,z)=>ye(q,{figure:z}),onPreview:q=>xe(q),notifyOn:tr,onToggleNotify:xo,notifyVetoed:Sa,notifyPermission:ks?_a:"unsupported",onAskNotify:bo,openerRef:je})]}),i.jsx("button",{className:"btn icon-btn",onClick:()=>cc(q=>q==="dark"?"light":"dark"),title:`Switch to ${ms==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:ms==="dark"?"☀":"☾"})]})]})]}),ki?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:["Restarted — now running v",ki,"."]}),i.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):uc&&!He?i.jsxs("div",{className:"conn-banner",role:"alert",children:[i.jsx("span",{className:"conn-dot"}),Zn?bi==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Wt}…`:(()=>{const q=uW({connected:He,paused:oo});return i.jsxs(i.Fragment,{children:[`Lost connection to the ${Wt} server. Reconnecting…`,q&&i.jsx("span",{className:"conn-sub",children:q})]})})()]}):Qn&&Ce?i.jsxs("div",{className:`ver-banner ${Ce.kind}`,role:"status",children:[i.jsx("span",{className:`ver-dot${er==null?"":" armed"}`}),Ce.kind==="restart"?i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:["v",Ce.to," is installed — this deck still runs v",Ce.from,"."]}),he!=null&&he.canRestart?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ver-act",onClick:()=>xn(),...dr(Zn),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
267
+ Click to set the volume and the sound of each tone, and to hear either one.`}function V2(e){const t=new Map;for(const n of e)for(const s of n.agents??[]){if(!s||typeof s.agent!="string"||s.agent==="")continue;const a=t.get(s.agent)??{id:s.agent,cost:0,tokens:0};a.cost+=Number.isFinite(s.totalCost)?s.totalCost:0,a.tokens+=Number.isFinite(s.totalTokens)?s.totalTokens:0,t.set(s.agent,a)}return[...t.values()].sort((n,s)=>s.cost-n.cost||n.id.localeCompare(s.id))}function QF(e){const t=V2([{agents:e}]);return t.length<2?null:t.map(n=>`${_x(n.id)} ${tt(n.cost)}`).join(" · ")}function B1(e){switch(e.toLowerCase()){case"claude":return"var(--usage-purple)";case"codex":return"var(--usage-orange)";case"gemini":return"var(--usage-indigo)";case"copilot":return"var(--usage-green)";default:return"var(--usage-zinc)"}}function ZF(e,t){if(!(t>0)||!(e>0))return"0%";const n=e/t*100;return n<.1?"<0.1%":`${n.toFixed(1)}%`}function Pu(e){const t=e.toLowerCase();return t.includes("opus")?"var(--usage-purple)":t.includes("sonnet")?"var(--usage-blue)":t.includes("haiku")?"var(--usage-green)":t.includes("gpt-5")||t.includes("gpt5")?"var(--usage-amber)":t.includes("gpt")?"var(--usage-red)":t.includes("gemini")?"var(--usage-indigo)":t.includes("codex")?"var(--usage-orange)":"var(--usage-zinc)"}const JF=[7,14,30,90];function e8(e){const[t,n]=b.useState(null),[s,a]=b.useState(!1),l=b.useState(WF)[0],c=b.useRef(!1),d=(h=!1)=>{if(h&&!hr(c.current))return;const p=l.begin();c.current=h;const f=e;a(!0);const y=`/api/ccusage?since=${Cv(f)}${h?"&refresh=1":""}`;fetch(y).then(v=>v.json()).then(v=>{p()&&n({range:f,resp:v})}).catch(()=>{p()&&n({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&(c.current=!1,a(!1))})};return b.useEffect(()=>(d(!1),()=>l.cancel()),[e]),{landed:t,loading:s,reload:()=>d(!0)}}function t8({onClose:e,providers:t}){var F;const[n,s]=b.useState(30),[a,l]=b.useState(null),{landed:c,loading:d,reload:h}=e8(n),p=b.useRef(null),f=Ht(e,{focusRef:p}),m=HF({loading:d,want:n,answer:c&&{range:c.range,ok:c.resp.ok===!0,days:((F=c.resp.days)==null?void 0:F.length)??0}}),y=m.phase==="chart"?c.resp.days??[]:[],v=b.useMemo(()=>y.reduce((O,M)=>Math.max(O,M.totalCost),0),[y]),j=b.useRef(null);b.useLayoutEffect(()=>{const O=j.current;O&&(O.scrollLeft=O.scrollWidth)},[y]);const{totalCost:_,totalTok:S,inOut:x,cacheRead:N,modelCosts:E}=b.useMemo(()=>{let O=0,M=0,L=0,H=0;const B=new Map;for(const A of y){O+=A.totalCost,M+=A.totalTokens,L+=A.inputTokens+A.outputTokens,H+=A.cacheReadTokens;for(const Q of A.modelBreakdowns)B.set(Q.modelName,(B.get(Q.modelName)??0)+Q.cost)}return{totalCost:O,totalTok:M,inOut:L,cacheRead:H,modelCosts:B}},[y]),C=b.useMemo(()=>Array.from(E.entries()).sort((O,M)=>M[1]-O[1]),[E]),R=b.useMemo(()=>V2(y),[y]),I=R.length>1,$=a?y.find(O=>O.period===a)??null:null;return i.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:f,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[i.jsxs("header",{className:"uh-head",children:[i.jsxs("div",{className:"uh-titlewrap",children:[i.jsx("div",{className:"uh-title",children:"Usage history"}),i.jsx("div",{className:"uh-sub",children:YF(t,R.map(O=>O.id))})]}),i.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:JF.map(O=>i.jsxs("button",{type:"button","aria-pressed":n===O,className:"uh-range-btn",onClick:()=>{s(O),l(null)},children:[O,"d"]},O))}),i.jsx("button",{className:"glyph-btn uh-reload",onClick:h,...dr(d),title:"Re-run ccusage","aria-label":"Reload",children:d?"…":"↻"}),i.jsx("button",{ref:p,className:"glyph-btn uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?i.jsxs("div",{className:"uh-status uh-status-wait","aria-busy":"true",children:[i.jsx("span",{className:"uh-wait-word",children:c?"running ccusage…":"running ccusage… (first run downloads the package)"}),i.jsx("span",{className:"uh-wait-axis","aria-hidden":!0})]}):m.phase==="error"?i.jsxs("div",{className:"uh-status uh-err",title:ii(c.resp)||void 0,children:[XD(c.resp,"ccusage did not report usage"),i.jsx("div",{children:i.jsx("button",{className:"btn uh-retry",onClick:h,...dr(d),children:d?"trying…":"Try again"})})]}):m.phase==="empty"?i.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):i.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[i.jsxs("div",{className:"uh-totals",children:[i.jsx(Lu,{label:"total cost",val:tt(_),accent:!0}),i.jsx(Lu,{label:"tokens",val:At(S)}),i.jsx(Lu,{label:"input+output",val:At(x)}),i.jsx(Lu,{label:"cache reads",val:At(N)})]}),I&&i.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[i.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:R.map(O=>i.jsx("span",{className:"uh-agent-seg",style:{width:`${_>0?O.cost/_*100:0}%`,background:B1(O.id)}},O.id))}),i.jsx("div",{className:"uh-agent-keys",children:R.map(O=>i.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${At(O.tokens)} tokens`,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:B1(O.id)}}),_x(O.id),i.jsx("span",{className:"uh-agent-cost",children:tt(O.cost)}),i.jsx("span",{className:"uh-agent-share",children:ZF(O.cost,_)})]},O.id))})]}),i.jsx("div",{ref:j,className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map((O,M)=>{const L=v>0?O.totalCost/v*100:0,H=O.period===a,B=`${O.period}, ${tt(O.totalCost)}`;return i.jsxs("button",{className:`uh-bar-col${H?" sel":""}`,onClick:()=>l(H?null:O.period),"aria-pressed":H,"aria-label":B,title:`${O.period} · ${tt(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`,"--uh-i":M,"--uh-step":`${Math.min(10,200/Math.max(y.length,1))}ms`},children:[i.jsx("div",{className:"uh-bar",style:{height:`${Math.max(L,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((A,Q)=>Q.cost-A.cost).map(A=>{const Q=O.totalCost>0?A.cost/O.totalCost*100:0;return i.jsx("div",{className:"uh-bar-seg",style:{height:`${Q}%`,background:Pu(A.modelName)}},A.modelName)})}),i.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),i.jsx("div",{className:"uh-legend",children:C.map(([O,M])=>i.jsxs("span",{className:"uh-legend-item",title:O,children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Pu(O)}}),Ks(O)," ",i.jsx("span",{className:"uh-legend-cost",children:tt(M)})]},O))}),$&&i.jsxs("div",{className:"uh-detail",children:[i.jsxs("div",{className:"uh-detail-head",children:[i.jsx("span",{className:"uh-detail-date",children:$.period}),i.jsx("span",{className:"uh-detail-cost",children:tt($.totalCost)}),(()=>{var L,H;const M=QF($.agents)??((H=(L=$.metadata)==null?void 0:L.agents)!=null&&H.length?$.metadata.agents.join(" · "):null);return M?i.jsx("span",{className:"uh-detail-agents",title:M,children:M}):null})()]}),i.jsxs("div",{className:"uh-detail-mini",children:[i.jsx(Du,{label:"input",val:At($.inputTokens)}),i.jsx(Du,{label:"output",val:At($.outputTokens)}),i.jsx(Du,{label:"cache write",val:At($.cacheCreationTokens)}),i.jsx(Du,{label:"cache read",val:At($.cacheReadTokens)})]}),i.jsx("div",{className:"uh-detail-models",children:$.modelBreakdowns.slice().sort((O,M)=>M.cost-O.cost).map(O=>{const M=$.totalCost>0?O.cost/$.totalCost*100:0;return i.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[i.jsxs("span",{className:"uh-model-name",children:[i.jsx("span",{className:"uh-legend-dot",style:{background:Pu(O.modelName)}}),i.jsx("span",{className:"uh-model-label",children:Ks(O.modelName)})]}),i.jsx("span",{className:"uh-model-bar",children:i.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Pu(O.modelName)}})}),i.jsx("span",{className:"uh-model-cost",children:tt(O.cost)})]},O.modelName)})})]})]})]})})}function Lu({label:e,val:t,accent:n}){return i.jsxs("div",{className:"uh-stat",children:[i.jsx("span",{className:`uh-stat-val${n?" accent":""}`,children:t}),i.jsx("span",{className:"uh-stat-label",children:e})]})}function Du({label:e,val:t}){return i.jsxs("div",{className:"uh-ministat",children:[i.jsx("span",{className:"uh-ministat-val",children:t}),i.jsx("span",{className:"uh-ministat-label",children:e})]})}function n8(e){const t=/^#?([0-9a-f]{6})$/i.exec((e??"").trim());if(!t)return!1;const n=parseInt(t[1],16),s=[n>>16&255,n>>8&255,n&255].map(a=>{const l=a/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)});return .2126*s[0]+.7152*s[1]+.0722*s[2]>.5}const z1=1e4,r8=12e3;function s8({browsers:e,findings:t,watching:n,palette:s,now:a=()=>Date.now()}){const l=b.useRef(null),c=b.useRef(null);return c.current={browsers:e,findings:t,watching:n},b.useEffect(()=>{var v;const d=l.current;if(!d)return;const h=d.getContext("2d");if(!h)return;const p=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let f=0,m=!1;const y=()=>{var ee;if(m)return;const j=c.current;if(!j)return;const{browsers:_,findings:S,watching:x}=j,N=s["--accent"]||"#7dd3fc",E=s["--line"]||"#1f2229",C=s["--text-dim"]||"#6e727c",R=n8(s["--bg"]),I=R?42:26,$=R?.85:.65,F=a(),O=Math.min(window.devicePixelRatio||1,2),M=d.clientWidth,L=d.clientHeight;(d.width!==M*O||d.height!==L*O)&&(d.width=M*O,d.height=L*O),h.setTransform(O,0,0,O,0,0),h.clearRect(0,0,M,L);const H=M/2,B=L/2,A=Math.min(M,L)/2-6;h.strokeStyle=E,h.lineWidth=1,h.globalAlpha=R?1:.9;for(const Z of[.4,.7,1])h.beginPath(),h.arc(H,B,A*Z,0,Math.PI*2),h.stroke();h.beginPath(),h.moveTo(H-A,B),h.lineTo(H+A,B),h.moveTo(H,B-A),h.lineTo(H,B+A),h.stroke(),h.globalAlpha=1;const K=(x&&!p?F%z1/z1:0)*Math.PI*2-Math.PI/2;if(x){const Z=(ee=h.createConicGradient)==null?void 0:ee.call(h,K-.85,H,B);Z&&(Z.addColorStop(0,"transparent"),Z.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${N} ${I}%, transparent)`),Z.addColorStop(1,"transparent"),h.fillStyle=Z,h.beginPath(),h.moveTo(H,B),h.arc(H,B,A,K-.85,K),h.closePath(),h.fill()),h.strokeStyle=N,h.globalAlpha=$,h.beginPath(),h.moveTo(H,B),h.lineTo(H+Math.cos(K)*A,B+Math.sin(K)*A),h.stroke(),h.globalAlpha=1}_.forEach((Z,D)=>{const Y=D/Math.max(_.length,1)*Math.PI*2-Math.PI/2,P=Z.lastReadMs===null?1:Math.min(1,(F-Z.lastReadMs)/12e4),G=A*(.42+P*.5),de=H+Math.cos(Y)*G,W=B+Math.sin(Y)*G,U=Math.abs((K-Y+Math.PI*3)%(Math.PI*2)-Math.PI),J=x?Math.max(0,1-U/.55):0;h.beginPath(),h.arc(de,W,3+J*1.6,0,Math.PI*2),h.fillStyle=Z.running?N:C,h.globalAlpha=Z.running?.55+J*.45:.35,h.fill(),h.globalAlpha=1});for(const Z of S){const D=(F-Z.atMs)/r8;if(D<0||D>1)continue;const P=Math.max(0,_.findIndex(W=>W.key===Z.browser))/Math.max(_.length,1)*Math.PI*2-Math.PI/2,G=H+Math.cos(P)*A*.6,de=B+Math.sin(P)*A*.6;h.beginPath(),h.arc(G,de,4+D*22,0,Math.PI*2),h.strokeStyle=N,h.globalAlpha=(1-D)*.8,h.lineWidth=1.5,h.stroke(),h.globalAlpha=1}f=requestAnimationFrame(y)};return y(),()=>{m=!0,cancelAnimationFrame(f)}},[a,s]),i.jsx("canvas",{ref:l,className:"bw-radar",role:"img","aria-label":n?`Watching ${e.length} browser${e.length===1?"":"s"}`:"Not watching"})}const U1="agent-dag.browserWatch.seenMs";function a8(e,t){return e.filter(n=>n.startMs>t)}function o8(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function i8(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 Y2(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function W1(e,t){return t?{kind:"saving",word:"Saving",detail:""}:e.settings.enabled?{kind:"on",word:"Watching",detail:""}:{kind:"off",word:"Paused",detail:"nothing new is recorded"}}function l8(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 c8(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 u8(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=Y2(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."}}function d8(e){const t=n=>new Date(n).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.count===1||e.endMs-e.startMs<6e4?t(e.startMs):`${t(e.startMs)} → ${t(e.endMs)}`}function h8(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function H1(e){const t=Math.round((e.endMs-e.startMs)/6e4);return t<1?"":`${t} min`}function f8({onClose:e,onSeen:t,onWatching:n,palette:s}){const a=Ht(e),[l,c]=b.useState(null),[d,h]=b.useState(null),[p,f]=b.useState(null),[m,y]=b.useState(!1),v=b.useRef(!1),[j,_]=b.useState(null),[S,x]=b.useState(null),[N,E]=b.useState(!1),C=b.useRef(!1),[R,I]=b.useState(!1),[$,F]=b.useState(!1),[O,M]=b.useState(!1),[L,H]=b.useState(!1),[B,A]=b.useState(!1),[Q,K]=b.useState(()=>Date.now());b.useEffect(()=>{const V=setInterval(()=>K(Date.now()),1e3);return()=>clearInterval(V)},[]);const ee=b.useCallback(async V=>{var ie,pe;if(!(V&&!hr(v.current))){v.current=V,y(!0);try{const me=await fetch(`/api/browser-watch${V?"?refresh=1":""}`);if(!me.ok)throw new Error(`the deck answered ${me.status}`);const Ie=await me.json();c(Ie),C.current||_(((ie=Ie==null?void 0:Ie.settings)==null?void 0:ie.quietMinutes)??15),n(((pe=Ie==null?void 0:Ie.settings)==null?void 0:pe.enabled)===!0),h(null)}catch(me){h(me instanceof Error?me.message:String(me))}finally{v.current=!1,y(!1)}}},[n]);b.useEffect(()=>{ee(!1)},[ee]),b.useEffect(()=>{const V=setInterval(()=>{ee(!1)},1e4);return()=>clearInterval(V)},[ee]);const Z=b.useCallback(async V=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:V.host,startMs:V.startMs})})}finally{await ee(!1)}},[ee]),D=b.useCallback(async V=>{C.current=!0,E(!0);try{const ie=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)});if(!ie.ok)throw new Error(`the deck answered ${ie.status}`);await ee(!1),f(null)}catch(ie){f(ie instanceof Error?ie.message:String(ie))}finally{C.current=!1,E(!1)}},[ee]),Y=b.useRef(t);Y.current=t,b.useEffect(()=>()=>Y.current(Date.now()),[]);const P=b.useMemo(()=>{const V=[];for(const ie of(l==null?void 0:l.episodes)??[]){const pe=h8(ie.startMs),me=V[V.length-1];me&&me.label===pe?me.episodes.push(ie):V.push({label:pe,episodes:[ie]})}return V},[l]),G=Y2(l==null?void 0:l.browsers),de=((l==null?void 0:l.browsers)??[]).filter(V=>!(V.installed&&V.profiles>0)),W=l?u8(l):null,U=G.reduce((V,ie)=>V+ie.profiles,0),J=l?o8(l.coverage.lastHumanMs,l.coverage.quietMs,Q):null;return i.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:i.jsxs("div",{ref:a,className:"modal bw-modal",onClick:V=>V.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("span",{className:"modal-tool-name",id:"bw-title",children:"Browser watch"}),i.jsx("span",{className:"modal-tool-id",children:l?`${U} ${U===1?"profile":"profiles"} · local only`:"local only"})]}),i.jsxs("div",{className:"modal-actions",children:[i.jsx("button",{className:"glyph-btn",onClick:()=>void ee(!0),...dr(m),"aria-label":"Re-read every profile now",title:"Re-read every profile now",children:m?"…":"↻"}),i.jsx("button",{className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),i.jsxs("div",{className:"modal-body bw-body",children:[!l&&!d&&i.jsxs("div",{className:"bw-loading",children:[i.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),i.jsx("p",{children:"Reading each browser's history. The first look copies the file, which takes a moment."})]}),d&&i.jsx("div",{className:"bw-state",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not read"}),i.jsx("span",{className:"bw-row-detail",children:d})]})}),l&&W&&i.jsx("p",{className:`bw-trouble ${W.kind}`,role:"status",children:W.text}),l&&i.jsxs("div",{className:"bw-work",children:[i.jsxs("aside",{className:"bw-side",children:[i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Activity overview",i.jsx("button",{className:"bw-help",onClick:()=>M(V=>!V),"aria-expanded":O,"aria-label":"What the sweep and the dots mean",children:"?"})]}),i.jsxs("div",{className:"bw-glance",children:[i.jsx(s8,{browsers:G.map(V=>{var ie;return{key:V.key,name:V.name,running:V.running,lastReadMs:((ie=l.profiles.find(pe=>pe.browser===V.key))==null?void 0:ie.lastWrittenMs)??null}}),findings:l.episodes.slice(0,6).map(V=>({browser:V.browser??null,atMs:V.endMs})),watching:l.settings.enabled,palette:s}),i.jsx("ul",{className:"bw-counts",children:l8(G,l.profiles).map(V=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-count-n",children:V.visits.toLocaleString("en-US")}),i.jsx("span",{className:"bw-count-of",children:V.name})]},V.key))})]}),i.jsx("p",{className:"bw-since",children:"Pages a program opened, since this deck started"}),l.coverage.checkedMs>0&&i.jsxs("p",{className:"bw-since",children:["Last checked ",c8(l.coverage.checkedMs,Q),l.coverage.checks>0&&i.jsxs(i.Fragment,{children:[" · ",l.coverage.checks.toLocaleString("en-US")," ",l.coverage.checks===1?"check":"checks"]})]}),J!==null&&i.jsxs("p",{className:"bw-gate",children:["You are browsing — a program page would count in ",i8(J)]}),O&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Sweep"}),i.jsx("dd",{children:"one poll of every watched profile"}),i.jsx("dt",{children:"Dot"}),i.jsx("dd",{children:"a browser, further out the longer since it last wrote history"}),i.jsx("dt",{children:"Ring"}),i.jsx("dd",{children:"a finding, leaving the browser it came from"})]})]}),i.jsxs("section",{className:"bw-sec",children:[i.jsxs("h4",{className:"bw-sec-head",children:["Watched profiles",i.jsx("button",{className:"bw-help",onClick:()=>H(V=>!V),"aria-expanded":L,"aria-label":"What running, idle and connected to Anthropic mean",children:"?"})]}),L&&i.jsxs("dl",{className:"bw-key",children:[i.jsx("dt",{children:"Running"}),i.jsx("dd",{children:"the browser has a process on this machine right now"}),i.jsx("dt",{children:"Connected"}),i.jsx("dd",{children:"an open connection to an address Anthropic's relay uses — which it shares with claude.ai, so an open tab looks the same as an agent channel"})]}),i.jsx("ul",{className:"bw-profiles",children:G.map(V=>i.jsxs("li",{children:[i.jsx("span",{className:`bw-prof-dot${V.running?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-prof-name",children:V.name}),i.jsx("span",{className:"bw-prof-state",children:V.running?"running":"idle"}),V.running&&V.relay.state==="live"&&i.jsx("span",{className:"bw-relay",children:"connected to Anthropic"})]},V.key))}),de.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>A(V=>!V),"aria-expanded":B,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:B?"▾":"▸"})," ",de.length," not watched"]}),B&&i.jsxs("p",{className:"bw-rest",children:[de.map(V=>V.name).join(", ")," — not installed, or installed and never opened, so there is no history to read."]})]})]}),l.relay&&i.jsx(p8,{relay:l.relay})]}),i.jsxs("div",{className:"bw-main",children:[i.jsxs("section",{className:"bw-findings",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Findings",l.episodes.length>0&&i.jsxs("span",{className:"bw-feed-count",children:[l.episodes.length," ",l.episodes.length===1?"episode":"episodes"]})]}),i.jsx("div",{className:"bw-eps",children:P.length===0?i.jsxs("div",{className:"bw-empty",children:[i.jsx("p",{className:"bw-empty-head",children:"Nothing found yet"}),i.jsxs("p",{className:"bw-empty-note",children:["An episode lands here when a program opens pages in a browser nobody has touched for"," ",l.settings.quietMinutes," ",l.settings.quietMinutes===1?"minute":"minutes",". On most machines that is rare, so an empty list is the ordinary result rather than a sign something is wrong."]}),!l.settings.enabled&&i.jsx("p",{className:"bw-empty-note",children:"Watching is off, so this shows only what this deck has seen since it started. Anything an earlier run recorded comes back when you switch it on."})]}):P.map(V=>i.jsxs("div",{className:"bw-day",children:[i.jsx("h4",{className:"bw-sec-head",children:V.label}),V.episodes.map(ie=>{const pe=`${ie.host}-${ie.startMs}`,me=S===pe;return i.jsxs("div",{className:`bw-ep${me?" open":""}`,children:[i.jsxs("div",{className:"bw-ep-row",children:[i.jsxs("button",{className:"bw-ep-head",onClick:()=>x(me?null:pe),"aria-expanded":me,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:me?"▾":"▸"}),i.jsx("span",{className:"bw-ep-host",children:ie.host}),i.jsxs("span",{className:"bw-ep-meta",children:[d8(ie),H1(ie)&&i.jsxs(i.Fragment,{children:[" · ",H1(ie)]})]}),i.jsxs("span",{className:"bw-ep-count",children:[ie.count," ",ie.count===1?"page":"pages"]})]}),i.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>void Z(ie),"aria-label":`Dismiss ${ie.host}`,title:"Dismiss — it leaves this list for good, and stays in the log file",children:"×"})]}),me&&i.jsx("ul",{className:"bw-urls",children:ie.urls.map((Ie,Le)=>i.jsxs("li",{children:[i.jsx("span",{className:"bw-url-time",children:new Date(Ie.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),i.jsx("span",{className:"bw-url",children:Ie.url})]},`${Ie.url}-${Ie.timeMs}-${Le}`))})]},pe)})]},V.label))})]}),i.jsxs("section",{className:"bw-feed",children:[i.jsxs("h4",{className:"bw-sec-head bw-head-row",children:["Live activity",i.jsxs("span",{className:"bw-feed-count",children:[l.log.length," ",l.log.length===1?"event":"events"]})]}),i.jsx("p",{className:"bw-since bw-feed-note",children:"Pages you opened yourself — counted to run the rule, never written down. Addresses appear under Findings, and only for pages a program opened."}),i.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:l.log.length===0?i.jsx("p",{className:"bw-note",children:"The deck writes a line here each time it looks at a profile."}):l.log.map(V=>i.jsxs("div",{className:`bw-log-line ${V.level}${V.parts?"":" sys"}`,children:[i.jsx("span",{className:"bw-log-time",children:new Date(V.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),V.parts?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"bw-log-browser",children:V.parts.browser}),i.jsx("span",{className:"bw-log-profile",title:V.parts.profile,children:V.parts.profile}),i.jsxs("span",{className:"bw-log-value",children:[V.parts.value,V.parts.flagged>0&&i.jsxs("span",{className:"bw-log-flag",children:[" · ",V.parts.flagged," flagged"]})]})]}):i.jsx("span",{className:"bw-log-sys",children:V.text})]},`${V.atMs}-${V.level}-${V.text}`))})]})]})]}),l&&R&&i.jsxs("div",{className:"bw-settings",children:[i.jsxs("label",{title:"A program opening a page counts as a finding only if nobody had touched the browser for this long. Shorter catches more and reports more of your own work; longer is quieter.",children:[i.jsx("span",{children:"Nobody browsing for"}),i.jsxs("select",{value:j??l.settings.quietMinutes,onChange:V=>{_(Number(V.target.value)),D({quietMinutes:Number(V.target.value)})},children:[i.jsx("option",{value:1,children:"1 min"}),i.jsx("option",{value:5,children:"5 min"}),i.jsx("option",{value:15,children:"15 min"}),i.jsx("option",{value:30,children:"30 min"}),i.jsx("option",{value:60,children:"60 min"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"When it finds one"}),i.jsx("select",{value:l.settings.reaction,onChange:V=>void D({reaction:V.target.value}),disabled:!l.settings.enabled,title:l.settings.enabled?"What to do besides writing it down.":"Turn watching on to arm a reaction.",children:(l.reactions??["notify"]).map(V=>i.jsx("option",{value:V,children:V==="notify"?"notify me":V==="close-tab"?"close the tab":"quit the browser"},V))})]}),i.jsxs("div",{className:"bw-settings-note",children:[i.jsxs("p",{children:["Chrome marks a navigation that came from an extension or a command rather than from a click. These are the ones that happened while nobody had touched the browser for the time above. ",i.jsx("strong",{children:"Usually that is your own agent doing what you asked."})]}),i.jsxs("button",{className:"bw-why",onClick:()=>F(V=>!V),"aria-expanded":$,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:$?"▾":"▸"})," What Browser Watch can access"]}),$&&i.jsxs("dl",{className:"bw-access",children:[i.jsx("dt",{children:"Reads"}),i.jsxs("dd",{children:["A copy of each browser's own history database — the live file is locked while the browser holds it. Only rows newer than the moment this deck started:"," ",new Date(l.coverage.startedMs).toLocaleString(),"."]}),i.jsx("dt",{children:"Keeps"}),i.jsxs("dd",{children:["Only while the switch is on, and only the episodes it flagged — never your ordinary browsing. In ",i.jsx("code",{className:"bw-path",children:l.coverage.logPath}),", with every address written in full so you can check it yourself."]}),i.jsx("dt",{children:"Sends"}),i.jsx("dd",{children:"Nothing. No part of this reads or writes over the network; the deck serves on 127.0.0.1 and this panel talks only to it."}),i.jsx("dt",{children:"Never reads"}),i.jsx("dd",{children:"Anything from before this deck started, cookies, saved passwords, page contents, or any browser profile with no history file."})]})]})]}),p&&i.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:i.jsxs("div",{className:"bw-row err",children:[i.jsx("span",{className:"bw-dot","aria-hidden":!0}),i.jsx("span",{className:"bw-row-label",children:"Could not save that setting"}),i.jsxs("span",{className:"bw-row-detail",children:[p," — the switches below show what is stored, not what you pressed."]}),i.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>f(null),"aria-label":"Dismiss",title:"Dismiss",children:"×"})]})}),l&&i.jsxs("footer",{className:"bw-status",children:[i.jsx("span",{className:`bw-mode-dot${l.settings.enabled?" on":""}`,"aria-hidden":!0}),i.jsx("span",{className:"bw-mode-word",children:W1(l,N).word},W1(l,N).kind),i.jsx("span",{className:"bw-status-text",children:l.coverage.archived===0?l.settings.enabled?"No episodes recorded yet":"No episodes on disk":`${l.coverage.archived} ${l.coverage.archived===1?"episode":"episodes"} on disk`}),i.jsx("button",{className:`glyph-btn bw-gear${R?" on":""}`,onClick:()=>I(V=>!V),"aria-expanded":R,"aria-label":"Settings",title:"Settings",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),i.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),i.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[i.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:"Watch browser activity"}),i.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":l.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"bw-toggle",onClick:()=>void D({enabled:!l.settings.enabled}),title:l.settings.enabled?"On — every episode it finds is written down, so the list outlives the browsing history being cleared":"Off — showing only what this deck has seen since it started. Anything an earlier run archived is hidden until you switch back on, and nothing new is kept",children:i.jsx("span",{className:"bw-toggle-knob"})})]})]})]})]})})}function p8({relay:e}){const[t,n]=b.useState(!1),[s,a]=b.useState(!1),l=e.killswitch.blocked?"unblock":"block",c=e.command[l],d=b.useCallback(async()=>{await L2(c.command)&&(a(!0),window.setTimeout(()=>a(!1),1600))},[c.command]),h=e.profiles.filter(f=>{var m;return(m=f.report)==null?void 0:m.present}),p=e.profiles.filter(f=>f.report===null);return i.jsxs("section",{className:"bw-sec",children:[i.jsx("h4",{className:"bw-sec-head",children:"Remote control"}),i.jsx("p",{className:`bw-rc-verdict ${e.verdict}`,role:"status",children:e.verdict==="exposed"?"Claude in Chrome is live here, so any Claude Code session signed in to your Anthropic account can drive this browser — from any machine, with no prompt on this one.":e.verdict==="protected"?`The relay is black-holed in ${e.hostsPath}, so no new connection to it can be made from this machine.`:"Claude in Chrome is not installed and enabled in any profile here, so there is nothing for the relay to drive."}),e.killswitch.foreign.length>0&&i.jsxs("p",{className:"bw-rc-foreign",children:["Another entry for this host is already in ",e.hostsPath,", and ccdeck will not touch it:",e.killswitch.foreign.map(f=>i.jsx("code",{className:"bw-path",children:f},f))]}),i.jsxs("button",{className:"bw-why",onClick:()=>n(f=>!f),"aria-expanded":t,children:[i.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",e.verdict==="protected"?"How to undo the block":"What it can reach, and how to stop it"]}),t&&i.jsxs("div",{className:"bw-rc-body",children:[h.length>0&&i.jsx("dl",{className:"bw-key",children:h.map(f=>i.jsxs(b.Fragment,{children:[i.jsxs("dt",{children:[f.name,f.profile==="Default"?"":` · ${f.profile}`]}),i.jsxs("dd",{children:[f.report.enabled?"enabled":"installed but switched off",f.report.allUrls?", can act on every site":", limited to the sites it was granted",f.report.sensitiveApis.length>0&&i.jsxs(i.Fragment,{children:[" — ",f.report.sensitiveApis.join(", ")]})]})]},`${f.browser}/${f.profile}`))}),p.length>0&&i.jsxs("p",{className:"bw-rc-note",children:[p.map(f=>f.name).join(", ")," — its settings file could not be read, so nothing is claimed about it either way."]}),!e.hostsRead&&i.jsxs("p",{className:"bw-rc-note",children:[e.hostsPath," could not be read, so whether the relay is already blocked is unknown."]}),h.some(f=>f.report.allUrls)&&i.jsxs("p",{className:"bw-rc-note",children:["Narrowing the sites in ",i.jsx("code",{className:"bw-path",children:"chrome://extensions"})," does not change this: the grant is held at the browser level and the per-site list is enforced inside the extension, by the extension."]}),i.jsxs("div",{className:"bw-rc-cmd",children:[i.jsx("code",{children:c.command}),i.jsx("button",{className:"btn bw-rc-copy",onClick:d,children:s?"Copied":"Copy"})]}),i.jsx("p",{className:"bw-rc-note",children:c.note})]})]})}function m8(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,l)=>(a.at??0)-(l.at??0));return{request:s[0],waiting:s.length-1}}function g8({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:l,onLater:c}){const d=b.useRef(null),h=Ht(c,{focusRef:d}),p=Xs(n,"accept"),f=Xs(n,"dismiss");return i.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:i.jsxs("div",{ref:h,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[i.jsxs("header",{className:"modal-head",children:[i.jsxs("div",{className:"modal-title",children:[i.jsx("i",{className:"ap-pulse","aria-hidden":!0}),i.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),i.jsx("div",{className:"modal-actions",children:i.jsx("button",{type:"button",className:"glyph-btn",onClick:c,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),i.jsxs("section",{className:"modal-body",children:[i.jsxs("p",{className:"lan-ask-who",children:[i.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",i.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",xx(e.at,s)]}),i.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),i.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",i.jsx("code",{className:"ap-lan-code",children:e.fp})," — it should match the one on their screen."]}),t>0&&i.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),i.jsxs("div",{className:"lan-ask-acts",children:[i.jsx("button",{type:"button",ref:d,className:"btn",disabled:f.disabled,"aria-busy":f.busy,onClick:l,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),i.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.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 Nx(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 qf,G1;function y8(){if(G1)return qf;G1=1;function e(){this.__data__=[],this.size=0}return qf=e,qf}var Ff,V1;function pi(){if(V1)return Ff;V1=1;function e(t,n){return t===n||t!==t&&n!==n}return Ff=e,Ff}var Bf,Y1;function Ed(){if(Y1)return Bf;Y1=1;var e=pi();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Bf=t,Bf}var zf,K1;function w8(){if(K1)return zf;K1=1;var e=Ed(),t=Array.prototype,n=t.splice;function s(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var d=l.length-1;return c==d?l.pop():n.call(l,c,1),--this.size,!0}return zf=s,zf}var Uf,X1;function v8(){if(X1)return Uf;X1=1;var e=Ed();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Uf=t,Uf}var Wf,Q1;function x8(){if(Q1)return Wf;Q1=1;var e=Ed();function t(n){return e(this.__data__,n)>-1}return Wf=t,Wf}var Hf,Z1;function b8(){if(Z1)return Hf;Z1=1;var e=Ed();function t(n,s){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,s])):a[l][1]=s,this}return Hf=t,Hf}var Gf,J1;function Cd(){if(J1)return Gf;J1=1;var e=y8(),t=w8(),n=v8(),s=x8(),a=b8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,Gf=l,Gf}var Vf,e_;function k8(){if(e_)return Vf;e_=1;var e=Cd();function t(){this.__data__=new e,this.size=0}return Vf=t,Vf}var Yf,t_;function _8(){if(t_)return Yf;t_=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Yf=e,Yf}var Kf,n_;function N8(){if(n_)return Kf;n_=1;function e(t){return this.__data__.get(t)}return Kf=e,Kf}var Xf,r_;function S8(){if(r_)return Xf;r_=1;function e(t){return this.__data__.has(t)}return Xf=e,Xf}var Qf,s_;function K2(){if(s_)return Qf;s_=1;var e=typeof yu=="object"&&yu&&yu.Object===Object&&yu;return Qf=e,Qf}var Zf,a_;function yr(){if(a_)return Zf;a_=1;var e=K2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Zf=n,Zf}var Jf,o_;function mi(){if(o_)return Jf;o_=1;var e=yr(),t=e.Symbol;return Jf=t,Jf}var ep,i_;function j8(){if(i_)return ep;i_=1;var e=mi(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function l(c){var d=n.call(c,a),h=c[a];try{c[a]=void 0;var p=!0}catch{}var f=s.call(c);return p&&(d?c[a]=h:delete c[a]),f}return ep=l,ep}var tp,l_;function E8(){if(l_)return tp;l_=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return tp=n,tp}var np,c_;function Qa(){if(c_)return np;c_=1;var e=mi(),t=j8(),n=E8(),s="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(d){return d==null?d===void 0?a:s:l&&l in Object(d)?t(d):n(d)}return np=c,np}var rp,u_;function Yn(){if(u_)return rp;u_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return rp=e,rp}var sp,d_;function tc(){if(d_)return sp;d_=1;var e=Qa(),t=Yn(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(d){if(!t(d))return!1;var h=e(d);return h==s||h==a||h==n||h==l}return sp=c,sp}var ap,h_;function C8(){if(h_)return ap;h_=1;var e=yr(),t=e["__core-js_shared__"];return ap=t,ap}var op,f_;function T8(){if(f_)return op;f_=1;var e=C8(),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 op=n,op}var ip,p_;function X2(){if(p_)return ip;p_=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 ip=n,ip}var lp,m_;function A8(){if(m_)return lp;m_=1;var e=tc(),t=T8(),n=Yn(),s=X2(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,d=Object.prototype,h=c.toString,p=d.hasOwnProperty,f=RegExp("^"+h.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var v=e(y)?f:l;return v.test(s(y))}return lp=m,lp}var cp,g_;function R8(){if(g_)return cp;g_=1;function e(t,n){return t==null?void 0:t[n]}return cp=e,cp}var up,y_;function Za(){if(y_)return up;y_=1;var e=A8(),t=R8();function n(s,a){var l=t(s,a);return e(l)?l:void 0}return up=n,up}var dp,w_;function Sx(){if(w_)return dp;w_=1;var e=Za(),t=yr(),n=e(t,"Map");return dp=n,dp}var hp,v_;function Td(){if(v_)return hp;v_=1;var e=Za(),t=e(Object,"create");return hp=t,hp}var fp,x_;function M8(){if(x_)return fp;x_=1;var e=Td();function t(){this.__data__=e?e(null):{},this.size=0}return fp=t,fp}var pp,b_;function I8(){if(b_)return pp;b_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return pp=e,pp}var mp,k_;function $8(){if(k_)return mp;k_=1;var e=Td(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var d=c[l];return d===t?void 0:d}return s.call(c,l)?c[l]:void 0}return mp=a,mp}var gp,__;function O8(){if(__)return gp;__=1;var e=Td(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return gp=s,gp}var yp,N_;function P8(){if(N_)return yp;N_=1;var e=Td(),t="__lodash_hash_undefined__";function n(s,a){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&a===void 0?t:a,this}return yp=n,yp}var wp,S_;function L8(){if(S_)return wp;S_=1;var e=M8(),t=I8(),n=$8(),s=O8(),a=P8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,wp=l,wp}var vp,j_;function D8(){if(j_)return vp;j_=1;var e=L8(),t=Cd(),n=Sx();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return vp=s,vp}var xp,E_;function q8(){if(E_)return xp;E_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return xp=e,xp}var bp,C_;function Ad(){if(C_)return bp;C_=1;var e=q8();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return bp=t,bp}var kp,T_;function F8(){if(T_)return kp;T_=1;var e=Ad();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return kp=t,kp}var _p,A_;function B8(){if(A_)return _p;A_=1;var e=Ad();function t(n){return e(this,n).get(n)}return _p=t,_p}var Np,R_;function z8(){if(R_)return Np;R_=1;var e=Ad();function t(n){return e(this,n).has(n)}return Np=t,Np}var Sp,M_;function U8(){if(M_)return Sp;M_=1;var e=Ad();function t(n,s){var a=e(this,n),l=a.size;return a.set(n,s),this.size+=a.size==l?0:1,this}return Sp=t,Sp}var jp,I_;function jx(){if(I_)return jp;I_=1;var e=D8(),t=F8(),n=B8(),s=z8(),a=U8();function l(c){var d=-1,h=c==null?0:c.length;for(this.clear();++d<h;){var p=c[d];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=s,l.prototype.set=a,jp=l,jp}var Ep,$_;function W8(){if($_)return Ep;$_=1;var e=Cd(),t=Sx(),n=jx(),s=200;function a(l,c){var d=this.__data__;if(d instanceof e){var h=d.__data__;if(!t||h.length<s-1)return h.push([l,c]),this.size=++d.size,this;d=this.__data__=new n(h)}return d.set(l,c),this.size=d.size,this}return Ep=a,Ep}var Cp,O_;function Rd(){if(O_)return Cp;O_=1;var e=Cd(),t=k8(),n=_8(),s=N8(),a=S8(),l=W8();function c(d){var h=this.__data__=new e(d);this.size=h.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=s,c.prototype.has=a,c.prototype.set=l,Cp=c,Cp}var Tp,P_;function Ex(){if(P_)return Tp;P_=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 Tp=e,Tp}var Ap,L_;function Q2(){if(L_)return Ap;L_=1;var e=Za(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Ap=t,Ap}var Rp,D_;function Md(){if(D_)return Rp;D_=1;var e=Q2();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Rp=t,Rp}var Mp,q_;function Id(){if(q_)return Mp;q_=1;var e=Md(),t=pi(),n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d){var h=l[c];(!(s.call(l,c)&&t(h,d))||d===void 0&&!(c in l))&&e(l,c,d)}return Mp=a,Mp}var Ip,F_;function nc(){if(F_)return Ip;F_=1;var e=Id(),t=Md();function n(s,a,l,c){var d=!l;l||(l={});for(var h=-1,p=a.length;++h<p;){var f=a[h],m=c?c(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),d?t(l,f,m):e(l,f,m)}return l}return Ip=n,Ip}var $p,B_;function H8(){if(B_)return $p;B_=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return $p=e,$p}var Op,z_;function $r(){if(z_)return Op;z_=1;function e(t){return t!=null&&typeof t=="object"}return Op=e,Op}var Pp,U_;function G8(){if(U_)return Pp;U_=1;var e=Qa(),t=$r(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Pp=s,Pp}var Lp,W_;function rc(){if(W_)return Lp;W_=1;var e=G8(),t=$r(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&s.call(c,"callee")&&!a.call(c,"callee")};return Lp=l,Lp}var Dp,H_;function Mt(){if(H_)return Dp;H_=1;var e=Array.isArray;return Dp=e,Dp}var jl={exports:{}},qp,G_;function V8(){if(G_)return qp;G_=1;function e(){return!1}return qp=e,qp}jl.exports;var V_;function gi(){return V_||(V_=1,(function(e,t){var n=yr(),s=V8(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,d=c?n.Buffer:void 0,h=d?d.isBuffer:void 0,p=h||s;e.exports=p})(jl,jl.exports)),jl.exports}var Fp,Y_;function $d(){if(Y_)return Fp;Y_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var l=typeof s;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return Fp=n,Fp}var Bp,K_;function Cx(){if(K_)return Bp;K_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Bp=t,Bp}var zp,X_;function Y8(){if(X_)return zp;X_=1;var e=Qa(),t=Cx(),n=$r(),s="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",p="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",v="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",x="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",$="[object Uint8Array]",F="[object Uint8ClampedArray]",O="[object Uint16Array]",M="[object Uint32Array]",L={};L[N]=L[E]=L[C]=L[R]=L[I]=L[$]=L[F]=L[O]=L[M]=!0,L[s]=L[a]=L[S]=L[l]=L[x]=L[c]=L[d]=L[h]=L[p]=L[f]=L[m]=L[y]=L[v]=L[j]=L[_]=!1;function H(B){return n(B)&&t(B.length)&&!!L[e(B)]}return zp=H,zp}var Up,Q_;function Od(){if(Q_)return Up;Q_=1;function e(t){return function(n){return t(n)}}return Up=e,Up}var El={exports:{}};El.exports;var Z_;function Tx(){return Z_||(Z_=1,(function(e,t){var n=K2(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l&&n.process,d=(function(){try{var h=a&&a.require&&a.require("util").types;return h||c&&c.binding&&c.binding("util")}catch{}})();e.exports=d})(El,El.exports)),El.exports}var Wp,J_;function sc(){if(J_)return Wp;J_=1;var e=Y8(),t=Od(),n=Tx(),s=n&&n.isTypedArray,a=s?t(s):e;return Wp=a,Wp}var Hp,eN;function Z2(){if(eN)return Hp;eN=1;var e=H8(),t=rc(),n=Mt(),s=gi(),a=$d(),l=sc(),c=Object.prototype,d=c.hasOwnProperty;function h(p,f){var m=n(p),y=!m&&t(p),v=!m&&!y&&s(p),j=!m&&!y&&!v&&l(p),_=m||y||v||j,S=_?e(p.length,String):[],x=S.length;for(var N in p)(f||d.call(p,N))&&!(_&&(N=="length"||v&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,x)))&&S.push(N);return S}return Hp=h,Hp}var Gp,tN;function Pd(){if(tN)return Gp;tN=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Gp=t,Gp}var Vp,nN;function J2(){if(nN)return Vp;nN=1;function e(t,n){return function(s){return t(n(s))}}return Vp=e,Vp}var Yp,rN;function K8(){if(rN)return Yp;rN=1;var e=J2(),t=e(Object.keys,Object);return Yp=t,Yp}var Kp,sN;function Ax(){if(sN)return Kp;sN=1;var e=Pd(),t=K8(),n=Object.prototype,s=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var d in Object(l))s.call(l,d)&&d!="constructor"&&c.push(d);return c}return Kp=a,Kp}var Xp,aN;function cs(){if(aN)return Xp;aN=1;var e=tc(),t=Cx();function n(s){return s!=null&&t(s.length)&&!e(s)}return Xp=n,Xp}var Qp,oN;function Qs(){if(oN)return Qp;oN=1;var e=Z2(),t=Ax(),n=cs();function s(a){return n(a)?e(a):t(a)}return Qp=s,Qp}var Zp,iN;function X8(){if(iN)return Zp;iN=1;var e=nc(),t=Qs();function n(s,a){return s&&e(a,t(a),s)}return Zp=n,Zp}var Jp,lN;function Q8(){if(lN)return Jp;lN=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Jp=e,Jp}var em,cN;function Z8(){if(cN)return em;cN=1;var e=Yn(),t=Pd(),n=Q8(),s=Object.prototype,a=s.hasOwnProperty;function l(c){if(!e(c))return n(c);var d=t(c),h=[];for(var p in c)p=="constructor"&&(d||!a.call(c,p))||h.push(p);return h}return em=l,em}var tm,uN;function Ja(){if(uN)return tm;uN=1;var e=Z2(),t=Z8(),n=cs();function s(a){return n(a)?e(a,!0):t(a)}return tm=s,tm}var nm,dN;function J8(){if(dN)return nm;dN=1;var e=nc(),t=Ja();function n(s,a){return s&&e(a,t(a),s)}return nm=n,nm}var Cl={exports:{}};Cl.exports;var hN;function eA(){return hN||(hN=1,(function(e,t){var n=yr(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?n.Buffer:void 0,d=c?c.allocUnsafe:void 0;function h(p,f){if(f)return p.slice();var m=p.length,y=d?d(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(Cl,Cl.exports)),Cl.exports}var rm,fN;function tA(){if(fN)return rm;fN=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 rm=e,rm}var sm,pN;function nA(){if(pN)return sm;pN=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=0,c=[];++s<a;){var d=t[s];n(d,s,t)&&(c[l++]=d)}return c}return sm=e,sm}var am,mN;function rA(){if(mN)return am;mN=1;function e(){return[]}return am=e,am}var om,gN;function Rx(){if(gN)return om;gN=1;var e=nA(),t=rA(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(d){return s.call(c,d)}))}:t;return om=l,om}var im,yN;function eB(){if(yN)return im;yN=1;var e=nc(),t=Rx();function n(s,a){return e(s,t(s),a)}return im=n,im}var lm,wN;function Mx(){if(wN)return lm;wN=1;function e(t,n){for(var s=-1,a=n.length,l=t.length;++s<a;)t[l+s]=n[s];return t}return lm=e,lm}var cm,vN;function Ld(){if(vN)return cm;vN=1;var e=J2(),t=e(Object.getPrototypeOf,Object);return cm=t,cm}var um,xN;function sA(){if(xN)return um;xN=1;var e=Mx(),t=Ld(),n=Rx(),s=rA(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var d=[];c;)e(d,n(c)),c=t(c);return d}:s;return um=l,um}var dm,bN;function tB(){if(bN)return dm;bN=1;var e=nc(),t=sA();function n(s,a){return e(s,t(s),a)}return dm=n,dm}var hm,kN;function aA(){if(kN)return hm;kN=1;var e=Mx(),t=Mt();function n(s,a,l){var c=a(s);return t(s)?c:e(c,l(s))}return hm=n,hm}var fm,_N;function oA(){if(_N)return fm;_N=1;var e=aA(),t=Rx(),n=Qs();function s(a){return e(a,n,t)}return fm=s,fm}var pm,NN;function nB(){if(NN)return pm;NN=1;var e=aA(),t=sA(),n=Ja();function s(a){return e(a,n,t)}return pm=s,pm}var mm,SN;function rB(){if(SN)return mm;SN=1;var e=Za(),t=yr(),n=e(t,"DataView");return mm=n,mm}var gm,jN;function sB(){if(jN)return gm;jN=1;var e=Za(),t=yr(),n=e(t,"Promise");return gm=n,gm}var ym,EN;function iA(){if(EN)return ym;EN=1;var e=Za(),t=yr(),n=e(t,"Set");return ym=n,ym}var wm,CN;function aB(){if(CN)return wm;CN=1;var e=Za(),t=yr(),n=e(t,"WeakMap");return wm=n,wm}var vm,TN;function yi(){if(TN)return vm;TN=1;var e=rB(),t=Sx(),n=sB(),s=iA(),a=aB(),l=Qa(),c=X2(),d="[object Map]",h="[object Object]",p="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",v=c(e),j=c(t),_=c(n),S=c(s),x=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=d||n&&N(n.resolve())!=p||s&&N(new s)!=f||a&&N(new a)!=m)&&(N=function(E){var C=l(E),R=C==h?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case j:return d;case _:return p;case S:return f;case x:return m}return C}),vm=N,vm}var xm,AN;function oB(){if(AN)return xm;AN=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,l=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return xm=n,xm}var bm,RN;function lA(){if(RN)return bm;RN=1;var e=yr(),t=e.Uint8Array;return bm=t,bm}var km,MN;function Ix(){if(MN)return km;MN=1;var e=lA();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return km=t,km}var _m,IN;function iB(){if(IN)return _m;IN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return _m=t,_m}var Nm,$N;function lB(){if($N)return Nm;$N=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return Nm=t,Nm}var Sm,ON;function cB(){if(ON)return Sm;ON=1;var e=mi(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return Sm=s,Sm}var jm,PN;function cA(){if(PN)return jm;PN=1;var e=Ix();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return jm=t,jm}var Em,LN;function uB(){if(LN)return Em;LN=1;var e=Ix(),t=iB(),n=lB(),s=cB(),a=cA(),l="[object Boolean]",c="[object Date]",d="[object Map]",h="[object Number]",p="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",x="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]";function F(O,M,L){var H=O.constructor;switch(M){case v:return e(O);case l:case c:return new H(+O);case j:return t(O,L);case _:case S:case x:case N:case E:case C:case R:case I:case $:return a(O,L);case d:return new H;case h:case m:return new H(O);case p:return n(O);case f:return new H;case y:return s(O)}}return Em=F,Em}var Cm,DN;function uA(){if(DN)return Cm;DN=1;var e=Yn(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var l=new s;return s.prototype=void 0,l}})();return Cm=n,Cm}var Tm,qN;function dA(){if(qN)return Tm;qN=1;var e=uA(),t=Ld(),n=Pd();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Tm=s,Tm}var Am,FN;function dB(){if(FN)return Am;FN=1;var e=yi(),t=$r(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Am=s,Am}var Rm,BN;function hB(){if(BN)return Rm;BN=1;var e=dB(),t=Od(),n=Tx(),s=n&&n.isMap,a=s?t(s):e;return Rm=a,Rm}var Mm,zN;function fB(){if(zN)return Mm;zN=1;var e=yi(),t=$r(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Mm=s,Mm}var Im,UN;function pB(){if(UN)return Im;UN=1;var e=fB(),t=Od(),n=Tx(),s=n&&n.isSet,a=s?t(s):e;return Im=a,Im}var $m,WN;function hA(){if(WN)return $m;WN=1;var e=Rd(),t=Ex(),n=Id(),s=X8(),a=J8(),l=eA(),c=tA(),d=eB(),h=tB(),p=oA(),f=nB(),m=yi(),y=oB(),v=uB(),j=dA(),_=Mt(),S=gi(),x=hB(),N=Yn(),E=pB(),C=Qs(),R=Ja(),I=1,$=2,F=4,O="[object Arguments]",M="[object Array]",L="[object Boolean]",H="[object Date]",B="[object Error]",A="[object Function]",Q="[object GeneratorFunction]",K="[object Map]",ee="[object Number]",Z="[object Object]",D="[object RegExp]",Y="[object Set]",P="[object String]",G="[object Symbol]",de="[object WeakMap]",W="[object ArrayBuffer]",U="[object DataView]",J="[object Float32Array]",V="[object Float64Array]",ie="[object Int8Array]",pe="[object Int16Array]",me="[object Int32Array]",Ie="[object Uint8Array]",Le="[object Uint8ClampedArray]",ce="[object Uint16Array]",xe="[object Uint32Array]",ye={};ye[O]=ye[M]=ye[W]=ye[U]=ye[L]=ye[H]=ye[J]=ye[V]=ye[ie]=ye[pe]=ye[me]=ye[K]=ye[ee]=ye[Z]=ye[D]=ye[Y]=ye[P]=ye[G]=ye[Ie]=ye[Le]=ye[ce]=ye[xe]=!0,ye[B]=ye[A]=ye[de]=!1;function ze(ke,je,Ye,it,Ne,He){var Xe,he=je&I,ge=je&$,Se=je&F;if(Ye&&(Xe=Ne?Ye(ke,it,Ne,He):Ye(ke)),Xe!==void 0)return Xe;if(!N(ke))return ke;var Fe=_(ke);if(Fe){if(Xe=y(ke),!he)return c(ke,Xe)}else{var et=m(ke),xt=et==A||et==Q;if(S(ke))return l(ke,he);if(et==Z||et==O||xt&&!Ne){if(Xe=ge||xt?{}:j(ke),!he)return ge?h(ke,a(Xe,ke)):d(ke,s(Xe,ke))}else{if(!ye[et])return Ne?ke:{};Xe=v(ke,et,he)}}He||(He=new e);var ht=He.get(ke);if(ht)return ht;He.set(ke,Xe),E(ke)?ke.forEach(function(Oe){Xe.add(ze(Oe,je,Ye,Oe,ke,He))}):x(ke)&&ke.forEach(function(Oe,Te){Xe.set(Te,ze(Oe,je,Ye,Te,ke,He))});var ne=Se?ge?f:p:ge?R:C,De=Fe?void 0:ne(ke);return t(De||ke,function(Oe,Te){De&&(Te=Oe,Oe=ke[Te]),n(Xe,Te,ze(Oe,je,Ye,Te,ke,He))}),Xe}return $m=ze,$m}var Om,HN;function mB(){if(HN)return Om;HN=1;var e=hA(),t=4;function n(s){return e(s,t)}return Om=n,Om}var Pm,GN;function $x(){if(GN)return Pm;GN=1;function e(t){return function(){return t}}return Pm=e,Pm}var Lm,VN;function gB(){if(VN)return Lm;VN=1;function e(t){return function(n,s,a){for(var l=-1,c=Object(n),d=a(n),h=d.length;h--;){var p=d[t?h:++l];if(s(c[p],p,c)===!1)break}return n}}return Lm=e,Lm}var Dm,YN;function Ox(){if(YN)return Dm;YN=1;var e=gB(),t=e();return Dm=t,Dm}var qm,KN;function Px(){if(KN)return qm;KN=1;var e=Ox(),t=Qs();function n(s,a){return s&&e(s,a,t)}return qm=n,qm}var Fm,XN;function yB(){if(XN)return Fm;XN=1;var e=cs();function t(n,s){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,d=s?c:-1,h=Object(a);(s?d--:++d<c)&&l(h[d],d,h)!==!1;);return a}}return Fm=t,Fm}var Bm,QN;function Dd(){if(QN)return Bm;QN=1;var e=Px(),t=yB(),n=t(e);return Bm=n,Bm}var zm,ZN;function eo(){if(ZN)return zm;ZN=1;function e(t){return t}return zm=e,zm}var Um,JN;function fA(){if(JN)return Um;JN=1;var e=eo();function t(n){return typeof n=="function"?n:e}return Um=t,Um}var Wm,eS;function pA(){if(eS)return Wm;eS=1;var e=Ex(),t=Dd(),n=fA(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c))}return Wm=a,Wm}var Hm,tS;function mA(){return tS||(tS=1,Hm=pA()),Hm}var Gm,nS;function wB(){if(nS)return Gm;nS=1;var e=Dd();function t(n,s){var a=[];return e(n,function(l,c,d){s(l,c,d)&&a.push(l)}),a}return Gm=t,Gm}var Vm,rS;function vB(){if(rS)return Vm;rS=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Vm=t,Vm}var Ym,sS;function xB(){if(sS)return Ym;sS=1;function e(t){return this.__data__.has(t)}return Ym=e,Ym}var Km,aS;function gA(){if(aS)return Km;aS=1;var e=jx(),t=vB(),n=xB();function s(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,Km=s,Km}var Xm,oS;function bB(){if(oS)return Xm;oS=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 Xm=e,Xm}var Qm,iS;function yA(){if(iS)return Qm;iS=1;function e(t,n){return t.has(n)}return Qm=e,Qm}var Zm,lS;function wA(){if(lS)return Zm;lS=1;var e=gA(),t=bB(),n=yA(),s=1,a=2;function l(c,d,h,p,f,m){var y=h&s,v=c.length,j=d.length;if(v!=j&&!(y&&j>v))return!1;var _=m.get(c),S=m.get(d);if(_&&S)return _==d&&S==c;var x=-1,N=!0,E=h&a?new e:void 0;for(m.set(c,d),m.set(d,c);++x<v;){var C=c[x],R=d[x];if(p)var I=y?p(R,C,x,d,c,m):p(C,R,x,c,d,m);if(I!==void 0){if(I)continue;N=!1;break}if(E){if(!t(d,function($,F){if(!n(E,F)&&(C===$||f(C,$,h,p,m)))return E.push(F)})){N=!1;break}}else if(!(C===R||f(C,R,h,p,m))){N=!1;break}}return m.delete(c),m.delete(d),N}return Zm=l,Zm}var Jm,cS;function kB(){if(cS)return Jm;cS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,l){s[++n]=[l,a]}),s}return Jm=e,Jm}var eg,uS;function Lx(){if(uS)return eg;uS=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return eg=e,eg}var tg,dS;function _B(){if(dS)return tg;dS=1;var e=mi(),t=lA(),n=pi(),s=wA(),a=kB(),l=Lx(),c=1,d=2,h="[object Boolean]",p="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,$,F,O,M,L,H){switch(F){case N:if(I.byteLength!=$.byteLength||I.byteOffset!=$.byteOffset)return!1;I=I.buffer,$=$.buffer;case x:return!(I.byteLength!=$.byteLength||!L(new t(I),new t($)));case h:case p:case y:return n(+I,+$);case f:return I.name==$.name&&I.message==$.message;case v:case _:return I==$+"";case m:var B=a;case j:var A=O&c;if(B||(B=l),I.size!=$.size&&!A)return!1;var Q=H.get(I);if(Q)return Q==$;O|=d,H.set(I,$);var K=s(B(I),B($),O,M,L,H);return H.delete(I),K;case S:if(C)return C.call(I)==C.call($)}return!1}return tg=R,tg}var ng,hS;function NB(){if(hS)return ng;hS=1;var e=oA(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(l,c,d,h,p,f){var m=d&t,y=e(l),v=y.length,j=e(c),_=j.length;if(v!=_&&!m)return!1;for(var S=v;S--;){var x=y[S];if(!(m?x in c:s.call(c,x)))return!1}var N=f.get(l),E=f.get(c);if(N&&E)return N==c&&E==l;var C=!0;f.set(l,c),f.set(c,l);for(var R=m;++S<v;){x=y[S];var I=l[x],$=c[x];if(h)var F=m?h($,I,x,c,l,f):h(I,$,x,l,c,f);if(!(F===void 0?I===$||p(I,$,d,h,f):F)){C=!1;break}R||(R=x=="constructor")}if(C&&!R){var O=l.constructor,M=c.constructor;O!=M&&"constructor"in l&&"constructor"in c&&!(typeof O=="function"&&O instanceof O&&typeof M=="function"&&M instanceof M)&&(C=!1)}return f.delete(l),f.delete(c),C}return ng=a,ng}var rg,fS;function SB(){if(fS)return rg;fS=1;var e=Rd(),t=wA(),n=_B(),s=NB(),a=yi(),l=Mt(),c=gi(),d=sc(),h=1,p="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function j(_,S,x,N,E,C){var R=l(_),I=l(S),$=R?f:a(_),F=I?f:a(S);$=$==p?m:$,F=F==p?m:F;var O=$==m,M=F==m,L=$==F;if(L&&c(_)){if(!c(S))return!1;R=!0,O=!1}if(L&&!O)return C||(C=new e),R||d(_)?t(_,S,x,N,E,C):n(_,S,$,x,N,E,C);if(!(x&h)){var H=O&&v.call(_,"__wrapped__"),B=M&&v.call(S,"__wrapped__");if(H||B){var A=H?_.value():_,Q=B?S.value():S;return C||(C=new e),E(A,Q,x,N,C)}}return L?(C||(C=new e),s(_,S,x,N,E,C)):!1}return rg=j,rg}var sg,pS;function vA(){if(pS)return sg;pS=1;var e=SB(),t=$r();function n(s,a,l,c,d){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,l,c,n,d)}return sg=n,sg}var ag,mS;function jB(){if(mS)return ag;mS=1;var e=Rd(),t=vA(),n=1,s=2;function a(l,c,d,h){var p=d.length,f=p,m=!h;if(l==null)return!f;for(l=Object(l);p--;){var y=d[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<f;){y=d[p];var v=y[0],j=l[v],_=y[1];if(m&&y[2]){if(j===void 0&&!(v in l))return!1}else{var S=new e;if(h)var x=h(j,_,v,l,c,S);if(!(x===void 0?t(_,j,n|s,h,S):x))return!1}}return!0}return ag=a,ag}var og,gS;function xA(){if(gS)return og;gS=1;var e=Yn();function t(n){return n===n&&!e(n)}return og=t,og}var ig,yS;function EB(){if(yS)return ig;yS=1;var e=xA(),t=Qs();function n(s){for(var a=t(s),l=a.length;l--;){var c=a[l],d=s[c];a[l]=[c,d,e(d)]}return a}return ig=n,ig}var lg,wS;function bA(){if(wS)return lg;wS=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return lg=e,lg}var cg,vS;function CB(){if(vS)return cg;vS=1;var e=jB(),t=EB(),n=bA();function s(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return cg=s,cg}var ug,xS;function wi(){if(xS)return ug;xS=1;var e=Qa(),t=$r(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return ug=s,ug}var dg,bS;function Dx(){if(bS)return dg;bS=1;var e=Mt(),t=wi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(l,c){if(e(l))return!1;var d=typeof l;return d=="number"||d=="symbol"||d=="boolean"||l==null||t(l)?!0:s.test(l)||!n.test(l)||c!=null&&l in Object(c)}return dg=a,dg}var hg,kS;function TB(){if(kS)return hg;kS=1;var e=jx(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,d=a?a.apply(this,c):c[0],h=l.cache;if(h.has(d))return h.get(d);var p=s.apply(this,c);return l.cache=h.set(d,p)||h,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,hg=n,hg}var fg,_S;function AB(){if(_S)return fg;_S=1;var e=TB(),t=500;function n(s){var a=e(s,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return fg=n,fg}var pg,NS;function RB(){if(NS)return pg;NS=1;var e=AB(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,d,h,p){l.push(h?p.replace(n,"$1"):d||c)}),l});return pg=s,pg}var mg,SS;function qd(){if(SS)return mg;SS=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,l=Array(a);++s<a;)l[s]=n(t[s],s,t);return l}return mg=e,mg}var gg,jS;function MB(){if(jS)return gg;jS=1;var e=mi(),t=qd(),n=Mt(),s=wi(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(d){if(typeof d=="string")return d;if(n(d))return t(d,c)+"";if(s(d))return l?l.call(d):"";var h=d+"";return h=="0"&&1/d==-1/0?"-0":h}return gg=c,gg}var yg,ES;function kA(){if(ES)return yg;ES=1;var e=MB();function t(n){return n==null?"":e(n)}return yg=t,yg}var wg,CS;function Fd(){if(CS)return wg;CS=1;var e=Mt(),t=Dx(),n=RB(),s=kA();function a(l,c){return e(l)?l:t(l,c)?[l]:n(s(l))}return wg=a,wg}var vg,TS;function ac(){if(TS)return vg;TS=1;var e=wi();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return vg=t,vg}var xg,AS;function Bd(){if(AS)return xg;AS=1;var e=Fd(),t=ac();function n(s,a){a=e(a,s);for(var l=0,c=a.length;s!=null&&l<c;)s=s[t(a[l++])];return l&&l==c?s:void 0}return xg=n,xg}var bg,RS;function IB(){if(RS)return bg;RS=1;var e=Bd();function t(n,s,a){var l=n==null?void 0:e(n,s);return l===void 0?a:l}return bg=t,bg}var kg,MS;function $B(){if(MS)return kg;MS=1;function e(t,n){return t!=null&&n in Object(t)}return kg=e,kg}var _g,IS;function _A(){if(IS)return _g;IS=1;var e=Fd(),t=rc(),n=Mt(),s=$d(),a=Cx(),l=ac();function c(d,h,p){h=e(h,d);for(var f=-1,m=h.length,y=!1;++f<m;){var v=l(h[f]);if(!(y=d!=null&&p(d,v)))break;d=d[v]}return y||++f!=m?y:(m=d==null?0:d.length,!!m&&a(m)&&s(v,m)&&(n(d)||t(d)))}return _g=c,_g}var Ng,$S;function NA(){if($S)return Ng;$S=1;var e=$B(),t=_A();function n(s,a){return s!=null&&t(s,a,e)}return Ng=n,Ng}var Sg,OS;function OB(){if(OS)return Sg;OS=1;var e=vA(),t=IB(),n=NA(),s=Dx(),a=xA(),l=bA(),c=ac(),d=1,h=2;function p(f,m){return s(f)&&a(m)?l(c(f),m):function(y){var v=t(y,f);return v===void 0&&v===m?n(y,f):e(m,v,d|h)}}return Sg=p,Sg}var jg,PS;function SA(){if(PS)return jg;PS=1;function e(t){return function(n){return n==null?void 0:n[t]}}return jg=e,jg}var Eg,LS;function PB(){if(LS)return Eg;LS=1;var e=Bd();function t(n){return function(s){return e(s,n)}}return Eg=t,Eg}var Cg,DS;function LB(){if(DS)return Cg;DS=1;var e=SA(),t=PB(),n=Dx(),s=ac();function a(l){return n(l)?e(s(l)):t(l)}return Cg=a,Cg}var Tg,qS;function us(){if(qS)return Tg;qS=1;var e=CB(),t=OB(),n=eo(),s=Mt(),a=LB();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?s(c)?t(c[0],c[1]):e(c):a(c)}return Tg=l,Tg}var Ag,FS;function jA(){if(FS)return Ag;FS=1;var e=nA(),t=wB(),n=us(),s=Mt();function a(l,c){var d=s(l)?e:t;return d(l,n(c,3))}return Ag=a,Ag}var Rg,BS;function DB(){if(BS)return Rg;BS=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Rg=n,Rg}var Mg,zS;function EA(){if(zS)return Mg;zS=1;var e=DB(),t=_A();function n(s,a){return s!=null&&t(s,a,e)}return Mg=n,Mg}var Ig,US;function qB(){if(US)return Ig;US=1;var e=Ax(),t=yi(),n=rc(),s=Mt(),a=cs(),l=gi(),c=Pd(),d=sc(),h="[object Map]",p="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(v){if(v==null)return!0;if(a(v)&&(s(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||d(v)||n(v)))return!v.length;var j=t(v);if(j==h||j==p)return!v.size;if(c(v))return!e(v).length;for(var _ in v)if(m.call(v,_))return!1;return!0}return Ig=y,Ig}var $g,WS;function CA(){if(WS)return $g;WS=1;function e(t){return t===void 0}return $g=e,$g}var Og,HS;function TA(){if(HS)return Og;HS=1;var e=Dd(),t=cs();function n(s,a){var l=-1,c=t(s)?Array(s.length):[];return e(s,function(d,h,p){c[++l]=a(d,h,p)}),c}return Og=n,Og}var Pg,GS;function AA(){if(GS)return Pg;GS=1;var e=qd(),t=us(),n=TA(),s=Mt();function a(l,c){var d=s(l)?e:n;return d(l,t(c,3))}return Pg=a,Pg}var Lg,VS;function FB(){if(VS)return Lg;VS=1;function e(t,n,s,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(s=t[++l]);++l<c;)s=n(s,t[l],l,t);return s}return Lg=e,Lg}var Dg,YS;function BB(){if(YS)return Dg;YS=1;function e(t,n,s,a,l){return l(t,function(c,d,h){s=a?(a=!1,c):n(s,c,d,h)}),s}return Dg=e,Dg}var qg,KS;function RA(){if(KS)return qg;KS=1;var e=FB(),t=Dd(),n=us(),s=BB(),a=Mt();function l(c,d,h){var p=a(c)?e:s,f=arguments.length<3;return p(c,n(d,4),h,f,t)}return qg=l,qg}var Fg,XS;function zB(){if(XS)return Fg;XS=1;var e=Qa(),t=Mt(),n=$r(),s="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==s}return Fg=a,Fg}var Bg,QS;function UB(){if(QS)return Bg;QS=1;var e=SA(),t=e("length");return Bg=t,Bg}var zg,ZS;function WB(){if(ZS)return zg;ZS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="\\u200d",d=RegExp("["+c+e+a+l+"]");function h(p){return d.test(p)}return zg=h,zg}var Ug,JS;function HB(){if(JS)return Ug;JS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,l="\\ufe0e\\ufe0f",c="["+e+"]",d="["+a+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+d+"|"+h+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",j=p+"?",_="["+l+"]?",S="(?:"+v+"(?:"+[f,m,y].join("|")+")"+_+j+")*",x=_+j+S,N="(?:"+[f+d+"?",d,m,y,c].join("|")+")",E=RegExp(h+"(?="+h+")|"+N+x,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Ug=C,Ug}var Wg,ej;function GB(){if(ej)return Wg;ej=1;var e=UB(),t=WB(),n=HB();function s(a){return t(a)?n(a):e(a)}return Wg=s,Wg}var Hg,tj;function VB(){if(tj)return Hg;tj=1;var e=Ax(),t=yi(),n=cs(),s=zB(),a=GB(),l="[object Map]",c="[object Set]";function d(h){if(h==null)return 0;if(n(h))return s(h)?a(h):h.length;var p=t(h);return p==l||p==c?h.size:e(h).length}return Hg=d,Hg}var Gg,nj;function YB(){if(nj)return Gg;nj=1;var e=Ex(),t=uA(),n=Px(),s=us(),a=Ld(),l=Mt(),c=gi(),d=tc(),h=Yn(),p=sc();function f(m,y,v){var j=l(m),_=j||c(m)||p(m);if(y=s(y,4),v==null){var S=m&&m.constructor;_?v=j?new S:[]:h(m)?v=d(S)?t(a(m)):{}:v={}}return(_?e:n)(m,function(x,N,E){return y(v,x,N,E)}),v}return Gg=f,Gg}var Vg,rj;function KB(){if(rj)return Vg;rj=1;var e=mi(),t=rc(),n=Mt(),s=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(s&&l&&l[s])}return Vg=a,Vg}var Yg,sj;function qx(){if(sj)return Yg;sj=1;var e=Mx(),t=KB();function n(s,a,l,c,d){var h=-1,p=s.length;for(l||(l=t),d||(d=[]);++h<p;){var f=s[h];a>0&&l(f)?a>1?n(f,a-1,l,c,d):e(d,f):c||(d[d.length]=f)}return d}return Yg=n,Yg}var Kg,aj;function XB(){if(aj)return Kg;aj=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 Kg=e,Kg}var Xg,oj;function MA(){if(oj)return Xg;oj=1;var e=XB(),t=Math.max;function n(s,a,l){return a=t(a===void 0?s.length-1:a,0),function(){for(var c=arguments,d=-1,h=t(c.length-a,0),p=Array(h);++d<h;)p[d]=c[a+d];d=-1;for(var f=Array(a+1);++d<a;)f[d]=c[d];return f[a]=l(p),e(s,this,f)}}return Xg=n,Xg}var Qg,ij;function QB(){if(ij)return Qg;ij=1;var e=$x(),t=Q2(),n=eo(),s=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Qg=s,Qg}var Zg,lj;function ZB(){if(lj)return Zg;lj=1;var e=800,t=16,n=Date.now;function s(a){var l=0,c=0;return function(){var d=n(),h=t-(d-c);if(c=d,h>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return Zg=s,Zg}var Jg,cj;function IA(){if(cj)return Jg;cj=1;var e=QB(),t=ZB(),n=t(e);return Jg=n,Jg}var ey,uj;function zd(){if(uj)return ey;uj=1;var e=eo(),t=MA(),n=IA();function s(a,l){return n(t(a,l,e),a+"")}return ey=s,ey}var ty,dj;function $A(){if(dj)return ty;dj=1;function e(t,n,s,a){for(var l=t.length,c=s+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return ty=e,ty}var ny,hj;function JB(){if(hj)return ny;hj=1;function e(t){return t!==t}return ny=e,ny}var ry,fj;function ez(){if(fj)return ry;fj=1;function e(t,n,s){for(var a=s-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return ry=e,ry}var sy,pj;function tz(){if(pj)return sy;pj=1;var e=$A(),t=JB(),n=ez();function s(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return sy=s,sy}var ay,mj;function nz(){if(mj)return ay;mj=1;var e=tz();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return ay=t,ay}var oy,gj;function rz(){if(gj)return oy;gj=1;function e(t,n,s){for(var a=-1,l=t==null?0:t.length;++a<l;)if(s(n,t[a]))return!0;return!1}return oy=e,oy}var iy,yj;function sz(){if(yj)return iy;yj=1;function e(){}return iy=e,iy}var ly,wj;function az(){if(wj)return ly;wj=1;var e=iA(),t=sz(),n=Lx(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(l){return new e(l)}:t;return ly=a,ly}var cy,vj;function oz(){if(vj)return cy;vj=1;var e=gA(),t=nz(),n=rz(),s=yA(),a=az(),l=Lx(),c=200;function d(h,p,f){var m=-1,y=t,v=h.length,j=!0,_=[],S=_;if(f)j=!1,y=n;else if(v>=c){var x=p?null:a(h);if(x)return l(x);j=!1,y=s,S=new e}else S=p?[]:_;e:for(;++m<v;){var N=h[m],E=p?p(N):N;if(N=f||N!==0?N:0,j&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;p&&S.push(E),_.push(N)}else y(S,E,f)||(S!==_&&S.push(E),_.push(N))}return _}return cy=d,cy}var uy,xj;function OA(){if(xj)return uy;xj=1;var e=cs(),t=$r();function n(s){return t(s)&&e(s)}return uy=n,uy}var dy,bj;function iz(){if(bj)return dy;bj=1;var e=qx(),t=zd(),n=oz(),s=OA(),a=t(function(l){return n(e(l,1,s,!0))});return dy=a,dy}var hy,kj;function lz(){if(kj)return hy;kj=1;var e=qd();function t(n,s){return e(s,function(a){return n[a]})}return hy=t,hy}var fy,_j;function PA(){if(_j)return fy;_j=1;var e=lz(),t=Qs();function n(s){return s==null?[]:e(s,t(s))}return fy=n,fy}var py,Nj;function Kn(){if(Nj)return py;Nj=1;var e;if(typeof Nx=="function")try{e={clone:mB(),constant:$x(),each:mA(),filter:jA(),has:EA(),isArray:Mt(),isEmpty:qB(),isFunction:tc(),isUndefined:CA(),keys:Qs(),map:AA(),reduce:RA(),size:VB(),transform:YB(),union:iz(),values:PA()}}catch{}return e||(e=window._),py=e,py}var my,Sj;function Fx(){if(Sj)return my;Sj=1;var e=Kn();my=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(m){return e.isEmpty(f._in[m])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},a.prototype.setNodes=function(f,m){var y=arguments,v=this;return e.each(f,function(j){y.length>1?v.setNode(j,m):v.setNode(j)}),this},a.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m: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 m=this;if(e.has(this._nodes,f)){var y=function(v){m.removeEdge(m._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){m.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==n)return m}},a.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},a.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},a.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},a.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},a.prototype.filterNodes=function(f){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var v={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(v[_]=S,S):S in v?v[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},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,m){var y=this,v=arguments;return e.reduce(f,function(j,_){return v.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},a.prototype.setEdge=function(){var f,m,y,v,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(v=arguments[1],j=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],j=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var S=d(this._isDirected,f,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=v),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[S]=j?v:this._defaultEdgeLabelFn(f,m,y);var x=h(this._isDirected,f,m,y);return f=x.v,m=x.w,Object.freeze(x),this._edgeObjs[S]=x,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][S]=x,this._out[f][S]=x,this._edgeCount++,this},a.prototype.edge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return this._edgeLabels[v]},a.prototype.hasEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y);return e.has(this._edgeLabels,v)},a.prototype.removeEdge=function(f,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):d(this._isDirected,f,m,y),j=this._edgeObjs[v];return j&&(f=j.v,m=j.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[m],f),c(this._sucs[f],m),delete this._in[m][v],delete this._out[f][v],this._edgeCount--),this},a.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var v=e.values(y);return m?e.filter(v,function(j){return j.v===m}):v}},a.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var v=e.values(y);return m?e.filter(v,function(j){return j.w===m}):v}},a.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function c(f,m){--f[m]||delete f[m]}function d(f,m,y,v){var j=""+m,_=""+y;if(!f&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(v)?t:v)}function h(f,m,y,v){var j=""+m,_=""+y;if(!f&&j>_){var S=j;j=_,_=S}var x={v:j,w:_};return v&&(x.name=v),x}function p(f,m){return d(f,m.v,m.w,m.name)}return my}var gy,jj;function cz(){return jj||(jj=1,gy="2.1.8"),gy}var yy,Ej;function uz(){return Ej||(Ej=1,yy={Graph:Fx(),version:cz()}),yy}var wy,Cj;function dz(){if(Cj)return wy;Cj=1;var e=Kn(),t=Fx();wy={write:n,read:l};function n(c){var d={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:s(c),edges:a(c)};return e.isUndefined(c.graph())||(d.value=e.clone(c.graph())),d}function s(c){return e.map(c.nodes(),function(d){var h=c.node(d),p=c.parent(d),f={v:d};return e.isUndefined(h)||(f.value=h),e.isUndefined(p)||(f.parent=p),f})}function a(c){return e.map(c.edges(),function(d){var h=c.edge(d),p={v:d.v,w:d.w};return e.isUndefined(d.name)||(p.name=d.name),e.isUndefined(h)||(p.value=h),p})}function l(c){var d=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(h){d.setNode(h.v,h.value),h.parent&&d.setParent(h.v,h.parent)}),e.each(c.edges,function(h){d.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),d}return wy}var vy,Tj;function hz(){if(Tj)return vy;Tj=1;var e=Kn();vy=t;function t(n){var s={},a=[],l;function c(d){e.has(s,d)||(s[d]=!0,l.push(d),e.each(n.successors(d),c),e.each(n.predecessors(d),c))}return e.each(n.nodes(),function(d){l=[],c(d),l.length&&a.push(l)}),a}return vy}var xy,Aj;function LA(){if(Aj)return xy;Aj=1;var e=Kn();xy=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 l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:s}),this._decrease(c),!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,l=a+1,c=n;a<s.length&&(c=s[a].priority<s[c].priority?a:c,l<s.length&&(c=s[l].priority<s[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var s=this._arr,a=s[n].priority,l;n!==0&&(l=n>>1,!(s[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,s){var a=this._arr,l=this._keyIndices,c=a[n],d=a[s];a[n]=d,a[s]=c,l[d.key]=n,l[c.key]=s},xy}var by,Rj;function DA(){if(Rj)return by;Rj=1;var e=Kn(),t=LA();by=s;var n=e.constant(1);function s(l,c,d,h){return a(l,String(c),d||n,h||function(p){return l.outEdges(p)})}function a(l,c,d,h){var p={},f=new t,m,y,v=function(j){var _=j.v!==m?j.v:j.w,S=p[_],x=d(j),N=y.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+x);N<S.distance&&(S.distance=N,S.predecessor=m,f.decrease(_,N))};for(l.nodes().forEach(function(j){var _=j===c?0:Number.POSITIVE_INFINITY;p[j]={distance:_},f.add(j,_)});f.size()>0&&(m=f.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(v);return p}return by}var ky,Mj;function fz(){if(Mj)return ky;Mj=1;var e=DA(),t=Kn();ky=n;function n(s,a,l){return t.transform(s.nodes(),function(c,d){c[d]=e(s,d,a,l)},{})}return ky}var _y,Ij;function qA(){if(Ij)return _y;Ij=1;var e=Kn();_y=t;function t(n){var s=0,a=[],l={},c=[];function d(h){var p=l[h]={onStack:!0,lowlink:s,index:s++};if(a.push(h),n.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(d(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var f=[],m;do m=a.pop(),l[m].onStack=!1,f.push(m);while(h!==m);c.push(f)}}return n.nodes().forEach(function(h){e.has(l,h)||d(h)}),c}return _y}var Ny,$j;function pz(){if($j)return Ny;$j=1;var e=Kn(),t=qA();Ny=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 Ny}var Sy,Oj;function mz(){if(Oj)return Sy;Oj=1;var e=Kn();Sy=n;var t=e.constant(1);function n(a,l,c){return s(a,l||t,c||function(d){return a.outEdges(d)})}function s(a,l,c){var d={},h=a.nodes();return h.forEach(function(p){d[p]={},d[p][p]={distance:0},h.forEach(function(f){p!==f&&(d[p][f]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(f){var m=f.v===p?f.w:f.v,y=l(f);d[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var f=d[p];h.forEach(function(m){var y=d[m];h.forEach(function(v){var j=y[p],_=f[v],S=y[v],x=j.distance+_.distance;x<S.distance&&(S.distance=x,S.predecessor=_.predecessor)})})}),d}return Sy}var jy,Pj;function FA(){if(Pj)return jy;Pj=1;var e=Kn();jy=t,t.CycleException=n;function t(s){var a={},l={},c=[];function d(h){if(e.has(l,h))throw new n;e.has(a,h)||(l[h]=!0,a[h]=!0,e.each(s.predecessors(h),d),delete l[h],c.push(h))}if(e.each(s.sinks(),d),e.size(a)!==s.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,jy}var Ey,Lj;function gz(){if(Lj)return Ey;Lj=1;var e=FA();Ey=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Ey}var Cy,Dj;function BA(){if(Dj)return Cy;Dj=1;var e=Kn();Cy=t;function t(s,a,l){e.isArray(a)||(a=[a]);var c=(s.isDirected()?s.successors:s.neighbors).bind(s),d=[],h={};return e.each(a,function(p){if(!s.hasNode(p))throw new Error("Graph does not have node: "+p);n(s,p,l==="post",h,c,d)}),d}function n(s,a,l,c,d,h){e.has(c,a)||(c[a]=!0,l||h.push(a),e.each(d(a),function(p){n(s,p,l,c,d,h)}),l&&h.push(a))}return Cy}var Ty,qj;function yz(){if(qj)return Ty;qj=1;var e=BA();Ty=t;function t(n,s){return e(n,s,"post")}return Ty}var Ay,Fj;function wz(){if(Fj)return Ay;Fj=1;var e=BA();Ay=t;function t(n,s){return e(n,s,"pre")}return Ay}var Ry,Bj;function vz(){if(Bj)return Ry;Bj=1;var e=Kn(),t=Fx(),n=LA();Ry=s;function s(a,l){var c=new t,d={},h=new n,p;function f(y){var v=y.v===p?y.w:y.v,j=h.priority(v);if(j!==void 0){var _=l(y);_<j&&(d[v]=p,h.decrease(v,_))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),h.decrease(a.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(d,p))c.setEdge(p,d[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(f)}return c}return Ry}var My,zj;function xz(){return zj||(zj=1,My={components:hz(),dijkstra:DA(),dijkstraAll:fz(),findCycles:pz(),floydWarshall:mz(),isAcyclic:gz(),postorder:yz(),preorder:wz(),prim:vz(),tarjan:qA(),topsort:FA()}),My}var Iy,Uj;function bz(){if(Uj)return Iy;Uj=1;var e=uz();return Iy={Graph:e.Graph,json:dz(),alg:xz(),version:e.version},Iy}var $y,Wj;function mr(){if(Wj)return $y;Wj=1;var e;if(typeof Nx=="function")try{e=bz()}catch{}return e||(e=window.graphlib),$y=e,$y}var Oy,Hj;function kz(){if(Hj)return Oy;Hj=1;var e=hA(),t=1,n=4;function s(a){return e(a,t|n)}return Oy=s,Oy}var Py,Gj;function Ud(){if(Gj)return Py;Gj=1;var e=pi(),t=cs(),n=$d(),s=Yn();function a(l,c,d){if(!s(d))return!1;var h=typeof c;return(h=="number"?t(d)&&n(c,d.length):h=="string"&&c in d)?e(d[c],l):!1}return Py=a,Py}var Ly,Vj;function _z(){if(Vj)return Ly;Vj=1;var e=zd(),t=pi(),n=Ud(),s=Ja(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(d,h){d=Object(d);var p=-1,f=h.length,m=f>2?h[2]:void 0;for(m&&n(h[0],h[1],m)&&(f=1);++p<f;)for(var y=h[p],v=s(y),j=-1,_=v.length;++j<_;){var S=v[j],x=d[S];(x===void 0||t(x,a[S])&&!l.call(d,S))&&(d[S]=y[S])}return d});return Ly=c,Ly}var Dy,Yj;function Nz(){if(Yj)return Dy;Yj=1;var e=us(),t=cs(),n=Qs();function s(a){return function(l,c,d){var h=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(h[m],m,h)}}var f=a(l,c,d);return f>-1?h[p?l[f]:f]:void 0}}return Dy=s,Dy}var qy,Kj;function Sz(){if(Kj)return qy;Kj=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return qy=t,qy}var Fy,Xj;function jz(){if(Xj)return Fy;Xj=1;var e=Sz(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Fy=n,Fy}var By,Qj;function Ez(){if(Qj)return By;Qj=1;var e=jz(),t=Yn(),n=wi(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,d=parseInt;function h(p){if(typeof p=="number")return p;if(n(p))return s;if(t(p)){var f=typeof p.valueOf=="function"?p.valueOf():p;p=t(f)?f+"":f}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?d(p.slice(2),m?2:8):a.test(p)?s:+p}return By=h,By}var zy,Zj;function zA(){if(Zj)return zy;Zj=1;var e=Ez(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return zy=s,zy}var Uy,Jj;function Cz(){if(Jj)return Uy;Jj=1;var e=zA();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Uy=t,Uy}var Wy,eE;function Tz(){if(eE)return Wy;eE=1;var e=$A(),t=us(),n=Cz(),s=Math.max;function a(l,c,d){var h=l==null?0:l.length;if(!h)return-1;var p=d==null?0:n(d);return p<0&&(p=s(h+p,0)),e(l,t(c,3),p)}return Wy=a,Wy}var Hy,tE;function Az(){if(tE)return Hy;tE=1;var e=Nz(),t=Tz(),n=e(t);return Hy=n,Hy}var Gy,nE;function UA(){if(nE)return Gy;nE=1;var e=qx();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Gy=t,Gy}var Vy,rE;function Rz(){if(rE)return Vy;rE=1;var e=Ox(),t=fA(),n=Ja();function s(a,l){return a==null?a:e(a,t(l),n)}return Vy=s,Vy}var Yy,sE;function Mz(){if(sE)return Yy;sE=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Yy=e,Yy}var Ky,aE;function Iz(){if(aE)return Ky;aE=1;var e=Md(),t=Px(),n=us();function s(a,l){var c={};return l=n(l,3),t(a,function(d,h,p){e(c,h,l(d,h,p))}),c}return Ky=s,Ky}var Xy,oE;function Bx(){if(oE)return Xy;oE=1;var e=wi();function t(n,s,a){for(var l=-1,c=n.length;++l<c;){var d=n[l],h=s(d);if(h!=null&&(p===void 0?h===h&&!e(h):a(h,p)))var p=h,f=d}return f}return Xy=t,Xy}var Qy,iE;function $z(){if(iE)return Qy;iE=1;function e(t,n){return t>n}return Qy=e,Qy}var Zy,lE;function Oz(){if(lE)return Zy;lE=1;var e=Bx(),t=$z(),n=eo();function s(a){return a&&a.length?e(a,n,t):void 0}return Zy=s,Zy}var Jy,cE;function WA(){if(cE)return Jy;cE=1;var e=Md(),t=pi();function n(s,a,l){(l!==void 0&&!t(s[a],l)||l===void 0&&!(a in s))&&e(s,a,l)}return Jy=n,Jy}var ew,uE;function Pz(){if(uE)return ew;uE=1;var e=Qa(),t=Ld(),n=$r(),s="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,d=l.hasOwnProperty,h=c.call(Object);function p(f){if(!n(f)||e(f)!=s)return!1;var m=t(f);if(m===null)return!0;var y=d.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==h}return ew=p,ew}var tw,dE;function HA(){if(dE)return tw;dE=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return tw=e,tw}var nw,hE;function Lz(){if(hE)return nw;hE=1;var e=nc(),t=Ja();function n(s){return e(s,t(s))}return nw=n,nw}var rw,fE;function Dz(){if(fE)return rw;fE=1;var e=WA(),t=eA(),n=cA(),s=tA(),a=dA(),l=rc(),c=Mt(),d=OA(),h=gi(),p=tc(),f=Yn(),m=Pz(),y=sc(),v=HA(),j=Lz();function _(S,x,N,E,C,R,I){var $=v(S,N),F=v(x,N),O=I.get(F);if(O){e(S,N,O);return}var M=R?R($,F,N+"",S,x,I):void 0,L=M===void 0;if(L){var H=c(F),B=!H&&h(F),A=!H&&!B&&y(F);M=F,H||B||A?c($)?M=$:d($)?M=s($):B?(L=!1,M=t(F,!0)):A?(L=!1,M=n(F,!0)):M=[]:m(F)||l(F)?(M=$,l($)?M=j($):(!f($)||p($))&&(M=a(F))):L=!1}L&&(I.set(F,M),C(M,F,E,R,I),I.delete(F)),e(S,N,M)}return rw=_,rw}var sw,pE;function qz(){if(pE)return sw;pE=1;var e=Rd(),t=WA(),n=Ox(),s=Dz(),a=Yn(),l=Ja(),c=HA();function d(h,p,f,m,y){h!==p&&n(p,function(v,j){if(y||(y=new e),a(v))s(h,p,j,f,d,m,y);else{var _=m?m(c(h,j),v,j+"",h,p,y):void 0;_===void 0&&(_=v),t(h,j,_)}},l)}return sw=d,sw}var aw,mE;function Fz(){if(mE)return aw;mE=1;var e=zd(),t=Ud();function n(s){return e(function(a,l){var c=-1,d=l.length,h=d>1?l[d-1]:void 0,p=d>2?l[2]:void 0;for(h=s.length>3&&typeof h=="function"?(d--,h):void 0,p&&t(l[0],l[1],p)&&(h=d<3?void 0:h,d=1),a=Object(a);++c<d;){var f=l[c];f&&s(a,f,c,h)}return a})}return aw=n,aw}var ow,gE;function Bz(){if(gE)return ow;gE=1;var e=qz(),t=Fz(),n=t(function(s,a,l){e(s,a,l)});return ow=n,ow}var iw,yE;function GA(){if(yE)return iw;yE=1;function e(t,n){return t<n}return iw=e,iw}var lw,wE;function zz(){if(wE)return lw;wE=1;var e=Bx(),t=GA(),n=eo();function s(a){return a&&a.length?e(a,n,t):void 0}return lw=s,lw}var cw,vE;function Uz(){if(vE)return cw;vE=1;var e=Bx(),t=us(),n=GA();function s(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return cw=s,cw}var uw,xE;function Wz(){if(xE)return uw;xE=1;var e=yr(),t=function(){return e.Date.now()};return uw=t,uw}var dw,bE;function Hz(){if(bE)return dw;bE=1;var e=Id(),t=Fd(),n=$d(),s=Yn(),a=ac();function l(c,d,h,p){if(!s(c))return c;d=t(d,c);for(var f=-1,m=d.length,y=m-1,v=c;v!=null&&++f<m;){var j=a(d[f]),_=h;if(j==="__proto__"||j==="constructor"||j==="prototype")return c;if(f!=y){var S=v[j];_=p?p(S,j,v):void 0,_===void 0&&(_=s(S)?S:n(d[f+1])?[]:{})}e(v,j,_),v=v[j]}return c}return dw=l,dw}var hw,kE;function Gz(){if(kE)return hw;kE=1;var e=Bd(),t=Hz(),n=Fd();function s(a,l,c){for(var d=-1,h=l.length,p={};++d<h;){var f=l[d],m=e(a,f);c(m,f)&&t(p,n(f,a),m)}return p}return hw=s,hw}var fw,_E;function Vz(){if(_E)return fw;_E=1;var e=Gz(),t=NA();function n(s,a){return e(s,a,function(l,c){return t(s,c)})}return fw=n,fw}var pw,NE;function Yz(){if(NE)return pw;NE=1;var e=UA(),t=MA(),n=IA();function s(a){return n(t(a,void 0,e),a+"")}return pw=s,pw}var mw,SE;function Kz(){if(SE)return mw;SE=1;var e=Vz(),t=Yz(),n=t(function(s,a){return s==null?{}:e(s,a)});return mw=n,mw}var gw,jE;function Xz(){if(jE)return gw;jE=1;var e=Math.ceil,t=Math.max;function n(s,a,l,c){for(var d=-1,h=t(e((a-s)/(l||1)),0),p=Array(h);h--;)p[c?h:++d]=s,s+=l;return p}return gw=n,gw}var yw,EE;function Qz(){if(EE)return yw;EE=1;var e=Xz(),t=Ud(),n=zA();function s(a){return function(l,c,d){return d&&typeof d!="number"&&t(l,c,d)&&(c=d=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),d=d===void 0?l<c?1:-1:n(d),e(l,c,d,a)}}return yw=s,yw}var ww,CE;function Zz(){if(CE)return ww;CE=1;var e=Qz(),t=e();return ww=t,ww}var vw,TE;function Jz(){if(TE)return vw;TE=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return vw=e,vw}var xw,AE;function eU(){if(AE)return xw;AE=1;var e=wi();function t(n,s){if(n!==s){var a=n!==void 0,l=n===null,c=n===n,d=e(n),h=s!==void 0,p=s===null,f=s===s,m=e(s);if(!p&&!m&&!d&&n>s||d&&h&&f&&!p&&!m||l&&h&&f||!a&&f||!c)return 1;if(!l&&!d&&!m&&n<s||m&&a&&c&&!l&&!d||p&&a&&c||!h&&c||!f)return-1}return 0}return xw=t,xw}var bw,RE;function tU(){if(RE)return bw;RE=1;var e=eU();function t(n,s,a){for(var l=-1,c=n.criteria,d=s.criteria,h=c.length,p=a.length;++l<h;){var f=e(c[l],d[l]);if(f){if(l>=p)return f;var m=a[l];return f*(m=="desc"?-1:1)}}return n.index-s.index}return bw=t,bw}var kw,ME;function nU(){if(ME)return kw;ME=1;var e=qd(),t=Bd(),n=us(),s=TA(),a=Jz(),l=Od(),c=tU(),d=eo(),h=Mt();function p(f,m,y){m.length?m=e(m,function(_){return h(_)?function(S){return t(S,_.length===1?_[0]:_)}:_}):m=[d];var v=-1;m=e(m,l(n));var j=s(f,function(_,S,x){var N=e(m,function(E){return E(_)});return{criteria:N,index:++v,value:_}});return a(j,function(_,S){return c(_,S,y)})}return kw=p,kw}var _w,IE;function rU(){if(IE)return _w;IE=1;var e=qx(),t=nU(),n=zd(),s=Ud(),a=n(function(l,c){if(l==null)return[];var d=c.length;return d>1&&s(l,c[0],c[1])?c=[]:d>2&&s(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return _w=a,_w}var Nw,$E;function sU(){if($E)return Nw;$E=1;var e=kA(),t=0;function n(s){var a=++t;return e(s)+a}return Nw=n,Nw}var Sw,OE;function aU(){if(OE)return Sw;OE=1;function e(t,n,s){for(var a=-1,l=t.length,c=n.length,d={};++a<l;){var h=a<c?n[a]:void 0;s(d,t[a],h)}return d}return Sw=e,Sw}var jw,PE;function oU(){if(PE)return jw;PE=1;var e=Id(),t=aU();function n(s,a){return t(s||[],a||[],e)}return jw=n,jw}var Ew,LE;function vt(){if(LE)return Ew;LE=1;var e;if(typeof Nx=="function")try{e={cloneDeep:kz(),constant:$x(),defaults:_z(),each:mA(),filter:jA(),find:Az(),flatten:UA(),forEach:pA(),forIn:Rz(),has:EA(),isUndefined:CA(),last:Mz(),map:AA(),mapValues:Iz(),max:Oz(),merge:Bz(),min:zz(),minBy:Uz(),now:Wz(),pick:Kz(),range:Zz(),reduce:RA(),sortBy:rU(),uniqueId:sU(),values:PA(),zipObject:oU()}}catch{}return e||(e=window._),Ew=e,Ew}var Cw,DE;function iU(){if(DE)return Cw;DE=1,Cw=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,l=a._prev;l!==a;)s.push(JSON.stringify(l,n)),l=l._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 Cw}var Tw,qE;function lU(){if(qE)return Tw;qE=1;var e=vt(),t=mr().Graph,n=iU();Tw=a;var s=e.constant(1);function a(p,f){if(p.nodeCount()<=1)return[];var m=d(p,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,f,m){for(var y=[],v=f[f.length-1],j=f[0],_;p.nodeCount();){for(;_=j.dequeue();)c(p,f,m,_);for(;_=v.dequeue();)c(p,f,m,_);if(p.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(c(p,f,m,_,!0));break}}}return y}function c(p,f,m,y,v){var j=v?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var S=p.edge(_),x=p.node(_.v);v&&j.push({v:_.v,w:_.w}),x.out-=S,h(f,m,x)}),e.forEach(p.outEdges(y.v),function(_){var S=p.edge(_),x=_.w,N=p.node(x);N.in-=S,h(f,m,N)}),p.removeNode(y.v),j}function d(p,f){var m=new t,y=0,v=0;e.forEach(p.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var x=m.edge(S.v,S.w)||0,N=f(S),E=x+N;m.setEdge(S.v,S.w,E),v=Math.max(v,m.node(S.v).out+=N),y=Math.max(y,m.node(S.w).in+=N)});var j=e.range(v+y+3).map(function(){return new n}),_=y+1;return e.forEach(m.nodes(),function(S){h(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function h(p,f,m){m.out?m.in?p[m.out-m.in+f].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Tw}var Aw,FE;function cU(){if(FE)return Aw;FE=1;var e=vt(),t=lU();Aw={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,d(l)):s(l);e.forEach(c,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function d(h){return function(p){return h.edge(p).weight}}}function s(l){var c=[],d={},h={};function p(f){e.has(h,f)||(h[f]=!0,d[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(d,m.w)?c.push(m):p(m.w)}),delete d[f])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var d=l.edge(c);if(d.reversed){l.removeEdge(c);var h=d.forwardName;delete d.reversed,delete d.forwardName,l.setEdge(c.w,c.v,d,h)}})}return Aw}var Rw,BE;function vn(){if(BE)return Rw;BE=1;var e=vt(),t=mr().Graph;Rw={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:d,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:v,time:j,notime:_};function n(S,x,N,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return N.dummy=x,S.setNode(C,N),C}function s(S){var x=new t().setGraph(S.graph());return e.forEach(S.nodes(),function(N){x.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){var E=x.edge(N.v,N.w)||{weight:0,minlen:1},C=S.edge(N);x.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),x}function a(S){var x=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(N){S.children(N).length||x.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){x.setEdge(N,S.edge(N))}),x}function l(S){var x=e.map(S.nodes(),function(N){var E={};return e.forEach(S.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),x)}function c(S){var x=e.map(S.nodes(),function(N){var E={};return e.forEach(S.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),x)}function d(S,x){var N=S.x,E=S.y,C=x.x-N,R=x.y-E,I=S.width/2,$=S.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var F,O;return Math.abs(R)*I>Math.abs(C)*$?(R<0&&($=-$),F=$*C/R,O=$):(C<0&&(I=-I),F=I,O=I*R/C),{x:N+F,y:E+O}}function h(S){var x=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(N){var E=S.node(N),C=E.rank;e.isUndefined(C)||(x[C][E.order]=N)}),x}function p(S){var x=e.min(e.map(S.nodes(),function(N){return S.node(N).rank}));e.forEach(S.nodes(),function(N){var E=S.node(N);e.has(E,"rank")&&(E.rank-=x)})}function f(S){var x=e.min(e.map(S.nodes(),function(R){return S.node(R).rank})),N=[];e.forEach(S.nodes(),function(R){var I=S.node(R).rank-x;N[I]||(N[I]=[]),N[I].push(R)});var E=0,C=S.graph().nodeRankFactor;e.forEach(N,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function($){S.node($).rank+=E})})}function m(S,x,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(S,"border",C,x)}function y(S){return e.max(e.map(S.nodes(),function(x){var N=S.node(x).rank;if(!e.isUndefined(N))return N}))}function v(S,x){var N={lhs:[],rhs:[]};return e.forEach(S,function(E){x(E)?N.lhs.push(E):N.rhs.push(E)}),N}function j(S,x){var N=e.now();try{return x()}finally{console.log(S+" time: "+(e.now()-N)+"ms")}}function _(S,x){return x()}return Rw}var Mw,zE;function uU(){if(zE)return Mw;zE=1;var e=vt(),t=vn();Mw={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){s(l,c)})}function s(l,c){var d=c.v,h=l.node(d).rank,p=c.w,f=l.node(p).rank,m=c.name,y=l.edge(c),v=y.labelRank;if(f!==h+1){l.removeEdge(c);var j,_,S;for(S=0,++h;h<f;++S,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:c,rank:h},j=t.addDummyNode(l,"edge",_,"_d"),h===v&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(d,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),d=j;l.setEdge(d,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var d=l.node(c),h=d.edgeLabel,p;for(l.setEdge(d.edgeObj,h);d.dummy;)p=l.successors(c)[0],l.removeNode(c),h.points.push({x:d.x,y:d.y}),d.dummy==="edge-label"&&(h.x=d.x,h.y=d.y,h.width=d.width,h.height=d.height),c=p,d=l.node(c)})}return Mw}var Iw,UE;function hd(){if(UE)return Iw;UE=1;var e=vt();Iw={longestPath:t,slack:n};function t(s){var a={};function l(c){var d=s.node(c);if(e.has(a,c))return d.rank;a[c]=!0;var h=e.min(e.map(s.outEdges(c),function(p){return l(p.w)-s.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),d.rank=h}e.forEach(s.sources(),l)}function n(s,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return Iw}var $w,WE;function VA(){if(WE)return $w;WE=1;var e=vt(),t=mr().Graph,n=hd().slack;$w=s;function s(d){var h=new t({directed:!1}),p=d.nodes()[0],f=d.nodeCount();h.setNode(p,{});for(var m,y;a(h,d)<f;)m=l(h,d),y=h.hasNode(m.v)?n(d,m):-n(d,m),c(h,d,y);return h}function a(d,h){function p(f){e.forEach(h.nodeEdges(f),function(m){var y=m.v,v=f===y?m.w:y;!d.hasNode(v)&&!n(h,m)&&(d.setNode(v,{}),d.setEdge(f,v,{}),p(v))})}return e.forEach(d.nodes(),p),d.nodeCount()}function l(d,h){return e.minBy(h.edges(),function(p){if(d.hasNode(p.v)!==d.hasNode(p.w))return n(h,p)})}function c(d,h,p){e.forEach(d.nodes(),function(f){h.node(f).rank+=p})}return $w}var Ow,HE;function dU(){if(HE)return Ow;HE=1;var e=vt(),t=VA(),n=hd().slack,s=hd().longestPath,a=mr().alg.preorder,l=mr().alg.postorder,c=vn().simplify;Ow=d,d.initLowLimValues=m,d.initCutValues=h,d.calcCutValue=f,d.leaveEdge=v,d.enterEdge=j,d.exchangeEdges=_;function d(E){E=c(E),s(E);var C=t(E);m(C),h(C,E);for(var R,I;R=v(C);)I=j(C,E,R),_(C,E,R,I)}function h(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){p(E,C,I)})}function p(E,C,R){var I=E.node(R),$=I.parent;E.edge(R,$).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),$=I.parent,F=!0,O=C.edge(R,$),M=0;return O||(F=!1,O=C.edge($,R)),M=O.weight,e.forEach(C.nodeEdges(R),function(L){var H=L.v===R,B=H?L.w:L.v;if(B!==$){var A=H===F,Q=C.edge(L).weight;if(M+=A?Q:-Q,x(E,R,B)){var K=E.edge(R,B).cutvalue;M+=A?-K:K}}}),M}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,$){var F=R,O=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(M){e.has(C,M)||(R=y(E,C,R,M,I))}),O.low=F,O.lim=R++,$?O.parent=$:delete O.parent,R}function v(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function j(E,C,R){var I=R.v,$=R.w;C.hasEdge(I,$)||(I=R.w,$=R.v);var F=E.node(I),O=E.node($),M=F,L=!1;F.lim>O.lim&&(M=O,L=!0);var H=e.filter(C.edges(),function(B){return L===N(E,E.node(B.v),M)&&L!==N(E,E.node(B.w),M)});return e.minBy(H,function(B){return n(C,B)})}function _(E,C,R,I){var $=R.v,F=R.w;E.removeEdge($,F),E.setEdge(I.v,I.w,{}),m(E),h(E,C),S(E,C)}function S(E,C){var R=e.find(E.nodes(),function($){return!C.node($).parent}),I=a(E,R);I=I.slice(1),e.forEach(I,function($){var F=E.node($).parent,O=C.edge($,F),M=!1;O||(O=C.edge(F,$),M=!0),C.node($).rank=C.node(F).rank+(M?O.minlen:-O.minlen)})}function x(E,C,R){return E.hasEdge(C,R)}function N(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return Ow}var Pw,GE;function hU(){if(GE)return Pw;GE=1;var e=hd(),t=e.longestPath,n=VA(),s=dU();Pw=a;function a(h){switch(h.graph().ranker){case"network-simplex":d(h);break;case"tight-tree":c(h);break;case"longest-path":l(h);break;default:d(h)}}var l=t;function c(h){t(h),n(h)}function d(h){s(h)}return Pw}var Lw,VE;function fU(){if(VE)return Lw;VE=1;var e=vt();Lw=t;function t(a){var l=s(a);e.forEach(a.graph().dummyChains,function(c){for(var d=a.node(c),h=d.edgeObj,p=n(a,l,h.v,h.w),f=p.path,m=p.lca,y=0,v=f[y],j=!0;c!==h.w;){if(d=a.node(c),j){for(;(v=f[y])!==m&&a.node(v).maxRank<d.rank;)y++;v===m&&(j=!1)}if(!j){for(;y<f.length-1&&a.node(v=f[y+1]).minRank<=d.rank;)y++;v=f[y]}a.setParent(c,v),c=a.successors(c)[0]}})}function n(a,l,c,d){var h=[],p=[],f=Math.min(l[c].low,l[d].low),m=Math.max(l[c].lim,l[d].lim),y,v;y=c;do y=a.parent(y),h.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(v=y,y=d;(y=a.parent(y))!==v;)p.push(y);return{path:h.concat(p.reverse()),lca:v}}function s(a){var l={},c=0;function d(h){var p=c;e.forEach(a.children(h),d),l[h]={low:p,lim:c++}}return e.forEach(a.children(),d),l}return Lw}var Dw,YE;function pU(){if(YE)return Dw;YE=1;var e=vt(),t=vn();Dw={run:n,cleanup:c};function n(d){var h=t.addDummyNode(d,"root",{},"_root"),p=a(d),f=e.max(e.values(p))-1,m=2*f+1;d.graph().nestingRoot=h,e.forEach(d.edges(),function(v){d.edge(v).minlen*=m});var y=l(d)+1;e.forEach(d.children(),function(v){s(d,h,m,y,f,p,v)}),d.graph().nodeRankFactor=m}function s(d,h,p,f,m,y,v){var j=d.children(v);if(!j.length){v!==h&&d.setEdge(h,v,{weight:0,minlen:p});return}var _=t.addBorderNode(d,"_bt"),S=t.addBorderNode(d,"_bb"),x=d.node(v);d.setParent(_,v),x.borderTop=_,d.setParent(S,v),x.borderBottom=S,e.forEach(j,function(N){s(d,h,p,f,m,y,N);var E=d.node(N),C=E.borderTop?E.borderTop:N,R=E.borderBottom?E.borderBottom:N,I=E.borderTop?f:2*f,$=C!==R?1:m-y[v]+1;d.setEdge(_,C,{weight:I,minlen:$,nestingEdge:!0}),d.setEdge(R,S,{weight:I,minlen:$,nestingEdge:!0})}),d.parent(v)||d.setEdge(h,_,{weight:0,minlen:m+y[v]})}function a(d){var h={};function p(f,m){var y=d.children(f);y&&y.length&&e.forEach(y,function(v){p(v,m+1)}),h[f]=m}return e.forEach(d.children(),function(f){p(f,1)}),h}function l(d){return e.reduce(d.edges(),function(h,p){return h+d.edge(p).weight},0)}function c(d){var h=d.graph();d.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(d.edges(),function(p){var f=d.edge(p);f.nestingEdge&&d.removeEdge(p)})}return Dw}var qw,KE;function mU(){if(KE)return qw;KE=1;var e=vt(),t=vn();qw=n;function n(a){function l(c){var d=a.children(c),h=a.node(c);if(d.length&&e.forEach(d,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,f=h.maxRank+1;p<f;++p)s(a,"borderLeft","_bl",c,h,p),s(a,"borderRight","_br",c,h,p)}}e.forEach(a.children(),l)}function s(a,l,c,d,h,p){var f={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=t.addDummyNode(a,"border",f,c);h[l][p]=y,a.setParent(y,d),m&&a.setEdge(m,y,{weight:1})}return qw}var Fw,XE;function gU(){if(XE)return Fw;XE=1;var e=vt();Fw={adjust:t,undo:n};function t(p){var f=p.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(p)}function n(p){var f=p.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(p),(f==="lr"||f==="rl")&&(d(p),s(p))}function s(p){e.forEach(p.nodes(),function(f){a(p.node(f))}),e.forEach(p.edges(),function(f){a(p.edge(f))})}function a(p){var f=p.width;p.width=p.height,p.height=f}function l(p){e.forEach(p.nodes(),function(f){c(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function d(p){e.forEach(p.nodes(),function(f){h(p.node(f))}),e.forEach(p.edges(),function(f){var m=p.edge(f);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var f=p.x;p.x=p.y,p.y=f}return Fw}var Bw,QE;function yU(){if(QE)return Bw;QE=1;var e=vt();Bw=t;function t(n){var s={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function d(p){if(!e.has(s,p)){s[p]=!0;var f=n.node(p);c[f.rank].push(p),e.forEach(n.successors(p),d)}}var h=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(h,d),c}return Bw}var zw,ZE;function wU(){if(ZE)return zw;ZE=1;var e=vt();zw=t;function t(s,a){for(var l=0,c=1;c<a.length;++c)l+=n(s,a[c-1],a[c]);return l}function n(s,a,l){for(var c=e.zipObject(l,e.map(l,function(y,v){return v})),d=e.flatten(e.map(a,function(y){return e.sortBy(e.map(s.outEdges(y),function(v){return{pos:c[v.w],weight:s.edge(v).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var f=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(d.forEach(function(y){var v=y.pos+h;f[v]+=y.weight;for(var j=0;v>0;)v%2&&(j+=f[v+1]),v=v-1>>1,f[v]+=y.weight;m+=y.weight*j})),m}return zw}var Uw,JE;function vU(){if(JE)return Uw;JE=1;var e=vt();Uw=t;function t(n,s){return e.map(s,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(d,h){var p=n.edge(h),f=n.node(h.v);return{sum:d.sum+p.weight*f.order,weight:d.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return Uw}var Ww,eC;function xU(){if(eC)return Ww;eC=1;var e=vt();Ww=t;function t(a,l){var c={};e.forEach(a,function(h,p){var f=c[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(f.barycenter=h.barycenter,f.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=c[h.v],f=c[h.w];!e.isUndefined(p)&&!e.isUndefined(f)&&(f.indegree++,p.out.push(c[h.w]))});var d=e.filter(c,function(h){return!h.indegree});return n(d)}function n(a){var l=[];function c(p){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(p.barycenter)||f.barycenter>=p.barycenter)&&s(p,f)}}function d(p){return function(f){f.in.push(p),--f.indegree===0&&a.push(f)}}for(;a.length;){var h=a.pop();l.push(h),e.forEach(h.in.reverse(),c(h)),e.forEach(h.out,d(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function s(a,l){var c=0,d=0;a.weight&&(c+=a.barycenter*a.weight,d+=a.weight),l.weight&&(c+=l.barycenter*l.weight,d+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/d,a.weight=d,a.i=Math.min(l.i,a.i),l.merged=!0}return Ww}var Hw,tC;function bU(){if(tC)return Hw;tC=1;var e=vt(),t=vn();Hw=n;function n(l,c){var d=t.partition(l,function(_){return e.has(_,"barycenter")}),h=d.lhs,p=e.sortBy(d.rhs,function(_){return-_.i}),f=[],m=0,y=0,v=0;h.sort(a(!!c)),v=s(f,p,v),e.forEach(h,function(_){v+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,v=s(f,p,v)});var j={vs:e.flatten(f,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,c,d){for(var h;c.length&&(h=e.last(c)).i<=d;)c.pop(),l.push(h.vs),d++;return d}function a(l){return function(c,d){return c.barycenter<d.barycenter?-1:c.barycenter>d.barycenter?1:l?d.i-c.i:c.i-d.i}}return Hw}var Gw,nC;function kU(){if(nC)return Gw;nC=1;var e=vt(),t=vU(),n=xU(),s=bU();Gw=a;function a(d,h,p,f){var m=d.children(h),y=d.node(h),v=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};v&&(m=e.filter(m,function(R){return R!==v&&R!==j}));var S=t(d,m);e.forEach(S,function(R){if(d.children(R.v).length){var I=a(d,R.v,p,f);_[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var x=n(S,p);l(x,_);var N=s(x,f);if(v&&(N.vs=e.flatten([v,N.vs,j],!0),d.predecessors(v).length)){var E=d.node(d.predecessors(v)[0]),C=d.node(d.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(d,h){e.forEach(d,function(p){p.vs=e.flatten(p.vs.map(function(f){return h[f]?h[f].vs:f}),!0)})}function c(d,h){e.isUndefined(d.barycenter)?(d.barycenter=h.barycenter,d.weight=h.weight):(d.barycenter=(d.barycenter*d.weight+h.barycenter*h.weight)/(d.weight+h.weight),d.weight+=h.weight)}return Gw}var Vw,rC;function _U(){if(rC)return Vw;rC=1;var e=vt(),t=mr().Graph;Vw=n;function n(a,l,c){var d=s(a),h=new t({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var f=a.node(p),m=a.parent(p);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(h.setNode(p),h.setParent(p,m||d),e.forEach(a[c](p),function(y){var v=y.v===p?y.w:y.v,j=h.edge(v,p),_=e.isUndefined(j)?0:j.weight;h.setEdge(v,p,{weight:a.edge(y).weight+_})}),e.has(f,"minRank")&&h.setNode(p,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),h}function s(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return Vw}var Yw,sC;function NU(){if(sC)return Yw;sC=1;var e=vt();Yw=t;function t(n,s,a){var l={},c;e.forEach(a,function(d){for(var h=n.parent(d),p,f;h;){if(p=n.parent(h),p?(f=l[p],l[p]=h):(f=c,c=h),f&&f!==h){s.setEdge(f,h);return}h=p}})}return Yw}var Kw,aC;function SU(){if(aC)return Kw;aC=1;var e=vt(),t=yU(),n=wU(),s=kU(),a=_U(),l=NU(),c=mr().Graph,d=vn();Kw=h;function h(y){var v=d.maxRank(y),j=p(y,e.range(1,v+1),"inEdges"),_=p(y,e.range(v-1,-1,-1),"outEdges"),S=t(y);m(y,S);for(var x=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){f(E%2?j:_,E%4>=2),S=d.buildLayerMatrix(y);var R=n(y,S);R<x&&(C=0,N=e.cloneDeep(S),x=R)}m(y,N)}function p(y,v,j){return e.map(v,function(_){return a(y,_,j)})}function f(y,v){var j=new c;e.forEach(y,function(_){var S=_.graph().root,x=s(_,S,j,v);e.forEach(x.vs,function(N,E){_.node(N).order=E}),l(_,j,x.vs)})}function m(y,v){e.forEach(v,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return Kw}var Xw,oC;function jU(){if(oC)return Xw;oC=1;var e=vt(),t=mr().Graph,n=vn();Xw={positionX:j,findType1Conflicts:s,findType2Conflicts:a,addConflict:c,hasConflict:d,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:v};function s(x,N){var E={};function C(R,I){var $=0,F=0,O=R.length,M=e.last(I);return e.forEach(I,function(L,H){var B=l(x,L),A=B?x.node(B).order:O;(B||L===M)&&(e.forEach(I.slice(F,H+1),function(Q){e.forEach(x.predecessors(Q),function(K){var ee=x.node(K),Z=ee.order;(Z<$||A<Z)&&!(ee.dummy&&x.node(Q).dummy)&&c(E,K,Q)})}),F=H+1,$=A)}),I}return e.reduce(N,C),E}function a(x,N){var E={};function C(I,$,F,O,M){var L;e.forEach(e.range($,F),function(H){L=I[H],x.node(L).dummy&&e.forEach(x.predecessors(L),function(B){var A=x.node(B);A.dummy&&(A.order<O||A.order>M)&&c(E,B,L)})})}function R(I,$){var F=-1,O,M=0;return e.forEach($,function(L,H){if(x.node(L).dummy==="border"){var B=x.predecessors(L);B.length&&(O=x.node(B[0]).order,C($,M,H,F,O),M=H,F=O)}C($,M,$.length,O,I.length)}),$}return e.reduce(N,R),E}function l(x,N){if(x.node(N).dummy)return e.find(x.predecessors(N),function(E){return x.node(E).dummy})}function c(x,N,E){if(N>E){var C=N;N=E,E=C}var R=x[N];R||(x[N]=R={}),R[E]=!0}function d(x,N,E){if(N>E){var C=N;N=E,E=C}return e.has(x[N],E)}function h(x,N,E,C){var R={},I={},$={};return e.forEach(N,function(F){e.forEach(F,function(O,M){R[O]=O,I[O]=O,$[O]=M})}),e.forEach(N,function(F){var O=-1;e.forEach(F,function(M){var L=C(M);if(L.length){L=e.sortBy(L,function(K){return $[K]});for(var H=(L.length-1)/2,B=Math.floor(H),A=Math.ceil(H);B<=A;++B){var Q=L[B];I[M]===M&&O<$[Q]&&!d(E,M,Q)&&(I[Q]=M,I[M]=R[M]=R[Q],O=$[Q])}}})}),{root:R,align:I}}function p(x,N,E,C,R){var I={},$=f(x,N,E,R),F=R?"borderLeft":"borderRight";function O(H,B){for(var A=$.nodes(),Q=A.pop(),K={};Q;)K[Q]?H(Q):(K[Q]=!0,A.push(Q),A=A.concat(B(Q))),Q=A.pop()}function M(H){I[H]=$.inEdges(H).reduce(function(B,A){return Math.max(B,I[A.v]+$.edge(A))},0)}function L(H){var B=$.outEdges(H).reduce(function(Q,K){return Math.min(Q,I[K.w]-$.edge(K))},Number.POSITIVE_INFINITY),A=x.node(H);B!==Number.POSITIVE_INFINITY&&A.borderType!==F&&(I[H]=Math.max(I[H],B))}return O(M,$.predecessors.bind($)),O(L,$.successors.bind($)),e.forEach(C,function(H){I[H]=I[E[H]]}),I}function f(x,N,E,C){var R=new t,I=x.graph(),$=_(I.nodesep,I.edgesep,C);return e.forEach(N,function(F){var O;e.forEach(F,function(M){var L=E[M];if(R.setNode(L),O){var H=E[O],B=R.edge(H,L);R.setEdge(H,L,Math.max($(x,M,O),B||0))}O=M})}),R}function m(x,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,$){var F=S(x,$)/2;C=Math.max(I+F,C),R=Math.min(I-F,R)}),C-R})}function y(x,N){var E=e.values(N),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function($){var F=I+$,O=x[F],M;if(O!==N){var L=e.values(O);M=$==="l"?C-e.min(L):R-e.max(L),M&&(x[F]=e.mapValues(O,function(H){return H+M}))}})})}function v(x,N){return e.mapValues(x.ul,function(E,C){if(N)return x[N.toLowerCase()][C];var R=e.sortBy(e.map(x,C));return(R[1]+R[2])/2})}function j(x){var N=n.buildLayerMatrix(x),E=e.merge(s(x,N),a(x,N)),C={},R;e.forEach(["u","d"],function($){R=$==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(F){F==="r"&&(R=e.map(R,function(H){return e.values(H).reverse()}));var O=($==="u"?x.predecessors:x.successors).bind(x),M=h(x,R,E,O),L=p(x,R,M.root,M.align,F==="r");F==="r"&&(L=e.mapValues(L,function(H){return-H})),C[$+F]=L})});var I=m(x,C);return y(C,I),v(C,x.graph().align)}function _(x,N,E){return function(C,R,I){var $=C.node(R),F=C.node(I),O=0,M;if(O+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":M=-$.width/2;break;case"r":M=$.width/2;break}if(M&&(O+=E?M:-M),M=0,O+=($.dummy?N:x)/2,O+=(F.dummy?N:x)/2,O+=F.width/2,e.has(F,"labelpos"))switch(F.labelpos.toLowerCase()){case"l":M=F.width/2;break;case"r":M=-F.width/2;break}return M&&(O+=E?M:-M),M=0,O}}function S(x,N){return x.node(N).width}return Xw}var Qw,iC;function EU(){if(iC)return Qw;iC=1;var e=vt(),t=vn(),n=jU().positionX;Qw=s;function s(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,d){l.node(d).x=c})}function a(l){var c=t.buildLayerMatrix(l),d=l.graph().ranksep,h=0;e.forEach(c,function(p){var f=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+f/2}),h+=f+d})}return Qw}var Zw,lC;function CU(){if(lC)return Zw;lC=1;var e=vt(),t=cU(),n=uU(),s=hU(),a=vn().normalizeRanks,l=fU(),c=vn().removeEmptyRanks,d=pU(),h=mU(),p=gU(),f=SU(),m=EU(),y=vn(),v=mr().Graph;Zw=j;function j(W,U){var J=U&&U.debugTiming?y.time:y.notime;J("layout",function(){var V=J(" buildLayoutGraph",function(){return O(W)});J(" runLayout",function(){_(V,J)}),J(" updateInputGraph",function(){S(W,V)})})}function _(W,U){U(" makeSpaceForEdgeLabels",function(){M(W)}),U(" removeSelfEdges",function(){D(W)}),U(" acyclic",function(){t.run(W)}),U(" nestingGraph.run",function(){d.run(W)}),U(" rank",function(){s(y.asNonCompoundGraph(W))}),U(" injectEdgeLabelProxies",function(){L(W)}),U(" removeEmptyRanks",function(){c(W)}),U(" nestingGraph.cleanup",function(){d.cleanup(W)}),U(" normalizeRanks",function(){a(W)}),U(" assignRankMinMax",function(){H(W)}),U(" removeEdgeLabelProxies",function(){B(W)}),U(" normalize.run",function(){n.run(W)}),U(" parentDummyChains",function(){l(W)}),U(" addBorderSegments",function(){h(W)}),U(" order",function(){f(W)}),U(" insertSelfEdges",function(){Y(W)}),U(" adjustCoordinateSystem",function(){p.adjust(W)}),U(" position",function(){m(W)}),U(" positionSelfEdges",function(){P(W)}),U(" removeBorderNodes",function(){Z(W)}),U(" normalize.undo",function(){n.undo(W)}),U(" fixupEdgeLabelCoords",function(){K(W)}),U(" undoCoordinateSystem",function(){p.undo(W)}),U(" translateGraph",function(){A(W)}),U(" assignNodeIntersects",function(){Q(W)}),U(" reversePoints",function(){ee(W)}),U(" acyclic.undo",function(){t.undo(W)})}function S(W,U){e.forEach(W.nodes(),function(J){var V=W.node(J),ie=U.node(J);V&&(V.x=ie.x,V.y=ie.y,U.children(J).length&&(V.width=ie.width,V.height=ie.height))}),e.forEach(W.edges(),function(J){var V=W.edge(J),ie=U.edge(J);V.points=ie.points,e.has(ie,"x")&&(V.x=ie.x,V.y=ie.y)}),W.graph().width=U.graph().width,W.graph().height=U.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},F=["labelpos"];function O(W){var U=new v({multigraph:!0,compound:!0}),J=de(W.graph());return U.setGraph(e.merge({},N,G(J,x),e.pick(J,E))),e.forEach(W.nodes(),function(V){var ie=de(W.node(V));U.setNode(V,e.defaults(G(ie,C),R)),U.setParent(V,W.parent(V))}),e.forEach(W.edges(),function(V){var ie=de(W.edge(V));U.setEdge(V,e.merge({},$,G(ie,I),e.pick(ie,F)))}),U}function M(W){var U=W.graph();U.ranksep/=2,e.forEach(W.edges(),function(J){var V=W.edge(J);V.minlen*=2,V.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?V.width+=V.labeloffset:V.height+=V.labeloffset)})}function L(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(J.width&&J.height){var V=W.node(U.v),ie=W.node(U.w),pe={rank:(ie.rank-V.rank)/2+V.rank,e:U};y.addDummyNode(W,"edge-proxy",pe,"_ep")}})}function H(W){var U=0;e.forEach(W.nodes(),function(J){var V=W.node(J);V.borderTop&&(V.minRank=W.node(V.borderTop).rank,V.maxRank=W.node(V.borderBottom).rank,U=e.max(U,V.maxRank))}),W.graph().maxRank=U}function B(W){e.forEach(W.nodes(),function(U){var J=W.node(U);J.dummy==="edge-proxy"&&(W.edge(J.e).labelRank=J.rank,W.removeNode(U))})}function A(W){var U=Number.POSITIVE_INFINITY,J=0,V=Number.POSITIVE_INFINITY,ie=0,pe=W.graph(),me=pe.marginx||0,Ie=pe.marginy||0;function Le(ce){var xe=ce.x,ye=ce.y,ze=ce.width,ke=ce.height;U=Math.min(U,xe-ze/2),J=Math.max(J,xe+ze/2),V=Math.min(V,ye-ke/2),ie=Math.max(ie,ye+ke/2)}e.forEach(W.nodes(),function(ce){Le(W.node(ce))}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.has(xe,"x")&&Le(xe)}),U-=me,V-=Ie,e.forEach(W.nodes(),function(ce){var xe=W.node(ce);xe.x-=U,xe.y-=V}),e.forEach(W.edges(),function(ce){var xe=W.edge(ce);e.forEach(xe.points,function(ye){ye.x-=U,ye.y-=V}),e.has(xe,"x")&&(xe.x-=U),e.has(xe,"y")&&(xe.y-=V)}),pe.width=J-U+me,pe.height=ie-V+Ie}function Q(W){e.forEach(W.edges(),function(U){var J=W.edge(U),V=W.node(U.v),ie=W.node(U.w),pe,me;J.points?(pe=J.points[0],me=J.points[J.points.length-1]):(J.points=[],pe=ie,me=V),J.points.unshift(y.intersectRect(V,pe)),J.points.push(y.intersectRect(ie,me))})}function K(W){e.forEach(W.edges(),function(U){var J=W.edge(U);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ee(W){e.forEach(W.edges(),function(U){var J=W.edge(U);J.reversed&&J.points.reverse()})}function Z(W){e.forEach(W.nodes(),function(U){if(W.children(U).length){var J=W.node(U),V=W.node(J.borderTop),ie=W.node(J.borderBottom),pe=W.node(e.last(J.borderLeft)),me=W.node(e.last(J.borderRight));J.width=Math.abs(me.x-pe.x),J.height=Math.abs(ie.y-V.y),J.x=pe.x+J.width/2,J.y=V.y+J.height/2}}),e.forEach(W.nodes(),function(U){W.node(U).dummy==="border"&&W.removeNode(U)})}function D(W){e.forEach(W.edges(),function(U){if(U.v===U.w){var J=W.node(U.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:U,label:W.edge(U)}),W.removeEdge(U)}})}function Y(W){var U=y.buildLayerMatrix(W);e.forEach(U,function(J){var V=0;e.forEach(J,function(ie,pe){var me=W.node(ie);me.order=pe+V,e.forEach(me.selfEdges,function(Ie){y.addDummyNode(W,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:me.rank,order:pe+ ++V,e:Ie.e,label:Ie.label},"_se")}),delete me.selfEdges})})}function P(W){e.forEach(W.nodes(),function(U){var J=W.node(U);if(J.dummy==="selfedge"){var V=W.node(J.e.v),ie=V.x+V.width/2,pe=V.y,me=J.x-ie,Ie=V.height/2;W.setEdge(J.e,J.label),W.removeNode(U),J.label.points=[{x:ie+2*me/3,y:pe-Ie},{x:ie+5*me/6,y:pe-Ie},{x:ie+me,y:pe},{x:ie+5*me/6,y:pe+Ie},{x:ie+2*me/3,y:pe+Ie}],J.label.x=J.x,J.label.y=J.y}})}function G(W,U){return e.mapValues(e.pick(W,U),Number)}function de(W){var U={};return e.forEach(W,function(J,V){U[V.toLowerCase()]=J}),U}return Zw}var Jw,cC;function TU(){if(cC)return Jw;cC=1;var e=vt(),t=vn(),n=mr().Graph;Jw={debugOrdering:s};function s(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(d){c.setNode(d,{label:d}),c.setParent(d,"layer"+a.node(d).rank)}),e.forEach(a.edges(),function(d){c.setEdge(d.v,d.w,{},d.name)}),e.forEach(l,function(d,h){var p="layer"+h;c.setNode(p,{rank:"same"}),e.reduce(d,function(f,m){return c.setEdge(f,m,{style:"invis"}),m})}),c}return Jw}var ev,uC;function AU(){return uC||(uC=1,ev="0.8.5"),ev}var tv,dC;function RU(){return dC||(dC=1,tv={graphlib:mr(),layout:CU(),debug:TU(),util:{time:vn().time,notime:vn().notime},version:AU()}),tv}var MU=RU();const hC=zv(MU),di=240,fd=130,ni=74,Wd=72,fC=ni+Wd;function IU(e,t){var s;let n=di;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??di);return n}const YA=420,$U=2;function zl(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function OU(e,t){return((t==null?void 0:t.get(e))??0)>0?YA:0}function PU(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ul(e,t,n){const s=t.get(e);return{w:((s==null?void 0:s.width)??di)+OU(e,n),h:Math.max((s==null?void 0:s.height)??fd,PU(e,n))}}function LU(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function DU(e,t,n,s,a,l){const c=new hC.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const d=e.filter(x=>!a.has(x)),h=new Set(d);for(const x of d){const{w:N,h:E}=Ul(x,s,l);c.setNode(x,{width:N,height:E})}for(const x of t)h.has(x.source)&&h.has(x.target)&&c.setEdge(x.source,x.target);hC.layout(c);const p=new Map;let f=1/0,m=1/0,y=-1/0,v=-1/0;for(const x of d){const N=c.node(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??di,R=(E==null?void 0:E.height)??fd,I=Ul(x,s,l),$=N.x-I.w/2,F=N.y-I.h/2;p.set(x,{x:$,y:F}),$<f&&(f=$),F<m&&(m=F),$+C>y&&(y=$+C),F+R>v&&(v=F+R)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[x,N]of p)p.set(x,{x:N.x-f,y:N.y-m});const j=Number.isFinite(y)?y-f:0,_=Number.isFinite(v)?v-m:0;let S=null;for(const x of e){const N=a.get(x);if(!N)continue;const E=s.get(x),C=(E==null?void 0:E.width)??di,R=(E==null?void 0:E.height)??fd;S=S===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+R}:{minX:Math.min(S.minX,N.x),minY:Math.min(S.minY,N.y),maxX:Math.max(S.maxX,N.x+C),maxY:Math.max(S.maxY,N.y+R)}}return{positions:p,width:j,height:_,pinnedBox:S}}function qU(e,t,n={}){const s=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,d=new Map;for(const x of e){const N=zl(x),E=d.get(N);E?E.push(x.id):d.set(N,[x.id])}const p=Array.from(d.keys()).sort().map(x=>({sid:x,...DU(d.get(x),t,s,l,a,c)})),f=IU(e,l),m=n.availableHeight&&n.availableHeight>0?n.availableHeight:Number.POSITIVE_INFINITY,y=x=>{const N=[[]];let E=0;for(const C of p)N.length<x&&E>0&&E+C.height>m&&(N.push([]),E=0),N[N.length-1].push(C),E+=C.height+fC;return N},v=x=>x.reduce((N,E)=>Math.max(N,E.width),0)+YA;let j=y(n.availableWidth?$U:1);j.length>1&&j.reduce((N,E)=>N+v(E),0)+f*(j.length-1)>(n.availableWidth??0)&&(j=y(1));const _=new Map;let S=0;for(const x of j){const N=v(x);let E=0;for(const{positions:C,height:R,pinnedBox:I}of x){for(const[F,O]of C)_.set(F,{x:O.x+S,y:O.y+E});let $=E+R;I&&I.maxY>$&&I.minX<S+N&&S<I.maxX&&($=I.maxY),E=$+fC}S+=N+f}return e.map(x=>{const N=a.get(x.id);if(N)return{...x,position:N};const E=_.get(x.id);return E?{...x,position:E}:x})}function FU(e,t,n,s,a){const c=ni+Wd,d=60,h=v=>Ul(v,s,a),p=new Map(e.map(v=>[v.id,zl(v)])),f=[],m=e.map(v=>({id:v.id,pos:n.get(v.id)??t.get(v.id)})).filter(v=>v.pos!=null).sort((v,j)=>v.pos.y-j.pos.y||v.pos.x-j.pos.x||v.id.localeCompare(j.id)),y=[];for(const{id:v,pos:j}of m){const{w:_,h:S}=h(v),x=p.get(v)??"_default";if(n.has(v)){f.push({x:j.x,y:j.y,w:_,h:S,sid:x});continue}let N=j.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===x?24:d,$=R.sid===x?24:c;return j.x<R.x+R.w+I&&R.x<j.x+_+I&&N<R.y+R.h+$&&R.y<N+S+$});if(!C)break;N=C.y+C.h+(C.sid===x?24:c)}N!==j.y&&(t.set(v,{x:j.x,y:N}),y.push(v)),f.push({x:j.x,y:N,w:_,h:S,sid:x})}return y}function BU(e,t,n,s,a,l){const c=_=>Ul(_,s,l),d=_=>n.get(_)??t.get(_),h=new Map;for(const _ of e){if(!d(_.id))continue;const S=zl(_),x=h.get(S);x?x.push(_):h.set(S,[_])}const p=new Set;for(const[_,S]of h)S.every(x=>a.has(x.id)&&!n.has(x.id))&&p.add(_);const f=new Map,m=[];for(const _ of e){const S=d(_.id);if(!S)continue;const{w:x,h:N}=c(_.id),E=zl(_);p.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:S.x,y:S.y,w:x,h:N})}if(f.size===0)return[];const y=ni+Wd,v=(_,S,x,N)=>m.some(E=>_<E.x+E.w+ni&&E.x<_+x+ni&&S<E.y+E.h+y&&E.y<S+N+y),j=[];for(const _ of[...f.keys()].sort()){const S=f.get(_);let x=1/0,N=1/0,E=-1/0,C=-1/0;for(const L of S){const H=d(L.id),{w:B,h:A}=c(L.id);x=Math.min(x,H.x),N=Math.min(N,H.y),E=Math.max(E,H.x+B),C=Math.max(C,H.y+A)}const R=E-x,I=C-N,$=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,H)=>L-H),F=$.length?$:[x],O=[0,...m.map(L=>L.y+L.h+y)].sort((L,H)=>L-H);let M=null;e:for(const L of F)for(const H of O){if(H>=N)break;if(!v(L,H,R,I)){M={x:L,y:H};break e}}if(M){const L=M.x-x,H=M.y-N;for(const B of S){const A=d(B.id);t.set(B.id,{x:A.x+L,y:A.y+H})}j.push(_)}for(const L of S){const H=d(L.id),{w:B,h:A}=c(L.id);m.push({x:H.x,y:H.y,w:B,h:A})}}return j}function zU(e,t,n,s,a,l=!1,c){const p=ni+Wd+1,f=8,m=1.75,y=200,v=.7,j=.01,_=M=>Ul(M,s,c),S=M=>n.get(M)??t.get(M),x=new Map;for(const M of e){if(!S(M.id))continue;const L=zl(M),H=x.get(L);H?H.push(M):x.set(L,[M])}const N=[],E=new Set,C=new Set,R=a.size===0;for(const M of[...x.keys()].sort()){const L=x.get(M);let H=1/0,B=1/0,A=-1/0,Q=-1/0,K=!1;for(const Y of L){const P=S(Y.id),{w:G,h:de}=_(Y.id);H=Math.min(H,P.x),B=Math.min(B,P.y),A=Math.max(A,P.x+G),Q=Math.max(Q,P.y+de),n.has(Y.id)&&(K=!0)}const ee=A-H,Z=Q-B;C.add(M);const D=a.get(M);D&&(ee>D.w+f||Z>D.h+f)&&E.add(M),a.set(M,{w:ee,h:Z}),N.push({sid:M,members:L.map(Y=>Y.id),x:H,y:B,w:ee,h:Z,anchored:K,mass:1})}for(const M of[...a.keys()])C.has(M)||a.delete(M);if(l||R)return[];let I=!1;for(let M=0;M<N.length&&!I;M++)for(let L=M+1;L<N.length;L++){const H=N[M],B=N[L];if(!(H.anchored&&B.anchored)&&Math.abs(H.x+H.w/2-(B.x+B.w/2))<(H.w+B.w)/2+61&&Math.abs(H.y+H.h/2-(B.y+B.h/2))<(H.h+B.h)/2+p){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const M of N)E.has(M.sid)&&(M.mass=8);else for(const M of N)M.mass=Math.max(1,M.w*M.h/(di*fd));const $=new Map(N.map(M=>[M.sid,M.x])),F=new Map(N.map(M=>[M.sid,M.y]));for(let M=0;M<y;M++){const L=new Map,H=new Map;let B=0;for(let A=0;A<N.length;A++)for(let Q=A+1;Q<N.length;Q++){const K=N[A],ee=N[Q];if(K.anchored&&ee.anchored)continue;const Z=K.x+K.w/2,D=K.y+K.h/2,Y=ee.x+ee.w/2,P=ee.y+ee.h/2,G=(K.w+ee.w)/2+61-Math.abs(Z-Y),de=(K.h+ee.h)/2+p-Math.abs(D-P);if(G<=0||de<=0)continue;const W=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.x<=0),U=(Xe,he)=>!Xe.anchored&&!(he<0&&Xe.y<=0),J=(Xe,he,ge)=>{const Se=Xe===he,Fe=Se?K.sid<ee.sid?-1:1:Math.sign(Xe-he);return ge(K,Fe)||ge(ee,-Fe)?Fe:Se&&(ge(K,-Fe)||ge(ee,Fe))?-Fe:0},V=J(Z,Y,W),ie=J(D,P,U),pe=V!==0,me=ie!==0;if(!pe&&!me)continue;const Ie=pe&&(!me||G*m<de),[Le,ce,xe,ye]=Ie?[V,G,L,W]:[ie,de,H,U],ze=ye(K,Le),ke=ye(ee,-Le),je=K.mass,Ye=ee.mass,it=ze?ke?Ye/(je+Ye):1:0,Ne=ke?ze?je/(je+Ye):1:0,He=ce*v;xe.set(K.sid,(xe.get(K.sid)??0)+Le*He*it),xe.set(ee.sid,(xe.get(ee.sid)??0)-Le*He*Ne),B+=He}for(const A of N)A.anchored||(A.x=Math.max(0,A.x+(L.get(A.sid)??0)),A.y=Math.max(0,A.y+(H.get(A.sid)??0)));if(B<j)break}const O=[];for(const M of N){const L=M.x-$.get(M.sid),H=M.y-F.get(M.sid);if(!(Math.abs(L)<1&&Math.abs(H)<1)){for(const B of M.members){if(n.has(B))continue;const A=t.get(B);A&&t.set(B,{x:A.x+L,y:A.y+H})}O.push(M.sid)}}return O}const UU=600;function Dv(e,t){return!(e.exitAt!=null&&t-e.exitAt>UU||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function WU(e,t){const n=new Set;for(const s of e.agents.values())Dv(s,t)&&n.add(s.id);return n}function HU(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 GU(e,t,n=0){if(!e)return!1;for(const s of t)if(HU(e,s,n))return!0;return!1}const KA="sessionGroup";function VU(e,t){var s;if(e.type===KA)return"transparent";const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const XA=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function pC(e){const t={};for(const n of XA)t[n]=e(n);return t}function YU(e){return t=>e[t]??""}function KU(e,t){return XA.every(n=>e[n]===t[n])}function XU(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,l]of e.positions)n.set(a,l),t.has(a)&&s.set(a,l);return{positions:n,pinned:s}}const QU=1200,ZU=1e3;function mC(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<QU?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<ZU}function nv({durationMs:e,documentHidden:t}){return t?!1:Number.isFinite(e)&&e>0}function JU(e,t,n){const s=e.x*t.zoom+t.x,a=e.y*t.zoom+t.y,l=(e.x+e.width)*t.zoom+t.x,c=(e.y+e.height)*t.zoom+t.y;return l>0&&s<n.width&&c>0&&a<n.height}function eW({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,JU(a,t,e))return!1;return s}const tW="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",rv="click for what's new";function nW(e){if(e.checkDisabled)return`${tW} · ${rv}`;if(e.checking)return`Asking npm for the newest release… · ${rv}`;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.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${rv}, and to check npm now`}function rW(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`:`${t} and check npm for a newer release`}function sW(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 aW(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."}}const qv={kind:"assumed",claude:!0,codex:!0};function oW(e){if(!e||typeof e!="object")return qv;const t=e.providers;if(!t||typeof t!="object")return qv;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function pd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const gC=99;function iW(e){const t=Math.max(0,Math.floor(e));return t>gC?`${gC}+`:String(t)}const lW="Pause the canvas";function cW(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${pd(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${pd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function uW(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 QA="paused · full",dW=(e,t)=>t>0?QA:e>0?`paused · ${iW(e)}`:"paused";function hW(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:dW(e.held,t),widest:QA,title:t>0?`Connected — the pause is full at ${pd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${pd(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function yC(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const fW={agent:hL,sessionGroup:TL},ZA="react-flow__node";function wC(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,ZA))===!0}function pW(e){try{const t=document.querySelector(`.${ZA}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const mW=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),gW=420;function yW(e){return e<.35?"far":e<.55?"mid":"full"}const qu=18,wW=200,vW=5*6e4,xW=6,bW=2*6e4,vC=400,zx="agent-dag.layout",Ux="agent-dag.viewport",JA="agent-dag.summariesDismissed",eR="agent-dag.sessionListOpen",tR="agent-dag.detailOpen",nR="agent-dag.usagePanelOpen",rR="agent-dag.systemPanelOpen",xC="agent-dag.accountsPanelOpen",sv="agent-dag.versionNoticeDismissed",bC="agent-dag.oldNameNoticeDismissed",kW=15*6e4,av={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},Fu="agent-dag.autoRestart",kC="agent-dag.bundleReloadedFor";function _W(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eR)==="1"}catch{return!1}}function NW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eR,e?"1":"0")}catch{}}function SW(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tR)==="1"}catch{return!1}}function jW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tR,e?"1":"0")}catch{}}function EW(){const e=fi(nR);return e===null?!0:e==="1"}function CW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nR,e?"1":"0")}catch{}}function TW(){const e=fi(rR);return e===null?!0:e==="1"}function AW(e){if(!(typeof window>"u"))try{window.localStorage.setItem(rR,e?"1":"0")}catch{}}function RW(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(JA);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function _C(e){if(!(typeof window>"u"))try{const t=Array.from(e),n=t.length>200?t.slice(-200):t;window.localStorage.setItem(JA,JSON.stringify(n))}catch{}}function MW(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(zx);if(!t)return e;const n=JSON.parse(t);if(!("v"in n)){const a=Object.entries(n).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:a,pins:a.map(([l])=>l)}}return{positions:Object.entries(n.positions??{}).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number"),pins:Array.isArray(n.pins)?n.pins:[]}}catch{return e}}function ov(e,t){if(!(typeof window>"u"))try{const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;window.localStorage.setItem(zx,JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())}))}catch{}}function IW(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ux);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function $W(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ux,JSON.stringify(e))}catch{}}function NC(){if(!(typeof window>"u")){try{window.localStorage.removeItem(zx)}catch{}try{window.localStorage.removeItem(Ux)}catch{}}}function OW(e,t){const n=e.agents.get(t);if(!n)return;const s=[];for(const f of e.agents.values())f.sessionId===t&&s.push(f);const a={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:n.label,cwd:n.cwd,startedAt:n.startedAt,endedAt:n.endedAt,model:n.model,agents:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(a,null,2),c=new Blob([l],{type:"application/json"}),d=URL.createObjectURL(c),h=document.createElement("a"),p=(n.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=d,h.download=`${Wt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(d),1e3)}const Fv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Bv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},sR=u2;function PW(e,t,n,s,a,l,c,d,h,p,f,m,y,v,j,_,S,x){const N=[],E=[];for(const M of e.agents.values()){if(!S.has(M.id))continue;const L=M.exitAt!=null,H=_!=null&&!_.has(M.id),B=[L?"rf-exiting":"",H?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=l.get(M.id);if(N.push({id:M.id,type:"agent",position:{x:0,y:0},data:{...M,now:t,onOpenContext:x},className:B,...A?{width:A.width,height:A.height}:null}),M.parentId&&S.has(M.parentId)){const Q=ix(M.sessionId),K=L,ee=j.size>0&&(j.has(M.id)||j.has(M.parentId)),Z=_!=null&&!_.has(M.id)&&!_.has(M.parentId),D=M.state==="active"?2:1.5,Y=ee?D+1.5:D,P=K?.2:Z?.12:1,G=["sess-edge",M.state==="active"?"sess-live":"sess-idle",K?"rf-edge-exiting":"",ee?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||ee)&&!K,type:"smoothstep",style:{"--session-hue":Q,strokeWidth:Y,opacity:P,transition:"var(--edge-transition)"},className:G})}}const C=new Map;for(const M of e.agents.values())M.tools.length>0&&C.set(M.id,Math.min(4,M.tools.length));const R=`${y}#lanes:${LU(C)}`,I=N.filter(M=>TF(M.id,a,f,m));if(I.length>0||R!==v.current){if(I.length>0){const M=qU(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:s,lanes:C});for(const L of M)H2(L.id,f,m)&&RF(L.id,L.position,f,m);BU(N,f,a,l,new Set(I.map(L=>L.id)),C)}FU(N,f,a,l,C),v.current=R}const $=zU(N,f,a,l,c,!h||p,C);$.length>0&&d($),Iu(f,e.agents),Iu(m,e.agents),Iu(a,e.agents),Iu(l,jF(e.agents.values()));const F=[];let O=!1;for(const M of N){let L=a.get(M.id)??f.get(M.id);L||(L=AF(M.id,f,m),O=!0),F.push({...M,position:L})}return O&&(v.current=""),{nodes:F,edges:E}}function LW(){return i.jsx(ax,{children:i.jsx(DW,{})})}function DW(){var Gi,Vi,Yi,Ki;const e=Yl(),t=Rt(),n=b.useState(_v)[0],s=b.useRef(n),[,a]=b.useState(0),l=b.useCallback(()=>a(q=>q+1),[]),[c,d]=b.useState(()=>new Set),[h,p]=b.useState(null),[f,m]=b.useState(null),y=b.useCallback((q,z)=>{d(se=>{if(!z)return new Set([q]);const oe=new Set(se);return oe.has(q)?oe.delete(q):oe.add(q),oe}),p(se=>z&&se===q?se:q)},[]),v=b.useCallback(()=>{d(new Set),p(null)},[]),[j,_]=b.useState(null),[S,x]=b.useState(null),N=b.useCallback(q=>x(q),[]),[E,C]=b.useState(!1),[R,I]=b.useState(!1),[$,F]=b.useState(!1),O=b.useRef(null),M=b.useState(RW)[0],[L,H]=b.useState(_W);b.useEffect(()=>{NW(L)},[L]);const[B,A]=b.useState(SW);b.useEffect(()=>{jW(B)},[B]);const[Q,K]=b.useState(EW);b.useEffect(()=>{CW(Q)},[Q]);const[ee,Z]=b.useState(TW);b.useEffect(()=>{AW(ee)},[ee]);const[D,Y]=b.useState(()=>{try{const q=window.localStorage.getItem(xC);return q===null?!0:q==="1"}catch{return!0}});b.useEffect(()=>{try{window.localStorage.setItem(xC,D?"1":"0")}catch{}},[D]);const P=Of(D,200),G=Of(Q,130),de=Of(ee,130),[W,U]=b.useState(null);b.useEffect(()=>{let q=null;try{q=localStorage.getItem("agent-dag.sound")}catch{}U(q===null?!0:q==="on")},[]);const J=b.useCallback(()=>{U(q=>{var se;const z=q!==!0;try{localStorage.setItem("agent-dag.sound",z?"on":"off")}catch{}return z&&((se=Ye.current)==null||se.unlock()),z})},[]),V=b.useCallback(q=>{J()},[J]),ie=b.useRef(V);ie.current=V;const pe=b.useRef(W);pe.current=W;const[me,Ie]=b.useState(()=>Uq(fi)),Le=b.useRef(me);Le.current=me;const ce=b.useRef(null),xe=b.useCallback((q,z=!1)=>{var se,oe;if((se=Ye.current)==null||se.unlock(),ce.current!==null&&clearTimeout(ce.current),ce.current=null,!z){(oe=Ye.current)==null||oe.play(q,!0);return}ce.current=setTimeout(()=>{var Ee;ce.current=null,(Ee=Ye.current)==null||Ee.play(q,!0)},Dq)},[]),ye=b.useCallback((q,z)=>{Ie(se=>{const oe={level:Bl(z.level??se[q].level),figure:D2(q,z.figure??se[q].figure)};try{localStorage.setItem(q2[q],String(oe.level)),localStorage.setItem(F2[q],oe.figure)}catch{}return{...se,[q]:oe}}),xe(q,!0)},[xe]);b.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const[ze,ke]=b.useState(!1),je=b.useRef(null),Ye=b.useRef(null),[it,Ne]=b.useState("locked");b.useEffect(()=>{const q=Gq({enabled:()=>pe.current===!0,prefs:()=>Le.current,onState:Ne});Ye.current=q,Ne(q.state());const z=()=>q.unlock();return window.addEventListener("pointerdown",z,{once:!0,capture:!0}),window.addEventListener("keydown",z,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",z,{capture:!0}),window.removeEventListener("keydown",z,{capture:!0})}},[]);const[He,Xe]=b.useState(!1),[he,ge]=b.useState(null),[Se,Fe]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(sv)??""}catch{return""}}),[et,xt]=b.useState(!1),ht=b.useRef(0),[ne,De]=b.useState(!1),Oe=b.useCallback((q=!1)=>(q&&(ht.current=Date.now(),De(!0)),fetch(q?"/api/version?refresh=1":"/api/version").then(z=>z.ok?z.json():null).then(z=>{z&&ge(z)}).catch(()=>{}).finally(()=>{q&&De(!1)})),[]),Te=b.useCallback(()=>{Oe(Date.now()-ht.current>=kW)},[Oe]);b.useEffect(()=>{Oe();const q=window.setInterval(Te,5*6e4),z=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",z),()=>{window.clearInterval(q),document.removeEventListener("visibilitychange",z)}},[Oe,Te]),b.useEffect(()=>{He&&Oe()},[He,Oe]),b.useEffect(()=>{const q=tF();let z=null;const se=We=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:q,looking:We}),keepalive:!0}).catch(()=>{})},oe=()=>{const We=Jq(document);eF(z,We)&&se(We),z=We},Ee=()=>{z&&se(!1),z=!1};oe();const Me=window.setInterval(oe,Zq);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",Ee),()=>{window.clearInterval(Me),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",Ee),Ee()}},[]);const Ce=(he==null?void 0:he.notice)??null,[lt,ut]=b.useState(null),Re=b.useRef(!1);b.useEffect(()=>{if(Re.current)return;const q=q1(),z=uF(q),se=gF({stored:z,running:(he==null?void 0:he.running)??null,notes:D1,remembers:dF(q)});if(se.reason==="no-version")return;Re.current=!0,se.record&&hF(q,se.record);const oe=mF({tourSeen:fF(q),decision:se}),Ee=se.show.length?{entries:se.show,since:z,firstRun:!1}:null;oe.tour&&F(!0),oe.notes==="now"?ut(Ee):oe.notes==="after"&&(O.current=Ee)},[he==null?void 0:he.running]);const mt=(he==null?void 0:he.running)??"3.22.6",ft=b.useMemo(()=>B2(D1,null,mt),[mt]),bt=b.useCallback(()=>{ut({entries:ft,since:null,firstRun:!1})},[ft]),[Xn,Tn]=b.useState(null),[ln,to]=b.useState(qv);b.useEffect(()=>{let q=!1;return fetch("/api/health").then(z=>z.ok?z.json():null).then(z=>{q||(to(oW(z)),!(!z||typeof z.workspace!="string")&&Tn(z.workspace))}).catch(()=>{}),()=>{q=!0}},[He]);const ds=b.useRef(ln);ds.current=ln;const Or=Ce?`${Ce.kind}:${Ce.to}`:"",Qn=Ce!=null&&Se!==Or,no=b.useCallback(()=>{Fe("");try{window.localStorage.setItem(sv,"")}catch{}},[]),Pr=b.useCallback(()=>{if(Ce){Fe(Or);try{window.localStorage.setItem(sv,Or)}catch{}}},[Ce,Or]),[Zs,Lr]=b.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(bC)??""}catch{return""}}),An=he!=null&&he.invokedAs&&he.invokedAs!==Wt?he.invokedAs:null,Dr=An!=null&&Zs!==An,hs=b.useCallback(()=>{if(An){Lr(An);try{window.localStorage.setItem(bC,An)}catch{}}},[An]),qt=((Gi=he==null?void 0:he.upgrade)==null?void 0:Gi.state)??"idle",wr=yq(he==null?void 0:he.upgrade),Js=b.useRef(!1),vi=b.useCallback(async()=>{if(hr(Js.current||qt==="running")){Js.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Oe(),Js.current=!1}},[qt,Oe]);b.useEffect(()=>{if(qt!=="running")return;const q=window.setInterval(Oe,3e3);return()=>window.clearInterval(q)},[qt,Oe]);const ro=b.useCallback(async()=>{const q=he==null?void 0:he.command;!q||!await L2(q)||(xt(!0),window.setTimeout(()=>xt(!1),1600))},[he==null?void 0:he.command]),Rn=b.useCallback(()=>{H(q=>(q||Y(!1),!q))},[]),ea=b.useCallback(()=>{Y(q=>(q||H(!1),!q))},[]),[ta,na]=b.useState(!1),[ra,sa]=b.useState(!1),[aa,so]=b.useState(()=>{try{return Number(localStorage.getItem(U1))||0}catch{return 0}}),[oa,xi]=b.useState([]),[dt,ao]=b.useState(!1);b.useEffect(()=>{let q=!0;const z=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var Ee;!q||!(oe!=null&&oe.ok)||(xi(oe.episodes??[]),ao(((Ee=oe.settings)==null?void 0:Ee.enabled)===!0))}).catch(()=>{})};z();const se=setInterval(z,5*6e4);return()=>{q=!1,clearInterval(se)}},[]);const[ia,qr]=b.useState([]),Fr=b.useRef(new Set),[Br,la]=b.useState(null);b.useEffect(()=>{let q=!0,z=0;const se=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>q?(oe!=null&&oe.ok&&qr(E1(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{q&&(z=window.setTimeout(se,(oe==null?void 0:oe.enabled)===!0?$v:I2))})};return se(),()=>{q=!1,window.clearTimeout(z)}},[]);const zr=b.useCallback(async(q,z)=>{if(!Br){la(q);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:q,fp:z})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?qr(E1(oe.pending,oe.aliases)):qr(Ee=>Ee.filter(Me=>Me.fp!==z))}catch{}finally{la(null)}}},[Br]),It=b.useMemo(()=>a8(oa,aa).length,[oa,aa]),[ca,cn]=b.useState(0),oc=b.useRef(null),[Hd,ic]=b.useState(!1),vr=b.useRef(null),[oo,fs]=b.useState(0),Xt=b.useState(()=>PF({protect:q=>y4(s.current,q)}))[0],[io,Gd]=b.useState(!1),ua=b.useCallback(()=>{const q=Xt.paused&&Xt.dropped>0,z=Xt.setPaused(!Xt.paused);q&&w4(s.current);for(const se of z)s.current=Mk(s.current,se);Gd(Xt.paused)},[Xt]),[Et,bi]=b.useState(Date.now()),[rn,lo]=b.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Fu)!=="0"}catch{return!0}}),co=b.useRef(!1),at=b.useCallback(()=>{const q=!rn;co.current=!0;try{window.localStorage.removeItem(Fu)}catch{}lo(q),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&lo(((se=z.prefs)==null?void 0:se.autoUpdate)!==!1)}).catch(()=>{})},[rn]),[Zn,da]=b.useState(!1),[ki,lc]=b.useState("restart"),[_i,Ni]=b.useState(null),xr=b.useRef(!1),ha=b.useRef(null),Jn=b.useRef(0),xn=b.useCallback(async q=>{if(!hr(xr.current))return;const z=(q==null?void 0:q.upgrade)===!0;xr.current=!0,ha.current=wr;const se=++Jn.current;lc(z?"npx":"restart"),da(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(Ce==null?void 0:Ce.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:z})})}catch{}window.setTimeout(()=>{if(Jn.current===se&&xr.current){xr.current=!1,da(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},z?18e4:3e4)},[Ce==null?void 0:Ce.to,wr]),Mn=b.useRef(null);b.useEffect(()=>{const q=I1(s.current.agents.values())>0,z=kq({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:q,idleSince:Mn.current,now:Et});Mn.current=z.idleSince,z.restart&&xn()},[rn,Ce==null?void 0:Ce.kind,he==null?void 0:he.canRestart,Qn,Et,xn]);const ps=I1(s.current.agents.values()),ms=bq(ps),er=P2({enabled:rn,kind:Ce==null?void 0:Ce.kind,canRestart:(he==null?void 0:he.canRestart)===!0,noticeOpen:Qn,visible:document.visibilityState==="visible",busy:ps>0,idleSince:Mn.current,now:Et});b.useEffect(()=>{const q=he==null?void 0:he.running;let z=null,se=null;try{z=window.sessionStorage.getItem("agent-dag.restartPending"),se=window.sessionStorage.getItem(kC)}catch{return}const oe=gq({bundle:"3.22.6",running:q,pending:z,lastTried:se});if(oe==="reload"){try{window.sessionStorage.setItem(kC,q??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,da(!1),Ni(q??null);const Ee=window.setTimeout(()=>Ni(null),6e3);return()=>window.clearTimeout(Ee)},[he==null?void 0:he.running]),b.useEffect(()=>{if(Zn&&wq({asked:ha.current,reported:wr})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}xr.current=!1,da(!1)}},[Zn,wr]);const cc=b.useState(()=>XU(MW()))[0],Qt=b.useRef(cc.pinned),br=b.useRef(null),uo=b.useState(()=>IW())[0],[ho,fo]=b.useState(()=>new Set),[gs,uc]=b.useState(DF),[un,fa]=b.useState(()=>pC(yC)),Ur=b.useMemo(()=>YU(un),[un]),po=b.useCallback(q=>VU(q,Ur),[Ur]),Vd=b.useMemo(()=>({background:un["--panel"],border:`1px solid ${un["--line"]}`,borderRadius:8}),[un]),[dc,Si]=b.useState(!1);b.useEffect(()=>{document.documentElement.dataset.theme=gs;try{window.localStorage.setItem(G2,gs)}catch{}fa(q=>{const z=pC(yC);return KU(q,z)?q:z})},[gs]);const In=b.useCallback((q,z)=>{if(nv({durationMs:z,documentHidden:document.hidden})){e.setViewport(q,{duration:z});return}const{d3Zoom:se,d3Selection:oe}=t.getState(),Ee=oe==null?void 0:oe.property("__zoom");if(se&&oe&&Ee&&Ee.k>0&&q.zoom>0){se.transform(oe,Ee.scale(q.zoom/Ee.k).translate((q.x-Ee.x)/q.zoom,(q.y-Ee.y)/q.zoom));return}e.setViewport(q,{duration:0})},[e,t]),Wr=b.useRef(null);b.useEffect(()=>{if(!uo)return;const q=window.setTimeout(()=>{try{In(uo,0)}catch{}bn.current=Date.now()},60);return()=>window.clearTimeout(q)},[In,uo]);const ji=b.useRef(!0);b.useEffect(()=>{const q=new EventSource("/events"),z=$F(l,{now:()=>Date.now(),setTimeout:(se,oe)=>window.setTimeout(se,oe),clearTimeout:se=>window.clearTimeout(se)});return q.addEventListener("open",()=>{Xe(!0),Si(!0)}),q.addEventListener("error",()=>Xe(!1)),q.addEventListener("replay-end",()=>{ji.current=!1,z.flush()}),q.addEventListener("hook",se=>{var oe;try{const Ee=JSON.parse(se.data);if(!Xt.accept(Ee))return;s.current=Mk(s.current,Ee);const Me=Ee.replay===!0||ji.current||Date.now()-Ee.receivedAt>3e4;Me?z.replay():z.live();const We=Hq(Ee,Me);We&&((oe=Ye.current)==null||oe.play(We))}catch{}}),()=>{q.close(),z.cancel()}},[l]),b.useEffect(()=>{const q=setInterval(()=>{const z=Date.now();bi(z);let se=v4(s.current,z,Rk);x4(s.current,z,Rk)&&(se=!0),m4(s.current,z,wW,vW)&&(se=!0),g4(s.current,z,xW,bW)&&(se=!0),d(oe=>SF(oe,s.current.agents)),p(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),x(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),_(oe=>oe!=null&&!s.current.agents.has(oe)?null:oe),se&&l()},250);return()=>clearInterval(q)},[l]);const $n=b.useRef(null),bn=b.useRef(0),mo=420,kn=b.useCallback((q=500)=>{try{const Me=document.querySelector(".canvas-wrap"),We=Array.from(document.querySelectorAll(".react-flow__node")).filter(Ct=>Ct.offsetWidth>0);if(!Me||We.length===0)return;const rt=Me.getBoundingClientRect(),gt=e.getViewport();if(!Number.isFinite(gt.zoom)||gt.zoom<=0)return;const ot=Ct=>(Ct-rt.left-gt.x)/gt.zoom,Qe=Ct=>(Ct-rt.top-gt.y)/gt.zoom,Ss=We.map(Ct=>Ct.getBoundingClientRect()),Ca=Math.min(...Ss.map(Ct=>ot(Ct.left))),Ta=Math.max(...Ss.map(Ct=>ot(Ct.right))),Xi=Math.min(...Ss.map(Ct=>Qe(Ct.top))),Qi=Math.max(...Ss.map(Ct=>Qe(Ct.bottom))),js=Ta-Ca,Es=Qi-Xi;if(!(js>0&&Es>0))return;const Pn=Math.max(.2,Math.min(1,(rt.width-160)/(js+mo)*.86,(rt.height-160)/Es*.86)),Cs={x:80-Ca*Pn,y:Math.max(80,(rt.height-Es*Pn)/2)-Xi*Pn,zoom:Pn};In(Cs,q),bn.current=Date.now(),Wr.current=nv({durationMs:q,documentHidden:document.hidden})?{target:Cs,until:Date.now()+q+60}:null,window.setTimeout(()=>{var Ct;try{((Ct=Wr.current)==null?void 0:Ct.target)===Cs&&(Wr.current=null);const Tc=e.getViewport();(Math.abs(Tc.zoom-Pn)>.01||Math.abs(Tc.x-Cs.x)>2)&&In(Cs,0)}catch{}},q+60)}catch{}},[e,In]);b.useEffect(()=>{const q=()=>{if(!document.hidden)return;const z=Wr.current;if(Wr.current=null,!(!z||Date.now()>z.until)){try{In(z.target,0)}catch{}bn.current=Date.now()}};return document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[In]);const ys=b.useRef(""),ws=b.useRef(null),Ei=b.useRef(0),Ft=b.useCallback(()=>{Ei.current=Date.now()},[]),kr=b.useRef(null),go=b.useRef(0),Hr=b.useCallback(()=>{go.current=Date.now()},[]),hc=b.useCallback(q=>({hasSourceEvent:!!q,at:Date.now(),lastDeckFitAt:bn.current,lastCanvasInputAt:go.current}),[]),pa="agent-dag.autoFitDisabled",yo=b.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(pa)==="1"}catch{return!1}})[0],On=b.useRef(yo),[ma,Ci]=b.useState(yo),Ti=b.useCallback(()=>{if(!On.current){On.current=!0,Ci(!0);try{window.localStorage.setItem(pa,"1")}catch{}}},[]),Yd=b.useCallback(()=>{On.current=!1,Ci(!1);try{window.localStorage.removeItem(pa)}catch{}kn(400)},[e,kn]);b.useEffect(()=>{const q=setInterval(()=>{if(On.current||Date.now()-Ei.current<800)return;const z=s.current,se=Date.now(),oe=[];for(const Me of z.agents.values())Dv(Me,se)&&oe.push({id:Me.id});if(oe.length===0)return;const Ee=[];for(const{id:Me}of oe){const We=_r.current.get(Me),rt=Qt.current.get(Me)??sn.current.get(Me);!We||!rt||Ee.push({x:rt.x,y:rt.y,width:We.width,height:We.height})}eW({pane:kr.current,viewport:e.getViewport(),boxes:Ee})&&kn(600)},1500);return()=>clearInterval(q)},[e]);const Ai=b.useRef(!1),_r=b.useRef(new Map),fc=b.useRef(0),Kd=b.useCallback(q=>{const z=_r.current;let se=!1;for(const oe of q.nodeInternals.values()){const Ee=oe.width,Me=oe.height;if(Ee==null||Me==null)continue;const We=z.get(oe.id);We?(Math.abs(We.height-Me)>4||Math.abs(We.width-Ee)>4)&&(z.set(oe.id,{width:Ee,height:Me}),se=!0):(z.set(oe.id,{width:Ee,height:Me}),se=!0)}return se&&(fc.current+=1),fc.current},[]),pc=ct(Kd),[mc,Xd]=b.useState(0);b.useEffect(()=>{let q=0;const z=()=>{const oe=_r.current;let Ee=!1;for(const Me of document.querySelectorAll(".react-flow__node[data-id]")){const We=Me.getAttribute("data-id");if(!We)continue;const rt=Me.offsetWidth,gt=Me.offsetHeight;if(!rt||!gt)continue;const ot=oe.get(We);(!ot||Math.abs(ot.width-rt)>4||Math.abs(ot.height-gt)>4)&&(oe.set(We,{width:rt,height:gt}),Ee=!0)}Ee&&Xd(Me=>Me+1)};if(Ai.current)return;let se=0;return document.visibilityState==="hidden"?se=window.setTimeout(z,32):q=requestAnimationFrame(z),()=>{cancelAnimationFrame(q),window.clearTimeout(se)}});const sn=b.useRef(cc.positions),Qd=b.useRef(new Set),Ri=b.useRef(""),vs=b.useMemo(()=>{const q=[];for(const z of s.current.agents.values())Dv(z,Et)&&q.push(z.id+(z.parentId?`>${z.parentId}`:""));return q.sort(),`${q.join("|")}#sv${pc}.${mc}`},[s.current,s.current.revision,Et,pc,mc]),ga=b.useRef(null);b.useEffect(()=>(ga.current!=null&&window.clearTimeout(ga.current),ga.current=window.setTimeout(()=>{ov(sn.current,Qt.current)},1500),()=>{ga.current!=null&&window.clearTimeout(ga.current)}),[vs]),b.useEffect(()=>{if(ys.current===vs)return;const q=ys.current;if(ys.current=vs,!q||On.current)return;Date.now()-bn.current>1200&&kn(400),$n.current&&window.clearTimeout($n.current),$n.current=window.setTimeout(()=>{On.current||kn(500)},280)},[vs,e,kn]);const ya=b.useMemo(()=>CF(s.current,c),[s.current,s.current.revision,c]),Mi=b.useMemo(()=>WU(s.current,Et),[s.current,s.current.revision,Et]),gc=b.useRef(null),[wo,Ii]=b.useState({w:0,h:0});b.useEffect(()=>{const q=gc.current;if(!q||typeof ResizeObserver>"u")return;const z=new ResizeObserver(se=>{var Ee;const oe=(Ee=se[0])==null?void 0:Ee.contentRect;oe&&(kr.current={width:oe.width,height:oe.height},Ii(Me=>Math.abs(Me.w-oe.width)>40||Math.abs(Me.h-oe.height)>40?{w:oe.width,h:oe.height}:Me))});return z.observe(q),kr.current={width:q.clientWidth,height:q.clientHeight},Ii({w:q.clientWidth,h:q.clientHeight}),()=>z.disconnect()},[]);const Zd=b.useCallback(q=>{var se,oe;const z=q.target;!(z!=null&&z.closest)||z.closest(mW)!==q.currentTarget||(q.preventDefault(),(oe=(se=document.activeElement)==null?void 0:se.blur)==null||oe.call(se))},[]),Jd=b.useRef(new Map),[yc,eh]=b.useState(!1);b.useEffect(()=>{const q=window.setTimeout(()=>eh(!0),2500);return()=>window.clearTimeout(q)},[]);const[th,$i]=b.useState(!1),Nr=b.useRef(null),[wa,xs]=b.useState(!1),[nh,wc]=b.useState("full"),Oi=b.useRef("full"),vc=b.useCallback(()=>{Nr.current&&(window.clearTimeout(Nr.current),Nr.current=null),$i(!1)},[]),xc=b.useCallback(q=>{q.length!==0&&queueMicrotask(()=>{$i(!0),Nr.current&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>$i(!1),gW+80)})},[]);b.useEffect(()=>()=>{Nr.current&&window.clearTimeout(Nr.current)},[]);const Pi=wo.w>0?wo.w*.92:0,Gr=wo.h>0?wo.h:0,{nodes:Sr,edges:rh}=b.useMemo(()=>PW(s.current,Et,Pi,Gr,Qt.current,_r.current,Jd.current,xc,yc,wa,sn.current,Qd.current,vs,Ri,c,ya,Mi,N),[s.current,s.current.revision,Et,Pi,Gr,yc,wa,vs,c,ya,Mi,N,ca]),bc=b.useMemo(()=>{const q=new Map;for(const se of Sr){const oe=se.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const Ee=se.width,Me=se.height;if(Ee==null||Me==null)continue;const We=se.position.x,rt=se.position.y,gt=We+Ee,ot=rt+Me,Qe=q.get(oe.sessionId);Qe?(Qe.minX=Math.min(Qe.minX,We),Qe.minY=Math.min(Qe.minY,rt),Qe.maxX=Math.max(Qe.maxX,gt),Qe.maxY=Math.max(Qe.maxY,ot)):q.set(oe.sessionId,{minX:We,minY:rt,maxX:gt,maxY:ot})}const z=[];for(const[se,oe]of q){const Ee=oe.maxX-oe.minX+qu*2,Me=oe.maxY-oe.minY+qu*2;z.push({id:`group:${se}`,type:KA,position:{x:oe.minX-qu,y:oe.minY-qu},data:{sessionId:se,w:Ee,h:Me},width:Ee,height:Me,style:{width:Ee,height:Me},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return z},[Sr,Et]),kc=b.useMemo(()=>{const q=[...bc,...Sr],z=vr.current;return!z||z.size===0?q:q.map(se=>{const oe=z.get(se.id);return oe?{...se,position:oe}:se})},[bc,Sr,oo]),va=b.useMemo(()=>{const q=new Set;for(const z of s.current.agents.values())for(const se of z.tools)q.add(sR(se.name));return Object.keys(Fv).filter(z=>q.has(z))},[s.current,s.current.revision]);b.useEffect(()=>{if(va.length<=1){ic(!1);return}let q=0;const z=()=>{const se=oc.current;if(se&&!document.hidden){const oe=se.getBoundingClientRect(),Ee=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(We=>We.getBoundingClientRect()),Me=GU(oe,Ee,8);ic(We=>We===Me?We:Me)}q=window.setTimeout(z,300)};return z(),()=>window.clearTimeout(q)},[va.length]);const xa=b.useCallback(q=>{fo(z=>{const se=new Set(z);return se.has(q)?se.delete(q):se.add(q),se})},[]),$t=h?s.current.agents.get(h):null,Li=f?Array.from(s.current.agents.values()).flatMap(q=>q.tools).find(q=>q.id===f)??null:null,ba=b.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}s.current=_v(),Qt.current.clear(),_r.current.clear(),sn.current.clear(),Ri.current="",NC(),v(),l()},[l,v]),_c=b.useRef(E);_c.current=E;const Di=b.useRef(R);Di.current=R;const ka=b.useRef(!1);ka.current=Li!=null||ta||S!=null||$||j!=null||ra||R||lt!=null;const bs=b.useCallback(q=>{const z=_q(q,{confirmOpen:_c.current,modalOpen:ka.current});z==="confirm"?C(!0):z==="clear"&&(C(!1),ba())},[ba]),vo=b.useCallback(()=>{Qt.current.clear(),sn.current.clear(),Ri.current="",NC(),l(),window.setTimeout(()=>kn(500),80)},[l,e,kn]),qi=b.useCallback(()=>kn(500),[kn]),_a=b.useRef(Sr);_a.current=Sr;const Nc=b.useRef(h);Nc.current=h;const Fi=b.useCallback(q=>{const z=_a.current,se=xF(z.map(Me=>({id:Me.id,x:Me.position.x,y:Me.position.y})),Nc.current,q),oe=se?z.find(Me=>Me.id===se):void 0;if(!oe)return;const Ee=wC(document.activeElement);y(oe.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[oe]})}catch{}bn.current=Date.now(),Ee&&pW(oe.id)},30)},[y,e]),Bi=b.useCallback(q=>{y(q,!1),window.setTimeout(()=>{try{const z=_a.current.find(se=>se.id===q);z&&e.fitView({padding:.3,duration:500,nodes:[z]}),bn.current=Date.now()}catch{}},60)},[y,e]);b.useEffect(()=>{const q=z=>{var rt,gt;const se=z.target,oe={tagName:se==null?void 0:se.tagName,isContentEditable:se==null?void 0:se.isContentEditable,role:(rt=se==null?void 0:se.getAttribute)==null?void 0:rt.call(se,"role"),type:se==null?void 0:se.type};if(z.key==="Escape"){const ot=K4({overlayOpen:od.depth()>0,typing:dx(oe)});ot==="dismiss"?od.dismissTop():ot==="blur"?se==null||se.blur():(NF(oe)&&(se==null||se.blur()),v());return}if(ux(z))return;const Ee=wC(se)?(gt=se==null?void 0:se.getAttribute)==null?void 0:gt.call(se,"data-id"):null,Me=Ee&&_a.current.some(ot=>ot.id===Ee)?Ee:null,We=kF(z,Me);if(We.kind==="activate"){z.preventDefault(),y(We.nodeId,We.additive);return}We.kind!=="node"&&(We.nodeId==null&&rL(oe)||sL({key:z.key,modalOpen:ka.current,sheetOpen:Di.current})||(z.key===" "&&(z.preventDefault(),ua()),(z.key==="c"||z.key==="C")&&bs("shortcut"),(z.key==="r"||z.key==="R")&&vo(),(z.key==="f"||z.key==="F")&&qi(),(z.key==="l"||z.key==="L")&&Rn(),(z.key==="d"||z.key==="D")&&A(ot=>!ot),(z.key==="h"||z.key==="H")&&na(ot=>!ot),(z.key==="u"||z.key==="U")&&K(ot=>!ot),(z.key==="a"||z.key==="A")&&ds.current.claude&&ea(),(z.key==="j"||z.key==="J")&&Fi(1),(z.key==="k"||z.key==="K")&&Fi(-1),(z.key==="t"||z.key==="T")&&uc(ot=>ot==="dark"?"light":"dark"),(z.key==="m"||z.key==="M")&&ds.current.claude&&pe.current!==null&&ie.current(z.shiftKey),z.key==="?"&&I(ot=>!ot)))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[bs,vo,qi,v,y,Fi,ua]);const Sc=s.current.agents.size,Zt=b.useMemo(()=>B4(s.current.agents.values()),[s.current,s.current.revision]),dn=b.useMemo(()=>z4(s.current.agents.values()),[s.current,s.current.revision]),ks=b.useRef(null);b.useEffect(()=>{const q=qF({waiting:Zt.length,running:dn,connected:He}),z=ks.current;if(ks.current=q,(z==null?void 0:z.title)!==q.title&&(document.title=q.title),(z==null?void 0:z.icon)!==q.icon){const se=document.querySelector('link[rel="icon"]');se&&(se.href=FF[q.icon])}},[Zt.length,dn,He]);const[jc,Ec]=b.useState(""),zi=zF(Zt);b.useEffect(()=>{Ec(q=>UF(q,zi))},[zi]);const[Na,Ui]=b.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[Vr,Wi]=b.useState(null),[tr,Sa]=b.useState(!0),[ja,xo]=b.useState(!1);b.useEffect(()=>{let q=!0;return fetch("/api/prefs").then(z=>z.ok?z.json():null).then(z=>{var se,oe,Ee;if(!(!q||!(z!=null&&z.ok))){if(!co.current){let Me=!1;try{Me=window.localStorage.getItem(Fu)==="0",window.localStorage.removeItem(Fu)}catch{}Me&&((se=z.prefs)==null?void 0:se.autoUpdate)!==!1?(lo(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):lo(((oe=z.prefs)==null?void 0:oe.autoUpdate)!==!1)}Sa(((Ee=z.prefs)==null?void 0:Ee.notifications)!==!1),xo(z.notificationsVetoed===!0)}}).catch(()=>{}),()=>{q=!1}},[]);const Hi=b.useRef(()=>{}),bo=b.useCallback(()=>{const q=!tr;Sa(q),q&&typeof Notification<"u"&&Notification.permission==="default"&&Hi.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:q})}).then(z=>z.ok?z.json():null).then(z=>{var se;z!=null&&z.ok&&(Sa(((se=z.prefs)==null?void 0:se.notifications)!==!1),xo(z.notificationsVetoed===!0))}).catch(()=>{})},[tr]),_s=typeof Notification<"u";b.useEffect(()=>{if(!Vr)return;const z=setTimeout(()=>Wi(null),Vr==="blocked"?8e3:4e3);return()=>clearTimeout(z)},[Vr]);const ko=b.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const z=q;Ui(z),z==="granted"?Wi("on"):z==="denied"&&Wi("blocked")})},[]);Hi.current=ko;const Ea=b.useRef(new Set),Ns=b.useRef(null),Cc=Zt.map(q=>_d(q.id,q.waiting)).join("|");return b.useEffect(()=>{G4(Ns.current,Na)&&(Ns.current=Na,Ea.current=Pk(Zt))},[Na]),b.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||Ns.current===null)return;const q=typeof document>"u"||!document.hidden,z=W4(Zt,Ea.current,q,tr);for(const se of z)try{const oe=new Notification(se.title,{body:se.body,tag:se.key});oe.onclick=()=>{window.focus(),Bi(se.sessionId),oe.close()}}catch{}Ea.current=q?Pk(Zt):H4(Zt,z,Ea.current)},[Cc]),i.jsxs("div",{className:"app",children:[i.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"readout",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"logo"}),i.jsx("h1",{children:Wt}),Ce?i.jsxs("button",{type:"button",className:"v stale",onClick:()=>{bt(),no()},"aria-haspopup":"dialog","aria-label":sW({...Ce,open:Qn}),title:Ce.kind==="restart"?`Running v${Ce.from}; v${Ce.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${Ce.from}; v${Ce.to} is on npm · click for what's new`,children:["v",Ce.from,i.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const q={running:mt,latest:he==null?void 0:he.latest,latestPending:he==null?void 0:he.latestPending,checkedAgo:he!=null&&he.checkedAt?Tv(Et-he.checkedAt):null,checkDisabled:he==null?void 0:he.checkDisabled,checking:ne};return i.jsxs("button",{type:"button",className:ne?"v checking":"v",onClick:()=>{bt(),Oe(!0)},"aria-busy":ne||void 0,"aria-haspopup":"dialog","aria-label":rW(q),title:nW(q),children:["v",q.running]})})()]}),i.jsx("span",{className:"status",children:(()=>{const q=hW({connected:He,paused:io,held:Xt.size,dropped:Xt.dropped});return q.resting?null:i.jsx("span",{className:`pill ${q.tone}`,title:q.title,children:i.jsxs("span",{className:"pill-box",children:[i.jsx("span",{className:"pill-widest","aria-hidden":!0,children:q.widest}),i.jsx("span",{className:"pill-label",children:q.label})]})})})()}),i.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:jc}),Zt.length>0&&i.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Bi(Zt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
268
+ ${Zt.map(q=>` ${q.label}: ${ql(q.waiting)} (${Tv(Et-q.waiting.since)})`).join(`
269
+ `)}`,"aria-label":`${Zt.length} session${Zt.length===1?"":"s"} waiting for you`,children:[i.jsx("span",{className:"ap-pulse","aria-hidden":!0}),i.jsx("b",{children:Zt.length})," waiting"]}),Vr&&i.jsx("span",{className:Vr==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:Vr==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:Vr==="on"?"notifications on":"notifications blocked"})]}),$t&&(()=>{const q=En($t),z=Math.max(0,(($t.endedAt??Et)-$t.startedAt)/1e3),se=$t.state==="active"?cx(q.total,z):null,oe=c.size-1;return i.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${$t.label}`,onClick:()=>{try{const Ee=Sr.find(Me=>Me.id===$t.id);Ee&&e.fitView({padding:.35,duration:500,nodes:[Ee]}),bn.current=Date.now()}catch{}},children:[i.jsx("span",{className:`state-pill state-${$t.state}`,children:$t.state==="active"?"live":$t.state}),i.jsx("span",{className:"selected-label",children:$t.label}),q.total>0&&i.jsxs("span",{className:"selected-cost",children:[tt(q.total),se?i.jsxs("span",{className:"selected-rate",children:[" · ",se]}):null]}),oe>0&&i.jsxs("span",{className:"selected-extra",children:["+",oe]}),i.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:Ee=>{Ee.stopPropagation(),v()},children:"×"})]})})(),i.jsxs("div",{className:"actions",children:[i.jsxs("div",{className:"action-run",children:[i.jsx("button",{className:"btn icon-btn",onClick:Rn,title:`${L?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":L,"aria-controls":L?"session-list":void 0,children:"☰"}),i.jsx("button",{className:"btn icon-btn",onClick:()=>K(q=>!q),title:`${Q?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":Q,"aria-controls":Q?"usage-panel":void 0,children:"$"}),ln.claude&&i.jsx("button",{className:"btn icon-btn",onClick:ea,title:`${D?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":D,"aria-controls":D?"accounts-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),i.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>Z(q=>!q),title:`${ee?"Hide":"Show"} this machine — cores, memory, temperature`,"aria-label":"Toggle machine detail","aria-expanded":ee,"aria-controls":ee?"system-panel":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),i.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]})}),i.jsx("button",{className:"btn icon-btn",onClick:()=>na(q=>!q),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[i.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),i.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),i.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),i.jsxs("button",{className:`btn icon-btn bw-btn${It>0?" has-findings":dt?" watching":""}`,onClick:()=>sa(q=>!q),title:dt?"Browser watch — watching; the deck is keeping its own copy":"Browser watch — not watching; reading the browser's history live","aria-label":`Browser watch, ${dt?"watching":"not watching"}`+(It>0?`, ${It} unread`:""),"aria-haspopup":"dialog",children:[i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":!0,children:[i.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),dt||It>0?i.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):i.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),It>0&&i.jsx("span",{className:"bw-badge","aria-hidden":!0,children:It})]})]}),i.jsxs("div",{className:"action-run",children:[ln.claude&&W!==null&&i.jsxs("div",{className:"sound-slot",children:[i.jsx("button",{ref:je,className:"btn icon-btn",onClick:()=>ke(q=>!q),...dr(!1),title:XF(ln,{on:W===!0,locked:it==="locked",prefs:me}),"aria-label":"Sound settings","aria-haspopup":"dialog","aria-expanded":ze,"aria-controls":ze?"sound-menu":void 0,children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[i.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),W?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),i.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M10 5.6l2.6 2.8"}),i.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),ze&&i.jsx(Qq,{onClose:()=>ke(!1),soundOn:W===!0,onToggleSound:J,prefs:me,onLevel:(q,z)=>ye(q,{level:z}),onFigure:(q,z)=>ye(q,{figure:z}),onPreview:q=>xe(q),notifyOn:tr,onToggleNotify:bo,notifyVetoed:ja,notifyPermission:_s?Na:"unsupported",onAskNotify:ko,openerRef:je})]}),i.jsx("button",{className:"btn icon-btn",onClick:()=>uc(q=>q==="dark"?"light":"dark"),title:`Switch to ${gs==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:gs==="dark"?"☀":"☾"})]})]})]}),_i?i.jsxs("div",{className:"ver-banner done",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:["Restarted — now running v",_i,"."]}),i.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):dc&&!He?i.jsxs("div",{className:"conn-banner",role:"alert",children:[i.jsx("span",{className:"conn-dot"}),Zn?ki==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Wt}…`:(()=>{const q=uW({connected:He,paused:io});return i.jsxs(i.Fragment,{children:[`Lost connection to the ${Wt} server. Reconnecting…`,q&&i.jsx("span",{className:"conn-sub",children:q})]})})()]}):Qn&&Ce?i.jsxs("div",{className:`ver-banner ${Ce.kind}`,role:"status",children:[i.jsx("span",{className:`ver-dot${er==null?"":" armed"}`}),Ce.kind==="restart"?i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:["v",Ce.to," is installed — this deck still runs v",Ce.from,"."]}),he!=null&&he.canRestart?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"ver-act",onClick:()=>xn(),...dr(Zn),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
270
270
 
271
- 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:Zn?"restarting…":ps.label}),!Zn&&i.jsx("span",{className:"ver-sub",children:ps.clause}),i.jsxs("button",{type:"button",className:`ver-auto${rn?" on":""}`,role:"switch","aria-checked":rn,onClick:at,"aria-label":"Auto-restart when idle",title:rn?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:[i.jsx("i",{"aria-hidden":!0}),i.jsx("span",{"aria-hidden":!0,children:xq(rn,er)})]})]}):i.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:[Wt," v",Ce.to," is out — you are on v",Ce.from,"."]}),(he==null?void 0:he.upgradeMode)==="install"&&qt!=="failed"&&i.jsx("button",{type:"button",className:"ver-act",onClick:wi,...dr(qt==="running",qt==="done"),title:`Runs ${((Gi=he==null?void 0:he.upgrade)==null?void 0:Gi.command)??(he==null?void 0:he.command)??"npm i -g"} here, then restarts once nothing is running.`,children:qt==="running"?"installing…":qt==="done"?"installed":"Update now"}),(he==null?void 0:he.upgradeMode)==="npx"&&(he==null?void 0:he.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>xn({upgrade:!0}),...dr(Zn),title:`Runs ${he==null?void 0:he.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Zn?"fetching…":qt==="failed"?"Retry update":"Update & restart"}),qt==="failed"?i.jsxs("span",{className:"ver-sub fail",title:((Vi=he==null?void 0:he.upgrade)==null?void 0:Vi.error)??"",children:[(he==null?void 0:he.upgradeMode)==="npx"?"update failed":"install failed",": ",((Yi=he==null?void 0:he.upgrade)==null?void 0:Yi.error)??"unknown error"," — run it yourself:"]}):(he==null?void 0:he.upgradeMode)==="npx"?i.jsx("span",{className:"ver-sub",children:he!=null&&he.canRestart?"npx cannot upgrade in place, so the deck re-runs:":sv.npx}):he!=null&&he.upgradeBlocked?i.jsx("span",{className:"ver-sub",children:Object.hasOwn(sv,he.upgradeBlocked)?sv[he.upgradeBlocked]:"cannot install from here"}):null,i.jsxs("button",{type:"button",className:"ver-cmd",onClick:no,title:"Copy to clipboard",children:[i.jsx("code",{children:he==null?void 0:he.command}),i.jsx("span",{className:"ver-cmd-hint",children:et?"copied":"copy"})]})]}),i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Pr,children:"×"})]}):Dr&&An?i.jsxs("div",{className:"ver-banner",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:[An," still works — the deck is called ",Wt," now."]}),he!=null&&he.renameFix?i.jsx("span",{className:"ver-sub",children:he.renameFix}):null,i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:ds,children:"×"})]}):null,If(G)&&i.jsx(X5,{state:s.current,now:Et,providers:ln,leaving:G==="leaving",onClose:()=>K(!1)}),If(P)&&ln.claude&&i.jsx(fq,{leaving:P==="leaving",onClose:()=>Y(!1)}),If(de)&&i.jsx(jD,{usageOpen:Q,leaving:de==="leaving",onClose:()=>Z(!1)}),L&&i.jsx(y5,{state:s.current,now:Et,selectedIds:c,onSelect:Fi,onClose:()=>H(!1)}),i.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${eh?" bubbling":""}${ya?" dragging-any":""}`,"data-detail":th,ref:mc,onMouseDownCapture:Qd,onPointerDownCapture:Hr,onPointerUpCapture:Hr,onWheelCapture:Hr,children:[Nc===0&&i.jsx(qW,{live:He,everConnected:uc,providers:ln,workspace:Xn,onTour:()=>F(!0)}),(wa.length>1||uo.size>0)&&i.jsx("div",{ref:ac,className:`cat-filter-bar${Wd?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:wa.map(q=>{const z=uo.has(q);return i.jsxs("button",{type:"button",className:`cat-filter${z?" off":""}`,onClick:()=>va(q),"aria-pressed":!z,title:`${z?"Show":"Hide"} ${Fv[q]} tools`,children:[i.jsx("span",{className:"cat-emoji",children:qv[q]}),i.jsx("span",{className:"cat-name",children:Fv[q]})]},q)})}),i.jsxs(UT,{nodes:bc,edges:nh,nodeTypes:fW,fitView:!co,fitViewOptions:{padding:.25,duration:tv({durationMs:vC,documentHidden:document.hidden})?vC:0},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(q,z)=>{if(z.type==="sessionGroup"){v();return}y(z.id,q.shiftKey)},onPaneClick:()=>v(),onMoveStart:q=>{mC(dc(q))&&Ci()},onMove:(q,z)=>{Ft(),mC(dc(q))&&Ci();const se=yW(z.zoom);se!==$i.current&&($i.current=se,yc(se)),ys.current&&window.clearTimeout(ys.current),ys.current=window.setTimeout(()=>$W(z),250)},onNodeDragStart:(q,z)=>{var se;if(wc(),Ti.current=!0,vr.current=new Map,vs(!0),Ft(),Ci(),z.type==="sessionGroup"){const oe=(se=z.data)==null?void 0:se.sessionId,Ee=new Map;if(oe)for(const Me of Sr){const We=Me.data;(We==null?void 0:We.sessionId)===oe&&Ee.set(Me.id,{x:Me.position.x,y:Me.position.y})}br.current={start:{x:z.position.x,y:z.position.y},members:Ee};return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y})},onNodeDrag:(q,z)=>{var se;if(Ft(),z.type==="sessionGroup"){const oe=br.current;if(!oe)return;const Ee=z.position.x-oe.start.x,Me=z.position.y-oe.start.y;for(const[rt,gt]of oe.members){const ot={x:gt.x+Ee,y:gt.y+Me};Qt.current.set(rt,ot),sn.current.set(rt,ot)}const We=vr.current;if(We){for(const[rt,gt]of oe.members)We.set(rt,{x:gt.x+Ee,y:gt.y+Me});We.set(z.id,{x:z.position.x,y:z.position.y})}hs(rt=>rt+1);return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y}),sn.current.set(z.id,{x:z.position.x,y:z.position.y}),(se=vr.current)==null||se.set(z.id,{x:z.position.x,y:z.position.y}),hs(oe=>oe+1)},onNodeDragStop:(q,z)=>{if(Ft(),Ti.current=!1,vr.current=null,vs(!1),cn(se=>se+1),z.type==="sessionGroup"){const se=br.current;if(se){const oe=z.position.x-se.start.x,Ee=z.position.y-se.start.y;for(const[Me,We]of se.members){const rt={x:We.x+oe,y:We.y+Ee};Qt.current.set(Me,rt),sn.current.set(Me,rt)}}br.current=null,av(sn.current,Qt.current),cn(oe=>oe+1);return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y}),sn.current.set(z.id,{x:z.position.x,y:z.position.y}),av(sn.current,Qt.current)},children:[i.jsx(J3,{gap:28,size:1,color:un["--grid-line"]}),i.jsx(EL,{onFit:()=>{bn.current=Date.now()}}),i.jsx(c5,{agents:s.current.agents,visibleAgentIds:Ri,positions:sn.current,pinned:Qt.current,measured:_r.current,spotlight:ga,hiddenCategories:uo,now:Et,onOpenTool:m}),i.jsxs(V3,{showInteractive:!1,children:[i.jsx(Rr,{onClick:Vd,title:pa?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:pa?{color:"var(--accent)"}:void 0,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:ca,title:cW({paused:oo,held:Xt.size,dropped:Xt.dropped}),"aria-label":lW,"aria-pressed":oo,children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:i.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),i.jsx(Rr,{onClick:wo,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:()=>xs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),i.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:()=>I(q=>!q),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),i.jsx(F3,{zoomable:!0,pannable:!0,nodeColor:fo,nodeStrokeWidth:2,maskColor:un["--minimap-mask"],style:Gd})]})]}),B&&$t?i.jsxs("aside",{className:"detail","aria-label":"Detail",children:[i.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>A(!1),children:"×"}),i.jsx(BW,{agent:$t,now:Et,onOpenTool:m,onShowSummary:q=>{M.has(q)&&(M.delete(q),_C(M)),_(q)},onExportSession:q=>OW(s.current,q)})]}):null,Pi&&i.jsx(vL,{tool:Pi,onClose:()=>m(null)}),ea&&i.jsx(t8,{providers:ln,onClose:()=>ta(!1)}),na&&i.jsx(f8,{onClose:()=>ra(!1),onSeen:q=>{ro(q);try{localStorage.setItem(U1,String(q))}catch{}},onWatching:so,palette:un}),S&&(()=>{const q=s.current.agents.get(S);return q?i.jsx(uL,{agent:q,onClose:()=>x(null)}):null})(),j&&i.jsx(p5,{state:s.current,sessionId:j,onClose:()=>{M.add(j),_C(M),_(null)}}),lt&&i.jsx(wF,{entries:lt.entries,since:lt.since,firstRun:lt.firstRun,running:mt,onClose:()=>ut(null),onTour:()=>{ut(null),F(!0)}}),(()=>{const{request:q,waiting:z}=m8(oa,Fr.current);return q?i.jsx(g8,{request:q,waiting:z,busy:Br,now:Date.now(),onAccept:()=>void zr("accept",q.fp),onDecline:()=>void zr("dismiss",q.fp),onLater:()=>{Br||(Fr.current.add(q.fp),qr(se=>[...se]))}}):null})(),R&&i.jsx(Aq,{onClose:()=>I(!1),onTour:()=>{I(!1),F(!0)}}),$&&i.jsx(A2,{title:"What the deck shows you",steps:A6,onClose:()=>{F(!1),pF(q1());const q=O.current;O.current=null,q&&ut(q)}}),E&&i.jsx(Eq,{agentCount:Nc,onConfirm:()=>xs("confirmation"),onCancel:()=>C(!1)})]})}function qW({live:e,everConnected:t,providers:n,workspace:s,onTour:a}){const l=!e;return i.jsxs("div",{className:"empty-hero",children:[i.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[i.jsx("div",{className:"core"}),i.jsxs("div",{className:"orbit r1",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r2",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r3",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]})]}),l?i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),i.jsxs("p",{children:["The browser cannot reach ",i.jsx("code",{children:"/events"}),". Check that",i.jsx("code",{children:Wt})," is still running in your terminal, then this page will resume automatically."]})]}):FW(n,s),!l&&i.jsx("button",{type:"button",className:"btn empty-tour",onClick:a,children:"Take the tour"})]})}function FW(e,t){const n=aW(t);return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?i.jsxs("p",{children:[n.lead," ",i.jsx("code",{children:n.workspace}),n.tail]}):i.jsxs("p",{children:["Run ",i.jsx("code",{children:"claude"})," or ",i.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),i.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",i.jsx("code",{children:Wt})," is running."]}),KF(e).map(s=>i.jsx("p",{className:"hint-row",children:s.spans.map((a,l)=>a.code?i.jsx("code",{children:a.text},l):i.jsx("span",{children:a.text},l))},s.provider))]})}function BW({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a}){const l=sd(e.startedAt,e.endedAt,t),c=En(e),d=c.total>0,h=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const j of e.tools){const _=sR(j.name);p.set(_,(p.get(_)??0)+1)}const f=e.tools.filter(j=>j.ok===!1).length,m=e.tools.filter(j=>!j.endedAt).length,y=Array.from(p.entries()).sort((j,_)=>_[1]-j[1]),v=p.has("mcp")?s5(e.tools.map(j=>j.name)):null;return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"detail-hero",children:[i.jsxs("div",{className:"hero-line",children:[i.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),i.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),i.jsxs("div",{className:"hero-meta",children:[i.jsx("span",{className:"hero-meta-item",children:e.kind}),i.jsx("span",{className:"hero-sep",children:"·"}),i.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const j=s2(e);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hero-sep",children:"·"}),i.jsxs("span",{className:"model-chip","data-family":bd(e.model),title:j.length>0?`${e.model}
271
+ 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:Zn?"restarting…":ms.label}),!Zn&&i.jsx("span",{className:"ver-sub",children:ms.clause}),i.jsxs("button",{type:"button",className:`ver-auto${rn?" on":""}`,role:"switch","aria-checked":rn,onClick:at,"aria-label":"Auto-restart when idle",title:rn?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:[i.jsx("i",{"aria-hidden":!0}),i.jsx("span",{"aria-hidden":!0,children:xq(rn,er)})]})]}):i.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("strong",{children:[Wt," v",Ce.to," is out — you are on v",Ce.from,"."]}),(he==null?void 0:he.upgradeMode)==="install"&&qt!=="failed"&&i.jsx("button",{type:"button",className:"ver-act",onClick:vi,...dr(qt==="running",qt==="done"),title:`Runs ${((Vi=he==null?void 0:he.upgrade)==null?void 0:Vi.command)??(he==null?void 0:he.command)??"npm i -g"} here, then restarts once nothing is running.`,children:qt==="running"?"installing…":qt==="done"?"installed":"Update now"}),(he==null?void 0:he.upgradeMode)==="npx"&&(he==null?void 0:he.canRestart)&&i.jsx("button",{type:"button",className:"ver-act",onClick:()=>xn({upgrade:!0}),...dr(Zn),title:`Runs ${he==null?void 0:he.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Zn?"fetching…":qt==="failed"?"Retry update":"Update & restart"}),qt==="failed"?i.jsxs("span",{className:"ver-sub fail",title:((Yi=he==null?void 0:he.upgrade)==null?void 0:Yi.error)??"",children:[(he==null?void 0:he.upgradeMode)==="npx"?"update failed":"install failed",": ",((Ki=he==null?void 0:he.upgrade)==null?void 0:Ki.error)??"unknown error"," — run it yourself:"]}):(he==null?void 0:he.upgradeMode)==="npx"?i.jsx("span",{className:"ver-sub",children:he!=null&&he.canRestart?"npx cannot upgrade in place, so the deck re-runs:":av.npx}):he!=null&&he.upgradeBlocked?i.jsx("span",{className:"ver-sub",children:Object.hasOwn(av,he.upgradeBlocked)?av[he.upgradeBlocked]:"cannot install from here"}):null,i.jsxs("button",{type:"button",className:"ver-cmd",onClick:ro,title:"Copy to clipboard",children:[i.jsx("code",{children:he==null?void 0:he.command}),i.jsx("span",{className:"ver-cmd-hint",children:et?"copied":"copy"})]})]}),i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Pr,children:"×"})]}):Dr&&An?i.jsxs("div",{className:"ver-banner",role:"status",children:[i.jsx("span",{className:"ver-dot"}),i.jsxs("strong",{children:[An," still works — the deck is called ",Wt," now."]}),he!=null&&he.renameFix?i.jsx("span",{className:"ver-sub",children:he.renameFix}):null,i.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:hs,children:"×"})]}):null,$f(G)&&i.jsx(X5,{state:s.current,now:Et,providers:ln,leaving:G==="leaving",onClose:()=>K(!1)}),$f(P)&&ln.claude&&i.jsx(fq,{leaving:P==="leaving",onClose:()=>Y(!1)}),$f(de)&&i.jsx(jD,{usageOpen:Q,leaving:de==="leaving",onClose:()=>Z(!1)}),L&&i.jsx(y5,{state:s.current,now:Et,selectedIds:c,onSelect:Bi,onClose:()=>H(!1)}),i.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${th?" bubbling":""}${wa?" dragging-any":""}`,"data-detail":nh,ref:gc,onMouseDownCapture:Zd,onPointerDownCapture:Hr,onPointerUpCapture:Hr,onWheelCapture:Hr,children:[Sc===0&&i.jsx(qW,{live:He,everConnected:dc,providers:ln,workspace:Xn,onTour:()=>F(!0)}),(va.length>1||ho.size>0)&&i.jsx("div",{ref:oc,className:`cat-filter-bar${Hd?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:va.map(q=>{const z=ho.has(q);return i.jsxs("button",{type:"button",className:`cat-filter${z?" off":""}`,onClick:()=>xa(q),"aria-pressed":!z,title:`${z?"Show":"Hide"} ${Bv[q]} tools`,children:[i.jsx("span",{className:"cat-emoji",children:Fv[q]}),i.jsx("span",{className:"cat-name",children:Bv[q]})]},q)})}),i.jsxs(UT,{nodes:kc,edges:rh,nodeTypes:fW,fitView:!uo,fitViewOptions:{padding:.25,duration:nv({durationMs:vC,documentHidden:document.hidden})?vC:0},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(q,z)=>{if(z.type==="sessionGroup"){v();return}y(z.id,q.shiftKey)},onPaneClick:()=>v(),onMoveStart:q=>{mC(hc(q))&&Ti()},onMove:(q,z)=>{Ft(),mC(hc(q))&&Ti();const se=yW(z.zoom);se!==Oi.current&&(Oi.current=se,wc(se)),ws.current&&window.clearTimeout(ws.current),ws.current=window.setTimeout(()=>$W(z),250)},onNodeDragStart:(q,z)=>{var se;if(vc(),Ai.current=!0,vr.current=new Map,xs(!0),Ft(),Ti(),z.type==="sessionGroup"){const oe=(se=z.data)==null?void 0:se.sessionId,Ee=new Map;if(oe)for(const Me of Sr){const We=Me.data;(We==null?void 0:We.sessionId)===oe&&Ee.set(Me.id,{x:Me.position.x,y:Me.position.y})}br.current={start:{x:z.position.x,y:z.position.y},members:Ee};return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y})},onNodeDrag:(q,z)=>{var se;if(Ft(),z.type==="sessionGroup"){const oe=br.current;if(!oe)return;const Ee=z.position.x-oe.start.x,Me=z.position.y-oe.start.y;for(const[rt,gt]of oe.members){const ot={x:gt.x+Ee,y:gt.y+Me};Qt.current.set(rt,ot),sn.current.set(rt,ot)}const We=vr.current;if(We){for(const[rt,gt]of oe.members)We.set(rt,{x:gt.x+Ee,y:gt.y+Me});We.set(z.id,{x:z.position.x,y:z.position.y})}fs(rt=>rt+1);return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y}),sn.current.set(z.id,{x:z.position.x,y:z.position.y}),(se=vr.current)==null||se.set(z.id,{x:z.position.x,y:z.position.y}),fs(oe=>oe+1)},onNodeDragStop:(q,z)=>{if(Ft(),Ai.current=!1,vr.current=null,xs(!1),cn(se=>se+1),z.type==="sessionGroup"){const se=br.current;if(se){const oe=z.position.x-se.start.x,Ee=z.position.y-se.start.y;for(const[Me,We]of se.members){const rt={x:We.x+oe,y:We.y+Ee};Qt.current.set(Me,rt),sn.current.set(Me,rt)}}br.current=null,ov(sn.current,Qt.current),cn(oe=>oe+1);return}Qt.current.set(z.id,{x:z.position.x,y:z.position.y}),sn.current.set(z.id,{x:z.position.x,y:z.position.y}),ov(sn.current,Qt.current)},children:[i.jsx(J3,{gap:28,size:1,color:un["--grid-line"]}),i.jsx(EL,{onFit:()=>{bn.current=Date.now()}}),i.jsx(c5,{agents:s.current.agents,visibleAgentIds:Mi,positions:sn.current,pinned:Qt.current,measured:_r.current,spotlight:ya,hiddenCategories:ho,now:Et,onOpenTool:m}),i.jsxs(V3,{showInteractive:!1,children:[i.jsx(Rr,{onClick:Yd,title:ma?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:ma?{color:"var(--accent)"}:void 0,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:ua,title:cW({paused:io,held:Xt.size,dropped:Xt.dropped}),"aria-label":lW,"aria-pressed":io,children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:i.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),i.jsx(Rr,{onClick:vo,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),i.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:()=>bs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),i.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),i.jsx(Rr,{onClick:()=>I(q=>!q),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[i.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),i.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),i.jsx(F3,{zoomable:!0,pannable:!0,nodeColor:po,nodeStrokeWidth:2,maskColor:un["--minimap-mask"],style:Vd})]})]}),B&&$t?i.jsxs("aside",{className:"detail","aria-label":"Detail",children:[i.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>A(!1),children:"×"}),i.jsx(BW,{agent:$t,now:Et,onOpenTool:m,onShowSummary:q=>{M.has(q)&&(M.delete(q),_C(M)),_(q)},onExportSession:q=>OW(s.current,q)})]}):null,Li&&i.jsx(vL,{tool:Li,onClose:()=>m(null)}),ta&&i.jsx(t8,{providers:ln,onClose:()=>na(!1)}),ra&&i.jsx(f8,{onClose:()=>sa(!1),onSeen:q=>{so(q);try{localStorage.setItem(U1,String(q))}catch{}},onWatching:ao,palette:un}),S&&(()=>{const q=s.current.agents.get(S);return q?i.jsx(uL,{agent:q,onClose:()=>x(null)}):null})(),j&&i.jsx(p5,{state:s.current,sessionId:j,onClose:()=>{M.add(j),_C(M),_(null)}}),lt&&i.jsx(wF,{entries:lt.entries,since:lt.since,firstRun:lt.firstRun,running:mt,onClose:()=>ut(null),onTour:()=>{ut(null),F(!0)}}),(()=>{const{request:q,waiting:z}=m8(ia,Fr.current);return q?i.jsx(g8,{request:q,waiting:z,busy:Br,now:Date.now(),onAccept:()=>void zr("accept",q.fp),onDecline:()=>void zr("dismiss",q.fp),onLater:()=>{Br||(Fr.current.add(q.fp),qr(se=>[...se]))}}):null})(),R&&i.jsx(Aq,{onClose:()=>I(!1),onTour:()=>{I(!1),F(!0)}}),$&&i.jsx(A2,{title:"What the deck shows you",steps:A6,onClose:()=>{F(!1),pF(q1());const q=O.current;O.current=null,q&&ut(q)}}),E&&i.jsx(Eq,{agentCount:Sc,onConfirm:()=>bs("confirmation"),onCancel:()=>C(!1)})]})}function qW({live:e,everConnected:t,providers:n,workspace:s,onTour:a}){const l=!e;return i.jsxs("div",{className:"empty-hero",children:[i.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[i.jsx("div",{className:"core"}),i.jsxs("div",{className:"orbit r1",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r2",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]}),i.jsxs("div",{className:"orbit r3",children:[i.jsx("span",{className:"dot"}),i.jsx("span",{className:"dot b"})]})]}),l?i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),i.jsxs("p",{children:["The browser cannot reach ",i.jsx("code",{children:"/events"}),". Check that",i.jsx("code",{children:Wt})," is still running in your terminal, then this page will resume automatically."]})]}):FW(n,s),!l&&i.jsx("button",{type:"button",className:"btn empty-tour",onClick:a,children:"Take the tour"})]})}function FW(e,t){const n=aW(t);return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?i.jsxs("p",{children:[n.lead," ",i.jsx("code",{children:n.workspace}),n.tail]}):i.jsxs("p",{children:["Run ",i.jsx("code",{children:"claude"})," or ",i.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),i.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",i.jsx("code",{children:Wt})," is running."]}),KF(e).map(s=>i.jsx("p",{className:"hint-row",children:s.spans.map((a,l)=>a.code?i.jsx("code",{children:a.text},l):i.jsx("span",{children:a.text},l))},s.provider))]})}function BW({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a}){const l=ad(e.startedAt,e.endedAt,t),c=En(e),d=c.total>0,h=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const j of e.tools){const _=sR(j.name);p.set(_,(p.get(_)??0)+1)}const f=e.tools.filter(j=>j.ok===!1).length,m=e.tools.filter(j=>!j.endedAt).length,y=Array.from(p.entries()).sort((j,_)=>_[1]-j[1]),v=p.has("mcp")?s5(e.tools.map(j=>j.name)):null;return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"detail-hero",children:[i.jsxs("div",{className:"hero-line",children:[i.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),i.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),i.jsxs("div",{className:"hero-meta",children:[i.jsx("span",{className:"hero-meta-item",children:e.kind}),i.jsx("span",{className:"hero-sep",children:"·"}),i.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const j=s2(e);return i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"hero-sep",children:"·"}),i.jsxs("span",{className:"model-chip","data-family":kd(e.model),title:j.length>0?`${e.model}
272
272
  spend on this panel also covers:
273
273
  ${j.join(`
274
- `)}`:e.model,children:[Ys(e.model),j.length>0?` +${j.length}`:""]})]})})()]}),d&&i.jsxs("div",{className:"hero-cost",children:[i.jsxs("div",{className:"hero-cost-headline",children:[i.jsx("span",{className:"hero-cost-value",children:tt(c.total)}),i.jsx("span",{className:"hero-cost-label",children:"spend"})]}),i.jsx(fx,{cost:c})]}),i.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&i.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&&i.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>a(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Activity"}),i.jsxs("div",{className:"activity-row",children:[i.jsxs("div",{className:"activity-counters",children:[i.jsxs("span",{className:"ac-item",children:[i.jsx("b",{children:e.toolCount})," calls"]}),m>0&&i.jsxs("span",{className:"ac-item ac-live",children:[i.jsx("b",{children:m})," live"]}),f>0&&i.jsxs("span",{className:"ac-item ac-err",children:[i.jsx("b",{children:f})," err"]})]}),i.jsx("div",{className:"cat-strip",children:y.map(([j,_])=>{const S=j==="mcp"?v:null,x=S==null?void 0:S.hue,N=`${_} ${Fv[j]} call${_===1?"":"s"}`;return i.jsxs("span",{className:`cat-chip cat-${j}${x!=null?" mcp-hue":""}`,style:x!=null?{"--mcp-hue":x}:void 0,title:S?`${N}, all to ${S.label}`:N,children:[i.jsx("span",{className:"cat-emoji",children:qv[j]}),i.jsx("span",{className:"cat-count",children:_}),S&&i.jsx("span",{className:"cat-server",children:S.label})]},j)})})]})]}),h>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Tokens"}),i.jsxs("div",{className:"tokens-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"in"}),i.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"out"}),i.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache r"}),i.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache c"}),i.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Identity"}),i.jsxs("div",{children:[e.cwd&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"cwd"}),i.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"session"}),i.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"parent"}),i.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Prompts ",i.jsx("span",{className:"section-count",children:e.prompts.length})]}),i.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((j,_)=>{const S=$5(j.at,t);return i.jsxs("div",{className:"prompt-entry",children:[i.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),i.jsx("div",{className:"prompt-text",children:j.text})]},_)})})]}),i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Tool calls ",i.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&i.jsx("div",{className:"empty",children:"No tool calls yet."}),i.jsx("div",{children:e.tools.slice().reverse().map(j=>i.jsx(UW,{t:j,onClick:()=>n(j.id)},j.id))})]})]})}const zW={inflight:"in-flight",done:"done",err:"error"};function UW({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=o2(e,"…");return i.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[i.jsxs("span",{className:"name",children:[i.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:zW[n]}),e.name]}),i.jsx("span",{style:{color:"var(--muted)"},children:s})]})}try{M5(window.localStorage)}catch{}const WW=ZR.createRoot(document.getElementById("root"));WW.render(i.jsx(LW,{}));
274
+ `)}`:e.model,children:[Ks(e.model),j.length>0?` +${j.length}`:""]})]})})()]}),d&&i.jsxs("div",{className:"hero-cost",children:[i.jsxs("div",{className:"hero-cost-headline",children:[i.jsx("span",{className:"hero-cost-value",children:tt(c.total)}),i.jsx("span",{className:"hero-cost-label",children:"spend"})]}),i.jsx(fx,{cost:c})]}),i.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&i.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&&i.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>a(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Activity"}),i.jsxs("div",{className:"activity-row",children:[i.jsxs("div",{className:"activity-counters",children:[i.jsxs("span",{className:"ac-item",children:[i.jsx("b",{children:e.toolCount})," calls"]}),m>0&&i.jsxs("span",{className:"ac-item ac-live",children:[i.jsx("b",{children:m})," live"]}),f>0&&i.jsxs("span",{className:"ac-item ac-err",children:[i.jsx("b",{children:f})," err"]})]}),i.jsx("div",{className:"cat-strip",children:y.map(([j,_])=>{const S=j==="mcp"?v:null,x=S==null?void 0:S.hue,N=`${_} ${Bv[j]} call${_===1?"":"s"}`;return i.jsxs("span",{className:`cat-chip cat-${j}${x!=null?" mcp-hue":""}`,style:x!=null?{"--mcp-hue":x}:void 0,title:S?`${N}, all to ${S.label}`:N,children:[i.jsx("span",{className:"cat-emoji",children:Fv[j]}),i.jsx("span",{className:"cat-count",children:_}),S&&i.jsx("span",{className:"cat-server",children:S.label})]},j)})})]})]}),h>0&&i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Tokens"}),i.jsxs("div",{className:"tokens-grid",children:[i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"in"}),i.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"out"}),i.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache r"}),i.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),i.jsxs("div",{children:[i.jsx("span",{className:"k",children:"cache c"}),i.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),i.jsxs("section",{className:"detail-section",children:[i.jsx("h3",{children:"Identity"}),i.jsxs("div",{children:[e.cwd&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"cwd"}),i.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"session"}),i.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&i.jsxs("div",{className:"row",children:[i.jsx("span",{className:"k",children:"parent"}),i.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Prompts ",i.jsx("span",{className:"section-count",children:e.prompts.length})]}),i.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((j,_)=>{const S=$5(j.at,t);return i.jsxs("div",{className:"prompt-entry",children:[i.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),i.jsx("div",{className:"prompt-text",children:j.text})]},_)})})]}),i.jsxs("section",{className:"detail-section",children:[i.jsxs("h3",{children:["Tool calls ",i.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&i.jsx("div",{className:"empty",children:"No tool calls yet."}),i.jsx("div",{children:e.tools.slice().reverse().map(j=>i.jsx(UW,{t:j,onClick:()=>n(j.id)},j.id))})]})]})}const zW={inflight:"in-flight",done:"done",err:"error"};function UW({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=o2(e,"…");return i.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[i.jsxs("span",{className:"name",children:[i.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),i.jsx("span",{className:"vis-hidden",children:zW[n]}),e.name]}),i.jsx("span",{style:{color:"var(--muted)"},children:s})]})}try{M5(window.localStorage)}catch{}const WW=ZR.createRoot(document.getElementById("root"));WW.render(i.jsx(LW,{}));