libre-webui 0.42.0 → 0.43.0

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 (184) hide show
  1. package/README.md +1 -0
  2. package/backend/dist/db.d.ts.map +1 -1
  3. package/backend/dist/db.js +12 -1
  4. package/backend/dist/db.js.map +1 -1
  5. package/backend/dist/services/agentCliService.d.ts +22 -1
  6. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  7. package/backend/dist/services/agentCliService.js +110 -3
  8. package/backend/dist/services/agentCliService.js.map +1 -1
  9. package/backend/dist/services/agentCliUsage.d.ts +3 -2
  10. package/backend/dist/services/agentCliUsage.d.ts.map +1 -1
  11. package/backend/dist/services/agentCliUsage.js +19 -1
  12. package/backend/dist/services/agentCliUsage.js.map +1 -1
  13. package/backend/dist/services/workAgentAccessService.js +1 -1
  14. package/backend/dist/services/workAgentCatalog.d.ts +15 -3
  15. package/backend/dist/services/workAgentCatalog.d.ts.map +1 -1
  16. package/backend/dist/services/workAgentCatalog.js +28 -0
  17. package/backend/dist/services/workAgentCatalog.js.map +1 -1
  18. package/backend/dist/services/workAgentCliRunner.d.ts +1 -0
  19. package/backend/dist/services/workAgentCliRunner.d.ts.map +1 -1
  20. package/backend/dist/services/workAgentCliRunner.js +31 -1
  21. package/backend/dist/services/workAgentCliRunner.js.map +1 -1
  22. package/backend/dist/services/workAgentHostLogins.d.ts +37 -0
  23. package/backend/dist/services/workAgentHostLogins.d.ts.map +1 -1
  24. package/backend/dist/services/workAgentHostLogins.js +190 -0
  25. package/backend/dist/services/workAgentHostLogins.js.map +1 -1
  26. package/backend/dist/services/workAgentService.d.ts +2 -0
  27. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  28. package/backend/dist/services/workAgentService.js +10 -2
  29. package/backend/dist/services/workAgentService.js.map +1 -1
  30. package/backend/dist/services/workAgentStream.d.ts +4 -0
  31. package/backend/dist/services/workAgentStream.d.ts.map +1 -1
  32. package/backend/dist/services/workAgentStream.js +80 -0
  33. package/backend/dist/services/workAgentStream.js.map +1 -1
  34. package/backend/dist/services/workAgentToolchainService.d.ts.map +1 -1
  35. package/backend/dist/services/workAgentToolchainService.js +22 -5
  36. package/backend/dist/services/workAgentToolchainService.js.map +1 -1
  37. package/backend/dist/services/workEgressRelay.d.ts.map +1 -1
  38. package/backend/dist/services/workEgressRelay.js +19 -4
  39. package/backend/dist/services/workEgressRelay.js.map +1 -1
  40. package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
  41. package/backend/dist/services/workRuntimeService.js +26 -8
  42. package/backend/dist/services/workRuntimeService.js.map +1 -1
  43. package/backend/dist/types/work.d.ts +2 -2
  44. package/backend/dist/types/work.d.ts.map +1 -1
  45. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  46. package/backend/dist/utils/pluginChatAdapter.js +2 -1
  47. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  48. package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
  49. package/backend/dist/utils/pluginDefinitionTrust.js +1 -0
  50. package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
  51. package/backend/package.json +1 -1
  52. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  53. package/frontend/dist/artifact-runtime/babel.js +15 -15
  54. package/frontend/dist/artifact-runtime/chart.js +2 -2
  55. package/frontend/dist/artifact-runtime/d3.js +2 -2
  56. package/frontend/dist/artifact-runtime/framer-motion.js +5 -5
  57. package/frontend/dist/artifact-runtime/lodash.js +2 -2
  58. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  59. package/frontend/dist/artifact-runtime/mathjs.js +4 -4
  60. package/frontend/dist/artifact-runtime/mermaid.js +360 -360
  61. package/frontend/dist/artifact-runtime/papaparse.js +1 -1
  62. package/frontend/dist/artifact-runtime/plotly.js +146 -20
  63. package/frontend/dist/artifact-runtime/react.js +2 -2
  64. package/frontend/dist/artifact-runtime/recharts.js +8 -8
  65. package/frontend/dist/artifact-runtime/tailwind.js +1 -1
  66. package/frontend/dist/artifact-runtime/three.js +2 -2
  67. package/frontend/dist/artifact-runtime/tone.js +3 -3
  68. package/frontend/dist/assets/index-BnbO3eTY.js +83 -0
  69. package/frontend/dist/index.html +33 -33
  70. package/frontend/dist/js/{ArtifactContainer-D5wijGHA.js → ArtifactContainer-C0R4kYVM.js} +1 -1
  71. package/frontend/dist/js/{ArtifactDemoPage-DwQzUFI-.js → ArtifactDemoPage-BQmbCyat.js} +1 -1
  72. package/frontend/dist/js/{ArtifactSandboxFrame-CQCAALvW.js → ArtifactSandboxFrame-CkDkrHpg.js} +1 -1
  73. package/frontend/dist/js/{ArtifactSlideOutPanel-Cn6Rp7Yx.js → ArtifactSlideOutPanel-DZnVzC0c.js} +1 -1
  74. package/frontend/dist/js/{AutomationModal-mgkoNA-S.js → AutomationModal-Cx1e_4df.js} +1 -1
  75. package/frontend/dist/js/AutomationsPage-D7UtYZ_0.js +1 -0
  76. package/frontend/dist/js/{AvatarUpload-BFU2a_eT.js → AvatarUpload-DGRQC20B.js} +1 -1
  77. package/frontend/dist/js/{Button-D_msp6KT.js → Button-DwZ26Lqc.js} +1 -1
  78. package/frontend/dist/js/{CalendarPage-DT6_t4fJ.js → CalendarPage-WmA1i7MQ.js} +1 -1
  79. package/frontend/dist/js/ChannelsPage-Bq4JQPR_.js +1 -0
  80. package/frontend/dist/js/ChatPage-Cd3fxx-N.js +14 -0
  81. package/frontend/dist/js/ConnectModels-BYul-veF.js +1 -0
  82. package/frontend/dist/js/EvaluationsPage-CV_Terzn.js +2 -0
  83. package/frontend/dist/js/FirstTimeSetup-CFhGy9a8.js +1 -0
  84. package/frontend/dist/js/GalleryPage-BRKZyq1w.js +1 -0
  85. package/frontend/dist/js/{HomePage-CXG83Qjk.js → HomePage-DdpnBu-Z.js} +1 -1
  86. package/frontend/dist/js/{LanguageSwitcher-DK5aMjVJ.js → LanguageSwitcher-CASJ8p5d.js} +1 -1
  87. package/frontend/dist/js/{Logo--9H7Lqkg.js → Logo-C-qwuy58.js} +1 -1
  88. package/frontend/dist/js/{LogoMark-DNzLawJz.js → LogoMark-zP-mitdI.js} +1 -1
  89. package/frontend/dist/js/{ModelManagerModals-MjJMyvPJ.js → ModelManagerModals-BYhFWv22.js} +1 -1
  90. package/frontend/dist/js/NotesPage-CmvVoWcH.js +3 -0
  91. package/frontend/dist/js/{OptimizedSyntaxHighlighter-Cruo0gJb.js → OptimizedSyntaxHighlighter-B8vbflQA.js} +1 -1
  92. package/frontend/dist/js/{OptimizedSyntaxHighlighter-BCkQOsIb.js → OptimizedSyntaxHighlighter-DoJF0j0l.js} +1 -1
  93. package/frontend/dist/js/{PasswordStrengthMeter-CEmuISNU.js → PasswordStrengthMeter-Dow8ZeTs.js} +1 -1
  94. package/frontend/dist/js/PersonasPage-BYKtoKWl.js +13 -0
  95. package/frontend/dist/js/PluginUsagePage-BVTOCxoE.js +1 -0
  96. package/frontend/dist/js/{RichMessageContent-CQY0R6rI.js → RichMessageContent-Bwpg3rfV.js} +3 -3
  97. package/frontend/dist/js/{RichMessageContent-B1TrzEbs.js → RichMessageContent-DJTLGpws.js} +1 -1
  98. package/frontend/dist/js/SettingsModal-CGyVfxOz.js +19 -0
  99. package/frontend/dist/js/{SettingsToggle-CjckNl8v.js → SettingsToggle-BpD6NSri.js} +1 -1
  100. package/frontend/dist/js/{ShareDialog-DiXoIWJx.js → ShareDialog-DYwyeyaI.js} +1 -1
  101. package/frontend/dist/js/{StrandsPage-BQ-PMkvY.js → StrandsPage-CvXeYOYR.js} +1 -1
  102. package/frontend/dist/js/SystemPage-B4qFsAsb.js +1 -0
  103. package/frontend/dist/js/{TurnstileWidget-J61wYyqA.js → TurnstileWidget-xx9lQV0b.js} +1 -1
  104. package/frontend/dist/js/UserManagementPage-DhMRuhqj.js +1 -0
  105. package/frontend/dist/js/UserManagementPanel-BVLSvRwa.js +1 -0
  106. package/frontend/dist/js/{WhatsNewModal-DcAyhGzi.js → WhatsNewModal-DfR7W93-.js} +1 -1
  107. package/frontend/dist/js/WorkPage-DSKBQEW0.js +7 -0
  108. package/frontend/dist/js/api-C5ps_CWQ.js +1 -0
  109. package/frontend/dist/js/{api-D3RzHftc.js → api-D6IF0v9_.js} +1 -1
  110. package/frontend/dist/js/{appNavigation-Df-xsLY5.js → appNavigation-BifMRN3D.js} +1 -1
  111. package/frontend/dist/js/{appStore-qi0l_wou.js → appStore-B6pAGo3p.js} +2 -2
  112. package/frontend/dist/js/appVersion-9UMn7b1T.js +1 -0
  113. package/frontend/dist/js/authStore-CDo5Co2D.js +1 -0
  114. package/frontend/dist/js/{authStore-BhwtFhS3.js → authStore-DdIb6km_.js} +3 -3
  115. package/frontend/dist/js/babel-BaOs8qJH.js +16 -0
  116. package/frontend/dist/js/{chatStore-mB6kXQVu.js → chatStore-hzQyRM9H.js} +3 -3
  117. package/frontend/dist/js/{client-tVKsnAVI.js → client-D_F_0LqX.js} +2 -2
  118. package/frontend/dist/js/{config-bhyjjacC.js → config-CHUQTU6j.js} +1 -1
  119. package/frontend/dist/js/{estree-BmKwYjuD.js → estree-Cw-tQG5d.js} +1 -1
  120. package/frontend/dist/js/{evaluationsApi-DxuXU4NS.js → evaluationsApi-C0FKNJua.js} +1 -1
  121. package/frontend/dist/js/{markdown-D-PuDeiZ.js → markdown-C7cnJl_Q.js} +5 -5
  122. package/frontend/dist/js/{markdown-core-D-4xNKNv.js → markdown-core-CGWDtd6X.js} +5 -5
  123. package/frontend/dist/js/{markdown-html-Cd75Y-85.js → markdown-html-BdYVneHE.js} +1 -1
  124. package/frontend/dist/js/{markdown-math-DUQvxNgB.js → markdown-math-BzLEmswF.js} +1 -1
  125. package/frontend/dist/js/{markdownHtml-mmK-QYY6.js → markdownHtml-B1Ll_Qgp.js} +1 -1
  126. package/frontend/dist/js/markdownMath-aI8uDQmz.js +1 -0
  127. package/frontend/dist/js/{messageCodeStyles-nVE1JYdR.js → messageCodeStyles-DVYyK8wm.js} +2 -2
  128. package/frontend/dist/js/{postcss-CU3LgMVN.js → postcss-DB_e0nkW.js} +1 -1
  129. package/frontend/dist/js/{react-vendor-GLIQTwVZ.js → react-vendor-C1iE8mnY.js} +2 -2
  130. package/frontend/dist/js/rfb-IV07oQgM.js +5 -0
  131. package/frontend/dist/js/rolldown-runtime-XKyaHtl9.js +1 -0
  132. package/frontend/dist/js/router-vendor-qltZAWoz.js +1 -0
  133. package/frontend/dist/js/{strandsApi-C04kQWMg.js → strandsApi-CeJLezXW.js} +1 -1
  134. package/frontend/dist/js/{syntax-highlight-BlVvro-Z.js → syntax-highlight-CemL-n1v.js} +2 -2
  135. package/frontend/dist/js/{teamEventStream-Cf62joPP.js → teamEventStream-DOMyufrH.js} +1 -1
  136. package/frontend/dist/js/{typescript-C28ytPnl.js → typescript-2anSzo_N.js} +2 -2
  137. package/frontend/dist/js/ui-D4Ytvr6d.js +2 -0
  138. package/frontend/dist/js/ui-vendor-BTcw5yZ6.js +1 -0
  139. package/frontend/dist/js/{useChat-BWWunIVw.js → useChat-BEbNywiP.js} +4 -4
  140. package/frontend/dist/js/{useDialogFocus-Dfa5Utj4.js → useDialogFocus-DpTun-ZV.js} +1 -1
  141. package/frontend/dist/js/useDictation-jTaorrHm.js +1 -0
  142. package/frontend/dist/js/useQuery-2_pQiHbl.js +1 -0
  143. package/frontend/dist/js/{useTranslation-B69j_cNd.js → useTranslation-D9EScZXH.js} +1 -1
  144. package/frontend/dist/js/utils-BvvV-Cka.js +1 -0
  145. package/frontend/dist/js/{utils-vendor-DWQLsiSj.js → utils-vendor-CsC5rH1J.js} +1 -1
  146. package/frontend/dist/js/workAnnouncements--WBYN99v.js +1 -0
  147. package/frontend/dist/js/workApi-CGvfDTRY.js +1 -0
  148. package/frontend/dist/js/{workApi-CMbUePsX.js → workApi-_0oxRyak.js} +1 -1
  149. package/frontend/dist/js/xterm-BMsy1fDS.js +16 -0
  150. package/frontend/dist/js/{yaml-uvx2gM_u.js → yaml-Breo7DWT.js} +1 -1
  151. package/package.json +4 -4
  152. package/plugins/meta.json +77 -0
  153. package/frontend/dist/assets/index-BvQepfeH.js +0 -53
  154. package/frontend/dist/js/AutomationsPage-CsaCHmN_.js +0 -1
  155. package/frontend/dist/js/ChannelsPage-DXD6PlTg.js +0 -1
  156. package/frontend/dist/js/ChatPage-C7NQy4ts.js +0 -14
  157. package/frontend/dist/js/ConnectModels-De18RKwJ.js +0 -1
  158. package/frontend/dist/js/EvaluationsPage-BCVJse6N.js +0 -2
  159. package/frontend/dist/js/FirstTimeSetup-M3iWWKTn.js +0 -1
  160. package/frontend/dist/js/GalleryPage-C-F45c09.js +0 -1
  161. package/frontend/dist/js/NotesPage-Dd2N_7zQ.js +0 -3
  162. package/frontend/dist/js/PersonasPage-DONF1JmU.js +0 -13
  163. package/frontend/dist/js/PluginUsagePage-Bu4pTUjq.js +0 -1
  164. package/frontend/dist/js/SettingsModal-Dabi8xVs.js +0 -19
  165. package/frontend/dist/js/SystemPage-CCCL2ByV.js +0 -1
  166. package/frontend/dist/js/UserManagementPage-H_uXYSnx.js +0 -1
  167. package/frontend/dist/js/UserManagementPanel-B2cJLYCP.js +0 -1
  168. package/frontend/dist/js/WorkPage-B1Rt99I9.js +0 -7
  169. package/frontend/dist/js/api-BU9PuoZz.js +0 -1
  170. package/frontend/dist/js/appVersion-CVfieEPW.js +0 -1
  171. package/frontend/dist/js/authStore-dszH-1C-.js +0 -1
  172. package/frontend/dist/js/babel-Dxd799BX.js +0 -16
  173. package/frontend/dist/js/markdownMath-Cf7jtPFB.js +0 -1
  174. package/frontend/dist/js/rfb-CtGtw_KV.js +0 -5
  175. package/frontend/dist/js/rolldown-runtime-hePW80VL.js +0 -1
  176. package/frontend/dist/js/router-vendor-BHaThOyH.js +0 -1
  177. package/frontend/dist/js/ui-DF-BqCU3.js +0 -2
  178. package/frontend/dist/js/ui-vendor--a64oKSu.js +0 -1
  179. package/frontend/dist/js/useDictation-Dxq5DG5V.js +0 -1
  180. package/frontend/dist/js/useQuery-Cv6hRATl.js +0 -1
  181. package/frontend/dist/js/utils-BCv-T6HP.js +0 -1
  182. package/frontend/dist/js/workAnnouncements-C2Cd6YCk.js +0 -1
  183. package/frontend/dist/js/workApi-CsmIQW0M.js +0 -1
  184. package/frontend/dist/js/xterm-CerOhKYV.js +0 -16
