cascade-ai 0.2.12 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +146 -58
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +147 -59
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +76 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +77 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/web/dist/assets/{index-BdaS_Mbj.js → index-BvxaBI9b.js} +34 -34
- package/web/dist/index.html +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ys=Object.defineProperty;var ws=(e,s
|
|
1
|
+
var ys=Object.defineProperty;var ws=(e,t,s)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Te=(e,t,s)=>ws(e,typeof t!="symbol"?t+"":t,s);import{r as h,a as Ut,H as it,P as at,M as js,R as _s,B as Ss,b as Ns,C as Cs,c as ks}from"./reactflow-B1e2RnXD.js";import{l as Es}from"./socketio-BcxXcwBL.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function s(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=s(r);fetch(r.href,i)}})();var Bt={exports:{}},je={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
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 Is=h,As=Symbol.for("react.element"),Ms=Symbol.for("react.fragment"),Ts=Object.prototype.hasOwnProperty,Os=Is.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rs={key:!0,ref:!0,__self:!0,__source:!0};function
|
|
9
|
+
*/var Is=h,As=Symbol.for("react.element"),Ms=Symbol.for("react.fragment"),Ts=Object.prototype.hasOwnProperty,Os=Is.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rs={key:!0,ref:!0,__self:!0,__source:!0};function Vt(e,t,s){var n,r={},i=null,o=null;s!==void 0&&(i=""+s),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(n in t)Ts.call(t,n)&&!Rs.hasOwnProperty(n)&&(r[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)r[n]===void 0&&(r[n]=t[n]);return{$$typeof:As,type:e,key:i,ref:o,props:r,_owner:Os.current}}je.Fragment=Ms;je.jsx=Vt;je.jsxs=Vt;Bt.exports=je;var a=Bt.exports,Ve={},ot=Ut;Ve.createRoot=ot.createRoot,Ve.hydrateRoot=ot.hydrateRoot;var Wt={exports:{}},Ht={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-with-selector.production.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
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 te=h;function Ds(e,s){return e===s&&(e!==0||1/e===1/s)||e!==e&&s!==s}var zs=typeof Object.is=="function"?Object.is:Ds,Ps=te.useSyncExternalStore,Ls=te.useRef,Fs=te.useEffect,$s=te.useMemo,Us=te.useDebugValue;Wt.useSyncExternalStoreWithSelector=function(e,s,t,n,r){var i=Ls(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=$s(function(){function c(f){if(!d){if(d=!0,u=f,f=n(f),r!==void 0&&o.hasValue){var g=o.value;if(r(g,f))return m=g}return m=f}if(g=m,zs(u,f))return g;var y=n(f);return r!==void 0&&r(g,y)?(u=f,g):(u=f,m=y)}var d=!1,u,m,p=t===void 0?null:t;return[function(){return c(s())},p===null?void 0:function(){return c(p())}]},[s,t,n,r]);var l=Ps(e,i[0],i[1]);return Fs(function(){o.hasValue=!0,o.value=l},[l]),Us(l),l};Vt.exports=Wt;var Bs=Vt.exports;function Vs(e){e()}function Ws(){let e=null,s=null;return{clear(){e=null,s=null},notify(){Vs(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(t){let n=!0;const r=s={callback:t,next:null,prev:s};return r.prev?r.prev.next=r:e=r,function(){!n||e===null||(n=!1,r.next?r.next.prev=r.prev:s=r.prev,r.prev?r.prev.next=r.next:e=r.next)}}}}var ot={notify(){},get:()=>[]};function Hs(e,s){let t,n=ot,r=0,i=!1;function o(y){u();const v=n.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),m())}}function l(){n.notify()}function c(){g.onStateChange&&g.onStateChange()}function d(){return i}function u(){r++,t||(t=e.subscribe(c),n=Ws())}function m(){r--,t&&r===0&&(t(),t=void 0,n.clear(),n=ot)}function p(){i||(i=!0,u())}function f(){i&&(i=!1,m())}const g={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:p,tryUnsubscribe:f,getListeners:()=>n};return g}var qs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ks=qs(),Gs=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Js=Gs(),Xs=()=>Ks||Js?h.useLayoutEffect:h.useEffect,Ys=Xs(),Te=Symbol.for("react-redux-context"),Oe=typeof globalThis<"u"?globalThis:{};function Zs(){if(!h.createContext)return{};const e=Oe[Te]??(Oe[Te]=new Map);let s=e.get(h.createContext);return s||(s=h.createContext(null),e.set(h.createContext,s)),s}var $=Zs();function Qs(e){const{children:s,context:t,serverState:n,store:r}=e,i=h.useMemo(()=>{const c=Hs(r);return{store:r,subscription:c,getServerState:n?()=>n:void 0}},[r,n]),o=h.useMemo(()=>r.getState(),[r]);Ys(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==r.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,o]);const l=t||$;return h.createElement(l.Provider,{value:i},s)}var en=Qs;function Ye(e=$){return function(){return h.useContext(e)}}var Ht=Ye();function qt(e=$){const s=e===$?Ht:Ye(e),t=()=>{const{store:n}=s();return n};return Object.assign(t,{withTypes:()=>t}),t}var tn=qt();function sn(e=$){const s=e===$?tn:qt(e),t=()=>s().dispatch;return Object.assign(t,{withTypes:()=>t}),t}var nn=sn(),rn=(e,s)=>e===s;function an(e=$){const s=e===$?Ht:Ye(e),t=(n,r={})=>{const{equalityFn:i=rn}=typeof r=="function"?{equalityFn:r}:r,o=s(),{store:l,subscription:c,getServerState:d}=o;h.useRef(!0);const u=h.useCallback({[n.name](p){return n(p)}}[n.name],[n]),m=Bs.useSyncExternalStoreWithSelector(c.addNestedSub,l.getState,d||l.getState,u,i);return h.useDebugValue(m),m};return Object.assign(t,{withTypes:()=>t}),t}var on=an();function E(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ln=typeof Symbol=="function"&&Symbol.observable||"@@observable",lt=ln,Re=()=>Math.random().toString(36).substring(7).split("").join("."),cn={INIT:`@@redux/INIT${Re()}`,REPLACE:`@@redux/REPLACE${Re()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Re()}`},me=cn;function Ze(e){if(typeof e!="object"||e===null)return!1;let s=e;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(e)===s||Object.getPrototypeOf(e)===null}function Kt(e,s,t){if(typeof e!="function")throw new Error(E(2));if(typeof s=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(E(0));if(typeof s=="function"&&typeof t>"u"&&(t=s,s=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(E(1));return t(Kt)(e,s)}let n=e,r=s,i=new Map,o=i,l=0,c=!1;function d(){o===i&&(o=new Map,i.forEach((v,x)=>{o.set(x,v)}))}function u(){if(c)throw new Error(E(3));return r}function m(v){if(typeof v!="function")throw new Error(E(4));if(c)throw new Error(E(5));let x=!0;d();const b=l++;return o.set(b,v),function(){if(x){if(c)throw new Error(E(6));x=!1,d(),o.delete(b),i=null}}}function p(v){if(!Ze(v))throw new Error(E(7));if(typeof v.type>"u")throw new Error(E(8));if(typeof v.type!="string")throw new Error(E(17));if(c)throw new Error(E(9));try{c=!0,r=n(r,v)}finally{c=!1}return(i=o).forEach(b=>{b()}),v}function f(v){if(typeof v!="function")throw new Error(E(10));n=v,p({type:me.REPLACE})}function g(){const v=m;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(E(11));function b(){const w=x;w.next&&w.next(u())}return b(),{unsubscribe:v(b)}},[lt](){return this}}}return p({type:me.INIT}),{dispatch:p,subscribe:m,getState:u,replaceReducer:f,[lt]:g}}function dn(e){Object.keys(e).forEach(s=>{const t=e[s];if(typeof t(void 0,{type:me.INIT})>"u")throw new Error(E(12));if(typeof t(void 0,{type:me.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(E(13))})}function un(e){const s=Object.keys(e),t={};for(let i=0;i<s.length;i++){const o=s[i];typeof e[o]=="function"&&(t[o]=e[o])}const n=Object.keys(t);let r;try{dn(t)}catch(i){r=i}return function(o={},l){if(r)throw r;let c=!1;const d={};for(let u=0;u<n.length;u++){const m=n[u],p=t[m],f=o[m],g=p(f,l);if(typeof g>"u")throw l&&l.type,new Error(E(14));d[m]=g,c=c||g!==f}return c=c||n.length!==Object.keys(o).length,c?d:o}}function pe(...e){return e.length===0?s=>s:e.length===1?e[0]:e.reduce((s,t)=>(...n)=>s(t(...n)))}function fn(...e){return s=>(t,n)=>{const r=s(t,n);let i=()=>{throw new Error(E(15))};const o={getState:r.getState,dispatch:(c,...d)=>i(c,...d)},l=e.map(c=>c(o));return i=pe(...l)(r.dispatch),{...r,dispatch:i}}}function hn(e){return Ze(e)&&"type"in e&&typeof e.type=="string"}var Gt=Symbol.for("immer-nothing"),ct=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function R(e,...s){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var O=Object,H=O.getPrototypeOf,xe="constructor",_e="prototype",Ve="configurable",ge="enumerable",fe="writable",Z="value",F=e=>!!e&&!!e[M];function D(e){var s;return e?Jt(e)||Ne(e)||!!e[ct]||!!((s=e[xe])!=null&&s[ct])||ke(e)||Ce(e):!1}var mn=O[_e][xe].toString(),dt=new WeakMap;function Jt(e){if(!e||!Qe(e))return!1;const s=H(e);if(s===null||s===O[_e])return!0;const t=O.hasOwnProperty.call(s,xe)&&s[xe];if(t===Object)return!0;if(!W(t))return!1;let n=dt.get(t);return n===void 0&&(n=Function.toString.call(t),dt.set(t,n)),n===mn}function Se(e,s,t=!0){se(e)===0?(t?Reflect.ownKeys(e):O.keys(e)).forEach(r=>{s(r,e[r],e)}):e.forEach((n,r)=>s(r,n,e))}function se(e){const s=e[M];return s?s.type_:Ne(e)?1:ke(e)?2:Ce(e)?3:0}var ut=(e,s,t=se(e))=>t===2?e.has(s):O[_e].hasOwnProperty.call(e,s),We=(e,s,t=se(e))=>t===2?e.get(s):e[s],ve=(e,s,t,n=se(e))=>{n===2?e.set(s,t):n===3?e.add(t):e[s]=t};function pn(e,s){return e===s?e!==0||1/e===1/s:e!==e&&s!==s}var Ne=Array.isArray,ke=e=>e instanceof Map,Ce=e=>e instanceof Set,Qe=e=>typeof e=="object",W=e=>typeof e=="function",De=e=>typeof e=="boolean";function xn(e){const s=+e;return Number.isInteger(s)&&String(s)===e}var P=e=>e.copy_||e.base_,et=e=>e.modified_?e.copy_:e.base_;function He(e,s){if(ke(e))return new Map(e);if(Ce(e))return new Set(e);if(Ne(e))return Array[_e].slice.call(e);const t=Jt(e);if(s===!0||s==="class_only"&&!t){const n=O.getOwnPropertyDescriptors(e);delete n[M];let r=Reflect.ownKeys(n);for(let i=0;i<r.length;i++){const o=r[i],l=n[o];l[fe]===!1&&(l[fe]=!0,l[Ve]=!0),(l.get||l.set)&&(n[o]={[Ve]:!0,[fe]:!0,[ge]:l[ge],[Z]:e[o]})}return O.create(H(e),n)}else{const n=H(e);if(n!==null&&t)return{...e};const r=O.create(n);return O.assign(r,e)}}function tt(e,s=!1){return Ee(e)||F(e)||!D(e)||(se(e)>1&&O.defineProperties(e,{set:ae,add:ae,clear:ae,delete:ae}),O.freeze(e),s&&Se(e,(t,n)=>{tt(n,!0)},!1)),e}function gn(){R(2)}var ae={[Z]:gn};function Ee(e){return e===null||!Qe(e)?!0:O.isFrozen(e)}var be="MapSet",qe="Patches",ft="ArrayMethods",Xt={};function B(e){const s=Xt[e];return s||R(0,e),s}var ht=e=>!!Xt[e],Q,Yt=()=>Q,vn=(e,s)=>({drafts_:[],parent_:e,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ht(be)?B(be):void 0,arrayMethodsPlugin_:ht(ft)?B(ft):void 0});function mt(e,s){s&&(e.patchPlugin_=B(qe),e.patches_=[],e.inversePatches_=[],e.patchListener_=s)}function Ke(e){Ge(e),e.drafts_.forEach(bn),e.drafts_=null}function Ge(e){e===Q&&(Q=e.parent_)}var pt=e=>Q=vn(Q,e);function bn(e){const s=e[M];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function xt(e,s){s.unfinalizedDrafts_=s.drafts_.length;const t=s.drafts_[0];if(e!==void 0&&e!==t){t[M].modified_&&(Ke(s),R(4)),D(e)&&(e=gt(s,e));const{patchPlugin_:r}=s;r&&r.generateReplacementPatches_(t[M].base_,e,s)}else e=gt(s,t);return yn(s,e,!0),Ke(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),e!==Gt?e:void 0}function gt(e,s){if(Ee(s))return s;const t=s[M];if(!t)return ye(s,e.handledSet_,e);if(!Ie(t,e))return s;if(!t.modified_)return t.base_;if(!t.finalized_){const{callbacks_:n}=t;if(n)for(;n.length>0;)n.pop()(e);es(t,e)}return t.copy_}function yn(e,s,t=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tt(s,t)}function Zt(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Ie=(e,s)=>e.scope_===s,wn=[];function Qt(e,s,t,n){const r=P(e),i=e.type_;if(n!==void 0&&We(r,n,i)===s){ve(r,n,t,i);return}if(!e.draftLocations_){const l=e.draftLocations_=new Map;Se(r,(c,d)=>{if(F(d)){const u=l.get(d)||[];u.push(c),l.set(d,u)}})}const o=e.draftLocations_.get(s)??wn;for(const l of o)ve(r,l,t,i)}function jn(e,s,t){e.callbacks_.push(function(r){var l;const i=s;if(!i||!Ie(i,r))return;(l=r.mapSetPlugin_)==null||l.fixSetContents(i);const o=et(i);Qt(e,i.draft_??i,o,t),es(i,r)})}function es(e,s){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:r}=s;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,s)}Zt(e)}}function _n(e,s,t){const{scope_:n}=e;if(F(t)){const r=t[M];Ie(r,n)&&r.callbacks_.push(function(){he(e);const o=et(r);Qt(e,t,o,s)})}else D(t)&&e.callbacks_.push(function(){const i=P(e);e.type_===3?i.has(t)&&ye(t,n.handledSet_,n):We(i,s,e.type_)===t&&n.drafts_.length>1&&(e.assigned_.get(s)??!1)===!0&&e.copy_&&ye(We(e.copy_,s,e.type_),n.handledSet_,n)})}function ye(e,s,t){return!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||F(e)||s.has(e)||!D(e)||Ee(e)||(s.add(e),Se(e,(n,r)=>{if(F(r)){const i=r[M];if(Ie(i,t)){const o=et(i);ve(e,n,o,e.type_),Zt(i)}}else D(r)&&ye(r,s,t)})),e}function Sn(e,s){const t=Ne(e),n={type_:t?1:0,scope_:s?s.scope_:Yt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let r=n,i=we;t&&(r=[n],i=ee);const{revoke:o,proxy:l}=Proxy.revocable(r,i);return n.draft_=l,n.revoke_=o,[l,n]}var we={get(e,s){if(s===M)return e;let t=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof s=="string";if(n&&t!=null&&t.isArrayOperationMethod(s))return t.createMethodInterceptor(e,s);const r=P(e);if(!ut(r,s,e.type_))return Nn(e,r,s);const i=r[s];if(e.finalized_||!D(i)||n&&e.operationMethod&&(t!=null&&t.isMutatingArrayMethod(e.operationMethod))&&xn(s))return i;if(i===ze(e.base_,s)){he(e);const o=e.type_===1?+s:s,l=Xe(e.scope_,i,e,o);return e.copy_[o]=l}return i},has(e,s){return s in P(e)},ownKeys(e){return Reflect.ownKeys(P(e))},set(e,s,t){const n=ts(P(e),s);if(n!=null&&n.set)return n.set.call(e.draft_,t),!0;if(!e.modified_){const r=ze(P(e),s),i=r==null?void 0:r[M];if(i&&i.base_===t)return e.copy_[s]=t,e.assigned_.set(s,!1),!0;if(pn(t,r)&&(t!==void 0||ut(e.base_,s,e.type_)))return!0;he(e),Je(e)}return e.copy_[s]===t&&(t!==void 0||s in e.copy_)||Number.isNaN(t)&&Number.isNaN(e.copy_[s])||(e.copy_[s]=t,e.assigned_.set(s,!0),_n(e,s,t)),!0},deleteProperty(e,s){return he(e),ze(e.base_,s)!==void 0||s in e.base_?(e.assigned_.set(s,!1),Je(e)):e.assigned_.delete(s),e.copy_&&delete e.copy_[s],!0},getOwnPropertyDescriptor(e,s){const t=P(e),n=Reflect.getOwnPropertyDescriptor(t,s);return n&&{[fe]:!0,[Ve]:e.type_!==1||s!=="length",[ge]:n[ge],[Z]:t[s]}},defineProperty(){R(11)},getPrototypeOf(e){return H(e.base_)},setPrototypeOf(){R(12)}},ee={};for(let e in we){let s=we[e];ee[e]=function(){const t=arguments;return t[0]=t[0][0],s.apply(this,t)}}ee.deleteProperty=function(e,s){return ee.set.call(this,e,s,void 0)};ee.set=function(e,s,t){return we.set.call(this,e[0],s,t,e[0])};function ze(e,s){const t=e[M];return(t?P(t):e)[s]}function Nn(e,s,t){var r;const n=ts(s,t);return n?Z in n?n[Z]:(r=n.get)==null?void 0:r.call(e.draft_):void 0}function ts(e,s){if(!(s in e))return;let t=H(e);for(;t;){const n=Object.getOwnPropertyDescriptor(t,s);if(n)return n;t=H(t)}}function Je(e){e.modified_||(e.modified_=!0,e.parent_&&Je(e.parent_))}function he(e){e.copy_||(e.assigned_=new Map,e.copy_=He(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,t,n)=>{if(W(s)&&!W(t)){const i=t;t=s;const o=this;return function(c=i,...d){return o.produce(c,u=>t.call(this,u,...d))}}W(t)||R(6),n!==void 0&&!W(n)&&R(7);let r;if(D(s)){const i=pt(this),o=Xe(i,s,void 0);let l=!0;try{r=t(o),l=!1}finally{l?Ke(i):Ge(i)}return mt(i,n),xt(r,i)}else if(!s||!Qe(s)){if(r=t(s),r===void 0&&(r=s),r===Gt&&(r=void 0),this.autoFreeze_&&tt(r,!0),n){const i=[],o=[];B(qe).generateReplacementPatches_(s,r,{patches_:i,inversePatches_:o}),n(i,o)}return r}else R(1,s)},this.produceWithPatches=(s,t)=>{if(W(s))return(o,...l)=>this.produceWithPatches(o,c=>s(c,...l));let n,r;return[this.produce(s,t,(o,l)=>{n=o,r=l}),n,r]},De(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),De(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),De(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){D(e)||R(8),F(e)&&(e=Cn(e));const s=pt(this),t=Xe(s,e,void 0);return t[M].isManual_=!0,Ge(s),t}finishDraft(e,s){const t=e&&e[M];(!t||!t.isManual_)&&R(9);const{scope_:n}=t;return mt(n,s),xt(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,s){let t;for(t=s.length-1;t>=0;t--){const r=s[t];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}t>-1&&(s=s.slice(t+1));const n=B(qe).applyPatches_;return F(e)?n(e,s):this.produce(e,r=>n(r,s))}};function Xe(e,s,t,n){const[r,i]=ke(s)?B(be).proxyMap_(s,t):Ce(s)?B(be).proxySet_(s,t):Sn(s,t);return((t==null?void 0:t.scope_)??Yt()).drafts_.push(r),i.callbacks_=(t==null?void 0:t.callbacks_)??[],i.key_=n,t&&n!==void 0?jn(t,i,n):i.callbacks_.push(function(c){var u;(u=c.mapSetPlugin_)==null||u.fixSetContents(i);const{patchPlugin_:d}=c;i.modified_&&d&&d.generatePatches_(i,[],c)}),r}function Cn(e){return F(e)||R(10,e),ss(e)}function ss(e){if(!D(e)||Ee(e))return e;const s=e[M];let t,n=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,t=He(e,s.scope_.immer_.useStrictShallowCopy_),n=s.scope_.immer_.shouldUseStrictIteration()}else t=He(e,!0);return Se(t,(r,i)=>{ve(t,r,ss(i))},n),s&&(s.finalized_=!1),t}var En=new kn,ns=En.produce;function In(e,s=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(s)}function An(e,s=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(s)}function Mn(e,s="expected all items to be functions, instead received the following types: "){if(!e.every(t=>typeof t=="function")){const t=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${s}[${t}]`)}}var vt=e=>Array.isArray(e)?e:[e];function Tn(e){const s=Array.isArray(e[0])?e[0]:e;return Mn(s,"createSelector expects all input-selectors to be functions, but received the following types: "),s}function On(e,s){const t=[],{length:n}=e;for(let r=0;r<n;r++)t.push(e[r].apply(null,s));return t}var Rn=class{constructor(e){this.value=e}deref(){return this.value}},Dn=typeof WeakRef<"u"?WeakRef:Rn,zn=0,bt=1;function oe(){return{s:zn,v:void 0,o:null,p:null}}function rs(e,s={}){let t=oe();const{resultEqualityCheck:n}=s;let r,i=0;function o(){var m;let l=t;const{length:c}=arguments;for(let p=0,f=c;p<f;p++){const g=arguments[p];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=l.o;y===null&&(l.o=y=new WeakMap);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}else{let y=l.p;y===null&&(l.p=y=new Map);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}}const d=l;let u;if(l.s===bt)u=l.v;else if(u=e.apply(null,arguments),i++,n){const p=((m=r==null?void 0:r.deref)==null?void 0:m.call(r))??r;p!=null&&n(p,u)&&(u=p,i!==0&&i--),r=typeof u=="object"&&u!==null||typeof u=="function"?new Dn(u):u}return d.s=bt,d.v=u,u}return o.clearCache=()=>{t=oe(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Pn(e,...s){const t=typeof e=="function"?{memoize:e,memoizeOptions:s}:e,n=(...r)=>{let i=0,o=0,l,c={},d=r.pop();typeof d=="object"&&(c=d,d=r.pop()),In(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const u={...t,...c},{memoize:m,memoizeOptions:p=[],argsMemoize:f=rs,argsMemoizeOptions:g=[]}=u,y=vt(p),v=vt(g),x=Tn(r),b=m(function(){return i++,d.apply(null,arguments)},...y),_=f(function(){o++;const j=On(x,arguments);return l=b.apply(null,j),l},...v);return Object.assign(_,{resultFunc:d,memoizedResultFunc:b,dependencies:x,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:m,argsMemoize:f})};return Object.assign(n,{withTypes:()=>n}),n}var q=Pn(rs),Ln=Object.assign((e,s=q)=>{An(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const t=Object.keys(e),n=t.map(i=>e[i]);return s(n,(...i)=>i.reduce((o,l,c)=>(o[t[c]]=l,o),{}))},{withTypes:()=>Ln});function is(e){return({dispatch:t,getState:n})=>r=>i=>typeof i=="function"?i(t,n,e):r(i)}var Fn=is(),$n=is,Un=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pe:pe.apply(null,arguments)},Bn=e=>e&&typeof e.match=="function";function X(e,s){function t(...n){if(s){let r=s(...n);if(!r)throw new Error(L(0));return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return t.toString=()=>`${e}`,t.type=e,t.match=n=>hn(n)&&n.type===e,t}var as=class G extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,G.prototype)}static get[Symbol.species](){return G}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new G(...s[0].concat(this)):new G(...s.concat(this))}};function yt(e){return D(e)?ns(e,()=>{}):e}function le(e,s,t){return e.has(s)?e.get(s):e.set(s,t(s)).get(s)}function Vn(e){return typeof e=="boolean"}var Wn=()=>function(s){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=s??{};let o=new as;return t&&(Vn(t)?o.push(Fn):o.push($n(t.extraArgument))),o},Hn="RTK_autoBatch",wt=e=>s=>{setTimeout(s,e)},qn=(e={type:"raf"})=>s=>(...t)=>{const n=s(...t);let r=!0,i=!1,o=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:wt(10):e.type==="callback"?e.queueNotification:wt(e.timeout),d=()=>{o=!1,i&&(i=!1,l.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){const m=()=>r&&u(),p=n.subscribe(m);return l.add(u),()=>{p(),l.delete(u)}},dispatch(u){var m;try{return r=!((m=u==null?void 0:u.meta)!=null&&m[Hn]),i=!r,i&&(o||(o=!0,c(d))),n.dispatch(u)}finally{r=!0}}})},Kn=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new as(e);return n&&r.push(qn(typeof n=="object"?n:void 0)),r};function Gn(e){const s=Wn(),{reducer:t=void 0,middleware:n,devTools:r=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let l;if(typeof t=="function")l=t;else if(Ze(t))l=un(t);else throw new Error(L(1));let c;typeof n=="function"?c=n(s):c=s();let d=pe;r&&(d=Un({trace:!1,...typeof r=="object"&&r}));const u=fn(...c),m=Kn(u);let p=typeof o=="function"?o(m):m();const f=d(...p);return Kt(l,i,f)}function os(e){const s={},t=[];let n;const r={addCase(i,o){const l=typeof i=="string"?i:i.type;if(!l)throw new Error(L(28));if(l in s)throw new Error(L(29));return s[l]=o,r},addAsyncThunk(i,o){return o.pending&&(s[i.pending.type]=o.pending),o.rejected&&(s[i.rejected.type]=o.rejected),o.fulfilled&&(s[i.fulfilled.type]=o.fulfilled),o.settled&&t.push({matcher:i.settled,reducer:o.settled}),r},addMatcher(i,o){return t.push({matcher:i,reducer:o}),r},addDefaultCase(i){return n=i,r}};return e(r),[s,t,n]}function Jn(e){return typeof e=="function"}function Xn(e,s){let[t,n,r]=os(s),i;if(Jn(e))i=()=>yt(e());else{const l=yt(e);i=()=>l}function o(l=i(),c){let d=[t[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return d.filter(u=>!!u).length===0&&(d=[r]),d.reduce((u,m)=>{if(m)if(F(u)){const f=m(u,c);return f===void 0?u:f}else{if(D(u))return ns(u,p=>m(p,c));{const p=m(u,c);if(p===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return u},l)}return o.getInitialState=i,o}var Yn=(e,s)=>Bn(e)?e.match(s):e(s);function Zn(...e){return s=>e.some(t=>Yn(t,s))}var Qn="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",er=(e=21)=>{let s="",t=e;for(;t--;)s+=Qn[Math.random()*64|0];return s},tr=["name","message","stack","code"],Pe=class{constructor(e,s){Me(this,"_type");this.payload=e,this.meta=s}},jt=class{constructor(e,s){Me(this,"_type");this.payload=e,this.meta=s}},sr=e=>{if(typeof e=="object"&&e!==null){const s={};for(const t of tr)typeof e[t]=="string"&&(s[t]=e[t]);return s}return{message:String(e)}},_t="External signal was aborted",nr=(()=>{function e(s,t,n){const r=X(s+"/fulfilled",(c,d,u,m)=>({payload:c,meta:{...m||{},arg:u,requestId:d,requestStatus:"fulfilled"}})),i=X(s+"/pending",(c,d,u)=>({payload:void 0,meta:{...u||{},arg:d,requestId:c,requestStatus:"pending"}})),o=X(s+"/rejected",(c,d,u,m,p)=>({payload:m,error:(n&&n.serializeError||sr)(c||"Rejected"),meta:{...p||{},arg:u,requestId:d,rejectedWithValue:!!m,requestStatus:"rejected",aborted:(c==null?void 0:c.name)==="AbortError",condition:(c==null?void 0:c.name)==="ConditionError"}}));function l(c,{signal:d}={}){return(u,m,p)=>{const f=n!=null&&n.idGenerator?n.idGenerator(c):er(),g=new AbortController;let y,v;function x(_){v=_,g.abort()}d&&(d.aborted?x(_t):d.addEventListener("abort",()=>x(_t),{once:!0}));const b=async function(){var j,N;let _;try{let C=(j=n==null?void 0:n.condition)==null?void 0:j.call(n,c,{getState:m,extra:p});if(ir(C)&&(C=await C),C===!1||g.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const I=new Promise((S,T)=>{y=()=>{T({name:"AbortError",message:v||"Aborted"})},g.signal.addEventListener("abort",y,{once:!0})});u(i(f,c,(N=n==null?void 0:n.getPendingMeta)==null?void 0:N.call(n,{requestId:f,arg:c},{getState:m,extra:p}))),_=await Promise.race([I,Promise.resolve(t(c,{dispatch:u,getState:m,extra:p,requestId:f,signal:g.signal,abort:x,rejectWithValue:(S,T)=>new Pe(S,T),fulfillWithValue:(S,T)=>new jt(S,T)})).then(S=>{if(S instanceof Pe)throw S;return S instanceof jt?r(S.payload,f,c,S.meta):r(S,f,c)})])}catch(C){_=C instanceof Pe?o(null,f,c,C.payload,C.meta):o(C,f,c)}finally{y&&g.signal.removeEventListener("abort",y)}return n&&!n.dispatchConditionRejection&&o.match(_)&&_.meta.condition||u(_),_}();return Object.assign(b,{abort:x,requestId:f,arg:c,unwrap(){return b.then(rr)}})}}return Object.assign(l,{pending:i,rejected:o,fulfilled:r,settled:Zn(o,r),typePrefix:s})}return e.withTypes=()=>e,e})();function rr(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function ir(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var ar=Symbol.for("rtk-slice-createasyncthunk");function or(e,s){return`${e}/${s}`}function lr({creators:e}={}){var t;const s=(t=e==null?void 0:e.asyncThunk)==null?void 0:t[ar];return function(r){const{name:i,reducerPath:o=i}=r;if(!i)throw new Error(L(11));const l=(typeof r.reducers=="function"?r.reducers(ur()):r.reducers)||{},c=Object.keys(l),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,j){const N=typeof w=="string"?w:w.type;if(!N)throw new Error(L(12));if(N in d.sliceCaseReducersByType)throw new Error(L(13));return d.sliceCaseReducersByType[N]=j,u},addMatcher(w,j){return d.sliceMatchers.push({matcher:w,reducer:j}),u},exposeAction(w,j){return d.actionCreators[w]=j,u},exposeCaseReducer(w,j){return d.sliceCaseReducersByName[w]=j,u}};c.forEach(w=>{const j=l[w],N={reducerName:w,type:or(i,w),createNotation:typeof r.reducers=="function"};hr(j)?pr(N,j,u,s):fr(N,j,u)});function m(){const[w={},j=[],N=void 0]=typeof r.extraReducers=="function"?os(r.extraReducers):[r.extraReducers],C={...w,...d.sliceCaseReducersByType};return Xn(r.initialState,I=>{for(let S in C)I.addCase(S,C[S]);for(let S of d.sliceMatchers)I.addMatcher(S.matcher,S.reducer);for(let S of j)I.addMatcher(S.matcher,S.reducer);N&&I.addDefaultCase(N)})}const p=w=>w,f=new Map,g=new WeakMap;let y;function v(w,j){return y||(y=m()),y(w,j)}function x(){return y||(y=m()),y.getInitialState()}function b(w,j=!1){function N(I){let S=I[w];return typeof S>"u"&&j&&(S=le(g,N,x)),S}function C(I=p){const S=le(f,j,()=>new WeakMap);return le(S,I,()=>{const T={};for(const[k,z]of Object.entries(r.selectors??{}))T[k]=cr(z,I,()=>le(g,I,x),j);return T})}return{reducerPath:w,getSelectors:C,get selectors(){return C(N)},selectSlice:N}}const _={name:i,reducer:v,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:x,...b(o),injectInto(w,{reducerPath:j,...N}={}){const C=j??o;return w.inject({reducerPath:C,reducer:v},N),{..._,...b(C,!0)}}};return _}}function cr(e,s,t,n){function r(i,...o){let l=s(i);return typeof l>"u"&&n&&(l=t()),e(l,...o)}return r.unwrapped=e,r}var dr=lr();function ur(){function e(s,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:s,...t}}return e.withTypes=()=>e,{reducer(s){return Object.assign({[s.name](...t){return s(...t)}}[s.name],{_reducerDefinitionType:"reducer"})},preparedReducer(s,t){return{_reducerDefinitionType:"reducerWithPrepare",prepare:s,reducer:t}},asyncThunk:e}}function fr({type:e,reducerName:s,createNotation:t},n,r){let i,o;if("reducer"in n){if(t&&!mr(n))throw new Error(L(17));i=n.reducer,o=n.prepare}else i=n;r.addCase(e,i).exposeCaseReducer(s,i).exposeAction(s,o?X(e,o):X(e))}function hr(e){return e._reducerDefinitionType==="asyncThunk"}function mr(e){return e._reducerDefinitionType==="reducerWithPrepare"}function pr({type:e,reducerName:s},t,n,r){if(!r)throw new Error(L(18));const{payloadCreator:i,fulfilled:o,pending:l,rejected:c,settled:d,options:u}=t,m=r(e,i,u);n.exposeAction(s,m),o&&n.addCase(m.fulfilled,o),l&&n.addCase(m.pending,l),c&&n.addCase(m.rejected,c),d&&n.addMatcher(m.settled,d),n.exposeCaseReducer(s,{fulfilled:o||ce,pending:l||ce,rejected:c||ce,settled:d||ce})}function ce(){}function L(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const xr=nr("runtime/fetchHistory",async({sessionId:e,before:s,limit:t=100})=>{const n=localStorage.getItem("cascade_token")??"",r=`/api/runtime/logs/${e}?limit=${t}${s?`&before=${s}`:""}`,i=await fetch(r,{headers:{Authorization:`Bearer ${n}`}});if(!i.ok)throw new Error("Failed to fetch history");const o=await i.json();return{sessionId:e,logs:o}}),gr={sessions:{},nodes:{},logIds:{},logs:{},activeSessionId:null,scope:"workspace",connected:!1};function St(e,s,t){for(const n of s){const r=n.sessionId??t??"",i=`${r}:${n.tierId}`;e[i]={...e[i],...n,sessionId:r}}}function de(e,s,t,n=1e3){e.logIds[s]||(e.logIds[s]=new Set),e.logs[s]||(e.logs[s]=[]);const r=e.logIds[s],i=e.logs[s];for(const o of t)r.has(o.id)||(r.add(o.id),i.push(o));if(i.length>n){const o=i.splice(0,i.length-n);for(const l of o)r.delete(l.id)}}const ls=dr({name:"runtime",initialState:gr,reducers:{setConnected(e,s){e.connected=s.payload},setScope(e,s){e.scope=s.payload},setActiveSession(e,s){e.activeSessionId=s.payload},updateRTKSnapshot(e,s){var o;const{sessions:t,nodes:n,logs:r,scope:i}=s.payload;(i==="workspace"||i==="global")&&(e.scope=i);for(const l of t)e.sessions[l.sessionId]={...e.sessions[l.sessionId]??{},...l};if(!e.activeSessionId&&t.length>0&&(e.activeSessionId=((o=t.find(l=>l.status==="ACTIVE"))==null?void 0:o.sessionId)??t[0].sessionId),n!=null&&n.length&&St(e.nodes,n),r!=null&&r.length)for(const l of r)l.sessionId&&de(e,l.sessionId,[l])},updateSessionDetails(e,s){var i;const{sessionId:t,nodes:n,logs:r}=s.payload;St(e.nodes,n,t),de(e,t,r),(i=e.logs[t])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())},appendLog(e,s){const t=s.payload;de(e,t.sessionId,[t])},clearFrontendGraphs(e){e.nodes={},e.logIds={},e.logs={}},removeSessionsBulk(e,s){var t,n;for(const r of s.payload){delete e.sessions[r];for(const i of Object.keys(e.nodes))((t=e.nodes[i])==null?void 0:t.sessionId)===r&&delete e.nodes[i];delete e.logs[r],delete e.logIds[r]}if(e.activeSessionId&&s.payload.includes(e.activeSessionId)){const r=Object.values(e.sessions);e.activeSessionId=((n=r[0])==null?void 0:n.sessionId)??null}}},extraReducers(e){e.addCase(xr.fulfilled,(s,t)=>{var i;const{sessionId:n,logs:r}=t.payload;de(s,n,r,2e3),(i=s.logs[n])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())})}}),{setConnected:Nt,setScope:Vi,setActiveSession:vr,updateRTKSnapshot:cs,updateSessionDetails:br,appendLog:yr,clearFrontendGraphs:kt,removeSessionsBulk:wr}=ls.actions,ne=e=>e.runtime,jr=q(ne,e=>Object.values(e.sessions).sort((s,t)=>new Date(t.updatedAt).getTime()-new Date(s.updatedAt).getTime())),st=q(ne,e=>e.activeSessionId?e.sessions[e.activeSessionId]??null:null),_r=q(ne,e=>e.activeSessionId?Object.values(e.nodes).filter(s=>s.sessionId===e.activeSessionId):[]),Sr=q(ne,e=>e.activeSessionId?e.logs[e.activeSessionId]??[]:[]),Nr=q(ne,e=>e.connected),kr=ls.reducer,Cr=Gn({reducer:{runtime:kr},middleware:e=>e({serializableCheck:{ignoredPaths:["runtime.logIds"]}})}),Ae=()=>nn(),U=on;var re={},nt={};function Er(e,s,t){for(var n=0,r=0,i=t.length;r<i;r++)n=t.charCodeAt(r),n<128?e.setUint8(s++,n):n<2048?(e.setUint8(s++,192|n>>6),e.setUint8(s++,128|n&63)):n<55296||n>=57344?(e.setUint8(s++,224|n>>12),e.setUint8(s++,128|n>>6&63),e.setUint8(s++,128|n&63)):(r++,n=65536+((n&1023)<<10|t.charCodeAt(r)&1023),e.setUint8(s++,240|n>>18),e.setUint8(s++,128|n>>12&63),e.setUint8(s++,128|n>>6&63),e.setUint8(s++,128|n&63))}function Ir(e){for(var s=0,t=0,n=0,r=e.length;n<r;n++)s=e.charCodeAt(n),s<128?t+=1:s<2048?t+=2:s<55296||s>=57344?t+=3:(n++,t+=4);return t}function J(e,s,t){var n=typeof t,r=0,i=0,o=0,l=0,c=0,d=0;if(n==="string"){if(c=Ir(t),c<32)e.push(c|160),d=1;else if(c<256)e.push(217,c),d=2;else if(c<65536)e.push(218,c>>8,c),d=3;else if(c<4294967296)e.push(219,c>>24,c>>16,c>>8,c),d=5;else throw new Error("String too long");return s.push({_str:t,_length:c,_offset:e.length}),d+c}if(n==="number")return Math.floor(t)!==t||!isFinite(t)?(e.push(203),s.push({_float:t,_length:8,_offset:e.length}),9):t>=0?t<128?(e.push(t),1):t<256?(e.push(204,t),2):t<65536?(e.push(205,t>>8,t),3):t<4294967296?(e.push(206,t>>24,t>>16,t>>8,t),5):(o=t/Math.pow(2,32)>>0,l=t>>>0,e.push(207,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9):t>=-32?(e.push(t),1):t>=-128?(e.push(208,t),2):t>=-32768?(e.push(209,t>>8,t),3):t>=-2147483648?(e.push(210,t>>24,t>>16,t>>8,t),5):(o=Math.floor(t/Math.pow(2,32)),l=t>>>0,e.push(211,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9);if(n==="object"){if(t===null)return e.push(192),1;if(Array.isArray(t)){if(c=t.length,c<16)e.push(c|144),d=1;else if(c<65536)e.push(220,c>>8,c),d=3;else if(c<4294967296)e.push(221,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Array too large");for(r=0;r<c;r++)d+=J(e,s,t[r]);return d}if(t instanceof Date){var u=t.getTime();return o=Math.floor(u/Math.pow(2,32)),l=u>>>0,e.push(215,0,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),10}if(t instanceof ArrayBuffer){if(c=t.byteLength,c<256)e.push(196,c),d=2;else if(c<65536)e.push(197,c>>8,c),d=3;else if(c<4294967296)e.push(198,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Buffer too large");return s.push({_bin:t,_length:c,_offset:e.length}),d+c}if(typeof t.toJSON=="function")return J(e,s,t.toJSON());var m=[],p="",f=Object.keys(t);for(r=0,i=f.length;r<i;r++)p=f[r],typeof t[p]!="function"&&m.push(p);if(c=m.length,c<16)e.push(c|128),d=1;else if(c<65536)e.push(222,c>>8,c),d=3;else if(c<4294967296)e.push(223,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Object too large");for(r=0;r<c;r++)p=m[r],d+=J(e,s,p),d+=J(e,s,t[p]);return d}if(n==="boolean")return e.push(t?195:194),1;if(n==="undefined")return e.push(212,0,0),3;throw new Error("Could not encode")}function Ar(e){var s=[],t=[],n=J(s,t,e),r=new ArrayBuffer(n),i=new DataView(r),o=0,l=0,c=-1;t.length>0&&(c=t[0]._offset);for(var d,u=0,m=0,p=0,f=s.length;p<f;p++)if(i.setUint8(l+p,s[p]),p+1===c){if(d=t[o],u=d._length,m=l+c,d._bin)for(var g=new Uint8Array(d._bin),y=0;y<u;y++)i.setUint8(m+y,g[y]);else d._str?Er(i,m,d._str):d._float!==void 0&&i.setFloat64(m,d._float);o++,l+=u,t[o]&&(c=t[o]._offset)}return r}var Mr=Ar;function K(e){if(this._offset=0,e instanceof ArrayBuffer)this._buffer=e,this._view=new DataView(this._buffer);else if(ArrayBuffer.isView(e))this._buffer=e.buffer,this._view=new DataView(this._buffer,e.byteOffset,e.byteLength);else throw new Error("Invalid argument")}function Tr(e,s,t){for(var n="",r=0,i=s,o=s+t;i<o;i++){var l=e.getUint8(i);if(!(l&128)){n+=String.fromCharCode(l);continue}if((l&224)===192){n+=String.fromCharCode((l&31)<<6|e.getUint8(++i)&63);continue}if((l&240)===224){n+=String.fromCharCode((l&15)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0);continue}if((l&248)===240){r=(l&7)<<18|(e.getUint8(++i)&63)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0,r>=65536?(r-=65536,n+=String.fromCharCode((r>>>10)+55296,(r&1023)+56320)):n+=String.fromCharCode(r);continue}throw new Error("Invalid byte "+l.toString(16))}return n}K.prototype._array=function(e){for(var s=new Array(e),t=0;t<e;t++)s[t]=this._parse();return s};K.prototype._map=function(e){for(var s="",t={},n=0;n<e;n++)s=this._parse(),t[s]=this._parse();return t};K.prototype._str=function(e){var s=Tr(this._view,this._offset,e);return this._offset+=e,s};K.prototype._bin=function(e){var s=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,s};K.prototype._parse=function(){var e=this._view.getUint8(this._offset++),s,t=0,n=0,r=0,i=0;if(e<192)return e<128?e:e<144?this._map(e&15):e<160?this._array(e&15):this._str(e&31);if(e>223)return(255-e+1)*-1;switch(e){case 192:return null;case 194:return!1;case 195:return!0;case 196:return t=this._view.getUint8(this._offset),this._offset+=1,this._bin(t);case 197:return t=this._view.getUint16(this._offset),this._offset+=2,this._bin(t);case 198:return t=this._view.getUint32(this._offset),this._offset+=4,this._bin(t);case 199:return t=this._view.getUint8(this._offset),n=this._view.getInt8(this._offset+1),this._offset+=2,[n,this._bin(t)];case 200:return t=this._view.getUint16(this._offset),n=this._view.getInt8(this._offset+2),this._offset+=3,[n,this._bin(t)];case 201:return t=this._view.getUint32(this._offset),n=this._view.getInt8(this._offset+4),this._offset+=5,[n,this._bin(t)];case 202:return s=this._view.getFloat32(this._offset),this._offset+=4,s;case 203:return s=this._view.getFloat64(this._offset),this._offset+=8,s;case 204:return s=this._view.getUint8(this._offset),this._offset+=1,s;case 205:return s=this._view.getUint16(this._offset),this._offset+=2,s;case 206:return s=this._view.getUint32(this._offset),this._offset+=4,s;case 207:return r=this._view.getUint32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 208:return s=this._view.getInt8(this._offset),this._offset+=1,s;case 209:return s=this._view.getInt16(this._offset),this._offset+=2,s;case 210:return s=this._view.getInt32(this._offset),this._offset+=4,s;case 211:return r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 212:if(n=this._view.getInt8(this._offset),this._offset+=1,n===0){this._offset+=1;return}return[n,this._bin(1)];case 213:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(2)];case 214:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(4)];case 215:return n=this._view.getInt8(this._offset),this._offset+=1,n===0?(r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,new Date(r+i)):[n,this._bin(8)];case 216:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(16)];case 217:return t=this._view.getUint8(this._offset),this._offset+=1,this._str(t);case 218:return t=this._view.getUint16(this._offset),this._offset+=2,this._str(t);case 219:return t=this._view.getUint32(this._offset),this._offset+=4,this._str(t);case 220:return t=this._view.getUint16(this._offset),this._offset+=2,this._array(t);case 221:return t=this._view.getUint32(this._offset),this._offset+=4,this._array(t);case 222:return t=this._view.getUint16(this._offset),this._offset+=2,this._map(t);case 223:return t=this._view.getUint32(this._offset),this._offset+=4,this._map(t)}throw new Error("Could not parse")};function Or(e){var s=new K(e),t=s._parse();if(s._offset!==e.byteLength)throw new Error(e.byteLength-s._offset+" trailing bytes");return t}var Rr=Or;nt.encode=Mr;nt.decode=Rr;var ds={exports:{}};(function(e){e.exports=s;function s(n){if(n)return t(n)}function t(n){for(var r in s.prototype)n[r]=s.prototype[r];return n}s.prototype.on=s.prototype.addEventListener=function(n,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(r),this},s.prototype.once=function(n,r){function i(){this.off(n,i),r.apply(this,arguments)}return i.fn=r,this.on(n,i),this},s.prototype.off=s.prototype.removeListener=s.prototype.removeAllListeners=s.prototype.removeEventListener=function(n,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,l=0;l<i.length;l++)if(o=i[l],o===r||o.fn===r){i.splice(l,1);break}return i.length===0&&delete this._callbacks["$"+n],this},s.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,l=i.length;o<l;++o)i[o].apply(this,r)}return this},s.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},s.prototype.hasListeners=function(n){return!!this.listeners(n).length}})(ds);var Dr=ds.exports,us=nt,zr=Dr;re.protocol=5;var Y=re.PacketType={CONNECT:0,DISCONNECT:1,EVENT:2,ACK:3,CONNECT_ERROR:4},Ct=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},fs=function(e){return typeof e=="string"},Et=function(e){return Object.prototype.toString.call(e)==="[object Object]"};function hs(){}hs.prototype.encode=function(e){return[us.encode(e)]};function ie(){}zr(ie.prototype);ie.prototype.add=function(e){var s=us.decode(e);this.checkPacket(s),this.emit("decoded",s)};function Pr(e){switch(e.type){case Y.CONNECT:return e.data===void 0||Et(e.data);case Y.DISCONNECT:return e.data===void 0;case Y.CONNECT_ERROR:return fs(e.data)||Et(e.data);default:return Array.isArray(e.data)}}ie.prototype.checkPacket=function(e){var s=Ct(e.type)&&e.type>=Y.CONNECT&&e.type<=Y.CONNECT_ERROR;if(!s)throw new Error("invalid packet type");if(!fs(e.nsp))throw new Error("invalid namespace");if(!Pr(e))throw new Error("invalid payload");var t=e.id===void 0||Ct(e.id);if(!t)throw new Error("invalid packet id")};ie.prototype.destroy=function(){};re.Encoder=hs;re.Decoder=ie;function Lr({url:e="/",token:s,activeSessionId:t,onRuntimeRefresh:n,onStreamToken:r,onCostUpdate:i,onEscalation:o}={}){const[l,c]=h.useState(null),d=Ae(),u=h.useRef(n),m=h.useRef(r),p=h.useRef(i),f=h.useRef(o);u.current=n,m.current=r,p.current=i,f.current=o;const g=h.useRef(t);g.current=t;const y=h.useRef(null);return h.useEffect(()=>{const v=Es(e,{auth:s?{token:s}:{},transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,parser:re});return v.on("connect",()=>{d(Nt(!0)),v.emit("runtime:refresh",{scope:"workspace"});const x=g.current;x&&(v.emit("join:session",{sessionId:x}),y.current=x),c(v)}),v.on("disconnect",()=>{d(Nt(!1)),c(null)}),v.on("runtime:update",x=>{d(cs(x))}),v.on("session:details",x=>{d(br(x))}),v.on("log:new",x=>{d(yr(x))}),v.on("runtime:refresh",x=>{var _;const b=x;(_=u.current)==null||_.call(u,b==null?void 0:b.scope)}),v.on("stream:token",x=>{var b;(b=m.current)==null||b.call(m,x)}),v.on("cost:update",x=>{var b;(b=p.current)==null||b.call(p,x)}),v.on("permission:user-required",x=>{var b;(b=f.current)==null||b.call(f,x)}),()=>{v.disconnect(),c(null),y.current=null}},[e,s,d]),h.useEffect(()=>{l&&t!==y.current&&(y.current&&l.emit("leave:session",{sessionId:y.current}),t&&l.emit("join:session",{sessionId:t}),y.current=t??null)},[l,t]),{socket:l}}const Fr=h.memo(function({onLogin:s}){const[t,n]=h.useState(""),[r,i]=h.useState(""),[o,l]=h.useState(!1),c=async d=>{if(d.preventDefault(),!!t.trim()){l(!0),i("");try{const u=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:"admin",password:t})});if(u.ok){const m=await u.json();s(m.token)}else i("Invalid token — check your cascade dashboard config.")}catch{i("Cannot reach server. Is the dashboard running?")}finally{l(!1)}}};return a.jsxs("div",{className:"relative flex items-center justify-center w-full h-full bg-[var(--bg-base)] dot-grid overflow-hidden",children:[a.jsx("div",{className:"absolute top-[20%] left-[30%] w-[480px] h-[480px] rounded-full bg-[var(--accent)] opacity-[0.035] blur-[140px] pointer-events-none"}),a.jsx("div",{className:"absolute bottom-[20%] right-[25%] w-[320px] h-[320px] rounded-full bg-[var(--t3-color)] opacity-[0.03] blur-[120px] pointer-events-none"}),a.jsxs("form",{onSubmit:c,"aria-label":"Cascade AI login",className:`
|
|
17
|
+
*/var te=h;function Ds(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zs=typeof Object.is=="function"?Object.is:Ds,Ps=te.useSyncExternalStore,Ls=te.useRef,Fs=te.useEffect,$s=te.useMemo,Us=te.useDebugValue;Ht.useSyncExternalStoreWithSelector=function(e,t,s,n,r){var i=Ls(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=$s(function(){function c(f){if(!d){if(d=!0,u=f,f=n(f),r!==void 0&&o.hasValue){var g=o.value;if(r(g,f))return m=g}return m=f}if(g=m,zs(u,f))return g;var y=n(f);return r!==void 0&&r(g,y)?(u=f,g):(u=f,m=y)}var d=!1,u,m,p=s===void 0?null:s;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,s,n,r]);var l=Ps(e,i[0],i[1]);return Fs(function(){o.hasValue=!0,o.value=l},[l]),Us(l),l};Wt.exports=Ht;var Bs=Wt.exports;function Vs(e){e()}function Ws(){let e=null,t=null;return{clear(){e=null,t=null},notify(){Vs(()=>{let s=e;for(;s;)s.callback(),s=s.next})},get(){const s=[];let n=e;for(;n;)s.push(n),n=n.next;return s},subscribe(s){let n=!0;const r=t={callback:s,next:null,prev:t};return r.prev?r.prev.next=r:e=r,function(){!n||e===null||(n=!1,r.next?r.next.prev=r.prev:t=r.prev,r.prev?r.prev.next=r.next:e=r.next)}}}}var lt={notify(){},get:()=>[]};function Hs(e,t){let s,n=lt,r=0,i=!1;function o(y){u();const v=n.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),m())}}function l(){n.notify()}function c(){g.onStateChange&&g.onStateChange()}function d(){return i}function u(){r++,s||(s=e.subscribe(c),n=Ws())}function m(){r--,s&&r===0&&(s(),s=void 0,n.clear(),n=lt)}function p(){i||(i=!0,u())}function f(){i&&(i=!1,m())}const g={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:p,tryUnsubscribe:f,getListeners:()=>n};return g}var qs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ks=qs(),Gs=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Js=Gs(),Xs=()=>Ks||Js?h.useLayoutEffect:h.useEffect,Ys=Xs(),Oe=Symbol.for("react-redux-context"),Re=typeof globalThis<"u"?globalThis:{};function Zs(){if(!h.createContext)return{};const e=Re[Oe]??(Re[Oe]=new Map);let t=e.get(h.createContext);return t||(t=h.createContext(null),e.set(h.createContext,t)),t}var $=Zs();function Qs(e){const{children:t,context:s,serverState:n,store:r}=e,i=h.useMemo(()=>{const c=Hs(r);return{store:r,subscription:c,getServerState:n?()=>n:void 0}},[r,n]),o=h.useMemo(()=>r.getState(),[r]);Ys(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==r.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,o]);const l=s||$;return h.createElement(l.Provider,{value:i},t)}var en=Qs;function Ze(e=$){return function(){return h.useContext(e)}}var qt=Ze();function Kt(e=$){const t=e===$?qt:Ze(e),s=()=>{const{store:n}=t();return n};return Object.assign(s,{withTypes:()=>s}),s}var tn=Kt();function sn(e=$){const t=e===$?tn:Kt(e),s=()=>t().dispatch;return Object.assign(s,{withTypes:()=>s}),s}var nn=sn(),rn=(e,t)=>e===t;function an(e=$){const t=e===$?qt:Ze(e),s=(n,r={})=>{const{equalityFn:i=rn}=typeof r=="function"?{equalityFn:r}:r,o=t(),{store:l,subscription:c,getServerState:d}=o;h.useRef(!0);const u=h.useCallback({[n.name](p){return n(p)}}[n.name],[n]),m=Bs.useSyncExternalStoreWithSelector(c.addNestedSub,l.getState,d||l.getState,u,i);return h.useDebugValue(m),m};return Object.assign(s,{withTypes:()=>s}),s}var on=an();function E(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ln=typeof Symbol=="function"&&Symbol.observable||"@@observable",ct=ln,De=()=>Math.random().toString(36).substring(7).split("").join("."),cn={INIT:`@@redux/INIT${De()}`,REPLACE:`@@redux/REPLACE${De()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${De()}`},me=cn;function Qe(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Gt(e,t,s){if(typeof e!="function")throw new Error(E(2));if(typeof t=="function"&&typeof s=="function"||typeof s=="function"&&typeof arguments[3]=="function")throw new Error(E(0));if(typeof t=="function"&&typeof s>"u"&&(s=t,t=void 0),typeof s<"u"){if(typeof s!="function")throw new Error(E(1));return s(Gt)(e,t)}let n=e,r=t,i=new Map,o=i,l=0,c=!1;function d(){o===i&&(o=new Map,i.forEach((v,x)=>{o.set(x,v)}))}function u(){if(c)throw new Error(E(3));return r}function m(v){if(typeof v!="function")throw new Error(E(4));if(c)throw new Error(E(5));let x=!0;d();const b=l++;return o.set(b,v),function(){if(x){if(c)throw new Error(E(6));x=!1,d(),o.delete(b),i=null}}}function p(v){if(!Qe(v))throw new Error(E(7));if(typeof v.type>"u")throw new Error(E(8));if(typeof v.type!="string")throw new Error(E(17));if(c)throw new Error(E(9));try{c=!0,r=n(r,v)}finally{c=!1}return(i=o).forEach(b=>{b()}),v}function f(v){if(typeof v!="function")throw new Error(E(10));n=v,p({type:me.REPLACE})}function g(){const v=m;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(E(11));function b(){const w=x;w.next&&w.next(u())}return b(),{unsubscribe:v(b)}},[ct](){return this}}}return p({type:me.INIT}),{dispatch:p,subscribe:m,getState:u,replaceReducer:f,[ct]:g}}function dn(e){Object.keys(e).forEach(t=>{const s=e[t];if(typeof s(void 0,{type:me.INIT})>"u")throw new Error(E(12));if(typeof s(void 0,{type:me.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(E(13))})}function un(e){const t=Object.keys(e),s={};for(let i=0;i<t.length;i++){const o=t[i];typeof e[o]=="function"&&(s[o]=e[o])}const n=Object.keys(s);let r;try{dn(s)}catch(i){r=i}return function(o={},l){if(r)throw r;let c=!1;const d={};for(let u=0;u<n.length;u++){const m=n[u],p=s[m],f=o[m],g=p(f,l);if(typeof g>"u")throw l&&l.type,new Error(E(14));d[m]=g,c=c||g!==f}return c=c||n.length!==Object.keys(o).length,c?d:o}}function pe(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,s)=>(...n)=>t(s(...n)))}function fn(...e){return t=>(s,n)=>{const r=t(s,n);let i=()=>{throw new Error(E(15))};const o={getState:r.getState,dispatch:(c,...d)=>i(c,...d)},l=e.map(c=>c(o));return i=pe(...l)(r.dispatch),{...r,dispatch:i}}}function hn(e){return Qe(e)&&"type"in e&&typeof e.type=="string"}var Jt=Symbol.for("immer-nothing"),dt=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function R(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var O=Object,H=O.getPrototypeOf,xe="constructor",_e="prototype",We="configurable",ge="enumerable",fe="writable",Z="value",F=e=>!!e&&!!e[M];function D(e){var t;return e?Xt(e)||Ne(e)||!!e[dt]||!!((t=e[xe])!=null&&t[dt])||Ce(e)||ke(e):!1}var mn=O[_e][xe].toString(),ut=new WeakMap;function Xt(e){if(!e||!et(e))return!1;const t=H(e);if(t===null||t===O[_e])return!0;const s=O.hasOwnProperty.call(t,xe)&&t[xe];if(s===Object)return!0;if(!W(s))return!1;let n=ut.get(s);return n===void 0&&(n=Function.toString.call(s),ut.set(s,n)),n===mn}function Se(e,t,s=!0){se(e)===0?(s?Reflect.ownKeys(e):O.keys(e)).forEach(r=>{t(r,e[r],e)}):e.forEach((n,r)=>t(r,n,e))}function se(e){const t=e[M];return t?t.type_:Ne(e)?1:Ce(e)?2:ke(e)?3:0}var ft=(e,t,s=se(e))=>s===2?e.has(t):O[_e].hasOwnProperty.call(e,t),He=(e,t,s=se(e))=>s===2?e.get(t):e[t],ve=(e,t,s,n=se(e))=>{n===2?e.set(t,s):n===3?e.add(s):e[t]=s};function pn(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ne=Array.isArray,Ce=e=>e instanceof Map,ke=e=>e instanceof Set,et=e=>typeof e=="object",W=e=>typeof e=="function",ze=e=>typeof e=="boolean";function xn(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var P=e=>e.copy_||e.base_,tt=e=>e.modified_?e.copy_:e.base_;function qe(e,t){if(Ce(e))return new Map(e);if(ke(e))return new Set(e);if(Ne(e))return Array[_e].slice.call(e);const s=Xt(e);if(t===!0||t==="class_only"&&!s){const n=O.getOwnPropertyDescriptors(e);delete n[M];let r=Reflect.ownKeys(n);for(let i=0;i<r.length;i++){const o=r[i],l=n[o];l[fe]===!1&&(l[fe]=!0,l[We]=!0),(l.get||l.set)&&(n[o]={[We]:!0,[fe]:!0,[ge]:l[ge],[Z]:e[o]})}return O.create(H(e),n)}else{const n=H(e);if(n!==null&&s)return{...e};const r=O.create(n);return O.assign(r,e)}}function st(e,t=!1){return Ee(e)||F(e)||!D(e)||(se(e)>1&&O.defineProperties(e,{set:ae,add:ae,clear:ae,delete:ae}),O.freeze(e),t&&Se(e,(s,n)=>{st(n,!0)},!1)),e}function gn(){R(2)}var ae={[Z]:gn};function Ee(e){return e===null||!et(e)?!0:O.isFrozen(e)}var be="MapSet",Ke="Patches",ht="ArrayMethods",Yt={};function B(e){const t=Yt[e];return t||R(0,e),t}var mt=e=>!!Yt[e],Q,Zt=()=>Q,vn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:mt(be)?B(be):void 0,arrayMethodsPlugin_:mt(ht)?B(ht):void 0});function pt(e,t){t&&(e.patchPlugin_=B(Ke),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ge(e){Je(e),e.drafts_.forEach(bn),e.drafts_=null}function Je(e){e===Q&&(Q=e.parent_)}var xt=e=>Q=vn(Q,e);function bn(e){const t=e[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const s=t.drafts_[0];if(e!==void 0&&e!==s){s[M].modified_&&(Ge(t),R(4)),D(e)&&(e=vt(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(s[M].base_,e,t)}else e=vt(t,s);return yn(t,e,!0),Ge(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Jt?e:void 0}function vt(e,t){if(Ee(t))return t;const s=t[M];if(!s)return ye(t,e.handledSet_,e);if(!Ie(s,e))return t;if(!s.modified_)return s.base_;if(!s.finalized_){const{callbacks_:n}=s;if(n)for(;n.length>0;)n.pop()(e);ts(s,e)}return s.copy_}function yn(e,t,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&st(t,s)}function Qt(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Ie=(e,t)=>e.scope_===t,wn=[];function es(e,t,s,n){const r=P(e),i=e.type_;if(n!==void 0&&He(r,n,i)===t){ve(r,n,s,i);return}if(!e.draftLocations_){const l=e.draftLocations_=new Map;Se(r,(c,d)=>{if(F(d)){const u=l.get(d)||[];u.push(c),l.set(d,u)}})}const o=e.draftLocations_.get(t)??wn;for(const l of o)ve(r,l,s,i)}function jn(e,t,s){e.callbacks_.push(function(r){var l;const i=t;if(!i||!Ie(i,r))return;(l=r.mapSetPlugin_)==null||l.fixSetContents(i);const o=tt(i);es(e,i.draft_??i,o,s),ts(i,r)})}function ts(e,t){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}Qt(e)}}function _n(e,t,s){const{scope_:n}=e;if(F(s)){const r=s[M];Ie(r,n)&&r.callbacks_.push(function(){he(e);const o=tt(r);es(e,s,o,t)})}else D(s)&&e.callbacks_.push(function(){const i=P(e);e.type_===3?i.has(s)&&ye(s,n.handledSet_,n):He(i,t,e.type_)===s&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&ye(He(e.copy_,t,e.type_),n.handledSet_,n)})}function ye(e,t,s){return!s.immer_.autoFreeze_&&s.unfinalizedDrafts_<1||F(e)||t.has(e)||!D(e)||Ee(e)||(t.add(e),Se(e,(n,r)=>{if(F(r)){const i=r[M];if(Ie(i,s)){const o=tt(i);ve(e,n,o,e.type_),Qt(i)}}else D(r)&&ye(r,t,s)})),e}function Sn(e,t){const s=Ne(e),n={type_:s?1:0,scope_:t?t.scope_:Zt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let r=n,i=we;s&&(r=[n],i=ee);const{revoke:o,proxy:l}=Proxy.revocable(r,i);return n.draft_=l,n.revoke_=o,[l,n]}var we={get(e,t){if(t===M)return e;let s=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof t=="string";if(n&&s!=null&&s.isArrayOperationMethod(t))return s.createMethodInterceptor(e,t);const r=P(e);if(!ft(r,t,e.type_))return Nn(e,r,t);const i=r[t];if(e.finalized_||!D(i)||n&&e.operationMethod&&(s!=null&&s.isMutatingArrayMethod(e.operationMethod))&&xn(t))return i;if(i===Pe(e.base_,t)){he(e);const o=e.type_===1?+t:t,l=Ye(e.scope_,i,e,o);return e.copy_[o]=l}return i},has(e,t){return t in P(e)},ownKeys(e){return Reflect.ownKeys(P(e))},set(e,t,s){const n=ss(P(e),t);if(n!=null&&n.set)return n.set.call(e.draft_,s),!0;if(!e.modified_){const r=Pe(P(e),t),i=r==null?void 0:r[M];if(i&&i.base_===s)return e.copy_[t]=s,e.assigned_.set(t,!1),!0;if(pn(s,r)&&(s!==void 0||ft(e.base_,t,e.type_)))return!0;he(e),Xe(e)}return e.copy_[t]===s&&(s!==void 0||t in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=s,e.assigned_.set(t,!0),_n(e,t,s)),!0},deleteProperty(e,t){return he(e),Pe(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Xe(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const s=P(e),n=Reflect.getOwnPropertyDescriptor(s,t);return n&&{[fe]:!0,[We]:e.type_!==1||t!=="length",[ge]:n[ge],[Z]:s[t]}},defineProperty(){R(11)},getPrototypeOf(e){return H(e.base_)},setPrototypeOf(){R(12)}},ee={};for(let e in we){let t=we[e];ee[e]=function(){const s=arguments;return s[0]=s[0][0],t.apply(this,s)}}ee.deleteProperty=function(e,t){return ee.set.call(this,e,t,void 0)};ee.set=function(e,t,s){return we.set.call(this,e[0],t,s,e[0])};function Pe(e,t){const s=e[M];return(s?P(s):e)[t]}function Nn(e,t,s){var r;const n=ss(t,s);return n?Z in n?n[Z]:(r=n.get)==null?void 0:r.call(e.draft_):void 0}function ss(e,t){if(!(t in e))return;let s=H(e);for(;s;){const n=Object.getOwnPropertyDescriptor(s,t);if(n)return n;s=H(s)}}function Xe(e){e.modified_||(e.modified_=!0,e.parent_&&Xe(e.parent_))}function he(e){e.copy_||(e.assigned_=new Map,e.copy_=qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Cn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,s,n)=>{if(W(t)&&!W(s)){const i=s;s=t;const o=this;return function(c=i,...d){return o.produce(c,u=>s.call(this,u,...d))}}W(s)||R(6),n!==void 0&&!W(n)&&R(7);let r;if(D(t)){const i=xt(this),o=Ye(i,t,void 0);let l=!0;try{r=s(o),l=!1}finally{l?Ge(i):Je(i)}return pt(i,n),gt(r,i)}else if(!t||!et(t)){if(r=s(t),r===void 0&&(r=t),r===Jt&&(r=void 0),this.autoFreeze_&&st(r,!0),n){const i=[],o=[];B(Ke).generateReplacementPatches_(t,r,{patches_:i,inversePatches_:o}),n(i,o)}return r}else R(1,t)},this.produceWithPatches=(t,s)=>{if(W(t))return(o,...l)=>this.produceWithPatches(o,c=>t(c,...l));let n,r;return[this.produce(t,s,(o,l)=>{n=o,r=l}),n,r]},ze(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),ze(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),ze(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){D(e)||R(8),F(e)&&(e=kn(e));const t=xt(this),s=Ye(t,e,void 0);return s[M].isManual_=!0,Je(t),s}finishDraft(e,t){const s=e&&e[M];(!s||!s.isManual_)&&R(9);const{scope_:n}=s;return pt(n,t),gt(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let s;for(s=t.length-1;s>=0;s--){const r=t[s];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}s>-1&&(t=t.slice(s+1));const n=B(Ke).applyPatches_;return F(e)?n(e,t):this.produce(e,r=>n(r,t))}};function Ye(e,t,s,n){const[r,i]=Ce(t)?B(be).proxyMap_(t,s):ke(t)?B(be).proxySet_(t,s):Sn(t,s);return((s==null?void 0:s.scope_)??Zt()).drafts_.push(r),i.callbacks_=(s==null?void 0:s.callbacks_)??[],i.key_=n,s&&n!==void 0?jn(s,i,n):i.callbacks_.push(function(c){var u;(u=c.mapSetPlugin_)==null||u.fixSetContents(i);const{patchPlugin_:d}=c;i.modified_&&d&&d.generatePatches_(i,[],c)}),r}function kn(e){return F(e)||R(10,e),ns(e)}function ns(e){if(!D(e)||Ee(e))return e;const t=e[M];let s,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,s=qe(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else s=qe(e,!0);return Se(s,(r,i)=>{ve(s,r,ns(i))},n),t&&(t.finalized_=!1),s}var En=new Cn,rs=En.produce;function In(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function An(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function Mn(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(s=>typeof s=="function")){const s=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${s}]`)}}var bt=e=>Array.isArray(e)?e:[e];function Tn(e){const t=Array.isArray(e[0])?e[0]:e;return Mn(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function On(e,t){const s=[],{length:n}=e;for(let r=0;r<n;r++)s.push(e[r].apply(null,t));return s}var Rn=class{constructor(e){this.value=e}deref(){return this.value}},Dn=typeof WeakRef<"u"?WeakRef:Rn,zn=0,yt=1;function oe(){return{s:zn,v:void 0,o:null,p:null}}function is(e,t={}){let s=oe();const{resultEqualityCheck:n}=t;let r,i=0;function o(){var m;let l=s;const{length:c}=arguments;for(let p=0,f=c;p<f;p++){const g=arguments[p];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=l.o;y===null&&(l.o=y=new WeakMap);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}else{let y=l.p;y===null&&(l.p=y=new Map);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}}const d=l;let u;if(l.s===yt)u=l.v;else if(u=e.apply(null,arguments),i++,n){const p=((m=r==null?void 0:r.deref)==null?void 0:m.call(r))??r;p!=null&&n(p,u)&&(u=p,i!==0&&i--),r=typeof u=="object"&&u!==null||typeof u=="function"?new Dn(u):u}return d.s=yt,d.v=u,u}return o.clearCache=()=>{s=oe(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Pn(e,...t){const s=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...r)=>{let i=0,o=0,l,c={},d=r.pop();typeof d=="object"&&(c=d,d=r.pop()),In(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const u={...s,...c},{memoize:m,memoizeOptions:p=[],argsMemoize:f=is,argsMemoizeOptions:g=[]}=u,y=bt(p),v=bt(g),x=Tn(r),b=m(function(){return i++,d.apply(null,arguments)},...y),_=f(function(){o++;const j=On(x,arguments);return l=b.apply(null,j),l},...v);return Object.assign(_,{resultFunc:d,memoizedResultFunc:b,dependencies:x,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:m,argsMemoize:f})};return Object.assign(n,{withTypes:()=>n}),n}var q=Pn(is),Ln=Object.assign((e,t=q)=>{An(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const s=Object.keys(e),n=s.map(i=>e[i]);return t(n,(...i)=>i.reduce((o,l,c)=>(o[s[c]]=l,o),{}))},{withTypes:()=>Ln});function as(e){return({dispatch:s,getState:n})=>r=>i=>typeof i=="function"?i(s,n,e):r(i)}var Fn=as(),$n=as,Un=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pe:pe.apply(null,arguments)},Bn=e=>e&&typeof e.match=="function";function X(e,t){function s(...n){if(t){let r=t(...n);if(!r)throw new Error(L(0));return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return s.toString=()=>`${e}`,s.type=e,s.match=n=>hn(n)&&n.type===e,s}var os=class G extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,G.prototype)}static get[Symbol.species](){return G}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new G(...t[0].concat(this)):new G(...t.concat(this))}};function wt(e){return D(e)?rs(e,()=>{}):e}function le(e,t,s){return e.has(t)?e.get(t):e.set(t,s(t)).get(t)}function Vn(e){return typeof e=="boolean"}var Wn=()=>function(t){const{thunk:s=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=t??{};let o=new os;return s&&(Vn(s)?o.push(Fn):o.push($n(s.extraArgument))),o},Hn="RTK_autoBatch",jt=e=>t=>{setTimeout(t,e)},qn=(e={type:"raf"})=>t=>(...s)=>{const n=t(...s);let r=!0,i=!1,o=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:jt(10):e.type==="callback"?e.queueNotification:jt(e.timeout),d=()=>{o=!1,i&&(i=!1,l.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){const m=()=>r&&u(),p=n.subscribe(m);return l.add(u),()=>{p(),l.delete(u)}},dispatch(u){var m;try{return r=!((m=u==null?void 0:u.meta)!=null&&m[Hn]),i=!r,i&&(o||(o=!0,c(d))),n.dispatch(u)}finally{r=!0}}})},Kn=e=>function(s){const{autoBatch:n=!0}=s??{};let r=new os(e);return n&&r.push(qn(typeof n=="object"?n:void 0)),r};function Gn(e){const t=Wn(),{reducer:s=void 0,middleware:n,devTools:r=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let l;if(typeof s=="function")l=s;else if(Qe(s))l=un(s);else throw new Error(L(1));let c;typeof n=="function"?c=n(t):c=t();let d=pe;r&&(d=Un({trace:!1,...typeof r=="object"&&r}));const u=fn(...c),m=Kn(u);let p=typeof o=="function"?o(m):m();const f=d(...p);return Gt(l,i,f)}function ls(e){const t={},s=[];let n;const r={addCase(i,o){const l=typeof i=="string"?i:i.type;if(!l)throw new Error(L(28));if(l in t)throw new Error(L(29));return t[l]=o,r},addAsyncThunk(i,o){return o.pending&&(t[i.pending.type]=o.pending),o.rejected&&(t[i.rejected.type]=o.rejected),o.fulfilled&&(t[i.fulfilled.type]=o.fulfilled),o.settled&&s.push({matcher:i.settled,reducer:o.settled}),r},addMatcher(i,o){return s.push({matcher:i,reducer:o}),r},addDefaultCase(i){return n=i,r}};return e(r),[t,s,n]}function Jn(e){return typeof e=="function"}function Xn(e,t){let[s,n,r]=ls(t),i;if(Jn(e))i=()=>wt(e());else{const l=wt(e);i=()=>l}function o(l=i(),c){let d=[s[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return d.filter(u=>!!u).length===0&&(d=[r]),d.reduce((u,m)=>{if(m)if(F(u)){const f=m(u,c);return f===void 0?u:f}else{if(D(u))return rs(u,p=>m(p,c));{const p=m(u,c);if(p===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return u},l)}return o.getInitialState=i,o}var Yn=(e,t)=>Bn(e)?e.match(t):e(t);function Zn(...e){return t=>e.some(s=>Yn(s,t))}var Qn="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",er=(e=21)=>{let t="",s=e;for(;s--;)t+=Qn[Math.random()*64|0];return t},tr=["name","message","stack","code"],Le=class{constructor(e,t){Te(this,"_type");this.payload=e,this.meta=t}},_t=class{constructor(e,t){Te(this,"_type");this.payload=e,this.meta=t}},sr=e=>{if(typeof e=="object"&&e!==null){const t={};for(const s of tr)typeof e[s]=="string"&&(t[s]=e[s]);return t}return{message:String(e)}},St="External signal was aborted",nr=(()=>{function e(t,s,n){const r=X(t+"/fulfilled",(c,d,u,m)=>({payload:c,meta:{...m||{},arg:u,requestId:d,requestStatus:"fulfilled"}})),i=X(t+"/pending",(c,d,u)=>({payload:void 0,meta:{...u||{},arg:d,requestId:c,requestStatus:"pending"}})),o=X(t+"/rejected",(c,d,u,m,p)=>({payload:m,error:(n&&n.serializeError||sr)(c||"Rejected"),meta:{...p||{},arg:u,requestId:d,rejectedWithValue:!!m,requestStatus:"rejected",aborted:(c==null?void 0:c.name)==="AbortError",condition:(c==null?void 0:c.name)==="ConditionError"}}));function l(c,{signal:d}={}){return(u,m,p)=>{const f=n!=null&&n.idGenerator?n.idGenerator(c):er(),g=new AbortController;let y,v;function x(_){v=_,g.abort()}d&&(d.aborted?x(St):d.addEventListener("abort",()=>x(St),{once:!0}));const b=async function(){var j,C;let _;try{let k=(j=n==null?void 0:n.condition)==null?void 0:j.call(n,c,{getState:m,extra:p});if(ir(k)&&(k=await k),k===!1||g.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const I=new Promise((S,T)=>{y=()=>{T({name:"AbortError",message:v||"Aborted"})},g.signal.addEventListener("abort",y,{once:!0})});u(i(f,c,(C=n==null?void 0:n.getPendingMeta)==null?void 0:C.call(n,{requestId:f,arg:c},{getState:m,extra:p}))),_=await Promise.race([I,Promise.resolve(s(c,{dispatch:u,getState:m,extra:p,requestId:f,signal:g.signal,abort:x,rejectWithValue:(S,T)=>new Le(S,T),fulfillWithValue:(S,T)=>new _t(S,T)})).then(S=>{if(S instanceof Le)throw S;return S instanceof _t?r(S.payload,f,c,S.meta):r(S,f,c)})])}catch(k){_=k instanceof Le?o(null,f,c,k.payload,k.meta):o(k,f,c)}finally{y&&g.signal.removeEventListener("abort",y)}return n&&!n.dispatchConditionRejection&&o.match(_)&&_.meta.condition||u(_),_}();return Object.assign(b,{abort:x,requestId:f,arg:c,unwrap(){return b.then(rr)}})}}return Object.assign(l,{pending:i,rejected:o,fulfilled:r,settled:Zn(o,r),typePrefix:t})}return e.withTypes=()=>e,e})();function rr(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function ir(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var ar=Symbol.for("rtk-slice-createasyncthunk");function or(e,t){return`${e}/${t}`}function lr({creators:e}={}){var s;const t=(s=e==null?void 0:e.asyncThunk)==null?void 0:s[ar];return function(r){const{name:i,reducerPath:o=i}=r;if(!i)throw new Error(L(11));const l=(typeof r.reducers=="function"?r.reducers(ur()):r.reducers)||{},c=Object.keys(l),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,j){const C=typeof w=="string"?w:w.type;if(!C)throw new Error(L(12));if(C in d.sliceCaseReducersByType)throw new Error(L(13));return d.sliceCaseReducersByType[C]=j,u},addMatcher(w,j){return d.sliceMatchers.push({matcher:w,reducer:j}),u},exposeAction(w,j){return d.actionCreators[w]=j,u},exposeCaseReducer(w,j){return d.sliceCaseReducersByName[w]=j,u}};c.forEach(w=>{const j=l[w],C={reducerName:w,type:or(i,w),createNotation:typeof r.reducers=="function"};hr(j)?pr(C,j,u,t):fr(C,j,u)});function m(){const[w={},j=[],C=void 0]=typeof r.extraReducers=="function"?ls(r.extraReducers):[r.extraReducers],k={...w,...d.sliceCaseReducersByType};return Xn(r.initialState,I=>{for(let S in k)I.addCase(S,k[S]);for(let S of d.sliceMatchers)I.addMatcher(S.matcher,S.reducer);for(let S of j)I.addMatcher(S.matcher,S.reducer);C&&I.addDefaultCase(C)})}const p=w=>w,f=new Map,g=new WeakMap;let y;function v(w,j){return y||(y=m()),y(w,j)}function x(){return y||(y=m()),y.getInitialState()}function b(w,j=!1){function C(I){let S=I[w];return typeof S>"u"&&j&&(S=le(g,C,x)),S}function k(I=p){const S=le(f,j,()=>new WeakMap);return le(S,I,()=>{const T={};for(const[N,z]of Object.entries(r.selectors??{}))T[N]=cr(z,I,()=>le(g,I,x),j);return T})}return{reducerPath:w,getSelectors:k,get selectors(){return k(C)},selectSlice:C}}const _={name:i,reducer:v,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:x,...b(o),injectInto(w,{reducerPath:j,...C}={}){const k=j??o;return w.inject({reducerPath:k,reducer:v},C),{..._,...b(k,!0)}}};return _}}function cr(e,t,s,n){function r(i,...o){let l=t(i);return typeof l>"u"&&n&&(l=s()),e(l,...o)}return r.unwrapped=e,r}var dr=lr();function ur(){function e(t,s){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...s}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...s){return t(...s)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,s){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:s}},asyncThunk:e}}function fr({type:e,reducerName:t,createNotation:s},n,r){let i,o;if("reducer"in n){if(s&&!mr(n))throw new Error(L(17));i=n.reducer,o=n.prepare}else i=n;r.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,o?X(e,o):X(e))}function hr(e){return e._reducerDefinitionType==="asyncThunk"}function mr(e){return e._reducerDefinitionType==="reducerWithPrepare"}function pr({type:e,reducerName:t},s,n,r){if(!r)throw new Error(L(18));const{payloadCreator:i,fulfilled:o,pending:l,rejected:c,settled:d,options:u}=s,m=r(e,i,u);n.exposeAction(t,m),o&&n.addCase(m.fulfilled,o),l&&n.addCase(m.pending,l),c&&n.addCase(m.rejected,c),d&&n.addMatcher(m.settled,d),n.exposeCaseReducer(t,{fulfilled:o||ce,pending:l||ce,rejected:c||ce,settled:d||ce})}function ce(){}function L(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const xr=nr("runtime/fetchHistory",async({sessionId:e,before:t,limit:s=100})=>{const n=localStorage.getItem("cascade_token")??"",r=`/api/runtime/logs/${e}?limit=${s}${t?`&before=${t}`:""}`,i=await fetch(r,{headers:{Authorization:`Bearer ${n}`}});if(!i.ok)throw new Error("Failed to fetch history");const o=await i.json();return{sessionId:e,logs:o}}),gr={sessions:{},nodes:{},logIds:{},logs:{},activeSessionId:null,scope:"workspace",connected:!1};function Nt(e,t,s){for(const n of t){const r=n.sessionId??s??"",i=`${r}:${n.tierId}`,o=e[i],l=n.output??(o==null?void 0:o.output);e[i]={...o,...n,sessionId:r,output:l}}}function de(e,t,s,n=1e3){e.logIds[t]||(e.logIds[t]=new Set),e.logs[t]||(e.logs[t]=[]);const r=e.logIds[t],i=e.logs[t];for(const o of s)r.has(o.id)||(r.add(o.id),i.push(o));if(i.length>n){const o=i.splice(0,i.length-n);for(const l of o)r.delete(l.id)}}const cs=dr({name:"runtime",initialState:gr,reducers:{setConnected(e,t){e.connected=t.payload},setScope(e,t){e.scope=t.payload},setActiveSession(e,t){e.activeSessionId=t.payload},updateRTKSnapshot(e,t){var o;const{sessions:s,nodes:n,logs:r,scope:i}=t.payload;(i==="workspace"||i==="global")&&(e.scope=i);for(const l of s)e.sessions[l.sessionId]={...e.sessions[l.sessionId]??{},...l};if(!e.activeSessionId&&s.length>0&&(e.activeSessionId=((o=s.find(l=>l.status==="ACTIVE"))==null?void 0:o.sessionId)??s[0].sessionId),n!=null&&n.length&&Nt(e.nodes,n),r!=null&&r.length)for(const l of r)l.sessionId&&de(e,l.sessionId,[l])},updateSessionDetails(e,t){var i;const{sessionId:s,nodes:n,logs:r}=t.payload;Nt(e.nodes,n,s),de(e,s,r),(i=e.logs[s])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())},appendLog(e,t){const s=t.payload;de(e,s.sessionId,[s])},clearFrontendGraphs(e){e.nodes={},e.logIds={},e.logs={}},removeSessionsBulk(e,t){var s,n;for(const r of t.payload){delete e.sessions[r];for(const i of Object.keys(e.nodes))((s=e.nodes[i])==null?void 0:s.sessionId)===r&&delete e.nodes[i];delete e.logs[r],delete e.logIds[r]}if(e.activeSessionId&&t.payload.includes(e.activeSessionId)){const r=Object.values(e.sessions);e.activeSessionId=((n=r[0])==null?void 0:n.sessionId)??null}}},extraReducers(e){e.addCase(xr.fulfilled,(t,s)=>{var i;const{sessionId:n,logs:r}=s.payload;de(t,n,r,2e3),(i=t.logs[n])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())})}}),{setConnected:Ct,setScope:Vi,setActiveSession:vr,updateRTKSnapshot:ds,updateSessionDetails:br,appendLog:yr,clearFrontendGraphs:kt,removeSessionsBulk:wr}=cs.actions,ne=e=>e.runtime,jr=q(ne,e=>Object.values(e.sessions).sort((t,s)=>new Date(s.updatedAt).getTime()-new Date(t.updatedAt).getTime())),nt=q(ne,e=>e.activeSessionId?e.sessions[e.activeSessionId]??null:null),_r=q(ne,e=>e.activeSessionId?Object.values(e.nodes).filter(t=>t.sessionId===e.activeSessionId):[]),Sr=q(ne,e=>e.activeSessionId?e.logs[e.activeSessionId]??[]:[]),Nr=q(ne,e=>e.connected),Cr=cs.reducer,kr=Gn({reducer:{runtime:Cr},middleware:e=>e({serializableCheck:{ignoredPaths:["runtime.logIds"]}})}),Ae=()=>nn(),U=on;var re={},rt={};function Er(e,t,s){for(var n=0,r=0,i=s.length;r<i;r++)n=s.charCodeAt(r),n<128?e.setUint8(t++,n):n<2048?(e.setUint8(t++,192|n>>6),e.setUint8(t++,128|n&63)):n<55296||n>=57344?(e.setUint8(t++,224|n>>12),e.setUint8(t++,128|n>>6&63),e.setUint8(t++,128|n&63)):(r++,n=65536+((n&1023)<<10|s.charCodeAt(r)&1023),e.setUint8(t++,240|n>>18),e.setUint8(t++,128|n>>12&63),e.setUint8(t++,128|n>>6&63),e.setUint8(t++,128|n&63))}function Ir(e){for(var t=0,s=0,n=0,r=e.length;n<r;n++)t=e.charCodeAt(n),t<128?s+=1:t<2048?s+=2:t<55296||t>=57344?s+=3:(n++,s+=4);return s}function J(e,t,s){var n=typeof s,r=0,i=0,o=0,l=0,c=0,d=0;if(n==="string"){if(c=Ir(s),c<32)e.push(c|160),d=1;else if(c<256)e.push(217,c),d=2;else if(c<65536)e.push(218,c>>8,c),d=3;else if(c<4294967296)e.push(219,c>>24,c>>16,c>>8,c),d=5;else throw new Error("String too long");return t.push({_str:s,_length:c,_offset:e.length}),d+c}if(n==="number")return Math.floor(s)!==s||!isFinite(s)?(e.push(203),t.push({_float:s,_length:8,_offset:e.length}),9):s>=0?s<128?(e.push(s),1):s<256?(e.push(204,s),2):s<65536?(e.push(205,s>>8,s),3):s<4294967296?(e.push(206,s>>24,s>>16,s>>8,s),5):(o=s/Math.pow(2,32)>>0,l=s>>>0,e.push(207,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9):s>=-32?(e.push(s),1):s>=-128?(e.push(208,s),2):s>=-32768?(e.push(209,s>>8,s),3):s>=-2147483648?(e.push(210,s>>24,s>>16,s>>8,s),5):(o=Math.floor(s/Math.pow(2,32)),l=s>>>0,e.push(211,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9);if(n==="object"){if(s===null)return e.push(192),1;if(Array.isArray(s)){if(c=s.length,c<16)e.push(c|144),d=1;else if(c<65536)e.push(220,c>>8,c),d=3;else if(c<4294967296)e.push(221,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Array too large");for(r=0;r<c;r++)d+=J(e,t,s[r]);return d}if(s instanceof Date){var u=s.getTime();return o=Math.floor(u/Math.pow(2,32)),l=u>>>0,e.push(215,0,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),10}if(s instanceof ArrayBuffer){if(c=s.byteLength,c<256)e.push(196,c),d=2;else if(c<65536)e.push(197,c>>8,c),d=3;else if(c<4294967296)e.push(198,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Buffer too large");return t.push({_bin:s,_length:c,_offset:e.length}),d+c}if(typeof s.toJSON=="function")return J(e,t,s.toJSON());var m=[],p="",f=Object.keys(s);for(r=0,i=f.length;r<i;r++)p=f[r],typeof s[p]!="function"&&m.push(p);if(c=m.length,c<16)e.push(c|128),d=1;else if(c<65536)e.push(222,c>>8,c),d=3;else if(c<4294967296)e.push(223,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Object too large");for(r=0;r<c;r++)p=m[r],d+=J(e,t,p),d+=J(e,t,s[p]);return d}if(n==="boolean")return e.push(s?195:194),1;if(n==="undefined")return e.push(212,0,0),3;throw new Error("Could not encode")}function Ar(e){var t=[],s=[],n=J(t,s,e),r=new ArrayBuffer(n),i=new DataView(r),o=0,l=0,c=-1;s.length>0&&(c=s[0]._offset);for(var d,u=0,m=0,p=0,f=t.length;p<f;p++)if(i.setUint8(l+p,t[p]),p+1===c){if(d=s[o],u=d._length,m=l+c,d._bin)for(var g=new Uint8Array(d._bin),y=0;y<u;y++)i.setUint8(m+y,g[y]);else d._str?Er(i,m,d._str):d._float!==void 0&&i.setFloat64(m,d._float);o++,l+=u,s[o]&&(c=s[o]._offset)}return r}var Mr=Ar;function K(e){if(this._offset=0,e instanceof ArrayBuffer)this._buffer=e,this._view=new DataView(this._buffer);else if(ArrayBuffer.isView(e))this._buffer=e.buffer,this._view=new DataView(this._buffer,e.byteOffset,e.byteLength);else throw new Error("Invalid argument")}function Tr(e,t,s){for(var n="",r=0,i=t,o=t+s;i<o;i++){var l=e.getUint8(i);if(!(l&128)){n+=String.fromCharCode(l);continue}if((l&224)===192){n+=String.fromCharCode((l&31)<<6|e.getUint8(++i)&63);continue}if((l&240)===224){n+=String.fromCharCode((l&15)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0);continue}if((l&248)===240){r=(l&7)<<18|(e.getUint8(++i)&63)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0,r>=65536?(r-=65536,n+=String.fromCharCode((r>>>10)+55296,(r&1023)+56320)):n+=String.fromCharCode(r);continue}throw new Error("Invalid byte "+l.toString(16))}return n}K.prototype._array=function(e){for(var t=new Array(e),s=0;s<e;s++)t[s]=this._parse();return t};K.prototype._map=function(e){for(var t="",s={},n=0;n<e;n++)t=this._parse(),s[t]=this._parse();return s};K.prototype._str=function(e){var t=Tr(this._view,this._offset,e);return this._offset+=e,t};K.prototype._bin=function(e){var t=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,t};K.prototype._parse=function(){var e=this._view.getUint8(this._offset++),t,s=0,n=0,r=0,i=0;if(e<192)return e<128?e:e<144?this._map(e&15):e<160?this._array(e&15):this._str(e&31);if(e>223)return(255-e+1)*-1;switch(e){case 192:return null;case 194:return!1;case 195:return!0;case 196:return s=this._view.getUint8(this._offset),this._offset+=1,this._bin(s);case 197:return s=this._view.getUint16(this._offset),this._offset+=2,this._bin(s);case 198:return s=this._view.getUint32(this._offset),this._offset+=4,this._bin(s);case 199:return s=this._view.getUint8(this._offset),n=this._view.getInt8(this._offset+1),this._offset+=2,[n,this._bin(s)];case 200:return s=this._view.getUint16(this._offset),n=this._view.getInt8(this._offset+2),this._offset+=3,[n,this._bin(s)];case 201:return s=this._view.getUint32(this._offset),n=this._view.getInt8(this._offset+4),this._offset+=5,[n,this._bin(s)];case 202:return t=this._view.getFloat32(this._offset),this._offset+=4,t;case 203:return t=this._view.getFloat64(this._offset),this._offset+=8,t;case 204:return t=this._view.getUint8(this._offset),this._offset+=1,t;case 205:return t=this._view.getUint16(this._offset),this._offset+=2,t;case 206:return t=this._view.getUint32(this._offset),this._offset+=4,t;case 207:return r=this._view.getUint32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 208:return t=this._view.getInt8(this._offset),this._offset+=1,t;case 209:return t=this._view.getInt16(this._offset),this._offset+=2,t;case 210:return t=this._view.getInt32(this._offset),this._offset+=4,t;case 211:return r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 212:if(n=this._view.getInt8(this._offset),this._offset+=1,n===0){this._offset+=1;return}return[n,this._bin(1)];case 213:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(2)];case 214:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(4)];case 215:return n=this._view.getInt8(this._offset),this._offset+=1,n===0?(r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,new Date(r+i)):[n,this._bin(8)];case 216:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(16)];case 217:return s=this._view.getUint8(this._offset),this._offset+=1,this._str(s);case 218:return s=this._view.getUint16(this._offset),this._offset+=2,this._str(s);case 219:return s=this._view.getUint32(this._offset),this._offset+=4,this._str(s);case 220:return s=this._view.getUint16(this._offset),this._offset+=2,this._array(s);case 221:return s=this._view.getUint32(this._offset),this._offset+=4,this._array(s);case 222:return s=this._view.getUint16(this._offset),this._offset+=2,this._map(s);case 223:return s=this._view.getUint32(this._offset),this._offset+=4,this._map(s)}throw new Error("Could not parse")};function Or(e){var t=new K(e),s=t._parse();if(t._offset!==e.byteLength)throw new Error(e.byteLength-t._offset+" trailing bytes");return s}var Rr=Or;rt.encode=Mr;rt.decode=Rr;var us={exports:{}};(function(e){e.exports=t;function t(n){if(n)return s(n)}function s(n){for(var r in t.prototype)n[r]=t.prototype[r];return n}t.prototype.on=t.prototype.addEventListener=function(n,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(r),this},t.prototype.once=function(n,r){function i(){this.off(n,i),r.apply(this,arguments)}return i.fn=r,this.on(n,i),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(n,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,l=0;l<i.length;l++)if(o=i[l],o===r||o.fn===r){i.splice(l,1);break}return i.length===0&&delete this._callbacks["$"+n],this},t.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,l=i.length;o<l;++o)i[o].apply(this,r)}return this},t.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},t.prototype.hasListeners=function(n){return!!this.listeners(n).length}})(us);var Dr=us.exports,fs=rt,zr=Dr;re.protocol=5;var Y=re.PacketType={CONNECT:0,DISCONNECT:1,EVENT:2,ACK:3,CONNECT_ERROR:4},Et=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},hs=function(e){return typeof e=="string"},It=function(e){return Object.prototype.toString.call(e)==="[object Object]"};function ms(){}ms.prototype.encode=function(e){return[fs.encode(e)]};function ie(){}zr(ie.prototype);ie.prototype.add=function(e){var t=fs.decode(e);this.checkPacket(t),this.emit("decoded",t)};function Pr(e){switch(e.type){case Y.CONNECT:return e.data===void 0||It(e.data);case Y.DISCONNECT:return e.data===void 0;case Y.CONNECT_ERROR:return hs(e.data)||It(e.data);default:return Array.isArray(e.data)}}ie.prototype.checkPacket=function(e){var t=Et(e.type)&&e.type>=Y.CONNECT&&e.type<=Y.CONNECT_ERROR;if(!t)throw new Error("invalid packet type");if(!hs(e.nsp))throw new Error("invalid namespace");if(!Pr(e))throw new Error("invalid payload");var s=e.id===void 0||Et(e.id);if(!s)throw new Error("invalid packet id")};ie.prototype.destroy=function(){};re.Encoder=ms;re.Decoder=ie;function Lr({url:e="/",token:t,activeSessionId:s,onRuntimeRefresh:n,onStreamToken:r,onCostUpdate:i,onEscalation:o}={}){const[l,c]=h.useState(null),d=Ae(),u=h.useRef(n),m=h.useRef(r),p=h.useRef(i),f=h.useRef(o);u.current=n,m.current=r,p.current=i,f.current=o;const g=h.useRef(s);g.current=s;const y=h.useRef(null);return h.useEffect(()=>{const v=Es(e,{auth:t?{token:t}:{},transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,parser:re});return v.on("connect",()=>{d(Ct(!0)),v.emit("runtime:refresh",{scope:"workspace"});const x=g.current;x&&(v.emit("join:session",{sessionId:x}),y.current=x),c(v)}),v.on("disconnect",()=>{d(Ct(!1)),c(null)}),v.on("runtime:update",x=>{d(ds(x))}),v.on("session:details",x=>{d(br(x))}),v.on("log:new",x=>{d(yr(x))}),v.on("runtime:refresh",x=>{var _;const b=x;(_=u.current)==null||_.call(u,b==null?void 0:b.scope)}),v.on("stream:token",x=>{var b;(b=m.current)==null||b.call(m,x)}),v.on("cost:update",x=>{var b;(b=p.current)==null||b.call(p,x)}),v.on("permission:user-required",x=>{var b;(b=f.current)==null||b.call(f,x)}),()=>{v.disconnect(),c(null),y.current=null}},[e,t,d]),h.useEffect(()=>{l&&s!==y.current&&(y.current&&l.emit("leave:session",{sessionId:y.current}),s&&l.emit("join:session",{sessionId:s}),y.current=s??null)},[l,s]),{socket:l}}const Fr=h.memo(function({onLogin:t}){const[s,n]=h.useState(""),[r,i]=h.useState(""),[o,l]=h.useState(!1),c=async d=>{if(d.preventDefault(),!!s.trim()){l(!0),i("");try{const u=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:"admin",password:s})});if(u.ok){const m=await u.json();t(m.token)}else i("Invalid token — check your cascade dashboard config.")}catch{i("Cannot reach server. Is the dashboard running?")}finally{l(!1)}}};return a.jsxs("div",{className:"relative flex items-center justify-center w-full h-full bg-[var(--bg-base)] dot-grid overflow-hidden",children:[a.jsx("div",{className:"absolute top-[20%] left-[30%] w-[480px] h-[480px] rounded-full bg-[var(--accent)] opacity-[0.035] blur-[140px] pointer-events-none"}),a.jsx("div",{className:"absolute bottom-[20%] right-[25%] w-[320px] h-[320px] rounded-full bg-[var(--t3-color)] opacity-[0.03] blur-[120px] pointer-events-none"}),a.jsxs("form",{onSubmit:c,"aria-label":"Cascade AI login",className:`
|
|
18
18
|
relative z-10 w-full max-w-[360px]
|
|
19
19
|
glass-elevated rounded-[var(--radius-lg)]
|
|
20
20
|
p-8 shadow-dialog animate-fade-in-up
|
|
@@ -22,12 +22,12 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
22
22
|
w-9 h-9 rounded-[var(--radius-sm)] bg-[var(--accent)]
|
|
23
23
|
flex items-center justify-center flex-shrink-0
|
|
24
24
|
shadow-[var(--shadow-glow-violet)]
|
|
25
|
-
`,children:a.jsx("span",{className:"text-white font-black text-[14px] font-mono",children:"C"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-[15px] font-bold text-[var(--text-primary)] tracking-tight",children:"Cascade AI"}),a.jsx("p",{className:"section-label mt-0.5",children:"Dashboard"})]})]}),a.jsxs("div",{className:"mb-5",children:[a.jsx("label",{htmlFor:"token-input",className:"block section-label mb-2",children:"Access Token"}),a.jsx("input",{id:"token-input",type:"password",className:"input",placeholder:"paste your token here",value:
|
|
25
|
+
`,children:a.jsx("span",{className:"text-white font-black text-[14px] font-mono",children:"C"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-[15px] font-bold text-[var(--text-primary)] tracking-tight",children:"Cascade AI"}),a.jsx("p",{className:"section-label mt-0.5",children:"Dashboard"})]})]}),a.jsxs("div",{className:"mb-5",children:[a.jsx("label",{htmlFor:"token-input",className:"block section-label mb-2",children:"Access Token"}),a.jsx("input",{id:"token-input",type:"password",className:"input",placeholder:"paste your token here",value:s,onChange:d=>n(d.target.value),autoComplete:"current-password",autoFocus:!0}),r&&a.jsx("p",{role:"alert",className:"text-[11px] text-[var(--error)] mt-2 font-mono",children:r})]}),a.jsx("button",{type:"submit",disabled:o||!s.trim(),className:"btn btn-primary w-full justify-center py-2.5",children:o?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/40 border-t-white animate-spin"}),"Connecting…"]}):"Connect"}),a.jsxs("p",{className:"text-center text-[10px] text-[var(--text-faint)] mt-5 font-mono",children:["No token?"," ",a.jsx("code",{className:"text-[var(--text-muted)]",children:"dashboard.auth: false"})]})]})]})});/**
|
|
26
26
|
* @license lucide-react v0.460.0 - ISC
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the ISC license.
|
|
29
29
|
* See the LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/const $r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),
|
|
30
|
+
*/const $r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ps=(...e)=>e.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).join(" ").trim();/**
|
|
31
31
|
* @license lucide-react v0.460.0 - ISC
|
|
32
32
|
*
|
|
33
33
|
* This source code is licensed under the ISC license.
|
|
@@ -37,17 +37,17 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
37
37
|
*
|
|
38
38
|
* This source code is licensed under the ISC license.
|
|
39
39
|
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
-
*/const Br=h.forwardRef(({color:e="currentColor",size:
|
|
40
|
+
*/const Br=h.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:r="",children:i,iconNode:o,...l},c)=>h.createElement("svg",{ref:c,...Ur,width:t,height:t,stroke:e,strokeWidth:n?Number(s)*24/Number(t):s,className:ps("lucide",r),...l},[...o.map(([d,u])=>h.createElement(d,u)),...Array.isArray(i)?i:[i]]));/**
|
|
41
41
|
* @license lucide-react v0.460.0 - ISC
|
|
42
42
|
*
|
|
43
43
|
* This source code is licensed under the ISC license.
|
|
44
44
|
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
-
*/const A=(e,
|
|
45
|
+
*/const A=(e,t)=>{const s=h.forwardRef(({className:n,...r},i)=>h.createElement(Br,{ref:i,iconNode:t,className:ps(`lucide-${$r(e)}`,n),...r}));return s.displayName=`${e}`,s};/**
|
|
46
46
|
* @license lucide-react v0.460.0 - ISC
|
|
47
47
|
*
|
|
48
48
|
* This source code is licensed under the ISC license.
|
|
49
49
|
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
-
*/const
|
|
50
|
+
*/const xs=A("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
|
|
51
51
|
* @license lucide-react v0.460.0 - ISC
|
|
52
52
|
*
|
|
53
53
|
* This source code is licensed under the ISC license.
|
|
@@ -62,12 +62,12 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
62
62
|
*
|
|
63
63
|
* This source code is licensed under the ISC license.
|
|
64
64
|
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/const
|
|
65
|
+
*/const gs=A("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
|
66
66
|
* @license lucide-react v0.460.0 - ISC
|
|
67
67
|
*
|
|
68
68
|
* This source code is licensed under the ISC license.
|
|
69
69
|
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
-
*/const
|
|
70
|
+
*/const At=A("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
71
71
|
* @license lucide-react v0.460.0 - ISC
|
|
72
72
|
*
|
|
73
73
|
* This source code is licensed under the ISC license.
|
|
@@ -107,12 +107,12 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
107
107
|
*
|
|
108
108
|
* This source code is licensed under the ISC license.
|
|
109
109
|
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
-
*/const
|
|
110
|
+
*/const Mt=A("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
|
111
111
|
* @license lucide-react v0.460.0 - ISC
|
|
112
112
|
*
|
|
113
113
|
* This source code is licensed under the ISC license.
|
|
114
114
|
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
-
*/const
|
|
115
|
+
*/const Tt=A("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
116
116
|
* @license lucide-react v0.460.0 - ISC
|
|
117
117
|
*
|
|
118
118
|
* This source code is licensed under the ISC license.
|
|
@@ -122,7 +122,7 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
122
122
|
*
|
|
123
123
|
* This source code is licensed under the ISC license.
|
|
124
124
|
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
-
*/const Qr=A("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ei=[{id:"topology",icon:Jr,label:"Agent Topology"},{id:"sessions",icon:Kr,label:"Sessions"},{id:"logs",icon:Hr,label:"Telemetry"},{id:"settings",icon:Xr,label:"Settings"}];function
|
|
125
|
+
*/const Qr=A("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ei=[{id:"topology",icon:Jr,label:"Agent Topology"},{id:"sessions",icon:Kr,label:"Sessions"},{id:"logs",icon:Hr,label:"Telemetry"},{id:"settings",icon:Xr,label:"Settings"}];function Ot({label:e}){return a.jsx("div",{role:"tooltip",className:`
|
|
126
126
|
absolute left-full ml-3 px-2.5 py-1.5
|
|
127
127
|
text-[10px] font-medium font-mono text-[var(--text-primary)]
|
|
128
128
|
bg-[var(--bg-overlay)] border border-[var(--border-strong)]
|
|
@@ -131,7 +131,7 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
131
131
|
translate-x-[-4px] group-hover:translate-x-0
|
|
132
132
|
transition-all duration-150 z-50
|
|
133
133
|
shadow-[var(--shadow-panel)]
|
|
134
|
-
`,children:e})}const ti=h.memo(function({activeTab:
|
|
134
|
+
`,children:e})}const ti=h.memo(function({activeTab:t,onTabChange:s,onLogout:n}){return a.jsxs("nav",{"aria-label":"Main navigation",className:`
|
|
135
135
|
flex flex-col items-center py-5 gap-1
|
|
136
136
|
w-[56px] flex-shrink-0 h-full z-20
|
|
137
137
|
bg-[var(--bg-surface)]
|
|
@@ -140,38 +140,38 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
140
140
|
mb-4 w-8 h-8 rounded-[var(--radius-sm)]
|
|
141
141
|
bg-[var(--accent)] flex items-center justify-center
|
|
142
142
|
shadow-[var(--shadow-glow-violet)] select-none
|
|
143
|
-
`,children:a.jsx("span",{className:"text-white font-black text-[13px] font-mono tracking-tighter",children:"C"})}),a.jsx("div",{className:"divider w-8 mb-2"}),a.jsx("div",{className:"flex flex-col gap-0.5 flex-1 w-full px-1.5",children:ei.map(({id:r,icon:i,label:o})=>{const l=
|
|
143
|
+
`,children:a.jsx("span",{className:"text-white font-black text-[13px] font-mono tracking-tighter",children:"C"})}),a.jsx("div",{className:"divider w-8 mb-2"}),a.jsx("div",{className:"flex flex-col gap-0.5 flex-1 w-full px-1.5",children:ei.map(({id:r,icon:i,label:o})=>{const l=t===r;return a.jsxs("div",{className:"relative group",children:[a.jsx("button",{id:`nav-${r}`,"aria-label":o,"aria-current":l?"page":void 0,onClick:()=>s(r),className:`nav-rail-btn w-full ${l?"active":""}`,children:a.jsx(i,{size:17,strokeWidth:l?2:1.75})}),a.jsx(Ot,{label:o})]},r)})}),a.jsxs("div",{className:"relative group px-1.5 w-full",children:[a.jsx("button",{"aria-label":"Log out",onClick:n,className:"nav-rail-btn w-full text-[var(--text-faint)] hover:text-[var(--error)]",children:a.jsx(Gr,{size:15,strokeWidth:1.75})}),a.jsx(Ot,{label:"Log out"})]})]})});function si(e){const[t,s]=h.useState(null);return h.useEffect(()=>{if(!e){s(null);return}let n=!1;const r=async()=>{const o=Date.now();try{await fetch("/api/ping",{cache:"no-store"}),n||s(Date.now()-o)}catch{n||s(null)}};r();const i=setInterval(r,5e3);return()=>{n=!0,clearInterval(i)}},[e]),t}function ni(e){const[t,s]=h.useState("");return h.useEffect(()=>{if(!e){s("");return}const n=()=>{const i=Date.now()-new Date(e).getTime(),o=Math.floor(i/36e5).toString().padStart(2,"0"),l=Math.floor(i%36e5/6e4).toString().padStart(2,"0"),c=Math.floor(i%6e4/1e3).toString().padStart(2,"0");s(`${o}:${l}:${c}`)};n();const r=setInterval(n,1e3);return()=>clearInterval(r)},[e]),t}function ue({label:e,value:t,highlight:s}){return a.jsxs("div",{className:"metric-chip",children:[a.jsx("span",{className:"label",children:e}),a.jsx("span",{className:`value ${s?"text-[var(--warning)]":""}`,children:t})]})}const ri=h.memo(function({isConnected:t,totalCostUsd:s,totalTokens:n}){const r=U(nt),i=si(t),o=ni(r==null?void 0:r.startedAt);return a.jsxs("header",{"aria-label":"Dashboard header",className:`
|
|
144
144
|
flex items-center justify-between px-5 h-11
|
|
145
145
|
border-b border-[var(--border-subtle)]
|
|
146
146
|
bg-[var(--bg-surface)] flex-shrink-0 z-10
|
|
147
|
-
`,children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{"aria-label":
|
|
147
|
+
`,children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{"aria-label":t?"Connected":"Disconnected",className:`
|
|
148
148
|
w-1.5 h-1.5 rounded-full transition-all duration-500
|
|
149
|
-
${
|
|
150
|
-
`}),a.jsx("span",{className:"section-label",children:
|
|
149
|
+
${t?"bg-[var(--success)] shadow-[var(--shadow-glow-green)]":"bg-[var(--text-faint)]"}
|
|
150
|
+
`}),a.jsx("span",{className:"section-label",children:t?"Live":"Offline"})]}),r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"divider-v h-4 flex-shrink-0"}),a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-[12px] font-medium text-[var(--text-primary)] truncate max-w-[200px]",children:r.title||"Untitled Session"}),a.jsx("span",{className:`badge badge-${r.status} flex-shrink-0`,children:r.status})]})]})]}),a.jsxs("div",{className:"flex items-center gap-5",children:[i!==null&&a.jsx(ue,{label:"Ping",value:`${i}ms`}),o&&a.jsx(ue,{label:"Uptime",value:o}),a.jsx("div",{className:"divider-v h-4"}),a.jsx(ue,{label:"Tokens",value:n>=1e3?`${(n/1e3).toFixed(1)}k`:n.toLocaleString()}),a.jsx(ue,{label:"Cost",value:`$${s.toFixed(4)}`,highlight:s>1})]})]})}),Fe={T1:"var(--t1-color)",T2:"var(--t2-color)",T3:"var(--t3-color)"},Rt={ACTIVE:"border-[var(--t3-color)] agent-node-ACTIVE",COMPLETED:"border-[var(--success)] agent-node-COMPLETED",FAILED:"border-[var(--error)] agent-node-FAILED",ESCALATED:"border-[var(--warning)] agent-node-ESCALATED",IDLE:"border-[var(--border-subtle)]"},ii=h.memo(function({data:t,selected:s}){const n=Rt[t.status]??Rt.IDLE;return a.jsxs("div",{"aria-label":`${t.role} agent: ${t.label}, status: ${t.status}`,className:`
|
|
151
151
|
relative px-3.5 py-3 glass min-w-[170px] max-w-[210px]
|
|
152
152
|
rounded-[var(--radius-md)] border transition-all duration-300
|
|
153
153
|
${n}
|
|
154
|
-
${
|
|
155
|
-
`,children:[a.jsx(
|
|
154
|
+
${s?"ring-2 ring-[var(--accent)] ring-offset-2 ring-offset-[var(--bg-base)]":""}
|
|
155
|
+
`,children:[a.jsx(it,{type:"target",position:at.Top,className:"!w-1.5 !h-1.5 !bg-[var(--border-strong)] !border-none !top-[-4px]"}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"badge",style:{color:Fe[t.role],background:`color-mix(in srgb, ${Fe[t.role]} 10%, transparent)`,borderColor:`color-mix(in srgb, ${Fe[t.role]} 22%, transparent)`},children:t.role}),a.jsxs("div",{className:"flex items-center gap-1",children:[t.status==="ACTIVE"&&a.jsx("div",{className:"flex gap-[2px] items-center","aria-label":"Active",children:[0,100,200].map(r=>a.jsx("span",{className:"w-1 h-1 rounded-full bg-[var(--t3-color)]",style:{animation:`pulse-glow 1.4s ease-in-out ${r}ms infinite`}},r))}),t.status==="COMPLETED"&&a.jsx("span",{className:"text-[var(--success)] text-[10px] font-mono",children:"✓"}),t.status==="FAILED"&&a.jsx("span",{className:"text-[var(--error)] text-[10px] font-mono",children:"✗"}),t.status==="ESCALATED"&&a.jsx("span",{className:"text-[var(--warning)] text-[10px]",children:"⚠"})]})]}),a.jsx("p",{className:"text-[11px] font-semibold text-[var(--text-primary)] truncate leading-snug mb-0.5",children:t.label}),t.action&&a.jsx("p",{className:"text-[9px] text-[var(--text-muted)] truncate leading-snug font-mono",children:t.action}),t.progressPct!==void 0&&t.status==="ACTIVE"&&a.jsx("div",{className:"progress-track mt-2.5",children:a.jsx("div",{className:"progress-fill",style:{width:`${t.progressPct}%`}})}),a.jsx(it,{type:"source",position:at.Bottom,className:"!w-1.5 !h-1.5 !bg-[var(--border-strong)] !border-none !bottom-[-4px]"})]})}),ai={agent:ii};function oi(){return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-5 animate-fade-in select-none",children:[a.jsxs("div",{className:"relative w-16 h-16",children:[[0,1,2].map(e=>a.jsx("div",{className:"absolute inset-0 rounded-full border border-[var(--accent)]",style:{opacity:.12+e*.08,animation:`orbit ${3.5+e*.8}s linear infinite`,animationDelay:`${e*-1.2}s`}},e)),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-2xl",children:"⬡"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-[13px] font-medium text-[var(--text-primary)]",children:"No active agents"}),a.jsx("p",{className:"text-[11px] text-[var(--text-muted)] mt-1",children:"Start a task to see the agent topology"})]})]})}const li=h.memo(function({nodes:t,edges:s,selectedNodeId:n,onSelectNode:r}){const i=h.useMemo(()=>{if(!t.length)return[];const c={T1:[],T2:[],T3:[]};t.forEach(p=>{var f;return(f=c[p.role])==null?void 0:f.push(p)});const d={T1:40,T2:210,T3:380},u=250,m=500;return t.map(p=>{const f=c[p.role],g=f.findIndex(b=>b.id===p.id),y=f.length,v=m-(y-1)*u/2+g*u,x=d[p.role]??40;return{id:p.id,type:"agent",position:{x:v,y:x},selected:n===p.id,data:{role:p.role,label:p.label,status:p.status,action:p.action,progressPct:p.progressPct}}})},[t,n]),o=h.useMemo(()=>s.map((c,d)=>({id:`e${d}`,source:c.from,target:c.to,animated:!0,style:{stroke:"rgba(124,106,247,0.28)",strokeWidth:1.5},markerEnd:{type:js.ArrowClosed,color:"rgba(124,106,247,0.45)",width:10,height:10}})),[s]),l=h.useCallback((c,d)=>{r(d.id===n?null:d.id)},[r,n]);return t.length?a.jsxs("div",{className:"w-full h-full relative","aria-label":"Agent topology graph",role:"img",children:[a.jsxs(_s,{nodes:i,edges:o,nodeTypes:ai,onNodeClick:l,onPaneClick:()=>r(null),fitView:!0,fitViewOptions:{padding:.18,maxZoom:1.2},minZoom:.25,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[a.jsx(Ss,{variant:Ns.Dots,color:"rgba(255,255,255,0.03)",gap:24,size:1}),a.jsx(Cs,{showInteractive:!1,"aria-label":"Graph controls"})]}),a.jsx("div",{className:"absolute inset-x-0 top-0 h-14 bg-gradient-to-b from-[var(--bg-base)] to-transparent pointer-events-none"}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 h-14 bg-gradient-to-t from-[var(--bg-base)] to-transparent pointer-events-none"})]}):a.jsx(oi,{})});function ci({pct:e}){return a.jsx("div",{className:"progress-track",children:a.jsx("div",{className:"progress-fill",style:{width:`${Math.min(Math.max(e,0),100)}%`}})})}function $e({icon:e,label:t,children:s}){return a.jsxs("div",{className:"px-4 py-3 border-b border-[var(--border-subtle)]",children:[a.jsxs("p",{className:"section-label flex items-center gap-1.5 mb-1.5",children:[a.jsx(e,{size:9}),t]}),s]})}const di=h.memo(function({node:t,streamLog:s,onClose:n}){const r=h.useRef(null);return h.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[s]),h.useEffect(()=>{const i=o=>{o.key==="Escape"&&n()};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[n]),a.jsxs("aside",{role:"complementary","aria-label":"Agent inspector",className:`
|
|
156
156
|
flex flex-col w-[300px] flex-shrink-0 h-full
|
|
157
157
|
border-l border-[var(--border-subtle)]
|
|
158
158
|
bg-[var(--bg-surface)] animate-slide-in overflow-hidden
|
|
159
|
-
`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(
|
|
159
|
+
`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(At,{size:13,className:"text-[var(--accent)]"}),a.jsx("span",{className:"section-label",children:"Inspector"})]}),a.jsx("button",{"aria-label":"Close inspector",onClick:n,className:`
|
|
160
160
|
w-6 h-6 rounded-[var(--radius-xs)] flex items-center justify-center
|
|
161
161
|
text-[var(--text-faint)] hover:text-[var(--text-primary)]
|
|
162
162
|
hover:bg-[var(--bg-elevated)] transition-all
|
|
163
|
-
`,children:a.jsx(Qr,{size:13})})]}),
|
|
163
|
+
`,children:a.jsx(Qr,{size:13})})]}),t?a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"px-4 py-4 border-b border-[var(--border-subtle)]",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:`badge badge-${t.role}`,children:t.role}),a.jsx("span",{className:`badge badge-${t.status}`,children:t.status})]}),a.jsx("h2",{className:"text-[12px] font-semibold text-[var(--text-primary)] leading-snug",children:t.label}),a.jsx("p",{className:"text-[9px] text-[var(--text-muted)] font-mono mt-1 break-all opacity-60",children:t.tierId})]}),t.progressPct!==void 0&&a.jsxs($e,{icon:xs,label:"Progress",children:[a.jsx("div",{className:"flex items-center justify-between mb-1.5",children:a.jsxs("span",{className:"text-[10px] font-mono text-[var(--text-primary)]",children:[t.progressPct,"%"]})}),a.jsx(ci,{pct:t.progressPct})]}),t.currentAction&&a.jsx($e,{icon:Wr,label:"Current action",children:a.jsx("p",{className:"text-[11px] text-[var(--text-primary)] leading-snug",children:t.currentAction})}),a.jsx($e,{icon:gs,label:"Last update",children:a.jsx("p",{className:"text-[10px] font-mono text-[var(--text-muted)]",children:new Date(t.updatedAt).toLocaleTimeString()})}),a.jsxs("div",{className:"flex flex-col flex-1 min-h-0 px-3 py-3",children:[a.jsx("p",{className:"section-label mb-2 flex-shrink-0",children:"Live output"}),a.jsx("div",{ref:r,className:`
|
|
164
164
|
flex-1 overflow-y-auto font-mono text-[9.5px]
|
|
165
165
|
text-[var(--t3-color)] leading-[1.7]
|
|
166
166
|
whitespace-pre-wrap break-words
|
|
167
167
|
bg-[var(--bg-base)] rounded-[var(--radius-xs)]
|
|
168
168
|
p-2.5 border border-[var(--border-subtle)]
|
|
169
169
|
scrollbar-thin
|
|
170
|
-
`,"aria-live":"polite","aria-label":"Live token stream",children:t?a.jsxs("span",{children:[
|
|
170
|
+
`,"aria-live":"polite","aria-label":"Live token stream",children:t.output?a.jsx("span",{children:t.output}):s&&t.status==="ACTIVE"?a.jsxs("span",{children:[s.slice(-4e3),a.jsx("span",{className:"animate-blink text-[var(--t3-color)]",children:"█"})]}):a.jsx("span",{className:"text-[var(--text-faint)] italic",children:t.status==="COMPLETED"?"No output recorded.":"Waiting for output…"})})]})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 gap-3 text-center p-6",children:[a.jsx("div",{className:"w-9 h-9 rounded-full bg-[var(--bg-elevated)] flex items-center justify-center",children:a.jsx(At,{size:16,className:"text-[var(--text-faint)]"})}),a.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"Select an agent node to inspect it"})]})]})});function Ue({icon:e,tier:t,label:s,isLast:n=!1}){return a.jsxs("div",{className:`flex items-start gap-3 py-2.5 ${n?"":"border-b border-[var(--border-subtle)]"}`,children:[a.jsx("div",{className:`
|
|
171
171
|
flex-shrink-0 w-6 h-6 rounded-full
|
|
172
172
|
bg-[var(--bg-overlay)] border border-[var(--border-subtle)]
|
|
173
173
|
flex items-center justify-center text-[11px] mt-0.5
|
|
174
|
-
`,children:e}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:`badge badge-${
|
|
174
|
+
`,children:e}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:`badge badge-${t}`,children:t}),a.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate",children:s})]}),a.jsx("p",{className:"text-[9px] font-mono text-[var(--warning)]",children:"⚠ Uncertain — escalated upward"})]}),a.jsx(Vr,{size:10,className:"text-[var(--text-faint)] mt-1.5 flex-shrink-0"})]})}const ui=h.memo(function({request:t,onDecide:s}){h.useEffect(()=>{const o=l=>{l.key==="y"&&s(!0,!1),l.key==="n"&&s(!1,!1)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[s]);const n=h.useCallback(o=>s(!0,o),[s]),r=h.useCallback(o=>s(!1,o),[s]),i=t.input.path??t.input.command??JSON.stringify(t.input).slice(0,60);return a.jsx("div",{className:"fixed inset-0 bg-black/65 backdrop-blur-[6px] z-50 flex items-center justify-center p-4 animate-fade-in",role:"dialog","aria-modal":"true","aria-labelledby":"escalation-title",children:a.jsxs("div",{className:"w-full max-w-[460px] glass-elevated rounded-[var(--radius-lg)] shadow-dialog animate-fade-in-up",onClick:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-[var(--border-subtle)]",children:[a.jsx("div",{className:`
|
|
175
175
|
w-9 h-9 rounded-[var(--radius-sm)] flex-shrink-0
|
|
176
176
|
bg-[rgba(245,166,35,0.1)] border border-[rgba(245,166,35,0.22)]
|
|
177
177
|
flex items-center justify-center
|
|
@@ -179,12 +179,12 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
179
179
|
flex items-center gap-2
|
|
180
180
|
bg-[var(--bg-base)] rounded-[var(--radius-xs)]
|
|
181
181
|
border border-[var(--border-subtle)] px-3 py-2
|
|
182
|
-
`,children:[a.jsx("code",{className:"text-[var(--accent)] font-mono font-bold text-[11px] flex-shrink-0",children:
|
|
182
|
+
`,children:[a.jsx("code",{className:"text-[var(--accent)] font-mono font-bold text-[11px] flex-shrink-0",children:t.toolName}),i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-faint)] text-[11px]",children:"→"}),a.jsx("code",{className:"text-[var(--text-muted)] font-mono text-[10px] truncate flex-1 min-w-0",children:i})]}),t.isDangerous&&a.jsx("span",{className:"ml-auto badge badge-FAILED flex-shrink-0",children:"Dangerous"})]})]}),a.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-subtle)]",children:[a.jsx("p",{className:"section-label mb-2",children:"Escalation trail"}),a.jsx(Ue,{icon:"🔹",tier:"T3",label:`"${t.subtaskContext}" requested this`}),a.jsx(Ue,{icon:"🟣",tier:"T2",label:`Section "${t.sectionContext}" evaluated — uncertain`}),a.jsx(Ue,{icon:"🟡",tier:"T1",label:"Full task context evaluated — uncertain",isLast:!0}),a.jsxs("div",{className:"flex items-center gap-3 pt-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--accent)] flex items-center justify-center flex-shrink-0",children:a.jsx("span",{className:"text-white text-[10px] font-bold",children:"?"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-[11px] font-semibold text-[var(--text-primary)]",children:"Your decision required"}),a.jsxs("p",{className:"text-[9px] font-mono text-[var(--text-muted)] mt-0.5",children:["Press"," ",a.jsx("kbd",{className:"px-1 py-0.5 rounded-[3px] bg-[var(--bg-overlay)] border border-[var(--border-strong)] font-mono text-[8px]",children:"Y"})," ","to approve,"," ",a.jsx("kbd",{className:"px-1 py-0.5 rounded-[3px] bg-[var(--bg-overlay)] border border-[var(--border-strong)] font-mono text-[8px]",children:"N"})," ","to deny"]})]})]})]}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("button",{className:"btn btn-danger justify-center",onClick:()=>r(!1),children:"Deny once"}),a.jsx("button",{className:"btn btn-success justify-center",onClick:()=>n(!1),children:"Approve once"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("button",{className:"btn btn-ghost justify-center",onClick:()=>r(!0),children:"Always deny"}),a.jsx("button",{className:"btn btn-ghost justify-center",onClick:()=>n(!0),children:"Always approve"})]})]})]})})});function fi(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}function hi(e,t){const s=new Date(t).getTime()-new Date(e).getTime();return s<1e3?"<1s":s<6e4?`${Math.round(s/1e3)}s`:`${Math.round(s/6e4)}m`}const mi=h.memo(function(){const t=Ae(),s=U(jr),n=U(nt),[r,i]=h.useState(new Set),[o,l]=h.useState(null),[c,d]=h.useState(!1),u=h.useCallback(x=>{r.size===0&&t(vr(x))},[t,r.size]),m=h.useCallback((x,b,_)=>{_.stopPropagation(),i(w=>{var C;const j=new Set(w);if(_.shiftKey&&o!==null){const[k,I]=[Math.min(o,b),Math.max(o,b)];for(let S=k;S<=I;S++){const T=(C=s[S])==null?void 0:C.sessionId;T&&j.add(T)}}else j.has(x)?j.delete(x):j.add(x);return j}),l(b)},[o,s]),p=h.useCallback(()=>{r.size===s.length?i(new Set):i(new Set(s.map(x=>x.sessionId)))},[r.size,s]),f=h.useCallback(async()=>{if(!(r.size===0||c)){d(!0);try{const x=Array.from(r);(await fetch("/api/sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:x})})).ok&&(t(wr(x)),i(new Set),l(null))}finally{d(!1)}}},[r,c,t]),g=h.useCallback(()=>{i(new Set),l(null)},[]);if(!s.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 animate-fade-in",children:[a.jsx("div",{className:"w-11 h-11 rounded-full bg-[var(--bg-elevated)] flex items-center justify-center",children:a.jsx(xs,{size:18,className:"text-[var(--text-faint)]"})}),a.jsx("p",{className:"text-[12px] text-[var(--text-muted)]",children:"No sessions yet"}),a.jsx("p",{className:"text-[10px] font-mono text-[var(--text-faint)]",children:"Run a task to create the first session"})]});const y=r.size===s.length,v=r.size>0;return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsx("div",{className:"px-5 py-4 border-b border-[var(--border-subtle)] flex-shrink-0 bg-[var(--bg-surface)]",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"section-label",children:"Sessions"}),a.jsxs("p",{className:"text-[10px] font-mono text-[var(--text-faint)] mt-1",children:[s.length," session",s.length!==1?"s":"",v&&a.jsxs("span",{className:"text-[var(--accent)] ml-2",children:["· ",r.size," selected"]})]})]}),a.jsx("button",{onClick:p,title:y?"Deselect all":"Select all",className:"p-1.5 rounded hover:bg-[var(--bg-elevated)] transition-colors",children:y?a.jsx(Mt,{size:14,className:"text-[var(--accent)]"}):a.jsx(Tt,{size:14,className:"text-[var(--text-faint)]"})})]})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:s.map((x,b)=>{const _=x.sessionId===(n==null?void 0:n.sessionId),w=r.has(x.sessionId);return a.jsxs("button",{"aria-selected":_,"aria-label":`Session: ${x.title}, status: ${x.status}`,onClick:()=>u(x.sessionId),className:`
|
|
183
183
|
w-full text-left px-5 py-3.5
|
|
184
184
|
border-b border-[var(--border-subtle)]
|
|
185
185
|
transition-all duration-150 relative
|
|
186
186
|
animate-slide-up
|
|
187
|
-
`,style:{animationDelay:`${b*25}ms`,background:w?"rgba(124,106,247,0.08)":_?"rgba(124,106,247,0.05)":void 0,borderLeft:w||_?"2px solid var(--accent)":"2px solid transparent",paddingLeft:_||w?"18px":"20px"},children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{role:"checkbox","aria-checked":w,onClick:j=>m(x.sessionId,b,j),className:"flex-shrink-0 cursor-pointer",children:w?a.jsx(
|
|
187
|
+
`,style:{animationDelay:`${b*25}ms`,background:w?"rgba(124,106,247,0.08)":_?"rgba(124,106,247,0.05)":void 0,borderLeft:w||_?"2px solid var(--accent)":"2px solid transparent",paddingLeft:_||w?"18px":"20px"},children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{role:"checkbox","aria-checked":w,onClick:j=>m(x.sessionId,b,j),className:"flex-shrink-0 cursor-pointer",children:w?a.jsx(Mt,{size:12,className:"text-[var(--accent)]"}):a.jsx(Tt,{size:12,className:"text-[var(--text-faint)] opacity-40 hover:opacity-100 transition-opacity"})}),a.jsx("span",{className:"text-[12px] font-semibold text-[var(--text-primary)] truncate",children:x.title||"Untitled Session"})]}),a.jsx("span",{className:`badge badge-${x.status} flex-shrink-0`,children:x.status})]}),x.workspacePath&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pl-5",children:[a.jsx(qr,{size:9,className:"text-[var(--text-faint)] flex-shrink-0"}),a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)] truncate",children:x.workspacePath.split("/").pop()})]}),x.latestPrompt&&a.jsxs("p",{className:"text-[10px] text-[var(--text-muted)] truncate mb-1.5 italic pl-5",children:['"',x.latestPrompt,'"']}),a.jsxs("div",{className:"flex items-center gap-3 pl-5",children:[a.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-mono text-[var(--text-faint)]",children:[a.jsx(gs,{size:8}),fi(x.updatedAt)]}),a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)]",children:hi(x.startedAt,x.updatedAt)})]})]},x.sessionId)})}),v&&a.jsxs("div",{className:`
|
|
188
188
|
absolute bottom-4 left-1/2 -translate-x-1/2
|
|
189
189
|
flex items-center gap-3 px-4 py-2.5 rounded-xl
|
|
190
190
|
bg-[var(--bg-elevated)] border border-[var(--border-subtle)]
|
|
@@ -193,24 +193,24 @@ var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,config
|
|
|
193
193
|
flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-medium
|
|
194
194
|
bg-red-500/10 text-red-400 border border-red-500/20
|
|
195
195
|
hover:bg-red-500/20 transition-colors disabled:opacity-50
|
|
196
|
-
`,children:[a.jsx(Zr,{size:12}),c?"Deleting...":`Delete ${r.size}`]}),a.jsx("button",{onClick:g,className:"text-[11px] text-[var(--text-faint)] hover:text-[var(--text-muted)] transition-colors",children:"Cancel"})]})]})});function V(e,s
|
|
196
|
+
`,children:[a.jsx(Zr,{size:12}),c?"Deleting...":`Delete ${r.size}`]}),a.jsx("button",{onClick:g,className:"text-[11px] text-[var(--text-faint)] hover:text-[var(--text-muted)] transition-colors",children:"Cancel"})]})]})});function V(e,t,s){let n=s.initialDeps??[],r,i=!0;function o(){var l,c,d;let u;s.key&&((l=s.debug)!=null&&l.call(s))&&(u=Date.now());const m=e();if(!(m.length!==n.length||m.some((g,y)=>n[y]!==g)))return r;n=m;let f;if(s.key&&((c=s.debug)!=null&&c.call(s))&&(f=Date.now()),r=t(...m),s.key&&((d=s.debug)!=null&&d.call(s))){const g=Math.round((Date.now()-u)*100)/100,y=Math.round((Date.now()-f)*100)/100,v=y/16,x=(b,_)=>{for(b=String(b);b.length<_;)b=" "+b;return b};console.info(`%c⏱ ${x(y,5)} /${x(g,5)} ms`,`
|
|
197
197
|
font-size: .6rem;
|
|
198
198
|
font-weight: bold;
|
|
199
|
-
color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,t==null?void 0:t.key)}return t!=null&&t.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(r),i=!1,r}return o.updateDeps=l=>{n=l},o}function Rt(e,s){if(e===void 0)throw new Error("Unexpected undefined");return e}const pi=(e,s)=>Math.abs(e-s)<1.01,xi=(e,s,t)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>s.apply(this,r),t)}},Dt=e=>{const{offsetWidth:s,offsetHeight:t}=e;return{width:s,height:t}},gi=e=>e,vi=e=>{const s=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let r=s;r<=t;r++)n.push(r);return n},bi=(e,s)=>{const t=e.scrollElement;if(!t)return;const n=e.targetWindow;if(!n)return;const r=o=>{const{width:l,height:c}=o;s({width:Math.round(l),height:Math.round(c)})};if(r(Dt(t)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(o=>{const l=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const d=c.borderBoxSize[0];if(d){r({width:d.inlineSize,height:d.blockSize});return}}r(Dt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},zt={passive:!0},Pt=typeof window>"u"?!0:"onscrollend"in window,yi=(e,s)=>{const t=e.scrollElement;if(!t)return;const n=e.targetWindow;if(!n)return;let r=0;const i=e.options.useScrollendEvent&&Pt?()=>{}:xi(n,()=>{s(r,!1)},e.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:m,isRtl:p}=e.options;r=m?t.scrollLeft*(p&&-1||1):t.scrollTop,i(),s(r,u)},l=o(!0),c=o(!1);t.addEventListener("scroll",l,zt);const d=e.options.useScrollendEvent&&Pt;return d&&t.addEventListener("scrollend",c,zt),()=>{t.removeEventListener("scroll",l),d&&t.removeEventListener("scrollend",c)}},wi=(e,s,t)=>{if(s!=null&&s.borderBoxSize){const n=s.borderBoxSize[0];if(n)return Math.round(n[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},ji=(e,{adjustments:s=0,behavior:t},n)=>{var r,i;const o=e+s;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:o,behavior:t})};class _i{constructor(s){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,n,r;return((r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))??Date.now()},this.observer=(()=>{let t=null;const n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const o=()=>{const l=i.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([n,r])=>{typeof r>"u"&&delete t[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gi,rangeExtractor:vi,onChange:()=>{},measureElement:wi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=V(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,n)=>{const r=new Map,i=new Map;for(let o=n-1;o>=0;o--){const l=t[o];if(r.has(l.lane))continue;const c=i.get(l.lane);if(c==null||l.end>c.end?i.set(l.lane,l):l.end<c.end&&r.set(l.lane,!0),r.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,l)=>o.end===l.end?o.index-l.index:o.end-l.end)[0]:void 0},this.getMeasurementOptions=V(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,n,r,i,o,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=V(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c},d)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const f of this.laneAssignments.keys())f>=t&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const m=this.measurementsCache.slice(0,u),p=new Array(l).fill(void 0);for(let f=0;f<u;f++){const g=m[f];g&&(p[g.lane]=f)}for(let f=u;f<t;f++){const g=i(f),y=this.laneAssignments.get(f);let v,x;const b=c==="estimate"||d.has(g);if(y!==void 0&&this.options.lanes>1){v=y;const N=p[v],C=N!==void 0?m[N]:void 0;x=C?C.end+this.options.gap:n+r}else{const N=this.options.lanes===1?m[f-1]:this.getFurthestMeasurement(m,f);x=N?N.end+this.options.gap:n+r,v=N?N.lane:f%this.options.lanes,this.options.lanes>1&&b&&this.laneAssignments.set(f,v)}const _=d.get(g),w=typeof _=="number"?_:this.options.estimateSize(f),j=x+w;m[f]={index:f,start:x,size:w,end:j,key:g,lane:v},p[v]=f}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=V(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,i)=>this.range=t.length>0&&n>0?Si({measurements:t,outerSize:n,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=V(()=>{let t=null,n=null;const r=this.calculateRange();return r&&(t=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,n]},(t,n,r,i,o)=>i===null||o===null?[]:t({startIndex:i,endIndex:o,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const n=this.options.indexAttribute,r=t.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(r!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-i),l=Math.min(this.options.count-1,r+i);return t>=o&&t<=l}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const n=this.indexFromElement(t),r=this.options.getItemKey(n),i=this.elementsCache.get(r);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,n)=>{var r;const i=this.measurementsCache[t];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,l=n-o;l!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,l,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,n)),this.notify(!1))},this.getVirtualItems=V(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{const r=[];for(let i=0,o=t.length;i<o;i++){const l=t[i],c=n[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const n=this.getMeasurements();if(n.length!==0)return Rt(n[gs(0,n.length-1,r=>Rt(n[r]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,n,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=t>=o+i?"end":"start"),n==="center"?t+=(r-i)/2:n==="end"&&(t-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,t),0)},this.getOffsetForIndex=(t,n="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[t];if(!o)return;if(n==="auto")if(o.end>=i+r-this.options.scrollPaddingEnd)n="end";else if(o.start<=i+this.options.scrollPaddingStart)n="start";else return[i,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];const l=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,n,o.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{const i=this.getOffsetForAlignment(t,n),o=this.now();this.scrollState={index:null,align:n,behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:n="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,n);if(!i)return;const[o,l]=i,c=this.now();this.scrollState={index:t,align:l,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{const r=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const n=this.getMeasurements();let r;if(n.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((t=n[n.length-1])==null?void 0:t.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&i.some(l=>l===null);){const l=n[o];i[l.lane]===null&&(i[l.lane]=l.end),o--}r=Math.max(...i.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:n,behavior:r})=>{this.options.scrollToFn(t,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(s)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=n?n[0]:this.scrollState.lastTargetOffset,i=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&pi(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=r,this.scrollState.behavior="auto",this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const gs=(e,s,t,n)=>{for(;e<=s;){const r=(e+s)/2|0,i=t(r);if(i<n)e=r+1;else if(i>n)s=r-1;else return r}return e>0?e-1:0};function Si({measurements:e,outerSize:s,scrollOffset:t,lanes:n}){const r=e.length-1,i=c=>e[c].start;if(e.length<=n)return{startIndex:0,endIndex:r};let o=gs(0,r,i,t),l=o;if(n===1)for(;l<r&&e[l].end<t+s;)l++;else if(n>1){const c=Array(n).fill(0);for(;l<r&&c.some(u=>u<t+s);){const u=e[l];c[u.lane]=u.end,l++}const d=Array(n).fill(t+s);for(;o>=0&&d.some(u=>u>=t);){const u=e[o];d[u.lane]=u.start,o--}o=Math.max(0,o-o%n),l=Math.min(r,l+(n-1-l%n))}return{startIndex:o,endIndex:l}}const Lt=typeof document<"u"?h.useLayoutEffect:h.useEffect;function Ni({useFlushSync:e=!0,...s}){const t=h.useReducer(()=>({}),{})[1],n={...s,onChange:(i,o)=>{var l;e&&o?$t.flushSync(t):t(),(l=s.onChange)==null||l.call(s,i,o)}},[r]=h.useState(()=>new _i(n));return r.setOptions(n),Lt(()=>r._didMount(),[]),Lt(()=>r._willUpdate()),r}function ki(e){return Ni({observeElementRect:bi,observeElementOffset:yi,scrollToFn:ji,...e})}function Ft({label:e,active:s,onClick:t}){return a.jsx("button",{className:`
|
|
199
|
+
color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,s==null?void 0:s.key)}return s!=null&&s.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(r),i=!1,r}return o.updateDeps=l=>{n=l},o}function Dt(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const pi=(e,t)=>Math.abs(e-t)<1.01,xi=(e,t,s)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>t.apply(this,r),s)}},zt=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},gi=e=>e,vi=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let r=t;r<=s;r++)n.push(r);return n},bi=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;const r=o=>{const{width:l,height:c}=o;t({width:Math.round(l),height:Math.round(c)})};if(r(zt(s)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(o=>{const l=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const d=c.borderBoxSize[0];if(d){r({width:d.inlineSize,height:d.blockSize});return}}r(zt(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},Pt={passive:!0},Lt=typeof window>"u"?!0:"onscrollend"in window,yi=(e,t)=>{const s=e.scrollElement;if(!s)return;const n=e.targetWindow;if(!n)return;let r=0;const i=e.options.useScrollendEvent&&Lt?()=>{}:xi(n,()=>{t(r,!1)},e.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:m,isRtl:p}=e.options;r=m?s.scrollLeft*(p&&-1||1):s.scrollTop,i(),t(r,u)},l=o(!0),c=o(!1);s.addEventListener("scroll",l,Pt);const d=e.options.useScrollendEvent&≪return d&&s.addEventListener("scrollend",c,Pt),()=>{s.removeEventListener("scroll",l),d&&s.removeEventListener("scrollend",c)}},wi=(e,t,s)=>{if(t!=null&&t.borderBoxSize){const n=t.borderBoxSize[0];if(n)return Math.round(n[s.options.horizontal?"inlineSize":"blockSize"])}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},ji=(e,{adjustments:t=0,behavior:s},n)=>{var r,i;const o=e+t;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:o,behavior:s})};class _i{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var s,n,r;return((r=(n=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:n.now)==null?void 0:r.call(n))??Date.now()},this.observer=(()=>{let s=null;const n=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const o=()=>{const l=i.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),s=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([n,r])=>{typeof r>"u"&&delete s[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gi,rangeExtractor:vi,onChange:()=>{},measureElement:wi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...s}},this.notify=s=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,s)},this.maybeNotify=V(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,n)=>{const r=new Map,i=new Map;for(let o=n-1;o>=0;o--){const l=s[o];if(r.has(l.lane))continue;const c=i.get(l.lane);if(c==null||l.end>c.end?i.set(l.lane,l):l.end<c.end&&r.set(l.lane,!0),r.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,l)=>o.end===l.end?o.index-l.index:o.end-l.end)[0]:void 0},this.getMeasurementOptions=V(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(s,n,r,i,o,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=V(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c},d)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const f of this.laneAssignments.keys())f>=s&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const m=this.measurementsCache.slice(0,u),p=new Array(l).fill(void 0);for(let f=0;f<u;f++){const g=m[f];g&&(p[g.lane]=f)}for(let f=u;f<s;f++){const g=i(f),y=this.laneAssignments.get(f);let v,x;const b=c==="estimate"||d.has(g);if(y!==void 0&&this.options.lanes>1){v=y;const C=p[v],k=C!==void 0?m[C]:void 0;x=k?k.end+this.options.gap:n+r}else{const C=this.options.lanes===1?m[f-1]:this.getFurthestMeasurement(m,f);x=C?C.end+this.options.gap:n+r,v=C?C.lane:f%this.options.lanes,this.options.lanes>1&&b&&this.laneAssignments.set(f,v)}const _=d.get(g),w=typeof _=="number"?_:this.options.estimateSize(f),j=x+w;m[f]={index:f,start:x,size:w,end:j,key:g,lane:v},p[v]=f}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=V(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,n,r,i)=>this.range=s.length>0&&n>0?Si({measurements:s,outerSize:n,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=V(()=>{let s=null,n=null;const r=this.calculateRange();return r&&(s=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,n]},(s,n,r,i,o)=>i===null||o===null?[]:s({startIndex:i,endIndex:o,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const n=this.options.indexAttribute,r=s.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(r!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-i),l=Math.min(this.options.count-1,r+i);return s>=o&&s<=l}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const n=this.indexFromElement(s),r=this.options.getItemKey(n),i=this.elementsCache.get(r);i!==s&&(i&&this.observer.unobserve(i),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,n)=>{var r;const i=this.measurementsCache[s];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,l=n-o;l!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,l,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,n)),this.notify(!1))},this.getVirtualItems=V(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,n)=>{const r=[];for(let i=0,o=s.length;i<o;i++){const l=s[i],c=n[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const n=this.getMeasurements();if(n.length!==0)return Dt(n[vs(0,n.length-1,r=>Dt(n[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,n,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=s>=o+i?"end":"start"),n==="center"?s+=(r-i)/2:n==="end"&&(s-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,s),0)},this.getOffsetForIndex=(s,n="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[s];if(!o)return;if(n==="auto")if(o.end>=i+r-this.options.scrollPaddingEnd)n="end";else if(o.start<=i+this.options.scrollPaddingStart)n="start";else return[i,n];if(n==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),n];const l=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,n,o.size),n]},this.scrollToOffset=(s,{align:n="start",behavior:r="auto"}={})=>{const i=this.getOffsetForAlignment(s,n),o=this.now();this.scrollState={index:null,align:n,behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:n="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const i=this.getOffsetForIndex(s,n);if(!i)return;const[o,l]=i,c=this.now();this.scrollState={index:s,align:l,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:n="auto"}={})=>{const r=this.getScrollOffset()+s,i=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var s;const n=this.getMeasurements();let r;if(n.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=n[n.length-1])==null?void 0:s.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&i.some(l=>l===null);){const l=n[o];i[l.lane]===null&&(i[l.lane]=l.end),o--}r=Math.max(...i.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:n,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=n?n[0]:this.scrollState.lastTargetOffset,i=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&pi(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=r,this.scrollState.behavior="auto",this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const vs=(e,t,s,n)=>{for(;e<=t;){const r=(e+t)/2|0,i=s(r);if(i<n)e=r+1;else if(i>n)t=r-1;else return r}return e>0?e-1:0};function Si({measurements:e,outerSize:t,scrollOffset:s,lanes:n}){const r=e.length-1,i=c=>e[c].start;if(e.length<=n)return{startIndex:0,endIndex:r};let o=vs(0,r,i,s),l=o;if(n===1)for(;l<r&&e[l].end<s+t;)l++;else if(n>1){const c=Array(n).fill(0);for(;l<r&&c.some(u=>u<s+t);){const u=e[l];c[u.lane]=u.end,l++}const d=Array(n).fill(s+t);for(;o>=0&&d.some(u=>u>=s);){const u=e[o];d[u.lane]=u.start,o--}o=Math.max(0,o-o%n),l=Math.min(r,l+(n-1-l%n))}return{startIndex:o,endIndex:l}}const Ft=typeof document<"u"?h.useLayoutEffect:h.useEffect;function Ni({useFlushSync:e=!0,...t}){const s=h.useReducer(()=>({}),{})[1],n={...t,onChange:(i,o)=>{var l;e&&o?Ut.flushSync(s):s(),(l=t.onChange)==null||l.call(t,i,o)}},[r]=h.useState(()=>new _i(n));return r.setOptions(n),Ft(()=>r._didMount(),[]),Ft(()=>r._willUpdate()),r}function Ci(e){return Ni({observeElementRect:bi,observeElementOffset:yi,scrollToFn:ji,...e})}function $t({label:e,active:t,onClick:s}){return a.jsx("button",{className:`
|
|
200
200
|
px-2.5 py-1 rounded-[3px] text-[9px] font-mono font-bold
|
|
201
201
|
uppercase tracking-wider transition-all duration-100 border
|
|
202
|
-
${
|
|
203
|
-
`,onClick:
|
|
202
|
+
${t?"bg-[var(--accent)] text-white border-[var(--accent)]":"bg-transparent text-[var(--text-muted)] border-[var(--border-subtle)] hover:border-[var(--border-strong)] hover:text-[var(--text-primary)]"}
|
|
203
|
+
`,onClick:s,children:e})}const ki=38,Ei=h.memo(function({log:t,style:s}){return a.jsxs("div",{style:s,className:`
|
|
204
204
|
flex items-center gap-3 px-5
|
|
205
205
|
border-b border-[var(--border-subtle)]
|
|
206
206
|
hover:bg-[var(--bg-elevated)] transition-colors
|
|
207
|
-
`,children:[a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)] flex-shrink-0 w-[64px] tabular-nums",children:new Date(
|
|
207
|
+
`,children:[a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)] flex-shrink-0 w-[64px] tabular-nums",children:new Date(t.timestamp).toLocaleTimeString("en-US",{hour12:!1})}),a.jsx("span",{className:`badge badge-${t.role} flex-shrink-0`,children:t.role}),a.jsx("span",{className:`badge badge-${t.status} flex-shrink-0`,children:t.status}),a.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] truncate flex-shrink-0 max-w-[120px]",children:t.label}),t.currentAction&&a.jsx("span",{className:"text-[9px] text-[var(--text-muted)] font-mono truncate flex-1 min-w-0",children:t.currentAction})]})}),Ii=h.memo(function(){const t=U(Sr),[s,n]=h.useState("ALL"),[r,i]=h.useState("ALL"),[o,l]=h.useState(!0),c=h.useRef(null),d=h.useMemo(()=>t.filter(f=>!(s!=="ALL"&&f.role!==s||r!=="ALL"&&f.status!==r)),[t,s,r]),u=Ci({count:d.length,getScrollElement:()=>c.current,estimateSize:()=>ki,overscan:12}),m=h.useCallback(()=>{d.length>0&&u.scrollToIndex(d.length-1,{behavior:"smooth"})},[d.length,u]);h.useEffect(()=>{o&&m()},[d.length,o]);const p=h.useCallback(()=>{const f=c.current;f&&l(f.scrollHeight-f.scrollTop<=f.clientHeight+60)},[]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-[var(--bg-base)]",children:[a.jsxs("div",{className:`
|
|
208
208
|
flex items-center gap-2 px-5 py-2.5
|
|
209
209
|
border-b border-[var(--border-subtle)] flex-shrink-0 flex-wrap
|
|
210
210
|
bg-[var(--bg-surface)]
|
|
211
|
-
`,children:[a.jsx("span",{className:"section-label mr-1",children:"Role"}),["ALL","T1","T2","T3"].map(f=>a.jsx(
|
|
211
|
+
`,children:[a.jsx("span",{className:"section-label mr-1",children:"Role"}),["ALL","T1","T2","T3"].map(f=>a.jsx($t,{label:f,active:s===f,onClick:()=>n(f)},f)),a.jsx("div",{className:"divider-v h-4 mx-1"}),a.jsx("span",{className:"section-label mr-1",children:"Status"}),["ALL","ACTIVE","COMPLETED","FAILED","ESCALATED"].map(f=>a.jsx($t,{label:f,active:r===f,onClick:()=>i(f)},f)),a.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[a.jsxs("span",{className:"text-[9px] font-mono text-[var(--text-faint)] tabular-nums",children:[d.length.toLocaleString()," entries"]}),!o&&a.jsx("button",{className:"btn btn-ghost py-0.5 px-2",onClick:()=>{l(!0),m()},children:"↓ Jump to latest"})]})]}),a.jsxs("div",{className:`
|
|
212
212
|
flex items-center gap-3 px-5 py-1.5
|
|
213
213
|
border-b border-[var(--border-subtle)]
|
|
214
214
|
bg-[var(--bg-surface)] flex-shrink-0
|
|
215
|
-
`,children:[a.jsx("span",{className:"section-label w-[64px]",children:"Time"}),a.jsx("span",{className:"section-label w-[28px]",children:"Tier"}),a.jsx("span",{className:"section-label w-[72px]",children:"Status"}),a.jsx("span",{className:"section-label w-[120px]",children:"Agent"}),a.jsx("span",{className:"section-label",children:"Action"})]}),d.length===0?a.jsx("div",{className:"flex items-center justify-center flex-1 text-[var(--text-faint)] text-[11px] font-mono",children:
|
|
216
|
-
${t===r.id?"bg-[var(--accent)]/15 text-[var(--accent)] font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-elevated)]"}`,children:[a.jsx("span",{className:"text-[11px] font-mono opacity-70",children:r.icon}),r.label]},r.id))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:a.jsxs("div",{className:"max-w-2xl mx-auto",children:[t==="identities"&&a.jsx(Ti,{token:e}),t==="tier-limits"&&a.jsx(Ri,{token:e}),t==="budget"&&a.jsx(Di,{token:e}),t==="danger"&&a.jsx(zi,{token:e,dispatch:s})]})})]})}function Ti({token:e}){const[s,t]=h.useState([]),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null),[d,u]=h.useState({name:"",description:"",systemPrompt:"",setDefault:!1}),[m,p]=h.useState(""),f=h.useCallback(async()=>{try{const b=await fetch("/api/identities",{headers:{Authorization:`Bearer ${e}`}});b.ok&&t(await b.json())}finally{r(!1)}},[e]);h.useEffect(()=>{f()},[f]);const g=()=>{u({name:"",description:"",systemPrompt:"",setDefault:!1}),p("")},y=async()=>{if(!d.name.trim()){p("Name is required");return}(await fetch("/api/identities",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(d)})).ok?(g(),o(!1),await f()):p("Failed to create identity")},v=async(b,_)=>{await fetch(`/api/identities/${b}`,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(_)}),c(null),await f()},x=async b=>{await fetch(`/api/identities/${b}`,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}}),await f()};return n?a.jsx(Pi,{}):a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)]",children:"Identities"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:"Persona profiles that shape how agents behave."})]}),a.jsx("button",{onClick:()=>{g(),o(!0)},className:"btn btn-primary h-8 text-sm px-3",children:"+ New Identity"})]}),i&&a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] p-5 mb-6 border border-[var(--accent)]/30",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] mb-4",children:"Create Identity"}),a.jsx(vs,{form:d,onChange:u,error:m}),a.jsxs("div",{className:"flex gap-2 mt-4",children:[a.jsx("button",{onClick:y,className:"btn btn-primary text-sm",children:"Create"}),a.jsx("button",{onClick:()=>{o(!1),g()},className:"btn glass text-sm",children:"Cancel"})]})]}),s.length===0&&!i&&a.jsxs("div",{className:"text-center py-12 text-[var(--text-muted)]",children:[a.jsx("p",{className:"text-2xl mb-2",children:"◎"}),a.jsx("p",{children:"No identities yet. Create one above."})]}),a.jsx("div",{className:"flex flex-col gap-3",children:s.map(b=>a.jsx(Oi,{identity:b,token:e,editing:l===b.id,onEdit:()=>c(l===b.id?null:b.id),onSave:_=>v(b.id,_),onDelete:()=>x(b.id),onSetDefault:()=>v(b.id,{setDefault:!0})},b.id))})]})}function vs({form:e,onChange:s,error:t}){return a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Name *"}),a.jsx("input",{className:"input",placeholder:"e.g. Senior Engineer",value:e.name,onChange:n=>s({...e,name:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Description"}),a.jsx("input",{className:"input",placeholder:"Short description",value:e.description,onChange:n=>s({...e,description:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"System Prompt"}),a.jsx("textarea",{className:"input resize-none",rows:3,placeholder:"You are a senior engineer who writes concise, maintainable code...",value:e.systemPrompt,onChange:n=>s({...e,systemPrompt:n.target.value})})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.setDefault,onChange:n=>s({...e,setDefault:n.target.checked}),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Set as default identity"})]}),t&&a.jsx("p",{className:"text-[11px] text-[var(--error)] font-mono",children:t})]})}function Oi({identity:e,editing:s,onEdit:t,onSave:n,onDelete:r,onSetDefault:i}){var u;const[o,l]=h.useState({name:e.name,description:e.description??"",systemPrompt:e.systemPrompt??"",setDefault:e.isDefault}),[c,d]=h.useState(!1);return a.jsxs("div",{className:`glass-elevated rounded-[var(--radius-lg)] p-4 border transition-all ${s?"border-[var(--accent)]/40":"border-[var(--border-base)]"}`,children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--accent)]/20 flex items-center justify-center flex-shrink-0 text-[var(--accent)] font-bold text-sm",children:(u=e.name[0])==null?void 0:u.toUpperCase()}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate",children:e.name}),e.isDefault&&a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent)]/20 text-[var(--accent)] font-mono",children:"Default"})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5 truncate",children:e.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[!e.isDefault&&a.jsx("button",{onClick:i,className:"btn glass text-xs h-7 px-2",children:"Set Default"}),a.jsx("button",{onClick:t,className:"btn glass text-xs h-7 px-2",children:s?"Cancel":"Edit"}),c?a.jsx("button",{onClick:r,className:"btn text-xs h-7 px-2 bg-[var(--error)] border-transparent text-white",children:"Confirm"}):a.jsx("button",{onClick:()=>d(!0),className:"btn glass text-xs h-7 px-2 text-[var(--error)]",children:"Delete"})]})]}),s&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border-base)]",children:[a.jsx(vs,{form:o,onChange:l,error:""}),a.jsx("div",{className:"flex gap-2 mt-4",children:a.jsx("button",{onClick:()=>n(o),className:"btn btn-primary text-sm",children:"Save Changes"})})]})]})}function Ri({token:e}){const[s,t]=h.useState({}),[n,r]=h.useState(!1),[i,o]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(d=>d.json()).then(d=>{d.tierLimits&&t(d.tierLimits)})},[e]);const l=async()=>{r(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({tierLimits:s})}),o(!0),setTimeout(()=>o(!1),2e3)}finally{r(!1)}},c=[{key:"t1MaxTokens",label:"T1 (Administrator)",desc:"Max output tokens for the planner tier",placeholder:"4096"},{key:"t2MaxTokens",label:"T2 (Manager)",desc:"Max output tokens for manager/coordinator",placeholder:"8192"},{key:"t3MaxTokens",label:"T3 (Worker)",desc:"Max output tokens for each task worker",placeholder:"32768"}];return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Tier Token Limits"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Cap the maximum output tokens per AI call for each tier. Leave blank to use model defaults."}),a.jsx("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)]",children:c.map(d=>a.jsxs("div",{className:"flex items-center justify-between p-5 gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:d.label}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:d.desc})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:128,max:2e5,step:128,placeholder:d.placeholder,value:s[d.key]??"",onChange:u=>t(m=>({...m,[d.key]:u.target.value?Number(u.target.value):void 0})),className:"input w-28 text-right font-mono text-sm"}),a.jsx("span",{className:"text-xs text-[var(--text-faint)] font-mono",children:"tokens"})]})]},d.key))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[a.jsx("button",{onClick:l,disabled:n,className:"btn btn-primary",children:n?"Saving…":i?"✓ Saved":"Save Limits"}),i&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function Di({token:e}){var p;const[s,t]=h.useState({warnAtPct:80}),[n,r]=h.useState(null),[i,o]=h.useState(!1),[l,c]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>{f.budget&&t(f.budget)}),fetch("/api/stats",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>r(f))},[e]);const d=async()=>{o(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({budget:s})}),c(!0),setTimeout(()=>c(!1),2e3)}finally{o(!1)}},u=s.sessionBudgetUsd&&n?Math.min(100,n.totalCostUsd/s.sessionBudgetUsd*100):null,m=s.warnAtPct;return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Cost Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Set spending limits. The agent will abort if a session budget is exceeded."}),a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)] mb-4",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Session Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Max spend per REPL session. Exceeding this aborts the current run."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.01,placeholder:"0.50",value:s.sessionBudgetUsd??"",onChange:f=>t(g=>({...g,sessionBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]}),u!==null&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mb-1",children:[a.jsx("span",{children:"Session spend"}),a.jsxs("span",{children:["$",n==null?void 0:n.totalCostUsd.toFixed(4)," / $",(p=s.sessionBudgetUsd)==null?void 0:p.toFixed(2)]})]}),a.jsx("div",{className:"h-1.5 rounded-full bg-[var(--bg-base)] overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all ${u>=100?"bg-[var(--error)]":u>=m?"bg-yellow-400":"bg-[var(--accent)]"}`,style:{width:`${u}%`}})})]})]}),a.jsx("div",{className:"p-5",children:a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"font-medium text-[var(--text-primary)]",children:["Daily Budget ",a.jsx("span",{className:"text-xs text-[var(--text-faint)] ml-1",children:"(display only)"})]}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Informational limit shown in the dashboard for reference."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.1,placeholder:"5.00",value:s.dailyBudgetUsd??"",onChange:f=>t(g=>({...g,dailyBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]})}),a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Warn at"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Show a dashboard warning when spend reaches this % of limit."})]}),a.jsxs("span",{className:"text-sm font-mono text-[var(--accent)]",children:[s.warnAtPct,"%"]})]}),a.jsx("input",{type:"range",min:10,max:99,step:5,value:s.warnAtPct,onChange:f=>t(g=>({...g,warnAtPct:Number(f.target.value)})),className:"w-full accent-[var(--accent)]"}),a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mt-1",children:[a.jsx("span",{children:"10%"}),a.jsx("span",{children:"50%"}),a.jsx("span",{children:"99%"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:d,disabled:i,className:"btn btn-primary",children:i?"Saving…":l?"✓ Saved":"Save Budget"}),l&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function zi({token:e,dispatch:s}){const[t,n]=h.useState(null),[r,i]=h.useState(!1),o=async l=>{n(l);try{await fetch(l,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}})}finally{n(null),i(!1)}};return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--error)] mb-1",children:"Danger Zone"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"These actions are irreversible."}),a.jsxs("div",{className:"rounded-[var(--radius-lg)] border border-[var(--error)]/30 divide-y divide-[var(--error)]/10 overflow-hidden",children:[a.jsx(Ue,{title:"Clear All Sessions",desc:"Permanently delete all conversation sessions and messages.",action:r?a.jsx("button",{onClick:()=>o("/api/sessions"),disabled:!!t,className:"btn text-sm bg-[var(--error)] border-transparent text-white",children:t==="/api/sessions"?"Clearing…":"Confirm Delete"}):a.jsx("button",{onClick:()=>i(!0),className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:"Clear Sessions"})}),a.jsx(Ue,{title:"Clear Graphs (Backend + Frontend)",desc:"Delete all runtime node logs from DB and reset the topology view.",action:a.jsx("button",{onClick:async()=>{await o("/api/runtime"),s(kt())},disabled:!!t,className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:t==="/api/runtime"?"Clearing…":"Clear DB Graphs"})}),a.jsx(Ue,{title:"Clear Graphs (Frontend Only)",desc:"Reset the topology view locally without touching the server database.",action:a.jsx("button",{onClick:()=>s(kt()),className:"btn glass text-sm",children:"Clear View"})})]})]})}function Ue({title:e,desc:s,action:t}){return a.jsxs("div",{className:"flex items-center justify-between gap-6 p-5 bg-[var(--error)]/[0.03]",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:e}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:s})]}),a.jsx("div",{className:"flex-shrink-0",children:t})]})}function Pi(){return a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx("div",{className:"w-6 h-6 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"})})}function Li(){const[e,s]=h.useState(()=>localStorage.getItem("cascade_token")),[t,n]=h.useState(e===null);h.useEffect(()=>{e===null&&(async()=>{try{(await fetch("/api/runtime?scope=workspace",{headers:{Authorization:"Bearer "}})).ok&&(s(""),localStorage.setItem("cascade_token",""))}catch{}finally{n(!1)}})()},[e]);const r=h.useCallback(o=>{s(o),localStorage.setItem("cascade_token",o)},[]),i=h.useCallback(()=>{s(null),localStorage.removeItem("cascade_token")},[]);return t?a.jsx("div",{className:"flex items-center justify-center w-full h-full bg-[var(--bg-base)]",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"}),a.jsx("p",{className:"section-label",children:"Connecting…"})]})}):e===null?a.jsx(Fr,{onLogin:r}):a.jsx(Fi,{token:e,onLogout:i,onNeedAuth:()=>{s(null),localStorage.removeItem("cascade_token")}})}function Fi({token:e,onLogout:s,onNeedAuth:t}){const n=Ae(),[r,i]=h.useState("topology"),[o,l]=h.useState(null),[c,d]=h.useState(""),[u,m]=h.useState(null),[p,f]=h.useState(0),[g,y]=h.useState(0),v=U(_r),x=U(st),b=U(Nr),_=h.useRef(u);_.current=u;const w=h.useCallback(async(k="workspace")=>{try{const z=await fetch(`/api/runtime?scope=${k}`,{headers:{Authorization:`Bearer ${e}`},cache:"no-store"});if(z.status===401){t();return}if(z.ok){const bs=await z.json();n(cs(bs))}}catch{}},[e,n,t]),{socket:j}=Lr({url:"/",token:e,activeSessionId:x==null?void 0:x.sessionId,onRuntimeRefresh:k=>w(k??"workspace"),onStreamToken:k=>d(z=>(z+k.text).slice(-8e3)),onCostUpdate:k=>{typeof k.totalCostUsd=="number"&&f(k.totalCostUsd),typeof k.totalTokens=="number"&&y(k.totalTokens)},onEscalation:k=>{_.current||m(k)}});h.useEffect(()=>{w()},[w]);const N=h.useMemo(()=>v.map(k=>({id:k.tierId,role:k.role,label:k.label,status:k.status,action:k.currentAction,progressPct:k.progressPct})),[v]),C=h.useMemo(()=>v.filter(k=>k.parentId).map(k=>({from:k.parentId,to:k.tierId})),[v]),I=h.useMemo(()=>v.find(k=>k.tierId===o)??null,[v,o]),S=h.useCallback((k,z)=>{!u||!j||(j.emit("permission:decision",{requestId:u.id,approved:k,always:z,decidedBy:"USER"}),m(null))},[u,j]),T=o!==null;return a.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-[var(--bg-base)]",children:[a.jsx(ti,{activeTab:r,onTabChange:i,onLogout:s}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden",children:[a.jsx(ri,{isConnected:b,totalCostUsd:p,totalTokens:g}),a.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[a.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden relative dot-grid",children:[r==="topology"&&a.jsx(li,{nodes:N,edges:C,selectedNodeId:o??void 0,onSelectNode:l}),r==="sessions"&&a.jsx(mi,{}),r==="logs"&&a.jsx(Ii,{}),r==="settings"&&a.jsx(Mi,{token:e})]}),r==="topology"&&T&&a.jsx(di,{node:I,streamLog:c,onClose:()=>l(null)})]})]}),u&&a.jsx(ui,{request:u,onDecide:S})]})}Be.createRoot(document.getElementById("root")).render(a.jsx(Cs.StrictMode,{children:a.jsx(en,{store:Cr,children:a.jsx(Li,{})})}));
|
|
215
|
+
`,children:[a.jsx("span",{className:"section-label w-[64px]",children:"Time"}),a.jsx("span",{className:"section-label w-[28px]",children:"Tier"}),a.jsx("span",{className:"section-label w-[72px]",children:"Status"}),a.jsx("span",{className:"section-label w-[120px]",children:"Agent"}),a.jsx("span",{className:"section-label",children:"Action"})]}),d.length===0?a.jsx("div",{className:"flex items-center justify-center flex-1 text-[var(--text-faint)] text-[11px] font-mono",children:t.length===0?"// no log entries":"// no entries match filter"}):a.jsx("div",{ref:c,onScroll:p,className:"flex-1 overflow-y-auto",role:"log","aria-label":"Activity log","aria-live":"polite",children:a.jsx("div",{style:{height:u.getTotalSize(),position:"relative"},children:u.getVirtualItems().map(f=>{const g=d[f.index];return a.jsx(Ei,{log:g,style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${f.start}px)`,height:`${f.size}px`}},g.id)})})})]})}),Ai=[{id:"identities",label:"Identities",icon:"◎"},{id:"tier-limits",label:"Tier Limits",icon:"⊟"},{id:"budget",label:"Budget",icon:"⟁"},{id:"danger",label:"Danger Zone",icon:"⚡"}];function Mi({token:e}){const t=Ae(),[s,n]=h.useState("identities");return a.jsxs("div",{className:"flex h-full overflow-hidden animate-fade-in",children:[a.jsxs("nav",{className:"w-44 flex-shrink-0 border-r border-[var(--border-base)] p-4 flex flex-col gap-1",children:[a.jsx("p",{className:"section-label mb-3",children:"Settings"}),Ai.map(r=>a.jsxs("button",{onClick:()=>n(r.id),className:`flex items-center gap-2.5 px-3 py-2 rounded-[var(--radius-sm)] text-sm transition-all text-left
|
|
216
|
+
${s===r.id?"bg-[var(--accent)]/15 text-[var(--accent)] font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-elevated)]"}`,children:[a.jsx("span",{className:"text-[11px] font-mono opacity-70",children:r.icon}),r.label]},r.id))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:a.jsxs("div",{className:"max-w-2xl mx-auto",children:[s==="identities"&&a.jsx(Ti,{token:e}),s==="tier-limits"&&a.jsx(Ri,{token:e}),s==="budget"&&a.jsx(Di,{token:e}),s==="danger"&&a.jsx(zi,{token:e,dispatch:t})]})})]})}function Ti({token:e}){const[t,s]=h.useState([]),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null),[d,u]=h.useState({name:"",description:"",systemPrompt:"",setDefault:!1}),[m,p]=h.useState(""),f=h.useCallback(async()=>{try{const b=await fetch("/api/identities",{headers:{Authorization:`Bearer ${e}`}});b.ok&&s(await b.json())}finally{r(!1)}},[e]);h.useEffect(()=>{f()},[f]);const g=()=>{u({name:"",description:"",systemPrompt:"",setDefault:!1}),p("")},y=async()=>{if(!d.name.trim()){p("Name is required");return}(await fetch("/api/identities",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(d)})).ok?(g(),o(!1),await f()):p("Failed to create identity")},v=async(b,_)=>{await fetch(`/api/identities/${b}`,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(_)}),c(null),await f()},x=async b=>{await fetch(`/api/identities/${b}`,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}}),await f()};return n?a.jsx(Pi,{}):a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)]",children:"Identities"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:"Persona profiles that shape how agents behave."})]}),a.jsx("button",{onClick:()=>{g(),o(!0)},className:"btn btn-primary h-8 text-sm px-3",children:"+ New Identity"})]}),i&&a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] p-5 mb-6 border border-[var(--accent)]/30",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] mb-4",children:"Create Identity"}),a.jsx(bs,{form:d,onChange:u,error:m}),a.jsxs("div",{className:"flex gap-2 mt-4",children:[a.jsx("button",{onClick:y,className:"btn btn-primary text-sm",children:"Create"}),a.jsx("button",{onClick:()=>{o(!1),g()},className:"btn glass text-sm",children:"Cancel"})]})]}),t.length===0&&!i&&a.jsxs("div",{className:"text-center py-12 text-[var(--text-muted)]",children:[a.jsx("p",{className:"text-2xl mb-2",children:"◎"}),a.jsx("p",{children:"No identities yet. Create one above."})]}),a.jsx("div",{className:"flex flex-col gap-3",children:t.map(b=>a.jsx(Oi,{identity:b,token:e,editing:l===b.id,onEdit:()=>c(l===b.id?null:b.id),onSave:_=>v(b.id,_),onDelete:()=>x(b.id),onSetDefault:()=>v(b.id,{setDefault:!0})},b.id))})]})}function bs({form:e,onChange:t,error:s}){return a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Name *"}),a.jsx("input",{className:"input",placeholder:"e.g. Senior Engineer",value:e.name,onChange:n=>t({...e,name:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Description"}),a.jsx("input",{className:"input",placeholder:"Short description",value:e.description,onChange:n=>t({...e,description:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"System Prompt"}),a.jsx("textarea",{className:"input resize-none",rows:3,placeholder:"You are a senior engineer who writes concise, maintainable code...",value:e.systemPrompt,onChange:n=>t({...e,systemPrompt:n.target.value})})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.setDefault,onChange:n=>t({...e,setDefault:n.target.checked}),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Set as default identity"})]}),s&&a.jsx("p",{className:"text-[11px] text-[var(--error)] font-mono",children:s})]})}function Oi({identity:e,editing:t,onEdit:s,onSave:n,onDelete:r,onSetDefault:i}){var u;const[o,l]=h.useState({name:e.name,description:e.description??"",systemPrompt:e.systemPrompt??"",setDefault:e.isDefault}),[c,d]=h.useState(!1);return a.jsxs("div",{className:`glass-elevated rounded-[var(--radius-lg)] p-4 border transition-all ${t?"border-[var(--accent)]/40":"border-[var(--border-base)]"}`,children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--accent)]/20 flex items-center justify-center flex-shrink-0 text-[var(--accent)] font-bold text-sm",children:(u=e.name[0])==null?void 0:u.toUpperCase()}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate",children:e.name}),e.isDefault&&a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent)]/20 text-[var(--accent)] font-mono",children:"Default"})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5 truncate",children:e.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[!e.isDefault&&a.jsx("button",{onClick:i,className:"btn glass text-xs h-7 px-2",children:"Set Default"}),a.jsx("button",{onClick:s,className:"btn glass text-xs h-7 px-2",children:t?"Cancel":"Edit"}),c?a.jsx("button",{onClick:r,className:"btn text-xs h-7 px-2 bg-[var(--error)] border-transparent text-white",children:"Confirm"}):a.jsx("button",{onClick:()=>d(!0),className:"btn glass text-xs h-7 px-2 text-[var(--error)]",children:"Delete"})]})]}),t&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border-base)]",children:[a.jsx(bs,{form:o,onChange:l,error:""}),a.jsx("div",{className:"flex gap-2 mt-4",children:a.jsx("button",{onClick:()=>n(o),className:"btn btn-primary text-sm",children:"Save Changes"})})]})]})}function Ri({token:e}){const[t,s]=h.useState({}),[n,r]=h.useState(!1),[i,o]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(d=>d.json()).then(d=>{d.tierLimits&&s(d.tierLimits)})},[e]);const l=async()=>{r(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({tierLimits:t})}),o(!0),setTimeout(()=>o(!1),2e3)}finally{r(!1)}},c=[{key:"t1MaxTokens",label:"T1 (Administrator)",desc:"Max output tokens for the planner tier",placeholder:"4096"},{key:"t2MaxTokens",label:"T2 (Manager)",desc:"Max output tokens for manager/coordinator",placeholder:"8192"},{key:"t3MaxTokens",label:"T3 (Worker)",desc:"Max output tokens for each task worker",placeholder:"32768"}];return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Tier Token Limits"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Cap the maximum output tokens per AI call for each tier. Leave blank to use model defaults."}),a.jsx("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)]",children:c.map(d=>a.jsxs("div",{className:"flex items-center justify-between p-5 gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:d.label}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:d.desc})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:128,max:2e5,step:128,placeholder:d.placeholder,value:t[d.key]??"",onChange:u=>s(m=>({...m,[d.key]:u.target.value?Number(u.target.value):void 0})),className:"input w-28 text-right font-mono text-sm"}),a.jsx("span",{className:"text-xs text-[var(--text-faint)] font-mono",children:"tokens"})]})]},d.key))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[a.jsx("button",{onClick:l,disabled:n,className:"btn btn-primary",children:n?"Saving…":i?"✓ Saved":"Save Limits"}),i&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function Di({token:e}){var p;const[t,s]=h.useState({warnAtPct:80}),[n,r]=h.useState(null),[i,o]=h.useState(!1),[l,c]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>{f.budget&&s(f.budget)}),fetch("/api/stats",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>r(f))},[e]);const d=async()=>{o(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({budget:t})}),c(!0),setTimeout(()=>c(!1),2e3)}finally{o(!1)}},u=t.sessionBudgetUsd&&n?Math.min(100,n.totalCostUsd/t.sessionBudgetUsd*100):null,m=t.warnAtPct;return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Cost Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Set spending limits. The agent will abort if a session budget is exceeded."}),a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)] mb-4",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Session Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Max spend per REPL session. Exceeding this aborts the current run."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.01,placeholder:"0.50",value:t.sessionBudgetUsd??"",onChange:f=>s(g=>({...g,sessionBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]}),u!==null&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mb-1",children:[a.jsx("span",{children:"Session spend"}),a.jsxs("span",{children:["$",n==null?void 0:n.totalCostUsd.toFixed(4)," / $",(p=t.sessionBudgetUsd)==null?void 0:p.toFixed(2)]})]}),a.jsx("div",{className:"h-1.5 rounded-full bg-[var(--bg-base)] overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all ${u>=100?"bg-[var(--error)]":u>=m?"bg-yellow-400":"bg-[var(--accent)]"}`,style:{width:`${u}%`}})})]})]}),a.jsx("div",{className:"p-5",children:a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"font-medium text-[var(--text-primary)]",children:["Daily Budget ",a.jsx("span",{className:"text-xs text-[var(--text-faint)] ml-1",children:"(display only)"})]}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Informational limit shown in the dashboard for reference."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.1,placeholder:"5.00",value:t.dailyBudgetUsd??"",onChange:f=>s(g=>({...g,dailyBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]})}),a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Warn at"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Show a dashboard warning when spend reaches this % of limit."})]}),a.jsxs("span",{className:"text-sm font-mono text-[var(--accent)]",children:[t.warnAtPct,"%"]})]}),a.jsx("input",{type:"range",min:10,max:99,step:5,value:t.warnAtPct,onChange:f=>s(g=>({...g,warnAtPct:Number(f.target.value)})),className:"w-full accent-[var(--accent)]"}),a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mt-1",children:[a.jsx("span",{children:"10%"}),a.jsx("span",{children:"50%"}),a.jsx("span",{children:"99%"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:d,disabled:i,className:"btn btn-primary",children:i?"Saving…":l?"✓ Saved":"Save Budget"}),l&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function zi({token:e,dispatch:t}){const[s,n]=h.useState(null),[r,i]=h.useState(!1),o=async l=>{n(l);try{await fetch(l,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}})}finally{n(null),i(!1)}};return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--error)] mb-1",children:"Danger Zone"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"These actions are irreversible."}),a.jsxs("div",{className:"rounded-[var(--radius-lg)] border border-[var(--error)]/30 divide-y divide-[var(--error)]/10 overflow-hidden",children:[a.jsx(Be,{title:"Clear All Sessions",desc:"Permanently delete all conversation sessions and messages.",action:r?a.jsx("button",{onClick:()=>o("/api/sessions"),disabled:!!s,className:"btn text-sm bg-[var(--error)] border-transparent text-white",children:s==="/api/sessions"?"Clearing…":"Confirm Delete"}):a.jsx("button",{onClick:()=>i(!0),className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:"Clear Sessions"})}),a.jsx(Be,{title:"Clear Graphs (Backend + Frontend)",desc:"Delete all runtime node logs from DB and reset the topology view.",action:a.jsx("button",{onClick:async()=>{await o("/api/runtime"),t(kt())},disabled:!!s,className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:s==="/api/runtime"?"Clearing…":"Clear DB Graphs"})}),a.jsx(Be,{title:"Clear Graphs (Frontend Only)",desc:"Reset the topology view locally without touching the server database.",action:a.jsx("button",{onClick:()=>t(kt()),className:"btn glass text-sm",children:"Clear View"})})]})]})}function Be({title:e,desc:t,action:s}){return a.jsxs("div",{className:"flex items-center justify-between gap-6 p-5 bg-[var(--error)]/[0.03]",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:e}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:t})]}),a.jsx("div",{className:"flex-shrink-0",children:s})]})}function Pi(){return a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx("div",{className:"w-6 h-6 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"})})}function Li(){const[e,t]=h.useState(()=>localStorage.getItem("cascade_token")),[s,n]=h.useState(e===null);h.useEffect(()=>{e===null&&(async()=>{try{(await fetch("/api/runtime?scope=workspace",{headers:{Authorization:"Bearer "}})).ok&&(t(""),localStorage.setItem("cascade_token",""))}catch{}finally{n(!1)}})()},[e]);const r=h.useCallback(o=>{t(o),localStorage.setItem("cascade_token",o)},[]),i=h.useCallback(()=>{t(null),localStorage.removeItem("cascade_token")},[]);return s?a.jsx("div",{className:"flex items-center justify-center w-full h-full bg-[var(--bg-base)]",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"}),a.jsx("p",{className:"section-label",children:"Connecting…"})]})}):e===null?a.jsx(Fr,{onLogin:r}):a.jsx(Fi,{token:e,onLogout:i,onNeedAuth:()=>{t(null),localStorage.removeItem("cascade_token")}})}function Fi({token:e,onLogout:t,onNeedAuth:s}){const n=Ae(),[r,i]=h.useState("topology"),[o,l]=h.useState(null),[c,d]=h.useState({}),[u,m]=h.useState(null),[p,f]=h.useState(0),[g,y]=h.useState(0),v=U(_r),x=U(nt),b=U(Nr),_=h.useRef(u);_.current=u;const w=h.useCallback(async(N="workspace")=>{try{const z=await fetch(`/api/runtime?scope=${N}`,{headers:{Authorization:`Bearer ${e}`},cache:"no-store"});if(z.status===401){s();return}if(z.ok){const Me=await z.json();n(ds(Me))}}catch{}},[e,n,s]),{socket:j}=Lr({url:"/",token:e,activeSessionId:x==null?void 0:x.sessionId,onRuntimeRefresh:N=>w(N??"workspace"),onStreamToken:N=>{d(z=>{const Me=z[N.tierId]||"";return{...z,[N.tierId]:(Me+N.text).slice(-8e3)}})},onCostUpdate:N=>{typeof N.totalCostUsd=="number"&&f(N.totalCostUsd),typeof N.totalTokens=="number"&&y(N.totalTokens)},onEscalation:N=>{_.current||m(N)}});h.useEffect(()=>{w()},[w]);const C=h.useMemo(()=>v.map(N=>({id:N.tierId,role:N.role,label:N.label,status:N.status,action:N.currentAction,progressPct:N.progressPct})),[v]),k=h.useMemo(()=>v.filter(N=>N.parentId).map(N=>({from:N.parentId,to:N.tierId})),[v]),I=h.useMemo(()=>v.find(N=>N.tierId===o)??null,[v,o]),S=h.useCallback((N,z)=>{!u||!j||(j.emit("permission:decision",{requestId:u.id,approved:N,always:z,decidedBy:"USER"}),m(null))},[u,j]),T=o!==null;return a.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-[var(--bg-base)]",children:[a.jsx(ti,{activeTab:r,onTabChange:i,onLogout:t}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden",children:[a.jsx(ri,{isConnected:b,totalCostUsd:p,totalTokens:g}),a.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[a.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden relative dot-grid",children:[r==="topology"&&a.jsx(li,{nodes:C,edges:k,selectedNodeId:o??void 0,onSelectNode:l}),r==="sessions"&&a.jsx(mi,{}),r==="logs"&&a.jsx(Ii,{}),r==="settings"&&a.jsx(Mi,{token:e})]}),r==="topology"&&T&&a.jsx(di,{node:I,streamLog:o&&c[o]||"",onClose:()=>l(null)})]})]}),u&&a.jsx(ui,{request:u,onDecide:S})]})}Ve.createRoot(document.getElementById("root")).render(a.jsx(ks.StrictMode,{children:a.jsx(en,{store:kr,children:a.jsx(Li,{})})}));
|