libre-webui 0.21.1 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/dist/services/ollamaService.d.ts +11 -1
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +66 -0
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-CN7wpzUO.js +26 -0
- package/frontend/dist/assets/index-Dqkx5o2y.css +1 -0
- package/frontend/dist/index.html +23 -16
- package/frontend/dist/js/ArtifactContainer-C_UdeK4k.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-DQBTKgzC.js → ArtifactDemoPage-D3AuvuR5.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-CpblpEf4.js → ArtifactSandboxFrame-BiXl9iGD.js} +2 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-CvgS3sfQ.js +1 -0
- package/frontend/dist/js/{Button-X9TT9gTD.js → Button-DcBM7gdH.js} +1 -1
- package/frontend/dist/js/ChatPage-DBEi-FSO.js +16 -0
- package/frontend/dist/js/{FirstTimeSetup-C3ldEPmK.js → FirstTimeSetup-B9742i3H.js} +1 -1
- package/frontend/dist/js/{GalleryPage-DrrOhli8.js → GalleryPage-BL0x_xl7.js} +1 -1
- package/frontend/dist/js/{HomePage-D21Haon_.js → HomePage-Ukn2Y-BG.js} +1 -1
- package/frontend/dist/js/LibreClawPage-Ds6pqEyk.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-D-NxeVvV.js → ModelManagerModals-BBNg2fxs.js} +1 -1
- package/frontend/dist/js/ModelSelector-CJfJYwxh.js +1 -0
- package/frontend/dist/js/ModelsPage-CDPJM-LA.js +2 -0
- package/frontend/dist/js/{NotesPage-D10aWpVj.js → NotesPage-DJ-_MSI1.js} +1 -1
- package/frontend/dist/js/{PersonasPage-BvCPzwx2.js → PersonasPage-CbQVv9OM.js} +2 -2
- package/frontend/dist/js/{PluginUsagePage-B9YgizW8.js → PluginUsagePage-D69rQvFl.js} +1 -1
- package/frontend/dist/js/{RichMessageContent-2L-mHp9Q.js → RichMessageContent-DfuCu6PB.js} +1 -1
- package/frontend/dist/js/SettingsModal-D87lWSx4.js +1 -0
- package/frontend/dist/js/{SettingsToggle-bZ5W4CCf.js → SettingsToggle-Uz2jvV64.js} +1 -1
- package/frontend/dist/js/{SystemPage-CKnhy0Fr.js → SystemPage-CIBDZTWB.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-B3gA_Zx8.js → UserManagementPage-DzMnFKDG.js} +1 -1
- package/frontend/dist/js/WorkPage-D84JNdjS.js +6 -0
- package/frontend/dist/js/{api-DjQINB7B.js → api-DhmVEJr2.js} +1 -1
- package/frontend/dist/js/{appStore-CIV0DhiE.js → appStore-BsqeY2tS.js} +2 -2
- package/frontend/dist/js/ar-BgCHB9_9.js +2 -0
- package/frontend/dist/js/{authStore-pmXfK_qt.js → authStore-DanfaPdm.js} +3 -3
- package/frontend/dist/js/{bn-C7CHC42H.js → bn-Cr8_opuR.js} +2 -2
- package/frontend/dist/js/chatStore-C25ywAXQ.js +3 -0
- package/frontend/dist/js/{config-DF-g5uwS.js → config-CV8L89A5.js} +1 -1
- package/frontend/dist/js/{cs-zGEtwQn_.js → cs-Bb9gXpfH.js} +2 -2
- package/frontend/dist/js/{da-B-0sHNTu.js → da-JfdGHjAw.js} +2 -2
- package/frontend/dist/js/{de-UZNE6t2h.js → de-CczkCOVx.js} +2 -2
- package/frontend/dist/js/{es-CPLnFYIw.js → es-n_0cjhn7.js} +2 -2
- package/frontend/dist/js/{estree-livw6QLA.js → estree-Lx6fK8Ug.js} +1 -1
- package/frontend/dist/js/{fr-Br1o0WVz.js → fr-Pno128cn.js} +2 -2
- package/frontend/dist/js/{hi-BcEvNEpb.js → hi-DBCdcL4p.js} +2 -2
- package/frontend/dist/js/{html-CWlKlrlk.js → html-Dx5reqmV.js} +1 -1
- package/frontend/dist/js/{id-C30L2DoT.js → id-85QDk-wA.js} +2 -2
- package/frontend/dist/js/{is-BAEhfi5Z.js → is-9MuKmBft.js} +2 -2
- package/frontend/dist/js/{it-HWnfQXZY.js → it-C5mz9I3H.js} +2 -2
- package/frontend/dist/js/ja-Cu90QTBd.js +2 -0
- package/frontend/dist/js/{ko-agDQ__KP.js → ko-CSdgcMgq.js} +2 -2
- package/frontend/dist/js/{markdown-BM75gisb.js → markdown-Bd5G8zQB.js} +1 -1
- package/frontend/dist/js/{messageCodeStyles-DxPb6SKm.js → messageCodeStyles-CUWSpffv.js} +2 -2
- package/frontend/dist/js/{ms-aNRa2QX7.js → ms-IQMi6HBU.js} +2 -2
- package/frontend/dist/js/{nl-BtkiDUn-.js → nl-BwpdTgvn.js} +2 -2
- package/frontend/dist/js/{pl-SEO0lBnX.js → pl-zq8ctKrQ.js} +2 -2
- package/frontend/dist/js/{pt-BYtjmvq1.js → pt-BIQu7dBu.js} +2 -2
- package/frontend/dist/js/{ru-B-ynj2hU.js → ru-BT5-Z0F9.js} +2 -2
- package/frontend/dist/js/{standalone-h0KNQ5yy.js → standalone-DLNXiOUi.js} +1 -1
- package/frontend/dist/js/{sv-CliKR15U.js → sv-B1_q6-Uj.js} +2 -2
- package/frontend/dist/js/{th-DJQyDr9J.js → th-BiLLwq0A.js} +2 -2
- package/frontend/dist/js/{tr-BBGKZ1la.js → tr-NZbkkeKs.js} +2 -2
- package/frontend/dist/js/{typescript-CPI0lY4n.js → typescript-YKxslwSt.js} +1 -1
- package/frontend/dist/js/{ui-ovAoLjDQ.js → ui-Dw6jDKxN.js} +2 -2
- package/frontend/dist/js/{uk-C1GcFWxE.js → uk-CGu1pg-F.js} +2 -2
- package/frontend/dist/js/useTranslation-t1quV8ce.js +1 -0
- package/frontend/dist/js/utils-iKndEgla.js +1 -0
- package/frontend/dist/js/{vi-CIxgICOQ.js → vi-ClvH5JZg.js} +2 -2
- package/frontend/dist/js/{workApi-CCHIEahA.js → workApi-LrQmhNxb.js} +2 -2
- package/frontend/dist/js/{zh-Cm7vsQ9s.js → zh-Jgjy3uAG.js} +2 -2
- package/package.json +3 -20
- package/electron/main.js +0 -560
- package/frontend/dist/assets/index-BN-WAt2j.js +0 -2
- package/frontend/dist/assets/index-D7m1zWWg.css +0 -1
- package/frontend/dist/js/ArtifactContainer-BD20LheX.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-BVgr8Cv6.js +0 -1
- package/frontend/dist/js/ChatPage-D2EWlzO4.js +0 -16
- package/frontend/dist/js/LibreClawPage-CEf9ws8z.js +0 -1
- package/frontend/dist/js/ModelSelector-whWBlN-S.js +0 -1
- package/frontend/dist/js/ModelsPage-CL2t9qNT.js +0 -2
- package/frontend/dist/js/SettingsModal-BK05P_rU.js +0 -1
- package/frontend/dist/js/WorkPage-Bj3UVrmb.js +0 -5
- package/frontend/dist/js/ar-Bm27TCMQ.js +0 -2
- package/frontend/dist/js/chatStore-D76rdaV6.js +0 -2
- package/frontend/dist/js/i18n-DJTg6xWw.js +0 -2
- package/frontend/dist/js/ja-Dvux1mon.js +0 -2
- package/frontend/dist/js/useTranslation-CdeLZqSW.js +0 -1
- package/frontend/dist/js/utils-BhpNrGnR.js +0 -1
|
@@ -1,16 +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{n as r}from"./react-vendor-DPNXrO-8.js";import{d as i,f as a,u as o}from"./router-vendor-Ca9zqOqT.js";import{t as s}from"./useTranslation-CdeLZqSW.js";import{i as c}from"./i18n-DJTg6xWw.js";import{A as l,B as u,D as d,En as f,Et as p,F as m,Ft as h,G as g,Jt as _,Kt as v,N as y,Nt as b,P as x,R as S,St as C,T as w,Tn as T,Tt as E,Wt as D,Yt as O,_n as k,a as ee,bn as A,c as j,d as M,fn as N,g as P,h as te,ht as F,in as ne,j as I,lt as L,mt as R,n as z,nt as re,o as ie,on as ae,pn as oe,q as se,r as ce,rn as le,rt as B,sn as ue,t as V,tt as de,v as fe,x as pe}from"./ui-vendor-xUzKqAXI.js";import{i as me,t as H}from"./logger-DSXjF4ye.js";import{S as U,a as W,b as G,d as K,g as he,i as ge,l as _e,n as ve,p as ye,u as q,v as be}from"./api-DjQINB7B.js";import{a as xe,n as Se,r as Ce,t as J}from"./utils-BhpNrGnR.js";import{a as we,c as Te,i as Ee,l as De,n as Oe,r as ke,t as Y}from"./chatStore-D76rdaV6.js";import{n as Ae,r as X}from"./authStore-pmXfK_qt.js";import{t as je}from"./appStore-CIV0DhiE.js";import{i as Me,r as Ne,t as Pe}from"./welcomePrompts-to5mv_gx.js";import{l as Fe}from"./messageCodeStyles-DxPb6SKm.js";import{t as Z}from"./Button-X9TT9gTD.js";import{d as Ie,f as Le,l as Re}from"./ui-ovAoLjDQ.js";import{l as ze}from"../assets/index-BN-WAt2j.js";import{c as Be,s as Ve}from"./ArtifactSandboxFrame-CpblpEf4.js";import{t as He}from"./ArtifactContainer-BD20LheX.js";import{t as Ue}from"./ModelSelector-whWBlN-S.js";var We=r(),Q=e(n(),1),$=t(),Ge=({statistics:e,className:t=``})=>{let[n,r]=(0,Q.useState)(!1),{t:i}=s(),a=e=>{if(e==null)return`N/A`;let t=e/1e6;return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(2)}s`},o=e=>e?`${e.toFixed(1)} t/s`:`N/A`,c=e.prompt_eval_count||0,l=e.eval_count||0,u=c+l,d=a(e.total_duration),f=o(e.tokens_per_second);return(0,$.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-dark-500 mt-2 ${t}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 mb-1`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-gray-600 dark:text-dark-600`,children:[(0,$.jsx)(R,{size:12,className:`text-primary-500`}),l,` tokens`]}),(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:f}),(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:d}),e.model&&(0,$.jsx)(`span`,{className:`text-gray-400 dark:text-dark-400 bg-gray-100 dark:bg-dark-200 px-2 py-0.5 rounded-full truncate max-w-32 sm:max-w-48`,title:e.model,children:e.model})]}),(0,$.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-1 text-gray-400 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-600 transition-colors`,children:[n?(0,$.jsx)(ae,{size:12}):(0,$.jsx)(ne,{size:12,className:`rtl:rotate-180`}),(0,$.jsx)(`span`,{children:i(`generationStats.details`)})]}),n&&(0,$.jsxs)(`div`,{className:`mt-2 p-3 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg text-xs space-y-2`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptTokens`)}),` `,c]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedTokens`)}),` `,l]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTokens`)}),` `,u]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.speed`)}),` `,f]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptEval`)}),` `,a(e.prompt_eval_duration)]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generation`)}),` `,a(e.eval_duration)]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.modelLoad`)}),` `,a(e.load_duration)]}),(0,$.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTime`)}),` `,d]})]}),e.created_at&&(0,$.jsxs)(`div`,{className:`pt-2 border-t border-gray-200 dark:border-dark-300 text-gray-600 dark:text-dark-600`,children:[(0,$.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedAt`)}),` `,new Date(e.created_at).toLocaleTimeString()]})]})]})},Ke=H(`components:ttsbutton`),qe=null,Je=null,Ye=0,Xe=3e5;async function Ze(e=!1){let t=Date.now();return!e&&qe!==null&&t-Ye<Xe?qe:Je||(Je=(async()=>{try{let e=await W.getModels();return e.success&&e.data&&e.data.length>0?(qe=e.data,Ye=t,e.data):(qe=[],Ye=t,[])}catch{return qe=[],Ye=t,[]}finally{Je=null}})(),Je)}function Qe(e){return e.split(/(?<=[.!?]["']?\s)|(?<=[.!?]["']?$)/).map(e=>e.trim()).filter(e=>e.length>0)}var $e=({text:e,className:t,size:n=`sm`})=>{let{t:r}=s(),{preferences:i}=je(),[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)([]),y=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{let e=!0;return(async()=>{let t=await Ze(),n=ve(t,i.ttsSettings?.model,i.ttsSettings?.pluginId);i.ttsSettings?.model&&!n&&(t=await Ze(!0)),e&&(p(t),h(t.length>0))})(),()=>{e=!1}},[i.ttsSettings?.model,i.ttsSettings?.pluginId]);let b=(0,Q.useCallback)(async(e,t,n,i,a,o)=>{let s=await W.generateBase64({model:t,pluginId:n,input:e,voice:i,speed:a,response_format:o});if(!s.success||!s.data?.audio)throw Error(s.message||r(`ttsButton.generateFailed`));let c=`data:${s.data.mimeType};base64,${s.data.audio}`,l=new Audio(c);return g.current=l,new Promise((e,t)=>{l.onended=()=>{g.current=null,e()},l.onerror=()=>{g.current=null,t(Error(r(`ttsButton.playbackFailed`)))},l.play().catch(t)})},[r]),x=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{v.current=e,y.current=0,_.current=!1;let o=null,s=async e=>{try{let o=await W.generateBase64({model:t,pluginId:n,input:e,voice:r,speed:i,response_format:a});return!o.success||!o.data?.audio?null:{audioUrl:`data:${o.data.mimeType};base64,${o.data.audio}`,mimeType:o.data.mimeType}}catch{return null}};e.length>0&&(o=s(e[0]));for(let t=0;t<e.length&&!_.current;t++){y.current=t;try{let n=await o;if(_.current)break;if(o=t+1<e.length?s(e[t+1]):null,!n){Ke.warn(`Failed to generate audio for sentence ${t+1}, skipping`);continue}let r=new Audio(n.audioUrl);g.current=r,await new Promise((e,t)=>{r.onended=()=>{g.current=null,e()},r.onerror=()=>{g.current=null,e()},r.play().catch(()=>{e()})})}catch(e){Ke.error(`Error playing sentence ${t+1}:`,e)}}},[]),S=(0,Q.useCallback)(()=>{_.current=!0,g.current&&(g.current.pause(),g.current.currentTime=0,g.current=null),o(!1),l(!1)},[]),C=async()=>{if(!c){if(a){S();return}l(!0),d(null),_.current=!1;try{let t=i.ttsSettings,n=ge(f,t?.model,t?.pluginId),a=n?.model||t?.model||`tts-1`,s=n?.plugin||t?.pluginId,c=n?.model===t?.model&&(!t?.pluginId||n?.plugin===t.pluginId)?t?.voice||n?.config?.default_voice||`alloy`:n?.config?.default_voice||`alloy`,u=t?.speed||1,p=n?.config?.default_format;if(t?.streamSentences){let t=Qe(e);if(t.length===0)throw Error(r(`ttsButton.generateFailed`));l(!1),o(!0),await x(t,a,s,c,u,p),_.current||o(!1)}else await b(e,a,s,c,u,p),l(!1),o(!0),g.current&&(g.current.onended=()=>{o(!1),g.current=null},g.current.onerror=()=>{d(r(`ttsButton.playbackFailed`)),o(!1),g.current=null})}catch(e){let t=e instanceof Error?e.message:r(`ttsButton.generateFailed`);d(t),Ke.error(`TTS error:`,e),o(!1),l(!1)}}};if((0,Q.useEffect)(()=>()=>{_.current=!0,g.current&&(g.current.pause(),g.current=null)},[]),m===!1||m===null)return null;let w={sm:`h-6 w-6 p-1`,md:`h-8 w-8 p-1.5`,lg:`h-10 w-10 p-2`},T={sm:`h-3.5 w-3.5`,md:`h-4 w-4`,lg:`h-5 w-5`};return(0,$.jsx)(`button`,{onClick:C,disabled:c||!e,title:u||r(a?`ttsButton.stopSpeaking`:c?`ttsButton.generatingSpeech`:`ttsButton.readAloud`),className:J(`rounded-full transition-all duration-200`,`hover:bg-gray-100 dark:hover:bg-dark-200`,`focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-1`,`disabled:opacity-50 disabled:cursor-not-allowed`,u?`text-red-500 dark:text-red-400`:a?`text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-gray-400`,w[n],t),children:c?(0,$.jsx)(L,{className:J(T[n],`animate-spin`)}):a?(0,$.jsx)(pe,{className:T[n]}):u?(0,$.jsx)(ee,{className:T[n]}):(0,$.jsx)(ie,{className:T[n]})})},et=new Map;function tt(e,t,n=``){let r=et.get(e);if(n){if((!r||r.state===`none`)&&(et.set(e,{state:`open`,startedAt:Date.now()}),!t))return;let n=et.get(e);t&&n?.state===`open`&&et.set(e,{state:`done`,durationMs:Date.now()-n.startedAt});return}if(r&&r.state!==`open`||!t)return;let i=xe(t);if(!r){i.thinkingComplete?et.set(e,{state:`none`}):et.set(e,{state:`open`,startedAt:Date.now()});return}i.thinkingComplete&&et.set(e,{state:`done`,durationMs:Date.now()-r.startedAt})}function nt(e){let t=et.get(e);if(t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function rt(e){let t=et.get(e);if(et.delete(e),t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function it(e){let t=e/1e3;if(t<.95)return`${Math.max(.1,Math.round(t*10)/10)}s`;if(t<60)return`${Math.round(t)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return r>0?`${n}m ${r}s`:`${n}m`}var at=/```([^\n`]*)\n([\s\S]*?)\n```/g,ot=/^(?:%%|flowchart|graph|sequenceDiagram|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|gantt|pie|mindmap|timeline|gitGraph|quadrantChart|requirementDiagram|sankey-beta|xychart-beta|block-beta|architecture-beta|packet-beta|kanban|radar-beta|treemap-beta|C4Context)\b/i,st=/[\w@./-]+\.(?:html?|css|mjs|js|jsx|ts|tsx|svg|json|py)/i,ct=[`html`,`react`,`svg`,`mermaid`,`chart`,`code`,`text`,`json`],lt=[{regex:/<artifact\s+type="([^"]+)"\s+title="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>({type:vt(e[1]),title:ut(e[2]).trim()||`Artifact`,content:e[3].trim()})},{regex:/<artifact\s+type="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>{let t=vt(e[1]);return{type:t,title:`${t.toUpperCase()} Artifact`,content:e[2].trim()}}}];function ut(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||t.innerText||``}return ft(dt(e))}function dt(e){return e.replace(/&(lt|gt|quot|apos|#39);/gi,(e,t)=>{switch(t.toLowerCase()){case`lt`:return`<`;case`gt`:return`>`;case`quot`:return`"`;case`apos`:case`#39`:return`'`;default:return``}}).replace(/&/gi,`&`)}function ft(e){let t=``,n=!1,r=null;for(let i=0;i<e.length;i+=1){let a=e[i];if(n){if(r){a===r&&(r=null);continue}if(a===`"`||a===`'`){r=a;continue}a===`>`&&(n=!1);continue}if(a===`<`){let t=e[i+1];if(t&&/[!/A-Za-z?]/.test(t)){n=!0;continue}}t+=a}return t}function pt(e){let t=e.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(t)return ut(t[1]).trim()||null;let n=e.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);return n&&ut(n[1]).trim()||null}function mt(e){for(let t of[/export\s+default\s+(?:function|class)\s+([A-Z]\w*)/,/export\s+default\s+([A-Z]\w*)\s*(?:;|$)/m,/(?:function|class)\s+([A-Z]\w*)/,/const\s+([A-Z]\w*)\s*[:=]/,/(?:function|const|class)\s+(\w+)/]){let n=e.match(t);if(n)return n[1]}return null}function ht(e){let t=e.match(/^\s*title\s+(.+)$/im);if(t)return t[1].trim();let n=e.trim().match(/^([A-Za-z][\w-]*)/);if(!n)return null;let r=n[1].replace(/-(?:beta|v2)$/i,``).replace(/([a-z])([A-Z])/g,`$1 $2`);return`${r.charAt(0).toUpperCase()}${r.slice(1)}`}function gt(e){if(e.includes(`def main(`))return`Python Script`;let t=e.match(/class\s+(\w+)/);if(t)return`${t[1]} Class`;let n=e.match(/def\s+(\w+)/);return n&&n[1]!==`__init__`?`${n[1]} Function`:null}function _t(e){let t=e.match(/function\s+(\w+)/);if(t)return`${t[1]} Function`;let n=e.match(/(?:const|let)\s+(\w+)\s*=/);return n?n[1]:null}function vt(e){let t=e.trim().toLowerCase();return ct.includes(t)?t:`text`}function yt(e){if(!e)return;let t=e.trim().toLowerCase().replace(/^\./,``).replace(/[,:;]+$/,``);switch(t){case`htm`:case`html`:return`html`;case`js`:case`mjs`:case`javascript`:return`javascript`;case`jsx`:case`tsx`:case`react`:return`react`;case`ts`:case`typescript`:return`typescript`;case`py`:case`python`:return`python`;case`css`:case`svg`:case`json`:return t;default:return t||void 0}}function bt(e){let t=[],n=new RegExp(at),r;for(;(r=n.exec(e))!==null;){let n=r[1].trim(),i=xt(n,Ct(e,r.index));t.push({raw:r[0],info:n,content:r[2].trim(),start:r.index,end:r.index+r[0].length,language:i.language,fileName:i.fileName})}return t}function xt(e,t){let n=St(e)||t,r=e.split(/\s+/).filter(Boolean)[0]?.replace(/[{}[\]()]/g,``);return{language:(r&&!st.test(r)&&!r.includes(`=`)?yt(r):void 0)||yt(Tt(n)),fileName:n}}function St(e){let t=e.match(/(?:file(?:name)?|path|name)\s*=\s*["']?([^"'\s]+)["']?/i);if(t&&st.test(t[1]))return wt(t[1]);let n=e.match(st);return n?wt(n[0]):void 0}function Ct(e,t){let n=e.slice(Math.max(0,t-180),t).split(`
|
|
2
|
-
`).slice(-3).reverse();for(let e of n){let t=e.trim().replace(/^#{1,6}\s*/,``).replace(/^[-*]\s*/,``).replace(/[::]\s*$/,``).match(st);if(t)return wt(t[0])}}function wt(e){return e.replace(/^["'`]+|["'`:]+$/g,``)}function Tt(e){return e?.match(/\.([a-z0-9]+)$/i)?.[1]}function Et(e){return e?.split(/[\\/]/).pop()}function Dt(e){let t=Et(e);if(!t)return null;let n=t.replace(/\.[^.]+$/,``);return/^(index|main|app)$/i.test(n)?null:n.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Ot(e){let t=Date.now();return{...e,id:`artifact-${t}-${Math.random().toString(36).slice(2,11)}`,createdAt:t,updatedAt:t}}function kt(e){let t=yt(e.language)||yt(Tt(e.fileName));switch(t){case`html`:return{type:`html`,title:pt(e.content)||Dt(e.fileName)||`HTML Document`};case`svg`:return{type:`svg`,title:Dt(e.fileName)||`SVG Image`};case`react`:return{type:`react`,title:mt(e.content)||Dt(e.fileName)||`React Component`,language:`jsx`};case`mermaid`:return{type:`mermaid`,title:ht(e.content)||`Diagram`,language:`mermaid`};case`json`:return{type:`json`,title:Dt(e.fileName)||`JSON Data`};case`python`:return{type:`code`,title:gt(e.content)||Dt(e.fileName)||`Python Code`,language:`python`};case`css`:return{type:`code`,title:Dt(e.fileName)||`CSS Styles`,language:`css`};case`javascript`:return{type:`code`,title:_t(e.content)||Dt(e.fileName)||`JavaScript Code`,language:`javascript`};case`typescript`:return{type:`code`,title:Dt(e.fileName)||`TypeScript Code`,language:`typescript`};default:return t?{type:`code`,title:Dt(e.fileName)||`${t.toUpperCase()} Code`,language:t}:null}}function At(e){return(yt(e.language)||yt(Tt(e.fileName)))===`html`}function jt(e){return(yt(e.language)||yt(Tt(e.fileName)))===`css`}function Mt(e){return(yt(e.language)||yt(Tt(e.fileName)))===`javascript`}function Nt(e){let t=bt(e),n=t.filter(At);if(n.length===0)return null;let r=t.filter(jt),i=t.filter(Mt);if(r.length===0&&i.length===0)return null;let a=n.find(e=>/(^|[/\\])index\.html?$/i.test(e.fileName||``))||n[0],o=Pt(a.content,r,i),s=Be(o,r.map(e=>e.content),i.map(e=>e.content));return zt(s,`html`)?{artifact:Ot({type:`html`,title:pt(s)||Dt(a.fileName)||`Interactive HTML App`,description:`Bundled generated HTML, CSS, and JavaScript files into one runnable artifact.`,content:s}),ranges:[a,...r,...i]}:null}function Pt(e,t,n){let r=e;for(let e of t){let t=Et(e.fileName);t&&(r=r.replace(RegExp(`<link\\b[^>]*href=["'][^"']*${Rt(t)}["'][^>]*>`,`gi`),``))}for(let e of n){let t=Et(e.fileName);t&&(r=r.replace(RegExp(`<script\\b[^>]*src=["'][^"']*${Rt(t)}["'][^>]*>\\s*<\\/script>`,`gi`),``))}return r}function Ft(e){let t=/<!doctype\s+html|<html[\s>]/i.exec(e);if(!t||t.index===void 0)return null;let n=bt(e);if(It(t.index,n))return null;let r=t.index,i=/<\/html>/gi;i.lastIndex=r;let a=i.exec(e),o=a?a.index+a[0].length:e.length,s=e.slice(r,o).trim();return zt(s,`html`)?{artifact:Ot({type:`html`,title:pt(s)||`HTML Document`,content:s}),ranges:[{start:r,end:o}]}:null}function It(e,t){return t.some(t=>e>=t.start&&e<=t.end)}function Lt(e,t){return[...t].sort((e,t)=>t.start-e.start).reduce((e,t)=>`${e.slice(0,t.start)}${e.slice(t.end)}`,e)}function Rt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function zt(e,t){if(t===`html`){let t=e.trim(),n=/<[^>]+>/.test(t),r=/<(canvas|script|style|button|form|input|select|textarea|video|audio)\b/i.test(t)||/\bon(?:click|input|submit|keydown|keyup|mousemove)=/i.test(t);return n&&(Ve(t)||t.length>160||r)}if(t===`svg`)return/<svg[^>]*>/.test(e);if(t===`react`)return/<[A-Za-z][^>]*>/.test(e)&&/\b(?:export\s+default|return\s*[(<]|=>\s*[(<]|createRoot|render\s*\()/.test(e);if(t===`mermaid`)return ot.test(e.trim());if(t===`json`)try{return JSON.parse(e),e.trim().length>100}catch{return!1}if(t===`code`){let t=e.split(`
|
|
3
|
-
`).length,n=e.trim().length,r=/function|class|def |import |from |const |let |var |if |for |while |try |catch/.test(e);return(n>500||t>15)&&r}return e.trim().length>200}function Bt(e){let t=[],n=e;for(let e of lt){e.regex.lastIndex=0;let r=[],i;for(;(i=e.regex.exec(n))!==null;){let n=e.extract(i);zt(n.content,n.type)&&(t.push(Ot({type:n.type,title:n.title,content:n.content})),r.push({start:i.index,end:i.index+i[0].length}))}n=Lt(n,r)}let r=Nt(n);for(;r;)t.push(r.artifact),n=Lt(n,r.ranges),r=Nt(n);let i=Ft(n);i&&(t.push(i.artifact),n=Lt(n,i.ranges));let a=bt(n),o=[];for(let e of a){let n=kt(e);!n||!zt(e.content,n.type)||(t.push(Ot({type:n.type,title:n.title,content:e.content,language:n.language})),o.push(e))}return n=Lt(n,o),{content:n.trim(),artifacts:t}}var Vt=H(`components:chat-message`);function Ht({role:e,user:t,personaAvatar:n}){let[r,i]=(0,Q.useState)(null);if(e===`assistant`){let e=n?.trim()||``,t=e.startsWith(`data:`)&&e!==r?e:``;return(0,$.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`chat-assistant-avatar`,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-black/[0.07] bg-white text-gray-900 shadow-sm dark:border-white/[0.09] dark:bg-dark-200 dark:text-dark-950`,children:t?(0,$.jsx)(`img`,{src:t,alt:``,className:`h-full w-full object-cover`,onError:()=>i(e)}):e?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`text-base leading-none`,children:e}):(0,$.jsx)(ze,{label:null,className:`h-4 w-4`})})}let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,$.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`chat-user-avatar`,className:J(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-black/[0.07] bg-white dark:border-white/[0.09] dark:bg-dark-200`:`bg-gray-950 text-white dark:bg-white dark:text-gray-950`),title:a,children:s?(0,$.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?.username?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,$.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Ut=({message:e,isStreaming:t=!1,className:n,isLastAssistantMessage:r=!1,onRegenerate:i,onEditResend:a})=>{let{t:o,i18n:c}=s(),u=e.role===`user`,d=e.role===`system`,{preferences:f}=je(),{user:p}=Ae(),{setSystemMessage:h,getCurrentPersona:_,currentSession:y,rateMessage:b}=Y(),x=_(),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(e.content),[D,O]=(0,Q.useState)(null),[k,ee]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,F]=(0,Q.useState)(!1),[ne,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(!1),re=(0,Q.useRef)(null),ie=(0,Q.useRef)(t),oe=(0,Q.useRef)(!1),se=async()=>{try{await navigator.clipboard.writeText(e.content),Fe(`success`),R(!0),setTimeout(()=>R(!1),2e3)}catch(e){Vt.error(`Failed to copy message:`,e)}},{thinkingContent:ce,thinkingStreaming:B,parsedContent:V,artifacts:de}=(0,Q.useMemo)(()=>{if(u||d||!e.content&&!e.thinking)return{thinkingContent:null,thinkingStreaming:!1,parsedContent:e.content,artifacts:e.artifacts||[]};let n=e.thinking?{thinking:e.thinking,content:e.content,thinkingComplete:!!e.content||!t}:xe(e.content),r=n.content,i=t&&!n.thinkingComplete;if(e.artifacts&&e.artifacts.length>0)return{thinkingContent:n.thinking,thinkingStreaming:i,parsedContent:r,artifacts:e.artifacts};if(!t){let e=Bt(r);return{thinkingContent:n.thinking,thinkingStreaming:i,parsedContent:e.content,artifacts:e.artifacts}}return{thinkingContent:n.thinking,thinkingStreaming:i,parsedContent:r,artifacts:[]}},[e.content,e.thinking,e.artifacts,u,d,t]),fe=B?void 0:e.statistics?.thinking_duration_ms??nt(e.id);(0,Q.useEffect)(()=>{let e=ie.current&&!t;return ie.current=t,e&&!oe.current&&!u&&!d&&V&&f.ttsSettings?.enabled&&f.ttsSettings?.autoPlay&&(oe.current=!0,(async()=>{I(!0);try{let e=await W.getModels(),t=e.success&&e.data?e.data:[],n=f.ttsSettings,r=ge(t,n?.model,n?.pluginId),i=ve(t,n?.model,n?.pluginId),a=await W.generateBase64({model:r?.model||n?.model||`tts-1`,pluginId:r?.plugin||n?.pluginId,input:V,voice:i?n?.voice||r?.config?.default_voice||`alloy`:r?.config?.default_voice||`alloy`,speed:n?.speed||1,response_format:r?.config?.default_format});if(a.success&&a.data?.audio){let e=`data:${a.data.mimeType};base64,${a.data.audio}`,t=new Audio(e);re.current=t,t.onended=()=>{I(!1),re.current=null},t.onerror=()=>{I(!1),re.current=null},await t.play()}}catch(e){Vt.error(`Auto-play TTS failed:`,e),I(!1)}})()),()=>{re.current&&(re.current.pause(),re.current=null)}},[t,u,d,V,f.ttsSettings]);let pe=()=>d?o(`chatMessage.system`):u?f.showUsername&&p?.username?p.username:o(`chatMessage.you`):x?.name?x.name:e.model||o(`chatMessage.assistant`),me=()=>{w(!0),E(e.content)},H=async()=>{ee(!0);try{h(T),w(!1),Vt.debug(`✅ System message updated:`,T)}catch(e){Vt.error(`Failed to save system message:`,e)}finally{ee(!1)}},U=()=>{w(!1),E(e.content)},G=()=>{let t=T.trim();w(!1),!(!t||t===e.content)&&a?.(e.id,t)},K=t=>{y&&b(y.id,e.id,e.rating===t?void 0:t)},he=(e,t=100)=>e.length<=t?e:e.substring(0,t)+`...`,_e=d&&e.content.length>100;return(0,$.jsxs)(`div`,{className:J(`group flex py-1.5 transition-colors sm:py-2`,u?`justify-end`:`justify-start`,n),children:[(0,$.jsxs)(`div`,{className:J(`flex min-w-0 gap-2.5 sm:gap-3`,u?`max-w-[85%] sm:max-w-[70%]`:`w-full`),children:[!u&&!d&&(0,$.jsx)(Ht,{role:`assistant`,personaAvatar:x?.avatar}),(0,$.jsxs)(`div`,{className:J(`min-w-0 flex-1`,u?`flex flex-col items-end`:d?`py-1.5`:`py-0.5`),children:[!u&&!d&&(0,$.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,$.jsx)(`span`,{dir:`auto`,className:`text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-700 rtl:tracking-normal dark:text-dark-700`,children:pe()}),e.model&&x?.name&&(0,$.jsx)(`span`,{dir:`ltr`,className:`max-w-32 truncate rounded-full bg-gray-100 px-2 py-0.5 text-[10px] text-gray-500 dark:bg-dark-200 dark:text-dark-600 sm:max-w-48`,title:e.model,children:e.model}),(0,$.jsx)(`span`,{dir:`auto`,className:`text-[10px] tabular-nums text-gray-400 dark:text-dark-500`,children:Se(e.timestamp,c.language)})]}),(0,$.jsxs)(`div`,{className:J(!u&&!d&&`text-[0.9375rem] leading-[1.65] text-gray-800 dark:text-dark-800`),children:[e.images&&e.images.length>0&&(0,$.jsx)(`div`,{className:`mb-1.5 grid max-w-lg grid-cols-2 gap-1.5 sm:grid-cols-3`,children:e.images.map((e,t)=>(0,$.jsx)(`div`,{className:`aspect-square overflow-hidden rounded-xl border border-black/[0.06] bg-gray-100 dark:border-white/[0.08] dark:bg-gray-800`,children:(0,$.jsx)(`img`,{src:e,alt:`Uploaded image ${t+1}`,className:`w-full h-full object-cover cursor-pointer hover:opacity-90 transition-opacity`,onClick:()=>O(e)})},t))}),u?C?(0,$.jsxs)(`div`,{className:`w-full min-w-[min(28rem,80vw)] rounded-2xl border border-black/[0.08] bg-white p-2 shadow-sm dark:border-white/[0.08] dark:bg-dark-100`,children:[(0,$.jsx)(`textarea`,{dir:`auto`,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),G()):e.key===`Escape`&&U()},autoFocus:!0,className:`min-h-[72px] w-full resize-y rounded-xl border-none bg-transparent p-2 text-[0.9375rem] leading-relaxed text-gray-900 focus:outline-none dark:text-dark-900`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 px-1 pb-1`,children:[(0,$.jsx)(`button`,{onClick:U,className:`rounded-lg px-2.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 dark:text-dark-600 dark:hover:bg-dark-200`,children:o(`chatMessage.cancelEditing`)}),(0,$.jsx)(`button`,{onClick:G,className:`rounded-lg bg-gray-900 px-2.5 py-1 text-xs text-white transition-colors hover:bg-gray-700 dark:bg-dark-300 dark:hover:bg-dark-400`,children:o(`chatMessage.saveAndSubmit`)})]})]}):(0,$.jsx)(`div`,{className:`rounded-2xl rounded-ee-md border border-black/[0.06] bg-gray-900 px-3.5 py-2 text-white shadow-sm dark:border-white/[0.07] dark:bg-dark-300`,children:(0,$.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap text-[0.9375rem] leading-relaxed`,children:e.content})}):d?(0,$.jsxs)(`div`,{className:`relative z-0 rounded-2xl border border-black/[0.06] bg-white/55 p-3 dark:border-white/[0.06] dark:bg-dark-200/45`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(l,{className:`h-2.5 w-2.5 opacity-50`}),o(`chatMessage.system`)]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:H,disabled:k,className:`rounded-lg p-1.5 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:hover:bg-dark-300`,title:o(`chatMessage.saveChanges`),children:(0,$.jsx)(m,{className:`h-3 w-3 text-green-600 dark:text-green-400`})}),(0,$.jsx)(`button`,{onClick:U,disabled:k,className:`rounded-lg p-1.5 transition-colors hover:bg-gray-100 disabled:opacity-50 dark:hover:bg-dark-300`,title:o(`chatMessage.cancelEditing`),children:(0,$.jsx)(z,{className:`h-3 w-3 text-red-600 dark:text-red-400`})})]}):(0,$.jsx)(`button`,{onClick:me,className:`rounded-lg p-1.5 transition-colors hover:bg-gray-100 dark:hover:bg-dark-300`,title:o(`chatMessage.editSystemMessage`),children:(0,$.jsx)(g,{className:`h-3 w-3 text-gray-600 dark:text-gray-400`})})})]}),C?(0,$.jsx)(`textarea`,{dir:`auto`,value:T,onChange:e=>E(e.target.value),className:`min-h-[100px] w-full resize-none rounded-xl border border-black/[0.08] bg-white p-3 text-sm text-gray-900 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-primary-500 dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 dark:focus:ring-primary-400`,placeholder:o(`chatMessage.systemMessagePlaceholder`),disabled:k}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap text-xs leading-relaxed text-gray-500 dark:text-dark-600`,children:A?e.content:he(e.content)}),_e&&(0,$.jsx)(`button`,{onClick:()=>j(!A),className:`mt-2 flex items-center gap-1 text-xs text-gray-400 transition-colors hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`,children:A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(le,{className:`h-3 w-3`}),o(`chatMessage.showLess`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ae,{className:`h-3 w-3`}),o(`chatMessage.showMore`)]})})]})]}):(0,$.jsxs)(`div`,{className:`relative`,children:[(ce||B)&&(0,$.jsxs)(`div`,{className:`mb-3 border-s border-gray-200 ps-3 dark:border-dark-300`,children:[(0,$.jsxs)(`button`,{onClick:()=>F(!M),className:`flex items-center gap-1.5 text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-600 dark:hover:text-dark-900`,children:[(0,$.jsx)(N,{className:J(`h-3.5 w-3.5`,B&&`animate-pulse-subtle motion-reduce:animate-none`)}),B?(0,$.jsxs)(`span`,{className:`animate-shimmer bg-gradient-to-r from-gray-400 via-gray-900 to-gray-400 bg-[length:200%_100%] bg-clip-text font-medium text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-gray-500 dark:from-dark-500 dark:via-dark-900 dark:to-dark-500 motion-reduce:dark:text-dark-600`,children:[o(`chatMessage.thinking`),`…`]}):(0,$.jsx)(`span`,{className:`font-medium`,children:fe===void 0?o(`chatMessage.thinking`):o(`chatMessage.thoughtFor`,{duration:it(fe)})}),M?(0,$.jsx)(le,{className:`h-3.5 w-3.5`}):(0,$.jsx)(ae,{className:`h-3.5 w-3.5`})]}),M&&ce&&(0,$.jsx)(`div`,{className:`mt-2 rounded-xl bg-gray-100/60 p-2.5 dark:bg-dark-200/60`,children:(0,$.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap text-[13px] leading-relaxed text-gray-600 dark:text-dark-700`,children:ce})})]}),(0,$.jsx)(Re,{content:V,isStreaming:t})]}),!u&&!d&&de.length>0&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(He,{artifacts:de})}),!u&&!d&&Array.isArray(e.providerMetadata?.webSearchSources)&&e.providerMetadata.webSearchSources.length>0&&(0,$.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:o(`chat.message.sources`,`Sources`)}),e.providerMetadata.webSearchSources.map((e,t)=>typeof e?.url==`string`?(0,$.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,className:`inline-flex max-w-[220px] items-center gap-1 rounded-full border border-gray-200 bg-gray-50 px-2 py-0.5 text-[11px] text-gray-600 transition-colors hover:border-primary-300 hover:text-primary-600 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-700 dark:hover:text-primary-400`,title:e.title||e.url,children:[(0,$.jsx)(`span`,{className:`tabular-nums`,children:t+1}),(0,$.jsx)(`span`,{className:`truncate`,children:(()=>{try{return new URL(e.url).hostname.replace(/^www\./,``)}catch{return e.url}})()})]},`${e.url}-${t}`):null)]}),!u&&!d&&e.statistics&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(Ge,{statistics:e.statistics})}),!d&&!t&&(0,$.jsxs)(`div`,{className:J(`flex items-center gap-0.5 text-gray-400 dark:text-dark-500`,`sm:opacity-0 sm:transition-opacity sm:duration-150 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100`,u?`mt-1 justify-end`:`mt-1`),children:[u&&(0,$.jsxs)(`span`,{dir:`auto`,className:`me-1 text-[10px] tabular-nums`,title:Se(e.timestamp,c.language),children:[pe(),` ·`,` `,Se(e.timestamp,c.language)]}),!u&&V&&(0,$.jsx)($e,{text:V,size:`sm`,className:J(`transition-colors`,ne&&`bg-primary-50 text-primary-600 dark:bg-primary-900/20 dark:text-primary-400`)}),u&&a&&!C&&(0,$.jsx)(`button`,{onClick:()=>{E(e.content),w(!0)},className:`flex h-7 w-7 items-center justify-center rounded-full transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-dark-200 dark:hover:text-dark-800`,title:o(`chatMessage.edit`),children:(0,$.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{onClick:se,className:`flex h-7 w-7 items-center justify-center rounded-full transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-dark-200 dark:hover:text-dark-800`,title:o(L?`chatMessage.copied`:`chatMessage.copyMessage`),children:L?(0,$.jsx)(ue,{className:`h-3.5 w-3.5 text-green-500`}):(0,$.jsx)(v,{className:`h-3.5 w-3.5`})}),!u&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:()=>K(1),className:J(`flex h-7 w-7 items-center justify-center rounded-full transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-dark-200 dark:hover:text-dark-800`,e.rating===1&&`text-primary-600 dark:text-primary-400`),title:o(`chatMessage.goodResponse`),"aria-pressed":e.rating===1,children:(0,$.jsx)(te,{className:`h-3.5 w-3.5`,fill:e.rating===1?`currentColor`:`none`})}),(0,$.jsx)(`button`,{onClick:()=>K(-1),className:J(`flex h-7 w-7 items-center justify-center rounded-full transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-dark-200 dark:hover:text-dark-800`,e.rating===-1&&`text-red-500 dark:text-red-400`),title:o(`chatMessage.badResponse`),"aria-pressed":e.rating===-1,children:(0,$.jsx)(P,{className:`h-3.5 w-3.5`,fill:e.rating===-1?`currentColor`:`none`})})]}),!u&&r&&i&&(0,$.jsx)(`button`,{onClick:i,className:`flex h-7 w-7 items-center justify-center rounded-full transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-dark-200 dark:hover:text-dark-800`,title:o(`chatMessage.regenerateResponse`),children:(0,$.jsx)(S,{className:`h-3.5 w-3.5`})})]})]})]}),u&&(0,$.jsx)(Ht,{role:`user`,user:p??null})]}),D&&(0,We.createPortal)((0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":o(`chatMessage.fullSizeImage`),className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-6 backdrop-blur-md`,onClick:()=>O(null),children:[(0,$.jsx)(`button`,{className:`absolute end-6 top-6 rounded-full border border-white/15 bg-white/10 p-3 text-white transition-colors hover:bg-white/20`,onClick:e=>{e.stopPropagation(),O(null)},children:(0,$.jsx)(z,{className:`h-7 w-7`})}),(0,$.jsx)(`img`,{src:D,alt:o(`chatMessage.fullSizeImage`),className:`max-h-[90vh] max-w-[90vw] rounded-2xl object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]}),document.body)]})},Wt=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Gt=220,Kt=e=>{let t=e.slice(0,880).replace(/```(?:\w+)?\s*([\s\S]*?)```/g,`$1`).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/<[^>]+>/g,` `).replace(/[#>*_~`|]/g,` `).replace(/\s+/g,` `).trim();return t.length>Gt?`${t.slice(0,219).trimEnd()}…`:t},qt=Q.memo(function({items:e,activeId:t,onSelect:n}){let{t:r}=s(),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(new Map),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(0),f=(0,Q.useCallback)((e,t)=>{let n=i.current;if(!n)return;let r=n.getBoundingClientRect(),a=t.getBoundingClientRect();d(a.top-r.top+a.height/2),l(e)},[]),p=(0,Q.useCallback)(t=>{let r=e[t],i=r?o.current.get(r.id):void 0;!r||!i||(i.focus(),f(r.id,i),n(r.id))},[e,n,f]);if((0,Q.useEffect)(()=>{if(!t)return;let e=a.current,n=o.current.get(t);if(!e||!n)return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),s=null;i.top<r.top?s=e.scrollTop-(r.top-i.top)-8:i.bottom>r.bottom&&(s=e.scrollTop+(i.bottom-r.bottom)+8),s!==null&&e.scrollTo({top:s,behavior:Wt()?`auto`:`smooth`})},[t]),e.length<3)return null;let m=Math.max(0,e.findIndex(e=>e.id===t)),h=e[m]?.id,g=e.findIndex(e=>e.id===c),_=g>=0?e[g]:null,v=g>=0?`conversation-history-preview-${g}`:void 0;return(0,$.jsxs)(`nav`,{ref:i,"data-testid":`conversation-history-rail`,"aria-label":r(`chatHistory.label`),className:`pointer-events-none absolute top-1/2 z-20 hidden h-[min(58vh,30rem)] w-7 -translate-y-1/2 lg:block xl:w-9`,style:{insetInlineStart:`max(0.25rem, calc(50% - 27rem))`},onPointerLeave:()=>{i.current?.contains(document.activeElement)||l(null)},children:[(0,$.jsx)(`ol`,{ref:a,className:`pointer-events-auto flex h-full min-h-0 flex-col overflow-y-auto py-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [&>li:first-child]:mt-auto [&>li:last-child]:mb-auto`,children:e.map((t,a)=>{let s=t.id===h,u=Math.abs(a-m),d=c===t.id?v:void 0;return(0,$.jsx)(`li`,{className:`flex h-4 flex-none items-center`,children:(0,$.jsx)(`button`,{ref:e=>{e?o.current.set(t.id,e):o.current.delete(t.id)},type:`button`,"data-testid":`conversation-history-marker`,"aria-current":s?`location`:void 0,"aria-describedby":d,"aria-label":r(`chatHistory.jumpToTurn`,{index:a+1,total:e.length}),tabIndex:a===m?0:-1,className:J(`group flex h-4 w-7 items-center outline-none xl:w-9`,`focus-visible:ring-2 focus-visible:ring-primary-500/45 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas`,`rounded-sm`),onClick:()=>n(t.id),onPointerEnter:e=>f(t.id,e.currentTarget),onFocus:e=>f(t.id,e.currentTarget),onBlur:()=>{window.requestAnimationFrame(()=>{i.current?.contains(document.activeElement)||l(null)})},onKeyDown:t=>{if(t.key===`Escape`){l(null);return}let n=null;t.key===`ArrowDown`?n=Math.min(e.length-1,a+1):t.key===`ArrowUp`?n=Math.max(0,a-1):t.key===`Home`?n=0:t.key===`End`&&(n=e.length-1),n!==null&&(t.preventDefault(),p(n))},children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`block h-0.5 rounded-full transition-[width,background-color,opacity] duration-150 motion-reduce:transition-none`,s?`w-6 bg-ink xl:w-7`:u===1?`w-3.5 bg-ink-subtle opacity-80 group-hover:w-5 group-hover:bg-ink-muted group-hover:opacity-100 group-focus-visible:w-5`:`w-2.5 bg-line-strong opacity-70 group-hover:w-5 group-hover:bg-ink-muted group-hover:opacity-100 group-focus-visible:w-5`)})})},t.id)})}),_&&(0,$.jsx)(`div`,{id:v,role:`tooltip`,className:J(`pointer-events-none absolute start-full ms-2 w-72 -translate-y-1/2`,`overflow-hidden rounded-xl border border-line bg-surface-overlay/95 shadow-overlay backdrop-blur-xl`,`animate-fade-in motion-reduce:animate-none`),style:{top:`clamp(3.5rem, ${u}px, calc(100% - 3.5rem))`},children:(0,$.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,$.jsx)(`p`,{dir:`auto`,className:`truncate text-[13px] font-semibold leading-5 text-ink`,children:Kt(_.prompt)}),_.response&&(0,$.jsx)(`p`,{dir:`auto`,className:`mt-1 line-clamp-3 text-xs leading-5 text-ink-muted`,children:Kt(_.response)})]})})]})}),Jt=({messages:e,isStreaming:t=!1,streamingMessage:n,streamingThinking:r,streamingMessageId:i,isLastAssistantMessage:a=!1,onRegenerate:o,onSelectBranch:s,className:c})=>{if(e.length===1){let s=e[0],l=t&&i===s.id,u=l?{...s,content:n??s.content,thinking:r||s.thinking}:s;return(0,$.jsx)(Ut,{message:u,isStreaming:l,isLastAssistantMessage:a,onRegenerate:o,className:c})}return(0,$.jsxs)(`div`,{className:J(`relative py-2`,c),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-3 text-[10px] font-medium uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[e.length,` variants`]})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:e.map((e,c)=>{let l=e.isActive!==!1,u=t&&i===e.id,d=u?{...e,content:n??e.content,thinking:r||e.thinking}:e;return(0,$.jsxs)(`div`,{className:J(`relative overflow-hidden rounded-2xl border bg-white/45 transition-colors duration-150 dark:bg-dark-200/35`,l||u?`border-primary-500/30 ring-1 ring-primary-500/10 dark:border-primary-400/30`:`border-black/[0.07] hover:bg-white/80 dark:border-white/[0.07] dark:hover:bg-dark-200/70`,!l&&!u&&`cursor-pointer`),role:!l&&!u?`button`:void 0,tabIndex:!l&&!u?0:void 0,onClick:()=>!l&&!u&&s?.(e.id),onKeyDown:t=>{!l&&!u&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s?.(e.id))},children:[(0,$.jsxs)(`div`,{className:J(`flex items-center justify-between border-b px-3 py-2 text-[10px] font-medium uppercase tracking-[0.12em]`,l||u?`border-primary-500/10 bg-primary-50/50 text-primary-600 dark:border-primary-400/10 dark:bg-primary-900/10 dark:text-primary-400`:`border-black/[0.05] text-gray-400 dark:border-white/[0.05] dark:text-dark-500`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:c+1}),u&&(0,$.jsx)(`span`,{className:`text-[10px] opacity-70 animate-pulse`,children:`generating...`})]}),l&&!u&&(0,$.jsx)(ue,{className:`h-3 w-3`}),!l&&!u&&(0,$.jsx)(`span`,{className:`text-[10px] opacity-50`,children:`select`})]}),(0,$.jsx)(`div`,{className:J(!l&&!u&&`opacity-75`),children:(0,$.jsx)(Ut,{message:d,isStreaming:u,isLastAssistantMessage:a&&(l||u),onRegenerate:l&&!t?o:void 0,className:`px-3 pb-3 !text-sm`})})]},e.id)})})]})},Yt={web_search:x,web_fetch:C,exec:fe,browser:C,Read:h,Write:h,Edit:h,image:F,memory_search:D,memory_get:D,working:ce,thinking:ce,default:ce},Xt={web_search:`Searching the web`,web_fetch:`Fetching page`,exec:`Running command`,browser:`Using browser`,Read:`Reading file`,Write:`Writing file`,Edit:`Editing file`,image:`Analyzing image`,memory_search:`Searching memory`,memory_get:`Reading memory`,cron:`Managing schedule`,message:`Sending message`,tts:`Generating speech`,nodes:`Checking devices`,sessions_spawn:`Spawning agent`,canvas:`Rendering canvas`,process:`Managing process`,working:`Using tools`,thinking:`Thinking`},Zt=({tools:e,className:t})=>{if(e.length===0)return null;let n=e.filter(e=>e.phase!==`result`&&e.phase!==`done`);return n.length===0?null:(0,$.jsx)(`div`,{className:J(`flex flex-col gap-1 py-2 px-1`,t),children:n.map(e=>{let t=Yt[e.name]||Yt.default,n=Xt[e.name]||`Using ${e.name}`,r=e.phase===`result`;return(0,$.jsxs)(`div`,{className:J(`flex items-center gap-2 text-sm transition-all duration-300`,r?`text-green-600 dark:text-green-400 opacity-60`:`text-gray-500 dark:text-gray-400`),children:[(0,$.jsx)(`div`,{className:J(`flex items-center justify-center w-5 h-5`,!r&&`animate-spin-slow`),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:r?`✓ ${n}`:`${n}…`}),!r&&(0,$.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,$.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`300ms`}})]})]},e.toolCallId)})})};H(`components:chat-messages`);var Qt=e=>e.messages.find(e=>e.isActive===!0)||e.messages.find(e=>e.isActive!==!1)||e.messages[0],$t=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,en=e=>Math.min(120,e*.28),tn=({messages:e,streamingMessage:t,streamingThinking:n,streamingMessageId:r,isStreaming:i=!1,toolActivities:a=[],className:o,onRegenerate:c,onSelectBranch:l,onEditResend:u,followUpSuggestions:d,onFollowUpSelect:f})=>{let{t:p}=s(),m=(0,Q.useRef)(null),h=(0,Q.useRef)(void 0),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null),v=(0,Q.useRef)(new Map),y=(0,Q.useRef)(null),b=(0,Q.useRef)(0),x=(0,Q.useRef)(!1),S=(0,Q.useRef)(!1),[C,T]=(0,Q.useState)(!1),E=(0,Q.useMemo)(()=>{let t=[],n=new Set,r=[...e].sort((e,t)=>e.role===`system`&&t.role!==`system`?-1:t.role===`system`&&e.role!==`system`?1:e.parentId===t.parentId?(e.branchIndex||0)-(t.branchIndex||0):e.timestamp-t.timestamp);for(let i of r){if(n.has(i.id))continue;let r=i.parentId;if(r){let a=t.findIndex(e=>e.id===r);if(a>=0)t[a].messages.push(i);else{let a=e.find(e=>e.id===r);a&&!n.has(r)?(t.push({id:r,messages:[a,i],messageIndex:t.length}),n.add(r)):t.push({id:i.id,messages:[i],messageIndex:t.length})}n.add(i.id)}else{let r=e.filter(e=>e.parentId===i.id);r.length>0?(t.push({id:i.id,messages:[i,...r],messageIndex:t.length}),n.add(i.id),r.forEach(e=>n.add(e.id))):(t.push({id:i.id,messages:[i],messageIndex:t.length}),n.add(i.id))}}return t.sort((e,t)=>{let n=e.messages[0],r=t.messages[0];return n.role===`system`&&r.role!==`system`?-1:r.role===`system`&&n.role!==`system`?1:n.timestamp-r.timestamp})},[e]),D=(0,Q.useMemo)(()=>{let e=[];for(let t=0;t<E.length;t++){let n=E[t],r=Qt(n);if(r.role!==`user`)continue;let i;for(let e=t+1;e<E.length;e++){let t=Qt(E[e]);if(t.role===`user`)break;if(t.role===`assistant`){i=t.content;break}}e.push({id:n.id,prompt:r.content,response:i})}return e},[E]),O=D.map(e=>e.id).join(``),k=(0,Q.useMemo)(()=>O?O.split(``):[],[O]),ee=(0,Q.useMemo)(()=>new Set(k),[k]),[j,M]=(0,Q.useState)(null),N=(0,Q.useCallback)(()=>{let e=g.current;if(!e||k.length===0){M(null);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=Math.min(b.current,k.length-1);if(t<=2)n=k.length-1;else{let t=e.scrollTop+en(e.clientHeight);for(;n<k.length-1;){let e=v.current.get(k[n+1]);if(!e||e.offsetTop>t)break;n++}for(;n>0;){let e=v.current.get(k[n]);if(!e||e.offsetTop<=t)break;n--}}b.current=n;let r=k[n];M(e=>e===r?e:r)},[k]),P=(0,Q.useCallback)(()=>{y.current===null&&(y.current=window.requestAnimationFrame(()=>{y.current=null,N()}))},[N]),te=(0,Q.useCallback)(()=>{let t=g.current;if(h.current&&clearTimeout(h.current),x.current=!1,h.current=void 0,!t)return;let n=t.scrollHeight-t.scrollTop-t.clientHeight<100;S.current=!n,T(!n&&e.length>0),P()},[e.length,P]),F=(0,Q.useCallback)(()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(te,180)},[te]),ne=(0,Q.useCallback)((e=!1)=>{S.current&&!e||m.current?.scrollIntoView({behavior:$t()})},[]),I=(0,Q.useCallback)(()=>{let t=g.current;if(!t)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t,a=r-n-i,o=a<100;if(x.current){S.current=!0,T(!o&&e.length>0),P(),F();return}S.current=!o,T(!o&&e.length>0),a<=2&&k.length>0?(b.current=k.length-1,M(k[k.length-1])):P()},[k,e.length,F,P]),L=(0,Q.useCallback)(e=>{let t=g.current,n=v.current.get(e);if(!t||!n)return;let r=$t();x.current=!0,S.current=!0,t.scrollTo({top:Math.max(0,n.offsetTop-en(t.clientHeight)),behavior:r}),P(),r===`auto`?te():F()},[te,F,P]),R=(0,Q.useRef)(e.length);if((0,Q.useEffect)(()=>{e.length>R.current&&!S.current&&ne(),R.current=e.length},[e.length,ne]),(0,Q.useEffect)(()=>{i&&(t||n)&&!S.current&&requestAnimationFrame(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)})},[i,t,n]),(0,Q.useEffect)(()=>{P();let e=_.current,t=g.current,n=typeof ResizeObserver>`u`?null:new ResizeObserver(P);return e&&n?.observe(e),t&&n?.observe(t),window.addEventListener(`resize`,P),()=>{n?.disconnect(),window.removeEventListener(`resize`,P)}},[O,P]),(0,Q.useEffect)(()=>()=>{y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null)},[]),(0,Q.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]),e.length===0&&!i)return(0,$.jsx)(`div`,{className:J(`flex-1 flex items-center justify-center p-6 sm:p-10`,o),children:(0,$.jsxs)(`div`,{className:`max-w-sm text-center text-gray-500 dark:text-dark-600`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-5 flex h-11 w-11 items-center justify-center rounded-2xl border border-black/[0.06] bg-surface/70 text-gray-500 shadow-sm dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:(0,$.jsx)(w,{className:`h-4 w-4`})}),(0,$.jsx)(`h3`,{className:`mb-2 text-lg font-medium tracking-[-0.02em] text-gray-900 dark:text-dark-900 sm:text-xl`,children:p(`chatMessage.startConversation`)}),(0,$.jsx)(`p`,{className:`px-4 text-sm leading-relaxed`,children:p(`chatMessage.startConversationDescription`)})]})});let z=-1;for(let e=E.length-1;e>=0;e--)if(E[e].messages.some(e=>e.role===`assistant`)){z=e;break}return(0,$.jsxs)(`div`,{className:J(`relative min-h-0 flex-1`,o),style:{WebkitAppRegion:`no-drag`},children:[(0,$.jsx)(`div`,{ref:g,"data-testid":`chat-scroll-viewport`,onScroll:I,className:J(`h-full overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600`,`scrollbar-track-transparent hover:scrollbar-thumb-gray-400 dark:hover:scrollbar-thumb-gray-500`,`overscroll-behavior-y-contain`,`[-webkit-overflow-scrolling:touch]`),style:{WebkitOverflowScrolling:`touch`,overscrollBehaviorY:`contain`},children:(0,$.jsxs)(`div`,{ref:_,className:`mx-auto w-full min-w-0 max-w-3xl px-4 sm:px-6 md:px-8`,children:[E.map((e,a)=>{let o=a===z,s=ee.has(e.id),d=i&&e.messages.some(e=>e.id===r),f;if(e.messages.length===1){let s=e.messages[0],l=i&&s.id===r,d=l?{...s,content:t??s.content,thinking:n||s.thinking}:s;f=(0,$.jsx)(Ut,{message:d,isStreaming:l,isLastAssistantMessage:o,onRegenerate:o?c:void 0,onEditResend:i?void 0:u,className:a===0?`mt-3 sm:mt-4`:``})}else f=(0,$.jsx)(Jt,{messages:e.messages,isStreaming:d,streamingMessage:t,streamingThinking:n,streamingMessageId:r||void 0,isLastAssistantMessage:o,onRegenerate:o?c:void 0,onSelectBranch:l,className:a===0?`mt-3 sm:mt-4`:``});return(0,$.jsx)(`div`,{ref:t=>{s&&(t?v.current.set(e.id,t):v.current.delete(e.id))},"data-testid":s?`conversation-turn-anchor`:void 0,"data-history-id":s?e.id:void 0,children:f},e.id)}),i&&a.length>0&&(0,$.jsx)(Zt,{tools:a,className:`px-0`}),!i&&d&&d.length>0&&f&&(0,$.jsxs)(`div`,{className:`mt-1 pb-2`,children:[(0,$.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500 dark:text-dark-500`,children:p(`chat.followUp`)}),(0,$.jsx)(`div`,{className:`flex flex-col`,children:d.map(e=>(0,$.jsx)(`button`,{onClick:()=>f(e),dir:`auto`,className:`border-t border-gray-100 py-2 text-start text-[0.9rem] leading-relaxed text-gray-600 transition-colors hover:text-gray-900 dark:border-dark-200 dark:text-dark-600 dark:hover:text-dark-900`,children:e},e))})]}),(0,$.jsx)(`div`,{ref:m,className:`h-4 sm:h-6`})]})}),(0,$.jsx)(qt,{items:D,activeId:j,onSelect:L}),C&&(0,$.jsxs)(`button`,{onClick:()=>{x.current=!1,h.current&&(clearTimeout(h.current),h.current=void 0),S.current=!1,m.current?.scrollIntoView({behavior:$t()}),T(!1)},className:J(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10`,`flex items-center justify-center gap-1.5`,`px-3.5 py-2 rounded-full`,`bg-surface/90 dark:bg-dark-200/90`,`border border-black/[0.07] dark:border-white/[0.08]`,`shadow-[0_8px_28px_rgba(15,23,42,0.12)] backdrop-blur-xl`,`text-gray-600 dark:text-dark-600`,`hover:bg-surface-raised dark:hover:bg-dark-200`,`hover:text-gray-900 dark:hover:text-dark-800`,`transition-colors duration-150`),title:p(`chatMessage.scrollToBottom`),children:[(0,$.jsx)(A,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:p(`chatMessage.newMessages`)})]})]})};function nn(e){let t=(e.match(/```/g)||[]).length,n=t%2==1,r=null;if(n){let t=e.lastIndexOf("```");if(t!==-1){let n=e.slice(t+3).match(/^(\w+)/);n&&(r=n[1])}}return{hasCodeBlocks:t>0,isInCodeBlock:n,language:r}}var rn=Q.forwardRef(({value:e,onChange:t,className:n,placeholder:r,disabled:i,onKeyDown:a,dir:o=`auto`,...s},c)=>{let{hasCodeBlocks:l,isInCodeBlock:u,language:d}=(0,Q.useMemo)(()=>nn(e),[e]);return(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(`textarea`,{ref:c,value:e,onChange:t,onKeyDown:a,placeholder:r,disabled:i,dir:o,className:J(`w-full resize-none transition-all duration-200`,u&&[`font-mono text-[13px]`,`bg-gray-50 dark:bg-dark-100/50`,`rounded-lg`],n),...s}),l&&(0,$.jsx)(`div`,{className:`absolute end-0 top-0 pointer-events-none flex items-center gap-1`,children:(0,$.jsxs)(`div`,{className:J(`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-500 dark:text-gray-400`,`border border-gray-200/50 dark:border-dark-300/50`,u&&`animate-pulse`),children:[(0,$.jsx)(O,{className:`h-3 w-3`}),d&&(0,$.jsx)(`span`,{children:d}),!d&&u&&(0,$.jsx)(`span`,{children:`code`})]})})]})});rn.displayName=`CodeAwareTextarea`;var an=H(`components:media-upload`),on=({images:e,onImagesChange:t,maxImages:n=5,sessionId:r,onDocumentUploaded:i,disabled:a=!1,className:o})=>{let{t:c}=s(),l=(0,Q.useRef)(null),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)([]),v=async e=>{if(!(!e||a))for(let t=0;t<e.length;t++){let n=e[t];n.type.startsWith(`image/`)?await y(n):n.type.includes(`pdf`)||n.type.includes(`text`)?await x(n):f.error(`File type not supported: ${n.name}`)}},y=async r=>{if(n-e.length<=0){f.error(`Maximum ${n} images allowed`);return}if(r.size>10485760){f.error(`Image ${r.name} is too large (max 10MB)`);return}let i=new FileReader;i.onload=n=>{n.target?.result&&t([...e,n.target.result])},i.readAsDataURL(r)},x=async e=>{if(e.size>10485760){f.error(`File size must be less than 10MB`);return}m(!0);try{let t=await G.uploadDocument(e,r);if(t.success&&t.data){let n=t.data;_(e=>[...e,n]),i?.(n),f.success(`Document "${e.name}" uploaded`)}else f.error(t.error||`Failed to upload document`)}catch(e){an.error(`Document upload error:`,e),f.error(`Failed to upload document`)}finally{m(!1)}},S=e=>{e.preventDefault(),a||d(!0)},C=e=>{e.preventDefault(),d(!1)},w=e=>{e.preventDefault(),d(!1),a||v(e.dataTransfer.files)},T=n=>{t(e.filter((e,t)=>t!==n))},E=async e=>{try{let t=await G.deleteDocument(e);t.success?(_(t=>t.filter(t=>t.id!==e)),f.success(`Document removed`)):f.error(t.error||`Failed to remove document`)}catch(e){an.error(`Error removing document:`,e),f.error(`Failed to remove document`)}},D=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]},O=e.length>0||g.length>0;return(0,$.jsxs)(`div`,{className:J(`space-y-3`,o),children:[(0,$.jsxs)(`div`,{className:J(`border-2 border-dashed rounded-xl p-6 transition-all duration-200 cursor-pointer`,`border-gray-300 dark:border-gray-600`,`hover:border-primary-400 dark:hover:border-primary-500`,u&&`border-primary-500 dark:border-primary-400 bg-primary-50/50 dark:bg-primary-900/10`,a&&`opacity-50 cursor-not-allowed`),onDragOver:S,onDragLeave:C,onDrop:w,onClick:()=>!a&&l.current?.click(),children:[(0,$.jsx)(`input`,{ref:l,type:`file`,multiple:!0,accept:`image/*,.pdf,.txt`,onChange:e=>{v(e.target.files),e.target.value=``},className:`hidden`,disabled:a}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[p?(0,$.jsx)(L,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2 animate-spin`}):(0,$.jsx)(M,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,$.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:[c(`chat.mediaUpload.dropImagesHere`),` `,(0,$.jsx)(`span`,{className:`text-primary-600 dark:text-primary-400 font-medium`,children:c(`chat.mediaUpload.browse`)})]}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:c(`chat.mediaUpload.supportedFormats`)})]})]}),O&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.map((e,t)=>(0,$.jsxs)(`div`,{className:`relative group w-16 h-16 rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,$.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),T(t)},className:`absolute top-0.5 right-0.5 p-0.5 rounded-full bg-black/60 hover:bg-black/80 text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(z,{className:`h-3 w-3`})})]},`img-${t}`)),g.map(e=>(0,$.jsxs)(`div`,{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[e.fileType===`pdf`?(0,$.jsx)(h,{className:`w-4 h-4 text-red-500 flex-shrink-0`}):(0,$.jsx)(b,{className:`w-4 h-4 text-blue-500 flex-shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100 truncate max-w-[100px]`,children:e.filename}),(0,$.jsx)(`p`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:D(e.size)})]}),(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),E(e.id)},className:`p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-red-500 transition-colors`,children:(0,$.jsx)(z,{className:`h-3 w-3`})})]},e.id))]})]})},sn=H(`components:document-indicator`),cn=({sessionId:e,className:t=``})=>{let[n,r]=(0,Q.useState)([]);if((0,Q.useEffect)(()=>{if(!e)return;let t=async()=>{try{let t=await G.getDocuments(e);t.success&&t.data&&r(t.data)}catch(e){sn.error(`Failed to load documents:`,e)}};t();let n=()=>void t();return window.addEventListener(`libre:documents-updated`,n),()=>window.removeEventListener(`libre:documents-updated`,n)},[e]),!e||n.length===0)return null;let i=n.reduce((e,t)=>e+t.size,0);return(0,$.jsxs)(`div`,{className:`
|
|
4
|
-
inline-flex items-center space-x-1 px-2 py-1
|
|
5
|
-
bg-blue-50 dark:bg-blue-900/20
|
|
6
|
-
border border-blue-200 dark:border-blue-800
|
|
7
|
-
rounded-md text-xs
|
|
8
|
-
${t}
|
|
9
|
-
`,title:`${n.length} document(s) available for context - Total: ${(e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]})(i)}`,children:[(0,$.jsx)(k,{className:`w-3 h-3 text-blue-600 dark:text-blue-400`}),(0,$.jsxs)(`span`,{className:`text-blue-700 dark:text-blue-300 font-medium`,children:[n.length,` doc`,n.length===1?``:`s`]})]})},ln=H(`components:structured-output`),un=[{key:`none`,value:null},{key:`json`,value:`json`},{key:`list`,value:{type:`object`,properties:{items:{type:`array`,items:{type:`string`}}},required:[`items`]}},{key:`summary`,value:{type:`object`,properties:{title:{type:`string`},summary:{type:`string`},key_points:{type:`array`,items:{type:`string`}}},required:[`title`,`summary`,`key_points`]}},{key:`analysis`,value:{type:`object`,properties:{analysis:{type:`string`},pros:{type:`array`,items:{type:`string`}},cons:{type:`array`,items:{type:`string`}},recommendation:{type:`string`}},required:[`analysis`,`pros`,`cons`,`recommendation`]}},{key:`custom`,value:`custom`}],dn=({format:e,onFormatChange:t,className:n})=>{let{t:r}=s(),[i,a]=(0,Q.useState)(!1),[o,c]=(0,Q.useState)(``),u=()=>un.map(e=>({key:e.key,label:r(`chat.structuredOutput.${e.key}`),value:e.value,description:r(`chat.structuredOutput.${e.key}Description`)})),d=()=>{let t=u();return e===null?t[0]:e===`json`?t[1]:typeof e==`object`?t.find(t=>typeof t.value==`object`&&JSON.stringify(t.value)===JSON.stringify(e))||{key:`customSchema`,label:r(`chat.structuredOutput.custom`),value:e,description:r(`chat.structuredOutput.customSchema`)}:t[0]},f=e=>{let n=u().find(t=>t.label===e);if(n){if(n.value===`custom`){a(!0);return}a(!1),t(n.value)}};return(0,$.jsxs)(`div`,{className:J(`space-y-3`,n),children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(l,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.title`)})]})}),(0,$.jsx)(Ie,{value:d().label,onChange:e=>f(e.target.value),options:u().map(e=>({value:e.label,label:e.label}))}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d().description}),i&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Le,{value:o,onChange:e=>c(e.target.value),placeholder:`{
|
|
10
|
-
"type": "object",
|
|
11
|
-
"properties": {
|
|
12
|
-
"field1": { "type": "string" },
|
|
13
|
-
"field2": { "type": "number" }
|
|
14
|
-
},
|
|
15
|
-
"required": ["field1"]
|
|
16
|
-
}`,rows:8,className:`font-mono text-sm`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{onClick:()=>{try{t(JSON.parse(o)),a(!1)}catch(e){ln.error(`Invalid JSON schema:`,e)}},size:`sm`,disabled:!o.trim(),children:r(`chat.structuredOutput.applySchema`)}),(0,$.jsx)(Z,{onClick:()=>{a(!1),c(``)},variant:`outline`,size:`sm`,children:r(`chat.structuredOutput.cancel`)})]})]}),(()=>{let e=d();return!e.value||e.value===`json`?null:(0,$.jsxs)(`div`,{className:`mt-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md`,children:[(0,$.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,$.jsx)(_,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.schemaPreview`)})]}),(0,$.jsx)(`pre`,{className:`text-xs text-gray-700 dark:text-gray-300 overflow-x-auto`,children:JSON.stringify(e.value,null,2)})]})})(),e&&(0,$.jsxs)(`div`,{className:`flex items-center text-xs text-green-600 dark:text-green-400`,children:[(0,$.jsx)(h,{className:`h-3 w-3 mr-1`}),r(`chat.structuredOutput.enabled`)]})]})},fn=H(`components:chat-input`),pn=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},mn=({onSendMessage:e,onStopGeneration:t,disabled:n=!1})=>{let{t:r,i18n:i}=s(),[a,o]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(``),p=(0,Q.useMemo)(()=>!!pn(),[]),[m,g]=(0,Q.useState)([]),[_,v]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=!1;return be.getConfig().then(t=>{!e&&t.success&&t.data&&D(t.data.allowed)}).catch(()=>{}),()=>{e=!0}},[]);let[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(!1),[P,te]=(0,Q.useState)([]),[ne,I]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(!1),B=(0,Q.useRef)(null),V=(0,Q.useRef)(null),{isGenerating:fe,setBackgroundImage:me}=je(),H=je(e=>e.preferences.imageGenSettings?.enabled===!0),W=H&&ce,{currentSession:K,models:ge}=Y(),ve=(0,Q.useRef)(null),ye=(0,Q.useMemo)(()=>({model:K?.personaId?`persona:${K.personaId}`:K?.model||``,providerType:K?.providerType,providerId:K?.providerId}),[K?.model,K?.personaId,K?.providerId,K?.providerType]),q=(0,Q.useMemo)(()=>De(ge,ye),[ge,ye]),xe=ye.model?we(q,ye):``,Se=Te(ge,ye);(0,Q.useEffect)(()=>{let e=!1;return H&&(async()=>{try{let t=await he.getPlugins();if(e)return;le(!!(t.success&&t.data&&t.data.length>0))}catch{if(e)return;le(!1)}})(),()=>{e=!0}},[H]),(0,Q.useEffect)(()=>{if(!S)return;let e=e=>{B.current&&!B.current.contains(e.target)&&(w(!1),j(null))};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[S]);let Ce=()=>{w(!1),j(null),N(!1)};(0,Q.useEffect)(()=>{if(!M)return;let e=!1;return G.getCollections().then(t=>{!e&&t.success&&t.data&&te(t.data)}).catch(()=>{}),()=>{e=!0}},[M]);let Ee=K?.settings?.knowledgeCollectionIds??[],Ae=async e=>{if(!K)return;let t=Ee.includes(e)?Ee.filter(t=>t!==e):[...Ee,e],n={...K.settings,knowledgeCollectionIds:t.length>0?t:void 0};if(Y.setState(e=>({currentSession:e.currentSession?.id===K.id?{...e.currentSession,settings:n}:e.currentSession,sessions:e.sessions.map(e=>e.id===K.id?{...e,settings:n}:e)})),!K.isPrivate)try{await U.updateSession(K.id,{settings:n})}catch(e){fn.error(`Failed to update knowledge collections:`,e),T.error(r(`chat.input.menu.attachFailed`))}};(0,Q.useEffect)(()=>()=>{d.current?.stop()},[]);let X=()=>{if(c){d.current?.stop();return}let e=pn();if(!e)return;let t=new e;t.lang=i.language,t.continuous=!0,t.interimResults=!0,f.current=a,t.onresult=e=>{let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;let n=f.current;o(n?`${n} ${t.trim()}`:t.trim())},t.onend=()=>{d.current=null,l(!1)},t.onerror=()=>{d.current=null,l(!1)},d.current=t;try{t.start(),l(!0)}catch(e){fn.error(`Failed to start dictation:`,e),d.current=null}},Me=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){Ce(),z(!0);try{let e=await G.uploadDocument(t,K?.id);e.success?(T.success(r(`chat.input.menu.documentAttached`)),window.dispatchEvent(new Event(`libre:documents-updated`))):T.error(e.error||r(`chat.input.menu.attachFailed`))}catch(e){fn.error(`Document upload failed:`,e),T.error(r(`chat.input.menu.attachFailed`))}finally{z(!1)}}},Ne=async()=>{let e=A?.trim();if(!(!e||ne)){I(!0);try{let t=await G.fetchWebpage(e,K?.id);t.success?(T.success(r(`chat.input.menu.webpageAttached`)),window.dispatchEvent(new Event(`libre:documents-updated`)),Ce()):T.error(t.error||r(`chat.input.menu.attachFailed`))}catch(e){let t=e?.response?.data?.error||r(`chat.input.menu.attachFailed`);fn.error(`Webpage attach failed:`,e),T.error(t)}finally{I(!1)}}},Pe=t=>{if(t.preventDefault(),!(!a.trim()||fe)){if(!Se){T.error(`Select an available model before sending`);return}e(a.trim(),m.length>0?m:void 0,_||void 0,E&&O?!0:void 0),o(``),g([])}},Fe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Pe(e))},Ie=()=>{t()};(0,Q.useEffect)(()=>{let e=ve.current;e&&(e.style.height=`auto`,e.style.height=a?`${Math.min(e.scrollHeight,200)}px`:``)},[a]),(0,Q.useEffect)(()=>{(async()=>{if(K?.personaId)try{let e=await _e.getPersona(K.personaId);if(e.success&&e.data)ae(e.data);else{fn.warn(`Persona ${K.personaId} not found, clearing reference`),ae(null);let{setCurrentSession:e}=Y.getState();e({...K,personaId:void 0})}}catch(e){if(fn.error(`Failed to load current persona:`,e),ae(null),K){let{setCurrentSession:e}=Y.getState();e({...K,personaId:void 0})}}else ae(null)})()},[K?.personaId]);let Le=async e=>{let t=ke(q,e.target.value);if(t&&K)try{if(t.model.startsWith(`persona:`)){let e=t.model.slice(8),n=await _e.getPersona(e);if(!n.success||!n.data){T.error(`Failed to load persona details`);return}let i=n.data,a=await U.updateSession(K.id,{personaId:e,model:t.model,providerType:`ollama`,providerId:null});if(a.success&&a.data){let{sessions:e}=Y.getState(),t=e.map(e=>e.id===K.id?a.data:e);Y.setState({sessions:t,currentSession:a.data}),i.background&&me(i.background),T.success(r(`chat.persona.applied`))}}else{let e=await U.updateSession(K.id,{model:t.model,providerType:t.providerType,providerId:(t.providerType===`plugin`||t.providerType===`agent`)&&t.providerId||null,personaId:null});if(e.success&&e.data){let{sessions:t}=Y.getState(),n=t.map(t=>t.id===K.id?e.data:t);Y.setState({sessions:n,currentSession:e.data}),me(null),T.success(r(`chat.model.updated`))}}}catch(e){fn.error(`Failed to update session:`,e),T.error(`Failed to update session`)}},Re=m.length>0||_!==null;return(0,$.jsx)(`div`,{className:`pointer-events-none`,children:(0,$.jsxs)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl px-4 sm:px-6 md:px-8`,children:[b&&(0,$.jsxs)(`div`,{className:`mb-2 animate-slide-up rounded-2xl border border-black/[0.07] bg-surface/90 p-4 shadow-[0_12px_40px_rgba(15,23,42,0.08)] backdrop-blur-xl dark:border-white/[0.08] dark:bg-dark-200/90`,children:[(0,$.jsx)(on,{images:m,onImagesChange:g,maxImages:5,sessionId:K?.id,disabled:n}),(0,$.jsx)(dn,{format:_,onFormatChange:v})]}),(0,$.jsxs)(`div`,{className:`pb-2.5 pt-1.5 sm:pb-3`,children:[(0,$.jsx)(`form`,{onSubmit:Pe,children:(0,$.jsxs)(`div`,{className:J(`flex items-end gap-2 rounded-[1.35rem] border p-2 transition-[border-color,box-shadow,background-color] duration-200`,`bg-surface/[0.92] dark:bg-dark-200/[0.92] backdrop-blur-xl`,`border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_1px_2px_rgba(0,0,0,0.03),0_14px_42px_rgba(15,23,42,0.08)]`,`focus-within:border-primary-500/35 focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_52px_rgba(15,23,42,0.11)]`),children:[(0,$.jsxs)(`div`,{ref:B,className:`relative flex-shrink-0`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{if(b){x(!1);return}w(e=>!e),j(null)},className:J(`h-9 w-9 sm:h-10 sm:w-10 !p-0 rounded-full flex-shrink-0`,`text-gray-500 dark:text-dark-600 hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 touch-manipulation`,Re&&`text-primary-600 dark:text-primary-400`,(b||S)&&`bg-gray-100 dark:bg-dark-300`),title:r(`chat.input.attachments`),children:R||ne?(0,$.jsx)(L,{className:`h-4 w-4 animate-spin`}):Re?(0,$.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,$.jsx)(se,{className:`h-4 w-4`}),(0,$.jsx)(`div`,{className:`absolute -top-0.5 -end-0.5 h-2 w-2 bg-primary-500 dark:bg-primary-400 rounded-full ring-2 ring-white dark:ring-dark-50`})]}):b?(0,$.jsx)(de,{className:`h-4 w-4`}):(0,$.jsx)(u,{className:`h-4 w-4`})}),S&&(0,$.jsx)(`div`,{className:`absolute bottom-full start-0 z-30 mb-2 w-64 rounded-2xl border border-black/[0.08] bg-surface/95 p-1.5 shadow-[0_16px_48px_rgba(15,23,42,0.16)] backdrop-blur-xl animate-scale-in dark:border-white/[0.09] dark:bg-dark-100/95`,children:M?(0,$.jsxs)(`div`,{className:`p-1`,children:[(0,$.jsx)(`p`,{className:`mb-1 px-1.5 text-[11px] font-medium text-gray-500 dark:text-dark-600`,children:r(`chat.input.menu.attachKnowledge`)}),P.length===0?(0,$.jsx)(`p`,{className:`px-1.5 pb-1 text-[12px] text-gray-400 dark:text-dark-500`,children:r(`chat.input.menu.noCollections`)}):P.map(e=>{let t=Ee.includes(e.id);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Ae(e.id),className:J(`flex w-full items-center justify-between gap-2 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,t&&`text-primary-600 dark:text-primary-400`),"aria-pressed":t,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(k,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]}),t&&(0,$.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0`})]},e.id)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>N(!1),className:`mt-1 w-full rounded-lg border-t border-gray-100 px-2.5 py-1.5 text-start text-xs text-gray-500 hover:bg-gray-100 dark:border-dark-300 dark:text-dark-600 dark:hover:bg-dark-200`,children:r(`common.back`)})]}):A===null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{x(!0),Ce()},className:`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,children:[(0,$.jsx)(F,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),r(`chat.input.menu.uploadImages`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>V.current?.click(),className:`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,children:[(0,$.jsx)(h,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),r(`chat.input.menu.attachDocument`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>j(``),className:`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,children:[(0,$.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),r(`chat.input.menu.attachWebpage`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`flex w-full items-center justify-between gap-2.5 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),r(`chat.input.menu.attachKnowledge`)]}),Ee.length>0&&(0,$.jsx)(`span`,{className:`rounded-full bg-primary-50 px-1.5 text-[10px] font-medium tabular-nums text-primary-600 dark:bg-primary-900/20 dark:text-primary-400`,children:Ee.length})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{x(!0),Ce()},className:`flex w-full items-center gap-2.5 rounded-xl px-2.5 py-2 text-start text-[13px] text-gray-700 hover:bg-gray-100 dark:text-dark-800 dark:hover:bg-dark-200`,children:[(0,$.jsx)(oe,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),r(`chat.input.menu.structuredOutput`)]})]}):(0,$.jsxs)(`div`,{className:`p-1.5`,children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-[11px] font-medium text-gray-500 dark:text-dark-600`,children:r(`chat.input.menu.attachWebpage`)}),(0,$.jsx)(`input`,{type:`url`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Ne()):e.key===`Escape`&&j(null)},placeholder:`https://…`,autoFocus:!0,dir:`ltr`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-50 dark:text-dark-900`}),(0,$.jsxs)(`div`,{className:`mt-2 flex justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(null),className:`rounded-lg px-2.5 py-1 text-xs text-gray-500 hover:bg-gray-100 dark:text-dark-600 dark:hover:bg-dark-200`,children:r(`common.cancel`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void Ne(),disabled:!A.trim()||ne,className:`rounded-lg bg-gray-900 px-2.5 py-1 text-xs text-white hover:bg-gray-700 disabled:opacity-50 dark:bg-dark-300 dark:hover:bg-dark-400`,children:ne?(0,$.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):r(`chat.input.menu.attach`)})]})]})}),(0,$.jsx)(`input`,{ref:V,type:`file`,accept:`.pdf,.txt,application/pdf,text/plain`,className:`hidden`,onChange:e=>void Me(e)})]}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(rn,{ref:ve,value:a,onChange:e=>o(e.target.value),onKeyDown:Fe,placeholder:r(`chat.input.placeholder`),disabled:n,className:`!m-0 block min-h-9 max-h-[160px] resize-none !rounded-none !border-0 !bg-transparent !px-1.5 !py-1.5 sm:!min-h-10 sm:!py-2 max-[768px]:!min-h-11 max-[768px]:!py-[10.5px] !shadow-none scrollbar-thin scrollbar-thumb-gray-300 placeholder:text-gray-400 focus:!border-0 focus:!bg-transparent focus:!shadow-none focus:!ring-0 dark:scrollbar-thumb-dark-400 dark:placeholder:text-dark-500 text-[0.9375rem] leading-relaxed touch-manipulation`,rows:1})}),(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1 sm:gap-2`,children:[K&&q.length>0&&(0,$.jsx)(`div`,{className:`hidden sm:block`,children:(0,$.jsx)(Ue,{models:q,selectedModel:xe,onModelChange:Le,getModelValue:Oe,currentPersona:ie,className:`min-w-[150px] max-w-[230px]`,compact:!0,showImageGen:W})}),E&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ee(e=>!e),className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`text-gray-500 dark:text-dark-600 hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 touch-manipulation`,O&&`bg-primary-50 text-primary-600 dark:bg-primary-900/25 dark:text-primary-400`),title:r(O?`chat.input.webSearchOn`:`chat.input.webSearchOff`),"aria-pressed":O,children:(0,$.jsx)(C,{className:`h-4 w-4`})}),p&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:X,className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`text-gray-500 dark:text-dark-600 hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 touch-manipulation`,c&&`bg-red-50 text-red-500 animate-pulse dark:bg-red-900/20 dark:text-red-400`),title:r(c?`chat.input.voiceStop`:`chat.input.voiceInput`),"aria-pressed":c,children:(0,$.jsx)(re,{className:`h-4 w-4`})}),fe?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:Ie,className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`bg-red-50 dark:bg-red-900/20`,`text-red-500 dark:text-red-400`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`transition-colors duration-150 touch-manipulation`),title:r(`chat.input.stopGeneration`),children:(0,$.jsx)(pe,{className:`h-4 w-4`})}):(0,$.jsx)(Z,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!a.trim()||n||!Se,className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`bg-gray-100 text-gray-400 dark:bg-dark-300 dark:text-dark-500`,`disabled:cursor-not-allowed disabled:opacity-70`,`transition-colors duration-150 touch-manipulation`,a.trim()&&!n&&Se&&[`bg-gray-950 text-white hover:bg-gray-800`,`dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,`shadow-sm`]),title:r(`chat.input.sendMessage`),children:(0,$.jsx)(y,{className:`h-4 w-4`})})]})]})}),K&&q.length>0&&(0,$.jsx)(`div`,{className:`mt-3 sm:hidden`,children:(0,$.jsx)(Ue,{models:q,selectedModel:xe,onModelChange:Le,getModelValue:Oe,currentPersona:ie,className:`w-full`,compact:!0,showImageGen:W})}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex min-h-4 items-center justify-center gap-2 text-[10px] text-gray-400 dark:text-dark-500`,children:[(0,$.jsx)(cn,{sessionId:K?.id}),(0,$.jsxs)(`div`,{className:`text-center leading-relaxed`,children:[(0,$.jsx)(`span`,{children:r(`chat.footer.disclaimer`)}),Re&&(0,$.jsxs)(`span`,{className:`ms-2 text-primary-600 dark:text-primary-400`,children:[`•`,` `,m.length>0&&r(`chat.footer.images`,{count:m.length}),m.length>0&&_&&` • `,_&&r(`chat.footer.structuredOutput`)]})]})]})]})]})})},hn=H(`components:chat-controls-panel`),gn=[{key:`temperature`,labelKey:`temperature`,step:`0.1`,min:0,max:2},{key:`top_p`,labelKey:`topP`,step:`0.05`,min:0,max:1},{key:`top_k`,labelKey:`topK`,step:`1`,min:1},{key:`min_p`,labelKey:`minP`,step:`0.05`,min:0,max:1},{key:`num_predict`,labelKey:`maxTokens`,step:`1`},{key:`repeat_penalty`,labelKey:`repeatPenalty`,step:`0.05`,min:0},{key:`seed`,labelKey:`seed`,step:`1`},{key:`num_ctx`,labelKey:`contextLength`,step:`1`}],_n=({session:e,draftModel:t,open:n,onClose:r})=>{let{t:i}=s(),a=Y(e=>e.draftSessionSettings),o=Y(e=>e.setDraftSessionSettings),c=e?.model??t??``,l=je(e=>e.preferences.generationOptions),u=je(e=>e.preferences.modelGenerationOptions?.[c]),[d,p]=(0,Q.useState)({options:{},contextCapped:!1});(0,Q.useEffect)(()=>{if(!n||!c)return;let e=!1;return ye.getModelDefaults(c).then(t=>{e||!t.success||!t.data||p({options:t.data.options??{},trainedContextLength:t.data.trainedContextLength,contextCapped:!!t.data.contextCapped})}).catch(()=>{}),()=>{e=!0}},[n,c]);let m=(0,Q.useMemo)(()=>({...l??{},...d.options,...u??{}}),[l,d.options,u]),h=(0,Q.useMemo)(()=>e?.messages.find(e=>e.role===`system`),[e?.messages]),[g,_]=(0,Q.useState)(h?.content??a.systemPrompt??``),[v,y]=(0,Q.useState)(e?.settings?.generationOptions??a.generationOptions??{}),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(e?.id??`draft`),w=e?.id??`draft`;S!==w&&(C(w),_(h?.content??a.systemPrompt??``),y(e?.settings?.generationOptions??a.generationOptions??{}));let T=(e,t)=>{y(n=>{let r={...n};if(t===``)delete r[e];else{let n=Number(t);Number.isNaN(n)||(r[e]=n)}return r})},E=async()=>{x(!0);try{let t=g.trim(),n=h?.content??``,a=Object.fromEntries(Object.entries(v).filter(([,e])=>e!==void 0)),s=Object.keys(a).length>0?{generationOptions:a}:void 0;if(!e){o({systemPrompt:t||void 0,generationOptions:s?.generationOptions}),f.success(i(`chat.controls.saved`)),r();return}let c=e.messages;if(t!==n.trim()&&(h?c=t?e.messages.map(e=>e.id===h.id?{...e,content:t}:e):e.messages.filter(e=>e.id!==h.id):t&&(c=[{id:Ce(),role:`system`,content:t,timestamp:Date.now()},...e.messages])),e.isPrivate)Y.setState(t=>({currentSession:t.currentSession?.id===e.id?{...t.currentSession,messages:c,settings:s}:t.currentSession}));else{let t=await U.updateSession(e.id,{messages:c,settings:s});if(!t.success||!t.data)throw Error(t.error||`Update failed`);let n=t.data;Y.setState(t=>({sessions:t.sessions.map(t=>t.id===e.id?n:t),currentSession:t.currentSession?.id===e.id?n:t.currentSession}))}f.success(i(`chat.controls.saved`)),r()}catch(e){hn.error(`Failed to save chat controls:`,e),f.error(i(`chat.controls.saveFailed`))}finally{x(!1)}};return n?(0,$.jsxs)(`div`,{"data-testid":`chat-controls-panel`,className:`flex h-full w-[21rem] shrink-0 flex-col border-s border-black/[0.06] bg-surface/70 backdrop-blur-xl dark:border-white/[0.07] dark:bg-dark-100/70`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:i(`chat.controls.title`)}),(0,$.jsx)(`button`,{onClick:r,className:`rounded-full p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-900`,title:i(`common.close`),children:(0,$.jsx)(z,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-2 scrollbar-thin`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500 dark:text-dark-500`,children:i(`chat.controls.systemPrompt`)}),(0,$.jsx)(`textarea`,{dir:`auto`,value:g,onChange:e=>_(e.target.value),placeholder:i(`chat.controls.systemPromptPlaceholder`),className:`min-h-[110px] w-full resize-y rounded-xl border border-black/[0.08] bg-white p-2.5 text-[13px] leading-relaxed text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-50 dark:text-dark-900 dark:placeholder:text-dark-500`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-1.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500 dark:text-dark-500`,children:i(`chat.controls.advancedParams`)}),(0,$.jsx)(`p`,{className:`mb-2.5 text-[11px] leading-snug text-gray-400 dark:text-dark-500`,children:i(`chat.controls.advancedParamsDescription`)}),d.contextCapped&&d.trainedContextLength&&(0,$.jsx)(`p`,{className:`mb-2.5 text-[11px] leading-snug text-gray-500 dark:text-dark-600`,children:i(`chat.controls.contextCapped`,{context:m.num_ctx?.toLocaleString(),trained:d.trainedContextLength.toLocaleString()})}),(0,$.jsx)(`div`,{className:`space-y-1.5`,children:gn.map(e=>{let t=v[e.key],n=m[e.key],r=d.options[e.key]!==void 0&&u?.[e.key]===void 0;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`label`,{htmlFor:`chat-control-${e.key}`,className:`text-[13px] text-gray-700 dark:text-dark-700`,children:[i(`chat.controls.params.${e.labelKey}`),r&&(0,$.jsx)(`span`,{title:i(`chat.controls.fromModelHint`),className:`ms-1.5 text-[10px] uppercase tracking-wide text-gray-400 dark:text-dark-500`,children:i(`chat.controls.fromModel`)})]}),(0,$.jsx)(`input`,{id:`chat-control-${e.key}`,type:`number`,inputMode:`decimal`,step:e.step,min:e.min,max:e.max,value:typeof t==`number`?t:``,placeholder:typeof n==`number`?String(n):i(`common.default`),onChange:t=>T(e.key,t.target.value),className:`w-24 rounded-lg border border-black/[0.08] bg-white px-2 py-1 text-end text-[12px] tabular-nums text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-50 dark:text-dark-900 dark:placeholder:text-dark-500`})]},e.key)})})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t border-black/[0.06] px-4 py-3 dark:border-white/[0.07] lg:pb-16`,children:[(0,$.jsx)(`button`,{onClick:()=>{y({}),_(h?.content??``)},className:`text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-600 dark:hover:text-dark-900`,children:i(`common.reset`)}),(0,$.jsx)(Z,{onClick:()=>void E(),size:`sm`,disabled:b,children:i(b?`common.saving`:`common.save`)})]})]}):null},vn=6,yn=[],bn=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}},xn=({session:e})=>{let{t}=s(),[n,r]=(0,Q.useState)({sessionId:``,docs:yn}),i=!e.isPrivate&&n.sessionId===e.id?n.docs:yn,[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),{webSources:f,ragSources:p}=(0,Q.useMemo)(()=>{let t=new Map,n=new Map;for(let r of e.messages){let e=r.providerMetadata;if(Array.isArray(e?.webSearchSources))for(let n of e.webSearchSources){let e=n;e&&typeof e.url==`string`&&e.url&&t.set(e.url,{url:e.url,title:typeof e.title==`string`&&e.title?e.title:e.url})}if(Array.isArray(e?.ragSources))for(let t of e.ragSources){let e=t;e&&typeof e.id==`string`&&e.id&&n.set(e.id,{id:e.id,filename:typeof e.filename==`string`&&e.filename?e.filename:e.id})}}return{webSources:Array.from(t.values()),ragSources:Array.from(n.values())}},[e.messages]);(0,Q.useEffect)(()=>{if(e.isPrivate)return;let t=!1,n=()=>{G.getDocuments(e.id).then(n=>{t||!n.success||!Array.isArray(n.data)||r({sessionId:e.id,docs:n.data.map(e=>({id:e.id,filename:e.filename}))})}).catch(()=>{})};return n(),window.addEventListener(`libre:documents-updated`,n),()=>{t=!0,window.removeEventListener(`libre:documents-updated`,n)}},[e.id,e.isPrivate]);let m=(0,Q.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,{...t,used:!1});for(let t of p)e.set(t.id,{id:t.id,filename:t.filename,used:!0});return Array.from(e.values())},[i,p]);if(f.length===0&&m.length===0)return null;let g=a?f:f.slice(0,vn),_=c?m:m.slice(0,vn),v=(e,n,r)=>(e>0||n)&&(0,$.jsx)(`button`,{type:`button`,onClick:r,className:`mt-1 flex items-center gap-1 px-1 text-[12px] text-gray-400 transition-colors hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(le,{className:`h-3 w-3`}),t(`chatMessage.showLess`,`Show less`)]}):`${t(`chatMessage.showMore`)} (${e})`}),y=(0,$.jsxs)($.Fragment,{children:[f.length>0&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-2 text-[13px] font-medium text-gray-500 dark:text-dark-500`,children:t(`chat.message.sources`,`Sources`)}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:g.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`group -mx-1 flex items-center gap-2.5 rounded-lg px-1 py-1.5 transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.05]`,title:e.url,children:[(0,$.jsx)(C,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-700 dark:text-dark-500 dark:group-hover:text-dark-800`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-[13px] leading-snug text-gray-800 dark:text-dark-800`,children:e.title}),(0,$.jsx)(`span`,{dir:`ltr`,className:`block truncate text-[11px] text-gray-400 dark:text-dark-500`,children:bn(e.url)})]})]})},e.url))}),v(f.length-g.length,a,()=>o(e=>!e))]}),m.length>0&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-2 text-[13px] font-medium text-gray-500 dark:text-dark-500`,children:t(`settings.tabs.documents`,`Documents`)}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:_.map(e=>(0,$.jsxs)(`li`,{className:`-mx-1 flex items-center gap-2.5 rounded-lg px-1 py-1.5`,title:e.filename,children:[(0,$.jsx)(h,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,$.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-[13px] leading-snug text-gray-800 dark:text-dark-800`,children:e.filename}),e.used&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary-500`})]},e.id))}),v(m.length-_.length,c,()=>l(e=>!e))]})]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`aside`,{"data-testid":`chat-sources-panel`,className:`hidden w-72 shrink-0 flex-col gap-7 overflow-y-auto border-s border-black/[0.05] px-5 py-6 scrollbar-thin dark:border-white/[0.06] xl:flex`,children:y}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),"data-testid":`chat-sources-trigger`,className:`absolute end-3 top-[4.25rem] z-20 flex h-8 w-8 items-center justify-center rounded-full border border-black/[0.07] bg-surface/65 text-gray-500 backdrop-blur-md transition-colors duration-150 hover:bg-surface-raised hover:text-gray-950 dark:border-white/[0.08] dark:bg-dark-200/65 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 xl:hidden`,title:t(`chat.message.sources`,`Sources`),"aria-haspopup":`dialog`,"aria-expanded":u,children:[(0,$.jsx)(k,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:f.length+m.length})]}),u&&(0,We.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-[80] xl:hidden`,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>d(!1),"aria-label":t(`common.close`)}),(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":t(`chat.message.sources`,`Sources`),className:`absolute inset-x-3 bottom-3 max-h-[75vh] overflow-y-auto rounded-2xl border border-black/[0.08] bg-surface p-5 shadow-[0_20px_70px_rgba(0,0,0,0.3)] scrollbar-thin dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`chat-sources-sheet`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:t(`chat.message.sources`,`Sources`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`rounded-md p-1.5 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,"aria-label":t(`common.close`),children:(0,$.jsx)(z,{className:`h-4 w-4`})})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:y})]})]}),document.body)]})},Sn=({persona:e,onClear:t,className:n})=>{let[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)({top:0,left:0});(0,Q.useEffect)(()=>{if(r&&a.current){let e=a.current.getBoundingClientRect(),t=document.documentElement.dir===`rtl`?e.right-288:e.left;s({top:e.bottom+8,left:Math.min(window.innerWidth-288-8,Math.max(8,t))})}},[r]);let c=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),l=()=>q(e,64),u=t=>{K(t.currentTarget,e.name,64)};return(0,$.jsxs)(`div`,{className:J(`relative`,n),children:[(0,$.jsxs)(`button`,{ref:a,onClick:()=>i(!r),className:J(`flex items-center gap-2 px-3 py-1.5 rounded-full transition-all duration-200`,`bg-primary-50 dark:bg-primary-900/30`,`border border-primary-200 dark:border-primary-700/50`,`hover:bg-primary-100 dark:hover:bg-primary-900/40`,`text-primary-700 dark:text-primary-300`),children:[(0,$.jsx)(`img`,{src:l(),alt:e.name,className:`w-5 h-5 rounded-full object-cover`,onError:u}),(0,$.jsx)(`span`,{className:`text-sm font-medium max-w-[120px] truncate`,children:e.name}),c&&(0,$.jsx)(w,{className:`h-3 w-3 text-purple-500 dark:text-purple-400`}),(0,$.jsx)(ae,{className:J(`h-3.5 w-3.5 transition-transform duration-200`,r&&`rotate-180`)})]}),r&&(0,We.createPortal)((0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9998]`,onClick:()=>i(!1)}),(0,$.jsx)(`div`,{className:`fixed w-72 z-[9999]`,style:{top:o.top,left:o.left},children:(0,$.jsxs)(`div`,{className:J(`rounded-xl overflow-hidden shadow-xl`,`bg-white dark:bg-dark-100`,`border border-gray-200 dark:border-dark-300`),children:[(0,$.jsxs)(`div`,{className:`relative h-16`,children:[e.background?(0,$.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-primary-400 via-primary-500 to-purple-600 dark:from-primary-600 dark:via-primary-700 dark:to-purple-800`}),(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/10`}),t&&(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(),i(!1)},className:`absolute top-2 end-2 p-1 rounded-full bg-white/20 hover:bg-white/30 backdrop-blur-sm transition-colors`,title:`Remove persona`,children:(0,$.jsx)(z,{className:`h-3.5 w-3.5 text-white`})}),c&&(0,$.jsxs)(`div`,{className:`absolute top-2 start-2 flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/20 backdrop-blur-sm text-white text-[10px] font-medium`,children:[(0,$.jsx)(N,{className:`h-3 w-3`}),`Enhanced`]})]}),(0,$.jsx)(`div`,{className:`relative px-4 -mt-6`,children:(0,$.jsx)(`img`,{src:l(),alt:e.name,className:`w-12 h-12 rounded-lg object-cover ring-3 ring-white dark:ring-dark-100 shadow-md`,onError:u})}),(0,$.jsxs)(`div`,{className:`px-4 pt-2 pb-4`,children:[(0,$.jsx)(`h4`,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:e.name}),(0,$.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 flex items-center gap-1 mt-0.5`,children:[(0,$.jsx)(I,{className:`h-3 w-3`}),e.model]}),e.description&&(0,$.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mt-2 line-clamp-2`,children:e.description}),e.parameters.system_prompt&&(0,$.jsxs)(`div`,{className:`mt-3 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-100 dark:border-dark-200`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mb-1`,children:[(0,$.jsx)(B,{className:`h-2.5 w-2.5 text-gray-400`}),(0,$.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider font-medium text-gray-400`,children:`System`})]}),(0,$.jsxs)(`p`,{className:`text-[11px] text-gray-600 dark:text-gray-400 line-clamp-2 italic`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-3`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[(0,$.jsx)(V,{className:`h-2.5 w-2.5`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),e.memory_settings?.enabled&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300`,children:[(0,$.jsx)(N,{className:`h-2.5 w-2.5`}),`Memory`]})]})]})]})})]}),document.body)]})},Cn=({images:e,onImagesChange:t,maxImages:n=5,className:r})=>{let{t:i}=s(),a=(0,Q.useRef)(null),[o,c]=(0,Q.useState)(!1),l=r=>{if(!r)return;let i=[],a=n-e.length;for(let n=0;n<Math.min(r.length,a);n++){let o=r[n];if(!o.type.startsWith(`image/`)){f.error(`File ${o.name} is not an image`);continue}if(o.size>10485760){f.error(`Image ${o.name} is too large (max 10MB)`);continue}let s=new FileReader;s.onload=n=>{n.target?.result&&(i.push(n.target.result),i.length===Math.min(r.length,a)&&t([...e,...i]))},s.readAsDataURL(o)}r.length>a&&f.error(`Only ${a} more images can be added`)},u=e=>{e.preventDefault(),c(!0)},d=e=>{e.preventDefault(),c(!1)},p=e=>{e.preventDefault(),c(!1),l(e.dataTransfer.files)},m=n=>{t(e.filter((e,t)=>t!==n))},h=e.length<n;return(0,$.jsxs)(`div`,{className:J(`space-y-3`,r),children:[h&&(0,$.jsxs)(`div`,{className:J(`border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 transition-colors`,`hover:border-primary-400 dark:hover:border-primary-500`,o&&`border-primary-500 bg-primary-50 dark:bg-primary-900/20`),onDragOver:u,onDragLeave:d,onDrop:p,children:[(0,$.jsx)(`input`,{ref:a,type:`file`,multiple:!0,accept:`image/*`,onChange:e=>l(e.target.files),className:`hidden`}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(M,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,$.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-2`,children:[i(`chat.mediaUpload.dropImagesHere`),` `,(0,$.jsx)(`button`,{onClick:()=>a.current?.click(),className:`text-primary-600 dark:text-primary-400 hover:underline font-medium`,children:i(`chat.mediaUpload.browse`)})]}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`chat.mediaUpload.supportedFormats`)})]})]}),e.length>0&&(0,$.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3`,children:e.map((e,t)=>(0,$.jsxs)(`div`,{className:`relative group aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,$.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-50 transition-all duration-200 flex items-center justify-center`,children:(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:()=>m(t),className:`opacity-0 group-hover:opacity-100 transition-opacity bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-red-100 dark:hover:bg-red-900/20 hover:text-red-600 dark:hover:text-red-400 p-1 rounded-full`,children:(0,$.jsx)(z,{className:`h-4 w-4`})})})]},t))}),h&&e.length>0&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>a.current?.click(),className:`w-full sm:w-auto`,children:[(0,$.jsx)(F,{className:`h-4 w-4 mr-2`}),`Add More Images (`,e.length,`/`,n,`)`]})]})},wn=H(`use-chat`),Tn=new Set([`New Chat`,`New Demo Session`]),En=e=>!e||Tn.has(e),Dn=e=>{let[t,n]=(0,Q.useState)(``),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)([]),{addMessage:d,updateMessage:p,updateMessageWithStatistics:m,applySessionTitle:h,setGeneratingTitleForSession:g}=Y(),{setIsGenerating:_}=je(),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(0,Q.useRef)(!1),x=(0,Q.useRef)(null),S=(0,Q.useRef)(``),C=(0,Q.useRef)(``),w=(0,Q.useRef)(0),T=(0,Q.useRef)(void 0),E=(0,Q.useRef)(null),D=(0,Q.useRef)(``),O=(0,Q.useRef)(``),k=(0,Q.useCallback)(()=>{E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null},[]),ee=(0,Q.useCallback)((e,t=!1,r=``)=>{if(D.current=e,O.current=r,t||typeof window>`u`){k(),n(e),i(r);return}E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null,n(D.current),i(O.current)}))},[k]),A=(0,Q.useCallback)(()=>{k(),D.current=``,O.current=``,n(``),i(``)},[k]),j=(0,Q.useCallback)(()=>{y.current=null,b.current=!1,x.current=null},[]),M=(0,Q.useCallback)(async e=>{let t=je.getState().preferences.titleSettings,n=y.current,r=b.current&&x.current===e;if(wn.debug(`Auto-title check:`,{firstMessage:n,autoTitle:t?.autoTitle,taskModel:t?.taskModel,shouldGenerateTitle:r}),!n||!r||!t?.autoTitle||!t?.taskModel){j();return}j(),wn.debug(`Triggering auto-title generation...`),g(e);try{let r=await U.generateTitle(e,t.taskModel,n,t.taskProviderType,t.taskProviderId);if(wn.debug(`Title generation response:`,r),!r.success||!r.data?.title)throw Error(r.error||`Title generation returned no title`);h(e,r.data.title,r.data.updatedAt),r.data.source===`fallback`?f.error(`Could not generate a title; using the message preview`):f.success(`Chat title generated`)}catch(e){wn.error(`Failed to generate title:`,e),f.error(`Failed to generate chat title`)}finally{g(null)}},[h,j,g]);(0,Q.useEffect)(()=>()=>{X.offMessage(`user_message`),X.offMessage(`assistant_chunk`),X.offMessage(`assistant_complete`),X.offMessage(`tool_status`),X.offMessage(`error`)},[e]),(0,Q.useEffect)(()=>{if(!e){X.offMessage(`user_message`),X.offMessage(`assistant_chunk`),X.offMessage(`assistant_complete`),X.offMessage(`tool_status`),X.offMessage(`error`);return}return X.onMessage(`user_message`,()=>{}),X.onMessage(`assistant_chunk`,t=>{let n=t,r=n.messageId||v.current;r&&(S.current=n.total,typeof n.thinkingTotal==`string`&&(C.current=n.thinkingTotal),tt(r,n.total,C.current),ee(n.total,n.done,C.current),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{p(e,r,S.current),w.current=Date.now()},n.done?0:200))}),X.onMessage(`tool_status`,e=>{let t=e;u(e=>e.find(e=>e.toolCallId===t.toolCallId)?e.map(e=>e.toolCallId===t.toolCallId?{...e,phase:t.phase}:e):[...e,{toolCallId:t.toolCallId,name:t.name,phase:t.phase,startedAt:Date.now()}])}),X.onMessage(`assistant_complete`,t=>{let n=t;wn.debug(`Hook: Received assistant_complete for session:`,e,`messageId:`,n.messageId,`with statistics:`,!!n.statistics),c(!1),A(),_(!1),u([]);let r=n.messageId||v.current;if(n&&r){let t=S.current||n.content,i=C.current||n.thinking,a=rt(r),o=n.statistics?.thinking_duration_ms===void 0&&a!==void 0?{...n.statistics,thinking_duration_ms:a}:n.statistics;m(e,r,t,o,n.providerMetadata,i)}M(e),v.current=null,S.current=``,C.current=``,T.current&&clearTimeout(T.current),w.current=0}),X.onMessage(`error`,e=>{let t=e;if(c(!1),A(),_(!1),v.current=null,C.current=``,t.code===`SESSION_NOT_FOUND`){wn.warn(`Session not found, redirecting to create new session...`),f.error(`Session not found. Creating a new session...`),window.location.href=`/`;return}f.error(t.error),j()}),c(!1),A(),v.current=null,C.current=``,()=>{T.current&&clearTimeout(T.current),k()}},[e,p,m,_,ee,A,k,M,j]);let N=(0,Q.useCallback)(async(t,n,r,i)=>{if(!(!e||!t.trim()&&(!n||n.length===0)))try{let a=Y.getState(),s=a.currentSession,l={model:s?.personaId?`persona:${s.personaId}`:s?.model||``,providerType:s?.providerType,providerId:s?.providerId};if(!Te(a.models,l)){f.error(`Select an available model before sending`);return}_(!0),c(!0),A(),T.current&&clearTimeout(T.current),w.current=Date.now();let u=s?.isPrivate===!0,m=s?.messages?.some(e=>e.role===`user`);!u&&!m&&En(s?.title)?(y.current=t.trim(),b.current=!0,x.current=e):(y.current=null,b.current=!1,x.current=null),d(e,{role:`user`,content:t.trim(),images:n});let h=Ce();if(v.current=h,C.current=``,o(h),d(e,{role:`assistant`,content:``,id:h}),me()){let n=`Demo response for: ${t.trim()}`;window.setTimeout(()=>{p(e,h,n),c(!1),A(),o(null),_(!1),M(e),v.current=null,S.current=``,C.current=``},500);return}X.isConnected||await X.connect();let g=u?s?.messages?.filter(e=>e.role!==`system`&&e.id!==h).map(e=>({role:e.role,content:e.content,thinking:e.thinking,images:e.images,providerMetadata:e.providerMetadata})):void 0;X.send({type:`chat_stream`,data:{sessionId:e,content:t.trim(),images:n,format:r,options:s?.settings?.generationOptions??{},assistantMessageId:h,isPrivate:u,...i===!0?{webSearch:!0}:{},...u?{model:s?.model,providerType:s?.providerType,providerId:s?.providerId,messageHistory:g}:{}}})}catch(e){wn.error(`Failed to send message:`,e),c(!1),A(),o(null),_(!1),v.current=null,C.current=``,f.error(`Failed to send message`)}},[e,d,p,_,A,M]),P=(0,Q.useCallback)(()=>{c(!1),A(),o(null),_(!1),v.current=null,C.current=``},[_,A]),te=(0,Q.useCallback)(async()=>{let t=Y.getState(),n=t.currentSession;if(!n||!e)return;if(!Te(t.models,{model:n.personaId?`persona:${n.personaId}`:n.model,providerType:n.providerType,providerId:n.providerId})){f.error(`Select an available model before regenerating`);return}let r=n.messages,i=-1,a=-1;for(let e=r.length-1;e>=0;e--)if(r[e].role===`assistant`){a=e;break}if(a>0){for(let e=a-1;e>=0;e--)if(r[e].role===`user`){i=e;break}}if(i===-1||a===-1){f.error(`No message to regenerate`);return}let s=r[i],l=r[a];try{_(!0),c(!0),A(),T.current&&clearTimeout(T.current),w.current=Date.now();let t=Ce();v.current=t,C.current=``,o(t),d(e,{role:`assistant`,content:``,id:t,parentId:l.parentId||l.id,branchIndex:l.siblingCount||1,isActive:!0}),X.isConnected||await X.connect();let i=n.isPrivate===!0,a=i?r.filter(e=>e.role!==`system`).map(e=>({role:e.role,content:e.content,thinking:e.thinking,images:e.images,providerMetadata:e.providerMetadata})):void 0;X.send({type:`chat_stream`,data:{sessionId:e,content:s.content,images:s.images,options:n.settings?.generationOptions??{},assistantMessageId:t,regenerate:!0,originalMessageId:l.id,isPrivate:i,...i?{model:n.model,providerType:n.providerType,providerId:n.providerId,messageHistory:a}:{}}})}catch(e){wn.error(`Failed to regenerate message:`,e),c(!1),A(),o(null),_(!1),v.current=null,C.current=``,f.error(`Failed to regenerate message`)}},[e,_,A,d]),F=(0,Q.useCallback)(async t=>{let n=Y.getState().currentSession;if(!n||!e)return;let r=n.messages.find(e=>e.id===t);if(!r){f.error(`Message not found`);return}if(r.isActive!==!1)return;let i=r.parentId||r.id,a=r.branchIndex||0;try{let r=await U.switchMessageBranch(e,t,a);if(r.success&&r.data){let r=n.messages.map(e=>e.id===i||e.parentId===i?{...e,isActive:e.id===t}:e),o={...n,messages:r,updatedAt:Date.now()};Y.setState(t=>({sessions:t.sessions.map(t=>t.id===e?o:t),currentSession:o})),f.success(`Switched to variant ${a+1}`)}else f.error(r.error||`Failed to select branch`)}catch(e){wn.error(`Failed to select branch:`,e),f.error(`Failed to select branch`)}},[e]);return{sendMessage:N,stopGeneration:P,regenerateLastMessage:te,editAndResendMessage:(0,Q.useCallback)(async(t,n)=>{if(!e||!n.trim())return;let r=Y.getState(),i=r.currentSession;if(!i||i.id!==e)return;let a=i.messages.findIndex(e=>e.id===t);if(a===-1||i.messages[a].role!==`user`)return;let o=i.messages[a],s=i.messages.slice(0,a);try{i.isPrivate||await U.updateSession(e,{messages:s}),r.truncateMessagesFrom(e,t),await N(n,o.images)}catch(e){wn.error(`Failed to edit message:`,e),f.error(`Failed to edit message`)}},[e,N]),selectBranch:F,isStreaming:s,streamingMessage:t,streamingThinking:r,streamingMessageId:a,toolActivities:l}},On=H(`pages:chat-page`),kn=(e,t,n=!1)=>{let r=new Date().getHours(),i=e?`${n?`،`:`,`} \u2068${e}\u2069`:``;return r>=5&&r<12?{id:`time`,title:`${t?t(`chat.greeting.morning`):`Good morning`}${i}`,subtitle:t?t(`chat.welcome.helpToday`):`What can I help with today?`}:r>=12&&r<17?{id:`time`,title:`${t?t(`chat.greeting.afternoon`):`Good afternoon`}${i}`,subtitle:t?t(`chat.welcome.helpToday`):`What can I help with today?`}:r>=17&&r<21?{id:`time`,title:`${t?t(`chat.greeting.evening`):`Good evening`}${i}`,subtitle:t?t(`chat.welcome.helpTonight`):`What can I help with tonight?`}:{id:`time`,title:`${t?t(`chat.greeting.night`):`Good night`}${i}`,subtitle:t?t(`chat.welcome.helpTonight`):`What can I help with tonight?`}},An=(e,t,n,r=!1)=>{let i=Ne(e);return i===`time`?kn(t,n,r):{id:i,title:n?n(`chat.welcome.variety.${i}.title`):`What should we make?`,subtitle:n?n(`chat.welcome.variety.${i}.subtitle`):`Start with a thought, a sketch, or a stubborn problem.`}},jn=()=>{let{t:e,i18n:t}=s(),{sessionId:n}=a(),r=i(),l=o(),{currentSession:m,sessions:h,models:g,selectedModel:_,selectedProviderType:v,selectedProviderId:b,setSelectedModel:x,createSession:S,setCurrentSession:w,loadSessions:T,getCurrentPersona:E}=Y(),{user:D}=Ae(),O=je(e=>e.preferences.imageGenSettings?.enabled===!0),{sendMessage:k,stopGeneration:ee,regenerateLastMessage:A,editAndResendMessage:j,selectBranch:M,isStreaming:N,streamingMessage:P,streamingThinking:te,streamingMessageId:F,toolActivities:ne}=Dn(m?.id||``),I=E(),L=(0,Q.useMemo)(()=>({model:_,providerType:v,providerId:b}),[_,b,v]),R=(0,Q.useMemo)(()=>De(g,L),[g,L]),z=_?we(R,L):``,re=Te(g,L),ie=new URLSearchParams(l.search).get(`incognito`)===`1`,[ae,oe]=(0,Q.useState)(Me),[ce,le]=(0,Q.useState)(null),[B,ue]=(0,Q.useState)(!1),V=je(e=>e.preferences.showFollowUpSuggestions!==!1),fe=(0,Q.useRef)(null),pe=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=m?.id,t=pe.current&&!N;if(pe.current=N,!e||N||!V||m?.isPrivate||!t)return;let n=m.messages[m.messages.length-1];if(!n||n.role!==`assistant`||!n.content.trim()||fe.current===n.id)return;fe.current=n.id;let r=!1;return U.generateFollowUps(e).then(t=>{r||!t.success||Y.getState().currentSession?.id===e&&le({sessionId:e,suggestions:t.data?.suggestions??[]})}).catch(()=>{}),()=>{r=!0}},[N,m,V]);let me=ce&&ce.sessionId===m?.id?ce.suggestions:[],H=(0,Q.useMemo)(()=>An(ae,D?.username,e,c(t.language)),[t.language,e,D?.username,ae]),[W,K]=(0,Q.useState)(``),[ge,_e]=(0,Q.useState)([]),[ve,ye]=(0,Q.useState)(!1),[q,xe]=(0,Q.useState)(!1),[Se,X]=(0,Q.useState)(!1),Ne=(0,Q.useRef)(null),Ie=async t=>{let n=t.target.files?.[0];if(t.target.value=``,n){X(!0);try{let t=await G.uploadDocument(n);t.success?(f.success(e(`chat.input.menu.documentAttached`)),window.dispatchEvent(new Event(`libre:documents-updated`))):f.error(t.error||e(`chat.input.menu.attachFailed`))}catch(t){On.error(`Document upload failed:`,t),f.error(e(`chat.input.menu.attachFailed`))}finally{X(!1)}}};(0,Q.useEffect)(()=>{let e=!1;return be.getConfig().then(t=>{!e&&t.success&&t.data&&ye(t.data.allowed)}).catch(()=>{}),()=>{e=!0}},[]);let[Le,Re]=(0,Q.useState)(!1),ze=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=()=>{oe(Me())};return window.addEventListener(Pe,e),()=>window.removeEventListener(Pe,e)},[]);let[Be,Ve]=(0,Q.useState)(!1),He=O&&Be,We=(0,Q.useCallback)((t=!0)=>{let n=_?L:g[0]?Ee(g[0]):null;if(!n||!Te(g,n))return t&&f.error(e(`chat.model.selectBeforePrivateChat`)),!1;let r=Date.now();return w({id:`private-${r}`,title:e(`chat.session.incognito`,`Incognito Chat`),model:n.model,providerType:n.providerType,providerId:n.providerId,messages:[],createdAt:r,updatedAt:r,isPrivate:!0}),!0},[g,_,L,w,e]);(0,Q.useEffect)(()=>{h.length===0&&T()},[T,h.length]),(0,Q.useEffect)(()=>{!ie||m?.isPrivate||We(!1)},[m?.isPrivate,ie,We]),(0,Q.useEffect)(()=>{let e=!1;return O&&(async()=>{try{let t=await he.getPlugins();if(e)return;Ve(!!(t.success&&t.data&&t.data.length>0))}catch{if(e)return;Ve(!1)}})(),()=>{e=!0}},[O]),(0,Q.useEffect)(()=>{(()=>{if(sessionStorage.getItem(`forceWelcomeScreen`)){sessionStorage.removeItem(`forceWelcomeScreen`);return}if(!(m?.isPrivate&&!n)&&h.length!==0)if(n){let e=h.find(e=>e.id===n);e&&e.id!==m?.id?w(e):e||(On.warn(`Session ${n} not found for current user, redirecting...`),h.length>0?r(`/c/${h[0].id}`,{replace:!0}):r(`/`,{replace:!0}))}else!n&&h.length>0&&l.pathname===`/`&&r(`/c/${h[0].id}`,{replace:!0})})()},[n,h,w,r,m?.id,m?.isPrivate,l.pathname]),(0,Q.useEffect)(()=>{if(m?.id){let e=sessionStorage.getItem(`pendingMessage`);if(e){sessionStorage.removeItem(`pendingMessage`);try{let t=JSON.parse(e);setTimeout(()=>{k(t.content,t.images,void 0,t.webSearch===!0)},100)}catch(e){On.error(`Failed to parse pending message:`,e)}}}},[m?.id,k]),(0,Q.useEffect)(()=>{let e=ze.current;e&&(e.style.height=`auto`,e.style.height=W?`${Math.min(e.scrollHeight,200)}px`:``)},[W]);let Ge=async t=>{if(t.preventDefault(),!W.trim()||!_)return;if(!re){f.error(e(`chat.model.selectBeforeSending`));return}Fe(`impact`);let n={content:W.trim(),images:ge.length>0?ge:void 0,webSearch:ve&&q?!0:void 0};sessionStorage.setItem(`pendingMessage`,JSON.stringify(n)),K(``),_e([]),xe(!1);let i=await S(_,void 0,_.startsWith(`persona:`)?_.slice(8):void 0,v,b);i&&(await Ke(i),r(`/c/${i.id}`,{replace:!0}))},Ke=(0,Q.useCallback)(async e=>{let t=Y.getState().draftSessionSettings,n=t.systemPrompt?.trim(),r=t.generationOptions;if(!n&&!r)return;let i=n?[{id:Ce(),role:`system`,content:n,timestamp:Date.now()},...e.messages.filter(e=>e.role!==`system`)]:e.messages;try{let t=await U.updateSession(e.id,{messages:i,settings:r?{generationOptions:r}:void 0});if(t.success&&t.data){let e=t.data;Y.setState(t=>({sessions:t.sessions.map(t=>t.id===e.id?e:t),currentSession:t.currentSession?.id===e.id?e:t.currentSession}))}}catch(e){On.error(`Failed to apply chat settings to the new session`,e)}finally{Y.getState().setDraftSessionSettings({})}},[]),qe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ge(e))},Je=async e=>{let t=ke(R,e.target.value);t&&x(t.model,t.providerType,t.providerId)},Ye=(e,t,n,r)=>{m&&(Fe(`impact`),le(null),k(e,t,n,r))};if(!m){let t=ge.length>0;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`relative h-full min-w-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-20 sm:px-8 sm:py-24`,children:[(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,$.jsx)(`div`,{className:`absolute left-[12%] top-[18%] h-56 w-56 rounded-full bg-primary-500/[0.035] blur-3xl dark:bg-primary-400/[0.04]`}),(0,$.jsx)(`div`,{className:`absolute bottom-[16%] right-[10%] h-72 w-72 rounded-full bg-gray-900/[0.025] blur-3xl dark:bg-white/[0.025]`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,$.jsx)(`button`,{onClick:()=>ue(e=>!e),className:J(`absolute end-4 top-4 z-10 flex h-9 w-9 items-center justify-center rounded-full border border-black/[0.07] bg-surface/65 text-gray-500 backdrop-blur-md transition-colors duration-150 hover:bg-surface-raised hover:text-gray-950 dark:border-white/[0.08] dark:bg-dark-200/65 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 sm:end-6 sm:top-6`,B&&`text-primary-600 dark:text-primary-400`),title:e(`chat.controls.title`),"aria-expanded":B,children:(0,$.jsx)(d,{className:`h-4 w-4`})}),(0,$.jsxs)(`button`,{onClick:()=>We(),disabled:!_&&g.length===0||!!_&&!re,className:`absolute end-[3.75rem] top-4 z-10 flex items-center gap-2 rounded-full border border-black/[0.07] bg-surface/65 px-3 py-2 text-xs font-medium text-gray-500 backdrop-blur-md transition-colors duration-150 hover:bg-surface-raised hover:text-gray-950 disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/[0.08] dark:bg-dark-200/65 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 sm:end-[4.25rem] sm:top-6`,title:e(`chat.session.privateTooltip`),children:[(0,$.jsx)(p,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`chat.session.incognito`,`Incognito Chat`)})]}),(0,$.jsxs)(`div`,{className:`relative z-[1] mx-auto flex min-h-full w-full max-w-3xl flex-col items-center justify-center`,children:[(0,$.jsxs)(`div`,{className:`mb-10 flex flex-col items-center text-center animate-fade-in sm:mb-12`,"aria-live":`polite`,children:[(0,$.jsx)(`h1`,{className:`mb-4 max-w-3xl text-balance text-[clamp(2.65rem,7vw,5.25rem)] font-light leading-[0.98] tracking-[-0.055em] text-gray-950 dark:text-dark-950 rtl:leading-[1.12] rtl:tracking-normal`,children:H.title}),(0,$.jsx)(`p`,{className:`max-w-xl text-balance text-base leading-relaxed text-gray-500 dark:text-dark-600 sm:text-lg`,children:H.subtitle})]},H.id),R.length>0?(0,$.jsxs)(`div`,{className:`w-full`,children:[Le&&(0,$.jsxs)(`div`,{className:`mb-3 animate-slide-up rounded-2xl border border-black/[0.07] bg-surface/80 p-4 shadow-sm backdrop-blur-xl dark:border-white/[0.08] dark:bg-dark-200/80`,children:[(0,$.jsx)(Cn,{images:ge,onImagesChange:_e,maxImages:5}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-black/[0.06] pt-3 dark:border-white/[0.07]`,children:[(0,$.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`chat.input.menu.attachDocument`)}),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`outline`,disabled:Se,onClick:()=>Ne.current?.click(),className:`shrink-0 whitespace-nowrap`,children:[(0,$.jsx)(se,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`ms-1.5`,children:e(Se?`documents.uploading`:`chat.input.menu.attach`)})]}),(0,$.jsx)(`input`,{ref:Ne,type:`file`,accept:`.pdf,.txt,.md`,className:`hidden`,onChange:e=>void Ie(e)})]})]}),(0,$.jsx)(`form`,{onSubmit:Ge,children:(0,$.jsxs)(`div`,{className:J(`flex items-end gap-2 rounded-[1.35rem] border p-2 transition-[border-color,box-shadow,background-color] duration-200`,`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,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Re(!Le),className:J(`h-9 w-9 sm:h-10 sm:w-10 !p-0 rounded-full flex-shrink-0`,`text-gray-500 dark:text-dark-600 hover:bg-gray-100 dark:hover:bg-dark-300 transition-colors touch-manipulation`,t&&`text-primary-600 dark:text-primary-400`,Le&&`bg-gray-100 dark:bg-dark-300`),title:e(`chat.input.attachImages`),children:t?(0,$.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,$.jsx)(se,{className:`h-4 w-4`}),(0,$.jsx)(`div`,{className:`absolute -top-0.5 -end-0.5 h-1.5 w-1.5 bg-primary-500 rounded-full`})]}):Le?(0,$.jsx)(de,{className:`h-4 w-4`}):(0,$.jsx)(u,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(rn,{ref:ze,value:W,onChange:e=>K(e.target.value),onKeyDown:qe,placeholder:e(`chat.input.messagePlaceholder`),className:`!m-0 block min-h-9 max-h-[160px] resize-none !rounded-none !border-0 !bg-transparent !px-1.5 !py-1.5 sm:!min-h-10 sm:!py-2 max-[768px]:!min-h-11 max-[768px]:!py-[10.5px] !shadow-none scrollbar-thin scrollbar-thumb-gray-300 placeholder:text-gray-400 focus:!border-0 focus:!bg-transparent focus:!shadow-none focus:!ring-0 dark:scrollbar-thumb-dark-400 dark:placeholder:text-dark-500 text-[0.9375rem] leading-relaxed touch-manipulation`,rows:1})}),ve&&(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>xe(e=>!e),className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`text-gray-500 dark:text-dark-600 hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 touch-manipulation`,q&&`bg-primary-50 text-primary-600 dark:bg-primary-900/25 dark:text-primary-400`),title:e(q?`chat.input.webSearchOn`:`chat.input.webSearchOff`),"aria-pressed":q,children:(0,$.jsx)(C,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`hidden sm:block`,children:(0,$.jsx)(Ue,{models:R,selectedModel:z,onModelChange:Je,getModelValue:Oe,className:`min-w-[140px] max-w-[210px]`,compact:!0,showImageGen:He})}),(0,$.jsx)(Z,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!W.trim()||!_||!re,className:J(`h-9 w-9 sm:h-10 sm:w-10 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`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 dark:disabled:bg-dark-300 dark:disabled:text-dark-500 disabled:hover:bg-gray-100 dark:disabled:hover:bg-dark-300`,`transition-colors duration-150 touch-manipulation`,W.trim()&&_&&`shadow-sm`),title:e(`chat.input.sendMessage`),children:(0,$.jsx)(y,{className:`h-4 w-4`})})]})}),(0,$.jsx)(`div`,{className:`sm:hidden mt-4`,children:(0,$.jsx)(Ue,{models:R,selectedModel:z,onModelChange:Je,getModelValue:Oe,className:`w-full`,compact:!0,showImageGen:He})}),(0,$.jsx)(`p`,{className:`mt-4 text-center text-[10px] leading-relaxed text-gray-400 dark:text-dark-500`,children:e(`chat.footer.disclaimer`)})]}):(0,$.jsx)(`div`,{className:`w-full max-w-lg`,children:(0,$.jsxs)(`div`,{className:`rounded-2xl border border-black/[0.07] bg-surface/70 p-6 backdrop-blur-xl dark:border-white/[0.08] dark:bg-dark-200/70`,children:[(0,$.jsx)(`p`,{className:`mb-4 text-sm leading-relaxed text-gray-600 dark:text-dark-700`,children:e(`chat.model.noModelsDescription`)}),(0,$.jsx)(`code`,{className:`block rounded-xl bg-gray-100 p-3 font-mono text-xs text-gray-800 dark:bg-dark-300 dark:text-dark-700`,children:e(`chat.model.pullCommand`)})]})})]})]}),(0,$.jsx)(_n,{draftModel:_,open:B,onClose:()=>ue(!1)})]})}return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col`,style:I?.background?{backgroundImage:`url(${I.background})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`}:void 0,children:[I?.background&&(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gray-50/[0.88] backdrop-blur-sm dark:bg-dark-100/[0.88]`}),(0,$.jsxs)(`div`,{className:`relative z-10 flex h-full flex-col`,children:[m?.isPrivate&&(0,$.jsx)(`div`,{className:`flex-shrink-0 border-b border-black/[0.05] bg-surface/55 px-4 py-2 backdrop-blur-xl dark:border-white/[0.06] dark:bg-dark-100/55`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-gray-500 dark:text-dark-600`,children:[(0,$.jsx)(p,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e(`chat.session.privateMode`)}),(0,$.jsxs)(`span`,{className:`hidden text-[11px] text-gray-400 dark:text-dark-500 sm:inline`,children:[`— `,e(`chat.session.privateDescription`)]})]})}),I&&!m?.isPrivate&&(0,$.jsx)(`div`,{className:`flex-shrink-0 border-b border-black/[0.05] bg-surface/55 px-4 py-2 backdrop-blur-xl dark:border-white/[0.06] dark:bg-dark-100/55`,children:(0,$.jsx)(Sn,{persona:I,onClear:()=>{m&&U.updateSession(m.id,{model:I.model,providerType:`ollama`,providerId:null,personaId:null}).then(e=>{if(!e.success||!e.data)throw Error(e.error||`Failed to remove persona`);Y.setState(t=>({sessions:t.sessions.map(t=>t.id===m.id?e.data:t),currentSession:e.data}))}).catch(t=>{On.error(`Failed to remove persona:`,t),f.error(e(`chat.persona.removeFailed`))})}})}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`button`,{onClick:()=>ue(e=>!e),className:J(`absolute end-3 top-3 z-20 flex h-8 w-8 items-center justify-center rounded-full border border-black/[0.07] bg-surface/65 text-gray-500 backdrop-blur-md transition-colors duration-150 hover:bg-surface-raised hover:text-gray-950 dark:border-white/[0.08] dark:bg-dark-200/65 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`,B&&`text-primary-600 dark:text-primary-400`),title:e(`chat.controls.title`),"aria-expanded":B,children:(0,$.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(tn,{messages:m.messages,streamingMessage:P,streamingThinking:te,streamingMessageId:F,isStreaming:N,toolActivities:ne,onRegenerate:A,onSelectBranch:M,onEditResend:j,followUpSuggestions:me,onFollowUpSelect:e=>Ye(e),className:`flex-1`}),(0,$.jsx)(mn,{onSendMessage:Ye,onStopGeneration:ee,disabled:!m})]}),m&&(0,$.jsx)(xn,{session:m}),(0,$.jsx)(_n,{session:m,open:B,onClose:()=>ue(!1)})]})]})]})};export{jn as ChatPage,jn as default};
|
|
@@ -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{n as r}from"./i18next-DgmgtwsV.js";import{a as i,c as a,d as o,l as s,n as c,r as l,s as u,t as d,u as f}from"./useTranslation-CdeLZqSW.js";import{Cn as p,En as m,K as h,R as g,Tt as _,V as v,Vt as y,Zt as b,gn as x,k as S,lt as C,m as w,n as ee,sn as T,un as te,v as E,x as D}from"./ui-vendor-xUzKqAXI.js";import{t as O}from"./logger-DSXjF4ye.js";import{h as k}from"./api-DjQINB7B.js";import{t as A}from"./utils-BhpNrGnR.js";import{t as j}from"./Button-X9TT9gTD.js";import{n as ne,t as M}from"./ui-ovAoLjDQ.js";var N={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},re=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function P(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(N[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(re),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var F=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,I=/<\/?([^\s]+?)[/\s>]/,ie=/^\s*$/,ae=/^(script|style)$/i,L=`\0`,oe=Object.create(null);function se(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(L).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(L).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(L)>-1&&(e.attrs[t]=n.split(L).join(`<`))}e.children.length&&se(e.children)})}function ce(e,t){let n=t&&t.components||oe,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;F.lastIndex=0;let o;for(;o=F.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(I);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=L,a=o.index+1,F.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=F.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=P(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=P(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&ae.test(s.name)){t=!0,d||(d=e.toLowerCase());let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);ie.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&se(a),a}function le(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`"`)+`"`);return t.length?` `+t.join(` `):``}function ue(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?le(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(ue,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function de(e){return e.reduce(function(e,t){return e+ue(``,t)},``)}var R={parse:ce,stringify:de},z=e(n()),B=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},V=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?H(t):t},fe=e=>Array.isArray(e)&&e.every(z.isValidElement),H=e=>Array.isArray(e)?e:[e],pe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},me=e=>{let t={};if(!e)return t;let n=e=>{H(e).forEach(e=>{s(e)||(B(e)?n(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},U=(e,t,n,r)=>{if(!e)return``;let i=``,o=H(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return o.forEach((e,o)=>{if(s(e)){i+=`${e}`;return}if((0,z.isValidElement)(e)){let{props:a,type:l}=e,u=Object.keys(a).length,d=c.indexOf(l)>-1,f=a.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||a.i18nIsDynamicList){i+=`<${o}></${o}>`;return}if(d&&u<=1){let e=s(f)?f:U(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=U(f,t,n,r);i+=`<${o}>${p}</${o}>`;return}if(e===null){f(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(a(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}f(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}f(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},W=(e,t,n,r,o,c,l)=>{if(n===``)return[];let d=o.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(d.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!l)return[n];let p=t??{},m=e=>{H(e).forEach(e=>{s(e)||(B(e)?m(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(p,e))})};m(e);let h=Object.keys(p),g=R.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||d.indexOf(e)>-1||h.indexOf(e)>-1}),_={...p,...c},v=(e,t,n)=>{let r=V(e),i=b(r,t.children,n);return fe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,z.cloneElement)(e,{key:r},i?void 0:t))):n.push(...z.Children.map([e],e=>{if(e.type===z.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,z.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,z.cloneElement)(e,n,i?null:t)}))},b=(e,n,c)=>{let p=H(e),m=H(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let i=p[parseInt(n.name,10)];!i&&t&&(i=t[n.name]),c.length===1&&!i&&(i=c[0][n.name]),i||(i={});let x={...n.attrs};l&&Object.keys(x).forEach(e=>{let t=x[e];s(t)&&(x[e]=u(t))});let S=Object.keys(x).length===0?i:pe({props:x},i),C=(0,z.isValidElement)(S),w=C&&B(n,!0)&&!n.voidElement,ee=f&&a(S)&&S.dummy&&!C,T=a(t)&&Object.hasOwnProperty.call(t,n.name);if(s(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(B(S)||w){let t=v(S,n,c);y(S,t,e,m)}else if(ee){let t=b(p,n.children,c);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(T){let t=v(S,n,c);y(S,t,e,m,n.voidElement)}else if(o.transSupportBasicHtmlNodes&&d.indexOf(n.name)>-1)if(n.voidElement)e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<p.length;e+=1){let a=p[e];if((0,z.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?H(V(r)):p,o=b(a,n.children,c);e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`},o))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(p,n.children,c);e.push(`<${n.name}>${t}</${n.name}>`)}else if(a(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=o.transWrapTextNodes,a=typeof o.unescape==`function`?o.unescape:i().unescape,s=l?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,z.createElement)(t,{key:`${n.name}-${m}`},s)):e.push(s)}return e},[])};return V(b([{dummy:!0,children:e||[]}],g,H(e||[]))[0])},G=(e,t,n)=>{let r=e.key||t,i=(0,z.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,z.createElement)(z.Fragment,null,i)}return(0,z.createElement)(a,{key:r})},he=(e,t)=>e.map((e,n)=>G(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:G(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?he(e,t):a(e)?ge(e,t):(o(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!a(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:a,context:c,tOptions:u={},values:d,defaults:f,components:p,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||l();if(!y)return o(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:a}),e;let b=g||y.t.bind(y)||(e=>e),x={...i(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=s(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...u}:u,ee=_??C?.shouldUnescape,T=C?.values?{...C.values,...d}:d,te=C?.components?{...C.components,...p}:p,E=U(e,x,y,a),D=f||w?.defaultValue||E||x.transEmptyNodeValue||(typeof a==`function`?r(a):a),{hashTransKey:O}=x,k=a||(O?O(E||D):E||D);d=y.options?.interpolation?.defaultVariables?T&&Object.keys(T).length>0?{...T,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:T;let A=me(e);A&&typeof A.count==`number`&&t===void 0&&(t=A.count);let j=d||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ne={...w,context:c||w.context,count:t,...d,...j,defaultValue:D,ns:S},M=k?b(k,ne):D;M===k&&D&&(M=D);let N=_e(te,M,y,a),re=N||e,P=null;ve(N)&&(P=N,re=e);let F=W(re,P,M,y,x,ne,ee),I=n??x.defaultTransParent;return I?(0,z.createElement)(I,v,F):F}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:u,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,z.useContext)(c)||{},v=f||g||l(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:u,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=t(),q=O(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=d(),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)(null),[f,O]=(0,z.useState)(null),[N,re]=(0,z.useState)(``),[P,F]=(0,z.useState)(null),[I,ie]=(0,z.useState)(!0),[ae,L]=(0,z.useState)(!1),[oe,se]=(0,z.useState)(!1),[ce,le]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(!1),[R,B]=(0,z.useState)(``),[V,fe]=(0,z.useState)(`chat`),[H,pe]=(0,z.useState)(``),[me,U]=(0,z.useState)(``),[W,G]=(0,z.useState)(``),[he,ge]=(0,z.useState)(``),[_e,ve]=(0,z.useState)(!1),[ye,xe]=(0,z.useState)(`lobster`),[Se,we]=(0,z.useState)(!0),[ke,Ae]=(0,z.useState)(``),[je,Y]=(0,z.useState)(``),[X,Fe]=(0,z.useState)(``),[Ie,Le]=(0,z.useState)(`report`),Z=(0,z.useMemo)(()=>r.find(e=>e.run_id===P)||null,[r,P]),Q=(0,z.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,z.useMemo)(()=>Pe(a,e),[a,e]),$=(0,z.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([k.status(),k.listRuns(30),k.currentModel(),k.currentFallback(),k.usage(``,100),k.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),F(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(u(r.data),G(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&O(a.data),o.success&&o.data&&re(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),m.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{ie(!1)}},[e]),ze=(0,z.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await k.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,z.useEffect)(()=>{if(!P){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=P;k.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[P]),(0,z.useEffect)(()=>{if(!P||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(P),k.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,P]);let Be=async()=>{if(!R.trim()){m.error(e(`libreClaw.toasts.enterTask`));return}L(!0);try{let t=await k.startRun({message:R,kind:V,provider:H||void 0,model:me||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),F(n.run_id),B(``),m.success(e(`libreClaw.toasts.runStarted`))}else m.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),m.error(e(`libreClaw.toasts.startRunFailed`))}finally{L(!1)}},Ve=async t=>{try{await k.cancelRun(t),await $(),m.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),m.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!P)return;let r=String(t.data.tool_call_id||``);if(r)try{await k.resolvePermission(P,r,n),await ze(P,!0),m.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),m.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!W.trim()||!he.trim()){m.error(e(`libreClaw.toasts.providerModelRequired`));return}se(!0);try{let t=await k.updateModel(W,he,_e);t.success&&t.data?(u(t.data),m.success(e(`libreClaw.toasts.modelUpdated`))):m.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),m.error(e(`libreClaw.toasts.updateModelFailed`))}finally{se(!1)}},We=async()=>{le(!0);try{let t=await k.updateTheme(ye,Se);t.success?m.success(e(`libreClaw.toasts.themeUpdated`)):m.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),m.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{le(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){m.error(e(`libreClaw.toasts.automationRequired`));return}de(!0);try{let t=await k.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),m.success(e(`libreClaw.toasts.automationCreated`))):m.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),m.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{de(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await k.pauseAutomation(t),n===`resume`&&await k.resumeAutomation(t),n===`run`&&await k.runAutomationNow(t),n===`delete`&&await k.deleteAutomation(t),await $(),m.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),m.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(ne,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(M,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(g,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(y,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!I&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(E,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(v,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:R,onChange:e=>B(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:V,onChange:e=>fe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:H,onChange:e=>pe(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:me,onChange:e=>U(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(j,{onClick:Be,loading:ae,children:[(0,K.jsx)(x,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(_,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(j,{variant:`secondary`,onClick:Ue,loading:oe,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(j,{variant:`secondary`,onClick:We,loading:ce,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),l&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(l,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(p,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>F(t.run_id),className:A(`w-full rounded-xl border p-3 text-start transition`,P===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(b,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(j,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(D,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(S,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(j,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(T,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(j,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(j,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(ee,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(te,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(j,{onClick:Ge,loading:ue,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(v,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(v,{className:`h-4 w-4`}):(0,K.jsx)(h,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(w,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(p,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:N||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(f||{},null,2)})]})]})})]}),I&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(C,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:A(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:A(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:A(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:A(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:A(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:A(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
|
|
@@ -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{n as r}from"./react-vendor-DPNXrO-8.js";import{d as i}from"./router-vendor-Ca9zqOqT.js";import{t as a}from"./useTranslation-CdeLZqSW.js";import{B as o,En as s,Gt as c,P as l,R as u,T as d,Ut as f,Vt as p,Xt as m,bt as h,c as g,ct as _,fn as v,gn as y,ht as b,n as x,on as ee,sn as S,t as C,v as te,vt as ne}from"./ui-vendor-xUzKqAXI.js";import{t as re}from"./logger-DSXjF4ye.js";import{_ as w,p as T}from"./api-DjQINB7B.js";import{t as E}from"./utils-BhpNrGnR.js";import{s as ie}from"./chatStore-D76rdaV6.js";import{n as ae}from"./authStore-pmXfK_qt.js";import{f as oe}from"../assets/index-BN-WAt2j.js";var D=e(n(),1),se=r(),O=t();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ce({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:o,hfGgufFiles:s,loadingGguf:c,pullingModel:l,pullProgress:d,setHfTask:m,setHfSort:h,onToggleHfModel:g,onPullHfGguf:v,onCancelPull:y,onRefreshHfModels:b}){let{t:S}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>m(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`text-generation`,children:S(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:S(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:S(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:S(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>h(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`downloads`,children:S(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:S(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:S(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:S(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(_,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(C,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:S(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=o===e.id,r=s[e.id]||[],i=c===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(C,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(f,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(ne,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(p,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(ee,{className:E(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(_,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:S(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:S(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:S(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=l===e.ollamaCommand;return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(x,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),v(e.ollamaCommand,e.filename)},disabled:!!l,className:E(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,O.jsx)(f,{className:`h-3 w-3 inline mr-1`}),S(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:S(`modelSelector.adminOnlyPull`)})]},e.filename)}),l?.startsWith(`hf.co/`)&&l.includes(e.id)&&d?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(p,{className:`h-3 w-3`}),S(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function le({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:l,onModelSelect:u,onOpenGallery:d}){let{t:f}=a();return(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>u(n),className:E(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),l(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:l(e)})]}),t===n&&(0,O.jsx)(S,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(c,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:f(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),f(`modelSelector.actions`)]})}),(0,O.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),d()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(b,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:f(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:f(`gallery.generateDescription`)})]})]})})]})]})}function ue({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:o,pullProgress:s,setLibraryCategory:c,isModelInstalled:l,onModelSelect:d,onPullModel:h,onCancelPull:g,onRefreshLibrary:v}){let{t:y}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),c(e)},className:E(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:y(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(_,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(m,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:y(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=l(e.name),r=o===e.name;return(0,O.jsxs)(`div`,{className:E(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(m,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:y(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,O.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,O.jsx)(m,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(f,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:s?.percent===void 0?`...`:`${s.percent}%`}),(0,O.jsx)(`button`,{onClick:g,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(x,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:y(`modelSelector.use`)}):n?(0,O.jsxs)(`button`,{onClick:()=>h(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,O.jsx)(f,{className:`h-3 w-3 inline mr-1`}),y(`modelSelector.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:y(`modelSelector.adminOnlyPull`)})})]}),r&&s?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${s.percent}%`}})})]},e.name)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(p,{className:`h-3 w-3`}),y(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var de=re(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:c=!1,compact:u=!1,showImageGen:f=!1,onModelsRefresh:p,getModelValue:_,getModelLabel:b,getModelTitle:S,triggerRef:ne,triggerTestId:re,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,fe]=(0,D.useState)(!1),[N,pe]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),me=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),he=i(),{user:ge,systemInfo:_e}=ae(),z=ge?.role===`admin`||_e?.requiresAuth===!1,[B,ve]=(0,D.useState)(`all`),[ye,be]=(0,D.useState)(``),[V,xe]=(0,D.useState)(`text-generation`),[H,Se]=(0,D.useState)(`downloads`),[Ce,we]=(0,D.useState)(``),[U,Te]=(0,D.useState)(null),[W,Ee]=(0,D.useState)({}),[De,Oe]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[ke,q]=(0,D.useState)(null),[Ae,J]=(0,D.useState)(null),je=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Me=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(x,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:j(`modelSelector.personas`),icon:(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(y,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>ie(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>_?.(e)??e.name,X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(ne,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{fe(!1),pe(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ne=[],isLoading:Pe,refetch:Fe}=oe({queryKey:[`ollama-library-selector`,ye,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await T.getLibraryModels({search:ye||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:Ie=[],isLoading:Le,refetch:Re}=oe({queryKey:[`hf-models-selector`,V,Ce,H],queryFn:async()=>{let e=await w.getModels({task:V,search:Ce||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),ze=Ne.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Be=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Oe(e);try{let r=await w.getGgufFiles(t,n);r.success&&r.data&&Ee(t=>({...t,[e]:r.data}))}catch(e){de.error(`Failed to load GGUF files:`,e)}finally{Oe(null)}}},[]),Ve=(0,D.useCallback)(e=>{U===e?Te(null):(Te(e),W[e]||Be(e))},[U,W,Be]),He=(0,D.useCallback)((e,t)=>{if(!z){s.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),s.success(`Downloaded ${t}`),p?.()},e=>{q(null),K(null),J(null),s.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),s.error(`Failed to start download`)}}},[z,p,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?we(N):P===`ollama`&&be(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ue=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Z();try{let e=await T.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await T.unloadAllModels())}}catch(e){de.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},We=async e=>{if(!z){s.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),s.success(`Downloaded ${e}`),p?.()},e=>{q(null),K(null),J(null),s.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),s.error(`Failed to start download`)}}},Ge=()=>{Ae&&(Ae(),J(null),K(null),q(null),s.success(`Download cancelled`))},Ke=t=>e.some(e=>ie(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>e.isLegacySelection?(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(y,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),$=e=>b?b(e):e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name),qe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:E(`relative`,o),ref:me,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":re,type:`button`,onClick:()=>!c&&fe(!M),disabled:c,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:E(u?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,c?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:u?X?S?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return u?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(y,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(u){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=qe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(v,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(ee,{className:E(u?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,se.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:E(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:j(`common.close`),children:(0,O.jsx)(x,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(l,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>pe(e.target.value),className:E(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,O.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`installed`,children:[(0,O.jsx)(h,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`ollama`,children:[(0,O.jsx)(m,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`huggingface`,children:[(0,O.jsx)(C,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(le,{filteredGroups:Me,selectedModel:t,showImageGen:f,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:qe,onModelSelect:Ue,onOpenGallery:()=>{Z(!1),he(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(ue,{libraryCategories:je,libraryCategory:B,canInstallModels:z,loadingLibrary:Pe,filteredLibraryModels:ze,pullingModel:G,pullProgress:ke,setLibraryCategory:ve,isModelInstalled:Ke,onModelSelect:Ue,onPullModel:We,onCancelPull:Ge,onRefreshLibrary:()=>{Fe()}}),P===`huggingface`&&(0,O.jsx)(ce,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Le,hfModels:Ie,expandedHfModel:U,hfGgufFiles:W,loadingGguf:De,pullingModel:G,pullProgress:ke,setHfTask:xe,setHfSort:Se,onToggleHfModel:Ve,onPullHfGguf:He,onCancelPull:Ge,onRefreshHfModels:()=>{Re()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-D-NxeVvV.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-DHnR5Hw8.js","js/react-vendor-DPNXrO-8.js","js/useTranslation-CdeLZqSW.js","js/ui-vendor-xUzKqAXI.js","js/utils-BhpNrGnR.js","js/utils-vendor-1zob7nK9.js","js/Button-X9TT9gTD.js"])))=>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{i as r}from"./router-vendor-Ca9zqOqT.js";import{t as i}from"./useTranslation-CdeLZqSW.js";import{A as a,Cn as o,Dt as s,En as c,Gt as l,Kt as u,M as d,Ot as f,P as p,R as m,Rt as ee,Ut as h,Vt as g,Xt as te,Zt as _,_ as ne,bt as v,ct as y,dt as b,it as re,m as x,mt as S,n as ie,on as C,rn as w,sn as T,t as ae,vt as oe,yt as E}from"./ui-vendor-xUzKqAXI.js";import{t as se}from"./logger-DSXjF4ye.js";import{_ as ce,p as D}from"./api-DjQINB7B.js";import{t as O}from"./utils-BhpNrGnR.js";import{n as le}from"./authStore-pmXfK_qt.js";import{t as k}from"./Button-X9TT9gTD.js";import{n as ue,t as de}from"./ui-ovAoLjDQ.js";import{f as A,m as fe}from"../assets/index-BN-WAt2j.js";var j=e(n(),1),M=t();function pe({expanded:e,models:t,search:n,task:r,sort:a,loadingModels:o,canInstallModels:s,expandedModelId:c,loadingGgufModelId:l,ggufFiles:u,pullingModel:d,pullProgress:f,setSearch:ee,setTask:h,setSort:te,onToggle:_,onToggleModel:ne,onPullGguf:v,onCancelPull:b,onRefresh:re}){let{t:x}=i();return(0,M.jsxs)(`div`,{className:O(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`button`,{onClick:_,"aria-expanded":e,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(ae,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:x(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,x(`modelManager.library.available`,`available`)]})]}),e?(0,M.jsx)(w,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(C,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(p,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:n,onChange:e=>ee(e.target.value),placeholder:x(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:O(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,M.jsxs)(`select`,{value:r,onChange:e=>h(e.target.value),className:O(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,M.jsx)(`option`,{value:`text-generation`,children:x(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,M.jsx)(`option`,{value:`text-to-speech`,children:x(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,M.jsx)(`option`,{value:`text-to-image`,children:x(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,M.jsx)(`option`,{value:`automatic-speech-recognition`,children:x(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,M.jsxs)(`select`,{value:a,onChange:e=>te(e.target.value),className:O(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,M.jsx)(`option`,{value:`downloads`,children:x(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,M.jsx)(`option`,{value:`likes`,children:x(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,M.jsx)(`option`,{value:`lastModified`,children:x(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!s&&(0,M.jsx)(`p`,{className:`text-xs text-ink`,children:x(`modelManager.pull.restricted`)}),o?(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,M.jsx)(y,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,M.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:x(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,M.jsx)(me,{model:e,expanded:c===e.id,loadingGguf:l===e.id,ggufFiles:u[e.id]||[],pullingModel:d,pullProgress:f,canInstallModels:s,onToggle:()=>ne(e.id),onPullGguf:v,onCancelPull:b},e.id))}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,M.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:O(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,M.jsx)(g,{className:`h-3 w-3`}),x(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,M.jsxs)(k,{onClick:re,variant:`outline`,size:`sm`,disabled:o,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(m,{className:O(`h-3.5 w-3.5`,o&&`animate-spin`)}),x(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function me({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:a,pullProgress:o,canInstallModels:s,onToggle:c,onPullGguf:l,onCancelPull:u}){let{t:d}=i();return(0,M.jsxs)(`div`,{className:O(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,M.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:c,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:d(`modelManager.huggingface.gated`,`Gated`)})]}),(0,M.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[d(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,M.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:d(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,M.jsx)(g,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,M.jsx)(C,{className:O(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(h,{className:`h-3.5 w-3.5`}),ge(e.downloads)]}),(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(oe,{className:`h-3.5 w-3.5`}),ge(e.likes)]}),e.pipeline_tag&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,M.jsx)(N,{modelId:e.id,loading:n,files:r,pullingModel:a,pullProgress:o,canInstallModels:s,onPullGguf:l,onCancelPull:u})]})}function N({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:a,canInstallModels:o,onPullGguf:s,onCancelPull:c}){let{t:l}=i();return(0,M.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,M.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,M.jsx)(y,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,M.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,M.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,M.jsx)(he,{file:e,pulling:r===e.ollamaCommand,pullProgress:a,canInstallModels:o,disabled:!!r||!o,onPullGguf:s,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&a?.percent!==void 0&&(0,M.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,M.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${a.percent}%`}})})]})})}function he({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:a,onCancelPull:o}){let{t:s}=i();return(0,M.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,M.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,M.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),o()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,M.jsx)(ie,{className:`h-4 w-4`})})]}):(0,M.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),a(e.ollamaCommand,e.filename)},disabled:n,className:O(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,M.jsx)(h,{className:`h-3 w-3 inline mr-1`}),s(`models.pull`)]})]})}function ge(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function _e({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c}){let{t:l}=i();return(0,M.jsxs)(`div`,{className:O(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:l(`modelManager.sections.local`)}),(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,l(`modelManager.local.installed`)]})]}),e?(0,M.jsx)(w,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(C,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,M.jsxs)(`div`,{className:O(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsx)(v,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,M.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:l(`modelManager.local.noModels`)}),(0,M.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:l(`modelManager.local.pullToStart`)})]}):(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsx)(ve,{model:e,running:r(e.name),formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c},e.name))})})]})}function ve({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:a,onDeleteModel:o}){let{t:s}=i();return(0,M.jsx)(`div`,{className:O(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,M.jsxs)(`span`,{className:O(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),s(`modelManager.local.running`)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(v,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,M.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(_,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,M.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,M.jsx)(E,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,M.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,M.jsxs)(k,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(S,{className:`h-3.5 w-3.5`}),s(`modelManager.local.info`)]}),(0,M.jsxs)(k,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5`}),s(`modelManager.local.copy`)]}),(0,M.jsxs)(k,{onClick:()=>o(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,M.jsx)(x,{className:`h-3.5 w-3.5`}),s(`modelManager.local.delete`)]})]})]})})}function ye({expanded:e,models:t,totalAvailable:n,categories:r,filter:a,search:o,loading:s,pulling:c,canInstallModels:l,pullSectionExpanded:u,setFilter:d,setSearch:ee,isModelInstalled:h,normalizeCloudPullName:g,onToggle:_,onTogglePullSection:ne,onPullModel:v,onRefresh:y}){let{t:b}=i();return(0,M.jsxs)(`div`,{className:O(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`button`,{onClick:_,"aria-expanded":e,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:b(`modelManager.sections.library`)}),(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,b(`modelManager.library.available`)]})]}),e?(0,M.jsx)(w,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(C,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(p,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:o,onChange:e=>ee(e.target.value),placeholder:b(`modelManager.library.search`),className:O(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(f,{className:`h-4 w-4 text-gray-400`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,M.jsx)(`button`,{onClick:()=>d(e),className:O(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,a===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),s?(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,M.jsx)(m,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,M.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:b(`modelManager.library.noResults`)}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?g(e.name):e.name,n=h(e.name)||h(t);return(0,M.jsx)(be,{model:e,installed:n,pulling:c,canInstallModels:l,pullSectionExpanded:u,onTogglePullSection:ne,onPullModel:v},e.name)})}),(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(k,{onClick:y,variant:`outline`,size:`sm`,disabled:s,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(m,{className:O(`h-3.5 w-3.5`,s&&`animate-spin`)}),b(`modelManager.library.refresh`)]})})]})]})}function be({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:a,onTogglePullSection:o,onPullModel:s}){let{t:c}=i();return(0,M.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:O(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,M.jsxs)(`span`,{className:O(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,M.jsx)(T,{className:`h-3 w-3`}),c(`modelManager.library.installed`)]})]}),(0,M.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,M.jsx)(`span`,{className:`text-xs text-gray-400`,children:c(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(h,{className:`h-3 w-3`}),e.pulls]}),(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,M.jsxs)(k,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{a||o(),s(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:O(`gap-1 text-xs`,``,``),children:[(0,M.jsx)(h,{className:`h-3 w-3`}),c(`modelManager.pull.button`)]})]})]})}function xe({expanded:e,modelName:t,setModelName:n,pulling:r,progress:a,canInstallModels:o,popularModels:s,onToggle:c,onPull:l,onCancelPull:u,formatSize:d}){let{t:f}=i();return(0,M.jsxs)(`div`,{className:O(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`button`,{onClick:c,"aria-expanded":e,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(h,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:f(`modelManager.sections.pull`)})]}),e?(0,M.jsx)(w,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(C,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(p,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:f(`modelManager.pull.placeholder`),className:O(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!o,onKeyDown:e=>{e.key===`Enter`&&!r&&o&&l()}})]}),r?(0,M.jsxs)(k,{onClick:u,variant:`outline`,className:O(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,M.jsx)(ie,{className:`h-4 w-4`}),f(`modelManager.pull.cancel`)]}):(0,M.jsxs)(k,{onClick:l,disabled:!t.trim()||!o,className:O(`px-4 py-2.5 gap-2`,``),children:[(0,M.jsx)(h,{className:`h-4 w-4`}),f(`modelManager.pull.button`)]})]}),r&&a&&(0,M.jsx)(P,{progress:a,formatSize:d}),!o&&(0,M.jsx)(`p`,{className:`text-xs text-ink-muted`,children:f(`modelManager.pull.restricted`)}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:f(`modelManager.pull.popular`)}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s.map(e=>(0,M.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!o,className:O(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,M.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,M.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:O(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,M.jsx)(g,{className:`h-3 w-3`}),f(`modelManager.pull.browseAll`)]})]})]})}function P({progress:e,formatSize:t}){let{t:n}=i(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,M.jsxs)(`div`,{className:O(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,M.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,M.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,M.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,M.jsx)(`div`,{className:O(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,M.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var Se=se(`components:model-manager`),Ce=j.lazy(()=>r(()=>import(`./ModelManagerModals-D-NxeVvV.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),F=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},we=e=>{let t=e.trim();if(!t||F(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},I=()=>{let{t:e}=i(),{user:t,systemInfo:n}=le(),{data:r}=A({queryKey:[`model-download-access`],queryFn:async()=>{let e=await D.getModelAccess();return e.success&&e.data?e.data:null},staleTime:6e4}),l=t?.role===`admin`||n?.requiresAuth===!1||r?.allowed===!0,f=fe(),[p,h]=(0,j.useState)(`all`),[g,te]=(0,j.useState)(``),[_,y]=(0,j.useState)(``),[x,S]=(0,j.useState)(!1),[ie,T]=(0,j.useState)(null),[oe,E]=(0,j.useState)(null),[se,ue]=(0,j.useState)(null),[de,me]=(0,j.useState)(``),[N,he]=(0,j.useState)(!1),[ge,ve]=(0,j.useState)(!1),[be,P]=(0,j.useState)(!1),[F,I]=(0,j.useState)(``),[L,Te]=(0,j.useState)(``),[Ee,De]=(0,j.useState)(!1),[Oe,ke]=(0,j.useState)(!1),[R,Ae]=(0,j.useState)(``),[je,Me]=(0,j.useState)(``),[Ne,Pe]=(0,j.useState)(!1),[Fe,Ie]=(0,j.useState)(!1),[Le,Re]=(0,j.useState)(``),[ze,Be]=(0,j.useState)(``),[Ve,He]=(0,j.useState)(null),[Ue,We]=(0,j.useState)(!1),[z,Ge]=(0,j.useState)(``),[Ke,qe]=(0,j.useState)(``),[B,Je]=(0,j.useState)(`text-generation`),[V,Ye]=(0,j.useState)(`downloads`),[Xe,Ze]=(0,j.useState)(null),[Qe,$e]=(0,j.useState)({}),[et,tt]=(0,j.useState)(null),[nt,H]=(0,j.useState)(null),[rt,U]=(0,j.useState)(null),[it,W]=(0,j.useState)(null),[G,at]=(0,j.useState)(new Set([`pull`,`local`])),K=e=>{at(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:q,isLoading:ot,refetch:J}=A({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([D.getModels(),D.listRunningModels(),D.getVersion(),D.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=q?.models??[],X=q?.runningModels??[],st=q?.ollamaVersion??null,ct=q?.isHealthy??null,Z=(0,j.useCallback)(async()=>{await J()},[J]),{data:Q=[],isLoading:lt}=A({queryKey:[`ollama-library`],queryFn:async()=>{let e=await D.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:ut=[],isLoading:dt}=A({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await D.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:p===`cloud`}),ft=()=>f.invalidateQueries({queryKey:[`ollama-library`]});(0,j.useEffect)(()=>{let e=setTimeout(()=>{qe(z)},300);return()=>clearTimeout(e)},[z]);let pt=G.has(`huggingface`),{data:mt=[],isLoading:ht}=A({queryKey:[`hf-models`,B,Ke,V],queryFn:async()=>{let e=await ce.getModels({task:B,search:Ke||void 0,sort:V,limit:30});return e.success&&e.data?e.data:[]},enabled:pt}),gt=()=>f.invalidateQueries({queryKey:[`hf-models`,B,Ke,V]}),_t=(0,j.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){tt(e);try{let r=await ce.getGgufFiles(t,n);r.success&&r.data&&$e(t=>({...t,[e]:r.data}))}catch(e){Se.error(`Failed to load GGUF files:`,e)}finally{tt(null)}}},[]),vt=(0,j.useCallback)(e=>{Xe===e?Ze(null):(Ze(e),Qe[e]||_t(e))},[Xe,Qe,_t]),yt=(0,j.useCallback)((t,n)=>{if(!l){c.error(e(`modelManager.pull.restricted`));return}if(!nt){H(t),U({status:`starting`});try{let e=D.pullModelStream(t,e=>{U(e)},()=>{U(null),H(null),W(null),c.success(`Downloaded ${n}`),Z()},e=>{U(null),H(null),W(null),c.error(`Failed to download: ${e}`)});W(()=>e)}catch{U(null),H(null),c.error(`Failed to start download`)}}},[l,nt,Z,e]),bt=(0,j.useCallback)(()=>{it&&(it(),W(null),H(null),U(null))},[it]),xt=async(t,n)=>{if(!l){c.error(e(`modelManager.pull.restricted`));return}let r=t||_.trim(),i=n===`cloud`||!t&&p===`cloud`?we(r):r;if(!i){c.error(e(`modelManager.pull.enterName`));return}t&&y(i),S(!0),T({status:`starting`});try{let t=D.pullModelStream(i,e=>{T(e)},()=>{T(null),S(!1),E(null),c.success(e(`modelManager.pull.success`,{name:i})),y(``),Z()},t=>{T(null),S(!1),E(null),c.error(e(`modelManager.pull.failed`)+`: `+t)});E(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.pull.failed`)+`: `+n),T(null),S(!1),E(null)}},St=()=>{oe&&(oe(),E(null),S(!1),T(null),c.success(e(`modelManager.pull.cancelled`)))},Ct=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await D.deleteModel(t),c.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},wt=async t=>{ve(!0),me(t),he(!0);try{let n=await D.showModel(t,!0);n.success&&n.data?ue(n.data):c.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{ve(!1)}},Tt=async()=>{if(!F.trim()||!L.trim()){c.error(e(`modelManager.modals.copy.enterBoth`));return}De(!0);try{await D.copyModel(F.trim(),L.trim()),c.success(e(`modelManager.modals.copy.success`,{name:L})),P(!1),I(``),Te(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{De(!1)}},Et=async()=>{if(!R.trim()||!je.trim()){c.error(e(`modelManager.modals.create.enterBoth`));return}Pe(!0);try{await D.createModel({model:R.trim(),modelfile:je.trim()}),c.success(e(`modelManager.modals.create.success`,{name:R})),ke(!1),Ae(``),Me(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Pe(!1)}},Dt=async()=>{if(!Le.trim()||!ze.trim()){c.error(e(`modelManager.modals.embeddings.enterBoth`));return}We(!0),He(null);try{let t=await D.generateEmbeddings({model:Le.trim(),input:ze.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];He(n),c.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);c.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{We(!1)}},$=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},Ot=e=>Array.isArray(X)&&X.some(t=>t.name===e),kt=()=>Y.reduce((e,t)=>e+t.size,0),At=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),jt=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),Mt=(p===`cloud`?ut:Q).filter(e=>{let t=p===`all`||p===`cloud`||e.category===p,n=!g||e.name.toLowerCase().includes(g.toLowerCase())||e.description.toLowerCase().includes(g.toLowerCase());return t&&n}),Nt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Pt=(0,j.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Ft=N||be||Oe||Fe;return ot?(0,M.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,M.jsx)(m,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(`div`,{className:O(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:O(`w-2.5 h-2.5 rounded-full`,ct?`bg-green-500`:`bg-red-500`)}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(ct?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),st&&(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(d,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[`v`,st]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(v,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(b,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{children:$(kt())})]}),X.length>0&&(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,M.jsx)(o,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(At()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,M.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,M.jsxs)(k,{onClick:Z,variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(m,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,M.jsx)(xe,{expanded:G.has(`pull`),modelName:_,setModelName:y,pulling:x,progress:ie,canInstallModels:l,popularModels:Pt,onToggle:()=>K(`pull`),onPull:()=>xt(),onCancelPull:St,formatSize:$}),(0,M.jsx)(ye,{expanded:G.has(`library`),models:Mt,totalAvailable:Q.length,categories:Nt,filter:p,search:g,loading:lt||dt,pulling:x,canInstallModels:l,pullSectionExpanded:G.has(`pull`),setFilter:h,setSearch:te,isModelInstalled:jt,normalizeCloudPullName:we,onToggle:()=>K(`library`),onTogglePullSection:()=>K(`pull`),onPullModel:xt,onRefresh:ft}),(0,M.jsx)(pe,{expanded:G.has(`huggingface`),models:mt,search:z,task:B,sort:V,loadingModels:ht,canInstallModels:l,expandedModelId:Xe,loadingGgufModelId:et,ggufFiles:Qe,pullingModel:nt,pullProgress:rt,setSearch:Ge,setTask:Je,setSort:Ye,onToggle:()=>K(`huggingface`),onToggleModel:vt,onPullGguf:yt,onCancelPull:bt,onRefresh:gt}),Array.isArray(X)&&X.length>0&&(0,M.jsxs)(`div`,{className:O(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,M.jsx)(o,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,M.jsxs)(`span`,{className:O(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,M.jsxs)(`div`,{className:O(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:t.name}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(re,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(v,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,M.jsxs)(`div`,{className:O(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,M.jsx)(ae,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,M.jsx)(_e,{expanded:G.has(`local`),models:Y,onToggle:()=>K(`local`),isModelRunning:Ot,formatSize:$,onShowModel:wt,onCopyModel:e=>{I(e),P(!0)},onDeleteModel:Ct}),(0,M.jsxs)(`div`,{className:O(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,M.jsxs)(`button`,{onClick:()=>K(`advanced`),"aria-expanded":G.has(`advanced`),className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(a,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),G.has(`advanced`)?(0,M.jsx)(w,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(C,{className:`h-5 w-5 text-gray-500`})]}),G.has(`advanced`)&&(0,M.jsx)(`div`,{className:`p-4 pt-0`,children:(0,M.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,M.jsxs)(k,{onClick:()=>ke(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(ee,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,M.jsxs)(`div`,{className:`text-start`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,M.jsxs)(k,{onClick:()=>P(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(u,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,M.jsxs)(`div`,{className:`text-start`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,M.jsxs)(k,{onClick:()=>Ie(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(ne,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,M.jsxs)(`div`,{className:`text-start`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,M.jsxs)(k,{onClick:async()=>{try{(await D.checkHealth()).success&&(await J(),c.success(e(`modelManager.advanced.healthy`)))}catch{await J(),c.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(s,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,M.jsxs)(`div`,{className:`text-start`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Ft&&(0,M.jsx)(j.Suspense,{fallback:null,children:(0,M.jsx)(Ce,{models:Y,showDetailsModal:N,setShowDetailsModal:he,selectedModelName:de,selectedModelDetails:se,loadingDetails:ge,showCopyModal:be,setShowCopyModal:P,copySource:F,setCopySource:I,copyDestination:L,setCopyDestination:Te,copying:Ee,handleCopyModel:Tt,showCreateModal:Oe,setShowCreateModal:ke,createModelName:R,setCreateModelName:Ae,createModelfile:je,setCreateModelfile:Me,creating:Ne,handleCreateModel:Et,showEmbeddingsModal:Fe,setShowEmbeddingsModal:Ie,embeddingsModel:Le,setEmbeddingsModel:Re,embeddingsInput:ze,setEmbeddingsInput:Be,embeddingsResult:Ve,generatingEmbeddings:Ue,handleGenerateEmbeddings:Dt})})]})},L=()=>{let{t:e}=i();return(0,M.jsxs)(ue,{children:[(0,M.jsx)(de,{title:e(`models.title`),description:e(`models.subtitle`)}),(0,M.jsx)(I,{})]})};export{L as ModelsPage,L as default};
|