@roastcodes/ttdash 6.1.9 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/assets/AnomalyDetection-BdGl1xvC.js +1 -0
  2. package/dist/assets/{AutoImportModal-C8gA0_mL.js → AutoImportModal-bokip1Pn.js} +3 -3
  3. package/dist/assets/CacheROI-IyVKLGZu.js +1 -0
  4. package/dist/assets/ChartCard-CBUnItl-.js +2 -0
  5. package/dist/assets/ChartLegend-B64cJdDI.js +1 -0
  6. package/dist/assets/CorrelationAnalysis-Dnd0YUCO.js +1 -0
  7. package/dist/assets/CostByModelOverTime-C10Hr2xR.js +1 -0
  8. package/dist/assets/CostByWeekday-X20qjGNA.js +1 -0
  9. package/dist/assets/CostForecast-C--EIZ4B.js +1 -0
  10. package/dist/assets/CumulativeCost-D9v6GDcr.js +1 -0
  11. package/dist/assets/CustomTooltip-CBVU1pyK.js +1 -0
  12. package/dist/assets/DistributionAnalysis-Cdly0pAu.js +1 -0
  13. package/dist/assets/DrillDownModal-BXf7B9B8.js +1 -0
  14. package/dist/assets/HelpPanel-HNxQElT5.js +1 -0
  15. package/dist/assets/InfoButton-CTgLGzb9.js +1 -0
  16. package/dist/assets/InfoHeading-oi90uCR7.js +1 -0
  17. package/dist/assets/MetricCard-Drluz0b9.js +1 -0
  18. package/dist/assets/ModelEfficiency-CZ4ZzDtA.js +1 -0
  19. package/dist/assets/ModelMix-TDHxSk5H.js +1 -0
  20. package/dist/assets/PeriodComparison-B9WuoaCr.js +1 -0
  21. package/dist/assets/ProviderEfficiency-DpDIYr_l.js +1 -0
  22. package/dist/assets/ProviderLimitsSection-CSuisho_.js +1 -0
  23. package/dist/assets/RecentDays-Cz4Yd_-Q.js +1 -0
  24. package/dist/assets/RequestCacheHitRateByModel-5bkvg7Hx.js +1 -0
  25. package/dist/assets/RequestQuality-iUIOJrpr.js +1 -0
  26. package/dist/assets/RequestsOverTime-D10OssgN.js +1 -0
  27. package/dist/assets/SettingsModal-D9-T5heB.js +1 -0
  28. package/dist/assets/TokenEfficiency-CGeyr8Zq.js +1 -0
  29. package/dist/assets/TokenTypes-BiRBF9VP.js +1 -0
  30. package/dist/assets/TokensOverTime-DeT3D-aC.js +1 -0
  31. package/dist/assets/app-settings-C3i52ycx.js +1 -0
  32. package/dist/assets/button-D--hHeVj.js +1 -0
  33. package/dist/assets/calculations-GOdNqKo6.js +1 -0
  34. package/dist/assets/card-h-Z9EWBl.js +1 -0
  35. package/dist/assets/chart-theme-D5iCFDJg.js +1 -0
  36. package/dist/assets/constants-jyhBMReu.js +1 -0
  37. package/dist/assets/dialog-C0AeNKs8.js +1 -0
  38. package/dist/assets/formatted-value-rO0EpKbc.js +1 -0
  39. package/dist/assets/formatters-yKppUXb3.js +1 -0
  40. package/dist/assets/help-content-Bt5KCpWS.js +1 -0
  41. package/dist/assets/i18n-C88wS2Uy.js +1 -0
  42. package/dist/assets/index-DjMakAzD.js +3 -0
  43. package/dist/assets/index-DuoM1Ukq.css +2 -0
  44. package/dist/assets/model-utils-BIvGAFGz.js +1 -0
  45. package/dist/assets/motion-vendor-vKc6gXHZ.js +1 -0
  46. package/dist/assets/provider-limits-5e1fUwPl.js +1 -0
  47. package/dist/assets/section-header-DbV45zH5.js +1 -0
  48. package/dist/assets/ui-vendor-BolBXLiD.js +45 -0
  49. package/dist/assets/useTranslation-BSl7t2D6.js +1 -0
  50. package/dist/index.html +26 -8
  51. package/package.json +15 -5
  52. package/server/report/chart-labels.js +12 -0
  53. package/server/report/charts.js +4 -8
  54. package/server/report/index.js +86 -27
  55. package/server/report/utils.js +64 -21
  56. package/server.js +281 -56
  57. package/shared/dashboard-domain.d.ts +12 -0
  58. package/shared/dashboard-domain.js +79 -0
  59. package/shared/dashboard-types.d.ts +4 -0
  60. package/shared/model-colors.d.ts +24 -0
  61. package/shared/model-colors.js +268 -0
  62. package/src/locales/de/common.json +59 -6
  63. package/src/locales/en/common.json +59 -5
  64. package/dist/assets/CustomTooltip-BXro6tIF.js +0 -1
  65. package/dist/assets/DrillDownModal-BnZ6q6tF.js +0 -1
  66. package/dist/assets/button-B26tLVFw.js +0 -1
  67. package/dist/assets/dialog-CA-ZSHjK.js +0 -1
  68. package/dist/assets/index-BfNaLs3g.js +0 -4
  69. package/dist/assets/index-BkGSNAne.css +0 -2
  70. package/dist/assets/motion-vendor-BXI2L__C.js +0 -1
  71. package/dist/assets/ui-vendor-BGjRFQGY.js +0 -45
  72. /package/dist/assets/{icons-vendor-z59La6A4.js → icons-vendor-CIvT_-Pb.js} +0 -0
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{h as i,i as a,n as o}from"./formatters-yKppUXb3.js";import{i as s}from"./icons-vendor-CIvT_-Pb.js";import{a as c,i as l,n as u,t as d}from"./card-h-Z9EWBl.js";import{t as f}from"./help-content-Bt5KCpWS.js";import{t as p}from"./InfoHeading-oi90uCR7.js";import{t as m}from"./calculations-GOdNqKo6.js";var h=e(t()),g=n();function _({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:_}=r(),{anomalies:v,mean:y,stdDev:b}=(0,h.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:m(e),mean:n,stdDev:r}},[e]);return v.length===0?(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsx)(c,{className:`text-sm font-medium text-muted-foreground`,children:_(`anomaly.title`,{period:i(n,!0)})})})}),(0,g.jsx)(u,{children:(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_(`anomaly.none`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:_(`anomaly.withinStdDev`)})]})})]}):(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsxs)(c,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-yellow-500`}),_(`anomaly.title`,{period:i(n,!0)}),` (`,v.length,`)`]})})}),(0,g.jsxs)(u,{children:[(0,g.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:_(`anomaly.description`,{period:i(n,!0),mean:o(y),stdDev:o(b)})}),(0,g.jsx)(`div`,{className:`space-y-2`,children:[...v].sort((e,t)=>t.totalCost-e.totalCost).map(e=>{let n=b>0?(e.totalCost-y)/b:0,r=n.toFixed(1),i=e.totalCost>y,s=Math.abs(n)>=3?`critical`:`warn`;return(0,g.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between rounded-lg p-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${s===`critical`?`bg-red-400/10 hover:bg-red-400/20 border border-red-400/20`:`bg-muted/30 hover:bg-muted/50`}`,disabled:!t,"aria-disabled":!t,onClick:()=>t?.(e.date),children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`h-2 w-2 rounded-full ${i?`bg-red-400`:`bg-green-400`} ${s===`critical`?`animate-pulse`:``}`}),(0,g.jsx)(`span`,{className:`text-sm`,children:a(e.date,`long`)}),s===`critical`&&(0,g.jsx)(`span`,{className:`rounded bg-red-400/10 px-1.5 py-0.5 text-[9px] font-semibold tracking-wider text-red-400 uppercase`,children:_(`anomaly.critical`)})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,g.jsx)(`span`,{className:`font-mono text-sm font-medium ${i?`text-red-400`:`text-green-400`}`,children:o(e.totalCost)}),(0,g.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-xs font-medium ${s===`critical`?`bg-red-400/15 text-red-300`:`text-muted-foreground`}`,children:[i?`+`:``,r,`σ`]})]})]},e.date)})})]})]})}export{_ as AnomalyDetection};
@@ -1,3 +1,3 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{r as n}from"./motion-vendor-BXI2L__C.js";import{a as r,i,n as a,o,r as s,t as c}from"./dialog-CA-ZSHjK.js";import{B as l,H as u,c as d,x as f}from"./icons-vendor-z59La6A4.js";import{t as p}from"./button-B26tLVFw.js";var m=e(t());function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e){try{let t=JSON.parse(e);return h(t)?t:null}catch{return null}}function _(e,t){switch(e.key){case`startingLocalImport`:return t(`autoImportModal.startingLocalImport`);case`loadingUsageData`:return t(`autoImportModal.loadingUsageData`,{command:String(e.vars?.command??``)});case`processingUsageData`:return t(`autoImportModal.processingUsageData`,{seconds:String(e.vars?.seconds??`0`)});case`serverConnectionLost`:return t(`autoImportModal.serverConnectionLost`);case`autoImportRunning`:return t(`autoImportModal.autoImportRunning`);case`noRunnerFound`:return t(`autoImportModal.noRunnerFound`);case`errorPrefix`:return t(`autoImportModal.errorPrefix`,{message:String(e.vars?.message??``)});default:return e.key}}function v(e,t=e=>e){let n=new AbortController,r=new TextDecoder,i=!1,a=!1,o=!1,s=()=>{i||(i=!0,e.onDone())},c=(n,r)=>{switch(n){case`check`:{let t=g(r);t&&e.onCheck(t);return}case`progress`:{let n=g(r);n&&e.onProgress({...n,message:_(n,t)});return}case`stderr`:{let t=g(r);t&&e.onStderr(t);return}case`success`:{let t=g(r);t&&e.onSuccess(t);return}case`error`:{o=!0;let n=g(r);n?e.onError({message:_(n,t)}):e.onError({message:t(`autoImportModal.serverConnectionLost`)});return}case`done`:a=!0,s()}},l=(e,t)=>{t.length!==0&&c(e||`message`,t.join(`
2
- `))},u=(e,t)=>{for(let n of e){if(!n){l(t.currentEvent,t.dataLines),t.currentEvent=``,t.dataLines=[];continue}if(n.startsWith(`event:`)){t.currentEvent=n.slice(6).trim();continue}n.startsWith(`data:`)&&t.dataLines.push(n.slice(5).trimStart())}};return(async()=>{let i=await fetch(`/api/auto-import/stream`,{method:`POST`,signal:n.signal});if(!i.ok){let n=t(`autoImportModal.serverConnectionLost`);try{let e=await i.json();h(e)&&typeof e.message==`string`&&e.message.trim()&&(n=e.message)}catch{}e.onError({message:n}),s();return}if(!i.body){e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}let c=i.body.getReader(),d=``,f={currentEvent:``,dataLines:[]};for(;;){let{value:n,done:i}=await c.read();if(i){d+=r.decode(),d&&u(d.split(/\r?\n/),f),l(f.currentEvent,f.dataLines),!a&&!o&&e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}d+=r.decode(n,{stream:!0});let p=d.split(/\r?\n/);d=p.pop()??``,u(p,f)}})().catch(r=>{if(n.signal.aborted){s();return}e.onError({message:r instanceof Error&&r.message?r.message:t(`autoImportModal.serverConnectionLost`)}),s()}),{close:()=>{n.abort(),s()}}}var y=n(),b={check:`text-primary`,progress:`text-muted-foreground`,stderr:`text-foreground`,success:`text-green-500`,error:`text-destructive`};function x({open:e,onOpenChange:t,onSuccess:n}){let{t:h}=o(),[g,_]=(0,m.useState)(`idle`),[x,S]=(0,m.useState)([]),[C,w]=(0,m.useState)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=(0,m.useCallback)((e,t)=>{S(n=>[...n,{type:e,text:t}])},[]),O=(0,m.useCallback)((e,t)=>t?h(e,t):h(e),[h]);(0,m.useEffect)(()=>{if(!e)return;_(`checking`),S([]),w(null);let t=v({onCheck:e=>{e.status===`checking`?D(`check`,h(`autoImportModal.checkingTool`,{tool:e.tool})):e.status===`found`?(D(`check`,h(`autoImportModal.toolFound`,{tool:e.tool,method:e.method,version:e.version})),_(`running`)):e.status===`not_found`&&D(`check`,h(`autoImportModal.toolNotFound`,{tool:e.tool}))},onProgress:e=>{D(`progress`,e.message)},onStderr:e=>{D(`stderr`,e.line)},onSuccess:e=>{D(`success`,h(`autoImportModal.importedDays`,{days:e.days,cost:e.totalCost.toFixed(2)})),w(e),_(`success`),n()},onError:e=>{D(`error`,e.message),_(`error`)},onDone:()=>{E.current=null}},O);return E.current=t,()=>{t.close(),E.current=null}},[e,D,O,n,h]),(0,m.useEffect)(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[x]);let k=g===`checking`||g===`running`;return(0,y.jsx)(c,{open:e,onOpenChange:e=>{k||t(e)},children:(0,y.jsxs)(a,{className:`max-w-lg`,onPointerDownOutside:e=>{k&&e.preventDefault()},children:[(0,y.jsxs)(i,{children:[(0,y.jsxs)(r,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{className:`h-5 w-5`}),h(`autoImportModal.title`)]}),(0,y.jsx)(s,{children:h(`autoImportModal.description`)})]}),(0,y.jsxs)(`div`,{ref:T,className:`bg-muted/30 rounded-lg p-3 font-mono text-xs max-h-[300px] min-h-[120px] overflow-y-auto border border-border`,children:[x.length===0&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(`autoImportModal.connecting`)}),x.map((e,t)=>(0,y.jsx)(`div`,{className:b[e.type],children:e.text.split(`
3
- `).map((e,t)=>(0,y.jsx)(`div`,{children:e},t))},t))]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[k&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{className:`h-4 w-4 animate-spin text-primary`}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(g===`checking`?`autoImportModal.checkingPrerequisites`:`autoImportModal.importingData`)})]}),g===`success`&&C&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{className:`h-4 w-4 text-green-500`}),(0,y.jsx)(`span`,{className:`text-green-500`,children:h(`autoImportModal.loadedDays`,{days:C.days,cost:C.totalCost.toFixed(2)})})]}),g===`error`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(l,{className:`h-4 w-4 text-destructive`}),(0,y.jsx)(`span`,{className:`text-destructive`,children:h(`autoImportModal.errorOccurred`)})]})]}),!k&&(0,y.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>t(!1),children:h(`autoImportModal.close`)})]})]})})}export{x as AutoImportModal};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{B as i,H as a,c as o,x as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-D--hHeVj.js";import{a as l,i as u,n as d,r as f,t as p}from"./dialog-C0AeNKs8.js";var m=e(t());function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e){try{let t=JSON.parse(e);return h(t)?t:null}catch{return null}}function _(e,t){switch(e.key){case`startingLocalImport`:return t(`autoImportModal.startingLocalImport`);case`loadingUsageData`:return t(`autoImportModal.loadingUsageData`,{command:String(e.vars?.command??``)});case`processingUsageData`:return t(`autoImportModal.processingUsageData`,{seconds:String(e.vars?.seconds??`0`)});case`serverConnectionLost`:return t(`autoImportModal.serverConnectionLost`);case`autoImportRunning`:return t(`autoImportModal.autoImportRunning`);case`noRunnerFound`:return t(`autoImportModal.noRunnerFound`);case`errorPrefix`:return t(`autoImportModal.errorPrefix`,{message:String(e.vars?.message??``)});default:return e.key}}function v(e,t=e=>e){let n=new AbortController,r=new TextDecoder,i=!1,a=!1,o=!1,s=()=>{i||(i=!0,e.onDone())},c=(n,r)=>{switch(n){case`check`:{let t=g(r);t&&e.onCheck(t);return}case`progress`:{let n=g(r);n&&e.onProgress({...n,message:_(n,t)});return}case`stderr`:{let t=g(r);t&&e.onStderr(t);return}case`success`:{let t=g(r);t&&e.onSuccess(t);return}case`error`:{o=!0;let n=g(r);n?e.onError({message:_(n,t)}):e.onError({message:t(`autoImportModal.serverConnectionLost`)});return}case`done`:a=!0,s()}},l=(e,t)=>{t.length!==0&&c(e||`message`,t.join(`
2
+ `))},u=(e,t)=>{for(let n of e){if(!n){l(t.currentEvent,t.dataLines),t.currentEvent=``,t.dataLines=[];continue}if(n.startsWith(`event:`)){t.currentEvent=n.slice(6).trim();continue}n.startsWith(`data:`)&&t.dataLines.push(n.slice(5).trimStart())}};return(async()=>{let i=await fetch(`/api/auto-import/stream`,{method:`POST`,signal:n.signal});if(!i.ok){let n=t(`autoImportModal.serverConnectionLost`);try{let e=await i.json();h(e)&&typeof e.message==`string`&&e.message.trim()&&(n=e.message)}catch{}e.onError({message:n}),s();return}if(!i.body){e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}let c=i.body.getReader(),d=``,f={currentEvent:``,dataLines:[]};for(;;){let{value:n,done:i}=await c.read();if(i){d+=r.decode(),d&&u(d.split(/\r?\n/),f),l(f.currentEvent,f.dataLines),!a&&!o&&e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}d+=r.decode(n,{stream:!0});let p=d.split(/\r?\n/);d=p.pop()??``,u(p,f)}})().catch(r=>{if(n.signal.aborted){s();return}e.onError({message:r instanceof Error&&r.message?r.message:t(`autoImportModal.serverConnectionLost`)}),s()}),{close:()=>{n.abort(),s()}}}var y=n(),b={check:`text-primary`,progress:`text-muted-foreground`,stderr:`text-foreground`,success:`text-green-500`,error:`text-destructive`};function x({open:e,onOpenChange:t,onSuccess:n}){let{t:h}=r(),[g,_]=(0,m.useState)(`idle`),[x,S]=(0,m.useState)([]),[C,w]=(0,m.useState)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=(0,m.useCallback)((e,t)=>{S(n=>[...n,{type:e,text:t}])},[]),O=(0,m.useCallback)((e,t)=>t?h(e,t):h(e),[h]);(0,m.useEffect)(()=>{if(!e)return;_(`checking`),S([]),w(null);let t=v({onCheck:e=>{e.status===`checking`?D(`check`,h(`autoImportModal.checkingTool`,{tool:e.tool})):e.status===`found`?(D(`check`,h(`autoImportModal.toolFound`,{tool:e.tool,method:e.method,version:e.version})),_(`running`)):e.status===`not_found`&&D(`check`,h(`autoImportModal.toolNotFound`,{tool:e.tool}))},onProgress:e=>{D(`progress`,e.message)},onStderr:e=>{D(`stderr`,e.line)},onSuccess:e=>{D(`success`,h(`autoImportModal.importedDays`,{days:e.days,cost:e.totalCost.toFixed(2)})),w(e),_(`success`),n()},onError:e=>{D(`error`,e.message),_(`error`)},onDone:()=>{E.current=null}},O);return E.current=t,()=>{t.close(),E.current=null}},[e,D,O,n,h]),(0,m.useEffect)(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[x]);let k=g===`checking`||g===`running`;return(0,y.jsx)(p,{open:e,onOpenChange:e=>{k||t(e)},children:(0,y.jsxs)(d,{className:`max-w-lg`,onPointerDownOutside:e=>{k&&e.preventDefault()},children:[(0,y.jsxs)(u,{children:[(0,y.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,y.jsx)(o,{className:`h-5 w-5`}),h(`autoImportModal.title`)]}),(0,y.jsx)(f,{children:h(`autoImportModal.description`)})]}),(0,y.jsxs)(`div`,{ref:T,className:`max-h-[300px] min-h-[120px] overflow-y-auto rounded-lg border border-border bg-muted/30 p-3 font-mono text-xs`,children:[x.length===0&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(`autoImportModal.connecting`)}),x.map((e,t)=>(0,y.jsx)(`div`,{className:b[e.type],children:e.text.split(`
3
+ `).map((e,t)=>(0,y.jsx)(`div`,{children:e},t))},t))]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[k&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{className:`h-4 w-4 animate-spin text-primary`}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(g===`checking`?`autoImportModal.checkingPrerequisites`:`autoImportModal.importingData`)})]}),g===`success`&&C&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a,{className:`h-4 w-4 text-green-500`}),(0,y.jsx)(`span`,{className:`text-green-500`,children:h(`autoImportModal.loadedDays`,{days:C.days,cost:C.totalCost.toFixed(2)})})]}),g===`error`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(i,{className:`h-4 w-4 text-destructive`}),(0,y.jsx)(`span`,{className:`text-destructive`,children:h(`autoImportModal.errorOccurred`)})]})]}),!k&&(0,y.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>t(!1),children:h(`autoImportModal.close`)})]})]})})}export{x as AutoImportModal};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{g as i,u as a}from"./formatters-yKppUXb3.js";import{t as o}from"./icons-vendor-CIvT_-Pb.js";import{r as s}from"./constants-jyhBMReu.js";import{c}from"./model-utils-BIvGAFGz.js";import{a as l,i as u,n as d,t as f}from"./card-h-Z9EWBl.js";import{t as p}from"./formatted-value-rO0EpKbc.js";import{t as m}from"./help-content-Bt5KCpWS.js";import{t as h}from"./InfoHeading-oi90uCR7.js";var g=e(t()),_=n();function v({data:e,viewMode:t=`daily`}){let{t:n}=r(),{actualCost:v,hypotheticalCost:y,savings:b,savingsPercent:x,dailyAvg:S,heuristicModels:C}=(0,g.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=c(e.modelName),i=s[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),l=o>0?t/o:0;return{actualCost:t,hypotheticalCost:n,savings:i,savingsPercent:a,dailyAvg:l,heuristicModels:Array.from(r).sort()}},[e]);if(e.length===0)return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsxs)(l,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,_.jsx)(o,{className:`h-4 w-4 text-muted-foreground/30`}),n(`cacheRoi.title`)]})}),(0,_.jsx)(d,{children:(0,_.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:n(`cacheRoi.noData`)})})]});let w=Math.sign(b),T=w>0,E=Math.max(0,Math.min(100,y>0?v/y*100:100)),D=w<0?`text-rose-700 dark:text-rose-300`:`text-emerald-700 dark:text-emerald-300`,O=`bg-rose-500/60 dark:bg-rose-400/60`,k=`bg-emerald-500/65 dark:bg-emerald-400/60`;return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsx)(h,{info:m.cacheROI,children:(0,_.jsxs)(l,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,_.jsx)(o,{className:`h-4 w-4 text-yellow-500`}),n(`cacheRoi.title`)]})})}),(0,_.jsxs)(d,{className:`space-y-4`,children:[C.length>0&&(0,_.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/12 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:n(`cacheRoi.heuristicFallback`,{count:C.length,modelsLabel:C.length===1?n(`cacheRoi.model`):n(`cacheRoi.models`)})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withoutCache`)}),(0,_.jsx)(`div`,{className:`text-lg font-bold text-rose-700 dark:text-rose-300`,children:(0,_.jsx)(p,{value:y,type:`currency`})})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withCacheActual`)}),(0,_.jsx)(`div`,{className:`text-lg font-bold ${D}`,children:(0,_.jsx)(p,{value:v,type:`currency`})})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.savings`)}),(0,_.jsxs)(`div`,{className:`text-lg font-bold ${D}`,children:[(0,_.jsx)(p,{value:b,type:`currency`}),(0,_.jsxs)(`span`,{className:`ml-1 text-xs ${D}`,children:[`(`,a(x),`)`]})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.avgCostPerUnit`,{unit:i(t)})}),(0,_.jsx)(`div`,{className:`text-lg font-bold text-foreground`,children:(0,_.jsx)(p,{value:S,type:`currency`})})]})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,_.jsx)(`span`,{className:`w-24 text-muted-foreground`,children:n(`cacheRoi.withoutCache`)}),(0,_.jsx)(`div`,{className:`h-6 flex-1 overflow-hidden rounded-md bg-rose-500/12 dark:bg-rose-500/18`,children:(0,_.jsx)(`div`,{className:`h-full rounded-md ${O}`,style:{width:`100%`}})})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,_.jsx)(`span`,{className:`w-24 text-muted-foreground`,children:n(`cacheRoi.withCache`)}),(0,_.jsxs)(`div`,{className:`flex h-6 flex-1 overflow-hidden rounded-md bg-muted/20`,children:[(0,_.jsx)(`div`,{className:`h-full rounded-l-md ${T?k:O} transition-all duration-1000 motion-reduce:transition-none`,style:{width:`${E}%`}}),(0,_.jsx)(`div`,{className:`h-full flex-1 rounded-r-md ${T?`bg-emerald-500/12 dark:bg-emerald-400/16 border-l border-emerald-500/35 dark:border-emerald-400/30 border-dashed`:`bg-muted/10`}`})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:[(0,_.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`h-2 w-2 rounded-sm ${k}`}),` `,n(`cacheRoi.paid`)]}),(0,_.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`h-2 w-2 rounded-sm bg-emerald-500/12 dark:bg-emerald-400/16 border border-emerald-500/35 dark:border-emerald-400/30 border-dashed`}),` `,n(`cacheRoi.saved`)]})]})]})]})]})}export{v as CacheROI};
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n,t as r}from"./motion-vendor-vKc6gXHZ.js";import{a as i,i as a,t as o}from"./useTranslation-BSl7t2D6.js";import{n as s}from"./formatters-yKppUXb3.js";import{b as c}from"./icons-vendor-CIvT_-Pb.js";import{a as l,i as u,n as d,r as f,t as p}from"./card-h-Z9EWBl.js";import{a as m,n as h,r as g,t as _}from"./dialog-C0AeNKs8.js";import{t as v}from"./InfoButton-CTgLGzb9.js";var y=e(t());function b(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 x(e){return e.map(e=>b(e)).join(`,`)}var S=n();function C(e){if(e.length===0)return``;let t=e[0];if(!t)return``;let n=Object.keys(t);return[x(n),...e.map(e=>x(n.map(t=>e[t])))].join(`
2
+ `)}var w=(0,y.createContext)(!1);function T(){return(0,y.useContext)(w)}function E({children:e}){let t=a(),n=T();return(0,S.jsx)(S.Fragment,{children:e(t?!1:n)})}function D({children:e,variant:t=`line`}){return(0,S.jsx)(`div`,{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 O({title:e,subtitle:t,summary:n,info:a,expandable:b=!0,children:x,className:T,chartData:E,valueKey:D,valueFormatter:O,expandedExtra:k}){let{t:A}=o(),[j,M]=(0,y.useState)(!1),N=(0,y.useRef)(null),P=r(N,{once:!0,amount:.25})||j,F=(0,y.useMemo)(()=>{if(!E||!D)return null;let e=E.map(e=>e[D]).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}},[E,D]),I=O??s,L=e=>typeof x==`function`?x(e):x,R=(0,y.useCallback)(()=>{if(!E||E.length===0)return;let t=C(E);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)},[E,e]),z=(0,S.jsxs)(u,{className:`pb-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:e}),a&&(0,S.jsx)(v,{text:a})]}),(0,S.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n&&(0,S.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:n})})]}),t&&(0,S.jsx)(f,{className:`mt-0.5`,children:t})]});return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(w.Provider,{value:P,children:(0,S.jsxs)(p,{ref:N,className:i(`group relative`,T),children:[z,(0,S.jsx)(d,{children:L(!1)}),b&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`absolute top-3 right-3 z-10 rounded-lg border border-border/50 bg-background/80 p-1.5 text-muted-foreground opacity-100 backdrop-blur-sm transition-opacity duration-200 hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none motion-reduce:transition-none md:opacity-0 md:group-focus-within:opacity-100 md:group-hover:opacity-100`,title:A(`common.expand`),"aria-label":A(`common.expandWithTitle`,{title:e}),children:(0,S.jsx)(c,{className:`h-3.5 w-3.5`})})]})}),b&&(0,S.jsx)(_,{open:j,onOpenChange:M,children:(0,S.jsxs)(h,{className:`h-[92vh] max-h-[92vh] w-[96vw] max-w-[96vw] overflow-auto p-0 sm:h-[90vh] sm:max-h-[90vh] sm:w-[95vw] sm:max-w-[95vw]`,children:[(0,S.jsx)(m,{className:`sr-only`,children:e}),(0,S.jsx)(g,{className:`sr-only`,children:A(`chartCard.expandedDescription`)}),(0,S.jsx)(w.Provider,{value:j,children:(0,S.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,S.jsxs)(`div`,{className:`p-4 pb-2 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:e}),t&&(0,S.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),E&&E.length>0&&(0,S.jsx)(`button`,{type:`button`,onClick:R,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-muted-foreground transition-all duration-200 hover:bg-accent hover:text-foreground`,children:A(`chartCard.exportCsv`)})]}),F&&(0,S.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:grid-cols-5`,children:[(0,S.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,S.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:A(`dashboard.stats.min`)}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:I(F.min)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,S.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:A(`dashboard.stats.max`)}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:I(F.max)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,S.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:A(`dashboard.stats.avg`)}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:I(F.avg)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,S.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:A(`dashboard.stats.total`)}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:I(F.total)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,S.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:A(`dashboard.stats.dataPoints`)}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:F.count})]})]})]}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-auto p-4 pt-2 sm:p-6`,children:[L(!0),k]})]})})]})})]})}export{x as i,O as n,D as r,E as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-vKc6gXHZ.js";var t=e();function n({payload:e}){return e?.length?(0,t.jsx)(`div`,{className:`mt-3 overflow-x-auto pb-1`,children:(0,t.jsx)(`div`,{className:`flex min-w-max items-center gap-3 pr-2`,children:e.map((e,n)=>{let r=typeof e.color==`string`?e.color:`currentColor`,i=String(e.value??``),a=e.id??e.dataKey??`${i}-${r}-${n}`;return(0,t.jsxs)(`div`,{className:`inline-flex items-center gap-2 text-xs`,children:[(0,t.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:r}}),(0,t.jsx)(`span`,{className:`whitespace-nowrap text-muted-foreground`,children:i})]},String(a))})})}):null}export{n as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,l as r,m as i,r as a,s as o,u as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u,t as d}from"./motion-vendor-vKc6gXHZ.js";import{i as f,t as p}from"./useTranslation-BSl7t2D6.js";import{d as m,i as h,l as g,n as _,u as v}from"./formatters-yKppUXb3.js";import{a as y,i as b,n as x,t as S}from"./card-h-Z9EWBl.js";import{t as C}from"./help-content-Bt5KCpWS.js";import{t as w}from"./InfoHeading-oi90uCR7.js";import{n as T,r as E,t as D}from"./chart-theme-D5iCFDJg.js";var O=e(l()),k=u();function A(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 j(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 M({active:e,payload:t,mode:n}){let{t:r}=p();if(!e||!t?.length)return null;let i=t[0]?.payload;return i?(0,k.jsxs)(`div`,{className:`max-w-[260px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,k.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:h(i.label)}),(0,k.jsx)(`div`,{className:`space-y-1`,children:n===`requestCost`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:g(i.requests)})]}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cost`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:_(i.y)})]}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.tokensLabel`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:i.tokens===void 0?`–`:m(i.tokens)})]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cacheRate`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:i.cacheRate===void 0?`–`:v(i.cacheRate,1)})]}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.costPerRequest`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:_(i.y)})]}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,k.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:g(i.requests)})]})]})})]}):null}function N({title:e,subtitle:l,mode:u,data:p,color:m,animationBegin:h=0,xAxisName:g,xTickFormatter:v,yAxisName:y,footer:b}){let x=(0,O.useRef)(null),S=d(x,{once:!0,amount:.45}),C=f(),w=C?!0:S,A=w?p:[];return(0,k.jsx)(`div`,{ref:x,children:(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,k.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e}),(0,k.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:l})]}),(0,k.jsx)(t,{width:`100%`,height:260,children:(0,k.jsxs)(a,{margin:E,children:[(0,k.jsx)(i,{strokeDasharray:`3 3`,stroke:T.grid,opacity:.25}),(0,k.jsx)(r,{type:`number`,dataKey:`x`,stroke:T.axis,fontSize:10,tickLine:!1,name:g,...v?{tickFormatter:v}:{}}),(0,k.jsx)(n,{type:`number`,dataKey:`y`,stroke:T.axis,fontSize:10,tickLine:!1,axisLine:!1,name:y,tickFormatter:_}),(0,k.jsx)(o,{type:`number`,dataKey:`z`,range:[30,180]}),(0,k.jsx)(c,{content:(0,k.jsx)(M,{mode:u}),cursor:{strokeDasharray:`4 4`}}),(0,k.jsx)(s,{data:A,fill:m,stroke:m,fillOpacity:.72,isAnimationActive:!C&&w,animationBegin:h,animationDuration:D.duration})]})}),(0,k.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:b})]})})}function P({data:e}){let{t}=p(),n=(0,O.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,O.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=j(n.map(e=>e.x),n.map(e=>e.y)),a=j(r.map(e=>e.x),r.map(e=>e.y));return e.length<2?(0,k.jsxs)(S,{children:[(0,k.jsx)(b,{children:(0,k.jsx)(w,{info:C.correlationAnalysis,children:(0,k.jsx)(y,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,k.jsx)(x,{children:(0,k.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,k.jsxs)(S,{children:[(0,k.jsx)(b,{children:(0,k.jsx)(w,{info:C.correlationAnalysis,children:(0,k.jsx)(y,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,k.jsxs)(x,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,k.jsx)(N,{title:t(`charts.correlation.requestsVsCost`),subtitle:`r ${i.toFixed(2)} · ${t(`charts.correlation.points`,{count:n.length})}`,mode:`requestCost`,data:n,color:T.cost,xAxisName:t(`charts.correlation.requestsAxis`),yAxisName:t(`charts.correlation.cost`),footer:A(t,i,`requestCost`)}),(0,k.jsx)(N,{title:t(`charts.correlation.cacheVsCostPerRequest`),subtitle:`r ${a.toFixed(2)} · ${t(`charts.correlation.points`,{count:r.length})}`,mode:`cacheEfficiency`,data:r,color:T.cumulative,animationBegin:D.stagger,xAxisName:t(`charts.correlation.cacheRate`),xTickFormatter:e=>v(e,0),yAxisName:t(`charts.correlation.costPerRequestAxis`),footer:A(t,a,`cacheEfficiency`)})]})]})}export{P as CorrelationAnalysis};
@@ -0,0 +1 @@
1
+ import{b as e,c as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./charts-vendor-CiBqdKXh.js";import{a as c}from"./motion-vendor-vKc6gXHZ.js";import{t as l}from"./useTranslation-BSl7t2D6.js";import{a as u,n as d,t as f}from"./formatters-yKppUXb3.js";import{t as p}from"./model-utils-BIvGAFGz.js";import{t as m}from"./help-content-Bt5KCpWS.js";import{n as h,r as g,t as _}from"./ChartCard-CBUnItl-.js";import{t as v}from"./ChartLegend-B64cJdDI.js";import{t as y}from"./CustomTooltip-CBVU1pyK.js";import{n as b,r as x,t as S}from"./chart-theme-D5iCFDJg.js";var C=c();function w({data:c,models:w}){let{t:T}=l(),E=w.map(e=>({model:e,total:c.reduce((t,n)=>t+(f(n[e])??0),0)})).sort((e,t)=>t.total-e.total)[0]??null,D=(0,C.jsx)(_,{children:l=>(0,C.jsxs)(`div`,{className:`mt-6`,children:[(0,C.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:T(`charts.costByModelOverTime.movingAverageHeading`)}),(0,C.jsx)(g,{variant:`line`,children:(0,C.jsx)(e,{width:`100%`,height:350,children:(0,C.jsxs)(i,{data:c,margin:x,children:[(0,C.jsx)(r,{strokeDasharray:`3 3`,stroke:b.grid,opacity:.3}),(0,C.jsx)(n,{dataKey:`date`,tickFormatter:u,stroke:b.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(t,{tickFormatter:e=>{let t=f(e);return t===null?``:d(t)},stroke:b.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(o,{content:(0,C.jsx)(y,{formatter:e=>d(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,C.jsx)(s,{content:(0,C.jsx)(v,{})}),w.map((e,t)=>(0,C.jsx)(a,{type:`monotone`,dataKey:`${e}_ma7`,stroke:p(e),name:`${e} ${T(`charts.costByModelOverTime.movingAverageSuffix`)}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,isAnimationActive:l,animationBegin:S.stagger*(t%5),animationDuration:S.slowDuration},`${e}_ma7`))]})})})]})});return(0,C.jsx)(h,{title:T(`charts.costByModelOverTime.title`),subtitle:E?T(`charts.costByModelOverTime.topDriver`,{model:E.model,total:d(E.total)}):T(`charts.costByModelOverTime.subtitle`),info:m.costByModelOverTime,className:`lg:col-span-2`,chartData:c,valueKey:`cost`,valueFormatter:d,expandedExtra:D,children:(0,C.jsx)(_,{children:l=>(0,C.jsx)(g,{variant:`line`,children:(0,C.jsx)(e,{width:`100%`,height:300,children:(0,C.jsxs)(i,{data:c,margin:x,children:[(0,C.jsx)(r,{strokeDasharray:`3 3`,stroke:b.grid,opacity:.3}),(0,C.jsx)(n,{dataKey:`date`,tickFormatter:u,stroke:b.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(t,{tickFormatter:e=>{let t=f(e);return t===null?``:d(t)},stroke:b.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(o,{content:(0,C.jsx)(y,{formatter:e=>d(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,C.jsx)(s,{content:(0,C.jsx)(v,{})}),w.map((e,t)=>(0,C.jsx)(a,{type:`monotone`,dataKey:e,stroke:p(e),name:e,dot:!1,strokeWidth:1.5,isAnimationActive:l,animationBegin:S.stagger*(t%5),animationDuration:S.duration,animationEasing:S.easing},e))]})})})})})}export{w as CostByModelOverTime};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,l as o,m as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-vKc6gXHZ.js";import{t as d}from"./useTranslation-BSl7t2D6.js";import{n as f,t as p}from"./formatters-yKppUXb3.js";import{t as m}from"./help-content-Bt5KCpWS.js";import{n as h,r as g,t as _}from"./ChartCard-CBUnItl-.js";import{t as v}from"./CustomTooltip-CBVU1pyK.js";import{n as y,r as b,t as x}from"./chart-theme-D5iCFDJg.js";var S=e(l()),C=u();function w({data:e}){let{t:l}=d(),[u,w]=(0,S.useState)(null),T=(0,S.useId)(),E=e=>`${T}-${e}`.replace(/:/g,``),D=Math.max(...e.map(e=>e.cost)),O=Math.min(...e.map(e=>e.cost)),k=e.findIndex(e=>e.cost===D),A=e.findIndex(e=>e.cost===O),j=e.filter(e=>e.day===`Sa`||e.day===`So`).reduce((e,t)=>e+t.cost,0),M=e.reduce((e,t)=>e+t.cost,0);return(0,C.jsx)(h,{title:l(`charts.costByWeekday.title`),subtitle:l(`charts.costByWeekday.subtitle`,{peak:e[k]?.day??`–`,low:e[A]?.day??`–`,share:`${(M>0?j/M*100:0).toFixed(0)}%`}),info:m.costByWeekday,chartData:e,valueKey:`cost`,valueFormatter:f,children:(0,C.jsx)(_,{children:d=>(0,C.jsx)(g,{variant:`bar`,children:(0,C.jsx)(r,{width:`100%`,height:300,children:(0,C.jsxs)(n,{data:e,margin:b,onMouseMove:e=>{e?.activeTooltipIndex!==void 0&&typeof e.activeTooltipIndex==`number`&&w(e.activeTooltipIndex)},onMouseLeave:()=>w(null),children:[(0,C.jsxs)(`defs`,{children:[(0,C.jsxs)(`linearGradient`,{id:E(`weekday`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:y.cost,stopOpacity:.9}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:y.cost,stopOpacity:.4})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayActive`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:y.cost,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:y.cost,stopOpacity:.6})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayPeak`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:.5})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayLow`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.8}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.3})]})]}),(0,C.jsx)(s,{strokeDasharray:`3 3`,stroke:y.grid,opacity:.3}),(0,C.jsx)(o,{dataKey:`day`,stroke:y.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(i,{tickFormatter:e=>{let t=p(e);return t===null?``:f(t)},stroke:y.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(c,{content:(0,C.jsx)(v,{formatter:e=>f(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,C.jsx)(a,{dataKey:`cost`,radius:[4,4,0,0],name:l(`charts.costByWeekday.averageCost`),isAnimationActive:d,animationBegin:x.stagger,animationDuration:x.duration,animationEasing:x.easing,children:e.map((e,n)=>{let r=`url(#${E(`weekday`)})`;return u===n?r=`url(#${E(`weekdayActive`)})`:n===k?r=`url(#${E(`weekdayPeak`)})`:n===A&&(r=`url(#${E(`weekdayLow`)})`),(0,C.jsx)(t,{fill:r},n)})})]})})})})})}export{w as CostByWeekday};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,p as o,t as s,v as c,w as l,y as u}from"./charts-vendor-CiBqdKXh.js";import{a as d}from"./motion-vendor-vKc6gXHZ.js";import{t as f}from"./useTranslation-BSl7t2D6.js";import{a as p,n as m,t as h}from"./formatters-yKppUXb3.js";import{a as g}from"./icons-vendor-CIvT_-Pb.js";import{t as _}from"./MetricCard-Drluz0b9.js";import{t as v}from"./formatted-value-rO0EpKbc.js";import{t as y}from"./help-content-Bt5KCpWS.js";import{n as b,r as x,t as S}from"./ChartCard-CBUnItl-.js";import{t as C}from"./ChartLegend-B64cJdDI.js";import{t as w}from"./CustomTooltip-CBVU1pyK.js";import{n as T,r as E,t as D}from"./chart-theme-D5iCFDJg.js";import{r as O}from"./calculations-GOdNqKo6.js";var k=e(l()),A=d();function j({data:e,viewMode:l=`daily`}){let{t:d}=f(),{chartData:j,forecastTotal:M,currentMonthTotal:N,dailyAvgTrend:P,projectedDailyBurn:F,remainingDays:I,confidence:L,confidenceColor:R}=(0,k.useMemo)(()=>{let t=O(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(l!==`daily`){let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)).reduce((e,t)=>e+t.totalCost,0),n=e.length>0?t/e.length:0;return e.length===0?(0,A.jsx)(`div`,{className:`space-y-4`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border/50 bg-card/80 p-6 text-center`,children:[(0,A.jsx)(g,{className:`mb-3 h-8 w-8 text-muted-foreground/20`}),(0,A.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:d(`forecast.noData`)})]})}):(0,A.jsx)(`div`,{className:`space-y-4`,children:(0,A.jsx)(_,{label:d(l===`monthly`?`forecast.avgMonthlyCost`:`forecast.avgYearlyCost`),value:(0,A.jsx)(v,{value:n,type:`currency`}),subtitle:d(`forecast.totalOverPeriods`,{total:m(t),count:e.length,unit:d(l===`monthly`?`periods.months`:`periods.years`)}),icon:(0,A.jsx)(g,{className:`h-4 w-4`})})})}return j.length===0?(0,A.jsx)(`div`,{className:`space-y-4`,children:(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border/50 bg-card/80 p-6 text-center`,children:[(0,A.jsx)(g,{className:`mb-3 h-8 w-8 text-muted-foreground/20`}),(0,A.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:d(`forecast.noForecast`)}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:d(`forecast.requiresTwoDays`)})]})}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(_,{label:(0,A.jsxs)(`span`,{className:`flex items-center gap-2`,children:[d(`forecast.monthEndForecast`),` `,(0,A.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] font-semibold tracking-wider uppercase ${R}`,children:d(`forecast.${L}`)})]}),value:(0,A.jsx)(v,{value:M,type:`currency`}),subtitle:`${d(`forecast.soFar`,{value:m(N)})} · ${d(`forecast.remainingDays`,{count:I})}${P?` · ${d(`forecast.projectedPerDay`,{value:m(F)})}`:``}`,icon:(0,A.jsx)(g,{className:`h-4 w-4`}),trend:P&&P.change!==0?{value:P.change,label:d(`forecast.vsLastWeek`)}:null}),(0,A.jsx)(b,{title:d(`forecast.chartTitle`),subtitle:d(`forecast.chartSubtitle`),summary:(0,A.jsx)(v,{value:M,type:`currency`}),info:y.forecast,chartData:j,valueKey:`cost`,valueFormatter:m,children:(0,A.jsx)(S,{children:e=>(0,A.jsx)(x,{variant:`line`,children:(0,A.jsx)(t,{width:`100%`,height:250,children:(0,A.jsxs)(s,{data:j,margin:E,children:[(0,A.jsx)(`defs`,{children:(0,A.jsxs)(`linearGradient`,{id:`forecast-cost-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,A.jsx)(`stop`,{offset:`0%`,stopColor:T.cost,stopOpacity:.3}),(0,A.jsx)(`stop`,{offset:`100%`,stopColor:T.cost,stopOpacity:0})]})}),(0,A.jsx)(a,{strokeDasharray:`3 3`,stroke:T.grid}),(0,A.jsx)(i,{dataKey:`date`,tickFormatter:p,stroke:T.axis,fontSize:11,tickLine:!1}),(0,A.jsx)(n,{tickFormatter:e=>{let t=h(e);return t===null?``:m(t)},stroke:T.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,A.jsx)(c,{content:(0,A.jsx)(w,{formatter:e=>m(e)})}),(0,A.jsx)(u,{content:(0,A.jsx)(C,{})}),(0,A.jsx)(r,{type:`monotone`,dataKey:`lower`,stackId:`forecast-band`,stroke:`none`,fill:`transparent`,name:d(`forecast.lowerBound`)}),(0,A.jsx)(r,{type:`monotone`,dataKey:`band`,stackId:`forecast-band`,stroke:`none`,fill:T.cumulative,fillOpacity:.12,name:d(`forecast.uncertaintyBand`),isAnimationActive:e,animationBegin:D.stagger,animationDuration:D.duration}),(0,A.jsx)(r,{type:`monotone`,dataKey:`cost`,stroke:T.cost,fill:`url(#forecast-cost-grad)`,name:d(`forecast.actualCost`),strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:0,animationDuration:D.duration,animationEasing:D.easing}),(0,A.jsx)(o,{type:`monotone`,dataKey:`forecast`,stroke:T.cumulative,name:d(`forecast.projection`),dot:!1,strokeWidth:2,strokeDasharray:`6 3`,connectNulls:!0,isAnimationActive:e,animationBegin:D.stagger*2,animationDuration:D.slowDuration})]})})})})})]})}export{j as CostForecast};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,p as o,t as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-vKc6gXHZ.js";import{t as d}from"./useTranslation-BSl7t2D6.js";import{a as f,n as p,t as m}from"./formatters-yKppUXb3.js";import{t as h}from"./help-content-Bt5KCpWS.js";import{n as g,r as _,t as v}from"./ChartCard-CBUnItl-.js";import{t as y}from"./CustomTooltip-CBVU1pyK.js";import{n as b,r as x,t as S}from"./chart-theme-D5iCFDJg.js";import{r as C}from"./calculations-GOdNqKo6.js";var w=e(l()),T=u();function E({data:e,rawData:l}){let{t:u}=d(),E=(0,w.useId)().replace(/:/g,``),D=(0,w.useMemo)(()=>{if(e.length<3)return e;let t=e[e.length-1];if(!t?.date||!t.cumulative)return e;let n=C(l);if(!n)return e;let{currentMonth:r,daysInMonth:i,projectedDailyBurn:a}=n,o=n.elapsedDays;if(o>=i)return e;let s=t.cumulative+a*(i-o),c=`${r}-${String(i).padStart(2,`0`)}`;return[...e.map(e=>({...e,projected:void 0})),{...e[e.length-1],projected:t.cumulative},{date:c,cumulative:void 0,projected:s,cost:0,ma7:0}]},[e,l]),O=e[e.length-1]?.cumulative??0;return(0,T.jsx)(g,{title:u(`charts.cumulativeCost.title`),subtitle:u(`charts.cumulativeCost.total`,{value:p(O)}),info:h.cumulativeCost,chartData:e,valueKey:`cumulative`,valueFormatter:p,children:(0,T.jsx)(v,{children:e=>(0,T.jsx)(_,{variant:`line`,children:(0,T.jsx)(t,{width:`100%`,height:300,children:(0,T.jsxs)(s,{data:D,margin:x,children:[(0,T.jsx)(`defs`,{children:(0,T.jsxs)(`linearGradient`,{id:`${E}-cumulGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,T.jsx)(`stop`,{offset:`0%`,stopColor:b.cumulative,stopOpacity:.4}),(0,T.jsx)(`stop`,{offset:`60%`,stopColor:b.cumulative,stopOpacity:.1}),(0,T.jsx)(`stop`,{offset:`100%`,stopColor:b.cumulative,stopOpacity:0})]})}),(0,T.jsx)(a,{strokeDasharray:`3 3`,stroke:b.grid,opacity:.3}),(0,T.jsx)(i,{dataKey:`date`,tickFormatter:f,stroke:b.axis,fontSize:11,tickLine:!1}),(0,T.jsx)(n,{tickFormatter:e=>{let t=m(e);return t===null?``:p(t)},stroke:b.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,T.jsx)(c,{content:(0,T.jsx)(y,{formatter:e=>p(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,T.jsx)(r,{type:`monotone`,dataKey:`cumulative`,stroke:b.cumulative,fill:`url(#${E}-cumulGrad)`,name:u(`charts.cumulativeCost.cumulative`),strokeWidth:2,activeDot:{r:5,strokeWidth:2,stroke:b.cumulative,fill:`hsl(var(--background))`},dot:!1,isAnimationActive:e,animationBegin:0,animationDuration:S.duration,animationEasing:S.easing,connectNulls:!1}),(0,T.jsx)(o,{type:`monotone`,dataKey:`projected`,stroke:b.cumulative,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,name:u(`charts.cumulativeCost.projection`),connectNulls:!0,isAnimationActive:e,animationBegin:S.stagger,animationDuration:S.slowDuration})]})})})})})}export{E as CumulativeCost};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{t}from"./useTranslation-BSl7t2D6.js";var n=e();function r({active:e,payload:r,label:i,formatter:a,pinnedEntryNames:o=[],showComputedTotal:s=!0,hideZeroValues:c=!1}){let{t:l}=t();if(!e||!r?.length)return null;let u=e=>e.name.includes(`Ø`)||e.dataKey?.toString().includes(`MA7`)||e.dataKey?.toString().includes(`_ma7`),d=e=>o.includes(e.name),f=e=>!c||Math.abs(e.value??0)>1e-4,p=r.filter(e=>!u(e)&&!d(e)&&f(e)).sort((e,t)=>(t.value??0)-(e.value??0)),m=r.filter(e=>!u(e)&&d(e)&&f(e)),h=r.filter(e=>u(e)),g=p.reduce((e,t)=>e+(t.value??0),0),_=s&&p.length>=2,v=r[0]?.payload??{},y=p.length===1?p[0]:m.length===1?m[0]:null,b=y?v[`${y.dataKey}Prev`]:void 0,x=typeof b==`number`?b:null,S=y?h.find(e=>e.dataKey===`${y.dataKey}MA7`||e.dataKey===`${y.dataKey.toString().toLowerCase()}MA7`)??(h.length===1?h[0]:null):null,C=y&&x!==null?y.value-x:null,w=y&&S?y.value-S.value:null,T=l(`customTooltip.total`),E=l(`customTooltip.delta`);return(0,n.jsxs)(`div`,{className:`max-w-[280px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,n.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:i}),(0,n.jsxs)(`div`,{className:`space-y-1.5`,children:[p.map((e,t)=>{let r=_&&g>0?e.value/g*100:null;return(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value}),r!==null&&(0,n.jsxs)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:[r.toFixed(0),`%`]})]},t)}),_&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`font-medium text-muted-foreground`,children:[T,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(g,T):g}),(0,n.jsx)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:`100%`})]})]}),h.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),h.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2 opacity-70`,children:[(0,n.jsx)(`span`,{className:`h-0.5 w-2 shrink-0 border-t border-dashed`,style:{borderColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`ma-${t}`))]}),m.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),m.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`pinned-${t}`))]}),(C!==null||w!==null)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),C!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsPrevious`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[C>=0?`+`:``,a?a(C,E):C]})]}),w!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsAverage`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[w>=0?`+`:``,a?a(w,E):w]})]})]})]})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,l as o,m as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-vKc6gXHZ.js";import{i as d,t as f}from"./useTranslation-BSl7t2D6.js";import{d as p,h as m,l as h,n as g}from"./formatters-yKppUXb3.js";import{a as _,i as v,n as y,t as b}from"./card-h-Z9EWBl.js";import{t as x}from"./help-content-Bt5KCpWS.js";import{t as S}from"./InfoHeading-oi90uCR7.js";import{n as C,r as w,t as T}from"./chart-theme-D5iCFDJg.js";var E=e(l()),D=u();function O(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 k({active:e,payload:t}){let{t:n}=f();if(!e||!t?.length)return null;let r=t[0];return r?(0,D.jsxs)(`div`,{className:`max-w-[280px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,D.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:r.payload.label}),(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.interval`)}),(0,D.jsx)(`span`,{className:`font-mono font-medium`,children:r.payload.label})]}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.dataPoints`)}),(0,D.jsx)(`span`,{className:`font-mono font-medium`,children:h(r.value)})]})]})]}):null}function A({data:e,viewMode:l=`daily`}){let{t:u}=f(),A=(0,E.useId)().replace(/:/g,``),j=d(),M=(0,E.useMemo)(()=>{if(e.length<2)return[];let t=e.map(e=>e.totalCost),n=e.map(e=>e.requestCount),r=e.map(e=>e.requestCount>0?e.totalTokens/e.requestCount:0);return[{title:u(`charts.distribution.costPerPeriod`,{period:m(l)}),data:O(t,g)},{title:u(`charts.distribution.requestsPerPeriod`,{period:m(l)}),data:O(n,h)},{title:u(`charts.distribution.tokensPerRequest`),data:O(r,p)}]},[e,l,u]);return e.length<2?(0,D.jsxs)(b,{children:[(0,D.jsx)(v,{children:(0,D.jsx)(S,{info:x.distributionAnalysis,children:(0,D.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:u(`charts.distribution.title`)})})}),(0,D.jsx)(y,{children:(0,D.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground`,children:u(`charts.distribution.requiresData`)})})]}):(0,D.jsxs)(b,{children:[(0,D.jsx)(v,{children:(0,D.jsx)(S,{info:x.distributionAnalysis,children:(0,D.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:u(`charts.distribution.title`)})})}),(0,D.jsx)(y,{className:`space-y-5`,children:M.map((e,l)=>(0,D.jsx)(`div`,{children:(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e.title}),(0,D.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.data.length,` `,u(`charts.distribution.buckets`)]})]}),(0,D.jsx)(r,{width:`100%`,height:160,children:(0,D.jsxs)(n,{data:e.data,margin:w,children:[(0,D.jsx)(`defs`,{children:(0,D.jsxs)(`linearGradient`,{id:`${A}-distribution-${l}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:C.cost,stopOpacity:.9}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:C.cost,stopOpacity:.4})]})}),(0,D.jsx)(s,{strokeDasharray:`3 3`,stroke:C.grid,opacity:.25}),(0,D.jsx)(o,{dataKey:`label`,stroke:C.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,D.jsx)(i,{stroke:C.axis,fontSize:10,tickLine:!1,axisLine:!1,allowDecimals:!1}),(0,D.jsx)(c,{content:(0,D.jsx)(k,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,D.jsx)(a,{dataKey:`count`,radius:[6,6,0,0],fill:`url(#${A}-distribution-${l})`,isAnimationActive:!j,animationBegin:T.stagger*l,animationDuration:T.duration,children:e.data.map((n,r)=>(0,D.jsx)(t,{fill:`hsla(215, 70%, 55%, ${(.45+(e.data.length>1?r/(e.data.length-1):0)*.35).toFixed(2)})`},`${e.title}-${r}`))})]})})]})},e.title))})]})}export{A as DistributionAnalysis};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,b as n,g as r,i,v as ee,w as a}from"./charts-vendor-CiBqdKXh.js";import{a as o}from"./motion-vendor-vKc6gXHZ.js";import{a as s,t as te}from"./useTranslation-BSl7t2D6.js";import{d as c,i as ne,l,n as u,u as d}from"./formatters-yKppUXb3.js";import{U as re,W as ie}from"./icons-vendor-CIvT_-Pb.js";import{t as f}from"./button-D--hHeVj.js";import{c as ae,i as p,r as oe,t as m}from"./model-utils-BIvGAFGz.js";import{a as se,i as ce,n as le,r as ue,t as de}from"./dialog-C0AeNKs8.js";import{t as h}from"./formatted-value-rO0EpKbc.js";import{t as fe}from"./CustomTooltip-CBVU1pyK.js";var g=e(a()),_=o();function pe(e){return/^\d{4}$/.test(e)?`year`:/^\d{4}-\d{2}$/.test(e)?`month`:`day`}function v(e){return e.cacheReadTokens+e.cacheCreationTokens+e.inputTokens+e.outputTokens+e.thinkingTokens}function y(e,t){return t>0?e/(t/1e6):null}function b(e,t){return t>0?e/t:null}function x(e,t){if(t===null)return null;let n=e-t;return{absolute:n,percent:t===0?null:n/t*100}}function S(e,t,n=`–`){return e?e.absolute===0?`→ ${t(0)}`:`${e.absolute>0?`↑`:`↓`} ${t(Math.abs(e.absolute))}`:n}function C(e,t=`–`){return!e||e.percent===null?t:e.percent===0?`0.0%`:`${e.percent>0?`+`:``}${e.percent.toFixed(1)}%`}function me(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return e.isContentEditable||t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function he(e,t){return`${e}${t}`}function w({day:e,contextData:a=[],open:o,hasPrevious:w,hasNext:ge,currentIndex:_e,totalCount:ve,onPrevious:T,onNext:E,onClose:ye}){let{t:D}=te(),O=e?pe(e.date):`day`,k=(0,g.useMemo)(()=>[...a].sort((e,t)=>e.date.localeCompare(t.date)),[a]),A=(0,g.useMemo)(()=>e?k.findIndex(t=>t.date===e.date):-1,[e,k]),j=A>0?k[A-1]:null,M=A>0?k.slice(Math.max(0,A-7),A):[],N=w??A>0,P=ge??(A>=0&&A<k.length-1),be=_e??(A>=0?A+1:0),xe=ve??k.length,F=e?v(e):0,I=F>0,L=(0,g.useMemo)(()=>{if(!e)return[];let t=new Map;for(let n of e.modelBreakdowns){let e=ae(n.modelName),r=oe(n.modelName),i=t.get(e)??{provider:r,cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheCreate:0,thinking:0,requests:0};i.cost+=n.cost,i.tokens+=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens+n.thinkingTokens,i.input+=n.inputTokens,i.output+=n.outputTokens,i.cacheRead+=n.cacheReadTokens,i.cacheCreate+=n.cacheCreationTokens,i.thinking+=n.thinkingTokens,i.requests+=n.requestCount,t.set(e,i)}return Array.from(t.entries()).map(([t,n])=>({name:t,...n,costShare:e.totalCost>0?n.cost/e.totalCost*100:0,tokenShare:F>0?n.tokens/F*100:0,costPerMillion:y(n.cost,n.tokens),costPerRequest:b(n.cost,n.requests),tokensPerRequest:b(n.tokens,n.requests)})).sort((e,t)=>t.cost-e.cost)},[e,F]),R=(0,g.useMemo)(()=>{let t=new Map;for(let e of L){let n=t.get(e.provider)??{cost:0,tokens:0,requests:0,activeModels:new Set};n.cost+=e.cost,n.tokens+=e.tokens,n.requests+=e.requests,n.activeModels.add(e.name),t.set(e.provider,n)}return Array.from(t.entries()).map(([t,n])=>({provider:t,cost:n.cost,tokens:n.tokens,requests:n.requests,activeModels:n.activeModels.size,costShare:e&&e.totalCost>0?n.cost/e.totalCost*100:0})).sort((e,t)=>t.cost-e.cost)},[e,L]);if(!e)return null;let z=L.map(e=>({name:e.name,value:e.cost})),Se=I?e.cacheReadTokens/F*100:0,B=b(F,e.requestCount),V=b(e.totalCost,e.requestCount),H=y(e.totalCost,F),U=e.requestCount>0||e.modelBreakdowns.some(e=>e.requestCount>0)||a.some(e=>e.requestCount>0),Ce=[...a].sort((e,t)=>t.totalCost-e.totalCost).findIndex(t=>t.date===e.date)+1,we=U?[...a].sort((e,t)=>t.requestCount-e.requestCount).findIndex(t=>t.date===e.date)+1:0,W=M.length>0?M.reduce((e,t)=>e+t.totalCost,0)/M.length:null,G=M.length>0?M.reduce((e,t)=>e+t.requestCount,0)/M.length:null,K=M.length>0?M.reduce((e,t)=>e+v(t),0)/M.length:null,q=M.length>0?y(M.reduce((e,t)=>e+t.totalCost,0),M.reduce((e,t)=>e+v(t),0)):null,J=he(M.length>0?M.length:7,D(`drillDown.windowUnit.${O}`)),Te=j?v(j):null,Y=j?y(j.totalCost,v(j)):null,X=L[0]??null,Z=U?L.reduce((e,t)=>!e||t.requests>e.requests?t:e,null):null,Q=L.reduce((e,t)=>!e||t.tokens>e.tokens?t:e,null),$=L.reduce((e,t)=>t.costPerMillion===null?e:!e||e.costPerMillion===null||t.costPerMillion>e.costPerMillion?t:e,null),Ee=e.totalCost>0?L.slice(0,3).reduce((e,t)=>e+t.cost,0)/e.totalCost*100:0,De=[{label:D(`common.tokens`),value:(0,_.jsx)(h,{value:F,type:`tokens`})},{label:`$/1M`,value:H===null?`–`:(0,_.jsx)(h,{value:H,type:`currency`})},{label:D(`common.requests`),value:(0,_.jsx)(h,{value:e.requestCount,type:`number`})},{label:D(`common.models`),value:l(L.length)},{label:D(`drillDown.activeProviders`),value:l(R.length)},{label:D(`drillDown.tokensPerRequest`),value:B===null?`–`:(0,_.jsx)(h,{value:B,type:`tokens`})},{label:D(`drillDown.costPerRequest`),value:V===null?`–`:(0,_.jsx)(h,{value:V,type:`currency`})},{label:D(`drillDown.cacheRate`),value:(0,_.jsx)(h,{value:Se,type:`percent`})},{label:D(`common.thinking`),value:(0,_.jsx)(h,{value:e.thinkingTokens,type:`tokens`})},{label:D(`drillDown.costRank`),value:Ce>0?`#${Ce}`:`–`},{label:D(`drillDown.requestRank`),value:we>0?`#${we}`:`–`},{label:D(`drillDown.coverage`),value:(e._aggregatedDays??1)>1?D(`drillDown.coverageDays`,{count:e._aggregatedDays??1}):D(`drillDown.singlePeriod`,{period:D(`periods.${O}`)})}],Oe=[{label:D(`drillDown.costVsPrevious`),primary:S(x(e.totalCost,j?.totalCost??null),u),secondary:C(x(e.totalCost,j?.totalCost??null))},{label:D(`drillDown.tokensVsPrevious`),primary:S(x(F,Te),c),secondary:C(x(F,Te))},{label:D(`drillDown.requestsVsPrevious`),primary:S(x(e.requestCount,j?.requestCount??null),e=>l(Math.round(e))),secondary:C(x(e.requestCount,j?.requestCount??null))},{label:D(`drillDown.costPerMillionVsAverageWindow`,{window:J}),primary:S(H===null?null:x(H,q),u),secondary:q===null?`–`:u(q)},{label:D(`drillDown.costVsAverageWindow`,{window:J}),primary:S(x(e.totalCost,W),u),secondary:W===null?`–`:u(W)},{label:D(`drillDown.requestsVsAverageWindow`,{window:J}),primary:S(x(e.requestCount,G),e=>l(Math.round(e))),secondary:G===null?`–`:l(Math.round(G))},{label:D(`drillDown.tokensVsAverageWindow`,{window:J}),primary:S(x(F,K),c),secondary:K===null?`–`:c(K)},{label:D(`drillDown.costPerMillionVsPrevious`),primary:S(H===null?null:x(H,Y),u),secondary:Y===null?`–`:u(Y)}],ke=[{id:`cacheRead`,value:e.cacheReadTokens,color:`hsl(160, 50%, 42%)`,label:D(`drillDown.tokenSegments.cacheRead`)},{id:`cacheWrite`,value:e.cacheCreationTokens,color:`hsl(262, 60%, 55%)`,label:D(`drillDown.tokenSegments.cacheWrite`)},{id:`input`,value:e.inputTokens,color:`hsl(340, 55%, 52%)`,label:D(`common.input`)},{id:`output`,value:e.outputTokens,color:`hsl(35, 80%, 52%)`,label:D(`common.output`)},{id:`thinking`,value:e.thinkingTokens,color:`hsl(12, 78%, 56%)`,label:D(`common.thinking`)}],Ae=[{label:D(`drillDown.topCostModel`),title:X?.name??`–`,value:X?d(X.costShare):`–`},{label:D(`drillDown.topRequestModel`),title:Z?.name??`–`,value:Z&&Z.requests>0?D(`drillDown.requestCountShort`,{count:Z.requests}):`–`},{label:D(`drillDown.topTokenModel`),title:Q?.name??`–`,value:Q?d(Q.tokenShare):`–`},{label:D(`drillDown.priciestPerMillionModel`),title:$?.name??`–`,value:$?.costPerMillion!==null&&$?.costPerMillion!==void 0?(0,_.jsx)(h,{value:$.costPerMillion,type:`currency`}):`–`},{label:D(`drillDown.topCostShare`),title:X?d(X.costShare):`–`,value:X?.provider??`–`},{label:D(`drillDown.topThreeCostShare`),title:d(Ee),value:D(`drillDown.modelCount`,{count:Math.min(L.length,3)})}],je=D(O===`day`?`drillDown.previousDay`:`drillDown.previousPeriod`),Me=D(O===`day`?`drillDown.nextDay`:`drillDown.nextPeriod`);return(0,_.jsx)(de,{open:o,onOpenChange:e=>!e&&ye(),children:(0,_.jsxs)(le,{className:`max-h-[85vh] max-w-5xl overflow-y-auto`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||me(e.target)||(e.key===`ArrowLeft`&&N&&(e.preventDefault(),T?.()),e.key===`ArrowRight`&&P&&(e.preventDefault(),E?.()))},children:[(0,_.jsxs)(ce,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(se,{children:[ne(e.date,`long`),` — `,u(e.totalCost)]}),(0,_.jsx)(ue,{children:D(`drillDown.description`,{periodType:D(`periods.${O}`)})})]}),(0,_.jsxs)(`div`,{className:`flex flex-col items-stretch gap-2 sm:items-end`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:T,disabled:!N,"aria-label":je,children:[(0,_.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:je})]}),(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:E,disabled:!P,"aria-label":Me,children:[(0,_.jsx)(`span`,{children:Me}),(0,_.jsx)(re,{className:`h-4 w-4`,"aria-hidden":`true`})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground sm:justify-end`,children:[(0,_.jsx)(`span`,{children:D(`drillDown.position`,{current:be,total:xe})}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,_.jsx)(`span`,{children:D(`drillDown.keyboardHint`)})]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-1 text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.periodType`,{period:D(`periods.${O}`)})}),(e._aggregatedDays??1)>1&&(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.coverageDays`,{count:e._aggregatedDays??1})})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.overview`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:De.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-muted/30 p-3 text-center`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-mono text-sm font-medium`,children:e.value})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.benchmarks`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Oe.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-medium`,children:e.primary}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.secondary})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.modelBreakdown`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.modelCount`,{count:L.length})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-2`,children:Ae.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-medium`,children:e.title}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.value})]},e.label))}),z.length>0&&(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.costShareByModel`)}),(0,_.jsx)(n,{width:`100%`,height:220,children:(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{data:z,cx:`50%`,cy:`50%`,innerRadius:46,outerRadius:84,paddingAngle:2,dataKey:`value`,children:z.map(e=>(0,_.jsx)(t,{fill:m(e.name)},e.name))}),(0,_.jsx)(ee,{content:(0,_.jsx)(fe,{formatter:e=>u(e)})})]})})]})]}),(0,_.jsx)(`div`,{className:`space-y-3`,children:L.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,_.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,p(e.provider)),children:e.provider})]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.requestCountShort`,{count:e.requests})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokenShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.tokenShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerMillion===null?`–`:(0,_.jsx)(h,{value:e.costPerMillion,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerRequest===null?`–`:(0,_.jsx)(h,{value:e.costPerRequest,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokensPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.tokensPerRequest===null?`–`:(0,_.jsx)(h,{value:e.tokensPerRequest,type:`tokens`})})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-[11px] sm:grid-cols-5`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.input`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.input)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.output`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.output)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheRead`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheRead)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheWrite`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheCreate)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.thinking`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.thinking)})]})]})]},e.name))})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.providerSummary`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.providerCount`,{count:R.length})})]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:R.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,p(e.provider)),children:e.provider}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.activeModelsCount`,{count:e.activeModels})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]})]})]},e.provider))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.tokenDistribution`)}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`flex h-3 overflow-hidden rounded-full`,children:I&&ke.map(e=>{let t=(e.value/F*100).toFixed(1),n=`${e.label}: ${c(e.value)} (${t}%)`;return(0,_.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${e.value/F*100}%`,backgroundColor:e.color},title:n,"aria-label":n},e.id)})}),(0,_.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 text-xs sm:grid-cols-2 lg:grid-cols-5`,children:ke.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:e.color}}),e.label]}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.value)}),(0,_.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:I?d(e.value/F*100):`–`})]},e.id))})]})]})]})})}export{w as DrillDownModal};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{J as i,K as a,T as o}from"./icons-vendor-CIvT_-Pb.js";import{a as s,i as c,n as l,t as u}from"./constants-jyhBMReu.js";import{a as d,i as f,n as p,r as m,t as h}from"./dialog-C0AeNKs8.js";import{a as g,i as _,n as v,r as y,t as b}from"./help-content-Bt5KCpWS.js";var x=e(t()),S=n(),C=[`requestQuality`,`providerLimits`,`concentrationRisk`],w=[`providerEfficiency`,`modelEfficiency`,`recentDays`];function T({open:e,onOpenChange:t}){let{t:n}=r(),T=g(),E=(0,x.useMemo)(()=>Object.keys(b),[]),D=(0,x.useMemo)(()=>Object.keys(_),[]),O=(0,x.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]),k=(0,x.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]),A=(0,x.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]),j=(0,x.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,S.jsx)(h,{open:e,onOpenChange:t,children:(0,S.jsxs)(p,{className:`max-h-[80vh] max-w-lg overflow-y-auto`,children:[(0,S.jsxs)(f,{children:[(0,S.jsx)(d,{className:`text-lg font-semibold`,children:n(`header.help`)}),(0,S.jsx)(m,{children:n(`commandPalette.description`)})]}),(0,S.jsxs)(`section`,{className:`rounded-lg border border-border/60 bg-muted/40 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`helpPanel.projectLinks.title`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`helpPanel.projectLinks.description`,{version:s})})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,S.jsx)(`a`,{href:c,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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.npm`)}),(0,S.jsx)(`a`,{href:l,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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.github`)}),(0,S.jsx)(`a`,{href:u,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:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.issues`)})]})]}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`header.help`)})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:T.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-foreground`,children:e.description}),(0,S.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,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`dashboard.metrics.title`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:Object.entries(y).map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:O[e]??e}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.chartsAndFeatures`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:E.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:k[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:b[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.dashboardSectionsTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:D.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:A[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.featuresTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:C.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.tablesTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:w.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]})]})})}export{T as HelpPanel};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{a as t,t as n}from"./useTranslation-BSl7t2D6.js";import{v as r,x as i,y as a}from"./formatters-yKppUXb3.js";import{E as o}from"./icons-vendor-CIvT_-Pb.js";var s=e();function c({text:e,className:c}){let{t:l}=n();return(0,s.jsxs)(r,{children:[(0,s.jsx)(i,{asChild:!0,children:(0,s.jsx)(`button`,{type:`button`,"aria-label":l(`common.showInfo`),"data-info-button":`true`,className:t(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,c),children:(0,s.jsx)(o,{className:`h-3.5 w-3.5`})})}),(0,s.jsx)(a,{side:`top`,className:`max-w-xs text-xs`,children:e})]})}export{c as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{a as t}from"./useTranslation-BSl7t2D6.js";import{t as n}from"./InfoButton-CTgLGzb9.js";var r=e();function i({children:e,info:i,className:a}){return(0,r.jsxs)(`div`,{className:t(`flex min-w-0 items-center gap-2`,a),children:[e,i&&(0,r.jsx)(n,{text:i,className:`shrink-0`})]})}export{i as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{a as t}from"./useTranslation-BSl7t2D6.js";import{t as n}from"./card-h-Z9EWBl.js";import{t as r}from"./InfoButton-CTgLGzb9.js";var i=e();function a({label:e,value:a,subtitle:o,icon:s,trend:c,info:l,className:u}){let d=c&&c.value>0?`bg-rose-500/14 text-rose-700 dark:bg-rose-500/12 dark:text-rose-300`:`bg-emerald-500/14 text-emerald-700 dark:bg-emerald-500/12 dark:text-emerald-300`;return(0,i.jsxs)(n,{className:t(`flex min-h-[122px] flex-col gap-1 p-4 transition-transform duration-200 hover:-translate-y-0.5 hover:shadow-lg motion-reduce:transform-none motion-reduce:transition-none`,u),children:[(0,i.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,i.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1 text-xs leading-tight font-medium text-balance text-muted-foreground`,children:[e,l&&(0,i.jsx)(r,{text:l})]}),s&&(0,i.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:s})]}),(0,i.jsx)(`div`,{className:`text-2xl leading-none font-bold tracking-tight`,children:a}),(0,i.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-2`,children:[o&&(0,i.jsx)(`span`,{className:`text-xs text-pretty text-muted-foreground`,children:o}),c&&c.value!==0&&(0,i.jsxs)(`span`,{className:t(`inline-flex items-center gap-0.5 rounded-md px-1.5 py-0.5 text-[10px] font-semibold`,d),children:[c.value>0?`↑`:`↓`,Math.abs(c.value).toFixed(1),`%`,c.label&&` ${c.label}`]})]})]})}export{a as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-yKppUXb3.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d,n as f,r as p,t as m}from"./model-utils-BIvGAFGz.js";import{a as h,i as g,n as _,t as v}from"./card-h-Z9EWBl.js";import{t as y}from"./formatted-value-rO0EpKbc.js";import{n as b}from"./help-content-Bt5KCpWS.js";import{t as x}from"./InfoHeading-oi90uCR7.js";var S=e(t()),C=n();function w({modelCosts:e,totalCost:t,viewMode:n=`daily`}){let{t:w}=i(),[T,E]=(0,S.useState)(`cost`),[D,O]=(0,S.useState)(!1),k=(0,S.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]),A=(0,S.useMemo)(()=>k.reduce((e,t)=>e+t.requests,0),[k]),j=(0,S.useMemo)(()=>k.map(e=>({...e,requestShare:A>0?e.requests/A*100:0})),[k,A]),M=(0,S.useMemo)(()=>[...j].sort((e,t)=>{let n=e[T]-t[T];return D?n:-n}),[j,D,T]),N=M[0]??null,P=(0,S.useMemo)(()=>[...k].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[k]),F=e=>{e===T?O(!D):(E(e),O(!1))},I=e=>T===e?D?`ascending`:`descending`:`none`,L=({label:e,field:t})=>(0,C.jsx)(`th`,{"aria-sort":I(t),className:r(`px-3 py-2 text-right text-xs font-medium`,T===t?`text-foreground`:`text-muted-foreground`),children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>F(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,C.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,T===t&&`text-primary`)})]})});return(0,C.jsxs)(v,{children:[(0,C.jsx)(g,{children:(0,C.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,C.jsx)(x,{info:b.modelEfficiency,children:(0,C.jsx)(h,{className:`text-sm font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.title`)})}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.count`,{count:k.length})})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModel`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?w(`tables.modelEfficiency.share`,{value:l(N.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.mostEfficient`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:P?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:P?w(`tables.modelEfficiency.share`,{value:l(P.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.totalRequests`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k.length>0?w(`tables.modelEfficiency.perModel`,{value:(A/k.length).toFixed(0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModelTokens`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?a(N.tokens):`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?`${N.days} ${s(n,!0)}`:`–`})]})]})]})}),(0,C.jsxs)(_,{children:[(0,C.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:M.map(e=>(0,C.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`truncate font-medium`,children:e.name})]}),(0,C.jsx)(`div`,{className:`mt-1 inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium text-muted-foreground`,children:p(e.name)})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.share`,{value:l(e.share,1)})})]})]}),(0,C.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokens`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerMillion`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`common.requests`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.requests)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokensPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokensPerRequest)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:`Cache %`}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,C.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,C.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,C.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.model`)}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cost`),field:`cost`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokens`),field:`tokens`}),(0,C.jsx)(L,{label:`$/1M`,field:`costPerMillion`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.shareShort`),field:`share`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.req`),field:`requests`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.reqShare`),field:`requestShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.costPerReq`),field:`costPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokensPerReq`),field:`tokensPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cacheShare`),field:`cacheShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.thinkingShare`),field:`thinkingShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.avgPerUnit`,{unit:o(n)}),field:`costPerDay`}),(0,C.jsx)(L,{label:s(n,!0),field:`days`})]})}),(0,C.jsx)(`tbody`,{children:M.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,C.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,C.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,C.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,d(p(e.name))),children:p(e.name)})]})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.tokens,type:`tokens`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})}),(0,C.jsxs)(`td`,{className:`relative px-3 py-2.5 text-right font-mono tabular-nums`,children:[(0,C.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm transition-all duration-500`,style:{width:`${e.share}%`,backgroundColor:f(e.name,.16)}}),(0,C.jsx)(`span`,{className:`relative`,children:l(e.share)})]}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.requestShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokensPerRequest)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.thinkingShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerDay,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:e.days})]},e.name))})]})})]})]})}export{w as ModelEfficiency};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,n as o,v as s,w as c}from"./charts-vendor-CiBqdKXh.js";import{a as l}from"./motion-vendor-vKc6gXHZ.js";import{t as u}from"./useTranslation-BSl7t2D6.js";import{a as d,t as f,u as p}from"./formatters-yKppUXb3.js";import{c as m,t as h}from"./model-utils-BIvGAFGz.js";import{t as g}from"./help-content-Bt5KCpWS.js";import{n as _,r as v,t as y}from"./ChartCard-CBUnItl-.js";import{n as b,r as x,t as S}from"./chart-theme-D5iCFDJg.js";var C=e(c()),w=l();function T({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:`rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,w.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,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:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,w.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:p(e.value)})]},t))})]})}function E({data:e}){let{t:c}=u(),{chartData:l,models:E}=(0,C.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(m(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=m(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 l.length<3||E.length<2?null:(0,w.jsx)(_,{title:c(`charts.modelMix.title`),subtitle:c(`charts.modelMix.subtitle`),info:g.modelMix,children:(0,w.jsx)(y,{children:e=>(0,w.jsx)(v,{variant:`line`,children:(0,w.jsx)(t,{width:`100%`,height:250,children:(0,w.jsxs)(o,{data:l,margin:x,stackOffset:`none`,children:[(0,w.jsx)(`defs`,{children:E.map(e=>{let t=h(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)(a,{strokeDasharray:`3 3`,stroke:b.grid,opacity:.3}),(0,w.jsx)(i,{dataKey:`date`,tickFormatter:d,stroke:b.axis,fontSize:11,tickLine:!1}),(0,w.jsx)(n,{tickFormatter:e=>{let t=f(e);return t===null?``:p(Math.round(t),0)},stroke:b.axis,fontSize:11,tickLine:!1,axisLine:!1,domain:[0,100],ticks:[0,25,50,75,100]}),(0,w.jsx)(s,{content:(0,w.jsx)(T,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),E.map((t,n)=>(0,w.jsx)(r,{type:`monotone`,dataKey:t,stackId:`1`,stroke:h(t),strokeWidth:.5,strokeOpacity:.6,fill:`url(#${`mix-grad-${t.replace(/[\s.]/g,`-`)}`})`,name:t,isAnimationActive:e,animationBegin:S.stagger*(n%5),animationDuration:S.duration,animationEasing:S.easing},t))]})})})})})}export{E as ModelMix};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{d as i,n as a,u as o}from"./formatters-yKppUXb3.js";import{nt as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-D--hHeVj.js";import{a as l,i as u,n as d,t as f}from"./card-h-Z9EWBl.js";import{t as p}from"./help-content-Bt5KCpWS.js";import{t as m}from"./InfoHeading-oi90uCR7.js";import{i as h}from"./calculations-GOdNqKo6.js";var g=e(t()),_=n();function v(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 y({data:e}){let{t}=r(),[n,y]=(0,g.useState)(`week`),{periodA:b,periodB:x,labelA:S,labelB:C}=(0,g.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]),w=(0,g.useMemo)(()=>h(b),[b]),T=(0,g.useMemo)(()=>h(x),[x]);if(e.length<7)return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})})}),(0,_.jsx)(d,{children:(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`comparison.notEnoughData`)}),(0,_.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:t(`comparison.requiresDays`,{count:e.length})})]})})]});let E=x.length>0,D=e=>E?e:`–`,O=[{label:t(`comparison.cost`),a:a(w.totalCost),b:D(a(T.totalCost)),delta:v(w.totalCost,T.totalCost)},{label:t(`comparison.tokens`),a:i(w.totalTokens),b:D(i(T.totalTokens)),delta:v(w.totalTokens,T.totalTokens)},{label:`$/1M`,a:`$${w.costPerMillion.toFixed(2)}`,b:D(`$${T.costPerMillion.toFixed(2)}`),delta:v(w.costPerMillion,T.costPerMillion)},{label:t(`comparison.avgPerDay`),a:a(w.avgDailyCost),b:D(a(T.avgDailyCost)),delta:v(w.avgDailyCost,T.avgDailyCost)},{label:t(`comparison.cacheRate`),a:o(w.cacheHitRate),b:D(o(T.cacheHitRate)),delta:v(w.cacheHitRate,T.cacheHitRate,!0)},{label:t(`comparison.days`),a:String(w.activeDays),b:D(String(T.activeDays)),delta:v(w.activeDays,T.activeDays)}];return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})}),(0,_.jsxs)(`div`,{className:`flex gap-1`,children:[(0,_.jsx)(c,{variant:n===`week`?`default`:`outline`,size:`sm`,onClick:()=>y(`week`),className:`h-7 text-xs`,children:t(`comparison.week`)}),(0,_.jsx)(c,{variant:n===`month`?`default`:`outline`,size:`sm`,onClick:()=>y(`month`),className:`h-7 text-xs`,children:t(`comparison.month`)})]})]})}),(0,_.jsx)(d,{children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,_.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:t(`comparison.metric`)}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:C}),(0,_.jsx)(`th`,{className:`w-8 px-2 py-2 text-center text-xs text-muted-foreground`}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:S}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground`,children:t(`comparison.delta`)})]})}),(0,_.jsx)(`tbody`,{children:O.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-border/50`,children:[(0,_.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.label}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono`,children:e.b}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,_.jsx)(s,{className:`inline h-3 w-3 text-muted-foreground`})}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono font-medium`,children:e.a}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right`,children:e.delta.hasData?(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-mono text-xs font-medium ${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,o(e.delta.value)]}):`–`})]},e.label))})]})})})]})}export{y as PeriodComparison};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-yKppUXb3.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d}from"./model-utils-BIvGAFGz.js";import{a as f,i as p,n as m,t as h}from"./card-h-Z9EWBl.js";import{t as g}from"./formatted-value-rO0EpKbc.js";import{n as _}from"./help-content-Bt5KCpWS.js";import{t as v}from"./InfoHeading-oi90uCR7.js";var y=e(t()),b=n();function x({providerMetrics:e,totalCost:t,viewMode:n=`daily`}){let{t:x}=i(),[S,C]=(0,y.useState)(`cost`),[w,T]=(0,y.useState)(!1),E=(0,y.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]),D=(0,y.useMemo)(()=>[...E].sort((e,t)=>{let n=e[S]-t[S];return w?n:-n}),[E,w,S]),O=D[0]??null,k=(0,y.useMemo)(()=>[...E].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[E]),A=(0,y.useMemo)(()=>E.reduce((e,t)=>e+t.requests,0),[E]),j=e=>{S===e?T(!w):(C(e),T(!1))},M=e=>S===e?w?`ascending`:`descending`:`none`,N=({label:e,field:t})=>(0,b.jsx)(`th`,{"aria-sort":M(t),className:r(`px-3 py-2 text-right text-xs font-medium`,S===t?`text-foreground`:`text-muted-foreground`),children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>j(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,b.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,S===t&&`text-primary`)})]})});return(0,b.jsxs)(h,{children:[(0,b.jsxs)(p,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(v,{info:_.providerEfficiency,children:(0,b.jsx)(f,{className:`text-sm font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.title`)})}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.count`,{count:E.length})})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.leadProvider`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?x(`tables.providerEfficiency.share`,{value:l(O.share,0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.mostEfficient`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:k?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k?`${k.costPerMillion.toFixed(2)} $/1M`:`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.totalRequests`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:E.length>0?x(`tables.providerEfficiency.perProvider`,{value:(A/E.length).toFixed(0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.avgPerUnit`,{unit:o(n)})}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?(0,b.jsx)(g,{value:O.cost/Math.max(O.days,1),type:`currency`}):`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?`${O.days} ${s(n,!0)}`:`–`})]})]})]}),(0,b.jsxs)(m,{children:[(0,b.jsx)(`div`,{className:`mb-4 grid gap-2 md:hidden`,children:D.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name}),(0,b.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.share`,{value:l(e.share,1)})})]}),(0,b.jsxs)(`div`,{className:`text-right`,children:[(0,b.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[c(e.requests),` `,x(`tables.providerEfficiency.req`)]})]})]}),(0,b.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.tokens`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerReq`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerMillion`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.cacheShare`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,b.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,b.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.provider`)}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cost`),field:`cost`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.shareShort`),field:`share`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.req`),field:`requests`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.tokens`),field:`tokens`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerReq`),field:`costPerRequest`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerMillion`),field:`costPerMillion`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cacheShare`),field:`cacheShare`})]})}),(0,b.jsx)(`tbody`,{children:D.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,b.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.share,1)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokens)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)})]},e.name))})]})})]})]})}export{x as ProviderEfficiency};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,h as i,l as a,m as o,p as s,t as c,v as l,w as u,y as d}from"./charts-vendor-CiBqdKXh.js";import{a as f,r as p,t as m}from"./motion-vendor-vKc6gXHZ.js";import{t as h}from"./useTranslation-BSl7t2D6.js";import{c as g,n as _,r as v,t as y}from"./formatters-yKppUXb3.js";import{i as b}from"./i18n-C88wS2Uy.js";import{L as x,a as S,i as C,m as w}from"./icons-vendor-CIvT_-Pb.js";import{a as T}from"./model-utils-BIvGAFGz.js";import{n as E,t as D}from"./card-h-Z9EWBl.js";import{i as O,t as k}from"./help-content-Bt5KCpWS.js";import{t as A}from"./section-header-DbV45zH5.js";import{n as j,r as M,t as N}from"./ChartCard-CBUnItl-.js";import{t as P}from"./ChartLegend-B64cJdDI.js";import{n as F,r as I,t as L}from"./chart-theme-D5iCFDJg.js";import{n as R,r as z}from"./provider-limits-5e1fUwPl.js";var B=e(u()),V=f();function H(e){return e.riskStatus===`limit`?b.t(`limits.statuses.limitExceeded`):e.riskStatus===`warning`?b.t(`limits.statuses.budgetTight`):e.riskStatus===`ok`?b.t(`limits.statuses.budgetStable`):b.t(`limits.statuses.noLimit`)}function U(e){return e.hasSubscription?e.subscriptionStatus===`gain`?b.t(`limits.statuses.subscriptionPaysOff`):b.t(`limits.statuses.belowSubscription`):b.t(`limits.statuses.noSubscription`)}function W(e,t){return e.monthlyLimit>0?b.t(`limits.badge.limit`,{value:e.utilization?.toFixed(0)??`0`}):e.hasSubscription?b.t(`limits.badge.subscription`,{value:Math.min(t,999).toFixed(0)}):b.t(`limits.badge.open`)}function G(e){let t=Number(Array.isArray(e)?e[0]??0:e??0);return Number.isFinite(t)?t:0}function K({data:e,providers:u,limits:f,selectedMonth:b}){let{t:K}=h(),q=(0,B.useRef)(null),J=m(q,{once:!0,amount:.2}),{rows:Y,focusMonth:X,timelineData:Z,atLimitCount:Q,nearLimitCount:$,subscriptionTotal:ee,subscriptionGainTotal:te}=(0,B.useMemo)(()=>{let{months:t,monthMap:n,providerTotals:r}=R(e),i=z(e),a=b??i,o=u.map(e=>{let t=f[e],i=a?n.get(a)?.get(e)??0:0,o=r.get(e)??0,s=t?.monthlyLimit??0,c=!!t?.hasSubscription,l=c?t?.subscriptionPrice??0:0,u=s>0?Math.max(i-s,0):0,d=s>0?Math.max(s-i,0):null,p=s>0?i/s*100:null,m=c?i-l:null,h=m===null?0:Math.max(m,0),g=m===null?0:Math.max(-m,0),_=`none`;return s>0&&i>=s?_=`limit`:s>0&&i>=s*.8?_=`warning`:s>0&&(_=`ok`),{provider:e,cost:i,totalCost:o,monthlyLimit:s,subscriptionPrice:l,hasSubscription:c,remaining:d,overrun:u,utilization:p,subscriptionDelta:m,subscriptionGain:h,subscriptionGap:g,riskStatus:_,subscriptionStatus:c?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:o,focusMonth:a,timelineData:t.map(e=>{let t=n.get(e)??new Map,r=u.reduce((e,n)=>e+(t.get(n)??0),0),i=u.reduce((e,t)=>{let n=f[t]?.monthlyLimit??0;return e+(n>0?n:0)},0),a=u.reduce((e,t)=>{let n=f[t];return e+(n?.hasSubscription?n.subscriptionPrice:0)},0),o=u.reduce((e,n)=>{let r=f[n]?.monthlyLimit??0,i=t.get(n)??0;return e+(r>0?Math.max(i-r,0):0)},0),s=u.reduce((e,n)=>{let r=f[n],i=t.get(n)??0,a=r?.hasSubscription?r.subscriptionPrice:0;return e+Math.max(i-a,0)},0),c=u.reduce((e,n)=>{let r=f[n],i=t.get(n)??0,a=r?.hasSubscription?r.subscriptionPrice:0;return e+(r?.hasSubscription?Math.max(a-i,0):0)},0);return{month:e,totalCost:r,totalLimit:i>0?i:null,totalSubscriptions:a>0?a:null,totalOverrun:o,totalSubscriptionGain:s,totalSubscriptionGap:c}}),atLimitCount:o.filter(e=>e.riskStatus===`limit`).length,nearLimitCount:o.filter(e=>e.riskStatus===`warning`).length,subscriptionTotal:o.reduce((e,t)=>e+t.subscriptionPrice,0),subscriptionGainTotal:o.reduce((e,t)=>e+t.subscriptionGain,0)}},[e,f,u,b]);return u.length===0?null:(0,V.jsxs)(`div`,{id:`limits`,ref:q,children:[(0,V.jsx)(A,{title:K(`limits.sectionTitle`),badge:K(`limits.providersBadge`,{count:u.length}),description:K(`limits.sectionDescription`),info:O.limits}),Q>0&&(0,V.jsx)(p.div,{initial:{opacity:0,y:12},animate:J?{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,V.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,V.jsx)(C,{className:`h-4 w-4`}),K(`limits.warningBanner`,{count:Q})]})}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-4`,children:[{label:K(`limits.cards.atLimit`),value:String(Q),hint:X?g(X):K(`limits.cards.noMonth`),icon:(0,V.jsx)(C,{className:`h-4 w-4`})},{label:K(`limits.cards.nearLimit`),value:String($),hint:K(`limits.cards.nearLimitHint`),icon:(0,V.jsx)(w,{className:`h-4 w-4`})},{label:K(`limits.cards.subscriptionVolume`),value:_(ee),hint:K(`limits.cards.subscriptionVolumeHint`),icon:(0,V.jsx)(x,{className:`h-4 w-4`})},{label:K(`limits.cards.subscriptionValue`),value:_(te),hint:K(`limits.cards.subscriptionValueHint`),icon:(0,V.jsx)(S,{className:`h-4 w-4`})}].map((e,t)=>(0,V.jsx)(p.div,{initial:{opacity:0,y:12},animate:J?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.04*t},children:(0,V.jsx)(D,{className:`h-full`,children:(0,V.jsx)(E,{className:`p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e.label}),(0,V.jsx)(`div`,{className:`mt-1 text-2xl font-semibold tabular-nums`,children:e.value}),(0,V.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hint})]}),(0,V.jsx)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 p-2 text-muted-foreground`,children:e.icon})]})})})},e.label))}),(0,V.jsx)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:Y.map((e,t)=>{let n=T(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,V.jsx)(p.div,{initial:{opacity:0,y:12},animate:J?{opacity:1,y:0}:{opacity:0,y:12},transition:{duration:.35,delay:.05+t*.03},children:(0,V.jsx)(D,{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,V.jsxs)(E,{className:`p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,V.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:H(e)}),(0,V.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground/80`,children:U(e)})]}),(0,V.jsx)(`div`,{className:`rounded-full border px-2.5 py-1 text-[11px] font-medium`,style:n,children:W(e,i)})]}),(0,V.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:K(`limits.tracks.usageFocusMonth`)}),(0,V.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:_(e.cost)})]}),(0,V.jsxs)(`div`,{className:`text-right`,children:[(0,V.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:K(`limits.tracks.limitSubscription`)}),(0,V.jsxs)(`div`,{className:`mt-1 text-sm font-medium tabular-nums`,children:[e.monthlyLimit>0?_(e.monthlyLimit):K(`limits.statuses.noLimit`),` `,`/ `,e.hasSubscription?_(e.subscriptionPrice):`–`]})]})]}),(0,V.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:K(`limits.tracks.budgetRisk`)}),(0,V.jsx)(`span`,{children:e.monthlyLimit>0?e.overrun>0?`+${_(e.overrun)}`:_(e.remaining??0):K(`limits.statuses.noLimit`)})]}),(0,V.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.monthlyLimit>0?(0,V.jsx)(p.div,{className:e.riskStatus===`limit`?`h-full bg-red-400`:e.riskStatus===`warning`?`h-full bg-amber-400`:`h-full`,initial:{width:0},animate:J?{width:`${r}%`}:{width:0},transition:{duration:.8,delay:.08+t*.04,ease:`easeOut`},...e.riskStatus===`limit`||e.riskStatus===`warning`?{}:{style:{backgroundColor:n.color}}}):(0,V.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:K(`limits.tracks.subscriptionEffect`)}),(0,V.jsx)(`span`,{className:e.subscriptionStatus===`gain`?`text-emerald-300`:e.subscriptionStatus===`gap`?`text-amber-200`:``,children:e.hasSubscription?e.subscriptionStatus===`gain`?`+${_(e.subscriptionGain)}`:_(e.subscriptionGap):K(`limits.statuses.noSubscription`)})]}),(0,V.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.hasSubscription?(0,V.jsx)(p.div,{className:e.subscriptionStatus===`gain`?`h-full bg-emerald-400`:`h-full bg-amber-300`,initial:{width:0},animate:J?{width:`${Math.max(8,a)}%`}:{width:0},transition:{duration:.8,delay:.12+t*.04,ease:`easeOut`}}):(0,V.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]})]})]})})},e.provider)})}),(0,V.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,V.jsx)(j,{title:K(`limits.tracks.budgetTitle`),subtitle:K(X?`limits.tracks.budgetSubtitle`:`limits.tracks.budgetNoMonth`),info:k.providerLimitProgress,chartData:Y,valueKey:`cost`,valueFormatter:_,children:(0,V.jsx)(`div`,{className:`space-y-3`,children:Y.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,o=e.monthlyLimit>0&&e.overrun>0?`${e.overrun/n*100}%`:`0%`;return(0,V.jsxs)(p.div,{initial:{opacity:0,y:10},animate:J?{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,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,V.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.monthlyLimit<=0?K(`limits.statuses.noLimit`):e.overrun>0?K(`limits.tracks.alreadyAboveLimit`,{value:_(e.overrun)}):K(`limits.tracks.stillToLimit`,{value:_(e.remaining??0)})})]}),(0,V.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,V.jsxs)(`div`,{className:`text-muted-foreground`,children:[K(`limits.tracks.usage`),` `,_(e.cost)]}),(0,V.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[K(`limits.tracks.limit`),` `,e.monthlyLimit>0?_(e.monthlyLimit):`–`]})]})]}),(0,V.jsx)(`div`,{className:`mt-4`,children:(0,V.jsxs)(`div`,{className:`relative h-14`,children:[(0,V.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.monthlyLimit>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`absolute top-5 left-0 h-4 rounded-l-full bg-sky-400/12`,style:{width:i}}),(0,V.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-red-400/12`,style:{left:i,width:`calc(100% - ${i})`}}),(0,V.jsx)(p.div,{className:e.riskStatus===`warning`?`absolute top-5 left-0 h-4 rounded-full bg-amber-400`:`absolute top-5 left-0 h-4 rounded-full bg-sky-400`,initial:{width:0},animate:J?{width:a}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),e.overrun>0&&(0,V.jsx)(p.div,{className:`absolute top-5 h-4 rounded-r-full bg-red-400`,style:{left:i},initial:{width:0},animate:J?{width:o}:{width:0},transition:{duration:.75,delay:.14+t*.04,ease:`easeOut`}}),(0,V.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,V.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:K(`limits.tracks.limit`)})]}):(0,V.jsx)(p.div,{className:`absolute top-5 left-0 h-4 rounded-full bg-muted-foreground/40`,initial:{width:0},animate:J?{width:r}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),(0,V.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,V.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:_(n)})]})}),(0,V.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.currentlyUsed`)}),(0,V.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:_(e.cost)})]}),(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.remainingToLimit`)}),(0,V.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?_(e.remaining??0):`$0.00`:`–`})]}),(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.alreadyOverLimit`)}),(0,V.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?_(e.overrun):`$0.00`:`–`})]})]})]},e.provider)})})}),(0,V.jsx)(j,{title:K(`limits.tracks.subscriptionTitle`),subtitle:K(X?`limits.tracks.subscriptionSubtitle`:`limits.tracks.subscriptionNoMonth`),info:k.providerSubscriptionMix,chartData:Y,valueKey:`cost`,valueFormatter:_,children:(0,V.jsx)(`div`,{className:`space-y-3`,children:Y.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,o=e.hasSubscription&&e.subscriptionGain>0?`${e.subscriptionGain/n*100}%`:`0%`;return(0,V.jsxs)(p.div,{initial:{opacity:0,y:10},animate:J?{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,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,V.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hasSubscription?e.subscriptionStatus===`gain`?K(`limits.tracks.alreadyAboveBreakEvenText`,{value:_(e.subscriptionGain)}):K(`limits.tracks.stillToBreakEven`,{value:_(e.subscriptionGap)}):K(`limits.tracks.noSubscriptionSet`)})]}),(0,V.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,V.jsxs)(`div`,{className:`text-muted-foreground`,children:[K(`limits.tracks.usage`),` `,_(e.cost)]}),(0,V.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[K(`limits.tracks.subscription`),` `,e.hasSubscription?_(e.subscriptionPrice):`–`]})]})]}),(0,V.jsx)(`div`,{className:`mt-4`,children:(0,V.jsxs)(`div`,{className:`relative h-14`,children:[(0,V.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.hasSubscription?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`absolute top-5 left-0 h-4 rounded-l-full bg-amber-300/18`,style:{width:i}}),(0,V.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400/14`,style:{left:i,width:`calc(100% - ${i})`}}),(0,V.jsx)(p.div,{className:`absolute top-5 left-0 h-4 rounded-full bg-amber-300`,initial:{width:0},animate:J?{width:a}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),e.subscriptionGain>0&&(0,V.jsx)(p.div,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400`,style:{left:i},initial:{width:0},animate:J?{width:o}:{width:0},transition:{duration:.75,delay:.14+t*.04,ease:`easeOut`}}),(0,V.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,V.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:K(`limits.tracks.breakEven`)})]}):(0,V.jsx)(p.div,{className:`absolute top-5 left-0 h-4 rounded-full bg-muted-foreground/40`,initial:{width:0},animate:J?{width:r}:{width:0},transition:{duration:.75,delay:.08+t*.04,ease:`easeOut`}}),(0,V.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,V.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:_(n)})]})}),(0,V.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.currentlyUsed`)}),(0,V.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:_(e.cost)})]}),(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.remainingToBreakEven`)}),(0,V.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?_(e.subscriptionGap):`$0.00`:`–`})]}),(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-muted-foreground`,children:K(`limits.tracks.alreadyAboveBreakEven`)}),(0,V.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?_(e.subscriptionGain):`$0.00`:`–`})]})]})]},e.provider)})})})]}),(0,V.jsx)(`div`,{className:`mt-4`,children:(0,V.jsx)(j,{title:K(`limits.tracks.portfolioTitle`),subtitle:K(`limits.tracks.portfolioSubtitle`),info:k.providerLimitTimeline,chartData:Z,valueKey:`totalCost`,valueFormatter:_,children:(0,V.jsx)(N,{children:e=>(0,V.jsx)(M,{variant:`line`,children:(0,V.jsx)(t,{width:`100%`,height:320,children:(0,V.jsxs)(c,{data:Z,margin:I,children:[(0,V.jsxs)(`defs`,{children:[(0,V.jsxs)(`linearGradient`,{id:`limits-risk-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(248 113 113)`,stopOpacity:.28}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(248 113 113)`,stopOpacity:0})]}),(0,V.jsxs)(`linearGradient`,{id:`limits-gain-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(74 222 128)`,stopOpacity:.28}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(74 222 128)`,stopOpacity:0})]})]}),(0,V.jsx)(o,{strokeDasharray:`3 3`,stroke:F.grid,opacity:.25}),(0,V.jsx)(a,{dataKey:`month`,tickFormatter:g,stroke:F.axis,fontSize:11,tickLine:!1}),(0,V.jsx)(n,{tickFormatter:e=>{let t=y(e);return t===null?``:_(Math.abs(t))},stroke:F.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,V.jsx)(l,{formatter:(e,t)=>[v(Math.abs(G(e))),t??``],labelFormatter:e=>g(String(e)),contentStyle:{borderRadius:12,borderColor:`hsl(var(--border))`,background:`color-mix(in srgb, hsl(var(--popover)) 90%, transparent)`}}),(0,V.jsx)(d,{content:(0,V.jsx)(P,{})}),(0,V.jsx)(i,{y:0,stroke:`hsl(var(--border))`,strokeDasharray:`4 4`}),(0,V.jsx)(r,{type:`monotone`,dataKey:`totalSubscriptionGain`,name:K(`limits.cards.subscriptionValue`),stroke:`rgb(74 222 128)`,fill:`url(#limits-gain-area)`,strokeWidth:2,isAnimationActive:e,animationBegin:0,animationDuration:L.duration}),(0,V.jsx)(r,{type:`monotone`,dataKey:`totalOverrun`,name:K(`limits.tracks.alreadyOverLimit`),stroke:`rgb(248 113 113)`,fill:`url(#limits-risk-area)`,strokeWidth:2,isAnimationActive:e,animationBegin:L.stagger*1.2,animationDuration:L.duration}),(0,V.jsx)(s,{type:`monotone`,dataKey:`totalCost`,name:`${K(`limits.tracks.usage`)} ${K(`common.costs`).toLowerCase()}`,stroke:F.cost,strokeWidth:2,dot:!1,isAnimationActive:e,animationBegin:L.stagger*1.6,animationDuration:L.slowDuration}),(0,V.jsx)(s,{type:`monotone`,dataKey:`totalLimit`,name:K(`limits.tracks.limits`),stroke:`rgb(251 146 60)`,strokeDasharray:`6 3`,strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:L.stagger*2,animationDuration:L.slowDuration}),(0,V.jsx)(s,{type:`monotone`,dataKey:`totalSubscriptions`,name:K(`limits.tracks.subscriptions`),stroke:`rgb(125 211 252)`,strokeDasharray:`3 3`,strokeWidth:2,dot:!1,connectNulls:!0,isAnimationActive:e,animationBegin:L.stagger*2.3,animationDuration:L.slowDuration})]})})})})})})]})}export{K as ProviderLimitsSection};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{h as a,i as o,l as s,n as c,u as l}from"./formatters-yKppUXb3.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{t as d}from"./button-D--hHeVj.js";import{c as f,i as p,n as m,r as h,t as g}from"./model-utils-BIvGAFGz.js";import{a as _,i as v,n as y,t as b}from"./card-h-Z9EWBl.js";import{t as x}from"./formatted-value-rO0EpKbc.js";import{n as S}from"./help-content-Bt5KCpWS.js";import{t as C}from"./InfoHeading-oi90uCR7.js";var w=e(t()),T=n(),E=30,D=120;function O(e){return Math.min(E+D,e)}function k(e,t,n){let r=O(e);if(t(r),r>=e)return null;let i=()=>{t(t=>{if(t>=e)return t;let r=Math.min(t+D,e);return r<e&&n(i),r})};return n(i)}function A(e){return e.modelBreakdowns.map(e=>({name:f(e.modelName),provider:h(e.modelName)})).filter((e,t,n)=>n.findIndex(t=>t.name===e.name&&t.provider===e.provider)===t)}function j(e){let t=new Map,n=0,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(!a)continue;if(i>7){let t=e[i-8];t&&(n-=t.totalCost,r-=t.requestCount)}if(i>0){let t=e[i-1];t&&(n+=t.totalCost,r+=t.requestCount)}let o=i>0?e[i-1]:null,s=Math.min(i,7),c=o&&o.totalCost>0?(a.totalCost-o.totalCost)/o.totalCost*100:null;t.set(a.date,{...c===null?{}:{prevCostDelta:c},...s>0?{avgCost7:n/s}:{},...s>0?{avgRequests7:r/s}:{}})}return t}function M(e,t){if(e)return{contentVisibility:`auto`,containIntrinsicSize:t}}function N({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:f}=i(),[h,D]=(0,w.useState)(!1),[O,N]=(0,w.useState)(`date`),[P,F]=(0,w.useState)(!1),[I,L]=(0,w.useState)(E),[,R]=(0,w.useTransition)(),z=(0,w.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(O){case`date`:return P?e.date.localeCompare(t.date):t.date.localeCompare(e.date);case`cost`:return P?e.totalCost-t.totalCost:t.totalCost-e.totalCost;case`tokens`:return P?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 P?n-r:r-n}}}),t},[e,O,P]);(0,w.useEffect)(()=>{if(!h){L(E);return}if(typeof window>`u`){L(z.length);return}let e=k(z.length,L,window.requestAnimationFrame);return()=>{e!==null&&window.cancelAnimationFrame(e)}},[h,z.length]);let B=(0,w.useMemo)(()=>h?z.slice(0,I):z.slice(0,E),[h,z,I]),V=(0,w.useMemo)(()=>[...e].sort((e,t)=>e.date.localeCompare(t.date)),[e]),H=(0,w.useMemo)(()=>j(V),[V]),U=(0,w.useMemo)(()=>Math.max(...e.map(e=>e.totalCost),0),[e]),W=(0,w.useMemo)(()=>{if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e)t+=o.totalCost,n+=o.totalTokens,r+=o.requestCount,i+=o.cacheReadTokens,(!a||o.totalCost>a.totalCost)&&(a=o);let o=n>0?i/n*100:0;return{totalCost:t,totalTokens:n,totalRequests:r,cacheShare:o,top:a}},[e]),G=(0,w.useMemo)(()=>B.map(e=>({day:e,benchmark:H.get(e.date),costPerM:e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,uniqueModels:A(e)})),[H,B]),K=e=>{R(()=>{e===O?F(!P):(N(e),F(!1))})},q=e=>O===e?P?`ascending`:`descending`:`none`,J=(0,w.useCallback)((e,n)=>{t&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),t(n)))},[t]);return(0,T.jsxs)(b,{children:[(0,T.jsxs)(v,{className:`flex flex-row items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,T.jsx)(C,{info:S.recentDays,children:(0,T.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:f(n===`monthly`?`tables.recentDays.monthsDetail`:n===`yearly`?`tables.recentDays.yearsDetail`:`tables.recentDays.daysDetail`)})}),(0,T.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:f(`tables.recentDays.showing`,{shown:B.length,total:z.length,unit:a(n,!0)})})]}),z.length>E&&(0,T.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>R(()=>{D(e=>!e)}),children:f(h?`tables.recentDays.showLess`:`tables.recentDays.showAll`)})]}),(0,T.jsxs)(y,{children:[W&&(0,T.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 lg:grid-cols-5`,children:[(0,T.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.totalCost`)}),(0,T.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,T.jsx)(x,{value:W.totalCost,type:`currency`})})]}),(0,T.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.totalTokens`)}),(0,T.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,T.jsx)(x,{value:W.totalTokens,type:`tokens`})})]}),(0,T.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.requests`)}),(0,T.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,T.jsx)(x,{value:W.totalRequests,type:`number`})})]}),(0,T.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.cacheReadShare`)}),(0,T.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:l(W.cacheShare,1)})]}),(0,T.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.peak`)}),(0,T.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:W.top?o(W.top.date):`–`}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:W.top?c(W.top.totalCost):`–`})]})]}),h&&I<z.length&&(0,T.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground`,children:f(`tables.recentDays.showing`,{shown:I,total:z.length,unit:a(n,!0)})}),(0,T.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:G.map(({day:e,benchmark:i,costPerM:a,uniqueModels:l})=>(0,T.jsxs)(`button`,{onClick:()=>t?.(e.date),className:`rounded-xl border border-border/50 bg-muted/10 p-3 text-left`,style:M(h,`220px`),children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`font-medium`,children:o(e.date,`long`)}),(0,T.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[s(e.requestCount),` `,f(`common.requests`)]})]}),(0,T.jsxs)(`div`,{className:`text-right`,children:[(0,T.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,T.jsx)(x,{value:e.totalCost,type:`currency`,interactive:!1})}),(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,T.jsx)(x,{value:e.totalTokens,type:`tokens`,interactive:!1})}),n===`daily`&&i?.prevCostDelta!==void 0&&(0,T.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.previousDay`),` `,i.prevCostDelta>=0?`↑`:`↓`,Math.abs(i.prevCostDelta).toFixed(0),`%`]})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:f(`common.input`)}),(0,T.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,T.jsx)(x,{value:e.inputTokens,type:`tokens`,interactive:!1})})]}),(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:f(`common.output`)}),(0,T.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,T.jsx)(x,{value:e.outputTokens,type:`tokens`,interactive:!1})})]}),(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,T.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,T.jsx)(x,{value:a,type:`currency`,interactive:!1})})]})]}),(0,T.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[l.slice(0,4).map(({name:e,provider:t})=>(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight font-medium`,style:{backgroundColor:m(e,.16),color:g(e)},children:[(0,T.jsx)(`span`,{children:e}),(0,T.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,p(t)),children:t})]},`${e}-${t}`)),l.length>4&&(0,T.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-border/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:f(`tables.modelEfficiency.more`,{count:l.length-4})})]}),n===`daily`&&i?.avgCost7!==void 0&&(0,T.jsxs)(`div`,{className:`mt-3 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.avg7d`),` `,c(i.avgCost7),` ·`,` `,f(`tables.recentDays.reqAvg`),` `,i.avgRequests7?.toFixed(0)??`–`]})]},e.date))}),(0,T.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,T.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,T.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,T.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,T.jsx)(`th`,{"aria-sort":q(`date`),className:r(`px-2 py-2 text-left text-xs font-medium`,O===`date`?`text-foreground`:`text-muted-foreground`),children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(`date`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[f(`tables.recentDays.date`),` `,(0,T.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,O===`date`&&`text-primary`)})]})}),(0,T.jsx)(`th`,{"aria-sort":q(`cost`),className:r(`px-2 py-2 text-right text-xs font-medium`,O===`cost`?`text-foreground`:`text-muted-foreground`),children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(`cost`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[f(`tables.recentDays.cost`),` `,(0,T.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,O===`cost`&&`text-primary`)})]})}),(0,T.jsx)(`th`,{"aria-sort":q(`tokens`),className:r(`px-2 py-2 text-right text-xs font-medium`,O===`tokens`?`text-foreground`:`text-muted-foreground`),children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(`tokens`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[f(`tables.recentDays.tokens`),` `,(0,T.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,O===`tokens`&&`text-primary`)})]})}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground md:table-cell`,children:f(`common.input`)}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground md:table-cell`,children:f(`common.output`)}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground lg:table-cell`,children:f(`common.cacheWrite`)}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground lg:table-cell`,children:f(`common.cacheRead`)}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground xl:table-cell`,children:f(`common.thinking`)}),(0,T.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground xl:table-cell`,children:f(`common.requestsShort`)}),(0,T.jsx)(`th`,{"aria-sort":q(`costPerM`),className:r(`px-2 py-2 text-right text-xs font-medium`,O===`costPerM`?`text-foreground`:`text-muted-foreground`),children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(`costPerM`),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[`$/1M`,` `,(0,T.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,O===`costPerM`&&`text-primary`)})]})}),(0,T.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:f(`tables.recentDays.models`)})]})}),(0,T.jsx)(`tbody`,{children:G.map(({day:e,benchmark:i,costPerM:a,uniqueModels:s})=>(0,T.jsxs)(`tr`,{className:`cursor-pointer border-b border-l-[3px] border-border/50 transition-colors hover:bg-muted/10 focus-visible:bg-muted/10 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset active:bg-muted/20`,style:{borderLeftColor:`hsla(215, 70%, 55%, ${.2+(U>0?e.totalCost/U:0)*.8})`,...M(h,`52px`)},onClick:()=>t?.(e.date),onKeyDown:t=>J(t,e.date),role:t?`button`:void 0,tabIndex:t?0:void 0,children:[(0,T.jsx)(`td`,{className:`px-2 py-2.5 whitespace-nowrap`,children:o(e.date,`long`)}),(0,T.jsxs)(`td`,{className:`relative px-2 py-2.5 text-right font-mono tabular-nums`,children:[(0,T.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm bg-primary/8 transition-all duration-300`,style:{width:`${U>0?e.totalCost/U*100:0}%`}}),(0,T.jsx)(`span`,{className:`relative`,children:(0,T.jsx)(x,{value:e.totalCost,type:`currency`})})]}),(0,T.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,T.jsx)(x,{value:e.totalTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums md:table-cell`,children:(0,T.jsx)(x,{value:e.inputTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums md:table-cell`,children:(0,T.jsx)(x,{value:e.outputTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums lg:table-cell`,children:(0,T.jsx)(x,{value:e.cacheCreationTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums lg:table-cell`,children:(0,T.jsx)(x,{value:e.cacheReadTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums xl:table-cell`,children:(0,T.jsx)(x,{value:e.thinkingTokens,type:`tokens`})}),(0,T.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums xl:table-cell`,children:(0,T.jsx)(x,{value:e.requestCount,type:`number`})}),(0,T.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,T.jsx)(x,{value:a,type:`currency`})}),(0,T.jsxs)(`td`,{className:`px-2 py-2.5`,children:[(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(({name:e,provider:t})=>(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight font-medium`,style:{backgroundColor:m(e,.16),color:g(e)},children:[(0,T.jsx)(`span`,{children:e}),(0,T.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,p(t)),children:t})]},`${e}-${t}`))}),n===`daily`&&i?.avgCost7!==void 0&&(0,T.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.previousDay`),` `,i.prevCostDelta===void 0?`–`:`${i.prevCostDelta>=0?`↑`:`↓`}${Math.abs(i.prevCostDelta).toFixed(0)}%`,` `,`· `,f(`tables.recentDays.avg7d`),` `,c(i.avgCost7)]})]})]},e.date))})]})})]})]})}export{N as RecentDays};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,f as o,l as s,m as c,p as l,t as u,v as d,w as f,y as p}from"./charts-vendor-CiBqdKXh.js";import{a as m}from"./motion-vendor-vKc6gXHZ.js";import{t as h}from"./useTranslation-BSl7t2D6.js";import{a as g,g as _,u as v}from"./formatters-yKppUXb3.js";import{c as y,t as b}from"./model-utils-BIvGAFGz.js";import{t as x}from"./help-content-Bt5KCpWS.js";import{n as S,r as C,t as w}from"./ChartCard-CBUnItl-.js";import{t as T}from"./ChartLegend-B64cJdDI.js";import{t as E}from"./CustomTooltip-CBVU1pyK.js";import{n as D,r as O,t as k}from"./chart-theme-D5iCFDJg.js";import{n as A,o as j}from"./calculations-GOdNqKo6.js";var M=e(f()),N=m();function P(e){return v(e,1)}function F(e,t,n,r,i){let a=e+t+n+r+i;return a>0?r/a*100:0}function I({timelineData:e,summaryData:f,viewMode:m}){let{t:v}=h(),I=(0,M.useId)().replace(/:/g,``),L=v(`charts.requestCacheHitRate.total`),R=v(m===`daily`?`charts.requestCacheHitRate.trailing7Rate`:`charts.requestCacheHitRate.trendRate`),z=(0,M.useMemo)(()=>A(f).map(e=>({...e,model:e.model===`Total`?L:e.model})),[f,L]),B=(0,M.useMemo)(()=>{if(z.length===0)return null;let e=z[0];return e?{total:e,topModel:z.slice(1).sort((e,t)=>t.totalRate-e.totalRate)[0]??null,dominantModel:z.slice(1).sort((e,t)=>t.totalBaseTokens-e.totalBaseTokens)[0]??null,models:Math.max(z.length-1,0)}:null},[z]),V=(0,M.useMemo)(()=>{if(e.length===0)return[];let t=z.slice(1).map(e=>e.model),n=[...e].sort((e,t)=>e.date.localeCompare(t.date)),r=n.map(e=>F(e.inputTokens,e.outputTokens,e.cacheCreationTokens,e.cacheReadTokens,e.thinkingTokens)),i=j(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=y(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?F(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,z]);if(!B||V.length===0)return null;let H=Math.max(220,Math.min(310,z.length*28+48)),U=Math.max(280,Math.min(420,z.length*34+56)),W=m===`daily`?280:250,G=m===`daily`?360:320,K=Object.keys(V[0]??{}).filter(e=>e!==`date`&&e!==`totalRate`&&e!==`totalRate_ma7`),q=(0,N.jsx)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:z.slice(0,6).map(e=>(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.model}),(0,N.jsxs)(`div`,{className:`mt-2 flex items-end gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.totalRate`)}),(0,N.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:P(e.totalRate)})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.trailing7Rate`)}),(0,N.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:P(e.trailing7Rate)})]})]})]},e.model))});return(0,N.jsx)(S,{title:v(`charts.requestCacheHitRate.title`),subtitle:v(`charts.requestCacheHitRate.subtitle`,{total:P(B.total.totalRate),trailing:P(B.total.trailing7Rate)}),info:x.requestCacheHitRate,chartData:z,valueKey:`totalRate`,valueFormatter:P,expandedExtra:q,children:e=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-center md:grid-cols-4`,children:[(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.totalRate`)}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:P(B.total.totalRate)})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.trailing7Rate`)}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:P(B.total.trailing7Rate)})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.topModel`)}),(0,N.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:B.topModel?.model??`–`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.models`)}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:B.models})]})]}),(0,N.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,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.timelineHeading`,{unit:_(m)})}),(0,N.jsx)(w,{children:t=>(0,N.jsx)(C,{variant:`line`,children:(0,N.jsx)(r,{width:`100%`,height:e?G:W,children:(0,N.jsxs)(u,{data:V,margin:O,children:[(0,N.jsx)(`defs`,{children:(0,N.jsxs)(`linearGradient`,{id:`${I}-total-rate`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,N.jsx)(`stop`,{offset:`0%`,stopColor:D.cost,stopOpacity:.24}),(0,N.jsx)(`stop`,{offset:`100%`,stopColor:D.cost,stopOpacity:0})]})}),(0,N.jsx)(c,{strokeDasharray:`3 3`,stroke:D.grid,opacity:.3}),(0,N.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:D.axis,fontSize:11,tickLine:!1}),(0,N.jsx)(i,{type:`number`,domain:[0,100],tickFormatter:P,stroke:D.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,N.jsx)(d,{content:(0,N.jsx)(E,{formatter:e=>P(e),pinnedEntryNames:[v(`charts.requestCacheHitRate.totalRate`)],showComputedTotal:!1,hideZeroValues:!0}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,N.jsx)(p,{content:(0,N.jsx)(T,{})}),(0,N.jsx)(o,{type:`monotone`,dataKey:`totalRate`,stroke:D.cost,fill:`url(#${I}-total-rate)`,name:v(`charts.requestCacheHitRate.totalRate`),strokeWidth:2,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:D.cost,fill:`hsl(var(--background))`},isAnimationActive:t,animationDuration:k.duration,animationEasing:k.easing}),(0,N.jsx)(l,{type:`monotone`,dataKey:`totalRate_ma7`,stroke:D.ma7,name:R,dot:!1,strokeWidth:2,strokeDasharray:`5 5`,connectNulls:!0,isAnimationActive:t,animationBegin:k.stagger,animationDuration:k.slowDuration,animationEasing:k.easing}),K.map((e,n)=>(0,N.jsx)(l,{type:`monotone`,dataKey:e,stroke:b(e),name:e,dot:!1,strokeWidth:1.8,connectNulls:!0,isAnimationActive:t,animationBegin:k.stagger*(n+2),animationDuration:k.slowDuration,animationEasing:k.easing},e))]})})})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.modelBreakdownHeading`)}),(0,N.jsx)(w,{children:o=>(0,N.jsx)(C,{variant:`line`,children:(0,N.jsx)(r,{width:`100%`,height:e?U:H,children:(0,N.jsxs)(n,{data:z,layout:`vertical`,margin:{...O,left:e?30:20,right:8},barCategoryGap:e?14:10,children:[(0,N.jsx)(c,{strokeDasharray:`3 3`,stroke:D.grid,opacity:.22,horizontal:!1}),(0,N.jsx)(s,{type:`number`,domain:[0,100],tickFormatter:P,stroke:D.axis,fontSize:10,tickLine:!1,axisLine:!1}),(0,N.jsx)(i,{type:`category`,dataKey:`model`,stroke:D.axis,fontSize:10,tickLine:!1,axisLine:!1,width:e?126:108}),(0,N.jsx)(d,{content:(0,N.jsx)(E,{formatter:e=>P(e),pinnedEntryNames:[v(`charts.requestCacheHitRate.totalRate`),v(`charts.requestCacheHitRate.trailing7Rate`)],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,N.jsx)(p,{content:(0,N.jsx)(T,{})}),(0,N.jsx)(a,{dataKey:`totalRate`,name:v(`charts.requestCacheHitRate.totalRate`),radius:[0,4,4,0],fill:D.cacheRead,isAnimationActive:o,animationDuration:k.duration,animationEasing:k.easing,children:z.map(e=>(0,N.jsx)(t,{fill:e.model===L?D.cost:D.cacheRead,fillOpacity:e.model===L?.95:.82},`${e.model}-total`))}),(0,N.jsx)(a,{dataKey:`trailing7Rate`,name:v(`charts.requestCacheHitRate.trailing7Rate`),radius:[0,4,4,0],fill:D.ma7,isAnimationActive:o,animationBegin:k.stagger,animationDuration:k.slowDuration,animationEasing:k.easing,children:z.map(e=>(0,N.jsx)(t,{fill:e.model===L?D.cumulative:D.ma7,fillOpacity:e.model===L?.95:.8},`${e.model}-recent`))})]})})})})]})]})]})})}export{I as RequestCacheHitRateByModel};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n,t as r}from"./motion-vendor-vKc6gXHZ.js";import{i,t as a}from"./useTranslation-BSl7t2D6.js";import{d as o,l as s,n as c,u as l}from"./formatters-yKppUXb3.js";import{a as u,i as d,n as f,t as p}from"./card-h-Z9EWBl.js";import{n as m}from"./help-content-Bt5KCpWS.js";import{t as h}from"./InfoHeading-oi90uCR7.js";var g=e(t()),_=n();function v({metrics:e,viewMode:t}){let{t:n}=a(),v=(0,g.useRef)(null),y=r(v,{once:!0,amount:.25}),b=i(),x=e.totalRequests>0?e.totalCacheRead/e.totalRequests:0,S=e.totalRequests>0?e.totalThinking/e.totalRequests:0,C=e.totalOutput>0?e.totalInput/e.totalOutput:0,w=e.activeDays>0?e.totalRequests/e.activeDays:0,T=[{label:n(`requestQuality.tokensPerRequest`),value:e.hasRequestData?o(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?c(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?o(x):n(`common.notAvailable`),accent:`var(--chart-1)`,hint:n(`requestQuality.cacheHint`),progress:Math.min(x/2e5,1)},{label:n(`requestQuality.thinkingPerRequest`),value:e.hasRequestData?o(S):n(`common.notAvailable`),accent:`var(--chart-5)`,hint:n(`requestQuality.thinkingHint`),progress:Math.min(S/1e4,1)}];return(0,_.jsxs)(p,{ref:v,className:`overflow-visible`,children:[(0,_.jsx)(d,{children:(0,_.jsx)(h,{info:m.requestQuality,children:(0,_.jsx)(u,{className:`text-sm font-medium text-muted-foreground`,children:n(`requestQuality.title`)})})}),(0,_.jsxs)(f,{className:`space-y-4`,children:[(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 xl:grid-cols-4`,children:T.map(t=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-3`,children:[(0,_.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:t.label}),(0,_.jsx)(`div`,{className:`mt-1 text-lg font-semibold tabular-nums`,children:t.value}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:t.hint}),(0,_.jsx)(`div`,{className:`mt-3 h-1.5 overflow-hidden rounded-full bg-muted/40`,children:(0,_.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-700 ease-out motion-reduce:transition-none`,style:{backgroundColor:`hsl(${t.accent})`,width:(y||b)&&e.hasRequestData&&t.progress>0?`${Math.max(t.progress*100,6)}%`:`0%`}})})]},t.label))}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-primary/[0.12] via-transparent to-transparent p-4`,children:[(0,_.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:n(`requestQuality.requestDensity`)}),(0,_.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:s(Math.round(w))}),(0,_.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,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-3/[0.12] via-transparent to-transparent p-4`,children:[(0,_.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:n(`requestQuality.cacheHitRate`)}),(0,_.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:l(e.cacheHitRate,1)}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`requestQuality.cacheHitHint`)})]}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-4/[0.12] via-transparent to-transparent p-4`,children:[(0,_.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:n(`requestQuality.inputOutput`)}),(0,_.jsxs)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:[C.toFixed(2),`:1`]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`requestQuality.inputOutputHint`)})]}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-5/[0.12] via-transparent to-transparent p-4`,children:[(0,_.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:n(`requestQuality.topRequestModel`)}),(0,_.jsx)(`div`,{className:`mt-1 truncate text-lg font-semibold`,children:e.topRequestModel?.name??`–`}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.topRequestModel?`${s(e.topRequestModel.requests)} ${n(`common.requests`)}`:n(`requestQuality.noRequestLeader`)})]})]})]})]})}export{v as RequestQuality};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,b as n,c as r,f as i,g as a,i as o,l as s,m as c,p as l,t as u,v as d,w as f,y as p}from"./charts-vendor-CiBqdKXh.js";import{a as m}from"./motion-vendor-vKc6gXHZ.js";import{t as h}from"./useTranslation-BSl7t2D6.js";import{a as g,g as _}from"./formatters-yKppUXb3.js";import{r as v}from"./i18n-C88wS2Uy.js";import{t as y}from"./model-utils-BIvGAFGz.js";import{t as b}from"./formatted-value-rO0EpKbc.js";import{t as x}from"./help-content-Bt5KCpWS.js";import{n as S,r as C,t as w}from"./ChartCard-CBUnItl-.js";import{t as T}from"./ChartLegend-B64cJdDI.js";import{t as E}from"./CustomTooltip-CBVU1pyK.js";import{n as D,r as O,t as k}from"./chart-theme-D5iCFDJg.js";var A=e(f()),j=m();function M(e){return new Intl.NumberFormat(v(),{notation:e>=1e4?`compact`:`standard`,maximumFractionDigits:+(e>=1e4)}).format(e)}function N({viewBox:e,total:t}){let{t:n}=h();if(!e)return null;let{cx:r,cy:i}=e;return(0,j.jsxs)(`g`,{children:[(0,j.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.requestsOverTime.total`)}),(0,j.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function P({data:e,viewMode:f=`daily`,onClickDay:m}){let{t:v}=h(),P=(0,A.useId)().replace(/:/g,``),F=v(`charts.requestsOverTime.averagePerUnit`,{unit:_(f)}),I=v(f===`daily`?`charts.requestsOverTime.movingAverage`:`charts.requestsOverTime.trend`),L=v(f===`daily`?`charts.requestsOverTime.movingAverageHeading`:`charts.requestsOverTime.trendHeading`),R=(0,A.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]),z=(0,A.useMemo)(()=>(R?.topModels??[]).slice(0,5).map(([e])=>e),[R]),B=(0,A.useMemo)(()=>(R?.topModels??[]).map(([e,t])=>({name:e,value:t})),[R]),V=e=>{let t=e;t?.activePayload?.[0]?.payload?.date&&m&&m(t.activePayload[0].payload.date)},H=(0,j.jsx)(w,{children:t=>(0,j.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:L}),(0,j.jsx)(C,{variant:`line`,children:(0,j.jsx)(n,{width:`100%`,height:360,children:(0,j.jsxs)(u,{data:e,margin:O,children:[(0,j.jsx)(c,{strokeDasharray:`3 3`,stroke:D.grid,opacity:.3}),(0,j.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:D.axis,fontSize:11,tickLine:!1}),(0,j.jsx)(r,{tickFormatter:M,stroke:D.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,j.jsx)(d,{content:(0,j.jsx)(E,{formatter:e=>M(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,j.jsx)(p,{content:(0,j.jsx)(T,{})}),(0,j.jsx)(l,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:D.ma7,name:v(`charts.requestsOverTime.totalMovingAverage`,{label:I}),dot:!1,strokeWidth:2.5,strokeDasharray:`6 4`,connectNulls:!0,isAnimationActive:t,animationBegin:0,animationDuration:k.slowDuration}),(R?.topModels??[]).map(([e],n)=>(0,j.jsx)(l,{type:`monotone`,dataKey:`${e}_ma7`,stroke:y(e),name:`${e} ${I}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,isAnimationActive:t,animationBegin:k.stagger*(n%6),animationDuration:k.slowDuration},`${e}_ma7`))]})})})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.requestsByModelTotal`)}),(0,j.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:(R?.topModels??[]).map(([e,t])=>{let n=R&&R.totalRequests>0?t/R.totalRequests*100:0;return(0,j.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:y(e)}}),(0,j.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e})]}),(0,j.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.toFixed(1),`%`]})]}),(0,j.jsx)(`div`,{className:`mt-2 text-lg font-semibold tabular-nums`,children:M(t)}),(0,j.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:v(`charts.requestsOverTime.requestsInRange`)})]},e)})})]})]})});return(0,j.jsx)(S,{title:v(`charts.requestsOverTime.title`),subtitle:R?v(`charts.requestsOverTime.summary`,{total:M(R.totalRequests),peak:M(R.peak.totalRequests),date:g(R.peak.date)}):v(`charts.requestsOverTime.subtitle`),info:x.requestsOverTime,summary:R?(0,j.jsx)(b,{value:R.totalRequests,type:`number`}):void 0,chartData:e,valueKey:`totalRequests`,valueFormatter:M,expandedExtra:H,children:f=>{let m=f?420:320,h=f?440:340,_=f?70:54,b=f?112:82,x=f?`48%`:`46%`;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-center md:grid-cols-4`,children:[(0,j.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,j.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.total`)}),(0,j.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:R?M(R.totalRequests):`0`})]}),(0,j.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,j.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:F}),(0,j.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:R&&e.length>0?M(R.totalRequests/e.length):`0`})]}),(0,j.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,j.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.topModel`)}),(0,j.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:R?.topModels[0]?.[0]??`–`})]}),(0,j.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,j.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.topShare`)}),(0,j.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:R&&R.totalRequests>0&&R.topModels[0]?`${(R.topModels[0][1]/R.totalRequests*100).toFixed(1)}%`:`–`})]})]}),(0,j.jsxs)(`div`,{className:`grid gap-4 ${f?`grid-cols-1 xl:grid-cols-3`:`grid-cols-1 lg:grid-cols-3`}`,children:[(0,j.jsx)(`div`,{className:f?`xl:col-span-2`:`lg:col-span-2`,children:(0,j.jsx)(w,{children:t=>(0,j.jsx)(C,{variant:`line`,children:(0,j.jsx)(n,{width:`100%`,height:m,children:(0,j.jsxs)(u,{data:e,margin:O,onClick:V,children:[(0,j.jsx)(`defs`,{children:(0,j.jsxs)(`linearGradient`,{id:`${P}-requests`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,j.jsx)(`stop`,{offset:`0%`,stopColor:D.cumulative,stopOpacity:.28}),(0,j.jsx)(`stop`,{offset:`100%`,stopColor:D.cumulative,stopOpacity:0})]})}),(0,j.jsx)(c,{strokeDasharray:`3 3`,stroke:D.grid,opacity:.3}),(0,j.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:D.axis,fontSize:11,tickLine:!1}),(0,j.jsx)(r,{tickFormatter:M,stroke:D.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,j.jsx)(d,{content:(0,j.jsx)(E,{formatter:e=>M(e),pinnedEntryNames:[v(`charts.requestsOverTime.totalRequestsSeries`)],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,j.jsx)(p,{content:(0,j.jsx)(T,{})}),(0,j.jsx)(i,{type:`monotone`,dataKey:`totalRequests`,stroke:D.cumulative,fill:`url(#${P}-requests)`,name:v(`charts.requestsOverTime.totalRequestsSeries`),strokeWidth:1.8,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:D.cumulative,fill:`hsl(var(--background))`},isAnimationActive:t,animationDuration:k.duration}),(0,j.jsx)(l,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:D.ma7,name:I,dot:!1,strokeWidth:2.2,strokeDasharray:`5 5`,connectNulls:!0,isAnimationActive:t,animationBegin:k.stagger,animationDuration:k.slowDuration}),z.map((e,n)=>(0,j.jsx)(l,{type:`monotone`,dataKey:e,stroke:y(e),name:e,dot:!1,strokeWidth:1.6,isAnimationActive:t,animationBegin:k.stagger*(n%5+1),animationDuration:k.duration},e))]})})})})}),(0,j.jsx)(`div`,{className:`min-w-0 pt-1`,children:(0,j.jsx)(w,{children:e=>(0,j.jsx)(C,{variant:`radial`,children:(0,j.jsx)(n,{width:`100%`,height:h,children:(0,j.jsxs)(o,{children:[(0,j.jsxs)(a,{data:B,cx:`50%`,cy:x,innerRadius:_,outerRadius:b,paddingAngle:2,dataKey:`value`,nameKey:`name`,isAnimationActive:e,animationDuration:k.duration,animationBegin:k.stagger,animationEasing:k.easing,children:[B.map(e=>(0,j.jsx)(t,{fill:y(e.name)},e.name)),(0,j.jsx)(N,{total:R?M(R.totalRequests):`0`})]}),(0,j.jsx)(d,{content:(0,j.jsx)(E,{formatter:e=>M(e)})}),(0,j.jsx)(p,{wrapperStyle:{fontSize:`12px`,paddingTop:f?`18px`:`8px`},formatter:e=>{let t=B.find(t=>t.name===e);return(0,j.jsxs)(`span`,{className:`text-xs text-foreground`,children:[e,` (`,t?M(t.value):``,`)`]})}})]})})})})})]})]})}})}export{P as RequestsOverTime};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{s as a}from"./formatters-yKppUXb3.js";import{t as o}from"./i18n-C88wS2Uy.js";import{I as s,N as ee,O as te,P as c,S as ne,et as re,h as ie,k as ae,r as l,rt as oe,w as se}from"./icons-vendor-CIvT_-Pb.js";import{t as u}from"./button-D--hHeVj.js";import{i as d}from"./model-utils-BIvGAFGz.js";import{a as ce,i as le,n as ue,r as de,t as fe}from"./dialog-C0AeNKs8.js";import{a as pe,c as f,i as me,l as p,o as he,s as m,t as ge}from"./app-settings-C3i52ycx.js";import{n as _e}from"./help-content-Bt5KCpWS.js";import{t as ve}from"./InfoHeading-oi90uCR7.js";import{a as h,t as g}from"./provider-limits-5e1fUwPl.js";var _=e(t()),v=n();function y(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 b(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function x(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))].sort((e,t)=>e.localeCompare(t))}function ye(e,t){let n={};for(let r of e)n[r]=t[r]??{...g};return n}function S(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 be(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 C({open:e,onOpenChange:t,language:n,limitProviders:C,filterProviders:w,models:T,limits:E,defaultFilters:D,sectionVisibility:O,sectionOrder:k,lastLoadedAt:A,lastLoadSource:j,cliAutoLoadActive:xe=!1,hasData:Se,onSaveSettings:Ce,onExportSettings:we,onImportSettings:Te,onExportData:Ee,onImportData:De,settingsBusy:M=!1,dataBusy:N=!1}){let{t:P}=i(),[F,I]=(0,_.useState)(n),[L,R]=(0,_.useState)(()=>h(C,E)),[z,B]=(0,_.useState)(D),[V,H]=(0,_.useState)(O),[U,W]=(0,_.useState)(k),[G,K]=(0,_.useState)(null),[q,J]=(0,_.useState)(null),Y=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(I(n),R(h(C,E)),B(D),H(O),W(k),K(null),J(null))},[e,n,C,E,D,O,k]);let X=(0,_.useMemo)(()=>x([...w,...z.providers]),[w,z.providers]),Z=(0,_.useMemo)(()=>x([...T,...z.models]),[T,z.models]),Q=(e,t)=>{R(n=>({...n,[e]:{...n[e]??g,...t}}))},Oe=async()=>{await Ce({language:F,providerLimits:ye(C,L),defaultFilters:{...z,providers:x(z.providers),models:x(z.models)},sectionVisibility:V,sectionOrder:U}),t(!1)},ke=()=>{I(ge.language),R(h(C,{})),B(m),H(p()),W(f()),K(null),J(null)},Ae=()=>{B(m)},je=()=>{H(p()),W(f())},Me=()=>{R(h(C,{}))},Ne=P(j?`settings.modal.sources.${j}`:`settings.modal.sources.unknown`),$=(0,_.useMemo)(()=>U.map(e=>pe[e]).filter(e=>e!==void 0),[U]);return(0,v.jsx)(fe,{open:e,onOpenChange:t,children:(0,v.jsxs)(ue,{className:`max-h-[88vh] max-w-5xl overflow-x-visible overflow-y-auto`,onOpenAutoFocus:e=>{e.preventDefault(),Y.current?.focus()},children:[(0,v.jsxs)(le,{className:`overflow-visible`,children:[(0,v.jsx)(ve,{info:_e.providerLimits,children:(0,v.jsx)(ce,{ref:Y,tabIndex:-1,className:`focus:outline-none`,children:P(`settings.modal.title`)})}),(0,v.jsx)(de,{children:P(`settings.modal.description`)})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-muted/20 px-4 py-3`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.dataStatus`)}),(0,v.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.lastLoaded`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:A?a(A):P(`common.notAvailable`)})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.loadedVia`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:Ne})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.cliAutoLoad`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(xe?`common.enabled`:`common.disabled`)})]})]})]}),(0,v.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(se,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.languageTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.languageDescription`)})]})]}),(0,v.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:o.map(e=>(0,v.jsx)(u,{type:`button`,"data-testid":`settings-language-${e}`,"aria-pressed":F===e,variant:F===e?`default`:`outline`,onClick:()=>I(e),children:P(`app.languages.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(ae,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.defaultFiltersTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.defaultFiltersDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-default-filters`,onClick:Ae,disabled:M,children:P(`common.reset`)})]}),(0,v.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.defaultViewMode`)}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:he.map(e=>(0,v.jsx)(u,{type:`button`,"aria-pressed":z.viewMode===e,variant:z.viewMode===e?`default`:`outline`,onClick:()=>B(t=>({...t,viewMode:e})),children:P(`settings.modal.viewModes.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.defaultDateRange`)}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:me.map(e=>(0,v.jsx)(u,{type:`button`,"aria-pressed":z.datePreset===e,variant:z.datePreset===e?`default`:`outline`,onClick:()=>B(t=>({...t,datePreset:e})),children:P(`settings.modal.datePresets.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.filterProviders`)}),X.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:P(`settings.modal.noProviders`)}):(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:X.map(e=>{let t=z.providers.includes(e);return(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>B(t=>({...t,providers:b(t.providers,e)})),className:r(`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`:d(e)),children:e},e)})})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.filterModels`)}),Z.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:P(`settings.modal.noModels`)}):(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map(e=>{let t=z.models.includes(e);return(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>B(t=>({...t,models:b(t.models,e)})),className:r(`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,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(ee,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.sectionVisibilityTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.sectionVisibilityDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-section-visibility`,onClick:je,disabled:M,children:P(`common.reset`)})]}),(0,v.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:P(`settings.modal.sectionOrderHint`)}),(0,v.jsx)(`div`,{className:`mt-4 space-y-2`,children:$.map((e,t)=>{let n=V[e.id];return(0,v.jsxs)(`div`,{"data-section-id":e.id,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),K(e.id),J(e.id)},onDragOver:t=>{t.preventDefault(),q!==e.id&&J(e.id)},onDragLeave:()=>{q===e.id&&J(null)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||G;n&&(W(t=>be(t,n,e.id)),K(null),J(null))},onDragEnd:()=>{K(null),J(null)},className:r(`flex items-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors`,q===e.id?`border-primary/40 bg-primary/10`:`border-border/70 bg-muted/10`,G===e.id&&`opacity-70`),children:[(0,v.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,v.jsx)(te,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:P(e.labelKey)}),(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:P(`settings.modal.positionLabel`,{position:t+1,total:$.length})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-up-${e.id}`,onClick:()=>W(t=>S(t,e.id,-1)),disabled:t===0,"aria-label":P(`settings.modal.moveSectionUp`,{section:P(e.labelKey)}),children:(0,v.jsx)(re,{className:`h-4 w-4`})}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-down-${e.id}`,onClick:()=>W(t=>S(t,e.id,1)),disabled:t===$.length-1,"aria-label":P(`settings.modal.moveSectionDown`,{section:P(e.labelKey)}),children:(0,v.jsx)(oe,{className:`h-4 w-4`})}),(0,v.jsx)(`button`,{type:`button`,"data-testid":`toggle-section-visibility-${e.id}`,"aria-pressed":n,onClick:()=>H(t=>({...t,[e.id]:!t[e.id]})),className:r(`inline-flex min-w-[88px] items-center justify-center rounded-full border px-3 py-1.5 text-xs font-medium tracking-[0.12em] uppercase 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:P(n?`common.visible`:`common.hidden`)})]})]},e.id)})})]})]}),(0,v.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(ie,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.settingsBackupTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.settingsBackupDescription`)})]})]}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,v.jsxs)(u,{variant:`outline`,onClick:we,disabled:M,className:`gap-2`,children:[(0,v.jsx)(c,{className:`h-4 w-4`}),P(`settings.modal.exportSettings`)]}),(0,v.jsxs)(u,{variant:`outline`,onClick:Te,disabled:M,className:`gap-2`,children:[(0,v.jsx)(l,{className:`h-4 w-4`}),P(`settings.modal.importSettings`)]})]})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(s,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.dataBackupTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.dataBackupDescription`)})]})]}),(0,v.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:P(`settings.modal.dataImportPolicy`)}),(0,v.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:P(`settings.modal.dataImportReplaceHint`)}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,v.jsxs)(u,{variant:`outline`,onClick:Ee,disabled:!Se||N,className:`gap-2`,children:[(0,v.jsx)(c,{className:`h-4 w-4`}),P(`settings.modal.exportData`)]}),(0,v.jsxs)(u,{variant:`outline`,onClick:De,disabled:N,className:`gap-2`,children:[(0,v.jsx)(l,{className:`h-4 w-4`}),P(`settings.modal.importData`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.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,v.jsx)(ne,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.providerLimitsTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.providerLimitsDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-provider-limits`,onClick:Me,disabled:M,children:P(`common.reset`)})]}),(0,v.jsx)(`div`,{className:`mt-4`,children:C.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-8 text-center text-sm text-muted-foreground`,children:P(`settings.modal.noProviders`)}):(0,v.jsx)(`div`,{className:`space-y-3`,children:C.map(e=>{let t=L[e]??g;return(0,v.jsx)(`div`,{"data-provider-id":e,className:`rounded-2xl border border-border/50 bg-background/40 p-4`,children:(0,v.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,v.jsx)(`div`,{className:`min-w-0`,children:(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium`,d(e)),children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>Q(e,{hasSubscription:!t.hasSubscription}),className:r(`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?P(`common.enabled`):P(`limits.statuses.noSubscription`)})]})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:w-[420px]`,children:[(0,v.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,v.jsx)(`span`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`limits.modal.subscriptionPerMonth`)}),(0,v.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.subscriptionPrice,disabled:!t.hasSubscription,onChange:t=>Q(e,{subscriptionPrice:y(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,v.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,v.jsx)(`span`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`limits.modal.monthlyLimit`)}),(0,v.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.monthlyLimit,onChange:t=>Q(e,{monthlyLimit:y(t.target.value)}),className:`h-10 w-full rounded-md border border-border bg-background px-3 text-sm`})]})]})]})},e)})})})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/50 pt-4`,children:[(0,v.jsx)(u,{variant:`ghost`,onClick:ke,disabled:M,"data-testid":`reset-all-settings-drafts`,children:P(`common.reset`)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(u,{variant:`ghost`,onClick:()=>t(!1),disabled:M,children:P(`settings.modal.close`)}),(0,v.jsx)(u,{onClick:()=>void Oe(),disabled:M,children:P(`settings.modal.save`)})]})]})]})})}export{C as SettingsModal};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,h as i,l as a,m as o,p as s,t as c,v as l,w as u}from"./charts-vendor-CiBqdKXh.js";import{a as d}from"./motion-vendor-vKc6gXHZ.js";import{t as f}from"./useTranslation-BSl7t2D6.js";import{a as p,n as m,t as h}from"./formatters-yKppUXb3.js";import{t as g}from"./help-content-Bt5KCpWS.js";import{n as _,r as v,t as y}from"./ChartCard-CBUnItl-.js";import{t as b}from"./CustomTooltip-CBVU1pyK.js";import{n as x,r as S,t as C}from"./chart-theme-D5iCFDJg.js";import{o as w}from"./calculations-GOdNqKo6.js";var T=e(u()),E=d();function D({data:e}){let{t:u}=f(),d=(0,T.useId)().replace(/:/g,``),{chartData:D,avg:O}=(0,T.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=w(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 D.length<3?null:(0,E.jsx)(_,{title:u(`charts.tokenEfficiency.title`),subtitle:u(`charts.tokenEfficiency.subtitle`,{value:m(O)}),info:g.tokenEfficiency,chartData:D,valueKey:`efficiency`,valueFormatter:m,children:(0,E.jsx)(y,{children:e=>(0,E.jsx)(v,{variant:`line`,children:(0,E.jsx)(t,{width:`100%`,height:250,children:(0,E.jsxs)(c,{data:D,margin:S,children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`${d}-effGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:x.input,stopOpacity:.2}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:x.input,stopOpacity:0})]})}),(0,E.jsx)(o,{strokeDasharray:`3 3`,stroke:x.grid,opacity:.3}),(0,E.jsx)(a,{dataKey:`date`,tickFormatter:p,stroke:x.axis,fontSize:11,tickLine:!1}),(0,E.jsx)(n,{tickFormatter:e=>{let t=h(e);return t===null?``:m(t)},stroke:x.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,E.jsx)(l,{content:(0,E.jsx)(b,{formatter:e=>m(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,E.jsx)(i,{y:O,stroke:x.axis,strokeDasharray:`3 3`,strokeOpacity:.5}),(0,E.jsx)(r,{type:`monotone`,dataKey:`efficiency`,stroke:x.input,fill:`url(#${d}-effGrad)`,strokeWidth:1.5,name:u(`charts.tokenEfficiency.series`),dot:!1,isAnimationActive:e,animationDuration:C.duration}),(0,E.jsx)(s,{type:`monotone`,dataKey:`effMA7`,stroke:x.ma7,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:u(`charts.tokenEfficiency.movingAverage`),isAnimationActive:e,animationBegin:C.stagger,animationDuration:C.slowDuration})]})})})})})}export{D as TokenEfficiency};
@@ -0,0 +1 @@
1
+ import{_ as e,b as t,g as n,i as r,v as i,y as a}from"./charts-vendor-CiBqdKXh.js";import{a as o}from"./motion-vendor-vKc6gXHZ.js";import{t as s}from"./useTranslation-BSl7t2D6.js";import{d as c}from"./formatters-yKppUXb3.js";import{t as l}from"./help-content-Bt5KCpWS.js";import{n as u,r as d,t as f}from"./ChartCard-CBUnItl-.js";import{t as p}from"./CustomTooltip-CBVU1pyK.js";import{n as m,t as h}from"./chart-theme-D5iCFDJg.js";var g=o(),_={Input:m.input,Output:m.output,"Cache Write":m.cacheWrite,"Cache Read":m.cacheRead,Thinking:m.cost};function v({viewBox:e,total:t}){let{t:n}=s();if(!e)return null;let{cx:r,cy:i}=e;return(0,g.jsxs)(`g`,{children:[(0,g.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.tokenTypes.total`)}),(0,g.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function y({data:o}){let{t:y}=s(),b=o.reduce((e,t)=>e+t.value,0);return(0,g.jsx)(u,{title:y(`charts.tokenTypes.title`),subtitle:y(`charts.tokenTypes.subtitle`),info:l.tokenTypes,chartData:o,valueKey:`value`,valueFormatter:c,children:s=>{let l=s?560:320,u=s?`66%`:`57%`,y=s?84:58,x=s?134:92;return(0,g.jsx)(f,{children:f=>(0,g.jsx)(d,{variant:`radial`,children:(0,g.jsx)(t,{width:`100%`,height:l,children:(0,g.jsxs)(r,{children:[(0,g.jsxs)(n,{data:o,cx:`50%`,cy:u,innerRadius:y,outerRadius:x,paddingAngle:2,dataKey:`value`,nameKey:`name`,isAnimationActive:f,animationDuration:h.duration,animationBegin:h.stagger,animationEasing:h.easing,children:[o.map(t=>(0,g.jsx)(e,{fill:_[t.name]??m.cost},t.name)),(0,g.jsx)(v,{total:c(b)})]}),(0,g.jsx)(i,{content:(0,g.jsx)(p,{formatter:e=>c(e)})}),(0,g.jsx)(a,{wrapperStyle:{fontSize:`12px`,paddingTop:s?`22px`:`8px`},formatter:e=>{let t=o.find(t=>t.name===e);return(0,g.jsxs)(`span`,{className:`text-xs text-foreground`,children:[e,` (`,t?c(t.value):``,`)`]})}})]})})})})}})}export{y as TokenTypes};