@roastcodes/ttdash 6.1.7 → 6.1.9

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.
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DrillDownModal-BnZ6q6tF.js","assets/rolldown-runtime-COnpUsM8.js","assets/charts-vendor-CiBqdKXh.js","assets/motion-vendor-BXI2L__C.js","assets/CustomTooltip-BXro6tIF.js","assets/ui-vendor-BGjRFQGY.js","assets/react-vendor-0R1rd57Z.js","assets/dialog-CA-ZSHjK.js","assets/icons-vendor-z59La6A4.js","assets/AutoImportModal-C8gA0_mL.js","assets/button-B26tLVFw.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{C as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,w as x,y as S}from"./charts-vendor-CiBqdKXh.js";import{u as ee}from"./react-vendor-0R1rd57Z.js";import{n as C,r as te,t as w}from"./motion-vendor-BXI2L__C.js";import{a as ne,c as re,i as T,l as ie,n as ae,o as oe,r as se,s as ce,t as E,u as le}from"./ui-vendor-BGjRFQGY.js";import{a as D,c as O,i as ue,n as de,o as k,r as fe,t as pe}from"./dialog-CA-ZSHjK.js";import{A,B as me,C as he,D as ge,E as _e,F as ve,I as ye,L as be,M as xe,N as Se,O as Ce,P as we,R as Te,S as Ee,T as De,_ as j,a as Oe,b as ke,c as Ae,d as M,f as N,g as je,h as Me,i as P,j as Ne,k as Pe,l as Fe,m as Ie,n as F,o as I,p as L,r as Le,s as R,t as z,u as Re,v as ze,w as Be,x as Ve,y as B,z as He}from"./CustomTooltip-BXro6tIF.js";import{$ as Ue,A as We,C as Ge,D as Ke,E as qe,F as Je,G as Ye,I as Xe,J as Ze,K as Qe,L as $e,M as et,N as tt,O as nt,P as rt,Q as it,R as at,S as ot,T as st,U as ct,V as lt,W as ut,X as dt,Y as ft,Z as pt,_ as mt,a as ht,b as gt,d as _t,et as vt,f as yt,g as bt,h as xt,i as St,it as Ct,j as wt,k as Tt,l as Et,m as Dt,n as Ot,nt as kt,o as At,p as jt,q as Mt,r as Nt,rt as Pt,s as Ft,t as It,tt as Lt,u as Rt,v as zt,w as Bt,x as Vt,y as Ht,z as Ut}from"./icons-vendor-z59La6A4.js";import{t as V}from"./button-B26tLVFw.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Wt=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(){}},Gt=new class extends Wt{#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`}},Kt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},qt=new class{#e=Kt;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 Jt(e){setTimeout(e,0)}var Yt=typeof window>`u`||`Deno`in globalThis;function Xt(){}function Zt(e,t){return typeof e==`function`?e(t):e}function Qt(e){return typeof e==`number`&&e>=0&&e!==1/0}function $t(e,t){return Math.max(e+(t||0)-Date.now(),0)}function en(e,t){return typeof e==`function`?e(t):e}function tn(e,t){return typeof e==`function`?e(t):e}function nn(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==an(o,t.options))return!1}else if(!sn(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 rn(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(on(t.options.mutationKey)!==on(a))return!1}else if(!sn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function an(e,t){return(t?.queryKeyHashFn||on)(e)}function on(e){return JSON.stringify(e,(e,t)=>fn(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function sn(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>sn(e[n],t[n])):!1}var cn=Object.prototype.hasOwnProperty;function ln(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=dn(e)&&dn(t);if(!r&&!(fn(e)&&fn(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:cn.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ln(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function un(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 dn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function fn(e){if(!pn(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!pn(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function pn(e){return Object.prototype.toString.call(e)===`[object Object]`}function mn(e){return new Promise(t=>{qt.setTimeout(t,e)})}function hn(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ln(e,t)}function gn(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function _n(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var vn=Symbol();function yn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===vn?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function bn(e,t){return typeof e==`function`?e(...t):!!e}function xn(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 Sn=(()=>{let e=()=>Yt;return{isServer(){return e()},setIsServer(t){e=t}}})();function Cn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var wn=Jt;function Tn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=wn,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 H=Tn(),En=new class extends Wt{#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 Dn(e){return Math.min(1e3*2**e,3e4)}function On(e){return(e??`online`)===`online`?En.isOnline():!0}var kn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function An(e){let t=!1,n=0,r,i=Cn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new kn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Gt.isFocused()&&(e.networkMode===`always`||En.isOnline())&&e.canRun(),u=()=>On(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())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(d).catch(r=>{if(a())return;let i=e.retry??(Sn.isServer()?0:3),o=e.retryDelay??Dn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),mn(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var jn=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qt(this.gcTime)&&(this.#e=qt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Sn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(qt.clearTimeout(this.#e),this.#e=void 0)}},Mn=class extends jn{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Fn(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Fn(this.options);e.data!==void 0&&(this.setState(Pn(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=hn(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Xt).catch(Xt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>tn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===vn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>en(e.options.staleTime,this)===`static`):!1}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:!$t(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.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.#o=!0,n.signal)})},i=()=>{let e=yn(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!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.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=An({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof kn&&e.revert&&this.setState({...this.#t,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 this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof kn){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(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,...Nn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Pn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=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),H.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Nn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:On(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Pn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Fn(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 In=class extends Wt{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Cn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Rn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return zn(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return zn(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 tn(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&&!un(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Bn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||tn(this.options.enabled,this.#t)!==tn(t.enabled,this.#t)||en(this.options.staleTime,this.#t)!==en(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||tn(this.options.enabled,this.#t)!==tn(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Hn(this,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),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.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);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Xt)),t}#g(){this.#b();let e=en(this.options.staleTime,this.#t);if(Sn.isServer()||this.#r.isStale||!Qt(e))return;let t=$t(this.#r.dataUpdatedAt,e)+1;this.#d=qt.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.#p=e,!(Sn.isServer()||tn(this.options.enabled,this.#t)===!1||!Qt(this.#p)||this.#p===0)&&(this.#f=qt.setInterval(()=>{(this.options.refetchIntervalInBackground||Gt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(qt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(qt.clearInterval(this.#f),this.#f=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&&Rn(e,t),o=i&&Bn(e,n,t,r);(a||o)&&(l={...l,...Nn(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.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=hn(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=hn(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={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:Vn(e,t),refetch:this.refetch,promise:this.#o,isEnabled:tn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Cn())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!un(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);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)})})()}))}#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()}#C(e){H.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Ln(e,t){return tn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Rn(e,t){return Ln(e,t)||e.state.data!==void 0&&zn(e,t,t.refetchOnMount)}function zn(e,t,n){if(tn(t.enabled,e)!==!1&&en(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Vn(e,t)}return!1}function Bn(e,t,n,r){return(e!==t||tn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Vn(e,n)}function Vn(e,t){return tn(t.enabled,e)!==!1&&e.isStaleByTime(en(t.staleTime,e))}function Hn(e,t){return!un(e.getCurrentResult(),t)}function Un(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=>{xn(e,()=>t.signal,()=>n=!0)},u=yn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?_n:gn;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Gn:Wn,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:Wn(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Wn(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 Gn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Kn=class extends jn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||qn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=An({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),H.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function qn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Jn=class extends Wt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Kn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Yn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Yn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){H.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>rn(t,e))}findAll(e={}){return this.getAll().filter(t=>rn(e,t))}notify(e){H.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return H.batch(()=>Promise.all(e.map(e=>e.continue().catch(Xt))))}};function Yn(e){return e.options.scope?.id}var Xn=class extends Wt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),un(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&on(t.mutationKey)!==on(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??qn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){H.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Zn=class extends Wt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??an(r,t),a=this.get(i);return a||(a=new Mn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){H.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>nn(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>nn(e,t)):t}notify(e){H.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){H.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){H.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Qn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Zn,this.#t=e.mutationCache||new Jn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Gt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=En.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(en(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Zt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return H.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;H.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return H.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=H.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Xt).catch(Xt)}invalidateQueries(e,t={}){return H.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=H.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Xt)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Xt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(en(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Xt).catch(Xt)}fetchInfiniteQuery(e){return e.behavior=Un(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Xt).catch(Xt)}ensureInfiniteQueryData(e){return e.behavior=Un(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return En.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(on(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{sn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(on(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{sn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=an(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===vn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},U=e(x(),1),W=te(),$n=U.createContext(void 0),er=e=>{let t=U.useContext($n);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},tr=({client:e,children:t})=>(U.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,W.jsx)($n.Provider,{value:e,children:t})),nr=U.createContext(!1),rr=()=>U.useContext(nr);nr.Provider;function ir(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ar=U.createContext(ir()),or=()=>U.useContext(ar),sr=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?bn(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},cr=e=>{U.useEffect(()=>{e.clearReset()},[e])},lr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||bn(n,[e.error,r])),ur=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))}},dr=(e,t)=>e.isLoading&&e.isFetching&&!t,fr=(e,t)=>e?.suspense&&t.isPending,pr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function mr(e,t,n){let r=rr(),i=or(),a=er(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,ur(o),sr(o,i,s),cr(i);let c=!a.getQueryCache().get(o.queryHash),[l]=U.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(U.useSyncExternalStore(U.useCallback(e=>{let t=d?l.subscribe(H.batchCalls(e)):Xt;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),U.useEffect(()=>{l.setOptions(o)},[o,l]),fr(o,u))throw pr(o,l,i);if(lr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Sn.isServer()&&dr(u,r)&&(c?pr(o,l,i):s?.promise)?.catch(Xt).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function hr(e,t){return mr(e,In,t)}function gr(e,t){let n=er(t),[r]=U.useState(()=>new Xn(n,e));U.useEffect(()=>{r.setOptions(e)},[r,e]);let i=U.useSyncExternalStore(U.useCallback(e=>r.subscribe(H.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=U.useCallback((e,t)=>{r.mutate(e,t).catch(Xt)},[r]);if(i.error&&bn(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var _r=ee(),vr=(0,U.createContext)(null);function yr({children:e}){let[t,n]=(0,U.useState)([]),r=(0,U.useCallback)((e,t=`info`)=>{let r=Math.random().toString(36).slice(2);n(n=>[...n,{id:r,message:e,type:t}]),setTimeout(()=>{n(e=>e.filter(e=>e.id!==r))},4e3)},[]),i=(0,U.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return(0,W.jsxs)(vr.Provider,{value:{toasts:t,addToast:r,removeToast:i},children:[e,(0,W.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-3 text-sm shadow-lg backdrop-blur-sm animate-in slide-in-from-bottom-2 fade-in-0 ${e.type===`error`?`bg-destructive/90 text-destructive-foreground`:e.type===`success`?`bg-primary/90 text-primary-foreground`:`bg-card/95 text-card-foreground`}`,onClick:()=>i(e.id),children:e.message},e.id))})]})}function br(){let e=(0,U.useContext)(vr);if(!e)throw Error(`useToast must be used within ToastProvider`);return e}var xr={de:{keyboardShortcuts:[{keys:`⌘ K`,description:`Command Palette öffnen`},{keys:`ESC`,description:`Dialog / Zoom schliessen`}],metric:{totalCost:`Zeigt die Gesamtkosten aller API-Aufrufe im gewählten Zeitraum. Die Berechnung basiert auf den hinterlegten Token-Preisen pro Modell.`,totalTokens:`Zeigt die Summe aller verarbeiteten Tokens aus Input, Output und Cache. Ein Token entspricht grob vier Zeichen Text.`,activeDays:`Zeigt, an wie vielen Tagen im gewählten Zeitraum mindestens ein API-Aufruf vorhanden war.`,topModel:`Zeigt das Modell mit den höchsten Gesamtkosten im aktuellen Ausschnitt.`,cacheHitRate:`Zeigt den Anteil der Tokens, die aus dem Cache gelesen wurden. Höhere Werte sprechen meist für bessere Kosteneffizienz.`,costPerMillion:`Zeigt die durchschnittlichen Kosten pro 1 Million verarbeiteter Tokens. Niedrigere Werte sprechen für effizientere Nutzung.`,mostExpensiveDay:`Zeigt den Zeitraumspunkt mit den höchsten API-Kosten im aktuellen Ausschnitt.`,cheapestDay:`Zeigt den Zeitraumspunkt mit den niedrigsten API-Kosten im aktuellen Ausschnitt.`,avgCostPerDay:`Zeigt die durchschnittlichen Kosten pro aktivem Zeitraumspunkt.`,outputTokens:`Zeigt die Menge der generierten Output-Tokens. Diese sind meist teurer als reine Input-Tokens.`},chart:{costOverTime:`Zeigt die API-Kosten im Zeitverlauf zusammen mit einem gleitenden 7-Tage-Durchschnitt. Klick auf einen Punkt öffnet den Drilldown.`,costByModel:`Zeigt die Kostenverteilung nach Modell als Donut. So wird sichtbar, welche Modelle den grössten Kostenanteil tragen.`,costByModelOverTime:`Zeigt, wie sich die Kosten je Modell über die Zeit entwickeln. Gut geeignet, um Treiber und Verschiebungen im Modellmix zu erkennen.`,cumulativeCost:`Zeigt die kumulierten Gesamtkosten über den gewählten Zeitraum. Falls möglich, wird zusätzlich die Monatsend-Projektion eingeblendet.`,costByWeekday:`Zeigt die durchschnittlichen Kosten pro Wochentag. So werden wiederkehrende Lastmuster über die Woche sichtbar.`,tokensOverTime:`Zeigt den Token-Verbrauch über die Zeit, getrennt nach Input, Output, Cache Write, Cache Read und Thinking.`,requestsOverTime:`Zeigt Anfragen im Zeitverlauf mit Gesamtlinie, Modelllinien und Trendlinie. Klick auf einen Punkt öffnet den Drilldown.`,requestCacheHitRate:`Zeigt die Cache-Hit-Rate pro Modell zusammen mit dem gefilterten Gesamtwert und dem gleitenden 7-Tage-Durchschnitt auf Basis des gewählten Tagesbereichs.`,tokenTypes:`Zeigt die Verteilung der Token-Typen als Donut. So wird sichtbar, welcher Anteil auf Input, Output, Cache oder Thinking entfällt.`,tokenEfficiency:`Zeigt die Kosten pro 1 Million Tokens im Zeitverlauf. So lässt sich erkennen, ob Modellmix und Cache-Nutzung effizienter oder teurer werden.`,modelMix:`Zeigt den prozentualen Kostenanteil der Modelle je Zeitraumspunkt. So werden Modellwechsel und Konzentration sichtbar.`,distributionAnalysis:`Zeigt Histogramme für Kosten, Anfragen und Tokens pro Anfrage. So wird die Streuung sichtbar, nicht nur der Durchschnitt.`,correlationAnalysis:`Zeigt Punktdiagramme für mögliche Zusammenhänge, etwa Anfragen zu Kosten oder Cache-Rate zu Kosten pro Anfrage. Die Korrelation ist ein Signal, aber kein Beweis für Kausalität.`,heatmap:`Zeigt eine Kalender-Heatmap der täglichen Kosten. Dunklere Felder stehen für höhere Werte.`,requestHeatmap:`Zeigt eine Kalender-Heatmap der Anfragen pro Tag. So werden Lastmuster unabhängig von Kosten sichtbar.`,tokenHeatmap:`Zeigt eine Kalender-Heatmap des Tokenvolumens pro Tag. So lassen sich volumenstarke und kostenstarke Tage besser unterscheiden.`,forecast:`Zeigt die Kostenprognose für den laufenden Monat auf Basis geglätteter Kalendertageskosten. Ergänzt wird sie durch Trend und Unsicherheitsband.`,cacheROI:`Zeigt den Effekt der Cache-Nutzung, indem hypothetische Kosten ohne Cache mit den tatsächlichen Kosten verglichen werden.`,providerLimitProgress:`Zeigt pro Anbieter, wie stark das konfigurierte Monatslimit bereits verbraucht ist. Überschreitungen werden separat markiert.`,providerSubscriptionMix:`Vergleicht pro Anbieter die fixen Abo-Kosten mit den variablen API-Kosten und blendet optional das gesetzte Monatslimit ein.`,providerLimitTimeline:`Zeigt im Monatsverlauf die Summe der aktuellen Anbieterkosten gegen die Summe aller konfigurierten Limits. So werden Engpässe früh sichtbar.`,periodComparison:`Zeigt den Vergleich zweier Zeiträume, etwa Woche gegen Vorwoche oder Monat gegen Vormonat, anhand zentraler Kennzahlen.`,anomalyDetection:`Zeigt auffällige Zeitraumspunkte mit ungewöhnlich hohen oder niedrigen Kosten. Grundlage ist die Abweichung vom Mittelwert in Standardabweichungen.`},section:{insights:`Zeigt verdichtete Aussagen zu Konzentration, Anfrage-Ökonomie, Nutzungsmuster und Peak-Fenstern. Diese Sektion ist als schneller Einstieg vor dem Detailblick gedacht.`,metrics:`Zeigt die wichtigsten Kennzahlen auf einen Blick. Hover über abgekürzte Werte zeigt den exakten Zahlenwert.`,today:`Zeigt die KPIs des aktuellen Tages im Datensatz. So wird sichtbar, wie stark der Tageswert vom Zeitraumdurchschnitt abweicht.`,currentMonth:`Zeigt die KPIs des laufenden Monats. So werden Fortschritt, Abdeckung und der Vergleich mit dem Vormonat sichtbar.`,activity:`Zeigt Kalenderansichten für Kosten, Anfragen und Tokens. So werden Lastspitzen, Lücken und saisonale Muster sichtbar.`,forecastCache:`Zeigt Monatsprognose, Cache-Ersparnis und operative Anfragequalität in einem Block. So entsteht ein gemeinsamer Blick auf Ausblick und Effizienz.`,limits:`Zeigt pro Anbieter konfigurierte Abos und Monatslimits. Die Sektion macht sichtbar, wie weit Kostenbudgets im aktuellen Ausschnitt ausgereizt sind.`,costAnalysis:`Zeigt Kostenverlauf und Kostenverteilung nach Modell. So wird sichtbar, wo Geld ausgegeben wurde und welche Modelle die Haupttreiber sind.`,tokenAnalysis:`Zeigt Tokenvolumen, Token-Typen, Wochentagsmuster und Effizienz. So lässt sich besser einordnen, ob Kosten eher aus Menge oder Preisniveau entstehen.`,requestAnalysis:`Zeigt Anfragen gesamt, nach Modell und im Verlauf. Im Zoom kommen zusätzliche Trends und Verteilungen hinzu.`,advancedAnalysis:`Zeigt Verteilungen, Korrelationen und Konzentrationsrisiken. So wird sichtbar, wie stabil, konzentriert oder ungewöhnlich die Nutzung ist.`,comparisons:`Zeigt Veränderungen zwischen Perioden und markiert Ausreisser. So lassen sich Verschiebungen schneller einordnen.`,tables:`Zeigt detaillierte Tabellen mit Sortierung und Drilldown. So lassen sich einzelne Modelle, Anbieter und Tage gezielt prüfen.`},feature:{requestQuality:`Zeigt verdichtete Anfragesignale wie Tokens pro Anfrage, Kosten pro Anfrage sowie Cache- und Thinking-Anteil. So lässt sich die operative Anfragequalität schneller einordnen.`,providerLimits:`Hier werden fixe Abo-Kosten und variable Monatslimits pro Anbieter gepflegt. Die Eingaben bleiben lokal im Browser gespeichert und gelten nur für Anbieter, die im geladenen Report vorkommen.`,concentrationRisk:`Zeigt die Abhängigkeit von einzelnen Modellen und Anbietern. Hohe Werte bedeuten, dass wenige Akteure einen grossen Teil der Kosten tragen.`,providerEfficiency:`Zeigt den Vergleich der Anbieter nach Kosten, Anfragen, Tokens und Effizienzkennzahlen wie Kosten pro Anfrage oder Kosten pro 1 Mio. Tokens.`,modelEfficiency:`Zeigt den Vergleich der Modelle nach Kosten, Volumen und Effizienz. So lassen sich teure oder ineffiziente Kandidaten schnell erkennen.`,recentDays:`Zeigt die Detailtabelle pro Tag, Monat oder Jahr mit Drilldown und Benchmarks gegen Vortag und 7-Tage-Mittel.`}},en:{keyboardShortcuts:[{keys:`⌘ K`,description:`Open command palette`},{keys:`ESC`,description:`Close dialog / zoom view`}],metric:{totalCost:`Shows total API cost across the selected range. The calculation is based on configured per-model token prices.`,totalTokens:`Shows the sum of all processed tokens across input, output, and cache. One token is roughly four text characters.`,activeDays:`Shows how many days in the selected range contain at least one API call.`,topModel:`Shows the model with the highest total cost in the current slice.`,cacheHitRate:`Shows the share of tokens served from cache. Higher values usually indicate better cost efficiency.`,costPerMillion:`Shows average cost per 1 million processed tokens. Lower values indicate more efficient usage.`,mostExpensiveDay:`Shows the period point with the highest API cost in the current slice.`,cheapestDay:`Shows the period point with the lowest API cost in the current slice.`,avgCostPerDay:`Shows the average cost per active period point.`,outputTokens:`Shows the volume of generated output tokens. These are usually more expensive than pure input tokens.`},chart:{costOverTime:`Shows API cost over time together with a rolling 7-day average. Clicking a point opens the drilldown.`,costByModel:`Shows cost distribution by model as a donut chart. This makes the main cost drivers visible.`,costByModelOverTime:`Shows how cost per model evolves over time. Useful for spotting shifts in the model mix.`,cumulativeCost:`Shows cumulative total cost over the selected range. When possible, a month-end projection is added.`,costByWeekday:`Shows average cost by weekday, making recurring weekly load patterns visible.`,tokensOverTime:`Shows token usage over time split by input, output, cache write, cache read, and thinking.`,requestsOverTime:`Shows requests over time with total line, per-model lines, and a trend line. Clicking a point opens the drilldown.`,requestCacheHitRate:`Shows cache hit rate per model together with the filtered overall total and the trailing 7-day average based on the selected daily range.`,tokenTypes:`Shows the distribution of token types as a donut chart so input, output, cache, and thinking shares become visible.`,tokenEfficiency:`Shows cost per 1 million tokens over time. This helps spot whether model mix and cache usage are becoming more or less efficient.`,modelMix:`Shows the percentage cost share of models at each period point. This makes model shifts and concentration visible.`,distributionAnalysis:`Shows histograms for costs, requests, and tokens per request. This highlights spread, not just averages.`,correlationAnalysis:`Shows scatter plots for potential relationships such as requests to cost or cache rate to cost per request. Correlation is a signal, not proof of causality.`,heatmap:`Shows a calendar heatmap of daily cost. Darker cells indicate higher values.`,requestHeatmap:`Shows a calendar heatmap of requests per day. This reveals load patterns independently of cost.`,tokenHeatmap:`Shows a calendar heatmap of token volume per day. This helps distinguish high-volume days from high-cost days.`,forecast:`Shows cost forecast for the current month based on smoothed calendar-day costs, complemented by trend and uncertainty band.`,cacheROI:`Shows the impact of cache usage by comparing hypothetical no-cache costs with actual costs.`,providerLimitProgress:`Shows how much of each configured monthly provider limit has already been used. Overruns are marked separately.`,providerSubscriptionMix:`Compares fixed subscription cost with variable API cost per provider and can optionally include the configured monthly limit.`,providerLimitTimeline:`Shows monthly provider cost against total configured limits over time so bottlenecks become visible early.`,periodComparison:`Shows the comparison of two periods, such as week-over-week or month-over-month, using central metrics.`,anomalyDetection:`Shows unusual period points with unusually high or low cost based on deviation from the mean in standard deviations.`},section:{insights:`Shows condensed statements about concentration, request economics, usage patterns, and peak windows. This section is meant as a fast entry point before deeper analysis.`,metrics:`Shows the most important KPIs at a glance. Hover abbreviated values to see exact numbers.`,today:`Shows the KPIs of the current day in the dataset. This makes it easy to compare the day against the period average.`,currentMonth:`Shows the KPIs of the current month, including progress, coverage, and comparison to the previous month.`,activity:`Shows calendar views for cost, requests, and tokens, making spikes, gaps, and seasonal patterns visible.`,forecastCache:`Shows month forecast, cache savings, and operational request quality in one block for a combined outlook on efficiency.`,limits:`Shows configured subscriptions and monthly limits per provider. This section makes it visible how far budgets are stretched in the current slice.`,costAnalysis:`Shows cost trend and cost distribution by model so it is clear where spend happened and which models dominate.`,tokenAnalysis:`Shows token volume, token types, weekday patterns, and efficiency so you can judge whether cost comes from volume or pricing level.`,requestAnalysis:`Shows requests overall, by model, and over time. The expanded views add extra trends and distributions.`,advancedAnalysis:`Shows distributions, correlations, and concentration risk so usage stability, concentration, and unusual behavior become visible.`,comparisons:`Shows changes between periods and marks outliers so shifts can be understood faster.`,tables:`Shows detailed tables with sorting and drilldown so individual models, providers, and days can be inspected directly.`},feature:{requestQuality:`Shows condensed request signals such as tokens per request, cost per request, and cache and thinking shares. This helps assess operational request quality faster.`,providerLimits:`This is where fixed subscription cost and variable monthly limits are maintained per provider. Values are stored in the local app settings and only apply to providers present in the loaded report.`,concentrationRisk:`Shows dependency on individual models and providers. Higher values mean that a small number of actors carries a large share of cost.`,providerEfficiency:`Shows the provider comparison by cost, requests, tokens, and efficiency metrics such as $/req or $/1M tokens.`,modelEfficiency:`Shows the model comparison by cost, volume, and efficiency so expensive or inefficient candidates are easy to spot.`,recentDays:`Shows the detailed table per day, month, or year with drilldown and benchmarks against the previous day and 7-day average.`}}};function Sr(){return xr[Ce()]}function Cr(e){return new Proxy({},{get:(t,n)=>{let r=e();if(Object.prototype.hasOwnProperty.call(r,n))return Reflect.get(r,n)},has:(t,n)=>{let r=e();return Object.prototype.hasOwnProperty.call(r,n)},ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=e();if(Object.prototype.hasOwnProperty.call(r,n))return{value:Reflect.get(r,n),enumerable:!0,configurable:!0}}})}function wr(){return Sr().keyboardShortcuts}var Tr=Cr(()=>Sr().metric),G=Cr(()=>Sr().chart),Er=Cr(()=>Sr().section),Dr=Cr(()=>Sr().feature),Or=[`requestQuality`,`providerLimits`,`concentrationRisk`],kr=[`providerEfficiency`,`modelEfficiency`,`recentDays`];function Ar({open:e,onOpenChange:t}){let{t:n}=k(),r=wr(),i=(0,U.useMemo)(()=>Object.keys(G),[]),a=(0,U.useMemo)(()=>Object.keys(Er),[]),o=(0,U.useMemo)(()=>({totalCost:n(`helpPanel.metricLabels.totalCost`),totalTokens:n(`helpPanel.metricLabels.totalTokens`),activeDays:n(`helpPanel.metricLabels.activeDays`),topModel:n(`helpPanel.metricLabels.topModel`),cacheHitRate:n(`helpPanel.metricLabels.cacheHitRate`),costPerMillion:n(`helpPanel.metricLabels.costPerMillion`),mostExpensiveDay:n(`helpPanel.metricLabels.mostExpensiveDay`),cheapestDay:n(`helpPanel.metricLabels.cheapestDay`),avgCostPerDay:n(`helpPanel.metricLabels.avgCostPerDay`),outputTokens:n(`helpPanel.metricLabels.outputTokens`)}),[n]),s=(0,U.useMemo)(()=>({costOverTime:n(`helpPanel.chartLabels.costOverTime`),costByModel:n(`helpPanel.chartLabels.costByModel`),costByModelOverTime:n(`helpPanel.chartLabels.costByModelOverTime`),cumulativeCost:n(`helpPanel.chartLabels.cumulativeCost`),costByWeekday:n(`helpPanel.chartLabels.costByWeekday`),tokensOverTime:n(`helpPanel.chartLabels.tokensOverTime`),requestsOverTime:n(`helpPanel.chartLabels.requestsOverTime`),requestCacheHitRate:n(`helpPanel.chartLabels.requestCacheHitRate`),tokenTypes:n(`helpPanel.chartLabels.tokenTypes`),tokenEfficiency:n(`helpPanel.chartLabels.tokenEfficiency`),modelMix:n(`helpPanel.chartLabels.modelMix`),distributionAnalysis:n(`helpPanel.chartLabels.distributionAnalysis`),correlationAnalysis:n(`helpPanel.chartLabels.correlationAnalysis`),heatmap:n(`helpPanel.chartLabels.heatmap`),requestHeatmap:n(`helpPanel.chartLabels.requestHeatmap`),tokenHeatmap:n(`helpPanel.chartLabels.tokenHeatmap`),forecast:n(`helpPanel.chartLabels.forecast`),cacheROI:n(`helpPanel.chartLabels.cacheROI`),providerLimitProgress:n(`helpPanel.chartLabels.providerLimitProgress`),providerSubscriptionMix:n(`helpPanel.chartLabels.providerSubscriptionMix`),providerLimitTimeline:n(`helpPanel.chartLabels.providerLimitTimeline`),periodComparison:n(`helpPanel.chartLabels.periodComparison`),anomalyDetection:n(`helpPanel.chartLabels.anomalyDetection`)}),[n]),c=(0,U.useMemo)(()=>({insights:n(`helpPanel.sectionLabels.insights`),metrics:n(`helpPanel.sectionLabels.metrics`),today:n(`helpPanel.sectionLabels.today`),currentMonth:n(`helpPanel.sectionLabels.currentMonth`),activity:n(`helpPanel.sectionLabels.activity`),forecastCache:n(`helpPanel.sectionLabels.forecastCache`),costAnalysis:n(`helpPanel.sectionLabels.costAnalysis`),tokenAnalysis:n(`helpPanel.sectionLabels.tokenAnalysis`),requestAnalysis:n(`helpPanel.sectionLabels.requestAnalysis`),advancedAnalysis:n(`helpPanel.sectionLabels.advancedAnalysis`),comparisons:n(`helpPanel.sectionLabels.comparisons`),tables:n(`helpPanel.sectionLabels.tables`),limits:n(`helpPanel.sectionLabels.limits`)}),[n]),l=(0,U.useMemo)(()=>({requestQuality:n(`helpPanel.featureLabels.requestQuality`),providerLimits:n(`helpPanel.featureLabels.providerLimits`),concentrationRisk:n(`helpPanel.featureLabels.concentrationRisk`),providerEfficiency:n(`helpPanel.featureLabels.providerEfficiency`),modelEfficiency:n(`helpPanel.featureLabels.modelEfficiency`),recentDays:n(`helpPanel.featureLabels.recentDays`)}),[n]);return(0,W.jsx)(pe,{open:e,onOpenChange:t,children:(0,W.jsxs)(de,{className:`max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,W.jsxs)(ue,{children:[(0,W.jsx)(D,{className:`text-lg font-semibold`,children:n(`header.help`)}),(0,W.jsx)(fe,{children:n(`commandPalette.description`)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-border/60 bg-muted/40 px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`helpPanel.projectLinks.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`helpPanel.projectLinks.description`,{version:ye})})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:n(`helpPanel.projectLinks.npm`)}),(0,W.jsx)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:n(`helpPanel.projectLinks.github`)}),(0,W.jsx)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:n(`helpPanel.projectLinks.issues`)})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(st,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`header.help`)})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:r.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-foreground`,children:e.description}),(0,W.jsx)(`kbd`,{className:`inline-flex items-center gap-0.5 rounded border border-border bg-background px-2 py-0.5 font-mono text-xs text-muted-foreground`,children:e.keys})]},e.keys))})]}),(0,W.jsx)(`hr`,{className:`border-border`}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(Ze,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`dashboard.metrics.title`)})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:Object.entries(Tr).map(([e,t])=>(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:o[e]??e}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t})]},e))})]}),(0,W.jsx)(`hr`,{className:`border-border`}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(Qe,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.chartsAndFeatures`)})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:i.map(e=>(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:s[e]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:G[e]})]},e))})]}),(0,W.jsx)(`hr`,{className:`border-border`}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(Ze,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.dashboardSectionsTitle`)})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:c[e]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Er[e]})]},e))})]}),(0,W.jsx)(`hr`,{className:`border-border`}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(Ze,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.featuresTitle`)})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:Or.map(e=>(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:l[e]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Dr[e]})]},e))})]}),(0,W.jsx)(`hr`,{className:`border-border`}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(Ze,{className:`h-4 w-4 text-primary`}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.tablesTitle`)})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:kr.map(e=>(0,W.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:l[e]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Dr[e]})]},e))})]})]})})}function jr({source:e}){let{t}=k();return e.type===`auto-import`?(0,W.jsxs)(`span`,{className:`text-[10px] font-medium inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-green-500/10 text-green-400 border border-green-500/20`,title:e.title??t(`emptyState.autoImport`),children:[(0,W.jsx)(It,{className:`h-2.5 w-2.5`}),t(`emptyState.autoImport`),e.time&&(0,W.jsxs)(`span`,{className:`text-green-400/60`,children:[`· `,e.time]})]}):e.type===`file`?(0,W.jsxs)(`span`,{className:`text-[10px] font-medium inline-flex max-w-full items-center gap-1 px-2 py-0.5 rounded-md bg-blue-500/10 text-blue-400 border border-blue-500/20`,title:e.title??e.label??t(`emptyState.uploadFile`),children:[(0,W.jsx)(wt,{className:`h-2.5 w-2.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate max-w-28 sm:max-w-40`,children:e.label??t(`emptyState.uploadFile`)}),e.time&&(0,W.jsxs)(`span`,{className:`text-blue-400/60 shrink-0`,children:[`· `,e.time]})]}):(0,W.jsxs)(`span`,{className:`text-[10px] font-medium inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-muted/50 text-muted-foreground border border-border/50`,title:e.title??t(`header.loaded`),children:[(0,W.jsx)(Ke,{className:`h-2.5 w-2.5`}),t(`header.loaded`),e.time&&(0,W.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[`· `,e.time]})]})}function Mr({badge:e}){let{t}=k();return e.active?(0,W.jsxs)(`span`,{className:`text-[10px] font-medium inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20`,title:e.title??t(`header.autoLoadActive`),children:[(0,W.jsx)(It,{className:`h-2.5 w-2.5`}),t(`header.autoLoadActive`),e.time&&(0,W.jsxs)(`span`,{className:`text-amber-400/70`,children:[`· `,e.time]})]}):null}function Nr({dateRange:e,isDark:t,currentLanguage:n,helpOpen:r,streak:i,dataSource:a,startupAutoLoad:o,onHelpOpenChange:s,onLanguageChange:c,onToggleTheme:l,onExportCSV:u,onDelete:d,onUpload:f,onAutoImport:p,settingsButton:m,pdfButton:h}){let{t:g}=k();return(0,W.jsxs)(`header`,{className:`py-4 px-1 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsxs)(`h1`,{className:`text-2xl font-bold tracking-tight shrink-0`,children:[(0,W.jsx)(`span`,{className:`text-primary`,children:`TT`}),`Dash`]}),(0,W.jsxs)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-muted-foreground font-mono shrink-0 rounded-sm underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,title:g(`header.versionLinkTitle`,{version:ye}),"aria-label":g(`header.versionLinkTitle`,{version:ye}),children:[`v`,ye]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 md:hidden`,children:[(0,W.jsx)(V,{variant:`ghost`,size:`icon`,onClick:()=>s(!0),title:g(`header.help`),children:(0,W.jsx)(lt,{className:`h-4 w-4`})}),(0,W.jsx)(V,{variant:`ghost`,size:`icon`,onClick:l,title:g(`commandPalette.commands.themeDark.description`),children:t?(0,W.jsx)(Rt,{className:`h-4 w-4`}):(0,W.jsx)(Ht,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e&&(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono px-2 py-0.5 rounded-md bg-muted/50 border border-border/50`,children:[e.start,` — `,e.end]}),a&&(0,W.jsx)(jr,{source:a}),o&&(0,W.jsx)(Mr,{badge:o}),i!=null&&i>1&&(0,W.jsxs)(`span`,{className:`text-xs font-medium inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-orange-500/10 text-orange-400 border border-orange-500/20 shrink-0`,children:[(0,W.jsx)(We,{className:`h-3 w-3`}),g(`header.streak`,{count:i})]})]})]}),(0,W.jsxs)(`div`,{className:`hidden md:flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(`div`,{className:`inline-flex items-center rounded-md border border-border/50 bg-muted/20 p-0.5`,children:[`de`,`en`].map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>c(e),className:`rounded px-2 py-1 text-[10px] font-medium transition-colors ${n===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,title:g(`app.languages.${e}`),children:e.toUpperCase()},e))}),(0,W.jsx)(V,{variant:`ghost`,size:`icon`,onClick:()=>s(!0),title:g(`header.help`),children:(0,W.jsx)(lt,{className:`h-4 w-4`})}),(0,W.jsx)(`kbd`,{className:`hidden lg:inline-flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono px-1.5 py-0.5 rounded border border-border/30 bg-muted/20`,children:`⌘K`}),(0,W.jsx)(V,{variant:`ghost`,size:`icon`,onClick:l,title:g(`commandPalette.commands.themeDark.description`),children:t?(0,W.jsx)(Rt,{className:`h-4 w-4`}):(0,W.jsx)(Ht,{className:`h-4 w-4`})})]})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-6 gap-2 sm:flex sm:flex-wrap sm:items-center sm:gap-2`,children:[(0,W.jsxs)(V,{variant:`outline`,size:`sm`,onClick:p,title:g(`emptyState.autoImport`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm`,children:[(0,W.jsx)(It,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:g(`header.import`)})]}),(0,W.jsxs)(V,{variant:`outline`,size:`sm`,onClick:f,title:g(`emptyState.uploadFile`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm`,children:[(0,W.jsx)(Nt,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:g(`header.upload`)})]}),(0,W.jsx)(`div`,{className:`contents sm:block sm:w-px sm:h-5 sm:bg-border/50`}),(0,W.jsx)(`div`,{className:`contents sm:block`,children:m}),(0,W.jsx)(`div`,{className:`contents sm:block`,children:h}),(0,W.jsxs)(V,{variant:`outline`,size:`sm`,onClick:u,title:g(`commandPalette.commands.exportCsv.label`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm`,children:[(0,W.jsx)(rt,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:g(`header.csv`)})]}),(0,W.jsx)(`div`,{className:`contents sm:block sm:w-px sm:h-5 sm:bg-border/50`}),(0,W.jsxs)(V,{variant:`ghost`,size:`sm`,onClick:d,title:g(`commandPalette.commands.delete.label`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm text-muted-foreground hover:text-destructive hover:bg-destructive/10`,children:[(0,W.jsx)(Ft,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{className:`sm:sr-only`,children:g(`header.delete`)})]})]}),(0,W.jsx)(Ar,{open:r,onOpenChange:s})]})}var Pr=e(t()),Fr=ce,Ir=ie,Lr=U.forwardRef(({className:e,children:t,...n},r)=>(0,W.jsxs)(re,{ref:r,className:O(`flex h-9 w-full items-center justify-between gap-2 rounded-md border border-border bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,W.jsx)(se,{asChild:!0,children:(0,W.jsx)(Ye,{className:`h-4 w-4 opacity-50`})})]}));Lr.displayName=`SelectTrigger`;var Rr=U.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,W.jsx)(oe,{children:(0,W.jsx)(ae,{ref:i,className:O(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,n===`popper`&&`translate-y-1`,e),position:n,...r,children:(0,W.jsx)(le,{className:O(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t})})}));Rr.displayName=`SelectContent`;var zr=U.forwardRef(({className:e,children:t,...n},r)=>(0,W.jsx)(T,{ref:r,className:O(`relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:(0,W.jsx)(ne,{children:t})}));zr.displayName=`SelectItem`;function Br(e){if(!e)return null;let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r)}function Vr(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0).getDate(),a=(r.getDay()+6)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=i;e++)o.push(new Date(t,n,e));for(;o.length%7!=0;)o.push(null);return o}function Hr(e,t,n){if(e)return null;if(!t&&!n)return`all`;if(!t||!n)return null;let r=new Date;r.setHours(0,0,0,0);let i=ze,a=e=>{switch(e){case`7d`:{let e=new Date(r);return e.setDate(r.getDate()-6),t===i(e)&&n===i(r)}case`30d`:{let e=new Date(r);return e.setDate(r.getDate()-29),t===i(e)&&n===i(r)}case`month`:return t===i(new Date(r.getFullYear(),r.getMonth(),1))&&n===i(r);case`year`:return t===i(new Date(r.getFullYear(),0,1))&&n===i(r);default:return!1}};for(let e of[`7d`,`30d`,`month`,`year`])if(a(e))return e;return null}function Ur({label:e,value:t,onChange:n}){let{t:r}=k(),[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(null),[l,u]=(0,U.useState)({top:0,left:0,width:292}),d=(0,U.useMemo)(()=>Br(t),[t]),[f,p]=(0,U.useState)(()=>d??Br(Me())??new Date),m=(0,U.useMemo)(()=>Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(Pe(),{weekday:`short`}).format(new Date(Date.UTC(2024,0,1+t))).replace(`.`,``).slice(0,2)),[]),h=(0,U.useMemo)(()=>f.toLocaleDateString(Pe(),{month:`long`,year:`numeric`}),[f]),g=(0,U.useMemo)(()=>Vr(f),[f]),_=Me();return(0,U.useEffect)(()=>{d&&p(new Date(d.getFullYear(),d.getMonth(),1))},[d]),(0,U.useEffect)(()=>{if(!i)return;let e=()=>{let e=s.current?.getBoundingClientRect();if(!e)return;let t=window.innerWidth,n=window.innerHeight,r=Math.min(Math.max(12,e.left),Math.max(12,t-292-12));u({top:e.bottom+330>n-12&&e.top>330?Math.max(12,e.top-330-8):Math.min(n-330-12,e.bottom+8),left:r,width:292})};e();let t=e=>{let t=e.target;!o.current?.contains(t)&&!c.current?.contains(t)&&a(!1)},n=e=>{e.key===`Escape`&&a(!1)};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),document.addEventListener(`mousedown`,t),document.addEventListener(`keydown`,n),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0),document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,n)}},[i]),(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.jsx)(`button`,{ref:s,type:`button`,onClick:()=>a(e=>!e),className:`flex h-10 w-full items-center justify-between gap-3 rounded-md border border-border bg-background px-3 pr-14 text-left text-sm transition-colors hover:bg-accent/40`,children:(0,W.jsx)(`span`,{className:O(`truncate`,t?`text-foreground`:`text-muted-foreground`),children:t?I(t,`long`):e})}),t&&(0,W.jsx)(`button`,{type:`button`,"aria-label":r(`filterBar.clearDate`,{label:e}),onClick:()=>n(void 0),className:`absolute right-8 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,W.jsx)(Ot,{className:`h-3.5 w-3.5`})}),(0,W.jsx)(pt,{className:`pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),i&&typeof document<`u`&&(0,Pr.createPortal)((0,W.jsxs)(`div`,{ref:c,className:`fixed z-[999] rounded-xl border border-border/80 bg-card/98 p-3 shadow-2xl backdrop-blur-xl`,style:{top:l.top,left:l.left,width:l.width},children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>p(e=>new Date(e.getFullYear(),e.getMonth()-1,1)),className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background/70 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,"aria-label":r(`common.previousMonth`),children:(0,W.jsx)(ut,{className:`h-4 w-4`})}),(0,W.jsx)(`div`,{className:`text-sm font-medium capitalize`,children:h}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>p(e=>new Date(e.getFullYear(),e.getMonth()+1,1)),className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background/70 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,"aria-label":r(`common.nextMonth`),children:(0,W.jsx)(ct,{className:`h-4 w-4`})})]}),(0,W.jsx)(`div`,{className:`mb-2 grid grid-cols-7 gap-1`,children:m.map(e=>(0,W.jsx)(`div`,{className:`px-1 py-1 text-center text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e},e))}),(0,W.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:g.map((e,r)=>{if(!e)return(0,W.jsx)(`div`,{className:`h-9`},`empty-${r}`);let i=ze(e);return(0,W.jsx)(`button`,{type:`button`,onClick:()=>{n(i),a(!1)},className:O(`h-9 rounded-md text-sm font-medium transition-colors`,t===i?`bg-primary text-primary-foreground shadow-sm`:i===_?`border border-primary/50 bg-primary/10 text-foreground hover:bg-primary/15`:`text-foreground hover:bg-accent`),children:e.getDate()},i)})}),(0,W.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 border-t border-border/70 pt-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n(void 0),className:`rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:r(`common.reset`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{let e=_;p(Br(e)??new Date),n(e),a(!1)},className:`rounded-md bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90`,children:r(`common.today`)})]})]}),document.body)]})}function Wr({viewMode:e,onViewModeChange:t,selectedMonth:n,onMonthChange:r,availableMonths:i,availableProviders:a,selectedProviders:o,onToggleProvider:s,onClearProviders:c,allModels:l,selectedModels:u,onToggleModel:d,onClearModels:f,startDate:p,endDate:m,onStartDateChange:h,onEndDateChange:g,onApplyPreset:_,onResetAll:v}){let{t:y}=k(),b=(0,U.useMemo)(()=>Hr(n,p,m),[n,p,m]),x=n!==null||o.length>0||u.length>0||!!(p||m)||e!==`daily`;return(0,W.jsx)(`div`,{className:`rounded-2xl border border-border/50 bg-card/40 px-3 py-3 backdrop-blur-xl`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`font-semibold uppercase tracking-[0.14em]`,children:y(`filterBar.status`)}),(0,W.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:o.length>0?y(`filterBar.providersActive`,{count:o.length}):y(`common.allProviders`)}),(0,W.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:u.length>0?y(`filterBar.modelsActive`,{count:u.length}):y(`common.allModels`)}),(p||m)&&(0,W.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:y(`filterBar.dateFilterActive`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>v(),className:`ml-auto inline-flex items-center rounded-full border border-border px-2.5 py-0.5 text-[11px] font-medium text-foreground transition-all duration-200 hover:bg-accent hover:border-accent disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:border-border`,disabled:!x,children:y(`filterBar.resetAll`)})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 xl:grid-cols-[160px_190px_1fr]`,children:[(0,W.jsxs)(Fr,{value:e,onValueChange:e=>t(e),children:[(0,W.jsx)(Lr,{className:`w-full`,"aria-label":y(`filterBar.viewModeLabel`),children:(0,W.jsx)(Ir,{})}),(0,W.jsx)(Rr,{children:[`daily`,`monthly`,`yearly`].map(e=>(0,W.jsx)(zr,{value:e,children:y(`viewModes.${e}`)},e))})]}),(0,W.jsxs)(Fr,{value:n??`all`,onValueChange:e=>r(e===`all`?null:e),children:[(0,W.jsx)(Lr,{className:`w-full`,"aria-label":y(`filterBar.focusMonthLabel`),children:(0,W.jsx)(Ir,{})}),(0,W.jsxs)(Rr,{children:[(0,W.jsx)(zr,{value:`all`,children:y(`common.allMonths`)}),i.map(e=>(0,W.jsx)(zr,{value:e,children:Re(e)},e))]})]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[{key:`7d`,label:y(`filterBar.presets.7d`)},{key:`30d`,label:y(`filterBar.presets.30d`)},{key:`month`,label:y(`filterBar.presets.month`)},{key:`year`,label:y(`filterBar.presets.year`)},{key:`all`,label:y(`filterBar.presets.all`)}].map(e=>(0,W.jsx)(`button`,{onClick:()=>_(e.key),className:O(`rounded-full px-3 py-1.5 text-xs font-medium border transition-all duration-200 min-w-[48px]`,b===e.key?`bg-primary text-primary-foreground border-primary shadow-[0_0_0_1px_rgba(255,255,255,0.06)]`:`border-border hover:bg-accent hover:border-accent`),children:e.label},e.key))})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsx)(Ur,{label:y(`common.startDate`),onChange:h,...p?{value:p}:{}}),(0,W.jsx)(`span`,{className:`hidden md:inline text-xs text-muted-foreground`,children:y(`filterBar.until`)}),(0,W.jsx)(Ur,{label:y(`common.endDate`),onChange:g,...m?{value:m}:{}}),(0,W.jsx)(`button`,{onClick:()=>{h(void 0),g(void 0)},className:`rounded-full px-3 py-2 text-xs font-medium border border-border transition-all duration-200 hover:bg-accent hover:border-accent`,children:y(`filterBar.resetDateRange`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:y(`filterBar.providers`)}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[a.map(e=>{let t=o.includes(e);return(0,W.jsx)(`button`,{onClick:()=>s(e),className:O(`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-semibold cursor-pointer border transition-all duration-200`,t||o.length===0?Ve(e):`border-border text-muted-foreground hover:bg-accent hover:text-foreground`),style:t||o.length===0?Ee(e):void 0,children:e},e)}),o.length>0&&(0,W.jsx)(`button`,{onClick:c,className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium border border-border transition-all duration-200 hover:bg-accent`,children:y(`common.reset`)})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:y(`filterBar.models`)}),u.length>0&&(0,W.jsx)(`button`,{onClick:f,className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium border border-border transition-all duration-200 hover:bg-accent`,children:y(`filterBar.resetModels`)})]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>{let t=u.includes(e),n=B(e);return(0,W.jsxs)(`button`,{onClick:()=>d(e),className:O(`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium cursor-pointer`,`border transition-all duration-200 hover:scale-[1.03]`,t||u.length===0?`opacity-100`:`opacity-40 hover:opacity-70`),style:{borderColor:n,backgroundColor:t||u.length===0?`${n}20`:`transparent`,color:n},children:[(0,W.jsx)(`span`,{className:`w-2 h-2 rounded-full mr-1.5`,style:{backgroundColor:n}}),e]},e)})})]})]})]})})}var K=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(C.div,{ref:n,...t,initial:{opacity:0,y:14},whileInView:{opacity:1,y:0},viewport:{once:!0,amount:.15},transition:{duration:.35,ease:`easeOut`},className:O(`relative rounded-xl border border-border/50 bg-card/80 backdrop-blur-xl text-card-foreground shadow-[var(--shadow-card)] transition-all duration-300 hover:shadow-[var(--shadow-card-hover)] hover:border-border/80`,e)}));K.displayName=`Card`;var Gr=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,className:O(`flex flex-col space-y-1.5 p-4`,e),...t}));Gr.displayName=`CardHeader`;var Kr=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`h3`,{ref:n,className:O(`font-semibold leading-none tracking-tight`,e),...t}));Kr.displayName=`CardTitle`;var q=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`div`,{ref:n,className:O(`p-4 pt-0`,e),...t}));q.displayName=`CardContent`;var qr=U.forwardRef(({className:e,...t},n)=>(0,W.jsx)(`p`,{ref:n,className:O(`text-xs text-muted-foreground`,e),...t}));qr.displayName=`CardDescription`;function J({children:e,delay:t=0,duration:n=.5,className:r,direction:i=`up`}){return(0,W.jsx)(C.div,{initial:{opacity:0,...{up:{y:20},down:{y:-20},left:{x:20},right:{x:-20},none:{}}[i]},whileInView:{opacity:1,x:0,y:0},viewport:{once:!0,amount:.2},transition:{duration:n,delay:t,ease:`easeOut`},className:r,children:e})}function Jr({onUpload:e,onAutoImport:t,onOpenSettings:n}){let{t:r}=k();return(0,W.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 bg-background`,children:(0,W.jsx)(J,{delay:0,duration:.45,children:(0,W.jsxs)(K,{className:`p-10 max-w-md w-full text-center space-y-6 border-primary/20 shadow-xl shadow-primary/5`,children:[(0,W.jsx)(`div`,{className:`mx-auto w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,W.jsx)(Ze,{className:`h-8 w-8 text-primary`})}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`h1`,{className:`text-3xl font-bold tracking-tight`,children:[(0,W.jsx)(`span`,{className:`text-primary`,children:`TT`}),`Dash`]}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:[`v`,ye]})]}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed`,children:r(`emptyState.description`)}),(0,W.jsxs)(V,{onClick:t,size:`lg`,className:`gap-2 w-full`,children:[(0,W.jsx)(It,{className:`h-4 w-4`}),r(`emptyState.autoImport`)]}),(0,W.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:r(`emptyState.or`)}),(0,W.jsxs)(V,{onClick:e,variant:`outline`,size:`lg`,className:`gap-2 w-full`,children:[(0,W.jsx)(Nt,{className:`h-4 w-4`}),r(`emptyState.uploadFile`)]}),(0,W.jsxs)(V,{onClick:n,variant:`ghost`,size:`lg`,className:`gap-2 w-full`,children:[(0,W.jsx)(yt,{className:`h-4 w-4`}),r(`emptyState.openSettings`)]})]})})})}function Yr({title:e,description:t,details:n,detailLabel:r,actions:i}){return(0,W.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 bg-background`,children:(0,W.jsx)(J,{delay:0,duration:.45,children:(0,W.jsxs)(K,{className:`p-8 max-w-xl w-full space-y-6 border-destructive/20 shadow-xl shadow-destructive/5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,W.jsx)(`div`,{className:`mt-1 flex h-12 w-12 items-center justify-center rounded-2xl bg-destructive/10 text-destructive`,children:(0,W.jsx)(St,{className:`h-6 w-6`})}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:t})]})]}),n.length>0?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-muted/20 p-4`,children:[(0,W.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:r}),(0,W.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-foreground`,children:n.map((e,t)=>(0,W.jsx)(`li`,{children:e},t))})]}):null,(0,W.jsx)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap`,children:i.map((e,t)=>(0,W.jsxs)(V,{onClick:e.onClick,variant:e.variant??`outline`,className:`gap-2`,children:[t===0?(0,W.jsx)(mt,{className:`h-4 w-4`}):null,e.label]},`${e.label}-${t}`))})]})})})}var Xr={datePresets:[`all`,`7d`,`30d`,`month`,`year`],viewModes:[`daily`,`monthly`,`yearly`],sectionDefinitions:[{id:`insights`,domId:`insights`,labelKey:`helpPanel.sectionLabels.insights`},{id:`metrics`,domId:`metrics`,labelKey:`helpPanel.sectionLabels.metrics`},{id:`today`,domId:`today`,labelKey:`helpPanel.sectionLabels.today`},{id:`currentMonth`,domId:`current-month`,labelKey:`helpPanel.sectionLabels.currentMonth`},{id:`activity`,domId:`activity`,labelKey:`helpPanel.sectionLabels.activity`},{id:`forecastCache`,domId:`forecast-cache`,labelKey:`helpPanel.sectionLabels.forecastCache`},{id:`limits`,domId:`limits`,labelKey:`helpPanel.sectionLabels.limits`},{id:`costAnalysis`,domId:`charts`,labelKey:`helpPanel.sectionLabels.costAnalysis`},{id:`tokenAnalysis`,domId:`token-analysis`,labelKey:`helpPanel.sectionLabels.tokenAnalysis`},{id:`requestAnalysis`,domId:`request-analysis`,labelKey:`helpPanel.sectionLabels.requestAnalysis`},{id:`advancedAnalysis`,domId:`advanced-analysis`,labelKey:`helpPanel.sectionLabels.advancedAnalysis`},{id:`comparisons`,domId:`comparisons`,labelKey:`helpPanel.sectionLabels.comparisons`},{id:`tables`,domId:`tables`,labelKey:`helpPanel.sectionLabels.tables`}]},Zr=[`all`,`7d`,`30d`,`month`,`year`],Qr=[`daily`,`monthly`,`yearly`],$r=[`insights`,`metrics`,`today`,`currentMonth`,`activity`,`forecastCache`,`limits`,`costAnalysis`,`tokenAnalysis`,`requestAnalysis`,`advancedAnalysis`,`comparisons`,`tables`];function ei(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ti(e,t,n){if(!Array.isArray(e))throw Error(`Invalid dashboard preferences: "${n}" must be an array.`);let r=e;if(r.find(e=>typeof e!=`string`||!t.includes(e))!==void 0)throw Error(`Invalid dashboard preferences: "${n}" contains unsupported values.`);return r.map(e=>e)}function ni(e){if(!Array.isArray(e))throw Error(`Invalid dashboard preferences: "sectionDefinitions" must be an array.`);return e.map(e=>{if(!ei(e))throw Error(`Invalid dashboard preferences: each "sectionDefinitions" entry must be an object.`);let{id:t,domId:n,labelKey:r}=e;if(typeof t!=`string`||!$r.includes(t))throw Error(`Invalid dashboard preferences: sectionDefinitions contain an unknown id.`);if(typeof n!=`string`||!n.trim())throw Error(`Invalid dashboard preferences: sectionDefinitions require a domId.`);if(typeof r!=`string`||!r.trim())throw Error(`Invalid dashboard preferences: sectionDefinitions require a labelKey.`);return{id:t,domId:n,labelKey:r}})}function ri(e){if(!ei(e))throw Error(`Invalid dashboard preferences: expected an object.`);return{datePresets:ti(e.datePresets,Zr,`datePresets`),viewModes:ti(e.viewModes,Qr,`viewModes`),sectionDefinitions:ni(e.sectionDefinitions)}}var ii=ri(Xr),ai=ii.datePresets,oi=ii.viewModes,si=ii.sectionDefinitions,ci=Object.fromEntries(si.map(e=>[e.id,e])),li={viewMode:`daily`,datePreset:`all`,providers:[],models:[]};function ui(){return si.reduce((e,t)=>({...e,[t.id]:!0}),{})}function di(){return si.map(e=>e.id)}function fi(e){return Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))]:[]}function pi(e){return ai.includes(e)?e:`all`}function mi(e){return oi.includes(e)?e:`daily`}function hi(e){let t=e&&typeof e==`object`?e:{};return{viewMode:mi(t.viewMode),datePreset:pi(t.datePreset),providers:fi(t.providers),models:fi(t.models)}}function gi(e){let t=e&&typeof e==`object`?e:{},n=ui();return si.reduce((e,r)=>({...e,[r.id]:typeof t[r.id]==`boolean`?!!t[r.id]:n[r.id]}),{})}function _i(e){let t=di();if(!Array.isArray(e))return t;let n=e.filter(e=>typeof e==`string`&&t.includes(e)),r=[...new Set(n)],i=t.filter(e=>!r.includes(e));return[...r,...i]}var vi={insights:(0,W.jsx)(jt,{className:`h-4 w-4`}),metrics:(0,W.jsx)(Ze,{className:`h-4 w-4`}),today:(0,W.jsx)(ft,{className:`h-4 w-4`}),currentMonth:(0,W.jsx)(dt,{className:`h-4 w-4`}),activity:(0,W.jsx)(ft,{className:`h-4 w-4`}),forecastCache:(0,W.jsx)(Qe,{className:`h-4 w-4`}),limits:(0,W.jsx)(yt,{className:`h-4 w-4`}),costAnalysis:(0,W.jsx)(Mt,{className:`h-4 w-4`}),tokenAnalysis:(0,W.jsx)(Ge,{className:`h-4 w-4`}),requestAnalysis:(0,W.jsx)(Qe,{className:`h-4 w-4`}),advancedAnalysis:(0,W.jsx)(jt,{className:`h-4 w-4`}),comparisons:(0,W.jsx)(Qe,{className:`h-4 w-4`}),tables:(0,W.jsx)(Et,{className:`h-4 w-4`})},yi={insights:[`summary`,`insight`],metrics:[`kpi`,`zahlen`],today:[`today`,`heute`],currentMonth:[`monat`,`current month`],activity:[`heatmap`,`aktivität`],forecastCache:[`forecast`,`cache`,`roi`],limits:[`limits`,`subscriptions`,`budget`,`anbieter limits`],costAnalysis:[`charts`,`kostenanalyse`],tokenAnalysis:[`tokens`,`token analyse`],requestAnalysis:[`requests`,`request analyse`,`anfragen`],advancedAnalysis:[`advanced analysis`,`distributions`,`risk`,`verteilungen`],comparisons:[`anomalie`,`vergleich`],tables:[`table`,`details`]},bi={limits:[`limits sektion`,`subscriptions sektion`],tokenAnalysis:[`token chart`],requestAnalysis:[`request chart`,`request donut`]};function xi(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^\p{L}\p{N}]+/gu,` `).trim()}function Si(e){return xi([e.label,e.description,...e.keywords??[],...e.aliases??[]].filter(Boolean).join(` `))}function Ci(e,t){if(!t)return 1;let n=xi(t);if(!n)return 1;let r=Si(e),i=n.split(/\s+/).filter(Boolean);if(i.length===0)return 1;let a=0;for(let t of i){if(!r.includes(t))return 0;if(xi(e.label)===t){a+=120;continue}if(xi(e.label).startsWith(t)){a+=80;continue}if((e.aliases??[]).some(e=>xi(e)===t)){a+=70;continue}if((e.keywords??[]).some(e=>xi(e).startsWith(t))){a+=55;continue}if(r.includes(` ${t}`)||r.startsWith(t)){a+=35;continue}a+=15}return a}function wi({isDark:e,availableProviders:t,selectedProviders:n,availableModels:r,selectedModels:i,hasTodaySection:a,hasMonthSection:o,hasRequestSection:s,sectionVisibility:c,sectionOrder:l,reportGenerating:u,onToggleTheme:d,onExportCSV:f,onGenerateReport:p,onDelete:m,onUpload:h,onAutoImport:g,onOpenSettings:_,onScrollTo:v,onViewModeChange:y,onApplyPreset:b,onToggleProvider:x,onToggleModel:S,onClearProviders:ee,onClearModels:C,onClearDateRange:te,onResetAll:w,onHelp:ne,onLanguageChange:re}){let{t:T}=k(),[ie,ae]=(0,U.useState)(!1),[oe,se]=(0,U.useState)(``),ce=(0,U.useMemo)(()=>({insights:!0,metrics:!0,today:a,currentMonth:o,activity:!0,forecastCache:!0,limits:!0,costAnalysis:!0,tokenAnalysis:!0,requestAnalysis:s,advancedAnalysis:!0,comparisons:!0,tables:!0}),[o,s,a]);(0,U.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),ae(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let le=(0,U.useMemo)(()=>l.flatMap(e=>{let t=ci[e];if(!c[e]||!ce[e])return[];let n=T(t.labelKey);return[{id:`section-${t.id}`,label:T(`commandPalette.commands.goToSection.label`,{section:n}),description:T(`commandPalette.commands.goToSection.description`,{section:n}),keywords:[n,t.domId,...yi[t.id]],icon:vi[t.id],action:()=>v(t.domId),group:T(`commandPalette.groups.navigation`),testId:`command-section-${t.id}`,...bi[t.id]?{aliases:bi[t.id]}:{}}]}),[v,ce,l,c,T]),O=(0,U.useMemo)(()=>[{id:`auto-import`,label:T(`commandPalette.commands.autoImport.label`),description:T(`commandPalette.commands.autoImport.description`),keywords:[`toktrack`,`import`,`load`,`sync`],aliases:[`auto import`,`daten importieren`],icon:(0,W.jsx)(It,{className:`h-4 w-4`}),action:g,group:T(`commandPalette.groups.actions`)},{id:`settings-open`,label:T(`commandPalette.commands.openSettings.label`),description:T(`commandPalette.commands.openSettings.description`),keywords:[`settings`,`limits`,`subscription`,`anbieter limit`,`backup`],aliases:[`settings dialog`,`einstellungen öffnen`,`provider limits`],icon:(0,W.jsx)(yt,{className:`h-4 w-4`}),action:_,group:T(`commandPalette.groups.actions`)},{id:`csv`,label:T(`commandPalette.commands.exportCsv.label`),description:T(`commandPalette.commands.exportCsv.description`),keywords:[`download`,`export`,`csv`],aliases:[`csv download`,`daten exportieren`],shortcut:`⌘E`,icon:(0,W.jsx)(rt,{className:`h-4 w-4`}),action:f,group:T(`commandPalette.groups.actions`)},{id:`report`,label:T(u?`commandPalette.commands.generateReport.labelLoading`:`commandPalette.commands.generateReport.label`),description:T(`commandPalette.commands.generateReport.description`),keywords:[`pdf`,`report`,`bericht`,`export`],aliases:[`report export`,`pdf export`,`bericht generieren`],icon:(0,W.jsx)(rt,{className:`h-4 w-4`}),action:p,group:T(`commandPalette.groups.actions`)},{id:`upload`,label:T(`commandPalette.commands.upload.label`),description:T(`commandPalette.commands.upload.description`),keywords:[`upload`,`file`,`json`,`import`],aliases:[`datei laden`,`json import`],shortcut:`⌘U`,icon:(0,W.jsx)(Nt,{className:`h-4 w-4`}),action:h,group:T(`commandPalette.groups.actions`)},{id:`delete`,label:T(`commandPalette.commands.delete.label`),description:T(`commandPalette.commands.delete.description`),keywords:[`reset data`,`clear data`,`delete`],aliases:[`daten reset`,`alles loeschen`],icon:(0,W.jsx)(Ft,{className:`h-4 w-4`}),action:m,group:T(`commandPalette.groups.actions`)},{id:`view-daily`,label:T(`commandPalette.commands.viewDaily.label`),description:T(`commandPalette.commands.viewDaily.description`),keywords:[`daily`,`tage`,`tag`,`tagesansicht`],aliases:[`daily view`],icon:(0,W.jsx)(ft,{className:`h-4 w-4`}),action:()=>y(`daily`),group:T(`commandPalette.groups.filters`)},{id:`view-monthly`,label:T(`commandPalette.commands.viewMonthly.label`),description:T(`commandPalette.commands.viewMonthly.description`),keywords:[`monthly`,`monate`,`monat`,`monatsansicht`],aliases:[`monthly view`],icon:(0,W.jsx)(Mt,{className:`h-4 w-4`}),action:()=>y(`monthly`),group:T(`commandPalette.groups.filters`)},{id:`view-yearly`,label:T(`commandPalette.commands.viewYearly.label`),description:T(`commandPalette.commands.viewYearly.description`),keywords:[`yearly`,`jahre`,`jahr`,`jahresansicht`],aliases:[`yearly view`],icon:(0,W.jsx)(Ge,{className:`h-4 w-4`}),action:()=>y(`yearly`),group:T(`commandPalette.groups.filters`)},{id:`preset-7d`,label:T(`commandPalette.commands.preset7d.label`),description:T(`commandPalette.commands.preset7d.description`),keywords:[`7d`,`7 tage`],icon:(0,W.jsx)(dt,{className:`h-4 w-4`}),action:()=>b(`7d`),group:T(`commandPalette.groups.filters`)},{id:`preset-30d`,label:T(`commandPalette.commands.preset30d.label`),description:T(`commandPalette.commands.preset30d.description`),keywords:[`30d`,`30 tage`],icon:(0,W.jsx)(dt,{className:`h-4 w-4`}),action:()=>b(`30d`),group:T(`commandPalette.groups.filters`)},{id:`preset-month`,label:T(`commandPalette.commands.presetMonth.label`),description:T(`commandPalette.commands.presetMonth.description`),keywords:[`current month`,`monat`],icon:(0,W.jsx)(dt,{className:`h-4 w-4`}),action:()=>b(`month`),group:T(`commandPalette.groups.filters`)},{id:`preset-year`,label:T(`commandPalette.commands.presetYear.label`),description:T(`commandPalette.commands.presetYear.description`),keywords:[`current year`,`jahr`],icon:(0,W.jsx)(dt,{className:`h-4 w-4`}),action:()=>b(`year`),group:T(`commandPalette.groups.filters`)},{id:`preset-all`,label:T(`commandPalette.commands.presetAll.label`),description:T(`commandPalette.commands.presetAll.description`),keywords:[`all`,`alles`],icon:(0,W.jsx)(zt,{className:`h-4 w-4`}),action:()=>b(`all`),group:T(`commandPalette.groups.filters`)},{id:`clear-providers`,label:T(`commandPalette.commands.clearProviders.label`),description:T(`commandPalette.commands.clearProviders.description`),keywords:[`provider`,`anbieter`,`clear`],icon:(0,W.jsx)(Tt,{className:`h-4 w-4`}),action:ee,group:T(`commandPalette.groups.filters`)},{id:`clear-models`,label:T(`commandPalette.commands.clearModels.label`),description:T(`commandPalette.commands.clearModels.description`),keywords:[`models`,`modelle`,`clear`],icon:(0,W.jsx)(Tt,{className:`h-4 w-4`}),action:C,group:T(`commandPalette.groups.filters`)},{id:`clear-dates`,label:T(`commandPalette.commands.clearDates.label`),description:T(`commandPalette.commands.clearDates.description`),keywords:[`date`,`datum`,`range`,`clear`],icon:(0,W.jsx)(zt,{className:`h-4 w-4`}),action:te,group:T(`commandPalette.groups.filters`)},{id:`reset-all`,label:T(`commandPalette.commands.resetAll.label`),description:T(`commandPalette.commands.resetAll.description`),keywords:[`reset all`,`alles zurücksetzen`,`default`,`clear filters`],aliases:[`reset dashboard`,`alles reset`,`filter reset`],icon:(0,W.jsx)(zt,{className:`h-4 w-4`}),action:w,group:T(`commandPalette.groups.filters`)},{id:`top`,label:T(`commandPalette.commands.scrollTop.label`),description:T(`commandPalette.commands.scrollTop.description`),keywords:[`top`,`start`,`anfang`],shortcut:`⌘↑`,icon:(0,W.jsx)(vt,{className:`h-4 w-4`}),action:()=>window.scrollTo({top:0,behavior:`smooth`}),group:T(`commandPalette.groups.navigation`)},{id:`bottom`,label:T(`commandPalette.commands.scrollBottom.label`),description:T(`commandPalette.commands.scrollBottom.description`),keywords:[`bottom`,`ende`],icon:(0,W.jsx)(Pt,{className:`h-4 w-4`}),action:()=>window.scrollTo({top:document.body.scrollHeight,behavior:`smooth`}),group:T(`commandPalette.groups.navigation`)},{id:`filters`,label:T(`commandPalette.commands.filters.label`),description:T(`commandPalette.commands.filters.description`),keywords:[`filterbar`,`filter`],icon:(0,W.jsx)(Tt,{className:`h-4 w-4`}),action:()=>v(`filters`),group:T(`commandPalette.groups.navigation`)},...le,{id:`theme`,label:T(e?`commandPalette.commands.themeLight.label`:`commandPalette.commands.themeDark.label`),description:T(`commandPalette.commands.themeDark.description`),keywords:[`theme`,`dark`,`light`],shortcut:`⌘D`,icon:e?(0,W.jsx)(Rt,{className:`h-4 w-4`}):(0,W.jsx)(Ht,{className:`h-4 w-4`}),action:d,group:T(`commandPalette.groups.view`)},{id:`language-de`,label:T(`commandPalette.commands.languageGerman.label`),description:T(`commandPalette.commands.languageGerman.description`),keywords:[`language`,`sprache`,`deutsch`,`german`,`locale`],aliases:[`switch german`,`auf deutsch`,`sprache deutsch`],icon:(0,W.jsx)(Bt,{className:`h-4 w-4`}),action:()=>re(`de`),group:T(`commandPalette.groups.language`)},{id:`language-en`,label:T(`commandPalette.commands.languageEnglish.label`),description:T(`commandPalette.commands.languageEnglish.description`),keywords:[`language`,`sprache`,`english`,`englisch`,`locale`],aliases:[`switch english`,`auf englisch`,`sprache english`],icon:(0,W.jsx)(Bt,{className:`h-4 w-4`}),action:()=>re(`en`),group:T(`commandPalette.groups.language`)},{id:`help`,label:T(`commandPalette.commands.help.label`),description:T(`commandPalette.commands.help.description`),keywords:[`shortcut`,`hilfe`],shortcut:`?`,icon:(0,W.jsx)(lt,{className:`h-4 w-4`}),action:ne,group:T(`commandPalette.groups.help`)}],[e,g,_,f,p,h,m,y,b,ee,C,te,w,v,le,u,d,re,ne,T]),ue=(0,U.useMemo)(()=>t.map(e=>{let t=n.includes(e);return{id:`provider-${e}`,label:`${T(t?`commandPalette.commands.clearProviders.label`:`common.provider`)}: ${e}`,description:t?`${T(`commandPalette.commands.clearProviders.description`)}: ${e}`:`${T(`common.provider`)} ${e}`,keywords:[`anbieter`,`provider`,e.toLowerCase()],aliases:[`filter ${e.toLowerCase()}`,`${e.toLowerCase()} daten`],icon:(0,W.jsx)(Tt,{className:`h-4 w-4`}),action:()=>x(e),group:T(`commandPalette.groups.providers`)}}),[t,n,x,T]),A=(0,U.useMemo)(()=>r.map(e=>{let t=i.includes(e);return{id:`model-${e}`,label:`${T(t?`commandPalette.commands.clearModels.label`:`common.model`)}: ${e}`,description:t?`${T(`commandPalette.commands.clearModels.description`)}: ${e}`:`${T(`common.model`)} ${e}`,keywords:[`modell`,`model`,e.toLowerCase()],aliases:[`filter ${e.toLowerCase()}`,`${e.toLowerCase()} requests`,`${e.toLowerCase()} kosten`],icon:(0,W.jsx)(Ge,{className:`h-4 w-4`}),action:()=>S(e),group:T(`commandPalette.groups.models`)}}),[r,i,S,T]),me=(0,U.useMemo)(()=>[...O,...ue,...A],[O,ue,A]),he=(0,U.useMemo)(()=>me.map((e,t)=>({cmd:e,score:Ci(e,oe),index:t})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score||e.index-t.index).map(e=>e.cmd),[me,oe]),ge=(0,U.useMemo)(()=>he.slice(0,9),[he]),_e=(0,U.useMemo)(()=>Array.from(new Set(he.map(e=>e.group))),[he]),ve=e=>{ae(!1),se(``),e.action()};return(0,U.useEffect)(()=>{if(!ie)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key))return;let t=ge[Number(e.key)-1];t&&(e.preventDefault(),ve(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[ie,ge]),(0,U.useEffect)(()=>{!ie&&oe&&se(``)},[ie,oe]),(0,W.jsx)(pe,{open:ie,onOpenChange:ae,children:(0,W.jsxs)(de,{className:`p-0 max-w-md overflow-hidden`,children:[(0,W.jsx)(D,{className:`sr-only`,children:T(`commandPalette.title`)}),(0,W.jsx)(fe,{className:`sr-only`,children:T(`commandPalette.description`)}),(0,W.jsxs)(E,{className:`bg-transparent`,shouldFilter:!1,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3`,children:[(0,W.jsx)(bt,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,W.jsx)(E.Input,{placeholder:T(`commandPalette.placeholder`),value:oe,onValueChange:se,className:`flex h-11 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground`})]}),(0,W.jsxs)(E.List,{className:`max-h-[300px] overflow-y-auto p-2`,children:[(0,W.jsx)(E.Empty,{className:`py-6 text-center text-sm text-muted-foreground`,children:T(`commandPalette.empty`)}),_e.map(e=>(0,W.jsx)(E.Group,{heading:e,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,children:he.filter(t=>t.group===e).map(e=>{let t=ge.findIndex(t=>t.id===e.id);return(0,W.jsxs)(E.Item,{value:e.id,"data-testid":e.testId??`command-${e.id}`,onSelect:()=>ve(e),className:`flex items-center gap-2 rounded-md px-2 py-2 text-sm cursor-pointer aria-selected:bg-accent`,children:[e.icon,(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(`div`,{children:e.label}),e.description&&(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]}),e.shortcut&&(0,W.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-0.5 rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:e.shortcut}),t>=0&&(0,W.jsx)(`kbd`,{className:`inline-flex items-center justify-center rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground min-w-6`,children:t+1})]},e.id)})},e))]})]})]})})}function Ti({text:e,className:t}){let{t:n}=k();return(0,W.jsxs)(be,{children:[(0,W.jsx)(me,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":n(`common.showInfo`),"data-info-button":`true`,className:O(`inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors`,t),children:(0,W.jsx)(qe,{className:`h-3.5 w-3.5`})})}),(0,W.jsx)(Te,{side:`top`,className:`max-w-xs text-xs`,children:e})]})}function Ei({children:e,info:t,className:n}){return(0,W.jsxs)(`div`,{className:O(`flex items-center gap-2 min-w-0`,n),children:[e,t&&(0,W.jsx)(Ti,{text:t,className:`shrink-0`})]})}var Di={hasSubscription:!1,subscriptionPrice:0,monthlyLimit:0};function Oi(e){return typeof e!=`number`||!Number.isFinite(e)?0:Math.max(0,Number(e.toFixed(2)))}function ki(e){if(!e||typeof e!=`object`)return{...Di};let t=e;return{hasSubscription:!!t.hasSubscription,subscriptionPrice:Oi(t.subscriptionPrice),monthlyLimit:Oi(t.monthlyLimit)}}function Ai(e,t){let n=t&&typeof t==`object`?t:{},r={};for(let t of e)r[t]=ki(n[t]);return r}function ji(e){let t=e.map(e=>e.date.slice(0,7)).filter(e=>/^\d{4}-\d{2}$/.test(e)).sort();return t.length>0?t[t.length-1]??null:null}function Mi(e){let t=new Map,n=new Map;for(let r of e){let e=r.date.slice(0,7);if(!/^\d{4}-\d{2}$/.test(e))continue;let i=t.get(e)??new Map;for(let e of r.modelBreakdowns){let t=ke(e.modelName);i.set(t,(i.get(t)??0)+e.cost),n.set(t,(n.get(t)??0)+e.cost)}t.set(e,i)}return{months:Array.from(t.keys()).sort(),monthMap:t,providerTotals:n}}var Ni={language:`de`,theme:`dark`,providerLimits:{},defaultFilters:li,sectionVisibility:ui(),sectionOrder:di(),lastLoadedAt:null,lastLoadSource:null,cliAutoLoadActive:!1};function Pi(e){return e===`en`?`en`:`de`}function Fi(e){return e===`light`?`light`:`dark`}function Ii(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=ki(r);return t}function Li(e){return e===`file`||e===`auto-import`||e===`cli-auto-load`?e:null}function Ri(e){if(typeof e!=`string`)return null;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function zi(e){let t=e&&typeof e==`object`?e:{};return{language:Pi(t.language),theme:Fi(t.theme),providerLimits:Ii(t.providerLimits),defaultFilters:hi(t.defaultFilters),sectionVisibility:gi(t.sectionVisibility),sectionOrder:_i(t.sectionOrder),lastLoadedAt:Ri(t.lastLoadedAt),lastLoadSource:Li(t.lastLoadSource),cliAutoLoadActive:!!t.cliAutoLoadActive}}function Bi(e){typeof document>`u`||document.documentElement.classList.toggle(`dark`,e===`dark`)}function Vi(e){let t=e.replace(`,`,`.`).trim();if(!t)return 0;let n=Number.parseFloat(t);return Number.isFinite(n)?Math.max(0,Number(n.toFixed(2))):0}function Hi(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Ui(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))].sort((e,t)=>e.localeCompare(t))}function Wi(e,t){let n={};for(let r of e)n[r]=t[r]??{...Di};return n}function Gi(e,t,n){let r=e.indexOf(t),i=r+n;if(r<0||i<0||i>=e.length)return e;let a=[...e],[o]=a.splice(r,1);return o?(a.splice(i,0,o),a):e}function Ki(e,t,n){if(t===n)return e;let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0)return e;let a=[...e],[o]=a.splice(r,1);if(!o)return e;let s=r<i?i-1:i;return a.splice(s,0,o),a}function qi({open:e,onOpenChange:t,language:n,limitProviders:r,filterProviders:i,models:a,limits:o,defaultFilters:s,sectionVisibility:c,sectionOrder:l,lastLoadedAt:u,lastLoadSource:d,cliAutoLoadActive:f=!1,hasData:p,onSaveSettings:m,onExportSettings:h,onImportSettings:g,onExportData:_,onImportData:v,settingsBusy:y=!1,dataBusy:b=!1}){let{t:x}=k(),[S,ee]=(0,U.useState)(n),[C,te]=(0,U.useState)(()=>Ai(r,o)),[w,ne]=(0,U.useState)(s),[re,T]=(0,U.useState)(c),[ie,ae]=(0,U.useState)(l),[oe,se]=(0,U.useState)(null),[ce,E]=(0,U.useState)(null);(0,U.useEffect)(()=>{e&&(ee(n),te(Ai(r,o)),ne(s),T(c),ae(l),se(null),E(null))},[e,n,r,o,s,c,l]);let le=(0,U.useMemo)(()=>Ui([...i,...w.providers]),[i,w.providers]),A=(0,U.useMemo)(()=>Ui([...a,...w.models]),[a,w.models]),me=(e,t)=>{te(n=>({...n,[e]:{...n[e]??Di,...t}}))},he=async()=>{await m({language:S,providerLimits:Wi(r,C),defaultFilters:{...w,providers:Ui(w.providers),models:Ui(w.models)},sectionVisibility:re,sectionOrder:ie}),t(!1)},_e=()=>{ee(Ni.language),te(Ai(r,{})),ne(li),T(ui()),ae(di()),se(null),E(null)},ve=()=>{ne(li)},ye=()=>{T(ui()),ae(di())},be=()=>{te(Ai(r,{}))},xe=x(d?`settings.modal.sources.${d}`:`settings.modal.sources.unknown`),Se=(0,U.useMemo)(()=>ie.map(e=>ci[e]).filter(e=>e!==void 0),[ie]);return(0,W.jsx)(pe,{open:e,onOpenChange:t,children:(0,W.jsxs)(de,{className:`max-w-5xl max-h-[88vh] overflow-y-auto overflow-x-visible`,children:[(0,W.jsxs)(ue,{className:`overflow-visible`,children:[(0,W.jsx)(Ei,{info:Dr.providerLimits,children:(0,W.jsx)(D,{children:x(`settings.modal.title`)})}),(0,W.jsx)(fe,{children:x(`settings.modal.description`)})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-muted/20 px-4 py-3`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`settings.modal.dataStatus`)}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:x(`settings.modal.lastLoaded`)}),(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:u?Fe(u):x(`common.notAvailable`)})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:x(`settings.modal.loadedVia`)}),(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:xe})]}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:x(`settings.modal.cliAutoLoad`)}),(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(f?`common.enabled`:`common.disabled`)})]})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(Bt,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.languageTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.languageDescription`)})]})]}),(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:ge.map(e=>(0,W.jsx)(V,{type:`button`,"data-testid":`settings-language-${e}`,"aria-pressed":S===e,variant:S===e?`default`:`outline`,onClick:()=>ee(e),children:x(`app.languages.${e}`)},e))})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(Tt,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.defaultFiltersTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.defaultFiltersDescription`)})]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-default-filters`,onClick:ve,disabled:y,children:x(`common.reset`)})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`settings.modal.defaultViewMode`)}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oi.map(e=>(0,W.jsx)(V,{type:`button`,"aria-pressed":w.viewMode===e,variant:w.viewMode===e?`default`:`outline`,onClick:()=>ne(t=>({...t,viewMode:e})),children:x(`settings.modal.viewModes.${e}`)},e))})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`settings.modal.defaultDateRange`)}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ai.map(e=>(0,W.jsx)(V,{type:`button`,"aria-pressed":w.datePreset===e,variant:w.datePreset===e?`default`:`outline`,onClick:()=>ne(t=>({...t,datePreset:e})),children:x(`settings.modal.datePresets.${e}`)},e))})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`settings.modal.filterProviders`)}),le.length===0?(0,W.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:x(`settings.modal.noProviders`)}):(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:le.map(e=>{let t=w.providers.includes(e);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>ne(t=>({...t,providers:Hi(t.providers,e)})),className:O(`inline-flex items-center rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,t?`border-primary/30 bg-primary text-primary-foreground`:Ve(e)),children:e},e)})})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`settings.modal.filterModels`)}),A.length===0?(0,W.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:x(`settings.modal.noModels`)}):(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:A.map(e=>{let t=w.models.includes(e);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>ne(t=>({...t,models:Hi(t.models,e)})),className:O(`inline-flex items-center rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,t?`border-primary/30 bg-primary text-primary-foreground`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent hover:text-foreground`),children:e},e)})})]})]})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(tt,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.sectionVisibilityTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.sectionVisibilityDescription`)})]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-section-visibility`,onClick:ye,disabled:y,children:x(`common.reset`)})]}),(0,W.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:x(`settings.modal.sectionOrderHint`)}),(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:Se.map((e,t)=>{let n=re[e.id];return(0,W.jsxs)(`div`,{"data-section-id":e.id,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),se(e.id),E(e.id)},onDragOver:t=>{t.preventDefault(),ce!==e.id&&E(e.id)},onDragLeave:()=>{ce===e.id&&E(null)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||oe;n&&(ae(t=>Ki(t,n,e.id)),se(null),E(null))},onDragEnd:()=>{se(null),E(null)},className:O(`flex items-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors`,ce===e.id?`border-primary/40 bg-primary/10`:`border-border/70 bg-muted/10`,oe===e.id&&`opacity-70`),children:[(0,W.jsx)(`span`,{className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/60 bg-background/40 text-muted-foreground`,children:(0,W.jsx)(nt,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:x(e.labelKey)}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:x(`settings.modal.positionLabel`,{position:t+1,total:Se.length})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-up-${e.id}`,onClick:()=>ae(t=>Gi(t,e.id,-1)),disabled:t===0,"aria-label":x(`settings.modal.moveSectionUp`,{section:x(e.labelKey)}),children:(0,W.jsx)(vt,{className:`h-4 w-4`})}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-down-${e.id}`,onClick:()=>ae(t=>Gi(t,e.id,1)),disabled:t===Se.length-1,"aria-label":x(`settings.modal.moveSectionDown`,{section:x(e.labelKey)}),children:(0,W.jsx)(Pt,{className:`h-4 w-4`})}),(0,W.jsx)(`button`,{type:`button`,"data-testid":`toggle-section-visibility-${e.id}`,"aria-pressed":n,onClick:()=>T(t=>({...t,[e.id]:!t[e.id]})),className:O(`inline-flex min-w-[88px] items-center justify-center rounded-full border px-3 py-1.5 text-xs font-medium uppercase tracking-[0.12em] transition-colors`,n?`border-emerald-500/30 bg-emerald-500/10 text-foreground`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent hover:text-foreground`),children:x(n?`common.visible`:`common.hidden`)})]})]},e.id)})})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(xt,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.settingsBackupTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.settingsBackupDescription`)})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{variant:`outline`,onClick:h,disabled:y,className:`gap-2`,children:[(0,W.jsx)(rt,{className:`h-4 w-4`}),x(`settings.modal.exportSettings`)]}),(0,W.jsxs)(V,{variant:`outline`,onClick:g,disabled:y,className:`gap-2`,children:[(0,W.jsx)(Nt,{className:`h-4 w-4`}),x(`settings.modal.importSettings`)]})]})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(Xe,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.dataBackupTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.dataBackupDescription`)})]})]}),(0,W.jsx)(`p`,{className:`mt-3 rounded-xl border border-amber-500/20 bg-amber-500/8 px-3 py-2 text-xs leading-relaxed text-amber-200/90`,children:x(`settings.modal.dataImportPolicy`)}),(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:x(`settings.modal.dataImportReplaceHint`)}),(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{variant:`outline`,onClick:_,disabled:!p||b,className:`gap-2`,children:[(0,W.jsx)(rt,{className:`h-4 w-4`}),x(`settings.modal.exportData`)]}),(0,W.jsxs)(V,{variant:`outline`,onClick:v,disabled:b,className:`gap-2`,children:[(0,W.jsx)(Nt,{className:`h-4 w-4`}),x(`settings.modal.importData`)]})]})]})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,W.jsx)(ot,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:x(`settings.modal.providerLimitsTitle`)}),(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:x(`settings.modal.providerLimitsDescription`)})]})]}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-provider-limits`,onClick:be,disabled:y,children:x(`common.reset`)})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:r.length===0?(0,W.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-8 text-sm text-muted-foreground text-center`,children:x(`settings.modal.noProviders`)}):(0,W.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>{let t=C[e]??Di;return(0,W.jsx)(`div`,{"data-provider-id":e,className:`rounded-2xl border border-border/50 bg-background/40 p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium`,Ve(e)),children:e}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>me(e,{hasSubscription:!t.hasSubscription}),className:O(`inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium transition-colors`,t.hasSubscription?`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent`),children:t.hasSubscription?x(`common.enabled`):x(`limits.statuses.noSubscription`)})]})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:w-[420px]`,children:[(0,W.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`limits.modal.subscriptionPerMonth`)}),(0,W.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.subscriptionPrice,disabled:!t.hasSubscription,onChange:t=>me(e,{subscriptionPrice:Vi(t.target.value)}),className:`h-10 w-full rounded-md border border-border bg-background px-3 text-sm disabled:cursor-not-allowed disabled:opacity-50`})]}),(0,W.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:x(`limits.modal.monthlyLimit`)}),(0,W.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.monthlyLimit,onChange:t=>me(e,{monthlyLimit:Vi(t.target.value)}),className:`h-10 w-full rounded-md border border-border bg-background px-3 text-sm`})]})]})]})},e)})})})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/50 pt-4`,children:[(0,W.jsx)(V,{variant:`ghost`,onClick:_e,disabled:y,"data-testid":`reset-all-settings-drafts`,children:x(`common.reset`)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(V,{variant:`ghost`,onClick:()=>t(!1),disabled:y,children:x(`settings.modal.close`)}),(0,W.jsx)(V,{onClick:()=>void he(),disabled:y,children:x(`settings.modal.save`)})]})]})]})})}function Ji({generating:e,onGenerate:t}){let{t:n}=k();return(0,W.jsxs)(V,{variant:`outline`,size:`sm`,onClick:t,disabled:e,title:n(`commandPalette.commands.generateReport.label`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm`,children:[e?(0,W.jsx)(Vt,{className:`h-4 w-4 animate-spin`}):(0,W.jsx)(et,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:n(`header.report`)})]})}function Y({label:e,value:t,subtitle:n,icon:r,trend:i,info:a,className:o}){return(0,W.jsxs)(K,{className:O(`p-4 flex min-h-[122px] flex-col gap-1 transition-transform duration-200 hover:-translate-y-0.5 hover:shadow-lg`,o),children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 text-xs text-muted-foreground font-medium flex items-start gap-1 leading-tight text-balance`,children:[e,a&&(0,W.jsx)(Ti,{text:a})]}),r&&(0,W.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:r})]}),(0,W.jsx)(`div`,{className:`text-2xl font-bold tracking-tight leading-none`,children:t}),(0,W.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-2`,children:[n&&(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground text-pretty`,children:n}),i&&i.value!==0&&(0,W.jsxs)(`span`,{className:O(`text-[10px] font-semibold px-1.5 py-0.5 rounded-md inline-flex items-center gap-0.5`,i.value>0?`text-red-400 bg-red-400/10`:`text-green-400 bg-green-400/10`),children:[i.value>0?`↑`:`↓`,Math.abs(i.value).toFixed(1),`%`,i.label&&` ${i.label}`]})]})]})}function Yi({metrics:e,totalCalendarDays:t,viewMode:n=`daily`}){let{t:r}=k(),i=Pe(),a=e.totalInput>0&&e.totalOutput>0?new Intl.NumberFormat(i,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e.totalInput/e.totalOutput):null,o=t&&n===`daily`?e.activeDays/t*100:null,s=e.topModel?`${P(e.topModel.cost)} · ${r(`metricCards.primary.share`,{value:N(e.topModelShare,0)})}${e.topRequestModel?` · ${r(`metricCards.primary.requestLead`,{value:e.topRequestModel.name})}`:``}`:null,c=e.totalTokens>0?r(`metricCards.primary.allTokensViaCacheRead`,{value:N(e.totalCacheRead/e.totalTokens*100)}):null,l=e.totalTokens>0?r(`metricCards.primary.thinkingShareOfVolume`,{value:N(e.totalThinking/e.totalTokens*100)}):null,u=e.totalTokens>0?r(`metricCards.primary.thinkingSubtitle`,{share:N(e.totalThinking/e.totalTokens*100),tokens:L(e.totalThinking/Math.max(e.totalRequests,1))}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 xl:grid-cols-8 gap-3`,children:[(0,W.jsx)(Y,{label:r(`metricCards.primary.totalCost`),value:(0,W.jsx)(F,{value:e.totalCost,type:`currency`,label:r(`metricCards.primary.totalCost`),insight:r(`metricCards.primary.avgPerPeriod`,{value:P(e.avgDailyCost),unit:j(n)})}),subtitle:r(`metricCards.primary.totalCostSubtitle`,{average:P(e.avgDailyCost),unit:j(n),costPerRequest:P(e.avgCostPerRequest)}),icon:(0,W.jsx)(Je,{className:`h-4 w-4`}),trend:e.weekOverWeekChange===null?null:{value:e.weekOverWeekChange},info:Tr.totalCost}),(0,W.jsx)(Y,{label:r(`metricCards.primary.totalTokens`),value:(0,W.jsx)(F,{value:e.totalTokens,type:`tokens`,label:r(`metricCards.primary.totalTokens`),insight:r(`metricCards.primary.tokensPerRequestAvg`,{value:L(e.avgTokensPerRequest)})}),subtitle:a?r(`metricCards.primary.totalTokensSubtitleWithRatio`,{ratio:a,tokensPerRequest:L(e.avgTokensPerRequest)}):r(`metricCards.primary.totalTokensSubtitle`,{tokensPerRequest:L(e.avgTokensPerRequest)}),icon:(0,W.jsx)(Ut,{className:`h-4 w-4`}),info:Tr.totalTokens}),(0,W.jsx)(Y,{label:r(`metricCards.primary.activeDays`),value:String(e.activeDays),subtitle:o===null?r(`metricCards.primary.providersActive`,{count:e.providerCount}):r(`metricCards.primary.coverageOfDays`,{coverage:N(o,0),days:t}),icon:(0,W.jsx)(ft,{className:`h-4 w-4`}),info:Tr.activeDays}),(0,W.jsx)(Y,{label:r(`metricCards.primary.topModel`),value:e.topModel?.name??`–`,icon:(0,W.jsx)(at,{className:`h-4 w-4`}),info:Tr.topModel,...s?{subtitle:s}:{}}),(0,W.jsx)(Y,{label:r(`metricCards.primary.cacheHitRate`),value:(0,W.jsx)(F,{value:e.cacheHitRate,type:`percent`}),icon:(0,W.jsx)(Xe,{className:`h-4 w-4`}),info:Tr.cacheHitRate,...c?{subtitle:c}:{}}),(0,W.jsx)(Y,{label:r(`metricCards.primary.costPerMillion`),value:(0,W.jsx)(F,{value:e.costPerMillion,type:`currency`}),icon:(0,W.jsx)(At,{className:`h-4 w-4`}),info:Tr.costPerMillion}),(0,W.jsx)(Y,{label:r(`metricCards.primary.requests`),value:e.hasRequestData?(0,W.jsx)(F,{value:e.totalRequests,type:`number`,label:r(`metricCards.primary.requests`),insight:r(`insights.requestEconomy.summary`,{cost:P(e.avgCostPerRequest),tokens:L(e.avgTokensPerRequest),leader:``}).trim()}):r(`common.notAvailable`),subtitle:e.hasRequestData?r(`metricCards.primary.requestsSubtitle`,{requests:e.avgRequestsPerDay.toFixed(1),unit:j(n),cost:P(e.avgCostPerRequest),volatility:Math.round(e.requestVolatility)}):r(`metricCards.primary.requestCountersMissing`),icon:(0,W.jsx)(Ct,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:r(`metricCards.primary.thinking`),value:(0,W.jsx)(F,{value:e.totalThinking,type:`tokens`,label:r(`metricCards.primary.thinking`),...l?{insight:l}:{}}),icon:(0,W.jsx)(Ue,{className:`h-4 w-4`}),...u?{subtitle:u}:{}})]})}function Xi({metrics:e,dailyCosts:t,viewMode:n=`daily`}){let{t:r}=k(),i=e.topDay&&e.cheapestDay?e.topDay.cost-e.cheapestDay.cost:null,a=(()=>{if(!t||t.length===0)return null;let e=[...t].sort((e,t)=>e-t),n=Math.floor(e.length/2),r=e[n];if(r===void 0)return null;if(e.length%2)return r;let i=e[n-1];return i===void 0?null:(i+r)/2})(),o=e.topRequestModel?r(`metricCards.secondary.requestLeader`,{model:e.topRequestModel.name,requests:M(e.topRequestModel.requests)}):null,s=e.topDay?I(e.topDay.date,`long`):null,c=e.topProvider?r(`metricCards.secondary.dominantProviderSubtitle`,{share:N(e.topProvider.share,0),cost:P(e.topProvider.cost),requestLeader:o?` · ${o}`:``}):null,l=n===`daily`&&e.busiestWeek?`${I(e.busiestWeek.start)} – ${I(e.busiestWeek.end)}`:i===null?null:r(`metricCards.secondary.spread`,{value:P(i)}),u=a!==null&&e.avgDailyCost>0?r(`metricCards.secondary.vsAverageWithVolatility`,{direction:a<e.avgDailyCost?`↓`:`↑`,value:Math.abs((a-e.avgDailyCost)/e.avgDailyCost*100).toFixed(0),volatility:Math.round(e.requestVolatility)}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,W.jsx)(Y,{label:r(n===`yearly`?`metricCards.secondary.mostExpensiveYear`:n===`monthly`?`metricCards.secondary.mostExpensiveMonth`:`metricCards.secondary.mostExpensiveDay`),value:e.topDay?(0,W.jsx)(F,{value:e.topDay.cost,type:`currency`}):`–`,icon:(0,W.jsx)(ht,{className:`h-4 w-4`}),info:Tr.mostExpensiveDay,...s?{subtitle:s}:{}}),(0,W.jsx)(Y,{label:r(`metricCards.secondary.dominantProvider`),value:e.topProvider?.name??`–`,icon:(0,W.jsx)(it,{className:`h-4 w-4`}),info:r(`metricCards.secondary.medianInfo`),...c?{subtitle:c}:{}}),(0,W.jsx)(Y,{label:n===`daily`?r(`metricCards.secondary.peak7Days`):r(`metricCards.secondary.avgCostPerUnit`,{unit:j(n)}),value:n===`daily`&&e.busiestWeek?(0,W.jsx)(F,{value:e.busiestWeek.cost,type:`currency`}):(0,W.jsx)(F,{value:e.avgDailyCost,type:`currency`}),icon:(0,W.jsx)(Ze,{className:`h-4 w-4`}),info:Tr.avgCostPerDay,...l?{subtitle:l}:{}}),(0,W.jsx)(Y,{label:r(`metricCards.secondary.medianPerUnit`,{unit:j(n)}),value:a===null?`–`:(0,W.jsx)(F,{value:a,type:`currency`}),icon:(0,W.jsx)(jt,{className:`h-4 w-4`}),info:r(`metricCards.secondary.medianInfo`),...u?{subtitle:u}:{}})]})}function Zi({title:e,description:t,badge:n,info:r,className:i}){return(0,W.jsxs)(`div`,{className:O(`mb-3 pl-3 border-l-2 border-primary/40`,i),children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3`,children:[(0,W.jsx)(Ei,{info:r,children:(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-foreground tracking-tight`,children:e})}),n&&(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground font-medium px-2 py-0.5 rounded-full bg-muted/50`,children:n}),t&&(0,W.jsx)(`span`,{className:`hidden sm:inline text-xs text-muted-foreground`,children:t})]}),t&&(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground sm:hidden`,children:t})]})}function Qi({today:e,metrics:t}){let{t:n}=k(),r=e.modelsUsed?.length??0,i=e.cacheReadTokens+e.cacheCreationTokens>0?e.cacheReadTokens/(e.cacheReadTokens+e.cacheCreationTokens+e.inputTokens+e.outputTokens+e.thinkingTokens)*100:0,a=e.modelBreakdowns?.length?e.modelBreakdowns.reduce((e,t)=>e.cost>t.cost?e:t):null,o=t.avgDailyCost>0?(e.totalCost-t.avgDailyCost)/t.avgDailyCost*100:null,s=o===null?null:n(`metricCards.today.avgPerDay`,{value:P(t.avgDailyCost)}),c=e.inputTokens>0&&e.outputTokens>0?n(`metricCards.today.ioRatio`,{value:(e.inputTokens/e.outputTokens).toFixed(1)}):null,l=a?n(`metricCards.today.topModel`,{value:De(a.modelName)}):null,u=t.costPerMillion>0?n(`metricCards.today.overallAverage`,{value:P(t.costPerMillion)}):null,d=e.requestCount>0&&r>0?n(`metricCards.today.requestsSubtitle`,{value:(e.requestCount/r).toFixed(1),cost:P(e.totalCost/e.requestCount)}):n(`metricCards.today.requestCountersMissing`),f=e.totalTokens>0?n(`metricCards.today.thinkingSubtitle`,{value:N(e.thinkingTokens/e.totalTokens*100)}):null;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Zi,{title:n(`metricCards.today.title`,{date:I(e.date,`long`)}),description:n(`metricCards.today.description`),info:Er.today}),(0,W.jsx)(J,{delay:.05,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 xl:grid-cols-6 gap-3`,children:[(0,W.jsx)(Y,{label:n(`metricCards.today.costToday`),value:(0,W.jsx)(F,{value:e.totalCost,type:`currency`}),icon:(0,W.jsx)(Je,{className:`h-4 w-4`}),trend:o===null?null:{value:o,label:n(`metricCards.today.vsAverageShort`)},...s?{subtitle:s}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.today.tokensToday`),value:(0,W.jsx)(F,{value:e.totalTokens,type:`tokens`,label:n(`metricCards.today.tokensToday`),insight:n(`metricCards.today.tokensInsight`,{value:L(e.requestCount>0?e.totalTokens/e.requestCount:0)})}),icon:(0,W.jsx)(Ut,{className:`h-4 w-4`}),...c?{subtitle:c}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.today.models`),value:String(r),icon:(0,W.jsx)(at,{className:`h-4 w-4`}),...l?{subtitle:l}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.today.costPerMillion`),value:(0,W.jsx)(F,{value:e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,type:`currency`}),icon:(0,W.jsx)(At,{className:`h-4 w-4`}),...u?{subtitle:u}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.today.cacheHitRate`),value:(0,W.jsx)(F,{value:i,type:`percent`}),subtitle:n(`metricCards.today.cacheShare`,{value:N(e.cacheReadTokens/(e.totalTokens||1)*100)}),icon:(0,W.jsx)(Xe,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:n(`metricCards.today.requests`),value:e.requestCount>0?(0,W.jsx)(F,{value:e.requestCount,type:`number`,label:n(`metricCards.today.requestsToday`),insight:n(`metricCards.today.requestsInsight`,{value:P(e.totalCost/e.requestCount)})}):n(`common.notAvailable`),subtitle:d,icon:(0,W.jsx)(Ct,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:n(`metricCards.today.thinking`),value:(0,W.jsx)(F,{value:e.thinkingTokens,type:`tokens`}),icon:(0,W.jsx)(Ue,{className:`h-4 w-4`}),...f?{subtitle:f}:{}})]})})]})}function $i({daily:e,metrics:t}){let{t:n}=k(),r=Pe(),i=Ie(),a=new Intl.NumberFormat(r,{minimumFractionDigits:1,maximumFractionDigits:1}),o=new Intl.NumberFormat(r,{style:`percent`,minimumFractionDigits:1,maximumFractionDigits:1}),s=new Intl.NumberFormat(r,{style:`percent`,minimumFractionDigits:0,maximumFractionDigits:0}),c=(0,U.useMemo)(()=>e.filter(e=>e.date.startsWith(i)),[e,i]),l=(0,U.useMemo)(()=>{let[t=0,n=1]=i.split(`-`).map(Number),r=n===1?`${t-1}-12`:`${t}-${String(n-1).padStart(2,`0`)}`;return e.filter(e=>e.date.startsWith(r))},[e,i]),u=(0,U.useMemo)(()=>{if(c.length===0)return null;let e=c.reduce((e,t)=>e+t.totalCost,0),t=c.reduce((e,t)=>e+t.totalTokens,0),n=c.reduce((e,t)=>e+t.inputTokens,0),r=c.reduce((e,t)=>e+t.outputTokens,0),i=c.reduce((e,t)=>e+t.cacheReadTokens,0),a=c.reduce((e,t)=>e+t.cacheCreationTokens,0),o=c.reduce((e,t)=>e+t.thinkingTokens,0),s=c.reduce((e,t)=>e+t.requestCount,0),l=i+a+n+r+o,u=l>0?i/l*100:0,d=t>0?e/(t/1e6):0,f=new Set,p=new Map;for(let e of c)for(let t of e.modelBreakdowns){let e=De(t.modelName);f.add(e),p.set(e,(p.get(e)??0)+t.cost)}let m=null;for(let[e,t]of p)(!m||t>m.cost)&&(m={name:e,cost:t});let h=new Date().getDate();return{totalCost:e,totalTokens:t,inputTokens:n,outputTokens:r,cacheRead:i,cacheCreate:a,thinkingTokens:o,requestCount:s,cacheHitRate:u,costPerMillion:d,activeDays:c.length,dayOfMonth:h,modelCount:f.size,topModel:m}},[c]),d=(0,U.useMemo)(()=>l.reduce((e,t)=>e+t.totalCost,0),[l]);if(!u)return null;let f=d>0?(u.totalCost-d)/d*100:null,p=u.inputTokens+u.outputTokens,m=u.inputTokens>0&&u.outputTokens>0?n(`metricCards.month.ioRatio`,{value:a.format(u.inputTokens/u.outputTokens)}):null,h=u.topModel?n(`metricCards.month.topModel`,{value:u.topModel.name}):null,g=t.costPerMillion>0?n(`metricCards.today.overallAverage`,{value:P(t.costPerMillion)}):null,_=u.totalTokens>0?n(`metricCards.month.thinkingSubtitle`,{value:o.format(u.thinkingTokens/u.totalTokens)}):null;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Zi,{title:n(`metricCards.month.title`,{date:Re(i)}),badge:n(`metricCards.month.badge`,{count:u.activeDays}),description:n(`metricCards.month.description`),info:Er.currentMonth}),(0,W.jsx)(J,{delay:.08,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 xl:grid-cols-8 gap-3`,children:[(0,W.jsx)(Y,{label:n(`metricCards.month.costMonth`),value:(0,W.jsx)(F,{value:u.totalCost,type:`currency`}),subtitle:n(`metricCards.month.avgPerDay`,{value:P(u.totalCost/u.activeDays)}),icon:(0,W.jsx)(Je,{className:`h-4 w-4`}),trend:f===null?null:{value:f,label:n(`metricCards.month.vsPreviousMonth`)}}),(0,W.jsx)(Y,{label:n(`metricCards.month.tokensMonth`),value:(0,W.jsx)(F,{value:u.totalTokens,type:`tokens`}),icon:(0,W.jsx)(Ut,{className:`h-4 w-4`}),...m?{subtitle:m}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.month.activeDays`),value:`${u.activeDays} / ${u.dayOfMonth}`,subtitle:n(`metricCards.month.coverage`,{value:s.format(u.activeDays/u.dayOfMonth)}),icon:(0,W.jsx)(pt,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:n(`metricCards.month.models`),value:String(u.modelCount),icon:(0,W.jsx)(at,{className:`h-4 w-4`}),...h?{subtitle:h}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.month.costPerMillion`),value:(0,W.jsx)(F,{value:u.costPerMillion,type:`currency`}),icon:(0,W.jsx)(At,{className:`h-4 w-4`}),...g?{subtitle:g}:{}}),(0,W.jsx)(Y,{label:n(`metricCards.month.cacheHitRate`),value:(0,W.jsx)(F,{value:u.cacheHitRate,type:`percent`}),subtitle:n(`metricCards.month.cacheMix`,{input:s.format(p>0?u.inputTokens/p:0),output:s.format(p>0?u.outputTokens/p:0)}),icon:(0,W.jsx)(Xe,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:n(`metricCards.month.requests`),value:u.requestCount>0?(0,W.jsx)(F,{value:u.requestCount,type:`number`,label:n(`metricCards.month.requestsInMonth`),insight:n(`metricCards.month.costPerRequest`,{value:P(u.totalCost/u.requestCount)})}):n(`common.notAvailable`),subtitle:u.requestCount>0?n(`metricCards.month.requestsSubtitle`,{value:(u.requestCount/u.activeDays).toFixed(1),cost:P(u.totalCost/u.requestCount)}):n(`metricCards.month.requestCountersMissing`),icon:(0,W.jsx)(Ct,{className:`h-4 w-4`})}),(0,W.jsx)(Y,{label:n(`metricCards.month.thinking`),value:(0,W.jsx)(F,{value:u.thinkingTokens,type:`tokens`}),icon:(0,W.jsx)(Ue,{className:`h-4 w-4`}),..._?{subtitle:_}:{}})]})})]})}function ea(e){let t=``;if(e==null)return`""`;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)t=String(e);else try{t=JSON.stringify(e)??``}catch{t=``}return`"${t.replace(/"/g,`""`)}"`}function ta(e){return e.map(e=>ea(e)).join(`,`)}function na(e){if(e.length===0)return``;let t=e[0];if(!t)return``;let n=Object.keys(t);return[ta(n),...e.map(e=>ta(n.map(t=>e[t])))].join(`
3
+ `)}var ra=(0,U.createContext)(!1);function ia(){return(0,U.useContext)(ra)}function X({children:e}){return(0,W.jsx)(W.Fragment,{children:e(ia())})}function Z({children:e,variant:t=`line`,delay:n=0,duration:r=.7}){let i=ia(),a=t===`radial`?Math.max(r,.95):Math.max(r,.9),o=t===`bar`?{opacity:0,clipPath:`inset(100% 0 0 0 round 16px)`,y:10}:t===`radial`?{opacity:0,scale:.82,rotate:-18}:{opacity:0,clipPath:`inset(0 100% 0 0 round 16px)`,x:-8},s=t===`bar`?{opacity:1,clipPath:`inset(0 0 0 0 round 16px)`,y:0}:t===`radial`?{opacity:1,scale:1,rotate:0}:{opacity:1,clipPath:`inset(0 0 0 0 round 16px)`,x:0};return(0,W.jsx)(C.div,{initial:o,animate:i?s:o,transition:{duration:a,delay:n,ease:`easeOut`},style:{width:`100%`,height:`100%`,overflow:t===`radial`?`visible`:`hidden`,transformOrigin:t===`bar`?`center bottom`:`center center`,paddingTop:t===`radial`?8:0,paddingBottom:t===`radial`?8:0,boxSizing:`border-box`},children:e})}function aa({title:e,subtitle:t,summary:n,info:r,expandable:i=!0,children:a,className:o,chartData:s,valueKey:c,valueFormatter:l,expandedExtra:u}){let{t:d}=k(),[f,p]=(0,U.useState)(!1),m=(0,U.useRef)(null),h=w(m,{once:!0,amount:.25})||f,g=(0,U.useMemo)(()=>{if(!s||!c)return null;let e=s.map(e=>e[c]).filter(e=>typeof e==`number`&&!isNaN(e));if(e.length===0)return null;let t=e.reduce((e,t)=>e+t,0);return{min:Math.min(...e),max:Math.max(...e),avg:t/e.length,total:t,count:e.length}},[s,c]),_=l??P,v=e=>typeof a==`function`?a(e):a,y=(0,U.useCallback)(()=>{if(!s||s.length===0)return;let t=na(s);if(!t)return;let n=new Blob([t],{type:`text/csv`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e}.csv`,i.click(),URL.revokeObjectURL(r)},[s,e]),b=(0,W.jsxs)(Gr,{className:`pb-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:e}),r&&(0,W.jsx)(Ti,{text:r})]}),(0,W.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:n&&(0,W.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:n})})]}),t&&(0,W.jsx)(qr,{className:`mt-0.5`,children:t})]});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ra.Provider,{value:h,children:(0,W.jsxs)(K,{ref:m,className:O(`group relative`,o),children:[b,(0,W.jsx)(q,{children:v(!1)}),i&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>p(!0),className:`absolute top-3 right-3 z-10 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 focus-visible:opacity-100 transition-opacity duration-200 p-1.5 rounded-lg bg-background/80 backdrop-blur-sm border border-border/50 hover:bg-accent text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,title:d(`common.expand`),"aria-label":d(`common.expandWithTitle`,{title:e}),children:(0,W.jsx)(gt,{className:`h-3.5 w-3.5`})})]})}),i&&(0,W.jsx)(pe,{open:f,onOpenChange:p,children:(0,W.jsxs)(de,{className:`max-w-[96vw] w-[96vw] sm:max-w-[95vw] sm:w-[95vw] max-h-[92vh] h-[92vh] sm:max-h-[90vh] sm:h-[90vh] overflow-auto p-0`,children:[(0,W.jsx)(D,{className:`sr-only`,children:e}),(0,W.jsx)(fe,{className:`sr-only`,children:d(`chartCard.expandedDescription`)}),(0,W.jsx)(ra.Provider,{value:f,children:(0,W.jsxs)(`div`,{className:`relative h-full flex flex-col`,children:[(0,W.jsxs)(`div`,{className:`p-4 sm:p-6 pb-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e}),t&&(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:t})]}),s&&s.length>0&&(0,W.jsx)(`button`,{type:`button`,onClick:y,className:`text-xs px-3 py-1.5 rounded-lg border border-border hover:bg-accent transition-all duration-200 text-muted-foreground hover:text-foreground`,children:d(`chartCard.exportCsv`)})]}),g&&(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-5 gap-3 mt-4`,children:[(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:d(`dashboard.stats.min`)}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:_(g.min)})]}),(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:d(`dashboard.stats.max`)}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:_(g.max)})]}),(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:d(`dashboard.stats.avg`)}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:_(g.avg)})]}),(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:d(`dashboard.stats.total`)}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:_(g.total)})]}),(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:d(`dashboard.stats.dataPoints`)}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:g.count})]})]})]}),(0,W.jsxs)(`div`,{className:`flex-1 p-4 sm:p-6 pt-2 overflow-auto`,children:[v(!0),u]})]})})]})})]})}var Q={cost:`hsl(215, 70%, 55%)`,ma7:`hsl(262, 60%, 65%)`,cumulative:`hsl(160, 50%, 52%)`,input:`hsl(340, 55%, 52%)`,output:`hsl(35, 80%, 52%)`,cacheWrite:`hsl(262, 60%, 55%)`,cacheRead:`hsl(160, 50%, 42%)`,grid:`hsl(224, 12%, 18%)`,axis:`hsl(220, 8%, 46%)`,tooltipBg:`hsl(224, 18%, 10%)`,tooltipBorder:`hsl(224, 12%, 18%)`},oa={top:5,right:10,left:10,bottom:5},$={duration:800,easing:`ease-out`,stagger:140,slowDuration:1200};function sa({data:e,onClickDay:t}){let{t:n}=k(),r=(0,U.useId)().replace(/:/g,``),o=(0,U.useMemo)(()=>{if(e.length===0)return null;let t=e[e.length-1],n=e[0];for(let t=1;t<e.length;t+=1){let r=e[t];r&&n&&r.cost>n.cost&&(n=r)}return!t||!n?null:{latest:t.cost,peak:n.cost,peakDate:n.date}},[e]);return(0,W.jsx)(aa,{title:n(`charts.costOverTime.title`),subtitle:o?n(`charts.costOverTime.summary`,{latest:P(o.latest),peak:P(o.peak),date:R(o.peakDate)}):n(`charts.costOverTime.subtitle`),info:G.costOverTime,chartData:e,valueKey:`cost`,valueFormatter:P,children:(0,W.jsx)(X,{children:o=>(0,W.jsx)(Z,{variant:`line`,children:(0,W.jsx)(i,{width:`100%`,height:300,children:(0,W.jsxs)(v,{data:e,margin:oa,onClick:n=>{if(t&&n?.activeTooltipIndex!=null&&typeof n.activeTooltipIndex==`number`){let r=e[n.activeTooltipIndex];r?.date&&t(r.date)}},children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${r}-gradCostLine`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.3}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(S,{}),(0,W.jsx)(s,{type:`monotone`,dataKey:`cost`,stroke:Q.cost,fill:`url(#${r}-gradCostLine)`,name:n(`charts.costOverTime.cost`),strokeWidth:1.5,activeDot:{r:5,strokeWidth:2,stroke:Q.cost,fill:`hsl(var(--background))`},dot:!1,isAnimationActive:o,animationBegin:0,animationDuration:$.duration,animationEasing:$.easing}),(0,W.jsx)(h,{type:`monotone`,dataKey:`ma7`,stroke:Q.ma7,name:n(`charts.costOverTime.movingAverage`),dot:!1,strokeWidth:2,strokeDasharray:`5 5`,connectNulls:!0,isAnimationActive:o,animationBegin:$.stagger,animationDuration:$.slowDuration})]})})})})})}function ca({viewBox:e,total:t}){let{t:n}=k();if(!e)return null;let{cx:r,cy:i}=e;return(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.costByModel.total`)}),(0,W.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function la({data:e}){let{t}=k(),r=e.reduce((e,t)=>e+t.value,0);return(0,W.jsx)(aa,{title:t(`charts.costByModel.title`),subtitle:t(`charts.costByModel.subtitle`),info:G.costByModel,chartData:e,valueKey:`value`,valueFormatter:P,children:t=>{let a=t?560:320,o=t?`66%`:`57%`,s=t?84:58,l=t?134:92;return(0,W.jsx)(X,{children:d=>(0,W.jsx)(Z,{variant:`radial`,children:(0,W.jsx)(i,{width:`100%`,height:a,children:(0,W.jsxs)(u,{children:[(0,W.jsxs)(c,{data:e,cx:`50%`,cy:o,innerRadius:s,outerRadius:l,paddingAngle:2,dataKey:`value`,nameKey:`name`,isAnimationActive:d,animationDuration:$.duration,animationBegin:$.stagger,animationEasing:$.easing,label:!1,children:[e.map(e=>(0,W.jsx)(n,{fill:B(e.name)},e.name)),(0,W.jsx)(ca,{total:P(r)})]}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)})}),(0,W.jsx)(S,{wrapperStyle:{fontSize:`12px`,paddingTop:t?`22px`:`8px`},formatter:t=>{let n=e.find(e=>e.name===t);return(0,W.jsxs)(`span`,{className:`text-xs text-foreground`,children:[t,` (`,n?P(n.value):``,`)`]})}})]})})})})}})}function ua({data:e,models:t}){let{t:n}=k(),r=t.map(t=>({model:t,total:e.reduce((e,n)=>e+(Le(n[t])??0),0)})).sort((e,t)=>t.total-e.total)[0]??null,o=(0,W.jsx)(X,{children:r=>(0,W.jsxs)(`div`,{className:`mt-6`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-2`,children:n(`charts.costByModelOverTime.movingAverageHeading`)}),(0,W.jsx)(Z,{variant:`line`,delay:.08,children:(0,W.jsx)(i,{width:`100%`,height:350,children:(0,W.jsxs)(m,{data:e,margin:oa,children:[(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,W.jsx)(S,{}),t.map((e,t)=>(0,W.jsx)(h,{type:`monotone`,dataKey:`${e}_ma7`,stroke:B(e),name:`${e} ${n(`charts.costByModelOverTime.movingAverageSuffix`)}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,isAnimationActive:r,animationBegin:$.stagger*(t%5),animationDuration:$.slowDuration},`${e}_ma7`))]})})})]})});return(0,W.jsx)(aa,{title:n(`charts.costByModelOverTime.title`),subtitle:r?n(`charts.costByModelOverTime.topDriver`,{model:r.model,total:P(r.total)}):n(`charts.costByModelOverTime.subtitle`),info:G.costByModelOverTime,className:`lg:col-span-2`,chartData:e,valueKey:`cost`,valueFormatter:P,expandedExtra:o,children:(0,W.jsx)(X,{children:n=>(0,W.jsx)(Z,{variant:`line`,children:(0,W.jsx)(i,{width:`100%`,height:300,children:(0,W.jsxs)(m,{data:e,margin:oa,children:[(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,W.jsx)(S,{}),t.map((e,t)=>(0,W.jsx)(h,{type:`monotone`,dataKey:e,stroke:B(e),name:e,dot:!1,strokeWidth:1.5,isAnimationActive:n,animationBegin:$.stagger*(t%5),animationDuration:$.duration,animationEasing:$.easing},e))]})})})})})}var da=_e();function fa(e){return(0,da.computeMetrics)(e)}function pa(e,t=7){return(0,da.computeMovingAverage)(e,t)}function ma(e){let t=new Map;for(let n of e){let e=n._aggregatedDays??1;for(let r of n.modelBreakdowns){let i=De(r.modelName),a=t.get(i)??{cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheCreate:0,thinking:0,requests:0,days:0,_dates:new Set};a.cost+=r.cost,a.tokens+=r.inputTokens+r.outputTokens+r.cacheCreationTokens+r.cacheReadTokens+r.thinkingTokens,a.input+=r.inputTokens,a.output+=r.outputTokens,a.cacheRead+=r.cacheReadTokens,a.cacheCreate+=r.cacheCreationTokens,a.thinking+=r.thinkingTokens,a.requests+=r.requestCount,a._dates.has(n.date)||(a._dates.add(n.date),a.days+=e),t.set(i,a)}}return t}function ha(e){let t=new Map;for(let n of e){let e=n._aggregatedDays??1;for(let r of n.modelBreakdowns){let i=ke(r.modelName),a=t.get(i)??{cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheCreate:0,thinking:0,requests:0,days:0,_dates:new Set};a.cost+=r.cost,a.input+=r.inputTokens,a.output+=r.outputTokens,a.cacheRead+=r.cacheReadTokens,a.cacheCreate+=r.cacheCreationTokens,a.thinking+=r.thinkingTokens,a.requests+=r.requestCount,a.tokens+=r.inputTokens+r.outputTokens+r.cacheReadTokens+r.cacheCreationTokens+r.thinkingTokens,a._dates.has(n.date)||(a._dates.add(n.date),a.days+=e),t.set(i,a)}}return new Map(Array.from(t.entries()).map(([e,t])=>[e,{cost:t.cost,tokens:t.tokens,input:t.input,output:t.output,cacheRead:t.cacheRead,cacheCreate:t.cacheCreate,thinking:t.thinking,requests:t.requests,days:t.days}]))}function ga(e,t,n,r,i){let a=e+t+n+r+i;return a>0?e/a*100:0}function _a(e){if(e.length===0)return[];let t=[...e].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e.date)).sort((e,t)=>e.date.localeCompare(t.date));if(t.length===0)return[];let n=t.slice(-Math.min(7,t.length)),r=new Map,i=new Map,a=(e,t,n,r,i,a,o)=>{let s=De(t),c=e.get(s)??{cacheRead:0,cacheCreate:0,input:0,output:0,thinking:0};c.cacheRead+=n,c.cacheCreate+=r,c.input+=i,c.output+=a,c.thinking+=o,e.set(s,c)};for(let e of t)for(let t of e.modelBreakdowns)a(r,t.modelName,t.cacheReadTokens,t.cacheCreationTokens,t.inputTokens,t.outputTokens,t.thinkingTokens);for(let e of n)for(let t of e.modelBreakdowns)a(i,t.modelName,t.cacheReadTokens,t.cacheCreationTokens,t.inputTokens,t.outputTokens,t.thinkingTokens);let o=e=>Array.from(e.values()).reduce((e,t)=>({cacheRead:e.cacheRead+t.cacheRead,cacheCreate:e.cacheCreate+t.cacheCreate,input:e.input+t.input,output:e.output+t.output,thinking:e.thinking+t.thinking}),{cacheRead:0,cacheCreate:0,input:0,output:0,thinking:0}),s=o(r),c=o(i),l=[{model:`Total`,totalRate:ga(s.cacheRead,s.cacheCreate,s.input,s.output,s.thinking),trailing7Rate:ga(c.cacheRead,c.cacheCreate,c.input,c.output,c.thinking),totalBaseTokens:s.cacheRead+s.cacheCreate+s.input+s.output+s.thinking,trailing7BaseTokens:c.cacheRead+c.cacheCreate+c.input+c.output+c.thinking}],u=Array.from(r.entries()).map(([e,t])=>{let n=i.get(e)??{cacheRead:0,cacheCreate:0,input:0,output:0,thinking:0};return{model:e,totalRate:ga(t.cacheRead,t.cacheCreate,t.input,t.output,t.thinking),trailing7Rate:ga(n.cacheRead,n.cacheCreate,n.input,n.output,n.thinking),totalBaseTokens:t.cacheRead+t.cacheCreate+t.input+t.output+t.thinking,trailing7BaseTokens:n.cacheRead+n.cacheCreate+n.input+n.output+n.thinking}}).filter(e=>e.totalBaseTokens>0).sort((e,t)=>t.totalBaseTokens-e.totalBaseTokens);return[...l,...u]}function va(e,t=2){if(e.length<3)return[];let n=e.map(e=>e.totalCost),r=n.reduce((e,t)=>e+t,0)/n.length,i=Math.sqrt(n.reduce((e,t)=>e+(t-r)**2,0)/n.length);return i===0?[]:e.filter(e=>Math.abs(e.totalCost-r)>t*i)}function ya(e){return e.length===0?0:e.reduce((e,t)=>e+t,0)/e.length}function ba(e){if(e.length<2)return 0;let t=ya(e);return Math.sqrt(e.reduce((e,n)=>e+(n-t)**2,0)/e.length)}function xa(e,t){if(e.length===0)return 0;let n=[...e].sort((e,t)=>e-t),r=(n.length-1)*t,i=Math.floor(r),a=Math.ceil(r),o=n[i],s=n[a];if(o===void 0||s===void 0)return 0;if(i===a)return o;let c=r-i;return o*(1-c)+s*c}function Sa(e,t=.15){if(e.length===0)return 0;if(e.length<4)return ya(e);let n=xa(e,t),r=xa(e,1-t);return ya(e.map(e=>Math.min(r,Math.max(n,e))))}function Ca(e,t,n){return Math.min(n,Math.max(t,e))}function wa(e){if(e.length<2)return null;let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=t[t.length-1];if(!n)return null;let r=new Date(n.date+`T00:00:00`),i=n.date.slice(0,7),a=t.filter(e=>e.date.startsWith(i));if(a.length<2)return null;let o=a.reduce((e,t)=>e+t.totalCost,0),s=new Map(a.map(e=>[e.date,e.totalCost])),c=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),l=r.getDate(),u=Math.max(0,c-l),d=Array.from({length:l},(e,t)=>{let n=t+1,r=`${i}-${String(n).padStart(2,`0`)}`;return{date:r,cost:s.get(r)??0}}),f=d.map(e=>e.cost),p=o/l,m=f.slice(-Math.min(7,f.length)),h=f.slice(-Math.min(14,f.length),-Math.min(7,f.length)),g=Sa(m),_=h.length>0?Sa(h):0,v=_>0?Ca((g-_)/_,-.35,.35)*.25:0,y=Math.max(0,(p*.6+g*.4)*(1+v)),b=ba(m.length>=4?m:f),x=Math.max(0,y-b),S=y+b,ee=o+y*u,C=_>0?{avg:g,change:(g-_)/_*100}:{avg:g,change:0},te=`low`;return l>=14&&b<=y*.75?te=`high`:l>=7&&b<=y*1.25&&(te=`medium`),{currentMonth:i,monthData:a,currentMonthTotal:o,elapsedDays:l,elapsedCalendarSeries:d,daysInMonth:c,remainingDays:u,projectedDailyBurn:y,volatility:b,lowerDaily:x,upperDaily:S,forecastTotal:ee,dailyAvgTrend:C,confidence:te}}function Ta({data:e,rawData:t}){let{t:n}=k(),r=(0,U.useId)().replace(/:/g,``),o=(0,U.useMemo)(()=>{if(e.length<3)return e;let n=e[e.length-1];if(!n?.date||!n.cumulative)return e;let r=wa(t);if(!r)return e;let{currentMonth:i,daysInMonth:a,projectedDailyBurn:o}=r,s=r.elapsedDays;if(s>=a)return e;let c=n.cumulative+o*(a-s),l=`${i}-${String(a).padStart(2,`0`)}`;return[...e.map(e=>({...e,projected:void 0})),{...e[e.length-1],projected:n.cumulative},{date:l,cumulative:void 0,projected:c,cost:0,ma7:0}]},[e,t]),c=e[e.length-1]?.cumulative??0;return(0,W.jsx)(aa,{title:n(`charts.cumulativeCost.title`),subtitle:n(`charts.cumulativeCost.total`,{value:P(c)}),info:G.cumulativeCost,chartData:e,valueKey:`cumulative`,valueFormatter:P,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`line`,delay:.05,children:(0,W.jsx)(i,{width:`100%`,height:300,children:(0,W.jsxs)(v,{data:o,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${r}-cumulGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cumulative,stopOpacity:.4}),(0,W.jsx)(`stop`,{offset:`60%`,stopColor:Q.cumulative,stopOpacity:.1}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cumulative,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(s,{type:`monotone`,dataKey:`cumulative`,stroke:Q.cumulative,fill:`url(#${r}-cumulGrad)`,name:n(`charts.cumulativeCost.cumulative`),strokeWidth:2,activeDot:{r:5,strokeWidth:2,stroke:Q.cumulative,fill:`hsl(var(--background))`},dot:!1,isAnimationActive:e,animationBegin:0,animationDuration:$.duration,animationEasing:$.easing,connectNulls:!1}),(0,W.jsx)(h,{type:`monotone`,dataKey:`projected`,stroke:Q.cumulative,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,name:n(`charts.cumulativeCost.projection`),connectNulls:!0,isAnimationActive:e,animationBegin:$.stagger,animationDuration:$.slowDuration})]})})})})})}function Ea({data:e,onClickDay:t}){let{t:n}=k(),r=(0,U.useId)(),o=e=>`${r}-${e}`.replace(/:/g,``),c=(0,U.useMemo)(()=>{let t=0,n=0,r=0,i=0,a=0;for(let o of e)t+=o[`Cache Read`],n+=o[`Cache Write`],r+=o.Input,i+=o.Output,a+=o.Thinking;return{cacheRead:t,cacheWrite:n,input:r,output:i,thinking:a,total:t+n+r+i+a}},[e]),l=(0,U.useMemo)(()=>e.map((t,n)=>({date:t.date,total:t.Input+t.Output+t[`Cache Write`]+t[`Cache Read`]+t.Thinking,totalPrev:(()=>{let t=n>0?e[n-1]:void 0;return t?t.Input+t.Output+t[`Cache Write`]+t[`Cache Read`]+t.Thinking:void 0})(),tokenMA7:t.tokenMA7})),[e]),u=e=>{let n=e;n?.activePayload?.[0]?.payload?.date&&t&&t(n.activePayload[0].payload.date)},p=(0,W.jsx)(X,{children:e=>(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1`,children:n(`charts.tokensOverTime.allTypes`)}),(0,W.jsx)(Z,{variant:`line`,delay:.06,children:(0,W.jsx)(i,{width:`100%`,height:180,children:(0,W.jsxs)(v,{data:l,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:o(`total`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:10,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:L,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,width:55}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:L}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(s,{type:`monotone`,dataKey:`total`,stroke:Q.cost,fill:`url(#${o(`total`)})`,strokeWidth:1.5,name:n(`charts.tokensOverTime.totalTokens`),isAnimationActive:e,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`tokenMA7`,stroke:Q.ma7,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:n(`charts.tokensOverTime.movingAverage`),isAnimationActive:e,animationBegin:$.stagger,animationDuration:$.slowDuration})]})})})]})});return(0,W.jsxs)(aa,{title:n(`charts.tokensOverTime.title`),subtitle:n(`charts.tokensOverTime.subtitle`),info:G.tokensOverTime,summary:(0,W.jsx)(F,{value:c.total,type:`tokens`}),className:`lg:col-span-2`,chartData:e,valueKey:`Cache Read`,valueFormatter:L,expandedExtra:p,children:[(0,W.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-5 gap-2 mb-3 text-center`,children:[{label:`Cache Read`,value:c.cacheRead,color:Q.cacheRead},{label:`Cache Write`,value:c.cacheWrite,color:Q.cacheWrite},{label:`Output`,value:c.output,color:Q.output},{label:`Input`,value:c.input,color:Q.input},{label:`Thinking`,value:c.thinking,color:Q.cost}].map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-1.5`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:e.label}),(0,W.jsx)(`div`,{className:`text-xs font-mono font-semibold`,style:{color:e.color},children:L(e.value)}),(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground/60 font-mono`,children:c.total>0?`${(e.value/c.total*100).toFixed(1)}%`:`–`})]},e.label))}),(0,W.jsxs)(`div`,{className:`mb-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1`,children:n(`charts.tokensOverTime.cacheTokens`)}),(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,children:(0,W.jsx)(i,{width:`100%`,height:150,children:(0,W.jsxs)(v,{data:e,margin:{...oa,bottom:0},onClick:u,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsxs)(`linearGradient`,{id:o(`cacheRead`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cacheRead,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cacheRead,stopOpacity:0})]}),(0,W.jsxs)(`linearGradient`,{id:o(`cacheWrite`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cacheWrite,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cacheWrite,stopOpacity:0})]})]}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:10,tickLine:!1,hide:!0}),(0,W.jsx)(a,{tickFormatter:L,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,width:55}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:L}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(s,{type:`monotone`,dataKey:`Cache Read`,stroke:Q.cacheRead,fill:`url(#${o(`cacheRead`)})`,strokeWidth:1.5,name:`Cache Read`,isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(s,{type:`monotone`,dataKey:`Cache Write`,stroke:Q.cacheWrite,fill:`url(#${o(`cacheWrite`)})`,strokeWidth:1.5,name:`Cache Write`,isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`cacheReadMA7`,stroke:Q.cacheRead,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:`Cache Read ${n(`charts.tokensOverTime.averageSuffix`)}`,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`cacheWriteMA7`,stroke:Q.cacheWrite,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:`Cache Write ${n(`charts.tokensOverTime.averageSuffix`)}`,isAnimationActive:t,animationBegin:$.stagger*2,animationDuration:$.slowDuration})]})})})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1`,children:n(`charts.tokensOverTime.inputOutputTokens`)}),(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,delay:.04,children:(0,W.jsx)(i,{width:`100%`,height:150,children:(0,W.jsxs)(v,{data:e,margin:oa,onClick:u,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsxs)(`linearGradient`,{id:o(`output`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.output,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.output,stopOpacity:0})]}),(0,W.jsxs)(`linearGradient`,{id:o(`input`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.input,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.input,stopOpacity:0})]})]}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:10,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:L,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,width:55}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:L}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(s,{type:`monotone`,dataKey:`Output`,stroke:Q.output,fill:`url(#${o(`output`)})`,strokeWidth:1.5,name:`Output`,isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(s,{type:`monotone`,dataKey:`Input`,stroke:Q.input,fill:`url(#${o(`input`)})`,strokeWidth:1.5,name:`Input`,isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`outputMA7`,stroke:Q.output,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:`Output ${n(`charts.tokensOverTime.averageSuffix`)}`,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`inputMA7`,stroke:Q.input,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:`Input ${n(`charts.tokensOverTime.averageSuffix`)}`,isAnimationActive:t,animationBegin:$.stagger*2,animationDuration:$.slowDuration})]})})})})]}),(0,W.jsxs)(`div`,{className:`mt-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1`,children:n(`charts.tokensOverTime.thinkingTokens`)}),(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,delay:.08,children:(0,W.jsx)(i,{width:`100%`,height:110,children:(0,W.jsxs)(v,{data:e,margin:oa,onClick:u,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:o(`thinking`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.25}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:10,tickLine:!1,hide:!0}),(0,W.jsx)(a,{tickFormatter:L,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,width:55}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:L}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(s,{type:`monotone`,dataKey:`Thinking`,stroke:Q.cost,fill:`url(#${o(`thinking`)})`,strokeWidth:1.5,name:`Thinking`,isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`thinkingMA7`,stroke:Q.cost,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:`Thinking ${n(`charts.tokensOverTime.averageSuffix`)}`,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration})]})})})})]})]})}function Da(e){return new Intl.NumberFormat(Pe(),{notation:e>=1e4?`compact`:`standard`,maximumFractionDigits:+(e>=1e4)}).format(e)}function Oa({viewBox:e,total:t}){let{t:n}=k();if(!e)return null;let{cx:r,cy:i}=e;return(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.requestsOverTime.total`)}),(0,W.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function ka({data:e,viewMode:t=`daily`,onClickDay:r}){let{t:o}=k(),l=(0,U.useId)().replace(/:/g,``),p=o(`charts.requestsOverTime.averagePerUnit`,{unit:j(t)}),m=o(t===`daily`?`charts.requestsOverTime.movingAverage`:`charts.requestsOverTime.trend`),g=o(t===`daily`?`charts.requestsOverTime.movingAverageHeading`:`charts.requestsOverTime.trendHeading`),_=(0,U.useMemo)(()=>{if(e.length===0)return null;let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n))e===`date`||e===`totalRequests`||e===`totalRequestsMA7`||e===`totalRequestsPrev`||e.endsWith(`_ma7`)||e.endsWith(`Prev`)||typeof r==`number`&&t.set(e,(t.get(e)??0)+r);let n=Array.from(t.entries()).sort((e,t)=>t[1]-e[1]),r=e.reduce((e,t)=>e+t.totalRequests,0),i=[...e].sort((e,t)=>t.totalRequests-e.totalRequests)[0];return i?{totalRequests:r,peak:i,topModels:n}:null},[e]),y=(0,U.useMemo)(()=>(_?.topModels??[]).slice(0,5).map(([e])=>e),[_]),x=(0,U.useMemo)(()=>(_?.topModels??[]).map(([e,t])=>({name:e,value:t})),[_]),ee=e=>{let t=e;t?.activePayload?.[0]?.payload?.date&&r&&r(t.activePayload[0].payload.date)},C=(0,W.jsx)(X,{children:t=>(0,W.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-2`,children:g}),(0,W.jsx)(Z,{variant:`line`,delay:.08,children:(0,W.jsx)(i,{width:`100%`,height:360,children:(0,W.jsxs)(v,{data:e,margin:oa,children:[(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:Da,stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>Da(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,W.jsx)(S,{}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:Q.ma7,name:o(`charts.requestsOverTime.totalMovingAverage`,{label:m}),dot:!1,strokeWidth:2.5,strokeDasharray:`6 4`,connectNulls:!0,isAnimationActive:t,animationBegin:0,animationDuration:$.slowDuration}),(_?.topModels??[]).map(([e],n)=>(0,W.jsx)(h,{type:`monotone`,dataKey:`${e}_ma7`,stroke:B(e),name:`${e} ${m}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,isAnimationActive:t,animationBegin:$.stagger*(n%6),animationDuration:$.slowDuration},`${e}_ma7`))]})})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-2`,children:o(`charts.requestsOverTime.requestsByModelTotal`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3`,children:(_?.topModels??[]).map(([e,t])=>{let n=_&&_.totalRequests>0?t/_.totalRequests*100:0;return(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,W.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:B(e)}}),(0,W.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e})]}),(0,W.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.toFixed(1),`%`]})]}),(0,W.jsx)(`div`,{className:`mt-2 text-lg font-semibold tabular-nums`,children:Da(t)}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:o(`charts.requestsOverTime.requestsInRange`)})]},e)})})]})]})});return(0,W.jsx)(aa,{title:o(`charts.requestsOverTime.title`),subtitle:_?o(`charts.requestsOverTime.summary`,{total:Da(_.totalRequests),peak:Da(_.peak.totalRequests),date:R(_.peak.date)}):o(`charts.requestsOverTime.subtitle`),info:G.requestsOverTime,summary:_?(0,W.jsx)(F,{value:_.totalRequests,type:`number`}):void 0,chartData:e,valueKey:`totalRequests`,valueFormatter:Da,expandedExtra:C,children:t=>{let r=t?420:320,g=t?440:340,C=t?70:54,te=t?112:82,w=t?`48%`:`46%`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-2 mb-3 text-center`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:o(`charts.requestsOverTime.total`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:_?Da(_.totalRequests):`0`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:p}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:_&&e.length>0?Da(_.totalRequests/e.length):`0`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:o(`charts.requestsOverTime.topModel`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold truncate`,children:_?.topModels[0]?.[0]??`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:o(`charts.requestsOverTime.topShare`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:_&&_.totalRequests>0&&_.topModels[0]?`${(_.topModels[0][1]/_.totalRequests*100).toFixed(1)}%`:`–`})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-4 ${t?`grid-cols-1 xl:grid-cols-3`:`grid-cols-1 lg:grid-cols-3`}`,children:[(0,W.jsx)(`div`,{className:t?`xl:col-span-2`:`lg:col-span-2`,children:(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,children:(0,W.jsx)(i,{width:`100%`,height:r,children:(0,W.jsxs)(v,{data:e,margin:oa,onClick:ee,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${l}-requests`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cumulative,stopOpacity:.28}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cumulative,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:Da,stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>Da(e),pinnedEntryNames:[o(`charts.requestsOverTime.totalRequestsSeries`)],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,W.jsx)(S,{}),(0,W.jsx)(s,{type:`monotone`,dataKey:`totalRequests`,stroke:Q.cumulative,fill:`url(#${l}-requests)`,name:o(`charts.requestsOverTime.totalRequestsSeries`),strokeWidth:1.8,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:Q.cumulative,fill:`hsl(var(--background))`},isAnimationActive:t,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:Q.ma7,name:m,dot:!1,strokeWidth:2.2,strokeDasharray:`5 5`,connectNulls:!0,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration}),y.map((e,n)=>(0,W.jsx)(h,{type:`monotone`,dataKey:e,stroke:B(e),name:e,dot:!1,strokeWidth:1.6,isAnimationActive:t,animationBegin:$.stagger*(n%5+1),animationDuration:$.duration},e))]})})})})}),(0,W.jsx)(`div`,{className:`min-w-0 pt-1`,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`radial`,delay:.04,children:(0,W.jsx)(i,{width:`100%`,height:g,children:(0,W.jsxs)(u,{children:[(0,W.jsxs)(c,{data:x,cx:`50%`,cy:w,innerRadius:C,outerRadius:te,paddingAngle:2,dataKey:`value`,nameKey:`name`,isAnimationActive:e,animationDuration:$.duration,animationBegin:$.stagger,animationEasing:$.easing,children:[x.map(e=>(0,W.jsx)(n,{fill:B(e.name)},e.name)),(0,W.jsx)(Oa,{total:_?Da(_.totalRequests):`0`})]}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>Da(e)})}),(0,W.jsx)(S,{wrapperStyle:{fontSize:`12px`,paddingTop:t?`18px`:`8px`},formatter:e=>{let t=x.find(t=>t.name===e);return(0,W.jsxs)(`span`,{className:`text-xs text-foreground`,children:[e,` (`,t?Da(t.value):``,`)`]})}})]})})})})})]})]})}})}function Aa(e){return N(e,1)}function ja(e,t,n,r,i){let a=e+t+n+r+i;return a>0?r/a*100:0}function Ma({timelineData:e,summaryData:t,viewMode:c}){let{t:l}=k(),u=(0,U.useId)().replace(/:/g,``),p=l(`charts.requestCacheHitRate.total`),m=l(c===`daily`?`charts.requestCacheHitRate.trailing7Rate`:`charts.requestCacheHitRate.trendRate`),g=(0,U.useMemo)(()=>_a(t).map(e=>({...e,model:e.model===`Total`?p:e.model})),[t,p]),_=(0,U.useMemo)(()=>{if(g.length===0)return null;let e=g[0];return e?{total:e,topModel:g.slice(1).sort((e,t)=>t.totalRate-e.totalRate)[0]??null,dominantModel:g.slice(1).sort((e,t)=>t.totalBaseTokens-e.totalBaseTokens)[0]??null,models:Math.max(g.length-1,0)}:null},[g]),y=(0,U.useMemo)(()=>{if(e.length===0)return[];let t=g.slice(1).map(e=>e.model),n=[...e].sort((e,t)=>e.date.localeCompare(t.date)),r=n.map(e=>ja(e.inputTokens,e.outputTokens,e.cacheCreationTokens,e.cacheReadTokens,e.thinkingTokens)),i=pa(r,Math.min(7,n.length)),a={};for(let e of t)a[e]=[];for(let e of n){let n=new Map;for(let r of e.modelBreakdowns){let e=De(r.modelName);if(!t.includes(e))continue;let i=n.get(e)??{input:0,output:0,cacheCreate:0,cacheRead:0,thinking:0};i.input+=r.inputTokens,i.output+=r.outputTokens,i.cacheCreate+=r.cacheCreationTokens,i.cacheRead+=r.cacheReadTokens,i.thinking+=r.thinkingTokens,n.set(e,i)}for(let e of t){let t=n.get(e),r=a[e];r&&r.push(t?ja(t.input,t.output,t.cacheCreate,t.cacheRead,t.thinking):0)}}return n.map((e,n)=>{let o={date:e.date,totalRate:r[n],totalRate_ma7:i[n]};for(let e of t)o[e]=a[e]?.[n]??0;return o})},[e,g]);if(!_||y.length===0)return null;let x=Math.max(220,Math.min(310,g.length*28+48)),ee=Math.max(280,Math.min(420,g.length*34+56)),C=c===`daily`?280:250,te=c===`daily`?360:320,w=Object.keys(y[0]??{}).filter(e=>e!==`date`&&e!==`totalRate`&&e!==`totalRate_ma7`),ne=(0,W.jsx)(`div`,{className:`mt-6 grid grid-cols-1 xl:grid-cols-3 gap-4`,children:g.slice(0,6).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.model}),(0,W.jsxs)(`div`,{className:`mt-2 flex items-end gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:l(`charts.requestCacheHitRate.totalRate`)}),(0,W.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:Aa(e.totalRate)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:l(`charts.requestCacheHitRate.trailing7Rate`)}),(0,W.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:Aa(e.trailing7Rate)})]})]})]},e.model))});return(0,W.jsx)(aa,{title:l(`charts.requestCacheHitRate.title`),subtitle:l(`charts.requestCacheHitRate.subtitle`,{total:Aa(_.total.totalRate),trailing:Aa(_.total.trailing7Rate)}),info:G.requestCacheHitRate,chartData:g,valueKey:`totalRate`,valueFormatter:Aa,expandedExtra:ne,children:e=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-2 mb-3 text-center`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:l(`charts.requestCacheHitRate.totalRate`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:Aa(_.total.totalRate)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:l(`charts.requestCacheHitRate.trailing7Rate`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:Aa(_.total.trailing7Rate)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:l(`charts.requestCacheHitRate.topModel`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold truncate`,children:_.topModel?.model??`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,W.jsx)(`div`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:l(`charts.requestCacheHitRate.models`)}),(0,W.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:_.models})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-4 ${e?`grid-cols-1 xl:grid-cols-[2fr_1fr]`:`grid-cols-1 lg:grid-cols-[2fr_1fr]`}`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-2`,children:l(`charts.requestCacheHitRate.timelineHeading`,{unit:j(c)})}),(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,delay:.04,children:(0,W.jsx)(i,{width:`100%`,height:e?te:C,children:(0,W.jsxs)(v,{data:y,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${u}-total-rate`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.24}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{type:`number`,domain:[0,100],tickFormatter:Aa,stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>Aa(e),pinnedEntryNames:[l(`charts.requestCacheHitRate.totalRate`)],showComputedTotal:!1,hideZeroValues:!0}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,W.jsx)(S,{}),(0,W.jsx)(s,{type:`monotone`,dataKey:`totalRate`,stroke:Q.cost,fill:`url(#${u}-total-rate)`,name:l(`charts.requestCacheHitRate.totalRate`),strokeWidth:2,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:Q.cost,fill:`hsl(var(--background))`},isAnimationActive:t,animationDuration:$.duration,animationEasing:$.easing}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalRate_ma7`,stroke:Q.ma7,name:m,dot:!1,strokeWidth:2,strokeDasharray:`5 5`,connectNulls:!0,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration,animationEasing:$.easing}),w.map((e,n)=>(0,W.jsx)(h,{type:`monotone`,dataKey:e,stroke:B(e),name:e,dot:!1,strokeWidth:1.8,connectNulls:!0,isAnimationActive:t,animationBegin:$.stagger*(n+2),animationDuration:$.slowDuration,animationEasing:$.easing},e))]})})})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-2`,children:l(`charts.requestCacheHitRate.modelBreakdownHeading`)}),(0,W.jsx)(X,{children:t=>(0,W.jsx)(Z,{variant:`line`,delay:.14,children:(0,W.jsx)(i,{width:`100%`,height:e?ee:x,children:(0,W.jsxs)(r,{data:g,layout:`vertical`,margin:{...oa,left:e?30:20,right:8},barCategoryGap:e?14:10,children:[(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.22,horizontal:!1}),(0,W.jsx)(d,{type:`number`,domain:[0,100],tickFormatter:Aa,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1}),(0,W.jsx)(a,{type:`category`,dataKey:`model`,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,width:e?126:108}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>Aa(e),pinnedEntryNames:[l(`charts.requestCacheHitRate.totalRate`),l(`charts.requestCacheHitRate.trailing7Rate`)],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,W.jsx)(S,{}),(0,W.jsx)(o,{dataKey:`totalRate`,name:l(`charts.requestCacheHitRate.totalRate`),radius:[0,4,4,0],fill:Q.cacheRead,isAnimationActive:t,animationDuration:$.duration,animationEasing:$.easing,children:g.map(e=>(0,W.jsx)(n,{fill:e.model===p?Q.cost:Q.cacheRead,fillOpacity:e.model===p?.95:.82},`${e.model}-total`))}),(0,W.jsx)(o,{dataKey:`trailing7Rate`,name:l(`charts.requestCacheHitRate.trailing7Rate`),radius:[0,4,4,0],fill:Q.ma7,isAnimationActive:t,animationBegin:$.stagger,animationDuration:$.slowDuration,animationEasing:$.easing,children:g.map(e=>(0,W.jsx)(n,{fill:e.model===p?Q.cumulative:Q.ma7,fillOpacity:e.model===p?.95:.8},`${e.model}-recent`))})]})})})})]})]})]})})}var Na={Input:Q.input,Output:Q.output,"Cache Write":Q.cacheWrite,"Cache Read":Q.cacheRead,Thinking:Q.cost};function Pa({viewBox:e,total:t}){let{t:n}=k();if(!e)return null;let{cx:r,cy:i}=e;return(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.tokenTypes.total`)}),(0,W.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function Fa({data:e}){let{t}=k(),r=e.reduce((e,t)=>e+t.value,0);return(0,W.jsx)(aa,{title:t(`charts.tokenTypes.title`),subtitle:t(`charts.tokenTypes.subtitle`),info:G.tokenTypes,chartData:e,valueKey:`value`,valueFormatter:L,children:t=>{let a=t?560:320,o=t?`66%`:`57%`,s=t?84:58,l=t?134:92;return(0,W.jsx)(X,{children:d=>(0,W.jsx)(Z,{variant:`radial`,delay:.04,children:(0,W.jsx)(i,{width:`100%`,height:a,children:(0,W.jsxs)(u,{children:[(0,W.jsxs)(c,{data:e,cx:`50%`,cy:o,innerRadius:s,outerRadius:l,paddingAngle:2,dataKey:`value`,nameKey:`name`,isAnimationActive:d,animationDuration:$.duration,animationBegin:$.stagger,animationEasing:$.easing,children:[e.map(e=>(0,W.jsx)(n,{fill:Na[e.name]??Q.cost},e.name)),(0,W.jsx)(Pa,{total:L(r)})]}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>L(e)})}),(0,W.jsx)(S,{wrapperStyle:{fontSize:`12px`,paddingTop:t?`22px`:`8px`},formatter:t=>{let n=e.find(e=>e.name===t);return(0,W.jsxs)(`span`,{className:`text-xs text-foreground`,children:[t,` (`,n?L(n.value):``,`)`]})}})]})})})})}})}function Ia({data:e}){let{t}=k(),[s,c]=(0,U.useState)(null),l=(0,U.useId)(),u=e=>`${l}-${e}`.replace(/:/g,``),p=Math.max(...e.map(e=>e.cost)),m=Math.min(...e.map(e=>e.cost)),h=e.findIndex(e=>e.cost===p),g=e.findIndex(e=>e.cost===m),_=e.filter(e=>e.day===`Sa`||e.day===`So`).reduce((e,t)=>e+t.cost,0),v=e.reduce((e,t)=>e+t.cost,0);return(0,W.jsx)(aa,{title:t(`charts.costByWeekday.title`),subtitle:t(`charts.costByWeekday.subtitle`,{peak:e[h]?.day??`–`,low:e[g]?.day??`–`,share:`${(v>0?_/v*100:0).toFixed(0)}%`}),info:G.costByWeekday,chartData:e,valueKey:`cost`,valueFormatter:P,children:(0,W.jsx)(X,{children:l=>(0,W.jsx)(Z,{variant:`bar`,children:(0,W.jsx)(i,{width:`100%`,height:300,children:(0,W.jsxs)(r,{data:e,margin:oa,onMouseMove:e=>{e?.activeTooltipIndex!==void 0&&typeof e.activeTooltipIndex==`number`&&c(e.activeTooltipIndex)},onMouseLeave:()=>c(null),children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsxs)(`linearGradient`,{id:u(`weekday`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.9}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:.4})]}),(0,W.jsxs)(`linearGradient`,{id:u(`weekdayActive`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:1}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:.6})]}),(0,W.jsxs)(`linearGradient`,{id:u(`weekdayPeak`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:1}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:.5})]}),(0,W.jsxs)(`linearGradient`,{id:u(`weekdayLow`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.8}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.3})]})]}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`day`,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(o,{dataKey:`cost`,radius:[4,4,0,0],name:t(`charts.costByWeekday.averageCost`),isAnimationActive:l,animationBegin:$.stagger,animationDuration:$.duration,animationEasing:$.easing,children:e.map((e,t)=>{let r=`url(#${u(`weekday`)})`;return s===t?r=`url(#${u(`weekdayActive`)})`:t===h?r=`url(#${u(`weekdayPeak`)})`:t===g&&(r=`url(#${u(`weekdayLow`)})`),(0,W.jsx)(n,{fill:r},t)})})]})})})})})}function La({data:e}){let{t}=k(),n=(0,U.useId)().replace(/:/g,``),{chartData:r,avg:o}=(0,U.useMemo)(()=>{let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=t.map(e=>e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0),r=pa(n),i=n.length>0?n.reduce((e,t)=>e+t,0)/n.length:0;return{chartData:t.map((e,t)=>({date:e.date,efficiency:n[t],effMA7:r[t]})),avg:i}},[e]);return r.length<3?null:(0,W.jsx)(aa,{title:t(`charts.tokenEfficiency.title`),subtitle:t(`charts.tokenEfficiency.subtitle`,{value:P(o)}),info:G.tokenEfficiency,chartData:r,valueKey:`efficiency`,valueFormatter:P,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`line`,delay:.04,children:(0,W.jsx)(i,{width:`100%`,height:250,children:(0,W.jsxs)(v,{data:r,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${n}-effGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.input,stopOpacity:.2}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.input,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(l,{y:o,stroke:Q.axis,strokeDasharray:`3 3`,strokeOpacity:.5}),(0,W.jsx)(s,{type:`monotone`,dataKey:`efficiency`,stroke:Q.input,fill:`url(#${n}-effGrad)`,strokeWidth:1.5,name:t(`charts.tokenEfficiency.series`),dot:!1,isAnimationActive:e,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`effMA7`,stroke:Q.ma7,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:t(`charts.tokenEfficiency.movingAverage`),isAnimationActive:e,animationBegin:$.stagger,animationDuration:$.slowDuration})]})})})})})}function Ra({active:e,payload:t,label:n}){if(!e||!t?.length)return null;let r=[...t].sort((e,t)=>t.value-e.value);return(0,W.jsxs)(`div`,{className:`bg-popover/90 backdrop-blur-xl border border-border/50 rounded-lg shadow-lg p-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`font-medium text-muted-foreground mb-1.5`,children:n}),(0,W.jsx)(`div`,{className:`space-y-1`,children:r.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{backgroundColor:e.color}}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,W.jsx)(`span`,{className:`font-mono font-medium text-foreground ml-auto`,children:N(e.value)})]},t))})]})}function za({data:e}){let{t}=k(),{chartData:n,models:r}=(0,U.useMemo)(()=>{let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=new Set;for(let e of t)for(let t of e.modelBreakdowns)n.add(De(t.modelName));let r=Array.from(n).sort();return{chartData:t.map(e=>{let t=e.totalCost,n={date:e.date},i={};for(let t of e.modelBreakdowns){let e=De(t.modelName);i[e]=(i[e]??0)+t.cost}for(let e of r)n[e]=t>0?(i[e]??0)/t*100:0;return n}),models:r}},[e]);return n.length<3||r.length<2?null:(0,W.jsx)(aa,{title:t(`charts.modelMix.title`),subtitle:t(`charts.modelMix.subtitle`),info:G.modelMix,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`line`,delay:.05,children:(0,W.jsx)(i,{width:`100%`,height:250,children:(0,W.jsxs)(p,{data:n,margin:oa,stackOffset:`none`,children:[(0,W.jsx)(`defs`,{children:r.map(e=>{let t=B(e),n=`mix-grad-${e.replace(/[\s.]/g,`-`)}`;return(0,W.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.85}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:.45})]},n)})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.3}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:N(Math.round(t),0)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1,domain:[0,100],ticks:[0,25,50,75,100]}),(0,W.jsx)(b,{content:(0,W.jsx)(Ra,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),r.map((t,n)=>(0,W.jsx)(s,{type:`monotone`,dataKey:t,stackId:`1`,stroke:B(t),strokeWidth:.5,strokeOpacity:.6,fill:`url(#${`mix-grad-${t.replace(/[\s.]/g,`-`)}`})`,name:t,isAnimationActive:e,animationBegin:$.stagger*(n%5),animationDuration:$.duration,animationEasing:$.easing},t))]})})})})})}function Ba(e,t){if(e.length===0)return[];let n=Math.min(...e),r=Math.max(...e),i=Math.min(8,Math.max(4,Math.ceil(Math.sqrt(e.length)))),a=(r-n||1)/i,o=Array.from({length:i},(e,o)=>{let s=n+a*o,c=o===i-1?r:s+a;return{label:`${t(s)}–${t(c)}`,rangeStart:s,rangeEnd:c,count:0}});for(let t of e){let e=o[Math.min(i-1,Math.floor((t-n)/a))];e&&(e.count+=1)}return o}function Va({active:e,payload:t}){let{t:n}=k();if(!e||!t?.length)return null;let r=t[0];return r?(0,W.jsxs)(`div`,{className:`max-w-[280px] bg-popover/90 backdrop-blur-xl border border-border/50 rounded-lg shadow-lg p-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`font-medium text-muted-foreground mb-1.5`,children:r.payload.label}),(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.interval`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:r.payload.label})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.dataPoints`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:M(r.value)})]})]})]}):null}function Ha({data:e,viewMode:t=`daily`}){let{t:s}=k(),c=(0,U.useId)().replace(/:/g,``),l=(0,U.useMemo)(()=>{if(e.length<2)return[];let n=e.map(e=>e.totalCost),r=e.map(e=>e.requestCount),i=e.map(e=>e.requestCount>0?e.totalTokens/e.requestCount:0);return[{title:s(`charts.distribution.costPerPeriod`,{period:je(t)}),data:Ba(n,P)},{title:s(`charts.distribution.requestsPerPeriod`,{period:je(t)}),data:Ba(r,M)},{title:s(`charts.distribution.tokensPerRequest`),data:Ba(i,L)}]},[e,t,s]);return e.length<2?(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:G.distributionAnalysis,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:s(`charts.distribution.title`)})})}),(0,W.jsx)(q,{children:(0,W.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground`,children:s(`charts.distribution.requiresData`)})})]}):(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:G.distributionAnalysis,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:s(`charts.distribution.title`)})})}),(0,W.jsx)(q,{className:`space-y-5`,children:l.map((e,t)=>(0,W.jsx)(C.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0,amount:.45},transition:{duration:.45,delay:.04*t,ease:`easeOut`},children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e.title}),(0,W.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.data.length,` `,s(`charts.distribution.buckets`)]})]}),(0,W.jsx)(i,{width:`100%`,height:160,children:(0,W.jsxs)(r,{data:e.data,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`${c}-distribution-${t}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.9}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:.4})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.25}),(0,W.jsx)(d,{dataKey:`label`,stroke:Q.axis,fontSize:10,tickLine:!1,interval:0,angle:e.data.length>5?-16:0,textAnchor:e.data.length>5?`end`:`middle`,height:e.data.length>5?48:30}),(0,W.jsx)(a,{stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,allowDecimals:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(Va,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,W.jsx)(o,{dataKey:`count`,radius:[6,6,0,0],fill:`url(#${c}-distribution-${t})`,isAnimationActive:!0,animationBegin:$.stagger*t,animationDuration:$.duration,children:e.data.map((t,r)=>(0,W.jsx)(n,{fill:`hsla(215, 70%, 55%, ${(.45+(e.data.length>1?r/(e.data.length-1):0)*.35).toFixed(2)})`},`${e.title}-${r}`))})]})})]})},e.title))})]})}function Ua(e,t,n){return e(n===`requestCost`?t>=.6?`charts.correlation.strongRequestCost`:t>=.3?`charts.correlation.mediumRequestCost`:`charts.correlation.weakRequestCost`:t<=-.3?`charts.correlation.negativeCache`:t<.2?`charts.correlation.neutralCache`:`charts.correlation.positiveCache`)}function Wa(e,t){if(e.length!==t.length||e.length<2)return 0;let n=e.reduce((e,t)=>e+t,0)/e.length,r=t.reduce((e,t)=>e+t,0)/t.length,i=e.reduce((e,i,a)=>{let o=t[a];return o===void 0?e:e+(i-n)*(o-r)},0),a=e.reduce((e,t)=>e+(t-n)**2,0),o=t.reduce((e,t)=>e+(t-r)**2,0);return a===0||o===0?0:i/Math.sqrt(a*o)}function Ga({active:e,payload:t,mode:n}){let{t:r}=k();if(!e||!t?.length)return null;let i=t[0]?.payload;return i?(0,W.jsxs)(`div`,{className:`max-w-[260px] bg-popover/90 backdrop-blur-xl border border-border/50 rounded-lg shadow-lg p-3 text-xs`,children:[(0,W.jsx)(`p`,{className:`font-medium text-muted-foreground mb-1.5`,children:I(i.label)}),(0,W.jsx)(`div`,{className:`space-y-1`,children:n===`requestCost`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:M(i.requests)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cost`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:P(i.y)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.tokensLabel`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:i.tokens===void 0?`–`:L(i.tokens)})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cacheRate`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:i.cacheRate===void 0?`–`:N(i.cacheRate,1)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.costPerRequest`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:P(i.y)})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,W.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:M(i.requests)})]})]})})]}):null}function Ka({title:e,subtitle:t,mode:n,data:r,color:o,animationBegin:s=0,xAxisName:c,xTickFormatter:l,yAxisName:u,footer:p,delay:m}){let h=(0,U.useRef)(null),v=w(h,{once:!0,amount:.45}),[x,S]=(0,U.useState)(!1),ee=x?r:[];return(0,W.jsx)(C.div,{ref:h,initial:{opacity:0,y:20},animate:v?{opacity:1,y:0}:{opacity:0,y:20},transition:{duration:.45,delay:m,ease:`easeOut`},onAnimationComplete:()=>{v&&S(!0)},children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t})]}),(0,W.jsx)(i,{width:`100%`,height:260,children:(0,W.jsxs)(g,{margin:oa,children:[(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.25}),(0,W.jsx)(d,{type:`number`,dataKey:`x`,stroke:Q.axis,fontSize:10,tickLine:!1,name:c,...l?{tickFormatter:l}:{}}),(0,W.jsx)(a,{type:`number`,dataKey:`y`,stroke:Q.axis,fontSize:10,tickLine:!1,axisLine:!1,name:u,tickFormatter:P}),(0,W.jsx)(_,{type:`number`,dataKey:`z`,range:[30,180]}),(0,W.jsx)(b,{content:(0,W.jsx)(Ga,{mode:n}),cursor:{strokeDasharray:`4 4`}}),(0,W.jsx)(y,{data:ee,fill:o,stroke:o,fillOpacity:.72,isAnimationActive:x,animationBegin:s,animationDuration:$.duration})]})}),(0,W.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:p})]})})}function qa({data:e}){let{t}=k(),n=(0,U.useMemo)(()=>e.map(e=>({x:e.requestCount,y:e.totalCost,z:Math.max(5,Math.sqrt(e.totalTokens/1e3)),label:e.date,tokens:e.totalTokens,requests:e.requestCount})),[e]),r=(0,U.useMemo)(()=>e.filter(e=>e.requestCount>0&&e.totalTokens>0).map(e=>{let t=e.cacheReadTokens/e.totalTokens*100;return{x:t,y:e.totalCost/e.requestCount,z:Math.max(5,Math.sqrt(e.requestCount)),label:e.date,cacheRate:t,requests:e.requestCount}}),[e]),i=Wa(n.map(e=>e.x),n.map(e=>e.y)),a=Wa(r.map(e=>e.x),r.map(e=>e.y));return e.length<2?(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:G.correlationAnalysis,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,W.jsx)(q,{children:(0,W.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground`,children:t(`charts.correlation.requiresData`)})})]}):(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:G.correlationAnalysis,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,W.jsxs)(q,{className:`grid grid-cols-1 xl:grid-cols-2 gap-4`,children:[(0,W.jsx)(Ka,{title:t(`charts.correlation.requestsVsCost`),subtitle:`r ${i.toFixed(2)} · ${t(`charts.correlation.points`,{count:n.length})}`,mode:`requestCost`,data:n,color:Q.cost,xAxisName:t(`charts.correlation.requestsAxis`),yAxisName:t(`charts.correlation.cost`),footer:Ua(t,i,`requestCost`),delay:.02}),(0,W.jsx)(Ka,{title:t(`charts.correlation.cacheVsCostPerRequest`),subtitle:`r ${a.toFixed(2)} · ${t(`charts.correlation.points`,{count:r.length})}`,mode:`cacheEfficiency`,data:r,color:Q.cumulative,animationBegin:$.stagger,xAxisName:t(`charts.correlation.cacheRate`),xTickFormatter:e=>N(e,0),yAxisName:t(`charts.correlation.costPerRequestAxis`),footer:Ua(t,a,`cacheEfficiency`),delay:.08})]})]})}function Ja({modelCosts:e,totalCost:t,viewMode:n=`daily`}){let{t:r}=k(),[i,a]=(0,U.useState)(`cost`),[o,s]=(0,U.useState)(!1),c=(0,U.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,cost:n.cost,tokens:n.tokens,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,costPerRequest:n.requests>0?n.cost/n.requests:0,tokensPerRequest:n.requests>0?n.tokens/n.requests:0,share:t>0?n.cost/t*100:0,requestShare:0,cacheShare:n.tokens>0?(n.cacheRead??0)/n.tokens*100:0,thinkingShare:n.tokens>0?(n.thinking??0)/n.tokens*100:0,days:n.days,requests:n.requests,costPerDay:n.days>0?n.cost/n.days:0})),[e,t]),l=(0,U.useMemo)(()=>c.reduce((e,t)=>e+t.requests,0),[c]),u=(0,U.useMemo)(()=>c.map(e=>({...e,requestShare:l>0?e.requests/l*100:0})),[c,l]),d=(0,U.useMemo)(()=>[...u].sort((e,t)=>{let n=e[i]-t[i];return o?n:-n}),[u,o,i]),f=d[0]??null,p=(0,U.useMemo)(()=>[...c].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[c]),m=e=>{e===i?s(!o):(a(e),s(!1))},h=e=>i===e?o?`ascending`:`descending`:`none`,g=({label:e,field:t})=>(0,W.jsx)(`th`,{"aria-sort":h(t),className:O(`px-3 py-2 text-right text-xs font-medium`,i===t?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>m(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,i===t&&`text-primary`)})]})});return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(Ei,{info:Dr.modelEfficiency,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:r(`tables.modelEfficiency.title`)})}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`tables.modelEfficiency.count`,{count:c.length})})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.modelEfficiency.topModel`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:f?.name??`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:f?r(`tables.modelEfficiency.share`,{value:N(f.share,0)}):`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.modelEfficiency.mostEfficient`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:p?.name??`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p?r(`tables.modelEfficiency.share`,{value:N(p.share,0)}):`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.modelEfficiency.totalRequests`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:M(l)}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:c.length>0?r(`tables.modelEfficiency.perModel`,{value:(l/c.length).toFixed(0)}):`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.modelEfficiency.topModelTokens`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:f?L(f.tokens):`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:f?`${f.days} ${je(n,!0)}`:`–`})]})]})]})}),(0,W.jsxs)(q,{children:[(0,W.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:d.map(e=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0`,style:{backgroundColor:B(e.name)}}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:e.name})]}),(0,W.jsx)(`div`,{className:`mt-1 inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground`,children:ke(e.name)})]}),(0,W.jsxs)(`div`,{className:`text-right`,children:[(0,W.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,W.jsx)(F,{value:e.cost,type:`currency`})}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`tables.modelEfficiency.share`,{value:N(e.share,1)})})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.modelEfficiency.tokens`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:L(e.tokens)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.modelEfficiency.costPerMillion`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.costPerMillion,type:`currency`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`common.requests`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:M(e.requests)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.modelEfficiency.costPerReq`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.costPerRequest,type:`currency`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.modelEfficiency.tokensPerReq`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:L(e.tokensPerRequest)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:`Cache %`}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:N(e.cacheShare,1)})]})]})]},e.name))}),(0,W.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,W.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,W.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,W.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:r(`tables.modelEfficiency.model`)}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.cost`),field:`cost`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.tokens`),field:`tokens`}),(0,W.jsx)(g,{label:`$/1M`,field:`costPerMillion`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.shareShort`),field:`share`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.req`),field:`requests`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.reqShare`),field:`requestShare`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.costPerReq`),field:`costPerRequest`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.tokensPerReq`),field:`tokensPerRequest`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.cacheShare`),field:`cacheShare`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.thinkingShare`),field:`thinkingShare`}),(0,W.jsx)(g,{label:r(`tables.modelEfficiency.avgPerUnit`,{unit:j(n)}),field:`costPerDay`}),(0,W.jsx)(g,{label:je(n,!0),field:`days`})]})}),(0,W.jsx)(`tbody`,{children:d.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-border/50 even:bg-muted/5 hover:bg-muted/10 transition-colors`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 flex-wrap`,children:[(0,W.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0`,style:{backgroundColor:B(e.name)}}),(0,W.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none`,Ve(ke(e.name))),children:ke(e.name)})]})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.cost,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.tokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.costPerMillion,type:`currency`})}),(0,W.jsxs)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm transition-all duration-500`,style:{width:`${e.share}%`,backgroundColor:`${B(e.name)}20`}}),(0,W.jsx)(`span`,{className:`relative`,children:N(e.share)})]}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:M(e.requests)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:N(e.requestShare,1)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.costPerRequest,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:L(e.tokensPerRequest)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:N(e.cacheShare,1)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:N(e.thinkingShare,1)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.costPerDay,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:e.days})]},e.name))})]})})]})]})}function Ya({providerMetrics:e,totalCost:t,viewMode:n=`daily`}){let{t:r}=k(),[i,a]=(0,U.useState)(`cost`),[o,s]=(0,U.useState)(!1),c=(0,U.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,...n,share:t>0?n.cost/t*100:0,costPerRequest:n.requests>0?n.cost/n.requests:0,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,cacheShare:n.tokens>0?n.cacheRead/n.tokens*100:0})),[e,t]),l=(0,U.useMemo)(()=>[...c].sort((e,t)=>{let n=e[i]-t[i];return o?n:-n}),[c,o,i]),u=l[0]??null,d=(0,U.useMemo)(()=>[...c].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[c]),f=(0,U.useMemo)(()=>c.reduce((e,t)=>e+t.requests,0),[c]),p=e=>{i===e?s(!o):(a(e),s(!1))},m=e=>i===e?o?`ascending`:`descending`:`none`,h=({label:e,field:t})=>(0,W.jsx)(`th`,{"aria-sort":m(t),className:O(`px-3 py-2 text-right text-xs font-medium`,i===t?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>p(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,i===t&&`text-primary`)})]})});return(0,W.jsxs)(K,{children:[(0,W.jsxs)(Gr,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(Ei,{info:Dr.providerEfficiency,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:r(`tables.providerEfficiency.title`)})}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`tables.providerEfficiency.count`,{count:c.length})})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.providerEfficiency.leadProvider`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:u?.name??`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u?r(`tables.providerEfficiency.share`,{value:N(u.share,0)}):`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.providerEfficiency.mostEfficient`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:d?.name??`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:d?`${d.costPerMillion.toFixed(2)} $/1M`:`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.providerEfficiency.totalRequests`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:M(f)}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:c.length>0?r(`tables.providerEfficiency.perProvider`,{value:(f/c.length).toFixed(0)}):`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.providerEfficiency.avgPerUnit`,{unit:j(n)})}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:u?(0,W.jsx)(F,{value:u.cost/Math.max(u.days,1),type:`currency`}):`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:u?`${u.days} ${je(n,!0)}`:`–`})]})]})]}),(0,W.jsxs)(q,{children:[(0,W.jsx)(`div`,{className:`grid gap-2 md:hidden mb-4`,children:l.map(e=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium leading-none`,Ve(e.name)),children:e.name}),(0,W.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:r(`tables.providerEfficiency.share`,{value:N(e.share,1)})})]}),(0,W.jsxs)(`div`,{className:`text-right`,children:[(0,W.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,W.jsx)(F,{value:e.cost,type:`currency`})}),(0,W.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[M(e.requests),` `,r(`tables.providerEfficiency.req`)]})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.providerEfficiency.tokens`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:L(e.tokens)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.providerEfficiency.costPerReq`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.costPerRequest,type:`currency`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.providerEfficiency.costPerMillion`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.costPerMillion,type:`currency`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`tables.providerEfficiency.cacheShare`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:N(e.cacheShare,1)})]})]})]},e.name))}),(0,W.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,W.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,W.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,W.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:r(`tables.providerEfficiency.provider`)}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.cost`),field:`cost`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.shareShort`),field:`share`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.req`),field:`requests`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.tokens`),field:`tokens`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.costPerReq`),field:`costPerRequest`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.costPerMillion`),field:`costPerMillion`}),(0,W.jsx)(h,{label:r(`tables.providerEfficiency.cacheShare`),field:`cacheShare`})]})}),(0,W.jsx)(`tbody`,{children:l.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-border/50 even:bg-muted/5 hover:bg-muted/10 transition-colors`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium leading-none`,Ve(e.name)),children:e.name})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.cost,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:N(e.share,1)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:M(e.requests)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:L(e.tokens)}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.costPerRequest,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.costPerMillion,type:`currency`})}),(0,W.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:N(e.cacheShare,1)})]},e.name))})]})})]})]})}function Xa({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:r}=k(),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(`date`),[c,l]=(0,U.useState)(!1),u=(0,U.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(o){case`date`:return c?e.date.localeCompare(t.date):t.date.localeCompare(e.date);case`cost`:return c?e.totalCost-t.totalCost:t.totalCost-e.totalCost;case`tokens`:return c?e.totalTokens-t.totalTokens:t.totalTokens-e.totalTokens;case`costPerM`:{let n=e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,r=t.totalTokens>0?t.totalCost/(t.totalTokens/1e6):0;return c?n-r:r-n}}}),t},[e,o,c]),d=i?u:u.slice(0,30),f=(0,U.useMemo)(()=>[...e].sort((e,t)=>e.date.localeCompare(t.date)),[e]),p=(0,U.useMemo)(()=>{let e=new Map;return f.forEach((t,n)=>{let r=n>0?f[n-1]:null,i=f.slice(Math.max(0,n-7),n),a=r&&r.totalCost>0?(t.totalCost-r.totalCost)/r.totalCost*100:null,o=i.length>0?i.reduce((e,t)=>e+t.totalCost,0)/i.length:null,s=i.length>0?i.reduce((e,t)=>e+t.requestCount,0)/i.length:null;e.set(t.date,{...a===null?{}:{prevCostDelta:a},...o===null?{}:{avgCost7:o},...s===null?{}:{avgRequests7:s}})}),e},[f]),m=(0,U.useMemo)(()=>Math.max(...e.map(e=>e.totalCost),0),[e]),h=(0,U.useMemo)(()=>{if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.totalCost,0),n=e.reduce((e,t)=>e+t.totalTokens,0);return{totalCost:t,totalTokens:n,totalRequests:e.reduce((e,t)=>e+t.requestCount,0),cacheShare:n>0?e.reduce((e,t)=>e+t.cacheReadTokens,0)/n*100:0,top:[...e].sort((e,t)=>t.totalCost-e.totalCost)[0]??null}},[e]),g=e=>{e===o?l(!c):(s(e),l(!1))},_=e=>o===e?c?`ascending`:`descending`:`none`;return(0,W.jsxs)(K,{children:[(0,W.jsxs)(Gr,{className:`flex flex-row items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,W.jsx)(Ei,{info:Dr.recentDays,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:r(n===`monthly`?`tables.recentDays.monthsDetail`:n===`yearly`?`tables.recentDays.yearsDetail`:`tables.recentDays.daysDetail`)})}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:r(`tables.recentDays.showing`,{shown:d.length,total:u.length,unit:je(n,!0)})})]}),u.length>30&&(0,W.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>a(!i),children:r(i?`tables.recentDays.showLess`:`tables.recentDays.showAll`)})]}),(0,W.jsxs)(q,{children:[h&&(0,W.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 lg:grid-cols-5 gap-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.recentDays.totalCost`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,W.jsx)(F,{value:h.totalCost,type:`currency`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.recentDays.totalTokens`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,W.jsx)(F,{value:h.totalTokens,type:`tokens`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.recentDays.requests`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,W.jsx)(F,{value:h.totalRequests,type:`number`})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.recentDays.cacheReadShare`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N(h.cacheShare,1)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:r(`tables.recentDays.peak`)}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:h.top?I(h.top.date):`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:h.top?P(h.top.totalCost):`–`})]})]}),(0,W.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:d.map(e=>{let i=e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,a=e.modelBreakdowns.map(e=>({name:De(e.modelName),provider:ke(e.modelName)})).filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t);return(0,W.jsxs)(`button`,{onClick:()=>t?.(e.date),className:`rounded-xl border border-border/50 bg-muted/10 p-3 text-left`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-medium`,children:I(e.date,`long`)}),(0,W.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[M(e.requestCount),` `,r(`common.requests`)]})]}),(0,W.jsxs)(`div`,{className:`text-right`,children:[(0,W.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,W.jsx)(F,{value:e.totalCost,type:`currency`,interactive:!1})}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,W.jsx)(F,{value:e.totalTokens,type:`tokens`,interactive:!1})}),n===`daily`&&p.get(e.date)?.prevCostDelta!==void 0&&(0,W.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[r(`tables.recentDays.previousDay`),` `,p.get(e.date).prevCostDelta>=0?`↑`:`↓`,Math.abs(p.get(e.date).prevCostDelta).toFixed(0),`%`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`common.input`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.inputTokens,type:`tokens`,interactive:!1})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:r(`common.output`)}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:e.outputTokens,type:`tokens`,interactive:!1})})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,W.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,W.jsx)(F,{value:i,type:`currency`,interactive:!1})})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[a.slice(0,4).map(({name:e,provider:t})=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium leading-tight`,style:{backgroundColor:`${B(e)}20`,color:B(e)},children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,Ve(t)),children:t})]},e)),a.length>4&&(0,W.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] text-muted-foreground border border-border/50`,children:r(`tables.modelEfficiency.more`,{count:a.length-4})})]}),n===`daily`&&p.get(e.date)?.avgCost7!==void 0&&(0,W.jsxs)(`div`,{className:`mt-3 text-[10px] text-muted-foreground`,children:[r(`tables.recentDays.avg7d`),` `,P(p.get(e.date).avgCost7),` ·`,` `,r(`tables.recentDays.reqAvg`),` `,p.get(e.date).avgRequests7?.toFixed(0)??`–`]})]},e.date)})}),(0,W.jsx)(`div`,{className:`hidden md:block overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,W.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,W.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,W.jsx)(`th`,{"aria-sort":_(`date`),className:O(`px-2 py-2 text-left text-xs font-medium`,o===`date`?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(`date`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[r(`tables.recentDays.date`),` `,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,o===`date`&&`text-primary`)})]})}),(0,W.jsx)(`th`,{"aria-sort":_(`cost`),className:O(`px-2 py-2 text-right text-xs font-medium`,o===`cost`?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(`cost`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[r(`tables.recentDays.cost`),` `,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,o===`cost`&&`text-primary`)})]})}),(0,W.jsx)(`th`,{"aria-sort":_(`tokens`),className:O(`px-2 py-2 text-right text-xs font-medium`,o===`tokens`?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(`tokens`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[r(`tables.recentDays.tokens`),` `,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,o===`tokens`&&`text-primary`)})]})}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden md:table-cell`,children:r(`common.input`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden md:table-cell`,children:r(`common.output`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden lg:table-cell`,children:r(`common.cacheWrite`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden lg:table-cell`,children:r(`common.cacheRead`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden xl:table-cell`,children:r(`common.thinking`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground hidden xl:table-cell`,children:r(`common.requestsShort`)}),(0,W.jsx)(`th`,{"aria-sort":_(`costPerM`),className:O(`px-2 py-2 text-right text-xs font-medium`,o===`costPerM`?`text-foreground`:`text-muted-foreground`),children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(`costPerM`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[`$/1M`,` `,(0,W.jsx)(Lt,{"aria-hidden":`true`,className:O(`h-3 w-3`,o===`costPerM`&&`text-primary`)})]})}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:r(`tables.recentDays.models`)})]})}),(0,W.jsx)(`tbody`,{children:d.map(e=>{let i=e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0;return(0,W.jsxs)(`tr`,{className:`border-b border-border/50 border-l-[3px] hover:bg-muted/10 transition-colors cursor-pointer active:bg-muted/20`,style:{borderLeftColor:`hsla(215, 70%, 55%, ${.2+(m>0?e.totalCost/m:0)*.8})`},onClick:()=>t?.(e.date),children:[(0,W.jsx)(`td`,{className:`px-2 py-2.5 whitespace-nowrap`,children:I(e.date,`long`)}),(0,W.jsxs)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums relative`,children:[(0,W.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm bg-primary/8 transition-all duration-300`,style:{width:`${m>0?e.totalCost/m*100:0}%`}}),(0,W.jsx)(`span`,{className:`relative`,children:(0,W.jsx)(F,{value:e.totalCost,type:`currency`})})]}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:e.totalTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden md:table-cell`,children:(0,W.jsx)(F,{value:e.inputTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden md:table-cell`,children:(0,W.jsx)(F,{value:e.outputTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden lg:table-cell`,children:(0,W.jsx)(F,{value:e.cacheCreationTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden lg:table-cell`,children:(0,W.jsx)(F,{value:e.cacheReadTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden xl:table-cell`,children:(0,W.jsx)(F,{value:e.thinkingTokens,type:`tokens`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums hidden xl:table-cell`,children:(0,W.jsx)(F,{value:e.requestCount,type:`number`})}),(0,W.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,W.jsx)(F,{value:i,type:`currency`})}),(0,W.jsxs)(`td`,{className:`px-2 py-2.5`,children:[(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.modelBreakdowns.map(e=>({name:De(e.modelName),provider:ke(e.modelName)})).filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).map(({name:e,provider:t})=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium leading-tight`,style:{backgroundColor:`${B(e)}20`,color:B(e)},children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`span`,{className:O(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,Ve(t)),children:t})]},e))}),n===`daily`&&p.get(e.date)?.avgCost7!==void 0&&(0,W.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[r(`tables.recentDays.previousDay`),` `,p.get(e.date)?.prevCostDelta===void 0?`–`:`${p.get(e.date).prevCostDelta>=0?`↑`:`↓`}${Math.abs(p.get(e.date).prevCostDelta).toFixed(0)}%`,` `,`· `,r(`tables.recentDays.avg7d`),` `,P(p.get(e.date).avgCost7)]})]})]},e.date)})})]})})]})]})}var Za=14,Qa=Za+2,$a=30,eo=26;function to(e,t,n){if(e===0)return`hsl(224, 12%, 14%)`;let r=Math.min(e/t,1);return r<.15?`hsl(${n}, 70%, 18%)`:r<.3?`hsl(${n}, 70%, 26%)`:r<.45?`hsl(${n}, 70%, 34%)`:r<.6?`hsl(${n}, 70%, 42%)`:r<.75?`hsl(${n}, 70%, 52%)`:r<.9?`hsl(${n}, 70%, 60%)`:`hsl(${n}, 70%, 70%)`}function no({data:e,viewMode:t=`daily`,metric:n=`cost`}){let{t:r}=k(),i=Pe(),[a,o]=(0,U.useState)(null),s=(0,U.useRef)(null),c=(0,U.useMemo)(()=>Array.from({length:7},(e,t)=>t).map(e=>e%2==1?``:new Intl.DateTimeFormat(i,{weekday:`short`}).format(new Date(Date.UTC(2024,0,1+e))).slice(0,2)),[i]),l=(0,U.useMemo)(()=>new Intl.DateTimeFormat(i,{year:`numeric`,month:`long`,day:`numeric`}),[i]),u={cost:{title:r(`charts.heatmap.costTitle`),empty:r(`charts.heatmap.costEmpty`),formatter:P,accessor:e=>e.totalCost,hue:215},requests:{title:r(`charts.heatmap.requestsTitle`),empty:r(`charts.heatmap.requestsEmpty`),formatter:M,accessor:e=>e.requestCount,hue:160},tokens:{title:r(`charts.heatmap.tokensTitle`),empty:r(`charts.heatmap.tokensEmpty`),formatter:L,accessor:e=>e.totalTokens,hue:35}}[n],d=n===`cost`?G.heatmap:n===`requests`?G.requestHeatmap:G.tokenHeatmap,{cells:f,weeks:p,months:m,maxValue:h}=(0,U.useMemo)(()=>{if(e.length===0)return{cells:[],weeks:0,months:[],maxValue:0};let t=new Map,n=0;for(let r of e){let e=u.accessor(r);t.set(r.date,e),e>n&&(n=e)}let r=[...e].sort((e,t)=>e.date.localeCompare(t.date)),a=r[0],o=r[r.length-1];if(!a||!o)return{cells:[],weeks:0,months:[],maxValue:0};let s=new Date(a.date+`T00:00:00`),c=new Date(o.date+`T00:00:00`),l=(s.getDay()+6)%7,d=new Date(s);d.setDate(d.getDate()-l);let f=[],p=[],m=new Date(d),h=0,g=-1;for(;m<=c||h===0;){let e=ze(m),n=(m.getDay()+6)%7,r=t.get(e)??0;if(n===0){let e=m.getMonth();e!==g&&(p.push({label:m.toLocaleDateString(i,{month:`short`}),week:h}),g=e)}if(f.push({date:e,value:r,week:h,day:n}),m.setDate(m.getDate()+1),n===6&&h++,m>c&&n===6)break}return{cells:f,weeks:h+1,months:p,maxValue:n}},[u,e,i]),g=Me();if(t!==`daily`)return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:d,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:u.title})})}),(0,W.jsx)(q,{children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u.empty}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:r(`charts.heatmap.switchToDaily`)})]})})]});if(f.length===0)return null;let _=p*Qa+$a,v=7*Qa+eo+8;return(0,W.jsxs)(K,{className:`overflow-visible`,children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:d,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:u.title})})}),(0,W.jsx)(q,{className:`overflow-visible`,children:(0,W.jsxs)(`div`,{ref:s,className:`relative overflow-visible z-10`,children:[(0,W.jsx)(`div`,{className:`overflow-x-auto overflow-y-hidden`,children:(0,W.jsxs)(`svg`,{width:_,height:v,className:`block`,children:[c.map((e,t)=>e&&(0,W.jsx)(`text`,{x:0,y:eo+t*Qa+Za-2,fontSize:9,fill:`hsl(220, 8%, 46%)`,className:`font-mono`,children:e},t)),m.map((e,t)=>(0,W.jsx)(`text`,{x:$a+e.week*Qa,y:12,fontSize:9,fill:`hsl(220, 8%, 46%)`,className:`font-mono`,children:e.label},t)),f.map((e,t)=>{let n=e.date===g,i=r(`charts.heatmap.cellLabel`,{date:l.format(new Date(`${e.date}T00:00:00`)),value:u.formatter(e.value)});return(0,W.jsxs)(`g`,{children:[(0,W.jsx)(`rect`,{x:$a+e.week*Qa,y:eo+e.day*Qa,width:Za,height:Za,rx:2,fill:to(e.value,h,u.hue),stroke:`transparent`,strokeWidth:1.5,className:`transition-all duration-150 cursor-pointer focus-visible:stroke-primary`,tabIndex:0,role:`img`,"aria-label":i,"aria-current":n?`date`:void 0,onMouseEnter:t=>{let n=s.current?.getBoundingClientRect();n&&o({x:t.clientX-n.left,y:t.clientY-n.top-12,date:e.date,value:e.value})},onFocus:t=>{let n=s.current?.getBoundingClientRect();if(!n)return;let r=t.currentTarget.getBoundingClientRect();o({x:r.left-n.left+r.width/2,y:r.top-n.top-8,date:e.date,value:e.value})},onBlur:()=>o(null),onMouseLeave:()=>o(null),children:(0,W.jsx)(`title`,{children:i})}),n&&(0,W.jsx)(`rect`,{x:$a+e.week*Qa-1,y:eo+e.day*Qa-1,width:Za+2,height:Za+2,rx:3,fill:`none`,stroke:`hsl(215, 70%, 55%)`,strokeWidth:1.5})]},t)})]})}),a&&(0,W.jsxs)(`div`,{className:`absolute z-30 -translate-x-1/2 -translate-y-full rounded-md border border-border bg-popover px-2 py-1 text-xs shadow-lg pointer-events-none whitespace-nowrap`,style:{left:a.x,top:a.y},children:[(0,W.jsx)(`span`,{className:`font-medium`,children:u.formatter(a.value)}),(0,W.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:a.date})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-2 text-[10px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:r(`charts.heatmap.less`)}),[0,.15,.3,.45,.6,.75,.9,1].map((e,t)=>(0,W.jsx)(`div`,{className:`w-3 h-3 rounded-sm`,style:{backgroundColor:to(e*h,h,u.hue)}},t)),(0,W.jsx)(`span`,{children:r(`charts.heatmap.more`)})]})]})})]})}function ro({data:e,viewMode:t=`daily`}){let{t:n}=k(),{chartData:r,forecastTotal:o,currentMonthTotal:c,dailyAvgTrend:l,projectedDailyBurn:u,remainingDays:p,confidence:m,confidenceColor:g}=(0,U.useMemo)(()=>{let t=wa(e);if(!t)return{chartData:[],forecastTotal:0,currentMonthTotal:0,dailyAvgTrend:null,projectedDailyBurn:0,remainingDays:0,confidence:`low`,confidenceColor:`text-red-400 bg-red-400/10`};let{currentMonth:n,currentMonthTotal:r,remainingDays:i,projectedDailyBurn:a,volatility:o,lowerDaily:s,upperDaily:c,forecastTotal:l,dailyAvgTrend:u,confidence:d,elapsedCalendarSeries:f,daysInMonth:p}=t,m=d===`high`?`text-green-400 bg-green-400/10`:d===`medium`?`text-yellow-400 bg-yellow-400/10`:`text-red-400 bg-red-400/10`,h=[];for(let e of f)h.push({date:e.date,cost:e.cost});let g=f[f.length-1]?.cost??0;if(h.length>0){let e=h[h.length-1];e&&(e.forecast=g,e.lower=Math.max(0,g-o),e.upper=g+o,e.band=(e.upper??0)-(e.lower??0))}for(let e=f.length+1;e<=p;e++){let t=`${n}-${String(e).padStart(2,`0`)}`;h.push({date:t,forecast:a,lower:s,upper:c,band:c-s})}return{chartData:h,forecastTotal:l,currentMonthTotal:r,dailyAvgTrend:u,projectedDailyBurn:a,remainingDays:i,confidence:d,confidenceColor:m}},[e]);if(t!==`daily`){let r=[...e].sort((e,t)=>e.date.localeCompare(t.date)).reduce((e,t)=>e+t.totalCost,0),i=e.length>0?r/e.length:0;return e.length===0?(0,W.jsx)(`div`,{className:`space-y-4`,children:(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/80 p-6 flex flex-col items-center justify-center text-center`,children:[(0,W.jsx)(ht,{className:`h-8 w-8 text-muted-foreground/20 mb-3`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground font-medium`,children:n(`forecast.noData`)})]})}):(0,W.jsx)(`div`,{className:`space-y-4`,children:(0,W.jsx)(Y,{label:n(t===`monthly`?`forecast.avgMonthlyCost`:`forecast.avgYearlyCost`),value:(0,W.jsx)(F,{value:i,type:`currency`}),subtitle:n(`forecast.totalOverPeriods`,{total:P(r),count:e.length,unit:n(t===`monthly`?`periods.months`:`periods.years`)}),icon:(0,W.jsx)(ht,{className:`h-4 w-4`})})})}return r.length===0?(0,W.jsx)(`div`,{className:`space-y-4`,children:(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/80 p-6 flex flex-col items-center justify-center text-center`,children:[(0,W.jsx)(ht,{className:`h-8 w-8 text-muted-foreground/20 mb-3`}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground font-medium`,children:n(`forecast.noForecast`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:n(`forecast.requiresTwoDays`)})]})}):(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(Y,{label:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[n(`forecast.monthEndForecast`),` `,(0,W.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${g}`,children:n(`forecast.${m}`)})]}),value:(0,W.jsx)(F,{value:o,type:`currency`}),subtitle:`${n(`forecast.soFar`,{value:P(c)})} · ${n(`forecast.remainingDays`,{count:p})}${l?` · ${n(`forecast.projectedPerDay`,{value:P(u)})}`:``}`,icon:(0,W.jsx)(ht,{className:`h-4 w-4`}),trend:l&&l.change!==0?{value:l.change,label:n(`forecast.vsLastWeek`)}:null}),(0,W.jsx)(aa,{title:n(`forecast.chartTitle`),subtitle:n(`forecast.chartSubtitle`),summary:(0,W.jsx)(F,{value:o,type:`currency`}),info:G.forecast,chartData:r,valueKey:`cost`,valueFormatter:P,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`line`,delay:.05,children:(0,W.jsx)(i,{width:`100%`,height:250,children:(0,W.jsxs)(v,{data:r,margin:oa,children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:`forecast-cost-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:Q.cost,stopOpacity:.3}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:Q.cost,stopOpacity:0})]})}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid}),(0,W.jsx)(d,{dataKey:`date`,tickFormatter:R,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(t)},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{content:(0,W.jsx)(z,{formatter:e=>P(e)})}),(0,W.jsx)(S,{}),(0,W.jsx)(s,{type:`monotone`,dataKey:`lower`,stackId:`forecast-band`,stroke:`none`,fill:`transparent`,name:n(`forecast.lowerBound`)}),(0,W.jsx)(s,{type:`monotone`,dataKey:`band`,stackId:`forecast-band`,stroke:`none`,fill:Q.cumulative,fillOpacity:.12,name:n(`forecast.uncertaintyBand`),isAnimationActive:e,animationBegin:$.stagger,animationDuration:$.duration}),(0,W.jsx)(s,{type:`monotone`,dataKey:`cost`,stroke:Q.cost,fill:`url(#forecast-cost-grad)`,name:n(`forecast.actualCost`),strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:0,animationDuration:$.duration,animationEasing:$.easing}),(0,W.jsx)(h,{type:`monotone`,dataKey:`forecast`,stroke:Q.cumulative,name:n(`forecast.projection`),dot:!1,strokeWidth:2,strokeDasharray:`6 3`,connectNulls:!0,isAnimationActive:e,animationBegin:$.stagger*2,animationDuration:$.slowDuration})]})})})})})]})}function io({data:e,viewMode:t=`daily`}){let{t:n}=k(),{actualCost:r,hypotheticalCost:i,savings:a,savingsPercent:o,dailyAvg:s,heuristicModels:c}=(0,U.useMemo)(()=>{let t=0,n=0,r=new Set;for(let i of e){t+=i.totalCost;for(let e of i.modelBreakdowns){let t=De(e.modelName),i=we[t];if(!i){r.add(t),n+=e.cost+e.cacheReadTokens/1e6*10;continue}let a=e.cacheReadTokens/1e6*i.input,o=e.cacheReadTokens/1e6*i.cacheRead;n+=e.cost-o+a}}let i=n-t,a=n>0?i/n*100:0,o=e.reduce((e,t)=>e+(t._aggregatedDays??1),0),s=o>0?t/o:0;return{actualCost:t,hypotheticalCost:n,savings:i,savingsPercent:a,dailyAvg:s,heuristicModels:Array.from(r).sort()}},[e]);if(e.length===0)return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsxs)(Kr,{className:`text-sm font-medium text-muted-foreground flex items-center gap-2`,children:[(0,W.jsx)(It,{className:`h-4 w-4 text-muted-foreground/30`}),n(`cacheRoi.title`)]})}),(0,W.jsx)(q,{children:(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:n(`cacheRoi.noData`)})})]});let l=i>0?r/i*100:100;return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:G.cacheROI,children:(0,W.jsxs)(Kr,{className:`text-sm font-medium text-muted-foreground flex items-center gap-2`,children:[(0,W.jsx)(It,{className:`h-4 w-4 text-yellow-500`}),n(`cacheRoi.title`)]})})}),(0,W.jsxs)(q,{className:`space-y-4`,children:[c.length>0&&(0,W.jsx)(`div`,{className:`rounded-lg border border-amber-500/20 bg-amber-500/8 px-3 py-2 text-xs text-amber-200/90`,children:n(`cacheRoi.heuristicFallback`,{count:c.length,modelsLabel:c.length===1?n(`cacheRoi.model`):n(`cacheRoi.models`)})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withoutCache`)}),(0,W.jsx)(`div`,{className:`text-lg font-bold text-red-400`,children:(0,W.jsx)(F,{value:i,type:`currency`})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withCacheActual`)}),(0,W.jsx)(`div`,{className:`text-lg font-bold text-green-400`,children:(0,W.jsx)(F,{value:r,type:`currency`})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.savings`)}),(0,W.jsxs)(`div`,{className:`text-lg font-bold text-primary`,children:[(0,W.jsx)(F,{value:a,type:`currency`}),(0,W.jsxs)(`span`,{className:`text-xs ml-1 text-green-400`,children:[`(`,N(o),`)`]})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.avgCostPerUnit`,{unit:j(t)})}),(0,W.jsx)(`div`,{className:`text-lg font-bold text-foreground`,children:(0,W.jsx)(F,{value:s,type:`currency`})})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground w-24`,children:n(`cacheRoi.withoutCache`)}),(0,W.jsx)(`div`,{className:`flex-1 h-6 bg-red-400/20 rounded-md overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full bg-red-400/60 rounded-md`,style:{width:`100%`}})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground w-24`,children:n(`cacheRoi.withCache`)}),(0,W.jsxs)(`div`,{className:`flex-1 h-6 bg-muted/20 rounded-md overflow-hidden flex`,children:[(0,W.jsx)(`div`,{className:`h-full bg-green-400/60 rounded-l-md transition-all duration-1000`,style:{width:`${l}%`}}),(0,W.jsx)(`div`,{className:`h-full bg-green-400/20 flex-1 rounded-r-md border-l border-green-400/30 border-dashed`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`w-2 h-2 rounded-sm bg-green-400/60`}),` `,n(`cacheRoi.paid`)]}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`w-2 h-2 rounded-sm bg-green-400/20 border border-green-400/30 border-dashed`}),` `,n(`cacheRoi.saved`)]})]})]})]})]})}function ao(e,t,n=!1){if(t===0&&e===0)return{value:0,color:`text-muted-foreground`,arrow:``,hasData:!1};if(t===0)return{value:0,color:`text-muted-foreground`,arrow:`↑`,hasData:!1};let r=(e-t)/t*100;return{value:Math.abs(r),color:r===0?`text-muted-foreground`:r>0===n?`text-green-400`:`text-red-400`,arrow:r>0?`↑`:r<0?`↓`:``,hasData:!0}}function oo({data:e}){let{t}=k(),[n,r]=(0,U.useState)(`week`),{periodA:i,periodB:a,labelA:o,labelB:s}=(0,U.useMemo)(()=>{let r=[...e].sort((e,t)=>e.date.localeCompare(t.date));if(r.length===0)return{periodA:[],periodB:[],labelA:``,labelB:``};let i=r[r.length-1];if(!i)return{periodA:[],periodB:[],labelA:``,labelB:``};let a=i.date,o=new Date(a+`T00:00:00`),s=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(n===`week`){let e=o.getDay(),n=e===0?6:e-1,i=new Date(o);i.setDate(i.getDate()-n);let c=new Date(i);c.setDate(c.getDate()-7);let l=new Date(i);l.setDate(l.getDate()-1);let u=s(i),d=s(c);return{periodA:r.filter(e=>e.date>=u&&e.date<=a),periodB:r.filter(e=>e.date>=d&&e.date<u),labelA:t(`comparison.thisWeek`),labelB:t(`comparison.lastWeek`)}}let c=a.slice(0,7),l=new Date(o);l.setDate(1),l.setMonth(l.getMonth()-1);let u=s(l).slice(0,7);return{periodA:r.filter(e=>e.date.startsWith(c)),periodB:r.filter(e=>e.date.startsWith(u)),labelA:t(`comparison.thisMonth`),labelB:t(`comparison.lastMonth`)}},[e,n,t]),c=(0,U.useMemo)(()=>fa(i),[i]),l=(0,U.useMemo)(()=>fa(a),[a]);if(e.length<7)return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:G.periodComparison,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})})}),(0,W.jsx)(q,{children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`comparison.notEnoughData`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:t(`comparison.requiresDays`,{count:e.length})})]})})]});let u=a.length>0,d=e=>u?e:`–`,f=[{label:t(`comparison.cost`),a:P(c.totalCost),b:d(P(l.totalCost)),delta:ao(c.totalCost,l.totalCost)},{label:t(`comparison.tokens`),a:L(c.totalTokens),b:d(L(l.totalTokens)),delta:ao(c.totalTokens,l.totalTokens)},{label:`$/1M`,a:`$${c.costPerMillion.toFixed(2)}`,b:d(`$${l.costPerMillion.toFixed(2)}`),delta:ao(c.costPerMillion,l.costPerMillion)},{label:t(`comparison.avgPerDay`),a:P(c.avgDailyCost),b:d(P(l.avgDailyCost)),delta:ao(c.avgDailyCost,l.avgDailyCost)},{label:t(`comparison.cacheRate`),a:N(c.cacheHitRate),b:d(N(l.cacheHitRate)),delta:ao(c.cacheHitRate,l.cacheHitRate,!0)},{label:t(`comparison.days`),a:String(c.activeDays),b:d(String(l.activeDays)),delta:ao(c.activeDays,l.activeDays)}];return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(Ei,{info:G.periodComparison,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})}),(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsx)(V,{variant:n===`week`?`default`:`outline`,size:`sm`,onClick:()=>r(`week`),className:`text-xs h-7`,children:t(`comparison.week`)}),(0,W.jsx)(V,{variant:n===`month`?`default`:`outline`,size:`sm`,onClick:()=>r(`month`),className:`text-xs h-7`,children:t(`comparison.month`)})]})]})}),(0,W.jsx)(q,{children:(0,W.jsx)(`div`,{className:`overflow-x-auto`,children:(0,W.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,W.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:t(`comparison.metric`)}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:s}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-center text-xs text-muted-foreground w-8`}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:o}),(0,W.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground`,children:t(`comparison.delta`)})]})}),(0,W.jsx)(`tbody`,{children:f.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-border/50`,children:[(0,W.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.label}),(0,W.jsx)(`td`,{className:`px-2 py-2 text-right font-mono`,children:e.b}),(0,W.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,W.jsx)(kt,{className:`h-3 w-3 text-muted-foreground inline`})}),(0,W.jsx)(`td`,{className:`px-2 py-2 text-right font-mono font-medium`,children:e.a}),(0,W.jsx)(`td`,{className:`px-2 py-2 text-right`,children:e.delta.hasData?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono font-medium text-xs px-1.5 py-0.5 rounded ${e.delta.color} ${e.delta.color===`text-red-400`?`bg-red-400/10`:e.delta.color===`text-green-400`?`bg-green-400/10`:``}`,children:[e.delta.arrow,N(e.delta.value)]}):`–`})]},e.label))})]})})})]})}function so({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:r}=k(),{anomalies:i,mean:a,stdDev:o}=(0,U.useMemo)(()=>{if(e.length<3)return{anomalies:[],mean:0,stdDev:0};let t=e.map(e=>e.totalCost),n=t.reduce((e,t)=>e+t,0)/t.length,r=Math.sqrt(t.reduce((e,t)=>e+(t-n)**2,0)/t.length);return{anomalies:va(e),mean:n,stdDev:r}},[e]);return i.length===0?(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:G.anomalyDetection,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:r(`anomaly.title`,{period:je(n,!0)})})})}),(0,W.jsx)(q,{children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`anomaly.none`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:r(`anomaly.withinStdDev`)})]})})]}):(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{className:`pb-2`,children:(0,W.jsx)(Ei,{info:G.anomalyDetection,children:(0,W.jsxs)(Kr,{className:`text-sm font-medium text-muted-foreground flex items-center gap-2`,children:[(0,W.jsx)(St,{className:`h-4 w-4 text-yellow-500`}),r(`anomaly.title`,{period:je(n,!0)}),` (`,i.length,`)`]})})}),(0,W.jsxs)(q,{children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:r(`anomaly.description`,{period:je(n,!0),mean:P(a),stdDev:P(o)})}),(0,W.jsx)(`div`,{className:`space-y-2`,children:[...i].sort((e,t)=>t.totalCost-e.totalCost).map(e=>{let n=o>0?(e.totalCost-a)/o:0,i=n.toFixed(1),s=e.totalCost>a,c=Math.abs(n)>=3?`critical`:`warn`;return(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded-lg transition-colors cursor-pointer ${c===`critical`?`bg-red-400/10 hover:bg-red-400/20 border border-red-400/20`:`bg-muted/30 hover:bg-muted/50`}`,onClick:()=>t?.(e.date),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-2 h-2 rounded-full ${s?`bg-red-400`:`bg-green-400`} ${c===`critical`?`animate-pulse`:``}`}),(0,W.jsx)(`span`,{className:`text-sm`,children:I(e.date,`long`)}),c===`critical`&&(0,W.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-red-400 bg-red-400/10 px-1.5 py-0.5 rounded`,children:r(`anomaly.critical`)})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsx)(`span`,{className:`text-sm font-mono font-medium ${s?`text-red-400`:`text-green-400`}`,children:P(e.totalCost)}),(0,W.jsxs)(`span`,{className:`text-xs font-mono font-medium px-1.5 py-0.5 rounded ${c===`critical`?`text-red-300 bg-red-400/15`:`text-muted-foreground`}`,children:[s?`+`:``,i,`σ`]})]})]},e.date)})})]})]})}function co({title:e,icon:t,value:n,summary:r,details:i}){return(0,W.jsxs)(K,{className:`overflow-hidden p-5`,children:[(0,W.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-primary/40 to-transparent`}),(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`mt-2 text-3xl font-semibold tracking-tight`,children:n})]}),(0,W.jsx)(`div`,{className:`rounded-2xl border border-border/60 bg-muted/30 p-2.5 text-muted-foreground`,children:t})]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:r}),(0,W.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:i.map(e=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/20 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium text-foreground`,children:e.value})]},e.label))})]})}function lo({metrics:e,viewMode:t,totalCalendarDays:n}){let{t:r}=k(),i=n&&t===`daily`?e.activeDays/n*100:null,a=r(t===`yearly`?`periods.years`:t===`monthly`?`periods.months`:`periods.days`),o=e.topThreeModelsShare>=80?r(`insights.peakWindow.signalStrong`):e.topThreeModelsShare>=55?r(`insights.peakWindow.signalModerate`):r(`insights.peakWindow.signalWide`);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Zi,{title:r(`dashboard.insights.title`),badge:r(`dashboard.insights.badge`),description:r(`dashboard.insights.description`),info:Er.insights}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 gap-4`,children:[(0,W.jsx)(J,{delay:.03,children:(0,W.jsx)(co,{title:r(`insights.concentration.title`),icon:(0,W.jsx)(it,{className:`h-5 w-5`}),value:e.topProvider?N(e.topProvider.share,0):`–`,summary:e.topProvider?r(`insights.concentration.summary`,{provider:e.topProvider.name,model:e.topModel?.name??r(`metricCards.primary.topModel`)}):r(`insights.concentration.fallback`),details:[{label:r(`insights.concentration.topProvider`),value:e.topProvider?.name??`–`},{label:r(`insights.concentration.topModel`),value:e.topModel?.name??`–`},{label:r(`insights.concentration.topModelShare`),value:N(e.topModelShare,0)},{label:r(`insights.concentration.topThreeModels`),value:N(e.topThreeModelsShare,0)}]})}),(0,W.jsx)(J,{delay:.08,children:(0,W.jsx)(co,{title:r(`insights.requestEconomy.title`),icon:(0,W.jsx)(Ct,{className:`h-5 w-5`}),value:e.hasRequestData?(0,W.jsx)(F,{value:e.avgCostPerRequest,type:`currency`,label:r(`insights.requestEconomy.valueLabel`),insight:r(`metricCards.primary.tokensPerRequestAvg`,{value:L(e.avgTokensPerRequest)})}):r(`common.notAvailable`),summary:e.hasRequestData?r(`insights.requestEconomy.summary`,{cost:P(e.avgCostPerRequest),tokens:L(e.avgTokensPerRequest),leader:e.topRequestModel?r(`insights.requestEconomy.leader`,{model:e.topRequestModel.name}):``}).trim():r(`insights.requestEconomy.fallback`),details:[{label:r(`insights.requestEconomy.avgRequests`,{unit:j(t)}),value:e.hasRequestData?e.avgRequestsPerDay.toFixed(1):r(`common.notAvailable`)},{label:r(`insights.requestEconomy.avgTokensPerRequest`),value:e.hasRequestData?L(e.avgTokensPerRequest):r(`common.notAvailable`)},{label:r(`insights.requestEconomy.costPerMillion`),value:P(e.costPerMillion)},{label:r(`insights.requestEconomy.totalRequests`),value:e.hasRequestData?M(e.totalRequests):r(`common.notAvailable`)}]})}),(0,W.jsx)(J,{delay:.13,children:(0,W.jsx)(co,{title:r(`insights.usagePatterns.title`),icon:(0,W.jsx)(Ge,{className:`h-5 w-5`}),value:i===null?M(e.activeDays):N(i,0),summary:i===null?r(`insights.usagePatterns.summaryWithoutCoverage`,{activeDays:e.activeDays,unit:a}):r(`insights.usagePatterns.summaryWithCoverage`,{activeDays:e.activeDays,totalDays:n,volatility:M(Math.round(e.requestVolatility))}),details:[{label:r(`insights.usagePatterns.avgModels`),value:e.avgModelsPerEntry.toFixed(1)},{label:r(`insights.usagePatterns.providersActive`),value:M(e.providerCount)},{label:r(`insights.usagePatterns.weekendShare`),value:e.weekendCostShare===null?`–`:N(e.weekendCostShare,0)},{label:r(`insights.usagePatterns.thinkingShare`),value:e.totalTokens>0?N(e.totalThinking/e.totalTokens*100,1):`–`}]})}),(0,W.jsx)(J,{delay:.18,children:(0,W.jsx)(co,{title:r(`insights.peakWindow.title`),icon:(0,W.jsx)(ht,{className:`h-5 w-5`}),value:e.busiestWeek?P(e.busiestWeek.cost):P(e.topDay?.cost??0),summary:e.busiestWeek?r(`insights.peakWindow.summary`,{start:I(e.busiestWeek.start),end:I(e.busiestWeek.end)}):r(`insights.peakWindow.fallback`),details:[{label:r(`insights.peakWindow.peakDay`),value:e.topDay?`${I(e.topDay.date)} · ${P(e.topDay.cost)}`:`–`},{label:r(`insights.peakWindow.avgPerUnit`,{unit:j(t)}),value:P(e.avgDailyCost)},{label:r(`insights.peakWindow.peak7DayAverage`),value:e.busiestWeek?P(e.busiestWeek.cost/7):`–`},{label:r(`insights.peakWindow.signal`),value:o}]})})]}),(0,W.jsx)(J,{delay:.22,children:(0,W.jsxs)(`div`,{className:`mt-4 rounded-2xl border border-border/60 bg-gradient-to-r from-primary/[0.08] via-transparent to-chart-3/[0.08] px-4 py-3 text-sm text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-foreground font-medium`,children:[(0,W.jsx)(_t,{className:`h-4 w-4 text-primary`}),r(`dashboard.insights.quickRead`)]}),(0,W.jsx)(`span`,{className:`ml-2`,children:e.topProvider?r(`insights.quickRead.summary`,{provider:e.topProvider.name,providerShare:N(e.topProvider.share,0),topThreeShare:N(e.topThreeModelsShare,0),requestLeader:e.topRequestModel?r(`insights.quickRead.requestLeader`,{requestModel:e.topRequestModel.name,tokenModel:e.topTokenModel?.name??r(`metricCards.primary.topModel`)}):``}).trim():r(`insights.quickRead.fallback`)})]})})]})}function uo(e){return e>=.6?{label:`high`,tone:`text-red-400 bg-red-400/10 border-red-400/20`}:e>=.35?{label:`medium`,tone:`text-amber-300 bg-amber-400/10 border-amber-400/20`}:{label:`low`,tone:`text-green-400 bg-green-400/10 border-green-400/20`}}function fo({topModelShare:e,topProviderShare:t,modelConcentrationIndex:n,providerConcentrationIndex:r}){let{t:i}=k(),a=uo(n),o=uo(r);return(0,W.jsxs)(K,{children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:Dr.concentrationRisk,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:i(`risk.title`)})})}),(0,W.jsx)(q,{className:`space-y-4`,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:i(`risk.modelDependency`)}),(0,W.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:N(e,1)})]}),(0,W.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium ${a.tone}`,children:i(`risk.${a.label}`)})]}),(0,W.jsx)(`div`,{className:`mt-3 h-2 rounded-full bg-muted/40 overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${Math.min(e,100)}%`}})}),(0,W.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`risk.modelHint`,{value:n.toFixed(2)})})]}),(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:i(`risk.providerDependency`)}),(0,W.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:N(t,1)})]}),(0,W.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium ${o.tone}`,children:i(`risk.${o.label}`)})]}),(0,W.jsx)(`div`,{className:`mt-3 h-2 rounded-full bg-muted/40 overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-chart-3`,style:{width:`${Math.min(t,100)}%`}})}),(0,W.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`risk.providerHint`,{value:r.toFixed(2)})})]})]})})]})}function po({metrics:e,viewMode:t}){let{t:n}=k(),r=(0,U.useRef)(null),i=w(r,{once:!0,amount:.25}),a=e.totalRequests>0?e.totalCacheRead/e.totalRequests:0,o=e.totalRequests>0?e.totalThinking/e.totalRequests:0,s=e.totalOutput>0?e.totalInput/e.totalOutput:0,c=e.activeDays>0?e.totalRequests/e.activeDays:0,l=[{label:n(`requestQuality.tokensPerRequest`),value:e.hasRequestData?L(e.avgTokensPerRequest):n(`common.notAvailable`),accent:`var(--chart-2)`,hint:n(`requestQuality.tokensHint`),progress:Math.min(e.avgTokensPerRequest/2e5,1)},{label:n(`requestQuality.costPerRequest`),value:e.hasRequestData?P(e.avgCostPerRequest):n(`common.notAvailable`),accent:`var(--chart-4)`,hint:n(`requestQuality.costHint`),progress:Math.min(e.avgCostPerRequest/.25,1)},{label:n(`requestQuality.cachePerRequest`),value:e.hasRequestData?L(a):n(`common.notAvailable`),accent:`var(--chart-1)`,hint:n(`requestQuality.cacheHint`),progress:Math.min(a/2e5,1)},{label:n(`requestQuality.thinkingPerRequest`),value:e.hasRequestData?L(o):n(`common.notAvailable`),accent:`var(--chart-5)`,hint:n(`requestQuality.thinkingHint`),progress:Math.min(o/1e4,1)}];return(0,W.jsxs)(K,{ref:r,className:`overflow-visible`,children:[(0,W.jsx)(Gr,{children:(0,W.jsx)(Ei,{info:Dr.requestQuality,children:(0,W.jsx)(Kr,{className:`text-sm font-medium text-muted-foreground`,children:n(`requestQuality.title`)})})}),(0,W.jsxs)(q,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`grid grid-cols-2 xl:grid-cols-4 gap-3`,children:l.map(e=>(0,W.jsxs)(C.div,{className:`rounded-xl border border-border/50 bg-muted/15 p-3`,initial:{opacity:0,y:12},animate:i?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.05},children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`mt-1 text-lg font-semibold tabular-nums`,children:e.value}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hint}),(0,W.jsx)(`div`,{className:`mt-3 h-1.5 overflow-hidden rounded-full bg-muted/40`,children:(0,W.jsx)(C.div,{className:`h-full rounded-full transition-all duration-500`,style:{backgroundColor:`hsl(${e.accent})`},initial:{width:0},animate:i?{width:`${Math.max(e.progress*100,6)}%`}:{width:0},transition:{duration:.7,delay:.08}})})]},e.label))}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-3`,children:[(0,W.jsxs)(C.div,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-primary/[0.12] via-transparent to-transparent p-4`,initial:{opacity:0,y:12},animate:i?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.1},children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:n(`requestQuality.requestDensity`)}),(0,W.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:M(Math.round(c))}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`requestQuality.averagePerActiveUnit`,{unit:n(t===`yearly`?`periods.year`:t===`monthly`?`periods.month`:`periods.day`)})})]}),(0,W.jsxs)(C.div,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-3/[0.12] via-transparent to-transparent p-4`,initial:{opacity:0,y:12},animate:i?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.14},children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:n(`requestQuality.cacheHitRate`)}),(0,W.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:N(e.cacheHitRate,1)}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`requestQuality.cacheHitHint`)})]}),(0,W.jsxs)(C.div,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-4/[0.12] via-transparent to-transparent p-4`,initial:{opacity:0,y:12},animate:i?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.18},children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:n(`requestQuality.inputOutput`)}),(0,W.jsxs)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:[s.toFixed(2),`:1`]}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`requestQuality.inputOutputHint`)})]}),(0,W.jsxs)(C.div,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-5/[0.12] via-transparent to-transparent p-4`,initial:{opacity:0,y:12},animate:i?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.22},children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:n(`requestQuality.topRequestModel`)}),(0,W.jsx)(`div`,{className:`mt-1 text-lg font-semibold truncate`,children:e.topRequestModel?.name??`–`}),(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.topRequestModel?`${M(e.topRequestModel.requests)} ${n(`common.requests`)}`:n(`requestQuality.noRequestLeader`)})]})]})]})]})}function mo(e){return e.riskStatus===`limit`?A.t(`limits.statuses.limitExceeded`):e.riskStatus===`warning`?A.t(`limits.statuses.budgetTight`):e.riskStatus===`ok`?A.t(`limits.statuses.budgetStable`):A.t(`limits.statuses.noLimit`)}function ho(e){return e.hasSubscription?e.subscriptionStatus===`gain`?A.t(`limits.statuses.subscriptionPaysOff`):A.t(`limits.statuses.belowSubscription`):A.t(`limits.statuses.noSubscription`)}function go(e,t){return e.monthlyLimit>0?A.t(`limits.badge.limit`,{value:e.utilization?.toFixed(0)??`0`}):e.hasSubscription?A.t(`limits.badge.subscription`,{value:Math.min(t,999).toFixed(0)}):A.t(`limits.badge.open`)}function _o(e){let t=Number(Array.isArray(e)?e[0]??0:e??0);return Number.isFinite(t)?t:0}function vo({data:e,providers:t,limits:n,selectedMonth:r}){let{t:o}=k(),c=(0,U.useRef)(null),u=w(c,{once:!0,amount:.2}),{rows:p,focusMonth:m,timelineData:g,atLimitCount:_,nearLimitCount:y,subscriptionTotal:x,subscriptionGainTotal:ee}=(0,U.useMemo)(()=>{let{months:i,monthMap:a,providerTotals:o}=Mi(e),s=ji(e),c=r??s,l=t.map(e=>{let t=n[e],r=c?a.get(c)?.get(e)??0:0,i=o.get(e)??0,s=t?.monthlyLimit??0,l=!!t?.hasSubscription,u=l?t?.subscriptionPrice??0:0,d=s>0?Math.max(r-s,0):0,f=s>0?Math.max(s-r,0):null,p=s>0?r/s*100:null,m=l?r-u:null,h=m===null?0:Math.max(m,0),g=m===null?0:Math.max(-m,0),_=`none`;return s>0&&r>=s?_=`limit`:s>0&&r>=s*.8?_=`warning`:s>0&&(_=`ok`),{provider:e,cost:r,totalCost:i,monthlyLimit:s,subscriptionPrice:u,hasSubscription:l,remaining:f,overrun:d,utilization:p,subscriptionDelta:m,subscriptionGain:h,subscriptionGap:g,riskStatus:_,subscriptionStatus:l?h>0?`gain`:`gap`:`none`}}).sort((e,t)=>e.riskStatus===`limit`&&t.riskStatus!==`limit`?-1:e.riskStatus!==`limit`&&t.riskStatus===`limit`?1:e.subscriptionStatus===`gain`&&t.subscriptionStatus!==`gain`?-1:e.subscriptionStatus!==`gain`&&t.subscriptionStatus===`gain`?1:t.cost-e.cost);return{rows:l,focusMonth:c,timelineData:i.map(e=>{let r=a.get(e)??new Map,i=t.reduce((e,t)=>e+(r.get(t)??0),0),o=t.reduce((e,t)=>{let r=n[t]?.monthlyLimit??0;return e+(r>0?r:0)},0),s=t.reduce((e,t)=>{let r=n[t];return e+(r?.hasSubscription?r.subscriptionPrice:0)},0),c=t.reduce((e,t)=>{let i=n[t]?.monthlyLimit??0,a=r.get(t)??0;return e+(i>0?Math.max(a-i,0):0)},0),l=t.reduce((e,t)=>{let i=n[t],a=r.get(t)??0,o=i?.hasSubscription?i.subscriptionPrice:0;return e+Math.max(a-o,0)},0),u=t.reduce((e,t)=>{let i=n[t],a=r.get(t)??0,o=i?.hasSubscription?i.subscriptionPrice:0;return e+(i?.hasSubscription?Math.max(o-a,0):0)},0);return{month:e,totalCost:i,totalLimit:o>0?o:null,totalSubscriptions:s>0?s:null,totalOverrun:c,totalSubscriptionGain:l,totalSubscriptionGap:u}}),atLimitCount:l.filter(e=>e.riskStatus===`limit`).length,nearLimitCount:l.filter(e=>e.riskStatus===`warning`).length,subscriptionTotal:l.reduce((e,t)=>e+t.subscriptionPrice,0),subscriptionGainTotal:l.reduce((e,t)=>e+t.subscriptionGain,0)}},[e,n,t,r]);return t.length===0?null:(0,W.jsxs)(`div`,{id:`limits`,ref:c,children:[(0,W.jsx)(Zi,{title:o(`limits.sectionTitle`),badge:o(`limits.providersBadge`,{count:t.length}),description:o(`limits.sectionDescription`),info:Er.limits}),_>0&&(0,W.jsx)(C.div,{initial:{opacity:0,y:12},animate:u?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35},className:`mb-4 rounded-2xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-100`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,W.jsx)(St,{className:`h-4 w-4`}),o(`limits.warningBanner`,{count:_})]})}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-4`,children:[{label:o(`limits.cards.atLimit`),value:String(_),hint:m?Re(m):o(`limits.cards.noMonth`),icon:(0,W.jsx)(St,{className:`h-4 w-4`})},{label:o(`limits.cards.nearLimit`),value:String(y),hint:o(`limits.cards.nearLimitHint`),icon:(0,W.jsx)(Dt,{className:`h-4 w-4`})},{label:o(`limits.cards.subscriptionVolume`),value:P(x),hint:o(`limits.cards.subscriptionVolumeHint`),icon:(0,W.jsx)($e,{className:`h-4 w-4`})},{label:o(`limits.cards.subscriptionValue`),value:P(ee),hint:o(`limits.cards.subscriptionValueHint`),icon:(0,W.jsx)(ht,{className:`h-4 w-4`})}].map((e,t)=>(0,W.jsx)(C.div,{initial:{opacity:0,y:12},animate:u?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.04*t},children:(0,W.jsx)(K,{className:`h-full`,children:(0,W.jsx)(q,{className:`p-4`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,W.jsx)(`div`,{className:`mt-1 text-2xl font-semibold tabular-nums`,children:e.value}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hint})]}),(0,W.jsx)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 p-2 text-muted-foreground`,children:e.icon})]})})})},e.label))}),(0,W.jsx)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:p.map((e,t)=>{let n=Ee(e.provider),r=e.monthlyLimit>0?Math.min(e.cost/e.monthlyLimit*100,100):0,i=e.hasSubscription&&e.subscriptionPrice>0?e.cost/e.subscriptionPrice*100:0,a=Math.min(i,100);return(0,W.jsx)(C.div,{initial:{opacity:0,y:12},animate:u?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.05+t*.03},children:(0,W.jsx)(K,{className:e.riskStatus===`limit`?`border-red-500/40 bg-red-500/[0.06]`:e.subscriptionStatus===`gain`?`border-emerald-500/30 bg-emerald-500/[0.05]`:void 0,children:(0,W.jsxs)(q,{className:`p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:mo(e)}),(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground/80`,children:ho(e)})]}),(0,W.jsx)(`div`,{className:`rounded-full border px-2.5 py-1 text-[11px] font-medium`,style:n,children:go(e,i)})]}),(0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:o(`limits.tracks.usageFocusMonth`)}),(0,W.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:P(e.cost)})]}),(0,W.jsxs)(`div`,{className:`text-right`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground`,children:o(`limits.tracks.limitSubscription`)}),(0,W.jsxs)(`div`,{className:`mt-1 text-sm font-medium tabular-nums`,children:[e.monthlyLimit>0?P(e.monthlyLimit):o(`limits.statuses.noLimit`),` `,`/ `,e.hasSubscription?P(e.subscriptionPrice):`–`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:o(`limits.tracks.budgetRisk`)}),(0,W.jsx)(`span`,{children:e.monthlyLimit>0?e.overrun>0?`+${P(e.overrun)}`:P(e.remaining??0):o(`limits.statuses.noLimit`)})]}),(0,W.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.monthlyLimit>0?(0,W.jsx)(C.div,{className:e.riskStatus===`limit`?`h-full bg-red-400`:e.riskStatus===`warning`?`h-full bg-amber-400`:`h-full`,initial:{width:0},animate:u?{width:`${r}%`}:{width:0},transition:{duration:.8,delay:.08+t*.04,ease:`easeOut`},...e.riskStatus===`limit`||e.riskStatus===`warning`?{}:{style:{backgroundColor:n.color}}}):(0,W.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:o(`limits.tracks.subscriptionEffect`)}),(0,W.jsx)(`span`,{className:e.subscriptionStatus===`gain`?`text-emerald-300`:e.subscriptionStatus===`gap`?`text-amber-200`:``,children:e.hasSubscription?e.subscriptionStatus===`gain`?`+${P(e.subscriptionGain)}`:P(e.subscriptionGap):o(`limits.statuses.noSubscription`)})]}),(0,W.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.hasSubscription?(0,W.jsx)(C.div,{className:e.subscriptionStatus===`gain`?`h-full bg-emerald-400`:`h-full bg-amber-300`,initial:{width:0},animate:u?{width:`${Math.max(8,a)}%`}:{width:0},transition:{duration:.8,delay:.12+t*.04,ease:`easeOut`}}):(0,W.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]})]})]})})},e.provider)})}),(0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,W.jsx)(aa,{title:o(`limits.tracks.budgetTitle`),subtitle:o(m?`limits.tracks.budgetSubtitle`:`limits.tracks.budgetNoMonth`),info:G.providerLimitProgress,chartData:p,valueKey:`cost`,valueFormatter:P,children:(0,W.jsx)(`div`,{className:`space-y-3`,children:p.map((e,t)=>{let n=(e.monthlyLimit>0?Math.max(e.monthlyLimit,e.cost,1):Math.max(e.cost,1))*1.15,r=`${e.cost/n*100}%`,i=e.monthlyLimit>0?`${e.monthlyLimit/n*100}%`:`0%`,a=e.monthlyLimit>0?`${Math.min(e.cost,e.monthlyLimit)/n*100}%`:r,s=e.monthlyLimit>0&&e.overrun>0?`${e.overrun/n*100}%`:`0%`;return(0,W.jsxs)(C.div,{initial:{opacity:0,y:10},animate:u?{opacity:1,y:0}:{opacity:0,y:10},transition:{duration:.35,delay:.04+t*.04},className:`rounded-xl border border-border/50 bg-muted/10 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.monthlyLimit<=0?o(`limits.statuses.noLimit`):e.overrun>0?o(`limits.tracks.alreadyAboveLimit`,{value:P(e.overrun)}):o(`limits.tracks.stillToLimit`,{value:P(e.remaining??0)})})]}),(0,W.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,W.jsxs)(`div`,{className:`text-muted-foreground`,children:[o(`limits.tracks.usage`),` `,P(e.cost)]}),(0,W.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[o(`limits.tracks.limit`),` `,e.monthlyLimit>0?P(e.monthlyLimit):`–`]})]})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsxs)(`div`,{className:`relative h-14`,children:[(0,W.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.monthlyLimit>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute left-0 top-5 h-4 rounded-l-full bg-sky-400/12`,style:{width:i}}),(0,W.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-red-400/12`,style:{left:i,width:`calc(100% - ${i})`}}),(0,W.jsx)(C.div,{className:e.riskStatus===`warning`?`absolute left-0 top-5 h-4 rounded-full bg-amber-400`:`absolute left-0 top-5 h-4 rounded-full bg-sky-400`,initial:{width:0},animate:u?{width:a}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),e.overrun>0&&(0,W.jsx)(C.div,{className:`absolute top-5 h-4 rounded-r-full bg-red-400`,style:{left:i},initial:{width:0},animate:u?{width:s}:{width:0},transition:{duration:.75,delay:.14+t*.04,ease:`easeOut`}}),(0,W.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,W.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 rounded-full border border-border/70 bg-background px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,style:{left:i},children:o(`limits.tracks.limit`)})]}):(0,W.jsx)(C.div,{className:`absolute left-0 top-5 h-4 rounded-full bg-muted-foreground/40`,initial:{width:0},animate:u?{width:r}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),(0,W.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,W.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:P(n)})]})}),(0,W.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.currentlyUsed`)}),(0,W.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:P(e.cost)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.remainingToLimit`)}),(0,W.jsx)(`div`,{className:e.monthlyLimit>0&&e.overrun===0?`mt-1 font-medium text-sky-300`:`mt-1 font-medium text-muted-foreground`,children:e.monthlyLimit>0?e.overrun===0?P(e.remaining??0):`$0.00`:`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.alreadyOverLimit`)}),(0,W.jsx)(`div`,{className:e.overrun>0?`mt-1 font-medium text-red-300`:`mt-1 font-medium text-muted-foreground`,children:e.monthlyLimit>0?e.overrun>0?P(e.overrun):`$0.00`:`–`})]})]})]},e.provider)})})}),(0,W.jsx)(aa,{title:o(`limits.tracks.subscriptionTitle`),subtitle:o(m?`limits.tracks.subscriptionSubtitle`:`limits.tracks.subscriptionNoMonth`),info:G.providerSubscriptionMix,chartData:p,valueKey:`cost`,valueFormatter:P,children:(0,W.jsx)(`div`,{className:`space-y-3`,children:p.map((e,t)=>{let n=(e.hasSubscription?Math.max(e.subscriptionPrice,e.cost,1):Math.max(e.cost,1))*1.15,r=`${e.cost/n*100}%`,i=e.hasSubscription?`${e.subscriptionPrice/n*100}%`:`0%`,a=e.hasSubscription?`${Math.min(e.cost,e.subscriptionPrice)/n*100}%`:r,s=e.hasSubscription&&e.subscriptionGain>0?`${e.subscriptionGain/n*100}%`:`0%`;return(0,W.jsxs)(C.div,{initial:{opacity:0,y:10},animate:u?{opacity:1,y:0}:{opacity:0,y:10},transition:{duration:.35,delay:.04+t*.04},className:`rounded-xl border border-border/50 bg-muted/10 p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,W.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hasSubscription?e.subscriptionStatus===`gain`?o(`limits.tracks.alreadyAboveBreakEvenText`,{value:P(e.subscriptionGain)}):o(`limits.tracks.stillToBreakEven`,{value:P(e.subscriptionGap)}):o(`limits.tracks.noSubscriptionSet`)})]}),(0,W.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,W.jsxs)(`div`,{className:`text-muted-foreground`,children:[o(`limits.tracks.usage`),` `,P(e.cost)]}),(0,W.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[o(`limits.tracks.subscription`),` `,e.hasSubscription?P(e.subscriptionPrice):`–`]})]})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsxs)(`div`,{className:`relative h-14`,children:[(0,W.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.hasSubscription?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`absolute left-0 top-5 h-4 rounded-l-full bg-amber-300/18`,style:{width:i}}),(0,W.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400/14`,style:{left:i,width:`calc(100% - ${i})`}}),(0,W.jsx)(C.div,{className:`absolute left-0 top-5 h-4 rounded-full bg-amber-300`,initial:{width:0},animate:u?{width:a}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),e.subscriptionGain>0&&(0,W.jsx)(C.div,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400`,style:{left:i},initial:{width:0},animate:u?{width:s}:{width:0},transition:{duration:.75,delay:.14+t*.04,ease:`easeOut`}}),(0,W.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,W.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 rounded-full border border-border/70 bg-background px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,style:{left:i},children:o(`limits.tracks.breakEven`)})]}):(0,W.jsx)(C.div,{className:`absolute left-0 top-5 h-4 rounded-full bg-muted-foreground/40`,initial:{width:0},animate:u?{width:r}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),(0,W.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,W.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:P(n)})]})}),(0,W.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.currentlyUsed`)}),(0,W.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:P(e.cost)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.remainingToBreakEven`)}),(0,W.jsx)(`div`,{className:e.hasSubscription&&e.subscriptionGap>0?`mt-1 font-medium text-amber-200`:`mt-1 font-medium text-muted-foreground`,children:e.hasSubscription?e.subscriptionGap>0?P(e.subscriptionGap):`$0.00`:`–`})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-muted-foreground`,children:o(`limits.tracks.alreadyAboveBreakEven`)}),(0,W.jsx)(`div`,{className:e.subscriptionGain>0?`mt-1 font-medium text-emerald-300`:`mt-1 font-medium text-muted-foreground`,children:e.hasSubscription?e.subscriptionGain>0?P(e.subscriptionGain):`$0.00`:`–`})]})]})]},e.provider)})})})]}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(aa,{title:o(`limits.tracks.portfolioTitle`),subtitle:o(`limits.tracks.portfolioSubtitle`),info:G.providerLimitTimeline,chartData:g,valueKey:`totalCost`,valueFormatter:P,children:(0,W.jsx)(X,{children:e=>(0,W.jsx)(Z,{variant:`line`,delay:.06,children:(0,W.jsx)(i,{width:`100%`,height:320,children:(0,W.jsxs)(v,{data:g,margin:oa,children:[(0,W.jsxs)(`defs`,{children:[(0,W.jsxs)(`linearGradient`,{id:`limits-risk-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(248 113 113)`,stopOpacity:.28}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(248 113 113)`,stopOpacity:0})]}),(0,W.jsxs)(`linearGradient`,{id:`limits-gain-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(74 222 128)`,stopOpacity:.28}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(74 222 128)`,stopOpacity:0})]})]}),(0,W.jsx)(f,{strokeDasharray:`3 3`,stroke:Q.grid,opacity:.25}),(0,W.jsx)(d,{dataKey:`month`,tickFormatter:Re,stroke:Q.axis,fontSize:11,tickLine:!1}),(0,W.jsx)(a,{tickFormatter:e=>{let t=Le(e);return t===null?``:P(Math.abs(t))},stroke:Q.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,W.jsx)(b,{formatter:(e,t)=>[Oe(Math.abs(_o(e))),t??``],labelFormatter:e=>Re(String(e)),contentStyle:{borderRadius:12,borderColor:`hsl(var(--border))`,background:`color-mix(in srgb, hsl(var(--popover)) 90%, transparent)`}}),(0,W.jsx)(S,{}),(0,W.jsx)(l,{y:0,stroke:`hsl(var(--border))`,strokeDasharray:`4 4`}),(0,W.jsx)(s,{type:`monotone`,dataKey:`totalSubscriptionGain`,name:o(`limits.cards.subscriptionValue`),stroke:`rgb(74 222 128)`,fill:`url(#limits-gain-area)`,strokeWidth:2,isAnimationActive:e,animationBegin:0,animationDuration:$.duration}),(0,W.jsx)(s,{type:`monotone`,dataKey:`totalOverrun`,name:o(`limits.tracks.alreadyOverLimit`),stroke:`rgb(248 113 113)`,fill:`url(#limits-risk-area)`,strokeWidth:2,isAnimationActive:e,animationBegin:$.stagger*1.2,animationDuration:$.duration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalCost`,name:`${o(`limits.tracks.usage`)} ${o(`common.costs`).toLowerCase()}`,stroke:Q.cost,strokeWidth:2,dot:!1,isAnimationActive:e,animationBegin:$.stagger*1.6,animationDuration:$.slowDuration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalLimit`,name:o(`limits.tracks.limits`),stroke:`rgb(251 146 60)`,strokeDasharray:`6 3`,strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:$.stagger*2,animationDuration:$.slowDuration}),(0,W.jsx)(h,{type:`monotone`,dataKey:`totalSubscriptions`,name:o(`limits.tracks.subscriptions`),stroke:`rgb(125 211 252)`,strokeDasharray:`3 3`,strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:$.stagger*2.3,animationDuration:$.slowDuration})]})})})})})})]})}function yo({children:e,title:t,className:n,expandedClassName:r,stats:i}){let{t:a}=k(),[o,s]=(0,U.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:O(`group relative`,n),children:[e,(0,W.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`absolute top-3 right-3 z-10 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 transition-opacity duration-200 p-1.5 rounded-lg bg-background/80 backdrop-blur-sm border border-border/50 hover:bg-accent text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,title:a(`common.expand`),"aria-label":t?a(`common.expandWithTitle`,{title:t}):a(`common.expand`),children:(0,W.jsx)(gt,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(pe,{open:o,onOpenChange:s,children:(0,W.jsxs)(de,{className:O(`max-w-[96vw] w-[96vw] sm:max-w-[95vw] sm:w-[95vw] max-h-[92vh] h-[92vh] sm:max-h-[90vh] sm:h-[90vh] overflow-auto p-4 sm:p-6`,r),children:[(0,W.jsx)(D,{className:`sr-only`,children:t??a(`common.expand`)}),(0,W.jsx)(fe,{className:`sr-only`,children:a(`common.expandedCardDescription`)}),(0,W.jsxs)(`div`,{className:`h-full`,children:[i&&i.length>0&&(0,W.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4`,children:i.map(e=>(0,W.jsxs)(`div`,{className:`p-2.5 rounded-lg bg-muted/20 text-center`,children:[(0,W.jsx)(`div`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider`,children:e.label}),(0,W.jsx)(`div`,{className:`font-mono font-medium text-sm mt-0.5`,children:e.value})]},e.label))}),e]})]})})]})}function bo({sectionOrder:e,sectionVisibility:t,metrics:n,viewMode:r,totalCalendarDays:i,filteredData:a,filteredDailyData:o,todayData:s,hasCurrentMonthData:c,visibleLimitProviders:l,providerLimits:u,selectedMonth:d,allModels:f,costChartData:p,modelPieData:m,modelCostChartData:h,weekdayData:g,tokenChartData:_,tokenPieData:v,requestChartData:y,comparisonData:b,modelCosts:x,providerMetrics:S,onDrillDownDateChange:ee}){let{t:C}=k(),te=e=>{switch(e){case`insights`:return t.insights?(0,W.jsx)(`div`,{id:`insights`,children:(0,W.jsx)(lo,{metrics:n,viewMode:r,totalCalendarDays:i})}):null;case`metrics`:return t.metrics?(0,W.jsxs)(`div`,{id:`metrics`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.metrics.title`),badge:C(`dashboard.metrics.badge`),description:C(`dashboard.metrics.description`),info:Er.metrics}),(0,W.jsx)(J,{delay:0,children:(0,W.jsx)(Yi,{metrics:n,totalCalendarDays:i,viewMode:r})}),(0,W.jsx)(J,{delay:.1,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(Xi,{metrics:n,dailyCosts:a.map(e=>e.totalCost),viewMode:r})})})]}):null;case`today`:return t.today&&s?(0,W.jsx)(`div`,{id:`today`,children:(0,W.jsx)(Qi,{today:s,metrics:n})}):null;case`currentMonth`:return t.currentMonth&&c?(0,W.jsx)(`div`,{id:`current-month`,children:(0,W.jsx)($i,{daily:o,metrics:n})}):null;case`activity`:return t.activity?(0,W.jsxs)(`div`,{id:`activity`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.activity.title`),description:C(r===`daily`?`dashboard.activity.dailyDescription`:r===`monthly`?`dashboard.activity.monthlyDescription`:`dashboard.activity.yearlyDescription`),info:Er.activity}),(0,W.jsx)(J,{delay:.2,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-3`,children:[(0,W.jsx)(no,{data:a,viewMode:r,metric:`cost`}),(0,W.jsx)(no,{data:a,viewMode:r,metric:`requests`}),(0,W.jsx)(no,{data:a,viewMode:r,metric:`tokens`})]})})]}):null;case`forecastCache`:return t.forecastCache?(0,W.jsxs)(`div`,{id:`forecast-cache`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.forecastCache.title`),description:C(`dashboard.forecastCache.description`),info:Er.forecastCache}),(0,W.jsx)(J,{delay:.25,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(yo,{title:C(`dashboard.cards.costForecast`),children:(0,W.jsx)(ro,{data:a,viewMode:r})}),(0,W.jsx)(yo,{title:C(`dashboard.cards.cacheRoi`),stats:[{label:C(`dashboard.stats.cacheHitRate`),value:N(n.cacheHitRate)},{label:C(`dashboard.stats.totalTokens`),value:L(n.totalTokens)},{label:C(`dashboard.stats.cacheRead`),value:L(n.totalCacheRead)}],children:(0,W.jsx)(io,{data:a,viewMode:r})})]})})]}):null;case`limits`:return t.limits?(0,W.jsx)(`div`,{id:`limits`,children:(0,W.jsx)(J,{delay:.27,children:(0,W.jsx)(vo,{data:o,providers:l,limits:u,selectedMonth:d})})}):null;case`costAnalysis`:return t.costAnalysis?(0,W.jsxs)(`div`,{id:`charts`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.costAnalysis.title`),badge:`${f.length} ${C(`common.models`)}`,description:C(`dashboard.costAnalysis.description`),info:Er.costAnalysis}),(0,W.jsx)(J,{delay:.3,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,W.jsx)(`div`,{className:`lg:col-span-2`,children:(0,W.jsx)(sa,{data:p,onClickDay:ee})}),(0,W.jsx)(la,{data:m})]})}),(0,W.jsx)(J,{delay:.35,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(ua,{data:h,models:f})})}),(0,W.jsx)(J,{delay:.4,children:(0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(Ta,{data:p,rawData:a}),(0,W.jsx)(Ia,{data:g})]})}),(0,W.jsx)(J,{delay:.42,children:(0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(La,{data:a}),(0,W.jsx)(za,{data:a})]})})]}):null;case`tokenAnalysis`:return t.tokenAnalysis?(0,W.jsxs)(`div`,{id:`token-analysis`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.tokenAnalysis.title`),description:C(`dashboard.tokenAnalysis.description`),info:Er.tokenAnalysis}),(0,W.jsx)(J,{delay:.45,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,W.jsx)(Ea,{data:_,onClickDay:ee}),(0,W.jsx)(Fa,{data:v})]})})]}):null;case`requestAnalysis`:return t.requestAnalysis&&n.hasRequestData?(0,W.jsxs)(`div`,{id:`request-analysis`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.requestAnalysis.title`),description:C(`dashboard.requestAnalysis.description`),info:Er.requestAnalysis}),(0,W.jsx)(J,{delay:.47,children:(0,W.jsx)(ka,{data:y,viewMode:r,onClickDay:ee})}),(0,W.jsx)(J,{delay:.49,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(Ma,{timelineData:a,summaryData:o,viewMode:r})})}),(0,W.jsx)(J,{delay:.51,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(po,{metrics:n,viewMode:r})})})]}):null;case`advancedAnalysis`:return t.advancedAnalysis?(0,W.jsxs)(`div`,{id:`advanced-analysis`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.advancedAnalysis.title`),description:C(`dashboard.advancedAnalysis.description`),info:Er.advancedAnalysis}),(0,W.jsx)(J,{delay:.48,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,W.jsx)(Ha,{data:a,viewMode:r}),(0,W.jsx)(fo,{topModelShare:n.topModelShare,topProviderShare:n.topProvider?.share??0,modelConcentrationIndex:n.modelConcentrationIndex,providerConcentrationIndex:n.providerConcentrationIndex})]})}),(0,W.jsx)(J,{delay:.5,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(qa,{data:a})})})]}):null;case`comparisons`:return t.comparisons?(0,W.jsxs)(`div`,{id:`comparisons`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.comparisons.title`),description:C(`dashboard.comparisons.description`),info:Er.comparisons}),(0,W.jsx)(J,{delay:.5,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,W.jsx)(yo,{title:C(`dashboard.cards.periodComparison`),stats:[{label:C(`dashboard.stats.dataPoints`),value:String(a.length)},{label:C(`dashboard.stats.avgCostPerUnit`,{unit:j(r)}),value:P(n.avgDailyCost)}],children:(0,W.jsx)(oo,{data:b})}),(0,W.jsx)(yo,{title:C(`dashboard.cards.anomalyDetection`),stats:[{label:C(`dashboard.stats.total`),value:P(n.totalCost)},{label:C(`dashboard.stats.avgPerUnit`,{unit:j(r)}),value:P(n.avgDailyCost)}],children:(0,W.jsx)(so,{data:a,onClickDay:ee,viewMode:r})})]})})]}):null;case`tables`:return t.tables?(0,W.jsxs)(`div`,{id:`tables`,children:[(0,W.jsx)(Zi,{title:C(`dashboard.tables.title`),description:C(`dashboard.tables.description`),info:Er.tables}),(0,W.jsx)(J,{delay:.55,children:(0,W.jsx)(Ja,{modelCosts:x,totalCost:n.totalCost,viewMode:r})}),(0,W.jsx)(J,{delay:.6,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(Ya,{providerMetrics:S,totalCost:n.totalCost,viewMode:r})})}),(0,W.jsx)(J,{delay:.65,children:(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(Xa,{data:a,onClickDay:ee,viewMode:r})})})]}):null;default:return null}};return(0,W.jsx)(W.Fragment,{children:e.map(e=>(0,W.jsx)(U.Fragment,{children:te(e)},e))})}function xo({className:e,...t}){return(0,W.jsx)(`div`,{className:O(`animate-pulse rounded-lg bg-muted/60`,e),...t})}function So(){return(0,W.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/80 backdrop-blur-xl p-4 flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(xo,{className:`h-3 w-20`}),(0,W.jsx)(xo,{className:`h-4 w-4 rounded`})]}),(0,W.jsx)(xo,{className:`h-8 w-28`}),(0,W.jsx)(xo,{className:`h-3 w-24`})]})}function Co({className:e}){return(0,W.jsxs)(`div`,{className:O(`rounded-xl border border-border/50 bg-card/80 backdrop-blur-xl`,e),children:[(0,W.jsx)(`div`,{className:`p-4 pb-2`,children:(0,W.jsx)(xo,{className:`h-4 w-32`})}),(0,W.jsx)(`div`,{className:`p-4 pt-0`,children:(0,W.jsx)(xo,{className:`h-[300px] w-full rounded-lg`})})]})}function wo(){return(0,W.jsxs)(`div`,{className:`min-h-screen max-w-7xl mx-auto px-4 pb-8`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between py-4 px-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(xo,{className:`h-8 w-32`}),(0,W.jsx)(xo,{className:`h-4 w-16`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(xo,{className:`h-8 w-20 rounded-lg`}),(0,W.jsx)(xo,{className:`h-8 w-20 rounded-lg`}),(0,W.jsx)(xo,{className:`h-8 w-8 rounded-lg`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 py-2 px-1`,children:[(0,W.jsx)(xo,{className:`h-9 w-[160px] rounded-lg`}),(0,W.jsx)(xo,{className:`h-9 w-[180px] rounded-lg`}),(0,W.jsx)(`div`,{className:`flex gap-1.5`,children:[1,2,3].map(e=>(0,W.jsx)(xo,{className:`h-7 w-20 rounded-full`},e))})]}),(0,W.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,W.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-3`,children:[1,2,3,4,5,6].map(e=>(0,W.jsx)(So,{},e))}),(0,W.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[1,2,3,4].map(e=>(0,W.jsx)(So,{},e))}),(0,W.jsx)(Co,{className:`h-[200px]`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,W.jsx)(Co,{}),(0,W.jsx)(Co,{})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,W.jsx)(Co,{className:`lg:col-span-2`}),(0,W.jsx)(Co,{})]})]})]})}async function To(e){return await e.json()}async function Eo(e,t){try{let n=await To(e);return typeof n.message==`string`&&n.message.trim()?n.message:t}catch{return t}}async function Do(){let e=await fetch(`/api/usage`);if(!e.ok)throw Error(await Eo(e,A.t(`api.fetchUsageFailed`)));return To(e)}async function Oo(e){let t=await fetch(`/api/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Eo(t,A.t(`api.uploadFailed`)));return To(t)}async function ko(){if(!(await fetch(`/api/usage`,{method:`DELETE`})).ok)throw Error(A.t(`api.deleteFailed`))}async function Ao(e){let t=await fetch(`/api/usage/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Eo(t,A.t(`api.importUsageFailed`)));return To(t)}async function jo(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(await Eo(e,A.t(`api.fetchSettingsFailed`)));return zi(await To(e))}async function Mo(){try{let e=await fetch(`/api/settings`);return e.ok?{settings:zi(await To(e)),errorMessage:null}:{settings:Ni,errorMessage:await Eo(e,A.t(`api.fetchSettingsFailed`))}}catch{return{settings:Ni,errorMessage:null}}}async function No(e){let t=await fetch(`/api/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Eo(t,A.t(`api.saveSettingsFailed`)));return zi(await To(t))}async function Po(){let e=await fetch(`/api/settings`,{method:`DELETE`});if(!e.ok)throw Error(await Eo(e,A.t(`api.deleteSettingsFailed`)));return zi((await To(e)).settings)}async function Fo(e){let t=await fetch(`/api/settings/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Eo(t,A.t(`api.importSettingsFailed`)));return zi(await To(t))}async function Io(e){let t=await fetch(`/api/report/pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Eo(t,A.t(`api.pdfFailed`)));return t.blob()}function Lo(){return hr({queryKey:[`usage`],queryFn:Do,staleTime:1e3*60*5})}function Ro(){let e=er();return gr({mutationFn:e=>Oo(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`usage`]})}})}function zo(){let e=er();return gr({mutationFn:ko,onSuccess:()=>{e.invalidateQueries({queryKey:[`usage`]})}})}function Bo(e,t){return zi({...e,...t,providerLimits:t.providerLimits??e.providerLimits})}function Vo(e){let t=er(),n=hr({queryKey:[`settings`],queryFn:jo,staleTime:1e3*60*5}),r=gr({mutationFn:e=>No(e),onMutate:async e=>{await t.cancelQueries({queryKey:[`settings`]});let n=t.getQueryData([`settings`])??Ni;return t.setQueryData([`settings`],Bo(n,e)),{previous:n}},onError:(e,n,r)=>{r?.previous&&t.setQueryData([`settings`],r.previous)},onSuccess:e=>{t.setQueryData([`settings`],e)}}),i=n.data??Ni;return{settings:i,providerLimits:(0,U.useMemo)(()=>Ai(e,i.providerLimits),[e,i.providerLimits]),setTheme:(0,U.useCallback)(e=>r.mutateAsync({theme:e}),[r]),setLanguage:(0,U.useCallback)(e=>r.mutateAsync({language:e}),[r]),setProviderLimits:(0,U.useCallback)(e=>r.mutateAsync({providerLimits:e}),[r]),setDefaultFilters:(0,U.useCallback)(e=>r.mutateAsync({defaultFilters:e}),[r]),setSectionVisibility:(0,U.useCallback)(e=>r.mutateAsync({sectionVisibility:e}),[r]),setSectionOrder:(0,U.useCallback)(e=>r.mutateAsync({sectionOrder:e}),[r]),saveSettings:(0,U.useCallback)(e=>r.mutateAsync(e),[r]),isLoading:n.isLoading,isSaving:r.isPending,error:n.error,isError:n.isError,hasFetchedAfterMount:n.isFetchedAfterMount}}function Ho(e,t,n){return(0,da.filterByDateRange)(e,t,n)}function Uo(e,t){return(0,da.filterByModels)(e,t)}function Wo(e,t){return(0,da.filterByProviders)(e,t)}function Go(e,t){return(0,da.filterByMonth)(e,t)}function Ko(e){return(0,da.sortByDate)(e)}function qo(e){let t=new Set;for(let n of e)t.add(n.date.slice(0,7));return Array.from(t).sort()}function Jo(e){if(e.length===0)return null;let t=null;for(let n of e)if(n){t=n;break}if(!t)return null;let n=t.date,r=t.date;for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=i.date;a<n&&(n=a),a>r&&(r=a)}return{start:n,end:r}}function Yo(e){let t=Ko(e),n=pa(t.map(e=>e.totalCost)),r=0;return t.map((e,i)=>{r+=e.totalCost;let a={date:e.date,cost:e.totalCost,cumulative:r},o=(i>0?t[i-1]:void 0)?.totalCost??null;return o!==null&&(a.costPrev=o),n[i]!==void 0&&(a.ma7=n[i]),a})}function Xo(e){let t=Ko(e),n=new Set;for(let e of t)for(let t of e.modelBreakdowns)n.add(De(t.modelName));let r=Array.from(n).sort(),i={};for(let e of r)i[e]=[];for(let e of t){let t={};for(let n of e.modelBreakdowns){let e=De(n.modelName);t[e]=(t[e]??0)+n.cost}for(let e of r){let n=i[e];n&&n.push(t[e]??0)}}let a={};for(let e of r)a[e]=pa(i[e]??[]);return t.map((e,t)=>{let n={date:e.date,cost:e.totalCost};for(let t of e.modelBreakdowns){let e=De(t.modelName);n[e]=(n[e]??0)+t.cost}for(let e of r)e in n||(n[e]=0),n[`${e}_ma7`]=a[e]?.[t];return n})}function Zo(e){let t=Ko(e),n=t.map(e=>e.totalTokens),r=t.map(e=>e.inputTokens),i=t.map(e=>e.outputTokens),a=t.map(e=>e.cacheCreationTokens),o=t.map(e=>e.cacheReadTokens),s=t.map(e=>e.thinkingTokens),c=pa(n),l=pa(r),u=pa(i),d=pa(a),f=pa(o),p=pa(s);return t.map((e,n)=>{let r={date:e.date,Input:e.inputTokens,Output:e.outputTokens,"Cache Write":e.cacheCreationTokens,"Cache Read":e.cacheReadTokens,Thinking:e.thinkingTokens,totalTokens:e.totalTokens},i=(n>0?t[n-1]:void 0)?.totalTokens??null;return i!==null&&(r.totalTokensPrev=i),c[n]!==void 0&&(r.tokenMA7=c[n]),l[n]!==void 0&&(r.inputMA7=l[n]),u[n]!==void 0&&(r.outputMA7=u[n]),d[n]!==void 0&&(r.cacheWriteMA7=d[n]),f[n]!==void 0&&(r.cacheReadMA7=f[n]),p[n]!==void 0&&(r.thinkingMA7=p[n]),r})}function Qo(e){let t=Ko(e),n=pa(t.map(e=>e.requestCount)),r=new Set;for(let e of t)for(let t of e.modelBreakdowns)r.add(De(t.modelName));let i=Array.from(r).sort(),a={};for(let e of i)a[e]=[];for(let e of t){let t={};for(let n of e.modelBreakdowns){let e=De(n.modelName);t[e]=(t[e]??0)+n.requestCount}for(let e of i){let n=a[e];n&&n.push(t[e]??0)}}let o={};for(let e of i)o[e]=pa(a[e]??[]);return t.map((e,r)=>{let a={date:e.date,totalRequests:e.requestCount},s=(r>0?t[r-1]:void 0)?.requestCount??null;s!==null&&(a.totalRequestsPrev=s),n[r]!==void 0&&(a.totalRequestsMA7=n[r]);for(let t of e.modelBreakdowns){let e=De(t.modelName);a[e]=(a[e]??0)+t.requestCount}for(let e of i)e in a||(a[e]=0),a[`${e}_ma7`]=o[e]?.[r];return a})}function $o(e){let t={0:[],1:[],2:[],3:[],4:[],5:[],6:[]},n=new Intl.DateTimeFormat(Pe(),{weekday:`short`,timeZone:`UTC`}),r=Array.from({length:7},(e,t)=>n.format(new Date(Date.UTC(2024,0,1+t))).replace(`.`,``).slice(0,2));for(let n of e){if(n.date.length!==10)continue;let e=t[(new Date(n.date+`T00:00:00`).getDay()+6)%7];e&&e.push(n.totalCost)}return r.map((e,n)=>{let r=t[n]??[];return{day:e,cost:r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0}})}function es(e,t){return(0,da.aggregateToDailyFormat)(e,t)}function ts(e){let t=new Date;t.setHours(0,0,0,0);let n=ze;switch(e){case`7d`:{let e=new Date(t);return e.setDate(t.getDate()-6),{startDate:n(e),endDate:n(t)}}case`30d`:{let e=new Date(t);return e.setDate(t.getDate()-29),{startDate:n(e),endDate:n(t)}}case`month`:return{startDate:n(new Date(t.getFullYear(),t.getMonth(),1)),endDate:n(t)};case`year`:return{startDate:n(new Date(t.getFullYear(),0,1)),endDate:n(t)};default:return{startDate:void 0,endDate:void 0}}}function ns(e,t){let n=new Set(Be(e.map(e=>e.modelsUsed))),r=new Set(he(e.map(e=>e.modelsUsed)));return{viewMode:t.viewMode,datePreset:t.datePreset,providers:t.providers.filter(e=>n.has(e)),models:t.models.filter(e=>r.has(e))}}function rs(e,t=li){let n=(0,U.useMemo)(()=>ns(e,t),[e,t]),r=(0,U.useMemo)(()=>ts(n.datePreset),[n.datePreset]),i=(0,U.useMemo)(()=>JSON.stringify(n),[n]),[a,o]=(0,U.useState)(n.viewMode),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(n.providers),[d,f]=(0,U.useState)(n.models),[p,m]=(0,U.useState)(r.startDate),[h,g]=(0,U.useState)(r.endDate),_=(0,U.useRef)(!1),v=(0,U.useRef)(i),y=(0,U.useCallback)((n=t)=>{let r=ns(e,n),i=ts(r.datePreset);_.current=!1,v.current=JSON.stringify(r),o(r.viewMode),c(null),u(r.providers),f(r.models),m(i.startDate),g(i.endDate)},[e,t]);(0,U.useEffect)(()=>{v.current===i||_.current||(v.current=i,o(n.viewMode),c(null),u(n.providers),f(n.models),m(r.startDate),g(r.endDate))},[i,n,r]);let b=(0,U.useCallback)(e=>{_.current=!0,o(e)},[]),x=(0,U.useCallback)(e=>{_.current=!0,c(e)},[]),S=(0,U.useCallback)(e=>{_.current=!0,m(e)},[]),ee=(0,U.useCallback)(e=>{_.current=!0,g(e)},[]),C=(0,U.useCallback)(e=>{_.current=!0,u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),f([])},[]),te=(0,U.useCallback)(()=>{_.current=!0,u([]),f([])},[]),w=(0,U.useCallback)(e=>{_.current=!0,f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ne=(0,U.useCallback)(()=>{_.current=!0,f([])},[]),re=(0,U.useCallback)(()=>{y()},[y]),T=(0,U.useCallback)(e=>{_.current=!0,c(null);let t=ts(e);m(t.startDate),g(t.endDate)},[]),ie=(0,U.useMemo)(()=>{let t=Ko(e);return t=Ho(t,p,h),t=Go(t,s),t},[e,p,h,s]),ae=(0,U.useMemo)(()=>{let e=ie;return e=Wo(e,l),e},[ie,l]),oe=(0,U.useMemo)(()=>{let e=ae;return e=Uo(e,d),e},[ae,d]);return{viewMode:a,setViewMode:b,selectedMonth:s,setSelectedMonth:x,selectedProviders:l,toggleProvider:C,clearProviders:te,selectedModels:d,toggleModel:w,clearModels:ne,startDate:p,setStartDate:S,endDate:h,setEndDate:ee,resetAll:re,applyDefaultFilters:y,applyPreset:T,filteredDailyData:oe,filteredData:(0,U.useMemo)(()=>{let e=oe;return e=es(e,a),e},[oe,a]),availableMonths:(0,U.useMemo)(()=>qo(e),[e]),availableProviders:(0,U.useMemo)(()=>Be(ie.map(e=>e.modelsUsed)),[ie]),availableModels:(0,U.useMemo)(()=>he(ae.map(e=>e.modelsUsed)),[ae]),dateRange:(0,U.useMemo)(()=>Jo(oe),[oe])}}function is(e){let t=(0,U.useMemo)(()=>fa(e),[e]),n=(0,U.useMemo)(()=>ma(e),[e]);return{metrics:t,modelCosts:n,providerMetrics:(0,U.useMemo)(()=>ha(e),[e]),costChartData:(0,U.useMemo)(()=>Yo(e),[e]),modelCostChartData:(0,U.useMemo)(()=>Xo(e),[e]),tokenChartData:(0,U.useMemo)(()=>Zo(e),[e]),requestChartData:(0,U.useMemo)(()=>Qo(e),[e]),weekdayData:(0,U.useMemo)(()=>$o(e),[e]),allModels:(0,U.useMemo)(()=>he(e.map(e=>e.modelsUsed)),[e]),modelPieData:(0,U.useMemo)(()=>Array.from(n.entries()).map(([e,t])=>({name:e,value:t.cost})).sort((e,t)=>t.value-e.value),[n]),tokenPieData:(0,U.useMemo)(()=>[{name:`Input`,value:t.totalInput},{name:`Output`,value:t.totalOutput},{name:`Cache Write`,value:t.totalCacheCreate},{name:`Cache Read`,value:t.totalCacheRead},{name:`Thinking`,value:t.totalThinking}],[t])}}function as(e){return[ta([`date`,`totalCost`,`totalTokens`,`inputTokens`,`outputTokens`,`cacheCreationTokens`,`cacheReadTokens`,`thinkingTokens`,`requestCount`,`models`]),...e.map(e=>{let t=e.modelBreakdowns.map(e=>De(e.modelName)).filter((e,t,n)=>n.indexOf(e)===t).join(`; `);return ta([e.date,e.totalCost.toFixed(2),e.totalTokens,e.inputTokens,e.outputTokens,e.cacheCreationTokens,e.cacheReadTokens,e.thinkingTokens,e.requestCount,t])})].join(`
4
+ `)}function os(e){let t=as(e),n=new Blob([t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`ttdash-export-${Me()}.csv`,i.click(),URL.revokeObjectURL(r)}var ss=`ttdash-settings-backup`,cs=`ttdash-usage-backup`,ls=1,us=`Settings file is unreadable or corrupted.`,ds=`Usage data file is unreadable or corrupted.`;function fs(e){return e instanceof Error&&e.message.trim()?e.message:null}function ps(e,t){return e===us||e===ds?t:e}function ms(e,t){let n=JSON.stringify(t,null,2),r=new Blob([n],{type:`application/json`});window.__TTDASH_TEST_HOOKS__?.onJsonDownload?.({filename:e,mimeType:r.type,size:r.size,text:n});let i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}function hs(e=null){let{t,i18n:n}=k(),{data:r,isLoading:i,error:a}=Lo(),o=Ro(),s=zo(),c=er(),{addToast:l}=br(),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(!1),[ee,C]=(0,U.useState)(!1),[te,w]=(0,U.useState)(!1),[ne,re]=(0,U.useState)(null),[T,ie]=(0,U.useState)(0),[ae,oe]=(0,U.useState)(e),se=(0,U.useMemo)(()=>r?.daily??[],[r]),ce=se.length>0,E=(0,U.useMemo)(()=>Be(se.map(e=>e.modelsUsed)),[se]),le=(0,U.useMemo)(()=>he(se.map(e=>e.modelsUsed)),[se]),{settings:D,providerLimits:O,setTheme:ue,setLanguage:de,saveSettings:fe,isSaving:pe,isLoading:A,error:me,hasFetchedAfterMount:ge}=Vo(E),_e=D.theme===`dark`;(0,U.useEffect)(()=>{ae&&ge&&!me&&oe(null)},[ae,ge,me]),(0,U.useEffect)(()=>{Bi(D.theme)},[D.theme]),(0,U.useEffect)(()=>{n.resolvedLanguage!==D.language&&n.changeLanguage(D.language)},[n,D.language]),(0,U.useEffect)(()=>{let e=window;if(e.__TTDASH_TEST_HOOKS__)return e.__TTDASH_TEST_HOOKS__.openSettings=()=>{b(!0)},()=>{e.__TTDASH_TEST_HOOKS__?.openSettings&&delete e.__TTDASH_TEST_HOOKS__.openSettings}},[]);let ve=(0,U.useMemo)(()=>D.lastLoadedAt?Ae(D.lastLoadedAt):void 0,[D.lastLoadedAt]),be=(0,U.useMemo)(()=>D.lastLoadedAt?t(`header.loadedAt`,{time:Fe(D.lastLoadedAt)}):void 0,[D.lastLoadedAt,t]),xe=(0,U.useMemo)(()=>ce?{type:`stored`,...ve?{time:ve}:{},...be?{title:be}:{}}:null,[ce,ve,be]),Se=ne??xe,Ce=(0,U.useMemo)(()=>D.cliAutoLoadActive?{active:!0,...ve?{time:ve}:{},title:D.lastLoadedAt?t(`header.autoLoadAt`,{time:Fe(D.lastLoadedAt)}):t(`header.autoLoadActive`)}:null,[D.cliAutoLoadActive,D.lastLoadedAt,ve,t]),{viewMode:we,setViewMode:Te,selectedMonth:Ee,setSelectedMonth:De,selectedProviders:j,toggleProvider:Oe,clearProviders:ke,selectedModels:M,toggleModel:N,clearModels:je,startDate:P,setStartDate:Ne,endDate:Ie,setEndDate:F,resetAll:I,applyDefaultFilters:L,applyPreset:Le,filteredDailyData:R,filteredData:z,availableMonths:Re,availableProviders:Ve,availableModels:B,dateRange:He}=rs(se,D.defaultFilters),{metrics:Ue,modelCosts:We,providerMetrics:Ge,costChartData:Ke,modelCostChartData:qe,tokenChartData:Je,requestChartData:Ye,weekdayData:Xe,allModels:Ze,modelPieData:Qe,tokenPieData:$e}=is(z),et=R,tt=(0,U.useMemo)(()=>{if(!He||we!==`daily`)return 0;let e=new Date(He.start+`T00:00:00`),t=new Date(He.end+`T00:00:00`);return Math.round((t.getTime()-e.getTime())/(1e3*60*60*24))+1},[He,we]),nt=Me(),rt=(0,U.useMemo)(()=>R.find(e=>e.date===nt)??null,[R,nt]),it=(0,U.useMemo)(()=>R.some(e=>e.date.startsWith(nt.slice(0,7))),[R,nt]),at=(0,U.useMemo)(()=>j.length>0?j:E,[j,E]),ot=(0,U.useMemo)(()=>[...new Set([...E,...D.defaultFilters.providers])].sort((e,t)=>e.localeCompare(t)),[E,D.defaultFilters.providers]),st=(0,U.useMemo)(()=>[...new Set([...le,...D.defaultFilters.models])].sort((e,t)=>e.localeCompare(t)),[le,D.defaultFilters.models]),ct=D.sectionVisibility,lt=D.sectionOrder,ut=(0,U.useMemo)(()=>{let e=new Set(R.map(e=>e.date)),t=0,n=new Date(nt+`T00:00:00`);for(;e.has(ze(n));)t+=1,n.setDate(n.getDate()-1);return t},[R,nt]),dt=(0,U.useMemo)(()=>p?z.find(e=>e.date===p)??null:null,[p,z]),ft=(0,U.useCallback)(()=>{u.current?.click()},[]),pt=(0,U.useCallback)(()=>{b(!0)},[]),mt=(0,U.useCallback)(async()=>{await Promise.all([c.invalidateQueries({queryKey:[`settings`]}),c.invalidateQueries({queryKey:[`usage`]})])},[c]),ht=(0,U.useCallback)(async()=>{try{let e=await Po();c.setQueryData([`settings`],e),oe(null),await c.invalidateQueries({queryKey:[`settings`]}),l(t(`toasts.settingsReset`),`success`)}catch(e){l(e instanceof Error?e.message:t(`api.deleteSettingsFailed`),`error`)}},[c,l,t]),gt=(0,U.useCallback)(()=>{ue(_e?`light`:`dark`)},[_e,ue]),_t=(0,U.useCallback)(async e=>{L((await fe(e)).defaultFilters),l(t(`toasts.settingsSaved`),`success`)},[fe,L,l,t]),vt=(0,U.useCallback)(e=>{D.language!==e&&de(e),n.resolvedLanguage!==e&&n.changeLanguage(e)},[n,de,D.language]),yt=(0,U.useCallback)(async e=>{let n=e.target.files?.[0];if(n){try{let e=JSON.parse(await n.text());try{await o.mutateAsync(e)}catch(e){l(fs(e)??t(`toasts.fileReadFailed`),`error`);return}c.invalidateQueries({queryKey:[`settings`]}),ie(e=>e+1);let r=new Date,i=r.toLocaleTimeString(Pe(),{hour:`2-digit`,minute:`2-digit`});re({type:`file`,label:n.name,time:i,title:`${n.name} · ${t(`header.loadedAt`,{time:Fe(r.toISOString())})}`}),l(t(`toasts.fileLoaded`,{name:n.name}),`success`)}catch{l(t(`toasts.fileReadFailed`),`error`)}e.target.value=``}},[o,c,l,t]),bt=(0,U.useCallback)(async()=>{try{await s.mutateAsync(),c.invalidateQueries({queryKey:[`settings`]}),ie(e=>e+1),re(null),l(t(`toasts.dataDeleted`),`info`)}catch(e){l(fs(e)??t(`toasts.deleteFailed`),`error`)}},[s,c,l,t]),xt=ae??fs(me)??null,St=fs(a);return{fileInputRef:u,settingsImportInputRef:d,dataImportInputRef:f,settings:D,providerLimits:O,isLoading:i,settingsLoading:A,isSaving:pe,isDark:_e,hasData:ce,helpOpen:h,setHelpOpen:g,autoImportOpen:_,setAutoImportOpen:v,settingsOpen:y,setSettingsOpen:b,drillDownDate:p,setDrillDownDate:m,drillDownDay:dt,reportGenerating:x,settingsTransferBusy:ee,dataTransferBusy:te,dataSource:ne,headerDataSource:Se,startupAutoLoadBadge:Ce,animationSeed:T,daily:se,usageData:r,allProviders:E,allModelsFromData:le,settingsProviderOptions:ot,settingsModelOptions:st,viewMode:we,setViewMode:Te,selectedMonth:Ee,setSelectedMonth:De,selectedProviders:j,toggleProvider:Oe,clearProviders:ke,selectedModels:M,toggleModel:N,clearModels:je,startDate:P,setStartDate:Ne,endDate:Ie,setEndDate:F,resetAll:I,applyPreset:Le,filteredDailyData:R,filteredData:z,availableMonths:Re,availableProviders:Ve,availableModels:B,dateRange:He,metrics:Ue,modelCosts:We,providerMetrics:Ge,costChartData:Ke,modelCostChartData:qe,tokenChartData:Je,requestChartData:Ye,weekdayData:Xe,allModels:Ze,modelPieData:Qe,tokenPieData:$e,comparisonData:et,totalCalendarDays:tt,todayData:rt,hasCurrentMonthData:it,visibleLimitProviders:at,sectionVisibility:ct,sectionOrder:lt,streak:ut,fatalLoadState:(0,U.useMemo)(()=>{let e=[],n=!!xt,r=!!St;return xt&&e.push(ps(xt,t(`loadError.settingsCorrupted`))),St&&e.push(ps(St,t(`loadError.usageCorrupted`))),!n&&!r?null:{title:t(`loadError.title`),description:t(n&&r?`loadError.multipleDescription`:n?`loadError.settingsDescription`:`loadError.usageDescription`),details:e,canResetSettings:n,canResetUsage:r}},[xt,St,t]),handleUpload:ft,handleOpenSettings:pt,handleRetryLoad:mt,handleResetSettings:ht,handleToggleTheme:gt,handleSaveSettings:_t,handleLanguageChange:vt,handleFileChange:yt,handleDelete:bt,handleExportCSV:(0,U.useCallback)(()=>{os(z),l(t(`toasts.csvExported`),`success`)},[z,l,t]),handleGenerateReport:(0,U.useCallback)(async()=>{if(!x){S(!0);try{let e=await Io({viewMode:we,selectedMonth:Ee,selectedProviders:j,selectedModels:M,language:n.language===`en`?`en`:`de`,...P?{startDate:P}:{},...Ie?{endDate:Ie}:{}}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=`ttdash-report-${new Date().toISOString().slice(0,10)}.pdf`,document.body.appendChild(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3),l(t(`commandPalette.commands.generateReport.label`),`success`)}catch(e){console.error(`PDF generation failed:`,e),l(`${t(`api.pdfFailed`)}: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}finally{S(!1)}}},[x,we,Ee,j,M,P,Ie,l,n.language,t]),handleAutoImport:(0,U.useCallback)(()=>{v(!0)},[]),handleAutoImportSuccess:(0,U.useCallback)(()=>{c.invalidateQueries({queryKey:[`usage`]}),c.invalidateQueries({queryKey:[`settings`]}),ie(e=>e+1);let e=new Date,n=e.toLocaleTimeString(Pe(),{hour:`2-digit`,minute:`2-digit`});re({type:`auto-import`,...n?{time:n}:{},title:t(`header.loadedAt`,{time:Fe(e.toISOString())})}),l(t(`toasts.dataImported`),`success`)},[c,l,t]),handleExportSettings:(0,U.useCallback)(()=>{ms(`ttdash-settings-backup-${Me()}.json`,{kind:ss,version:ls,exportedAt:new Date().toISOString(),appVersion:ye,settings:{language:D.language,theme:D.theme,providerLimits:D.providerLimits,defaultFilters:D.defaultFilters,sectionVisibility:D.sectionVisibility,sectionOrder:D.sectionOrder,lastLoadedAt:D.lastLoadedAt,lastLoadSource:D.lastLoadSource}}),l(t(`toasts.settingsExported`),`success`)},[D,l,t]),handleExportData:(0,U.useCallback)(()=>{if(!r||r.daily.length===0){l(t(`toasts.noDataToExport`),`info`);return}ms(`ttdash-data-backup-${Me()}.json`,{kind:cs,version:ls,exportedAt:new Date().toISOString(),appVersion:ye,data:r}),l(t(`toasts.dataExported`),`success`)},[r,l,t]),handleImportSettings:(0,U.useCallback)(()=>{d.current?.click()},[]),handleImportData:(0,U.useCallback)(()=>{f.current?.click()},[]),handleSettingsImportChange:(0,U.useCallback)(async e=>{let n=e.target.files?.[0];if(n){C(!0);try{let e=await Fo(JSON.parse(await n.text()));c.setQueryData([`settings`],e),L(e.defaultFilters),l(t(`toasts.settingsImported`,{name:n.name}),`success`)}catch(e){l(e instanceof Error?e.message:t(`toasts.fileReadFailed`),`error`)}finally{C(!1),e.target.value=``}}},[c,L,l,t]),handleDataImportChange:(0,U.useCallback)(async e=>{let n=e.target.files?.[0];if(n){w(!0);try{let e=await Ao(JSON.parse(await n.text()));await c.invalidateQueries({queryKey:[`usage`]}),await c.invalidateQueries({queryKey:[`settings`]}),ie(e=>e+1);let r=new Date,i=r.toLocaleTimeString(Pe(),{hour:`2-digit`,minute:`2-digit`});re({type:`file`,label:n.name,...i?{time:i}:{},title:`${n.name} · ${t(`header.loadedAt`,{time:Fe(r.toISOString())})}`});let a=e.conflictingDays>0?`info`:`success`;l(t(e.conflictingDays>0?`toasts.dataBackupImportedWithConflicts`:`toasts.dataBackupImported`,{added:e.addedDays,unchanged:e.unchangedDays,conflicts:e.conflictingDays}),a)}catch(e){l(e instanceof Error?e.message:t(`toasts.fileReadFailed`),`error`)}finally{w(!1),e.target.value=``}}},[c,l,t]),handleScrollTo:(0,U.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})},[])}}var gs=`modulepreload`,_s=function(e){return`/`+e},vs={},ys=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=_s(t,n),t in vs)return;vs[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:gs,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},bs=(0,U.lazy)(()=>ys(()=>import(`./DrillDownModal-BnZ6q6tF.js`).then(e=>({default:e.DrillDownModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),xs=(0,U.lazy)(()=>ys(()=>import(`./AutoImportModal-C8gA0_mL.js`).then(e=>({default:e.AutoImportModal})),__vite__mapDeps([9,1,2,10,5,6,3,7,8])));function Ss({initialSettingsError:e=null}){let{t}=k(),{fileInputRef:n,settingsImportInputRef:r,dataImportInputRef:i,settings:a,providerLimits:o,isLoading:s,settingsLoading:c,isSaving:l,isDark:u,hasData:d,helpOpen:f,setHelpOpen:p,autoImportOpen:m,setAutoImportOpen:h,settingsOpen:g,setSettingsOpen:_,drillDownDate:v,setDrillDownDate:y,drillDownDay:b,reportGenerating:x,settingsTransferBusy:S,dataTransferBusy:ee,headerDataSource:C,startupAutoLoadBadge:te,animationSeed:w,daily:ne,allProviders:re,settingsProviderOptions:T,settingsModelOptions:ie,viewMode:ae,setViewMode:oe,selectedMonth:se,setSelectedMonth:ce,selectedProviders:E,toggleProvider:le,clearProviders:D,selectedModels:O,toggleModel:ue,clearModels:de,startDate:fe,setStartDate:pe,endDate:A,setEndDate:me,resetAll:he,applyPreset:ge,filteredDailyData:_e,filteredData:ve,availableMonths:ye,availableProviders:be,availableModels:xe,dateRange:Se,metrics:Ce,modelCosts:we,providerMetrics:Te,costChartData:Ee,modelCostChartData:De,tokenChartData:j,requestChartData:Oe,weekdayData:ke,allModels:Ae,modelPieData:M,tokenPieData:N,comparisonData:je,totalCalendarDays:Me,todayData:P,hasCurrentMonthData:Ne,visibleLimitProviders:Pe,sectionVisibility:Fe,sectionOrder:Ie,streak:F,fatalLoadState:I,handleUpload:L,handleOpenSettings:Le,handleRetryLoad:R,handleResetSettings:z,handleToggleTheme:Re,handleSaveSettings:ze,handleLanguageChange:Be,handleFileChange:Ve,handleDelete:B,handleExportCSV:He,handleGenerateReport:Ue,handleAutoImport:We,handleAutoImportSuccess:Ge,handleExportSettings:Ke,handleExportData:qe,handleImportSettings:Je,handleImportData:Ye,handleSettingsImportChange:Xe,handleDataImportChange:Ze,handleScrollTo:Qe}=hs(e),$e=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{ref:n,type:`file`,accept:`.json`,className:`hidden`,onChange:Ve,"data-testid":`usage-upload-input`}),(0,W.jsx)(`input`,{ref:r,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:Xe,"data-testid":`settings-import-input`}),(0,W.jsx)(`input`,{ref:i,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:Ze,"data-testid":`data-import-input`})]}),et=(0,W.jsx)(U.Suspense,{fallback:null,children:m&&(0,W.jsx)(xs,{open:m,onOpenChange:h,onSuccess:Ge})}),tt=(0,W.jsx)(qi,{open:g,onOpenChange:_,language:a.language,limitProviders:re,filterProviders:T,models:ie,limits:a.providerLimits,defaultFilters:a.defaultFilters,sectionVisibility:a.sectionVisibility,sectionOrder:a.sectionOrder,lastLoadedAt:a.lastLoadedAt,lastLoadSource:a.lastLoadSource,cliAutoLoadActive:a.cliAutoLoadActive,hasData:d,onSaveSettings:ze,onExportSettings:Ke,onImportSettings:Je,onExportData:qe,onImportData:Ye,settingsBusy:S||l,dataBusy:ee});if(!I&&(s||c))return(0,W.jsx)(wo,{});if(I){let e=[{label:t(`loadError.retry`),onClick:()=>void R(),variant:`default`},...I.canResetSettings?[{label:t(`loadError.resetSettings`),onClick:()=>void z()}]:[],...I.canResetUsage?[{label:t(`loadError.deleteData`),onClick:()=>void B()}]:[]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Yr,{title:I.title,description:I.description,details:I.details,detailLabel:t(`loadError.details`),actions:e}),$e]})}return d?(0,W.jsxs)(`div`,{className:`min-h-screen max-w-7xl mx-auto px-4 pb-8`,children:[$e,(0,W.jsx)(Nr,{dateRange:Se,isDark:u,currentLanguage:a.language,helpOpen:f,streak:F,dataSource:C,startupAutoLoad:te,onHelpOpenChange:p,onLanguageChange:Be,onToggleTheme:Re,onExportCSV:He,onDelete:B,onUpload:L,onAutoImport:We,settingsButton:(0,W.jsxs)(V,{variant:`outline`,size:`sm`,onClick:Le,title:t(`header.settings`),className:`h-11 flex-col gap-1 px-0 text-[10px] sm:h-9 sm:flex-row sm:gap-2 sm:px-3 sm:text-sm`,children:[(0,W.jsx)(yt,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:t(`header.settings`)})]}),pdfButton:(0,W.jsx)(Ji,{generating:x,onGenerate:Ue})}),(0,W.jsx)(`div`,{id:`filters`,children:(0,W.jsx)(Wr,{viewMode:ae,onViewModeChange:oe,selectedMonth:se,onMonthChange:ce,availableMonths:ye,availableProviders:be,selectedProviders:E,onToggleProvider:le,onClearProviders:D,allModels:xe,selectedModels:O,onToggleModel:ue,onClearModels:de,...fe?{startDate:fe}:{},...A?{endDate:A}:{},onStartDateChange:pe,onEndDateChange:me,onApplyPreset:ge,onResetAll:he})}),(0,W.jsx)(`div`,{className:`mt-4 space-y-4`,children:(0,W.jsx)(bo,{sectionOrder:Ie,sectionVisibility:Fe,metrics:Ce,viewMode:ae,totalCalendarDays:Me,filteredData:ve,filteredDailyData:_e,todayData:P,hasCurrentMonthData:Ne,visibleLimitProviders:Pe,providerLimits:o,selectedMonth:se,allModels:Ae,costChartData:Ee,modelPieData:M,modelCostChartData:De,weekdayData:ke,tokenChartData:j,tokenPieData:N,requestChartData:Oe,comparisonData:je,modelCosts:we,providerMetrics:Te,onDrillDownDateChange:y})},`${w}-${ne.length}-${ne[ne.length-1]?.date??`empty`}-${Math.round(Ce.totalCost)}`),(0,W.jsx)(U.Suspense,{fallback:null,children:v!==null&&(0,W.jsx)(bs,{day:b,contextData:ve,open:!0,onClose:()=>y(null)})}),(0,W.jsx)(wi,{isDark:u,availableProviders:be,selectedProviders:E,availableModels:xe,selectedModels:O,hasTodaySection:!!P,hasMonthSection:Ne,hasRequestSection:Ce.hasRequestData,sectionVisibility:Fe,sectionOrder:Ie,reportGenerating:x,onToggleTheme:Re,onExportCSV:He,onGenerateReport:Ue,onDelete:B,onUpload:L,onAutoImport:We,onOpenSettings:Le,onScrollTo:Qe,onViewModeChange:oe,onApplyPreset:ge,onToggleProvider:le,onToggleModel:ue,onClearProviders:D,onClearModels:de,onClearDateRange:()=>{pe(void 0),me(void 0)},onResetAll:he,onHelp:()=>p(!0),onLanguageChange:Be}),et,tt]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Jr,{onUpload:L,onAutoImport:We,onOpenSettings:Le}),$e,et,tt]})}function Cs({initialSettings:e,initialSettingsError:t=null}){let[n]=(0,U.useState)(()=>{let t=new Qn({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});return t.setQueryData([`settings`],e),t});return(0,W.jsx)(tr,{client:n,children:(0,W.jsx)(yr,{children:(0,W.jsx)(He,{delayDuration:100,children:(0,W.jsx)(Ss,{initialSettingsError:t})})})})}async function ws(){let{settings:e,errorMessage:t}=await Mo();Bi(e.theme),await Ne(e.language),(0,_r.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(U.StrictMode,{children:(0,W.jsx)(Cs,{initialSettings:e,initialSettingsError:t})}))}ws();