llmxray 0.4.5 → 0.4.7

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 (49) hide show
  1. package/README.md +25 -1
  2. package/dist/assets/{AITrainingPage-CTbiKR4o.js → AITrainingPage-CsvXVCl4.js} +1 -1
  3. package/dist/assets/{AnalyticsPage-L3-8eM5L.js → AnalyticsPage-vkaPSUTM.js} +1 -1
  4. package/dist/assets/{BenchmarkPage-Cp2LdW1Y.js → BenchmarkPage-D0OBLy2p.js} +6 -6
  5. package/dist/assets/{ComparisonPage-F2QFxXKK.js → ComparisonPage-yjlQyMSr.js} +1 -1
  6. package/dist/assets/{CostDashboardPage-CmkI6RhJ.js → CostDashboardPage--NlorE5h.js} +1 -1
  7. package/dist/assets/DashboardPage-C7HpWzo0.js +114 -0
  8. package/dist/assets/{EmbeddingsPage-Dhn69cMU.js → EmbeddingsPage-BjI-MRAa.js} +1 -1
  9. package/dist/assets/FimPlaygroundPage-DFbVhKk_.js +7 -0
  10. package/dist/assets/{GoogleCallbackPage-BPOipV3I.js → GoogleCallbackPage-CtnaMbov.js} +1 -1
  11. package/dist/assets/{JsonTreeNode-C5Z9FiUn.js → JsonTreeNode-D4tXijI2.js} +1 -1
  12. package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-BYJHAYcE.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-Cj2LskB0.js} +1 -1
  13. package/dist/assets/ProtocolObservatoryPage-BCBMa4BZ.js +2 -0
  14. package/dist/assets/{RAGPage-CsjbL5YH.js → RAGPage-DhajwBAP.js} +1 -1
  15. package/dist/assets/{SessionPage-B36k_j6J.js → SessionPage-D9yVmDvL.js} +1 -1
  16. package/dist/assets/{SettingsPage-tCYrEuZu.js → SettingsPage-CMAnCevk.js} +1 -1
  17. package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-l4RPMSub.js → StatusBadge.vue_vue_type_script_setup_true_lang-n7TTYhNJ.js} +1 -1
  18. package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-BZ0xe8a5.js → StorageGauge.vue_vue_type_style_index_0_lang-BKb4VKNU.js} +1 -1
  19. package/dist/assets/{SystemPage-DbM1asxH.js → SystemPage-D4Zziyum.js} +2 -2
  20. package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-DvNMmBew.js → TabBar.vue_vue_type_script_setup_true_lang-DQpdkass.js} +1 -1
  21. package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-DbSc7oKx.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-Bkp4Zqzc.js} +1 -1
  22. package/dist/assets/{ToolWorkshopPage-DlvGbnXA.js → ToolWorkshopPage-Bi-P9pPj.js} +1 -1
  23. package/dist/assets/{agent-store-BAbxPyGG.js → agent-store-uNRCwO3m.js} +1 -1
  24. package/dist/assets/{canvas-ai-db-DNjr8LU-.js → canvas-ai-db-vwusn4PB.js} +1 -1
  25. package/dist/assets/{download-C1Met8Ds.js → download-CE6FVTgu.js} +1 -1
  26. package/dist/assets/{generate-service-VZbSAJDg.js → generate-service-CYQ8kwVP.js} +1 -1
  27. package/dist/assets/{google-auth-store-DkdmpAZx.js → google-auth-store-Dz06BePf.js} +1 -1
  28. package/dist/assets/index-BwnEclbR.js +36 -0
  29. package/dist/assets/{index-BAH6vZD2.js → index-Dv-x214f.js} +1 -1
  30. package/dist/assets/{index-JwzhZrFR.js → index-FRDa6LAg.js} +1 -1
  31. package/dist/assets/{index-B0RKZCO8.css → index-aU4tMz4Z.css} +1 -1
  32. package/dist/assets/{info-L1PieSf1.js → info-DnW3KRin.js} +1 -1
  33. package/dist/assets/{metrics-store-CTvzJiqS.js → metrics-store-BDn0738m.js} +1 -1
  34. package/dist/assets/{papaparse.min-_t35gVwJ.js → papaparse.min-DzDO_wBU.js} +1 -1
  35. package/dist/assets/{pencil-CyyRcZEK.js → pencil-clhQxwX0.js} +1 -1
  36. package/dist/assets/play-4DIDJWWS.js +1 -0
  37. package/dist/assets/{rag-store-BenIN46q.js → rag-store-Do5yRDAH.js} +3 -3
  38. package/dist/assets/{session-store-CUrHUAx1.js → session-store-DRoQgYmX.js} +1 -1
  39. package/dist/assets/{share-2-yHQTyFhw.js → share-2-DmfX3XRE.js} +1 -1
  40. package/dist/assets/square-BSrc21IW.js +1 -0
  41. package/dist/assets/{storage-store-BVMT_hD6.js → storage-store-BNeLgzhr.js} +1 -1
  42. package/dist/assets/{stream-handler-aBc67cBl.js → stream-handler-m2cr76ko.js} +2 -2
  43. package/dist/assets/{tool-workshop-store-BMnfrBeR.js → tool-workshop-store-CvrmwDRz.js} +1 -1
  44. package/dist/assets/{toolcall-store-BaQPfRpR.js → toolcall-store-EOcmOTQ4.js} +1 -1
  45. package/dist/assets/{trash-2-DAcbs__v.js → trash-2-DghOHCMp.js} +1 -1
  46. package/dist/index.html +2 -2
  47. package/package.json +1 -1
  48. package/dist/assets/DashboardPage-BsQXjnwn.js +0 -116
  49. package/dist/assets/index-BSSjp86R.js +0 -8
