codesesh 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-EYZ73CYP.js → chunk-AGUAXTKC.js} +2 -2
  3. package/dist/{chunk-VVCSQU5B.js → chunk-DHQPM5FF.js} +6 -6
  4. package/dist/chunk-DHQPM5FF.js.map +1 -0
  5. package/dist/{chunk-YEQTRALH.js → chunk-KVTLNX7V.js} +3 -3
  6. package/dist/chunk-KVTLNX7V.js.map +1 -0
  7. package/dist/{chunk-WIWK7BXS.js → chunk-L4G3LE7I.js} +25 -26
  8. package/dist/chunk-L4G3LE7I.js.map +1 -0
  9. package/dist/{chunk-SII3M66U.js → chunk-RBCCNCDO.js} +8 -8
  10. package/dist/chunk-RBCCNCDO.js.map +1 -0
  11. package/dist/{chunk-DE6UJMOY.js → chunk-V3HKVTIO.js} +3 -2
  12. package/dist/chunk-V3HKVTIO.js.map +1 -0
  13. package/dist/{chunk-QHWSZFRM.js → chunk-YLXHGL4S.js} +4 -4
  14. package/dist/chunk-YLXHGL4S.js.map +1 -0
  15. package/dist/{discovery-4WAEYSTR.js → discovery-KEZQU6RL.js} +5 -5
  16. package/dist/index.js +10 -10
  17. package/dist/index.js.map +1 -1
  18. package/dist/project-identity-worker.js +4 -4
  19. package/dist/scan-refresh-worker.js +6 -6
  20. package/dist/search-index-worker.js +6 -6
  21. package/dist/session-detail-worker.js +6 -6
  22. package/dist/smart-tag-worker.js +3 -3
  23. package/dist/web/assets/CustomTimeWindowDialog-z5xtqkBF.js +1 -0
  24. package/dist/web/assets/DetailLanding-CpV0jLmT.js +1 -0
  25. package/dist/web/assets/DialogTitle-B8zPwJB8.js +1 -0
  26. package/dist/web/assets/InteractiveReceipt-Bsj37HtN.js +1 -0
  27. package/dist/web/assets/OverviewScreen-B9qZqEQA.js +1 -0
  28. package/dist/web/assets/PrismHighlighter-DWS6Nx_X.js +6 -0
  29. package/dist/web/assets/Projects-oY3KCgS4.js +1 -0
  30. package/dist/web/assets/SearchResultsPanel-BAManMmt.js +1 -0
  31. package/dist/web/assets/SessionDetail-KSgkmLV7.js +53 -0
  32. package/dist/web/assets/SmartTagChips-BMP9pPRw.js +1 -0
  33. package/dist/web/assets/{api-ToidoNW6.js → api-CtZGdxlN.js} +1 -1
  34. package/dist/web/assets/index-BSLHxV0w.css +1 -0
  35. package/dist/web/assets/index-DNw59Qsn.js +1423 -0
  36. package/dist/web/assets/jsx-runtime-D3jfb0Ew.js +1 -0
  37. package/dist/web/assets/panel-DcOuALYX.js +1 -0
  38. package/dist/web/assets/session-indexes-DKukxoe1.js +4 -0
  39. package/dist/web/assets/translate-CLoII3EO.js +2 -0
  40. package/dist/web/assets/utils-Dk_44zMo.js +1 -0
  41. package/dist/web/index.html +9 -8
  42. package/package.json +2 -2
  43. package/dist/chunk-DE6UJMOY.js.map +0 -1
  44. package/dist/chunk-QHWSZFRM.js.map +0 -1
  45. package/dist/chunk-SII3M66U.js.map +0 -1
  46. package/dist/chunk-VVCSQU5B.js.map +0 -1
  47. package/dist/chunk-WIWK7BXS.js.map +0 -1
  48. package/dist/chunk-YEQTRALH.js.map +0 -1
  49. package/dist/web/assets/CustomTimeWindowDialog-CVURkiVO.js +0 -1
  50. package/dist/web/assets/InteractiveReceipt-DGC-xV7U.js +0 -1
  51. package/dist/web/assets/OverviewScreen-DoXrZ5qp.js +0 -1
  52. package/dist/web/assets/PrismHighlighter-02695Lmx.js +0 -6
  53. package/dist/web/assets/Projects-DZiYh6hp.js +0 -1
  54. package/dist/web/assets/SearchResultsPanel-CAQe8Di0.js +0 -1
  55. package/dist/web/assets/SessionDetail-Da8EBygt.js +0 -53
  56. package/dist/web/assets/index-Bl8pbRFj.js +0 -1423
  57. package/dist/web/assets/index-CRI1m3xN.css +0 -1
  58. package/dist/web/assets/jsx-runtime-B-hcVAMW.js +0 -1
  59. package/dist/web/assets/session-indexes-D5gps7K8.js +0 -4
  60. package/dist/web/assets/translate-BDFu3ZiK.js +0 -2
  61. package/dist/web/assets/utils-BIZi2up3.js +0 -1
  62. /package/dist/{chunk-EYZ73CYP.js.map → chunk-AGUAXTKC.js.map} +0 -0
  63. /package/dist/{discovery-4WAEYSTR.js.map → discovery-KEZQU6RL.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-WIWK7BXS.js";
3
- import "./chunk-DE6UJMOY.js";
2
+ import "./chunk-L4G3LE7I.js";
3
+ import "./chunk-V3HKVTIO.js";
4
4
  import {
5
5
  computeIdentityProjection
6
- } from "./chunk-YEQTRALH.js";
7
- import "./chunk-QHWSZFRM.js";
6
+ } from "./chunk-KVTLNX7V.js";
7
+ import "./chunk-YLXHGL4S.js";
8
8
 
9
9
  // src/project-identity-worker.ts
10
10
  import { parentPort } from "worker_threads";
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-RF3EEWPH.js";
5
5
  import {
6
6
  acknowledgeWorkerLogDrain
7
- } from "./chunk-EYZ73CYP.js";
7
+ } from "./chunk-AGUAXTKC.js";
8
8
  import "./chunk-QH2HOXJH.js";
9
9
  import {
10
10
  appLogger
11
- } from "./chunk-DE6UJMOY.js";
11
+ } from "./chunk-V3HKVTIO.js";
12
12
  import {
13
13
  attachMissingProjectIdentities,
14
14
  buildAgentCacheMeta,
@@ -18,14 +18,14 @@ import {
18
18
  hasStaleSessionTags,
19
19
  planAgentScan,
20
20
  sortSessions
21
- } from "./chunk-VVCSQU5B.js";
22
- import "./chunk-YEQTRALH.js";
21
+ } from "./chunk-DHQPM5FF.js";
22
+ import "./chunk-KVTLNX7V.js";
23
23
  import {
24
24
  createRegisteredAgents
25
- } from "./chunk-SII3M66U.js";
25
+ } from "./chunk-RBCCNCDO.js";
26
26
  import {
27
27
  synchronizePricingGeneration
28
- } from "./chunk-QHWSZFRM.js";
28
+ } from "./chunk-YLXHGL4S.js";
29
29
 
30
30
  // src/scan-refresh-worker.ts
31
31
  import { parentPort, workerData } from "worker_threads";
@@ -1,25 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  acknowledgeWorkerLogDrain
4
- } from "./chunk-EYZ73CYP.js";
4
+ } from "./chunk-AGUAXTKC.js";
5
5
  import "./chunk-QH2HOXJH.js";
6
6
  import {
7
7
  appLogger
8
- } from "./chunk-DE6UJMOY.js";
8
+ } from "./chunk-V3HKVTIO.js";
9
9
  import {
10
10
  commitDurableSessionPublication,
11
11
  markAgentCacheInitialized,
12
12
  sessionDetailVersion,
13
13
  syncSessionSearchIndex,
14
14
  syncSessionSearchIndexChanges
15
- } from "./chunk-VVCSQU5B.js";
16
- import "./chunk-YEQTRALH.js";
15
+ } from "./chunk-DHQPM5FF.js";
16
+ import "./chunk-KVTLNX7V.js";
17
17
  import {
18
18
  createRegisteredAgents
19
- } from "./chunk-SII3M66U.js";
19
+ } from "./chunk-RBCCNCDO.js";
20
20
  import {
21
21
  synchronizePricingGeneration
22
- } from "./chunk-QHWSZFRM.js";
22
+ } from "./chunk-YLXHGL4S.js";
23
23
 
24
24
  // src/search-index-worker.ts
25
25
  import { randomUUID } from "crypto";
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  acknowledgeWorkerLogDrain
4
- } from "./chunk-EYZ73CYP.js";
4
+ } from "./chunk-AGUAXTKC.js";
5
5
  import "./chunk-QH2HOXJH.js";
6
6
  import {
7
7
  appLogger
8
- } from "./chunk-DE6UJMOY.js";
8
+ } from "./chunk-V3HKVTIO.js";
9
9
  import {
10
10
  closeCacheStorage,
11
11
  materializeSessionDetailResponse
12
- } from "./chunk-VVCSQU5B.js";
13
- import "./chunk-YEQTRALH.js";
12
+ } from "./chunk-DHQPM5FF.js";
13
+ import "./chunk-KVTLNX7V.js";
14
14
  import {
15
15
  createRegisteredAgents
16
- } from "./chunk-SII3M66U.js";
16
+ } from "./chunk-RBCCNCDO.js";
17
17
  import {
18
18
  synchronizePricingGeneration
19
- } from "./chunk-QHWSZFRM.js";
19
+ } from "./chunk-YLXHGL4S.js";
20
20
 
21
21
  // src/session-detail-worker.ts
22
22
  import { parentPort, workerData } from "worker_threads";
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import "./chunk-QH2HOXJH.js";
3
- import "./chunk-DE6UJMOY.js";
3
+ import "./chunk-V3HKVTIO.js";
4
4
  import {
5
5
  createRegisteredAgents
6
- } from "./chunk-SII3M66U.js";
6
+ } from "./chunk-RBCCNCDO.js";
7
7
  import {
8
8
  classifySessionTags,
9
9
  getSmartTagSourceTimestamp,
10
10
  synchronizePricingGeneration
11
- } from "./chunk-QHWSZFRM.js";
11
+ } from "./chunk-YLXHGL4S.js";
12
12
 
13
13
  // src/smart-tag-worker.ts
