libre-webui 0.34.0 → 0.34.2
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.
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +20 -31
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/cors.d.ts +12 -7
- package/backend/dist/middleware/cors.d.ts.map +1 -1
- package/backend/dist/middleware/cors.js +27 -26
- package/backend/dist/middleware/cors.js.map +1 -1
- package/backend/dist/middleware/preferencesBody.d.ts +4 -0
- package/backend/dist/middleware/preferencesBody.d.ts.map +1 -0
- package/backend/dist/middleware/preferencesBody.js +43 -0
- package/backend/dist/middleware/preferencesBody.js.map +1 -0
- package/backend/dist/routes/preferences.d.ts.map +1 -1
- package/backend/dist/routes/preferences.js +2 -1
- package/backend/dist/routes/preferences.js.map +1 -1
- package/backend/dist/services/preferencesService.d.ts.map +1 -1
- package/backend/dist/services/preferencesService.js +7 -10
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/types/index.d.ts +1 -0
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/utils/backgroundSettings.d.ts +7 -0
- package/backend/dist/utils/backgroundSettings.d.ts.map +1 -0
- package/backend/dist/utils/backgroundSettings.js +39 -0
- package/backend/dist/utils/backgroundSettings.js.map +1 -0
- package/backend/package.json +3 -3
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
- package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
- package/frontend/dist/assets/index-C59a0tht.css +1 -0
- package/frontend/dist/assets/index-Cyi10ekV.js +43 -0
- package/frontend/dist/assets/{markdown-math-Ddr6Z9Sf.css → markdown-math-B3MBJsZb.css} +1 -1
- package/frontend/dist/index.html +22 -21
- package/frontend/dist/js/{ArtifactContainer-8ZacPNwg.js → ArtifactContainer-CQjqR9G1.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-DvvT45ZJ.js → ArtifactDemoPage-DbbqglMU.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-Dbp1bB_9.js → ArtifactSandboxFrame-DI2b9BW5.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-Ct9nlG_6.js → ArtifactSlideOutPanel-B_UX92CK.js} +1 -1
- package/frontend/dist/js/{AutomationModal-Ie_MxC18.js → AutomationModal-CNiy1Dxm.js} +1 -1
- package/frontend/dist/js/{AutomationsPage-Czg-rMEr.js → AutomationsPage-CeAsldk_.js} +1 -1
- package/frontend/dist/js/{AvatarUpload-DgyIHr7P.js → AvatarUpload-xCWQm3_w.js} +1 -1
- package/frontend/dist/js/CalendarPage-Cwk0X00z.js +1 -0
- package/frontend/dist/js/ChannelsPage-BG3n4ElV.js +1 -0
- package/frontend/dist/js/ChatPage-wSRfAOeh.js +14 -0
- package/frontend/dist/js/{ConnectModels-Cg7Wp-43.js → ConnectModels-D7ZTGihA.js} +1 -1
- package/frontend/dist/js/{EvaluationsPage-BBafHC8o.js → EvaluationsPage-C795TI_6.js} +2 -2
- package/frontend/dist/js/{FirstTimeSetup-Cd9cLLz6.js → FirstTimeSetup-C4C5GLjW.js} +1 -1
- package/frontend/dist/js/{GalleryPage-6aa0A9fS.js → GalleryPage-DVWl3LaC.js} +1 -1
- package/frontend/dist/js/{HomePage-1vKjY6Aw.js → HomePage-BljB9ZMN.js} +1 -1
- package/frontend/dist/js/LanguageSwitcher-BuS3i6u5.js +1 -0
- package/frontend/dist/js/{LibreClawPage-DXxJP96Q.js → LibreClawPage-OD6iZtiy.js} +1 -1
- package/frontend/dist/js/ModelManagerModals-DdL3LeGl.js +1 -0
- package/frontend/dist/js/NotesPage-rqL0zS8z.js +3 -0
- package/frontend/dist/js/{PasswordStrengthMeter-DLQ5jaO_.js → PasswordStrengthMeter-H0Os6XbX.js} +1 -1
- package/frontend/dist/js/{PersonasPage-HYkaAXAe.js → PersonasPage-Babix8IA.js} +1 -1
- package/frontend/dist/js/{PluginUsagePage-B2MRIZme.js → PluginUsagePage-CudDkMxy.js} +1 -1
- package/frontend/dist/js/RichMessageContent-B-U0EcyW.js +1 -0
- package/frontend/dist/js/{RichMessageContent-BnpRgouz.js → RichMessageContent-CcKn_kcQ.js} +3 -3
- package/frontend/dist/js/SettingsModal-CXU60RIf.js +19 -0
- package/frontend/dist/js/{ShareDialog-BdFJRfxV.js → ShareDialog-CnU4ptx7.js} +1 -1
- package/frontend/dist/js/{SystemPage-DkKnu35i.js → SystemPage-BzpTjdQY.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-DdpcN4-Q.js → UserManagementPage-BHEMaK5a.js} +1 -1
- package/frontend/dist/js/{UserManagementPanel-Dpn15Nyr.js → UserManagementPanel-pbtLqF8X.js} +1 -1
- package/frontend/dist/js/{WhatsNewModal-BH-kE-Wb.js → WhatsNewModal-TuDrBWKj.js} +1 -1
- package/frontend/dist/js/WorkPage-DCeqm0BN.js +7 -0
- package/frontend/dist/js/api-BIVGtaZy.js +1 -0
- package/frontend/dist/js/{api-HgGU3dII.js → api-CgnEj5Jc.js} +1 -1
- package/frontend/dist/js/{appNavigation-DAd7SkU_.js → appNavigation-DySHcEGS.js} +1 -1
- package/frontend/dist/js/appStore-DrTsJPfh.js +2 -0
- package/frontend/dist/js/appVersion-CAidQlBP.js +1 -0
- package/frontend/dist/js/{ar-CM3oZcHT.js → ar-DNI77Stn.js} +1 -1
- package/frontend/dist/js/authStore-CieFdk4S.js +4 -0
- package/frontend/dist/js/authStore-GaOHAAsM.js +1 -0
- package/frontend/dist/js/{bn-BuYroL_j.js → bn-u6oyZr4U.js} +1 -1
- package/frontend/dist/js/{chatStore-DYm9cXVV.js → chatStore-BvZkd8Un.js} +3 -3
- package/frontend/dist/js/composerStyles-BjJm_BgC.js +1 -0
- package/frontend/dist/js/{config-BH2zUU2X.js → config-D7WLbWrW.js} +1 -1
- package/frontend/dist/js/{cs-D3NqP5wD.js → cs-BIkJ6jwb.js} +1 -1
- package/frontend/dist/js/{da-BGpE68rg.js → da-DV3V6XJ_.js} +1 -1
- package/frontend/dist/js/{de-BjYUQYNL.js → de-DdcTQ-vn.js} +1 -1
- package/frontend/dist/js/{es-vNJrO8Lj.js → es-Cw-ozFaX.js} +1 -1
- package/frontend/dist/js/{evaluationsApi-v6Qj2fFv.js → evaluationsApi-Dn-WNzzH.js} +1 -1
- package/frontend/dist/js/{fr-BvtHFXNM.js → fr-Y2NfnlYR.js} +1 -1
- package/frontend/dist/js/{hi-CUfuHlbY.js → hi-BKU62_1Y.js} +1 -1
- package/frontend/dist/js/{i18next-ChipS_AK.js → i18next-Dq_6N9uy.js} +1 -1
- package/frontend/dist/js/{id-B4CE64s6.js → id-q6wo4InR.js} +1 -1
- package/frontend/dist/js/{is-Dr6Is7-Q.js → is-_B6QblCu.js} +1 -1
- package/frontend/dist/js/{it-Cj4NfoeU.js → it-NUupXhzK.js} +1 -1
- package/frontend/dist/js/{ja-DByiJVO0.js → ja-BUvl9RXq.js} +1 -1
- package/frontend/dist/js/{ko-DqBvZqIv.js → ko-df4leR83.js} +1 -1
- package/frontend/dist/js/markdownMath-BW8RNkEl.js +1 -0
- package/frontend/dist/js/{messageCodeStyles-ERvWXB7Y.js → messageCodeStyles-C0pbLr0L.js} +2 -2
- package/frontend/dist/js/{ms-DobJ-R5X.js → ms-CN-7Q9S2.js} +1 -1
- package/frontend/dist/js/{nl-D4tVIakl.js → nl-OEm4uNIo.js} +1 -1
- package/frontend/dist/js/{pl-BIoYiVJA.js → pl-B9pHpjg7.js} +1 -1
- package/frontend/dist/js/{pt-Bzww3XtB.js → pt-D3uaEKud.js} +1 -1
- package/frontend/dist/js/router-vendor-Epc3_KZ_.js +1 -0
- package/frontend/dist/js/{ru-lqQ-JuMd.js → ru-z9H07lhi.js} +1 -1
- package/frontend/dist/js/{sv-9dcksSEJ.js → sv-GkQDA4wx.js} +1 -1
- package/frontend/dist/js/{teamEventStream-CTyr4r5f.js → teamEventStream-CI_GSbae.js} +1 -1
- package/frontend/dist/js/{th-DuOX28lk.js → th-0hzCkDzt.js} +1 -1
- package/frontend/dist/js/{tr-Dz7bMTi1.js → tr-CZDobfHQ.js} +1 -1
- package/frontend/dist/js/ui-CgokQU6I.js +2 -0
- package/frontend/dist/js/ui-vendor-Dt9hfsGD.js +177 -0
- package/frontend/dist/js/{uk-aTAky5l4.js → uk-BwspIPCI.js} +1 -1
- package/frontend/dist/js/{useChat-CXcosgJB.js → useChat-DIGuMg5j.js} +1 -1
- package/frontend/dist/js/useDialogFocus-BQLdAGYH.js +1 -0
- package/frontend/dist/js/{vi-CHcYXhCs.js → vi-Dipdv5ta.js} +1 -1
- package/frontend/dist/js/{workApi-CntsmsAA.js → workApi-C-WfyZSs.js} +2 -2
- package/frontend/dist/js/workApi-CApikuye.js +1 -0
- package/frontend/dist/js/{zh-DvvksD8_.js → zh-CgdWmtP_.js} +1 -1
- package/package.json +8 -4
- package/frontend/dist/assets/index-By_-fwuh.css +0 -1
- package/frontend/dist/assets/index-D3XhYdgN.js +0 -108
- package/frontend/dist/js/CalendarPage-D1ZeHpZ0.js +0 -1
- package/frontend/dist/js/ChannelsPage-DgXZdSLa.js +0 -1
- package/frontend/dist/js/ChatPage-ov4Xlf8Q.js +0 -14
- package/frontend/dist/js/ModelManagerModals-BBGWbTTi.js +0 -1
- package/frontend/dist/js/NotesPage-DCLkl9a9.js +0 -3
- package/frontend/dist/js/RichMessageContent-2fzm0XIM.js +0 -1
- package/frontend/dist/js/SettingsModal-4ITUSJqi.js +0 -19
- package/frontend/dist/js/WorkPage-CCyCPnwr.js +0 -7
- package/frontend/dist/js/api-DOlirnw_.js +0 -1
- package/frontend/dist/js/appStore-DefVAJAx.js +0 -2
- package/frontend/dist/js/appVersion-RvElMU1Q.js +0 -1
- package/frontend/dist/js/authStore-AE-cc9PJ.js +0 -1
- package/frontend/dist/js/authStore-DbDFBMx0.js +0 -4
- package/frontend/dist/js/markdownMath-CoDj1i7z.js +0 -1
- package/frontend/dist/js/router-vendor-CMbYTGdh.js +0 -1
- package/frontend/dist/js/ui-CHgZA8lG.js +0 -2
- package/frontend/dist/js/ui-vendor-BvD5yGW1.js +0 -177
- package/frontend/dist/js/useDictation-BGlY44fp.js +0 -1
- package/frontend/dist/js/webauthnClient-B1yv1m81.js +0 -1
- package/frontend/dist/js/workApi-nKavXIsg.js +0 -1
- /package/frontend/dist/js/{markdown-math-Dg-WB9ui.js → markdown-math-gtdBxaM5.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./useQuery-BKulzCS7.js";import{t as i}from"./useTranslation-rdLmo6zV.js";import{t as a}from"./utils-CKWltgs8.js";import{Bn as o,Ft as s,In as c,Tn as l,Z as u,an as d,br as f,et as p,g as m,or as h,s as g,v as _,vr as v}from"./ui-vendor-BvD5yGW1.js";import{n as y}from"./workApi-CntsmsAA.js";import{u as b}from"./api-HgGU3dII.js";import{t as x}from"./Button-BxwbQ5xw.js";import{a as S,o as C}from"./ui-CHgZA8lG.js";var w=e(t(),1),T={getAnalytics:e=>y.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>y.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>y.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>y.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>y.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>y.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>y.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>y.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},E=n(),D=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),O=`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`,k=({days:e})=>{let{t}=i(),[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)([]),[c,u]=(0,w.useState)([]),[d,m]=(0,w.useState)(!0),[h,g]=(0,w.useState)(0),[v,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,S]=(0,w.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,w.useEffect)(()=>{let n=!1;return Promise.all([T.getAnalytics(e),T.listTariffs(),T.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&o(t.data),i.success&&i.data&&u(i.data))}).catch(()=>f.error(t(`costs.loadFailed`))).finally(()=>{n||m(!1)}),()=>{n=!0}},[e,h,t]);let C=e=>{if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0},k=async()=>{try{let e=await T.createTariff({pluginId:v.pluginId.trim(),model:v.model.trim()||void 0,inputPerMillion:C(v.inputPerMillion),outputPerMillion:C(v.outputPerMillion),unitPrice:C(v.unitPrice)});if(!e.success)throw Error(e.message);f.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),g(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.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);f.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),g(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await T.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{f.error(t(`costs.exportFailed`))}};return d&&!n?(0,E.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,E.jsx)(s,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,E.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,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,E.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,E.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:D(n.totalUsd)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,E.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${D(n.byModel[0].usd)})`:`—`})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,E.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,E.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,E.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,E.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[D(e.spentUsd),` / `,D(e.amountUsd)]}),(0,E.jsx)(`button`,{onClick:()=>{T.deleteBudget(e.id).then(()=>g(e=>e+1)).catch(()=>f.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})]}),(0,E.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded bg-gray-200 dark:bg-dark-300`,children:(0,E.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)}),c.length===0&&(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>S({...b,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.principalType,onChange:e=>S({...b,principalType:e.target.value}),children:[(0,E.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,E.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,E.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>S({...b,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.period,onChange:e=>S({...b,period:e.target.value}),children:[(0,E.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,E.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,E.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(`input`,{className:O,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>S({...b,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.mode,onChange:e=>S({...b,mode:e.target.value}),children:[(0,E.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,E.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,E.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(p,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,E.jsx)(`thead`,{className:`text-gray-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,E.jsx)(`th`,{})]})}),(0,E.jsxs)(`tbody`,{children:[a.map(e=>(0,E.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:D(e.input_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:D(e.output_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:D(e.unit_price)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,E.jsx)(`td`,{className:`py-1`,children:(0,E.jsx)(`button`,{onClick:()=>{T.deleteTariff(e.id).then(()=>g(e=>e+1)).catch(()=>f.error(t(`costs.saveFailed`)))},className:`rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})})]},e.id)),a.length===0&&(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.plugin`),value:v.pluginId,onChange:e=>y({...v,pluginId:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.modelOptional`),value:v.model,onChange:e=>y({...v,model:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:v.inputPerMillion,onChange:e=>y({...v,inputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:v.outputPerMillion,onChange:e=>y({...v,outputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:v.unitPrice,onChange:e=>y({...v,unitPrice:e.target.value})}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(p,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},A=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),j=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),M=e=>e>=1e4?j.format(e):A.format(e),N=e=>e?e<1e3?`${A.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,P=(e,t)=>e===0?0:(e-t)/e*100,F=({analytics:e,metric:t,onMetricChange:n})=>{let{t:r}=i(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,E.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:r(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:r(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,E.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm 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:r(`usageAnalytics.metrics.${e}`)},e))})]}),(0,E.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":r(`usageAnalytics.activity.chartLabel`,{metric:r(`usageAnalytics.metrics.${t}`)}),children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,E.jsxs)(`g`,{children:[(0,E.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,E.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:M(n)})]},e)}),h&&(0,E.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,E.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:i})=>(0,E.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,E.jsx)(`title`,{children:`${g.format(i.timestamp)}: ${M(i[t])} ${r(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},i.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,E.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},I=864e5,L=10,R=12,z=30,B=16,V=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],H=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],U=`fill-gray-400 dark:fill-gray-500`,W=`bg-gray-400 dark:bg-gray-500`,G=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,K=[0,.35,.55,.75,1],q=({heatmap:e})=>{let{t,i18n:n}=i(),[r,o]=(0,w.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,w.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*I,i=n-new Date(n).getUTCDay()*I;return{weeks:Math.ceil((r-i+I)/(7*I)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*I,v=z+s*R,y=[],b=-1;for(let e=0;e<s;e++){let t=c+e*7*I,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==b&&t>=g-6*I&&((b!==-1||t>=g)&&y.push({x:z+e*R,label:p.format(n)}),b=r)}let x=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),S=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?U:V[n]},C=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,E.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,E.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:M(f)})})]}),(0,E.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[y.map(({x:e,label:t})=>(0,E.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,E.jsx)(`text`,{x:0,y:B+e*R+L-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let i=c+(t*7+n)*I;if(i<g||i>_)return null;let o=l.get(i),s=o?.calls??0,u=x(s);return(0,E.jsx)(`rect`,{x:z+t*R,y:B+n*R,width:L,height:L,rx:2,fillOpacity:u===0?1:K[u],strokeWidth:+(r?.timestamp===i),className:a(`transition-opacity`,u===0||!o?G:S(o),r?.timestamp===i?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,i,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(i)} — ${M(s)}`})},i)}))]})}),r&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -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/[0.1] dark:bg-dark-100/95`,style:{left:r.x,top:r.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(r.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:r.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(r.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),r.models.slice(0,3).map(e=>(0,E.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:a(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?H[d.get(e.model)]:W)}),(0,E.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,E.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:M(e.calls)})]},e.model))]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,H[t])}),(0,E.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,W)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),K.slice(1).map(e=>(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},J=()=>{let{t:e}=i(),[t,n]=(0,w.useState)(30),[l,f]=(0,w.useState)(`calls`),{data:p,error:_,isLoading:y,isFetching:T,refetch:D}=r({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await b.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=_?_ instanceof Error?_.message:e(`usageAnalytics.loadFailed`):null,A=p?.totals,j=(0,w.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:M(A?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:A?.uniqueUsers??0}),icon:v},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:d},{label:e(`usageAnalytics.cards.success`),value:`${P(A?.calls??0,(A?.failedCalls??0)+(A?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:A?.failedCalls??0}),icon:o},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:c}],[e,A]);return y&&!p?(0,E.jsx)(C,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(s,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(C,{width:`wide`,children:[(0,E.jsx)(S,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,E.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,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`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,E.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(u,{className:a(`h-4 w-4`,T&&`animate-spin`)}),(0,E.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),O&&(0,E.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,E.jsx)(m,{className:`h-4 w-4 shrink-0`}),(0,E.jsx)(`span`,{children:O})]}),(0,E.jsx)(`div`,{className:`mb-6`,children:(0,E.jsx)(k,{days:t})}),p&&(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:j.map(e=>{let t=e.icon;return(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,E.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,E.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),p.heatmap&&p.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:p.heatmap}),(0,E.jsx)(F,{analytics:p,metric:l,onMetricChange:f}),p.totals.calls===0?(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,E.jsx)(h,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,E.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,E.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,E.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,E.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,E.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,E.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:p.models.slice(0,12).map(e=>(0,E.jsxs)(`tr`,{children:[(0,E.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,E.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:M(e.calls)}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?M(e.tokens):`—`}),(0,E.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[P(e.calls,e.errors).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:N(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,E.jsx)(`div`,{className:`mt-5 space-y-4`,children:p.plugins.slice(0,8).map(t=>{let n=p.totals.calls?t.calls/p.totals.calls*100:0;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,E.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[M(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,E.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:M(t.calls)})]}),(0,E.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(g,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,E.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:p.capabilities.map(t=>(0,E.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,E.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:M(t.calls)}),(0,E.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:M(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:M(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:M(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:M(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:M(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:M(t.tokens)})})]},t.capability))})]})]})]}),(0,E.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{J as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./useQuery-BKulzCS7.js";import{t as i}from"./useTranslation-rdLmo6zV.js";import{t as a}from"./utils-CKWltgs8.js";import{Bn as o,Ft as s,In as c,Tn as l,Z as u,an as d,br as f,g as p,or as m,s as h,tt as g,v as _,vr as v}from"./ui-vendor-Dt9hfsGD.js";import{n as y}from"./workApi-C-WfyZSs.js";import{u as b}from"./api-CgnEj5Jc.js";import{t as x}from"./Button-BxwbQ5xw.js";import{a as S,o as C}from"./ui-CgokQU6I.js";var w=e(t(),1),T={getAnalytics:e=>y.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>y.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>y.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>y.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>y.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>y.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>y.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>y.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},E=n(),D=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),O=`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`,k=({days:e})=>{let{t}=i(),[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)([]),[c,u]=(0,w.useState)([]),[d,p]=(0,w.useState)(!0),[m,h]=(0,w.useState)(0),[v,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,S]=(0,w.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,w.useEffect)(()=>{let n=!1;return Promise.all([T.getAnalytics(e),T.listTariffs(),T.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&o(t.data),i.success&&i.data&&u(i.data))}).catch(()=>f.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},k=async()=>{try{let e=await T.createTariff({pluginId:v.pluginId.trim(),model:v.model.trim()||void 0,inputPerMillion:C(v.inputPerMillion),outputPerMillion:C(v.outputPerMillion),unitPrice:C(v.unitPrice)});if(!e.success)throw Error(e.message);f.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),h(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.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);f.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),h(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await T.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{f.error(t(`costs.exportFailed`))}};return d&&!n?(0,E.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,E.jsx)(s,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,E.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,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,E.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,E.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:D(n.totalUsd)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,E.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${D(n.byModel[0].usd)})`:`—`})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,E.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,E.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,E.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,E.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[D(e.spentUsd),` / `,D(e.amountUsd)]}),(0,E.jsx)(`button`,{onClick:()=>{T.deleteBudget(e.id).then(()=>h(e=>e+1)).catch(()=>f.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})]}),(0,E.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded bg-gray-200 dark:bg-dark-300`,children:(0,E.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)}),c.length===0&&(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>S({...b,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.principalType,onChange:e=>S({...b,principalType:e.target.value}),children:[(0,E.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,E.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,E.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>S({...b,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.period,onChange:e=>S({...b,period:e.target.value}),children:[(0,E.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,E.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,E.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(`input`,{className:O,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>S({...b,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.mode,onChange:e=>S({...b,mode:e.target.value}),children:[(0,E.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,E.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,E.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,E.jsx)(`thead`,{className:`text-gray-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,E.jsx)(`th`,{})]})}),(0,E.jsxs)(`tbody`,{children:[a.map(e=>(0,E.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:D(e.input_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:D(e.output_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:D(e.unit_price)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,E.jsx)(`td`,{className:`py-1`,children:(0,E.jsx)(`button`,{onClick:()=>{T.deleteTariff(e.id).then(()=>h(e=>e+1)).catch(()=>f.error(t(`costs.saveFailed`)))},className:`rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})})]},e.id)),a.length===0&&(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.plugin`),value:v.pluginId,onChange:e=>y({...v,pluginId:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.modelOptional`),value:v.model,onChange:e=>y({...v,model:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:v.inputPerMillion,onChange:e=>y({...v,inputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:v.outputPerMillion,onChange:e=>y({...v,outputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:v.unitPrice,onChange:e=>y({...v,unitPrice:e.target.value})}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},A=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),j=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),M=e=>e>=1e4?j.format(e):A.format(e),N=e=>e?e<1e3?`${A.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,P=(e,t)=>e===0?0:(e-t)/e*100,F=({analytics:e,metric:t,onMetricChange:n})=>{let{t:r}=i(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,E.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:r(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:r(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,E.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm 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:r(`usageAnalytics.metrics.${e}`)},e))})]}),(0,E.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":r(`usageAnalytics.activity.chartLabel`,{metric:r(`usageAnalytics.metrics.${t}`)}),children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,E.jsxs)(`g`,{children:[(0,E.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,E.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:M(n)})]},e)}),h&&(0,E.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,E.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:i})=>(0,E.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,E.jsx)(`title`,{children:`${g.format(i.timestamp)}: ${M(i[t])} ${r(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},i.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,E.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},I=864e5,L=10,R=12,z=30,B=16,V=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],H=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],U=`fill-gray-400 dark:fill-gray-500`,W=`bg-gray-400 dark:bg-gray-500`,G=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,K=[0,.35,.55,.75,1],q=({heatmap:e})=>{let{t,i18n:n}=i(),[r,o]=(0,w.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,w.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*I,i=n-new Date(n).getUTCDay()*I;return{weeks:Math.ceil((r-i+I)/(7*I)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*I,v=z+s*R,y=[],b=-1;for(let e=0;e<s;e++){let t=c+e*7*I,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==b&&t>=g-6*I&&((b!==-1||t>=g)&&y.push({x:z+e*R,label:p.format(n)}),b=r)}let x=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),S=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?U:V[n]},C=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,E.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.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,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,E.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:M(f)})})]}),(0,E.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[y.map(({x:e,label:t})=>(0,E.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,E.jsx)(`text`,{x:0,y:B+e*R+L-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let i=c+(t*7+n)*I;if(i<g||i>_)return null;let o=l.get(i),s=o?.calls??0,u=x(s);return(0,E.jsx)(`rect`,{x:z+t*R,y:B+n*R,width:L,height:L,rx:2,fillOpacity:u===0?1:K[u],strokeWidth:+(r?.timestamp===i),className:a(`transition-opacity`,u===0||!o?G:S(o),r?.timestamp===i?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,i,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(i)} — ${M(s)}`})},i)}))]})}),r&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -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/[0.1] dark:bg-dark-100/95`,style:{left:r.x,top:r.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(r.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:r.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(r.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),r.models.slice(0,3).map(e=>(0,E.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:a(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?H[d.get(e.model)]:W)}),(0,E.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,E.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:M(e.calls)})]},e.model))]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,H[t])}),(0,E.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,W)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),K.slice(1).map(e=>(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},J=()=>{let{t:e}=i(),[t,n]=(0,w.useState)(30),[l,f]=(0,w.useState)(`calls`),{data:g,error:_,isLoading:y,isFetching:T,refetch:D}=r({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await b.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=_?_ instanceof Error?_.message:e(`usageAnalytics.loadFailed`):null,A=g?.totals,j=(0,w.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:M(A?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:A?.uniqueUsers??0}),icon:v},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:d},{label:e(`usageAnalytics.cards.success`),value:`${P(A?.calls??0,(A?.failedCalls??0)+(A?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:A?.failedCalls??0}),icon:o},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:c}],[e,A]);return y&&!g?(0,E.jsx)(C,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(s,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(C,{width:`wide`,children:[(0,E.jsx)(S,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,E.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,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`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,E.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(u,{className:a(`h-4 w-4`,T&&`animate-spin`)}),(0,E.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),O&&(0,E.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,E.jsx)(p,{className:`h-4 w-4 shrink-0`}),(0,E.jsx)(`span`,{children:O})]}),(0,E.jsx)(`div`,{className:`mb-6`,children:(0,E.jsx)(k,{days:t})}),g&&(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:j.map(e=>{let t=e.icon;return(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,E.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,E.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),g.heatmap&&g.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:g.heatmap}),(0,E.jsx)(F,{analytics:g,metric:l,onMetricChange:f}),g.totals.calls===0?(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,E.jsx)(m,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,E.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,E.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,E.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,E.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,E.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,E.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:g.models.slice(0,12).map(e=>(0,E.jsxs)(`tr`,{children:[(0,E.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,E.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:M(e.calls)}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?M(e.tokens):`—`}),(0,E.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[P(e.calls,e.errors).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:N(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,E.jsx)(`div`,{className:`mt-5 space-y-4`,children:g.plugins.slice(0,8).map(t=>{let n=g.totals.calls?t.calls/g.totals.calls*100:0;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,E.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[M(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,E.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:M(t.calls)})]}),(0,E.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,E.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:g.capabilities.map(t=>(0,E.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,E.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:M(t.calls)}),(0,E.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:M(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:M(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:M(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:M(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:M(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:M(t.tokens)})})]},t.capability))})]})]})]}),(0,E.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{J as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./RichMessageContent-CcKn_kcQ.js";export{e as RichMessageContent,e as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{o as r}from"./logger-DnuT4jgB.js";import{t as i}from"./utils-CKWltgs8.js";import{t as a}from"./appStore-
|
|
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:r,codeTheme:`night`,backgroundColor:r?d:c,borderRadius:0,customStyle:s,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:f})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:i(`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-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-BW8RNkEl.js","js/markdown-math-gtdBxaM5.js","js/markdown-core-D067gSd8.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-D0Ec-185.js","assets/markdown-math-B3MBJsZb.css","js/markdownHtml-Djpz4yB3.js","js/markdown-html-CQM6wA9G.js","js/OptimizedSyntaxHighlighter-SkJc7ZMe.js","js/OptimizedSyntaxHighlighter-CtQ_FGCX.js","js/syntax-highlight-DTWfgxYh.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{o as r}from"./logger-DnuT4jgB.js";import{t as i}from"./utils-CKWltgs8.js";import{t as a}from"./appStore-DrTsJPfh.js";import{a as o,i as s,n as c,r as l,s as u,t as d}from"./messageCodeStyles-C0pbLr0L.js";import{i as f,s as p}from"./markdown-core-D067gSd8.js";var m=e(t(),1),h=null,g=null,_=null,v=null,y=()=>_??=r(()=>import(`./markdownMath-BW8RNkEl.js`).then(e=>(h=e,e)),__vite__mapDeps([0,1,2,3,4,5])),b=()=>v??=r(()=>import(`./markdownHtml-Djpz4yB3.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(()=>r(()=>import(`./OptimizedSyntaxHighlighter-SkJc7ZMe.js`),__vite__mapDeps([8,9,3,4,10,2])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:i(l,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=m.memo(({content:e,className:t,allowHtml:n=!1})=>{let r=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:i(`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:r,codeTheme:`night`,backgroundColor:r?d:c,borderRadius:0,customStyle:s,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:f})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:i(`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:i(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,C.jsx)(`table`,{dir:`auto`,className:`w-full min-w-[42rem] 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/[0.025] last:[&>td]:border-b-0 dark:hover:bg-white/[0.025]`,...n,children:e})},th({align:e,children:t,node:n,...r}){return(0,C.jsx)(`th`,{className:i(`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:i(`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})}},children:l})})});E.displayName=`RichMessageContent`;export{E as t};
|