libre-webui 0.43.0 → 0.44.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 (154) hide show
  1. package/README.md +2 -0
  2. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  3. package/backend/dist/services/agentCliService.js +3 -0
  4. package/backend/dist/services/agentCliService.js.map +1 -1
  5. package/backend/dist/services/pluginService.d.ts.map +1 -1
  6. package/backend/dist/services/pluginService.js +12 -9
  7. package/backend/dist/services/pluginService.js.map +1 -1
  8. package/backend/dist/services/workAgentHostLogins.d.ts.map +1 -1
  9. package/backend/dist/services/workAgentHostLogins.js +4 -0
  10. package/backend/dist/services/workAgentHostLogins.js.map +1 -1
  11. package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
  12. package/backend/dist/services/workModelProviderService.js +13 -1
  13. package/backend/dist/services/workModelProviderService.js.map +1 -1
  14. package/backend/dist/utils/pluginChatAdapter.d.ts +15 -1
  15. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  16. package/backend/dist/utils/pluginChatAdapter.js +84 -14
  17. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  18. package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
  19. package/backend/dist/utils/pluginDefinitionTrust.js +7 -5
  20. package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
  21. package/backend/dist/utils/pluginModelCatalog.d.ts +10 -0
  22. package/backend/dist/utils/pluginModelCatalog.d.ts.map +1 -1
  23. package/backend/dist/utils/pluginModelCatalog.js +24 -0
  24. package/backend/dist/utils/pluginModelCatalog.js.map +1 -1
  25. package/backend/package.json +2 -2
  26. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  27. package/frontend/dist/artifact-runtime/babel.js +179 -173
  28. package/frontend/dist/artifact-runtime/chart.js +1 -1
  29. package/frontend/dist/artifact-runtime/d3.js +4 -4
  30. package/frontend/dist/artifact-runtime/framer-motion.js +2 -10
  31. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  32. package/frontend/dist/artifact-runtime/mathjs.js +1 -1
  33. package/frontend/dist/artifact-runtime/mermaid.js +368 -368
  34. package/frontend/dist/artifact-runtime/plotly.js +59 -59
  35. package/frontend/dist/artifact-runtime/recharts.js +45 -45
  36. package/frontend/dist/artifact-runtime/tailwind.js +18 -18
  37. package/frontend/dist/artifact-runtime/three.js +419 -397
  38. package/frontend/dist/artifact-runtime/tone.js +1 -1
  39. package/frontend/dist/assets/index-BM0txgxR.css +2 -0
  40. package/frontend/dist/assets/index-CYJjXpq5.js +34 -0
  41. package/frontend/dist/assets/{markdown-math-Ngnvt50Q.css → markdown-math-Bv5fr4tV.css} +1 -1
  42. package/frontend/dist/index.html +30 -30
  43. package/frontend/dist/js/{ArtifactContainer-C0R4kYVM.js → ArtifactContainer-C2PgJwen.js} +1 -1
  44. package/frontend/dist/js/{ArtifactDemoPage-BQmbCyat.js → ArtifactDemoPage-Dcy-lVrh.js} +2 -2
  45. package/frontend/dist/js/{ArtifactSandboxFrame-CkDkrHpg.js → ArtifactSandboxFrame-C7gLjHfY.js} +6 -6
  46. package/frontend/dist/js/ArtifactSlideOutPanel-BKZQ7VwV.js +1 -0
  47. package/frontend/dist/js/{AutomationModal-Cx1e_4df.js → AutomationModal-zImHyodn.js} +1 -1
  48. package/frontend/dist/js/AutomationsPage-BuJ1Y810.js +1 -0
  49. package/frontend/dist/js/{AvatarUpload-DGRQC20B.js → AvatarUpload-BECcVNWc.js} +1 -1
  50. package/frontend/dist/js/{Button-DwZ26Lqc.js → Button-BGE6ZJv5.js} +1 -1
  51. package/frontend/dist/js/CalendarPage-hF8Gk80e.js +1 -0
  52. package/frontend/dist/js/ChannelsPage-Bb7qgmXS.js +1 -0
  53. package/frontend/dist/js/ChatPage-BkMm-S6C.js +14 -0
  54. package/frontend/dist/js/ConnectModels-DVd2RDUM.js +1 -0
  55. package/frontend/dist/js/EvaluationsPage-D_R88N9b.js +2 -0
  56. package/frontend/dist/js/FirstTimeSetup-CQQUhpPj.js +1 -0
  57. package/frontend/dist/js/GalleryPage-BYyAx84l.js +1 -0
  58. package/frontend/dist/js/HomePage-BRjiDJZa.js +1 -0
  59. package/frontend/dist/js/{LanguageSwitcher-CASJ8p5d.js → LanguageSwitcher-0vFsK1v-.js} +1 -1
  60. package/frontend/dist/js/{Logo-C-qwuy58.js → Logo-GlNrhpKp.js} +1 -1
  61. package/frontend/dist/js/{LogoMark-zP-mitdI.js → LogoMark-rgOHhWo-.js} +1 -1
  62. package/frontend/dist/js/{ModelManagerModals-BYhFWv22.js → ModelManagerModals-BK0iqnHd.js} +1 -1
  63. package/frontend/dist/js/NotesPage-DD6EntAT.js +3 -0
  64. package/frontend/dist/js/{PasswordStrengthMeter-Dow8ZeTs.js → PasswordStrengthMeter-DrXjBWiT.js} +1 -1
  65. package/frontend/dist/js/PersonasPage-CkGtixCB.js +13 -0
  66. package/frontend/dist/js/PluginUsagePage-BBfqotzy.js +1 -0
  67. package/frontend/dist/js/{RichMessageContent-DJTLGpws.js → RichMessageContent-BcBbr-Q2.js} +1 -1
  68. package/frontend/dist/js/{RichMessageContent-Bwpg3rfV.js → RichMessageContent-Cdz4MI7q.js} +3 -3
  69. package/frontend/dist/js/SettingsModal-CKtlOet9.js +19 -0
  70. package/frontend/dist/js/SettingsToggle-BT6cbOnw.js +1 -0
  71. package/frontend/dist/js/{ShareDialog-DYwyeyaI.js → ShareDialog-CTZp6YtI.js} +1 -1
  72. package/frontend/dist/js/StrandsPage-BYY6YV5N.js +1 -0
  73. package/frontend/dist/js/{SystemPage-B4qFsAsb.js → SystemPage-DaDG0V07.js} +1 -1
  74. package/frontend/dist/js/{TurnstileWidget-xx9lQV0b.js → TurnstileWidget-B_dl1YjT.js} +1 -1
  75. package/frontend/dist/js/{UserManagementPage-DhMRuhqj.js → UserManagementPage-BrogyZDQ.js} +1 -1
  76. package/frontend/dist/js/UserManagementPanel-B7SuWPQg.js +1 -0
  77. package/frontend/dist/js/{WhatsNewModal-DfR7W93-.js → WhatsNewModal-DgMfeACt.js} +1 -1
  78. package/frontend/dist/js/WorkPage-CVcyA61Q.js +7 -0
  79. package/frontend/dist/js/api-BSMl2Tok.js +1 -0
  80. package/frontend/dist/js/api-Bje32kcr.js +16 -0
  81. package/frontend/dist/js/{appNavigation-BifMRN3D.js → appNavigation-6Vs8h0Iv.js} +1 -1
  82. package/frontend/dist/js/{appStore-B6pAGo3p.js → appStore-DmeFFzzj.js} +2 -2
  83. package/frontend/dist/js/appVersion-DWwbhdm2.js +1 -0
  84. package/frontend/dist/js/authStore-DQ-PhUey.js +1 -0
  85. package/frontend/dist/js/{authStore-DdIb6km_.js → authStore-DUmjkugT.js} +3 -3
  86. package/frontend/dist/js/chatStore-Di86sm3T.js +3 -0
  87. package/frontend/dist/js/{client-D_F_0LqX.js → client-DIxMEDnJ.js} +2 -2
  88. package/frontend/dist/js/{config-CHUQTU6j.js → config-HBTc75oS.js} +1 -1
  89. package/frontend/dist/js/{evaluationsApi-C0FKNJua.js → evaluationsApi-CJ9eIoSl.js} +1 -1
  90. package/frontend/dist/js/logger-DAQsBb8I.js +1 -0
  91. package/frontend/dist/js/markdown-html-DRL6swKb.js +2 -0
  92. package/frontend/dist/js/{markdown-math-BzLEmswF.js → markdown-math-CCWDDhWR.js} +3 -3
  93. package/frontend/dist/js/{markdownHtml-B1Ll_Qgp.js → markdownHtml-DpKMtcCu.js} +1 -1
  94. package/frontend/dist/js/markdownMath-CKB9Q-yN.js +1 -0
  95. package/frontend/dist/js/{messageCodeStyles-DVYyK8wm.js → messageCodeStyles-C0H1Lad5.js} +1 -1
  96. package/frontend/dist/js/rfb-xHgMEWMb.js +5 -0
  97. package/frontend/dist/js/router-vendor-DLHZHk4K.js +1 -0
  98. package/frontend/dist/js/{strandsApi-CeJLezXW.js → strandsApi-Cuqp8JZv.js} +1 -1
  99. package/frontend/dist/js/{teamEventStream-DOMyufrH.js → teamEventStream-DHeJw2eu.js} +1 -1
  100. package/frontend/dist/js/ui-BPtWIxXL.js +2 -0
  101. package/frontend/dist/js/ui-vendor-Bac5e8jE.js +1 -0
  102. package/frontend/dist/js/useChat-DjRbGblw.js +13 -0
  103. package/frontend/dist/js/useDictation-C31FhomS.js +1 -0
  104. package/frontend/dist/js/useQuery-DCqz3UJt.js +1 -0
  105. package/frontend/dist/js/{useTranslation-D9EScZXH.js → useTranslation-D-_KTORQ.js} +1 -1
  106. package/frontend/dist/js/utils-DsCVr_wG.js +1 -0
  107. package/frontend/dist/js/workApi-D4JbAtE2.js +1 -0
  108. package/frontend/dist/js/workApi-Dkf48LjA.js +5 -0
  109. package/package.json +3 -3
  110. package/plugins/anthropic.json +1 -0
  111. package/plugins/baseten.json +68 -0
  112. package/plugins/codex-oauth.json +1 -0
  113. package/plugins/meta.json +1 -0
  114. package/plugins/modal.json +82 -0
  115. package/plugins/openai.json +2 -1
  116. package/plugins/openrouter.json +1 -0
  117. package/frontend/dist/assets/index-BnbO3eTY.js +0 -83
  118. package/frontend/dist/assets/index-CYKYBgsy.css +0 -2
  119. package/frontend/dist/js/ArtifactSlideOutPanel-DZnVzC0c.js +0 -1
  120. package/frontend/dist/js/AutomationsPage-D7UtYZ_0.js +0 -1
  121. package/frontend/dist/js/CalendarPage-WmA1i7MQ.js +0 -1
  122. package/frontend/dist/js/ChannelsPage-Bq4JQPR_.js +0 -1
  123. package/frontend/dist/js/ChatPage-Cd3fxx-N.js +0 -14
  124. package/frontend/dist/js/ConnectModels-BYul-veF.js +0 -1
  125. package/frontend/dist/js/EvaluationsPage-CV_Terzn.js +0 -2
  126. package/frontend/dist/js/FirstTimeSetup-CFhGy9a8.js +0 -1
  127. package/frontend/dist/js/GalleryPage-BRKZyq1w.js +0 -1
  128. package/frontend/dist/js/HomePage-DdpnBu-Z.js +0 -1
  129. package/frontend/dist/js/NotesPage-CmvVoWcH.js +0 -3
  130. package/frontend/dist/js/PersonasPage-BYKtoKWl.js +0 -13
  131. package/frontend/dist/js/PluginUsagePage-BVTOCxoE.js +0 -1
  132. package/frontend/dist/js/SettingsModal-CGyVfxOz.js +0 -19
  133. package/frontend/dist/js/SettingsToggle-BpD6NSri.js +0 -1
  134. package/frontend/dist/js/StrandsPage-CvXeYOYR.js +0 -1
  135. package/frontend/dist/js/UserManagementPanel-BVLSvRwa.js +0 -1
  136. package/frontend/dist/js/WorkPage-DSKBQEW0.js +0 -7
  137. package/frontend/dist/js/api-C5ps_CWQ.js +0 -1
  138. package/frontend/dist/js/api-D6IF0v9_.js +0 -16
  139. package/frontend/dist/js/appVersion-9UMn7b1T.js +0 -1
  140. package/frontend/dist/js/authStore-CDo5Co2D.js +0 -1
  141. package/frontend/dist/js/chatStore-hzQyRM9H.js +0 -3
  142. package/frontend/dist/js/logger-rEW7uQ8m.js +0 -1
  143. package/frontend/dist/js/markdown-html-BdYVneHE.js +0 -2
  144. package/frontend/dist/js/markdownMath-aI8uDQmz.js +0 -1
  145. package/frontend/dist/js/rfb-IV07oQgM.js +0 -5
  146. package/frontend/dist/js/router-vendor-qltZAWoz.js +0 -1
  147. package/frontend/dist/js/ui-D4Ytvr6d.js +0 -2
  148. package/frontend/dist/js/ui-vendor-BTcw5yZ6.js +0 -1
  149. package/frontend/dist/js/useChat-BEbNywiP.js +0 -13
  150. package/frontend/dist/js/useDictation-jTaorrHm.js +0 -1
  151. package/frontend/dist/js/useQuery-2_pQiHbl.js +0 -1
  152. package/frontend/dist/js/utils-BvvV-Cka.js +0 -1
  153. package/frontend/dist/js/workApi-CGvfDTRY.js +0 -1
  154. package/frontend/dist/js/workApi-_0oxRyak.js +0 -5
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{t as r}from"./useQuery-DCqz3UJt.js";import{t as i}from"./useTranslation-D-_KTORQ.js";import{An as a,Cr as o,Dr as s,Kn as c,Q as l,Rt as u,Vn as d,Y as f,dr as p,er as m,g as h,nt as g,s as _,un as v,v as y}from"./ui-vendor-Bac5e8jE.js";import{o as b,s as x}from"./ui-BPtWIxXL.js";import{t as S}from"./Button-BGE6ZJv5.js";import{t as C}from"./client-DIxMEDnJ.js";import{u as w}from"./api-Bje32kcr.js";import{t as T}from"./utils-DsCVr_wG.js";var E=e(t(),1),D={getAnalytics:e=>C.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>C.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>C.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>C.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>C.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>C.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>C.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>C.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},O=n(),k=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),A=`w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dark-300 dark:bg-dark-50`,j=({days:e})=>{let{t}=i(),[n,r]=(0,E.useState)(null),[o,c]=(0,E.useState)([]),[l,d]=(0,E.useState)([]),[f,p]=(0,E.useState)(!0),[m,h]=(0,E.useState)(0),[_,v]=(0,E.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,x]=(0,E.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,E.useEffect)(()=>{let n=!1;return Promise.all([D.getAnalytics(e),D.listTariffs(),D.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&c(t.data),i.success&&i.data&&d(i.data))}).catch(()=>s.error(t(`costs.loadFailed`))).finally(()=>{n||p(!1)}),()=>{n=!0}},[e,m,t]);let C=e=>{if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0},w=async()=>{try{let e=await D.createTariff({pluginId:_.pluginId.trim(),model:_.model.trim()||void 0,inputPerMillion:C(_.inputPerMillion),outputPerMillion:C(_.outputPerMillion),unitPrice:C(_.unitPrice)});if(!e.success)throw Error(e.message);s.success(t(`costs.tariffSaved`)),v({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),h(e=>e+1)}catch(e){s.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},T=async()=>{try{let e=await D.createBudget({name:b.name.trim(),principalType:b.principalType,principalId:b.principalType===`instance`?void 0:b.principalId.trim(),period:b.period,amountUsd:Number(b.amountUsd),mode:b.mode});if(!e.success)throw Error(e.message);s.success(t(`costs.budgetSaved`)),x({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),h(e=>e+1)}catch(e){s.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await D.exportCsv(e),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`libre-webui-costs.csv`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch{s.error(t(`costs.exportFailed`))}};return f&&!n?(0,O.jsx)(`div`,{className:`flex justify-center rounded-lg border border-gray-200 bg-white p-6 dark:border-dark-300 dark:bg-dark-100`,children:(0,O.jsx)(u,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,O.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,"data-testid":`cost-governance-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,O.jsxs)(S,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,O.jsx)(a,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,O.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:k(n.totalUsd)})]}),(0,O.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,O.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,O.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,O.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${k(n.byModel[0].usd)})`:`—`})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,O.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-gray-500`,children:[t(`costs.mode.${e.mode}`),` ·`,` `,t(`costs.period.${e.period}`),` ·`,` `,e.principalType===`instance`?t(`costs.scope.instance`):`${t(`costs.scope.${e.principalType}`)}: ${e.principalId}`]})]}),(0,O.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[k(e.spentUsd),` / `,k(e.amountUsd)]}),(0,O.jsx)(`button`,{onClick:()=>{D.deleteBudget(e.id).then(()=>h(e=>e+1)).catch(()=>s.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded-sm p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,O.jsx)(y,{className:`h-3.5 w-3.5`})})]}),(0,O.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-sm bg-gray-200 dark:bg-dark-300`,children:(0,O.jsx)(`div`,{className:n>=1?`h-full bg-red-500`:n>=.8?`h-full bg-amber-500`:`h-full bg-emerald-500`,style:{width:`${Math.round(n*100)}%`}})})]},e.id)}),l.length===0&&(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,O.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>x({...b,name:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:b.principalType,onChange:e=>x({...b,principalType:e.target.value}),children:[(0,O.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,O.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,O.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>x({...b,principalId:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:b.period,onChange:e=>x({...b,period:e.target.value}),children:[(0,O.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,O.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,O.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{className:A,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>x({...b,amountUsd:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:b.mode,onChange:e=>x({...b,mode:e.target.value}),children:[(0,O.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,O.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,O.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,O.jsxs)(S,{size:`sm`,onClick:()=>void T(),children:[(0,O.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,O.jsx)(`div`,{className:`overflow-x-auto`,children:(0,O.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,O.jsx)(`thead`,{className:`text-gray-500`,children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,O.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,O.jsx)(`th`,{})]})}),(0,O.jsxs)(`tbody`,{children:[o.map(e=>(0,O.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:k(e.input_per_million)}),(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:k(e.output_per_million)}),(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:k(e.unit_price)}),(0,O.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,O.jsx)(`td`,{className:`py-1`,children:(0,O.jsx)(`button`,{onClick:()=>{D.deleteTariff(e.id).then(()=>h(e=>e+1)).catch(()=>s.error(t(`costs.saveFailed`)))},className:`rounded-sm p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,O.jsx)(y,{className:`h-3.5 w-3.5`})})})]},e.id)),o.length===0&&(0,O.jsx)(`tr`,{children:(0,O.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,O.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.plugin`),value:_.pluginId,onChange:e=>v({..._,pluginId:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.modelOptional`),value:_.model,onChange:e=>v({..._,model:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:_.inputPerMillion,onChange:e=>v({..._,inputPerMillion:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:_.outputPerMillion,onChange:e=>v({..._,outputPerMillion:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:_.unitPrice,onChange:e=>v({..._,unitPrice:e.target.value})}),(0,O.jsxs)(S,{size:`sm`,onClick:()=>void w(),children:[(0,O.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},M={strands:`Strands`,"claude-code":`Claude Code`,codex:`Codex`,kiro:`Kiro`,muse:`Muse Code`,opencode:`OpenCode`,pi:`Pi`},N=e=>{if(e.startsWith(`agent-cli:`))return e.slice(10)||void 0};function P(e){if(e.agents!==void 0)return e.agents;let t=new Map;for(let n of e.plugins){let e=N(n.pluginId);if(!e)continue;let r=t.get(e)??{agentId:e,agentName:M[e]??n.pluginName,calls:0,tokens:0,errors:0,averageLatencyMs:0,models:[]},i=r.calls+n.calls;r.averageLatencyMs=i?(r.averageLatencyMs*r.calls+n.averageLatencyMs*n.calls)/i:0,r.calls=i,r.tokens+=n.tokens,r.errors+=n.errors,t.set(e,r)}for(let n of e.models){let e=N(n.pluginId),r=e?t.get(e):void 0;if(!r)continue;let i=r.models.find(e=>e.model===n.model);i?(i.calls+=n.calls,i.tokens+=n.tokens,i.errors+=n.errors):r.models.push({model:n.model,calls:n.calls,tokens:n.tokens,errors:n.errors})}return[...t.values()]}var F=[`#3b82f6`,`#059669`,`#db683c`,`#8b5cf6`,`#e11d48`,`#0891b2`,`#a16207`,`#db2777`,`#0d9488`,`#6366f1`,`#65a30d`,`#a855f7`,`#4879a8`,`#9d6c34`,`#c25280`,`#6f7d35`,`#5363bb`],I=`#6b7280`,L=e=>{let t=e*137.508%360,n=e=>{let n=.65*Math.min(e,1-e);return[0,8,4].map(r=>{let i=(r+t/30)%12;return e-n*Math.max(-1,Math.min(i-3,9-i,1))})},r=0,i=1;for(let e=0;e<16;e++){let e=(r+i)/2,t=n(e).map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);t[0]*.2126+t[1]*.7152+t[2]*.0722<.2?r=e:i=e}return`#${n((r+i)/2).map(e=>Math.round(e*255).toString(16).padStart(2,`0`)).join(``)}`},R=e=>e===null?`other`:`model:${e}`;function z(e,t){return e.range.from===t.range.from&&e.range.to===t.range.to&&e.series.length===t.series.length&&e.series.every((e,n)=>{let r=t.series[n];return e.timestamp===r.timestamp&&e.calls===r.calls&&e.tokens===r.tokens&&e.errors===r.errors})}function ee(e){return e.modelSeries?.length?e.modelSeries.map(e=>({...e,key:R(e.model)})):[{key:`total`,model:void 0,points:e.series}]}function te(e){let t=e.heatmap?.models??[],n=(e.modelSeries??[]).flatMap(e=>e.model===null?[]:[e.model]).filter(e=>!t.includes(e)).sort(),r=new Set([...t,...e.heatmap?.cells.flatMap(e=>e.models.map(e=>e.model))??[],...e.modelSeries?.flatMap(e=>e.model===null?[]:[e.model])??[],...e.models.map(e=>e.model)]),i=[...t,...n,...[...r].filter(e=>!t.includes(e)&&!n.includes(e)).sort()],a=new Map([[`other`,I],[`total`,I]]);return i.forEach((e,t)=>{a.set(R(e),F[t]??L(t))}),a}function ne(e,t,n,r){let i=e.models.filter(e=>e.pluginId===t&&(r===void 0||e.pluginName===r)&&e.calls>0).map(({model:e,calls:t})=>({model:e,calls:t})),a=n-i.reduce((e,t)=>e+t.calls,0);return a>0?[...i,{model:null,calls:a}]:i}function re({analytics:e,metric:t,onMetricChange:n,colors:r,highlighted:a,selected:o,loadingModel:s,canLoadModels:c=!1,onHighlight:l,onSelect:u}){let{t:d,i18n:p}=i(),h=(0,E.useMemo)(()=>ee(e),[e]),g=(0,E.useRef)(null),[_,v]=(0,E.useState)(960),[y,b]=(0,E.useState)();(0,E.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(e=>{v(Math.max(280,e[0].contentRect.width))});return t.observe(e),()=>t.disconnect()},[]);let x=(e,t=!1)=>new Intl.NumberFormat(p.language,{notation:t&&e>=1e4?`compact`:`standard`,maximumFractionDigits:+!!t}).format(e),S=new Intl.DateTimeFormat(p.language,{month:`short`,day:`numeric`,timeZone:`UTC`}),C=e=>e===void 0?d(`usageAnalytics.activity.allModels`):e===null?d(`usageAnalytics.heatmap.other`):e||`—`,w={top:18,right:20,bottom:32,left:48},D=_-w.left-w.right,k=260-w.top-w.bottom,A=Math.max(1,...h.flatMap(e=>e.points.map(e=>e[t]))),j=Math.ceil(A/4)*4,M=e.series.reduce((e,n)=>e+n[t],0),N=t===`tokens`&&M===0,P=t=>w.left+(e.series.length<=1?D/2:t/(e.series.length-1)*D),F=e=>w.top+k-e/j*k,I=e.series.findIndex(e=>e.timestamp===y),L=I<0?Math.max(0,e.series.length-1):I,R=e.series[L],z=h.find(e=>e.key===a),te=[...new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])].filter(e=>e>=0),ne=h.map(e=>({...e,value:e.points[L]?.[t]??0})).sort((e,t)=>t.value-e.value),re=e=>e.map((e,n)=>`${n===0?`M`:`L`} ${P(n)} ${F(e[t])}`).join(` `);return(0,O.jsxs)(`section`,{"data-testid":`plugin-usage-chart`,"aria-busy":s!==void 0,className:`min-w-0 overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle dark:border-white/8 dark:bg-dark-100/75`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-gray-200/70 px-4 py-4 dark:border-white/[0.07] sm:px-5`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:d(`usageAnalytics.activity.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:d(`usageAnalytics.activity.${t===`calls`?`callsDescription`:`tokensDescription`}`)})]}),(0,O.jsx)(`div`,{className:`inline-flex rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:T(`min-h-9 rounded-lg px-3 text-xs font-medium focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500`,t===e?`bg-white text-gray-950 shadow-xs dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),onClick:()=>n(e),children:d(`usageAnalytics.metrics.${e}`)},e))})]}),(0,O.jsxs)(`div`,{className:`px-4 pt-4 sm:px-5`,children:[(0,O.jsxs)(`div`,{className:`mb-3 flex min-h-8 flex-wrap items-center justify-between gap-2`,children:[(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:d(`usageAnalytics.activity.compareHint`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:!o&&!a,className:T(`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-gray-700 hover:bg-gray-100 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-primary-500 dark:text-dark-800 dark:hover:bg-dark-200`,!o&&!a&&`invisible`),onClick:()=>{u(void 0),l(void 0)},children:[(0,O.jsx)(f,{className:`h-3.5 w-3.5`}),d(`usageAnalytics.activity.showAll`)]})]}),(0,O.jsx)(`div`,{"data-testid":`usage-model-legend`,className:T(`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,c&&`h-48 content-start overflow-y-auto pe-1`),children:h.map(e=>{let n=a===e.key,i=o===e.key,s=r.get(e.key)??`#6b7280`,c=e.points.reduce((e,n)=>e+n[t],0);return(0,O.jsxs)(`button`,{type:`button`,"aria-pressed":i,"aria-label":C(e.model),title:C(e.model),onMouseEnter:()=>l(e.key),onMouseLeave:()=>l(void 0),onFocus:()=>l(e.key),onBlur:()=>l(void 0),onClick:()=>u(i?void 0:e.key),className:T(`flex min-h-11 min-w-0 items-center gap-2.5 rounded-xl border px-3 py-2 text-start focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500`,n?`border-gray-400 bg-gray-50 dark:border-dark-500 dark:bg-dark-200`:`border-gray-200/70 hover:bg-gray-50 dark:border-white/[0.07] dark:hover:bg-dark-200/70`),children:[(0,O.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:s},"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-gray-800 dark:text-dark-900`,dir:`auto`,children:C(e.model)}),(0,O.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:x(c,!0)}),i&&(0,O.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-gray-800 dark:text-dark-900`,"aria-hidden":`true`})]},e.key)})}),(c||h.some(e=>e.model===null))&&(0,O.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-dark-500`,children:d(`usageAnalytics.activity.topModels`)}),h[0]?.model===void 0&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:d(`usageAnalytics.activity.breakdownUnavailable`)})]}),(0,O.jsx)(`div`,{className:`relative mx-3 mt-4 sm:mx-5`,ref:g,children:N?(0,O.jsx)(`div`,{className:`flex h-[260px] items-center justify-center text-sm text-gray-500 dark:text-dark-500`,children:d(`usageAnalytics.activity.noTokens`)}):(0,O.jsxs)(`svg`,{viewBox:`0 0 ${_} 260`,direction:`ltr`,className:`block h-[260px] w-full touch-pan-y`,role:`img`,"aria-label":d(`usageAnalytics.activity.chartLabel`,{metric:d(`usageAnalytics.metrics.${t}`)}),onPointerMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=(t.clientX-n.left)*_/n.width,i=Math.round(Math.max(0,Math.min(1,(r-w.left)/D))*(e.series.length-1));e.series[i]&&b(e.series[i].timestamp)},children:[(0,O.jsx)(`title`,{children:d(`usageAnalytics.activity.chartLabel`,{metric:d(`usageAnalytics.metrics.${t}`)})}),[0,.25,.5,.75,1].map(e=>{let t=w.top+k*e;return(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:w.left,x2:_-w.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`3 6`}),(0,O.jsx)(`text`,{x:w.left-9,y:t+4,textAnchor:`end`,className:`fill-gray-500 text-[11px] dark:fill-dark-500`,children:x(Math.round(j*(1-e)),!0)})]},e)}),R&&(0,O.jsx)(`line`,{x1:P(L),x2:P(L),y1:w.top,y2:260-w.bottom,className:`stroke-gray-300 dark:stroke-dark-400`,strokeDasharray:`3 4`}),[...h].sort((e,t)=>Number(e.key===a)-Number(t.key===a)).map(e=>{let n=e.key===a,i=r.get(e.key)??`#6b7280`,o=e.points[L];return(0,O.jsxs)(`g`,{opacity:a&&!n?.18:1,children:[(0,O.jsx)(`path`,{"data-testid":`usage-model-line`,"data-model":e.model===void 0?`__total__`:e.model??`__other__`,"data-highlighted":n,d:re(e.points),stroke:i,fill:`none`,strokeWidth:n?3.5:2,strokeDasharray:e.model===null?`6 4`:void 0,strokeLinecap:`round`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`,children:(0,O.jsx)(`title`,{children:C(e.model)})}),o&&(0,O.jsx)(`circle`,{cx:P(L),cy:F(o[t]),r:n?5:3.5,fill:i,className:`stroke-white dark:stroke-dark-100`,strokeWidth:`2`})]},e.key)}),te.map(t=>(0,O.jsx)(`text`,{x:P(t),y:252,textAnchor:t===0?`start`:t===e.series.length-1?`end`:`middle`,className:`fill-gray-500 text-[11px] dark:fill-dark-500`,children:S.format(e.series[t].timestamp)},t))]})}),R&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200/70 px-4 py-4 dark:border-white/[0.07] sm:px-5`,children:[(0,O.jsxs)(`label`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2 text-xs text-gray-500 dark:text-dark-500`,children:[(0,O.jsx)(`span`,{children:d(`usageAnalytics.activity.exploreDay`)}),(0,O.jsx)(`span`,{className:`text-gray-800 dark:text-dark-800`,children:S.format(R.timestamp)}),(0,O.jsx)(`input`,{"data-testid":`usage-chart-day-slider`,type:`range`,min:0,max:Math.max(0,e.series.length-1),step:1,value:L,"aria-label":d(`usageAnalytics.activity.exploreDay`),"aria-valuetext":S.format(R.timestamp),onChange:t=>b(e.series[Number(t.target.value)]?.timestamp),className:`h-6 w-full cursor-pointer accent-gray-700 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-primary-500 dark:accent-gray-300`,dir:`ltr`})]}),(0,O.jsxs)(`div`,{"data-testid":`usage-chart-day-detail`,"aria-live":`polite`,"aria-atomic":`true`,children:[(0,O.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline justify-between gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-dark-800`,children:[d(`usageAnalytics.activity.dayTotal`),` ·`,` `,S.format(R.timestamp)]}),(0,O.jsxs)(`span`,{className:`text-sm font-medium tabular-nums text-gray-950 dark:text-dark-950`,children:[x(R[t]),` `,d(`usageAnalytics.metrics.${t}`)]})]}),(0,O.jsx)(`div`,{className:T(`grid gap-x-5 gap-y-2 sm:grid-cols-2 lg:grid-cols-3`,c&&`max-h-40 overflow-y-auto`),children:ne.map(e=>(0,O.jsxs)(`div`,{"data-model":e.model===void 0?`__total__`:e.model??`__other__`,className:T(`flex min-w-0 items-center gap-2 text-xs`,a===e.key&&`font-medium`),children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:r.get(e.key)??`#6b7280`}}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-gray-600 dark:text-dark-700`,title:C(e.model),dir:`auto`,children:C(e.model)}),(0,O.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-900 dark:text-dark-900`,children:x(e.value)})]},e.key))}),(0,O.jsx)(`p`,{className:`mt-3 h-4 truncate text-xs font-medium text-gray-600 dark:text-dark-700`,children:s===void 0?z?d(`usageAnalytics.activity.highlightedModel`,{model:C(z.model)}):d(`usageAnalytics.activity.allModels`):d(`usageAnalytics.activity.loadingModel`,{model:s})})]})]})]})}var B=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),V=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),H=e=>e>=1e4?V.format(e):B.format(e),U=e=>e?e<1e3?`${B.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,W=(e,t)=>e===0?0:(e-t)/e*100,G=864e5,K=10,q=12,J=30,Y=16,ie=`fill-gray-950/6 dark:fill-white/[0.07]`,ae=[0,.35,.55,.75,1],oe=({heatmap:e,colors:t,chartModels:n,focusedModel:r})=>{let{t:a,i18n:o}=i(),[s,c]=(0,E.useState)(null),l=[...new Set([...e.models,...n])],u=e=>e!==void 0&&(l.includes(e)||e===r)?t.get(R(e))??`#6b7280`:I,{weeks:d,firstColStart:f,cellsByDay:p,maxCalls:m,totalCalls:h}=(0,E.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*G,i=n-new Date(n).getUTCDay()*G;return{weeks:Math.ceil((r-i+G)/(7*G)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),g=new Intl.DateTimeFormat(o.language,{month:`short`,timeZone:`UTC`}),_=new Intl.DateTimeFormat(o.language,{weekday:`short`,timeZone:`UTC`}),v=new Intl.DateTimeFormat(o.language,{dateStyle:`medium`,timeZone:`UTC`}),y=e.from,b=e.from+(e.days-1)*G,x=J+d*q,S=[],C=-1;for(let e=0;e<d;e++){let t=f+e*7*G,n=Math.max(t,y),r=new Date(n).getUTCMonth();r!==C&&t>=y-6*G&&((C!==-1||t>=y)&&S.push({x:J+e*q,label:g.format(n)}),C=r)}let w=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/m*4))),D=e=>u(e.models[0]?.model),k=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),o=a.left-i.left+a.width/2;c({x:Math.min(Math.max(o,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,O.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`min-w-0 overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/75`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:a(`usageAnalytics.heatmap.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:a(`usageAnalytics.heatmap.description`)})]}),(0,O.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:a(`usageAnalytics.heatmap.yearTotal`,{count:h,formatted:H(h)})})]}),(0,O.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,O.jsx)(`div`,{className:`overflow-x-auto`,children:(0,O.jsxs)(`svg`,{viewBox:`0 0 ${x} 100`,direction:`ltr`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":a(`usageAnalytics.heatmap.title`),onMouseLeave:()=>c(null),children:[S.map(({x:e,label:t})=>(0,O.jsx)(`text`,{x:e,y:10,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:t},`${e}-${t}`)),[1,3,5].map(e=>(0,O.jsx)(`text`,{x:0,y:Y+e*q+K-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:_.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:d},(e,t)=>Array.from({length:7},(e,n)=>{let r=f+(t*7+n)*G;if(r<y||r>b)return null;let i=p.get(r),a=i?.calls??0,o=w(a);return(0,O.jsx)(`rect`,{x:J+t*q,y:Y+n*q,width:K,height:K,rx:2,"data-model":i?.models[0]?.model,fill:i&&o>0?D(i):void 0,fillOpacity:o===0?1:ae[o],strokeWidth:+(s?.timestamp===r),className:T(`motion-safe:transition-opacity`,(o===0||!i)&&ie,s?.timestamp===r?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>k(e,r,{calls:a,models:i?.models??[]}),children:(0,O.jsx)(`title`,{children:`${v.format(r)} — ${H(a)}`})},r)}))]})}),s&&(0,O.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-40 -translate-x-1/2 -translate-y-full rounded-lg border border-gray-200/80 bg-white/95 px-3 py-2 shadow-card backdrop-blur-md dark:border-white/10 dark:bg-dark-100/95`,style:{left:s.x,top:s.y-6},children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:v.format(s.timestamp)}),(0,O.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:s.calls===0?a(`usageAnalytics.heatmap.noCalls`):`${H(s.calls)} ${a(`usageAnalytics.heatmap.calls`)}`}),s.models.slice(0,3).map(e=>(0,O.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,O.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-[3px]`,style:{backgroundColor:u(e.model)}}),(0,O.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,O.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:H(e.calls)})]},e.model))]}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[l.map(e=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,O.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px]`,style:{backgroundColor:t.get(R(e))??`#6b7280`}}),(0,O.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,O.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px]`,style:{backgroundColor:I}}),a(`usageAnalytics.heatmap.other`)]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[a(`usageAnalytics.heatmap.less`),(0,O.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/6 dark:bg-white/[0.07]`}),ae.slice(1).map(e=>(0,O.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-500`,style:{opacity:e}},e)),a(`usageAnalytics.heatmap.more`)]})]})]})]})},se=({analytics:e})=>{let{t}=i(),n=P(e),r=e=>(e.meteredCalls??0)>0||e.tokens>0;return(0,O.jsxs)(`section`,{"data-testid":`usage-agent-breakdown`,"aria-labelledby":`usage-agent-heading`,className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle dark:border-white/8 dark:bg-dark-100/75 sm:p-5`,children:[(0,O.jsxs)(`h2`,{id:`usage-agent-heading`,className:`flex items-center gap-2 text-sm font-medium text-gray-950 dark:text-dark-950`,children:[(0,O.jsx)(p,{className:`h-4 w-4`,"aria-hidden":`true`}),t(`usageAnalytics.agents.title`)]}),(0,O.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.agents.description`)}),e.agents===void 0&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.agents.legacy`)}),(0,O.jsx)(`div`,{className:`mt-4 grid min-w-0 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,O.jsxs)(`article`,{"data-agent":e.agentId,className:`min-w-0 rounded-xl border border-gray-200/70 p-3 dark:border-white/[0.07]`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e.agentName}),(0,O.jsxs)(`dl`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.metrics.calls`)}),(0,O.jsx)(`dd`,{"data-agent-metric":`calls`,className:`mt-1 text-lg tabular-nums text-gray-950 dark:text-dark-950`,children:H(e.calls)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.cards.tokens`)}),(0,O.jsx)(`dd`,{"data-agent-metric":`tokens`,className:`mt-1 text-sm tabular-nums text-gray-950 dark:text-dark-950`,children:r(e)?H(e.tokens):e.calls===0?`—`:e.meteredCalls===0?t(`usageAnalytics.agents.unreported`):`—`})]})]}),e.calls===0?(0,O.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.agents.noCalls`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.cards.latency`),`:`,` `,(0,O.jsx)(`span`,{className:`tabular-nums`,dir:`ltr`,children:U(e.averageLatencyMs)})]}),e.meteredCalls!==void 0&&e.meteredCalls>0&&(0,O.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.cards.tokensDetail`,{count:e.meteredCalls})}),e.errors>0&&(0,O.jsxs)(`p`,{className:`mt-2 flex items-center gap-1 text-xs text-gray-600 dark:text-dark-600`,children:[(0,O.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),t(`usageAnalytics.providers.failures`,{count:e.errors})]}),e.models.length>0&&(0,O.jsxs)(`div`,{className:`mt-3`,children:[(0,O.jsx)(`h4`,{className:`text-xs font-medium text-gray-700 dark:text-dark-700`,children:t(`usageAnalytics.agents.topModels`)}),(0,O.jsx)(`div`,{className:`mt-1 max-h-48 overflow-y-auto`,children:(0,O.jsxs)(`table`,{className:`w-full table-fixed text-start text-xs`,children:[(0,O.jsx)(`thead`,{className:`text-gray-500 dark:text-dark-500`,children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{className:`w-1/2 py-1 text-start font-normal`,children:t(`usageAnalytics.models.model`)}),(0,O.jsx)(`th`,{className:`px-1 py-1 text-end font-normal`,children:t(`usageAnalytics.metrics.calls`)}),(0,O.jsx)(`th`,{className:`py-1 text-end font-normal`,children:t(`usageAnalytics.metrics.tokens`)})]})}),(0,O.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/6`,children:e.models.map(e=>(0,O.jsxs)(`tr`,{"data-agent-model":e.model,children:[(0,O.jsx)(`td`,{className:`wrap-break-word py-1.5 pe-2 text-gray-700 dark:text-dark-700`,children:(0,O.jsx)(`span`,{dir:`auto`,children:e.model})}),(0,O.jsx)(`td`,{className:`px-1 py-1.5 text-end tabular-nums`,children:H(e.calls)}),(0,O.jsx)(`td`,{className:`py-1.5 text-end tabular-nums`,children:r(e)?H(e.tokens):`—`})]},e.model))})]})})]})]})]},e.agentId))})]})},X=()=>{let{t:e}=i(),[t,n]=(0,E.useState)(30),[a,s]=(0,E.useState)(`calls`),[f,m]=(0,E.useState)(),[g,y]=(0,E.useState)(),{data:C,error:D,isLoading:k,isFetching:A,refetch:M}=r({queryKey:[`plugin-usage`,t],refetchInterval:2e4,refetchIntervalInBackground:!1,queryFn:async()=>{let n=await w.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),N=(0,E.useMemo)(()=>new Set(C?ee(C).map(e=>e.key):[]),[C]),P=(0,E.useMemo)(()=>new Set([...N,...C?.models.map(e=>R(e.model))??[]]),[N,C]),F=f&&P.has(f)?f:void 0,I=g&&P.has(g)?g:void 0,L=N.has(`other`),B=(L?[I,F].find(e=>e?.startsWith(`model:`)&&!N.has(e)):void 0)?.slice(6),V=r({queryKey:[`plugin-usage`,t,`model`,B,C?.range.to],enabled:B!==void 0,staleTime:3e4,queryFn:async()=>{let n=await w.getUsage(t,B,C?.range.to);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),G=C,K=!!C&&!!V.data&&z(C,V.data),q=(0,E.useMemo)(()=>C&&B!==void 0&&K?{...C,modelSeries:V.data.modelSeries}:C,[C,B,K,V.data]),J=(0,E.useRef)(null);(0,E.useEffect)(()=>{B!==void 0&&V.data&&!K&&!A&&J.current!==V.data&&(J.current=V.data,M())},[B,V.data,K,A,M]);let Y=D??(B===void 0?null:V.error),ie=Y?Y instanceof Error?Y.message:e(`usageAnalytics.loadFailed`):null,ae=B!==void 0&&!K&&!Y?B:void 0,X=(0,E.useMemo)(()=>C?te(C):new Map,[C]),ce=(0,E.useMemo)(()=>new Set(q?ee(q).map(e=>e.key):[]),[q]),Z=I??F,le=e=>m(e),Q=e=>{if(C?.modelSeries?.length&&(e!==null||N.has(`other`)))return R(e)},$=G?.totals,ue=(0,E.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:H($?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:$?.uniqueUsers??0}),icon:o},{label:e(`usageAnalytics.cards.tokens`),value:H($?.reportedTokens??0),detail:e(`usageAnalytics.cards.coverage`,{percent:$?.calls?($.meteredCalls/$.calls*100).toFixed(1):`0`}),icon:v},{label:e(`usageAnalytics.cards.success`),value:`${W($?.calls??0,($?.failedCalls??0)+($?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:$?.failedCalls??0}),icon:c},{label:e(`usageAnalytics.cards.latency`),value:U($?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:d}],[e,$]);return k&&!G?(0,O.jsx)(x,{width:`wide`,children:(0,O.jsxs)(`div`,{role:`status`,className:`flex min-h-[50vh] items-center justify-center`,children:[(0,O.jsx)(u,{className:`h-7 w-7 motion-safe:animate-spin text-primary-500`}),(0,O.jsx)(`span`,{className:`sr-only`,children:e(`common.loading`)})]})}):(0,O.jsxs)(x,{width:`wide`,children:[(0,O.jsx)(b,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/8 dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,O.jsx)(`button`,{type:`button`,className:T(`min-h-9 rounded-lg px-3 py-1.5 text-xs font-medium motion-safe:transition-colors focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-primary-500`,t===r?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`text-gray-500 hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`),"aria-pressed":t===r,onClick:()=>{n(r),y(void 0)},children:e(`usageAnalytics.days`,{count:r})},r))}),(0,O.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>{M(),B!==void 0&&V.refetch()},disabled:A||B!==void 0&&V.isFetching,children:[(0,O.jsx)(l,{className:T(`h-4 w-4`,A&&`motion-safe:animate-spin`)}),(0,O.jsx)(`span`,{children:e(`usageAnalytics.refresh`)})]})]})}),ie&&(0,O.jsxs)(`div`,{role:`alert`,className:`mb-6 flex items-center gap-3 rounded-2xl border border-error-200 bg-error-50 px-4 py-3 text-sm text-error-700 dark:border-error-900/40 dark:bg-error-900/30 dark:text-error-300`,children:[(0,O.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,O.jsx)(`span`,{children:ie})]}),!G&&(0,O.jsx)(j,{days:t}),G&&(0,O.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:ue.map(e=>{let t=e.icon;return(0,O.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/70`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,O.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,O.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,O.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),(0,O.jsx)(se,{analytics:G}),(0,O.jsx)(j,{days:t}),G.heatmap&&G.heatmap.cells.length>0&&(0,O.jsx)(oe,{heatmap:G.heatmap,colors:X,focusedModel:Z?.startsWith(`model:`)?Z.slice(6):void 0,chartModels:(C?.modelSeries??[]).flatMap(e=>e.model===null?[]:[e.model])}),(0,O.jsx)(re,{analytics:q??G,metric:a,onMetricChange:s,colors:X,highlighted:Z,selected:F,onHighlight:y,onSelect:le,loadingModel:ae,canLoadModels:L}),G.totals.calls===0?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/12`,children:[(0,O.jsx)(p,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,O.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,O.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.empty.description`)})]}):(0,O.jsxs)(`div`,{className:`grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]`,children:[(0,O.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/75`,children:[(0,O.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,O.jsx)(`div`,{className:`overflow-x-auto`,children:(0,O.jsxs)(`table`,{"data-testid":`usage-model-table`,className:`w-full min-w-[620px] text-start text-sm`,children:[(0,O.jsx)(`thead`,{className:`text-[11px] uppercase tracking-widest text-gray-400 dark:text-dark-500`,children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,O.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,O.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,O.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,O.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,O.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/6`,children:G.models.map(t=>(0,O.jsxs)(`tr`,{"data-testid":`usage-model-row`,"data-model":t.model,"data-highlighted":Z===Q(t.model),onMouseEnter:()=>y(Q(t.model)),onMouseLeave:()=>y(void 0),className:T(Z===Q(t.model)&&Z&&`bg-gray-50 dark:bg-dark-200/70`),children:[(0,O.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,O.jsxs)(`button`,{type:`button`,disabled:!Q(t.model),"aria-label":e(`usageAnalytics.activity.highlightModel`,{model:t.model}),"aria-pressed":!!F&&F===Q(t.model),className:`flex min-h-9 max-w-[260px] items-center gap-2 rounded-md text-start font-medium text-gray-900 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:text-dark-900`,title:ce.has(R(t.model))?t.model:e(`usageAnalytics.models.notCharted`),onFocus:()=>y(Q(t.model)),onBlur:()=>y(void 0),onClick:()=>le(F===Q(t.model)?void 0:Q(t.model)),children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:X.get(R(t.model))??`#6b7280`}}),(0,O.jsx)(`span`,{className:`truncate`,dir:`ltr`,children:t.model})]}),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:t.pluginName})]}),(0,O.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[H(t.calls),(0,O.jsxs)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,title:e(`usageAnalytics.models.share`),children:[(t.calls/G.totals.calls*100).toFixed(1),`%`]})]}),(0,O.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:t.tokens?H(t.tokens):`—`}),(0,O.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[W(t.calls,t.errors).toFixed(1),`%`]}),(0,O.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:U(t.averageLatencyMs)})]},JSON.stringify([t.pluginId,t.pluginName,t.model])))})]})})]}),(0,O.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,O.jsxs)(`section`,{"data-testid":`usage-provider-breakdown`,className:`min-w-0 rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle dark:border-white/8 dark:bg-dark-100/75 sm:p-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.providers.description`)}),(0,O.jsx)(`div`,{className:`mt-4 divide-y divide-gray-200/70 dark:divide-white/[0.07]`,children:G.plugins.map(t=>{let n=G.totals.calls?t.calls/G.totals.calls*100:0,r=ne(G,t.pluginId,t.calls,t.pluginName);return(0,O.jsxs)(`article`,{"data-provider":t.pluginId,className:`py-4 first:pt-0 last:pb-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h3`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,title:t.pluginName,children:t.pluginName}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.providers.share`,{percent:n.toFixed(1)})})]}),(0,O.jsxs)(`div`,{className:`shrink-0 text-end`,children:[(0,O.jsx)(`div`,{className:`text-base font-medium tabular-nums text-gray-950 dark:text-dark-950`,children:H(t.calls)}),(0,O.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.metrics.calls`)})]})]}),(0,O.jsx)(`div`,{className:`my-3 flex h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,"aria-hidden":`true`,children:r.map(n=>(0,O.jsx)(`span`,{"data-model":n.model??`__other__`,title:`${n.model??e(`usageAnalytics.heatmap.other`)}: ${H(n.calls)}`,style:{width:`${t.calls?n.calls/t.calls*100:0}%`,backgroundColor:X.get(R(n.model))??`#6b7280`,opacity:Z&&Z!==Q(n.model)?.25:1}},R(n.model)))}),(0,O.jsxs)(`dl`,{className:`grid grid-cols-3 gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[10px] text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.metrics.tokens`)}),(0,O.jsx)(`dd`,{className:`mt-1 text-xs tabular-nums text-gray-800 dark:text-dark-800`,title:t.tokens?void 0:e(`usageAnalytics.providers.noTokens`),children:t.tokens?H(t.tokens):`—`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[10px] text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.success`)}),(0,O.jsxs)(`dd`,{className:`mt-1 text-xs tabular-nums text-gray-800 dark:text-dark-800`,children:[W(t.calls,t.errors).toFixed(1),`%`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[10px] text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.latency`)}),(0,O.jsx)(`dd`,{className:`mt-1 text-xs tabular-nums text-gray-800 dark:text-dark-800`,children:U(t.averageLatencyMs)})]})]}),t.errors>0&&(0,O.jsxs)(`p`,{className:`mt-2 flex items-center gap-1 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,O.jsx)(h,{className:`h-3 w-3`}),e(`usageAnalytics.providers.failures`,{count:t.errors})]}),(0,O.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:r.map(t=>{let n=Q(t.model),r=t.model??e(`usageAnalytics.heatmap.other`);return(0,O.jsxs)(`button`,{type:`button`,disabled:!n,"aria-label":e(`usageAnalytics.activity.highlightModel`,{model:r}),"aria-pressed":!!F&&F===n,title:r,onMouseEnter:()=>y(n),onMouseLeave:()=>y(void 0),onFocus:()=>y(n),onBlur:()=>y(void 0),onClick:()=>le(F===n?void 0:n),className:T(`flex min-h-8 min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] text-gray-600 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-primary-500 dark:text-dark-700`,Z&&Z===n?`border-gray-400 bg-gray-50 dark:border-dark-500 dark:bg-dark-200`:`border-gray-200/70 dark:border-white/[0.07]`),children:[(0,O.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:X.get(R(t.model))??`#6b7280`},"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`truncate`,dir:`auto`,children:r})]},R(t.model))})})]},JSON.stringify([t.pluginId,t.pluginName]))})})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/75 sm:p-5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(_,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,O.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,O.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:G.capabilities.map(t=>(0,O.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,O.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:H(t.calls)}),(0,O.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:H(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:H(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:H(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:H(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:H(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:H(t.tokens)})})]},t.capability))})]})]})]}),(0,O.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{X as default};
@@ -1 +1 @@
1
- export{t as RichMessageContent,t as default}from"./RichMessageContent-Bwpg3rfV.js";
1
+ export{t as RichMessageContent,t as default}from"./RichMessageContent-Cdz4MI7q.js";
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-aI8uDQmz.js","js/markdown-math-BzLEmswF.js","js/markdown-core-CGWDtd6X.js","js/rolldown-runtime-XKyaHtl9.js","js/react-vendor-C1iE8mnY.js","assets/markdown-math-Ngnvt50Q.css","js/markdownHtml-B1Ll_Qgp.js","js/markdown-html-BdYVneHE.js","js/OptimizedSyntaxHighlighter-DoJF0j0l.js","js/OptimizedSyntaxHighlighter-B8vbflQA.js","js/syntax-highlight-CemL-n1v.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{t as r}from"./utils-BvvV-Cka.js";import{o as i}from"./logger-rEW7uQ8m.js";import{t as a}from"./appStore-B6pAGo3p.js";import{a as o,i as s,n as c,r as l,s as u,t as d}from"./messageCodeStyles-DVYyK8wm.js";import{i as f,s as p}from"./markdown-core-CGWDtd6X.js";var m=e(t(),1),h=null,g=null,_=null,v=null,y=()=>_??=i(()=>import(`./markdownMath-aI8uDQmz.js`).then(e=>(h=e,e)),__vite__mapDeps([0,1,2,3,4,5])),b=()=>v??=i(()=>import(`./markdownHtml-B1Ll_Qgp.js`).then(e=>(g=e,e)),__vite__mapDeps([6,7,2,3,4])),x=e=>e.includes(`$`);function S(e){let{needsMath:t,needsHtml:n}=e,[,r]=m.useReducer(e=>e+1,0);return m.useEffect(()=>{if(!t||h)return;let e=!1;return y().then(()=>{e||r()}),()=>{e=!0}},[t]),m.useEffect(()=>{if(!n||g)return;let e=!1;return b().then(()=>{e||r()}),()=>{e=!0}},[n]),{math:t?h:null,html:n?g:null}}var C=n(),w=m.lazy(()=>i(()=>import(`./OptimizedSyntaxHighlighter-DoJF0j0l.js`),__vite__mapDeps([8,9,3,4,10,2])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:r(l,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=m.memo(({content:e,className:t,allowHtml:n=!1})=>{let i=a(e=>e.theme.mode!==`light`),l=m.useMemo(()=>u(e),[e]),{math:h,html:g}=S({needsMath:x(l),needsHtml:n}),_=m.useMemo(()=>h?[f,h.remarkMath]:[f],[h]),v=m.useMemo(()=>{let e=[];return g&&e.push(g.rehypeRaw,[g.rehypeSanitize,g.richContentSanitizeSchema]),h&&e.push([h.rehypeKatex,{strict:e=>e===`unknownSymbol`?`ignore`:`warn`}]),e},[g,h]);return(0,C.jsx)(`div`,{dir:`auto`,className:r(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,C.jsx)(p,{remarkPlugins:_,rehypePlugins:v,components:{code({className:e,children:t,node:n,...a}){let l=/language-([^\s]+)/.exec(e||``),u=String(t),f=u.replace(/\n$/,``),p=l?l[1]:null;return p||u.includes(`
3
- `)?(0,C.jsx)(o,{code:f,language:p,state:`complete`,children:(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsx)(m.Suspense,{fallback:(0,C.jsx)(T,{className:`m-0! rounded-none! border-none!`,children:f}),children:(0,C.jsx)(w,{language:p||`text`,isDark:i,codeTheme:`night`,backgroundColor:i?d:c,borderRadius:0,customStyle:s,className:`m-0! rounded-none! border-none!`,showLineNumbers:!0,children:f})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:r(`px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-[0.85em] border border-gray-200 dark:border-dark-300`,e),...a,children:t})},pre({children:e}){return(0,C.jsx)(C.Fragment,{children:e})},p({children:e,...t}){return(0,C.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,C.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,C.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},li({children:e,...t}){return(0,C.jsx)(`li`,{dir:`auto`,className:`text-ink leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,C.jsx)(`blockquote`,{dir:`auto`,className:`border-s-2 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-3 py-2 my-3 rounded-e-lg italic text-ink`,...t,children:e})},h1({children:e,...t}){return(0,C.jsx)(`h1`,{dir:`auto`,className:`text-xl font-bold mb-3 mt-5 first:mt-0 text-ink border-b border-gray-200 dark:border-dark-300 pb-1.5`,...t,children:e})},h2({children:e,...t}){return(0,C.jsx)(`h2`,{dir:`auto`,className:`text-lg font-semibold mb-2 mt-5 first:mt-0 text-ink`,...t,children:e})},h3({children:e,...t}){return(0,C.jsx)(`h3`,{dir:`auto`,className:`text-base font-medium mb-2 mt-4 first:mt-0 text-ink`,...t,children:e})},table({children:e,node:t,...n}){return(0,C.jsx)(`div`,{className:r(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,C.jsx)(`table`,{dir:`auto`,className:`w-full min-w-2xl border-separate border-spacing-0 text-start text-sm`,...n,children:e})})},thead({children:e,node:t,...n}){return(0,C.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,C.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,C.jsx)(`tr`,{className:`transition-colors hover:bg-black/2.5 [&>td]:last:border-b-0 dark:hover:bg-white/2.5`,...n,children:e})},th({align:e,children:t,node:n,...i}){return(0,C.jsx)(`th`,{className:r(`border-b border-e border-line-strong px-3 py-2.5 align-bottom font-semibold text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...i,children:t})},td({align:e,children:t,node:n,...i}){return(0,C.jsx)(`td`,{className:r(`min-w-40 border-b border-e border-line px-3 py-2.5 align-top leading-relaxed text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...i,children:t})},a({children:e,node:t,href:n,...r}){let i=!!n&&!n?.startsWith(`#`);return(0,C.jsx)(`a`,{...r,href:n,...i?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`text-primary-600 underline decoration-primary-600/30 underline-offset-2 transition-colors hover:decoration-current dark:text-primary-400 dark:decoration-primary-400/40`,children:e})}},children:l})})});E.displayName=`RichMessageContent`;export{E as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-CKB9Q-yN.js","js/markdown-math-CCWDDhWR.js","js/markdown-core-CGWDtd6X.js","js/rolldown-runtime-XKyaHtl9.js","js/react-vendor-C1iE8mnY.js","assets/markdown-math-Bv5fr4tV.css","js/markdownHtml-DpKMtcCu.js","js/markdown-html-DRL6swKb.js","js/OptimizedSyntaxHighlighter-DoJF0j0l.js","js/OptimizedSyntaxHighlighter-B8vbflQA.js","js/syntax-highlight-CemL-n1v.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{i as r,s as i}from"./markdown-core-CGWDtd6X.js";import{o as a}from"./logger-DAQsBb8I.js";import{t as o}from"./appStore-DmeFFzzj.js";import{t as s}from"./utils-DsCVr_wG.js";import{a as c,i as l,n as u,r as d,s as f,t as p}from"./messageCodeStyles-C0H1Lad5.js";var m=e(t(),1),h=null,g=null,_=null,v=null,y=()=>_??=a(()=>import(`./markdownMath-CKB9Q-yN.js`).then(e=>(h=e,e)),__vite__mapDeps([0,1,2,3,4,5])),b=()=>v??=a(()=>import(`./markdownHtml-DpKMtcCu.js`).then(e=>(g=e,e)),__vite__mapDeps([6,7,2,3,4])),x=e=>e.includes(`$`);function S(e){let{needsMath:t,needsHtml:n}=e,[,r]=m.useReducer(e=>e+1,0);return m.useEffect(()=>{if(!t||h)return;let e=!1;return y().then(()=>{e||r()}),()=>{e=!0}},[t]),m.useEffect(()=>{if(!n||g)return;let e=!1;return b().then(()=>{e||r()}),()=>{e=!0}},[n]),{math:t?h:null,html:n?g:null}}var C=n(),w=m.lazy(()=>a(()=>import(`./OptimizedSyntaxHighlighter-DoJF0j0l.js`),__vite__mapDeps([8,9,3,4,10,2])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:s(d,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=m.memo(({content:e,className:t,allowHtml:n=!1})=>{let a=o(e=>e.theme.mode!==`light`),d=m.useMemo(()=>f(e),[e]),{math:h,html:g}=S({needsMath:x(d),needsHtml:n}),_=m.useMemo(()=>h?[r,h.remarkMath]:[r],[h]),v=m.useMemo(()=>{let e=[];return g&&e.push(g.rehypeRaw,[g.rehypeSanitize,g.richContentSanitizeSchema]),h&&e.push([h.rehypeKatex,{strict:e=>e===`unknownSymbol`?`ignore`:`warn`}]),e},[g,h]);return(0,C.jsx)(`div`,{dir:`auto`,className:s(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,C.jsx)(i,{remarkPlugins:_,rehypePlugins:v,components:{code({className:e,children:t,node:n,...r}){let i=/language-([^\s]+)/.exec(e||``),o=String(t),d=o.replace(/\n$/,``),f=i?i[1]:null;return f||o.includes(`
3
+ `)?(0,C.jsx)(c,{code:d,language:f,state:`complete`,children:(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsx)(m.Suspense,{fallback:(0,C.jsx)(T,{className:`m-0! rounded-none! border-none!`,children:d}),children:(0,C.jsx)(w,{language:f||`text`,isDark:a,codeTheme:`night`,backgroundColor:a?p:u,borderRadius:0,customStyle:l,className:`m-0! rounded-none! border-none!`,showLineNumbers:!0,children:d})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:s(`px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-[0.85em] border border-gray-200 dark:border-dark-300`,e),...r,children:t})},pre({children:e}){return(0,C.jsx)(C.Fragment,{children:e})},p({children:e,...t}){return(0,C.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,C.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,C.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},li({children:e,...t}){return(0,C.jsx)(`li`,{dir:`auto`,className:`text-ink leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,C.jsx)(`blockquote`,{dir:`auto`,className:`border-s-2 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-3 py-2 my-3 rounded-e-lg italic text-ink`,...t,children:e})},h1({children:e,...t}){return(0,C.jsx)(`h1`,{dir:`auto`,className:`text-xl font-bold mb-3 mt-5 first:mt-0 text-ink border-b border-gray-200 dark:border-dark-300 pb-1.5`,...t,children:e})},h2({children:e,...t}){return(0,C.jsx)(`h2`,{dir:`auto`,className:`text-lg font-semibold mb-2 mt-5 first:mt-0 text-ink`,...t,children:e})},h3({children:e,...t}){return(0,C.jsx)(`h3`,{dir:`auto`,className:`text-base font-medium mb-2 mt-4 first:mt-0 text-ink`,...t,children:e})},table({children:e,node:t,...n}){return(0,C.jsx)(`div`,{className:s(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,C.jsx)(`table`,{dir:`auto`,className:`w-full min-w-2xl border-separate border-spacing-0 text-start text-sm`,...n,children:e})})},thead({children:e,node:t,...n}){return(0,C.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,C.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,C.jsx)(`tr`,{className:`transition-colors hover:bg-black/2.5 [&>td]:last:border-b-0 dark:hover:bg-white/2.5`,...n,children:e})},th({align:e,children:t,node:n,...r}){return(0,C.jsx)(`th`,{className:s(`border-b border-e border-line-strong px-3 py-2.5 align-bottom font-semibold text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})},td({align:e,children:t,node:n,...r}){return(0,C.jsx)(`td`,{className:s(`min-w-40 border-b border-e border-line px-3 py-2.5 align-top leading-relaxed text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})},a({children:e,node:t,href:n,...r}){let i=!!n&&!n?.startsWith(`#`);return(0,C.jsx)(`a`,{...r,href:n,...i?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`text-primary-600 underline decoration-primary-600/30 underline-offset-2 transition-colors hover:decoration-current dark:text-primary-400 dark:decoration-primary-400/40`,children:e})}},children:d})})});E.displayName=`RichMessageContent`;export{E as t};