14
14
  import { parentPort, workerData } from "worker_threads";
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{dn as r,i,kt as a,n as o,s,t as c}from"./DialogTitle-B8zPwJB8.js";import{n as l,t as u}from"./translate-CLoII3EO.js";import{o as d}from"./api-CtZGdxlN.js";var f=e(t(),1),p=n(),m=f.createContext(void 0),h=e=>{let t=f.useContext(m);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},g=({client:e,children:t})=>(f.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,p.jsx)(m.Provider,{value:e,children:t})),_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function y(e){setTimeout(e,0)}var b=typeof window>`u`||`Deno`in globalThis;function x(){}function ee(e,t){return typeof e==`function`?e(t):e}function S(e){return typeof e==`number`&&e>=0&&e!==1/0}function C(e,t){return Math.max(e+(t||0)-Date.now(),0)}function w(e,t){return typeof e==`function`?e(t):e}function te(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==re(o,t.options))return!1}else if(!E(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ne(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(T(t.options.mutationKey)!==T(a))return!1}else if(!E(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function re(e,t){return(t?.queryKeyHashFn||T)(e)}function T(e){return JSON.stringify(e,(e,t)=>k(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function E(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!E(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!E(e[r],t[r]))return!1;return!0}return!1}var ie=Object.prototype.hasOwnProperty;function D(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ae(e)&&ae(t);if(!r&&!(k(e)&&k(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ie.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=D(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function O(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ae(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function k(e){if(!A(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!A(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function A(e){return Object.prototype.toString.call(e)===`[object Object]`}function oe(e){return new Promise(t=>{v.setTimeout(t,e)})}function j(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:D(e,t)}function se(e){return e}function ce(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function le(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var M=Symbol();function N(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===M?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function P(e,t){return typeof e==`function`?e(...t):!!e}function ue(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var de=()=>b,F=()=>de(),I=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},L=new class extends I{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},fe=y;function pe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=fe,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var R=pe(),z=new class extends I{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function me(e){return Math.min(1e3*2**e,3e4)}function B(e){return(e??`online`)!==`online`||z.isOnline()}var V=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function H(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(x);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new V(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>L.isFocused()&&(e.networkMode===`always`||z.isOnline())&&e.canRun(),p=()=>B(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(F()?0:3),a=e.retryDelay??me,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),oe(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var U=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),S(this.gcTime)&&(this.#e=v.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(F()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(v.clearTimeout(this.#e),this.#e=void 0)}};function he(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ue(e,()=>t.signal,()=>n=!0)},u=N(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?le:ce;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ge:W,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:W(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function W(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ge(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var _e=class extends U{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=q(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=q(this.options);e.data!==void 0&&(this.setState(K(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=j(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(x).catch(x):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>w(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===M||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>w(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!C(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=N(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?he(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=H({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof V&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof V){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...G(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...K(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),R.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function G(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:B(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function K(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function q(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var ve=class extends I{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),J(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Y(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Y(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof w(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!O(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&be(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||w(this.options.enabled,this.#t)!==w(t.enabled,this.#t)||w(this.options.staleTime,this.#t)!==w(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||w(this.options.enabled,this.#t)!==w(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return O(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(x)),t}#h(e){return!F()&&w(this.options.enabled,this.#t)!==!1&&S(e)}#g(){this.#b();let e=w(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=C(this.#r.dataUpdatedAt,e)+1;this.#u=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=v.setInterval(()=>{(this.options.refetchIntervalInBackground||L.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(v.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(v.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&J(e,t),o=i&&be(e,n,t,r);(a||o)&&(l={...l,...G(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=j(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=j(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:X(e,t),refetch:this.refetch,isEnabled:w(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),O(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();R.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function ye(e,t){return w(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||w(t.retryOnMount,e)!==!1)}function J(e,t){return ye(e,t)||e.state.data!==void 0&&Y(e,t,t.refetchOnMount)}function Y(e,t,n){if(w(t.enabled,e)!==!1&&w(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&X(e,t)}return!1}function be(e,t,n,r){return(e!==t||w(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&X(e,n)}function X(e,t){return w(t.enabled,e)!==!1&&e.isStaleByTime(w(t.staleTime,e))}var Z=f.createContext(!1),xe=()=>f.useContext(Z);Z.Provider;function Se(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ce=f.createContext(Se()),we=()=>f.useContext(Ce),Te=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?P(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Ee=e=>{f.useEffect(()=>{e.clearReset()},[e])},De=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||P(n,[e.error,r])),Oe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},ke=(e,t)=>e?.suspense&&t.isPending,Ae=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function je(e,t,n){let r=xe(),i=we(),a=h(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Oe(o),Te(o,i,s),Ee(i);let[l]=f.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(f.useSyncExternalStore(f.useCallback(e=>{let t=d?l.subscribe(R.batchCalls(e)):x;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),f.useEffect(()=>{l.setOptions(o)},[o,l]),ke(o,u))throw Ae(o,l,i);if(De({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function Me(e,t){return je(e,ve,t)}function Ne(e){return e}function Q(e){return{days:e.days,from:e.from,to:e.to}}function Pe(e){return{...e.project?{project:e.project}:{},...e.agent?{agent:e.agent}:{},timeZone:e.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone}}var Fe={bookmarks:[`bookmarks`],config:[`config`],dashboards:[`dashboard`],dashboard:(e,t)=>[`dashboard`,Q(e),Pe(t)],agentCatalogs:[`agent-catalog`],agentCatalog:e=>[`agent-catalog`,Q(e)],projects:[`projects`],projectWindow:e=>[`projects`,Q(e)],projectPage:(e,t)=>[`projects`,Q(e),`page`,t??null],projectDetail:(e,t)=>[`projects`,Q(e),`detail`,t],search:(e,t)=>[`search`,e,t],searches:[`search`],sessionDetails:[`session-detail`],sessionDetail:(e,t)=>[`session-detail`,e,t],sessionProjections:[`session-projection`],sessionProjection:e=>[`session-projection`,Q(e)]},Ie=2e3;function Le(e,t){return Ne({queryKey:Fe.dashboard(e,t),staleTime:Ie,queryFn:async({signal:n})=>{try{return await d(e,t,{signal:n})}catch(e){throw n.aborted||console.error(`Failed to load dashboard:`,e),e}}})}var Re=(0,f.createContext)(`light`),ze=`(prefers-color-scheme: dark)`;function Be(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(ze).matches}function Ve(e){let[t,n]=(0,f.useState)(Be);(0,f.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(ze),t=e=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let r=e===`system`?t?`dark`:`light`:e;return(0,f.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,r===`dark`)},[r]),r}function He({title:e,message:t,onRetry:n,className:r=``}){return l(),(0,p.jsxs)(`div`,{role:`alert`,className:`rounded-sm border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-4 text-[var(--console-error)] ${r}`,children:[(0,p.jsx)(`p`,{className:`text-sm font-medium`,children:e}),(0,p.jsx)(`p`,{className:`console-mono mt-1 break-words text-[11px]`,children:t}),(0,p.jsx)(`button`,{type:`button`,onClick:n,className:`console-mono mt-3 rounded-sm border border-[var(--console-error-border)] bg-[var(--console-surface)] px-2.5 py-1 text-[11px] font-semibold motion-hover hover:bg-[var(--console-error-bg)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:u(`Retry`)})]})}function Ue(e){let t=e.sourceFailureCount;return[t==null?null:u(`{0} source{1} failed`,[t,t===1?``:`s`]),e.sourceFailureSummary].filter(e=>e!=null).join(` · `)}function We(e){return(e.sourceFailureCount??0)>0||e.sourceFailureSummary!=null}function $(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Ge(e){if(!e)return null;let{from:t,to:n,days:r}=e.window;if(r===0||t==null)return u(`All time`);let i=$(t),a=$(n??Date.now());return r?u(`Last {0}d · {1} → {2}`,[r,i,a]):`${i} → ${a}`}function Ke(e,t,n){return t?e?u(`Searching for "{0}"`,[e]):u(`Loading recent sessions`):e?u(`{0} matches for "{1}"`,[n,e]):u(`{0} recent sessions`,[n])}function qe(e){if(!e)return null;if(e.backfill?.active){let t=e.backfill.currentAgent,n=e.backfill.pendingAgents.length,r=e.backfill.progress,i=(r?.phase==null||r.phase===`scanning`||r.phase===`finalizing`)&&r?.total&&r.processed!=null?` · ${r.processed}/${r.total}`:``,a=r?.phase===`publish-queued`?u(`Full-history publication queued`):r?.phase===`committing`?u(`Committing full-history publication`):r?.phase===`indexing`?u(`Writing full-history search index`):r?.phase===`publishing`?u(`Preparing full-history publication`):r?.phase===`finalizing`?u(`Finalizing full-history metadata`):u(`Scanning full session history`);return t?`${a} · ${t}${i}${n>0?u(` · {0} history scan queued`,[n]):``}`:`${a}${i}`}if(e.backfill?.failedAgents.length)return u(`Full-history refresh failed · {0}`,[e.backfill.failedAgents.join(`, `)]);let t=Object.values(e.agentStatuses??{}).find(e=>e.status===`failed`);if(t)return u(`Session refresh failed · {0}{1}`,[t.agentName,t.error?` · ${t.error}`:``]);if(e.active&&e.phase===`initializing`)return u(`Initializing recent sessions`);let n=Object.entries(e.backfill?.partialAgents??{}).find(([,e])=>e.completeness===`partial`&&We(e));if(n){let[e,t]=n,r=Ue(t);return u(`Full-history refresh completed with partial data · {0}{1}`,[e,r?` · ${r}`:``])}let r=Object.values(e.agentStatuses??{}).find(e=>e.status===`complete`&&e.completeness===`partial`&&We(e));if(r){let e=Ue(r);return u(`Session refresh completed with partial data · {0}{1}`,[r.agentName,e?` · ${e}`:``])}return e.searchIndexMaintenance?.failedAgents.length?u(`Background search index maintenance paused · {0}`,[e.searchIndexMaintenance.failedAgents.join(`, `)]):null}function Je({open:e,onOpenChange:t,window:n,customFrom:r,customTo:i,onSelectCustom:a}){l();let s=r??(n?.from==null?``:$(n.from)),c=i??(n?.to==null?null:$(n.to));return(0,p.jsx)(o,{open:e,onOpenChange:t,children:e?(0,p.jsx)(Ye,{initialFrom:s,initialTo:c,onOpenChange:t,onSelectCustom:a}):null})}function Ye({initialFrom:e,initialTo:t,onOpenChange:n,onSelectCustom:o}){l();let[d,m]=(0,f.useState)(e),[h,g]=(0,f.useState)(()=>t??$(Date.now()));return(0,p.jsxs)(i,{children:[(0,p.jsx)(r,{className:`motion-backdrop fixed inset-0 z-50 bg-[var(--scrim)]`}),(0,p.jsxs)(s,{className:`motion-modal fixed top-1/2 left-1/2 z-50 w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-5 shadow-[var(--shadow-overlay)] outline-none`,children:[(0,p.jsx)(c,{className:`console-mono text-sm font-semibold text-[var(--console-text)]`,children:u(`Custom time range`)}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:u(`Both dates are included.`)}),(0,p.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:[(0,p.jsxs)(`label`,{className:`console-mono text-[11px] uppercase tracking-wide text-[var(--console-muted)]`,children:[u(`From`),` `,(0,p.jsx)(`input`,{type:`date`,value:d,max:h||void 0,onChange:e=>m(e.target.value),className:`mt-1.5 w-full rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-2 py-2 text-xs normal-case tracking-normal text-[var(--console-text)] outline-none focus:border-[var(--brand)] focus:ring-2 focus:ring-[var(--brand)]/25`})]}),(0,p.jsxs)(`label`,{className:`console-mono text-[11px] uppercase tracking-wide text-[var(--console-muted)]`,children:[u(`To`),` `,(0,p.jsx)(`input`,{type:`date`,value:h,min:d||void 0,onChange:e=>g(e.target.value),className:`mt-1.5 w-full rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-2 py-2 text-xs normal-case tracking-normal text-[var(--console-text)] outline-none focus:border-[var(--brand)] focus:ring-2 focus:ring-[var(--brand)]/25`})]})]}),(0,p.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,p.jsx)(a,{className:`rounded-sm border border-[var(--console-border)] px-3 py-1.5 text-xs text-[var(--console-text)] hover:bg-[var(--console-surface-muted)]`,children:u(`Cancel`)}),(0,p.jsx)(`button`,{type:`button`,disabled:!d||!h||d>h,onClick:()=>{o(d,h),n(!1)},className:`rounded-sm border border-[var(--console-accent)] bg-[var(--console-accent)] px-3 py-1.5 text-xs text-[var(--console-accent-fg)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40`,children:u(`Apply range`)})]})]})]})}export{O as A,se as C,E as D,x as E,M,g as N,D as O,h as P,re as S,te as T,R as _,He as a,ee as b,Ie as c,Ne as d,Me as f,z as g,H as h,Ge as i,P as j,w as k,Le as l,U as m,qe as n,Re as o,_e as p,Ke as r,Ve as s,Je as t,Fe as u,L as v,ne as w,T as x,I as y};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{E as r,i,j as a,n as o,t as s,w as c}from"./translate-CLoII3EO.js";import{t as l}from"./SmartTagChips-BMP9pPRw.js";import{o as u}from"./session-indexes-DKukxoe1.js";import{$ as d,F as f,H as p,W as m,Z as h,nt as g,q as _,st as v}from"./index-DNw59Qsn.js";import{n as y,t as b}from"./panel-DcOuALYX.js";var x=e(t(),1),S=n();function C({active:e,onToggle:t,className:n=``}){return o(),(0,S.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":s(e?`Remove bookmark`:`Add bookmark`),title:s(e?`Remove bookmark`:`Add bookmark`),className:`motion-hover motion-press inline-flex size-6 shrink-0 items-center justify-center rounded-sm border focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none ${n} ${e?`border-[var(--brand-line)] bg-[var(--brand-soft)] text-[var(--brand)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,S.jsx)(f,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function w(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function T({label:e,value:t,hint:n}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,S.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function E({label:e,value:t}){return o(),(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function D({code:e,title:t,description:n,aside:r,iconSrc:i,iconColored:a,iconAlt:c}){return o(),(0,S.jsx)(b,{className:`p-5 md:p-6`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,S.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,S.jsx)(`span`,{className:`console-eyebrow inline-flex rounded-full border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2.5 py-1`,children:e}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,S.jsx)(p,{icon:i,iconColored:a,alt:c||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,S.jsx)(`h2`,{className:`console-display text-2xl leading-tight font-semibold text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,S.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,S.jsxs)(`div`,{className:`min-w-0 rounded-md border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`STATUS NOTE`)}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function O({agentItems:e}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Agents`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(u,{to:c(e.key),className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)]`,children:[e.icon?(0,S.jsx)(p,{icon:e.icon,iconColored:e.iconColored,alt:e.name,className:`size-4 object-contain`}):null,(0,S.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,S.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function k({sessions:e,isBookmarked:t,onToggleBookmark:n}){return o(),e.length===0?(0,S.jsx)(b,{className:`p-4 text-sm text-[var(--console-muted)]`,children:s(`No sessions yet`)}):(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Recent Sessions`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>{let i=t(e.reference.agentName,e.reference.sessionId);return(0,S.jsx)(`li`,{children:(0,S.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,S.jsxs)(u,{to:a({agentName:e.reference.agentName,sessionId:e.reference.sessionId}),className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:m(e)}),(0,S.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,r(e.reference),` ·`,` `,g(e.time_updated||e.time_created)]}),(0,S.jsx)(l,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,S.jsx)(C,{active:i,onToggle:()=>n(e)})]})},r(e.reference))})})]})}var A=(0,x.memo)(function({type:e,agentCatalog:t,sessions:n,agentItems:r,activeAgentKey:a,attemptedAgentKey:c,attemptedSessionId:l,loadFailureMessage:u,isBookmarked:f,onToggleBookmark:m,onRetry:y}){o();let{recentSessions:C,totalMessages:A,totalTokens:j,totalCost:M,costSource:N,latestUpdatedAt:P}=(0,x.useMemo)(()=>{let e=n.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),t=0,r=0,i=0,a=!1;for(let e of n)t+=e.stats.message_count,r+=w(e.stats),i+=e.stats.total_cost,a||=e.stats.cost_source===`estimated`;return{recentSessions:e.slice(0,5),totalMessages:t,totalTokens:r,totalCost:i,costSource:i>0?a?`estimated`:`recorded`:void 0,latestUpdatedAt:e[0]?.time_updated||e[0]?.time_created}},[n]);if(e===`missing-agent`){let e=`/${c||`unknown`}${l?`/${l}`:``}`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / AGENT`),title:s(`This agent isn't on the roster.`),description:s(`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`),aside:s(`Choose one of the available agents to continue.`)}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(E,{label:s(`Requested Agent`),value:c||`unknown`}),(0,S.jsx)(E,{label:s(`Requested Path`),value:e}),l?(0,S.jsx)(E,{label:s(`Requested Session`),value:l}):null]}),(0,S.jsx)(O,{agentItems:r})]})}if(e===`missing-session`){let e=a?v(t,a):void 0,n=e?.displayName??a??s(`Unknown Agent`),r=e?.icon,i=l||`unknown-session`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / SESSION`),title:s(`This session isn't in the index.`),description:s(`{0} is available, but the session you're looking for does not exist in the current index. The session ID may be incorrect, or the record may never have been part of this dataset.`,[n]),aside:s(`We checked the current path, but nothing matched. The session list on the left is still available.`),iconSrc:r,iconColored:e?.iconColored,iconAlt:n}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`Agent`)}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[r?(0,S.jsx)(p,{icon:r,iconColored:e?.iconColored,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,S.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,S.jsx)(E,{label:s(`Session`),value:i})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:f,onToggleBookmark:m})]})}if(e===`load-failed`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`LOAD / SESSION`),title:s(`We couldn't load this session.`),description:s(`The session request failed before we could determine whether the record exists. It may still be available once the connection or server recovers.`),aside:s(`Retry this request without leaving the current session path.`)}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(E,{label:s(`Request Error`),value:u??s(`Unable to load this session.`)})}),(0,S.jsx)(`button`,{type:`button`,onClick:y,className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-1.5 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:s(`Retry`)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:f,onToggleBookmark:m})]});if(e===`global`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(T,{label:s(`Total Sessions`),value:d(n.length)}),(0,S.jsx)(T,{label:s(`Total Messages`),value:d(A)}),(0,S.jsx)(T,{label:s(`Latest Activity`),value:g(P),hint:P?new Date(P).toLocaleString(i()):void 0})]}),(0,S.jsx)(O,{agentItems:r}),(0,S.jsx)(k,{sessions:C,isBookmarked:f,onToggleBookmark:m})]});let F=a?v(t,a):void 0,I=F?.displayName??s(`Unknown Agent`);return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(b,{className:`p-4`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[F?.icon?(0,S.jsx)(p,{icon:F.icon,iconColored:F.iconColored,alt:I,className:`size-6 object-contain`}):null,(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:I}),(0,S.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:s(`Select a session from the left to view details`)})]})]})}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,S.jsx)(T,{label:s(`Sessions`),value:d(n.length)}),(0,S.jsx)(T,{label:s(`Messages`),value:d(A)}),(0,S.jsx)(T,{label:s(`Tokens`),value:d(j)}),(0,S.jsx)(T,{label:s(`Total Cost`),value:h(M),hint:_(N)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:f,onToggleBookmark:m})]})});export{A as DetailLanding};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,r as n,t as r}from"./jsx-runtime-D3jfb0Ew.js";var i=n((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return l(e,t,null,n)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.0`})),a=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=i()})),o=e(t(),1);function s(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var c=s(`https://base-ui.com/production-error`,`Base UI`),l=o.createContext(void 0);function u(e){let t=o.useContext(l);if(!e&&t===void 0)throw Error(c(27));return t}var d={};function f(e,t){let n=o.useRef(d);return n.current===d&&(n.current=e(t)),n}function p(e,t,n,r){let i=f(h).current;return g(i,e,t,n,r)&&v(i,[e,t,n,r]),i.callback}function m(e){let t=f(h).current;return _(t,e)&&v(t,e),t.callback}function h(){return{callback:null,cleanup:null,refs:[]}}function g(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function _(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function v(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var y=19;function b(e){return y>=e}function x(e){if(!o.isValidElement(e))return null;let t=e,n=t.props;return(b(19)?n?.ref:t.ref)??null}function S(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function C(){}var w=Object.freeze([]),T=Object.freeze({});function ee(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function E(e,t){return typeof e==`function`?e(t):e}function D(e,t){return typeof e==`function`?e(t):e}var O={};function k(e,t,n,r,i){if(!n&&!r&&!i&&!e)return j(t);let a=j(e);return t&&(a=M(a,t)),n&&(a=M(a,n)),r&&(a=M(a,r)),i&&(a=M(a,i)),a}function A(e){if(e.length===0)return O;if(e.length===1)return j(e[0]);let t=j(e[0]);for(let n=1;n<e.length;n+=1)t=M(t,e[n]);return t}function j(e){return P(e)?{...F(e,O)}:te(e)}function M(e,t){return P(t)?F(t,e):ne(e,t)}function te(e){let t={...e};for(let e in t){let n=t[e];N(e,n)&&(t[e]=re(n))}return t}function ne(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=S(e.style,r);break;case`className`:e[n]=ae(e.className,r);break;default:e[n]=N(n,r)?I(e[n],r):r}}return e}function N(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function P(e){return typeof e==`function`}function F(e,t){return P(e)?e(t):e??O}function I(e,t){return t?e?(...n)=>{let r=n[0];if(oe(r)){let i=r;ie(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:re(t):e}function re(e){return e&&((...t)=>{let n=t[0];return oe(n)&&ie(n),e(...t)})}function ie(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function ae(e,t){return t?e?t+` `+e:t:e}function oe(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function L(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=B(r));let i=se(t,n,r);if(n.enabled===!1)return null;let a=n.state??T;return ce(e,r,i,a)}function se(e,t,n){let{className:r,style:i}=e,{state:a=T,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?E(r,a):void 0,d=l?D(i,a):void 0,f=l?ee(a,c):T,h=l&&s?R(s):void 0,g=l?S(f,h)??{}:T;return typeof document<`u`&&(l?g.ref=Array.isArray(o)?m([g.ref,x(n),...o]):p(g.ref,x(n),o):p(null,null)),l?(u!==void 0&&(g.className=ae(g.className,u)),d!==void 0&&(g.style=S(g.style,d)),g):T}function R(e){return Array.isArray(e)?A(e):k(void 0,e)}var z=Symbol.for(`react.lazy`);function B(e){if(e?.$$typeof!==z)return e;let t=o.Children.toArray(e)[0];return o.isValidElement(t)?t:e}function ce(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=k(n,t.props);return e.ref=n.ref,o.cloneElement(t,e)}if(e&&typeof e==`string`)return le(e,n);throw Error(c(8))}function le(e,t){return e===`button`?(0,o.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,o.createElement)(`img`,{alt:``,...t,key:t.key}):o.createElement(e,t)}var ue=`data-starting-style`,de=`data-ending-style`,fe={[ue]:``},pe={[de]:``},me={transitionStatus(e){return e===`starting`?fe:e===`ending`?pe:null}},he=`data-open`,ge=`data-closed`,_e=`data-anchor-hidden`,ve=`data-popup-open`,ye=`data-pressed`,be={[ve]:``,[ye]:``},xe={[he]:``},Se={[ge]:``},Ce={[_e]:``},we={open(e){return e?be:null}},Te={open(e){return e?xe:Se},anchorHidden(e){return e?Ce:null}},Ee={...Te,...me},De=o.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=u(),c=s.useState(`open`),l=s.useState(`nested`),d=s.useState(`mounted`);return L(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Ee,props:[{role:`presentation`,hidden:!d,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});function Oe(){return typeof window<`u`}function V(e){return Ae(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ke(e){return((Ae(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ae(e){return Oe()?e instanceof Node||e instanceof H(e).Node:!1}function U(e){return Oe()?e instanceof Element||e instanceof H(e).Element:!1}function W(e){return Oe()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function je(e){return!Oe()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function Me(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ue(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Ne(e){return/^(table|td|th)$/.test(V(e))}function Pe(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Fe=/transform|translate|scale|rotate|perspective|filter/,Ie=/paint|layout|strict|content/,Le=e=>!!e&&e!==`none`,Re;function ze(e){let t=U(e)?Ue(e):e;return Le(t.transform)||Le(t.translate)||Le(t.scale)||Le(t.rotate)||Le(t.perspective)||!Ve()&&(Le(t.backdropFilter)||Le(t.filter))||Fe.test(t.willChange||``)||Ie.test(t.contain||``)}function Be(e){let t=Ge(e);for(;W(t)&&!He(t);){if(ze(t))return t;if(Pe(t))return null;t=Ge(t)}return null}function Ve(){return Re??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Re}function He(e){return/^(html|body|#document)$/.test(V(e))}function Ue(e){return H(e).getComputedStyle(e)}function We(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ge(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||je(e)&&e.host||ke(e);return je(t)?t.host:t}function Ke(e){let t=Ge(e);return He(t)?(e.ownerDocument||e).body:W(t)&&Me(t)?t:Ke(t)}function qe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ke(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=Je(a);return t.concat(a,a.visualViewport||[],Me(r)?r:[],e&&n?qe(e):[])}return t.concat(r,qe(r,[],n))}function Je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var Ye={...o},Xe=Ye.useInsertionEffect,Ze=Xe&&Xe!==Ye.useLayoutEffect?Xe:e=>e();function G(e){let t=f(Qe).current;return t.next=e,Ze(t.effect),t.trampoline}function Qe(){let e={next:void 0,callback:$e,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function $e(){}var K=typeof document<`u`?o.useLayoutEffect:()=>{},et=o.createContext(void 0);function tt(e=!1){let t=o.useContext(et);if(t===void 0&&!e)throw Error(c(16));return t}function nt(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,s=r&&t!==!1,c=r&&t===!1;return{props:o.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||s)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||c)&&(e.disabled=n),e},[r,n,t,s,c,a,i])}}function q(e){return e?.ownerDocument||document}function rt(e,t,{detail:n=0}={}){e.dispatchEvent(new(H(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function it(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,s=o.useRef(null),c=tt(!0),l=a??c!==void 0,{props:u}=nt({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:r,isNativeButton:i}),d=o.useCallback(()=>{let e=s.current;at(e)&&l&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,l]);return K(d,[d]),{getButtonProps:o.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...c}=e;return k({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(ie(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=at(r),s=!i&&ot(r),c=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&l&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),rt(r,e));return}if(!c||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),rt(r,e)))},onKeyUp(e){if(!t){if(ie(e),a?.(e),e.target===e.currentTarget&&i&&l&&at(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!l&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),rt(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},u,c)},[t,u,l,i]),buttonRef:G(e=>{s.current=e,d()})}}function at(e){return W(e)&&e.tagName===`BUTTON`}function ot(e){return W(e)&&e.tagName===`A`&&!!e.href}var st=`none`,ct=`trigger-press`,lt=`trigger-hover`,ut=`trigger-focus`,dt=`outside-press`,ft=`item-press`,pt=`close-press`,mt=`focus-out`,ht=`escape-key`,gt=`list-navigation`,_t=`cancel-open`,vt=`sibling-open`,yt=`imperative-action`;function J(e,t,n,r){let i=!1,a=!1,o=r??T;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var bt=o.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=u(),l=c.useState(`open`),{getButtonProps:d,buttonRef:f}=it({disabled:a,native:o}),p={disabled:a};function m(e){l&&c.setOpen(!1,J(pt,e.nativeEvent))}return L(`button`,e,{state:p,ref:[t,f],props:[{onClick:m},s,d]})}),xt=e(a(),1),Y=r(),St=0;function Ct(e,t=`mui`){let[n,r]=o.useState(e),i=e||n;return o.useEffect(()=>{n??(St+=1,r(`${t}-${St}`))},[n,t]),i}var wt=Ye.useId;function Tt(e,t){if(wt!==void 0){let n=wt();return e??(t?`${t}-${n}`:n)}return Ct(e,t)}function Et(e){return Tt(e,`base-ui`)}function Dt(e){o.useEffect(e,w)}var Ot=0,kt=class e{static create(){return new e}currentId=Ot;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ot,t()},e)}isStarted(){return this.currentId!==Ot}clear=()=>{this.currentId!==Ot&&(clearTimeout(this.currentId),this.currentId=Ot)};disposeEffect=()=>this.clear};function At(){let e=f(kt.create).current;return Dt(e.disposeEffect),e}function jt(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Mt,platform:Nt,maxTouchPoints:Pt}=jt(),Ft=Mt.toLowerCase(),It=Nt.toLowerCase(),Lt=/^i(os$|p)/.test(It)||It===`macintel`&&Pt>1,Rt=`android`,zt=It===Rt||Ft.includes(Rt),Bt=!Lt&&It.startsWith(`mac`);It.startsWith(`win`),!zt&&/^(linux|chrome os)/.test(It);var Vt=Bt||Lt,Ht=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!Ht&&Ft.includes(`firefox`),!Ht&&Ft.includes(`chrom`);var Ut=Vt,Wt=/jsdom|happydom/.test(Ft);function Gt(e){e.preventDefault(),e.stopPropagation()}function Kt(e){return`nativeEvent`in e}function qt(e){return e.pointerType===``&&e.isTrusted?!0:zt&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Jt(e){return Wt?!1:!zt&&e.width===0&&e.height===0||zt&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Yt(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Xt(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function X(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Z(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&je(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Q(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Zt=`data-base-ui-focusable`,Qt=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,$t=`ArrowLeft`,en=`ArrowRight`,tn=`ArrowUp`,nn=`ArrowDown`,rn=`data-trigger-disabled`;function an(e,t){if(!U(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(rn);for(let[,e]of t.entries())if(Z(e,n))return!e.hasAttribute(rn);return!1}function on(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function sn(e){return e.matches(`html,body`)}function cn(e){return W(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function ln(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Qt}`)!=null}function un(e){return e?e.getAttribute(`role`)===`combobox`&&cn(e):!1}function dn(e){if(!e||Wt)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function fn(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function $(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function pn(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function mn(e){let t=f(hn,e).current;return t.next=e,K(t.effect),t}function hn(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var gn=null;globalThis.requestAnimationFrame;var _n=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},vn=class e{static create(){return new e}static request(e){return _n.request(e)}static cancel(e){return _n.cancel(e)}currentId=gn;request(e){this.cancel(),this.currentId=_n.request(()=>{this.currentId=gn,e()})}cancel=()=>{this.currentId!==gn&&(_n.cancel(this.currentId),this.currentId=gn)};disposeEffect=()=>this.cancel};function yn(){let e=f(vn.create).current;return Dt(e.disposeEffect),e}var bn={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},xn={...bn,position:`fixed`,top:0,left:0};({...bn});var Sn=o.forwardRef(function(e,t){let[n,r]=o.useState();K(()=>{Ut&&Ht&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Y.jsx)(`span`,{...e,ref:t,style:xn,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})});function Cn(e,t){return t<0||t>=e.length}function wn(e,t){return En(e.current,{disabledIndices:t})}function Tn(e,t){return En(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function En(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Dn(e,a,r));return a}function Dn(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!kn(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function On(e){return e.visibility===`hidden`||e.visibility===`collapse`}function kn(e,t=e?Ue(e):null){return!e||!e.isConnected||!t||On(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var An=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function jn(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return je(n)?n.host:null}function Mn(e){for(let t of Array.from(e.children))if(V(t)===`summary`)return t;return null}function Nn(e,t){let n=Mn(t);return!!n&&(e===n||Z(n,e))}function Pn(e){let t=e?V(e):``;return e!=null&&e.matches(An)&&(t!==`summary`||e.parentElement!=null&&V(e.parentElement)===`details`&&Mn(e.parentElement)===e)&&(t!==`details`||Mn(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Fn(e){if(!Pn(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=jn(t)){let n=t!==e,r=V(t)===`slot`;if(t.hasAttribute(`inert`)||n&&V(t)===`details`&&!t.open&&!Nn(e,t)||t.hasAttribute(`hidden`)||!r&&!In(t,n))return!1}return!0}function In(e,t){let n=Ue(e);return t?n.display!==`none`:kn(e,n)}function Ln(e){let t=e.tabIndex;if(t<0){let t=V(e);if(t===`details`||t===`audio`||t===`video`||W(e)&&e.isContentEditable)return 0}return t}function Rn(e){if(V(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function zn(e,t){let n=Rn(e);if(!n)return!0;let r=t.find(e=>{let t=Rn(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Rn(e);return t?.name===n.name&&t.form===n.form})===n}function Bn(e){if(W(e)&&V(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return W(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Vn(e,t){Bn(e).forEach(e=>{Pn(e)&&t.push(e),Vn(e,t)})}function Hn(e,t,n){Bn(e).forEach(e=>{W(e)&&e.matches(t)&&n.push(e),Hn(e,t,n)})}function Un(e){return Fn(e)&&Ln(e)>=0}function Wn(e){let t=[];return Vn(e,t),t.filter(Fn)}function Gn(e){let t=Wn(e);return t.filter(e=>Ln(e)>=0&&zn(e,t))}function Kn(e,t){let n=Gn(e),r=n.length;if(r===0)return;let i=X(q(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function qn(e){return Kn(q(e).body,1)||e}function Jn(e){return Kn(q(e).body,-1)||e}function Yn(e,t){if(!e)return null;let n=Gn(q(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function Xn(e){return Yn(e,1)}function Zn(e){return Yn(e,-1)}function Qn(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Z(n,r)}function $n(e){Gn(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function er(e){let t=[];Hn(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function tr(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...tr(e,t.id,n)])}function nr(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function rr(e){return`data-base-ui-${e}`}var ir=0;function ar(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(ir);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),C;let o=requestAnimationFrame(a);return ir=o,()=>{ir===o&&(cancelAnimationFrame(o),ir=0)}}var or={inert:new WeakMap,"aria-hidden":new WeakMap},sr=`data-base-ui-inert`,cr={inert:new WeakSet,"aria-hidden":new WeakSet},lr=new WeakMap,ur=0;function dr(e){return cr[e]}function fr(e){return e?je(e)?e.host:fr(e.parentNode):null}var pr=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=fr(t);return e.contains(n)?n:null}).filter(e=>e!=null),mr=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},hr=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{V(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function gr(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=pr(t,e),l=i?hr(t,mr(c),new Set(c)):[],u=[],d=[];if(a){let e=or[a],n=dr(a);s=n,o=e;let r=pr(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);hr(t,mr(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(lr.get(e)||0)+1;lr.set(e,t),d.push(e),t===1&&e.setAttribute(sr,``)}),ur+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(lr.get(e)||0)-1;lr.set(e,t),t||e.removeAttribute(sr)}),--ur,ur||(or.inert=new WeakMap,or[`aria-hidden`]=new WeakMap,cr.inert=new WeakSet,cr[`aria-hidden`]=new WeakSet,lr=new WeakMap)}}function _r(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=q(e[0]).body;return gr(e,a,n,r,{mark:i})}var vr={style:{transition:`none`}},yr={fallbackAxisSide:`none`},br={fallbackAxisSide:`end`},xr={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},Sr=o.createContext(null),Cr=()=>o.useContext(Sr),wr=rr(`portal`);function Tr(e={}){let{ref:t,container:n,componentProps:r=T,elementProps:i}=e,a=Tt(),s=Cr()?.portalNode,[c,l]=o.useState(null),[u,d]=o.useState(null),f=G(e=>{e!==null&&d(e)}),p=o.useRef(null);K(()=>{if(n===null){p.current&&(p.current=null,d(null),l(null));return}let e=(n&&(Ae(n)?n:n.current))??s??document.body;if(e==null){p.current&&(p.current=null,d(null),l(null));return}p.current!==e&&(p.current=e,d(null),l(e))},[n,s]);let m=L(`div`,r,{ref:[t,f],props:[{id:a,[wr]:``},i]}),h=c&&m?xt.createPortal(m,c):null;return{node:u,nodeId:o.isValidElement(m)?m.props.id:void 0,subtree:h}}var Er=o.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:s,portalOwnerRole:c,...l}=e,{node:u,nodeId:d,subtree:f}=Tr({container:s,ref:t,componentProps:e,elementProps:l}),p=o.useRef(null),m=o.useRef(null),h=o.useRef(null),g=o.useRef(null),[_,v]=o.useState(null),y=o.useRef(!1),b=_?.modal,x=_?.open,S=!!_&&!_.modal&&_.open&&!!u;o.useEffect(()=>{if(!u||b)return;function e(e){u&&e.relatedTarget&&Qn(e)&&(e.type===`focusin`?y.current&&=(er(u),!1):($n(u),y.current=!0))}return pn($(u,`focusin`,e,!0),$(u,`focusout`,e,!0))},[u,b]),K(()=>{u&&x===!0&&y.current&&(er(u),y.current=!1)},[x,u]);let C=o.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:u,setFocusManagerState:v}),[u]);return(0,Y.jsxs)(o.Fragment,{children:[f,(0,Y.jsxs)(Sr.Provider,{value:C,children:[S&&u&&(0,Y.jsx)(Sn,{"data-type":`outside`,ref:p,onFocus:e=>{Qn(e,u)?h.current?.focus():Jn(_?_.domReference:null)?.focus()}}),S&&u&&(0,Y.jsx)(`span`,{role:c,"aria-owns":d,style:xr}),u&&xt.createPortal(a,u),S&&u&&(0,Y.jsx)(Sn,{"data-type":`outside`,ref:m,onFocus:e=>{Qn(e,u)?g.current?.focus():(qn(_?_.domReference:null)?.focus(),_?.closeOnFocusOut&&_?.onOpenChange(!1,J(`focus-out`,e.nativeEvent)))}})]})]})});function Dr(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var Or=class{nodesRef={current:[]};events=Dr();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},kr=o.createContext(null),Ar=o.createContext(null),jr=()=>o.useContext(kr)?.id||null,Mr=e=>{let t=o.useContext(Ar);return e??t};function Nr(e){let t=Tt(),n=Mr(e),r=jr();return K(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Pr(e){let{children:t,id:n}=e,r=jr();return(0,Y.jsx)(kr.Provider,{value:o.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Fr(e){let{children:t,externalTree:n}=e,r=f(()=>n??new Or).current;return(0,Y.jsx)(Ar.Provider,{value:r,children:t})}function Ir(e){return e==null?e:`current`in e?e.current:e}function Lr(e,t){let n=H(Q(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Rr=20,zr=[];function Br(){zr=zr.filter(e=>e.deref()?.isConnected)}function Vr(e){Br(),e&&V(e)!==`body`&&(zr.push(new WeakRef(e)),zr.length>Rr&&(zr=zr.slice(-20)))}function Hr(){return Br(),zr[zr.length-1]?.deref()}function Ur(e){return e?Un(e)?e:Gn(e)[0]||e:null}function Wr(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Wn(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Un(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function Gr(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:m,externalTree:h,getInsideElements:g}=e,_=`rootStore`in t?t.rootStore:t,v=_.useState(`open`),y=_.useState(`domReferenceElement`),b=_.useState(`floatingElement`),{events:x,dataRef:S}=_.context,C=G(()=>S.current.floatingContext?.nodeId),w=i===!1,T=un(y)&&w,ee=mn(i),E=mn(a),D=mn(u),O=mn(v),k=Mr(h),A=Cr(),j=o.useRef(!1),M=o.useRef(!1),te=o.useRef(!1),ne=o.useRef(null),N=o.useRef(``),P=o.useRef(``),F=o.useRef(null),I=o.useRef(null),re=p(F,m,A?.beforeInsideRef),ie=p(I,A?.afterInsideRef),ae=At(),oe=At(),L=yn(),se=A!=null,R=fn(b),z=G((e=R)=>e?Gn(e):[]),B=G(()=>g?.().filter(e=>e!=null)??[]);o.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Z(R,X(q(R)))&&z().length===0&&!T&&Gt(e)}return $(q(R),`keydown`,e)},[r,R,c,T,z]),o.useEffect(()=>{if(r||!v)return;let e=q(R);function t(){te.current=!1}function n(e){let t=Q(e),n=B(),r=Z(b,t)||Z(y,t)||Z(A?.portalNode,t)||n.some(e=>e===t||Z(e,t));te.current=!r,P.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,oe.start(0,()=>{M.current=!1}))}function i(){P.current=`keyboard`}return pn($(e,`pointerdown`,n,!0),$(e,`pointerup`,t,!0),$(e,`pointercancel`,t,!0),$(e,`keydown`,i,!0),t)},[r,b,y,R,v,A,oe,B]),o.useEffect(()=>{if(r||!l)return;let e=q(R);function t(){M.current=!0,oe.start(0,()=>{M.current=!1})}function n(e){let t=Q(e);Un(t)&&(ne.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Q(t);c&&n==null&&i!=null&&Z(b,i)&&Vr(i),queueMicrotask(()=>{let a=C(),o=_.context.triggerElements,l=B(),u=n?.hasAttribute(rr(`focus-guard`))&&[F.current,I.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Ir(f),Ir(d)].includes(n),p=!(Z(y,n)||Z(b,n)||Z(n,b)||Z(A?.portalNode,n)||l.some(e=>e===n||Z(e,n))||o.hasMatchingElement(e=>Z(e,n))||u||k&&(tr(k.nodesRef.current,a).find(e=>Z(e.context?.elements.floating,n)||Z(e.context?.elements.domReference,n))||nr(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,fn(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===y&&R&&Wr(R),s&&r!==y&&!kn(i)&&X(e)===e.body){if(W(R)&&(R.focus(),s===`popup`)){L.request(()=>{R.focus()});return}let e=z(),t=ne.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||R;W(n)&&n.focus()}if(S.current.insideReactTree){S.current.insideReactTree=!1;return}(T||!c)&&n&&p&&!M.current&&(T||n!==Hr())&&(j.current=!0,_.setOpen(!1,J(mt,t)))})}function a(){te.current||(S.current.insideReactTree=!0,ae.start(0,()=>{S.current.insideReactTree=!1}))}let o=W(y)?y:null;if(b||o)return pn(o&&$(o,`focusout`,i),o&&$(o,`pointerdown`,t),b&&$(b,`focusin`,n),b&&$(b,`focusout`,i),b&&A&&$(b,`focusout`,a,!0))},[r,y,b,R,c,k,A,_,l,s,z,T,C,S,ae,oe,L,d,f,B]),o.useEffect(()=>{if(r||!b||!v)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${rr(`portal`)}]`)||[]),t=(k?nr(k.nodesRef.current,C()):[]).find(e=>un(e.context?.elements.domReference||null))?.context?.elements.domReference,n=_r([b,...e,F.current,I.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...B(),t,Ir(f),Ir(d),T?y:null].filter(e=>e!=null),{ariaHidden:c||T,mark:!1}),i=_r([b,...e].filter(e=>e!=null));return()=>{i(),n()}},[v,r,y,b,c,A,T,k,C,d,f,B]),K(()=>{if(!v||r||!W(R))return;N.current=``,P.current=``;let e=q(R),t=X(e);queueMicrotask(()=>{let n=ee.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||Z(R,t))return;let i=null,a=()=>(i??=z(R),i[0]||R),o;o=r===!0||r===null?a():Ir(r),o||=a();let s=Z(R,X(e));ar(o,{preventScroll:o===R,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=X(e);return!(t!==o&&Z(R,t))}})})},[r,v,R,z,ee,D,O]),K(()=>{if(r||!R)return;let e=q(R),t=X(e),n=D.current==null;Vr(t);function i(e){if(e.open||(N.current=Lr(e.nativeEvent,P.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(qt(e.nativeEvent)||Jt(e.nativeEvent))j.current=!1;else{let e=!1;q(R).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}x.on(`openchange`,i);function a(e){let r=E.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=y?.isConnected?y:null,o=t?.isConnected&&V(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Hr()||null,typeof i==`boolean`?s:Ir(i)||s||null}return()=>{x.off(`openchange`,i);let t=X(e),n=B(),r=Z(b,t)||n.some(e=>e===t||Z(e,t))||k&&tr(k.nodesRef.current,C(),!1).some(e=>Z(e.context?.elements.floating,t)),o=E.current,s=N.current,c=a(s);queueMicrotask(()=>{let n=Ur(c),i=typeof o!=`boolean`;if(o&&!j.current&&W(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,b,R,E,D,x,k,y,C,B]),K(()=>{if(!Ht||v||!b)return;let e=X(q(b));W(e)&&cn(e)&&Z(b,e)&&e.blur()},[v,b]),K(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:v,onOpenChange:_.setOpen,domReference:y}),()=>{A.setFocusManagerState(null)}},[r,A,c,v,_,l,y]),K(()=>{if(!r&&R)return Wr(R),()=>{queueMicrotask(Br)}},[r,R]);let ce=!r&&(!c||!T)&&(se||c);return(0,Y.jsxs)(o.Fragment,{children:[ce&&(0,Y.jsx)(Sn,{"data-type":`inside`,ref:re,onFocus:e=>{if(c){let e=z();ar(e[e.length-1])}else A?.portalNode&&(j.current=!1,Qn(e,A.portalNode)?qn(y)?.focus():Ir(f??A.beforeOutsideRef)?.focus())}}),n,ce&&(0,Y.jsx)(Sn,{"data-type":`inside`,ref:ie,onFocus:e=>{c?ar(z()[0]):A?.portalNode&&(l&&(j.current=!0),Qn(e,A.portalNode)?Jn(y)?.focus():Ir(d??A.afterOutsideRef)?.focus())}})]})}function Kr(){return!1}function qr(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Jr(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:s=Kr,bubbles:c,externalTree:l}=t,u=`rootStore`in e?e.rootStore:e,d=u.useState(`open`),f=u.useState(`floatingElement`),{dataRef:p,events:m}=u.context,h=Mr(l),g=G(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=G(()=>a),{escapeKey:b,outsidePress:x}=qr(c),S=o.useRef(!1),C=o.useRef(!1),w=o.useRef(!1),T=o.useRef(!1),ee=o.useRef(!1),E=o.useRef(``),D=o.useRef(null),O=At(),k=At(),A=G(()=>{k.clear(),p.current.insideReactTree=!1}),j=G(e=>{let t=p.current.floatingContext?.nodeId;return(h?tr(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=G(e=>on(e,u.select(`floatingElement`))||on(e,u.select(`domReferenceElement`))),te=G(e=>{s()&&u.setOpen(!1,J(ct,e.nativeEvent))}),ne=G(e=>{if(!d||!n||!r||e.key!==`Escape`||ee.current||!b&&j(`__escapeKeyBubbles`))return;let t=J(ht,Kt(e)?e.nativeEvent:e);u.setOpen(!1,t),t.isCanceled||e.preventDefault(),!b&&!t.isPropagationAllowed&&e.stopPropagation()}),N=G(()=>{p.current.insideReactTree=!0,k.start(0,A)}),P=G(e=>{if(!d||!n||e.button!==0)return;let t=Q(e.nativeEvent);Z(u.select(`floatingElement`),t)&&(S.current||(S.current=!0,C.current=!1))}),F=G(e=>{d&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&S.current&&(C.current=!0)});o.useEffect(()=>{function e(e){e.open||(T.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),o.useEffect(()=>{if(!d||!n)return d||(T.current=!1),A;p.current.__escapeKeyBubbles=b,p.current.__outsidePressBubbles=x;let e=new kt,t=new kt,i=q(f);function a(){e.clear(),ee.current=!0}function o(){e.start(Ht?5:0,()=>{ee.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){S.current=!1,C.current=!1}function l(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=y(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=l();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function g(e){let t=p.current.floatingContext?.nodeId,n=h&&tr(h.nodesRef.current,t).some(t=>on(e,t.context?.elements.floating));return M(e)||n}function k(e){if(m(e)){e.type!==`click`&&!M(e)&&(t.clear(),w.current=!1),A();return}if(p.current.insideReactTree){A();return}let n=Q(e),r=`[${rr(`inert`)}]`,i=U(n)?n.getRootNode():null,a=Array.from((je(i)?i:q(u.select(`floatingElement`))).querySelectorAll(r)),o=u.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Z(e,n))))return;let s=U(n)?n:null;for(;s&&!He(s);){let e=Ge(s);if(He(e)||!U(e))break;s=e}if(!(a.length&&U(n)&&!sn(n)&&!Z(n,u.select(`floatingElement`))&&a.every(e=>!Z(s,e)))){if(W(n)&&!(`touches`in e)){let t=He(n),r=Ue(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!g(e)){if(l()===`intentional`){if(e.detail!==0&&!qt(e)&&!T.current)return;if(w.current){t.clear(),w.current=!1;return}}(typeof _!=`function`||_(e))&&(j(`__outsidePressBubbles`)||(u.setOpen(!1,J(dt,e)),A()))}}}function te(e){l()===`sloppy`&&e.pointerType!==`touch`&&u.select(`open`)&&n&&!M(e)&&k(e)}function N(e){if(l()!==`sloppy`||!u.select(`open`)||!n||M(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function P(e,t){let n=Q(e);if(!n)return;let r=$(n,e.type,()=>{t(e),r()})}function F(e){E.current=`touch`,P(e,N)}function I(e){O.clear(),e.type===`pointerdown`&&(e.button===0&&(T.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&P(e,e=>{e.type===`pointerdown`?te(e):k(e)})}function re(e){if(e.type===`pointercancel`&&(T.current=!1),!S.current)return;let n=C.current;if(c(),l()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!g(e)){if(n){s();return}(typeof _!=`function`||_(e))&&(t.clear(),w.current=!0,A())}}}function ie(e){if(l()!==`sloppy`||!D.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(k(e),O.clear(),D.current=null)}function ae(e){P(e,ie)}function oe(e){l()===`sloppy`&&D.current&&!M(e)&&(D.current.dismissOnTouchEnd&&k(e),O.clear(),D.current=null)}function L(e){P(e,oe)}let se=pn(r&&pn($(i,`keydown`,ne),$(i,`compositionstart`,a),$(i,`compositionend`,o)),v&&pn($(i,`click`,I,!0),$(i,`pointerdown`,I,!0),$(i,`pointerup`,re,!0),$(i,`pointercancel`,re,!0),$(i,`mousedown`,I,!0),$(i,`mouseup`,re,!0),$(i,`touchstart`,F,{capture:!0,passive:!0}),$(i,`touchmove`,ae,{capture:!0,passive:!0}),$(i,`touchend`,L,{capture:!0,passive:!0})));return()=>{se(),e.clear(),t.clear(),c(),w.current=!1,A()}},[p,f,r,v,_,d,n,b,x,ne,A,y,j,M,h,u,O]);let I=o.useMemo(()=>({onKeyDown:ne,onPointerDown:te,onClick:te}),[ne,te]),re=o.useMemo(()=>({onKeyDown:ne,onPointerDown:F,onMouseDown:F,onClickCapture:N,onMouseDownCapture(e){N(),P(e)},onPointerDownCapture(e){N(),P(e)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[ne,N,P,F]);return o.useMemo(()=>n?{reference:I,floating:re,trigger:I}:{},[n,I,re])}var Yr=n((e=>{var n=t();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useState,o=n.useEffect,s=n.useLayoutEffect,c=n.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=n.useSyncExternalStore===void 0?f:n.useSyncExternalStore})),Xr=n(((e,t)=>{t.exports=Yr()})),Zr=n((e=>{var n=t(),r=Xr();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=n.useRef,c=n.useEffect,l=n.useMemo,u=n.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Qr=n(((e,t)=>{t.exports=Zr()})),$r=Xr(),ei=Qr(),ti=[],ni=void 0;function ri(){return ni}function ii(e){ti.push(e)}function ai(e){let t=(t,n)=>{let r=f(si).current,i;try{ni=r;for(let e of ti)e.before(r);i=e(t,n);for(let e of ti)e.after(r);r.didInitialize=!0}finally{ni=void 0}return i};return t.displayName=e.displayName||e.name,t}function oi(e){return o.forwardRef(ai(e))}function si(){return{didInitialize:!1}}var ci=b(19)?di:fi;function li(e,t,n,r,i){return ci(e,t,n,r,i)}function ui(e,t,n,r,i){let a=o.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,$r.useSyncExternalStore)(e.subscribe,a,a)}ii({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,$r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function di(e,t,n,r,i){let a=ri();if(!a)return ui(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function fi(e,t,n,r,i){return(0,ei.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var pi=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return li(this,e,t,n,r)}},mi=class extends pi{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){o.useDebugValue(e);let n=this;K(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;K(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;K(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){o.useDebugValue(e);let n=this,r=t!==void 0;K(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return o.useDebugValue(e),li(this,this.selectors[e],t,n,r)}useContextCallback(e,t){o.useDebugValue(e);let n=G(t??C);this.context[e]=n}useStateSetter(e){let t=o.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},hi={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},gi=class extends mi{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:Dr(),nested:n,triggerElements:i},hi),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Xt(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function _i(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:s}=e,c=t.useState(`open`),l=t.useState(`activeTriggerElement`),u=t.useState(n?`popupElement`:`positionerElement`),d=t.context.triggerElements,f=s,p=o.useRef(null);r===void 0&&p.current===null&&(p.current=new gi({open:c,transitionStatus:void 0,referenceElement:l,floatingElement:u,triggerElements:d,onOpenChange:f,floatingId:i,syncOnly:!0,nested:a}));let m=r??p.current;return t.useSyncedValue(`floatingId`,i),K(()=>{let e={open:c,floatingId:i,referenceElement:l,floatingElement:u};U(l)&&(e.domReferenceElement=l),m.state.positionReference===m.state.referenceElement&&(e.positionReference=l),m.update(e)},[c,i,l,u,m]),m.context.onOpenChange=f,m.context.nested=a,m}function vi(e,t=!1,n=!1,r=!1){let[i,a]=o.useState(e&&t?`idle`:void 0),[s,c]=o.useState(e&&!r);return e&&!s&&(c(!0),a(`starting`)),!e&&s&&i!==`ending`&&!n&&a(`ending`),!e&&!s&&i===`ending`&&a(void 0),K(()=>{if(!e&&s&&i!==`ending`&&n){let e=vn.request(()=>{a(`ending`)});return()=>{vn.cancel(e)}}},[e,s,i,n]),K(()=>{if(!e||t)return;let n=vn.request(()=>{a(void 0)});return()=>{vn.cancel(n)}},[t,e]),K(()=>{if(!e||!t)return;e&&s&&i!==`idle`&&a(`starting`);let n=vn.request(()=>{a(`idle`)});return()=>{vn.cancel(n)}},[t,e,s,i]),{mounted:s,setMounted:c,transitionStatus:i}}var yi=null;function bi(e){if(!yi){let e=[];yi=e,queueMicrotask(()=>{yi=null,xt.flushSync(()=>{for(let t of e)t()})})}yi.push(e)}function xi(e,t=!1,n=!1){let r=yn();return G((i,a=null)=>{r.cancel();let o=Ir(e);if(o==null)return;let s=o,c=()=>{if(!n){xt.flushSync(i);return}bi(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=ue;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function Si(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,s=G(a),c=xi(r,n,i);o.useEffect(()=>{if(!t)return;let e=new AbortController;return c(s,e.signal),()=>{e.abort()}},[t,n,s,c])}var Ci={tabIndex:-1,[Zt]:``};function wi(e){return t=>t!==`touch`||e.current}function Ti(e,t=!1){let n=Tt(),r=jr()!=null,i=f(()=>e(n,r)).current;return _i({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Ei({handle:e,store:t}){return K(()=>e.attachStore(t),[e,t]),null}function Di(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Oi(e,t){let n=o.useRef(null);return G(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Di(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Di(t))})}function ki(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function Ai(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function ji(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Oi(e,n),o=G(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=G(e=>{a(e),e&&o(e)});return K(()=>(s(t.current),()=>s(null)),[s,t,n,e]),K(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Mi(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=o.useRef(null),i=e.useState(`open`);K(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=J(st);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Ni(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=vi(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=G(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Si({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Pi(e,t){e.useSyncedValues(t),K(()=>()=>{e.update({activeTriggerProps:T,inactiveTriggerProps:T,popupProps:T})},[e])}function Fi(e,t){K(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),K(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Ii=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Li(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new gi({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:T,inactiveTriggerProps:T,popupProps:T}}var Ri=e=>e.triggerIdProp??e.activeTriggerId,zi=e=>e.openProp??e.open,Bi=e=>(e.popupElement?.id??e.floatingId)||void 0;function Vi(e,t){return t!==void 0&&zi(e)&&Ri(e)===t}function Hi(e,t){return Vi(e,t)?!0:t!==void 0&&zi(e)&&Ri(e)==null&&e.triggerCount===1}var Ui={open:zi,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Ri,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Bi,isTriggerActive:(e,t)=>t!==void 0&&Ri(e)===t,isOpenedByTrigger:(e,t)=>Vi(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Ri(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Hi(e,t)?Bi(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},Wi=o.createContext(void 0);function Gi(){let e=o.useContext(Wi);if(e===void 0)throw Error(c(26));return e}var Ki=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),qi=`--nested-dialogs`,Ji=`data-nested-dialog-open`,Yi={...Te,...me,nestedDialogOpen(e){return e?{[Ji]:``}:null}},Xi=o.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=u(),l=c.useState(`descriptionElementId`),d=c.useState(`disablePointerDismissal`),f=c.useState(`floatingRootContext`),p=c.useState(`popupProps`),m=c.useState(`modal`),h=c.useState(`mounted`),g=c.useState(`nested`),_=c.useState(`nestedOpenDialogCount`),v=c.useState(`open`),y=c.useState(`openMethod`),b=c.useState(`titleElementId`),x=c.useState(`transitionStatus`),S=c.useState(`role`),C=f.useState(`floatingId`);Gi(),Si({open:v,ref:c.context.popupRef,onComplete(){v&&c.context.onOpenChangeComplete?.(!0)}});let w=o===void 0?wi(c.context.popupRef):o,T=_>0,ee=c.useStateSetter(`popupElement`),E=L(`div`,e,{state:{open:v,nested:g,transitionStatus:x,nestedDialogOpen:T},props:[p,{id:C,"aria-labelledby":b,"aria-describedby":l,role:S,...Ci,hidden:!h,onKeyDown(e){Ki.has(e.key)&&e.stopPropagation()},style:{[qi]:_}},s],ref:[t,c.context.popupRef,ee],stateAttributesMapping:Yi});return(0,Y.jsx)(Gr,{context:f,openInteractionType:y,disabled:!h,closeOnFocusOut:!d,initialFocus:w,returnFocus:a,modal:m!==!1,restoreFocus:`popup`,children:E})});function Zi(e){return b(19)?e:e?`true`:void 0}var Qi=o.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Y.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),$i=o.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=u(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Y.jsx)(Wi.Provider,{value:n,children:(0,Y.jsxs)(Er,{ref:t,...r,children:[a&&o===!0&&(0,Y.jsx)(Qi,{ref:i.context.internalBackdropRef,inert:Zi(!s)}),e.children]})}):null}),ea={},ta={},na=``;function ra(e,t){return Me(e)?e:t}function ia(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ra(t,n)).overflowY)}function aa(e){if(typeof document>`u`)return!1;let t=q(e);return H(t).innerWidth-t.documentElement.clientWidth>0}function oa(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=q(e),n=t.documentElement,r=t.body,i=ra(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function sa(e){let t=q(e),n=t.documentElement,r=t.body,i=ra(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function ca(e){let t=q(e),n=t.documentElement,r=t.body,i=H(n),a=0,o=0,s=!1,c=vn.create();if(Ht&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,ea={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},na=n.style.scrollBehavior,ta={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=ra(n,r);if(s=oa(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,ea),Object.assign(r.style,ta),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=na)}function d(){u(),c.request(l)}l();let f=$(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var la=new class{lockCount=0;restore=null;timeoutLock=kt.create();timeoutUnlock=kt.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=q(e),n=t.documentElement,r=t.body,i=H(n);if(ia(i,n,r)){let t=new i.MutationObserver(()=>{ia(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Lt||!aa(e);this.restore=a?sa(e):ca(e)}};function ua(e=!0,t=null){K(()=>{if(e)return la.acquire(t)},[e,t])}function da({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=o.useState(0),[d,f]=o.useState(0),p=l===0,m=Jr(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Q(t);if(p&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Z(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return ua(r&&a===!0,s),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{u(e),f(t)}),K(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(l+1,d+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Pi(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var fa={...Ui,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},pa=class extends mi{constructor(e,t,n){let r=new Ii,i=ma(e,r,t,n);super(i,ha(r),fa)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(ki(this.state,e,t.trigger)))}};function ma(e,t,n,r=!1){return{...Li(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function ha(e){return{popupRef:o.createRef(),backdropRef:o.createRef(),internalBackdropRef:o.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function ga(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:s,disablePointerDismissal:c=!1,modal:d=!0,actionsRef:f,handle:p,triggerId:m,defaultTriggerId:h=null}=t,g=e===`drawer`,_=e===`alert-dialog`,v=_?!0:d,y=_||c,b=_?`alertdialog`:`dialog`,x=u(!0),S={modal:v,disablePointerDismissal:y,nested:x!=null,role:b},C=Ti((e,t)=>new pa({open:i,openProp:r,activeTriggerId:h,triggerIdProp:m,...S},e,t),!0);C.useControlledProp(`openProp`,r),C.useControlledProp(`triggerIdProp`,m),C.useSyncedValues(S),C.useContextCallback(`onOpenChange`,a),C.useContextCallback(`onOpenChangeComplete`,s);let w=C.useState(`open`),T=C.useState(`mounted`),ee=C.useState(`payload`);Fi(C,w),Mi(C);let{forceUnmount:E}=Ni(w,C);o.useImperativeHandle(f,()=>({unmount:E,close:()=>C.setOpen(!1,J(yt))}),[E,C]);let D=w||T;return(0,Y.jsxs)(l.Provider,{value:C,children:[p&&(0,Y.jsx)(Ei,{handle:p,store:C}),D&&(0,Y.jsx)(da,{store:C,parentContext:x?.context,isDrawer:g}),typeof n==`function`?n({payload:ee}):n]})}var _a=ai(function(e){return ga(`dialog`,e)}),va=o.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=u(),c=Et(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),L(`h2`,e,{ref:t,props:[{id:c},o]})});export{yn as $,We as $t,Fr as A,J as At,rr as B,lt as Bt,mi as C,a as Cn,Bt as Ct,Jr as D,Et as Dt,Xr as E,Dt as Et,Er as F,ft as Ft,Qn as G,tt as Gt,qn as H,it as Ht,vr as I,gt as It,wn as J,Ue as Jt,En as K,K as Kt,yr as L,dt as Lt,jr as M,ht as Mt,Mr as N,mt as Nt,Gr as O,Tt as Ot,Or as P,yt as Pt,Sn as Q,V as Qt,br as R,vt as Rt,_i as S,c as Sn,Lt as St,oi as T,At as Tt,Xn as U,rt as Ut,tr as V,ct as Vt,Zn as W,q as Wt,Cn as X,ke as Xt,kn as Y,Be as Yt,Dn as Z,Je as Zt,Ni as _,w as _n,qt as _t,Qi as a,W as an,an as at,Si as b,p as bn,Wt as bt,Ki as c,Ne as cn,dn as ct,Ii as d,De as dn,en as dt,qe as en,mn as et,Ci as f,Te as fn,tn as ft,Mi as g,k as gn,Yt as gt,ki as h,L as hn,Q as ht,$i as i,U as in,ln as it,Nr as j,_t as jt,Pr as k,bt as kt,Li as l,Pe as ln,nn as lt,Ai as m,we as mn,Z as mt,_a as n,H as nn,$ as nt,Zi as o,He as on,un as ot,Ei as p,Ee as pn,X as pt,Tn as q,G as qt,ua as r,ze as rn,fn as rt,Xi as s,Me as sn,cn as st,va as t,Ge as tn,pn as tt,Ui as u,Ve as un,$t as ut,Pi as v,T as vn,Jt as vt,ai as w,kt as wt,xi as x,f as xn,Ht as xt,ji as y,C as yn,Gt as yt,ar as z,ut as zt};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{D as r,i,n as a,t as o}from"./translate-CLoII3EO.js";import{W as s}from"./index-DNw59Qsn.js";var c=e(t(),1);function l(e,t){return t===0||e-t>=15.666666666666668}function u(e,t,n){return!e&&t<=.12?n+1:0}function d(e,t){return e?0:t+1}function f(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function p(e,t,n){return e>=2&&(t>=8||n>=300)}function m(e,t){return!e||Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5}var h=18,g=42,ee=5,_=270,v=500,y=2,b=.035;function te(e){let t=window.getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{paperTop:n(`--console-surface`,`white`),paperBottom:n(`--console-surface-sunken`,`whitesmoke`),ink:n(`--console-text`,`black`),inkMuted:n(`--console-text-secondary`,`dimgray`),line:n(`--console-border-strong`,`silver`),shadow:n(`--scrim`,`gray`)}}function ne(e){return window.getComputedStyle(e).getPropertyValue(`--font-mono`).trim()||`monospace`}function x(e){return Math.round(e??0).toLocaleString(i())}function S(e){return`$${(e??0).toFixed(4)}`}function C(e){return new Date(e).toLocaleString(i(),{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function w(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function T(e){let t=e||1;return()=>(t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296)}function E(e,t,n,r,i){let a=t.toUpperCase(),o=n.toUpperCase();e.fillText(a,18,r),e.fillText(o,i-18-e.measureText(o).width,r)}function D(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}...`).width>n;)r=r.slice(0,-1);return`${r}...`}function O(e,t,n,r){let i=t.toUpperCase().split(/\s+/).filter(Boolean),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n){o=i;continue}if(o?(a.push(o),o=t):(a.push(D(e,t,n)),o=``),a.length===r)break}return a.length<r&&o&&a.push(o),a.length>0&&a.length===r&&(a[a.length-1]=D(e,a[a.length-1]??``,n)),a.slice(0,r)}function re(e,t,n){let r=document.createElement(`canvas`);r.width=_*y,r.height=v*y;let i=r.getContext(`2d`);if(!i)return r;i.scale(y,y);let a=e=>`${e} ${n}`,s=i.createLinearGradient(0,0,_,v);s.addColorStop(0,t.paperTop),s.addColorStop(1,t.paperBottom),i.fillStyle=s,i.fillRect(0,0,_,v);let c=T(w(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=b*(.12+c()*.14),i.fillRect(c()*_,c()*v,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,_/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(D(i,e.subtitle.toUpperCase(),234),_/2,51),i.strokeStyle=t.line,i.lineWidth=1,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,66),i.lineTo(252,66),i.stroke(),i.setLineDash([]),i.textAlign=`left`,i.fillStyle=t.ink,i.font=a(`11px`),E(i,o(`Agent`),e.agent,88,_),E(i,o(`Updated`),C(e.updatedAt),104,_),E(i,o(`Session`),`#${e.id.slice(0,8)}`,120,_),i.setLineDash([2,3]),i.beginPath(),i.moveTo(18,140),i.lineTo(252,140),i.stroke(),i.setLineDash([]),i.font=a(`700 12px`),i.fillText(o(`SESSION TOC RECEIPT LIST`),18,163),i.font=a(`11px`);let l=185;for(let t of e.items){let e=x(t.count);i.fillText(D(i,t.label,168),18,l),i.fillText(e,252-i.measureText(e).width,l),l+=17}return i.strokeStyle=t.line,i.lineWidth=1.5,i.beginPath(),i.moveTo(18,l+5),i.lineTo(252,l+5),i.stroke(),l+=26,E(i,o(`Input tokens`),x(e.inputTokens),l,_),l+=16,E(i,o(`Output tokens`),x(e.outputTokens),l,_),l+=16,E(i,o(`Messages`),x(e.messageCount),l,_),l+=22,i.font=a(`700 13px`),E(i,o(`TOTAL COST`),S(e.totalCost),l,_),i.strokeStyle=t.line,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,l+18),i.lineTo(252,l+18),i.stroke(),i.setLineDash([]),i.font=a(`10px`),i.textAlign=`center`,i.fillStyle=t.inkMuted,O(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,_/2,l+38+t*13)}),r}function k(e,t){return e*h+t}function A(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=r+t*a,c=i+e*o;s.push({x:n,y:c,oldX:n,oldY:c,fixedX:e===0?n:null,fixedY:e===0?c:null})}let l=(e,t,n)=>{let r=s[e],i=s[t];r&&i&&c.push({a:e,b:t,length:Math.hypot(i.x-r.x,i.y-r.y),stiffness:n})};for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=k(e,t);t<17&&l(n,k(e,t+1),.98),e<41&&l(n,k(e+1,t),.92),e<41&&t<17&&(l(n,k(e+1,t+1),.46),l(k(e+1,t),k(e,t+1),.46)),t<16&&l(n,k(e,t+2),.35),e<40&&l(n,k(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function ie(e,t){let n=t.receiptWidth/17;for(let r=0;r<h;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function j(e){for(let t=0;t<h;t+=1){let n=e[t];n&&n.fixedX!=null&&n.fixedY!=null&&(n.x=n.fixedX,n.y=n.fixedY,n.oldX=n.fixedX,n.oldY=n.fixedY)}}function ae(e,t){let n=e[t.a],r=e[t.b];if(!n||!r)return;let i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<1e-4)return;let s=(o-t.length)/o*t.stiffness,c=n.fixedX!=null&&n.fixedY!=null,l=r.fixedX!=null&&r.fixedY!=null,u=c?0:l?1:.5,d=l?0:c?1:.5,f=i*s,p=a*s;c||(n.x+=f*u,n.y+=p*u),l||(r.x-=f*d,r.y-=p*d)}function M(e,t,n,r,i,a){let o=r[k(i,a)],s=r[k(i,a+1)],c=r[k(i+1,a)],l=r[k(i+1,a+1)];if(!o||!s||!c||!l)return;let u=a/17*t.width,d=i/41*t.height,f=t.width/17,p=t.height/41;e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.clip(),e.transform((s.x-o.x)/f,(s.y-o.y)/f,(c.x-o.x)/p,(c.y-o.y)/p,o.x,o.y),e.drawImage(t,u,d,f+1,p+1,0,0,f+1,p+1),e.restore();let m=Math.atan2(s.y-o.y,s.x-o.x),h=Math.hypot(c.x-o.x,c.y-o.y)/(v/41),g=Math.sin(m)*.08+(h-1)*.16;Math.abs(g)<.01||(e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.globalAlpha=Math.abs(g),e.fillStyle=g>0?n.paperTop:n.shadow,e.fill(),e.restore())}function N(e,t,n){let r=null,i=44;for(let a=h;a<e.length;a+=1){let o=e[a];if(!o)continue;let s=Math.hypot(o.x-t,o.y-n);s<i&&(i=s,r=a)}return r}function oe(e){let t=0;for(let n=h;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function P({canvas:e,anchor:t,hitSurface:n,payload:r,minWidthQuery:i}){let a=e.getContext(`2d`,{alpha:!0});if(!a)return null;let o=r,s={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},c=null,g=!1,y=0,b=0,x=0,S=A({receiptWidth:_,receiptHeight:v,startX:0,startY:32}),C=performance.now(),w=null,T=0,E=0,D=0,O=0,k=!1,P=!1,F=window.matchMedia(i),I=window.matchMedia(`(prefers-reduced-motion: reduce)`),L=()=>c!=null&&F.matches&&document.visibilityState===`visible`,R=()=>{let e=te(t);c={texture:re(o,e,ne(t)),palette:e}},z=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(_,n-34);return{receiptWidth:r,receiptHeight:Math.min(v,Math.max(320,x-42)),startX:(n-r)/2,startY:32}},B=t=>{k!==t&&(k=t,e.style.visibility=t?`visible`:`hidden`,n.style.visibility=t&&!I.matches?`visible`:`hidden`)},V=()=>{P=!1,y&&=(window.cancelAnimationFrame(y),0),B(!1)},H=(e,t=performance.now())=>{S=A(e),w=e,C=t},U=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();b=Math.max(1,r.width),x=Math.max(1,r.height),e.width=Math.floor(b*n),e.height=Math.floor(x*n),a.setTransform(n,0,0,n,0,0),T=0,E=0,D=0,O=0,B(!1),H(z()),L()&&W()},W=()=>{!P&&L()&&(P=!0,y=window.requestAnimationFrame(Z))},G=()=>{L()?U():V()},K=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},q=e=>{if(e.button!==0||I.matches)return;let t=K(e),r=N(S.particles,t.x,t.y);r!=null&&(e.preventDefault(),n.setPointerCapture(e.pointerId),s.id=e.pointerId,s.x=t.x,s.y=t.y,s.prevX=t.x,s.prevY=t.y,s.vx=0,s.vy=0,s.grabbedIndex=r,E=0,D=0,W())},J=e=>{if(s.id!==e.pointerId)return;let t=K(e);s.vx=t.x-s.prevX,s.vy=t.y-s.prevY,s.prevX=t.x,s.prevY=t.y,s.x=t.x,s.y=t.y},Y=e=>{if(s.id!==e.pointerId)return;let t=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];t&&(t.oldX=t.x-s.vx*.9,t.oldY=t.y-s.vy*.9),s.id=null,s.grabbedIndex=null},se=e=>{let t=(e-C)/1e3;for(let e=h;e<S.particles.length;e+=1){let n=S.particles[e];if(!n)continue;let r=(n.x-n.oldX)*.985,i=(n.y-n.oldY)*.985;n.oldX=n.x,n.oldY=n.y,n.x+=r+Math.sin(t*1.7+e*.19)*.018,n.y+=i+.22}let n=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];n&&(n.x+=(s.x-n.x)*.72,n.y+=(s.y-n.y)*.72)},ce=()=>{for(let e=0;e<ee;e+=1){j(S.particles);for(let e of S.constraints)ae(S.particles,e)}j(S.particles)},le=()=>{let e=1/0,t=1/0,r=-1/0,i=-1/0;for(let n of S.particles)e=Math.min(e,n.x),t=Math.min(t,n.y),r=Math.max(r,n.x),i=Math.max(i,n.y);n.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,n.style.width=`${r-e+40}px`,n.style.height=`${i-t+40}px`},ue=e=>{let t=S.particles[0],n=S.particles[17],r=S.particles[755],i=S.particles[738];t&&n&&r&&i&&(a.save(),a.shadowColor=e.shadow,a.shadowBlur=24,a.shadowOffsetY=16,a.fillStyle=e.shadow,a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(n.x,n.y),a.lineTo(r.x,r.y),a.lineTo(i.x,i.y),a.closePath(),a.fill(),a.restore())},de=e=>{let t=S.particles[0],n=S.particles[17];t&&n&&(a.save(),a.strokeStyle=e.ink,a.lineWidth=4,a.lineCap=`round`,a.beginPath(),a.moveTo(t.x-10,t.y-3),a.lineTo(n.x+10,n.y-3),a.stroke(),a.strokeStyle=e.paperTop,a.lineWidth=1,a.beginPath(),a.moveTo(t.x-8,t.y-5),a.lineTo(n.x+8,n.y-5),a.stroke(),a.restore())},X=()=>{if(c){a.clearRect(0,0,b,x),ue(c.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)M(a,c.texture,c.palette,S.particles,e,t);de(c.palette),le()}},Z=e=>{if(!P)return;if(!L()){V();return}if(!l(e,O)){y=window.requestAnimationFrame(Z);return}O=e;let t=z();m(w,t)&&s.id==null?(T=0,B(!1),H(t,e)):(T+=1,w=t),ie(S.particles,t),I.matches||(se(e),ce()),X();let n=s.id!=null;E=u(n,oe(S.particles),E),D=d(n,D);let r=I.matches;if((r||T>=2)&&B(!0),r||p(T,E,D)){r||(H(t,e),X()),P=!1,y=0;return}y=window.requestAnimationFrame(Z)};B(!1),f().then(()=>{g||(R(),G())});let Q=new ResizeObserver(U);Q.observe(t);let $=new MutationObserver(()=>{R(),X()});return $.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),F.addEventListener(`change`,G),I.addEventListener(`change`,G),document.addEventListener(`visibilitychange`,G),window.addEventListener(`resize`,G),n.addEventListener(`pointerdown`,q),n.addEventListener(`pointermove`,J),n.addEventListener(`pointerup`,Y),n.addEventListener(`pointercancel`,Y),{updatePayload(e){o=e,!g&&c&&(R(),X())},destroy(){g||(g=!0,V(),Q.disconnect(),$.disconnect(),F.removeEventListener(`change`,G),I.removeEventListener(`change`,G),document.removeEventListener(`visibilitychange`,G),window.removeEventListener(`resize`,G),n.removeEventListener(`pointerdown`,q),n.removeEventListener(`pointermove`,J),n.removeEventListener(`pointerup`,Y),n.removeEventListener(`pointercancel`,Y))}}}var F=n();function I(e){let t=[{label:o(`User`),count:e.counts.user},{label:o(`Agent Responses`),count:e.counts.agent_message},{label:o(`Thinking`),count:e.counts.thinking},{label:o(`Plans`),count:e.counts.plan},{label:o(`Tools`),count:e.counts.tools_all}].filter(e=>e.count>0),n=e.tools.map(e=>({label:e.label,count:e.count})),r=Math.max(0,9-t.length),i=n.length>r?n.slice(0,Math.max(0,r-1)):n,a=n.slice(i.length).reduce((e,t)=>e+t.count,0);return a>0&&i.push({label:o(`Other tools`),count:a}),[...t,...i].slice(0,9)}function L(e){return!e||e.length===0?o(`SESSION ACTIVITY RECEIPT`):e.map(e=>o(e)).join(` / `)}function R(e,t){return{id:e.reference.sessionId,title:s(e)||o(`Untitled session`),agent:r(e),updatedAt:e.time_updated??e.time_created,subtitle:L(e.smart_tags),inputTokens:e.stats.total_input_tokens??0,outputTokens:e.stats.total_output_tokens??0,messageCount:e.stats.message_count??0,totalCost:e.stats.total_cost??0,items:I(t)}}function z({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=a(),i=(0,c.useRef)(null),s=(0,c.useRef)(null),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useMemo)(()=>R(e,t),[r,e,t]),f=(0,c.useRef)(d);return(0,c.useLayoutEffect)(()=>{let e=i.current,t=s.current,r=l.current;if(!e||!t||!r)return;let a=P({canvas:e,anchor:t,hitSurface:r,payload:f.current,minWidthQuery:n});return u.current=a,()=>{a?.destroy(),u.current===a&&(u.current=null)}},[n]),(0,c.useLayoutEffect)(()=>{f.current=d,u.current?.updatePayload(d)},[d]),(0,F.jsxs)(`div`,{ref:s,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,F.jsx)(`canvas`,{ref:i,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{ref:l,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":o(`Interactive thermal receipt with Verlet paper simulation`)})]})}export{z as InteractiveReceipt};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,f as i,l as a,o,t as s}from"./CustomTimeWindowDialog-z5xtqkBF.js";import{n as c,t as l}from"./translate-CLoII3EO.js";import{H as u,J as d,K as f,Q as p,Y as m,at as h,et as g,it as _,tt as v}from"./index-DNw59Qsn.js";import{t as y}from"./utils-Dk_44zMo.js";import{n as b,t as x}from"./panel-DcOuALYX.js";var S=e(t(),1);function C(e,t){let n=e!==null,r=i({...a(e??{},t),enabled:n}),o=r.refetch,s=(0,S.useCallback)(async()=>{await o()},[o]);return{dashboard:n?r.data??null:null,loading:n&&r.isPending,error:n&&r.isError?r.error instanceof Error?r.error.message:l(`Unable to load dashboard.`):null,retry:s}}var w=n();function T({index:e,count:t,position:n=(e+.5)/t*100,children:r}){return(0,w.jsx)(`div`,{role:`tooltip`,className:`console-mono pointer-events-none absolute top-2 z-10 w-max max-w-full rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] break-words text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,style:{left:`${n}%`,transform:`translateX(-${n}%)`},children:r})}var E=Math.PI*2;function D(e){return e<0?0:e>1?1:e}function O(e){let t=D(e);return t*t*(3-2*t)}function k(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function A(e,t,n){return O((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function j(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var M=/^var\((--[\w-]+)\)$/;function N(e,t){let n=M.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function P(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var F=50;function ee(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{e&&t!==null&&!n&&(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},F))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function I(e,t){let[n]=(0,S.useState)(ee);return(0,S.useEffect)(()=>{let r=e.current;if(!r||t){n.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>n.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(r),document.addEventListener(`visibilitychange`,s),o(),()=>{n.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[n,t,e]),n.api}var te=2,L=5,ne=8,re=7,ie=620,ae=.05,oe=.8,se=.0018,ce=.3,le=.48,ue={barRatio:.62,barMax:76,bandGap:4,minBand:6};function de(e,t,n){let r=Math.max(1,t-1),i=Math.min(ae,oe/r),a=1-(t-1)*i;return 1-(1-D((n-e*i)/a))**3}function fe(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:s,reducedMotion:c}){let l=(0,S.useContext)(o),u=I(e,c),d=r.join(`\0`),f=(0,S.useRef)({values:t,axisMax:n,hovered:a,layout:s}),p=(0,S.useRef)(new Map),m=(0,S.useRef)(new Map),h=(0,S.useRef)({startedAt:0,running:!1}),g=(0,S.useRef)({w:0,h:0}),_=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{f.current={values:t,axisMax:n,hovered:a,layout:s},c?_.current():u.requestFrame()},[n,u,a,s,c,t]),(0,S.useEffect)(()=>{m.current=new Map(p.current),c?(h.current.running=!1,_.current()):(h.current={startedAt:performance.now(),running:!0},u.requestFrame())},[n,u,c,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(d?d.split(`\0`):[]).map(e=>N(a,e)),s=N(a,i),l=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(te,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),g.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!h.current.running)return 1;let r=D((n-h.current.startedAt)/ie);return r>=1&&(h.current.running=!1),de(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?ne:L,l?ne:L,u?re:L,u?re:L],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=O(1-(e-t)/i),o=A(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*k(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*se;let{w:t,h:n}=g.current;if(!t||!n)return;let i=f.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){h.current.running=!1;return}let{barRatio:a,barMax:c,bandGap:l,minBand:u}=i.layout,d=i.values.length,_=t/d,x=Math.min(_*a,c),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,d,e),a=r*_+(_-x)/2,c=n;t.forEach((e,n)=>{let d=`${r}:${n}`,f=e>0?Math.max(u,e*C):0,h=m.current.get(d)??0,g=h+(f-h)*i;p.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:le:ce;g>0&&b(a,c-g,x,g,o[n]??o[0]??s,s,v,_,n===t.length-1,n===0,S),c-=g+l})})};_.current=()=>{l(),x(performance.now())},u.setFrameHandler(e=>(x(e),h.current.running?`active`:f.current.hovered===null?`stop`:`idle`)),l();let S=new ResizeObserver(()=>{l(),c?x(performance.now()):u.requestFrame()});return S.observe(n),c&&x(performance.now()),()=>{u.setFrameHandler(null),S.disconnect()}},[e,d,u,i,c,l]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=g.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=f.current,d=l.length,m=i/d,h=Math.floor(s/m);if(h<0||h>=d)return null;let _=Math.min(m*u.barRatio,u.barMax),v=h*m+(m-_)/2;if(s<v||s>v+_)return{column:h,band:null};let y=a;for(let e=0;e<l[h].length;e++){let t=p.current.get(`${h}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:h,band:e};y-=t+u.bandGap}return{column:h,band:null}}}}var pe=`(prefers-reduced-motion: reduce)`;function R(){let[e,t]=(0,S.useState)(()=>globalThis.matchMedia?.(pe).matches??!1);return(0,S.useEffect)(()=>{let e=globalThis.matchMedia?.(pe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function me(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function he({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,S.useRef)([]),[o,s]=(0,S.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=me(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:y(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,w.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:y(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,w.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var ge=[1,.75,.5,.25,0];function _e(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function ve({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:d}){let f=(0,S.useRef)(null),p=(0,S.useRef)(i),m=R(),{hitTest:h}=fe(f,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...ue,...o},reducedMotion:m});(0,S.useEffect)(()=>{p.current=i},[i]);let g=e=>{_e(p.current,e)||(p.current=e,a(e))};return(0,w.jsxs)(`div`,{className:y(`flex`,d),children:[c?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:ge.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>g(h(e.clientX,e.clientY)),onPointerLeave:()=>g(null),children:[ge.map(e=>(0,w.jsx)(`span`,{"aria-hidden":!0,className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,w.jsx)(`canvas`,{ref:f,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,w.jsx)(he,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>g(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var z=6,ye=118,be={barRatio:.52,barMax:34,bandGap:0,minBand:4},xe=[`var(--brand)`];function Se({perAgent:e}){let t=c(),[n,r]=(0,S.useState)(null),{byCost:i,visible:a,values:o,axisMax:s,itemLabels:d}=(0,S.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,z),i=r.map(e=>[n(e)]),a=r.map(e=>t?l(`{0}: {1}, {2} sessions`,[e.displayName,_(e.cost),m(e.sessions)]):l(`{0}: {1} sessions`,[e.displayName,m(e.sessions)]));return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:a}},[t,e]),p=n===null?void 0:a[n.column];return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Agents`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Agents`),meta:l(`{0} · {1} total`,[l(i?`by cost`:`by sessions`),e.length])}),a.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No data`)}):(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:o,axisMax:s,colors:xe,hovered:n,onHover:r,layout:be,height:ye,ariaLabel:l(`Agent distribution chart`),itemLabels:d}),p&&n?(0,w.jsxs)(T,{index:n.column,count:a.length,children:[(0,w.jsx)(`div`,{children:p.displayName}),(0,w.jsxs)(`div`,{children:[f(p.tokens),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:_(p.cost)})]}),(0,w.jsxs)(`div`,{children:[m(p.sessions),` `,l(`sessions ·`),` `,m(p.messages),` `,l(`messages`)]})]}):null,(0,w.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((e,t)=>(0,w.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,w.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,w.jsx)(u,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,w.jsx)(`span`,{className:y(`console-mono max-w-full truncate text-[9.5px]`,n?.column===t?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:i?_(e.cost):m(e.sessions)}),i?(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:m(e.sessions)}):null]},e.name))})]}),e.length>z?(0,w.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-z,` `,l(`more`)]}):null]})}function Ce(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return`oklch(0.65 0.16 ${(t>>>0)%360})`}function we(e,t){let n=e.filter(e=>e.tokens>0).toSorted((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>({key:e.model,label:e.model,value:e.tokens,color:Ce(e.model),display:f(e.tokens)})),i=n.slice(5).reduce((e,t)=>e+t.tokens,0);i>0&&r.push({key:`__other`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:f(i)});let a=t-n.reduce((e,t)=>e+t.tokens,0);return a>0&&r.push({key:`__unknown`,label:l(`Unknown model`),value:a,color:`var(--console-muted)`,display:f(a)}),r}var B=200,V=100,H=100,U=86,W=55,Te=-Math.PI/2,Ee=.07,De=6,G=4.6,Oe=2,ke=.0018,Ae=500,je=6,Me=.72,Ne=.3,Pe=(()=>{let e=[];for(let t=14;t<=186;t+=G)for(let n=14;n<=186;n+=G){let r=t-V,i=n-H,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*O((a-W)/31),jitter:k(t,n)})}return e})();function Fe(e,{a0:t,a1:n}){let r=n-t,i=Math.min(De,31*.45,W*r*.45),a=i/U,o=i/W,s=(e,t)=>[V+Math.cos(t)*e,H+Math.sin(t)*e],[c,l]=s(U,t+a);e.beginPath(),e.moveTo(c,l),e.arc(V,H,U,t+a,n-a),e.arcTo(...s(U,n),...s(W,n),i),e.arcTo(...s(W,n),...s(W,n-o),i),e.arc(V,H,W,n-o,t+o,!0),e.arcTo(...s(W,t),...s(U,t),i),e.arcTo(...s(U,t),c,l,i),e.closePath()}function Ie(e){let t=Te;return e.map(e=>{let n=e*E,r={a0:t+Ee/2,a1:t+n-Ee/2};return t+=n,r})}function Le(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,S.useContext)(o),s=I(e,i),c=n.join(`\0`),l=(0,S.useRef)(r),u=(0,S.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),d=(0,S.useRef)(Ie(t)),f=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{let e=u.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,f.current()):(e.startedAt=performance.now(),e.running=!0,s.requestFrame())},[s,i,t]),(0,S.useEffect)(()=>{l.current=r,i?f.current():s.requestFrame()},[s,r,i]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(c?c.split(`\0`):[]).map(e=>N(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(Oe,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/B*r},h=0,g=e=>{let t=u.current;if(!t.running)return;let n=D((e-t.startedAt)/Ae),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*je,Math.sin(n)*je),r.shadowColor=P(e,.55),r.shadowBlur=5}Fe(r,t),r.clip(),r.globalAlpha=i?n?1:Ne*Me:Me,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of Pe){let t=e.angle;for(;t<o;)t+=E;for(;t>=o+E;)t-=E;if(t>s)continue;let n=A(e.x,e.y,h),i=G*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*ke,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,B,B);let t=Ie(u.current.displayed);d.current=t;let n=l.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(o[t]??o[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(o[n]??``,a,!0,!0)};f.current=()=>{m(),v(performance.now())},s.setFrameHandler(e=>(g(e),v(e),u.current.running?`active`:l.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):s.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{s.setFrameHandler(null),y.disconnect()}},[e,c,s,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*B-V,o=(n-i.top)/i.height*B-H,s=Math.hypot(a,o);if(s<W||s>U)return null;let c=Math.atan2(o,a);for(let e=0;e<d.current.length;e++){let{a0:t,a1:n}=d.current[e],r=c;for(;r<t;)r+=E;for(;r>=t+E;)r-=E;if(r<=n)return e}return null}}}function Re({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,S.useRef)(null),{hitTest:l}=Le(c,{shares:e,colors:t,hovered:n,reducedMotion:R()});return(0,w.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,w.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,w.jsx)(he,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var ze=5,Be=142,Ve=.01;function He(e){return e!==null&&e.some(e=>e.cost>0)}function Ue(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,ze),r=n.map(e=>({key:e.model,label:e.model,value:e.cost,color:Ce(e.model),display:h(e.cost)})),i=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&i>t*Ve&&r.push({key:`__remainder`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:h(i)}),r}function We({modelCost:e,modelDistribution:t,totals:n}){let r=c(),[i,a]=(0,S.useState)(null),{byCost:o,entries:s}=(0,S.useMemo)(()=>{let r=He(e);return{byCost:r,entries:r?Ue(e,n.cost):we(t,n.tokens)}},[r,e,t,n.cost,n.tokens]),u=s.reduce((e,t)=>e+t.value,0),d=(0,S.useMemo)(()=>s.map(e=>u>0?e.value/u:1/s.length),[s,u]),p=l(o?`Cost by Model`:`Models`),m=s.map(e=>`${e.label}: ${g(u>0?e.value/u:0)}, ${e.display}`);return(0,w.jsxs)(x,{role:`region`,"aria-label":p,className:`p-4`,children:[(0,w.jsx)(b,{title:p,meta:l(o?`by cost`:`by tokens`)}),s.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No model data`)}):(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,w.jsxs)(Re,{shares:d,colors:s.map(e=>e.color),hovered:i,onHover:a,size:Be,ariaLabel:l(`{0} chart`,[p]),itemLabels:m,children:[(0,w.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:o?h(n.cost):f(n.tokens)}),(0,w.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l(o?`total cost`:`total tokens`)})]}),(0,w.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:s.map((e,t)=>(0,w.jsxs)(`li`,{className:y(`flex min-w-0 items-center gap-2 transition-opacity`,i!==null&&i!==t?`opacity-45`:null),onPointerEnter:()=>a(t),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,w.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,w.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:g(u>0?e.value/u:0)}),(0,w.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,w.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:o?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:l(`Estimated`)}),_(n.costEstimated),` `,l(`from model unit price,`),` `,_(n.costRecorded),` `,l(`from agent records`)]}):l(`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`)})]})}var Ge=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function Ke({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:u}){c();let[d,f]=(0,S.useState)(!1);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,w.jsxs)(`select`,{"aria-label":l(`Filter by agent`),value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,w.jsx)(`option`,{value:K,children:l(`All agents`)}),n.active.map(e=>(0,w.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,w.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:l(`{0} projects · {1} agents in scope`,[r.projects,r.agents])}):null,(0,w.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ge.map(e=>{let t=e.value===a;return(0,w.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?f(!0):o(e.value)},className:y(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:l(e.label)},e.value)})})]}),(0,w.jsx)(s,{open:d,onOpenChange:f,window:i,onSelectCustom:u})]})}function qe(e){return e.toFixed(1)}var Je={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return c(),(0,w.jsxs)(x,{className:y(`px-4 py-[14px]`,a?`border-[var(--brand-line)]`:null),children:[(0,w.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,w.jsx)(`p`,{className:y(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,w.jsxs)(`div`,{className:`mt-[7px] flex items-center gap-[7px]`,children:[n===void 0?null:(0,w.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:y(`console-mono text-[10.5px]`,Je[r]),children:n}),i===void 0?null:(0,w.jsx)(`span`,{className:`console-mono truncate text-[10.5px] text-[var(--console-muted)]`,children:i})]})]})}function Ye(e){return e.costEstimated===0?l(`All recorded by agents`):e.costEstimated===e.cost&&e.cost>0?l(`All estimated from unit price`):l(`{0} estimated`,[_(e.costEstimated)])}function Xe(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function Ze({totals:e,rangeDays:t}){c();let n=e.previous,r=(e,t)=>t===void 0?null:d(e,t),i=r(e.sessions,n?.sessions),a=r(e.messages,n?.messages),o=r(e.tokens,n?.tokens),s=r(e.cost,n?.cost),u=n?.cost!==void 0&&e.cost>n.cost;return(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,w.jsx)(q,{label:l(`Sessions`),value:m(e.sessions),trend:i??void 0,hint:t?l(`{0}/day`,[qe(e.sessions/t)]):void 0}),(0,w.jsx)(q,{label:l(`Messages`),value:m(e.messages),trend:a??void 0,hint:e.sessions>0?l(`{0}/session`,[qe(e.messages/e.sessions)]):void 0}),(0,w.jsx)(q,{label:l(`Tokens`),value:f(e.tokens),trend:o??void 0,hint:l(`Cache hit {0}`,[g(e.cacheReadTokens/e.tokens)])}),(0,w.jsx)(q,{label:l(`Cost`),value:_(e.cost),trend:s??void 0,trendTone:u?`warning`:`positive`,hint:Ye(e),emphasis:!0}),(0,w.jsx)(q,{label:l(`Last activity`),value:e.latestActivity===void 0?l(`No activity`):v(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Xe(e)})]})}var J=32,Y=4;function Qe({shares:e,colors:t,hovered:n,onHover:r,ariaLabel:i,itemLabels:a}){let s=(0,S.useRef)(null),c=R(),l=(0,S.useContext)(o),u=I(s,c),d=(0,S.useRef)(n),f=(0,S.useRef)(()=>{}),p=e.join(`,`),m=t.join(`\0`);return(0,S.useEffect)(()=>{d.current=n,c?f.current():u.requestFrame()},[u,n,c]),(0,S.useEffect)(()=>{let e=s.current,t=e?.parentElement,n=e?.getContext(`2d`);if(!e||!t||!n)return;let r=getComputedStyle(e),i=m.split(`\0`).map(e=>N(r,e)),a=p.split(`,`).map(Number),o=0,l=()=>{o=t.clientWidth;let r=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(o*r),e.height=J*r,n.setTransform(r,0,0,r,0,0)},h=e=>{n.clearRect(0,0,o,J);let t=0;a.forEach((r,a)=>{let s=r*o,c=Math.min(1,s/6),l=t+c,u=s-c*2;if(t+=s,u<=0)return;let f=d.current===a;n.save(),n.beginPath(),n.roundRect(l,0,u,J,Math.min(4,u/2)),n.clip(),n.fillStyle=i[a]??``,n.globalAlpha=d.current===null?.72:f?1:.3,n.beginPath();for(let t=l+Math.min(Y,u)/2;t<l+u;t+=Y)for(let r=Y/2;r<J;r+=Y){let i=O(1-r/J),a=A(t,r,e*.0018),o=Y*((f?.46:.34)+.36*i+.26*a)*(.78+.42*k(t,r));n.rect(t-o/2,r-o/2,o,o)}n.fill(),n.restore()})};f.current=()=>h(performance.now());let g=()=>{l(),c?f.current():u.requestFrame()};u.setFrameHandler(e=>(h(e),d.current===null?`stop`:`idle`));let _=new ResizeObserver(g);return _.observe(t),g(),()=>{_.disconnect(),u.setFrameHandler(null)}},[m,u,c,p,l]),(0,w.jsxs)(`div`,{className:`chart-hatch relative rounded-sm`,style:{height:J},onPointerMove:t=>{let n=t.currentTarget.getBoundingClientRect(),i=(t.clientX-n.left)/n.width,a=0,o=e.findIndex(e=>(a+=e,i<a));r(o<0?null:o)},onPointerLeave:e=>{e.pointerType!==`touch`&&r(null)},children:[(0,w.jsx)(`canvas`,{ref:s,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(he,{label:i,itemLabels:a,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}function $e({models:e,totalTokens:t}){let n=c(),[r,i]=(0,S.useState)(null),a=(0,S.useMemo)(()=>we(e,t),[n,e,t]),o=a.map(e=>e.value/t),s=o.map(e=>e>0&&e<.001?`<0.1%`:e.toLocaleString(n,{style:`percent`,maximumFractionDigits:1})),u=a.map((e,t)=>`${e.label}: ${m(e.value)} ${l(`tokens`)}, ${s[t]}`),d=a.findIndex(e=>e.key===r),p=a[d],h=(o.slice(0,d).reduce((e,t)=>e+t,0)+(o[d]??0)/2)*100;return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Tokens by Model`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Tokens by Model`),meta:`${f(t)} ${l(`total tokens`)}`}),(0,w.jsx)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:l(`Token share in the selected range, including cache tokens.`)}),t<=0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`relative mt-3`,children:[(0,w.jsx)(Qe,{shares:o,colors:a.map(e=>e.color),hovered:d<0?null:d,onHover:e=>i(e===null?null:a[e]?.key??null),ariaLabel:l(`Model token distribution chart`),itemLabels:u}),p?(0,w.jsxs)(T,{index:d,count:a.length,position:h,children:[(0,w.jsx)(`div`,{className:`font-semibold`,children:p.label}),(0,w.jsxs)(`div`,{children:[m(p.value),` `,l(`tokens`),` · `,s[d]]})]}):null]}),(0,w.jsx)(`ul`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-2`,children:a.map((e,t)=>(0,w.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,w.jsxs)(`button`,{type:`button`,"aria-label":u[t],className:y(`console-mono flex max-w-full items-center gap-1.5 rounded-sm text-[10.5px] text-[var(--console-text)] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-[var(--brand)]`,p&&p.key!==e.key?`opacity-45`:null),onPointerEnter:()=>i(e.key),onPointerLeave:()=>i(null),onFocus:()=>i(e.key),onBlur:()=>i(null),onClick:()=>i(e.key),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:[(0,w.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color}}),(0,w.jsx)(`span`,{className:`truncate`,children:e.label}),(0,w.jsxs)(`span`,{className:`shrink-0 text-[var(--console-muted)]`,children:[e.display,` · `,s[t]]})]})},e.key))})]})]})}var et=[0,1,2,3,4];function X({className:e}){return c(),(0,w.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Z({bodyClassName:e}){return c(),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-3 ${e}`})]})}function tt(){return c(),(0,w.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:et.map(e=>(0,w.jsxs)(x,{className:`px-4 py-[14px]`,children:[(0,w.jsx)(X,{className:`h-[10px] w-16`}),(0,w.jsx)(X,{className:`mt-[9px] h-[27px] w-24`}),(0,w.jsx)(X,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,w.jsx)(Z,{bodyClassName:`h-[68px] w-full`}),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-[14px] h-[168px] w-full`})]}),(0,w.jsx)(Z,{bodyClassName:`h-[428px] w-full`}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[248px] w-full`}),(0,w.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[116px] w-full`}),(0,w.jsx)(Z,{bodyClassName:`h-[100px] w-full`})]})]})]})}function nt(e){return`${String(e*2).padStart(2,`0`)}:00–${String(e*2+2).padStart(2,`0`)}:00`}function rt({count:e,peak:t}){let n=(0,S.useId)(),r=t>0?Math.sqrt(e/t):0,i=12*r;return(0,w.jsx)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 28 28`,"aria-hidden":`true`,style:{color:`color-mix(in oklab, var(--activity-high) ${r*100}%, var(--activity-low))`},children:e>0?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`pattern`,{id:n,width:`3`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,w.jsx)(`rect`,{width:`2`,height:`2`,fill:`currentColor`})})}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`currentColor`,opacity:`0.2`}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`url(#${n})`})]}):null})}function it({activity:e}){let t=c(),n=[l(`Overnight`),l(`Morning`),l(`Afternoon`),l(`Evening`)],[r,i]=(0,S.useState)(null),a=t===`zh-CN`?[1,2,3,4,5,6,0]:[0,1,2,3,4,5,6],o=new Intl.DateTimeFormat(t,{weekday:`short`,timeZone:`UTC`}),s=a.map(e=>o.format(Date.UTC(2026,8,6+e))),u=Math.max(0,...e?.counts??[]),d=e?.counts.reduce((e,t)=>e+t,0)??0;return(0,w.jsxs)(x,{className:`p-4`,"aria-label":l(`Active hours`),children:[(0,w.jsx)(b,{title:l(`Active hours`)}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:l(`User messages by weekday and two-hour period. Counts are cumulative within the selected range.`)}),e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2 console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`span`,{children:l(`Time zone: {0}`,[e.timeZone])}),(0,w.jsx)(`span`,{children:l(`{0} user messages`,[m(d)])})]}),(0,w.jsxs)(`table`,{className:`mt-[14px] w-full table-fixed border-collapse console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`caption`,{className:`sr-only`,children:l(`Active hours`)}),(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{scope:`col`,className:t===`en`?`w-16`:`w-9`,children:(0,w.jsx)(`span`,{className:`sr-only`,children:l(`Day period`)})}),(0,w.jsx)(`th`,{scope:`col`,className:`w-11 pb-2 text-left font-normal`,children:l(`Time`)}),s.map(e=>(0,w.jsx)(`th`,{scope:`col`,className:`pb-2 font-normal`,children:e},e))]})}),n.map((t,n)=>(0,w.jsx)(`tbody`,{className:`chart-hatch`,children:Array.from({length:3},(o,c)=>{let d=n*3+c;return(0,w.jsxs)(`tr`,{className:c===0&&n>0?`border-t border-solid border-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`,children:[c===0?(0,w.jsx)(`th`,{scope:`rowgroup`,rowSpan:3,className:`bg-[var(--console-surface)] pr-2 text-left align-middle font-normal`,children:t}):null,(0,w.jsx)(`th`,{scope:`row`,className:`h-8 bg-[var(--console-surface)] text-left font-normal tabular-nums`,children:`${String(d*2).padStart(2,`0`)}:00`}),a.map((t,n)=>{let a=t*12+d,o=e.counts[a]??0,c=`${s[n]} · ${nt(d)} · ${l(`{0} user messages`,[m(o)])}`;return(0,w.jsxs)(`td`,{className:`relative p-0 text-center`,children:[(0,w.jsx)(`button`,{type:`button`,"aria-label":c,className:`flex h-8 w-full items-center justify-center rounded-sm outline-none hover:bg-[var(--brand-soft)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]`,onMouseEnter:()=>i(a),onMouseLeave:()=>i(null),onFocus:()=>i(a),onBlur:()=>i(null),onClick:()=>i(a),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:(0,w.jsx)(rt,{count:o,peak:u})}),r===a?(0,w.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-full z-10 w-max max-w-[180px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-left text-[var(--console-text)] shadow-[var(--shadow-overlay)] ${n<3?`left-0`:`right-0`}`,children:[`${s[n]} · ${nt(d)} · `,(0,w.jsx)(`span`,{className:`font-semibold text-[var(--brand)]`,children:l(`{0} user messages`,[m(o)])})]}):null]},t)})]},d)})},t))]}),(0,w.jsx)(`div`,{className:`mt-3 flex min-h-7 flex-wrap items-center justify-end gap-4 console-mono text-[10.5px] text-[var(--console-muted)]`,children:u===0?(0,w.jsx)(`span`,{children:l(`No user messages in this range.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-1.5`,"aria-label":l(`Size reference (messages)`),children:[l(`Less`),[1,4,9].map(e=>(0,w.jsx)(rt,{count:e,peak:9},e)),l(`More`)]}),(0,w.jsx)(`span`,{children:l(`Peak: {0}`,[m(u)])})]})})]}):(0,w.jsx)(`p`,{className:`py-8 text-center text-sm text-[var(--console-muted)]`,children:l(`Activity data is unavailable.`)})]})}var at=.16;function ot(e){return e*e*(3-2*e)}function st(e,t,n){return e<t?t:e>n?n:e}function Q(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=st(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=ot(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function ct(e,t){let n=st(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function lt(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var ut=2,dt=460,ft=180,pt=32,mt=.06,ht=.24,gt=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function _t(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function vt(e,t){let n=gt.exec(e),r=gt.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/pt,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function yt(e,{values:t,max:n,reducedMotion:r}){let i=(0,S.useContext)(o),a=I(e,r),s=(0,S.useRef)({from:Q(t),to:Q(t),current:Q(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),c=(0,S.useRef)(null),l=(0,S.useRef)(()=>{}),u=(0,S.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,S.useEffect)(()=>{let e=s.current;e.from.set(e.current),e.fromMax=e.currentMax,Q(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:dt,r?l.current():a.requestFrame()},[a,n,r,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let o=u.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=vt(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(ut,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let s=Math.max(3,Math.round(e/ft)),l=Math.ceil(e/s),u=Math.ceil(r/s),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(_t(e)<mt);c.current={cell:s,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=s.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=u.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=c.current;if(!n)return!1;let a=s.current,{cell:o,cols:l,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(o*.34)),x=y((o-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<l;e++){let t=e*o+x;for(let e=0;e<d;e++)i.fillRect(t,e*o+x,b,b)}let S=u.current,C=h*(ht+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,D=e*.0018,O=-1,k=!1;for(let t=0;t<l;t++){let n=l>1?(t+.5)/l:.5,s=lt(ct(a.current,n),a.currentMax),c=Math.max(.001,1-s),u=t*o,m=u+o/2;for(let n=0;n<d;n++){let a=t*d+n,l=n*o,b=(l+o/2)/h,x=0;b>=s&&(x=1-.55*((b-s)/c));let A=_[a];if(w){let e=Math.hypot(m-S.smoothX,l+o/2-S.smoothY),t=e<C?1-e/C:0;A+=(t-A)*(t>A?T:E),_[a]=A}else A>0&&(A*=1-E,_[a]=A<.002?0:A);_[a]>0&&(k=!0);let j=Math.min(1,x+A*.5);if(j<=.02)continue;let M=j;r||(M*=1+.07*Math.sin(b*Math.PI*3-D),v[a]&&A>.02&&(M*=1+.25*A*Math.sin(e*.012+a)),M=Math.min(1,M));let N=Math.max(g,y(o*(.28+.42*j))),P=y((o-N)/2),F=Math.round(M*pt);F!==O&&(O=F,i.fillStyle=p[O]??p[pt]??f),i.fillRect(u+P,l+P,N,N)}}return k},v=()=>{m(),h(performance.now()),_(performance.now())};l.current=v;let y=e=>{let t=c.current;if(!t)return;let r=u.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{u.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:u.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),o.inside=!1}},[e,a,r,i])}var bt=[1,.66,.33,0],xt=e=>`${(1-e*(1-at))*100}%`,St=(e,t)=>(e+.5)/t*100;function Ct({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,S.useState)(null),o=(0,S.useRef)(null),s=R(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,d=e[u]??0,f=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,w.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,transition:f}}),(0,w.jsxs)(`div`,{className:y(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,top:`${lt(d,t)*100}%`,transition:f},children:[(0,w.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,w.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,w.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(d)})]})]})]})}function wt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,S.useRef)(null);return yt(s,{values:e,max:t,reducedMotion:R()}),(0,w.jsxs)(`div`,{className:y(`flex`,o),"aria-hidden":!0,children:[a?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:bt.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:xt(e)},children:a(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[bt.map(e=>(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:xt(e)}},e)),(0,w.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,w.jsx)(Ct,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var Tt=168,Et=132,Dt=6,Ot={barRatio:.86,barMax:46,bandGap:2,minBand:3},kt=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],At=kt.map(e=>e.color);function jt(e){return e>=1e3?`$${f(e)}`:`$${Math.round(e)}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function Mt(e){return l(`{0}: {1} tokens, {2}, {3} sessions, {4} messages, input {5}, output {6}, cache read {7}, cache write {8}`,[p(e.date),f($(e)),_(e.cost),m(e.sessions),m(e.messages),f(e.input),f(e.output),f(e.cache_read),f(e.cache_create)])}function Nt({daily:e}){c();let t=(0,S.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,S.useMemo)(()=>e.map(e=>p(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,w.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:l(`Daily cost`)}),(0,w.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[l(`Peak`),` `,_(i),` `,l(`· Avg`),` `,_(r/e.length),` `,l(`· Total`),` `,_(r)]})]}),(0,w.jsx)(wt,{values:t,max:i,labels:n,height:Et,formatValue:_,formatTick:jt,className:`mt-[7px]`})]})}function Pt({bucket:e,index:t,count:n}){return c(),(0,w.jsxs)(T,{index:t,count:n,children:[(0,w.jsx)(`div`,{children:p(e.date)}),(0,w.jsxs)(`div`,{children:[f($(e)),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:_(e.cost)})]}),(0,w.jsxs)(`div`,{children:[m(e.sessions),` `,l(`sessions ·`),` `,m(e.messages),` `,l(`messages`)]}),(0,w.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[l(`In`),` `,f(e.input),` `,l(`· Out`),` `,f(e.output),` `,l(`· Read`),` `,f(e.cache_read),` `,l(`· Write`),` `,f(e.cache_create)]})]})}function Ft({daily:e}){let t=c(),[n,r]=(0,S.useState)(null),i=(0,S.useMemo)(()=>e.map(e=>kt.map(t=>e[t.key])),[e]),a=(0,S.useMemo)(()=>e.map(Mt),[t,e]),o=(0,S.useMemo)(()=>j(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),s=n===null?void 0:e[n.column];return(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:i,axisMax:o,colors:At,hovered:n,onHover:r,layout:Ot,height:Tt,formatTick:f,ariaLabel:l(`Daily usage chart`),itemLabels:a}),s&&n?(0,w.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,w.jsx)(Pt,{bucket:s,index:n.column,count:e.length})}):null]})}function It({daily:e}){c();let t=e[0],n=e[e.length-1],r=t&&n?` · ${p(t.date)} → ${p(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/Dt));return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Daily usage`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Daily usage`),action:(0,w.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:kt.map(e=>(0,w.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),l(e.label)]},e.key))})}),(0,w.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[l(`Stacked bars = token mix · Area below = daily cost`),r]}),e.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ft,{daily:e}),(0,w.jsx)(Nt,{daily:e}),(0,w.jsx)(`div`,{style:{paddingLeft:38},children:(0,w.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,w.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?p(t.date):``},t.date))})})]}),(0,w.jsxs)(`table`,{className:`sr-only`,"aria-label":l(`Daily usage data`),children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{children:l(`Date`)}),(0,w.jsx)(`th`,{children:l(`Sessions`)}),(0,w.jsx)(`th`,{children:l(`Messages`)}),(0,w.jsx)(`th`,{children:l(`Tokens`)}),(0,w.jsx)(`th`,{children:l(`Cost`)})]})}),(0,w.jsx)(`tbody`,{children:e.map(e=>(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`td`,{children:p(e.date)}),(0,w.jsx)(`td`,{children:m(e.sessions)}),(0,w.jsx)(`td`,{children:m(e.messages)}),(0,w.jsx)(`td`,{children:m($(e))}),(0,w.jsx)(`td`,{children:_(e.cost)})]},e.date))})]})]})}function Lt({project:e,agent:t,onAgentChange:n,window:i,agentCatalog:a,rangePreset:o,onRangeChange:s,onSelectCustom:u}){c();let[d,f]=(0,S.useState)(void 0),p=n?t:d,{dashboard:m,error:h,retry:g}=C(i,{project:e,agent:p});return(0,w.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,w.jsx)(Ke,{agent:p,onAgentChange:n?void 0:f,agentCatalog:a,scopeCounts:m?.scopeCounts,window:i,rangePreset:o,onRangeChange:s,onSelectCustom:u}),h?(0,w.jsx)(r,{title:l(`Couldn't load the dashboard.`),message:h,onRetry:()=>void g()}):null,m?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ze,{totals:m.totals,rangeDays:m.window.days}),(0,w.jsx)($e,{models:m.modelDistribution,totalTokens:m.totals.tokens}),(0,w.jsx)(It,{daily:m.dailyActivity}),(0,w.jsx)(it,{activity:m.activeHours}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,w.jsx)(Se,{perAgent:m.perAgent}),(0,w.jsx)(We,{modelCost:m.modelCost,modelDistribution:m.modelDistribution,totals:m.totals})]})]}):h?null:(0,w.jsx)(tt,{})]})}export{Lt as OverviewScreen};