@dudousxd/nestjs-agent-dashboard 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- var ut=t=>{throw TypeError(t)};var He=(t,e,s)=>e.has(t)||ut("Cannot "+s);var i=(t,e,s)=>(He(t,e,"read from private field"),s?s.call(t):e.get(t)),d=(t,e,s)=>e.has(t)?ut("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),u=(t,e,s,r)=>(He(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),m=(t,e,s)=>(He(t,e,"access private method"),s);var ke=(t,e,s,r)=>({set _(n){u(t,e,n,s)},get _(){return i(t,e,r)}});import{r as F,j as p,p as Ht,L as Gt,D as $t,C as Bt,U as zt,W as Wt,A as Yt,a as Vt,R as Jt,b as Xt,M as Zt,S as es,c as ts}from"./index-iAxp-O4a.js";var Ie=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},le=typeof window>"u"||"Deno"in globalThis;function _(){}function ss(t,e){return typeof t=="function"?t(e):t}function $e(t){return typeof t=="number"&&t>=0&&t!==1/0}function Qt(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ye(t,e){return typeof t=="function"?t(e):t}function G(t,e){return typeof t=="function"?t(e):t}function ht(t,e){const{type:s="all",exact:r,fetchStatus:n,predicate:a,queryKey:o,stale:h}=t;if(o){if(r){if(e.queryHash!==it(o,e.options))return!1}else if(!je(e.queryKey,o))return!1}if(s!=="all"){const c=e.isActive();if(s==="active"&&!c||s==="inactive"&&c)return!1}return!(typeof h=="boolean"&&e.isStale()!==h||n&&n!==e.state.fetchStatus||a&&!a(e))}function ct(t,e){const{exact:s,status:r,predicate:n,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(s){if(De(e.options.mutationKey)!==De(a))return!1}else if(!je(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||n&&!n(e))}function it(t,e){return((e==null?void 0:e.queryKeyHashFn)||De)(t)}function De(t){return JSON.stringify(t,(e,s)=>ze(s)?Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{}):s)}function je(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?!Object.keys(e).some(s=>!je(t[s],e[s])):!1}function At(t,e){if(t===e)return t;const s=lt(t)&&lt(e);if(s||ze(t)&&ze(e)){const r=s?t:Object.keys(t),n=r.length,a=s?e:Object.keys(e),o=a.length,h=s?[]:{};let c=0;for(let g=0;g<o;g++){const f=s?g:a[g];(!s&&r.includes(f)||s)&&t[f]===void 0&&e[f]===void 0?(h[f]=void 0,c++):(h[f]=At(t[f],e[f]),h[f]===t[f]&&t[f]!==void 0&&c++)}return n===o&&c===n?t:h}return e}function Be(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function lt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function ze(t){if(!dt(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!dt(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function dt(t){return Object.prototype.toString.call(t)==="[object Object]"}function rs(t){return new Promise(e=>{setTimeout(e,t)})}function We(t,e,s){return typeof s.structuralSharing=="function"?s.structuralSharing(t,e):s.structuralSharing!==!1?At(t,e):e}function is(t,e,s=0){const r=[...t,e];return s&&r.length>s?r.slice(1):r}function ns(t,e,s=0){const r=[e,...t];return s&&r.length>s?r.slice(0,-1):r}var nt=Symbol();function Tt(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===nt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var ie,J,pe,St,as=(St=class extends Ie{constructor(){super();d(this,ie);d(this,J);d(this,pe);u(this,pe,e=>{if(!le&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){i(this,J)||this.setEventListener(i(this,pe))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,J))==null||e.call(this),u(this,J,void 0))}setEventListener(e){var s;u(this,pe,e),(s=i(this,J))==null||s.call(this),u(this,J,e(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(e){i(this,ie)!==e&&(u(this,ie,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){var e;return typeof i(this,ie)=="boolean"?i(this,ie):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},ie=new WeakMap,J=new WeakMap,pe=new WeakMap,St),at=new as,me,X,ve,Ct,os=(Ct=class extends Ie{constructor(){super();d(this,me,!0);d(this,X);d(this,ve);u(this,ve,e=>{if(!le&&window.addEventListener){const s=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,X)||this.setEventListener(i(this,ve))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,X))==null||e.call(this),u(this,X,void 0))}setEventListener(e){var s;u(this,ve,e),(s=i(this,X))==null||s.call(this),u(this,X,e(this.setOnline.bind(this)))}setOnline(e){i(this,me)!==e&&(u(this,me,e),this.listeners.forEach(r=>{r(e)}))}isOnline(){return i(this,me)}},me=new WeakMap,X=new WeakMap,ve=new WeakMap,Ct),_e=new os;function Ye(){let t,e;const s=new Promise((n,a)=>{t=n,e=a});s.status="pending",s.catch(()=>{});function r(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{r({status:"fulfilled",value:n}),t(n)},s.reject=n=>{r({status:"rejected",reason:n}),e(n)},s}function us(t){return Math.min(1e3*2**t,3e4)}function Mt(t){return(t??"online")==="online"?_e.isOnline():!0}var It=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Ge(t){return t instanceof It}function qt(t){let e=!1,s=0,r=!1,n;const a=Ye(),o=y=>{var b;r||(w(new It(y)),(b=t.abort)==null||b.call(t))},h=()=>{e=!0},c=()=>{e=!1},g=()=>at.isFocused()&&(t.networkMode==="always"||_e.isOnline())&&t.canRun(),f=()=>Mt(t.networkMode)&&t.canRun(),l=y=>{var b;r||(r=!0,(b=t.onSuccess)==null||b.call(t,y),n==null||n(),a.resolve(y))},w=y=>{var b;r||(r=!0,(b=t.onError)==null||b.call(t,y),n==null||n(),a.reject(y))},S=()=>new Promise(y=>{var b;n=D=>{(r||g())&&y(D)},(b=t.onPause)==null||b.call(t)}).then(()=>{var y;n=void 0,r||(y=t.onContinue)==null||y.call(t)}),P=()=>{if(r)return;let y;const b=s===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(D){y=Promise.reject(D)}Promise.resolve(y).then(l).catch(D=>{var K;if(r)return;const T=t.retry??(le?0:3),R=t.retryDelay??us,Q=typeof R=="function"?R(s,D):R,k=T===!0||typeof T=="number"&&s<T||typeof T=="function"&&T(s,D);if(e||!k){w(D);return}s++,(K=t.onFail)==null||K.call(t,s,D),rs(Q).then(()=>g()?void 0:S()).then(()=>{e?w(D):P()})})};return{promise:a,cancel:o,continue:()=>(n==null||n(),a),cancelRetry:h,continueRetry:c,canStart:f,start:()=>(f()?P():S().then(P),a)}}function hs(){let t=[],e=0,s=h=>{h()},r=h=>{h()},n=h=>setTimeout(h,0);const a=h=>{e?t.push(h):n(()=>{s(h)})},o=()=>{const h=t;t=[],h.length&&n(()=>{r(()=>{h.forEach(c=>{s(c)})})})};return{batch:h=>{let c;e++;try{c=h()}finally{e--,e||o()}return c},batchCalls:h=>(...c)=>{a(()=>{h(...c)})},schedule:a,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{r=h},setScheduler:h=>{n=h}}}var j=hs(),ne,Rt,Ut=(Rt=class{constructor(){d(this,ne)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$e(this.gcTime)&&u(this,ne,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(le?1/0:5*60*1e3))}clearGcTimeout(){i(this,ne)&&(clearTimeout(i(this,ne)),u(this,ne,void 0))}},ne=new WeakMap,Rt),be,ge,N,A,Qe,ae,H,Y,Ot,cs=(Ot=class extends Ut{constructor(e){super();d(this,H);d(this,be);d(this,ge);d(this,N);d(this,A);d(this,Qe);d(this,ae);u(this,ae,!1),u(this,Qe,e.defaultOptions),this.setOptions(e.options),this.observers=[],u(this,N,e.cache),this.queryKey=e.queryKey,this.queryHash=e.queryHash,u(this,be,ls(this.options)),this.state=e.state??i(this,be),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=i(this,A))==null?void 0:e.promise}setOptions(e){this.options={...i(this,Qe),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,N).remove(this)}setData(e,s){const r=We(this.state.data,e,this.options);return m(this,H,Y).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(e,s){m(this,H,Y).call(this,{type:"setState",state:e,setStateOptions:s})}cancel(e){var r,n;const s=(r=i(this,A))==null?void 0:r.promise;return(n=i(this,A))==null||n.cancel(e),s?s.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(i(this,be))}isActive(){return this.observers.some(e=>G(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nt||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!Qt(this.state.dataUpdatedAt,e)}onFocus(){var s;const e=this.observers.find(r=>r.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}onOnline(){var s;const e=this.observers.find(r=>r.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,N).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(s=>s!==e),this.observers.length||(i(this,A)&&(i(this,ae)?i(this,A).cancel({revert:!0}):i(this,A).cancelRetry()),this.scheduleGc()),i(this,N).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||m(this,H,Y).call(this,{type:"invalidate"})}fetch(e,s){var c,g,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(i(this,A))return i(this,A).continueRetry(),i(this,A).promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(w=>w.options.queryFn);l&&this.setOptions(l.options)}const r=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(u(this,ae,!0),r.signal)})},a=()=>{const l=Tt(this.options,s),w={queryKey:this.queryKey,meta:this.meta};return n(w),u(this,ae,!1),this.options.persister?this.options.persister(l,w,this):l(w)},o={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:a};n(o),(c=this.options.behavior)==null||c.onFetch(o,this),u(this,ge,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=o.fetchOptions)==null?void 0:g.meta))&&m(this,H,Y).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta});const h=l=>{var w,S,P,y;Ge(l)&&l.silent||m(this,H,Y).call(this,{type:"error",error:l}),Ge(l)||((S=(w=i(this,N).config).onError)==null||S.call(w,l,this),(y=(P=i(this,N).config).onSettled)==null||y.call(P,this.state.data,l,this)),this.scheduleGc()};return u(this,A,qt({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,abort:r.abort.bind(r),onSuccess:l=>{var w,S,P,y;if(l===void 0){h(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(l)}catch(b){h(b);return}(S=(w=i(this,N).config).onSuccess)==null||S.call(w,l,this),(y=(P=i(this,N).config).onSettled)==null||y.call(P,l,this.state.error,this),this.scheduleGc()},onError:h,onFail:(l,w)=>{m(this,H,Y).call(this,{type:"failed",failureCount:l,error:w})},onPause:()=>{m(this,H,Y).call(this,{type:"pause"})},onContinue:()=>{m(this,H,Y).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),i(this,A).start()}},be=new WeakMap,ge=new WeakMap,N=new WeakMap,A=new WeakMap,Qe=new WeakMap,ae=new WeakMap,H=new WeakSet,Y=function(e){const s=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...kt(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Ge(n)&&n.revert&&i(this,ge)?{...i(this,ge),fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),j.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),i(this,N).notify({query:this,type:"updated",action:e})})},Ot);function kt(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mt(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ls(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,s=e!==void 0,r=s?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var $,Pt,ds=(Pt=class extends Ie{constructor(e={}){super();d(this,$);this.config=e,u(this,$,new Map)}build(e,s,r){const n=s.queryKey,a=s.queryHash??it(n,s);let o=this.get(a);return o||(o=new cs({cache:this,queryKey:n,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){i(this,$).has(e.queryHash)||(i(this,$).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const s=i(this,$).get(e.queryHash);s&&(e.destroy(),s===e&&i(this,$).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,$).get(e)}getAll(){return[...i(this,$).values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>ht(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>ht(e,r)):s}notify(e){j.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){j.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){j.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$=new WeakMap,Pt),B,I,oe,z,V,Et,fs=(Et=class extends Ut{constructor(e){super();d(this,z);d(this,B);d(this,I);d(this,oe);this.mutationId=e.mutationId,u(this,I,e.mutationCache),u(this,B,[]),this.state=e.state||ys(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,B).includes(e)||(i(this,B).push(e),this.clearGcTimeout(),i(this,I).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){u(this,B,i(this,B).filter(s=>s!==e)),this.scheduleGc(),i(this,I).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,B).length||(this.state.status==="pending"?this.scheduleGc():i(this,I).remove(this))}continue(){var e;return((e=i(this,oe))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var n,a,o,h,c,g,f,l,w,S,P,y,b,D,T,R,Q,k,K,M;u(this,oe,qt({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(E,C)=>{m(this,z,V).call(this,{type:"failed",failureCount:E,error:C})},onPause:()=>{m(this,z,V).call(this,{type:"pause"})},onContinue:()=>{m(this,z,V).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,I).canRun(this)}));const s=this.state.status==="pending",r=!i(this,oe).canStart();try{if(!s){m(this,z,V).call(this,{type:"pending",variables:e,isPaused:r}),await((a=(n=i(this,I).config).onMutate)==null?void 0:a.call(n,e,this));const C=await((h=(o=this.options).onMutate)==null?void 0:h.call(o,e));C!==this.state.context&&m(this,z,V).call(this,{type:"pending",context:C,variables:e,isPaused:r})}const E=await i(this,oe).start();return await((g=(c=i(this,I).config).onSuccess)==null?void 0:g.call(c,E,e,this.state.context,this)),await((l=(f=this.options).onSuccess)==null?void 0:l.call(f,E,e,this.state.context)),await((S=(w=i(this,I).config).onSettled)==null?void 0:S.call(w,E,null,this.state.variables,this.state.context,this)),await((y=(P=this.options).onSettled)==null?void 0:y.call(P,E,null,e,this.state.context)),m(this,z,V).call(this,{type:"success",data:E}),E}catch(E){try{throw await((D=(b=i(this,I).config).onError)==null?void 0:D.call(b,E,e,this.state.context,this)),await((R=(T=this.options).onError)==null?void 0:R.call(T,E,e,this.state.context)),await((k=(Q=i(this,I).config).onSettled)==null?void 0:k.call(Q,void 0,E,this.state.variables,this.state.context,this)),await((M=(K=this.options).onSettled)==null?void 0:M.call(K,void 0,E,e,this.state.context)),E}finally{m(this,z,V).call(this,{type:"error",error:E})}}finally{i(this,I).runNext(this)}}},B=new WeakMap,I=new WeakMap,oe=new WeakMap,z=new WeakSet,V=function(e){const s=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=s(this.state),j.batch(()=>{i(this,B).forEach(r=>{r.onMutationUpdate(e)}),i(this,I).notify({mutation:this,type:"updated",action:e})})},Et);function ys(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L,Ae,Ft,ps=(Ft=class extends Ie{constructor(e={}){super();d(this,L);d(this,Ae);this.config=e,u(this,L,new Map),u(this,Ae,Date.now())}build(e,s,r){const n=new fs({mutationCache:this,mutationId:++ke(this,Ae)._,options:e.defaultMutationOptions(s),state:r});return this.add(n),n}add(e){const s=Le(e),r=i(this,L).get(s)??[];r.push(e),i(this,L).set(s,r),this.notify({type:"added",mutation:e})}remove(e){var r;const s=Le(e);if(i(this,L).has(s)){const n=(r=i(this,L).get(s))==null?void 0:r.filter(a=>a!==e);n&&(n.length===0?i(this,L).delete(s):i(this,L).set(s,n))}this.notify({type:"removed",mutation:e})}canRun(e){var r;const s=(r=i(this,L).get(Le(e)))==null?void 0:r.find(n=>n.state.status==="pending");return!s||s===e}runNext(e){var r;const s=(r=i(this,L).get(Le(e)))==null?void 0:r.find(n=>n!==e&&n.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}clear(){j.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}getAll(){return[...i(this,L).values()].flat()}find(e){const s={exact:!0,...e};return this.getAll().find(r=>ct(s,r))}findAll(e={}){return this.getAll().filter(s=>ct(e,s))}notify(e){j.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return j.batch(()=>Promise.all(e.map(s=>s.continue().catch(_))))}},L=new WeakMap,Ae=new WeakMap,Ft);function Le(t){var e;return((e=t.options.scope)==null?void 0:e.id)??String(t.mutationId)}function ft(t){return{onFetch:(e,s)=>{var f,l,w,S,P;const r=e.options,n=(w=(l=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:l.fetchMore)==null?void 0:w.direction,a=((S=e.state.data)==null?void 0:S.pages)||[],o=((P=e.state.data)==null?void 0:P.pageParams)||[];let h={pages:[],pageParams:[]},c=0;const g=async()=>{let y=!1;const b=R=>{Object.defineProperty(R,"signal",{enumerable:!0,get:()=>(e.signal.aborted?y=!0:e.signal.addEventListener("abort",()=>{y=!0}),e.signal)})},D=Tt(e.options,e.fetchOptions),T=async(R,Q,k)=>{if(y)return Promise.reject();if(Q==null&&R.pages.length)return Promise.resolve(R);const K={queryKey:e.queryKey,pageParam:Q,direction:k?"backward":"forward",meta:e.options.meta};b(K);const M=await D(K),{maxPages:E}=e.options,C=k?ns:is;return{pages:C(R.pages,M,E),pageParams:C(R.pageParams,Q,E)}};if(n&&a.length){const R=n==="backward",Q=R?ms:yt,k={pages:a,pageParams:o},K=Q(r,k);h=await T(k,K,R)}else{const R=t??a.length;do{const Q=c===0?o[0]??r.initialPageParam:yt(r,h);if(c>0&&Q==null)break;h=await T(h,Q),c++}while(c<R)}return h};e.options.persister?e.fetchFn=()=>{var y,b;return(b=(y=e.options).persister)==null?void 0:b.call(y,g,{queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s)}:e.fetchFn=g}}}function yt(t,{pages:e,pageParams:s}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,s[r],s):void 0}function ms(t,{pages:e,pageParams:s}){var r;return e.length>0?(r=t.getPreviousPageParam)==null?void 0:r.call(t,e[0],e,s[0],s):void 0}var O,Z,ee,we,xe,te,Se,Ce,Dt,vs=(Dt=class{constructor(t={}){d(this,O);d(this,Z);d(this,ee);d(this,we);d(this,xe);d(this,te);d(this,Se);d(this,Ce);u(this,O,t.queryCache||new ds),u(this,Z,t.mutationCache||new ps),u(this,ee,t.defaultOptions||{}),u(this,we,new Map),u(this,xe,new Map),u(this,te,0)}mount(){ke(this,te)._++,i(this,te)===1&&(u(this,Se,at.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,O).onFocus())})),u(this,Ce,_e.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,O).onOnline())})))}unmount(){var t,e;ke(this,te)._--,i(this,te)===0&&((t=i(this,Se))==null||t.call(this),u(this,Se,void 0),(e=i(this,Ce))==null||e.call(this),u(this,Ce,void 0))}isFetching(t){return i(this,O).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Z).findAll({...t,status:"pending"}).length}getQueryData(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=i(this,O).get(e.queryHash))==null?void 0:s.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=i(this,O).build(this,e),r=s.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(ye(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return i(this,O).findAll(t).map(({queryKey:e,state:s})=>{const r=s.data;return[e,r]})}setQueryData(t,e,s){const r=this.defaultQueryOptions({queryKey:t}),n=i(this,O).get(r.queryHash),a=n==null?void 0:n.state.data,o=ss(e,a);if(o!==void 0)return i(this,O).build(this,r).setData(o,{...s,manual:!0})}setQueriesData(t,e,s){return j.batch(()=>i(this,O).findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,s)]))}getQueryState(t){var s;const e=this.defaultQueryOptions({queryKey:t});return(s=i(this,O).get(e.queryHash))==null?void 0:s.state}removeQueries(t){const e=i(this,O);j.batch(()=>{e.findAll(t).forEach(s=>{e.remove(s)})})}resetQueries(t,e){const s=i(this,O),r={type:"active",...t};return j.batch(()=>(s.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries(r,e)))}cancelQueries(t,e={}){const s={revert:!0,...e},r=j.batch(()=>i(this,O).findAll(t).map(n=>n.cancel(s)));return Promise.all(r).then(_).catch(_)}invalidateQueries(t,e={}){return j.batch(()=>{if(i(this,O).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none")return Promise.resolve();const s={...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"};return this.refetchQueries(s,e)})}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},r=j.batch(()=>i(this,O).findAll(t).filter(n=>!n.isDisabled()).map(n=>{let a=n.fetch(void 0,s);return s.throwOnError||(a=a.catch(_)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(_)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const s=i(this,O).build(this,e);return s.isStaleByTime(ye(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(_).catch(_)}fetchInfiniteQuery(t){return t.behavior=ft(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(_).catch(_)}ensureInfiniteQueryData(t){return t.behavior=ft(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return _e.isOnline()?i(this,Z).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,O)}getMutationCache(){return i(this,Z)}getDefaultOptions(){return i(this,ee)}setDefaultOptions(t){u(this,ee,t)}setQueryDefaults(t,e){i(this,we).set(De(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...i(this,we).values()],s={};return e.forEach(r=>{je(t,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(t,e){i(this,xe).set(De(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...i(this,xe).values()];let s={};return e.forEach(r=>{je(t,r.mutationKey)&&(s={...s,...r.defaultOptions})}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...i(this,ee).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=it(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===nt&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...i(this,ee).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,O).clear(),i(this,Z).clear()}},O=new WeakMap,Z=new WeakMap,ee=new WeakMap,we=new WeakMap,xe=new WeakMap,te=new WeakMap,Se=new WeakMap,Ce=new WeakMap,Dt),U,v,Te,q,ue,Re,se,W,Me,Oe,Pe,he,ce,re,Ee,x,Fe,Ve,Je,Xe,Ze,et,tt,st,Lt,jt,bs=(jt=class extends Ie{constructor(e,s){super();d(this,x);d(this,U);d(this,v);d(this,Te);d(this,q);d(this,ue);d(this,Re);d(this,se);d(this,W);d(this,Me);d(this,Oe);d(this,Pe);d(this,he);d(this,ce);d(this,re);d(this,Ee,new Set);this.options=s,u(this,U,e),u(this,W,null),u(this,se,Ye()),this.options.experimental_prefetchInRender||i(this,se).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,v).addObserver(this),pt(i(this,v),this.options)?m(this,x,Fe).call(this):this.updateResult(),m(this,x,Ze).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rt(i(this,v),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rt(i(this,v),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,m(this,x,et).call(this),m(this,x,tt).call(this),i(this,v).removeObserver(this)}setOptions(e,s){const r=this.options,n=i(this,v);if(this.options=i(this,U).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof G(this.options.enabled,i(this,v))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");m(this,x,st).call(this),i(this,v).setOptions(this.options),r._defaulted&&!Be(this.options,r)&&i(this,U).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,v),observer:this});const a=this.hasListeners();a&&mt(i(this,v),n,this.options,r)&&m(this,x,Fe).call(this),this.updateResult(s),a&&(i(this,v)!==n||G(this.options.enabled,i(this,v))!==G(r.enabled,i(this,v))||ye(this.options.staleTime,i(this,v))!==ye(r.staleTime,i(this,v)))&&m(this,x,Ve).call(this);const o=m(this,x,Je).call(this);a&&(i(this,v)!==n||G(this.options.enabled,i(this,v))!==G(r.enabled,i(this,v))||o!==i(this,re))&&m(this,x,Xe).call(this,o)}getOptimisticResult(e){const s=i(this,U).getQueryCache().build(i(this,U),e),r=this.createResult(s,e);return ws(this,r)&&(u(this,q,r),u(this,Re,this.options),u(this,ue,i(this,v).state)),r}getCurrentResult(){return i(this,q)}trackResult(e,s){const r={};return Object.keys(e).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),s==null||s(n),e[n])})}),r}trackProp(e){i(this,Ee).add(e)}getCurrentQuery(){return i(this,v)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=i(this,U).defaultQueryOptions(e),r=i(this,U).getQueryCache().build(i(this,U),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(e){return m(this,x,Fe).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,q)))}createResult(e,s){var E;const r=i(this,v),n=this.options,a=i(this,q),o=i(this,ue),h=i(this,Re),g=e!==r?e.state:i(this,Te),{state:f}=e;let l={...f},w=!1,S;if(s._optimisticResults){const C=this.hasListeners(),de=!C&&pt(e,s),fe=C&&mt(e,r,s,n);(de||fe)&&(l={...l,...kt(f.data,e.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:P,errorUpdatedAt:y,status:b}=l;if(s.select&&l.data!==void 0)if(a&&l.data===(o==null?void 0:o.data)&&s.select===i(this,Me))S=i(this,Oe);else try{u(this,Me,s.select),S=s.select(l.data),S=We(a==null?void 0:a.data,S,s),u(this,Oe,S),u(this,W,null)}catch(C){u(this,W,C)}else S=l.data;if(s.placeholderData!==void 0&&S===void 0&&b==="pending"){let C;if(a!=null&&a.isPlaceholderData&&s.placeholderData===(h==null?void 0:h.placeholderData))C=a.data;else if(C=typeof s.placeholderData=="function"?s.placeholderData((E=i(this,Pe))==null?void 0:E.state.data,i(this,Pe)):s.placeholderData,s.select&&C!==void 0)try{C=s.select(C),u(this,W,null)}catch(de){u(this,W,de)}C!==void 0&&(b="success",S=We(a==null?void 0:a.data,C,s),w=!0)}i(this,W)&&(P=i(this,W),S=i(this,Oe),y=Date.now(),b="error");const D=l.fetchStatus==="fetching",T=b==="pending",R=b==="error",Q=T&&D,k=S!==void 0,M={status:b,fetchStatus:l.fetchStatus,isPending:T,isSuccess:b==="success",isError:R,isInitialLoading:Q,isLoading:Q,data:S,dataUpdatedAt:l.dataUpdatedAt,error:P,errorUpdatedAt:y,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>g.dataUpdateCount||l.errorUpdateCount>g.errorUpdateCount,isFetching:D,isRefetching:D&&!T,isLoadingError:R&&!k,isPaused:l.fetchStatus==="paused",isPlaceholderData:w,isRefetchError:R&&k,isStale:ot(e,s),refetch:this.refetch,promise:i(this,se)};if(this.options.experimental_prefetchInRender){const C=Ue=>{M.status==="error"?Ue.reject(M.error):M.data!==void 0&&Ue.resolve(M.data)},de=()=>{const Ue=u(this,se,M.promise=Ye());C(Ue)},fe=i(this,se);switch(fe.status){case"pending":e.queryHash===r.queryHash&&C(fe);break;case"fulfilled":(M.status==="error"||M.data!==fe.value)&&de();break;case"rejected":(M.status!=="error"||M.error!==fe.reason)&&de();break}}return M}updateResult(e){const s=i(this,q),r=this.createResult(i(this,v),this.options);if(u(this,ue,i(this,v).state),u(this,Re,this.options),i(this,ue).data!==void 0&&u(this,Pe,i(this,v)),Be(r,s))return;u(this,q,r);const n={},a=()=>{if(!s)return!0;const{notifyOnChangeProps:o}=this.options,h=typeof o=="function"?o():o;if(h==="all"||!h&&!i(this,Ee).size)return!0;const c=new Set(h??i(this,Ee));return this.options.throwOnError&&c.add("error"),Object.keys(i(this,q)).some(g=>{const f=g;return i(this,q)[f]!==s[f]&&c.has(f)})};(e==null?void 0:e.listeners)!==!1&&a()&&(n.listeners=!0),m(this,x,Lt).call(this,{...n,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&m(this,x,Ze).call(this)}},U=new WeakMap,v=new WeakMap,Te=new WeakMap,q=new WeakMap,ue=new WeakMap,Re=new WeakMap,se=new WeakMap,W=new WeakMap,Me=new WeakMap,Oe=new WeakMap,Pe=new WeakMap,he=new WeakMap,ce=new WeakMap,re=new WeakMap,Ee=new WeakMap,x=new WeakSet,Fe=function(e){m(this,x,st).call(this);let s=i(this,v).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(_)),s},Ve=function(){m(this,x,et).call(this);const e=ye(this.options.staleTime,i(this,v));if(le||i(this,q).isStale||!$e(e))return;const r=Qt(i(this,q).dataUpdatedAt,e)+1;u(this,he,setTimeout(()=>{i(this,q).isStale||this.updateResult()},r))},Je=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,v)):this.options.refetchInterval)??!1},Xe=function(e){m(this,x,tt).call(this),u(this,re,e),!(le||G(this.options.enabled,i(this,v))===!1||!$e(i(this,re))||i(this,re)===0)&&u(this,ce,setInterval(()=>{(this.options.refetchIntervalInBackground||at.isFocused())&&m(this,x,Fe).call(this)},i(this,re)))},Ze=function(){m(this,x,Ve).call(this),m(this,x,Xe).call(this,m(this,x,Je).call(this))},et=function(){i(this,he)&&(clearTimeout(i(this,he)),u(this,he,void 0))},tt=function(){i(this,ce)&&(clearInterval(i(this,ce)),u(this,ce,void 0))},st=function(){const e=i(this,U).getQueryCache().build(i(this,U),this.options);if(e===i(this,v))return;const s=i(this,v);u(this,v,e),u(this,Te,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},Lt=function(e){j.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(i(this,q))}),i(this,U).getQueryCache().notify({query:i(this,v),type:"observerResultsUpdated"})})},jt);function gs(t,e){return G(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function pt(t,e){return gs(t,e)||t.state.data!==void 0&&rt(t,e,e.refetchOnMount)}function rt(t,e,s){if(G(e.enabled,t)!==!1){const r=typeof s=="function"?s(t):s;return r==="always"||r!==!1&&ot(t,e)}return!1}function mt(t,e,s,r){return(t!==e||G(r.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&ot(t,s)}function ot(t,e){return G(e.enabled,t)!==!1&&t.isStaleByTime(ye(e.staleTime,t))}function ws(t,e){return!Be(t.getCurrentResult(),e)}var Nt=F.createContext(void 0),xs=t=>{const e=F.useContext(Nt);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ss=({client:t,children:e})=>(F.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),p.jsx(Nt.Provider,{value:t,children:e})),_t=F.createContext(!1),Cs=()=>F.useContext(_t);_t.Provider;function Rs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Os=F.createContext(Rs()),Ps=()=>F.useContext(Os);function Es(t,e){return typeof t=="function"?t(...e):!!t}function vt(){}var Fs=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Ds=t=>{F.useEffect(()=>{t.clearReset()},[t])},js=({result:t,errorResetBoundary:e,throwOnError:s,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&Es(s,[t.error,r]),Qs=t=>{t.suspense&&(t.staleTime===void 0&&(t.staleTime=1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},As=(t,e)=>t.isLoading&&t.isFetching&&!e,Ts=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,bt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function Ms(t,e,s){var f,l,w,S,P;const r=xs(),n=Cs(),a=Ps(),o=r.defaultQueryOptions(t);(l=(f=r.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||l.call(f,o),o._optimisticResults=n?"isRestoring":"optimistic",Qs(o),Fs(o,a),Ds(a);const h=!r.getQueryCache().get(o.queryHash),[c]=F.useState(()=>new e(r,o)),g=c.getOptimisticResult(o);if(F.useSyncExternalStore(F.useCallback(y=>{const b=n?vt:c.subscribe(j.batchCalls(y));return c.updateResult(),b},[c,n]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),F.useEffect(()=>{c.setOptions(o,{listeners:!1})},[o,c]),Ts(o,g))throw bt(o,c,a);if(js({result:g,errorResetBoundary:a,throwOnError:o.throwOnError,query:r.getQueryCache().get(o.queryHash)}))throw g.error;if((S=(w=r.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||S.call(w,o,g),o.experimental_prefetchInRender&&!le&&As(g,n)){const y=h?bt(o,c,a):(P=r.getQueryCache().get(o.queryHash))==null?void 0:P.promise;y==null||y.catch(vt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?g:c.trackResult(g)}function Ke(t,e){return Ms(t,bs)}const Is=864e5,qs=/^\d{4}-\d{2}-\d{2}$/;function gt(t,e=Date.now()){return new Date(e-t*Is).toISOString().slice(0,10)}function Us(t=30,e=Date.now()){return{fromDay:gt(t-1,e),toDay:gt(0,e)}}function ks(t){return qs.test(t)}function Kt(){return typeof window<"u"&&window.__AGENT_API__?window.__AGENT_API__:`${typeof window<"u"&&window.__AGENT_BASE__||"/ai-gateway"}/api`}async function Ne(t,e){const s=await fetch(Kt()+t,e);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return await s.json()}const qe={spend(t){const e=new URLSearchParams({from:t.fromDay,to:t.toDay});return Ne(`/spend?${e.toString()}`)},topThreads(t,e=10){const s=new URLSearchParams({from:t.fromDay,to:t.toDay,limit:`${e}`});return Ne(`/top-threads?${s.toString()}`)},toolCalls(t=50){return Ne(`/tool-calls?limit=${t}`)},threads(t=50){return Ne(`/threads?limit=${t}`)},streamEvents(t){const e=new EventSource(`${Kt()}/stream`);return e.onmessage=s=>{try{t(JSON.parse(s.data))}catch{}},()=>e.close()}};function Ls(t){return Ke({queryKey:["spend",t.fromDay,t.toDay],queryFn:()=>qe.spend(t)})}function Ns(t,e=10){return Ke({queryKey:["top-threads",t.fromDay,t.toDay,e],queryFn:()=>qe.topThreads(t,e)})}function _s(t=50){return Ke({queryKey:["tool-calls",t],queryFn:()=>qe.toolCalls(t)})}function Ks(t=50){return Ke({queryKey:["threads",t],queryFn:()=>qe.threads(t)})}function Hs(t=200){const[e,s]=F.useState([]),[r,n]=F.useState(!1),a=F.useRef(0);return F.useEffect(()=>{n(!0);const o=qe.streamEvents(h=>{a.current+=1,s(c=>Ht(c,h,a.current,t))});return()=>{n(!1),o()}},[t]),{events:e,connected:r}}const Gs=[{key:"spend",label:"Spend & usage",icon:p.jsx($t,{})},{key:"models",label:"Models",icon:p.jsx(Bt,{})},{key:"actors",label:"Actors & budgets",icon:p.jsx(zt,{})},{key:"runs",label:"Runs & tools",icon:p.jsx(Wt,{})},{key:"live",label:"Live",icon:p.jsx(Yt,{})}],$s={byModel:[],byActor:[],trend:[]},Bs=[],zs=[],Ws=[];function Ys(){const[t,e]=F.useState(Us()),[s,r]=F.useState("spend"),n=Ls(t),a=Ns(t),o=_s(),h=Ks(),c=Hs(),g=n.data??$s;return p.jsxs("div",{className:"relative min-h-full",children:[p.jsx("div",{className:"app-bg"}),p.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] px-5 py-5",children:[p.jsx(Js,{range:t,onRange:e,connected:c.connected,liveCount:c.events.length}),p.jsx("nav",{className:"mb-5 flex flex-wrap gap-1",children:Gs.map(f=>p.jsxs("button",{type:"button",onClick:()=>r(f.key),className:`flex items-center gap-2 rounded-lg border px-3 py-1.5 text-xs transition-colors ${s===f.key?"border-[var(--accent)]/50 bg-[var(--accent)]/10 text-[var(--text)]":"border-transparent text-[var(--muted)] hover:text-[var(--text)]"}`,children:[f.icon,f.label,f.key==="live"&&c.events.length>0&&p.jsx("span",{className:"mono tnum rounded bg-[var(--accent)]/20 px-1 text-[10px] text-[var(--accent)]",children:c.events.length})]},f.key))}),p.jsx(Vs,{section:s,overview:g,topThreads:a.data??Ws,loadingSpend:n.isLoading,errorSpend:n.isError,toolCalls:o.data??Bs,threads:h.data??zs,liveEvents:c.events,connected:c.connected})]})]})}function Vs({section:t,overview:e,topThreads:s,loadingSpend:r,errorSpend:n,toolCalls:a,threads:o,liveEvents:h,connected:c}){if(n&&(t==="spend"||t==="models"||t==="actors"))return p.jsx("div",{className:"panel p-6 text-sm text-[var(--bad)]",children:"Failed to load the read-model. Is the governance read-model bound and the API reachable?"});if(r&&(t==="spend"||t==="models"||t==="actors"))return p.jsx("div",{className:"panel animate-pulse p-6 text-sm text-[var(--muted)]",children:"Loading…"});switch(t){case"spend":return p.jsx(es,{overview:e,topThreads:s});case"models":return p.jsx(Zt,{rows:e.byModel});case"actors":return p.jsx(Xt,{rows:e.byActor});case"runs":return p.jsx(Jt,{toolCalls:a,threads:o});case"live":return p.jsx(Vt,{events:h,connected:c});default:return null}}function Js({range:t,onRange:e,connected:s,liveCount:r}){return p.jsxs("header",{className:"mb-5 flex flex-wrap items-center gap-4",children:[p.jsxs("div",{className:"flex items-center gap-2.5",children:[p.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:p.jsx(Gt,{className:"h-4 w-4 text-[var(--accent)]"})}),p.jsxs("div",{className:"leading-none",children:[p.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway"}),p.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"governance console"})]})]}),p.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[p.jsx(wt,{label:"From",value:t.fromDay,onChange:n=>e({...t,fromDay:n})}),p.jsx(wt,{label:"To",value:t.toDay,onChange:n=>e({...t,toDay:n})}),p.jsxs("span",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] px-2.5 py-1.5 text-[11px] text-[var(--muted)]",children:[p.jsx("span",{className:`dot ${s?"s-ok pulse":"s-failed"}`,"aria-hidden":!0}),"live ",r>0?`· ${r}`:""]})]})]})}function wt({label:t,value:e,onChange:s}){return p.jsxs("label",{className:"flex items-center gap-1.5 rounded-lg border border-[var(--line)] bg-[var(--panel)] px-2.5 py-1 text-[11px] text-[var(--muted)]",children:[p.jsx("span",{className:"uppercase tracking-wider",children:t}),p.jsx("input",{type:"date",value:e,onChange:r=>{const n=r.target.value;ks(n)&&s(n)},className:"mono bg-transparent text-[var(--text)] outline-none"})]})}const Xs=new vs({defaultOptions:{queries:{refetchInterval:5e3,refetchOnWindowFocus:!1,retry:1}}}),xt=document.getElementById("root");xt&&ts.createRoot(xt).render(p.jsx(F.StrictMode,{children:p.jsx(Ss,{client:Xs,children:p.jsx(Ys,{})})}));
@@ -1 +0,0 @@
1
- import{c as l,j as e,r as c,L as i,S as u,M as m,b as p,R as h,a as g}from"./index-iAxp-O4a.js";const x=[{modelId:"gpt-4o",requests:4200,inputTokens:84e5,outputTokens:21e5,costUsd:84.2},{modelId:"claude-3-5-sonnet",requests:2600,inputTokens:52e5,outputTokens:13e5,costUsd:41.6},{modelId:"gpt-4o-mini",requests:9800,inputTokens:12e6,outputTokens:3e6,costUsd:9.4},{modelId:"llama-3-70b",requests:1200,inputTokens:21e5,outputTokens:64e4,costUsd:0}],T=[{actorRef:"tenant:acme",requests:8200,totalTokens:184e5,costUsd:78.1},{actorRef:"user:davi@goflip.ai",requests:3100,totalTokens:69e5,costUsd:34.2},{actorRef:"tenant:globex",requests:4400,totalTokens:92e5,costUsd:21.8},{actorRef:"user:ops-bot",requests:2100,totalTokens:394e4,costUsd:1.1}],v={"tenant:acme":2e7,"user:davi@goflip.ai":5e6,"tenant:globex":12e6};function I(){const s=[];for(let t=29;t>=0;t-=1){const d=new Date(Date.now()-t*864e5).toISOString().slice(0,10),n=Math.sin(t/3)*.5+1;s.push({day:d,totalTokens:Math.round(7e5*n+t*4e3),costUsd:Number((4.2*n+t*.05).toFixed(2))})}return s}const a={byModel:x,byActor:T,trend:I()},w=v,S=[{toolCallId:"tc1",toolName:"search_records",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-12e3).toISOString()},{toolCallId:"tc2",toolName:"delete_asset",toolType:"action",status:"forbidden",threadId:"th2",createdAt:new Date(Date.now()-9e4).toISOString()},{toolCallId:"tc3",toolName:"fetch_pricing",toolType:"read",status:"ok",threadId:"th1",createdAt:new Date(Date.now()-24e4).toISOString()},{toolCallId:"tc4",toolName:"send_email",toolType:"action",status:"failed",threadId:"th3",createdAt:new Date(Date.now()-62e4).toISOString()},{toolCallId:"tc5",toolName:"summarize_thread",toolType:"read",status:"ok",threadId:"th2",createdAt:new Date(Date.now()-12e5).toISOString()}],k=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",messageCount:24,totalTokens:184e3,lastActivityAt:new Date(Date.now()-3e4).toISOString()},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",messageCount:11,totalTokens:62e3,lastActivityAt:new Date(Date.now()-4e5).toISOString()},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",messageCount:6,totalTokens:28400,lastActivityAt:new Date(Date.now()-18e5).toISOString()}],b=[{threadId:"th1",title:"Q3 procurement review",actorRef:"tenant:acme",requests:24,totalTokens:184e3,costUsd:18.4},{threadId:"th2",title:"Incident triage",actorRef:"user:ops-bot",requests:11,totalTokens:62e3,costUsd:6.2},{threadId:"th3",title:"Contract summary",actorRef:"user:davi@goflip.ai",requests:6,totalTokens:28400,costUsd:2.8}],f=[{id:"e1",event:"run.started",ts:Date.now()-2e3,payload:{runId:"r-9f2",agentName:"analyst"}},{id:"e2",event:"tool-call",ts:Date.now()-5e3,payload:{toolName:"search_records",toolType:"read",status:"ok"}},{id:"e3",event:"quota.exceeded",ts:Date.now()-9e3,payload:{actorId:"tenant:globex",usedTokens:124e5,limitTokens:12e6}},{id:"e4",event:"tool-call",ts:Date.now()-14e3,payload:{toolName:"delete_asset",toolType:"action",status:"forbidden"}},{id:"e5",event:"delegated",ts:Date.now()-2e4,payload:{fromAgent:"router",toAgent:"billing-agent"}},{id:"e6",event:"run.finished",ts:Date.now()-26e3,payload:{runId:"r-8a1",steps:7,inputTokens:4200,outputTokens:1100}}];function D(){return e.jsxs("div",{className:"relative min-h-full",children:[e.jsx("div",{className:"app-bg"}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-[1180px] space-y-6 px-5 py-6",children:[e.jsxs("header",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"grid h-8 w-8 place-items-center rounded-lg border border-[var(--accent)]/40 bg-[var(--accent)]/10",children:e.jsx(i,{className:"h-4 w-4 text-[var(--accent)]"})}),e.jsxs("div",{className:"leading-none",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"AI gateway — preview"}),e.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-[var(--muted)]",children:"mock data · no backend"})]})]}),e.jsx(o,{label:"Spend & usage",children:e.jsx(u,{overview:a,topThreads:b})}),e.jsx(o,{label:"Models",children:e.jsx(m,{rows:a.byModel})}),e.jsx(o,{label:"Actors & budgets",children:e.jsx(p,{rows:a.byActor,budgets:w})}),e.jsx(o,{label:"Runs & tools",children:e.jsx(h,{toolCalls:S,threads:k})}),e.jsx(o,{label:"Live",children:e.jsx(g,{events:f,connected:!0})})]})]})}function o({label:s,children:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"mono text-[11px] uppercase tracking-[0.2em] text-[var(--muted)]",children:s}),t]})}const r=document.getElementById("root");r&&l.createRoot(r).render(e.jsx(c.StrictMode,{children:e.jsx(D,{})}));