libre-webui 0.19.2 → 0.19.4

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 (143) hide show
  1. package/backend/dist/index.d.ts.map +1 -1
  2. package/backend/dist/index.js +61 -2
  3. package/backend/dist/index.js.map +1 -1
  4. package/backend/dist/routes/artifacts.d.ts +3 -0
  5. package/backend/dist/routes/artifacts.d.ts.map +1 -0
  6. package/backend/dist/routes/artifacts.js +167 -0
  7. package/backend/dist/routes/artifacts.js.map +1 -0
  8. package/backend/dist/routes/ollama.d.ts.map +1 -1
  9. package/backend/dist/routes/ollama.js +25 -0
  10. package/backend/dist/routes/ollama.js.map +1 -1
  11. package/backend/dist/routes/preferences.d.ts.map +1 -1
  12. package/backend/dist/routes/preferences.js +44 -0
  13. package/backend/dist/routes/preferences.js.map +1 -1
  14. package/backend/dist/services/chatGenerationService.d.ts +11 -0
  15. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  16. package/backend/dist/services/chatGenerationService.js +20 -1
  17. package/backend/dist/services/chatGenerationService.js.map +1 -1
  18. package/backend/dist/services/ollamaService.d.ts +9 -0
  19. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  20. package/backend/dist/services/ollamaService.js +27 -0
  21. package/backend/dist/services/ollamaService.js.map +1 -1
  22. package/backend/dist/services/preferencesService.d.ts +7 -0
  23. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  24. package/backend/dist/services/preferencesService.js +22 -0
  25. package/backend/dist/services/preferencesService.js.map +1 -1
  26. package/backend/dist/types/index.d.ts +5 -0
  27. package/backend/dist/types/index.d.ts.map +1 -1
  28. package/backend/dist/types/index.js.map +1 -1
  29. package/backend/dist/utils/ollamaModelDefaults.d.ts +39 -0
  30. package/backend/dist/utils/ollamaModelDefaults.d.ts.map +1 -0
  31. package/backend/dist/utils/ollamaModelDefaults.js +157 -0
  32. package/backend/dist/utils/ollamaModelDefaults.js.map +1 -0
  33. package/backend/package.json +1 -1
  34. package/frontend/dist/apple-touch-icon.png +0 -0
  35. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -0
  36. package/frontend/dist/artifact-runtime/babel.js +613 -0
  37. package/frontend/dist/artifact-runtime/chart.js +3 -0
  38. package/frontend/dist/artifact-runtime/d3.js +5 -0
  39. package/frontend/dist/artifact-runtime/fonts.js +255 -0
  40. package/frontend/dist/artifact-runtime/framer-motion.js +10 -0
  41. package/frontend/dist/artifact-runtime/lodash.js +20 -0
  42. package/frontend/dist/artifact-runtime/lucide-react.js +1 -0
  43. package/frontend/dist/artifact-runtime/mathjs.js +54 -0
  44. package/frontend/dist/artifact-runtime/mermaid.js +3535 -0
  45. package/frontend/dist/artifact-runtime/papaparse.js +10 -0
  46. package/frontend/dist/artifact-runtime/plotly.js +3790 -0
  47. package/frontend/dist/artifact-runtime/react.js +9 -0
  48. package/frontend/dist/artifact-runtime/recharts.js +69 -0
  49. package/frontend/dist/artifact-runtime/runtime.js +1 -0
  50. package/frontend/dist/artifact-runtime/tailwind.js +952 -0
  51. package/frontend/dist/artifact-runtime/three.js +5271 -0
  52. package/frontend/dist/artifact-runtime/tone.js +210 -0
  53. package/frontend/dist/assets/index-DrcHGnwk.js +64 -0
  54. package/frontend/dist/assets/index-DtkGuqvC.css +1 -0
  55. package/frontend/dist/favicon-dark.png +0 -0
  56. package/frontend/dist/favicon-light.png +0 -0
  57. package/frontend/dist/favicon.svg +1 -0
  58. package/frontend/dist/fonts/inter.css +254 -0
  59. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa0ZL7W0Q5n-wU.woff2 +0 -0
  60. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7W0Q5nw.woff2 +0 -0
  61. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1pL7W0Q5n-wU.woff2 +0 -0
  62. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa25L7W0Q5n-wU.woff2 +0 -0
  63. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7W0Q5n-wU.woff2 +0 -0
  64. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2ZL7W0Q5n-wU.woff2 +0 -0
  65. package/frontend/dist/fonts/v20-UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2pL7W0Q5n-wU.woff2 +0 -0
  66. package/frontend/dist/icon-192.png +0 -0
  67. package/frontend/dist/icon-512.png +0 -0
  68. package/frontend/dist/index.html +16 -11
  69. package/frontend/dist/js/ArtifactContainer-CEBbQqtg.js +1 -0
  70. package/frontend/dist/js/{ArtifactDemoPage-BlVBMy6a.js → ArtifactDemoPage-BDTtUPjk.js} +58 -2
  71. package/frontend/dist/js/ArtifactSandboxFrame-DOQWmEAm.js +151 -0
  72. package/frontend/dist/js/ArtifactSlideOutPanel-BMhWWM3P.js +1 -0
  73. package/frontend/dist/js/ChatPage-B64xgIPZ.js +16 -0
  74. package/frontend/dist/js/FirstTimeSetup-1IqkWCsV.js +1 -0
  75. package/frontend/dist/js/{GalleryPage-BnaFZERr.js → GalleryPage-CKgQAYmH.js} +1 -1
  76. package/frontend/dist/js/{HomePage-BvpoUzGG.js → HomePage-aNO615Go.js} +1 -1
  77. package/frontend/dist/js/{LibreClawPage-B-6rO5Jl.js → LibreClawPage-DZqgIOgT.js} +1 -1
  78. package/frontend/dist/js/ModelSelector-DhmVTh2d.js +1 -0
  79. package/frontend/dist/js/{ModelsPage-D5H70fs3.js → ModelsPage-tzXaut3l.js} +1 -1
  80. package/frontend/dist/js/{NotesPage-D9b3JxCx.js → NotesPage-Ciwrazz9.js} +1 -1
  81. package/frontend/dist/js/{PersonasPage-CJOGnyQV.js → PersonasPage-C9Pkl4yH.js} +2 -2
  82. package/frontend/dist/js/{PluginUsagePage-DHNMWquK.js → PluginUsagePage-DPfyos1y.js} +1 -1
  83. package/frontend/dist/js/{RichMessageContent-C7NG7gs-.js → RichMessageContent-CUcmvdXW.js} +1 -1
  84. package/frontend/dist/js/SettingsModal-DhrjNMcd.js +1 -0
  85. package/frontend/dist/js/{SystemPage-BsPen2Qb.js → SystemPage-CkUsJ-UR.js} +1 -1
  86. package/frontend/dist/js/{UserManagementPage-I9i5r0V3.js → UserManagementPage-DClRsCeA.js} +1 -1
  87. package/frontend/dist/js/WorkPage-cJEe9LZ_.js +5 -0
  88. package/frontend/dist/js/api-iDBo7I0x.js +19 -0
  89. package/frontend/dist/js/{appStore-CLIS0fvz.js → appStore-BAFz_6aP.js} +2 -2
  90. package/frontend/dist/js/{ar-B_uYj5Gv.js → ar-D3PgKaYD.js} +1 -1
  91. package/frontend/dist/js/{authStore-CsCkBmaG.js → authStore-2665PsVB.js} +2 -2
  92. package/frontend/dist/js/{bn-Pd4HHYsG.js → bn-DJiNo5j1.js} +1 -1
  93. package/frontend/dist/js/chatStore-fX9gMb9B.js +2 -0
  94. package/frontend/dist/js/config-CmH3hRFc.js +1 -0
  95. package/frontend/dist/js/{cs-CgVXogHE.js → cs-BJ7pToPB.js} +1 -1
  96. package/frontend/dist/js/{da-DTUIrClO.js → da-Cqw35YeI.js} +1 -1
  97. package/frontend/dist/js/{de-CKITtmnY.js → de-DLw7O2DX.js} +1 -1
  98. package/frontend/dist/js/{es-DKDhsL9J.js → es-CLg6Zl_p.js} +1 -1
  99. package/frontend/dist/js/{estree-CrfVSazx.js → estree-63s2XfPj.js} +1 -1
  100. package/frontend/dist/js/{fr-CUvNp0pc.js → fr-BUmG4BWs.js} +1 -1
  101. package/frontend/dist/js/{hi-Bwdmc__g.js → hi-CGktbsaL.js} +1 -1
  102. package/frontend/dist/js/{html-BbJLJMaV.js → html-CRbptZf3.js} +1 -1
  103. package/frontend/dist/js/{i18n-ZJQSoIuM.js → i18n-DFbHZ75-.js} +2 -2
  104. package/frontend/dist/js/{id-CWTPw3NJ.js → id-C7FnPtw9.js} +1 -1
  105. package/frontend/dist/js/{is-4dV6F4Bo.js → is-_FSS24Pj.js} +1 -1
  106. package/frontend/dist/js/{it-8uw2-j2s.js → it-DWTgF8my.js} +1 -1
  107. package/frontend/dist/js/{ja-Bl7gd3kp.js → ja-jYrlZiIs.js} +1 -1
  108. package/frontend/dist/js/{ko-C_CYwJnL.js → ko-3PZ87sc7.js} +1 -1
  109. package/frontend/dist/js/{markdown-DiMg1QLf.js → markdown-C23cybKA.js} +1 -1
  110. package/frontend/dist/js/{messageCodeStyles-CfzjQF-R.js → messageCodeStyles-BJVb4sK7.js} +1 -1
  111. package/frontend/dist/js/{ms-Dznw3AkA.js → ms-BfySq07T.js} +1 -1
  112. package/frontend/dist/js/{nl-fW-4lPWK.js → nl-DupdNsDK.js} +1 -1
  113. package/frontend/dist/js/{pl-CanprK04.js → pl-DYoPcTNe.js} +1 -1
  114. package/frontend/dist/js/{pt-JhTaVvKa.js → pt-p_-S_r1k.js} +1 -1
  115. package/frontend/dist/js/{ru-uPtHQATq.js → ru-CuJFlVPc.js} +1 -1
  116. package/frontend/dist/js/{standalone-Vs6LnjM6.js → standalone-BwzoPJoZ.js} +1 -1
  117. package/frontend/dist/js/{sv-yr6iqxR-.js → sv-DyZJcYOQ.js} +1 -1
  118. package/frontend/dist/js/{th-Bx4U5yKy.js → th-Cd6fTxUn.js} +1 -1
  119. package/frontend/dist/js/{tr-C7tCwYuZ.js → tr-BB1gefYF.js} +1 -1
  120. package/frontend/dist/js/{typescript-BhVG1zGU.js → typescript-CS-sPC9m.js} +1 -1
  121. package/frontend/dist/js/{ui-Dj9IFugT.js → ui-B-C2BCTb.js} +2 -2
  122. package/frontend/dist/js/{uk-C4SbiAUn.js → uk-DFURilqa.js} +1 -1
  123. package/frontend/dist/js/{vi-C3-TmuzC.js → vi-BXclLwGp.js} +1 -1
  124. package/frontend/dist/js/{zh-CRfqIC_I.js → zh-BS8f68w1.js} +1 -1
  125. package/frontend/dist/logo-dark.png +0 -0
  126. package/frontend/dist/logo-dark.svg +1 -0
  127. package/frontend/dist/logo-light.png +0 -0
  128. package/frontend/dist/logo-light.svg +1 -0
  129. package/frontend/dist/logo.svg +1 -6
  130. package/frontend/dist/maskable-512.png +0 -0
  131. package/package.json +3 -3
  132. package/frontend/dist/assets/index-B9H3vQ-n.css +0 -1
  133. package/frontend/dist/assets/index-D4LhtFTX.js +0 -38
  134. package/frontend/dist/js/ArtifactContainer-DvuGeXXu.js +0 -1
  135. package/frontend/dist/js/ArtifactSlideOutPanel-CaPMk1Qj.js +0 -1
  136. package/frontend/dist/js/ChatPage-D4UBhGLk.js +0 -16
  137. package/frontend/dist/js/FirstTimeSetup-DJiDNTXY.js +0 -1
  138. package/frontend/dist/js/ModelSelector-BV1kuaVg.js +0 -1
  139. package/frontend/dist/js/SettingsModal-DEBxDPne.js +0 -1
  140. package/frontend/dist/js/WorkPage-e30yqvJe.js +0 -5
  141. package/frontend/dist/js/api-jwjnjqx6.js +0 -19
  142. package/frontend/dist/js/artifactHtml-C0Hu9I1u.js +0 -41
  143. package/frontend/dist/js/chatStore-DRY8C0J1.js +0 -2
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{a as i,n as a,o}from"./i18n-ZJQSoIuM.js";import{Bt as s,Ct as c,E as l,F as u,Ht as d,I as f,P as p,R as m,Rt as h,Tn as g,Ut as _,V as v,Z as y,an as b,bt as x,d as S,dt as C,f as w,ft as T,gn as E,hn as D,m as ee,n as te,nn as ne,o as re,on as O,pt as k,q as A,st as j,tt as M,vt as ie,x as ae,xn as oe,xt as se,y as N,z as ce,zt as le}from"./ui-vendor-D_pYT79f.js";import{t as P}from"./logger-DSXjF4ye.js";import{a as F,b as ue,c as I,g as de,i as fe,l as pe,n as me,p as he,r as ge,y as L}from"./api-jwjnjqx6.js";import{a as _e,o as ve,s as ye,t as be}from"./imageGenModels-Dx_QMLJQ.js";import{n as xe,t as R}from"./utils-BhpNrGnR.js";import{a as Se,d as Ce,f as we,l as Te,n as Ee,o as De,p as Oe,r as ke,t as Ae,u as je}from"./chatStore-DRY8C0J1.js";import{c as Me,n as Ne}from"./authStore-CsCkBmaG.js";import{a as Pe,n as Fe,o as Ie,t as Le}from"./appStore-CLIS0fvz.js";import{l as Re}from"./messageCodeStyles-CfzjQF-R.js";import{t as z}from"./Button-X9TT9gTD.js";import{d as B,f as ze}from"./ui-Dj9IFugT.js";import{d as Be,l as Ve,p as He,t as Ue}from"../assets/index-D4LhtFTX.js";var V=e(n(),1),H=t(),We=[{href:`https://github.com/libre-webui/libre-webui`,icon:c,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:se,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:s,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:E,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:D,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:M,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],Ge=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function Ke({appVersion:e}){let{t}=r();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-4`,children:(0,H.jsx)(Ve,{className:`text-gray-900 dark:text-gray-100`})}),(0,H.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,H.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,H.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:Ge.map(e=>(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,H.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,H.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:We.map(e=>{let n=e.icon;return(0,H.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,H.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,H.jsx)(s,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,H.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,H.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,H.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,H.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,H.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var qe=P(`components:background-upload`),Je=({className:e=``})=>{let{t}=r(),{preferences:n,setPreferences:i,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=Le(),c=(0,V.useRef)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){g.error(`Please select a valid image file`);return}if(e.size>5242880){g.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),g.success(`Background image uploaded successfully`)}catch(e){qe.error(`Failed to upload background:`,e),g.error(`Failed to upload background image`)}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},_=e=>{e.preventDefault(),f(!0)},v=e=>{e.preventDefault(),f(!1)},y=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},b=()=>{s(),g.success(`Background image removed`)},x=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(i({backgroundSettings:n}),t||!e)try{await I.updatePreferences({backgroundSettings:n})}catch(e){qe.error(`Failed to update preferences:`,e)}},C=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(i({backgroundSettings:n}),t)try{await I.updatePreferences({backgroundSettings:n})}catch(e){qe.error(`Failed to update preferences:`,e)}},w=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(i({backgroundSettings:n}),t)try{await I.updatePreferences({backgroundSettings:n})}catch(e){qe.error(`Failed to update preferences:`,e)}};return(0,H.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>x(e.target.checked)}),(0,H.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,H.jsx)(`div`,{className:`relative`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,H.jsx)(`div`,{className:`flex-shrink-0`,children:(0,H.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:b,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,H.jsx)(te,{className:`h-4 w-4`})})]})}):(0,H.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`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:_,onDragLeave:v,onDrop:y,onClick:()=>c.current?.click(),children:[(0,H.jsx)(k,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,H.jsxs)(z,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,H.jsx)(S,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,H.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),a&&(0,H.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,H.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>C(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,H.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>w(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},Ye=()=>{let{t:e,i18n:t}=r();return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(x,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,H.jsx)(`select`,{"data-testid":`language-switcher-select`,value:i(t.language),onChange:e=>{let t=e.target.value;a(t)},className:`w-full px-3 py-2 text-sm border border-gray-200 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500`,children:o.map(e=>(0,H.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function Xe({theme:e,preferences:t,onThemeChange:n,onAccentChange:i,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s,onShowFollowUpsChange:c,onHapticFeedbackChange:l}){let{t:u}=r(),d=e.accent||`blue`,f=e.customAccent||`#2563eb`,p=Pe(e);return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(Ye,{}),(0,H.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.appearance.title`)})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`button`,{onClick:()=>n(`light`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`light`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,H.jsx)(N,{className:`h-4 w-4`}),u(`settings.appearance.theme.light`)]}),(0,H.jsxs)(`button`,{onClick:()=>n(`dark`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`dark`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,H.jsx)(y,{className:`h-4 w-4`}),u(`settings.appearance.theme.dark`)]})]}),(0,H.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,H.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:p},"aria-hidden":`true`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[Fe.map(e=>{let t=d===e.id;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`relative h-10 rounded-xl border transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${t?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,style:{backgroundColor:e.color},"aria-label":u(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,H.jsx)(O,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,H.jsxs)(`label`,{className:`relative h-10 rounded-xl border transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-dark-50 overflow-hidden cursor-pointer ${d===`custom`?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,title:u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,H.jsx)(`input`,{type:`color`,value:f,onInput:e=>a(e.currentTarget.value),onChange:e=>a(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,H.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:f},"aria-hidden":`true`}),(0,H.jsx)(A,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,H.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.behaviorTitle`)}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.behaviorDescription`)}),(0,H.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>o(!1),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`:`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`}`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.defaultStyle`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>o(!0),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`:`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`}`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.adaptedStyle`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:u(`settings.appearance.chatInterface.title`)}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.showUsername`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,H.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.followUpSuggestions`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.followUpSuggestionsDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showFollowUpSuggestions!==!1,onChange:e=>c(e.target.checked)}),(0,H.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`})}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`})})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"data-testid":`haptic-feedback-toggle`,"aria-label":u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),className:`peer sr-only`,checked:t.hapticFeedbackEnabled===!0,onChange:e=>l(e.target.checked)}),(0,H.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 peer-checked:bg-primary-600 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:content-[''] after:transition-all peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-primary-800 rtl:peer-checked:after:-translate-x-full`})]})]})]})]}),(0,H.jsx)(Je,{})]})}function Ze(){let{t:e,i18n:t}=r(),{sessions:n,setSessionArchived:i,deleteSession:a}=Ae(),o=n.filter(e=>e.archived);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),o.length===0?(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,H.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:o.map(n=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,H.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:xe(n.updatedAt,t.language)})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>i(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,H.jsx)(oe,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&a(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,H.jsx)(ee,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function Qe({sessionCount:e,loading:t,importing:n,showImportOptions:i,mergeStrategy:a,importResult:o,importFileInputRef:s,onExportData:c,onImportFileSelect:l,onClearAllHistory:u,onMergeStrategyChange:d,onConfirmImport:f,onCancelImport:p,onDismissImportResult:m}){let{t:h}=r();return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,H.jsx)(z,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,H.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,H.jsx)(z,{onClick:()=>s.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,H.jsx)(z,{onClick:u,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?h(`settings.data.clearing`):h(`settings.data.clearAll`,{count:e})})]})]}),i&&(0,H.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,H.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,H.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,H.jsxs)(`label`,{className:`flex items-center`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,H.jsxs)(`label`,{className:`flex items-center`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(z,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,H.jsx)(z,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,H.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,H.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,H.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,H.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,H.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,H.jsxs)(`div`,{children:[h(`settings.data.documents`),`:`,` `,o.documents.imported,` `,h(`settings.data.importedLabel`),`,`,` `,o.documents.skipped,` `,h(`settings.data.skipped`)]}),(o.sessions.errors.length>0||o.documents.errors.length>0)&&(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,H.jsx)(z,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]}),(0,H.jsx)(Ze,{})]})}function U({checked:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,H.jsx)(`div`,{className:R(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,n?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,H.jsx)(`span`,{className:R(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}function $e({settings:e,effectiveSettings:t,modelOptions:n,status:i,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=r();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,H.jsx)(U,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,H.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,H.jsx)(B,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,H.jsx)(tt,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>o(`chunkSize`,e)}),(0,H.jsx)(tt,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>o(`chunkOverlap`,e)}),(0,H.jsx)(tt,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>o(`similarityThreshold`,e)})]})]}),i&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,H.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,H.jsx)(`span`,{className:i.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:i.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,H.jsx)(`span`,{className:`font-medium`,children:i.model})]}),(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,H.jsxs)(`span`,{className:`font-medium`,children:[i.chunksWithEmbeddings,` / `,i.totalChunks]})]}),i.totalChunks>0&&(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,H.jsxs)(`span`,{className:`font-medium`,children:[Math.round(i.chunksWithEmbeddings/i.totalChunks*100),`%`]})]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(z,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&i&&i.totalChunks>0&&(0,H.jsxs)(z,{onClick:c,disabled:a,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,H.jsx)(_,{size:16}),u(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,H.jsxs)(z,{onClick:l,className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{size:16}),u(`settings.saveSettings`)]})]}),(0,H.jsx)(et,{})]})})}function et(){let{t:e}=r(),t=He(),[n,i]=(0,V.useState)(``),{data:a}=Be({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([L.getCollections(),L.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:o=[],documents:s=[]}=a??{},c=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),l=async()=>{let e=n.trim();e&&(i(``),(await L.createCollection(e)).success&&await c())},u=async t=>{window.confirm(e(`settings.documents.collections.deleteConfirm`))&&(await L.deleteCollection(t)).success&&await c()},d=async(e,t)=>{(await L.setDocumentCollection(e,t)).success&&await c()};return(0,H.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,H.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,H.jsx)(`input`,{value:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,H.jsx)(z,{size:`sm`,onClick:()=>void l(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),o.length>0&&(0,H.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:o.map(t=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:[(0,H.jsx)(E,{className:`h-3 w-3`}),t.name,(0,H.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),(0,H.jsx)(`button`,{onClick:()=>void u(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,H.jsx)(te,{className:`h-3 w-3`})})]},t.id))}),s.length>0&&o.length>0&&(0,H.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:s.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,H.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void d(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,H.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),o.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]},t.id))})]})}function tt({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,H.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function nt({generationOptions:e,embeddingSettings:t,effectiveEmbeddingSettings:n,embeddingModelOptions:i,embeddingStatus:a,onGenerationOptionChange:o,onEmbeddingSettingsChange:s,onResetGenerationOptions:c,onSaveGenerationOptions:l,onResetEmbeddingSettings:u,onSaveEmbeddingSettings:d}){let{t:p}=r(),[m,h]=(0,V.useState)(!1),g=(0,V.useId)();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.generation.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.generation.description`)}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":m,"aria-controls":g,onClick:()=>h(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.generation.advancedSettings`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:p(`settings.generation.advancedSettingsDescription`)})]}),(0,H.jsx)(b,{className:R(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,m&&`rotate-180`)})]}),m&&(0,H.jsxs)(`div`,{id:g,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,H.jsxs)(rt,{title:p(`settings.generation.coreParameters`),children:[(0,H.jsx)(W,{label:p(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:p(`settings.generation.temperatureDescription`),onChange:e=>o(`temperature`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:p(`settings.generation.topPDescription`),onChange:e=>o(`top_p`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:p(`settings.generation.topKDescription`),onChange:e=>o(`top_k`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:p(`settings.generation.minPDescription`),onChange:e=>o(`min_p`,e)})]}),(0,H.jsxs)(rt,{title:p(`settings.generation.generationControl`),children:[(0,H.jsx)(W,{label:p(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:p(`settings.generation.maxTokensDescription`),onChange:e=>o(`num_predict`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:p(`settings.generation.repeatPenaltyDescription`),onChange:e=>o(`repeat_penalty`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:p(`settings.generation.contextLengthDescription`),onChange:e=>o(`num_ctx`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.seed`),hint:`(${p(`settings.generation.optional`)})`,value:e.seed,placeholder:p(`settings.generation.random`),integer:!0,description:p(`settings.generation.seedDescription`),onChange:e=>o(`seed`,e)})]}),(0,H.jsxs)(rt,{title:p(`settings.generation.advancedOptions`),children:[(0,H.jsx)(W,{label:p(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:p(`settings.generation.presencePenaltyDescription`),onChange:e=>o(`presence_penalty`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:p(`settings.generation.frequencyPenaltyDescription`),onChange:e=>o(`frequency_penalty`,e)}),(0,H.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[p(`settings.generation.stopSequences`),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,p(`settings.generation.commaSeparated`),`)`]})]}),(0,H.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>o(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.generation.stopSequencesDescription`)})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(z,{onClick:c,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),p(`settings.generation.resetDefaults`)]}),(0,H.jsxs)(z,{onClick:l,className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{size:16}),p(`settings.generation.saveOptions`)]})]})]})]}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.generation.embeddingSettings`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:p(`settings.generation.enableEmbeddings`)}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.documents.embeddings.model`)}),(0,H.jsx)(B,{value:n.model,onChange:e=>s(`model`,e.target.value),options:i,disabled:!t.enabled})]}),(0,H.jsx)(it,{label:p(`settings.documents.embeddings.chunkSize`),hint:p(`settings.documents.embeddings.chunkSizeInTokens`),value:t.chunkSize,min:1,disabled:!t.enabled,onChange:e=>s(`chunkSize`,e)}),(0,H.jsx)(it,{label:p(`settings.documents.embeddings.chunkOverlap`),hint:p(`settings.documents.embeddings.chunkOverlapInTokens`),value:t.chunkOverlap,min:0,disabled:!t.enabled,onChange:e=>s(`chunkOverlap`,e)}),(0,H.jsx)(it,{label:p(`settings.documents.embeddings.similarityThreshold`),value:t.similarityThreshold,min:0,max:1,step:.01,disabled:!t.enabled,onChange:e=>s(`similarityThreshold`,e)})]}),a&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,H.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[p(`settings.documents.embeddings.status`),`:`]}),(0,H.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:a.available?p(`settings.documents.embeddings.available`):p(`settings.documents.embeddings.unavailable`)})]}),a.available&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,H.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[p(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,H.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[a.chunksWithEmbeddings,` /`,` `,a.totalChunks]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,H.jsxs)(z,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),p(`settings.generation.resetDefaults`)]}),(0,H.jsxs)(z,{onClick:d,className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{size:16}),p(`settings.saveSettings`)]})]})]})})]})})}function rt({title:e,children:t}){return(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function W({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,H.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,H.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function it({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,H.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,H.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function at({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,sizes:o,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:p}){let{t:m}=r(),h=be(i,n.model,n.pluginId);return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.imageGen.description`)}),e?(0,H.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,H.jsx)(j,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,H.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.imageGen.loadingProviders`)})]}):i.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(k,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.imageGen.noProviders`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.imageGen.enable`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.imageGen.enableDescription`)})]}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.configuration`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.model`)}),(0,H.jsx)(B,{value:h?_e(h):``,onChange:e=>{let t=i.find(t=>_e(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...i.map(e=>({value:_e(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.modelDescription`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h?.config?.size_label||m(`settings.imageGen.size`)}),(0,H.jsx)(B,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||o.length===0,options:[...o.length>0?o.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.quality`)}),(0,H.jsx)(B,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.style`)}),(0,H.jsx)(B,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.imageGen.availableProviders`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(z,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),m(`common.reset`)]}),(0,H.jsxs)(z,{onClick:p,className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function ot({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:i,systemMessage:a,tempSystemMessage:o,loading:s,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:f,updatingAllModels:p,updateProgress:m,onModelChange:h,onSystemMessageChange:g,onSystemMessageSave:_,onAutoTitleChange:v,onAutoTitleTaskModelChange:y,onVisionModelChange:b,onUpdateAllModels:x}){let{t:S}=r(),C={model:t,providerType:n,providerId:i},w=Te(e,C),T=t?Se(w,C):``,E=De(w,C);return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:S(`settings.model.title`)}),(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.defaultModel`)}),(0,H.jsx)(B,{value:T,onChange:h,options:[{value:``,label:S(`settings.model.selectModel`)},...w.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${S(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.defaultModelDescription`)})]}),t&&(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.currentModelInfo`)}),(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,H.jsx)(st,{label:`${S(`settings.model.name`)}:`,value:t,truncate:!0}),E?.details&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(st,{label:`${S(`settings.model.size`)}:`,value:E.details.parameter_size}),(0,H.jsx)(st,{label:`${S(`settings.model.family`)}:`,value:E.details.family}),(0,H.jsx)(st,{label:`${S(`settings.model.format`)}:`,value:E.details.format})]})]})})]}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.systemMessage.title`)}),(0,H.jsx)(ze,{value:o,onChange:g,placeholder:S(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.systemMessage.description`)}),(0,H.jsx)(z,{onClick:_,size:`sm`,disabled:s||o===a,children:S(`common.save`)})]})]})]}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,H.jsx)(B,{"data-testid":`vision-model-select`,value:l,onChange:e=>b(e.target.value),options:u}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,H.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:S(`settings.model.autoTitle.enable`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.model.autoTitle.enableDescription`)})]}),(0,H.jsx)(U,{checked:c.titleSettings?.autoTitle||!1,onChange:v})]}),c.titleSettings?.autoTitle&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.autoTitle.taskModel`)}),(0,H.jsx)(B,{value:d,onChange:e=>y(e.target.value),options:f}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.bulkOperations`)}),(0,H.jsx)(`div`,{className:`space-y-3`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.updateAll`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:S(`settings.model.updateAllDescription`)}),p&&m&&(0,H.jsx)(ct,{progress:m}),(0,H.jsx)(z,{onClick:x,variant:`outline`,size:`sm`,className:`w-full`,disabled:p||s||e.length===0,children:p?S(`settings.model.updating`):S(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function st({label:e,value:t,truncate:n=!1}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,H.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}function ct({progress:e}){let{t}=r(),n=Math.round(e.current/e.total*100);return(0,H.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsx)(`span`,{className:`text-gray-600 dark:text-dark-600 font-medium`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,H.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,H.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,H.jsx)(`div`,{className:`bg-gradient-to-r from-primary-500 to-primary-600 dark:from-primary-400 dark:to-primary-500 h-3 rounded-full transition-all duration-500 ease-out shadow-glow`,style:{width:`${e.current/e.total*100}%`}})}),(0,H.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,H.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,H.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,H.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,H.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}var lt=8;function ut(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function dt(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function ft(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function pt(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=lt;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===lt)return!1;n=t}return!1}var mt=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function ht(e){let t=new Set(mt),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function gt(e,t){return ht(t).has(e)}function _t(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function vt(e,t){let n=[],r=[];for(let i of e)(gt(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function yt(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function G(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=_t(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}P(`components:hugging-face-model-browser`);var bt=({plugin:e})=>{let{t}=r(),n=Ne(e=>e.user),i=Ne(e=>e.systemInfo)?.requiresAuth===!1||n?.role===`admin`,{pluginVariables:a,fetchPluginVariables:o,updatePluginVariables:s,resetPluginVariables:c,loadPlugins:l}=Me(),[d,p]=(0,V.useState)({}),[m,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),[x,S]=(0,V.useState)(new Set),[C,T]=(0,V.useState)({}),[E,D]=(0,V.useState)(new Set),[ee,te]=(0,V.useState)(!1),ne=V.useId(),re=V.useId(),O=(0,V.useMemo)(()=>e.variables||[],[e.variables]),k=(0,V.useMemo)(()=>ht(e),[e]),A=(0,V.useMemo)(()=>i?O:O.filter(e=>!k.has(e.name)),[i,k,O]),j=(0,V.useMemo)(()=>a[e.id]||{},[a,e.id]),M=(0,V.useMemo)(()=>vt(A,e),[e,A]);(0,V.useEffect)(()=>{o(e.id)},[o,e.id]);let ie=JSON.stringify(j),ae=(0,V.useRef)(null);(0,V.useEffect)(()=>{let t=A.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${ie}`;if(ae.current===n)return;ae.current=n;let r=JSON.parse(ie);p(e=>{let t=yt(A,r);for(let n of E)n in e&&(t[n]=e[n]);return t})},[E,e.id,A,ie]);let oe=async()=>{let n={};for(let r of A){if(!E.has(r.name))continue;let i=d[r.name],a=typeof i==`string`&&i.trim().length===0,o=j[r.name],s=_t(r,e);if(a&&r.required&&s===void 0&&!(r.sensitive&&o?.has_value)){n[r.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(ft(r.name)&&typeof i==`string`&&!a){let e=ut(i,r.name);e===`invalid-url`?n[r.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?n[r.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(n[r.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(r.name===`api_path`&&typeof i==`string`&&i.length>0&&!pt(i)&&(n[r.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),r.type===`number`&&!a){let e=Number(i);r.min!==void 0&&e<r.min&&(n[r.name]=`Min: ${r.min}`),r.max!==void 0&&e>r.max&&(n[r.name]=`Max: ${r.max}`)}r.type===`string`&&typeof i==`string`&&i.length>2048&&(n[r.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(T(n),Object.keys(n).length>0)return;let r=G(A,d,E,j,e),i=new Set(E),a=Object.fromEntries([...Object.keys(r.variables).map(e=>[e,!0]),...r.unset.map(e=>[e,!0])]);if(Object.keys(r.variables).length===0&&r.unset.length===0){D(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),T(e=>{let t={...e};for(let e of i)delete t[e];return t}),g.success(t(`pluginManager.variables.saved`,`Variables saved`));return}_(!0);try{await s(e.id,r.variables,r.unset)?(Object.keys(a).some(e=>k.has(e))&&await l(),p(e=>{let t={...e};for(let e of A)e.sensitive&&i.has(e.name)&&(t[e.name]=``);return t}),S(e=>{let t=new Set(e);for(let e of A)e.sensitive&&i.has(e.name)&&t.delete(e.name);return t}),D(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),T(e=>{let t={...e};for(let e of i)delete t[e];return t}),g.success(t(`pluginManager.variables.saved`,`Variables saved`))):g.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{_(!1)}},se=async()=>{y(!0);try{if(!await c(e.id)){g.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}A.some(e=>k.has(e.name))&&await l(),p(yt(A,{})),D(new Set),T({}),S(new Set),g.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{y(!1)}},N=(e,t)=>{p(n=>({...n,[e]:t})),D(t=>new Set(t).add(e)),T(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},ce=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=e=>{let t=A.indexOf(e),n=`${re}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},F=t=>{if(!ft(t.name))return!1;let n=d[t.name],r=_t(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&dt(i)},ue=n=>{let r=d[n.name],i=n.sensitive??!1,a=x.has(n.name),o=j[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:u}=P(n),f=!!C[n.name],p=F(n),g=n.name===`endpoint`||n.name===`api_url`,_=[n.description||g?c:void 0,p?u:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,y=_t(n,e),b=y===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(y)}),S=R(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,H.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>N(n.name,e.target.value===``?``:e.target.value===`true`),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v,children:[(0,H.jsx)(`option`,{value:``,children:b}),(0,H.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,H.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,H.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>N(n.name,e.target.value),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v,children:[(0,H.jsx)(`option`,{value:``,children:b}),(n.options||[]).map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,H.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:b,onChange:e=>N(n.name,e.target.value===``?``:Number(e.target.value)),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v});default:return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):b,onChange:e=>N(n.name,e.target.value),className:R(S,i&&`pr-10`),"aria-invalid":f,"aria-describedby":_,disabled:m||v}),i&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>ce(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:m||v,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,H.jsx)(le,{className:`w-4 h-4`}):(0,H.jsx)(h,{className:`w-4 h-4`})})]})}},I=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=P(e),o=e.name===`endpoint`||e.name===`api_url`,s=F(e);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,H.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),ue(e),s&&(0,H.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,H.jsx)(w,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),C[e.name]&&(0,H.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:C[e.name]})]},e.name)};return(0,H.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[M.connection.length>0&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),M.connection.map(I)]}),M.advanced.length>0&&(0,H.jsxs)(`div`,{className:R(M.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":ee,"aria-controls":ne,onClick:()=>te(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,H.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,M.advanced.length,`)`]}),(0,H.jsx)(b,{className:R(`h-4 w-4 transition-transform`,ee&&`rotate-180`)})]}),ee&&(0,H.jsx)(`div`,{id:ne,className:`mt-3 space-y-3`,children:M.advanced.map(I)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,H.jsxs)(z,{size:`sm`,onClick:oe,disabled:m||v||E.size===0,className:`gap-1.5`,children:[(0,H.jsx)(u,{className:`w-3.5 h-3.5`}),m?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:se,disabled:m||v,className:`gap-1.5`,children:[(0,H.jsx)(f,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function xt({plugins:e,loading:t,uploading:n,error:i,hasKeys:a,showUploadForm:o,showJsonForm:s,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:m,refreshingPluginIds:h,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:C,onPluginApiKeyChange:w,onShowApiKeyChange:T,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:ee,onSaveApiKey:ne,onDeleteApiKey:re,onRefreshModels:O}){let{t:k}=r(),A=Ne(e=>e.user),M=Ne(e=>e.systemInfo)?.requiresAuth===!1||A?.role===`admin`,[ie,ae]=(0,V.useState)(``),[oe,se]=(0,V.useState)(null),N=(0,V.useId)(),le=(0,V.useMemo)(()=>e.filter(e=>we(e,ie)),[e,ie]),P=oe&&e.some(e=>e.id===oe)?oe:e[0]?.id??null,F=e.find(e=>e.id===P)??null,ue=e=>{e!==P&&(C(null),se(e))};return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:k(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:k(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),i&&(0,H.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:i}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,H.jsx)(te,{className:`h-4 w-4`})})]})}),M&&(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:k(`settings.plugins.addNew`)}),(0,H.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>_(!o),disabled:t||n,children:[(0,H.jsx)(S,{className:`h-4 w-4 me-2`}),k(`settings.plugins.upload`)]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>v(!s),disabled:t,children:k(`settings.plugins.addJson`)})]})]}),o&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,H.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:k(`common.cancel`)})]}),n&&(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:k(`settings.plugins.uploading`)})]}),s&&(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:k(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:k(`common.cancel`)}),(0,H.jsx)(z,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:k(`settings.plugins.install`)})]})]})})]}),(0,H.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,H.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,H.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":k(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:border-b-0 lg:border-e`,children:[(0,H.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:k(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,H.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,H.jsx)(`label`,{htmlFor:N,className:`sr-only`,children:k(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(p,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,H.jsx)(`input`,{id:N,type:`search`,value:ie,onChange:e=>ae(e.target.value),placeholder:k(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,H.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3`,children:t&&e.length===0?(0,H.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,H.jsx)(j,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),k(`settings.plugins.loading`)]}):e.length===0?(0,H.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,H.jsx)(ce,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,H.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:k(`settings.plugins.noPlugins`)}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:k(`settings.plugins.noPluginsDescription`)})]}):le.length===0?(0,H.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:k(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):le.map(e=>{let t=P===e.id,n=Ce(e).length;return(0,H.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>ue(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`sr-only`,children:[e.active?k(`settings.plugins.activeLabel`):k(`settings.plugins.inactive`),`.`,` `]}),(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,H.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,k(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,H.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:F?(0,H.jsx)(St,{plugin:F,loading:t,hasApiKey:a[F.id]||!1,expanded:u===F.id,apiKey:d[F.id]||``,showApiKey:f[F.id]||!1,savingApiKey:m===F.id,refreshingModels:!!h[F.id],canManagePlugin:M,onExpand:()=>C(u===F.id?null:F.id),onActivate:()=>E(F.id),onExport:()=>ee(F.id),onDelete:()=>D(F.id),onRefreshModels:()=>O(F.id),onApiKeyChange:e=>w(F.id,e),onShowApiKeyChange:e=>T(F.id,e),onSaveApiKey:()=>ne(F.id),onDeleteApiKey:()=>re(F.id)}):(0,H.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(ce,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:k(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:k(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function St({plugin:e,loading:t,hasApiKey:n,expanded:i,apiKey:a,showApiKey:o,savingApiKey:s,refreshingModels:c,canManagePlugin:u,onExpand:f,onActivate:p,onExport:m,onDelete:h,onRefreshModels:g,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:x}){let{t:S}=r(),w=!!(e.auth?.header||e.auth?.key_env),T=ht(e),E=u?e.variables||[]:(e.variables||[]).filter(e=>!T.has(e.name)),D=E.length>0,te=w||D,re=(0,V.useId)(),k=Ce(e),A=e.base_url||e.endpoint;return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,H.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,H.jsx)(`span`,{className:`capitalize`,children:e.type}),w&&n&&(0,H.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,S(`settings.plugins.apiKeySet`)]})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[te&&(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:f,"aria-expanded":i,"aria-controls":re,title:S(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[w?(0,H.jsx)(C,{className:`h-4 w-4`}):(0,H.jsx)(l,{className:`h-4 w-4`}),S(`settings.plugins.configure`),i?(0,H.jsx)(ne,{className:`h-3 w-3`}):(0,H.jsx)(b,{className:`h-3 w-3`})]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:p,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(O,{className:`h-4 w-4`}),S(`settings.plugins.deactivate`)]}):S(`settings.plugins.activate`)}),u&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:m,disabled:t,title:S(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,H.jsx)(d,{className:`h-4 w-4`})}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:h,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:S(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,H.jsx)(ee,{className:`h-4 w-4`})})]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.status`,{defaultValue:`Status`})}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?S(`settings.plugins.activeLabel`):S(`settings.plugins.inactive`)})]}),(0,H.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.models`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:k.length})]}),(0,H.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:A,children:A})]})]})]}),i&&te&&(0,H.jsxs)(`div`,{id:re,children:[w&&(0,H.jsx)(K,{plugin:e,hasApiKey:n,apiKey:a,showApiKey:o,savingApiKey:s,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:x}),D&&(0,H.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,H.jsx)(l,{className:`h-4 w-4 text-gray-500`}),(0,H.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[S(`settings.plugins.providerSettings`),` (`,E.length,`)`]})]}),(0,H.jsx)(bt,{plugin:e},e.id)]})]}),(0,H.jsx)(Ct,{catalog:k,canRefresh:Oe(e),refreshing:c,onRefresh:g})]})}function Ct({catalog:e,canRefresh:t,refreshing:n,onRefresh:i}){let{t:a}=r();return(0,H.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:a(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:a(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:i,disabled:n,"aria-busy":n,children:[n?(0,H.jsx)(j,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(m,{className:`h-4 w-4`}),a(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:a(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,H.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,H.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,H.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,H.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:a(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function K({plugin:e,hasApiKey:t,apiKey:n,showApiKey:i,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=r(),d=(0,V.useId)();return(0,H.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,H.jsx)(C,{className:`h-4 w-4 text-gray-500`}),(0,H.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,H.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,H.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,H.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,H.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{className:`h-4 w-4 text-green-600`}),(0,H.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:l,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,H.jsx)(j,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,H.jsx)(`input`,{id:d,type:i?`text`:`password`,value:n,onChange:e=>o(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:a,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(!i),"aria-controls":d,"aria-label":u(i?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:a,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:i?(0,H.jsx)(le,{className:`h-4 w-4`}):(0,H.jsx)(h,{className:`h-4 w-4`})})]}),(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(z,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(j,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}function wt({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,voices:o,testing:s,onSettingChange:c,onModelChange:l,onReset:u,onTest:d,onSave:p}){let{t:m}=r(),h=i.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.tts.description`)}),e?(0,H.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,H.jsx)(j,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,H.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.tts.loadingProviders`)})]}):i.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(re,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.tts.noProviders`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.tts.noProvidersDescription`)})]})]})}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.enable`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.enableDescription`)})]}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.autoPlay`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.autoPlayDescription`)})]}),(0,H.jsx)(U,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>c(`autoPlay`,e)})]})}),(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.streamSentences`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.streamSentencesDescription`)})]}),(0,H.jsx)(U,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>c(`streamSentences`,e)})]})}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.voiceConfiguration`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.model`)}),(0,H.jsx)(B,{"aria-label":m(`settings.tts.model`),value:h?ge(h):``,onChange:e=>{let t=i.find(t=>ge(t)===e.target.value);t&&l(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...i.map(e=>({value:ge(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.modelDescription`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.voice`)}),(0,H.jsx)(B,{"aria-label":m(`settings.tts.voice`),value:n.voice,onChange:e=>c(`voice`,e.target.value),disabled:!t.enabled||o.length===0,options:[{value:``,label:m(`settings.tts.selectVoice`)},...o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.voiceDescription`)})]})]})]}),a.length>0&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.tts.availableProviders`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.tts.models`),`)`]})]},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(z,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),m(`common.reset`)]}),(0,H.jsx)(z,{onClick:d,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ae,{size:16}),m(`settings.tts.stop`)]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{size:16}),m(`settings.tts.test`)]})})]}),(0,H.jsxs)(z,{onClick:p,className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function Tt({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(`skip`),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),g.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await I.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),g.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){g.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Et=Ue()||`0.0.0`,Dt=`__current_running_model__`,Ot={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},kt={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},At={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},jt=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,setSelectedModel:s,systemMessage:c,setSystemMessage:u,clearAllSessions:d,loading:f,sessions:m,loadModels:h,loadSessions:v}=Ae(),{theme:y,updateTheme:b,preferences:x,setPreferences:S,loadPreferences:C}=Le(),{plugins:w,isLoading:E,isUploading:ee,error:ne,loadPlugins:O,uploadPlugin:j,deletePlugin:M,activatePlugin:ae,deactivatePlugin:oe,exportPlugin:se,clearError:N,installPlugin:le}=Me(),{t:P}=r(),ge=V.useId(),_e=Te(n,{model:i,providerType:a,providerId:o}),xe={model:x.titleSettings?.taskModel||``,providerType:x.titleSettings?.taskProviderType,providerId:x.titleSettings?.taskProviderId},Ce=Te(n,xe),we=xe.model===Dt?Dt:xe.model?Se(Ce,xe):``,De={model:x.visionModel||``,providerType:x.visionProviderType,providerId:x.visionProviderId},Oe=Te(n,De),Ne=De.model?Se(Oe,De):``,Pe=[{value:``,label:P(`settings.model.selectVisionModel`,{defaultValue:`Use the current chat model`})},...Oe.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:e.isAgent?`${e.agentName||e.name} · Agent CLI${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],Fe=[{value:``,label:P(`settings.model.autoTitle.selectTaskModel`)},{value:Dt,label:`Use current running model`},...Ce.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],[B,ze]=(0,V.useState)(`appearance`),[Ve,Ue]=(0,V.useState)(``),[We,Ge]=(0,V.useState)(c),[qe,Je]=(0,V.useState)(!1),[Ye,Ze]=(0,V.useState)(null),[U,et]=(0,V.useState)(!1),[tt,rt]=(0,V.useState)(!1),[W,it]=(0,V.useState)(``),st=(0,V.useRef)(null),[ct,lt]=(0,V.useState)(null),[ut,dt]=(0,V.useState)({}),[ft,pt]=(0,V.useState)({}),[mt,ht]=(0,V.useState)(null),[gt,_t]=(0,V.useState)({}),[vt,yt]=(0,V.useState)(x.generationOptions||{}),[G,bt]=(0,V.useState)(x.embeddingSettings||Ot),[St,Ct]=(0,V.useState)(!1),[K,jt]=(0,V.useState)(x.ttsSettings||kt),[Mt,Nt]=(0,V.useState)(!1),Pt=(0,V.useRef)(null),[q,Ft]=(0,V.useState)(x.imageGenSettings||At),{importing:It,showImportOptions:Lt,mergeStrategy:Rt,setMergeStrategy:zt,importResult:Bt,setImportResult:Vt,importFileInputRef:Ht,handleExportData:Ut,handleImportFileSelect:Wt,handleConfirmImport:Gt,handleCancelImport:Kt}=Tt({preferences:x,sessions:m,loadPreferences:C,loadSessions:v}),J=He(),{data:qt={}}=Be({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await pe.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:Jt=[]}=Be({queryKey:[`embedding-models`],queryFn:async()=>{let e=await ue.getModels();return e.success&&e.data?e.data:[]},enabled:e}),Y=(0,V.useMemo)(()=>{let e=Jt.find(e=>e.id===G.model||e.rawModel===G.model);return e&&e.id!==G.model?{...G,model:e.id}:G},[Jt,G]),{data:Yt=null}=Be({queryKey:[`embedding-status`],queryFn:async()=>{let e=await L.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:Xt,isLoading:Zt}=Be({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([F.getModels(),F.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),X=(0,V.useMemo)(()=>Xt?.models??[],[Xt]),Qt=Xt?.plugins??[],$t=(0,V.useMemo)(()=>fe(X,K.model,K.pluginId),[X,K.model,K.pluginId]),Z=(0,V.useMemo)(()=>{if(!$t)return K;let e=me(X,K.model,K.pluginId);return e&&K.pluginId===e.plugin?K:{...K,model:$t.model,pluginId:$t.plugin,voice:$t.config?.default_voice||``}},[$t,X,K]),en=(0,V.useMemo)(()=>me(X,Z.model,Z.pluginId)?.config?.voices??[],[Z,X]),{data:tn,isLoading:nn}=Be({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([de.getModels(),de.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,V.useMemo)(()=>tn?.models??[],[tn]),rn=(0,V.useMemo)(()=>tn?.plugins??[],[tn]),$=(0,V.useMemo)(()=>ve(Q,q.model,q.pluginId),[Q,q.model,q.pluginId]),an=(0,V.useMemo)(()=>{if(!$)return q;let e=be(Q,q.model,q.pluginId);return e&&q.pluginId===e.plugin?q:{...q,model:$.model,pluginId:$.plugin,size:ye($.config?.sizes,q.size,$.config?.default_size,`1024x1024`),quality:ye($.config?.qualities,q.quality,$.config?.default_quality,`standard`),style:ye($.config?.styles,q.style,$.config?.default_style,`vivid`)}},[Q,q,$]),on=$?.config?.sizes??[],sn=$?.config?.qualities??[],cn=$?.config?.styles??[],ln=(0,V.useRef)(!1),un=(0,V.useRef)(c);(0,V.useEffect)(()=>{if(!e){ln.current=!1;return}ln.current&&un.current===c||(ln.current=!0,un.current=c,Ge(c),yt(x.generationOptions||{}),bt(x.embeddingSettings||Ot),jt(x.ttsSettings||kt),Ft(x.imageGenSettings||At))},[e,x.embeddingSettings,x.generationOptions,x.imageGenSettings,x.ttsSettings,c]);let dn=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(!e){dn.current=!1;return}dn.current||(dn.current=!0,O(),h())},[e,O,h]),(0,V.useEffect)(()=>{if(!e)return;let n=document.body.style.overflow,r=e=>{e.key===`Escape`&&t()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,r),()=>{document.body.style.overflow=n,document.removeEventListener(`keydown`,r)}},[e,t]);let fn=async e=>{let t=ut[e];if(!t?.trim()){g.error(`Please enter an API key`);return}ht(e);try{let n=await pe.setApiKey(e,t.trim());n.success?(g.success(`API key saved successfully`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await O(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),dt(t=>({...t,[e]:``})),pt(t=>({...t,[e]:!1}))):g.error(n.error||`Failed to save API key`)}catch{g.error(`Failed to save API key`)}finally{ht(null)}},pn=async e=>{ht(e);try{let t=await pe.deleteApiKey(e);t.success?(g.success(`API key removed`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await O(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),dt(t=>({...t,[e]:``}))):g.error(t.error||`Failed to remove API key`)}catch{g.error(`Failed to remove API key`)}finally{ht(null)}},mn=(e,t)=>{let n=me(X,e,t);n&&jt(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice||r.voice}))},hn=(e,t)=>{let n=be(Q,e,t);n&&Ft(t=>({...t,model:e,pluginId:n.plugin,size:ye(n.config?.sizes,t.size,n.config?.default_size,`1024x1024`),quality:ye(n.config?.qualities,t.quality,n.config?.default_quality,`standard`),style:ye(n.config?.styles,t.style,n.config?.default_style,`vivid`)}))},gn=(e,t)=>{jt(n=>({...n,[e]:t}))},_n=async()=>{try{let e=await I.updatePreferences({ttsSettings:Z});e.success&&e.data&&(S(e.data),g.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save TTS settings: `+t)}},vn=async()=>{if(Mt){let e=Pt.current;e&&(e.pause(),e.currentTime=0,Pt.current=null),Nt(!1);return}Nt(!0);try{let e=await F.generateBase64({model:Z.model||`tts-1`,pluginId:Z.pluginId,input:`Hello! This is a test of the text-to-speech system.`,voice:Z.voice||`alloy`,speed:Z.speed||1,response_format:$t?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);Pt.current=n,n.onended=()=>{Nt(!1),Pt.current=null},n.onerror=()=>{g.error(`Failed to play audio`),Nt(!1),Pt.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`TTS test failed: `+t),Nt(!1)}},yn=()=>{jt({enabled:!1,autoPlay:!1,model:X[0]?.model||``,voice:X[0]?.config?.default_voice||``,speed:1,pluginId:X[0]?.plugin||``,streamSentences:!1})},bn=(e,t)=>{Ft(n=>({...n,[e]:t}))},xn=async()=>{try{let e=await I.updatePreferences({imageGenSettings:an});e.success&&e.data&&(S(e.data),g.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save image generation settings: `+t)}},Sn=()=>{Ft({enabled:!1,model:Q[0]?.model||``,size:Q[0]?.config?.default_size||`1024x1024`,quality:Q[0]?.config?.default_quality||`standard`,style:Q[0]?.config?.default_style||`vivid`,pluginId:Q[0]?.plugin||``})},Cn=async()=>{try{Ct(!0),(await L.regenerateEmbeddings()).success&&(g.success(`Embeddings regenerated successfully`),await J.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to regenerate embeddings: `+t)}finally{Ct(!1)}},wn=async e=>{try{let t=await I.updatePreferences(e);t.success&&t.data&&(S(t.data),g.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)}},Tn=async e=>{let t=e.target.files?.[0];t&&(await j(t),et(!1),st.current&&(st.current.value=``),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},En=async()=>{try{let e=JSON.parse(W);await le(e),rt(!1),it(``),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]})}catch{N(),g.error(`Invalid JSON format`)}},Dn=async e=>{w.find(t=>t.id===e)?.active?await oe(e):await ae(e),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]})},On=async e=>{if(!gt[e]){_t(t=>({...t,[e]:!0}));try{let t=await pe.discoverModels(e);if(!t.success||!t.data){g.error(t.error||P(`settings.plugins.modelCatalogRefreshFailed`));return}await Promise.all([O(),h()]);let{outcome:n,models:r,reason:i}=t.data;n===`updated`?g.success(P(`settings.plugins.modelCatalogUpdated`,{count:r.length})):n===`unchanged`?g.success(P(`settings.plugins.modelCatalogUnchanged`)):n===`missing_credentials`?g.error(i||P(`settings.plugins.modelCatalogNeedsApiKey`)):g.error(i?`${P(`settings.plugins.modelCatalogUnavailable`)} ${i}`:P(`settings.plugins.modelCatalogUnavailable`))}catch(e){g.error(je(e,P(`settings.plugins.modelCatalogRefreshFailed`)))}finally{_t(t=>{let n={...t};return delete n[e],n})}}},kn=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await M(e),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},An=async e=>{await se(e)};if(!e)return null;let jn=e=>{let t=Le.getState().theme,n=Ie({...t,mode:e});b(n)},Mn=e=>{let t=Le.getState().theme,n=Ie({...t,accent:e});b(n)},Nn=e=>{let t=Le.getState().theme,n=Ie({...t,accent:`custom`,customAccent:e});b(n)},Pn=e=>{let t=Le.getState().theme,n=Ie({...t,adaptToAccent:e});b(n)},Fn=e=>{S({showUsername:e}),I.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},In=e=>{S({showFollowUpSuggestions:e}),I.updatePreferences({showFollowUpSuggestions:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},Ln=e=>{S({hapticFeedbackEnabled:e}),e&&Re(`selection`),I.updatePreferences({hapticFeedbackEnabled:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},Rn=e=>{if(!e.target.value){Ae.setState({selectedModel:``,selectedProviderType:null,selectedProviderId:null}),wn({defaultModel:``,defaultProviderType:null,defaultProviderId:null});return}let t=ke(_e,e.target.value);t&&(s(t.model,t.providerType,t.providerId),S({defaultModel:t.model,defaultProviderType:t.providerType,defaultProviderId:t.providerId}),g.success(`Default model updated`))},zn=e=>{Ge(e.target.value)},Bn=()=>{u(We),wn({systemMessage:We}),g.success(`System message updated`)},Vn=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await d(),g.success(`All chat sessions deleted`))},Hn=async()=>{Je(!0),Ze(null),he.pullAllModelsStream(e=>{Ze(e)},()=>{Je(!1),Ze(null),g.success(`All models updated successfully!`),h()},e=>{Je(!1),Ze(null),g.error(`Failed to update models: `+e)})},Un=e=>{let t={...x.titleSettings,autoTitle:e,taskModel:x.titleSettings?.taskModel||``};S({titleSettings:t}),I.updatePreferences({titleSettings:t})},Wn=e=>{if(!e){let e={visionModel:``,visionProviderType:null,visionProviderId:null};S(e),I.updatePreferences(e);return}let t=ke(Oe,e);if(!t?.providerType){g.error(P(`settings.model.visionModelNoProvider`));return}let n={visionModel:t.model,visionProviderType:t.providerType,visionProviderId:t.providerId||null};S(n),I.updatePreferences(n).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(P(`settings.model.visionModelUpdateFailed`,{error:t}))})},Gn=e=>{let t=e&&e!==Dt?ke(Ce,e):null,n={...x.titleSettings,autoTitle:x.titleSettings?.autoTitle||!1,taskModel:t?.model||e,taskProviderType:t?.providerType||null,taskProviderId:t?.providerType===`plugin`&&t.providerId||null};S({titleSettings:n}),I.updatePreferences({titleSettings:n})},Kn=(e,t)=>{dt(n=>({...n,[e]:t}))},qn=(e,t)=>{pt(n=>({...n,[e]:t}))},Jn=(e,t)=>{yt(n=>({...n,[e]:t}))},Yn=async()=>{try{let e=await I.setGenerationOptions(vt);e.success&&e.data&&(S(e.data),g.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update generation options: `+t)}},Xn=async()=>{try{let e=await I.resetGenerationOptions();e.success&&e.data&&(S(e.data),yt(e.data.generationOptions||{}),g.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset generation options: `+t)}},Zn=(e,t)=>{bt(n=>({...n,[e]:t}))},Qn=[...Jt.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!Jt.find(e=>e.id===Y.model||e.rawModel===Y.model)&&Y.model?[{value:Y.model,label:`${Y.model} (current)`}]:[]],$n=async()=>{try{let e=await I.setEmbeddingSettings(Y);e.success&&e.data&&(S(e.data),g.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update embedding settings: `+t)}},er=async()=>{try{let e=await I.resetEmbeddingSettings();e.success&&e.data&&(S(e.data),bt(e.data.embeddingSettings||{}),g.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset embedding settings: `+t)}},tr={appearance:`theme dark light accent color language username follow-up background interface`,data:`export import backup clear history sessions`,about:`version license update`,models:`default model system prompt title vision auto`,generation:`temperature top_p top_k seed tokens context penalty embedding chunk similarity`,documents:`upload pdf rag document embedding`,tts:`voice speech audio speak read aloud`,"image-gen":`image generation size quality style`,plugins:`api key provider connection openai anthropic groq gemini`},nr=Ve.trim().toLowerCase(),rr=e=>!nr||e.label.toLowerCase().includes(nr)||(tr[e.id]||``).includes(nr),ir=[{id:`general`,label:P(`settings.groups.general`,`General`),tabs:[{id:`appearance`,label:P(`settings.tabs.appearance`),icon:A},{id:`data`,label:P(`settings.tabs.data`),icon:ie},{id:`about`,label:P(`settings.tabs.about`),icon:T}]},{id:`chat`,label:P(`settings.groups.chat`,`Chat`),tabs:[{id:`models`,label:P(`settings.tabs.model`),icon:D},{id:`generation`,label:P(`settings.tabs.generation`),icon:l},{id:`documents`,label:P(`settings.tabs.documents`),icon:_}]},{id:`media`,label:P(`settings.groups.media`,`Speech & images`),tabs:[{id:`tts`,label:P(`settings.tabs.tts`),icon:re},{id:`image-gen`,label:P(`settings.tabs.imageGen`),icon:k}]},{id:`connections`,label:P(`settings.groups.connections`,`Connections`),tabs:[{id:`plugins`,label:P(`settings.tabs.plugins`),icon:ce}]}];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-0 sm:p-4 lg:p-6`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":ge,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,H.jsxs)(`div`,{"data-testid":`settings-modal-panel`,className:`flex h-full w-full flex-col overscroll-behavior-contain border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95 sm:max-h-[94vh] sm:max-w-6xl sm:rounded-3xl`,children:[(0,H.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-gray-200/70 px-4 py-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:[(0,H.jsx)(`h2`,{id:ge,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:P(`settings.title`)}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:t,autoFocus:!0,className:`h-9 w-9 touch-manipulation p-0 hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.06] dark:active:bg-white/10`,title:P(`common.close`,{defaultValue:`Close`}),children:(0,H.jsx)(te,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,H.jsxs)(`div`,{className:`w-full shrink-0 overflow-x-auto border-b border-gray-200/70 p-2 scrollbar-thin dark:border-white/[0.08] sm:w-56 sm:overflow-x-hidden sm:overflow-y-auto sm:border-b-0 sm:border-e sm:p-3 lg:w-64`,style:{WebkitOverflowScrolling:`touch`},children:[(0,H.jsxs)(`div`,{className:`relative mb-1 hidden sm:block`,children:[(0,H.jsx)(p,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-subtle`}),(0,H.jsx)(`input`,{type:`search`,value:Ve,onChange:e=>{let t=e.target.value;Ue(t);let n=t.trim().toLowerCase();if(!n)return;let r=ir.flatMap(e=>e.tabs).filter(e=>e.label.toLowerCase().includes(n)||(tr[e.id]||``).includes(n));r.length>0&&!r.some(e=>e.id===B)&&ze(r[0].id)},placeholder:P(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-[13px] text-ink placeholder:text-ink-subtle focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05]`})]}),(0,H.jsx)(`nav`,{className:`flex gap-1 sm:flex-col sm:gap-0`,role:`tablist`,"aria-label":P(`settings.title`,`Settings`),children:ir.map(e=>({...e,tabs:e.tabs.filter(rr)})).filter(e=>e.tabs.length>0).map(e=>(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 sm:flex-col sm:gap-0.5 sm:pb-2`,children:[(0,H.jsx)(`p`,{"aria-hidden":`true`,className:`hidden px-2.5 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle sm:block`,children:e.label}),e.tabs.map(e=>{let t=e.icon,n=B===e.id;return(0,H.jsxs)(`button`,{onClick:()=>ze(e.id),className:R(`flex shrink-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 sm:w-full`,n?`bg-black/[0.06] text-ink dark:bg-white/[0.08]`:`text-ink-muted hover:bg-black/[0.04] hover:text-ink dark:hover:bg-white/[0.05]`),role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,H.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate whitespace-nowrap text-[13px]`,children:e.label})]},e.id)})]},e.id))})]}),(0,H.jsx)(`div`,{"data-testid":`settings-scroll-region`,className:`scroll-region min-h-0 flex-1 p-4 scrollbar-thin sm:p-6 lg:p-8`,id:`settings-tab-panel`,role:`tabpanel`,children:(()=>{switch(B){case`appearance`:return(0,H.jsx)(Xe,{theme:y,preferences:x,onThemeChange:jn,onAccentChange:Mn,onCustomAccentChange:Nn,onAdaptToAccentChange:Pn,onShowUsernameChange:Fn,onShowFollowUpsChange:In,onHapticFeedbackChange:Ln});case`models`:return(0,H.jsx)(ot,{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,systemMessage:c,tempSystemMessage:We,loading:f,preferences:x,currentVisionModel:Ne,visionModelOptions:Pe,currentTaskModel:we,autoTitleTaskModelOptions:Fe,updatingAllModels:qe,updateProgress:Ye,onModelChange:Rn,onSystemMessageChange:zn,onSystemMessageSave:Bn,onAutoTitleChange:Un,onAutoTitleTaskModelChange:Gn,onVisionModelChange:Wn,onUpdateAllModels:Hn});case`tts`:return(0,H.jsx)(wt,{loading:Zt,settings:K,effectiveSettings:Z,models:X,plugins:Qt,voices:en,testing:Mt,onSettingChange:gn,onModelChange:mn,onReset:yn,onTest:vn,onSave:_n});case`image-gen`:return(0,H.jsx)(at,{loading:nn,settings:q,effectiveSettings:an,models:Q,plugins:rn,sizes:on,qualities:sn,styles:cn,onSettingChange:bn,onModelChange:hn,onReset:Sn,onSave:xn});case`documents`:return(0,H.jsx)($e,{settings:G,effectiveSettings:Y,modelOptions:Qn,status:Yt,regenerating:St,onSettingChange:Zn,onReset:er,onRegenerate:Cn,onSave:$n});case`plugins`:return(0,H.jsx)(xt,{plugins:w,loading:E,uploading:ee,error:ne,hasKeys:qt,showUploadForm:U,showJsonForm:tt,jsonInput:W,fileInputRef:st,expandedPluginId:ct,pluginApiKeys:ut,showApiKey:ft,savingApiKey:mt,refreshingPluginIds:gt,onClearError:N,onShowUploadFormChange:et,onShowJsonFormChange:rt,onJsonInputChange:it,onFileUpload:Tn,onJsonSubmit:En,onExpandedPluginChange:lt,onPluginApiKeyChange:Kn,onShowApiKeyChange:qn,onActivatePlugin:Dn,onRefreshModels:On,onDeletePlugin:kn,onExportPlugin:An,onSaveApiKey:fn,onDeleteApiKey:pn});case`data`:return(0,H.jsx)(Qe,{sessionCount:m.length,loading:f,importing:It,showImportOptions:Lt,mergeStrategy:Rt,importResult:Bt,importFileInputRef:Ht,onExportData:Ut,onImportFileSelect:Wt,onClearAllHistory:Vn,onMergeStrategyChange:zt,onConfirmImport:Gt,onCancelImport:Kt,onDismissImportResult:()=>Vt(null)});case`about`:return(0,H.jsx)(Ke,{appVersion:Et});case`generation`:return(0,H.jsx)(nt,{generationOptions:vt,embeddingSettings:G,effectiveEmbeddingSettings:Y,embeddingModelOptions:Qn,embeddingStatus:Yt,onGenerationOptionChange:Jn,onEmbeddingSettingsChange:Zn,onResetGenerationOptions:Xn,onSaveGenerationOptions:Yn,onResetEmbeddingSettings:er,onSaveEmbeddingSettings:$n});default:return null}})()})]})]})})]})};export{jt as SettingsModal};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-CmENXdZw.js","js/router-vendor-Ca9zqOqT.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-DHnR5Hw8.js","js/estree-CrfVSazx.js","assets/index-D4LhtFTX.js","js/react-vendor-DPNXrO-8.js","js/useTranslation-CdeLZqSW.js","js/i18n-ZJQSoIuM.js","js/i18next-DgmgtwsV.js","js/ui-vendor-D_pYT79f.js","js/utils-vendor-1zob7nK9.js","js/logger-DSXjF4ye.js","js/api-jwjnjqx6.js","js/utils-BhpNrGnR.js","js/chatStore-DRY8C0J1.js","js/authStore-CsCkBmaG.js","js/appStore-CLIS0fvz.js","js/welcomePrompts-to5mv_gx.js","js/messageCodeStyles-CfzjQF-R.js","js/Button-X9TT9gTD.js","js/ui-Dj9IFugT.js","assets/index-B9H3vQ-n.css","js/typescript-BhVG1zGU.js","js/postcss-B5WIGhAY.js","js/html-BbJLJMaV.js","js/markdown-DiMg1QLf.js","js/yaml-QD4znPfZ.js","js/standalone-Vs6LnjM6.js","js/OptimizedSyntaxHighlighter-CWYUn9Oe.js","js/syntax-highlight-Ca9bHsaz.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-Ca9zqOqT.js";import{t as c}from"./useTranslation-CdeLZqSW.js";import{i as l}from"./i18n-ZJQSoIuM.js";import{$t as u,B as d,Bt as f,C as p,Ct as m,Dt as h,F as g,It as _,L as v,Mt as y,N as b,Nt as x,Q as S,R as C,Sn as w,St as T,T as E,Tn as D,V as O,Vt as k,an as A,c as j,dn as M,i as ee,in as te,kt as N,m as ne,n as P,on as re,pn as ie,st as F,tt as ae,vn as oe,vt as se,x as ce,yn as le}from"./ui-vendor-D_pYT79f.js";import{c as ue,o as de,w as fe}from"./api-jwjnjqx6.js";import{t as I}from"./utils-BhpNrGnR.js";import{t as L}from"./chatStore-DRY8C0J1.js";import{a as pe,i as me,l as he,n as ge,o as _e,s as ve}from"./authStore-CsCkBmaG.js";import{t as ye}from"./appStore-CLIS0fvz.js";import{t as R}from"./Button-X9TT9gTD.js";import{u as be}from"./ui-Dj9IFugT.js";import{c as xe}from"../assets/index-D4LhtFTX.js";import{t as Se}from"./RichMessageContent-C7NG7gs-.js";import{t as Ce}from"./ModelSelector-BV1kuaVg.js";import{n as we,t as Te}from"./work-DVgm81bJ.js";var z=e(n(),1),B=t(),V=e=>we({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),Ee=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},H=e=>{let t=`${e.model} · `;return{name:e.model,model:e.model,size:0,digest:``,modified_at:``,details:{},isPlugin:e.providerType===`plugin`,pluginId:e.providerId,pluginName:e.providerType===`plugin`?e.label.startsWith(t)?e.label.slice(t.length):e.providerId:void 0}};function U({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,remoteDisclosureDismissed:s,remoteDisclosureSaving:l,onModelChange:d,onDismissRemoteDisclosure:f,onModelsRefresh:p,onSubmit:m,onCancel:h}){let{t:g}=c(),[_,v]=(0,z.useState)(``),y=(0,z.useRef)(null),x=(0,z.useRef)(null),S=(0,z.useRef)(null),C=e.find(e=>e.key===n),w=C?.remote===!0,T=a===`landing`,E=(0,z.useMemo)(()=>{let n=new Set(t.map(V)),r=e.filter(e=>!n.has(e.key)).map(H);return[...t,...r]},[e,t]);(0,z.useEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[_]);let D=async()=>{await f()&&([x.current,S.current].find(e=>e&&e.offsetParent!==null)||x.current)?.focus()},O=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&d(n.key)},k=async()=>{let e=_.trim();!e||i||r||o||!C||await m(e)&&v(``)};return(0,B.jsxs)(`div`,{"data-testid":T?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:I(`relative shrink-0`,T?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[w&&!s&&(0,B.jsx)(`div`,{className:I(`absolute inset-x-3 z-30 mx-auto max-w-3xl md:inset-x-5`,`bottom-full mb-3`),children:(0,B.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":g(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,B.jsx)(P,{className:`h-4 w-4`})}),(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,B.jsx)(u,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:g(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,B.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:g(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,B.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,B.jsx)(R,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:l,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void D(),children:g(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,B.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),k()},children:(0,B.jsxs)(`div`,{"data-testid":`work-composer-surface`,className:I(`flex items-end gap-2 rounded-[1.6rem] border p-2.5 transition-[border-color,box-shadow,background-color] duration-200 sm:p-3`,`border-black/[0.08] bg-surface/90 dark:border-white/[0.09] dark:bg-dark-200/90`,`shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_50px_rgba(15,23,42,0.08)] backdrop-blur-xl`,`focus-within:border-primary-500/35 focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_22px_65px_rgba(15,23,42,0.12)]`),children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,B.jsx)(`textarea`,{ref:y,"data-testid":`work-composer-input`,dir:`auto`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),k())},disabled:o||r,rows:1,className:`m-0 block max-h-[160px] min-h-10 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent p-2 text-base leading-relaxed text-ink shadow-none outline-none placeholder:text-ink-subtle focus:border-0 focus:bg-transparent focus:ring-0 disabled:cursor-not-allowed disabled:opacity-60`,placeholder:g(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})})}),(0,B.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,B.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:V,getModelLabel:Ee,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,B.jsx)(R,{"data-testid":`work-cancel-button`,type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full bg-error-500/15 p-0 text-error-600 transition-colors duration-150 hover:bg-error-500/25 dark:text-error-400 sm:h-10 sm:w-10`,title:g(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":g(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void h(),children:i?(0,B.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,B.jsx)(ce,{className:`h-4 w-4 fill-current`})}):(0,B.jsx)(R,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!_.trim()||!C,className:I(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150 sm:h-10 sm:w-10`,`bg-gray-950 text-white hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,`disabled:bg-gray-100 disabled:text-gray-400 disabled:hover:bg-gray-100 dark:disabled:bg-dark-300 dark:disabled:text-dark-500 dark:disabled:hover:bg-dark-300`,_.trim()&&C&&!o&&`shadow-sm`),title:g(`work.composer.send`,{defaultValue:`Run`}),"aria-label":g(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,B.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,B.jsx)(b,{className:`h-4 w-4`})})]})}),(0,B.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,B.jsx)(Ce,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:V,getModelLabel:Ee,getModelTitle:e=>e.name,triggerRef:S,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var De=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},Oe=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},ke=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function Ae({run:e}){let[t,n]=(0,z.useState)();if((0,z.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,B.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:Oe(r-e.startedAt)}):null}function je({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,z.useState)(e.status),[i,a]=(0,z.useState)(null),o=(0,z.useMemo)(()=>De(e.arguments),[e.arguments]),s=e.output||null,l=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,z.useId)(),m=d?n(`work.activity.kinds.error`,{defaultValue:`Error`}):f?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),h=i??(e.status===r?t:e.status===`error`);return(0,B.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:I(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,d?`border-error-500/30`:`border-line`),children:[(0,B.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{a(!h)},"aria-expanded":l?h:void 0,"aria-controls":l?p:void 0,"aria-label":`${m}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,B.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,B.jsx)(u,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,B.jsx)(re,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,B.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:Oe(e.durationMs)}),l&&(0,B.jsx)(A,{"aria-hidden":`true`,className:I(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,h&&`rotate-180`)})]}),l&&h&&(0,B.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,B.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,B.jsx)(`pre`,{dir:`ltr`,className:I(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,d?`text-error-600`:`text-ink-muted`),children:s})]})]})}var Me=e=>{let t=e.split(`
3
- `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function W({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,z.useState)(!1),a=t&&!r?Me(e):``;return(0,B.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,B.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,B.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(M,{className:I(`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`,t&&`animate-pulse-subtle motion-reduce:animate-none`)}),t?(0,B.jsxs)(`span`,{className:`animate-shimmer truncate bg-gradient-to-r from-ink-subtle via-ink to-ink-subtle bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-ink-muted`,children:[n(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),`…`]}):(0,B.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,B.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,B.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,B.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,B.jsx)(be,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var G=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),Ne=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function Pe({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Ne(e.connection,n)||G(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,l=o!==void 0&&o>0?o:s?ke(s):o,d=(o===void 0||o===0)&&!!s&&l!==void 0,f=e.usage?.tokensPerSecond;return(0,B.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:I(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,B.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:I(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,B.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,B.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,B.jsx)(Ae,{run:e})]}),t===`conversation`&&(0,B.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,B.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,B.jsx)(E,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,B.jsx)(`div`,{"data-testid":`work-live-timeline`,className:`space-y-2`,children:e.timeline.map((t,n)=>{let r=n===e.timeline.length-1;if(t.kind===`reasoning`)return(0,B.jsx)(W,{content:t.text,streaming:a&&r},`segment-${n}`);if(t.kind===`tool`){let n=e.tools.find(e=>e.id===t.toolId);return n?(0,B.jsx)(je,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,B.jsx)(be,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,B.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,B.jsx)(je,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,B.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,B.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{children:e.error})]}),(l!==void 0||f!==void 0)&&(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[l!==void 0&&(0,B.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,B.jsxs)(`bdi`,{dir:`ltr`,children:[d&&`≈`,l.toLocaleString()]})]}),f!==void 0&&(0,B.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,B.jsxs)(`bdi`,{dir:`ltr`,children:[f.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,B.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,B.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,B.jsx)(p,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function K({role:e,user:t,size:n=`message`}){let[r,i]=(0,z.useState)(null);if(e===`assistant`)return(0,B.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`work-assistant-avatar`,className:I(`flex shrink-0 items-center justify-center rounded-full border border-line bg-surface-raised shadow-subtle`,n===`empty`?`mx-auto mb-4 h-12 px-3`:`mt-0.5 h-8 px-2`),children:(0,B.jsx)(`span`,{"aria-hidden":`true`,className:I(`libre-brand text-ink`,n===`empty`?`text-sm`:`text-[11px]`),children:`Libre`})});let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,B.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`work-user-avatar`,className:I(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:a,children:s?(0,B.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,B.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Fe=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Ie=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},Le=(e,t,n)=>{let r=e??t,i=t?.kind===`error`||t?.metadata?.isError===!0||!t&&r?.kind===`error`,a=t?.metadata?.durationMs;return{id:(e??t)?.id??`tool`,name:r?Fe(r,n):n,status:i?`error`:`completed`,arguments:e?.metadata,output:t?.content||(!t&&e?e.content:void 0),durationMs:typeof a==`number`?a:void 0}},q=(e,t)=>{let n=[],r=new Map,i=(e,t)=>{let r=n[n.length-1];return r?.item.type===`tools`?(r.item.tools.push(e),r.item.tools.length-1):(n.push({key:t,item:{type:`tools`,tools:[e]}}),0)};for(let a of e){if(a.kind===`reasoning`){n.push({key:a.id,item:{type:`reasoning`,message:a}});continue}if(a.role!==`tool`&&a.kind===`message`){n.push({key:a.id,item:{type:`message`,message:a}});continue}let e=Ie(a);if(a.kind===`tool_call`&&e){let o=i(Le(a,void 0,t),a.id);r.set(e,{itemIndex:n.length-1,toolIndex:o,call:a});continue}if(a.kind===`tool_result`&&e){let i=r.get(e);if(i){let o=n[i.itemIndex];if(o.item.type===`tools`){o.item.tools[i.toolIndex]=Le(i.call,a,t),r.delete(e);continue}}}i(Le(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function Re({message:e}){let{t}=c();return(0,B.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,B.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,B.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,B.jsx)(A,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,B.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function ze({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,z.useRef)(null),l=(0,z.useRef)(!0),[u,d]=(0,z.useState)(!1),f=(0,z.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),p=i?.runId,m=(0,z.useMemo)(()=>q(f.filter(e=>!(p&&e.runId===p&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[p,f,o]),h=[...f].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,z.useEffect)(()=>{l.current=!0;let e=s.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>d(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,z.useEffect)(()=>{let e=s.current,t;return e&&l.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>d(!1))):e&&i&&(t=window.requestAnimationFrame(()=>d(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,f,e.status]);let g=async()=>{let e=s.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;l.current=!1;try{await a(),requestAnimationFrame(()=>{let e=s.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&f.length===0?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,B.jsx)(F,{className:`h-6 w-6 animate-spin`})}):(0,B.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,B.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;l.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,l.current&&d(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,B.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:f.length===0&&!i?(0,B.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,B.jsx)(K,{role:`assistant`,size:`empty`}),(0,B.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:o(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,B.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,B.jsx)(`div`,{className:`flex justify-center`,children:(0,B.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void g(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),m.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,B.jsx)(Re,{message:r.message},n);if(r.type===`tools`)return(0,B.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,B.jsx)(je,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===h&&i.runId===e.activeRun?.id;return(0,B.jsxs)(`article`,{className:I(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,B.jsx)(K,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,B.jsx)(`div`,{className:I(`min-w-0 max-w-[88%]`,a&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:a?(0,B.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,B.jsx)(be,{content:i.content,className:`text-ink`}):(0,B.jsx)(Se,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,B.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,B.jsx)(K,{role:`assistant`}),(0,B.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,B.jsx)(Pe,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?o(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):o(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),u&&(0,B.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight),l.current=!0,d(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,B.jsx)(le,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var J=45,Be=30,Ve=70,He=360,Ue=480,We=9,Y=2,Ge=10,Ke=`libre-webui-work-split:`,qe=(e,t,n)=>Math.min(n,Math.max(t,e)),Je=e=>`${Ke}${encodeURIComponent(e||`local`)}`,Ye=e=>{if(typeof window>`u`)return J;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return J;let n=Number(t);return Number.isFinite(n)?qe(n,Be,Ve):J}catch{return J}},Xe=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Ze=e=>{let t=Math.max(0,e-We);if(t===0)return{min:Be,max:Ve};let n=Math.max(Be,He/t*100),r=Math.min(Ve,(t-Ue)/t*100);if(n<=r)return{min:n,max:r};let i=qe(He/840*100,Be,Ve);return{min:i,max:i}},X=(e,t)=>qe(e,t.min,t.max);function Qe({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=l(o.language),u=Je(n),[d,f]=(0,z.useState)(()=>({storageKey:u,percent:Ye(u)})),[p,m]=(0,z.useState)(0),[h,g]=(0,z.useState)(!1),_=(0,z.useRef)(null),v=(0,z.useRef)(null),y=(0,z.useRef)(null),b=(0,z.useRef)(u),x=(0,z.useRef)(d.percent),S=(0,z.useRef)(null),C=d.storageKey===u?d.percent:Ye(u),w=(0,z.useMemo)(()=>Ze(p),[p]),T=X(C,w),E=Math.round(T),D=100-E,O=(0,z.useCallback)(e=>{f({storageKey:u,percent:e})},[u]),k=(0,z.useCallback)(e=>{let t=X(e,Ze(_.current?.getBoundingClientRect().width??0));x.current=t,S.current===null&&(S.current=window.requestAnimationFrame(()=>{S.current=null,O(x.current)}))},[O]),A=(0,z.useCallback)(()=>{if(y.current===null&&!h)return;S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null);let e=_.current?.getBoundingClientRect().width??0,t=X(x.current,Ze(e));x.current=t,O(t),Xe(b.current,t);let n=y.current;y.current=null,n!==null&&v.current?.hasPointerCapture(n)&&v.current.releasePointerCapture(n),g(!1)},[h,O]),j=(0,z.useCallback)(e=>{let t=_.current?.getBoundingClientRect();if(!t)return x.current;let n=Math.max(1,t.width-We);return((s?t.right-e:e-t.left)-We/2)/n*100},[s]),M=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),y.current=e.pointerId,b.current=u,x.current=T,e.currentTarget.setPointerCapture(e.pointerId),g(!0))},ee=(0,z.useCallback)(e=>{let t=X(e,w);x.current=t,O(t),Xe(u,t)},[w,O,u]),te=(0,z.useCallback)(()=>{ee(J)},[ee]),N=e=>{let t=e.shiftKey?Ge:Y,n=null;e.key===`ArrowLeft`?n=T+(s?t:-t):e.key===`ArrowRight`?n=T+(s?-t:t):e.key===`Home`?n=w.min:e.key===`End`?n=w.max:e.key===`Enter`&&(n=J),n!==null&&(e.preventDefault(),ee(n))};(0,z.useEffect)(()=>{let e=_.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>m(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&m(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,z.useEffect)(()=>{if(!h)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===y.current&&(e.preventDefault(),k(j(e.clientX)))},r=e=>{e.pointerId===y.current&&A()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,A),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,A),document.body.style.cursor=e,document.body.style.userSelect=t}},[A,h,j,k]),(0,z.useEffect)(()=>()=>{S.current!==null&&window.cancelAnimationFrame(S.current),y.current!==null&&Xe(b.current,x.current)},[]);let ne={gridTemplateColumns:`minmax(0, ${T}fr) ${We}px minmax(0, ${100-T}fr)`};return(0,B.jsxs)(`div`,{ref:_,"data-testid":`work-split-pane`,"data-split-percent":T.toFixed(2),"data-resizing":h?`true`:`false`,className:I(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ne,children:[(0,B.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:I(`min-h-0 min-w-0 flex-1 flex-col bg-transparent xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,B.jsxs)(`div`,{ref:v,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(w.min),"aria-valuemax":Math.round(w.max),"aria-valuenow":E,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:E,workspace:D,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:M,onDoubleClick:te,onKeyDown:N,className:I(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:I(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,h&&`bg-[#ff7b52]`)}),(0,B.jsx)(`span`,{"aria-hidden":`true`,className:I(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,h&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,B.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:I(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised/85 backdrop-blur-xl xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),h&&(0,B.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var $e=1e5,Z=4e3,et={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},tt={".bashrc":`bash`,".zshrc":`bash`},nt={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},rt=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,it=e=>{let t=rt(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},at=e=>tt[rt(e)]??et[it(e)]??`text`,ot=e=>nt[it(e)],st=e=>ot(e)!==void 0,ct=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Q=async e=>(await e).default,lt=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))]);case`typescript`:return Promise.all([Q(a(()=>import(`./typescript-BhVG1zGU.js`),__vite__mapDeps([23,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))]);case`postcss`:return[await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([24,1,2,3])))];case`html`:{let e=[await Q(a(()=>import(`./html-BbJLJMaV.js`),__vite__mapDeps([25,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))];return/<script\b/i.test(t)&&e.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Q(a(()=>import(`./typescript-BhVG1zGU.js`),__vite__mapDeps([23,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))),/<style\b/i.test(t)&&e.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([24,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Q(a(()=>import(`./markdown-DiMg1QLf.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))),r(`ts|tsx|typescript`)&&n.push(await Q(a(()=>import(`./typescript-BhVG1zGU.js`),__vite__mapDeps([23,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),await Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])))),r(`css|scss|less`)&&n.push(await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([24,1,2,3])))),r(`html`)&&n.push(await Q(a(()=>import(`./html-BbJLJMaV.js`),__vite__mapDeps([25,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),await Q(a(()=>import(`./babel-CmENXdZw.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CrfVSazx.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),await Q(a(()=>import(`./typescript-BhVG1zGU.js`),__vite__mapDeps([23,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),await Q(a(()=>import(`./postcss-B5WIGhAY.js`),__vite__mapDeps([24,1,2,3])))),r(`yaml|yml`)&&n.push(await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([27,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Q(a(()=>import(`./yaml-QD4znPfZ.js`),__vite__mapDeps([27,1,2,3])))]}},ut=async(e,t)=>{let n=ot(e);if(!n)throw Error(`Formatting is not supported for “${rt(e)||e}”.`);if(!ct(t))throw Error(`Could not format “${rt(e)||e}”: files are limited to ${$e.toLocaleString()} characters and ${Z.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-Vs6LnjM6.js`),__vite__mapDeps([28,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22])),lt(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${rt(e)||e}”: ${n}`)}},dt=(0,z.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-CWYUn9Oe.js`).then(e=>e.n),__vite__mapDeps([29,2,3,30]))).OptimizedSyntaxHighlighter})),ft=8e3,pt=400,mt=500;function ht({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),l=ye(e=>e.theme.mode===`dark`),u=(0,z.useRef)(null),d=(0,z.useRef)(null),[f,p]=(0,z.useState)(``),m=(0,z.useMemo)(()=>at(e),[e]),h=(0,z.useMemo)(()=>{if(t.length>ft)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>pt));n+=1);return e},[t]),g=t.length>ft||h>pt,_=m!==`text`&&!g,v=_&&f===t;return(0,z.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>p(t),mt);return()=>window.clearTimeout(e)},[_,e,t]),(0,z.useLayoutEffect)(()=>{!v||!u.current||!d.current||(u.current.style.transform=`translate3d(${-d.current.scrollLeft}px, ${-d.current.scrollTop}px, 0)`)},[v,e]),(0,B.jsxs)(`div`,{dir:`ltr`,className:I(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":m,"data-highlighted":v?`true`:`false`,children:[v&&(0,B.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,B.jsx)(`div`,{ref:u,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||`​`}),children:(0,B.jsx)(dt,{language:m,isDark:l,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:f||`​`})})})}),(0,B.jsx)(`textarea`,{ref:d,"data-testid":`work-file-editor`,"data-language":m,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{u.current&&(u.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:I(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,v?`text-transparent caret-ink`:`text-ink`),style:v?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),g&&(0,B.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var gt=4e6,_t=e=>{if(e===``)return[];let t=e.split(`
4
- `);return t[t.length-1]===``&&t.pop(),t},vt=(e,t)=>{let n=_t(e),r=_t(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=[];for(let e=0;e<i;e+=1)c.push({type:`context`,text:n[e],beforeLine:e+1,afterLine:e+1});let l=$(o,s);for(let e of l){let t={type:e.type,text:e.text};e.beforeLine!==void 0&&(t.beforeLine=e.beforeLine+i),e.afterLine!==void 0&&(t.afterLine=e.afterLine+i),c.push(t)}for(let e=0;e<a;e+=1){let t=n.length-a+e,i=r.length-a+e;c.push({type:`context`,text:n[t],beforeLine:t+1,afterLine:i+1})}return c},$=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>gt)return[...e.map((e,t)=>({type:`removed`,text:e,beforeLine:t+1})),...t.map((e,t)=>({type:`added`,text:e,afterLine:t+1}))];let n=e.length+1,r=t.length+1,i=new Uint32Array(n*r);for(let n=e.length-1;n>=0;--n)for(let a=t.length-1;a>=0;--a)i[n*r+a]=e[n]===t[a]?i[(n+1)*r+a+1]+1:Math.max(i[(n+1)*r+a],i[n*r+a+1]);let a=[],o=0,s=0;for(;o<e.length&&s<t.length;)e[o]===t[s]?(a.push({type:`context`,text:e[o],beforeLine:o+1,afterLine:s+1}),o+=1,s+=1):i[(o+1)*r+s]>=i[o*r+s+1]?(a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1):(a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1);for(;o<e.length;)a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1;for(;s<t.length;)a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1;return a},yt=e=>{let t=0,n=0;for(let r of e)r.type===`added`&&(t+=1),r.type===`removed`&&(n+=1);return{added:t,removed:n}},bt=3,xt=e=>{let t=Array(e.length).fill(!1);for(let n=0;n<e.length;n+=1){if(e[n].type===`context`)continue;let r=Math.max(0,n-bt),i=Math.min(e.length-1,n+bt);for(let e=r;e<=i;e+=1)t[e]=!0}let n=[],r=0;for(let i=0;i<e.length;i+=1){if(!t[i]){r+=1;continue}r>0&&(n.push({type:`fold`,count:r}),r=0),n.push({type:`line`,line:e[i]})}return r>0&&n.push({type:`fold`,count:r}),n};function St({lines:e,ariaLabel:t}){let{t:n}=c(),r=(0,z.useMemo)(()=>xt(e),[e]);return(0,B.jsx)(`div`,{dir:`ltr`,role:`region`,"aria-label":t,"data-testid":`work-file-diff`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:(0,B.jsx)(`table`,{className:`w-full border-collapse`,children:(0,B.jsx)(`tbody`,{children:r.map((e,t)=>e.type===`fold`?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:3,className:`select-none border-y border-line bg-surface-subtle/70 px-4 py-1 text-center text-[11px] text-ink-subtle`,children:n(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})})},`fold-${t}`):(0,B.jsxs)(`tr`,{className:I(e.line.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-ink`,e.line.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-ink-muted`,e.line.type===`context`&&`text-ink-muted`),children:[(0,B.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.beforeLine??``}),(0,B.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.afterLine??``}),(0,B.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:I(`me-2 inline-block w-3 select-none text-center`,e.line.type===`added`&&`text-[rgb(46,164,79)]`,e.line.type===`removed`&&`text-[rgb(255,61,129)]`),children:e.line.type===`added`?`+`:e.line.type===`removed`?`−`:``}),e.line.text||`​`]})]},`line-${t}`))})})})}var Ct=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},wt=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t};function Tt({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(!0),[l,u]=(0,z.useState)(!1),[f,p]=(0,z.useState)(null),[h,g]=(0,z.useState)([]),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(``),[w,T]=(0,z.useState)(null),[E,O]=(0,z.useState)(!1),k=(0,z.useRef)(0),A=(0,z.useCallback)(async()=>{let t=++k.current;s(!0),p(null);try{let n=Ct(await de.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==k.current)return;a(n),g([])}catch(e){if(t!==k.current)return;p(wt(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===k.current&&s(!1)}},[r,e]);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>void A(),0);return()=>{window.clearTimeout(e),k.current+=1}},[A]);let j=async(e,n)=>{if(t||l)return!1;u(!0),p(null);try{let t=Ct(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return a(t),g([]),T(null),D.success(n),!0}catch(e){let t=wt(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return p(t),D.error(t),!1}finally{u(!1)}},M=async t=>{O(!0),p(null);try{T(Ct(await de.getGitDiff(e,t),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}catch(e){p(wt(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{O(!1)}};if(o&&!i)return(0,B.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,B.jsx)(F,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,B.jsx)(m,{className:`mb-3 h-8 w-8 text-error-500`}),(0,B.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:f||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,B.jsxs)(R,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void A(),children:[(0,B.jsx)(C,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,B.jsx)(m,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,B.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,B.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-relaxed text-ink-muted`,children:r(`work.git.initializeDescription`,{defaultValue:`Create a local repository for status, diffs, branches, and commits. No remote credentials are connected.`})}),f&&(0,B.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:f}),(0,B.jsxs)(R,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l,onClick:()=>void j(()=>de.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[l?(0,B.jsx)(F,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(d,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,B.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ee=i.changes.filter(e=>e.staged).length,te=i.changes.length>0;return(0,B.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-lg bg-surface-subtle px-2 py-1 font-mono text-[11px] text-ink`,children:[(0,B.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),(i.ahead>0||i.behind>0)&&(0,B.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,B.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||l||te,onChange:t=>{let n=t.target.value;!n||n===i.branch||j(()=>de.switchGitBranch(e,n),r(`work.git.branchSwitched`,{name:n,defaultValue:`Switched to {{name}}.`}))},className:`h-7 max-w-44 rounded-lg border border-line bg-surface px-2 text-[11px] text-ink outline-none disabled:opacity-50`,children:[i.detached&&(0,B.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]}),(0,B.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,B.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:x,maxLength:200,onChange:e=>S(e.target.value),placeholder:r(`work.git.newBranch`,{defaultValue:`New local branch`}),className:`h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,B.jsxs)(R,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||l||!i.head||!x.trim(),onClick:()=>{let t=x.trim();j(()=>de.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&S(``)})},children:[(0,B.jsx)(d,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:o||l,"aria-label":r(`common.refresh`,{defaultValue:`Refresh`}),className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink disabled:opacity-50`,children:(0,B.jsx)(C,{className:I(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),f&&(0,B.jsx)(`div`,{className:`border-b border-error-200 bg-error-50 px-3 py-2 text-xs text-error-700 dark:border-error-900/60 dark:bg-error-900/30 dark:text-error-300`,children:f}),t&&n&&(0,B.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,B.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(14rem,0.8fr)_minmax(18rem,1.2fr)_minmax(13rem,0.8fr)]`,children:[(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,B.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,B.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,B.jsxs)(R,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||l||h.length===0&&i.changes.length===0,onClick:()=>{let t=h.length>0?h:i.changes.map(e=>e.path);j(()=>de.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,B.jsx)(re,{className:`h-3.5 w-3.5`}),h.length>0?r(`work.git.stageSelected`,{count:h.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),(0,B.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,B.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):i.changes.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,children:[(0,B.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:h.includes(e.path),onChange:t=>g(n=>t.target.checked?[...n,e.path]:n.filter(t=>t!==e.path)),className:`ms-2 h-3.5 w-3.5 accent-[#ff7b52]`}),(0,B.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void M(e.path),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,children:[(0,B.jsxs)(`span`,{dir:`ltr`,className:I(`w-5 shrink-0 font-mono text-[10px] font-semibold`,e.staged?`text-emerald-600`:`text-amber-600`),children:[e.indexStatus,e.workingTreeStatus]}),(0,B.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:e.path,children:e.path})]})]},`${e.path}:${e.originalPath||``}`))}),(0,B.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,B.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:y,maxLength:4e3,rows:2,onChange:e=>b(e.target.value),placeholder:r(`work.git.commitMessage`,{defaultValue:`Commit message`}),className:`w-full resize-none rounded-lg border border-line bg-surface px-2.5 py-2 text-xs text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,B.jsxs)(R,{"data-testid":`work-git-commit-button`,size:`sm`,className:`mt-1.5 w-full bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l||ee===0||!y.trim(),onClick:()=>{let t=y.trim();j(()=>de.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&b(``)})},children:[l&&(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]})]}),(0,B.jsxs)(`section`,{className:`flex min-h-48 min-w-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-medium text-ink`,children:[(0,B.jsx)(_,{className:`h-3.5 w-3.5`}),w?.path||r(`work.git.diff`,{defaultValue:`Diff preview`})]}),E?(0,B.jsx)(F,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):w?w.patch?(0,B.jsxs)(`pre`,{"data-testid":`work-git-diff`,dir:`ltr`,className:`min-h-0 flex-1 overflow-auto whitespace-pre p-3 text-left font-mono text-[11px] leading-relaxed text-ink`,children:[w.patch,w.truncated&&`
5
- … diff truncated …`]}):(0,B.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.noDiff`,{defaultValue:`No textual diff is available yet. Untracked files appear after staging.`})}):(0,B.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.selectChange`,{defaultValue:`Select a changed file to inspect its diff.`})})]}),(0,B.jsxs)(`section`,{className:`min-h-36 overflow-y-auto p-3`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,B.jsx)(v,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,B.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,B.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,B.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,B.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,B.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,B.jsx)(`span`,{dir:`auto`,children:e.author}),(0,B.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,B.jsx)(`p`,{className:`mt-4 border-t border-line pt-3 text-[10px] leading-relaxed text-ink-subtle`,children:r(`work.git.localOnly`,{defaultValue:`Local Git only. Push, pull, and pull requests require a separate trusted credential broker.`})})]})]})]})}var Et=`/ws/work-terminal`;function Dt(e,t){let n;if(t.protocol===`file:`)n=`ws://localhost:3001`;else if(t.apiBaseUrl)n=t.apiBaseUrl.replace(/\/api$/,``).replace(/^http:/,`ws:`).replace(/^https:/,`wss:`);else{let e=t.protocol===`https:`?`wss:`:`ws:`;n=t.production?`${e}//${t.host}`:`${e}//${t.hostname}:3001`}let r=new URL(`${n}${Et}`);return r.searchParams.set(`taskId`,e),t.token&&r.searchParams.set(`token`,t.token),r.toString()}function Ot(e){return Dt(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,production:!0,token:localStorage.getItem(`auth-token`)})}var kt={background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:`rgba(255, 123, 82, 0.28)`},At={background:`#0f1115`,foreground:`#e6e6e6`,cursor:`#ff7b52`,selectionBackground:`rgba(255, 123, 82, 0.32)`};function jt({taskId:e,active:t,disabledReason:n}){let{t:r}=c(),i=ye(e=>e.theme.mode===`dark`),o=(0,z.useRef)(null),s=(0,z.useRef)(null),l=(0,z.useRef)(null),u=(0,z.useRef)(null),[d,f]=(0,z.useState)(`idle`),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(0),v=(0,z.useCallback)(()=>{let e=u.current,t=l.current,n=s.current;if(!(!e||!t||!n||n.readyState!==WebSocket.OPEN)){try{e.fit()}catch{return}n.send(JSON.stringify({type:`resize`,cols:t.cols,rows:t.rows}))}},[]);(0,z.useEffect)(()=>{if(!t||n)return;let r=!1,c,d;return(async()=>{f(`connecting`),h(null);let[{Terminal:t},{FitAddon:n}]=await Promise.all([a(()=>import(`./xterm-Da5ppSVt.js`),[]),a(()=>import(`./addon-fit-DIOBYJe3.js`),[])]);if(await a(()=>Promise.resolve({}),__vite__mapDeps([31])),r||!o.current)return;c=new t({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,fontSize:12,scrollback:5e3,theme:i?At:kt});let p=new n;c.loadAddon(p),c.open(o.current),l.current=c,u.current=p;try{p.fit()}catch{}d=new WebSocket(Ot(e)),d.binaryType=`arraybuffer`,s.current=d;let m=new TextDecoder;d.onmessage=e=>{if(typeof e.data!=`string`){c?.write(m.decode(new Uint8Array(e.data)));return}try{let t=JSON.parse(e.data);if(t.type===`ready`){f(`connected`),v(),c?.focus();return}if(t.type===`error`){f(`error`),h(t.message||null);return}t.type===`exit`&&f(`closed`)}catch{}},d.onclose=()=>{r||f(e=>e===`error`||e===`closed`?e:`closed`)},d.onerror=()=>{r||f(`error`)},c.onData(e=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{r=!0,d?.close(),s.current=null,c?.dispose(),l.current=null,u.current=null}},[t,n,g,i,v,e]),(0,z.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=new ResizeObserver(()=>v());return n.observe(e),()=>n.disconnect()},[t,v]);let y=()=>{s.current?.close(),_(e=>e+1)},b=n??(d===`error`?m??r(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):d===`closed`?r(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,B.jsxs)(`div`,{"data-testid":`work-terminal-panel`,"data-status":n?`unavailable`:d,className:`relative flex min-h-0 flex-1 flex-col bg-surface`,children:[!n&&(0,B.jsx)(`div`,{ref:o,"data-testid":`work-terminal-surface`,dir:`ltr`,className:I(`min-h-0 flex-1 overflow-hidden p-2 text-left`,d!==`connected`&&`opacity-60`)}),d===`connecting`&&!n&&(0,B.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,B.jsx)(F,{className:`h-4 w-4 animate-spin`}),r(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,B.jsxs)(`div`,{role:d===`error`?`alert`:void 0,className:`flex flex-col items-center gap-3 border-t border-line bg-surface-raised px-6 py-4 text-center`,children:[(0,B.jsx)(p,{className:`h-6 w-6 text-ink-subtle`}),(0,B.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!n&&(0,B.jsx)(R,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-[#ff7b52] px-3 text-[#3d120c] hover:bg-[#ff7b52]/90`,onClick:y,children:r(`work.terminal.reconnect`,{defaultValue:`Reconnect`})})]})]})}var Mt=e=>{if(!e)return null;if(/^\/api\/work\/previews\/[A-Za-z0-9-]{1,100}\/\d{1,5}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\//.test(e))try{let t=new URL(fe,window.location.origin).origin;return new URL(e,`${t}/`).toString()}catch{return null}return null},Nt=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},Pt=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function Ft({task:e,liveRun:t,files:n,selectedFile:r,loadingFiles:i,actionLoading:a,onLoadFiles:o,onLoadFile:s,onClearSelectedFile:u,onSaveFile:d,onStartPreview:_,onStopPreview:v,onDirtyChange:b,terminal:E}){let{t:k,i18n:A}=c(),j=l(A.language),[M,te]=(0,z.useState)(`files`),[N,ne]=(0,z.useState)(``),[P,re]=(0,z.useState)(``),[ie,ae]=(0,z.useState)(),[se,le]=(0,z.useState)(``),[ue,de]=(0,z.useState)(!1),[fe,L]=(0,z.useState)(!1),pe=(0,z.useRef)(new Map),[he,ge]=(0,z.useState)(()=>new Map),ye=Mt(e.previewUrl),be=t?.runId,xe=t?.error,Se=t?.tools,Ce=(0,z.useMemo)(()=>{let t=new Set(Se?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!be||e.runId!==be)return!0;if(e.kind===`error`&&xe)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[xe,be,Se,e.messages]),we=Ce.length+(Se?.length||0),Te=!!r&&P!==(r?.content??``),V=e.status===`preparing`||e.status===`running`,Ee=(0,z.useRef)(V),H=(0,z.useRef)(0),U=(0,z.useRef)(P),De=(0,z.useRef)(ie),Oe=(0,z.useRef)(r),ke=(0,z.useRef)(e.id),Ae=(0,z.useRef)(o),je=(0,z.useRef)(s),Me=(0,z.useRef)(b),W=(0,z.useRef)(!0),G=r?he.get(r.path):void 0,Ne=(0,z.useMemo)(()=>r&&G!==void 0&&G!==r.content?vt(G,r.content):null,[G,r]),K=(0,z.useMemo)(()=>Ne?yt(Ne):null,[Ne]),Fe=!!(K&&(K.added>0||K.removed>0)),Ie=r?st(r.path):!1,Le=!r||ct(P),q=Ie&&Le;(0,z.useEffect)(()=>{U.current=P,De.current=ie,Oe.current=r,ke.current=e.id,Me.current=b},[ie,P,b,r,e.id]),(0,z.useEffect)(()=>{Ae.current=o,je.current=s},[s,o]),(0,z.useEffect)(()=>(W.current=!0,()=>{W.current=!1,H.current+=1,Me.current(!1)}),[]),(0,z.useEffect)(()=>{if(!Ee.current&&V&&ge(new Map(pe.current)),Ee.current&&!V&&(Ae.current(N),r&&!Te)){let e=++H.current,t=r.path,n=U.current,i=De.current;je.current(t).then(r=>{if(!W.current||e!==H.current||r.path!==t||U.current!==n||De.current!==i)return;pe.current.set(r.path,r.content);let a=he.get(r.path);a!==void 0&&a!==r.content&&L(!0),U.current=r.content,De.current=r.updatedAt??r.modifiedAt,re(r.content),ae(r.updatedAt??r.modifiedAt)}).catch(()=>void 0)}Ee.current=V},[N,Te,r,V,he]);let Re=()=>!Te||window.confirm(k(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),ze=()=>{r&&me(e.id,r.path)},J=async e=>{Re()&&(H.current+=1,ze(),u(),b(!1),L(!1),ne(e),await o(e).catch(()=>void 0))},Be=async t=>{if(!Re())return;let n=++H.current;ze();let r=await s(t).catch(()=>void 0);if(!W.current||!r||n!==H.current)return;pe.current.set(r.path,r.content);let i=he.get(r.path);L(i!==void 0&&i!==r.content);let a=_e(e.id,r.path),o=a?.content??r.content,c=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;U.current=o,De.current=c,re(o),ae(c),b(a!==null&&a.content!==r.content)},Ve=()=>{Re()&&(H.current+=1,ze(),u(),b(!1),L(!1))},He=t=>{r&&(U.current=t,re(t),t===r.content?me(e.id,r.path):ve(e.id,r.path,{content:t,baseUpdatedAt:ie??r.updatedAt??r.modifiedAt}),b(t!==r.content))},Ue=async()=>{if(!r)return;let t=e.id,n=r.path,i=P,a=H.current,o=await d(n,i,ie).catch(()=>!1);if(!W.current||o===!1||a!==H.current||ke.current!==t||Oe.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;pe.current.set(n,typeof o.content==`string`?o.content:i),De.current=s,ae(s);let c=U.current;if(c===i){me(t,n),b(!1);return}ve(t,n,{content:c,baseUpdatedAt:s}),b(!0)},We=async()=>{if(!r||V||ue||!q)return;de(!0);let e=H.current,t=r.path,n=U.current;try{let r=await ut(t,n);if(!W.current||e!==H.current||Oe.current?.path!==t||U.current!==n)return;He(r),D.success(k(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!W.current||e!==H.current||Oe.current?.path!==t||U.current!==n)return;D.error(r instanceof Error?r.message:k(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{W.current&&de(!1)}},Y=[{id:`files`,label:k(`work.workspace.files`,{defaultValue:`Files`}),icon:x,testId:`work-files-tab`},{id:`activity`,label:k(`work.workspace.activity`,{defaultValue:`Activity`}),icon:w,testId:`work-activity-tab`},{id:`git`,label:k(`work.workspace.git`,{defaultValue:`Git`}),icon:m,testId:`work-git-tab`},{id:`terminal`,label:k(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:p,testId:`work-terminal-tab`},{id:`preview`,label:k(`work.workspace.preview`,{defaultValue:`Preview`}),icon:S,testId:`work-preview-tab`}],Ge=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(j?-1:1)+Y.length)%Y.length),e.key===`ArrowLeft`&&(n=(t+(j?1:-1)+Y.length)%Y.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=Y.length-1),n===null)return;e.preventDefault();let r=Y[n];te(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,B.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,B.jsxs)(`div`,{"data-testid":`work-workspace-toolbar`,className:`flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface-raised/75 px-2 backdrop-blur-xl`,children:[(0,B.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":k(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex min-w-0 items-center overflow-x-auto rounded-xl border border-line bg-surface-subtle p-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:Y.map((e,t)=>{let n=e.icon;return(0,B.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":M===e.id,"aria-controls":M===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:M===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>te(e.id),onKeyDown:e=>Ge(e,t),className:I(`flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow]`,M===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,B.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&we>0&&(0,B.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:we})]},e.id)})}),M===`files`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,B.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink sm:hidden`,onClick:Ve,"aria-label":k(`work.files.back`,{defaultValue:`Back to files`}),children:(0,B.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,B.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${N?`/${N}`:``}`,children:[r?.path??`/workspace${N?`/${N}`:``}`,Te&&` •`]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,B.jsx)(`button`,{type:`button`,disabled:!N,onClick:()=>void J(Nt(N)),className:I(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!r&&`inline-flex`),"aria-label":k(`work.files.up`,{defaultValue:`Parent folder`}),title:k(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,B.jsx)(oe,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,B.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(N).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":k(`common.refresh`,{defaultValue:`Refresh`}),title:k(`common.refresh`,{defaultValue:`Refresh`}),children:(0,B.jsx)(C,{className:I(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&Fe&&K&&(0,B.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":fe,onClick:()=>L(e=>!e),title:k(`work.files.changesSince`,{defaultValue:`What changed since the last turn`}),className:I(`inline-flex h-8 items-center gap-1.5 rounded-lg border px-2 text-[11px] font-medium transition-colors`,fe?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,B.jsx)(T,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:k(`work.files.changes`,{defaultValue:`Changes`})}),(0,B.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,B.jsxs)(`span`,{className:fe?void 0:`text-[rgb(46,164,79)]`,children:[`+`,K.added]}),` `,(0,B.jsxs)(`span`,{className:fe?void 0:`text-[rgb(255,61,129)]`,children:[`−`,K.removed]})]})]}),r&&!fe&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(R,{"data-testid":`work-format-file-button`,size:`sm`,variant:`ghost`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:V||ue||!q,onClick:()=>void We(),"aria-busy":ue||void 0,title:q?k(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Ie?k(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):k(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":k(`work.files.format`,{defaultValue:`Format file`}),children:[ue?(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.files.format`,{defaultValue:`Format`})})]}),(0,B.jsxs)(R,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:!Te||V||ue||a,onClick:()=>void Ue(),"aria-busy":a||void 0,title:k(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":k(`common.save`),children:[a?(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(g,{className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`common.save`)})]})]})]})]}),(M===`activity`||M===`git`)&&(0,B.jsx)(`div`,{className:`min-w-0 flex-1`}),M===`terminal`&&(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,B.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),V&&(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:k(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),M===`preview`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{dir:`auto`,value:se,onChange:e=>le(e.target.value),placeholder:k(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":k(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,B.jsxs)(R,{"data-testid":`work-stop-preview-button`,variant:`danger`,size:`sm`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void v(),"aria-busy":a||void 0,"aria-label":k(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(ce,{className:`h-3.5 w-3.5 fill-current`}),(0,B.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,B.jsxs)(R,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void _(se.trim()||void 0),"aria-busy":a||void 0,"aria-label":k(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,B.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(O,{className:`h-3.5 w-3.5 fill-current`}),(0,B.jsx)(`span`,{className:`hidden 2xl:inline`,children:k(`work.preview.start`,{defaultValue:`Start preview`})})]}),ye&&(0,B.jsx)(`a`,{href:ye,target:`_blank`,rel:`noopener noreferrer`,"aria-label":k(`work.preview.open`,{defaultValue:`Open`}),title:k(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,B.jsx)(f,{className:`h-3.5 w-3.5`})})]})]})]}),M===`files`&&(0,B.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,B.jsx)(`div`,{className:I(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,r?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,B.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,B.jsx)(F,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,B.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:k(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...n].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,B.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?J(e.path):Be(e.path)},className:I(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-xs hover:bg-surface-subtle`,r?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,B.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,B.jsx)(y,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,B.jsx)(`div`,{className:I(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r&&fe&&Ne?(0,B.jsx)(St,{lines:Ne,ariaLabel:k(`work.files.diffLabel`,{path:r.path,defaultValue:`Changes since the last turn: {{path}}`})}):r?(0,B.jsx)(ht,{path:r.path,value:P,ariaLabel:k(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:He,onSaveShortcut:()=>{Te&&!V&&!a&&!ue&&Ue()},onFormatShortcut:()=>void We(),disabled:V||ue}):(0,B.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,B.jsx)(y,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),k(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),M===`activity`&&(0,B.jsxs)(`div`,{id:`work-workspace-panel-activity`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-activity`,className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[t&&(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(Pe,{run:t,variant:`activity`})}),Ce.length===0&&!t?(0,B.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,B.jsx)(p,{className:`mb-3 h-7 w-7 text-ink-subtle`}),k(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,B.jsx)(`div`,{className:`space-y-2`,children:Ce.map(e=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:Pt(e,k(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:k(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:k(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:k(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:k(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:k(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,B.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:e.content})]},e.id))})]}),M===`git`&&(0,B.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,B.jsx)(Tt,{taskId:e.id,mutationsDisabled:V||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:V?k(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?k(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),M===`terminal`&&(0,B.jsx)(`div`,{id:`work-workspace-panel-terminal`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-terminal`,className:`flex min-h-0 flex-1 flex-col`,children:(0,B.jsx)(jt,{taskId:e.id,active:M===`terminal`,disabledReason:E&&!E.available?E.reason??k(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):V?k(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),M===`preview`&&(0,B.jsx)(`div`,{id:`work-workspace-panel-preview`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-preview`,className:`flex min-h-0 flex-1 flex-col`,children:e.previewStatus===`starting`?(0,B.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,B.jsx)(F,{className:`h-4 w-4 animate-spin`}),k(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):ye&&e.previewStatus===`running`?(0,B.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:k(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:ye,sandbox:`allow-scripts allow-forms allow-modals allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 flex-1 border-0 bg-white`}):(0,B.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,B.jsx)(S,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?k(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):k(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var It=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},Lt=(e,t)=>e instanceof Error&&e.message?e.message:t,Rt=(e,t)=>new Promise(n=>{if(t.aborted){n();return}let r,i=()=>{r!==void 0&&window.clearTimeout(r),t.removeEventListener(`abort`,i),n()};r=window.setTimeout(i,e),t.addEventListener(`abort`,i,{once:!0})});function zt(){let{t:e}=c(),t=s(),n=r(),{taskId:a}=i(),l=ye(e=>e.preferences),d=ye(e=>e.setPreferences),f=ge(e=>e.user),p=f?.id??null,[m,h]=(0,z.useState)(!1),g=L(e=>e.models),_=L(e=>e.selectedModel),v=L(e=>e.selectedProviderType),y=L(e=>e.selectedProviderId),b=L(e=>e.loadModels),{capabilities:x,tasks:C,selectedTask:w,files:T,selectedFile:E,liveRuns:O,loadingTask:A,loadingOlderMessages:j,loadingFiles:M,actionLoading:ee,error:P,loadCapabilities:re,loadTasks:F,selectTask:oe,loadTask:ce,loadOlderMessages:le,createTask:fe,updateTask:_e,deleteTask:ve,startRun:R,cancelRun:be,beginLiveRun:Se,applyRunEvents:Ce,setLiveRunConnection:V,clearLiveRun:Ee,loadFiles:H,loadFile:De,clearSelectedFile:Oe,saveFile:ke,startPreview:Ae,stopPreview:je,clearError:Me}=he(),W=(0,z.useMemo)(()=>g.filter(e=>!e.isPersona&&!e.isAgent&&It(e.name)&&(!e.isPlugin||!!e.pluginId)),[g]),G=(0,z.useMemo)(()=>W.flatMap(e=>{if(e.isPlugin&&!e.pluginId)return[];let t=e.isPlugin?`plugin`:`ollama`,n=e.isPlugin?e.pluginId:void 0,r=e.name.trim().toLowerCase(),i={model:e.name,providerType:t,providerId:n};return[{...i,key:we(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[W]),[Ne,Pe]=(0,z.useState)(``),[K,Fe]=(0,z.useState)({locationKey:t.key,value:`conversation`}),Ie=K.locationKey===t.key?K.value:`conversation`,Le=e=>Fe({locationKey:t.key,value:e}),[q,Re]=(0,z.useState)(!1),[J,Be]=(0,z.useState)(``),Ve=x?.hostWorkspaces?.enabled===!0,He=x?.hostWorkspaces?.roots??[],[Ue,We]=(0,z.useState)({taskId:null,open:!1}),Y=Ue.open&&Ue.taskId===w?.id,Ge=(0,z.useRef)(null),Ke=(0,z.useRef)(null),qe=(0,z.useRef)(null),Je=(0,z.useCallback)((e=!1)=>{We(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>Ke.current?.focus())},[]);(0,z.useEffect)(()=>{if(!Y)return;let e=window.requestAnimationFrame(()=>{qe.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!Ge.current?.contains(e.target)&&Je()},n=e=>{e.key===`Escape`&&(e.preventDefault(),Je(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[Je,Y]);let Ye=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Je(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...qe.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()};(0,z.useEffect)(()=>{re(),F()},[re,F]),(0,z.useEffect)(()=>{if(!a){oe(null);return}oe(a),ce(a).catch(()=>void 0),H(a,``).catch(()=>void 0)},[a,H,ce,oe]);let Xe=G.find(e=>e.key===Ne)||G.find(e=>e.model===_&&(v===`plugin`?e.providerType===`plugin`&&e.providerId===y:e.providerType===`ollama`))||G[0],Ze=a?C.find(e=>e.id===a):void 0,X=Ze?.status??w?.status,$e=w?.activeRun??Ze?.activeRun??null,Z=$e?.id,et=$e?.status===`queued`||$e?.status===`preparing`||$e?.status===`running`,tt=a&&O[a]?.runId===Z?O[a]:void 0,nt=X===`preparing`||X===`running`?1e3:4e3;(0,z.useEffect)(()=>{let e,t=!1,n=async()=>{await F(!0),t||(e=setTimeout(n,nt))};return e=setTimeout(n,nt),()=>{t=!0,e&&clearTimeout(e)}},[F,nt]);let rt=(0,z.useRef)(null);(0,z.useEffect)(()=>{if(!a||!X){rt.current=null;return}let e=rt.current;rt.current={taskId:a,status:X},e?.taskId===a&&(e.status===`preparing`||e.status===`running`)&&X!==`preparing`&&X!==`running`&&(ce(a,!0).catch(()=>void 0),H(a,``).catch(()=>void 0))},[H,ce,X,a]),(0,z.useEffect)(()=>{if(!a||!Z||!et)return;let e=new AbortController,t=!1,n=0,r=he.getState().liveRuns[a]?.runId===Z&&he.getState().liveRuns[a]?.lastEventId||0,i=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],Ce(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),r=Math.max(r,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){i=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return Se(a,Z,$e?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!i;){V(a,Z,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await de.streamRunEvents({taskId:a,runId:Z,after:r,signal:e.signal,onEvent:l}),c(),i||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(r){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,V(a,Z,n>=3?`error`:`reconnecting`,n>=3?Lt(r,`Live updates are reconnecting in the background.`):void 0),await Rt(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!i||e.signal.aborted)){V(a,Z,`closed`);try{await Promise.all([ce(a,!0),H(a,``),F(!0)])}catch{}finally{Ee(a,Z)}}})(),()=>{t=!0,e.abort(),c()}},[Ce,Se,Ee,H,ce,F,$e?.startedAt,et,Z,V,a]),(0,z.useEffect)(()=>{if(!q)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[q]);let it=(0,z.useCallback)(()=>!q||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,q]),at=(0,z.useCallback)(()=>!q||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,q]),ot=()=>{w&&E&&me(w.id,E.path)},st=o(({currentLocation:e,nextLocation:t})=>{let n=t.state;return q&&n?.deletedWorkTaskId!==a&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,z.useEffect)(()=>{if(st.state!==`blocked`)return;if(!at()){st.reset();return}let e=st.proceed,t=window.setTimeout(()=>{Re(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[at,st]);let ct=()=>{Me(),Le(`conversation`),n(`/work`)},Q=async t=>{if(w&&!it())return!1;w&&q&&(ot(),Oe(),Re(!1));try{if(w)await R(w.id,{message:t,model:w.model,providerType:w.providerType,providerId:w.providerId||void 0});else{if(!Xe)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await fe({message:t,model:Xe.model,providerType:Xe.providerType,providerId:Xe.providerId,networkEnabled:!0,...Ve&&J.trim()?{hostPath:J.trim()}:{}});n(`/work/${r.id}`)}return!0}catch(t){return D.error(Lt(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},lt=async t=>{let n=xt.find(e=>e.key===t);if(n){if(!w){Pe(t);return}try{await _e(w.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){D.error(Lt(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},ut=async()=>{if(w)try{await be(w.id),D.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){D.error(Lt(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},dt=async t=>{let r=C.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:r?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let i=a===t&&q;i&&Re(!1);try{await ve(t),pe(t),a===t&&n(`/work`)}catch(t){i&&Re(!0),D.error(Lt(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},ft=async t=>{if(!w)return!1;let n=t.trim();if(!n||n===w.title)return!!n;try{return await _e(w.id,{title:n}),!0}catch(t){return D.error(Lt(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},pt=async(e,t,n)=>{try{return await e(),n&&D.success(n),!0}catch(e){return D.error(Lt(e,t)),!1}},mt=async(t,n,r)=>{if(!w)return!1;let i=w.id;try{let a=await ke(i,t,n,r);return he.getState().selectedTaskId===i&&D.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return he.getState().selectedTaskId===i&&D.error(Lt(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},ht=x?.available===!1,gt=x?.pluginAvailable?x.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),_t=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),vt=w?Te(w):!1,$=w?{model:w.model,providerType:w.providerType,providerId:w.providerId||void 0}:void 0,yt=$?we($):Xe?.key||``,bt=$&&!G.some(e=>e.key===yt)?{...$,key:yt,label:`${$.model} · ${$.providerType===`plugin`?$.providerId||`plugin`:`Ollama`}`,remote:$.providerType===`plugin`||$.model.toLowerCase().endsWith(`:cloud`)||$.model.toLowerCase().endsWith(`-cloud`)}:void 0,xt=bt?[bt,...G]:G,St=xe[w?.status??`idle`],Ct=e(St.labelKey,{defaultValue:St.label}),wt=async()=>{if(l.workRemoteProviderDisclosureDismissed||m)return!1;let t=p;h(!0);try{let n=await ue.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(ge.getState().user?.id??null)===t&&(d({workRemoteProviderDisclosureDismissed:!0}),!0)}catch{return D.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{h(!1)}};return(0,B.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,B.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,B.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3 border-b border-line bg-surface/55 px-3 backdrop-blur-xl md:px-4`,children:[w?(0,B.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:w.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=w.title;return}ft(t.value).then(e=>{e||(t.value=w.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=w.title,e.currentTarget.blur())},className:`min-w-0 max-w-sm flex-1 truncate rounded-lg border border-transparent bg-transparent px-2 py-1 text-sm font-semibold text-ink outline-none hover:border-line focus:border-primary-500 focus:bg-surface`,"aria-label":e(`work.tasks.rename`,{defaultValue:`Task title`})},`${w.id}:${w.title}`):(0,B.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,B.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),w?.hostPath&&(0,B.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:w.hostPath,className:`hidden h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 font-mono text-[11px] text-ink-muted sm:inline-flex`,children:[(0,B.jsx)(N,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:w.hostPath})]}),w&&(0,B.jsxs)(`span`,{"data-testid":`work-compact-status`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2 text-[11px] font-medium text-ink-muted xl:hidden`,"aria-label":e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),title:e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:I(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),(0,B.jsx)(`span`,{className:`hidden md:inline`,children:Ct})]}),w&&(0,B.jsxs)(`div`,{className:`ms-auto inline-flex h-9 shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-1 shadow-subtle xl:hidden`,role:`group`,"aria-label":e(`work.mobile.surface`,{defaultValue:`Task surface`}),children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>Le(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Ie===`conversation`,className:I(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,B.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>Le(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Ie===`workspace`,className:I(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,B.jsx)(S,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,B.jsxs)(`div`,{className:I(`ms-auto hidden min-w-0 items-center gap-2`,w?`xl:flex`:`sm:flex`),children:[w&&(0,B.jsxs)(`span`,{"data-testid":`work-status`,className:`inline-flex h-7 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:I(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),Ct]}),(0,B.jsxs)(`span`,{"data-testid":`work-runtime-status`,className:I(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium`,ht?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:ht?x?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):x?.image?`${gt} · ${x.image}`:gt,children:[(0,B.jsx)(ie,{className:`h-3.5 w-3.5`}),ht?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):_t]}),w&&(0,B.jsxs)(`span`,{className:`hidden h-7 max-w-44 items-center gap-1.5 truncate rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted md:inline-flex`,children:[(0,B.jsx)(se,{className:`h-3.5 w-3.5 shrink-0`}),(0,B.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:w.model})]})]}),w&&(0,B.jsxs)(`div`,{ref:Ge,className:`relative shrink-0`,children:[(0,B.jsx)(`button`,{ref:Ke,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>We(e=>({taskId:w.id,open:e.taskId!==w.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),We({taskId:w.id,open:!0}))},className:`inline-flex h-9 w-9 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink`,"aria-label":e(`work.tasks.actions`,{defaultValue:`Task actions`}),"aria-haspopup":`menu`,"aria-expanded":Y,"aria-controls":Y?`work-task-actions-menu`:void 0,children:(0,B.jsx)(k,{className:`h-4 w-4`})}),Y&&(0,B.jsx)(`div`,{ref:qe,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:Ye,className:`absolute end-0 top-10 z-40 min-w-44 rounded-xl border border-line bg-surface-overlay p-1.5 shadow-overlay`,children:(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{Je(!0),dt(w.id)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-start text-xs font-medium text-error-600 transition-colors hover:bg-error-500/10`,children:[(0,B.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(ht||P)&&(0,B.jsxs)(`div`,{className:I(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,ht?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,B.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,B.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:ht?x?.reason||e(`work.runtime.reason`,{defaultValue:`Docker and an available Ollama or plugin model provider are required.`}):P}),P&&!ht&&(0,B.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:Me,"aria-label":e(`common.close`),children:`×`})]}),a?w?(0,B.jsx)(Qe,{userId:p,mobileSurface:Ie,conversation:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ze,{task:w,user:f,liveRun:tt,loading:A,loadingOlder:j,onLoadOlder:()=>le(w.id)}),(0,B.jsx)(U,{models:xt,selectorModels:W,modelKey:yt,running:vt,loading:ee,disabled:ht,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:m,onModelChange:lt,onDismissRemoteDisclosure:wt,onModelsRefresh:b,onSubmit:Q,onCancel:ut},w.id)]}),workspace:(0,B.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,B.jsx)(Ft,{task:w,liveRun:tt,files:T,selectedFile:E,loadingFiles:M,actionLoading:ee,onLoadFiles:e=>H(w.id,e),onLoadFile:e=>De(w.id,e),onClearSelectedFile:Oe,onSaveFile:mt,onStartPreview:t=>pt(()=>Ae(w.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>pt(()=>je(w.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Re,terminal:x?.terminal},w.id)})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:A?(0,B.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(u,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,B.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,B.jsxs)(`button`,{type:`button`,onClick:ct,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,B.jsx)(te,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,B.jsxs)(`section`,{"data-testid":`work-landing`,className:`mx-auto flex min-h-full w-full max-w-3xl flex-col items-center justify-center px-4 py-20 sm:px-8 sm:py-24`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,B.jsx)(`h2`,{className:`max-w-3xl text-balance text-[clamp(2.65rem,7vw,5.25rem)] font-light leading-[0.98] tracking-[-0.055em] text-ink rtl:leading-[1.12] rtl:tracking-normal`,children:e(`work.landing.title`,{defaultValue:`Start a new Work task`})}),(0,B.jsx)(`p`,{className:`mt-4 max-w-xl text-balance text-base leading-relaxed text-ink-muted sm:text-lg`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),Ve&&(0,B.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,B.jsx)(`label`,{htmlFor:`work-host-path`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.hostWorkspace.label`,{defaultValue:`Workspace folder (optional)`})}),(0,B.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:J,onChange:e=>Be(e.target.value),spellCheck:!1,placeholder:He[0]?`${He[0]}/my-project`:`/path/to/folder`,className:`w-full rounded-xl border border-line bg-surface px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-subtle focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`}),(0,B.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:J.trim()?e(`work.hostWorkspace.warning`,{defaultValue:`The task can read and write this folder directly. Leave blank to use an isolated workspace instead.`}):e(`work.hostWorkspace.hint`,{defaultValue:`Leave blank for an isolated workspace, or point the task at a folder on this machine.`})})]}),(0,B.jsx)(U,{variant:`landing`,models:G,selectorModels:W,modelKey:Xe?.key||``,running:!1,loading:ee,disabled:ht,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:m,onModelChange:lt,onDismissRemoteDisclosure:wt,onModelsRefresh:b,onSubmit:Q,onCancel:ut}),(0,B.jsxs)(`div`,{"data-testid":`work-workspace-note`,role:`note`,className:`mt-4 flex max-w-2xl flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[10px] leading-relaxed text-ink-subtle`,children:[(0,B.jsx)(ie,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,B.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})})]})})}export{zt as default};