@@ -0,0 +1,13 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-vendor-C1iE8mnY.js";import{C as r,t as i}from"./useQuery-2_pQiHbl.js";import{t as a}from"./utils-BvvV-Cka.js";import{t as o}from"./useTranslation-D9EScZXH.js";import{t as s}from"./chatStore-hzQyRM9H.js";import{t as c}from"./logger-rEW7uQ8m.js";import{t as l}from"./appStore-B6pAGo3p.js";import{$t as u,An as d,B as f,Bn as p,D as m,Dt as h,Jt as g,M as _,N as ee,Or as v,Q as y,V as te,_ as b,c as x,g as ne,it as S,j as re,jn as C,kn as w,n as T,p as E,qt as D,rt as O,s as k,sr as A,t as j,tr as M,v as N,xn as P,xr as F,zt as I}from"./ui-vendor-BTcw5yZ6.js";import{t as L}from"./Button-DwZ26Lqc.js";import{n as R,o as z,r as B,s as V,t as H}from"./ui-D4Ytvr6d.js";import{M as ie,_ as U,d as W,f as G,g as ae,j as oe,m as K,p as se}from"./api-D6IF0v9_.js";import{t as ce}from"./AvatarUpload-DGRQC20B.js";import{t as le}from"./ShareDialog-DYwyeyaI.js";var q=e(t(),1),J=n(),Y=c(`components:persona-card`),ue=({persona:e,onEdit:t,onDelete:n,onDownload:s,onSelect:c,onToggleFavorite:l,isSelected:u=!1,compact:p=!1})=>{let{t:g}=o(),ee=r(),[y,b]=(0,q.useState)(!1),x=(0,q.useRef)(null),T=(0,q.useRef)(null),[E,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(!1);(0,q.useEffect)(()=>{y&&T.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[y]);let M=(e=!1)=>{b(!1),e&&x.current?.focus()},I=e=>{if(e.key===`Escape`){e.stopPropagation(),M(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=Array.from(T.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()},R=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),{data:z=null}=i({queryKey:[`persona-memory-status`,e.id],queryFn:async()=>{let t=await K.getMemoryStatus(e.id);return t.success&&t.data?t.data:null},enabled:R}),B=()=>ee.invalidateQueries({queryKey:[`persona-memory-status`,e.id]}),V=async()=>{if(confirm(g(`personaCard.wipeConfirm`))){k(!0);try{let t=await K.wipeMemories(e.id);t.success?(v.success(g(`personaCard.wipeSuccess`,{count:t.data?.deleted_count||0})),await B()):v.error(g(`personaCard.wipeFailed`))}catch(e){v.error(g(`personaCard.wipeFailed`)),Y.error(e)}finally{k(!1),b(!1)}}},H=async()=>{k(!0);try{let t=await K.backupPersona(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-backup.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),v.success(g(`personaCard.backupSuccess`))}catch(e){v.error(g(`personaCard.backupFailed`)),Y.error(e)}finally{k(!1),b(!1)}},ie=async()=>{k(!0);try{let t=await K.exportPersonaDNA(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-dna.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),v.success(g(`personaCard.dnaSuccess`))}catch(e){v.error(g(`personaCard.exportDnaFailed`)),Y.error(e)}finally{k(!1),b(!1)}},W=(t=128)=>ae(e,t),G=(t=128)=>n=>{U(n.currentTarget,e.name,t)};return p?(0,J.jsxs)(`div`,{className:a(`group relative flex items-center gap-3 p-3 rounded-xl cursor-pointer transition-all duration-200`,`border border-transparent`,`hover:bg-gray-50 dark:hover:bg-dark-100`,u&&[`bg-primary-50 dark:bg-primary-900/20`,`border-primary-200 dark:border-primary-700`]),onClick:()=>c?.(e),children:[(0,J.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,J.jsx)(`img`,{src:W(64),alt:e.name,className:`w-10 h-10 rounded-full object-cover ring-2 ring-white dark:ring-dark-100`,onError:G(64)}),R&&(0,J.jsx)(`div`,{className:`absolute -bottom-0.5 -inset-e-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-primary-600`,children:(0,J.jsx)(_,{className:`h-2.5 w-2.5 text-white`})})]}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`h4`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 truncate`,children:e.name}),e.is_favorite&&(0,J.jsx)(m,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`})]}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:e.model})]}),u&&(0,J.jsx)(`div`,{className:`shrink-0`,children:(0,J.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary-500 dark:bg-primary-600 flex items-center justify-center`,children:(0,J.jsx)(S,{className:`h-3 w-3 text-white rtl:rotate-180`})})})]}):(0,J.jsxs)(`div`,{className:a(`group relative overflow-hidden rounded-2xl transition-[border-color,background-color] duration-200`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`hover:border-gray-300 dark:hover:border-white/20`,u&&[`ring-2 ring-primary-500 dark:ring-primary-400`,`border-primary-300 dark:border-primary-600`]),children:[(0,J.jsxs)(`div`,{className:`relative h-24`,children:[e.background?(0,J.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,J.jsx)(`div`,{className:`absolute inset-0 bg-gray-200 dark:bg-dark-200`}),e.background&&(0,J.jsx)(`div`,{className:`absolute inset-0 bg-black/15 dark:bg-black/25`}),(0,J.jsxs)(`div`,{className:`absolute inset-x-3 top-3 flex items-start justify-between`,children:[l?(0,J.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e)},"aria-pressed":!!e.is_favorite,"aria-label":g(`personaCard.favorite`),title:g(`personaCard.favorite`),className:a(`p-1.5 rounded-full transition-all duration-200`,`border border-white/30 bg-black/20 text-white backdrop-blur-sm hover:bg-black/30`,e.is_favorite&&`bg-amber-500/80 hover:bg-amber-500`),children:(0,J.jsx)(m,{className:a(`h-4 w-4`,e.is_favorite?`fill-ink text-ink dark:fill-ink-inverse dark:text-ink-inverse`:`text-white/80 hover:text-white`)})}):e.is_favorite?(0,J.jsx)(`span`,{role:`img`,"aria-label":g(`personaCard.favorite`),title:g(`personaCard.favorite`),className:`rounded-full border border-white/30 bg-amber-500/80 p-1.5 backdrop-blur-sm`,children:(0,J.jsx)(m,{className:`h-4 w-4 fill-ink text-ink dark:fill-ink-inverse dark:text-ink-inverse`})}):(0,J.jsx)(`span`,{}),R&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full border border-white/30 bg-black/20 px-2 py-1 text-[10px] font-medium text-white backdrop-blur-sm`,children:[(0,J.jsx)(_,{className:`h-3 w-3`}),g(`personaCard.enhanced`)]})]})]}),(0,J.jsx)(`div`,{className:`relative -mt-8 px-4`,children:(0,J.jsxs)(`div`,{className:`relative inline-block`,children:[(0,J.jsx)(`img`,{src:W(128),alt:e.name,className:`h-16 w-16 rounded-xl object-cover ring-4 ring-white dark:ring-dark-100`,onError:G(128)}),R&&(0,J.jsx)(`div`,{className:`absolute -bottom-1 -inset-e-1 flex h-6 w-6 items-center justify-center rounded-lg bg-primary-600 ring-2 ring-white dark:ring-dark-100`,children:(0,J.jsx)(A,{className:`h-3.5 w-3.5 text-white`})})]})}),(0,J.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[(0,J.jsxs)(`div`,{className:`mb-3`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 leading-tight`,children:e.name}),(0,J.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1.5 mt-0.5`,children:[(0,J.jsx)(te,{className:`h-3.5 w-3.5`}),e.model]})]}),e.description&&(0,J.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3`,children:e.description}),e.parameters.system_prompt&&(0,J.jsxs)(`div`,{className:`mb-3 rounded-xl border border-gray-200/70 bg-gray-50/70 p-2.5 dark:border-white/8 dark:bg-white/2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,J.jsx)(h,{className:`h-3 w-3 text-gray-400 dark:text-gray-500`}),(0,J.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-gray-400 dark:text-gray-500`,children:g(`personaCard.systemPrompt`)})]}),(0,J.jsxs)(`p`,{className:`line-clamp-2 text-xs leading-5 text-gray-600 dark:text-gray-400`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/8 dark:text-gray-400`,children:[(0,J.jsx)(j,{className:`h-3 w-3`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/8 dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/8 dark:text-gray-400`,children:[(e.parameters.context_window||4096).toLocaleString(),` ctx`]})]}),R&&z&&(0,J.jsx)(`div`,{className:`mb-3 rounded-xl border border-primary-200/70 bg-primary-50/50 p-2.5 dark:border-primary-800/40 dark:bg-primary-900/10`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(C,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300`,children:[z.memory_count,` `,g(`personaCard.memories`)]}),(0,J.jsx)(`span`,{className:`ms-2 text-[10px] text-primary-600/70 dark:text-primary-400/70`,children:(e=>e<1?`${(e*1024).toFixed(0)} KB`:`${e.toFixed(1)} MB`)(z.size_mb)})]})]}),z.status&&(0,J.jsx)(`span`,{className:a(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,z.status===`active`?`bg-success-500/20 text-ink`:`bg-surface-subtle text-ink-muted`),children:g(`personaCard.memoryStatus.${z.status}`)})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200/70 pt-3 dark:border-white/8`,children:[c&&(0,J.jsxs)(L,{onClick:()=>c(e),size:`sm`,className:`px-4`,children:[(0,J.jsx)(S,{className:`me-1.5 h-3.5 w-3.5 rtl:rotate-180`}),g(`personaCard.use`)]}),(0,J.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:g(`personaCard.editTooltip`),"aria-label":g(`personaCard.editTooltip`),children:(0,J.jsx)(re,{className:`h-4 w-4`})}),!e.shared&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>D(!0),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:g(`personaCard.shareTooltip`),"aria-label":g(`personaCard.shareTooltip`),"data-testid":`persona-share`,children:(0,J.jsx)(f,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>s(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:g(`personaCard.downloadTooltip`),"aria-label":g(`personaCard.downloadTooltip`),children:(0,J.jsx)(d,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`button`,{ref:x,type:`button`,onClick:()=>b(!y),"aria-haspopup":`menu`,"aria-expanded":y,className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:g(`common.more`),"aria-label":g(`common.more`),children:(0,J.jsx)(w,{className:`h-4 w-4`})}),y&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>b(!1)}),(0,J.jsxs)(`div`,{ref:T,role:`menu`,onKeyDown:I,className:`absolute inset-e-0 bottom-full z-20 mb-1 w-44 rounded-xl border border-gray-200 bg-white py-1 shadow-lg dark:border-white/10 dark:bg-dark-100`,children:[R&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:H,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,J.jsx)(F,{className:`h-4 w-4`}),g(`personaCard.backup`)]}),(0,J.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:ie,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,J.jsx)(P,{className:`h-4 w-4`}),g(`personaCard.exportDNA`)]}),z&&z.memory_count>0&&(0,J.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:V,disabled:O,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50`,children:[(0,J.jsx)(ne,{className:`h-4 w-4`}),g(`personaCard.wipeMemories`)]}),(0,J.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200`})]}),(0,J.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{n(e),b(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20`,children:[(0,J.jsx)(N,{className:`h-4 w-4`}),g(`common.delete`)]})]})]})]})]})]})]}),E&&(0,J.jsx)(le,{resourceType:`persona`,resourceId:e.id,resourceLabel:e.name,onClose:()=>D(!1)})]})},X={name:``,description:``,model:``,parameters:{temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0},avatar:``,background:``,embedding_model:``,memory_settings:{enabled:!1,max_memories:1e3,auto_cleanup:!0,retention_days:90},mutation_settings:{enabled:!1,sensitivity:`medium`,auto_adapt:!0}};function de({embeddingModel:e,embeddingModels:t,onEmbeddingModelChange:n}){let{t:r}=o(),i=t.filter(e=>e.isDetectedEmbedding),a=t.filter(e=>!e.isDetectedEmbedding);return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`rounded-xl p-5 bg-linear-to-br from-primary-50 to-primary-100/50 dark:from-primary-900/30 dark:to-primary-800/20 border border-primary-200/50 dark:border-primary-700/30`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,J.jsx)(C,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,J.jsx)(`h3`,{className:`font-semibold text-primary-900 dark:text-primary-100`,children:r(`personaForm.advanced.embeddingModel`)})]}),(0,J.jsx)(`p`,{className:`text-xs text-primary-600 dark:text-primary-400 mb-3`,children:r(`personaForm.advanced.embeddingHint`)}),(0,J.jsx)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full px-3 py-2.5 border border-primary-200 dark:border-primary-700 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20`,children:t.length===0?(0,J.jsx)(`option`,{value:``,disabled:!0,children:r(`personaForm.advanced.noModels`)}):(0,J.jsxs)(J.Fragment,{children:[i.length>0&&(0,J.jsx)(`optgroup`,{label:r(`personaForm.advanced.embeddingModels`),children:i.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))}),a.length>0&&(0,J.jsx)(`optgroup`,{label:r(`personaForm.advanced.otherModels`),children:a.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))})]})}),t.length===0&&(0,J.jsx)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-700/50 dark:bg-amber-900/20`,children:(0,J.jsxs)(`p`,{className:`text-sm text-ink`,children:[r(`personaForm.advanced.installHint`),` `,(0,J.jsx)(`code`,{className:`rounded-sm bg-amber-500/20 px-1.5 py-0.5 text-xs dark:bg-amber-900/40`,children:`ollama pull nomic-embed-text`})]})}),(0,J.jsx)(`p`,{className:`text-[10px] text-primary-500 dark:text-primary-500 mt-2`,children:r(`personaForm.advanced.recommended`)})]}),(0,J.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-dark-50 rounded-xl border border-gray-200 dark:border-dark-300`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(D,{className:`h-5 w-5 text-gray-400 mt-0.5 shrink-0`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`personaForm.advanced.aboutTitle`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:r(`personaForm.advanced.aboutDescription`)})]})]})})]})}var fe=c(`components:persona-background-upload`),pe=({value:e,onChange:t,className:n=``})=>{let{t:r}=o(),i=(0,q.useRef)(null),[a,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),u=async e=>{if(!e.type.startsWith(`image/`))v.error(r(`personaBackground.invalidFile`));else if(e.size>5242880)v.error(r(`personaBackground.fileTooLarge`));else{s(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),v.success(r(`personaBackground.uploaded`))},n.onerror=()=>{v.error(r(`personaBackground.readFailed`))},n.readAsDataURL(e)}catch(e){fe.error(`Failed to upload background:`,e),v.error(r(`personaBackground.uploadFailed`))}finally{s(!1)}}};return(0,J.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`personaBackground.label`)}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[e?(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`div`,{className:`w-full h-32 rounded-lg bg-cover bg-center border-2 border-gray-300 dark:border-dark-300`,style:{backgroundImage:`url(${e})`}}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`personaBackground.customBackground`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`personaBackground.clickToChange`)})]}),(0,J.jsx)(L,{variant:`ghost`,size:`sm`,onClick:()=>{t(``),v.success(r(`personaBackground.removed`))},className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,J.jsx)(T,{className:`h-4 w-4`})})]})]}):(0,J.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${c?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:e=>{e.preventDefault(),l(!1)},onDrop:e=>{e.preventDefault(),l(!1);let t=e.dataTransfer.files?.[0];t&&u(t)},onClick:()=>i.current?.click(),children:[(0,J.jsx)(g,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`personaBackground.uploadBackgroundImage`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:r(`personaBackground.dragAndDrop`)}),(0,J.jsxs)(L,{variant:`outline`,size:`sm`,disabled:a,className:`mx-auto`,children:[(0,J.jsx)(E,{className:`h-4 w-4 mr-2`}),r(a?`personaBackground.uploading`:`personaBackground.chooseImage`)]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`personaBackground.enterImageUrl`)}),(0,J.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/background.jpg`})]})]}),(0,J.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)},className:`hidden`}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`personaBackground.supportedFormats`)})]})})};function me({formData:e,availableModels:t,onFieldChange:n,onParameterChange:r}){let{t:i}=o(),a=(0,q.useMemo)(()=>t.filter(e=>!e.isPlugin),[t]),s=(0,q.useMemo)(()=>{let e=new Map;for(let n of t){if(!n.isPlugin)continue;let t=n.pluginName||n.pluginId||`Provider`,r=e.get(t);r?r.push(n):e.set(t,[n])}return[...e.entries()].sort(([e],[t])=>e.localeCompare(t))},[t]);return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[i(`personaForm.basic.name`),` *`]}),(0,J.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>n(`name`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,placeholder:i(`personaForm.basic.namePlaceholder`),required:!0})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[i(`personaForm.basic.model`),` *`]}),(0,J.jsxs)(`select`,{value:e.model,onChange:e=>n(`model`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,required:!0,children:[(0,J.jsx)(`option`,{value:``,children:i(`personaForm.basic.selectModel`)}),e.model&&!t.some(t=>t.name===e.model)&&(0,J.jsx)(`option`,{value:e.model,children:e.model}),a.length>0&&(0,J.jsx)(`optgroup`,{label:`Ollama`,children:a.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.name))}),s.map(([e,t])=>(0,J.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.name))},e))]})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaForm.basic.description`)}),(0,J.jsx)(`textarea`,{value:e.description,onChange:e=>n(`description`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none`,rows:3,placeholder:i(`personaForm.basic.descriptionPlaceholder`)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,J.jsx)(ce,{value:e.avatar||``,onChange:e=>n(`avatar`,e)}),(0,J.jsx)(pe,{value:e.background||``,onChange:e=>n(`background`,e)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaForm.basic.systemPrompt`)}),(0,J.jsx)(`textarea`,{value:e.parameters.system_prompt,onChange:e=>r(`system_prompt`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none font-mono text-sm`,rows:6,placeholder:i(`personaForm.basic.systemPromptPlaceholder`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-2`,children:i(`personaForm.basic.systemPromptHint`)})]})]})}function he({submitting:e,lastSaved:t,onCancel:n,onSave:r}){let{t:i}=o();return(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(L,{type:`button`,variant:`ghost`,onClick:n,disabled:e,className:`text-gray-600 dark:text-gray-400`,children:i(`personaForm.actions.cancel`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,J.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-1.5 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,J.jsx)(M,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{children:i(`personaForm.saved`)})]}),(0,J.jsx)(L,{type:`button`,onClick:r,disabled:e,children:i(e?`personaForm.actions.saving`:`personaForm.actions.save`)})]})]})}var ge=c(`components:persona-bindings`),_e=[`web_search`,`search_documents`,`list_documents`,`read_document`,`load_skill`];function ve({bindings:e,onChange:t}){let{t:n}=o(),[r,i]=(0,q.useState)([]),[a,s]=(0,q.useState)([]),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(!0);(0,q.useEffect)(()=>{let e=!1;return Promise.all([W.listServers(),G.list(),se.list(),oe.getCollections()]).then(([t,n,r,a])=>{e||(t.success&&t.data&&i(t.data),n.success&&n.data&&s(n.data),r.success&&r.data&&l(r.data),a.success&&a.data&&d(a.data))}).catch(e=>{ge.error(`Failed to load bindable resources:`,e)}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let m=n=>t({...e??{},...n}),h=(t,n)=>{let r=e?.[t]??[];m({[t]:r.includes(n)?r.filter(e=>e!==n):[...r,n]})};return f?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,J.jsx)(I,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,J.jsxs)(`div`,{className:`space-y-6`,"data-testid":`persona-bindings-tab`,children:[(0,J.jsx)(Z,{title:n(`personaForm.bindings.toolServers`),hint:n(`personaForm.bindings.toolServersHint`),emptyLabel:n(`personaForm.bindings.noToolServers`),options:r.map(e=>({id:e.id,label:e.name,detail:e.description})),selected:e?.tool_server_ids??[],onToggle:e=>h(`tool_server_ids`,e),testId:`persona-binding-tool-servers`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.builtinTools`),hint:n(`personaForm.bindings.builtinToolsHint`),emptyLabel:n(`personaForm.bindings.noBuiltinTools`),options:_e.map(e=>({id:e,label:n(`personaForm.bindings.builtin.${e}`),detail:e})),selected:e?.builtin_tools??[],onToggle:e=>h(`builtin_tools`,e),testId:`persona-binding-builtin-tools`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.skills`),hint:n(`personaForm.bindings.skillsHint`),emptyLabel:n(`personaForm.bindings.noSkills`),options:a.map(e=>({id:e.id,label:e.name,detail:`$${e.slug}`})),selected:e?.skill_ids??[],onToggle:e=>h(`skill_ids`,e),testId:`persona-binding-skills`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.collections`),hint:n(`personaForm.bindings.collectionsHint`),emptyLabel:n(`personaForm.bindings.noCollections`),options:u.map(e=>({id:e.id,label:e.name})),selected:e?.knowledge_collection_ids??[],onToggle:t=>{let n=e?.knowledge_collection_ids??[];m({knowledge_collection_ids:n.includes(t)?n.filter(e=>e!==t):[...n,t]})},testId:`persona-binding-collections`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-800`,children:n(`personaForm.bindings.prompt`)}),(0,J.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-gray-500 dark:text-dark-600`,children:n(`personaForm.bindings.promptHint`)}),(0,J.jsxs)(`select`,{value:e?.prompt_id??``,onChange:e=>m({prompt_id:e.target.value||void 0}),"data-testid":`persona-binding-prompt`,"aria-label":n(`personaForm.bindings.prompt`),className:`w-full rounded-lg border border-gray-200 bg-white px-3 py-2.5 text-sm text-gray-900 focus:ring-2 focus:ring-primary-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,J.jsx)(`option`,{value:``,children:n(`personaForm.bindings.noPrompt`)}),c.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,J.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:n(`personaForm.bindings.version`,{version:e?.version??0})})]})}function Z({title:e,hint:t,emptyLabel:n,options:r,selected:i,onToggle:a,testId:o}){return(0,J.jsxs)(`div`,{"data-testid":o,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-800`,children:e}),(0,J.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-gray-500 dark:text-dark-600`,children:t}),r.length===0?(0,J.jsx)(`p`,{className:`rounded-lg border border-dashed border-gray-200 px-3 py-4 text-center text-xs text-gray-400 dark:border-dark-300 dark:text-dark-500`,children:n}):(0,J.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-1.5 transition-colors hover:bg-gray-50 dark:hover:bg-dark-200`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.id),onChange:()=>a(e.id),className:`h-4 w-4 rounded-sm border-gray-300 dark:border-dark-400`}),(0,J.jsx)(`span`,{className:`text-sm text-gray-900 dark:text-dark-800`,children:e.label}),e.detail&&(0,J.jsx)(`span`,{className:`truncate text-xs text-gray-400 dark:text-dark-500`,children:e.detail})]},e.id))})]})}var Q=({label:e,value:t,min:n,max:r,step:i,onChange:o,hint:s,format:c=e=>String(e),colorClass:l=`text-gray-700 dark:text-dark-600`})=>{let u=(t-n)/(r-n)*100;return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`label`,{className:a(`block text-sm font-medium`,l),children:e}),(0,J.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:c(t),onChange:e=>{let t=parseFloat(e.target.value);isNaN(t)||o(Math.min(r,Math.max(n,t)))},className:`w-20 px-2 py-1 text-sm text-right bg-gray-100 dark:bg-dark-200 border border-gray-300 dark:border-dark-300 rounded-sm focus:outline-hidden focus:ring-1 focus:ring-primary-500 dark:text-dark-600`})]}),(0,J.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>o(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 dark:bg-dark-200 rounded-lg appearance-none cursor-pointer slider`,style:{"--progress":`${u}%`}}),s&&(0,J.jsx)(`p`,{className:a(`text-xs mt-1`,l.replace(`700`,`500`).replace(`600`,`400`)),children:s})]})},$=({label:e,checked:t,onChange:n,colorClass:r=`text-gray-700 dark:text-dark-600`})=>(0,J.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,J.jsx)(`div`,{className:a(`relative w-10 h-5 rounded-full transition-colors`,t?`bg-primary-500 dark:bg-primary-600`:`bg-gray-300 dark:bg-dark-300`),onClick:()=>n(!t),children:(0,J.jsx)(`div`,{className:a(`absolute top-0.5 inset-s-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform`,t&&`translate-x-5 rtl:-translate-x-5`)})}),(0,J.jsx)(`span`,{className:a(`text-sm font-medium`,r),children:e})]});function ye({formData:e,persona:t,memoryStatus:n,loadingMemoryStatus:r,wipingMemories:i,onSettingsChange:s,onWipeMemories:c}){let{t:l}=o();return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-emerald-200/50 dark:border-emerald-700/30`,children:[(0,J.jsx)(`div`,{className:`px-5 py-4 bg-linear-to-r from-emerald-500 to-teal-500 dark:from-emerald-600 dark:to-teal-600`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,J.jsx)(C,{className:`h-5 w-5 text-white`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`font-semibold text-white`,children:l(`personaForm.memory.title`)}),(0,J.jsx)(`p`,{className:`text-xs text-white/80`,children:l(`personaForm.memory.subtitle`)})]})]}),(0,J.jsx)($,{label:``,checked:e.memory_settings?.enabled||!1,onChange:e=>s(`memory_settings`,{enabled:e})})]})}),e.memory_settings?.enabled&&t?.id&&(0,J.jsx)(`div`,{className:`px-5 py-4 bg-emerald-50 dark:bg-emerald-900/20 border-b border-emerald-100 dark:border-emerald-800/30`,children:r?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,J.jsx)(y,{className:`h-4 w-4 animate-spin`}),l(`personaForm.memory.loading`)]}):n?(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(C,{className:`h-5 w-5`}),n.memory_count.toLocaleString()]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.memories`)})]}),(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(u,{className:`h-5 w-5`}),n.size_mb.toFixed(1)]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.mbUsed`)})]}),(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(p,{className:`h-5 w-5`}),n.last_backup?new Date(n.last_backup).toLocaleDateString():l(`personaForm.memory.never`)]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.lastBackup`)})]})]}):(0,J.jsx)(`p`,{className:`text-sm text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.noData`)})}),e.memory_settings?.enabled&&(0,J.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-4`,children:[(0,J.jsx)(Q,{label:l(`personaForm.memory.maxMemories`),value:e.memory_settings.max_memories,min:100,max:1e4,step:100,hint:l(`personaForm.memory.maxMemoriesHint`),format:e=>e.toLocaleString(),colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{max_memories:e})}),(0,J.jsx)(Q,{label:l(`personaForm.memory.retention`),value:e.memory_settings.retention_days,min:7,max:365,step:7,hint:l(`personaForm.memory.retentionHint`),format:e=>`${Math.round(e)} days`,colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{retention_days:e})}),(0,J.jsx)($,{label:l(`personaForm.memory.autoCleanup`),checked:e.memory_settings.auto_cleanup,onChange:e=>s(`memory_settings`,{auto_cleanup:e}),colorClass:`text-emerald-700 dark:text-emerald-300`}),t?.id&&n&&n.memory_count>0&&(0,J.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800/30`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:l(`personaForm.memory.wipeAll`)}),(0,J.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l(`personaForm.memory.wipeCannot`)})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:c,disabled:i,className:`px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5`,children:[i?(0,J.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(N,{className:`h-3.5 w-3.5`}),l(i?`personaForm.memory.wiping`:`personaForm.memory.wipeButton`)]})]})})]}),!e.memory_settings?.enabled&&(0,J.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,J.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:l(`personaForm.memory.enableHint`)})})]}),(0,J.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-primary-200/50 dark:border-primary-700/30`,children:[(0,J.jsx)(`div`,{className:`px-5 py-4 bg-primary-600 dark:bg-primary-600`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,J.jsx)(b,{className:`h-5 w-5 text-white`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`font-semibold text-white`,children:l(`personaForm.learning.title`)}),(0,J.jsx)(`p`,{className:`text-xs text-white/80`,children:l(`personaForm.learning.subtitle`)})]})]}),(0,J.jsx)($,{label:``,checked:e.mutation_settings?.enabled||!1,onChange:e=>s(`mutation_settings`,{enabled:e})})]})}),e.mutation_settings?.enabled&&(0,J.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-primary-700 dark:text-primary-300 mb-3`,children:l(`personaForm.learning.speed`)}),(0,J.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{level:`low`,icon:j,label:l(`personaForm.learning.slow`),desc:l(`personaForm.learning.slowDesc`)},{level:`medium`,icon:b,label:l(`personaForm.learning.balanced`),desc:l(`personaForm.learning.balancedDesc`)},{level:`high`,icon:_,label:l(`personaForm.learning.fast`),desc:l(`personaForm.learning.fastDesc`)}].map(({level:t,icon:n,label:r,desc:i})=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(`mutation_settings`,{sensitivity:t}),className:a(`p-3 rounded-xl text-center transition-all border`,e.mutation_settings?.sensitivity===t?`bg-primary-600 border-primary-600 text-white shadow-lg`:`bg-primary-50 dark:bg-primary-900/20 border-primary-200 dark:border-primary-700/30 text-primary-700 dark:text-primary-300 hover:bg-primary-100 dark:hover:bg-primary-900/30`),children:[(0,J.jsx)(n,{className:`h-5 w-5 mx-auto mb-1`}),(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:r}),(0,J.jsx)(`p`,{className:`text-[10px] opacity-70`,children:i})]},t))})]}),(0,J.jsx)($,{label:l(`personaForm.learning.autoAdapt`),checked:e.mutation_settings.auto_adapt,onChange:e=>s(`mutation_settings`,{auto_adapt:e}),colorClass:`text-primary-700 dark:text-primary-300`}),(0,J.jsxs)(`div`,{className:`p-4 bg-primary-50 dark:bg-primary-900/20 rounded-xl`,children:[(0,J.jsxs)(`p`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300 mb-2 flex items-center gap-1.5`,children:[(0,J.jsx)(A,{className:`h-3.5 w-3.5`}),l(`personaForm.learning.whatLearns`)]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-primary-600 dark:text-primary-400`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.conversationTone`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.responseStyle`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.userPreferences`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.topicInterests`)]})]})]})]}),!e.mutation_settings?.enabled&&(0,J.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,J.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:l(`personaForm.learning.enableHint`)})})]})]})}function be({parameters:e,onParameterChange:t}){let{t:n}=o(),r=(0,q.useMemo)(()=>[{key:`temperature`,label:n(`personaForm.parameters.temperature`),min:0,max:2,step:.1,hint:n(`personaForm.parameters.temperatureHint`),format:e=>e.toFixed(1)},{key:`top_p`,label:n(`personaForm.parameters.topP`),min:0,max:1,step:.1,hint:n(`personaForm.parameters.topPHint`),format:e=>e.toFixed(1)},{key:`top_k`,label:n(`personaForm.parameters.topK`),min:1,max:100,step:1,hint:n(`personaForm.parameters.topKHint`),format:e=>String(Math.round(e))},{key:`context_window`,label:n(`personaForm.parameters.contextWindow`),min:128,max:131072,step:128,hint:n(`personaForm.parameters.contextWindowHint`),format:e=>String(Math.round(e))},{key:`max_tokens`,label:n(`personaForm.parameters.maxTokens`),min:1,max:8192,step:1,hint:n(`personaForm.parameters.maxTokensHint`),format:e=>String(Math.round(e))},{key:`repeat_penalty`,label:n(`personaForm.parameters.repeatPenalty`),min:.5,max:2,step:.1,hint:n(`personaForm.parameters.repeatPenaltyHint`),format:e=>e.toFixed(1)}],[n]);return(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:r.map(({key:n,label:r,min:i,max:a,step:o,hint:s,format:c})=>(0,J.jsx)(Q,{label:r,value:e[n]||0,min:i,max:a,step:o,hint:s,format:c,onChange:e=>t(n,e)},n))})}var xe=c(`components:persona-form`),Se=({persona:e,onSubmit:t,onCancel:n})=>{let{preferences:c}=l(),{t:u}=o(),[d,f]=(0,q.useState)(X),p=s(e=>e.models),m=s(e=>e.loadModels),h=(0,q.useMemo)(()=>p.filter(e=>!e.isPersona&&!e.isAgent&&!e.isUnavailable&&!e.isLegacySelection),[p]),[g,y]=(0,q.useState)([]),[te,b]=(0,q.useState)(!1),[ne,S]=(0,q.useState)(!1),[re,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(`basic`),[E,D]=(0,q.useState)(!1),k=(0,q.useRef)(!1),j=(0,q.useCallback)((e,t)=>{f(n=>({...n,[e]:t})),C(null)},[]),M=(0,q.useCallback)((e,t)=>{f(n=>({...n,parameters:{...n.parameters,[e]:t}})),C(null)},[]),N=(0,q.useCallback)((e,t)=>{f(n=>({...n,[e]:{...n[e],...t}})),C(null)},[]),P=(0,q.useCallback)(e=>{let t=e.reduce((e,t)=>(e.find(e=>e.id===t.id)||e.push(t),e),[]);return t.length>0?t:[{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]},[]),F=e?.id,I=!!d.memory_settings?.enabled,L=r(),{data:R=null,isLoading:z}=i({queryKey:[`persona-memory-status`,F],queryFn:async()=>{if(!F)return null;let e=await K.getMemoryStatus(F);return e.success&&e.data?e.data:null},enabled:!!F&&I}),B=()=>L.invalidateQueries({queryKey:[`persona-memory-status`,F]}),V=async()=>{if(e?.id&&confirm(u(`personaForm.memory.wipeConfirm`))){D(!0);try{let t=await K.wipeMemories(e.id);t.success?(v.success(u(`personaForm.memory.wipeSuccess`,{count:t.data?.deleted_count||0})),await B()):v.error(u(`personaForm.error.saveFailed`))}catch{v.error(u(`personaForm.error.saveFailed`))}finally{D(!1)}}};(0,q.useEffect)(()=>{k.current||(k.current=!0,(async()=>{b(!0);try{let[t,n]=await Promise.all([ie.getModels(),e?Promise.resolve(null):K.getDefaultParameters(),s.getState().models.length===0?m({quiet:!0}):Promise.resolve()]),r=P(t.success&&t.data?t.data:[]);y(r);let i=r.find(e=>e.id===c.embeddingSettings?.model||e.rawModel===c.embeddingSettings?.model)?.id||r[0]?.id||``,a=r.find(t=>t.id===e?.embedding_model||t.rawModel===e?.embedding_model)?.id||e?.embedding_model||r[0]?.id||``;if(e)f({name:e.name,description:e.description||``,model:e.model,parameters:e.parameters,avatar:e.avatar||``,background:e.background||``,embedding_model:a,memory_settings:e.memory_settings||X.memory_settings,mutation_settings:e.mutation_settings||X.mutation_settings,bindings:e.bindings}),e.embedding_model&&!r.find(t=>t.id===e.embedding_model||t.rawModel===e.embedding_model)&&y(t=>P([...t,{id:e.embedding_model,name:e.embedding_model,description:`Previously selected model (not currently available)`,provider:`openai`,dimensions:0}]));else{let e=n?.success?n.data:{};f(t=>({...t,parameters:{...t.parameters,...e},embedding_model:i}))}}catch(e){xe.error(`Error loading data:`,e)}finally{b(!1)}})())},[e,P,m,c.embeddingSettings?.model]);let H=async()=>{S(!0);try{let n={name:d.name,description:d.description,model:d.model,parameters:d.parameters,avatar:d.avatar,background:d.background,embedding_model:d.embedding_model,memory_settings:d.memory_settings,mutation_settings:d.mutation_settings,bindings:d.bindings},r=e?await K.updatePersona(e.id,n):await K.createPersona(d);r.success&&r.data?(v.success(u(e?`personaForm.success.updated`:`personaForm.success.created`)),C(new Date),await t(r.data)):v.error(r.error?`${u(`personaForm.error.saveFailed`)}: ${r.error}`:u(`personaForm.error.saveFailed`))}catch(e){v.error(`${u(`personaForm.error.saveFailed`)}: ${e instanceof Error?e.message:String(e)}`)}finally{S(!1)}},U=(0,q.useMemo)(()=>[{id:`basic`,label:u(`personaForm.tabs.basic`),icon:x},{id:`parameters`,label:u(`personaForm.tabs.parameters`),icon:ee},{id:`memory`,label:u(`personaForm.tabs.memory`),icon:_},{id:`bindings`,label:u(`personaForm.tabs.bindings`),icon:O},{id:`advanced`,label:u(`personaForm.tabs.advanced`),icon:A}],[u]);return te?(0,J.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,J.jsxs)(`div`,{className:`animate-pulse flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin`}),(0,J.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:u(`personaForm.loading`)})]})}):(0,J.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:u(e?`personaForm.title.edit`:`personaForm.title.create`)}),(0,J.jsx)(`p`,{className:`mt-1 text-gray-600 dark:text-dark-600`,children:u(e?`personaForm.subtitle.edit`:`personaForm.subtitle.create`)})]}),(0,J.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg shadow-xs border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`div`,{role:`tablist`,"aria-label":u(`personaForm.sections`),className:`flex overflow-x-auto border-b border-gray-200 dark:border-dark-300`,onKeyDown:e=>{let t=U.findIndex(e=>e.id===w),n=document.documentElement.dir===`rtl`,r=n?`ArrowLeft`:`ArrowRight`,i=n?`ArrowRight`:`ArrowLeft`,a=-1;e.key===r?a=(t+1)%U.length:e.key===i?a=(t-1+U.length)%U.length:e.key===`Home`?a=0:e.key===`End`&&(a=U.length-1);let o=U[a];o&&(e.preventDefault(),T(o.id),document.getElementById(`persona-tab-${o.id}`)?.focus())},children:U.map(e=>(0,J.jsxs)(`button`,{id:`persona-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":w===e.id,"aria-controls":`persona-tabpanel`,tabIndex:w===e.id?0:-1,onClick:()=>T(e.id),className:a(`flex shrink-0 items-center gap-2 whitespace-nowrap px-6 py-4 text-sm font-medium transition-colors`,w===e.id?`border-b-2 border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-dark-600 hover:text-gray-700 dark:hover:text-dark-800`),children:[(0,J.jsx)(e.icon,{className:`h-4 w-4`,"aria-hidden":`true`}),e.label]},e.id))}),(0,J.jsxs)(`div`,{id:`persona-tabpanel`,role:`tabpanel`,"aria-labelledby":`persona-tab-${w}`,className:`p-6`,children:[w===`basic`&&(0,J.jsx)(me,{formData:d,availableModels:h,onFieldChange:j,onParameterChange:M}),w===`parameters`&&(0,J.jsx)(be,{parameters:d.parameters,onParameterChange:M}),w===`memory`&&(0,J.jsx)(ye,{formData:d,persona:e,memoryStatus:R,loadingMemoryStatus:z,wipingMemories:E,onSettingsChange:N,onWipeMemories:V}),w===`bindings`&&(0,J.jsx)(ve,{bindings:d.bindings,onChange:e=>j(`bindings`,e)}),w===`advanced`&&(0,J.jsx)(de,{embeddingModel:d.embedding_model,embeddingModels:g,onEmbeddingModelChange:e=>j(`embedding_model`,e)})]})]}),(0,J.jsx)(he,{submitting:ne,lastSaved:re,onCancel:n,onSave:H})]})]})},Ce=c(`components:persona-import-export`),we=({personas:e,onImport:t,onClose:n})=>{let{t:r}=o(),[i,a]=(0,q.useState)(!1),[s,c]=(0,q.useState)(``),l=async e=>{try{let t=await K.exportPersona(e.id),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=`${e.name}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),v.success(r(`personaImportExport.exportSuccess`,{name:e.name}))}catch(e){let t=e instanceof Error?e.message:String(e);v.error(r(`personaImportExport.exportFailed`)+`: `+t)}};return(0,J.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:r(`personaImportExport.title`)}),(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:r(`personaImportExport.description`)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-xs border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.exportPersonas`)}),e.length===0?(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-center py-8`,children:r(`personaImportExport.noPersonasToExport`)}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,J.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:r(`personaImportExport.personasAvailable`,{count:e.length})}),(0,J.jsx)(L,{onClick:async()=>{try{let t=e.map(e=>K.exportPersona(e.id)),n=await Promise.all(t),i={personas:n,exportedAt:Date.now(),version:`1.0.0`,count:n.length},a=new Blob([JSON.stringify(i,null,2)],{type:`application/json`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`personas-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o),v.success(r(`personaImportExport.exportAllSuccess`,{count:e.length}))}catch(e){let t=e instanceof Error?e.message:String(e);v.error(r(`personaImportExport.exportAllFailed`)+`: `+t)}},variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`personaImportExport.exportAll`)})]}),(0,J.jsx)(`div`,{className:`space-y-2 max-h-80 overflow-y-auto`,children:e.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 dark:bg-dark-200 rounded-md`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`img`,{src:ae(e,32),alt:e.name,className:`w-8 h-8 rounded-full`,onError:t=>U(t.currentTarget,e.name,32)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,J.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e.model})]})]}),(0,J.jsx)(L,{onClick:()=>l(e),variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`common.export`)})]},e.id))})]})]}),(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-xs border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.importPersonas`)}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.uploadJsonFile`)}),(0,J.jsx)(`input`,{type:`file`,accept:`.json`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{let t=e.target?.result;typeof t==`string`&&c(t)},e.readAsText(t)}},className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`})]}),(0,J.jsx)(`div`,{className:`text-center text-gray-500 dark:text-dark-500`,children:r(`common.or`).toUpperCase()}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.pasteJsonLabel`)}),(0,J.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`,rows:8,placeholder:r(`personaImportExport.pasteJsonPlaceholder`)})]}),(0,J.jsx)(L,{onClick:async()=>{if(!s.trim())v.error(r(`personaImportExport.pasteJsonData`));else{a(!0);try{let e=JSON.parse(s);if(e.personas&&Array.isArray(e.personas)){let t=0,n=0;for(let r of e.personas)try{await K.importPersona(r),t++}catch(e){n++,Ce.error(`Failed to import persona:`,e)}t>0?(v.success(r(`personaImportExport.importMultipleSuccess`,{count:t})),n>0&&v.error(r(`personaImportExport.importMultipleFailed`,{count:n}))):v.error(r(`personaImportExport.importNoneFailed`))}else await K.importPersona(e),v.success(r(`personaImportExport.importSuccess`));c(``),t()}catch(e){let t=e instanceof Error?e.message:String(e);v.error(r(`personaImportExport.importFailed`)+`: `+t)}finally{a(!1)}}},disabled:!s.trim()||i,className:`w-full`,children:r(i?`personaImportExport.importing`:`personaImportExport.importButton`)})]})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 bg-gray-50 dark:bg-dark-200 rounded-lg p-4`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-dark-800 mb-2`,children:r(`personaImportExport.expectedFormat`)}),(0,J.jsx)(`pre`,{className:`text-xs text-gray-600 dark:text-dark-600 overflow-x-auto`,children:`{
2
+ "name": "Assistant Name",
3
+ "description": "Brief description of the assistant's personality",
4
+ "model": "model-name:version",
5
+ "params": {
6
+ "temperature": 0.8,
7
+ "top_p": 0.9,
8
+ "context_window": 4096,
9
+ "system_prompt": "You are a helpful assistant with specific traits..."
10
+ },
11
+ "avatar": "/path/to/avatar.png",
12
+ "background": "/path/to/background.png"
13
+ }`})]}),(0,J.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,J.jsx)(L,{onClick:n,variant:`outline`,children:r(`common.close`)})})]})},Te=()=>{let{t:e}=o(),t=r(),[n,a]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1),{data:d=[],isLoading:f,isError:p,refetch:m}=i({queryKey:[`personas`],queryFn:async()=>{let e=await K.getPersonas();if(!e.success)throw Error(e.error||`Failed to load personas`);return e.data||[]}}),h=async()=>{await t.invalidateQueries({queryKey:[`personas`]}),await m()},g=()=>{c(null),a(!0)},_=e=>{c(e),a(!0)},ee=async t=>{if(confirm(e(`personaManager.deleteConfirm`,{name:t.name})))try{let n=await K.deletePersona(t.id);n.success?(v.success(e(`personaManager.deleteSuccess`,{name:t.name})),await h()):v.error(e(`personaManager.deleteFailed`)+`: `+n.error)}catch(t){let n=t instanceof Error?t.message:String(t);v.error(e(`personaManager.deleteFailed`)+`: `+n)}},y=async t=>{try{await K.downloadPersona(t.id,t.name),v.success(e(`personaManager.downloadSuccess`,{name:t.name}))}catch(t){let n=t instanceof Error?t.message:String(t);v.error(e(`personaManager.downloadFailed`)+`: `+n)}};return f?(0,J.jsx)(R,{label:e(`personaManager.loading`)}):n?(0,J.jsx)(Se,{persona:s,onSubmit:async e=>{c(e),await h()},onCancel:()=>{a(!1),c(null)}}):l?(0,J.jsx)(we,{personas:d,onImport:h,onClose:()=>u(!1)}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:[(0,J.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e(`personaManager.stats.title`)}),` `,`· `,e(`personaManager.stats.count`,{count:d.length})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(L,{onClick:()=>u(!0),variant:`outline`,className:`px-4`,children:e(`personaManager.importExport`)}),(0,J.jsx)(L,{onClick:g,className:`px-4`,children:e(`personaManager.createButton`)})]})]}),p&&d.length===0?(0,J.jsx)(H,{message:e(`personaManager.loadFailed`),onRetry:()=>void m()}):d.length===0?(0,J.jsx)(B,{icon:k,titleAs:`h3`,title:e(`personaManager.empty.title`),description:e(`personaManager.empty.description`),action:(0,J.jsx)(L,{onClick:g,className:`px-6 py-2`,children:e(`personaManager.empty.button`)})}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3`,children:d.map(e=>(0,J.jsx)(ue,{persona:e,onEdit:_,onDelete:ee,onDownload:y},e.id))})]})},Ee=()=>{let{t:e}=o();return(0,J.jsxs)(V,{children:[(0,J.jsx)(z,{title:e(`personaManager.title`),description:e(`personaManager.subtitle`)}),(0,J.jsx)(Te,{})]})};export{Ee as PersonasPage,Ee as default};
@@ -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-2_pQiHbl.js";import{t as i}from"./utils-BvvV-Cka.js";import{t as a}from"./useTranslation-D9EScZXH.js";import{An as o,Cr as s,Dr as c,Gn as l,Q as u,Vn as d,Y as f,dr as p,g as m,s as h,tr as g,tt as _,un as v,v as y,zt as b}from"./ui-vendor-BTcw5yZ6.js";import{t as x}from"./Button-DwZ26Lqc.js";import{o as S,s as C}from"./ui-D4Ytvr6d.js";import{t as w}from"./client-D_F_0LqX.js";import{u as T}from"./api-D6IF0v9_.js";var E=e(t(),1),D={getAnalytics:e=>w.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>w.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>w.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>w.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>w.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>w.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>w.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>w.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}=a(),[n,r]=(0,E.useState)(null),[i,s]=(0,E.useState)([]),[l,u]=(0,E.useState)([]),[d,f]=(0,E.useState)(!0),[p,m]=(0,E.useState)(0),[h,g]=(0,E.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[v,S]=(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&&s(t.data),i.success&&i.data&&u(i.data))}).catch(()=>c.error(t(`costs.loadFailed`))).finally(()=>{n||f(!1)}),()=>{n=!0}},[e,p,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:h.pluginId.trim(),model:h.model.trim()||void 0,inputPerMillion:C(h.inputPerMillion),outputPerMillion:C(h.outputPerMillion),unitPrice:C(h.unitPrice)});if(!e.success)throw Error(e.message);c.success(t(`costs.tariffSaved`)),g({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),m(e=>e+1)}catch(e){c.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},T=async()=>{try{let e=await D.createBudget({name:v.name.trim(),principalType:v.principalType,principalId:v.principalType===`instance`?void 0:v.principalId.trim(),period:v.period,amountUsd:Number(v.amountUsd),mode:v.mode});if(!e.success)throw Error(e.message);c.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),m(e=>e+1)}catch(e){c.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{c.error(t(`costs.exportFailed`))}};return d&&!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)(b,{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)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,O.jsx)(o,{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(()=>m(e=>e+1)).catch(()=>c.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:v.name,onChange:e=>S({...v,name:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:v.principalType,onChange:e=>S({...v,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:v.principalId,disabled:v.principalType===`instance`,onChange:e=>S({...v,principalId:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:v.period,onChange:e=>S({...v,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:v.amountUsd,onChange:e=>S({...v,amountUsd:e.target.value})}),(0,O.jsxs)(`select`,{className:A,value:v.mode,onChange:e=>S({...v,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)(x,{size:`sm`,onClick:()=>void T(),children:[(0,O.jsx)(_,{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:[i.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(()=>m(e=>e+1)).catch(()=>c.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)),i.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:h.pluginId,onChange:e=>g({...h,pluginId:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.modelOptional`),value:h.model,onChange:e=>g({...h,model:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:h.inputPerMillion,onChange:e=>g({...h,inputPerMillion:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:h.outputPerMillion,onChange:e=>g({...h,outputPerMillion:e.target.value})}),(0,O.jsx)(`input`,{className:A,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:h.unitPrice,onChange:e=>g({...h,unitPrice:e.target.value})}),(0,O.jsxs)(x,{size:`sm`,onClick:()=>void w(),children:[(0,O.jsx)(_,{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 B(e){return e.modelSeries?.length?e.modelSeries.map(e=>({...e,key:R(e.model)})):[{key:`total`,model:void 0,points:e.series}]}function ee(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 te(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 ne({analytics:e,metric:t,onMetricChange:n,colors:r,highlighted:o,selected:s,loadingModel:c,canLoadModels:l=!1,onHighlight:u,onSelect:d}){let{t:p,i18n:m}=a(),h=(0,E.useMemo)(()=>B(e),[e]),_=(0,E.useRef)(null),[v,y]=(0,E.useState)(960),[b,x]=(0,E.useState)();(0,E.useEffect)(()=>{let e=_.current;if(!e)return;let t=new ResizeObserver(e=>{y(Math.max(280,e[0].contentRect.width))});return t.observe(e),()=>t.disconnect()},[]);let S=(e,t=!1)=>new Intl.NumberFormat(m.language,{notation:t&&e>=1e4?`compact`:`standard`,maximumFractionDigits:+!!t}).format(e),C=new Intl.DateTimeFormat(m.language,{month:`short`,day:`numeric`,timeZone:`UTC`}),w=e=>e===void 0?p(`usageAnalytics.activity.allModels`):e===null?p(`usageAnalytics.heatmap.other`):e||`—`,T={top:18,right:20,bottom:32,left:48},D=v-T.left-T.right,k=260-T.top-T.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=>T.left+(e.series.length<=1?D/2:t/(e.series.length-1)*D),F=e=>T.top+k-e/j*k,I=e.series.findIndex(e=>e.timestamp===b),L=I<0?Math.max(0,e.series.length-1):I,R=e.series[L],z=h.find(e=>e.key===o),ee=[...new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])].filter(e=>e>=0),te=h.map(e=>({...e,value:e.points[L]?.[t]??0})).sort((e,t)=>t.value-e.value),ne=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":c!==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:p(`usageAnalytics.activity.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:p(`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:i(`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:p(`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:p(`usageAnalytics.activity.compareHint`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:!s&&!o,className:i(`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`,!s&&!o&&`invisible`),onClick:()=>{d(void 0),u(void 0)},children:[(0,O.jsx)(f,{className:`h-3.5 w-3.5`}),p(`usageAnalytics.activity.showAll`)]})]}),(0,O.jsx)(`div`,{"data-testid":`usage-model-legend`,className:i(`grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,l&&`h-48 content-start overflow-y-auto pe-1`),children:h.map(e=>{let n=o===e.key,a=s===e.key,c=r.get(e.key)??`#6b7280`,l=e.points.reduce((e,n)=>e+n[t],0);return(0,O.jsxs)(`button`,{type:`button`,"aria-pressed":a,"aria-label":w(e.model),title:w(e.model),onMouseEnter:()=>u(e.key),onMouseLeave:()=>u(void 0),onFocus:()=>u(e.key),onBlur:()=>u(void 0),onClick:()=>d(a?void 0:e.key),className:i(`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:c},"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:w(e.model)}),(0,O.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:S(l,!0)}),a&&(0,O.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 text-gray-800 dark:text-dark-900`,"aria-hidden":`true`})]},e.key)})}),(l||h.some(e=>e.model===null))&&(0,O.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-dark-500`,children:p(`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:p(`usageAnalytics.activity.breakdownUnavailable`)})]}),(0,O.jsx)(`div`,{className:`relative mx-3 mt-4 sm:mx-5`,ref:_,children:N?(0,O.jsx)(`div`,{className:`flex h-[260px] items-center justify-center text-sm text-gray-500 dark:text-dark-500`,children:p(`usageAnalytics.activity.noTokens`)}):(0,O.jsxs)(`svg`,{viewBox:`0 0 ${v} 260`,direction:`ltr`,className:`block h-[260px] w-full touch-pan-y`,role:`img`,"aria-label":p(`usageAnalytics.activity.chartLabel`,{metric:p(`usageAnalytics.metrics.${t}`)}),onPointerMove:t=>{let n=t.currentTarget.getBoundingClientRect(),r=(t.clientX-n.left)*v/n.width,i=Math.round(Math.max(0,Math.min(1,(r-T.left)/D))*(e.series.length-1));e.series[i]&&x(e.series[i].timestamp)},children:[(0,O.jsx)(`title`,{children:p(`usageAnalytics.activity.chartLabel`,{metric:p(`usageAnalytics.metrics.${t}`)})}),[0,.25,.5,.75,1].map(e=>{let t=T.top+k*e;return(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:T.left,x2:v-T.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:T.left-9,y:t+4,textAnchor:`end`,className:`fill-gray-500 text-[11px] dark:fill-dark-500`,children:S(Math.round(j*(1-e)),!0)})]},e)}),R&&(0,O.jsx)(`line`,{x1:P(L),x2:P(L),y1:T.top,y2:260-T.bottom,className:`stroke-gray-300 dark:stroke-dark-400`,strokeDasharray:`3 4`}),[...h].sort((e,t)=>Number(e.key===o)-Number(t.key===o)).map(e=>{let n=e.key===o,i=r.get(e.key)??`#6b7280`,a=e.points[L];return(0,O.jsxs)(`g`,{opacity:o&&!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:ne(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:w(e.model)})}),a&&(0,O.jsx)(`circle`,{cx:P(L),cy:F(a[t]),r:n?5:3.5,fill:i,className:`stroke-white dark:stroke-dark-100`,strokeWidth:`2`})]},e.key)}),ee.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:C.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:p(`usageAnalytics.activity.exploreDay`)}),(0,O.jsx)(`span`,{className:`text-gray-800 dark:text-dark-800`,children:C.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":p(`usageAnalytics.activity.exploreDay`),"aria-valuetext":C.format(R.timestamp),onChange:t=>x(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:[p(`usageAnalytics.activity.dayTotal`),` ·`,` `,C.format(R.timestamp)]}),(0,O.jsxs)(`span`,{className:`text-sm font-medium tabular-nums text-gray-950 dark:text-dark-950`,children:[S(R[t]),` `,p(`usageAnalytics.metrics.${t}`)]})]}),(0,O.jsx)(`div`,{className:i(`grid gap-x-5 gap-y-2 sm:grid-cols-2 lg:grid-cols-3`,l&&`max-h-40 overflow-y-auto`),children:te.map(e=>(0,O.jsxs)(`div`,{"data-model":e.model===void 0?`__total__`:e.model??`__other__`,className:i(`flex min-w-0 items-center gap-2 text-xs`,o===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:w(e.model),dir:`auto`,children:w(e.model)}),(0,O.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-900 dark:text-dark-900`,children:S(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:c===void 0?z?p(`usageAnalytics.activity.highlightedModel`,{model:w(z.model)}):p(`usageAnalytics.activity.allModels`):p(`usageAnalytics.activity.loadingModel`,{model:c})})]})]})]})}var V=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),H=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),U=e=>e>=1e4?H.format(e):V.format(e),W=e=>e?e<1e3?`${V.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,re=(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:o,i18n:s}=a(),[c,l]=(0,E.useState)(null),u=[...new Set([...e.models,...n])],d=e=>e!==void 0&&(u.includes(e)||e===r)?t.get(R(e))??`#6b7280`:I,{weeks:f,firstColStart:p,cellsByDay:m,maxCalls:h,totalCalls:g}=(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]),_=new Intl.DateTimeFormat(s.language,{month:`short`,timeZone:`UTC`}),v=new Intl.DateTimeFormat(s.language,{weekday:`short`,timeZone:`UTC`}),y=new Intl.DateTimeFormat(s.language,{dateStyle:`medium`,timeZone:`UTC`}),b=e.from,x=e.from+(e.days-1)*G,S=J+f*q,C=[],w=-1;for(let e=0;e<f;e++){let t=p+e*7*G,n=Math.max(t,b),r=new Date(n).getUTCMonth();r!==w&&t>=b-6*G&&((w!==-1||t>=b)&&C.push({x:J+e*q,label:_.format(n)}),w=r)}let T=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/h*4))),D=e=>d(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;l({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:o(`usageAnalytics.heatmap.title`)}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:o(`usageAnalytics.heatmap.description`)})]}),(0,O.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:o(`usageAnalytics.heatmap.yearTotal`,{count:g,formatted:U(g)})})]}),(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 ${S} 100`,direction:`ltr`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":o(`usageAnalytics.heatmap.title`),onMouseLeave:()=>l(null),children:[C.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:v.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:f},(e,t)=>Array.from({length:7},(e,n)=>{let r=p+(t*7+n)*G;if(r<b||r>x)return null;let a=m.get(r),o=a?.calls??0,s=T(o);return(0,O.jsx)(`rect`,{x:J+t*q,y:Y+n*q,width:K,height:K,rx:2,"data-model":a?.models[0]?.model,fill:a&&s>0?D(a):void 0,fillOpacity:s===0?1:ae[s],strokeWidth:+(c?.timestamp===r),className:i(`motion-safe:transition-opacity`,(s===0||!a)&&ie,c?.timestamp===r?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>k(e,r,{calls:o,models:a?.models??[]}),children:(0,O.jsx)(`title`,{children:`${y.format(r)} — ${U(o)}`})},r)}))]})}),c&&(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:c.x,top:c.y-6},children:[(0,O.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:y.format(c.timestamp)}),(0,O.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:c.calls===0?o(`usageAnalytics.heatmap.noCalls`):`${U(c.calls)} ${o(`usageAnalytics.heatmap.calls`)}`}),c.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:d(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:U(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:[u.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}}),o(`usageAnalytics.heatmap.other`)]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[o(`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)),o(`usageAnalytics.heatmap.more`)]})]})]})]})},se=({analytics:e})=>{let{t}=a(),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:U(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)?U(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:W(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)(m,{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:U(e.calls)}),(0,O.jsx)(`td`,{className:`py-1.5 text-end tabular-nums`,children:r(e)?U(e.tokens):`—`})]},e.model))})]})})]})]})]},e.agentId))})]})},X=()=>{let{t:e}=a(),[t,n]=(0,E.useState)(30),[o,c]=(0,E.useState)(`calls`),[f,g]=(0,E.useState)(),[_,y]=(0,E.useState)(),{data:w,error:D,isLoading:k,isFetching:A,refetch:M}=r({queryKey:[`plugin-usage`,t],refetchInterval:2e4,refetchIntervalInBackground:!1,queryFn:async()=>{let n=await T.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),N=(0,E.useMemo)(()=>new Set(w?B(w).map(e=>e.key):[]),[w]),P=(0,E.useMemo)(()=>new Set([...N,...w?.models.map(e=>R(e.model))??[]]),[N,w]),F=f&&P.has(f)?f:void 0,I=_&&P.has(_)?_:void 0,L=N.has(`other`),V=(L?[I,F].find(e=>e?.startsWith(`model:`)&&!N.has(e)):void 0)?.slice(6),H=r({queryKey:[`plugin-usage`,t,`model`,V,w?.range.to],enabled:V!==void 0,staleTime:3e4,queryFn:async()=>{let n=await T.getUsage(t,V,w?.range.to);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),G=w,K=!!w&&!!H.data&&z(w,H.data),q=(0,E.useMemo)(()=>w&&V!==void 0&&K?{...w,modelSeries:H.data.modelSeries}:w,[w,V,K,H.data]),J=(0,E.useRef)(null);(0,E.useEffect)(()=>{V!==void 0&&H.data&&!K&&!A&&J.current!==H.data&&(J.current=H.data,M())},[V,H.data,K,A,M]);let Y=D??(V===void 0?null:H.error),ie=Y?Y instanceof Error?Y.message:e(`usageAnalytics.loadFailed`):null,ae=V!==void 0&&!K&&!Y?V:void 0,X=(0,E.useMemo)(()=>w?ee(w):new Map,[w]),ce=(0,E.useMemo)(()=>new Set(q?B(q).map(e=>e.key):[]),[q]),Z=I??F,le=e=>g(e),Q=e=>{if(w?.modelSeries?.length&&(e!==null||N.has(`other`)))return R(e)},$=G?.totals,ue=(0,E.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:U($?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:$?.uniqueUsers??0}),icon:s},{label:e(`usageAnalytics.cards.tokens`),value:U($?.reportedTokens??0),detail:e(`usageAnalytics.cards.coverage`,{percent:$?.calls?($.meteredCalls/$.calls*100).toFixed(1):`0`}),icon:v},{label:e(`usageAnalytics.cards.success`),value:`${re($?.calls??0,($?.failedCalls??0)+($?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:$?.failedCalls??0}),icon:l},{label:e(`usageAnalytics.cards.latency`),value:W($?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:d}],[e,$]);return k&&!G?(0,O.jsx)(C,{width:`wide`,children:(0,O.jsxs)(`div`,{role:`status`,className:`flex min-h-[50vh] items-center justify-center`,children:[(0,O.jsx)(b,{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)(C,{width:`wide`,children:[(0,O.jsx)(S,{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:i(`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)(x,{variant:`outline`,size:`sm`,onClick:()=>{M(),V!==void 0&&H.refetch()},disabled:A||V!==void 0&&H.isFetching,children:[(0,O.jsx)(u,{className:i(`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)(m,{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:(w?.modelSeries??[]).flatMap(e=>e.model===null?[]:[e.model])}),(0,O.jsx)(ne,{analytics:q??G,metric:o,onMetricChange:c,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:i(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:[U(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?U(t.tokens):`—`}),(0,O.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[re(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:W(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=te(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:U(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`)}: ${U(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?U(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:[re(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:W(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)(m,{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:i(`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)(h,{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:U(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:U(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:U(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:U(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:U(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:U(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:U(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,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-Cf7jtPFB.js","js/markdown-math-DUQvxNgB.js","js/markdown-core-D-4xNKNv.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-GLIQTwVZ.js","assets/markdown-math-Ngnvt50Q.css","js/markdownHtml-mmK-QYY6.js","js/markdown-html-Cd75Y-85.js","js/OptimizedSyntaxHighlighter-BCkQOsIb.js","js/OptimizedSyntaxHighlighter-Cruo0gJb.js","js/syntax-highlight-BlVvro-Z.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-GLIQTwVZ.js";import{o as r}from"./logger-rEW7uQ8m.js";import{t as i}from"./utils-BCv-T6HP.js";import{t as a}from"./appStore-qi0l_wou.js";import{a as o,i as s,n as c,r as l,s as u,t as d}from"./messageCodeStyles-nVE1JYdR.js";import{i as f,s as p}from"./markdown-core-D-4xNKNv.js";var m=e(t(),1),h=null,g=null,_=null,v=null,y=()=>_??=r(()=>import(`./markdownMath-Cf7jtPFB.js`).then(e=>(h=e,e)),__vite__mapDeps([0,1,2,3,4,5])),b=()=>v??=r(()=>import(`./markdownHtml-mmK-QYY6.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-BCkQOsIb.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-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: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})},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-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 +1 @@
1
- export{t as RichMessageContent,t as default}from"./RichMessageContent-CQY0R6rI.js";
1
+ export{t as RichMessageContent,t as default}from"./RichMessageContent-Bwpg3rfV.js";