llmxray 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/assets/{AITrainingPage-GE_hvc8i.js → AITrainingPage-BVvM9c3w.js} +1 -1
  2. package/dist/assets/{AnalyticsPage-CUpkcOcS.js → AnalyticsPage-BXq_Bseq.js} +1 -1
  3. package/dist/assets/{BenchmarkPage-DQuv9EdH.js → BenchmarkPage-BCqqL1M2.js} +1 -1
  4. package/dist/assets/{ComparisonPage-DXh2a8TJ.js → ComparisonPage-czrwH66h.js} +1 -1
  5. package/dist/assets/{CostDashboardPage-C4IVmHn1.js → CostDashboardPage-BR0kcGWe.js} +1 -1
  6. package/dist/assets/DashboardPage-RSlbctDt.js +108 -0
  7. package/dist/assets/{EmbeddingsPage-tMH5Unz8.js → EmbeddingsPage-DrWx8pzx.js} +1 -1
  8. package/dist/assets/{GoogleCallbackPage-Bljvoj2X.js → GoogleCallbackPage-DagDM0id.js} +1 -1
  9. package/dist/assets/{JsonTreeNode-srBpwnIe.js → JsonTreeNode-CJDN2gMs.js} +1 -1
  10. package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CBo5u7cq.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-ZVZG2QJf.js} +1 -1
  11. package/dist/assets/{RAGPage-Br6DZPuU.js → RAGPage-DuboRMs8.js} +1 -1
  12. package/dist/assets/{SessionPage-CVpgkmrd.js → SessionPage-gdjMmXms.js} +1 -1
  13. package/dist/assets/{SettingsPage-DY1zfkza.js → SettingsPage-BOgg5oN9.js} +1 -1
  14. package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-PDuG6Cj4.js → StatusBadge.vue_vue_type_script_setup_true_lang-CAUQKTSd.js} +1 -1
  15. package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-OYUc8hU5.js → StorageGauge.vue_vue_type_style_index_0_lang-BXU36Aoc.js} +1 -1
  16. package/dist/assets/{SystemPage-D-tjkE5U.js → SystemPage-D15_nq0O.js} +2 -2
  17. package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-DvubG_tm.js → TabBar.vue_vue_type_script_setup_true_lang-GaVAqJYj.js} +1 -1
  18. package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-GmRAK2xe.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-CU1jcClu.js} +1 -1
  19. package/dist/assets/{ToolWorkshopPage-ChG2v784.js → ToolWorkshopPage-CcnMYV0-.js} +1 -1
  20. package/dist/assets/{agent-store-qLxji-w9.js → agent-store-7ERQoYE_.js} +1 -1
  21. package/dist/assets/{canvas-ai-db-DIu3Cyqr.js → canvas-ai-db-BQgRWF3i.js} +1 -1
  22. package/dist/assets/{download-DBk31Sbj.js → download-Bt_RPvva.js} +1 -1
  23. package/dist/assets/{generate-service-BIV4odla.js → generate-service-DZWvg2CZ.js} +1 -1
  24. package/dist/assets/{google-auth-store-Cxj4bIXD.js → google-auth-store-BlzSHGyV.js} +1 -1
  25. package/dist/assets/index-BXlm4Yjw.js +36 -0
  26. package/dist/assets/{index-CIiugJtV.js → index-CJR-Mn7H.js} +1 -1
  27. package/dist/assets/{index-lybAETDi.js → index-ClS2OLai.js} +1 -1
  28. package/dist/assets/{info-Cxpjao0U.js → info-Dakpd0oS.js} +1 -1
  29. package/dist/assets/{metrics-store-BZ8E63Rc.js → metrics-store-BxvSgW3I.js} +1 -1
  30. package/dist/assets/{papaparse.min-kBINl9ZG.js → papaparse.min-B2JsqFEL.js} +1 -1
  31. package/dist/assets/{pencil-DuvF5FdW.js → pencil-qLgRz8v5.js} +1 -1
  32. package/dist/assets/{rag-store-fluSCOWr.js → rag-store-DXWEPNvK.js} +3 -3
  33. package/dist/assets/{session-store-DQW7koXz.js → session-store-DccvjxkU.js} +1 -1
  34. package/dist/assets/{share-2-NJrUNieP.js → share-2-BV2yUwOL.js} +1 -1
  35. package/dist/assets/{storage-store-BVsJ2m6T.js → storage-store-CsJ0rV6C.js} +1 -1
  36. package/dist/assets/{stream-handler-BJnVDKi0.js → stream-handler-DzltRNC4.js} +1 -1
  37. package/dist/assets/{tool-workshop-store-C-j6ilp2.js → tool-workshop-store-CLI2kTMZ.js} +1 -1
  38. package/dist/assets/{toolcall-store-CMBLYe4d.js → toolcall-store-CHxkee5s.js} +1 -1
  39. package/dist/assets/{trash-2-CCIzK_vg.js → trash-2-BpPF0NKP.js} +1 -1
  40. package/dist/index.html +1 -1
  41. package/package.json +1 -1
  42. package/dist/assets/DashboardPage-DhvUf3u6.js +0 -116
  43. package/dist/assets/index-BI1ok0nK.js +0 -8