@@ -0,0 +1,114 @@
1
+ import{u as ut}from"./metrics-store-BDn0738m.js";import{c as Fe,_ as js,o as Le,n as we,r as A,d as Vt,w as oe,a as L,b as ae,e as f,f as a,g as P,t as u,h as ze,i as E,j as g,F as W,k as Y,l as Ps,u as b,m as Ds,p as F,q as De,T as Is,s as Ut,v as Ze,X as tt,x as Kt,y as Fs,z as Ht,A as dt,B as Wt,E as Ls,C as Z,D as X,G as He,H as Gt,I as Zt,J as Bs,S as Os,K as qs}from"./index-BwnEclbR.js";import{f as Ae,a as Je,b as at,c as Jt,d as Vs}from"./format-BqVZ9rwM.js";import{u as st}from"./session-store-DRoQgYmX.js";import{a as Us,s as Ks}from"./generate-service-CYQ8kwVP.js";import{u as Hs,a as Ws,_ as Gs,b as We}from"./StatusBadge.vue_vue_type_script_setup_true_lang-n7TTYhNJ.js";import{u as Zs}from"./toolcall-store-EOcmOTQ4.js";import{u as pt}from"./tool-workshop-store-CvrmwDRz.js";import{u as Js,a as Qt,b as Qs}from"./agent-store-uNRCwO3m.js";import{e as Xs}from"./stream-handler-m2cr76ko.js";import{d as Ys,p as en,u as Xt}from"./rag-store-Do5yRDAH.js";import{messageMemoryDB as Yt}from"./message-memory-db-C3Ifhs2B.js";import{_ as Rt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-Cj2LskB0.js";import{P as At}from"./pencil-clhQxwX0.js";import{D as tn}from"./download-CE6FVTgu.js";import"./vector-db-ChAzHl5A.js";const sn=Fe("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);const es=Fe("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=Fe("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=Fe("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=Fe("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,r]of Object.entries(e))s.set(i,r);const o=[...t].sort((i,r)=>i.order-r.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=Ie(t.url,e),o=t.body?Ie(t.body,e):void 0,n={};for(const[l,h]of Object.entries(t.headers))n[l]=Ie(h,e);const i=await fetch(s,{method:t.method,headers:n,body:t.method!=="GET"?o:void 0});let r;(i.headers.get("content-type")??"").includes("application/json")?r=await i.json():r=await i.text(),e.set(t.outputVariable||"response",r)}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=Ie(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):Ie(s,e)}async function mn(){const{getAccessToken:t,isConnected:e}=await js(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 Ie(t,e){return t.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g,(s,o)=>{const n=o.split(".");let i=e.get(n[0]??"");for(let r=1;r<n.length;r++){if(i==null||typeof i!="object")return"";i=i[n[r]??""]}return i==null?"":typeof i=="object"?JSON.stringify(i):String(i)})}const gn=5;async function fn(t){const e=st(),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=Us(n,t.messages);s.setAnatomy(n,i);const r=new AbortController;return bn(n,t.model,[...t.messages],t.tools,t.options,r.signal,t.think,t.format).catch(c=>{r.signal.aborted||e.setSessionError(n,c instanceof Error?c.message:"Chat failed")}),{sessionId:n,abort:()=>{r.abort(),e.cancelSession(n)}}}async function bn(t,e,s,o,n,i,r,c){const l=Zs(),h=pt(),d=Js();let m=0,y=0;for(;m<gn;){if(i.aborted)return;const T=await Le.streamChat({model:e,messages:s,tools:o,options:n,logprobs:!0,think:r,format:c},i),S=await Xs(t,T,i);if(S.toolCalls.length===0)return;s.push({role:"assistant",content:"",tool_calls:S.toolCalls});for(const M of S.toolCalls){const _=h.findByFunctionName(M.function.name),K=l.getToolCalls(t).find(V=>V.functionName===M.function.name&&V.status==="pending");if(!_){const V=`Tool "${M.function.name}" has no implementation`;d.addNode(t,{id:we(),type:"error",label:`No impl: ${M.function.name}`,sessionId:t,stepIndex:y++,state:{tool:M.function.name,error:V},timestamp:Date.now()}),K&&l.updateToolCall(t,K.id,{status:"failed",error:V,completedAt:Date.now()}),s.push({role:"tool",content:JSON.stringify({error:V})});continue}K&&l.updateToolCall(t,K.id,{status:"executing"});const B=await rn(_,M.function.arguments);d.addNode(t,{id:we(),type:B.success?"output":"error",label:B.success?`Tool Result: ${M.function.name}`:`Tool Failed: ${M.function.name}`,sessionId:t,stepIndex:y++,state:{tool:M.function.name,success:B.success,durationMs:B.durationMs},timestamp:Date.now()}),K&&l.updateToolCall(t,K.id,{status:B.success?"completed":"failed",result:B.result,error:B.error,completedAt:Date.now(),durationMs:B.durationMs});const G=B.success?typeof B.result=="string"?B.result:JSON.stringify(B.result):JSON.stringify({error:B.error});s.push({role:"tool",content:G})}d.addNode(t,{id:we(),type:"llm_call",label:`LLM Round ${m+2} (with tool results)`,sessionId:t,stepIndex:y++,state:{round:m+1},timestamp:Date.now()}),m++}}function xn(){const t=A(!1),e=A(null),s=A(null);let o=null;async function n(c,l,h,d){t.value=!0,e.value=null;try{const m=await Ks({model:c,prompt:l,system:d,options:h});return s.value=m.sessionId,o=m.abort,m.sessionId}catch(m){throw e.value=m instanceof Error?m.message:"Failed to start generation",t.value=!1,m}}async function i(c,l,h,d,m){t.value=!0,e.value=null;try{const y=await fn({model:c,messages:l,tools:d,options:h,think:m?.think,format:m?.format});return s.value=y.sessionId,o=y.abort,y.sessionId}catch(y){throw e.value=y instanceof Error?y.message:"Failed to start chat",t.value=!1,y}}function r(){o&&(o(),o=null),t.value=!1}return{isStreaming:t,error:e,currentSessionId:s,startGenerate:n,startChatStream:i,cancel:r}}const R="dashboard.slashCommands.notifications",Qe=[{name:"help",descriptionKey:"dashboard.slashCommands.descriptions.help",description:"Show all available commands",usage:"/help",category:"chat",execute(t,e){const s=ts(e.t),o=[e.t(`${R}.helpHeader`)];for(const[n,i]of Object.entries(s)){o.push(`**${n}**`);for(const r of i){const c=r.descriptionKey?e.t(r.descriptionKey):r.description;o.push(` ${r.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(`${R}.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(`${R}.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(`${R}.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(`${R}.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(`${R}.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(`${R}.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(`${R}.switchedTo`,{model:o}))):e.showNotification(e.t(`${R}.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(`${R}.none`);e.showNotification(e.t(`${R}.currentSystemPrompt`,{prompt:o}));return}e.setSystemPrompt(s),e.showNotification(e.t(`${R}.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(`${R}.tempUsage`,{current:e.chatSettings.value.options.temperature??.7}));return}e.setOption("temperature",s),e.showNotification(e.t(`${R}.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(`${R}.topPUsage`,{current:e.chatSettings.value.options.top_p??.9}));return}e.setOption("top_p",s),e.showNotification(e.t(`${R}.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(`${R}.topKUsage`,{current:e.chatSettings.value.options.top_k??40}));return}e.setOption("top_k",s),e.showNotification(e.t(`${R}.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(`${R}.contextUsage`,{current:Ae(e.chatSettings.value.options.num_ctx??4096),sizes:o.join(", ")}));return}e.setOption("num_ctx",s),e.showNotification(e.t(`${R}.contextSet`,{value:Ae(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(`${R}.repeatPenaltyUsage`,{current:e.chatSettings.value.options.repeat_penalty??1.1}));return}e.setOption("repeat_penalty",s),e.showNotification(e.t(`${R}.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(`${R}.seedUsage`,{current:e.chatSettings.value.options.seed??-1}));return}e.setOption("seed",s===-1?void 0:s),e.showNotification(s===-1?e.t(`${R}.seedRandom`):e.t(`${R}.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(`${R}.none`);e.showNotification(e.t(`${R}.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(`${R}.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(`${R}.mirostatUsage`,{current:e.chatSettings.value.options.mirostat??0}));return}e.setOption("mirostat",s),e.showNotification(s===0?e.t(`${R}.mirostatDisabled`):e.t(`${R}.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(`${R}.jsonFormatEnabled`):e.t(`${R}.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(`${R}.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(`${R}.ragDisabled`):e.t(`${R}.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(`${R}.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(`${R}.ollamaConnected`):e.t(`${R}.ollamaDisconnected`);e.showNotification(e.t(`${R}.ollamaStatus`,{status:o,model:s.model||e.t(`${R}.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(`${R}.noActiveSession`));return}e.showNotification(e.t(`${R}.tokenCounts`,{prompt:Ae(s.prompt),completion:Ae(s.completion),total:Ae(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(`${R}.noSessionsRecorded`));return}e.showNotification(e.t(`${R}.averageSpeed`,{speed:Je(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(`${R}.rememberUsage`));return}e.addFact(s),e.showNotification(e.t(`${R}.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(`${R}.forgetUsage`));return}e.removeFact(s)?e.showNotification(e.t(`${R}.forgot`,{search:s})):e.showNotification(e.t(`${R}.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(`${R}.noMemories`));return}const o=s.map((n,i)=>`${i+1}. ${n.content}`);e.showNotification(e.t(`${R}.yourMemories`,{count:s.length,list:o.join(`
4
+ `)}))}}];function vn(t){const e=t.toLowerCase().replace(/^\//,"");return e?Qe.filter(s=>s.name.startsWith(e)):Qe}function yn(t){return Qe.find(e=>e.name===t.toLowerCase())}function ts(t){const e={};for(const s of Qe){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 zt={slidingWindow:{enabled:!0,maxMessages:50},autoSummarize:{enabled:!1,triggerThreshold:30},ragMemory:{enabled:!1,embeddingModel:"",topK:3},userFacts:{enabled:!0}},Nt="llmxray-memory-settings",Et="llmxray-user-facts";function jt(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 ss=Vt("memory",()=>{const t=A(jt(Nt,{...zt}));oe(t,S=>Pt(Nt,S),{deep:!0});function e(S){t.value={...t.value,...S}}function s(){t.value={...zt}}const o=A(jt(Et,[]));oe(o,S=>Pt(Et,S),{deep:!0});const n=L(()=>o.value.length);function i(S){const M={id:we(),content:S.trim(),createdAt:Date.now()};return o.value=[...o.value,M],M}function r(S){o.value=o.value.filter(M=>M.id!==S)}function c(S){const M=S.toLowerCase().trim(),_=o.value.findIndex(J=>J.content.toLowerCase().includes(M));return _===-1?!1:(o.value=[...o.value.slice(0,_),...o.value.slice(_+1)],!0)}function l(){o.value=[]}function h(){return o.value.length===0?"":`The user has asked you to remember these facts about them:
5
+ ${o.value.map(M=>`- ${M.content}`).join(`
6
+ `)}
7
+
8
+ Keep these in mind when responding.`}const d=A(new Map);function m(S,M,_){d.value.set(S,{conversationId:S,summary:M,messageCount:_,createdAt:Date.now()})}function y(S){return d.value.get(S)}function T(S){d.value.delete(S)}return{settings:t,updateSettings:e,resetSettings:s,facts:o,factCount:n,addFact:i,removeFact:r,removeFactByContent:c,clearFacts:l,getFactsAsSystemPrompt:h,summaries:d,setSummary:m,getSummary:y,clearSummary:T}}),ns=Vt("quality",()=>{const t=A(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 r of s)o.set(r,(o.get(r)??0)+1);let n=0;for(const r of o.values())r>1&&(n+=r);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 r=[$n(s),Sn(s),_n(s),Cn(s),Tn(s,o,n,i)];return{messageId:t,sessionId:e,overall:Mn(r),checks:r,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"),r=o.slice(0,-n),c=o.slice(-n),l=t.existingSummary?`Previous summary:
9
+ ${t.existingSummary}
10
+
11
+ New messages to incorporate:
12
+ `:"",h=await Nn(t.model,l+r.map(d=>`${d.role}: ${d.content}`).join(`
13
+ `));h&&(s=h,e=[...i,{role:"system",content:`Summary of earlier conversation:
14
+ ${h}`},...c])}if(t.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),i=e.filter(c=>c.role!=="system"),r=t.settings.slidingWindow.maxMessages;if(i.length>r){const c=i.slice(-r);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"),r=e.filter(c=>c.role!=="system");e=[...i,{role:"system",content:n},...r]}}catch{}return{messages:e,newSummary:s}}async function zn(t,e,s){if(!s||e.length===0)return;const o=e.map(r=>r.content),n=await Le.embed({model:s,input:o}),i=[];for(let r=0;r<e.length;r++){const c=n.embeddings[r];if(!c)continue;const l=e[r];i.push({id:we(),conversationId:t,role:l.role,content:l.content,embedding:c,timestamp:l.timestamp})}await Yt.storeMessages(i)}async function Nn(t,e){try{return(await Le.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(m=>m.role==="user"),i=n[n.length-1];if(!i)return null;const c=(await Le.embed({model:s,input:[i.content]})).embeddings[0];if(!c)return null;const h=(await Yt.search(c,o,t)).filter(m=>m.score>.5);return h.length===0?null:`Relevant messages from past conversations:
15
+ ${h.map(m=>`[${m.message.role}, relevance: ${(m.score*100).toFixed(0)}%] ${m.message.content}`).join(`
16
+
17
+ `)}
18
+
19
+ Use this context if helpful, but prioritize the current conversation.`}function ht(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Te=ht();function os(t){Te=t}var _e={exec:()=>null};function I(t,e=""){let s=typeof t=="string"?t:t.source,o={replace:(n,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(ee.caret,"$1"),s=s.replace(n,r),o},getRegex:()=>new RegExp(s,e)};return o}var jn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ee={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)}}>`)},Pn=/^(?:[ \t]*(?:\n|$))+/,Dn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,In=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Be=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,mt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,as=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,rs=I(as).replace(/bull/g,mt).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(),Ln=I(as).replace(/bull/g,mt).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(),gt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bn=/^[^\n]+/,ft=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,On=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ft).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qn=I(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,mt).getRegex(),nt="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",bt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vn=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",bt).replace("tag",nt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),is=I(gt).replace("hr",Be).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",nt).getRegex(),Un=I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",is).getRegex(),xt={blockquote:Un,code:Dn,def:On,fences:In,heading:Fn,hr:Be,html:Vn,lheading:rs,list:qn,newline:Pn,paragraph:is,table:_e,text:Bn},Dt=I("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Be).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",nt).getRegex(),Kn={...xt,lheading:Ln,table:Dt,paragraph:I(gt).replace("hr",Be).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",nt).getRegex()},Hn={...xt,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",bt).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:_e,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(gt).replace("hr",Be).replace("heading",` *#{1,6} *[^
20
+ ]`).replace("lheading",rs).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Wn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ls=/^( {2,}|\\)\n(?!\s*$)/,Zn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ot=/[\p{P}\p{S}]/u,vt=/[\s\p{P}\p{S}]/u,cs=/[^\s\p{P}\p{S}]/u,Jn=I(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vt).getRegex(),us=/(?!~)[\p{P}\p{S}]/u,Qn=/(?!~)[\s\p{P}\p{S}]/u,Xn=/(?:[^\s\p{P}\p{S}]|~)/u,ds=/(?![*_])[\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-",jn?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ps=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,so=I(ps,"u").replace(/punct/g,ot).getRegex(),no=I(ps,"u").replace(/punct/g,us).getRegex(),hs="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oo=I(hs,"gu").replace(/notPunctSpace/g,cs).replace(/punctSpace/g,vt).replace(/punct/g,ot).getRegex(),ao=I(hs,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,Qn).replace(/punct/g,us).getRegex(),ro=I("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,cs).replace(/punctSpace/g,vt).replace(/punct/g,ot).getRegex(),io=I(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ds).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,ds).getRegex(),uo=I(/\\(punct)/,"gu").replace(/punct/g,ot).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(bt).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(),Xe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,go=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Xe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ms=I(/^!?\[(label)\]\[(ref)\]/).replace("label",Xe).replace("ref",ft).getRegex(),gs=I(/^!?\[(ref)\](?:\[\])?/).replace("ref",ft).getRegex(),fo=I("reflink|nolink(?!\\()","g").replace("reflink",ms).replace("nolink",gs).getRegex(),It=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yt={_backpedal:_e,anyPunctuation:uo,autolink:po,blockSkip:to,br:ls,code:Gn,del:_e,delLDelim:_e,delRDelim:_e,emStrongLDelim:so,emStrongRDelimAst:oo,emStrongRDelimUnd:ro,escape:Wn,link:go,nolink:gs,punctuation:Jn,reflink:ms,reflinkSearch:fo,tag:mo,text:Zn,url:_e},bo={...yt,link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",Xe).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xe).getRegex()},rt={...yt,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={...rt,br:I(ls).replace("{2,}","*").getRegex(),text:I(rt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ge={normal:xt,gfm:Kn,pedantic:Hn},Ee={normal:yt,gfm:rt,breaks:xo,pedantic:bo},vo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ft=t=>vo[t];function me(t,e){if(e){if(ee.escapeTest.test(t))return t.replace(ee.escapeReplace,Ft)}else if(ee.escapeTestNoEncode.test(t))return t.replace(ee.escapeReplaceNoEncode,Ft);return t}function Lt(t){try{t=encodeURI(t).replace(ee.percentDecode,"%")}catch{return null}return t}function Bt(t,e){let s=t.replace(ee.findPipe,(i,r,c)=>{let l=!1,h=r;for(;--h>=0&&c[h]==="\\";)l=!l;return l?"|":" |"}),o=s.split(ee.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(ee.slashPipe,"|");return o}function je(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 yo(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 Ot(t,e,s,o,n){let i=e.href,r=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:r,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 r=i.match(s.other.beginningSpace);if(r===null)return i;let[c]=r;return c.length>=n.length?i.slice(n.length):i}).join(`
22
+ `)}var Ye=class{options;rules;lexer;constructor(t){this.options=t||Te}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:je(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=je(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:je(e[0],`
24
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=je(e[0],`
25
+ `).split(`
26
+ `),o="",n="",i=[];for(;s.length>0;){let r=!1,c=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))c.push(s[l]),r=!0;else if(!r)c.push(s[l]);else break;s=s.slice(l);let h=c.join(`
27
+ `),d=h.replace(this.rules.other.blockquoteSetextReplace,`
28
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
29
+ ${h}`:h,n=n?`${n}
30
+ ${d}`:d;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,i,!0),this.lexer.state.top=m,s.length===0)break;let y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){let T=y,S=T.raw+`
31
+ `+s.join(`
32
+ `),M=this.blockquote(S);i[i.length-1]=M,o=o.substring(0,o.length-T.raw.length)+M.raw,n=n.substring(0,n.length-T.text.length)+M.text;break}else if(y?.type==="list"){let T=y,S=T.raw+`
33
+ `+s.join(`
34
+ `),M=this.list(S);i[i.length-1]=M,o=o.substring(0,o.length-y.raw.length)+M.raw,n=n.substring(0,n.length-T.raw.length)+M.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),r=!1;for(;t;){let l=!1,h="",d="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;h=e[0],t=t.substring(h.length);let m=ko(e[2].split(`
36
+ `,1)[0],e[1].length),y=t.split(`
37
+ `,1)[0],T=!m.trim(),S=0;if(this.options.pedantic?(S=2,d=m.trimStart()):T?S=e[1].length+1:(S=m.search(this.rules.other.nonSpaceChar),S=S>4?1:S,d=m.slice(S),S+=e[1].length),T&&this.rules.other.blankLine.test(y)&&(h+=y+`
38
+ `,t=t.substring(y.length+1),l=!0),!l){let M=this.rules.other.nextBulletRegex(S),_=this.rules.other.hrRegex(S),J=this.rules.other.fencesBeginRegex(S),K=this.rules.other.headingBeginRegex(S),B=this.rules.other.htmlBeginRegex(S),G=this.rules.other.blockquoteBeginRegex(S);for(;t;){let V=t.split(`
39
+ `,1)[0],H;if(y=V,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),H=y):H=y.replace(this.rules.other.tabCharGlobal," "),J.test(y)||K.test(y)||B.test(y)||G.test(y)||M.test(y)||_.test(y))break;if(H.search(this.rules.other.nonSpaceChar)>=S||!y.trim())d+=`
40
+ `+H.slice(S);else{if(T||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||J.test(m)||K.test(m)||_.test(m))break;d+=`
41
+ `+y}T=!y.trim(),h+=V+`
42
+ `,t=t.substring(V.length+1),m=H.slice(S)}}n.loose||(r?n.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(r=!0)),n.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),n.raw+=h}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 h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let d={type:"checkbox",raw:h[0]+" ",checked:h[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 h=l.tokens.filter(m=>m.type==="space"),d=h.length>0&&h.some(m=>this.rules.other.anyLine.test(m.raw));n.loose=d}}if(n.loose)for(let l of n.items){l.loose=!0;for(let h of l.tokens)h.type==="text"&&(h.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 r of o)this.rules.other.tableAlignRight.test(r)?i.align.push("right"):this.rules.other.tableAlignCenter.test(r)?i.align.push("center"):this.rules.other.tableAlignLeft.test(r)?i.align.push("left"):i.align.push(null);for(let r=0;r<s.length;r++)i.header.push({text:s[r],tokens:this.lexer.inline(s[r]),header:!0,align:i.align[r]});for(let r of n)i.rows.push(Bt(r,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=je(s.slice(0,-1),"\\");if((s.length-i.length)%2===0)return}else{let i=yo(e[2],"()");if(i===-2)return;if(i>-1){let r=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,r).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)),Ot(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 Ot(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,r,c=n,l=0,h=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+n);(o=h.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(r=[...i].length,o[3]||o[4]){c+=r;continue}else if((o[5]||o[6])&&n%3&&!((n+r)%3)){l+=r;continue}if(c-=r,c>0)continue;r=Math.min(r,r+c+l);let d=[...o[0]][0].length,m=t.slice(0,n+o.index+d+r);if(Math.min(n,r)%2){let T=m.slice(1,-1);return{type:"em",raw:m,text:T,tokens:this.lexer.inlineTokens(T)}}let y=m.slice(2,-2);return{type:"strong",raw:m,text:y,tokens:this.lexer.inlineTokens(y)}}}}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,r,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||(r=[...i].length,r!==n))continue;if(o[3]||o[4]){c+=r;continue}if(c-=r,c>0)continue;r=Math.min(r,r+c);let h=[...o[0]][0].length,d=t.slice(0,n+o.index+h+r),m=d.slice(n,-n);return{type:"del",raw:d,text:m,tokens:this.lexer.inlineTokens(m)}}}}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}}}},ue=class it{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Te,this.options.tokenizer=this.options.tokenizer||new Ye,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:ee,block:Ge.normal,inline:Ee.normal};this.options.pedantic?(s.block=Ge.pedantic,s.inline=Ee.pedantic):this.options.gfm&&(s.block=Ge.gfm,this.options.breaks?s.inline=Ee.breaks:s.inline=Ee.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ge,inline:Ee}}static lex(e,s){return new it(s).lex(e)}static lexInline(e,s){return new it(s).inlineTokens(e)}lex(e){e=e.replace(ee.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(ee.tabCharGlobal," ").replace(ee.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(r=>(n=r.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 r=s.at(-1);n.raw.length===1&&r!==void 0?r.raw+=`
46
+ `:s.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let r=s.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`
47
+ `)?"":`
48
+ `)+n.raw,r.text+=`
49
+ `+n.text,this.inlineQueue.at(-1).src=r.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 r=s.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=(r.raw.endsWith(`
50
+ `)?"":`
51
+ `)+n.raw,r.text+=`
52
+ `+n.raw,this.inlineQueue.at(-1).src=r.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 r=1/0,c=e.slice(1),l;this.options.extensions.startBlock.forEach(h=>{l=h.call({lexer:this},c),typeof l=="number"&&l>=0&&(r=Math.min(r,l))}),r<1/0&&r>=0&&(i=e.substring(0,r+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let r=s.at(-1);o&&r?.type==="paragraph"?(r.raw+=(r.raw.endsWith(`
53
+ `)?"":`
54
+ `)+n.raw,r.text+=`
55
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.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 r=s.at(-1);r?.type==="text"?(r.raw+=(r.raw.endsWith(`
56
+ `)?"":`
57
+ `)+n.raw,r.text+=`
58
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):s.push(n);continue}if(e){let r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}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 r=!1,c="";for(;e;){r||(c=""),r=!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 h=e;if(this.options.extensions?.startInline){let d=1/0,m=e.slice(1),y;this.options.extensions.startInline.forEach(T=>{y=T.call({lexer:this},m),typeof y=="number"&&y>=0&&(d=Math.min(d,y))}),d<1/0&&d>=0&&(h=e.substring(0,d+1))}if(l=this.tokenizer.inlineText(h)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(c=l.raw.slice(-1)),r=!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}},et=class{options;parser;constructor(t){this.options=t||Te}space(t){return""}code({text:t,lang:e,escaped:s}){let o=(e||"").match(ee.notSpaceStart)?.[0],n=t.replace(ee.endingNewline,"")+`
59
+ `;return o?'<pre><code class="language-'+me(o)+'">'+(s?n:me(n,!0))+`</code></pre>
60
+ `:"<pre><code>"+(s?n:me(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 r=0;r<t.items.length;r++){let c=t.items[r];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 r=0;r<i.length;r++)s+=this.tablecell(i[r]);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>${me(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="'+me(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 me(s);t=n;let i=`<img src="${t}" alt="${me(s)}"`;return e&&(i+=` title="${me(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:me(t.text)}},kt=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}},de=class lt{options;renderer;textRenderer;constructor(e){this.options=e||Te,this.options.renderer=this.options.renderer||new et,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new kt}static parse(e,s){return new lt(s).parse(e)}static parseInline(e,s){return new lt(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 r=n,c=this.options.extensions.renderers[r.type].call({parser:this},r);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(r.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 r='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(r),"";throw new Error(r)}}}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 r=i;switch(r.type){case"escape":{o+=s.text(r);break}case"html":{o+=s.html(r);break}case"link":{o+=s.link(r);break}case"image":{o+=s.image(r);break}case"checkbox":{o+=s.checkbox(r);break}case"strong":{o+=s.strong(r);break}case"em":{o+=s.em(r);break}case"codespan":{o+=s.codespan(r);break}case"br":{o+=s.br(r);break}case"del":{o+=s.del(r);break}case"text":{o+=s.text(r);break}default:{let c='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return o}},Pe=class{options;block;constructor(t){this.options=t||Te}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?ue.lex:ue.lexInline}provideParser(){return this.block?de.parse:de.parseInline}},fs=class{defaults=ht();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=de;Renderer=et;TextRenderer=kt;Lexer=ue;Tokenizer=Ye;Hooks=Pe;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 r of i)s=s.concat(this.walkTokens(r.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 r=n[i].flat(1/0);s=s.concat(this.walkTokens(r,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(...r){let c=n.renderer.apply(this,r);return c===!1&&(c=i.apply(this,r)),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 et(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 r=i,c=s.renderer[r],l=n[r];n[r]=(...h)=>{let d=c.apply(n,h);return d===!1&&(d=l.apply(n,h)),d||""}}o.renderer=n}if(s.tokenizer){let n=this.defaults.tokenizer||new Ye(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 r=i,c=s.tokenizer[r],l=n[r];n[r]=(...h)=>{let d=c.apply(n,h);return d===!1&&(d=l.apply(n,h)),d}}o.tokenizer=n}if(s.hooks){let n=this.defaults.hooks||new Pe;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 r=i,c=s.hooks[r],l=n[r];Pe.passThroughHooks.has(i)?n[r]=h=>{if(this.defaults.async&&Pe.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(n,h);return l.call(n,m)})();let d=c.call(n,h);return l.call(n,d)}:n[r]=(...h)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(n,h);return m===!1&&(m=await l.apply(n,h)),m})();let d=c.apply(n,h);return d===!1&&(d=l.apply(n,h)),d}}o.hooks=n}if(s.walkTokens){let n=this.defaults.walkTokens,i=s.walkTokens;o.walkTokens=function(r){let c=[];return c.push(i.call(this,r)),n&&(c=c.concat(n.call(this,r))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ue.lex(t,e??this.defaults)}parser(t,e){return de.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 r=n.hooks?await n.hooks.preprocess(e):e,c=await(n.hooks?await n.hooks.provideLexer():t?ue.lex:ue.lexInline)(r,n),l=n.hooks?await n.hooks.processAllTokens(c):c;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let h=await(n.hooks?await n.hooks.provideParser():t?de.parse:de.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(h):h})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let r=(n.hooks?n.hooks.provideLexer():t?ue.lex:ue.lexInline)(e,n);n.hooks&&(r=n.hooks.processAllTokens(r)),n.walkTokens&&this.walkTokens(r,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():t?de.parse:de.parseInline)(r,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(r){return i(r)}}}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>"+me(s.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(s);throw s}}},Ce=new fs;function q(t,e){return Ce.parse(t,e)}q.options=q.setOptions=function(t){return Ce.setOptions(t),q.defaults=Ce.defaults,os(q.defaults),q};q.getDefaults=ht;q.defaults=Te;q.use=function(...t){return Ce.use(...t),q.defaults=Ce.defaults,os(q.defaults),q};q.walkTokens=function(t,e){return Ce.walkTokens(t,e)};q.parseInline=Ce.parseInline;q.Parser=de;q.parser=de.parse;q.Renderer=et;q.TextRenderer=kt;q.Lexer=ue;q.lexer=ue.lex;q.Tokenizer=Ye;q.Hooks=Pe;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;de.parse;ue.lex;const $o=new fs({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=ae({__name:"InlineThinkingBlock",props:{isThinking:{type:Boolean},content:{},completed:{type:Boolean}},setup(t){const e=A(!1);return(s,o)=>t.isThinking||t.completed&&t.content?(g(),f("div",_o,[a("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?(g(),f("span",Co,[...o[1]||(o[1]=[a("span",{class:"absolute h-full w-full rounded-full border-2 border-[#a78bfa]/30"},null,-1),a("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),a("span",{class:"h-1.5 w-1.5 rounded-full bg-[#a78bfa]"},null,-1)])])):(g(),f("span",To,"💭")),a("span",null,u(t.isThinking?"Thinking...":"Thought process"),1),a("span",{class:P(["text-text-muted transition-transform",{"rotate-180":e.value}])},"▾",2)],2),e.value?(g(),f("div",Mo,[ze(u(t.content)+" ",1),t.isThinking?(g(),f("span",Ro,[...o[2]||(o[2]=[a("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),a("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),a("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=ae({__name:"AssistantTokenStream",props:{sessionId:{}},setup(t){const e=t,s=Qt(),{getColor:o}=Ws(Ds(e,"sessionId")),n=L(()=>s.getTokens(e.sessionId)),i=L(()=>{const r=n.value,c=[];let l=!1,h="";for(const d of r){if(h+=d.text,!l&&h.includes("<think>")){l=!0;const m=h.split("<think>")[0]??"";m&&c.length===0&&c.push({...d,text:m});continue}if(l){if(h.includes("</think>")){l=!1;const m=h.split("</think>").pop()??"",y=d.text;if(m.endsWith(y)&&y.includes("</think>")){const T=y.split("</think>").pop()??"";T&&c.push({...d,text:T})}}continue}c.push(d)}return c});return(r,c)=>(g(),f("div",zo,[(g(!0),f(W,null,Y(i.value,l=>(g(),f("span",{key:l.id,class:"inline",style:Ps({borderBottom:`2px solid ${b(o)(l.confidence)}`})},u(l.text),5))),128))]))}}),Eo={key:0,class:"mb-1.5 space-y-1.5"},jo=["src","alt","onClick"],Po={class:"mt-0.5 flex items-center gap-1.5 text-[10px] opacity-60"},Do={class:"truncate"},Io={class:"flex flex-wrap gap-1.5"},Fo={class:"max-w-[100px] truncate opacity-90"},Lo={class:"opacity-60"},Bo=["src"],Oo=ae({__name:"AttachmentBubble",props:{attachments:{}},setup(t){const e=A(null);function s(n){n.content&&(e.value=n.content)}function o(){e.value=null}return(n,i)=>t.attachments.length>0?(g(),f("div",Eo,[(g(!0),f(W,null,Y(t.attachments.filter(r=>r.type==="image"&&r.content),r=>(g(),f("div",{key:r.id},[a("img",{src:r.content,alt:r.name,class:"max-h-48 max-w-full cursor-pointer rounded-lg object-contain",onClick:c=>s(r)},null,8,jo),a("div",Po,[a("span",Do,u(r.name),1),a("span",null,u(b(at)(r.sizeBytes)),1)])]))),128)),a("div",Io,[(g(!0),f(W,null,Y(t.attachments.filter(r=>r.type==="document"),r=>(g(),f("div",{key:r.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[F(b(es),{class:"h-3.5 w-3.5 opacity-70"}),a("span",Fo,u(r.name),1),a("span",Lo,u(b(at)(r.sizeBytes)),1)]))),128))]),(g(),De(Is,{to:"body"},[F(Kt,{"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?(g(),f("div",{key:0,class:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:o},[a("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]=Ze(()=>{},["stop"]))},null,8,Bo),a("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},[F(b(tt),{class:"h-5 w-5"})])])):E("",!0)]),_:1})]))])):E("",!0)}}),qo={key:0,class:"mt-1 flex items-center gap-1 flex-wrap"},Vo=["title"],Uo=ae({__name:"QualityBadges",props:{report:{}},setup(t){const e=t,s=L(()=>e.report?e.report.checks.filter(n=>n.status!=="pass"):[]),o=L(()=>s.value.length>0);return(n,i)=>o.value?(g(),f("div",qo,[(g(!0),f(W,null,Y(s.value,r=>(g(),f("span",{key:r.detector,class:P(["inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium",r.status==="fail"?"bg-error/15 text-error":"bg-warning/15 text-warning"]),title:r.detail??n.$t(r.reason)},u(n.$t(`quality.${r.detector}.label`)),11,Vo))),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"},Jo=["title"],Qo=["title"],Xo={class:"text-[10px] opacity-50"},Yo=ae({__name:"ChatBubble",props:{message:{}},setup(t){const e=t,s=st(),o=Qs(),n=ut(),i=ns(),r=L(()=>i.getReport(e.message.id)),c=L(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),l=L(()=>e.message.sessionId?s.sessionById(e.message.sessionId)?.doneReason==="length":!1),h=L(()=>e.message.sessionId?o.getThinking(e.message.sessionId):{isThinking:!1,content:""}),d=L(()=>e.message.role==="user"),m=L(()=>c.value?c.value.loadDurationMs>500:!1),y=L(()=>{if(d.value){if(e.message.attachments?.length){const M=`
78
+
79
+ ---
80
+
81
+ `,_=e.message.content.lastIndexOf(M);if(_!==-1)return e.message.content.slice(_+M.length)}return e.message.content}return e.message.isStreaming?"":e.message.content.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}),T=L(()=>d.value||!y.value?"":So(y.value)),S=L(()=>new Date(e.message.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}));return(M,_)=>(g(),f("div",{class:P(["flex w-full",d.value?"justify-end":"justify-start"])},[a("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?(g(),f(W,{key:0},[t.message.attachments?.length?(g(),De(Oo,{key:0,attachments:t.message.attachments},null,8,["attachments"])):E("",!0),a("p",Ko,u(y.value),1)],64)):(g(),f(W,{key:1},[t.message.sessionId?(g(),De(Ao,{key:0,"is-thinking":h.value.isThinking,content:h.value.content,completed:!t.message.isStreaming},null,8,["is-thinking","content","completed"])):E("",!0),t.message.isStreaming&&t.message.sessionId?(g(),De(No,{key:1,"session-id":t.message.sessionId},null,8,["session-id"])):y.value?(g(),f("div",{key:2,class:"markdown-prose",innerHTML:T.value},null,8,Ho)):E("",!0),t.message.isStreaming&&!y.value?(g(),f("span",Wo,[..._[0]||(_[0]=[a("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),a("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),a("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&&!r.value?(g(),f("div",Go,u(M.$t("dashboard.bubble.truncatedWarning")),1)):E("",!0)],64)),!d.value&&!t.message.isStreaming&&c.value?(g(),f("div",Zo,[a("span",null,u(c.value.completionTokenCount)+" "+u(M.$t("dashboard.bubble.tokens")),1),_[2]||(_[2]=a("span",{class:"opacity-40"},"·",-1)),a("span",null,u(c.value.tokensPerSecond.toFixed(1))+" "+u(M.$t("dashboard.bubble.tokPerSec")),1),_[3]||(_[3]=a("span",{class:"opacity-40"},"·",-1)),a("span",null,u(c.value.ttftMs<1e3?c.value.ttftMs.toFixed(0)+"ms":(c.value.ttftMs/1e3).toFixed(1)+"s")+" "+u(M.$t("dashboard.bubble.ttft")),1),m.value?(g(),f(W,{key:0},[_[1]||(_[1]=a("span",{class:"opacity-40"},"·",-1)),a("span",{class:"text-warning",title:M.$t("dashboard.bubble.coldStart")},u(M.$t("dashboard.bubble.cold")),9,Jo)],64)):E("",!0),r.value&&r.value.overall!=="pass"?(g(),f("span",{key:1,class:P(["ml-1 inline-block h-1.5 w-1.5 rounded-full",r.value.overall==="fail"?"bg-error":"bg-warning"]),title:M.$t("quality.issuesDetected")},null,10,Qo)):E("",!0)])):E("",!0),F(Uo,{report:r.value},null,8,["report"]),a("div",{class:P(["mt-1",d.value?"text-end":""])},[a("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=ae({__name:"ChatMessageList",props:{messages:{}},setup(t,{expose:e}){const s=t,o=A(null);function n(){Fs(()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight)})}return oe(()=>s.messages.length,()=>n()),oe(()=>s.messages[s.messages.length-1]?.content,()=>n()),e({scrollToBottom:n}),(i,r)=>(g(),f("div",{ref_key:"containerRef",ref:o,class:"flex-1 overflow-y-auto px-4 py-6"},[a("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?(g(),f("div",ea,[a("div",ta,[r[0]||(r[0]=a("svg",{class:"mx-auto mb-4 h-20 w-20 text-text-muted/20",viewBox:"0 0 297.5 297.5"},[a("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)),r[1]||(r[1]=a("p",{class:"text-2xl font-semibold text-text-primary mb-2"},"LLMxRay",-1)),a("p",sa,u(i.$t("dashboard.empty.startConversation")),1)])])):E("",!0),(g(!0),f(W,null,Y(t.messages,c=>(g(),De(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 bs(t){return t.split(".").pop()?.toLowerCase()??""}function ct(t){return oa.has(bs(t))}function xs(t){return aa.has(bs(t))}function ra(t){return ct(t)||xs(t)}const ia=".pdf,.docx,.txt,.md,.csv,.png,.jpg,.jpeg,.gif,.webp",qt=8e3;function la(){const t=A([]),e=L(()=>t.value.some(c=>c.status==="parsing"));async function s(c){for(const l of c){if(!ra(l.name))continue;const h={id:we(),name:l.name,type:ct(l.name)?"image":"document",mimeType:l.type,sizeBytes:l.size,status:"pending"};t.value.push(h),ct(l.name)?o(l,h):xs(l.name)&&n(l,h)}}function o(c,l){l.status="parsing";const h=l.id,d=new FileReader;d.onload=()=>{const m=t.value.find(y=>y.id===h);m&&(m.content=d.result,m.status="ready")},d.onerror=()=>{const m=t.value.find(y=>y.id===h);m&&(m.error="Failed to read image",m.status="error")},d.readAsDataURL(c)}async function n(c,l){l.status="parsing";const h=l.id;try{const d=Ys(c.name);if(!d){const T=t.value.find(S=>S.id===h);T&&(T.error="Unsupported format",T.status="error");return}let m=await en(c,d);m.length>qt&&(m=m.slice(0,qt)+`
82
+
83
+ [... truncated]`);const y=t.value.find(T=>T.id===h);y&&(y.content=m,y.status="ready")}catch(d){const m=t.value.find(y=>y.id===h);m&&(m.error=d instanceof Error?d.message:"Parse failed",m.status="error")}}function i(c){t.value=t.value.filter(l=>l.id!==c)}function r(){t.value=[]}return{attachments:t,isProcessing:e,addFiles:s,removeAttachment:i,clearAttachments:r}}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=ae({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(t,{expose:e,emit:s}){const{t:o}=Ht(),n=t,i=s,r=A(0),c=L(()=>{if(!n.visible)return[];const m=n.filter.replace(/^\//,"");return m?vn(m):Object.values(ts()).flat()});oe(()=>n.filter,()=>{r.value=0});function l(m){return!n.visible||c.value.length===0?!1:m.key==="ArrowDown"?(m.preventDefault(),r.value=(r.value+1)%c.value.length,!0):m.key==="ArrowUp"?(m.preventDefault(),r.value=r.value<=0?c.value.length-1:r.value-1,!0):m.key==="Tab"||m.key==="Enter"&&c.value.length>0?(m.preventDefault(),i("select",c.value[r.value]),!0):m.key==="Escape"?(m.preventDefault(),i("close"),!0):!1}e({handleKeydown:l});const h=L(()=>({chat:o("dashboard.slashCommands.chatConversation"),settings:o("dashboard.slashCommands.modelSettings"),navigation:o("dashboard.slashCommands.featuresNavigation"),memory:o("dashboard.slashCommands.memory")}));function d(m){return m.descriptionKey?o(m.descriptionKey):m.description}return(m,y)=>t.visible&&c.value.length>0?(g(),f("div",ca,[a("div",ua,[(g(!0),f(W,null,Y(c.value,(T,S)=>(g(),f("button",{key:T.name,class:P(["flex w-full items-center gap-3 rounded-lg px-3 py-2 text-start text-sm transition-colors",S===r.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMouseenter:M=>r.value=S,onClick:M=>m.$emit("select",T)},[a("span",pa,"/"+u(T.name),1),a("span",ha,u(d(T)),1),a("span",ma,u(h.value[T.category]??T.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"},va={class:"max-w-[120px] truncate text-text-primary"},ya={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=ae({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(t){return(e,s)=>t.attachments.length>0?(g(),f("div",fa,[(g(!0),f(W,null,Y(t.attachments,o=>(g(),f("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?(g(),f("img",{key:0,src:o.content,alt:o.name,class:"h-6 w-6 rounded object-cover"},null,8,ba)):o.type==="document"?(g(),f("span",xa,[F(b(es),{class:"h-4 w-4"})])):E("",!0),a("span",va,u(o.name),1),a("span",ya,u(b(at)(o.sizeBytes)),1),o.status==="parsing"?(g(),f("span",ka)):o.status==="error"?(g(),f("span",wa,"!")):E("",!0),a("button",{class:"text-text-muted hover:text-error transition-colors","aria-label":"Remove attachment",onClick:n=>e.$emit("remove",o.id)},[F(b(tt),{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"],ja=["title"],Pa=["disabled","title"],Da=ae({__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:K});const n=dt(),i=A(""),r=A(null),c=A(null),l=A(null),h=A(!1),{attachments:d,isProcessing:m,addFiles:y,removeAttachment:T,clearAttachments:S}=la();Wt(()=>{n.fetchModels()});const M=L(()=>{const C=i.value;return C.startsWith("/")&&!C.includes(`
84
+ `)}),_=L(()=>{if(!M.value)return"";const C=i.value.indexOf(" ");return C===-1?i.value:i.value.slice(0,C)}),J=L(()=>{const C=i.value.trim().length>0,D=d.value.length>0;return(C||D)&&!m.value});function K(){r.value?.focus()}function B(C){M.value&&l.value&&l.value.handleKeydown(C)||C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),V())}function G(C){i.value=`/${C.name} `,r.value?.focus()}function V(){const C=i.value.trim();if(!(!C&&d.value.length===0)){if(C.startsWith("/")&&d.value.length===0){const D=C.indexOf(" "),te=D===-1?C.slice(1):C.slice(1,D),U=D===-1?"":C.slice(D+1);o("command",te,U)}else o("send",C,[...d.value]),S();i.value="",r.value&&(r.value.style.height="auto")}}function H(C){const D=C.target;D.style.height="auto",D.style.height=Math.min(D.scrollHeight,200)+"px"}function j(){i.value=""}function ie(){i.value="/",r.value?.focus()}function re(){c.value?.click()}function be(C){const D=C.target;D.files&&D.files.length>0&&(y(D.files),D.value="")}function xe(C){C.preventDefault(),h.value=!0}function ve(){h.value=!1}function ye(C){C.preventDefault(),h.value=!1,C.dataTransfer?.files&&C.dataTransfer.files.length>0&&y(C.dataTransfer.files)}function ge(C){const D=C.clipboardData?.items;if(!D)return;const te=[];for(const U of D)if(U.type.startsWith("image/")){const pe=U.getAsFile();pe&&te.push(pe)}te.length>0&&(C.preventDefault(),y(te))}return(C,D)=>(g(),f("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:xe,onDragleave:ve,onDrop:ye},[h.value?(g(),f("div",_a,[a("span",Ca,u(C.$t("dashboard.dropZone")),1)])):E("",!0),a("div",Ta,[F(ga,{ref_key:"dropdownRef",ref:l,filter:_.value,visible:M.value,onSelect:G,onClose:j},null,8,["filter","visible"])]),a("input",{ref_key:"fileInputRef",ref:c,type:"file",multiple:"",accept:b(ia),class:"hidden",onChange:be},null,40,Ma),a("div",Ra,[F(Sa,{attachments:b(d),onRemove:b(T)},null,8,["attachments","onRemove"]),a("div",{class:P(["flex items-end gap-2 p-1.5",{"pt-0":b(d).length>0}])},[a("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?C.$t("dashboard.input.attachFilesVision"):C.$t("dashboard.input.attachFiles"),onClick:re},[F(b(nn),{class:"h-4 w-4"}),t.isVisionModel?(g(),f("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:C.$t("dashboard.input.visionBadge")},[F(b(Ls),{class:"h-2.5 w-2.5","stroke-width":3})],8,za)):E("",!0)],8,Aa),a("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:C.$t("dashboard.input.commands"),onClick:ie},[F(b(an),{class:"h-4 w-4"})],8,Na),Z(a("textarea",{ref_key:"textareaRef",ref:r,"onUpdate:modelValue":D[0]||(D[0]=te=>i.value=te),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?C.$t("dashboard.input.placeholderVision"):C.$t("dashboard.input.placeholder"),onKeydown:B,onInput:H,onPaste:ge},null,40,Ea),[[X,i.value]]),t.isStreaming?(g(),f("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:C.$t("dashboard.input.stopGenerating"),onClick:D[1]||(D[1]=te=>C.$emit("cancel"))},[...D[2]||(D[2]=[a("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-white"},null,-1)])],8,ja)):(g(),f("button",{key:1,disabled:!J.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:C.$t("dashboard.input.sendMessage"),onClick:V},[F(b(on),{class:"h-4 w-4 rtl:-scale-x-100"})],8,Pa))],2)])],32))}}),Ia={class:"flex h-full flex-col overflow-y-auto"},Fa={class:"space-y-5 p-4 pb-12"},La={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Ba=["placeholder"],Oa={class:"mt-1 text-[10px] text-text-muted"},qa={key:0},Va={class:"mb-1.5 flex items-center justify-between"},Ua={class:"text-xs font-medium text-text-secondary"},Ka={class:"text-[10px] text-text-muted"},Ha={class:"flex gap-1 rounded-lg border border-border-default bg-surface p-1"},Wa={class:"mt-1 text-[10px] text-text-muted"},Ga={class:"mb-1.5 flex items-center justify-between"},Za={class:"text-xs font-medium text-text-secondary"},Ja={class:"text-[10px] text-text-muted"},Qa={value:"none"},Xa={value:"json"},Ya={value:"schema"},er={class:"mt-1 text-[10px] text-text-muted"},tr={key:0,class:"mt-2"},sr=["placeholder"],nr={key:0,class:"mt-1 text-[10px] text-error"},or={key:1,class:"mt-1 text-[10px] text-text-muted"},ar={class:"flex items-center justify-between"},rr={class:"flex items-center gap-2"},ir={class:"text-xs font-medium text-text-secondary"},lr=["disabled"],cr={key:1,class:"text-[10px] text-text-muted -mt-3"},ur={key:2,class:"text-[10px] text-text-muted -mt-3"},dr={class:"mb-1.5 flex items-center justify-between"},pr={class:"text-xs font-medium text-text-secondary"},hr={class:"text-xs text-text-muted"},mr={class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},gr={class:"mb-1.5 flex items-center justify-between"},fr={class:"text-xs font-medium text-text-secondary"},br={class:"text-xs text-text-muted"},xr=["placeholder"],vr={class:"mt-1 text-[10px] text-text-muted"},yr={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={class:"mt-1 text-[10px] text-text-muted"},Sr={key:3,class:"space-y-4 ps-1"},_r={class:"mb-1.5 flex items-center justify-between"},Cr={class:"text-xs font-medium text-text-secondary"},Tr={class:"text-xs text-text-muted"},Mr={class:"mt-1 text-[10px] text-text-muted"},Rr={class:"mb-1.5 flex items-center justify-between"},Ar={class:"text-xs font-medium text-text-secondary"},zr={class:"text-xs text-text-muted"},Nr={class:"mt-1 text-[10px] text-text-muted"},Er={class:"mb-1.5 flex items-center justify-between"},jr={class:"text-xs font-medium text-text-secondary"},Pr={class:"text-xs text-text-muted"},Dr={class:"mt-1 text-[10px] text-text-muted"},Ir={class:"mb-1.5 flex items-center justify-between"},Fr={class:"text-xs font-medium text-text-secondary"},Lr={class:"text-xs text-text-muted"},Br={value:0},Or={value:1},qr={value:2},Vr={class:"mt-1 text-[10px] text-text-muted"},Ur={class:"mb-1.5 flex items-center justify-between"},Kr={class:"text-xs font-medium text-text-secondary"},Hr={class:"text-xs text-text-muted"},Wr=["placeholder"],Gr={class:"mt-1 text-[10px] text-text-muted"},Zr={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Jr=["placeholder"],Qr={class:"mt-1 text-[10px] text-text-muted"},Xr={key:0,class:"ms-1 text-accent"},Yr={key:0,class:"ps-1 space-y-2"},ei={key:0,class:"space-y-1"},ti=["onClick"],si={key:1,class:"text-[10px] text-text-muted px-2"},ni={key:0,class:"ms-1 text-accent"},oi={key:5,class:"space-y-4 ps-1"},ai={class:"flex items-center justify-between"},ri={class:"text-xs font-medium text-text-secondary"},ii={class:"text-[10px] text-text-muted"},li={key:0},ci={class:"mb-1 flex items-center justify-between"},ui={class:"text-[10px] text-text-muted"},di={class:"text-[10px] text-text-muted"},pi={class:"flex items-center justify-between"},hi={class:"text-xs font-medium text-text-secondary"},mi={class:"text-[10px] text-text-muted"},gi={key:1},fi={class:"mb-1 flex items-center justify-between"},bi={class:"text-[10px] text-text-muted"},xi={class:"text-[10px] text-text-muted"},vi={class:"flex items-center justify-between"},yi={class:"text-xs font-medium text-text-secondary"},ki={class:"text-[10px] text-text-muted"},wi={key:2,class:"space-y-1"},$i={class:"flex-1 text-text-secondary"},Si=["onClick"],_i={class:"flex items-center justify-between"},Ci={class:"text-xs font-medium text-text-secondary"},Ti={class:"text-[10px] text-text-muted"},Mi={key:3,class:"space-y-2"},Ri={class:"mb-1 block text-[10px] text-text-muted"},Ai={value:"",disabled:""},zi=["value"],Ni={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},Ei={class:"mb-2 text-[10px] text-accent"},ji={class:"space-y-1.5"},Pi={class:"min-w-0 flex-1"},Di={class:"truncate text-[11px] font-mono text-text-primary"},Ii={class:"text-[9px] text-text-muted"},Fi=["disabled","onClick"],Li={key:0,class:"mt-2 text-[9px] text-text-muted"},Bi={class:"mb-1 flex items-center justify-between"},Oi={class:"text-[10px] text-text-muted"},qi={class:"text-[10px] text-text-muted"},Vi=ae({__name:"ChatSettingsPanel",props:{modelValue:{},selectedModel:{},ragEnabled:{type:Boolean}},emits:["update:modelValue","update:ragEnabled"],setup(t,{emit:e}){const s=t,o=e,n=A(s.modelValue.systemPrompt),i=A(s.modelValue.options.temperature??.7),r=A(s.modelValue.options.num_predict??-1),c=A(s.modelValue.options.num_ctx??4096),l=A(s.modelValue.options.top_p??.9),h=A(s.modelValue.options.top_k??40),d=A(s.modelValue.options.repeat_penalty??1.1),m=A(s.modelValue.options.seed??-1),y=A(s.modelValue.options.stop?.join(", ")??""),T=A(s.modelValue.options.mirostat??0);function S(p){return p==="max"?"max":p===!0?"on":"off"}function M(p){if(p==="max")return"max";if(p==="on")return!0}const _=A(S(s.modelValue.think));function J(p){return p==="json"?"json":p&&typeof p=="object"?"schema":"none"}const K=A(J(s.modelValue.format)),B=A(s.modelValue.format&&typeof s.modelValue.format=="object"?JSON.stringify(s.modelValue.format,null,2):`{
85
+ "type": "object",
86
+ "properties": {
87
+ "answer": { "type": "string" }
88
+ },
89
+ "required": ["answer"]
90
+ }`),G=A(null);oe(()=>s.modelValue.options,p=>{i.value=p.temperature??.7,r.value=p.num_predict??-1,c.value=p.num_ctx??4096,l.value=p.top_p??.9,h.value=p.top_k??40,d.value=p.repeat_penalty??1.1,m.value=p.seed??-1,y.value=p.stop?.join(", ")??"",T.value=p.mirostat??0},{deep:!0}),oe([n,i,r,c,l,h,d,m,y,T,_,K,B],()=>{const p=y.value.split(",").map(x=>x.trim()).filter(Boolean);let v;if(K.value==="json")v="json";else if(K.value==="schema")try{const x=JSON.parse(B.value);typeof x=="object"&&x!==null?(v=x,G.value=null):G.value="Schema must be a JSON object"}catch(x){G.value=x instanceof Error?x.message:"Invalid JSON"}else v=void 0,G.value=null;o("update:modelValue",{systemPrompt:n.value,options:{temperature:i.value,num_predict:r.value===-1?void 0:r.value,num_ctx:c.value,top_p:l.value,top_k:h.value,repeat_penalty:d.value,seed:m.value===-1?void 0:m.value,stop:p.length>0?p:void 0,mirostat:T.value},think:M(_.value),format:v})},{deep:!0}),oe(()=>s.modelValue,p=>{n.value=p.systemPrompt,i.value=p.options.temperature??.7,r.value=p.options.num_predict??-1,c.value=p.options.num_ctx??4096,l.value=p.options.top_p??.9,h.value=p.options.top_k??40,d.value=p.options.repeat_penalty??1.1,m.value=p.options.seed??-1,T.value=p.options.mirostat??0,_.value=S(p.think),K.value=J(p.format),p.format&&typeof p.format=="object"&&(B.value=JSON.stringify(p.format,null,2))});const V=pt(),H=Gt(),j=ss(),ie=dt(),re=Xt(),be=L(()=>ie.supportsTools(s.selectedModel)),xe=L(()=>ie.isThinkingModel(s.selectedModel));oe(()=>s.selectedModel,p=>{p&&!ie.supportsTools(p)&&V.enabledTools.length>0&&V.disableAll()});const ve=A(!1),ye=A(!1),ge=A(!1),C=A(!1),D=A(""),te=A(""),U=[{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 pe(p){C.value=!0,te.value=p,D.value="Starting download...";try{await Le.pullModel(p,(v,x,$e)=>{if(x&&$e){const Oe=Math.round(x/$e*100);D.value=`${v} ${Oe}%`}else D.value=v}),D.value="Done!",await ie.fetchModels(),j.settings.ragMemory.embeddingModel=p}catch(v){D.value=`Failed: ${v instanceof Error?v.message:"Unknown error"}`}finally{C.value=!1,setTimeout(()=>{D.value="",te.value=""},3e3)}}return(p,v)=>(g(),f("div",Ia,[a("div",Fa,[a("div",null,[a("label",La,u(p.$t("dashboard.settings.systemPrompt")),1),Z(a("textarea",{"onUpdate:modelValue":v[0]||(v[0]=x=>n.value=x),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:p.$t("dashboard.settings.systemPromptPlaceholder")},null,8,Ba),[[X,n.value]]),a("p",Oa,u(p.$t("dashboard.settings.systemPromptHint")),1)]),xe.value?(g(),f("div",qa,[a("div",Va,[a("label",Ua,u(p.$t("dashboard.settings.thinking.label")),1),a("span",Ka,u(p.$t("dashboard.settings.thinking.modelSupportsHint")),1)]),a("div",Ha,[a("button",{type:"button",class:P(["flex-1 rounded-md px-2 py-1 text-[11px] font-medium transition-colors",_.value==="off"?"bg-accent text-surface":"text-text-secondary hover:bg-surface-overlay"]),onClick:v[1]||(v[1]=x=>_.value="off")},u(p.$t("dashboard.settings.thinking.off")),3),a("button",{type:"button",class:P(["flex-1 rounded-md px-2 py-1 text-[11px] font-medium transition-colors",_.value==="on"?"bg-accent text-surface":"text-text-secondary hover:bg-surface-overlay"]),onClick:v[2]||(v[2]=x=>_.value="on")},u(p.$t("dashboard.settings.thinking.on")),3),a("button",{type:"button",class:P(["flex-1 rounded-md px-2 py-1 text-[11px] font-medium transition-colors",_.value==="max"?"bg-accent text-surface":"text-text-secondary hover:bg-surface-overlay"]),onClick:v[3]||(v[3]=x=>_.value="max")},u(p.$t("dashboard.settings.thinking.max")),3)]),a("p",Wa,u(p.$t("dashboard.settings.thinking.hint")),1)])):E("",!0),a("div",null,[a("div",Ga,[a("label",Za,u(p.$t("dashboard.settings.responseFormat.label")),1),a("span",Ja,u(K.value==="none"?p.$t("dashboard.settings.responseFormat.freeForm"):K.value==="json"?"JSON":"JSON Schema"),1)]),Z(a("select",{"onUpdate:modelValue":v[4]||(v[4]=x=>K.value=x),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"},[a("option",Qa,u(p.$t("dashboard.settings.responseFormat.none")),1),a("option",Xa,u(p.$t("dashboard.settings.responseFormat.json")),1),a("option",Ya,u(p.$t("dashboard.settings.responseFormat.schema")),1)],512),[[He,K.value]]),a("p",er,u(p.$t("dashboard.settings.responseFormat.hint")),1),K.value==="schema"?(g(),f("div",tr,[Z(a("textarea",{"onUpdate:modelValue":v[5]||(v[5]=x=>B.value=x),rows:"6",spellcheck:"false",class:"w-full resize-y rounded-lg border border-border-default bg-surface px-3 py-2 font-mono text-[11px] text-text-primary outline-none focus:border-accent",placeholder:p.$t("dashboard.settings.responseFormat.schemaPlaceholder")},null,8,sr),[[X,B.value]]),G.value?(g(),f("p",nr,u(G.value),1)):(g(),f("p",or,u(p.$t("dashboard.settings.responseFormat.schemaHint")),1))])):E("",!0)]),a("div",ar,[a("div",rr,[a("span",ir,u(p.$t("dashboard.settings.knowledgeBase")),1),a("span",{class:P(["rounded-full px-1.5 py-0.5 text-[9px] font-medium",t.ragEnabled&&b(re).readyDocuments.length>0?"bg-accent/10 text-accent":"bg-surface-overlay text-text-muted"])},u(t.ragEnabled&&b(re).readyDocuments.length>0?p.$t("dashboard.settings.kbEnabled"):p.$t("dashboard.settings.kbDisabled")),3)]),a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",t.ragEnabled&&b(re).readyDocuments.length>0?"bg-accent":"bg-surface-overlay"]),disabled:b(re).readyDocuments.length===0,onClick:v[6]||(v[6]=x=>o("update:ragEnabled",!t.ragEnabled))},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",t.ragEnabled&&b(re).readyDocuments.length>0?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,lr)]),b(re).readyDocuments.length>0?(g(),f("p",cr,[ze(u(b(re).enabledDocuments.length)+"/"+u(b(re).readyDocuments.length)+" "+u(p.$t("dashboard.settings.documents"))+" · ",1),a("button",{class:"text-accent hover:underline",onClick:v[7]||(v[7]=x=>b(H).push("/rag"))},u(p.$t("dashboard.settings.manage")),1)])):(g(),f("p",ur,[ze(u(p.$t("dashboard.settings.noDocumentsIngested"))+" · ",1),a("button",{class:"text-accent hover:underline",onClick:v[8]||(v[8]=x=>b(H).push("/rag"))},u(p.$t("dashboard.settings.addDocuments")),1)])),a("div",null,[a("div",dr,[a("label",pr,u(p.$t("dashboard.settings.temperature")),1),a("span",hr,u(i.value.toFixed(2)),1)]),Z(a("input",{"onUpdate:modelValue":v[9]||(v[9]=x=>i.value=x),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[X,i.value,void 0,{number:!0}]]),a("div",mr,[a("span",null,u(p.$t("dashboard.settings.precise")),1),a("span",null,u(p.$t("dashboard.settings.creative")),1)])]),a("div",null,[a("div",gr,[a("label",fr,u(p.$t("dashboard.settings.maxTokens")),1),a("span",br,u(r.value===-1?p.$t("dashboard.settings.unlimited"):r.value),1)]),Z(a("input",{"onUpdate:modelValue":v[10]||(v[10]=x=>r.value=x),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:p.$t("dashboard.settings.maxTokensPlaceholder")},null,8,xr),[[X,r.value,void 0,{number:!0}]]),a("p",vr,u(p.$t("dashboard.settings.maxTokensHint")),1)]),a("div",null,[a("div",yr,[a("label",kr,u(p.$t("dashboard.settings.contextWindow")),1),a("span",wr,u(c.value.toLocaleString()),1)]),Z(a("select",{"onUpdate:modelValue":v[11]||(v[11]=x=>c.value=x),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"},[...v[30]||(v[30]=[a("option",{value:2048},"2,048",-1),a("option",{value:4096},"4,096",-1),a("option",{value:8192},"8,192",-1),a("option",{value:16384},"16,384",-1),a("option",{value:32768},"32,768",-1),a("option",{value:65536},"65,536",-1),a("option",{value:131072},"131,072",-1)])],512),[[He,c.value,void 0,{number:!0}]]),a("p",$r,u(p.$t("dashboard.settings.contextWindowHint")),1)]),a("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:v[12]||(v[12]=x=>ve.value=!ve.value)},[a("span",null,u(p.$t("dashboard.settings.advancedSampling")),1),a("span",{class:P(["transition-transform",{"rotate-180":ve.value}])},"▾",2)]),ve.value?(g(),f("div",Sr,[a("div",null,[a("div",_r,[a("label",Cr,u(p.$t("dashboard.settings.topP")),1),a("span",Tr,u(l.value.toFixed(2)),1)]),Z(a("input",{"onUpdate:modelValue":v[13]||(v[13]=x=>l.value=x),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[X,l.value,void 0,{number:!0}]]),a("p",Mr,u(p.$t("dashboard.settings.topPHint")),1)]),a("div",null,[a("div",Rr,[a("label",Ar,u(p.$t("dashboard.settings.topK")),1),a("span",zr,u(h.value),1)]),Z(a("input",{"onUpdate:modelValue":v[14]||(v[14]=x=>h.value=x),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[X,h.value,void 0,{number:!0}]]),a("p",Nr,u(p.$t("dashboard.settings.topKHint")),1)]),a("div",null,[a("div",Er,[a("label",jr,u(p.$t("dashboard.settings.repeatPenalty")),1),a("span",Pr,u(d.value.toFixed(2)),1)]),Z(a("input",{"onUpdate:modelValue":v[15]||(v[15]=x=>d.value=x),type:"range",min:"1.0",max:"2.0",step:"0.05",class:"w-full accent-accent"},null,512),[[X,d.value,void 0,{number:!0}]]),a("p",Dr,u(p.$t("dashboard.settings.repeatPenaltyHint")),1)]),a("div",null,[a("div",Ir,[a("label",Fr,u(p.$t("dashboard.settings.mirostat")),1),a("span",Lr,u(T.value===0?p.$t("dashboard.settings.mirostatOff"):`v${T.value}`),1)]),Z(a("select",{"onUpdate:modelValue":v[16]||(v[16]=x=>T.value=x),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"},[a("option",Br,u(p.$t("dashboard.settings.mirostatDisabled")),1),a("option",Or,u(p.$t("dashboard.settings.mirostatV1")),1),a("option",qr,u(p.$t("dashboard.settings.mirostatV2")),1)],512),[[He,T.value,void 0,{number:!0}]]),a("p",Vr,u(p.$t("dashboard.settings.mirostatHint")),1)]),a("div",null,[a("div",Ur,[a("label",Kr,u(p.$t("dashboard.settings.seed")),1),a("span",Hr,u(m.value===-1?p.$t("dashboard.settings.seedRandom"):m.value),1)]),Z(a("input",{"onUpdate:modelValue":v[17]||(v[17]=x=>m.value=x),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:p.$t("dashboard.settings.seedPlaceholder")},null,8,Wr),[[X,m.value,void 0,{number:!0}]]),a("p",Gr,u(p.$t("dashboard.settings.seedHint")),1)]),a("div",null,[a("label",Zr,u(p.$t("dashboard.settings.stopSequences")),1),Z(a("input",{"onUpdate:modelValue":v[18]||(v[18]=x=>y.value=x),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:p.$t("dashboard.settings.stopSequencesPlaceholder")},null,8,Jr),[[X,y.value]]),a("p",Qr,u(p.$t("dashboard.settings.stopSequencesHint")),1)])])):E("",!0),be.value?(g(),f(W,{key:4},[a("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:v[19]||(v[19]=x=>ye.value=!ye.value)},[a("span",null,[ze(u(p.$t("dashboard.settings.tools"))+" ",1),b(V).enabledDefinitions.length>0?(g(),f("span",Xr," ("+u(b(V).enabledDefinitions.length)+" "+u(p.$t("dashboard.settings.active"))+") ",1)):E("",!0)]),a("span",{class:P(["transition-transform",{"rotate-180":ye.value}])},"▾",2)]),ye.value?(g(),f("div",Yr,[b(V).allTools.length>0?(g(),f("div",ei,[(g(!0),f(W,null,Y(b(V).allTools,x=>(g(),f("div",{key:x.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1.5 text-[11px]"},[a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",x.enabled?"bg-accent":"bg-surface-overlay"]),onClick:$e=>b(V).toggleEnabled(x.id)},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",x.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,ti),a("span",{class:P(["font-mono",x.enabled?"text-text-primary":"text-text-muted"])},u(x.definition.function.name),3)]))),128))])):(g(),f("p",si,u(p.$t("dashboard.settings.noToolsDefined")),1)),a("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:v[20]||(v[20]=x=>b(H).push("/tools"))},u(p.$t("dashboard.settings.manageInToolWorkshop")),1)])):E("",!0)],64)):E("",!0),a("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:v[21]||(v[21]=x=>ge.value=!ge.value)},[a("span",null,[ze(u(p.$t("dashboard.memory.memory"))+" ",1),b(j).factCount>0?(g(),f("span",ni," ("+u(b(j).factCount)+" "+u(p.$t("dashboard.memory.facts"))+") ",1)):E("",!0)]),a("span",{class:P(["transition-transform",{"rotate-180":ge.value}])},"▾",2)]),ge.value?(g(),f("div",oi,[a("div",ai,[a("div",null,[a("p",ri,u(p.$t("dashboard.memory.slidingWindow")),1),a("p",ii,u(p.$t("dashboard.memory.slidingWindowHint")),1)]),a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.slidingWindow.enabled?"bg-accent":"bg-surface-overlay"]),onClick:v[22]||(v[22]=x=>b(j).settings.slidingWindow.enabled=!b(j).settings.slidingWindow.enabled)},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(j).settings.slidingWindow.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(j).settings.slidingWindow.enabled?(g(),f("div",li,[a("div",ci,[a("label",ui,u(p.$t("dashboard.memory.maxMessages")),1),a("span",di,u(b(j).settings.slidingWindow.maxMessages),1)]),Z(a("input",{"onUpdate:modelValue":v[23]||(v[23]=x=>b(j).settings.slidingWindow.maxMessages=x),type:"range",min:"10",max:"200",step:"10",class:"w-full accent-accent"},null,512),[[X,b(j).settings.slidingWindow.maxMessages,void 0,{number:!0}]])])):E("",!0),a("div",pi,[a("div",null,[a("p",hi,u(p.$t("dashboard.memory.autoSummarize")),1),a("p",mi,u(p.$t("dashboard.memory.autoSummarizeHint")),1)]),a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.autoSummarize.enabled?"bg-accent":"bg-surface-overlay"]),onClick:v[24]||(v[24]=x=>b(j).settings.autoSummarize.enabled=!b(j).settings.autoSummarize.enabled)},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(j).settings.autoSummarize.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(j).settings.autoSummarize.enabled?(g(),f("div",gi,[a("div",fi,[a("label",bi,u(p.$t("dashboard.memory.triggerAfter")),1),a("span",xi,u(b(j).settings.autoSummarize.triggerThreshold)+" "+u(p.$t("dashboard.memory.messages")),1)]),Z(a("input",{"onUpdate:modelValue":v[25]||(v[25]=x=>b(j).settings.autoSummarize.triggerThreshold=x),type:"range",min:"10",max:"100",step:"5",class:"w-full accent-accent"},null,512),[[X,b(j).settings.autoSummarize.triggerThreshold,void 0,{number:!0}]])])):E("",!0),a("div",vi,[a("div",null,[a("p",yi,u(p.$t("dashboard.memory.userMemories")),1),a("p",ki,u(p.$t("dashboard.memory.userMemoriesHint")),1)]),a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.userFacts.enabled?"bg-accent":"bg-surface-overlay"]),onClick:v[26]||(v[26]=x=>b(j).settings.userFacts.enabled=!b(j).settings.userFacts.enabled)},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(j).settings.userFacts.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(j).settings.userFacts.enabled&&b(j).facts.length>0?(g(),f("div",wi,[(g(!0),f(W,null,Y(b(j).facts,x=>(g(),f("div",{key:x.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1 text-[11px]"},[a("span",$i,u(x.content),1),a("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:$e=>b(j).removeFact(x.id)},[F(b(tt),{class:"h-3 w-3"})],8,Si)]))),128))])):E("",!0),a("div",_i,[a("div",null,[a("p",Ci,u(p.$t("dashboard.memory.messageMemoryRag")),1),a("p",Ti,u(p.$t("dashboard.memory.messageMemoryHint")),1)]),a("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.ragMemory.enabled?"bg-accent":"bg-surface-overlay"]),onClick:v[27]||(v[27]=x=>b(j).settings.ragMemory.enabled=!b(j).settings.ragMemory.enabled)},[a("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",b(j).settings.ragMemory.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),b(j).settings.ragMemory.enabled?(g(),f("div",Mi,[a("div",null,[a("label",Ri,u(p.$t("dashboard.memory.embeddingModel")),1),Z(a("select",{"onUpdate:modelValue":v[28]||(v[28]=x=>b(j).settings.ragMemory.embeddingModel=x),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"},[a("option",Ai,u(p.$t("dashboard.memory.selectEmbeddingModel")),1),(g(!0),f(W,null,Y(b(ie).embeddingModelNames,x=>(g(),f("option",{key:x,value:x},u(x)+" "+u(b(ie).capabilityIcons(x)),9,zi))),128))],512),[[He,b(j).settings.ragMemory.embeddingModel]])]),b(ie).embeddingModelNames.length===0?(g(),f("div",Ni,[a("p",Ei,u(p.$t("dashboard.memory.noEmbeddingModels")),1),a("div",ji,[(g(),f(W,null,Y(U,x=>a("div",{key:x.name,class:"flex items-center gap-2"},[a("div",Pi,[a("p",Di,u(x.name),1),a("p",Ii,u(x.description)+" ("+u(x.size)+")",1)]),a("button",{disabled:C.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:$e=>pe(x.name)},u(C.value&&te.value===x.name?p.$t("dashboard.settings.pulling"):p.$t("dashboard.settings.pull")),9,Fi)])),64))]),D.value?(g(),f("p",Li,u(D.value),1)):E("",!0)])):E("",!0),a("div",null,[a("div",Bi,[a("label",Oi,u(p.$t("dashboard.memory.retrieveTop")),1),a("span",qi,u(b(j).settings.ragMemory.topK)+" "+u(p.$t("dashboard.memory.messages")),1)]),Z(a("input",{"onUpdate:modelValue":v[29]||(v[29]=x=>b(j).settings.ragMemory.topK=x),type:"range",min:"1",max:"10",step:"1",class:"w-full accent-accent"},null,512),[[X,b(j).settings.ragMemory.topK,void 0,{number:!0}]])])])):E("",!0)])):E("",!0)])]))}}),Ui={class:"flex h-full flex-col"},Ki={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"},Hi={class:"flex items-start gap-3"},Wi={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},Gi={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},Zi={class:"flex items-center gap-3"},Ji={class:"relative"},Qi={key:0,class:"text-text-muted"},Xi={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"},Yi=["onMousedown"],el={key:0,class:"flex items-center"},tl=["title"],sl={class:"truncate"},nl={class:"flex items-center gap-2"},ol={class:"relative"},al={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"},rl={class:"flex flex-1 min-h-0"},il={key:0,class:"w-64 shrink-0 border-e border-border-default bg-surface-raised flex flex-col"},ll={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},cl={class:"text-xs font-medium text-text-secondary"},ul={class:"flex-1 overflow-y-auto p-2"},dl={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},pl={key:1,class:"space-y-0.5"},hl=["onClick"],ml={key:0,class:"flex-1 min-w-0"},gl=["onBlur","onKeydown"],fl={class:"flex-1 min-w-0"},bl={class:"truncate text-[11px]"},xl={class:"truncate text-[9px] text-text-muted"},vl={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},yl=["title","onClick"],kl=["title","onClick"],wl={class:"flex flex-1 flex-col min-w-0"},$l={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"},Sl={class:"font-medium"},_l={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"},Tl={class:"text-xs font-medium text-text-secondary"},Ml=ae({__name:"ChatConversation",setup(t){const{t:e}=Ht(),s=Gt(),o=Zt(),n=dt(),i=st(),r=Xt(),c=ut(),l=pt(),h=ss(),d=Qt(),m=ns(),{isStreaming:y,currentSessionId:T,startChatStream:S,cancel:M}=xn(),_=A(""),J=A(!1);function K(){setTimeout(()=>{J.value=!1},150)}const B=A(!0),G=A(!1),V=A(!1),H=A(!1);function j(){const k=v.value;if(!k||k.messages.length===0)return;const $=JSON.stringify(k.messages,null,2),w=new Blob([$],{type:"application/json"}),N=URL.createObjectURL(w),z=document.createElement("a");z.href=N,z.download=`chat-${k.id}.json`,z.click(),URL.revokeObjectURL(N),H.value=!1}function ie(){const k=v.value;if(!k||k.messages.length===0)return;const $=k.messages.map(se=>{const ke=se.role.charAt(0).toUpperCase()+se.role.slice(1),le=new Date(se.timestamp).toLocaleString();return`### ${ke}
91
+ *${le}*
92
+
93
+ ${se.content}`}),w=`# Chat Export — ${k.name}
94
+
95
+ ${$.join(`
96
+
97
+ ---
98
+
99
+ `)}
100
+
101
+ ---
102
+ *Generated by LLMxRay — Local LLM Observatory*
103
+ `,N=new Blob([w],{type:"text/markdown"}),z=URL.createObjectURL(N),O=document.createElement("a");O.href=z,O.download=`chat-${k.id}.md`,O.click(),URL.revokeObjectURL(z),H.value=!1}function re(){const k=v.value;if(!k||k.messages.length===0)return;const $=k.messages.map(O=>`[${O.role}] ${O.content}`).join(`
104
+
105
+ `),w=new Blob([$],{type:"text/plain"}),N=URL.createObjectURL(w),z=document.createElement("a");z.href=N,z.download=`chat-${k.id}.txt`,z.click(),URL.revokeObjectURL(N),H.value=!1}const be=A(null),xe=A("");function ve(k){o.setActiveConversation(k)}function ye(k,$){be.value=k,xe.value=$}function ge(k){const $=xe.value.trim();$&&o.renameConversation(k,$),be.value=null}function C(){be.value=null}function D(k,$){k.key==="Enter"?ge($):k.key==="Escape"&&C()}function te(k){const w=Date.now()-k,N=Math.floor(w/6e4);if(N<1)return e("common.time.justNow");if(N<60)return e("dashboard.conversation.minutesAgo",{n:N});const z=Math.floor(N/60);if(z<24)return e("dashboard.conversation.hoursAgo",{n:z});const O=Math.floor(z/24);return O<7?e("dashboard.conversation.daysAgo",{n:O}):new Date(k).toLocaleDateString()}const U=A({systemPrompt:"",options:{}}),pe=A(null);let p=null;const v=L(()=>o.activeConversation),x=L(()=>v.value?.messages??[]),$e=L(()=>n.isVisionModel(_.value)),Oe=L(()=>{const k=Me.value??T.value;if(!k)return null;const $=i.sessionById(k);return $?.status==="error"&&$.error?$.error:null}),Me=L(()=>{const k=x.value;for(let $=k.length-1;$>=0;$--)if(k[$].sessionId)return k[$].sessionId;return null}),Re=A(e("dashboard.conversation.untitled")),Ne=A(!1),qe=A(""),wt=L(()=>v.value?.name??Re.value);function vs(){qe.value=wt.value,Ne.value=!0}function $t(){const k=qe.value.trim();if(!k){Ne.value=!1;return}v.value?o.renameConversation(v.value.id,k):Re.value=k,Ne.value=!1}function ys(){Ne.value=!1}function ks(k){k.key==="Enter"?$t():k.key==="Escape"&&ys()}Wt(async()=>{await n.fetchModels(),n.chatModelNames.length>0&&!_.value&&(_.value=n.chatModelNames[0]),await r.loadDocuments()}),oe(_,k=>{if(!k)return;const $=n.getModelDefaults(k);Object.keys($).length>0&&(U.value={systemPrompt:U.value.systemPrompt,options:{...$}})}),oe(()=>o.activeConversationId,async k=>{if(!k)return;const $=o.conversations.get(k);if($){$.model&&n.chatModelNames.includes($.model)&&(_.value=$.model);try{const w=await qs.getSessionsByConversation(k);for(const N of w)i.sessionById(N.id)||(i.sessions.set(N.id,{id:N.id,mode:N.mode,model:N.model,status:N.status,createdAt:N.createdAt,prompt:N.prompt,messages:N.messages,options:N.options,outputText:N.outputText,metrics:N.metrics,error:N.error,doneReason:N.doneReason}),i.linkSessionToConversation(N.id,k)),await d.loadTokens(N.id)}catch(w){console.error("Failed to restore sessions for conversation:",w)}}});async function St(k,$=[]){if(!_.value)return;let w=o.activeConversationId;w||(w=o.createConversation(_.value),Re.value!==e("dashboard.conversation.untitled")&&o.renameConversation(w,Re.value),Re.value=e("dashboard.conversation.untitled"));const N=o.conversations.get(w);N&&N.model!==_.value&&(N.model=_.value);const z=$.filter(Q=>Q.type==="document"&&Q.content),O=$.filter(Q=>Q.type==="image"&&Q.content);let se=k;z.length>0&&(se=z.map(ne=>`[Attached: ${ne.name}]
106
+ ${ne.content}`).join(`
107
+
108
+ `)+`
109
+
110
+ ---
111
+
112
+ `+k);const ke={id:we(),conversationId:w,role:"user",content:se,timestamp:Date.now(),isStreaming:!1,attachments:$.length>0?$:void 0};o.addMessage(w,ke);const le=we(),Ve={id:le,conversationId:w,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};o.addMessage(w,Ve);const fe=o.getMessagesAsOllamaFormat(w).slice(0,-1);if(O.length>0){const Q=[...fe].reverse().find(ne=>ne.role==="user");Q&&(Q.images=O.map(ne=>ne.content.replace(/^data:[^;]+;base64,/,"")))}if(U.value.systemPrompt.trim()&&fe.unshift({role:"system",content:U.value.systemPrompt.trim()}),B.value&&r.enabledDocuments.length>0)try{const Q=await r.getContextForQuery(k,_.value,5);Q&&fe.unshift({role:"system",content:Q})}catch{}let _t=fe;try{const Q=h.getSummary(w)?.summary,ne=await An({conversationId:w,messages:fe,model:_.value,settings:h.settings,userFactsPrompt:h.getFactsAsSystemPrompt(),existingSummary:Q});if(_t=ne.messages,ne.newSummary){const ce=fe.filter(Ct=>Ct.role!=="system");h.setSummary(w,ne.newSummary,ce.length)}}catch{}try{const Q={...v.value?.options,...U.value.options},ne=l.enabledDefinitions,ce=await S(_.value,_t,Q,ne.length>0?ne:void 0,{think:n.isThinkingModel(_.value)?U.value.think:void 0,format:U.value.format}),Tt=o.conversations.get(w)?.messages.find(he=>he.id===le);Tt&&(Tt.sessionId=ce),i.linkSessionToConversation(ce,w);const Ms=oe(()=>i.sessionById(ce)?.outputText,he=>{he!==void 0&&o.updateAssistantContent(w,le,he)}),Mt=w,Rs=k,As=oe(()=>i.sessionById(ce)?.status,he=>{if(he==="completed"||he==="error"||he==="cancelled"){if(o.finalizeMessage(Mt,le),y.value=!1,Ms(),As(),d.persistTokens(ce),he==="completed"){const Ke=i.sessionById(ce),zs=(Ke?.outputText??"").replace(/<think>[\s\S]*?<\/think>/g,"").trim(),Ns=c.getMetrics(ce),Es=Rn(le,ce,zs,Ns?.completionTokenCount??0,U.value.options.num_predict,Ke?.doneReason);m.setReport(le,Es)}if(he==="completed"&&h.settings.ragMemory.enabled&&h.settings.ragMemory.embeddingModel){const Ke=i.sessionById(ce)?.outputText??"";zn(Mt,[{role:"user",content:Rs,timestamp:ke.timestamp},{role:"assistant",content:Ke,timestamp:Date.now()}],h.settings.ragMemory.embeddingModel).catch(()=>{})}}})}catch{o.finalizeMessage(w,le)}}function ws(){M()}function $s(){o.setActiveConversation(null),Re.value=e("dashboard.conversation.untitled")}function Ss(k){s.push({name:"session",params:{id:k}})}function Se(k){pe.value=k,p&&clearTimeout(p),p=setTimeout(()=>{pe.value=null},5e3)}function _s(){pe.value=null,p&&clearTimeout(p)}const Cs={systemPrompt:"",options:{}};async function Ts(k,$){const w=yn(k);if(!w){Se(e("dashboard.slashCommands.notifications.unknownCommand",{name:k}));return}const N={clearConversation:()=>o.setActiveConversation(null),newChat:()=>o.setActiveConversation(null),sendAsUser:z=>St(z),copyLastResponse:()=>{const z=x.value.filter(se=>se.role==="assistant"),O=z[z.length-1];O?.content?(navigator.clipboard.writeText(O.content),Se(e("dashboard.slashCommands.notifications.copiedToClipboard"))):Se(e("dashboard.slashCommands.notifications.noAssistantResponseToCopy"))},exportConversation:z=>{const O=v.value;if(!O||O.messages.length===0){Se(e("dashboard.slashCommands.notifications.noConversationToExport"));return}let se,ke;z==="json"?(se=JSON.stringify(O.messages,null,2),ke=`chat-${O.id}.json`):(se=O.messages.map(fe=>`[${fe.role}] ${fe.content}`).join(`
113
+
114
+ `),ke=`chat-${O.id}.txt`);const le=new Blob([se],{type:"text/plain"}),Ve=URL.createObjectURL(le),Ue=document.createElement("a");Ue.href=Ve,Ue.download=ke,Ue.click(),URL.revokeObjectURL(Ve)},setSystemPrompt:z=>{U.value={...U.value,systemPrompt:z}},setOption:(z,O)=>{U.value={...U.value,options:{...U.value.options,[z]:O}}},resetSettings:()=>{U.value={...Cs}},setJsonFormat:z=>{Se(e("dashboard.slashCommands.notifications.jsonFormatToggled"))},switchModel:z=>{_.value=z},availableModels:n.chatModelNames,currentModel:_.value,toggleRag:()=>{B.value=!B.value},ragEnabled:B.value,navigate:z=>s.push(z),openSettings:()=>{G.value=!0},openSessionDetails:()=>{const z=Me.value;z?s.push({name:"session",params:{id:z}}):Se(e("dashboard.slashCommands.notifications.noActiveSession"))},addFact:z=>h.addFact(z),removeFact:z=>h.removeFactByContent(z),getFacts:()=>h.facts,showNotification:Se,messages:x.value,chatSettings:U,currentSessionId:Me.value??T.value,getSessionTokenCount:()=>{const z=Me.value??T.value;if(!z)return null;const O=c.getMetrics(z);return O?{prompt:O.promptTokenCount,completion:O.completionTokenCount}:null},getAverageSpeed:()=>{const z=c.aggregate;return z.totalSessions>0?z.avgTps:null},getOllamaStatus:async()=>{try{return{connected:(await fetch("/api/tags")).ok,model:_.value}}catch{return{connected:!1,model:_.value}}},t:(z,O)=>e(z,O??{})};await w.execute($,N)}return(k,$)=>(g(),f("div",Ui,[F(Kt,{"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(()=>[pe.value?(g(),f("div",Ki,[a("div",Hi,[a("p",Wi,u(pe.value),1),a("button",{class:"shrink-0 text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Dismiss notification",onClick:_s}," ✕ ")])])):E("",!0)]),_:1}),a("div",Gi,[a("div",Zi,[a("div",Ji,[a("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=>J.value=!J.value),onBlur:K},[_.value?(g(),f(W,{key:1},[a("span",null,u(_.value),1),F(Rt,{"model-name":_.value},null,8,["model-name"])],64)):(g(),f("span",Qi,u(k.$t("common.model.noModels")),1)),F(b(Bs),{class:P(["h-3 w-3 text-text-muted transition-transform",J.value?"rotate-180":""])},null,8,["class"])],32),J.value?(g(),f("div",Xi,[(g(!0),f(W,null,Y(b(n).chatModelNames,w=>(g(),f("button",{key:w,class:P(["flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm transition-colors",w===_.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:Ze(N=>{_.value=w,J.value=!1},["prevent"])},[a("span",null,u(w),1),F(Rt,{"model-name":w},null,8,["model-name"])],42,Yi))),128))])):E("",!0)]),Ne.value?(g(),f("div",el,[Z(a("input",{"onUpdate:modelValue":$[1]||($[1]=w=>qe.value=w),class:"w-48 rounded border border-accent bg-surface px-2 py-0.5 text-xs text-text-primary outline-none",onBlur:$t,onKeydown:ks,onVnodeMounted:$[2]||($[2]=w=>{w.el.focus(),w.el.select()})},null,544),[[X,qe.value]])])):(g(),f("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:k.$t("dashboard.conversation.clickToRename"),onClick:vs},[a("span",sl,u(wt.value),1),F(b(At),{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100"})],8,tl))]),a("div",nl,[Me.value?(g(),f("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(Me.value))},u(k.$t("dashboard.conversation.viewSessionDetails")),1)):E("",!0),a("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",V.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[4]||($[4]=w=>V.value=!V.value)},[F(b(sn),{class:"h-3.5 w-3.5"}),a("span",null,u(k.$t("dashboard.conversation.history")),1)],2),a("div",ol,[a("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",H.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[5]||($[5]=w=>H.value=!H.value)},[F(b(tn),{class:"h-3.5 w-3.5"}),a("span",null,u(k.$t("common.actions.export")),1)],2),H.value?(g(),f("div",{key:0,class:"fixed inset-0 z-10",onClick:$[6]||($[6]=w=>H.value=!1)})):E("",!0),H.value?(g(),f("div",al,[a("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:j},u(k.$t("dashboard.export.downloadJson")),1),a("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:ie},u(k.$t("dashboard.export.downloadMarkdown")),1),a("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:re},u(k.$t("dashboard.export.downloadText")),1)])):E("",!0)]),a("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(k.$t("dashboard.conversation.newChatButton")),1),a("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",G.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[7]||($[7]=w=>G.value=!G.value)},[F(b(Os),{class:"h-3.5 w-3.5"}),a("span",null,u(k.$t("dashboard.settings.chatSettings")),1)],2)])]),a("div",rl,[V.value?(g(),f("div",il,[a("div",ll,[a("span",cl,u(k.$t("dashboard.conversation.chatHistory")),1),a("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Close history",onClick:$[8]||($[8]=w=>V.value=!1)}," ✕ ")]),a("div",ul,[b(o).recentConversations.length===0?(g(),f("p",dl,u(k.$t("dashboard.conversation.noConversationsYet")),1)):(g(),f("div",pl,[(g(!0),f(W,null,Y(b(o).recentConversations,w=>(g(),f("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:N=>ve(w.id)},[be.value===w.id?(g(),f("div",ml,[Z(a("input",{"onUpdate:modelValue":$[9]||($[9]=N=>xe.value=N),class:"w-full rounded bg-surface px-1.5 py-0.5 text-xs text-text-primary outline-none border border-accent",onBlur:N=>ge(w.id),onKeydown:N=>D(N,w.id),onVnodeMounted:$[10]||($[10]=N=>{N.el.focus(),N.el.select()})},null,40,gl),[[X,xe.value]])])):(g(),f(W,{key:1},[a("div",fl,[a("p",bl,u(w.name),1),a("p",xl,u(w.model)+" · "+u(te(w.updatedAt)),1)]),a("div",vl,[a("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:k.$t("dashboard.conversation.rename"),onClick:Ze(N=>ye(w.id,w.name),["stop"])},[F(b(At),{class:"h-3 w-3"})],8,yl),a("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:k.$t("common.actions.delete"),onClick:Ze(N=>b(o).deleteConversation(w.id),["stop"])},[F(b(tt),{class:"h-3 w-3"})],8,kl)])],64))],10,hl))),128))]))])])):E("",!0),a("div",wl,[Oe.value?(g(),f("div",$l,[a("span",Sl,u(k.$t("common.status.error"))+":",1),ze(" "+u(Oe.value),1)])):E("",!0),F(na,{messages:x.value},null,8,["messages"]),F(Da,{"is-streaming":b(y),"selected-model":_.value,"is-vision-model":$e.value,onSend:St,onCommand:Ts,onCancel:ws},null,8,["is-streaming","selected-model","is-vision-model"])]),G.value?(g(),f("div",_l,[a("div",Cl,[a("span",Tl,u(k.$t("dashboard.settings.chatSettings")),1),a("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:$[11]||($[11]=w=>G.value=!1)}," ✕ ")]),F(Vi,{modelValue:U.value,"onUpdate:modelValue":$[12]||($[12]=w=>U.value=w),"selected-model":_.value,"rag-enabled":B.value,"onUpdate:ragEnabled":$[13]||($[13]=w=>B.value=w)},null,8,["modelValue","selected-model","rag-enabled"])])):E("",!0)])]))}}),Rl={class:"rounded-lg border border-border-default bg-surface-raised"},Al={class:"overflow-x-auto"},zl={class:"w-full text-sm"},Nl=["onClick"],El={class:"px-4 py-2 font-medium text-text-primary"},jl={class:"px-4 py-2"},Pl={class:"px-4 py-2 text-text-secondary"},Dl={class:"px-4 py-2 text-text-secondary"},Il={class:"px-4 py-2 text-text-secondary"},Fl={class:"px-4 py-2 text-text-muted"},Ll={key:0},Bl=ae({__name:"SessionHistoryTable",setup(t){const e=st();return(s,o)=>(g(),f("div",Rl,[o[2]||(o[2]=a("div",{class:"px-4 py-3 border-b border-border-default"},[a("h3",{class:"text-sm font-medium text-text-secondary"},"Recent Sessions")],-1)),a("div",Al,[a("table",zl,[o[1]||(o[1]=a("thead",null,[a("tr",{class:"border-b border-border-default text-left text-xs text-text-muted uppercase tracking-wide"},[a("th",{class:"px-4 py-2"},"Model"),a("th",{class:"px-4 py-2"},"Status"),a("th",{class:"px-4 py-2"},"Tokens"),a("th",{class:"px-4 py-2"},"Speed"),a("th",{class:"px-4 py-2"},"Duration"),a("th",{class:"px-4 py-2"},"When")])],-1)),a("tbody",null,[(g(!0),f(W,null,Y(b(e).recentSessions.slice(0,20),n=>(g(),f("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}})},[a("td",El,u(n.model),1),a("td",jl,[F(Gs,{status:n.status,detail:n.error},null,8,["status","detail"])]),a("td",Pl,u(n.metrics?n.metrics.totalTokenCount:"—"),1),a("td",Dl,u(n.metrics?b(Je)(n.metrics.tokensPerSecond):"—"),1),a("td",Il,u(n.metrics?b(Jt)(n.metrics.totalDurationMs):"—"),1),a("td",Fl,u(b(Vs)(n.createdAt)),1)],8,Nl))),128)),b(e).recentSessions.length===0?(g(),f("tr",Ll,[...o[0]||(o[0]=[a("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):E("",!0)])])])]))}}),Ol={class:"flex h-full flex-col"},ql={class:"flex-1 min-h-0"},Vl={key:0,class:"border-t border-border-default"},Ul={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Kl={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Hl={key:1,class:"border-t border-border-default px-4 py-2"},Wl={class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},Gl={class:"flex gap-2 overflow-x-auto pb-1"},Zl=["onClick"],hc=ae({__name:"DashboardPage",setup(t){const e=ut(),s=Zt(),o=A(!1),n=L(()=>e.aggregate),i=L(()=>n.value.totalSessions>0),r=L(()=>s.recentConversations);return(c,l)=>(g(),f("div",Ol,[a("div",ql,[F(Ml)]),i.value?(g(),f("div",Vl,[a("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]=h=>o.value=!o.value)},[a("span",null,u(n.value.totalSessions)+" "+u(c.$t("dashboard.metrics.sessions"))+" · Avg "+u(b(Je)(n.value.avgTps)),1),a("span",{class:P(["transition-transform",{"rotate-180":o.value}])},"▾",2)]),o.value?(g(),f("div",Ul,[a("div",Kl,[F(We,{label:c.$t("dashboard.metrics.totalSessions"),value:n.value.totalSessions},null,8,["label","value"]),F(We,{label:c.$t("dashboard.metrics.avgTtft"),value:b(Jt)(n.value.avgTtftMs)},null,8,["label","value"]),F(We,{label:c.$t("dashboard.metrics.avgSpeed"),value:b(Je)(n.value.avgTps)},null,8,["label","value"]),F(We,{label:c.$t("dashboard.metrics.totalTokens"),value:b(Ae)(n.value.totalTokensGenerated),unit:"tok"},null,8,["label","value"])]),F(Bl)])):E("",!0)])):E("",!0),r.value.length>1?(g(),f("div",Hl,[a("p",Wl,u(c.$t("dashboard.metrics.recentChats")),1),a("div",Gl,[(g(!0),f(W,null,Y(r.value.slice(0,5),h=>(g(),f("button",{key:h.id,class:P(["shrink-0 rounded-lg px-3 py-1.5 text-xs transition-colors",b(s).activeConversationId===h.id?"bg-accent/10 text-accent":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:d=>b(s).setActiveConversation(h.id)},u(h.name),11,Zl))),128))])])):E("",!0)]))}});export{hc as default};