@@ -0,0 +1,108 @@
1
+ import{u as lt}from"./metrics-store-BxvSgW3I.js";import{c as Ie,_ as Ps,o as je,n as ye,r as z,d as Ot,w as se,a as F,b as ne,e as g,f as r,g as P,t as u,h as Me,i as E,j as m,F as U,k as J,l as Ds,u as b,m as Is,p as j,q as Pe,T as js,s as Ut,v as He,X as Xe,x as Vt,y as Ls,z as Kt,A as ct,B as Ht,E as Bs,C as G,D as Y,G as st,H as Wt,I as Gt,J as Fs,S as qs,K as Os}from"./index-BXlm4Yjw.js";import{f as Te,a as We,b as nt,c as Zt,d as Us}from"./format-BqVZ9rwM.js";import{u as Ye}from"./session-store-DccvjxkU.js";import{a as Vs,s as Ks}from"./generate-service-DZWvg2CZ.js";import{u as Hs,a as Ws,_ as Gs,b as Ve}from"./StatusBadge.vue_vue_type_script_setup_true_lang-CAUQKTSd.js";import{u as Zs}from"./toolcall-store-CHxkee5s.js";import{u as ut}from"./tool-workshop-store-CLI2kTMZ.js";import{u as Qs,a as Qt,b as Js}from"./agent-store-7ERQoYE_.js";import{e as Xs}from"./stream-handler-DzltRNC4.js";import{d as Ys,p as en,u as Jt}from"./rag-store-DXWEPNvK.js";import{messageMemoryDB as Xt}from"./message-memory-db-C3Ifhs2B.js";import{_ as Mt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-ZVZG2QJf.js";import{P as Rt}from"./pencil-qLgRz8v5.js";import{D as tn}from"./download-Bt_RPvva.js";import"./vector-db-ChAzHl5A.js";const sn=Ie("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);const Yt=Ie("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const nn=Ie("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]);const on=Ie("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const an=Ie("slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);async function rn(t,e){const s=performance.now();try{let o;return t.implementation.mode==="code"?o=await ln(t.implementation.code,e):o=await cn(t.implementation.blocks,e),{success:!0,result:o,durationMs:performance.now()-s}}catch(o){return{success:!1,result:null,durationMs:performance.now()-s,error:o instanceof Error?o.message:String(o)}}}async function ln(t,e){if(!t.trim())throw new Error("Tool has no implementation code");const s=Object.getPrototypeOf(async function(){}).constructor;return await new s("args","fetch","getGoogleToken",t)(e,fetch.bind(globalThis),mn)}async function cn(t,e){if(t.length===0)throw new Error("Tool has no action blocks");const s=new Map;for(const[i,a]of Object.entries(e))s.set(i,a);const o=[...t].sort((i,a)=>i.order-a.order);let n=null;for(const i of o)switch(i.type){case"http_request":await un(i.config,s);break;case"extract_field":dn(i.config,s);break;case"template":pn(i.config,s);break;case"return_value":n=hn(i.config,s);break}return n}async function un(t,e){const s=De(t.url,e),o=t.body?De(t.body,e):void 0,n={};for(const[l,p]of Object.entries(t.headers))n[l]=De(p,e);const i=await fetch(s,{method:t.method,headers:n,body:t.method!=="GET"?o:void 0});let a;(i.headers.get("content-type")??"").includes("application/json")?a=await i.json():a=await i.text(),e.set(t.outputVariable||"response",a)}function dn(t,e){const s=e.get(t.input);if(s==null){e.set(t.outputVariable||"value",null);return}const o=t.fieldPath.split(".");let n=s;for(const i of o){if(n==null||typeof n!="object"){n=null;break}n=n[i]}e.set(t.outputVariable||"value",n)}function pn(t,e){const s=De(t.template,e);e.set(t.outputVariable||"text",s)}function hn(t,e){const s=t.expression.trim();return e.has(s)?e.get(s):De(s,e)}async function mn(){const{getAccessToken:t,isConnected:e}=await Ps(async()=>{const{getAccessToken:s,isConnected:o}=await import("./google-auth-CfEcVMA7.js");return{getAccessToken:s,isConnected:o}},[]);if(!e())throw new Error("Google account not connected. Go to Settings to connect your Google account.");return t()}function De(t,e){return t.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g,(s,o)=>{const n=o.split(".");let i=e.get(n[0]??"");for(let a=1;a<n.length;a++){if(i==null||typeof i!="object")return"";i=i[n[a]??""]}return i==null?"":typeof i=="object"?JSON.stringify(i):String(i)})}const gn=5;async function fn(t){const e=Ye(),s=Hs(),o=t.messages.map(c=>`[${c.role}] ${c.content}`).join(`
2
+ `),n=e.createSession({mode:"chat",model:t.model,prompt:o,messages:t.messages,options:t.options});e.setActiveSession(n);const i=Vs(n,t.messages);s.setAnatomy(n,i);const a=new AbortController;return bn(n,t.model,[...t.messages],t.tools,t.options,a.signal).catch(c=>{a.signal.aborted||e.setSessionError(n,c instanceof Error?c.message:"Chat failed")}),{sessionId:n,abort:()=>{a.abort(),e.cancelSession(n)}}}async function bn(t,e,s,o,n,i){const a=Zs(),c=ut(),l=Qs();let p=0,d=0;for(;p<gn;){if(i.aborted)return;const h=await je.streamChat({model:e,messages:s,tools:o,options:n,logprobs:!0},i),v=await Xs(t,h,i);if(v.toolCalls.length===0)return;s.push({role:"assistant",content:"",tool_calls:v.toolCalls});for(const C of v.toolCalls){const S=c.findByFunctionName(C.function.name),x=a.getToolCalls(t).find(K=>K.functionName===C.function.name&&K.status==="pending");if(!S){const K=`Tool "${C.function.name}" has no implementation`;l.addNode(t,{id:ye(),type:"error",label:`No impl: ${C.function.name}`,sessionId:t,stepIndex:d++,state:{tool:C.function.name,error:K},timestamp:Date.now()}),x&&a.updateToolCall(t,x.id,{status:"failed",error:K,completedAt:Date.now()}),s.push({role:"tool",content:JSON.stringify({error:K})});continue}x&&a.updateToolCall(t,x.id,{status:"executing"});const D=await rn(S,C.function.arguments);l.addNode(t,{id:ye(),type:D.success?"output":"error",label:D.success?`Tool Result: ${C.function.name}`:`Tool Failed: ${C.function.name}`,sessionId:t,stepIndex:d++,state:{tool:C.function.name,success:D.success,durationMs:D.durationMs},timestamp:Date.now()}),x&&a.updateToolCall(t,x.id,{status:D.success?"completed":"failed",result:D.result,error:D.error,completedAt:Date.now(),durationMs:D.durationMs});const H=D.success?typeof D.result=="string"?D.result:JSON.stringify(D.result):JSON.stringify({error:D.error});s.push({role:"tool",content:H})}l.addNode(t,{id:ye(),type:"llm_call",label:`LLM Round ${p+2} (with tool results)`,sessionId:t,stepIndex:d++,state:{round:p+1},timestamp:Date.now()}),p++}}function xn(){const t=z(!1),e=z(null),s=z(null);let o=null;async function n(c,l,p,d){t.value=!0,e.value=null;try{const h=await Ks({model:c,prompt:l,system:d,options:p});return s.value=h.sessionId,o=h.abort,h.sessionId}catch(h){throw e.value=h instanceof Error?h.message:"Failed to start generation",t.value=!1,h}}async function i(c,l,p,d){t.value=!0,e.value=null;try{const h=await fn({model:c,messages:l,tools:d,options:p});return s.value=h.sessionId,o=h.abort,h.sessionId}catch(h){throw e.value=h instanceof Error?h.message:"Failed to start chat",t.value=!1,h}}function a(){o&&(o(),o=null),t.value=!1}return{isStreaming:t,error:e,currentSessionId:s,startGenerate:n,startChatStream:i,cancel:a}}const M="dashboard.slashCommands.notifications",Ge=[{name:"help",descriptionKey:"dashboard.slashCommands.descriptions.help",description:"Show all available commands",usage:"/help",category:"chat",execute(t,e){const s=es(e.t),o=[e.t(`${M}.helpHeader`)];for(const[n,i]of Object.entries(s)){o.push(`**${n}**`);for(const a of i){const c=a.descriptionKey?e.t(a.descriptionKey):a.description;o.push(` ${a.usage} — ${c}`)}o.push("")}e.showNotification(o.join(`
3
+ `))}},{name:"clear",descriptionKey:"dashboard.slashCommands.descriptions.clear",description:"Clear current conversation",usage:"/clear",category:"chat",execute(t,e){e.clearConversation(),e.showNotification(e.t(`${M}.conversationCleared`))}},{name:"new",descriptionKey:"dashboard.slashCommands.descriptions.new",description:"Start a new chat session",usage:"/new",category:"chat",execute(t,e){e.newChat(),e.showNotification(e.t(`${M}.newChatStarted`))}},{name:"summarize",descriptionKey:"dashboard.slashCommands.descriptions.summarize",description:"Ask the model to summarize the conversation",usage:"/summarize",category:"chat",execute(t,e){if(e.messages.length===0){e.showNotification(e.t(`${M}.nothingToSummarize`));return}e.sendAsUser("Please summarize our conversation so far in a concise way.")}},{name:"save",descriptionKey:"dashboard.slashCommands.descriptions.save",description:"Export conversation as JSON or text",usage:"/save [json|text]",category:"chat",execute(t,e){const s=t.trim()==="text"?"text":"json";e.exportConversation(s),e.showNotification(e.t(`${M}.conversationExported`,{format:s}))}},{name:"copy",descriptionKey:"dashboard.slashCommands.descriptions.copy",description:"Copy last assistant response to clipboard",usage:"/copy",category:"chat",execute(t,e){e.copyLastResponse()}},{name:"history",descriptionKey:"dashboard.slashCommands.descriptions.history",description:"Show recent conversations",usage:"/history",category:"chat",execute(t,e){e.showNotification(e.t(`${M}.historyHint`))}},{name:"model",descriptionKey:"dashboard.slashCommands.descriptions.model",description:"Switch model or list available models",usage:"/model [name]",category:"settings",execute(t,e){const s=t.trim();if(!s){const n=e.availableModels.join(", ");e.showNotification(e.t(`${M}.availableModels`,{list:n,current:e.currentModel}));return}const o=e.availableModels.find(n=>n===s||n.startsWith(s));o?(e.switchModel(o),e.showNotification(e.t(`${M}.switchedTo`,{model:o}))):e.showNotification(e.t(`${M}.modelNotFound`,{name:s,list:e.availableModels.join(", ")}))}},{name:"system",descriptionKey:"dashboard.slashCommands.descriptions.system",description:"Set the system prompt",usage:"/system <prompt>",category:"settings",execute(t,e){const s=t.trim();if(!s){const o=e.chatSettings.value.systemPrompt||e.t(`${M}.none`);e.showNotification(e.t(`${M}.currentSystemPrompt`,{prompt:o}));return}e.setSystemPrompt(s),e.showNotification(e.t(`${M}.systemPromptUpdated`))}},{name:"temperature",descriptionKey:"dashboard.slashCommands.descriptions.temperature",description:"Set temperature (0-2)",usage:"/temperature <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<0||s>2){e.showNotification(e.t(`${M}.tempUsage`,{current:e.chatSettings.value.options.temperature??.7}));return}e.setOption("temperature",s),e.showNotification(e.t(`${M}.temperatureSet`,{value:s}))}},{name:"top_p",descriptionKey:"dashboard.slashCommands.descriptions.top_p",description:"Set top-p / nucleus sampling (0-1)",usage:"/top_p <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<0||s>1){e.showNotification(e.t(`${M}.topPUsage`,{current:e.chatSettings.value.options.top_p??.9}));return}e.setOption("top_p",s),e.showNotification(e.t(`${M}.topPSet`,{value:s}))}},{name:"top_k",descriptionKey:"dashboard.slashCommands.descriptions.top_k",description:"Set top-k sampling (1-100)",usage:"/top_k <value>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(isNaN(s)||s<1||s>100){e.showNotification(e.t(`${M}.topKUsage`,{current:e.chatSettings.value.options.top_k??40}));return}e.setOption("top_k",s),e.showNotification(e.t(`${M}.topKSet`,{value:s}))}},{name:"context",descriptionKey:"dashboard.slashCommands.descriptions.context",description:"Set context window size",usage:"/context <size>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10),o=[2048,4096,8192,16384,32768,65536,131072];if(isNaN(s)||!o.includes(s)){e.showNotification(e.t(`${M}.contextUsage`,{current:Te(e.chatSettings.value.options.num_ctx??4096),sizes:o.join(", ")}));return}e.setOption("num_ctx",s),e.showNotification(e.t(`${M}.contextSet`,{value:Te(s)}))}},{name:"repeat_penalty",descriptionKey:"dashboard.slashCommands.descriptions.repeat_penalty",description:"Set repeat penalty (1.0-2.0)",usage:"/repeat_penalty <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<1||s>2){e.showNotification(e.t(`${M}.repeatPenaltyUsage`,{current:e.chatSettings.value.options.repeat_penalty??1.1}));return}e.setOption("repeat_penalty",s),e.showNotification(e.t(`${M}.repeatPenaltySet`,{value:s}))}},{name:"seed",descriptionKey:"dashboard.slashCommands.descriptions.seed",description:"Set seed for reproducibility (-1 for random)",usage:"/seed <value>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(isNaN(s)){e.showNotification(e.t(`${M}.seedUsage`,{current:e.chatSettings.value.options.seed??-1}));return}e.setOption("seed",s===-1?void 0:s),e.showNotification(s===-1?e.t(`${M}.seedRandom`):e.t(`${M}.seedSet`,{value:s}))}},{name:"stop",descriptionKey:"dashboard.slashCommands.descriptions.stop",description:"Set stop sequences (comma-separated)",usage:"/stop <sequences>",category:"settings",execute(t,e){const s=t.trim();if(!s){const n=e.chatSettings.value.options.stop?.join(", ")||e.t(`${M}.none`);e.showNotification(e.t(`${M}.stopCurrent`,{sequences:n}));return}const o=s.split(",").map(n=>n.trim()).filter(Boolean);e.setOption("stop",o.length>0?o:void 0),e.showNotification(e.t(`${M}.stopSet`,{sequences:o.join(", ")}))}},{name:"mirostat",descriptionKey:"dashboard.slashCommands.descriptions.mirostat",description:"Set mirostat mode (0=off, 1=v1, 2=v2)",usage:"/mirostat <0|1|2>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(![0,1,2].includes(s)){e.showNotification(e.t(`${M}.mirostatUsage`,{current:e.chatSettings.value.options.mirostat??0}));return}e.setOption("mirostat",s),e.showNotification(s===0?e.t(`${M}.mirostatDisabled`):e.t(`${M}.mirostatEnabled`,{version:s}))}},{name:"format",descriptionKey:"dashboard.slashCommands.descriptions.format",description:"Toggle JSON output format",usage:"/format [json]",category:"settings",execute(t,e){const s=t.trim().toLowerCase()==="json";e.setJsonFormat(s),e.showNotification(s?e.t(`${M}.jsonFormatEnabled`):e.t(`${M}.jsonFormatDisabled`))}},{name:"reset",descriptionKey:"dashboard.slashCommands.descriptions.reset",description:"Reset all settings to defaults",usage:"/reset",category:"settings",execute(t,e){e.resetSettings(),e.showNotification(e.t(`${M}.settingsReset`))}},{name:"rag",descriptionKey:"dashboard.slashCommands.descriptions.rag",description:"Toggle RAG context on/off",usage:"/rag",category:"navigation",execute(t,e){e.toggleRag(),e.showNotification(e.ragEnabled?e.t(`${M}.ragDisabled`):e.t(`${M}.ragEnabled`))}},{name:"tools",descriptionKey:"dashboard.slashCommands.descriptions.tools",description:"Open tools settings panel",usage:"/tools",category:"navigation",execute(t,e){e.openSettings(),e.showNotification(e.t(`${M}.settingsPanelOpened`))}},{name:"status",descriptionKey:"dashboard.slashCommands.descriptions.status",description:"Show Ollama connection status and model info",usage:"/status",category:"navigation",async execute(t,e){const s=await e.getOllamaStatus(),o=s.connected?e.t(`${M}.ollamaConnected`):e.t(`${M}.ollamaDisconnected`);e.showNotification(e.t(`${M}.ollamaStatus`,{status:o,model:s.model||e.t(`${M}.none`)}))}},{name:"tokens",descriptionKey:"dashboard.slashCommands.descriptions.tokens",description:"Show token count for current session",usage:"/tokens",category:"navigation",execute(t,e){const s=e.getSessionTokenCount();if(!s){e.showNotification(e.t(`${M}.noActiveSession`));return}e.showNotification(e.t(`${M}.tokenCounts`,{prompt:Te(s.prompt),completion:Te(s.completion),total:Te(s.prompt+s.completion)}))}},{name:"speed",descriptionKey:"dashboard.slashCommands.descriptions.speed",description:"Show average generation speed across sessions",usage:"/speed",category:"navigation",execute(t,e){const s=e.getAverageSpeed();if(s===null){e.showNotification(e.t(`${M}.noSessionsRecorded`));return}e.showNotification(e.t(`${M}.averageSpeed`,{speed:We(s)}))}},{name:"compare",descriptionKey:"dashboard.slashCommands.descriptions.compare",description:"Navigate to the Compare page",usage:"/compare",category:"navigation",execute(t,e){e.navigate("/compare")}},{name:"session",descriptionKey:"dashboard.slashCommands.descriptions.session",description:"View current session details",usage:"/session",category:"navigation",execute(t,e){e.openSessionDetails()}},{name:"remember",descriptionKey:"dashboard.slashCommands.descriptions.remember",description:"Remember a fact about you across conversations",usage:"/remember <fact>",category:"memory",execute(t,e){const s=t.trim();if(!s){e.showNotification(e.t(`${M}.rememberUsage`));return}e.addFact(s),e.showNotification(e.t(`${M}.remembered`,{fact:s}))}},{name:"forget",descriptionKey:"dashboard.slashCommands.descriptions.forget",description:"Forget a previously remembered fact",usage:"/forget <search>",category:"memory",execute(t,e){const s=t.trim();if(!s){e.showNotification(e.t(`${M}.forgetUsage`));return}e.removeFact(s)?e.showNotification(e.t(`${M}.forgot`,{search:s})):e.showNotification(e.t(`${M}.factNotFound`,{search:s}))}},{name:"memories",descriptionKey:"dashboard.slashCommands.descriptions.memories",description:"Show all remembered facts",usage:"/memories",category:"memory",execute(t,e){const s=e.getFacts();if(s.length===0){e.showNotification(e.t(`${M}.noMemories`));return}const o=s.map((n,i)=>`${i+1}. ${n.content}`);e.showNotification(e.t(`${M}.yourMemories`,{count:s.length,list:o.join(`
4
+ `)}))}}];function yn(t){const e=t.toLowerCase().replace(/^\//,"");return e?Ge.filter(s=>s.name.startsWith(e)):Ge}function vn(t){return Ge.find(e=>e.name===t.toLowerCase())}function es(t){const e={};for(const s of Ge){let o;t?o=s.category==="chat"?t("dashboard.slashCommands.chatConversation"):s.category==="settings"?t("dashboard.slashCommands.modelSettings"):s.category==="memory"?t("dashboard.slashCommands.memory"):t("dashboard.slashCommands.featuresNavigation"):o=s.category==="chat"?"Chat & Conversation":s.category==="settings"?"Model & Settings":s.category==="memory"?"Memory":"Features & Navigation",(e[o]??=[]).push(s)}return e}const At={slidingWindow:{enabled:!0,maxMessages:50},autoSummarize:{enabled:!1,triggerThreshold:30},ragMemory:{enabled:!1,embeddingModel:"",topK:3},userFacts:{enabled:!0}},zt="llmxray-memory-settings",Nt="llmxray-user-facts";function Et(t,e){try{const s=localStorage.getItem(t);return s?JSON.parse(s):e}catch{return e}}function Pt(t,e){localStorage.setItem(t,JSON.stringify(e))}const ts=Ot("memory",()=>{const t=z(Et(zt,{...At}));se(t,S=>Pt(zt,S),{deep:!0});function e(S){t.value={...t.value,...S}}function s(){t.value={...At}}const o=z(Et(Nt,[]));se(o,S=>Pt(Nt,S),{deep:!0});const n=F(()=>o.value.length);function i(S){const N={id:ye(),content:S.trim(),createdAt:Date.now()};return o.value=[...o.value,N],N}function a(S){o.value=o.value.filter(N=>N.id!==S)}function c(S){const N=S.toLowerCase().trim(),x=o.value.findIndex(D=>D.content.toLowerCase().includes(N));return x===-1?!1:(o.value=[...o.value.slice(0,x),...o.value.slice(x+1)],!0)}function l(){o.value=[]}function p(){return o.value.length===0?"":`The user has asked you to remember these facts about them:
5
+ ${o.value.map(N=>`- ${N.content}`).join(`
6
+ `)}
7
+
8
+ Keep these in mind when responding.`}const d=z(new Map);function h(S,N,x){d.value.set(S,{conversationId:S,summary:N,messageCount:x,createdAt:Date.now()})}function v(S){return d.value.get(S)}function C(S){d.value.delete(S)}return{settings:t,updateSettings:e,resetSettings:s,facts:o,factCount:n,addFact:i,removeFact:a,removeFactByContent:c,clearFacts:l,getFactsAsSystemPrompt:p,summaries:d,setSummary:h,getSummary:v,clearSummary:C}}),ss=Ot("quality",()=>{const t=z(new Map);function e(n){return t.value.get(n)??null}function s(n,i){t.value.set(n,i)}function o(n){return t.value.has(n)}return{reportsByMessage:t,getReport:e,setReport:s,hasReport:o}}),kn=[/as an ai( language)? model/i,/i cannot (help|assist|provide)/i,/i('m| am) not able to/i,/i('m| am) unable to/i,/i must (decline|refuse)/i,/it('s| is) not (appropriate|ethical)/i,/i don'?t have the ability/i,/my programming (prevents|doesn'?t allow)/i];function wn(t,e){const s=[];for(let o=0;o<=t.length-e;o++)s.push(t.slice(o,o+e).join(" "));return s}function $n(t){const e=t.toLowerCase().split(/\s+/).filter(Boolean);if(e.length<8)return{detector:"repetition",status:"pass",reason:"quality.repetition.reason"};const s=wn(e,4);if(s.length===0)return{detector:"repetition",status:"pass",reason:"quality.repetition.reason"};const o=new Map;for(const a of s)o.set(a,(o.get(a)??0)+1);let n=0;for(const a of o.values())a>1&&(n+=a);const i=n/s.length;return i>.5?{detector:"repetition",status:"fail",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:i>.3?{detector:"repetition",status:"warn",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:{detector:"repetition",status:"pass",reason:"quality.repetition.reason"}}function Sn(t){for(const e of kn)if(e.test(t))return{detector:"refusal",status:"warn",reason:"quality.refusal.reason",detail:`Matched: ${e.source}`};return{detector:"refusal",status:"pass",reason:"quality.refusal.reason"}}function _n(t){if(t.length<=20)return{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"};let e=0;for(let o=0;o<t.length;o++)t.charCodeAt(o)>127&&e++;const s=e/t.length;return s>.4?{detector:"gibberish",status:"warn",reason:"quality.gibberish.reason",detail:`${(s*100).toFixed(0)}% non-ASCII characters`}:{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"}}function Cn(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?{detector:"empty",status:"fail",reason:"quality.empty.reason",detail:"0 words"}:e.length<10?{detector:"empty",status:"warn",reason:"quality.empty.reason",detail:`${e.length} words`}:{detector:"empty",status:"pass",reason:"quality.empty.reason"}}function Tn(t,e,s,o){if(o==="length")return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:"Model stopped due to token limit"};if(s&&s>0){const n=e/s,i=/[.!?\n)\]"]$/.test(t.trim());if(n>.9&&!i)return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:`Used ${(n*100).toFixed(0)}% of token budget without clean ending`}}return{detector:"truncation",status:"pass",reason:"quality.truncation.reason"}}function Mn(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}function Rn(t,e,s,o,n,i){const a=[$n(s),Sn(s),_n(s),Cn(s),Tn(s,o,n,i)];return{messageId:t,sessionId:e,overall:Mn(a),checks:a,analyzedAt:Date.now()}}async function An(t){let e=[...t.messages],s;t.settings.userFacts.enabled&&t.userFactsPrompt&&e.unshift({role:"system",content:t.userFactsPrompt});const o=e.filter(n=>n.role!=="system");if(t.settings.autoSummarize.enabled&&o.length>t.settings.autoSummarize.triggerThreshold){const n=Math.floor(t.settings.autoSummarize.triggerThreshold/3),i=e.filter(d=>d.role==="system"),a=o.slice(0,-n),c=o.slice(-n),l=t.existingSummary?`Previous summary:
9
+ ${t.existingSummary}
10
+
11
+ New messages to incorporate:
12
+ `:"",p=await Nn(t.model,l+a.map(d=>`${d.role}: ${d.content}`).join(`
13
+ `));p&&(s=p,e=[...i,{role:"system",content:`Summary of earlier conversation:
14
+ ${p}`},...c])}if(t.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),i=e.filter(c=>c.role!=="system"),a=t.settings.slidingWindow.maxMessages;if(i.length>a){const c=i.slice(-a);e=[...n,...c]}}if(t.settings.ragMemory.enabled&&t.settings.ragMemory.embeddingModel)try{const n=await En(t.conversationId,e,t.settings.ragMemory.embeddingModel,t.settings.ragMemory.topK);if(n){const i=e.filter(c=>c.role==="system"),a=e.filter(c=>c.role!=="system");e=[...i,{role:"system",content:n},...a]}}catch{}return{messages:e,newSummary:s}}async function zn(t,e,s){if(!s||e.length===0)return;const o=e.map(a=>a.content),n=await je.embed({model:s,input:o}),i=[];for(let a=0;a<e.length;a++){const c=n.embeddings[a];if(!c)continue;const l=e[a];i.push({id:ye(),conversationId:t,role:l.role,content:l.content,embedding:c,timestamp:l.timestamp})}await Xt.storeMessages(i)}async function Nn(t,e){try{return(await je.chat({model:t,messages:[{role:"system",content:"You are a helpful assistant. Summarize the following conversation concisely, preserving key facts, decisions, and context that would be important for continuing the conversation. Keep it under 300 words."},{role:"user",content:e}],stream:!1})).message.content.trim()||null}catch{return null}}async function En(t,e,s,o){const n=e.filter(h=>h.role==="user"),i=n[n.length-1];if(!i)return null;const c=(await je.embed({model:s,input:[i.content]})).embeddings[0];if(!c)return null;const p=(await Xt.search(c,o,t)).filter(h=>h.score>.5);return p.length===0?null:`Relevant messages from past conversations:
15
+ ${p.map(h=>`[${h.message.role}, relevance: ${(h.score*100).toFixed(0)}%] ${h.message.content}`).join(`
16
+
17
+ `)}
18
+
19
+ Use this context if helpful, but prioritize the current conversation.`}function dt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Se=dt();function ns(t){Se=t}var we={exec:()=>null};function I(t,e=""){let s=typeof t=="string"?t:t.source,o={replace:(n,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(X.caret,"$1"),s=s.replace(n,a),o},getRegex:()=>new RegExp(s,e)};return o}var Pn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),X={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Dn=/^(?:[ \t]*(?:\n|$))+/,In=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Le=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ln=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,pt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,os=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,as=I(os).replace(/bull/g,pt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Bn=I(os).replace(/bull/g,pt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ht=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Fn=/^[^\n]+/,mt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qn=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",mt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),On=I(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,pt).getRegex(),et="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",gt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Un=I("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",gt).replace("tag",et).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rs=I(ht).replace("hr",Le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",et).getRegex(),Vn=I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rs).getRegex(),ft={blockquote:Vn,code:In,def:qn,fences:jn,heading:Ln,hr:Le,html:Un,lheading:as,list:On,newline:Dn,paragraph:rs,table:we,text:Fn},Dt=I("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",et).getRegex(),Kn={...ft,lheading:Bn,table:Dt,paragraph:I(ht).replace("hr",Le).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Dt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",et).getRegex()},Hn={...ft,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:we,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(ht).replace("hr",Le).replace("heading",` *#{1,6} *[^
20
+ ]`).replace("lheading",as).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Wn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,is=/^( {2,}|\\)\n(?!\s*$)/,Zn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tt=/[\p{P}\p{S}]/u,bt=/[\s\p{P}\p{S}]/u,ls=/[^\s\p{P}\p{S}]/u,Qn=I(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bt).getRegex(),cs=/(?!~)[\p{P}\p{S}]/u,Jn=/(?!~)[\s\p{P}\p{S}]/u,Xn=/(?:[^\s\p{P}\p{S}]|~)/u,us=/(?![*_])[\p{P}\p{S}]/u,Yn=/(?![*_])[\s\p{P}\p{S}]/u,eo=/(?:[^\s\p{P}\p{S}]|[*_])/u,to=I(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Pn?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ds=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,so=I(ds,"u").replace(/punct/g,tt).getRegex(),no=I(ds,"u").replace(/punct/g,cs).getRegex(),ps="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oo=I(ps,"gu").replace(/notPunctSpace/g,ls).replace(/punctSpace/g,bt).replace(/punct/g,tt).getRegex(),ao=I(ps,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,Jn).replace(/punct/g,cs).getRegex(),ro=I("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ls).replace(/punctSpace/g,bt).replace(/punct/g,tt).getRegex(),io=I(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,us).getRegex(),lo="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",co=I(lo,"gu").replace(/notPunctSpace/g,eo).replace(/punctSpace/g,Yn).replace(/punct/g,us).getRegex(),uo=I(/\\(punct)/,"gu").replace(/punct/g,tt).getRegex(),po=I(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ho=I(gt).replace("(?:-->|$)","-->").getRegex(),mo=I("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ho).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ze=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,go=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ze).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hs=I(/^!?\[(label)\]\[(ref)\]/).replace("label",Ze).replace("ref",mt).getRegex(),ms=I(/^!?\[(ref)\](?:\[\])?/).replace("ref",mt).getRegex(),fo=I("reflink|nolink(?!\\()","g").replace("reflink",hs).replace("nolink",ms).getRegex(),It=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,xt={_backpedal:we,anyPunctuation:uo,autolink:po,blockSkip:to,br:is,code:Gn,del:we,delLDelim:we,delRDelim:we,emStrongLDelim:so,emStrongRDelimAst:oo,emStrongRDelimUnd:ro,escape:Wn,link:go,nolink:ms,punctuation:Qn,reflink:hs,reflinkSearch:fo,tag:mo,text:Zn,url:we},bo={...xt,link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",Ze).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ze).getRegex()},ot={...xt,emStrongRDelimAst:ao,emStrongLDelim:no,delLDelim:io,delRDelim:co,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",It).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",It).getRegex()},xo={...ot,br:I(is).replace("{2,}","*").getRegex(),text:I(ot.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ke={normal:ft,gfm:Kn,pedantic:Hn},ze={normal:xt,gfm:ot,breaks:xo,pedantic:bo},yo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},jt=t=>yo[t];function de(t,e){if(e){if(X.escapeTest.test(t))return t.replace(X.escapeReplace,jt)}else if(X.escapeTestNoEncode.test(t))return t.replace(X.escapeReplaceNoEncode,jt);return t}function Lt(t){try{t=encodeURI(t).replace(X.percentDecode,"%")}catch{return null}return t}function Bt(t,e){let s=t.replace(X.findPipe,(i,a,c)=>{let l=!1,p=a;for(;--p>=0&&c[p]==="\\";)l=!l;return l?"|":" |"}),o=s.split(X.splitPipe),n=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;n<o.length;n++)o[n]=o[n].trim().replace(X.slashPipe,"|");return o}function Ne(t,e,s){let o=t.length;if(o===0)return"";let n=0;for(;n<o&&t.charAt(o-n-1)===e;)n++;return t.slice(0,o-n)}function vo(t,e){if(t.indexOf(e[1])===-1)return-1;let s=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])s++;else if(t[o]===e[1]&&(s--,s<0))return o;return s>0?-2:-1}function ko(t,e=0){let s=e,o="";for(let n of t)if(n===" "){let i=4-s%4;o+=" ".repeat(i),s+=i}else o+=n,s++;return o}function Ft(t,e,s,o,n){let i=e.href,a=e.title||null,c=t[1].replace(n.other.outputLinkReplace,"$1");o.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:s,href:i,title:a,text:c,tokens:o.inlineTokens(c)};return o.state.inLink=!1,l}function wo(t,e,s){let o=t.match(s.other.indentCodeCompensation);if(o===null)return e;let n=o[1];return e.split(`
21
+ `).map(i=>{let a=i.match(s.other.beginningSpace);if(a===null)return i;let[c]=a;return c.length>=n.length?i.slice(n.length):i}).join(`
22
+ `)}var Qe=class{options;rules;lexer;constructor(t){this.options=t||Se}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let s=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?s:Ne(s,`
23
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let s=e[0],o=wo(s,e[3]||"",this.rules);return{type:"code",raw:s,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let s=e[2].trim();if(this.rules.other.endingHash.test(s)){let o=Ne(s,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(s=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ne(e[0],`
24
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=Ne(e[0],`
25
+ `).split(`
26
+ `),o="",n="",i=[];for(;s.length>0;){let a=!1,c=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))c.push(s[l]),a=!0;else if(!a)c.push(s[l]);else break;s=s.slice(l);let p=c.join(`
27
+ `),d=p.replace(this.rules.other.blockquoteSetextReplace,`
28
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
29
+ ${p}`:p,n=n?`${n}
30
+ ${d}`:d;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=h,s.length===0)break;let v=i.at(-1);if(v?.type==="code")break;if(v?.type==="blockquote"){let C=v,S=C.raw+`
31
+ `+s.join(`
32
+ `),N=this.blockquote(S);i[i.length-1]=N,o=o.substring(0,o.length-C.raw.length)+N.raw,n=n.substring(0,n.length-C.text.length)+N.text;break}else if(v?.type==="list"){let C=v,S=C.raw+`
33
+ `+s.join(`
34
+ `),N=this.list(S);i[i.length-1]=N,o=o.substring(0,o.length-v.raw.length)+N.raw,n=n.substring(0,n.length-C.raw.length)+N.raw,s=S.substring(i.at(-1).raw.length).split(`
35
+ `);continue}}return{type:"blockquote",raw:o,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),o=s.length>1,n={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let i=this.rules.other.listItemRegex(s),a=!1;for(;t;){let l=!1,p="",d="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let h=ko(e[2].split(`
36
+ `,1)[0],e[1].length),v=t.split(`
37
+ `,1)[0],C=!h.trim(),S=0;if(this.options.pedantic?(S=2,d=h.trimStart()):C?S=e[1].length+1:(S=h.search(this.rules.other.nonSpaceChar),S=S>4?1:S,d=h.slice(S),S+=e[1].length),C&&this.rules.other.blankLine.test(v)&&(p+=v+`
38
+ `,t=t.substring(v.length+1),l=!0),!l){let N=this.rules.other.nextBulletRegex(S),x=this.rules.other.hrRegex(S),D=this.rules.other.fencesBeginRegex(S),H=this.rules.other.headingBeginRegex(S),K=this.rules.other.htmlBeginRegex(S),Q=this.rules.other.blockquoteBeginRegex(S);for(;t;){let W=t.split(`
39
+ `,1)[0],O;if(v=W,this.options.pedantic?(v=v.replace(this.rules.other.listReplaceNesting," "),O=v):O=v.replace(this.rules.other.tabCharGlobal," "),D.test(v)||H.test(v)||K.test(v)||Q.test(v)||N.test(v)||x.test(v))break;if(O.search(this.rules.other.nonSpaceChar)>=S||!v.trim())d+=`
40
+ `+O.slice(S);else{if(C||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||D.test(h)||H.test(h)||x.test(h))break;d+=`
41
+ `+v}C=!v.trim(),p+=W+`
42
+ `,t=t.substring(W.length+1),h=O.slice(S)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(a=!0)),n.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),n.raw+=p}let c=n.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l of n.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=d.checked,n.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}if(!n.loose){let p=l.tokens.filter(h=>h.type==="space"),d=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));n.loose=d}}if(n.loose)for(let l of n.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let s=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:s,raw:e[0],href:o,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let s=Bt(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
43
+ `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(s.length===o.length){for(let a of o)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<s.length;a++)i.header.push({text:s[a],tokens:this.lexer.inline(s[a]),header:!0,align:i.align[a]});for(let a of n)i.rows.push(Bt(a,i.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let s=e[1].charAt(e[1].length-1)===`
44
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let i=Ne(s.slice(0,-1),"\\");if((s.length-i.length)%2===0)return}else{let i=vo(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],n="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(o);i&&(o=i[1],n=i[3])}else n=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?o=o.slice(1):o=o.slice(1,-1)),Ft(e,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let s;if((s=this.rules.inline.reflink.exec(t))||(s=this.rules.inline.nolink.exec(t))){let o=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[o.toLowerCase()];if(!n){let i=s[0].charAt(0);return{type:"text",raw:i,text:i}}return Ft(s,n,s[0],this.lexer,this.rules)}}emStrong(t,e,s=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!(!o||o[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(o[1]||o[2])||!s||this.rules.inline.punctuation.exec(s))){let n=[...o[0]].length-1,i,a,c=n,l=0,p=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*t.length+n);(o=p.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(a=[...i].length,o[3]||o[4]){c+=a;continue}else if((o[5]||o[6])&&n%3&&!((n+a)%3)){l+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+l);let d=[...o[0]][0].length,h=t.slice(0,n+o.index+d+a);if(Math.min(n,a)%2){let C=h.slice(1,-1);return{type:"em",raw:h,text:C,tokens:this.lexer.inlineTokens(C)}}let v=h.slice(2,-2);return{type:"strong",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(s),n=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return o&&n&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,s=""){let o=this.rules.inline.delLDelim.exec(t);if(o&&(!o[1]||!s||this.rules.inline.punctuation.exec(s))){let n=[...o[0]].length-1,i,a,c=n,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+n);(o=l.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i||(a=[...i].length,a!==n))continue;if(o[3]||o[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let p=[...o[0]][0].length,d=t.slice(0,n+o.index+p+a),h=d.slice(n,-n);return{type:"del",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let s,o;return e[2]==="@"?(s=e[1],o="mailto:"+s):(s=e[1],o=s),{type:"link",raw:e[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let s,o;if(e[2]==="@")s=e[0],o="mailto:"+s;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);s=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let s=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:s}}}},ie=class at{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Se,this.options.tokenizer=this.options.tokenizer||new Qe,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:X,block:Ke.normal,inline:ze.normal};this.options.pedantic?(s.block=Ke.pedantic,s.inline=ze.pedantic):this.options.gfm&&(s.block=Ke.gfm,this.options.breaks?s.inline=ze.breaks:s.inline=ze.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ke,inline:ze}}static lex(e,s){return new at(s).lex(e)}static lexInline(e,s){return new at(s).inlineTokens(e)}lex(e){e=e.replace(X.carriageReturn,`
45
+ `),this.blockTokens(e,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let o=this.inlineQueue[s];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,s=[],o=!1){for(this.options.pedantic&&(e=e.replace(X.tabCharGlobal," ").replace(X.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(a=>(n=a.call({lexer:this},e,s))?(e=e.substring(n.raw.length),s.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let a=s.at(-1);n.raw.length===1&&a!==void 0?a.raw+=`
46
+ `:s.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
47
+ `)?"":`
48
+ `)+n.raw,a.text+=`
49
+ `+n.text,this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
50
+ `)?"":`
51
+ `)+n.raw,a.text+=`
52
+ `+n.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title},s.push(n));continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),s.push(n);continue}let i=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),l;this.options.extensions.startBlock.forEach(p=>{l=p.call({lexer:this},c),typeof l=="number"&&l>=0&&(a=Math.min(a,l))}),a<1/0&&a>=0&&(i=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let a=s.at(-1);o&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
53
+ `)?"":`
54
+ `)+n.raw,a.text+=`
55
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n),o=i.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
56
+ `)?"":`
57
+ `)+n.raw,a.text+=`
58
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,s}inline(e,s=[]){return this.inlineQueue.push({src:e,tokens:s}),s}inlineTokens(e,s=[]){let o=e,n=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)l.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,n.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)i=n[2]?n[2].length:0,o=o.slice(0,n.index+i)+"["+"a".repeat(n[0].length-i-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let a=!1,c="";for(;e;){a||(c=""),a=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},e,s))?(e=e.substring(l.raw.length),s.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let d=s.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.del(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),s.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),s.push(l);continue}let p=e;if(this.options.extensions?.startInline){let d=1/0,h=e.slice(1),v;this.options.extensions.startInline.forEach(C=>{v=C.call({lexer:this},h),typeof v=="number"&&v>=0&&(d=Math.min(d,v))}),d<1/0&&d>=0&&(p=e.substring(0,d+1))}if(l=this.tokenizer.inlineText(p)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(c=l.raw.slice(-1)),a=!0;let d=s.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(e){let d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return s}},Je=class{options;parser;constructor(t){this.options=t||Se}space(t){return""}code({text:t,lang:e,escaped:s}){let o=(e||"").match(X.notSpaceStart)?.[0],n=t.replace(X.endingNewline,"")+`
59
+ `;return o?'<pre><code class="language-'+de(o)+'">'+(s?n:de(n,!0))+`</code></pre>
60
+ `:"<pre><code>"+(s?n:de(n,!0))+`</code></pre>
61
+ `}blockquote({tokens:t}){return`<blockquote>
62
+ ${this.parser.parse(t)}</blockquote>
63
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
64
+ `}hr(t){return`<hr>
65
+ `}list(t){let e=t.ordered,s=t.start,o="";for(let a=0;a<t.items.length;a++){let c=t.items[a];o+=this.listitem(c)}let n=e?"ol":"ul",i=e&&s!==1?' start="'+s+'"':"";return"<"+n+i+`>
66
+ `+o+"</"+n+`>
67
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
68
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
69
+ `}table(t){let e="",s="";for(let n=0;n<t.header.length;n++)s+=this.tablecell(t.header[n]);e+=this.tablerow({text:s});let o="";for(let n=0;n<t.rows.length;n++){let i=t.rows[n];s="";for(let a=0;a<i.length;a++)s+=this.tablecell(i[a]);o+=this.tablerow({text:s})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
70
+ <thead>
71
+ `+e+`</thead>
72
+ `+o+`</table>
73
+ `}tablerow({text:t}){return`<tr>
74
+ ${t}</tr>
75
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+e+`</${s}>
76
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${de(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:s}){let o=this.parser.parseInline(s),n=Lt(t);if(n===null)return o;t=n;let i='<a href="'+t+'"';return e&&(i+=' title="'+de(e)+'"'),i+=">"+o+"</a>",i}image({href:t,title:e,text:s,tokens:o}){o&&(s=this.parser.parseInline(o,this.parser.textRenderer));let n=Lt(t);if(n===null)return de(s);t=n;let i=`<img src="${t}" alt="${de(s)}"`;return e&&(i+=` title="${de(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:de(t.text)}},yt=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},le=class rt{options;renderer;textRenderer;constructor(e){this.options=e||Se,this.options.renderer=this.options.renderer||new Je,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new yt}static parse(e,s){return new rt(s).parse(e)}static parseInline(e,s){return new rt(s).parseInline(e)}parse(e){let s="";for(let o=0;o<e.length;o++){let n=e[o];if(this.options.extensions?.renderers?.[n.type]){let a=n,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=c||"";continue}}let i=n;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,s=this.renderer){let o="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){o+=c||"";continue}}let a=i;switch(a.type){case"escape":{o+=s.text(a);break}case"html":{o+=s.html(a);break}case"link":{o+=s.link(a);break}case"image":{o+=s.image(a);break}case"checkbox":{o+=s.checkbox(a);break}case"strong":{o+=s.strong(a);break}case"em":{o+=s.em(a);break}case"codespan":{o+=s.codespan(a);break}case"br":{o+=s.br(a);break}case"del":{o+=s.del(a);break}case"text":{o+=s.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return o}},Ee=class{options;block;constructor(t){this.options=t||Se}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?ie.lex:ie.lexInline}provideParser(){return this.block?le.parse:le.parseInline}},gs=class{defaults=dt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=le;Renderer=Je;TextRenderer=yt;Lexer=ie;Tokenizer=Qe;Hooks=Ee;constructor(...t){this.use(...t)}walkTokens(t,e){let s=[];for(let o of t)switch(s=s.concat(e.call(this,o)),o.type){case"table":{let n=o;for(let i of n.header)s=s.concat(this.walkTokens(i.tokens,e));for(let i of n.rows)for(let a of i)s=s.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=o;s=s.concat(this.walkTokens(n.items,e));break}default:{let n=o;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(i=>{let a=n[i].flat(1/0);s=s.concat(this.walkTokens(a,e))}):n.tokens&&(s=s.concat(this.walkTokens(n.tokens,e)))}}return s}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let o={...s};if(o.async=this.defaults.async||o.async||!1,s.extensions&&(s.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[n.level];i?i.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),o.extensions=e),s.renderer){let n=this.defaults.renderer||new Je(this.defaults);for(let i in s.renderer){if(!(i in n))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,c=s.renderer[a],l=n[a];n[a]=(...p)=>{let d=c.apply(n,p);return d===!1&&(d=l.apply(n,p)),d||""}}o.renderer=n}if(s.tokenizer){let n=this.defaults.tokenizer||new Qe(this.defaults);for(let i in s.tokenizer){if(!(i in n))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,c=s.tokenizer[a],l=n[a];n[a]=(...p)=>{let d=c.apply(n,p);return d===!1&&(d=l.apply(n,p)),d}}o.tokenizer=n}if(s.hooks){let n=this.defaults.hooks||new Ee;for(let i in s.hooks){if(!(i in n))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,c=s.hooks[a],l=n[a];Ee.passThroughHooks.has(i)?n[a]=p=>{if(this.defaults.async&&Ee.passThroughHooksRespectAsync.has(i))return(async()=>{let h=await c.call(n,p);return l.call(n,h)})();let d=c.call(n,p);return l.call(n,d)}:n[a]=(...p)=>{if(this.defaults.async)return(async()=>{let h=await c.apply(n,p);return h===!1&&(h=await l.apply(n,p)),h})();let d=c.apply(n,p);return d===!1&&(d=l.apply(n,p)),d}}o.hooks=n}if(s.walkTokens){let n=this.defaults.walkTokens,i=s.walkTokens;o.walkTokens=function(a){let c=[];return c.push(i.call(this,a)),n&&(c=c.concat(n.call(this,a))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ie.lex(t,e??this.defaults)}parser(t,e){return le.parse(t,e??this.defaults)}parseMarkdown(t){return(e,s)=>{let o={...s},n={...this.defaults,...o},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let a=n.hooks?await n.hooks.preprocess(e):e,c=await(n.hooks?await n.hooks.provideLexer():t?ie.lex:ie.lexInline)(a,n),l=n.hooks?await n.hooks.processAllTokens(c):c;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let p=await(n.hooks?await n.hooks.provideParser():t?le.parse:le.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(p):p})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer():t?ie.lex:ie.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():t?le.parse:le.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(t,e){return s=>{if(s.message+=`
77
+ Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+de(s.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(s);throw s}}},$e=new gs;function q(t,e){return $e.parse(t,e)}q.options=q.setOptions=function(t){return $e.setOptions(t),q.defaults=$e.defaults,ns(q.defaults),q};q.getDefaults=dt;q.defaults=Se;q.use=function(...t){return $e.use(...t),q.defaults=$e.defaults,ns(q.defaults),q};q.walkTokens=function(t,e){return $e.walkTokens(t,e)};q.parseInline=$e.parseInline;q.Parser=le;q.parser=le.parse;q.Renderer=Je;q.TextRenderer=yt;q.Lexer=ie;q.lexer=ie.lex;q.Tokenizer=Qe;q.Hooks=Ee;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;le.parse;ie.lex;const $o=new gs({breaks:!0,gfm:!0});function So(t){return t?$o.parse(t):""}const _o={key:0,class:"my-2"},Co={key:0,class:"relative inline-flex h-4 w-4 items-center justify-center"},To={key:1,class:"text-text-muted"},Mo={key:0,class:"mt-1 ms-2 rounded-lg border-s-2 border-[#a78bfa]/30 bg-surface px-4 py-3 text-sm text-text-secondary leading-relaxed whitespace-pre-wrap max-h-80 overflow-auto"},Ro={key:0,class:"inline-flex items-center gap-0.5 ms-1 align-text-bottom"},Ao=ne({__name:"InlineThinkingBlock",props:{isThinking:{type:Boolean},content:{},completed:{type:Boolean}},setup(t){const e=z(!1);return(s,o)=>t.isThinking||t.completed&&t.content?(m(),g("div",_o,[r("button",{class:P(["flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-colors",t.isThinking?"bg-[#a78bfa]/10 text-[#a78bfa]":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:o[0]||(o[0]=n=>e.value=!e.value)},[t.isThinking?(m(),g("span",Co,[...o[1]||(o[1]=[r("span",{class:"absolute h-full w-full rounded-full border-2 border-[#a78bfa]/30"},null,-1),r("span",{class:"absolute h-full w-full rounded-full border-2 border-transparent border-t-[#a78bfa]",style:{animation:"thinking-orbit 1s linear infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-[#a78bfa]"},null,-1)])])):(m(),g("span",To,"💭")),r("span",null,u(t.isThinking?"Thinking...":"Thought process"),1),r("span",{class:P(["text-text-muted transition-transform",{"rotate-180":e.value}])},"▾",2)],2),e.value?(m(),g("div",Mo,[Me(u(t.content)+" ",1),t.isThinking?(m(),g("span",Ro,[...o[2]||(o[2]=[r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):E("",!0)])):E("",!0)])):E("",!0)}}),zo={class:"text-sm leading-relaxed text-text-primary"},No=ne({__name:"AssistantTokenStream",props:{sessionId:{}},setup(t){const e=t,s=Qt(),{getColor:o}=Ws(Is(e,"sessionId")),n=F(()=>s.getTokens(e.sessionId)),i=F(()=>{const a=n.value,c=[];let l=!1,p="";for(const d of a){if(p+=d.text,!l&&p.includes("<think>")){l=!0;const h=p.split("<think>")[0]??"";h&&c.length===0&&c.push({...d,text:h});continue}if(l){if(p.includes("</think>")){l=!1;const h=p.split("</think>").pop()??"",v=d.text;if(h.endsWith(v)&&v.includes("</think>")){const C=v.split("</think>").pop()??"";C&&c.push({...d,text:C})}}continue}c.push(d)}return c});return(a,c)=>(m(),g("div",zo,[(m(!0),g(U,null,J(i.value,l=>(m(),g("span",{key:l.id,class:"inline",style:Ds({borderBottom:`2px solid ${b(o)(l.confidence)}`})},u(l.text),5))),128))]))}}),Eo={key:0,class:"mb-1.5 space-y-1.5"},Po=["src","alt","onClick"],Do={class:"mt-0.5 flex items-center gap-1.5 text-[10px] opacity-60"},Io={class:"truncate"},jo={class:"flex flex-wrap gap-1.5"},Lo={class:"max-w-[100px] truncate opacity-90"},Bo={class:"opacity-60"},Fo=["src"],qo=ne({__name:"AttachmentBubble",props:{attachments:{}},setup(t){const e=z(null);function s(n){n.content&&(e.value=n.content)}function o(){e.value=null}return(n,i)=>t.attachments.length>0?(m(),g("div",Eo,[(m(!0),g(U,null,J(t.attachments.filter(a=>a.type==="image"&&a.content),a=>(m(),g("div",{key:a.id},[r("img",{src:a.content,alt:a.name,class:"max-h-48 max-w-full cursor-pointer rounded-lg object-contain",onClick:c=>s(a)},null,8,Po),r("div",Do,[r("span",Io,u(a.name),1),r("span",null,u(b(nt)(a.sizeBytes)),1)])]))),128)),r("div",jo,[(m(!0),g(U,null,J(t.attachments.filter(a=>a.type==="document"),a=>(m(),g("div",{key:a.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[j(b(Yt),{class:"h-3.5 w-3.5 opacity-70"}),r("span",Lo,u(a.name),1),r("span",Bo,u(b(nt)(a.sizeBytes)),1)]))),128))]),(m(),Pe(js,{to:"body"},[j(Vt,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","leave-active-class":"transition-opacity duration-150","leave-to-class":"opacity-0"},{default:Ut(()=>[e.value?(m(),g("div",{key:0,class:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:o},[r("img",{src:e.value,alt:"Enlarged attachment preview",class:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl",onClick:i[0]||(i[0]=He(()=>{},["stop"]))},null,8,Fo),r("button",{class:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Close lightbox",onClick:o},[j(b(Xe),{class:"h-5 w-5"})])])):E("",!0)]),_:1})]))])):E("",!0)}}),Oo={key:0,class:"mt-1 flex items-center gap-1 flex-wrap"},Uo=["title"],Vo=ne({__name:"QualityBadges",props:{report:{}},setup(t){const e=t,s=F(()=>e.report?e.report.checks.filter(n=>n.status!=="pass"):[]),o=F(()=>s.value.length>0);return(n,i)=>o.value?(m(),g("div",Oo,[(m(!0),g(U,null,J(s.value,a=>(m(),g("span",{key:a.detector,class:P(["inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium",a.status==="fail"?"bg-error/15 text-error":"bg-warning/15 text-warning"]),title:a.detail??n.$t(a.reason)},u(n.$t(`quality.${a.detector}.label`)),11,Uo))),128))])):E("",!0)}}),Ko={class:"text-sm leading-relaxed whitespace-pre-wrap"},Ho=["innerHTML"],Wo={key:3,class:"inline-flex items-center gap-1 py-1"},Go={key:4,class:"mt-1 text-[10px] text-warning"},Zo={key:2,class:"mt-1.5 flex items-center gap-2 text-[10px] text-text-muted"},Qo=["title"],Jo=["title"],Xo={class:"text-[10px] opacity-50"},Yo=ne({__name:"ChatBubble",props:{message:{}},setup(t){const e=t,s=Ye(),o=Js(),n=lt(),i=ss(),a=F(()=>i.getReport(e.message.id)),c=F(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),l=F(()=>e.message.sessionId?s.sessionById(e.message.sessionId)?.doneReason==="length":!1),p=F(()=>e.message.sessionId?o.getThinking(e.message.sessionId):{isThinking:!1,content:""}),d=F(()=>e.message.role==="user"),h=F(()=>c.value?c.value.loadDurationMs>500:!1),v=F(()=>{if(d.value){if(e.message.attachments?.length){const N=`
78
+
79
+ ---
80
+
81
+ `,x=e.message.content.lastIndexOf(N);if(x!==-1)return e.message.content.slice(x+N.length)}return e.message.content}return e.message.isStreaming?"":e.message.content.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}),C=F(()=>d.value||!v.value?"":So(v.value)),S=F(()=>new Date(e.message.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}));return(N,x)=>(m(),g("div",{class:P(["flex w-full",d.value?"justify-end":"justify-start"])},[r("div",{class:P(["max-w-[80%] rounded-2xl px-4 py-2.5",d.value?"bg-accent text-white rounded-br-md":"bg-surface-raised border border-border-default rounded-bl-md"])},[d.value?(m(),g(U,{key:0},[t.message.attachments?.length?(m(),Pe(qo,{key:0,attachments:t.message.attachments},null,8,["attachments"])):E("",!0),r("p",Ko,u(v.value),1)],64)):(m(),g(U,{key:1},[t.message.sessionId?(m(),Pe(Ao,{key:0,"is-thinking":p.value.isThinking,content:p.value.content,completed:!t.message.isStreaming},null,8,["is-thinking","content","completed"])):E("",!0),t.message.isStreaming&&t.message.sessionId?(m(),Pe(No,{key:1,"session-id":t.message.sessionId},null,8,["session-id"])):v.value?(m(),g("div",{key:2,class:"markdown-prose",innerHTML:C.value},null,8,Ho)):E("",!0),t.message.isStreaming&&!v.value?(m(),g("span",Wo,[...x[0]||(x[0]=[r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):E("",!0),l.value&&!t.message.isStreaming&&!a.value?(m(),g("div",Go,u(N.$t("dashboard.bubble.truncatedWarning")),1)):E("",!0)],64)),!d.value&&!t.message.isStreaming&&c.value?(m(),g("div",Zo,[r("span",null,u(c.value.completionTokenCount)+" "+u(N.$t("dashboard.bubble.tokens")),1),x[2]||(x[2]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,u(c.value.tokensPerSecond.toFixed(1))+" "+u(N.$t("dashboard.bubble.tokPerSec")),1),x[3]||(x[3]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,u(c.value.ttftMs<1e3?c.value.ttftMs.toFixed(0)+"ms":(c.value.ttftMs/1e3).toFixed(1)+"s")+" "+u(N.$t("dashboard.bubble.ttft")),1),h.value?(m(),g(U,{key:0},[x[1]||(x[1]=r("span",{class:"opacity-40"},"·",-1)),r("span",{class:"text-warning",title:N.$t("dashboard.bubble.coldStart")},u(N.$t("dashboard.bubble.cold")),9,Qo)],64)):E("",!0),a.value&&a.value.overall!=="pass"?(m(),g("span",{key:1,class:P(["ml-1 inline-block h-1.5 w-1.5 rounded-full",a.value.overall==="fail"?"bg-error":"bg-warning"]),title:N.$t("quality.issuesDetected")},null,10,Jo)):E("",!0)])):E("",!0),j(Vo,{report:a.value},null,8,["report"]),r("div",{class:P(["mt-1",d.value?"text-end":""])},[r("span",Xo,u(S.value),1)],2)],2)],2))}}),ea={key:0,class:"flex items-center justify-center"},ta={class:"text-center"},sa={class:"text-sm text-text-muted"},na=ne({__name:"ChatMessageList",props:{messages:{}},setup(t,{expose:e}){const s=t,o=z(null);function n(){Ls(()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight)})}return se(()=>s.messages.length,()=>n()),se(()=>s.messages[s.messages.length-1]?.content,()=>n()),e({scrollToBottom:n}),(i,a)=>(m(),g("div",{ref_key:"containerRef",ref:o,class:"flex-1 overflow-y-auto px-4 py-6"},[r("div",{class:P(["mx-auto max-w-3xl space-y-4",t.messages.length===0?"flex min-h-full flex-col justify-center":""])},[t.messages.length===0?(m(),g("div",ea,[r("div",ta,[a[0]||(a[0]=r("svg",{class:"mx-auto mb-4 h-20 w-20 text-text-muted/20",viewBox:"0 0 297.5 297.5"},[r("path",{fill:"currentColor",d:"M179.293,23.839c-64.904,0-117.707,52.804-117.707,117.707c0,1.832,0.056,3.651,0.14,5.463H9.933 c-5.486,0-9.933,4.448-9.933,9.933v46.189c0,5.486,4.448,9.933,9.933,9.933h22.349v43.209h-6.953c-4.663,0-8.443,3.78-8.443,8.443 c0,4.663,3.78,8.443,8.443,8.443h30.793c4.663,0,8.443-3.78,8.443-8.443c0-4.663-3.78-8.443-8.443-8.443h-6.953v-43.209h36.713 c21.533,28.059,55.39,46.189,93.411,46.189c64.904,0,117.707-52.804,117.707-117.707S244.196,23.839,179.293,23.839z M19.866,166.876h213.087c-5.257,11.091-13.854,20.295-24.483,26.323H19.866V166.876z M119.942,141.547 c0-32.726,26.624-59.35,59.35-59.35s59.35,26.624,59.35,59.35c0,1.843-0.096,3.663-0.261,5.463H120.206 C120.04,145.21,119.942,143.39,119.942,141.547z M179.293,239.388c-25.75,0-49.202-10.003-66.689-26.323h32.684 c10.31,4.925,21.837,7.698,34.005,7.698c43.68,0,79.217-35.536,79.217-79.217S222.973,62.33,179.293,62.33 s-79.217,35.536-79.217,79.217c0,1.839,0.086,3.657,0.214,5.463H81.611c-0.101-1.809-0.16-3.629-0.16-5.463 c0-48.871,36.016-89.488,82.901-96.702c-0.758,1.266-1.201,2.741-1.201,4.324c0,4.663,3.78,8.443,8.443,8.443h15.396 c4.663,0,8.443-3.78,8.443-8.443c0-1.583-0.443-3.058-1.201-4.324c46.884,7.214,82.901,47.83,82.901,96.702 C277.134,195.497,233.243,239.388,179.293,239.388z"})],-1)),a[1]||(a[1]=r("p",{class:"text-2xl font-semibold text-text-primary mb-2"},"LLMxRay",-1)),r("p",sa,u(i.$t("dashboard.empty.startConversation")),1)])])):E("",!0),(m(!0),g(U,null,J(t.messages,c=>(m(),Pe(Yo,{key:c.id,message:c},null,8,["message"]))),128))],2)],512))}}),oa=new Set(["png","jpg","jpeg","gif","webp"]),aa=new Set(["pdf","docx","txt","md","csv"]);function fs(t){return t.split(".").pop()?.toLowerCase()??""}function it(t){return oa.has(fs(t))}function bs(t){return aa.has(fs(t))}function ra(t){return it(t)||bs(t)}const ia=".pdf,.docx,.txt,.md,.csv,.png,.jpg,.jpeg,.gif,.webp",qt=8e3;function la(){const t=z([]),e=F(()=>t.value.some(c=>c.status==="parsing"));async function s(c){for(const l of c){if(!ra(l.name))continue;const p={id:ye(),name:l.name,type:it(l.name)?"image":"document",mimeType:l.type,sizeBytes:l.size,status:"pending"};t.value.push(p),it(l.name)?o(l,p):bs(l.name)&&n(l,p)}}function o(c,l){l.status="parsing";const p=l.id,d=new FileReader;d.onload=()=>{const h=t.value.find(v=>v.id===p);h&&(h.content=d.result,h.status="ready")},d.onerror=()=>{const h=t.value.find(v=>v.id===p);h&&(h.error="Failed to read image",h.status="error")},d.readAsDataURL(c)}async function n(c,l){l.status="parsing";const p=l.id;try{const d=Ys(c.name);if(!d){const C=t.value.find(S=>S.id===p);C&&(C.error="Unsupported format",C.status="error");return}let h=await en(c,d);h.length>qt&&(h=h.slice(0,qt)+`
82
+
83
+ [... truncated]`);const v=t.value.find(C=>C.id===p);v&&(v.content=h,v.status="ready")}catch(d){const h=t.value.find(v=>v.id===p);h&&(h.error=d instanceof Error?d.message:"Parse failed",h.status="error")}}function i(c){t.value=t.value.filter(l=>l.id!==c)}function a(){t.value=[]}return{attachments:t,isProcessing:e,addFiles:s,removeAttachment:i,clearAttachments:a}}const ca={key:0,class:"absolute bottom-full left-0 right-0 mb-2 max-h-64 overflow-y-auto rounded-xl border border-border-default bg-surface-raised shadow-lg"},ua={class:"p-1.5"},da=["onMouseenter","onClick"],pa={class:"shrink-0 font-mono text-xs text-accent"},ha={class:"truncate text-xs text-text-muted"},ma={class:"ms-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 text-[10px] text-text-muted"},ga=ne({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(t,{expose:e,emit:s}){const{t:o}=Kt(),n=t,i=s,a=z(0),c=F(()=>{if(!n.visible)return[];const h=n.filter.replace(/^\//,"");return h?yn(h):Object.values(es()).flat()});se(()=>n.filter,()=>{a.value=0});function l(h){return!n.visible||c.value.length===0?!1:h.key==="ArrowDown"?(h.preventDefault(),a.value=(a.value+1)%c.value.length,!0):h.key==="ArrowUp"?(h.preventDefault(),a.value=a.value<=0?c.value.length-1:a.value-1,!0):h.key==="Tab"||h.key==="Enter"&&c.value.length>0?(h.preventDefault(),i("select",c.value[a.value]),!0):h.key==="Escape"?(h.preventDefault(),i("close"),!0):!1}e({handleKeydown:l});const p=F(()=>({chat:o("dashboard.slashCommands.chatConversation"),settings:o("dashboard.slashCommands.modelSettings"),navigation:o("dashboard.slashCommands.featuresNavigation"),memory:o("dashboard.slashCommands.memory")}));function d(h){return h.descriptionKey?o(h.descriptionKey):h.description}return(h,v)=>t.visible&&c.value.length>0?(m(),g("div",ca,[r("div",ua,[(m(!0),g(U,null,J(c.value,(C,S)=>(m(),g("button",{key:C.name,class:P(["flex w-full items-center gap-3 rounded-lg px-3 py-2 text-start text-sm transition-colors",S===a.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMouseenter:N=>a.value=S,onClick:N=>h.$emit("select",C)},[r("span",pa,"/"+u(C.name),1),r("span",ha,u(d(C)),1),r("span",ma,u(p.value[C.category]??C.category),1)],42,da))),128))])])):E("",!0)}}),fa={key:0,class:"flex flex-wrap gap-2 px-2.5 pb-1.5 pt-1"},ba=["src","alt"],xa={key:1,class:"text-text-muted"},ya={class:"max-w-[120px] truncate text-text-primary"},va={class:"text-text-muted"},ka={key:2,class:"h-3 w-3 animate-spin rounded-full border-2 border-accent border-t-transparent"},wa={key:3,class:"text-error",title:"Parse error"},$a=["onClick"],Sa=ne({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(t){return(e,s)=>t.attachments.length>0?(m(),g("div",fa,[(m(!0),g(U,null,J(t.attachments,o=>(m(),g("div",{key:o.id,class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface-overlay px-2.5 py-1.5 text-xs"},[o.type==="image"&&o.content?(m(),g("img",{key:0,src:o.content,alt:o.name,class:"h-6 w-6 rounded object-cover"},null,8,ba)):o.type==="document"?(m(),g("span",xa,[j(b(Yt),{class:"h-4 w-4"})])):E("",!0),r("span",ya,u(o.name),1),r("span",va,u(b(nt)(o.sizeBytes)),1),o.status==="parsing"?(m(),g("span",ka)):o.status==="error"?(m(),g("span",wa,"!")):E("",!0),r("button",{class:"text-text-muted hover:text-error transition-colors","aria-label":"Remove attachment",onClick:n=>e.$emit("remove",o.id)},[j(b(Xe),{class:"h-3.5 w-3.5"})],8,$a)]))),128))])):E("",!0)}}),_a={key:0,class:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-accent bg-accent/5"},Ca={class:"text-sm text-accent"},Ta={class:"relative mx-auto max-w-3xl"},Ma=["accept"],Ra={class:"mx-auto flex max-w-3xl flex-col rounded-xl border border-border-default bg-surface transition-colors focus-within:border-accent"},Aa=["disabled","title"],za=["title"],Na=["disabled","title"],Ea=["disabled","placeholder"],Pa=["title"],Da=["disabled","title"],Ia=ne({__name:"ChatInput",props:{isStreaming:{type:Boolean},selectedModel:{},isVisionModel:{type:Boolean}},emits:["send","command","cancel"],setup(t,{expose:e,emit:s}){const o=s;e({focus:H});const n=ct(),i=z(""),a=z(null),c=z(null),l=z(null),p=z(!1),{attachments:d,isProcessing:h,addFiles:v,removeAttachment:C,clearAttachments:S}=la();Ht(()=>{n.fetchModels()});const N=F(()=>{const T=i.value;return T.startsWith("/")&&!T.includes(`
84
+ `)}),x=F(()=>{if(!N.value)return"";const T=i.value.indexOf(" ");return T===-1?i.value:i.value.slice(0,T)}),D=F(()=>{const T=i.value.trim().length>0,L=d.value.length>0;return(T||L)&&!h.value});function H(){a.value?.focus()}function K(T){N.value&&l.value&&l.value.handleKeydown(T)||T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),W())}function Q(T){i.value=`/${T.name} `,a.value?.focus()}function W(){const T=i.value.trim();if(!(!T&&d.value.length===0)){if(T.startsWith("/")&&d.value.length===0){const L=T.indexOf(" "),ce=L===-1?T.slice(1):T.slice(1,L),V=L===-1?"":T.slice(L+1);o("command",ce,V)}else o("send",T,[...d.value]),S();i.value="",a.value&&(a.value.style.height="auto")}}function O(T){const L=T.target;L.style.height="auto",L.style.height=Math.min(L.scrollHeight,200)+"px"}function me(){i.value=""}function oe(){i.value="/",a.value?.focus()}function ve(){c.value?.click()}function ge(T){const L=T.target;L.files&&L.files.length>0&&(v(L.files),L.value="")}function fe(T){T.preventDefault(),p.value=!0}function f(){p.value=!1}function _(T){T.preventDefault(),p.value=!1,T.dataTransfer?.files&&T.dataTransfer.files.length>0&&v(T.dataTransfer.files)}function k(T){const L=T.clipboardData?.items;if(!L)return;const ce=[];for(const V of L)if(V.type.startsWith("image/")){const be=V.getAsFile();be&&ce.push(be)}ce.length>0&&(T.preventDefault(),v(ce))}return(T,L)=>(m(),g("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:fe,onDragleave:f,onDrop:_},[p.value?(m(),g("div",_a,[r("span",Ca,u(T.$t("dashboard.dropZone")),1)])):E("",!0),r("div",Ta,[j(ga,{ref_key:"dropdownRef",ref:l,filter:x.value,visible:N.value,onSelect:Q,onClose:me},null,8,["filter","visible"])]),r("input",{ref_key:"fileInputRef",ref:c,type:"file",multiple:"",accept:b(ia),class:"hidden",onChange:ge},null,40,Ma),r("div",Ra,[j(Sa,{attachments:b(d),onRemove:b(C)},null,8,["attachments","onRemove"]),r("div",{class:P(["flex items-end gap-2 p-1.5",{"pt-0":b(d).length>0}])},[r("button",{disabled:t.isStreaming,class:"relative flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:t.isVisionModel?T.$t("dashboard.input.attachFilesVision"):T.$t("dashboard.input.attachFiles"),onClick:ve},[j(b(nn),{class:"h-4 w-4"}),t.isVisionModel?(m(),g("span",{key:0,class:"absolute -right-0.5 -top-0.5 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-success text-[8px] text-white",title:T.$t("dashboard.input.visionBadge")},[j(b(Bs),{class:"h-2.5 w-2.5","stroke-width":3})],8,za)):E("",!0)],8,Aa),r("button",{disabled:t.isStreaming,class:"flex h-8 shrink-0 items-center justify-center rounded-lg px-1.5 text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:T.$t("dashboard.input.commands"),onClick:oe},[j(b(an),{class:"h-4 w-4"})],8,Na),G(r("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":L[0]||(L[0]=ce=>i.value=ce),disabled:t.isStreaming,rows:"1",class:"flex-1 resize-none bg-transparent px-1 py-1 text-sm text-text-primary placeholder-text-muted outline-none disabled:opacity-50",placeholder:t.isVisionModel?T.$t("dashboard.input.placeholderVision"):T.$t("dashboard.input.placeholder"),onKeydown:K,onInput:O,onPaste:k},null,40,Ea),[[Y,i.value]]),t.isStreaming?(m(),g("button",{key:0,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-error text-white transition-colors hover:bg-error/80",title:T.$t("dashboard.input.stopGenerating"),onClick:L[1]||(L[1]=ce=>T.$emit("cancel"))},[...L[2]||(L[2]=[r("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-white"},null,-1)])],8,Pa)):(m(),g("button",{key:1,disabled:!D.value||!t.selectedModel,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-accent text-white transition-colors hover:bg-accent-hover disabled:opacity-30 disabled:cursor-not-allowed",title:T.$t("dashboard.input.sendMessage"),onClick:W},[j(b(on),{class:"h-4 w-4 rtl:-scale-x-100"})],8,Da))],2)])],32))}}),ja={class:"flex h-full flex-col overflow-y-auto"},La={class:"space-y-5 p-4 pb-12"},Ba={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Fa=["placeholder"],qa={class:"mt-1 text-[10px] text-text-muted"},Oa={class:"flex items-center justify-between"},Ua={class:"flex items-center gap-2"},Va={class:"text-xs font-medium text-text-secondary"},Ka=["disabled"],Ha={key:0,class:"text-[10px] text-text-muted -mt-3"},Wa={key:1,class:"text-[10px] text-text-muted -mt-3"},Ga={class:"mb-1.5 flex items-center justify-between"},Za={class:"text-xs font-medium text-text-secondary"},Qa={class:"text-xs text-text-muted"},Ja={class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},Xa={class:"mb-1.5 flex items-center justify-between"},Ya={class:"text-xs font-medium text-text-secondary"},er={class:"text-xs text-text-muted"},tr=["placeholder"],sr={class:"mt-1 text-[10px] text-text-muted"},nr={class:"mb-1.5 flex items-center justify-between"},or={class:"text-xs font-medium text-text-secondary"},ar={class:"text-xs text-text-muted"},rr={class:"mt-1 text-[10px] text-text-muted"},ir={key:2,class:"space-y-4 ps-1"},lr={class:"mb-1.5 flex items-center justify-between"},cr={class:"text-xs font-medium text-text-secondary"},ur={class:"text-xs text-text-muted"},dr={class:"mt-1 text-[10px] text-text-muted"},pr={class:"mb-1.5 flex items-center justify-between"},hr={class:"text-xs font-medium text-text-secondary"},mr={class:"text-xs text-text-muted"},gr={class:"mt-1 text-[10px] text-text-muted"},fr={class:"mb-1.5 flex items-center justify-between"},br={class:"text-xs font-medium text-text-secondary"},xr={class:"text-xs text-text-muted"},yr={class:"mt-1 text-[10px] text-text-muted"},vr={class:"mb-1.5 flex items-center justify-between"},kr={class:"text-xs font-medium text-text-secondary"},wr={class:"text-xs text-text-muted"},$r={value:0},Sr={value:1},_r={value:2},Cr={class:"mt-1 text-[10px] text-text-muted"},Tr={class:"mb-1.5 flex items-center justify-between"},Mr={class:"text-xs font-medium text-text-secondary"},Rr={class:"text-xs text-text-muted"},Ar=["placeholder"],zr={class:"mt-1 text-[10px] text-text-muted"},Nr={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Er=["placeholder"],Pr={class:"mt-1 text-[10px] text-text-muted"},Dr={key:0,class:"ms-1 text-accent"},Ir={key:0,class:"ps-1 space-y-2"},jr={key:0,class:"space-y-1"},Lr=["onClick"],Br={key:1,class:"text-[10px] text-text-muted px-2"},Fr={key:0,class:"ms-1 text-accent"},qr={key:4,class:"space-y-4 ps-1"},Or={class:"flex items-center justify-between"},Ur={class:"text-xs font-medium text-text-secondary"},Vr={class:"text-[10px] text-text-muted"},Kr={key:0},Hr={class:"mb-1 flex items-center justify-between"},Wr={class:"text-[10px] text-text-muted"},Gr={class:"text-[10px] text-text-muted"},Zr={class:"flex items-center justify-between"},Qr={class:"text-xs font-medium text-text-secondary"},Jr={class:"text-[10px] text-text-muted"},Xr={key:1},Yr={class:"mb-1 flex items-center justify-between"},ei={class:"text-[10px] text-text-muted"},ti={class:"text-[10px] text-text-muted"},si={class:"flex items-center justify-between"},ni={class:"text-xs font-medium text-text-secondary"},oi={class:"text-[10px] text-text-muted"},ai={key:2,class:"space-y-1"},ri={class:"flex-1 text-text-secondary"},ii=["onClick"],li={class:"flex items-center justify-between"},ci={class:"text-xs font-medium text-text-secondary"},ui={class:"text-[10px] text-text-muted"},di={key:3,class:"space-y-2"},pi={class:"mb-1 block text-[10px] text-text-muted"},hi={value:"",disabled:""},mi=["value"],gi={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},fi={class:"mb-2 text-[10px] text-accent"},bi={class:"space-y-1.5"},xi={class:"min-w-0 flex-1"},yi={class:"truncate text-[11px] font-mono text-text-primary"},vi={class:"text-[9px] text-text-muted"},ki=["disabled","onClick"],wi={key:0,class:"mt-2 text-[9px] text-text-muted"},$i={class:"mb-1 flex items-center justify-between"},Si={class:"text-[10px] text-text-muted"},_i={class:"text-[10px] text-text-muted"},Ci=ne({__name:"ChatSettingsPanel",props:{modelValue:{},selectedModel:{},ragEnabled:{type:Boolean}},emits:["update:modelValue","update:ragEnabled"],setup(t,{emit:e}){const s=t,o=e,n=z(s.modelValue.systemPrompt),i=z(s.modelValue.options.temperature??.7),a=z(s.modelValue.options.num_predict??-1),c=z(s.modelValue.options.num_ctx??4096),l=z(s.modelValue.options.top_p??.9),p=z(s.modelValue.options.top_k??40),d=z(s.modelValue.options.repeat_penalty??1.1),h=z(s.modelValue.options.seed??-1),v=z(s.modelValue.options.stop?.join(", ")??""),C=z(s.modelValue.options.mirostat??0);se(()=>s.modelValue.options,f=>{i.value=f.temperature??.7,a.value=f.num_predict??-1,c.value=f.num_ctx??4096,l.value=f.top_p??.9,p.value=f.top_k??40,d.value=f.repeat_penalty??1.1,h.value=f.seed??-1,v.value=f.stop?.join(", ")??"",C.value=f.mirostat??0},{deep:!0}),se([n,i,a,c,l,p,d,h,v,C],()=>{const f=v.value.split(",").map(_=>_.trim()).filter(Boolean);o("update:modelValue",{systemPrompt:n.value,options:{temperature:i.value,num_predict:a.value===-1?void 0:a.value,num_ctx:c.value,top_p:l.value,top_k:p.value,repeat_penalty:d.value,seed:h.value===-1?void 0:h.value,stop:f.length>0?f:void 0,mirostat:C.value}})},{deep:!0}),se(()=>s.modelValue,f=>{n.value=f.systemPrompt,i.value=f.options.temperature??.7,a.value=f.options.num_predict??-1,c.value=f.options.num_ctx??4096,l.value=f.options.top_p??.9,p.value=f.options.top_k??40,d.value=f.options.repeat_penalty??1.1,h.value=f.options.seed??-1,C.value=f.options.mirostat??0});const S=ut(),N=Wt(),x=ts(),D=ct(),H=Jt(),K=F(()=>D.supportsTools(s.selectedModel));se(()=>s.selectedModel,f=>{f&&!D.supportsTools(f)&&S.enabledTools.length>0&&S.disableAll()});const Q=z(!1),W=z(!1),O=z(!1),me=z(!1),oe=z(""),ve=z(""),ge=[{name:"nomic-embed-text",description:"Nomic — 137M params, fast & good",size:"274 MB"},{name:"mxbai-embed-large",description:"mixedbread.ai — 335M params, high quality",size:"670 MB"},{name:"all-minilm",description:"MiniLM — 23M params, very lightweight",size:"46 MB"},{name:"snowflake-arctic-embed",description:"Snowflake — 110M params, balanced",size:"229 MB"}];async function fe(f){me.value=!0,ve.value=f,oe.value="Starting download...";try{await je.pullModel(f,(_,k,T)=>{if(k&&T){const L=Math.round(k/T*100);oe.value=`${_} ${L}%`}else oe.value=_}),oe.value="Done!",await D.fetchModels(),x.settings.ragMemory.embeddingModel=f}catch(_){oe.value=`Failed: ${_ instanceof Error?_.message:"Unknown error"}`}finally{me.value=!1,setTimeout(()=>{oe.value="",ve.value=""},3e3)}}return(f,_)=>(m(),g("div",ja,[r("div",La,[r("div",null,[r("label",Ba,u(f.$t("dashboard.settings.systemPrompt")),1),G(r("textarea",{"onUpdate:modelValue":_[0]||(_[0]=k=>n.value=k),rows:"6",class:"w-full resize-y rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.systemPromptPlaceholder")},null,8,Fa),[[Y,n.value]]),r("p",qa,u(f.$t("dashboard.settings.systemPromptHint")),1)]),r("div",Oa,[r("div",Ua,[r("span",Va,u(f.$t("dashboard.settings.knowledgeBase")),1),r("span",{class:P(["rounded-full px-1.5 py-0.5 text-[9px] font-medium",t.ragEnabled&&b(H).readyDocuments.length>0?"bg-accent/10 text-accent":"bg-surface-overlay text-text-muted"])},u(t.ragEnabled&&b(H).readyDocuments.length>0?f.$t("dashboard.settings.kbEnabled"):f.$t("dashboard.settings.kbDisabled")),3)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",t.ragEnabled&&b(H).readyDocuments.length>0?"bg-accent":"bg-surface-overlay"]),disabled:b(H).readyDocuments.length===0,onClick:_[1]||(_[1]=k=>o("update:ragEnabled",!t.ragEnabled))},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",t.ragEnabled&&b(H).readyDocuments.length>0?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,Ka)]),b(H).readyDocuments.length>0?(m(),g("p",Ha,[Me(u(b(H).enabledDocuments.length)+"/"+u(b(H).readyDocuments.length)+" "+u(f.$t("dashboard.settings.documents"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:_[2]||(_[2]=k=>b(N).push("/rag"))},u(f.$t("dashboard.settings.manage")),1)])):(m(),g("p",Wa,[Me(u(f.$t("dashboard.settings.noDocumentsIngested"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:_[3]||(_[3]=k=>b(N).push("/rag"))},u(f.$t("dashboard.settings.addDocuments")),1)])),r("div",null,[r("div",Ga,[r("label",Za,u(f.$t("dashboard.settings.temperature")),1),r("span",Qa,u(i.value.toFixed(2)),1)]),G(r("input",{"onUpdate:modelValue":_[4]||(_[4]=k=>i.value=k),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[Y,i.value,void 0,{number:!0}]]),r("div",Ja,[r("span",null,u(f.$t("dashboard.settings.precise")),1),r("span",null,u(f.$t("dashboard.settings.creative")),1)])]),r("div",null,[r("div",Xa,[r("label",Ya,u(f.$t("dashboard.settings.maxTokens")),1),r("span",er,u(a.value===-1?f.$t("dashboard.settings.unlimited"):a.value),1)]),G(r("input",{"onUpdate:modelValue":_[5]||(_[5]=k=>a.value=k),type:"number",min:"-1",max:"32768",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.maxTokensPlaceholder")},null,8,tr),[[Y,a.value,void 0,{number:!0}]]),r("p",sr,u(f.$t("dashboard.settings.maxTokensHint")),1)]),r("div",null,[r("div",nr,[r("label",or,u(f.$t("dashboard.settings.contextWindow")),1),r("span",ar,u(c.value.toLocaleString()),1)]),G(r("select",{"onUpdate:modelValue":_[6]||(_[6]=k=>c.value=k),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[..._[25]||(_[25]=[r("option",{value:2048},"2,048",-1),r("option",{value:4096},"4,096",-1),r("option",{value:8192},"8,192",-1),r("option",{value:16384},"16,384",-1),r("option",{value:32768},"32,768",-1),r("option",{value:65536},"65,536",-1),r("option",{value:131072},"131,072",-1)])],512),[[st,c.value,void 0,{number:!0}]]),r("p",rr,u(f.$t("dashboard.settings.contextWindowHint")),1)]),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[7]||(_[7]=k=>Q.value=!Q.value)},[r("span",null,u(f.$t("dashboard.settings.advancedSampling")),1),r("span",{class:P(["transition-transform",{"rotate-180":Q.value}])},"▾",2)]),Q.value?(m(),g("div",ir,[r("div",null,[r("div",lr,[r("label",cr,u(f.$t("dashboard.settings.topP")),1),r("span",ur,u(l.value.toFixed(2)),1)]),G(r("input",{"onUpdate:modelValue":_[8]||(_[8]=k=>l.value=k),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[Y,l.value,void 0,{number:!0}]]),r("p",dr,u(f.$t("dashboard.settings.topPHint")),1)]),r("div",null,[r("div",pr,[r("label",hr,u(f.$t("dashboard.settings.topK")),1),r("span",mr,u(p.value),1)]),G(r("input",{"onUpdate:modelValue":_[9]||(_[9]=k=>p.value=k),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[Y,p.value,void 0,{number:!0}]]),r("p",gr,u(f.$t("dashboard.settings.topKHint")),1)]),r("div",null,[r("div",fr,[r("label",br,u(f.$t("dashboard.settings.repeatPenalty")),1),r("span",xr,u(d.value.toFixed(2)),1)]),G(r("input",{"onUpdate:modelValue":_[10]||(_[10]=k=>d.value=k),type:"range",min:"1.0",max:"2.0",step:"0.05",class:"w-full accent-accent"},null,512),[[Y,d.value,void 0,{number:!0}]]),r("p",yr,u(f.$t("dashboard.settings.repeatPenaltyHint")),1)]),r("div",null,[r("div",vr,[r("label",kr,u(f.$t("dashboard.settings.mirostat")),1),r("span",wr,u(C.value===0?f.$t("dashboard.settings.mirostatOff"):`v${C.value}`),1)]),G(r("select",{"onUpdate:modelValue":_[11]||(_[11]=k=>C.value=k),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[r("option",$r,u(f.$t("dashboard.settings.mirostatDisabled")),1),r("option",Sr,u(f.$t("dashboard.settings.mirostatV1")),1),r("option",_r,u(f.$t("dashboard.settings.mirostatV2")),1)],512),[[st,C.value,void 0,{number:!0}]]),r("p",Cr,u(f.$t("dashboard.settings.mirostatHint")),1)]),r("div",null,[r("div",Tr,[r("label",Mr,u(f.$t("dashboard.settings.seed")),1),r("span",Rr,u(h.value===-1?f.$t("dashboard.settings.seedRandom"):h.value),1)]),G(r("input",{"onUpdate:modelValue":_[12]||(_[12]=k=>h.value=k),type:"number",min:"-1",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.seedPlaceholder")},null,8,Ar),[[Y,h.value,void 0,{number:!0}]]),r("p",zr,u(f.$t("dashboard.settings.seedHint")),1)]),r("div",null,[r("label",Nr,u(f.$t("dashboard.settings.stopSequences")),1),G(r("input",{"onUpdate:modelValue":_[13]||(_[13]=k=>v.value=k),type:"text",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.stopSequencesPlaceholder")},null,8,Er),[[Y,v.value]]),r("p",Pr,u(f.$t("dashboard.settings.stopSequencesHint")),1)])])):E("",!0),K.value?(m(),g(U,{key:3},[r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[14]||(_[14]=k=>W.value=!W.value)},[r("span",null,[Me(u(f.$t("dashboard.settings.tools"))+" ",1),b(S).enabledDefinitions.length>0?(m(),g("span",Dr," ("+u(b(S).enabledDefinitions.length)+" "+u(f.$t("dashboard.settings.active"))+") ",1)):E("",!0)]),r("span",{class:P(["transition-transform",{"rotate-180":W.value}])},"▾",2)]),W.value?(m(),g("div",Ir,[b(S).allTools.length>0?(m(),g("div",jr,[(m(!0),g(U,null,J(b(S).allTools,k=>(m(),g("div",{key:k.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1.5 text-[11px]"},[r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",k.enabled?"bg-accent":"bg-surface-overlay"]),onClick:T=>b(S).toggleEnabled(k.id)},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",k.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,Lr),r("span",{class:P(["font-mono",k.enabled?"text-text-primary":"text-text-muted"])},u(k.definition.function.name),3)]))),128))])):(m(),g("p",Br,u(f.$t("dashboard.settings.noToolsDefined")),1)),r("button",{class:"w-full rounded-lg border border-dashed border-border-default px-3 py-1.5 text-[11px] text-text-muted hover:border-accent hover:text-text-primary transition-colors",onClick:_[15]||(_[15]=k=>b(N).push("/tools"))},u(f.$t("dashboard.settings.manageInToolWorkshop")),1)])):E("",!0)],64)):E("",!0),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[16]||(_[16]=k=>O.value=!O.value)},[r("span",null,[Me(u(f.$t("dashboard.memory.memory"))+" ",1),b(x).factCount>0?(m(),g("span",Fr," ("+u(b(x).factCount)+" "+u(f.$t("dashboard.memory.facts"))+") ",1)):E("",!0)]),r("span",{class:P(["transition-transform",{"rotate-180":O.value}])},"▾",2)]),O.value?(m(),g("div",qr,[r("div",Or,[r("div",null,[r("p",Ur,u(f.$t("dashboard.memory.slidingWindow")),1),r("p",Vr,u(f.$t("dashboard.memory.slidingWindowHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(x).settings.slidingWindow.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[17]||(_[17]=k=>b(x).settings.slidingWindow.enabled=!b(x).settings.slidingWindow.enabled)},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(x).settings.slidingWindow.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(x).settings.slidingWindow.enabled?(m(),g("div",Kr,[r("div",Hr,[r("label",Wr,u(f.$t("dashboard.memory.maxMessages")),1),r("span",Gr,u(b(x).settings.slidingWindow.maxMessages),1)]),G(r("input",{"onUpdate:modelValue":_[18]||(_[18]=k=>b(x).settings.slidingWindow.maxMessages=k),type:"range",min:"10",max:"200",step:"10",class:"w-full accent-accent"},null,512),[[Y,b(x).settings.slidingWindow.maxMessages,void 0,{number:!0}]])])):E("",!0),r("div",Zr,[r("div",null,[r("p",Qr,u(f.$t("dashboard.memory.autoSummarize")),1),r("p",Jr,u(f.$t("dashboard.memory.autoSummarizeHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(x).settings.autoSummarize.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[19]||(_[19]=k=>b(x).settings.autoSummarize.enabled=!b(x).settings.autoSummarize.enabled)},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(x).settings.autoSummarize.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(x).settings.autoSummarize.enabled?(m(),g("div",Xr,[r("div",Yr,[r("label",ei,u(f.$t("dashboard.memory.triggerAfter")),1),r("span",ti,u(b(x).settings.autoSummarize.triggerThreshold)+" "+u(f.$t("dashboard.memory.messages")),1)]),G(r("input",{"onUpdate:modelValue":_[20]||(_[20]=k=>b(x).settings.autoSummarize.triggerThreshold=k),type:"range",min:"10",max:"100",step:"5",class:"w-full accent-accent"},null,512),[[Y,b(x).settings.autoSummarize.triggerThreshold,void 0,{number:!0}]])])):E("",!0),r("div",si,[r("div",null,[r("p",ni,u(f.$t("dashboard.memory.userMemories")),1),r("p",oi,u(f.$t("dashboard.memory.userMemoriesHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(x).settings.userFacts.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[21]||(_[21]=k=>b(x).settings.userFacts.enabled=!b(x).settings.userFacts.enabled)},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(x).settings.userFacts.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(x).settings.userFacts.enabled&&b(x).facts.length>0?(m(),g("div",ai,[(m(!0),g(U,null,J(b(x).facts,k=>(m(),g("div",{key:k.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1 text-[11px]"},[r("span",ri,u(k.content),1),r("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:T=>b(x).removeFact(k.id)},[j(b(Xe),{class:"h-3 w-3"})],8,ii)]))),128))])):E("",!0),r("div",li,[r("div",null,[r("p",ci,u(f.$t("dashboard.memory.messageMemoryRag")),1),r("p",ui,u(f.$t("dashboard.memory.messageMemoryHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(x).settings.ragMemory.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[22]||(_[22]=k=>b(x).settings.ragMemory.enabled=!b(x).settings.ragMemory.enabled)},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(x).settings.ragMemory.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(x).settings.ragMemory.enabled?(m(),g("div",di,[r("div",null,[r("label",pi,u(f.$t("dashboard.memory.embeddingModel")),1),G(r("select",{"onUpdate:modelValue":_[23]||(_[23]=k=>b(x).settings.ragMemory.embeddingModel=k),class:"w-full rounded-lg border border-border-default bg-surface px-2 py-1 text-xs text-text-primary outline-none focus:border-accent"},[r("option",hi,u(f.$t("dashboard.memory.selectEmbeddingModel")),1),(m(!0),g(U,null,J(b(D).embeddingModelNames,k=>(m(),g("option",{key:k,value:k},u(k)+" "+u(b(D).capabilityIcons(k)),9,mi))),128))],512),[[st,b(x).settings.ragMemory.embeddingModel]])]),b(D).embeddingModelNames.length===0?(m(),g("div",gi,[r("p",fi,u(f.$t("dashboard.memory.noEmbeddingModels")),1),r("div",bi,[(m(),g(U,null,J(ge,k=>r("div",{key:k.name,class:"flex items-center gap-2"},[r("div",xi,[r("p",yi,u(k.name),1),r("p",vi,u(k.description)+" ("+u(k.size)+")",1)]),r("button",{disabled:me.value,class:"shrink-0 rounded-md bg-accent px-2 py-0.5 text-[10px] text-white hover:bg-accent-hover disabled:opacity-30 transition-colors",onClick:T=>fe(k.name)},u(me.value&&ve.value===k.name?f.$t("dashboard.settings.pulling"):f.$t("dashboard.settings.pull")),9,ki)])),64))]),oe.value?(m(),g("p",wi,u(oe.value),1)):E("",!0)])):E("",!0),r("div",null,[r("div",$i,[r("label",Si,u(f.$t("dashboard.memory.retrieveTop")),1),r("span",_i,u(b(x).settings.ragMemory.topK)+" "+u(f.$t("dashboard.memory.messages")),1)]),G(r("input",{"onUpdate:modelValue":_[24]||(_[24]=k=>b(x).settings.ragMemory.topK=k),type:"range",min:"1",max:"10",step:"1",class:"w-full accent-accent"},null,512),[[Y,b(x).settings.ragMemory.topK,void 0,{number:!0}]])])])):E("",!0)])):E("",!0)])]))}}),Ti={class:"flex h-full flex-col"},Mi={key:0,class:"absolute left-1/2 top-16 z-50 -translate-x-1/2 rounded-xl border border-border-default bg-surface-raised px-4 py-3 shadow-lg"},Ri={class:"flex items-start gap-3"},Ai={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},zi={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},Ni={class:"flex items-center gap-3"},Ei={class:"relative"},Pi={key:0,class:"text-text-muted"},Di={key:0,class:"absolute left-0 top-full z-50 mt-1 max-h-64 w-max min-w-full overflow-y-auto rounded-lg border border-border-default bg-surface-raised shadow-lg"},Ii=["onMousedown"],ji={key:0,class:"flex items-center"},Li=["title"],Bi={class:"truncate"},Fi={class:"flex items-center gap-2"},qi={class:"relative"},Oi={key:1,class:"absolute end-0 top-full z-20 mt-1 w-48 rounded-lg border border-border-default bg-surface-raised shadow-lg py-1"},Ui={class:"flex flex-1 min-h-0"},Vi={key:0,class:"w-64 shrink-0 border-e border-border-default bg-surface-raised flex flex-col"},Ki={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},Hi={class:"text-xs font-medium text-text-secondary"},Wi={class:"flex-1 overflow-y-auto p-2"},Gi={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},Zi={key:1,class:"space-y-0.5"},Qi=["onClick"],Ji={key:0,class:"flex-1 min-w-0"},Xi=["onBlur","onKeydown"],Yi={class:"flex-1 min-w-0"},el={class:"truncate text-[11px]"},tl={class:"truncate text-[9px] text-text-muted"},sl={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},nl=["title","onClick"],ol=["title","onClick"],al={class:"flex flex-1 flex-col min-w-0"},rl={key:0,class:"mx-4 mt-2 rounded-lg border border-error/30 bg-error/10 px-4 py-2.5 text-sm text-error"},il={class:"font-medium"},ll={key:1,class:"w-72 shrink-0 border-s border-border-default bg-surface-raised"},cl={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},ul={class:"text-xs font-medium text-text-secondary"},dl=ne({__name:"ChatConversation",setup(t){const{t:e}=Kt(),s=Wt(),o=Gt(),n=ct(),i=Ye(),a=Jt(),c=lt(),l=ut(),p=ts(),d=Qt(),h=ss(),{isStreaming:v,currentSessionId:C,startChatStream:S,cancel:N}=xn(),x=z(""),D=z(!1);function H(){setTimeout(()=>{D.value=!1},150)}const K=z(!0),Q=z(!1),W=z(!1),O=z(!1);function me(){const y=pe.value;if(!y||y.messages.length===0)return;const $=JSON.stringify(y.messages,null,2),w=new Blob([$],{type:"application/json"}),A=URL.createObjectURL(w),R=document.createElement("a");R.href=A,R.download=`chat-${y.id}.json`,R.click(),URL.revokeObjectURL(A),O.value=!1}function oe(){const y=pe.value;if(!y||y.messages.length===0)return;const $=y.messages.map(ee=>{const xe=ee.role.charAt(0).toUpperCase()+ee.role.slice(1),ae=new Date(ee.timestamp).toLocaleString();return`### ${xe}
85
+ *${ae}*
86
+
87
+ ${ee.content}`}),w=`# Chat Export — ${y.name}
88
+
89
+ ${$.join(`
90
+
91
+ ---
92
+
93
+ `)}
94
+
95
+ ---
96
+ *Generated by LLMxRay — Local LLM Observatory*
97
+ `,A=new Blob([w],{type:"text/markdown"}),R=URL.createObjectURL(A),B=document.createElement("a");B.href=R,B.download=`chat-${y.id}.md`,B.click(),URL.revokeObjectURL(R),O.value=!1}function ve(){const y=pe.value;if(!y||y.messages.length===0)return;const $=y.messages.map(B=>`[${B.role}] ${B.content}`).join(`
98
+
99
+ `),w=new Blob([$],{type:"text/plain"}),A=URL.createObjectURL(w),R=document.createElement("a");R.href=A,R.download=`chat-${y.id}.txt`,R.click(),URL.revokeObjectURL(A),O.value=!1}const ge=z(null),fe=z("");function f(y){o.setActiveConversation(y)}function _(y,$){ge.value=y,fe.value=$}function k(y){const $=fe.value.trim();$&&o.renameConversation(y,$),ge.value=null}function T(){ge.value=null}function L(y,$){y.key==="Enter"?k($):y.key==="Escape"&&T()}function ce(y){const w=Date.now()-y,A=Math.floor(w/6e4);if(A<1)return e("common.time.justNow");if(A<60)return e("dashboard.conversation.minutesAgo",{n:A});const R=Math.floor(A/60);if(R<24)return e("dashboard.conversation.hoursAgo",{n:R});const B=Math.floor(R/24);return B<7?e("dashboard.conversation.daysAgo",{n:B}):new Date(y).toLocaleDateString()}const V=z({systemPrompt:"",options:{}}),be=z(null);let Re=null;const pe=F(()=>o.activeConversation),Be=F(()=>pe.value?.messages??[]),xs=F(()=>n.isVisionModel(x.value)),vt=F(()=>{const y=_e.value??C.value;if(!y)return null;const $=i.sessionById(y);return $?.status==="error"&&$.error?$.error:null}),_e=F(()=>{const y=Be.value;for(let $=y.length-1;$>=0;$--)if(y[$].sessionId)return y[$].sessionId;return null}),Ce=z(e("dashboard.conversation.untitled")),Ae=z(!1),Fe=z(""),kt=F(()=>pe.value?.name??Ce.value);function ys(){Fe.value=kt.value,Ae.value=!0}function wt(){const y=Fe.value.trim();if(!y){Ae.value=!1;return}pe.value?o.renameConversation(pe.value.id,y):Ce.value=y,Ae.value=!1}function vs(){Ae.value=!1}function ks(y){y.key==="Enter"?wt():y.key==="Escape"&&vs()}Ht(async()=>{await n.fetchModels(),n.chatModelNames.length>0&&!x.value&&(x.value=n.chatModelNames[0]),await a.loadDocuments()}),se(x,y=>{if(!y)return;const $=n.getModelDefaults(y);Object.keys($).length>0&&(V.value={systemPrompt:V.value.systemPrompt,options:{...$}})}),se(()=>o.activeConversationId,async y=>{if(!y)return;const $=o.conversations.get(y);if($){$.model&&n.chatModelNames.includes($.model)&&(x.value=$.model);try{const w=await Os.getSessionsByConversation(y);for(const A of w)i.sessionById(A.id)||(i.sessions.set(A.id,{id:A.id,mode:A.mode,model:A.model,status:A.status,createdAt:A.createdAt,prompt:A.prompt,messages:A.messages,options:A.options,outputText:A.outputText,metrics:A.metrics,error:A.error,doneReason:A.doneReason}),i.linkSessionToConversation(A.id,y)),await d.loadTokens(A.id)}catch(w){console.error("Failed to restore sessions for conversation:",w)}}});async function $t(y,$=[]){if(!x.value)return;let w=o.activeConversationId;w||(w=o.createConversation(x.value),Ce.value!==e("dashboard.conversation.untitled")&&o.renameConversation(w,Ce.value),Ce.value=e("dashboard.conversation.untitled"));const A=o.conversations.get(w);A&&A.model!==x.value&&(A.model=x.value);const R=$.filter(Z=>Z.type==="document"&&Z.content),B=$.filter(Z=>Z.type==="image"&&Z.content);let ee=y;R.length>0&&(ee=R.map(te=>`[Attached: ${te.name}]
100
+ ${te.content}`).join(`
101
+
102
+ `)+`
103
+
104
+ ---
105
+
106
+ `+y);const xe={id:ye(),conversationId:w,role:"user",content:ee,timestamp:Date.now(),isStreaming:!1,attachments:$.length>0?$:void 0};o.addMessage(w,xe);const ae=ye(),qe={id:ae,conversationId:w,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};o.addMessage(w,qe);const he=o.getMessagesAsOllamaFormat(w).slice(0,-1);if(B.length>0){const Z=[...he].reverse().find(te=>te.role==="user");Z&&(Z.images=B.map(te=>te.content.replace(/^data:[^;]+;base64,/,"")))}if(V.value.systemPrompt.trim()&&he.unshift({role:"system",content:V.value.systemPrompt.trim()}),K.value&&a.enabledDocuments.length>0)try{const Z=await a.getContextForQuery(y,x.value,5);Z&&he.unshift({role:"system",content:Z})}catch{}let St=he;try{const Z=p.getSummary(w)?.summary,te=await An({conversationId:w,messages:he,model:x.value,settings:p.settings,userFactsPrompt:p.getFactsAsSystemPrompt(),existingSummary:Z});if(St=te.messages,te.newSummary){const re=he.filter(_t=>_t.role!=="system");p.setSummary(w,te.newSummary,re.length)}}catch{}try{const Z={...pe.value?.options,...V.value.options},te=l.enabledDefinitions,re=await S(x.value,St,Z,te.length>0?te:void 0),Ct=o.conversations.get(w)?.messages.find(ue=>ue.id===ae);Ct&&(Ct.sessionId=re),i.linkSessionToConversation(re,w);const Ms=se(()=>i.sessionById(re)?.outputText,ue=>{ue!==void 0&&o.updateAssistantContent(w,ae,ue)}),Tt=w,Rs=y,As=se(()=>i.sessionById(re)?.status,ue=>{if(ue==="completed"||ue==="error"||ue==="cancelled"){if(o.finalizeMessage(Tt,ae),v.value=!1,Ms(),As(),d.persistTokens(re),ue==="completed"){const Ue=i.sessionById(re),zs=(Ue?.outputText??"").replace(/<think>[\s\S]*?<\/think>/g,"").trim(),Ns=c.getMetrics(re),Es=Rn(ae,re,zs,Ns?.completionTokenCount??0,V.value.options.num_predict,Ue?.doneReason);h.setReport(ae,Es)}if(ue==="completed"&&p.settings.ragMemory.enabled&&p.settings.ragMemory.embeddingModel){const Ue=i.sessionById(re)?.outputText??"";zn(Tt,[{role:"user",content:Rs,timestamp:xe.timestamp},{role:"assistant",content:Ue,timestamp:Date.now()}],p.settings.ragMemory.embeddingModel).catch(()=>{})}}})}catch{o.finalizeMessage(w,ae)}}function ws(){N()}function $s(){o.setActiveConversation(null),Ce.value=e("dashboard.conversation.untitled")}function Ss(y){s.push({name:"session",params:{id:y}})}function ke(y){be.value=y,Re&&clearTimeout(Re),Re=setTimeout(()=>{be.value=null},5e3)}function _s(){be.value=null,Re&&clearTimeout(Re)}const Cs={systemPrompt:"",options:{}};async function Ts(y,$){const w=vn(y);if(!w){ke(e("dashboard.slashCommands.notifications.unknownCommand",{name:y}));return}const A={clearConversation:()=>o.setActiveConversation(null),newChat:()=>o.setActiveConversation(null),sendAsUser:R=>$t(R),copyLastResponse:()=>{const R=Be.value.filter(ee=>ee.role==="assistant"),B=R[R.length-1];B?.content?(navigator.clipboard.writeText(B.content),ke(e("dashboard.slashCommands.notifications.copiedToClipboard"))):ke(e("dashboard.slashCommands.notifications.noAssistantResponseToCopy"))},exportConversation:R=>{const B=pe.value;if(!B||B.messages.length===0){ke(e("dashboard.slashCommands.notifications.noConversationToExport"));return}let ee,xe;R==="json"?(ee=JSON.stringify(B.messages,null,2),xe=`chat-${B.id}.json`):(ee=B.messages.map(he=>`[${he.role}] ${he.content}`).join(`
107
+
108
+ `),xe=`chat-${B.id}.txt`);const ae=new Blob([ee],{type:"text/plain"}),qe=URL.createObjectURL(ae),Oe=document.createElement("a");Oe.href=qe,Oe.download=xe,Oe.click(),URL.revokeObjectURL(qe)},setSystemPrompt:R=>{V.value={...V.value,systemPrompt:R}},setOption:(R,B)=>{V.value={...V.value,options:{...V.value.options,[R]:B}}},resetSettings:()=>{V.value={...Cs}},setJsonFormat:R=>{ke(e("dashboard.slashCommands.notifications.jsonFormatToggled"))},switchModel:R=>{x.value=R},availableModels:n.chatModelNames,currentModel:x.value,toggleRag:()=>{K.value=!K.value},ragEnabled:K.value,navigate:R=>s.push(R),openSettings:()=>{Q.value=!0},openSessionDetails:()=>{const R=_e.value;R?s.push({name:"session",params:{id:R}}):ke(e("dashboard.slashCommands.notifications.noActiveSession"))},addFact:R=>p.addFact(R),removeFact:R=>p.removeFactByContent(R),getFacts:()=>p.facts,showNotification:ke,messages:Be.value,chatSettings:V,currentSessionId:_e.value??C.value,getSessionTokenCount:()=>{const R=_e.value??C.value;if(!R)return null;const B=c.getMetrics(R);return B?{prompt:B.promptTokenCount,completion:B.completionTokenCount}:null},getAverageSpeed:()=>{const R=c.aggregate;return R.totalSessions>0?R.avgTps:null},getOllamaStatus:async()=>{try{return{connected:(await fetch("/api/tags")).ok,model:x.value}}catch{return{connected:!1,model:x.value}}},t:(R,B)=>e(R,B??{})};await w.execute($,A)}return(y,$)=>(m(),g("div",Ti,[j(Vt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2","leave-active-class":"transition-all duration-150 ease-in","leave-to-class":"opacity-0 -translate-y-2"},{default:Ut(()=>[be.value?(m(),g("div",Mi,[r("div",Ri,[r("p",Ai,u(be.value),1),r("button",{class:"shrink-0 text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Dismiss notification",onClick:_s}," ✕ ")])])):E("",!0)]),_:1}),r("div",zi,[r("div",Ni,[r("div",Ei,[r("button",{class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none hover:border-accent/50 focus:border-accent",onClick:$[0]||($[0]=w=>D.value=!D.value),onBlur:H},[x.value?(m(),g(U,{key:1},[r("span",null,u(x.value),1),j(Mt,{"model-name":x.value},null,8,["model-name"])],64)):(m(),g("span",Pi,u(y.$t("common.model.noModels")),1)),j(b(Fs),{class:P(["h-3 w-3 text-text-muted transition-transform",D.value?"rotate-180":""])},null,8,["class"])],32),D.value?(m(),g("div",Di,[(m(!0),g(U,null,J(b(n).chatModelNames,w=>(m(),g("button",{key:w,class:P(["flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm transition-colors",w===x.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:He(A=>{x.value=w,D.value=!1},["prevent"])},[r("span",null,u(w),1),j(Mt,{"model-name":w},null,8,["model-name"])],42,Ii))),128))])):E("",!0)]),Ae.value?(m(),g("div",ji,[G(r("input",{"onUpdate:modelValue":$[1]||($[1]=w=>Fe.value=w),class:"w-48 rounded border border-accent bg-surface px-2 py-0.5 text-xs text-text-primary outline-none",onBlur:wt,onKeydown:ks,onVnodeMounted:$[2]||($[2]=w=>{w.el.focus(),w.el.select()})},null,544),[[Y,Fe.value]])])):(m(),g("button",{key:1,class:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-text-muted hover:text-text-primary hover:bg-surface-overlay transition-colors truncate max-w-[200px]",title:y.$t("dashboard.conversation.clickToRename"),onClick:ys},[r("span",Bi,u(kt.value),1),j(b(Rt),{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100"})],8,Li))]),r("div",Fi,[_e.value?(m(),g("button",{key:0,class:"rounded-lg px-3 py-1.5 text-xs text-accent hover:bg-surface-overlay transition-colors",onClick:$[3]||($[3]=w=>Ss(_e.value))},u(y.$t("dashboard.conversation.viewSessionDetails")),1)):E("",!0),r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",W.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[4]||($[4]=w=>W.value=!W.value)},[j(b(sn),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("dashboard.conversation.history")),1)],2),r("div",qi,[r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",O.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[5]||($[5]=w=>O.value=!O.value)},[j(b(tn),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("common.actions.export")),1)],2),O.value?(m(),g("div",{key:0,class:"fixed inset-0 z-10",onClick:$[6]||($[6]=w=>O.value=!1)})):E("",!0),O.value?(m(),g("div",Oi,[r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:me},u(y.$t("dashboard.export.downloadJson")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:oe},u(y.$t("dashboard.export.downloadMarkdown")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:ve},u(y.$t("dashboard.export.downloadText")),1)])):E("",!0)]),r("button",{class:"rounded-lg px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-overlay hover:text-text-primary transition-colors",onClick:$s},u(y.$t("dashboard.conversation.newChatButton")),1),r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",Q.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[7]||($[7]=w=>Q.value=!Q.value)},[j(b(qs),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("dashboard.settings.chatSettings")),1)],2)])]),r("div",Ui,[W.value?(m(),g("div",Vi,[r("div",Ki,[r("span",Hi,u(y.$t("dashboard.conversation.chatHistory")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Close history",onClick:$[8]||($[8]=w=>W.value=!1)}," ✕ ")]),r("div",Wi,[b(o).recentConversations.length===0?(m(),g("p",Gi,u(y.$t("dashboard.conversation.noConversationsYet")),1)):(m(),g("div",Zi,[(m(!0),g(U,null,J(b(o).recentConversations,w=>(m(),g("div",{key:w.id,class:P(["group flex items-center gap-1 rounded-lg px-2.5 py-2 text-xs transition-colors cursor-pointer",w.id===b(o).activeConversationId?"bg-surface-overlay text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:A=>f(w.id)},[ge.value===w.id?(m(),g("div",Ji,[G(r("input",{"onUpdate:modelValue":$[9]||($[9]=A=>fe.value=A),class:"w-full rounded bg-surface px-1.5 py-0.5 text-xs text-text-primary outline-none border border-accent",onBlur:A=>k(w.id),onKeydown:A=>L(A,w.id),onVnodeMounted:$[10]||($[10]=A=>{A.el.focus(),A.el.select()})},null,40,Xi),[[Y,fe.value]])])):(m(),g(U,{key:1},[r("div",Yi,[r("p",el,u(w.name),1),r("p",tl,u(w.model)+" · "+u(ce(w.updatedAt)),1)]),r("div",sl,[r("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:y.$t("dashboard.conversation.rename"),onClick:He(A=>_(w.id,w.name),["stop"])},[j(b(Rt),{class:"h-3 w-3"})],8,nl),r("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:y.$t("common.actions.delete"),onClick:He(A=>b(o).deleteConversation(w.id),["stop"])},[j(b(Xe),{class:"h-3 w-3"})],8,ol)])],64))],10,Qi))),128))]))])])):E("",!0),r("div",al,[vt.value?(m(),g("div",rl,[r("span",il,u(y.$t("common.status.error"))+":",1),Me(" "+u(vt.value),1)])):E("",!0),j(na,{messages:Be.value},null,8,["messages"]),j(Ia,{"is-streaming":b(v),"selected-model":x.value,"is-vision-model":xs.value,onSend:$t,onCommand:Ts,onCancel:ws},null,8,["is-streaming","selected-model","is-vision-model"])]),Q.value?(m(),g("div",ll,[r("div",cl,[r("span",ul,u(y.$t("dashboard.settings.chatSettings")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:$[11]||($[11]=w=>Q.value=!1)}," ✕ ")]),j(Ci,{modelValue:V.value,"onUpdate:modelValue":$[12]||($[12]=w=>V.value=w),"selected-model":x.value,"rag-enabled":K.value,"onUpdate:ragEnabled":$[13]||($[13]=w=>K.value=w)},null,8,["modelValue","selected-model","rag-enabled"])])):E("",!0)])]))}}),pl={class:"rounded-lg border border-border-default bg-surface-raised"},hl={class:"overflow-x-auto"},ml={class:"w-full text-sm"},gl=["onClick"],fl={class:"px-4 py-2 font-medium text-text-primary"},bl={class:"px-4 py-2"},xl={class:"px-4 py-2 text-text-secondary"},yl={class:"px-4 py-2 text-text-secondary"},vl={class:"px-4 py-2 text-text-secondary"},kl={class:"px-4 py-2 text-text-muted"},wl={key:0},$l=ne({__name:"SessionHistoryTable",setup(t){const e=Ye();return(s,o)=>(m(),g("div",pl,[o[2]||(o[2]=r("div",{class:"px-4 py-3 border-b border-border-default"},[r("h3",{class:"text-sm font-medium text-text-secondary"},"Recent Sessions")],-1)),r("div",hl,[r("table",ml,[o[1]||(o[1]=r("thead",null,[r("tr",{class:"border-b border-border-default text-left text-xs text-text-muted uppercase tracking-wide"},[r("th",{class:"px-4 py-2"},"Model"),r("th",{class:"px-4 py-2"},"Status"),r("th",{class:"px-4 py-2"},"Tokens"),r("th",{class:"px-4 py-2"},"Speed"),r("th",{class:"px-4 py-2"},"Duration"),r("th",{class:"px-4 py-2"},"When")])],-1)),r("tbody",null,[(m(!0),g(U,null,J(b(e).recentSessions.slice(0,20),n=>(m(),g("tr",{key:n.id,class:"border-b border-border-default last:border-0 hover:bg-surface-overlay cursor-pointer transition-colors",onClick:i=>s.$router.push({name:"session",params:{id:n.id}})},[r("td",fl,u(n.model),1),r("td",bl,[j(Gs,{status:n.status,detail:n.error},null,8,["status","detail"])]),r("td",xl,u(n.metrics?n.metrics.totalTokenCount:"—"),1),r("td",yl,u(n.metrics?b(We)(n.metrics.tokensPerSecond):"—"),1),r("td",vl,u(n.metrics?b(Zt)(n.metrics.totalDurationMs):"—"),1),r("td",kl,u(b(Us)(n.createdAt)),1)],8,gl))),128)),b(e).recentSessions.length===0?(m(),g("tr",wl,[...o[0]||(o[0]=[r("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):E("",!0)])])])]))}}),Sl={class:"flex h-full flex-col"},_l={class:"flex-1 min-h-0"},Cl={key:0,class:"border-t border-border-default"},Tl={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Ml={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Rl={key:1,class:"border-t border-border-default px-4 py-2"},Al={class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},zl={class:"flex gap-2 overflow-x-auto pb-1"},Nl=["onClick"],Ql=ne({__name:"DashboardPage",setup(t){const e=lt(),s=Gt(),o=z(!1),n=F(()=>e.aggregate),i=F(()=>n.value.totalSessions>0),a=F(()=>s.recentConversations);return(c,l)=>(m(),g("div",Sl,[r("div",_l,[j(dl)]),i.value?(m(),g("div",Cl,[r("button",{class:"flex w-full items-center justify-between px-4 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:l[0]||(l[0]=p=>o.value=!o.value)},[r("span",null,u(n.value.totalSessions)+" "+u(c.$t("dashboard.metrics.sessions"))+" · Avg "+u(b(We)(n.value.avgTps)),1),r("span",{class:P(["transition-transform",{"rotate-180":o.value}])},"▾",2)]),o.value?(m(),g("div",Tl,[r("div",Ml,[j(Ve,{label:c.$t("dashboard.metrics.totalSessions"),value:n.value.totalSessions},null,8,["label","value"]),j(Ve,{label:c.$t("dashboard.metrics.avgTtft"),value:b(Zt)(n.value.avgTtftMs)},null,8,["label","value"]),j(Ve,{label:c.$t("dashboard.metrics.avgSpeed"),value:b(We)(n.value.avgTps)},null,8,["label","value"]),j(Ve,{label:c.$t("dashboard.metrics.totalTokens"),value:b(Te)(n.value.totalTokensGenerated),unit:"tok"},null,8,["label","value"])]),j($l)])):E("",!0)])):E("",!0),a.value.length>1?(m(),g("div",Rl,[r("p",Al,u(c.$t("dashboard.metrics.recentChats")),1),r("div",zl,[(m(!0),g(U,null,J(a.value.slice(0,5),p=>(m(),g("button",{key:p.id,class:P(["shrink-0 rounded-lg px-3 py-1.5 text-xs transition-colors",b(s).activeConversationId===p.id?"bg-accent/10 text-accent":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:d=>b(s).setActiveConversation(p.id)},u(p.name),11,Nl))),128))])])):E("",!0)]))}});export{Ql as default};