llmxray 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.ar.md +6 -5
  2. package/README.fr.md +6 -5
  3. package/README.md +9 -8
  4. package/README.sr.md +6 -5
  5. package/README.zh-CN.md +6 -5
  6. package/dist/assets/{AITrainingPage-DKjKWcx-.js → AITrainingPage-BGxiNftI.js} +1 -1
  7. package/dist/assets/{AnalyticsPage-jTBXre2c.js → AnalyticsPage-Ct-sjfwM.js} +1 -1
  8. package/dist/assets/{BenchmarkPage-BVmzrGF3.js → BenchmarkPage-q41YsHY8.js} +2 -2
  9. package/dist/assets/{ComparisonPage-C9o6y6vj.js → ComparisonPage-BnJNpxsl.js} +1 -1
  10. package/dist/assets/{CostDashboardPage-CHoN2eQ2.js → CostDashboardPage-B4NDxJsX.js} +1 -1
  11. package/dist/assets/DashboardPage-BGQp7-l9.js +114 -0
  12. package/dist/assets/EmbeddingsPage-VBfXkb7Z.js +1 -0
  13. package/dist/assets/{FimPlaygroundPage-BcrmoLxo.js → FimPlaygroundPage-DLoI_Bvm.js} +1 -1
  14. package/dist/assets/{GoogleCallbackPage-C9_rQxue.js → GoogleCallbackPage-Cs3tBy_I.js} +1 -1
  15. package/dist/assets/{JsonTreeNode-RIieSDXb.js → JsonTreeNode-BSiw1fzq.js} +1 -1
  16. package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-BN_k6QDr.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-BEGN0dLS.js} +1 -1
  17. package/dist/assets/{ProtocolObservatoryPage-CXoj3a1O.js → ProtocolObservatoryPage-CgunJ_Wi.js} +1 -1
  18. package/dist/assets/{RAGPage-HwnlHxQ0.js → RAGPage-CnnZW7un.js} +1 -1
  19. package/dist/assets/{SessionPage-12S3fV1c.js → SessionPage-NE_x02_4.js} +1 -1
  20. package/dist/assets/{SettingsPage-B_hBcAPj.js → SettingsPage-DTpQIrlG.js} +1 -1
  21. package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-BQhKjjl9.js → StatusBadge.vue_vue_type_script_setup_true_lang-DO0LFtqz.js} +1 -1
  22. package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-DOKnxhnC.js → StorageGauge.vue_vue_type_style_index_0_lang-BvYHZigP.js} +1 -1
  23. package/dist/assets/{SystemPage-BtFTvlZl.js → SystemPage-BEGyNOxu.js} +2 -2
  24. package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-BStny7LH.js → TabBar.vue_vue_type_script_setup_true_lang-BwHA1qGL.js} +1 -1
  25. package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-DMEwK9YF.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-DyRMkTKm.js} +1 -1
  26. package/dist/assets/{ToolWorkshopPage-BRXtDJIQ.js → ToolWorkshopPage-CNhpkdiG.js} +1 -1
  27. package/dist/assets/{agent-store-CR4CQ_VV.js → agent-store-Ak5tH3gE.js} +1 -1
  28. package/dist/assets/{canvas-ai-db-Ck_6zOgd.js → canvas-ai-db-Bw1M5Zgc.js} +1 -1
  29. package/dist/assets/{download-CaV4vzuu.js → download-DgBo5doZ.js} +1 -1
  30. package/dist/assets/{generate-service-Bhf2jPuC.js → generate-service-D1KjeWIo.js} +1 -1
  31. package/dist/assets/{google-auth-store-LaJFtciC.js → google-auth-store-Db6JKC8L.js} +1 -1
  32. package/dist/assets/{index-CQPzvMUz.js → index-BM7fRtY0.js} +1 -1
  33. package/dist/assets/index-S2vqeDf7.js +36 -0
  34. package/dist/assets/{index-Dy_48xr0.js → index-YmhR__TY.js} +1 -1
  35. package/dist/assets/{info-C9qZFgvQ.js → info-47X0r1B2.js} +1 -1
  36. package/dist/assets/{metrics-store-B4lQqH-w.js → metrics-store-DzujlkfW.js} +1 -1
  37. package/dist/assets/{papaparse.min-CfA1otDr.js → papaparse.min-D0aQsTQw.js} +1 -1
  38. package/dist/assets/{pencil-BcLPhQp1.js → pencil-B-eZ2Kq9.js} +1 -1
  39. package/dist/assets/{play-CYCSil_U.js → play-DT41vD7M.js} +1 -1
  40. package/dist/assets/{rag-store-BXD_zIis.js → rag-store-gqowRN8t.js} +3 -3
  41. package/dist/assets/{session-store-Dy1-rRkz.js → session-store-BO1u_qJQ.js} +1 -1
  42. package/dist/assets/{share-2-D2IlHB5H.js → share-2-IBretU3M.js} +1 -1
  43. package/dist/assets/{square-Dtyb8Nls.js → square-CbKkOlNA.js} +1 -1
  44. package/dist/assets/{storage-store-me3LAKpj.js → storage-store-GsT1cPEh.js} +1 -1
  45. package/dist/assets/{stream-handler-DDNDUY1M.js → stream-handler-B5y5PItW.js} +1 -1
  46. package/dist/assets/{tool-workshop-store-C_CvI0_B.js → tool-workshop-store-BLoF0Gob.js} +1 -1
  47. package/dist/assets/{toolcall-store-CUeITA8C.js → toolcall-store-BEFdRqL-.js} +1 -1
  48. package/dist/assets/{trash-2-Ct6xU7VV.js → trash-2-BdlHNMOp.js} +1 -1
  49. package/dist/index.html +1 -1
  50. package/package.json +89 -89
  51. package/dist/assets/DashboardPage-CMZSfb4t.js +0 -114
  52. package/dist/assets/EmbeddingsPage-DdbGCntf.js +0 -1
  53. package/dist/assets/index-CZ4a6rAU.js +0 -36
@@ -0,0 +1,114 @@
1
+ import{u as ut}from"./metrics-store-DzujlkfW.js";import{c as Fe,_ as js,o as Be,n as we,r as A,d as Vt,w as ie,a as B,b as le,e as f,f as r,g as P,t as u,h as Ae,i as E,j as g,F as W,k as X,l as Ps,u as b,m as Ds,p as L,q as Ie,T as Is,s as Ut,v as Ze,X as tt,x as Kt,y as Ls,z as Ht,A as dt,B as Wt,E as Fs,C as Z,D as te,G as He,H as Gt,I as Zt,J as Bs,S as Os,K as qs}from"./index-S2vqeDf7.js";import{f as Re,a as Je,b as at,c as Jt,d as Vs}from"./format-BqVZ9rwM.js";import{u as st}from"./session-store-BO1u_qJQ.js";import{a as Us,s as Ks}from"./generate-service-D1KjeWIo.js";import{u as Hs,a as Ws,_ as Gs,b as We}from"./StatusBadge.vue_vue_type_script_setup_true_lang-DO0LFtqz.js";import{u as Zs}from"./toolcall-store-BEFdRqL-.js";import{u as pt}from"./tool-workshop-store-BLoF0Gob.js";import{u as Js,a as Qt,b as Qs}from"./agent-store-Ak5tH3gE.js";import{e as Xs}from"./stream-handler-B5y5PItW.js";import{d as Ys,p as en,u as Xt}from"./rag-store-gqowRN8t.js";import{messageMemoryDB as Yt}from"./message-memory-db-C3Ifhs2B.js";import{_ as Rt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-BEGN0dLS.js";import{P as At}from"./pencil-B-eZ2Kq9.js";import{D as tn}from"./download-DgBo5doZ.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,a]of Object.entries(e))s.set(i,a);const o=[...t].sort((i,a)=>i.order-a.order);let n=null;for(const i of o)switch(i.type){case"http_request":await un(i.config,s);break;case"extract_field":dn(i.config,s);break;case"template":pn(i.config,s);break;case"return_value":n=hn(i.config,s);break}return n}async function un(t,e){const s=Le(t.url,e),o=t.body?Le(t.body,e):void 0,n={};for(const[l,h]of Object.entries(t.headers))n[l]=Le(h,e);const i=await fetch(s,{method:t.method,headers:n,body:t.method!=="GET"?o:void 0});let a;(i.headers.get("content-type")??"").includes("application/json")?a=await i.json():a=await i.text(),e.set(t.outputVariable||"response",a)}function dn(t,e){const s=e.get(t.input);if(s==null){e.set(t.outputVariable||"value",null);return}const o=t.fieldPath.split(".");let n=s;for(const i of o){if(n==null||typeof n!="object"){n=null;break}n=n[i]}e.set(t.outputVariable||"value",n)}function pn(t,e){const s=Le(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):Le(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 Le(t,e){return t.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g,(s,o)=>{const n=o.split(".");let i=e.get(n[0]??"");for(let a=1;a<n.length;a++){if(i==null||typeof i!="object")return"";i=i[n[a]??""]}return i==null?"":typeof i=="object"?JSON.stringify(i):String(i)})}const gn=5;async function fn(t){const e=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 a=new AbortController;return bn(n,t.model,[...t.messages],t.tools,t.options,a.signal,t.think,t.format).catch(c=>{a.signal.aborted||e.setSessionError(n,c instanceof Error?c.message:"Chat failed")}),{sessionId:n,abort:()=>{a.abort(),e.cancelSession(n)}}}async function bn(t,e,s,o,n,i,a,c){const l=Zs(),h=pt(),d=Js();let m=0,v=0;for(;m<gn;){if(i.aborted)return;const T=await Be.streamChat({model:e,messages:s,tools:o,options:n,logprobs:!0,think:a,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 _ of S.toolCalls){const M=h.findByFunctionName(_.function.name),G=l.getToolCalls(t).find(U=>U.functionName===_.function.name&&U.status==="pending");if(!M){const U=`Tool "${_.function.name}" has no implementation`;d.addNode(t,{id:we(),type:"error",label:`No impl: ${_.function.name}`,sessionId:t,stepIndex:v++,state:{tool:_.function.name,error:U},timestamp:Date.now()}),G&&l.updateToolCall(t,G.id,{status:"failed",error:U,completedAt:Date.now()}),s.push({role:"tool",content:JSON.stringify({error:U})});continue}G&&l.updateToolCall(t,G.id,{status:"executing"});const V=await rn(M,_.function.arguments);d.addNode(t,{id:we(),type:V.success?"output":"error",label:V.success?`Tool Result: ${_.function.name}`:`Tool Failed: ${_.function.name}`,sessionId:t,stepIndex:v++,state:{tool:_.function.name,success:V.success,durationMs:V.durationMs},timestamp:Date.now()}),G&&l.updateToolCall(t,G.id,{status:V.success?"completed":"failed",result:V.result,error:V.error,completedAt:Date.now(),durationMs:V.durationMs});const H=V.success?typeof V.result=="string"?V.result:JSON.stringify(V.result):JSON.stringify({error:V.error});s.push({role:"tool",content:H})}d.addNode(t,{id:we(),type:"llm_call",label:`LLM Round ${m+2} (with tool results)`,sessionId:t,stepIndex:v++,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 v=await fn({model:c,messages:l,tools:d,options:h,think:m?.think,format:m?.format});return s.value=v.sessionId,o=v.abort,v.sessionId}catch(v){throw e.value=v instanceof Error?v.message:"Failed to start chat",t.value=!1,v}}function a(){o&&(o(),o=null),t.value=!1}return{isStreaming:t,error:e,currentSessionId:s,startGenerate:n,startChatStream:i,cancel:a}}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 a of i){const c=a.descriptionKey?e.t(a.descriptionKey):a.description;o.push(` ${a.usage} — ${c}`)}o.push("")}e.showNotification(o.join(`
3
+ `))}},{name:"clear",descriptionKey:"dashboard.slashCommands.descriptions.clear",description:"Clear current conversation",usage:"/clear",category:"chat",execute(t,e){e.clearConversation(),e.showNotification(e.t(`${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:Re(e.chatSettings.value.options.num_ctx??4096),sizes:o.join(", ")}));return}e.setOption("num_ctx",s),e.showNotification(e.t(`${R}.contextSet`,{value:Re(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:Re(s.prompt),completion:Re(s.completion),total:Re(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 Nt={slidingWindow:{enabled:!0,maxMessages:50},autoSummarize:{enabled:!1,triggerThreshold:30},ragMemory:{enabled:!1,embeddingModel:"",topK:3},userFacts:{enabled:!0}},zt="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(zt,{...Nt}));ie(t,S=>Pt(zt,S),{deep:!0});function e(S){t.value={...t.value,...S}}function s(){t.value={...Nt}}const o=A(jt(Et,[]));ie(o,S=>Pt(Et,S),{deep:!0});const n=B(()=>o.value.length);function i(S){const _={id:we(),content:S.trim(),createdAt:Date.now()};return o.value=[...o.value,_],_}function a(S){o.value=o.value.filter(_=>_.id!==S)}function c(S){const _=S.toLowerCase().trim(),M=o.value.findIndex(J=>J.content.toLowerCase().includes(_));return M===-1?!1:(o.value=[...o.value.slice(0,M),...o.value.slice(M+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(_=>`- ${_.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:_,messageCount:M,createdAt:Date.now()})}function v(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:a,removeFactByContent:c,clearFacts:l,getFactsAsSystemPrompt:h,summaries:d,setSummary:m,getSummary:v,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 a of s)o.set(a,(o.get(a)??0)+1);let n=0;for(const a of o.values())a>1&&(n+=a);const i=n/s.length;return i>.5?{detector:"repetition",status:"fail",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:i>.3?{detector:"repetition",status:"warn",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:{detector:"repetition",status:"pass",reason:"quality.repetition.reason"}}function Sn(t){for(const e of kn)if(e.test(t))return{detector:"refusal",status:"warn",reason:"quality.refusal.reason",detail:`Matched: ${e.source}`};return{detector:"refusal",status:"pass",reason:"quality.refusal.reason"}}function _n(t){if(t.length<=20)return{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"};let e=0;for(let o=0;o<t.length;o++)t.charCodeAt(o)>127&&e++;const s=e/t.length;return s>.4?{detector:"gibberish",status:"warn",reason:"quality.gibberish.reason",detail:`${(s*100).toFixed(0)}% non-ASCII characters`}:{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"}}function Cn(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?{detector:"empty",status:"fail",reason:"quality.empty.reason",detail:"0 words"}:e.length<10?{detector:"empty",status:"warn",reason:"quality.empty.reason",detail:`${e.length} words`}:{detector:"empty",status:"pass",reason:"quality.empty.reason"}}function Tn(t,e,s,o){if(o==="length")return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:"Model stopped due to token limit"};if(s&&s>0){const n=e/s,i=/[.!?\n)\]"]$/.test(t.trim());if(n>.9&&!i)return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:`Used ${(n*100).toFixed(0)}% of token budget without clean ending`}}return{detector:"truncation",status:"pass",reason:"quality.truncation.reason"}}function Mn(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}function Rn(t,e,s,o,n,i){const a=[$n(s),Sn(s),_n(s),Cn(s),Tn(s,o,n,i)];return{messageId:t,sessionId:e,overall:Mn(a),checks:a,analyzedAt:Date.now()}}async function An(t){let e=[...t.messages],s;t.settings.userFacts.enabled&&t.userFactsPrompt&&e.unshift({role:"system",content:t.userFactsPrompt});const o=e.filter(n=>n.role!=="system");if(t.settings.autoSummarize.enabled&&o.length>t.settings.autoSummarize.triggerThreshold){const n=Math.floor(t.settings.autoSummarize.triggerThreshold/3),i=e.filter(d=>d.role==="system"),a=o.slice(0,-n),c=o.slice(-n),l=t.existingSummary?`Previous summary:
9
+ ${t.existingSummary}
10
+
11
+ New messages to incorporate:
12
+ `:"",h=await zn(t.model,l+a.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"),a=t.settings.slidingWindow.maxMessages;if(i.length>a){const c=i.slice(-a);e=[...n,...c]}}if(t.settings.ragMemory.enabled&&t.settings.ragMemory.embeddingModel)try{const n=await En(t.conversationId,e,t.settings.ragMemory.embeddingModel,t.settings.ragMemory.topK);if(n){const i=e.filter(c=>c.role==="system"),a=e.filter(c=>c.role!=="system");e=[...i,{role:"system",content:n},...a]}}catch{}return{messages:e,newSummary:s}}async function Nn(t,e,s){if(!s||e.length===0)return;const o=e.map(a=>a.content),n=await Be.embed({model:s,input:o}),i=[];for(let a=0;a<e.length;a++){const c=n.embeddings[a];if(!c)continue;const l=e[a];i.push({id:we(),conversationId:t,role:l.role,content:l.content,embedding:c,timestamp:l.timestamp})}await Yt.storeMessages(i)}async function zn(t,e){try{return(await Be.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 Be.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 Me=ht();function os(t){Me=t}var Ce={exec:()=>null};function D(t,e=""){let s=typeof t=="string"?t:t.source,o={replace:(n,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(se.caret,"$1"),s=s.replace(n,a),o},getRegex:()=>new RegExp(s,e)};return o}var jn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),se={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|$)|$)/,Oe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ln=/^ {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=D(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(),Fn=D(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=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ft).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qn=D(/^(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=D("^ {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=D(gt).replace("hr",Oe).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=D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",is).getRegex(),xt={blockquote:Un,code:Dn,def:On,fences:In,heading:Ln,hr:Oe,html:Vn,lheading:rs,list:qn,newline:Pn,paragraph:is,table:Ce,text:Bn},Dt=D("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Oe).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:Fn,table:Dt,paragraph:D(gt).replace("hr",Oe).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:D(`^ *(?: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:Ce,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:D(gt).replace("hr",Oe).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=D(/^((?![*_])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=D(/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=D(ps,"u").replace(/punct/g,ot).getRegex(),no=D(ps,"u").replace(/punct/g,us).getRegex(),hs="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oo=D(hs,"gu").replace(/notPunctSpace/g,cs).replace(/punctSpace/g,vt).replace(/punct/g,ot).getRegex(),ao=D(hs,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,Qn).replace(/punct/g,us).getRegex(),ro=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)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=D(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ds).getRegex(),lo="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",co=D(lo,"gu").replace(/notPunctSpace/g,eo).replace(/punctSpace/g,Yn).replace(/punct/g,ds).getRegex(),uo=D(/\\(punct)/,"gu").replace(/punct/g,ot).getRegex(),po=D(/^<(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=D(bt).replace("(?:-->|$)","-->").getRegex(),mo=D("^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=D(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Xe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ms=D(/^!?\[(label)\]\[(ref)\]/).replace("label",Xe).replace("ref",ft).getRegex(),gs=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",ft).getRegex(),fo=D("reflink|nolink(?!\\()","g").replace("reflink",ms).replace("nolink",gs).getRegex(),It=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yt={_backpedal:Ce,anyPunctuation:uo,autolink:po,blockSkip:to,br:ls,code:Gn,del:Ce,delLDelim:Ce,delRDelim:Ce,emStrongLDelim:so,emStrongRDelimAst:oo,emStrongRDelimUnd:ro,escape:Wn,link:go,nolink:gs,punctuation:Jn,reflink:ms,reflinkSearch:fo,tag:mo,text:Zn,url:Ce},bo={...yt,link:D(/^!?\[(label)\]\((.*?)\)/).replace("label",Xe).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xe).getRegex()},rt={...yt,emStrongRDelimAst:ao,emStrongLDelim:no,delLDelim:io,delRDelim:co,url:D(/^((?: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:D(/^([`~]+|[^`~])(?:(?= {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:D(ls).replace("{2,}","*").getRegex(),text:D(rt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ge={normal:xt,gfm:Kn,pedantic:Hn},je={normal:yt,gfm:rt,breaks:xo,pedantic:bo},vo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Lt=t=>vo[t];function be(t,e){if(e){if(se.escapeTest.test(t))return t.replace(se.escapeReplace,Lt)}else if(se.escapeTestNoEncode.test(t))return t.replace(se.escapeReplaceNoEncode,Lt);return t}function Ft(t){try{t=encodeURI(t).replace(se.percentDecode,"%")}catch{return null}return t}function Bt(t,e){let s=t.replace(se.findPipe,(i,a,c)=>{let l=!1,h=a;for(;--h>=0&&c[h]==="\\";)l=!l;return l?"|":" |"}),o=s.split(se.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(se.slashPipe,"|");return o}function Pe(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,a=e.title||null,c=t[1].replace(n.other.outputLinkReplace,"$1");o.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:s,href:i,title:a,text:c,tokens:o.inlineTokens(c)};return o.state.inLink=!1,l}function wo(t,e,s){let o=t.match(s.other.indentCodeCompensation);if(o===null)return e;let n=o[1];return e.split(`
21
+ `).map(i=>{let a=i.match(s.other.beginningSpace);if(a===null)return i;let[c]=a;return c.length>=n.length?i.slice(n.length):i}).join(`
22
+ `)}var Ye=class{options;rules;lexer;constructor(t){this.options=t||Me}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:Pe(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=Pe(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:Pe(e[0],`
24
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=Pe(e[0],`
25
+ `).split(`
26
+ `),o="",n="",i=[];for(;s.length>0;){let a=!1,c=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))c.push(s[l]),a=!0;else if(!a)c.push(s[l]);else break;s=s.slice(l);let 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 v=i.at(-1);if(v?.type==="code")break;if(v?.type==="blockquote"){let T=v,S=T.raw+`
31
+ `+s.join(`
32
+ `),_=this.blockquote(S);i[i.length-1]=_,o=o.substring(0,o.length-T.raw.length)+_.raw,n=n.substring(0,n.length-T.text.length)+_.text;break}else if(v?.type==="list"){let T=v,S=T.raw+`
33
+ `+s.join(`
34
+ `),_=this.list(S);i[i.length-1]=_,o=o.substring(0,o.length-v.raw.length)+_.raw,n=n.substring(0,n.length-T.raw.length)+_.raw,s=S.substring(i.at(-1).raw.length).split(`
35
+ `);continue}}return{type:"blockquote",raw:o,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),o=s.length>1,n={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let i=this.rules.other.listItemRegex(s),a=!1;for(;t;){let l=!1,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),v=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(v)&&(h+=v+`
38
+ `,t=t.substring(v.length+1),l=!0),!l){let _=this.rules.other.nextBulletRegex(S),M=this.rules.other.hrRegex(S),J=this.rules.other.fencesBeginRegex(S),G=this.rules.other.headingBeginRegex(S),V=this.rules.other.htmlBeginRegex(S),H=this.rules.other.blockquoteBeginRegex(S);for(;t;){let U=t.split(`
39
+ `,1)[0],K;if(v=U,this.options.pedantic?(v=v.replace(this.rules.other.listReplaceNesting," "),K=v):K=v.replace(this.rules.other.tabCharGlobal," "),J.test(v)||G.test(v)||V.test(v)||H.test(v)||_.test(v)||M.test(v))break;if(K.search(this.rules.other.nonSpaceChar)>=S||!v.trim())d+=`
40
+ `+K.slice(S);else{if(T||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||J.test(m)||G.test(m)||M.test(m))break;d+=`
41
+ `+v}T=!v.trim(),h+=U+`
42
+ `,t=t.substring(U.length+1),m=K.slice(S)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!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 a of o)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<s.length;a++)i.header.push({text:s[a],tokens:this.lexer.inline(s[a]),header:!0,align:i.align[a]});for(let a of n)i.rows.push(Bt(a,i.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let s=e[1].charAt(e[1].length-1)===`
44
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let i=Pe(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 a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],n="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(o);i&&(o=i[1],n=i[3])}else n=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?o=o.slice(1):o=o.slice(1,-1)),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,a,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(a=[...i].length,o[3]||o[4]){c+=a;continue}else if((o[5]||o[6])&&n%3&&!((n+a)%3)){l+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+l);let d=[...o[0]][0].length,m=t.slice(0,n+o.index+d+a);if(Math.min(n,a)%2){let T=m.slice(1,-1);return{type:"em",raw:m,text:T,tokens:this.lexer.inlineTokens(T)}}let v=m.slice(2,-2);return{type:"strong",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(s),n=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return o&&n&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,s=""){let o=this.rules.inline.delLDelim.exec(t);if(o&&(!o[1]||!s||this.rules.inline.punctuation.exec(s))){let n=[...o[0]].length-1,i,a,c=n,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+n);(o=l.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i||(a=[...i].length,a!==n))continue;if(o[3]||o[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let h=[...o[0]][0].length,d=t.slice(0,n+o.index+h+a),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}}}},me=class it{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Me,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:se,block:Ge.normal,inline:je.normal};this.options.pedantic?(s.block=Ge.pedantic,s.inline=je.pedantic):this.options.gfm&&(s.block=Ge.gfm,this.options.breaks?s.inline=je.breaks:s.inline=je.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ge,inline:je}}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(se.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(se.tabCharGlobal," ").replace(se.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(a=>(n=a.call({lexer:this},e,s))?(e=e.substring(n.raw.length),s.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let a=s.at(-1);n.raw.length===1&&a!==void 0?a.raw+=`
46
+ `:s.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
47
+ `)?"":`
48
+ `)+n.raw,a.text+=`
49
+ `+n.text,this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
50
+ `)?"":`
51
+ `)+n.raw,a.text+=`
52
+ `+n.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title},s.push(n));continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),s.push(n);continue}let i=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),l;this.options.extensions.startBlock.forEach(h=>{l=h.call({lexer:this},c),typeof l=="number"&&l>=0&&(a=Math.min(a,l))}),a<1/0&&a>=0&&(i=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let a=s.at(-1);o&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
53
+ `)?"":`
54
+ `)+n.raw,a.text+=`
55
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n),o=i.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
56
+ `)?"":`
57
+ `)+n.raw,a.text+=`
58
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,s}inline(e,s=[]){return this.inlineQueue.push({src:e,tokens:s}),s}inlineTokens(e,s=[]){let o=e,n=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)l.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,n.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)i=n[2]?n[2].length:0,o=o.slice(0,n.index+i)+"["+"a".repeat(n[0].length-i-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let a=!1,c="";for(;e;){a||(c=""),a=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},e,s))?(e=e.substring(l.raw.length),s.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let d=s.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.del(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),s.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),s.push(l);continue}let h=e;if(this.options.extensions?.startInline){let d=1/0,m=e.slice(1),v;this.options.extensions.startInline.forEach(T=>{v=T.call({lexer:this},m),typeof v=="number"&&v>=0&&(d=Math.min(d,v))}),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)),a=!0;let d=s.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):s.push(l);continue}if(e){let d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return s}},et=class{options;parser;constructor(t){this.options=t||Me}space(t){return""}code({text:t,lang:e,escaped:s}){let o=(e||"").match(se.notSpaceStart)?.[0],n=t.replace(se.endingNewline,"")+`
59
+ `;return o?'<pre><code class="language-'+be(o)+'">'+(s?n:be(n,!0))+`</code></pre>
60
+ `:"<pre><code>"+(s?n:be(n,!0))+`</code></pre>
61
+ `}blockquote({tokens:t}){return`<blockquote>
62
+ ${this.parser.parse(t)}</blockquote>
63
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
64
+ `}hr(t){return`<hr>
65
+ `}list(t){let e=t.ordered,s=t.start,o="";for(let a=0;a<t.items.length;a++){let c=t.items[a];o+=this.listitem(c)}let n=e?"ol":"ul",i=e&&s!==1?' start="'+s+'"':"";return"<"+n+i+`>
66
+ `+o+"</"+n+`>
67
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
68
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
69
+ `}table(t){let e="",s="";for(let n=0;n<t.header.length;n++)s+=this.tablecell(t.header[n]);e+=this.tablerow({text:s});let o="";for(let n=0;n<t.rows.length;n++){let i=t.rows[n];s="";for(let a=0;a<i.length;a++)s+=this.tablecell(i[a]);o+=this.tablerow({text:s})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
70
+ <thead>
71
+ `+e+`</thead>
72
+ `+o+`</table>
73
+ `}tablerow({text:t}){return`<tr>
74
+ ${t}</tr>
75
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+e+`</${s}>
76
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${be(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=Ft(t);if(n===null)return o;t=n;let i='<a href="'+t+'"';return e&&(i+=' title="'+be(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=Ft(t);if(n===null)return be(s);t=n;let i=`<img src="${t}" alt="${be(s)}"`;return e&&(i+=` title="${be(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:be(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}},ge=class lt{options;renderer;textRenderer;constructor(e){this.options=e||Me,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 a=n,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=c||"";continue}}let i=n;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,s=this.renderer){let o="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){o+=c||"";continue}}let a=i;switch(a.type){case"escape":{o+=s.text(a);break}case"html":{o+=s.html(a);break}case"link":{o+=s.link(a);break}case"image":{o+=s.image(a);break}case"checkbox":{o+=s.checkbox(a);break}case"strong":{o+=s.strong(a);break}case"em":{o+=s.em(a);break}case"codespan":{o+=s.codespan(a);break}case"br":{o+=s.br(a);break}case"del":{o+=s.del(a);break}case"text":{o+=s.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return o}},De=class{options;block;constructor(t){this.options=t||Me}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?me.lex:me.lexInline}provideParser(){return this.block?ge.parse:ge.parseInline}},fs=class{defaults=ht();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ge;Renderer=et;TextRenderer=kt;Lexer=me;Tokenizer=Ye;Hooks=De;constructor(...t){this.use(...t)}walkTokens(t,e){let s=[];for(let o of t)switch(s=s.concat(e.call(this,o)),o.type){case"table":{let n=o;for(let i of n.header)s=s.concat(this.walkTokens(i.tokens,e));for(let i of n.rows)for(let a of i)s=s.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=o;s=s.concat(this.walkTokens(n.items,e));break}default:{let n=o;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(i=>{let a=n[i].flat(1/0);s=s.concat(this.walkTokens(a,e))}):n.tokens&&(s=s.concat(this.walkTokens(n.tokens,e)))}}return s}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let o={...s};if(o.async=this.defaults.async||o.async||!1,s.extensions&&(s.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[n.level];i?i.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),o.extensions=e),s.renderer){let n=this.defaults.renderer||new 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 a=i,c=s.renderer[a],l=n[a];n[a]=(...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 a=i,c=s.tokenizer[a],l=n[a];n[a]=(...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 De;for(let i in s.hooks){if(!(i in n))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,c=s.hooks[a],l=n[a];De.passThroughHooks.has(i)?n[a]=h=>{if(this.defaults.async&&De.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[a]=(...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(a){let c=[];return c.push(i.call(this,a)),n&&(c=c.concat(n.call(this,a))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return me.lex(t,e??this.defaults)}parser(t,e){return ge.parse(t,e??this.defaults)}parseMarkdown(t){return(e,s)=>{let o={...s},n={...this.defaults,...o},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let a=n.hooks?await n.hooks.preprocess(e):e,c=await(n.hooks?await n.hooks.provideLexer():t?me.lex:me.lexInline)(a,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?ge.parse:ge.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(h):h})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer():t?me.lex:me.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():t?ge.parse:ge.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(t,e){return s=>{if(s.message+=`
77
+ Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+be(s.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(s);throw s}}},Te=new fs;function q(t,e){return Te.parse(t,e)}q.options=q.setOptions=function(t){return Te.setOptions(t),q.defaults=Te.defaults,os(q.defaults),q};q.getDefaults=ht;q.defaults=Me;q.use=function(...t){return Te.use(...t),q.defaults=Te.defaults,os(q.defaults),q};q.walkTokens=function(t,e){return Te.walkTokens(t,e)};q.parseInline=Te.parseInline;q.Parser=ge;q.parser=ge.parse;q.Renderer=et;q.TextRenderer=kt;q.Lexer=me;q.lexer=me.lex;q.Tokenizer=Ye;q.Hooks=De;q.parse=q;q.options;q.setOptions;q.use;q.walkTokens;q.parseInline;ge.parse;me.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=le({__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,[r("button",{class:P(["flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-colors",t.isThinking?"bg-[#a78bfa]/10 text-[#a78bfa]":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:o[0]||(o[0]=n=>e.value=!e.value)},[t.isThinking?(g(),f("span",Co,[...o[1]||(o[1]=[r("span",{class:"absolute h-full w-full rounded-full border-2 border-[#a78bfa]/30"},null,-1),r("span",{class:"absolute h-full w-full rounded-full border-2 border-transparent border-t-[#a78bfa]",style:{animation:"thinking-orbit 1s linear infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-[#a78bfa]"},null,-1)])])):(g(),f("span",To,"💭")),r("span",null,u(t.isThinking?"Thinking...":"Thought process"),1),r("span",{class:P(["text-text-muted transition-transform",{"rotate-180":e.value}])},"▾",2)],2),e.value?(g(),f("div",Mo,[Ae(u(t.content)+" ",1),t.isThinking?(g(),f("span",Ro,[...o[2]||(o[2]=[r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):E("",!0)])):E("",!0)])):E("",!0)}}),No={class:"text-sm leading-relaxed text-text-primary"},zo=le({__name:"AssistantTokenStream",props:{sessionId:{}},setup(t){const e=t,s=Qt(),{getColor:o}=Ws(Ds(e,"sessionId")),n=B(()=>s.getTokens(e.sessionId)),i=B(()=>{const a=n.value,c=[];let l=!1,h="";for(const d of a){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()??"",v=d.text;if(m.endsWith(v)&&v.includes("</think>")){const T=v.split("</think>").pop()??"";T&&c.push({...d,text:T})}}continue}c.push(d)}return c});return(a,c)=>(g(),f("div",No,[(g(!0),f(W,null,X(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"},Lo={class:"max-w-[100px] truncate opacity-90"},Fo={class:"opacity-60"},Bo=["src"],Oo=le({__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,X(t.attachments.filter(a=>a.type==="image"&&a.content),a=>(g(),f("div",{key:a.id},[r("img",{src:a.content,alt:a.name,class:"max-h-48 max-w-full cursor-pointer rounded-lg object-contain",onClick:c=>s(a)},null,8,jo),r("div",Po,[r("span",Do,u(a.name),1),r("span",null,u(b(at)(a.sizeBytes)),1)])]))),128)),r("div",Io,[(g(!0),f(W,null,X(t.attachments.filter(a=>a.type==="document"),a=>(g(),f("div",{key:a.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[L(b(es),{class:"h-3.5 w-3.5 opacity-70"}),r("span",Lo,u(a.name),1),r("span",Fo,u(b(at)(a.sizeBytes)),1)]))),128))]),(g(),Ie(Is,{to:"body"},[L(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},[r("img",{src:e.value,alt:"Enlarged attachment preview",class:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl",onClick:i[0]||(i[0]=Ze(()=>{},["stop"]))},null,8,Bo),r("button",{class:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Close lightbox",onClick:o},[L(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=le({__name:"QualityBadges",props:{report:{}},setup(t){const e=t,s=B(()=>e.report?e.report.checks.filter(n=>n.status!=="pass"):[]),o=B(()=>s.value.length>0);return(n,i)=>o.value?(g(),f("div",qo,[(g(!0),f(W,null,X(s.value,a=>(g(),f("span",{key:a.detector,class:P(["inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium",a.status==="fail"?"bg-error/15 text-error":"bg-warning/15 text-warning"]),title:a.detail??n.$t(a.reason)},u(n.$t(`quality.${a.detector}.label`)),11,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=le({__name:"ChatBubble",props:{message:{}},setup(t){const e=t,s=st(),o=Qs(),n=ut(),i=ns(),a=B(()=>i.getReport(e.message.id)),c=B(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),l=B(()=>e.message.sessionId?s.sessionById(e.message.sessionId)?.doneReason==="length":!1),h=B(()=>e.message.sessionId?o.getThinking(e.message.sessionId):{isThinking:!1,content:""}),d=B(()=>e.message.role==="user"),m=B(()=>c.value?c.value.loadDurationMs>500:!1),v=B(()=>{if(d.value){if(e.message.attachments?.length){const _=`
78
+
79
+ ---
80
+
81
+ `,M=e.message.content.lastIndexOf(_);if(M!==-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=B(()=>d.value||!v.value?"":So(v.value)),S=B(()=>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"])},[r("div",{class:P(["max-w-[80%] rounded-2xl px-4 py-2.5",d.value?"bg-accent text-white rounded-br-md":"bg-surface-raised border border-border-default rounded-bl-md"])},[d.value?(g(),f(W,{key:0},[t.message.attachments?.length?(g(),Ie(Oo,{key:0,attachments:t.message.attachments},null,8,["attachments"])):E("",!0),r("p",Ko,u(v.value),1)],64)):(g(),f(W,{key:1},[t.message.sessionId?(g(),Ie(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(),Ie(zo,{key:1,"session-id":t.message.sessionId},null,8,["session-id"])):v.value?(g(),f("div",{key:2,class:"markdown-prose",innerHTML:T.value},null,8,Ho)):E("",!0),t.message.isStreaming&&!v.value?(g(),f("span",Wo,[...M[0]||(M[0]=[r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):E("",!0),l.value&&!t.message.isStreaming&&!a.value?(g(),f("div",Go,u(_.$t("dashboard.bubble.truncatedWarning")),1)):E("",!0)],64)),!d.value&&!t.message.isStreaming&&c.value?(g(),f("div",Zo,[r("span",null,u(c.value.completionTokenCount)+" "+u(_.$t("dashboard.bubble.tokens")),1),M[2]||(M[2]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,u(c.value.tokensPerSecond.toFixed(1))+" "+u(_.$t("dashboard.bubble.tokPerSec")),1),M[3]||(M[3]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,u(c.value.ttftMs<1e3?c.value.ttftMs.toFixed(0)+"ms":(c.value.ttftMs/1e3).toFixed(1)+"s")+" "+u(_.$t("dashboard.bubble.ttft")),1),m.value?(g(),f(W,{key:0},[M[1]||(M[1]=r("span",{class:"opacity-40"},"·",-1)),r("span",{class:"text-warning",title:_.$t("dashboard.bubble.coldStart")},u(_.$t("dashboard.bubble.cold")),9,Jo)],64)):E("",!0),a.value&&a.value.overall!=="pass"?(g(),f("span",{key:1,class:P(["ml-1 inline-block h-1.5 w-1.5 rounded-full",a.value.overall==="fail"?"bg-error":"bg-warning"]),title:_.$t("quality.issuesDetected")},null,10,Qo)):E("",!0)])):E("",!0),L(Uo,{report:a.value},null,8,["report"]),r("div",{class:P(["mt-1",d.value?"text-end":""])},[r("span",Xo,u(S.value),1)],2)],2)],2))}}),ea={key:0,class:"flex items-center justify-center"},ta={class:"text-center"},sa={class:"text-sm text-text-muted"},na=le({__name:"ChatMessageList",props:{messages:{}},setup(t,{expose:e}){const s=t,o=A(null);function n(){Ls(()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight)})}return ie(()=>s.messages.length,()=>n()),ie(()=>s.messages[s.messages.length-1]?.content,()=>n()),e({scrollToBottom:n}),(i,a)=>(g(),f("div",{ref_key:"containerRef",ref:o,class:"flex-1 overflow-y-auto px-4 py-6"},[r("div",{class:P(["mx-auto max-w-3xl space-y-4",t.messages.length===0?"flex min-h-full flex-col justify-center":""])},[t.messages.length===0?(g(),f("div",ea,[r("div",ta,[a[0]||(a[0]=r("svg",{class:"mx-auto mb-4 h-20 w-20 text-text-muted/20",viewBox:"0 0 297.5 297.5"},[r("path",{fill:"currentColor",d:"M179.293,23.839c-64.904,0-117.707,52.804-117.707,117.707c0,1.832,0.056,3.651,0.14,5.463H9.933 c-5.486,0-9.933,4.448-9.933,9.933v46.189c0,5.486,4.448,9.933,9.933,9.933h22.349v43.209h-6.953c-4.663,0-8.443,3.78-8.443,8.443 c0,4.663,3.78,8.443,8.443,8.443h30.793c4.663,0,8.443-3.78,8.443-8.443c0-4.663-3.78-8.443-8.443-8.443h-6.953v-43.209h36.713 c21.533,28.059,55.39,46.189,93.411,46.189c64.904,0,117.707-52.804,117.707-117.707S244.196,23.839,179.293,23.839z M19.866,166.876h213.087c-5.257,11.091-13.854,20.295-24.483,26.323H19.866V166.876z M119.942,141.547 c0-32.726,26.624-59.35,59.35-59.35s59.35,26.624,59.35,59.35c0,1.843-0.096,3.663-0.261,5.463H120.206 C120.04,145.21,119.942,143.39,119.942,141.547z M179.293,239.388c-25.75,0-49.202-10.003-66.689-26.323h32.684 c10.31,4.925,21.837,7.698,34.005,7.698c43.68,0,79.217-35.536,79.217-79.217S222.973,62.33,179.293,62.33 s-79.217,35.536-79.217,79.217c0,1.839,0.086,3.657,0.214,5.463H81.611c-0.101-1.809-0.16-3.629-0.16-5.463 c0-48.871,36.016-89.488,82.901-96.702c-0.758,1.266-1.201,2.741-1.201,4.324c0,4.663,3.78,8.443,8.443,8.443h15.396 c4.663,0,8.443-3.78,8.443-8.443c0-1.583-0.443-3.058-1.201-4.324c46.884,7.214,82.901,47.83,82.901,96.702 C277.134,195.497,233.243,239.388,179.293,239.388z"})],-1)),a[1]||(a[1]=r("p",{class:"text-2xl font-semibold text-text-primary mb-2"},"LLMxRay",-1)),r("p",sa,u(i.$t("dashboard.empty.startConversation")),1)])])):E("",!0),(g(!0),f(W,null,X(t.messages,c=>(g(),Ie(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=B(()=>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(v=>v.id===h);m&&(m.content=d.result,m.status="ready")},d.onerror=()=>{const m=t.value.find(v=>v.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 v=t.value.find(T=>T.id===h);v&&(v.content=m,v.status="ready")}catch(d){const m=t.value.find(v=>v.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 a(){t.value=[]}return{attachments:t,isProcessing:e,addFiles:s,removeAttachment:i,clearAttachments:a}}const ca={key:0,class:"absolute bottom-full left-0 right-0 mb-2 max-h-64 overflow-y-auto rounded-xl border border-border-default bg-surface-raised shadow-lg"},ua={class:"p-1.5"},da=["onMouseenter","onClick"],pa={class:"shrink-0 font-mono text-xs text-accent"},ha={class:"truncate text-xs text-text-muted"},ma={class:"ms-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 text-[10px] text-text-muted"},ga=le({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(t,{expose:e,emit:s}){const{t:o}=Ht(),n=t,i=s,a=A(0),c=B(()=>{if(!n.visible)return[];const m=n.filter.replace(/^\//,"");return m?vn(m):Object.values(ts()).flat()});ie(()=>n.filter,()=>{a.value=0});function l(m){return!n.visible||c.value.length===0?!1:m.key==="ArrowDown"?(m.preventDefault(),a.value=(a.value+1)%c.value.length,!0):m.key==="ArrowUp"?(m.preventDefault(),a.value=a.value<=0?c.value.length-1:a.value-1,!0):m.key==="Tab"||m.key==="Enter"&&c.value.length>0?(m.preventDefault(),i("select",c.value[a.value]),!0):m.key==="Escape"?(m.preventDefault(),i("close"),!0):!1}e({handleKeydown:l});const h=B(()=>({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,v)=>t.visible&&c.value.length>0?(g(),f("div",ca,[r("div",ua,[(g(!0),f(W,null,X(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===a.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMouseenter:_=>a.value=S,onClick:_=>m.$emit("select",T)},[r("span",pa,"/"+u(T.name),1),r("span",ha,u(d(T)),1),r("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=le({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(t){return(e,s)=>t.attachments.length>0?(g(),f("div",fa,[(g(!0),f(W,null,X(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,[L(b(es),{class:"h-4 w-4"})])):E("",!0),r("span",va,u(o.name),1),r("span",ya,u(b(at)(o.sizeBytes)),1),o.status==="parsing"?(g(),f("span",ka)):o.status==="error"?(g(),f("span",wa,"!")):E("",!0),r("button",{class:"text-text-muted hover:text-error transition-colors","aria-label":"Remove attachment",onClick:n=>e.$emit("remove",o.id)},[L(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"],Na=["title"],za=["disabled","title"],Ea=["disabled","placeholder"],ja=["title"],Pa=["disabled","title"],Da=le({__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:G});const n=dt(),i=A(""),a=A(null),c=A(null),l=A(null),h=A(!1),{attachments:d,isProcessing:m,addFiles:v,removeAttachment:T,clearAttachments:S}=la();Wt(()=>{n.fetchModels()});const _=B(()=>{const C=i.value;return C.startsWith("/")&&!C.includes(`
84
+ `)}),M=B(()=>{if(!_.value)return"";const C=i.value.indexOf(" ");return C===-1?i.value:i.value.slice(0,C)}),J=B(()=>{const C=i.value.trim().length>0,I=d.value.length>0;return(C||I)&&!m.value});function G(){a.value?.focus()}function V(C){_.value&&l.value&&l.value.handleKeydown(C)||C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),U())}function H(C){i.value=`/${C.name} `,a.value?.focus()}function U(){const C=i.value.trim();if(!(!C&&d.value.length===0)){if(C.startsWith("/")&&d.value.length===0){const I=C.indexOf(" "),ee=I===-1?C.slice(1):C.slice(1,I),F=I===-1?"":C.slice(I+1);o("command",ee,F)}else o("send",C,[...d.value]),S();i.value="",a.value&&(a.value.style.height="auto")}}function K(C){const I=C.target;I.style.height="auto",I.style.height=Math.min(I.scrollHeight,200)+"px"}function ue(){i.value=""}function $e(){i.value="/",a.value?.focus()}function j(){c.value?.click()}function ne(C){const I=C.target;I.files&&I.files.length>0&&(v(I.files),I.value="")}function Y(C){C.preventDefault(),h.value=!0}function Ne(){h.value=!1}function ze(C){C.preventDefault(),h.value=!1,C.dataTransfer?.files&&C.dataTransfer.files.length>0&&v(C.dataTransfer.files)}function xe(C){const I=C.clipboardData?.items;if(!I)return;const ee=[];for(const F of I)if(F.type.startsWith("image/")){const ce=F.getAsFile();ce&&ee.push(ce)}ee.length>0&&(C.preventDefault(),v(ee))}return(C,I)=>(g(),f("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:Y,onDragleave:Ne,onDrop:ze},[h.value?(g(),f("div",_a,[r("span",Ca,u(C.$t("dashboard.dropZone")),1)])):E("",!0),r("div",Ta,[L(ga,{ref_key:"dropdownRef",ref:l,filter:M.value,visible:_.value,onSelect:H,onClose:ue},null,8,["filter","visible"])]),r("input",{ref_key:"fileInputRef",ref:c,type:"file",multiple:"",accept:b(ia),class:"hidden",onChange:ne},null,40,Ma),r("div",Ra,[L(Sa,{attachments:b(d),onRemove:b(T)},null,8,["attachments","onRemove"]),r("div",{class:P(["flex items-end gap-2 p-1.5",{"pt-0":b(d).length>0}])},[r("button",{disabled:t.isStreaming,class:"relative flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:t.isVisionModel?C.$t("dashboard.input.attachFilesVision"):C.$t("dashboard.input.attachFiles"),onClick:j},[L(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")},[L(b(Fs),{class:"h-2.5 w-2.5","stroke-width":3})],8,Na)):E("",!0)],8,Aa),r("button",{disabled:t.isStreaming,class:"flex h-8 shrink-0 items-center justify-center rounded-lg px-1.5 text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:C.$t("dashboard.input.commands"),onClick:$e},[L(b(an),{class:"h-4 w-4"})],8,za),Z(r("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":I[0]||(I[0]=ee=>i.value=ee),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:V,onInput:K,onPaste:xe},null,40,Ea),[[te,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:I[1]||(I[1]=ee=>C.$emit("cancel"))},[...I[2]||(I[2]=[r("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:U},[L(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"},La={class:"space-y-5 p-4 pb-12"},Fa={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:"grid grid-cols-3 gap-1 rounded-lg border border-border-default bg-surface p-1"},Wa=["onClick"],Ga={class:"mt-1 text-[10px] text-text-muted"},Za={class:"mb-1.5 flex items-center justify-between"},Ja={class:"text-xs font-medium text-text-secondary"},Qa={class:"text-[10px] text-text-muted"},Xa={value:"none"},Ya={value:"json"},er={value:"schema"},tr={class:"mt-1 text-[10px] text-text-muted"},sr={key:0,class:"mt-2"},nr=["placeholder"],or={key:0,class:"mt-1 text-[10px] text-error"},ar={key:1,class:"mt-1 text-[10px] text-text-muted"},rr={class:"flex items-center justify-between"},ir={class:"flex items-center gap-2"},lr={class:"text-xs font-medium text-text-secondary"},cr=["disabled"],ur={key:1,class:"text-[10px] text-text-muted -mt-3"},dr={key:2,class:"text-[10px] text-text-muted -mt-3"},pr={class:"mb-1.5 flex items-center justify-between"},hr={class:"text-xs font-medium text-text-secondary"},mr={class:"text-xs text-text-muted"},gr={class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},fr={class:"mb-1.5 flex items-center justify-between"},br={class:"text-xs font-medium text-text-secondary"},xr={class:"text-xs text-text-muted"},vr=["placeholder"],yr={class:"mt-1 text-[10px] text-text-muted"},kr={class:"mb-1.5 flex items-center justify-between"},wr={class:"text-xs font-medium text-text-secondary"},$r={class:"text-xs text-text-muted"},Sr={class:"mt-1 text-[10px] text-text-muted"},_r={key:3,class:"space-y-4 ps-1"},Cr={class:"mb-1.5 flex items-center justify-between"},Tr={class:"text-xs font-medium text-text-secondary"},Mr={class:"text-xs text-text-muted"},Rr={class:"mt-1 text-[10px] text-text-muted"},Ar={class:"mb-1.5 flex items-center justify-between"},Nr={class:"text-xs font-medium text-text-secondary"},zr={class:"text-xs text-text-muted"},Er={class:"mt-1 text-[10px] text-text-muted"},jr={class:"mb-1.5 flex items-center justify-between"},Pr={class:"text-xs font-medium text-text-secondary"},Dr={class:"text-xs text-text-muted"},Ir={class:"mt-1 text-[10px] text-text-muted"},Lr={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"},Or={value:0},qr={value:1},Vr={value:2},Ur={class:"mt-1 text-[10px] text-text-muted"},Kr={class:"mb-1.5 flex items-center justify-between"},Hr={class:"text-xs font-medium text-text-secondary"},Wr={class:"text-xs text-text-muted"},Gr=["placeholder"],Zr={class:"mt-1 text-[10px] text-text-muted"},Jr={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Qr=["placeholder"],Xr={class:"mt-1 text-[10px] text-text-muted"},Yr={key:0,class:"ms-1 text-accent"},ei={key:0,class:"ps-1 space-y-2"},ti={key:0,class:"space-y-1"},si=["onClick"],ni={key:1,class:"text-[10px] text-text-muted px-2"},oi={key:0,class:"ms-1 text-accent"},ai={key:5,class:"space-y-4 ps-1"},ri={class:"flex items-center justify-between"},ii={class:"text-xs font-medium text-text-secondary"},li={class:"text-[10px] text-text-muted"},ci={key:0},ui={class:"mb-1 flex items-center justify-between"},di={class:"text-[10px] text-text-muted"},pi={class:"text-[10px] text-text-muted"},hi={class:"flex items-center justify-between"},mi={class:"text-xs font-medium text-text-secondary"},gi={class:"text-[10px] text-text-muted"},fi={key:1},bi={class:"mb-1 flex items-center justify-between"},xi={class:"text-[10px] text-text-muted"},vi={class:"text-[10px] text-text-muted"},yi={class:"flex items-center justify-between"},ki={class:"text-xs font-medium text-text-secondary"},wi={class:"text-[10px] text-text-muted"},$i={key:2,class:"space-y-1"},Si={class:"flex-1 text-text-secondary"},_i=["onClick"],Ci={class:"flex items-center justify-between"},Ti={class:"text-xs font-medium text-text-secondary"},Mi={class:"text-[10px] text-text-muted"},Ri={key:3,class:"space-y-2"},Ai={class:"mb-1 block text-[10px] text-text-muted"},Ni={value:"",disabled:""},zi=["value"],Ei={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},ji={class:"mb-2 text-[10px] text-accent"},Pi={class:"space-y-1.5"},Di={class:"min-w-0 flex-1"},Ii={class:"truncate text-[11px] font-mono text-text-primary"},Li={class:"text-[9px] text-text-muted"},Fi=["disabled","onClick"],Bi={key:0,class:"mt-2 text-[9px] text-text-muted"},Oi={class:"mb-1 flex items-center justify-between"},qi={class:"text-[10px] text-text-muted"},Vi={class:"text-[10px] text-text-muted"},Ui=le({__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),a=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),v=A(s.modelValue.options.stop?.join(", ")??""),T=A(s.modelValue.options.mirostat??0),S=["off","on","low","medium","high","max"],_=["low","medium","high","max"];function M(p){return typeof p=="string"&&_.includes(p)?p:p===!0?"on":"off"}function J(p){if(_.includes(p))return p;if(p==="on")return!0}const G=A(M(s.modelValue.think));function V(p){return p==="json"?"json":p&&typeof p=="object"?"schema":"none"}const H=A(V(s.modelValue.format)),U=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
+ }`),K=A(null);ie(()=>s.modelValue.options,p=>{i.value=p.temperature??.7,a.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,v.value=p.stop?.join(", ")??"",T.value=p.mirostat??0},{deep:!0}),ie([n,i,a,c,l,h,d,m,v,T,G,H,U],()=>{const p=v.value.split(",").map(x=>x.trim()).filter(Boolean);let k;if(H.value==="json")k="json";else if(H.value==="schema")try{const x=JSON.parse(U.value);typeof x=="object"&&x!==null?(k=x,K.value=null):K.value="Schema must be a JSON object"}catch(x){K.value=x instanceof Error?x.message:"Invalid JSON"}else k=void 0,K.value=null;o("update:modelValue",{systemPrompt:n.value,options:{temperature:i.value,num_predict:a.value===-1?void 0:a.value,num_ctx:c.value,top_p:l.value,top_k: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:J(G.value),format:k})},{deep:!0}),ie(()=>s.modelValue,p=>{n.value=p.systemPrompt,i.value=p.options.temperature??.7,a.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,G.value=M(p.think),H.value=V(p.format),p.format&&typeof p.format=="object"&&(U.value=JSON.stringify(p.format,null,2))});const ue=pt(),$e=Gt(),j=ss(),ne=dt(),Y=Xt(),Ne=B(()=>ne.supportsTools(s.selectedModel)),ze=B(()=>ne.isThinkingModel(s.selectedModel));ie(()=>s.selectedModel,p=>{p&&!ne.supportsTools(p)&&ue.enabledTools.length>0&&ue.disableAll()});const xe=A(!1),C=A(!1),I=A(!1),ee=A(!1),F=A(""),ce=A(""),Se=[{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 de(p){ee.value=!0,ce.value=p,F.value="Starting download...";try{await Be.pullModel(p,(k,x,oe)=>{if(x&&oe){const ye=Math.round(x/oe*100);F.value=`${k} ${ye}%`}else F.value=k}),F.value="Done!",await ne.fetchModels(),j.settings.ragMemory.embeddingModel=p}catch(k){F.value=`Failed: ${k instanceof Error?k.message:"Unknown error"}`}finally{ee.value=!1,setTimeout(()=>{F.value="",ce.value=""},3e3)}}return(p,k)=>(g(),f("div",Ia,[r("div",La,[r("div",null,[r("label",Fa,u(p.$t("dashboard.settings.systemPrompt")),1),Z(r("textarea",{"onUpdate:modelValue":k[0]||(k[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),[[te,n.value]]),r("p",Oa,u(p.$t("dashboard.settings.systemPromptHint")),1)]),ze.value?(g(),f("div",qa,[r("div",Va,[r("label",Ua,u(p.$t("dashboard.settings.thinking.label")),1),r("span",Ka,u(p.$t("dashboard.settings.thinking.modelSupportsHint")),1)]),r("div",Ha,[(g(),f(W,null,X(S,x=>r("button",{key:x,type:"button",class:P(["rounded-md px-2 py-1 text-[11px] font-medium transition-colors",G.value===x?"bg-accent text-surface":"text-text-secondary hover:bg-surface-overlay"]),onClick:oe=>G.value=x},u(p.$t(`dashboard.settings.thinking.${x}`)),11,Wa)),64))]),r("p",Ga,u(p.$t("dashboard.settings.thinking.hint")),1)])):E("",!0),r("div",null,[r("div",Za,[r("label",Ja,u(p.$t("dashboard.settings.responseFormat.label")),1),r("span",Qa,u(H.value==="none"?p.$t("dashboard.settings.responseFormat.freeForm"):H.value==="json"?"JSON":"JSON Schema"),1)]),Z(r("select",{"onUpdate:modelValue":k[1]||(k[1]=x=>H.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"},[r("option",Xa,u(p.$t("dashboard.settings.responseFormat.none")),1),r("option",Ya,u(p.$t("dashboard.settings.responseFormat.json")),1),r("option",er,u(p.$t("dashboard.settings.responseFormat.schema")),1)],512),[[He,H.value]]),r("p",tr,u(p.$t("dashboard.settings.responseFormat.hint")),1),H.value==="schema"?(g(),f("div",sr,[Z(r("textarea",{"onUpdate:modelValue":k[2]||(k[2]=x=>U.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,nr),[[te,U.value]]),K.value?(g(),f("p",or,u(K.value),1)):(g(),f("p",ar,u(p.$t("dashboard.settings.responseFormat.schemaHint")),1))])):E("",!0)]),r("div",rr,[r("div",ir,[r("span",lr,u(p.$t("dashboard.settings.knowledgeBase")),1),r("span",{class:P(["rounded-full px-1.5 py-0.5 text-[9px] font-medium",t.ragEnabled&&b(Y).readyDocuments.length>0?"bg-accent/10 text-accent":"bg-surface-overlay text-text-muted"])},u(t.ragEnabled&&b(Y).readyDocuments.length>0?p.$t("dashboard.settings.kbEnabled"):p.$t("dashboard.settings.kbDisabled")),3)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",t.ragEnabled&&b(Y).readyDocuments.length>0?"bg-accent":"bg-surface-overlay"]),disabled:b(Y).readyDocuments.length===0,onClick:k[3]||(k[3]=x=>o("update:ragEnabled",!t.ragEnabled))},[r("span",{class:P(["block h-3 w-3 rounded-full bg-white transition-transform",t.ragEnabled&&b(Y).readyDocuments.length>0?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,cr)]),b(Y).readyDocuments.length>0?(g(),f("p",ur,[Ae(u(b(Y).enabledDocuments.length)+"/"+u(b(Y).readyDocuments.length)+" "+u(p.$t("dashboard.settings.documents"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:k[4]||(k[4]=x=>b($e).push("/rag"))},u(p.$t("dashboard.settings.manage")),1)])):(g(),f("p",dr,[Ae(u(p.$t("dashboard.settings.noDocumentsIngested"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:k[5]||(k[5]=x=>b($e).push("/rag"))},u(p.$t("dashboard.settings.addDocuments")),1)])),r("div",null,[r("div",pr,[r("label",hr,u(p.$t("dashboard.settings.temperature")),1),r("span",mr,u(i.value.toFixed(2)),1)]),Z(r("input",{"onUpdate:modelValue":k[6]||(k[6]=x=>i.value=x),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[te,i.value,void 0,{number:!0}]]),r("div",gr,[r("span",null,u(p.$t("dashboard.settings.precise")),1),r("span",null,u(p.$t("dashboard.settings.creative")),1)])]),r("div",null,[r("div",fr,[r("label",br,u(p.$t("dashboard.settings.maxTokens")),1),r("span",xr,u(a.value===-1?p.$t("dashboard.settings.unlimited"):a.value),1)]),Z(r("input",{"onUpdate:modelValue":k[7]||(k[7]=x=>a.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,vr),[[te,a.value,void 0,{number:!0}]]),r("p",yr,u(p.$t("dashboard.settings.maxTokensHint")),1)]),r("div",null,[r("div",kr,[r("label",wr,u(p.$t("dashboard.settings.contextWindow")),1),r("span",$r,u(c.value.toLocaleString()),1)]),Z(r("select",{"onUpdate:modelValue":k[8]||(k[8]=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"},[...k[27]||(k[27]=[r("option",{value:2048},"2,048",-1),r("option",{value:4096},"4,096",-1),r("option",{value:8192},"8,192",-1),r("option",{value:16384},"16,384",-1),r("option",{value:32768},"32,768",-1),r("option",{value:65536},"65,536",-1),r("option",{value:131072},"131,072",-1)])],512),[[He,c.value,void 0,{number:!0}]]),r("p",Sr,u(p.$t("dashboard.settings.contextWindowHint")),1)]),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:k[9]||(k[9]=x=>xe.value=!xe.value)},[r("span",null,u(p.$t("dashboard.settings.advancedSampling")),1),r("span",{class:P(["transition-transform",{"rotate-180":xe.value}])},"▾",2)]),xe.value?(g(),f("div",_r,[r("div",null,[r("div",Cr,[r("label",Tr,u(p.$t("dashboard.settings.topP")),1),r("span",Mr,u(l.value.toFixed(2)),1)]),Z(r("input",{"onUpdate:modelValue":k[10]||(k[10]=x=>l.value=x),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[te,l.value,void 0,{number:!0}]]),r("p",Rr,u(p.$t("dashboard.settings.topPHint")),1)]),r("div",null,[r("div",Ar,[r("label",Nr,u(p.$t("dashboard.settings.topK")),1),r("span",zr,u(h.value),1)]),Z(r("input",{"onUpdate:modelValue":k[11]||(k[11]=x=>h.value=x),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[te,h.value,void 0,{number:!0}]]),r("p",Er,u(p.$t("dashboard.settings.topKHint")),1)]),r("div",null,[r("div",jr,[r("label",Pr,u(p.$t("dashboard.settings.repeatPenalty")),1),r("span",Dr,u(d.value.toFixed(2)),1)]),Z(r("input",{"onUpdate:modelValue":k[12]||(k[12]=x=>d.value=x),type:"range",min:"1.0",max:"2.0",step:"0.05",class:"w-full accent-accent"},null,512),[[te,d.value,void 0,{number:!0}]]),r("p",Ir,u(p.$t("dashboard.settings.repeatPenaltyHint")),1)]),r("div",null,[r("div",Lr,[r("label",Fr,u(p.$t("dashboard.settings.mirostat")),1),r("span",Br,u(T.value===0?p.$t("dashboard.settings.mirostatOff"):`v${T.value}`),1)]),Z(r("select",{"onUpdate:modelValue":k[13]||(k[13]=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"},[r("option",Or,u(p.$t("dashboard.settings.mirostatDisabled")),1),r("option",qr,u(p.$t("dashboard.settings.mirostatV1")),1),r("option",Vr,u(p.$t("dashboard.settings.mirostatV2")),1)],512),[[He,T.value,void 0,{number:!0}]]),r("p",Ur,u(p.$t("dashboard.settings.mirostatHint")),1)]),r("div",null,[r("div",Kr,[r("label",Hr,u(p.$t("dashboard.settings.seed")),1),r("span",Wr,u(m.value===-1?p.$t("dashboard.settings.seedRandom"):m.value),1)]),Z(r("input",{"onUpdate:modelValue":k[14]||(k[14]=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,Gr),[[te,m.value,void 0,{number:!0}]]),r("p",Zr,u(p.$t("dashboard.settings.seedHint")),1)]),r("div",null,[r("label",Jr,u(p.$t("dashboard.settings.stopSequences")),1),Z(r("input",{"onUpdate:modelValue":k[15]||(k[15]=x=>v.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,Qr),[[te,v.value]]),r("p",Xr,u(p.$t("dashboard.settings.stopSequencesHint")),1)])])):E("",!0),Ne.value?(g(),f(W,{key:4},[r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:k[16]||(k[16]=x=>C.value=!C.value)},[r("span",null,[Ae(u(p.$t("dashboard.settings.tools"))+" ",1),b(ue).enabledDefinitions.length>0?(g(),f("span",Yr," ("+u(b(ue).enabledDefinitions.length)+" "+u(p.$t("dashboard.settings.active"))+") ",1)):E("",!0)]),r("span",{class:P(["transition-transform",{"rotate-180":C.value}])},"▾",2)]),C.value?(g(),f("div",ei,[b(ue).allTools.length>0?(g(),f("div",ti,[(g(!0),f(W,null,X(b(ue).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]"},[r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",x.enabled?"bg-accent":"bg-surface-overlay"]),onClick:oe=>b(ue).toggleEnabled(x.id)},[r("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,si),r("span",{class:P(["font-mono",x.enabled?"text-text-primary":"text-text-muted"])},u(x.definition.function.name),3)]))),128))])):(g(),f("p",ni,u(p.$t("dashboard.settings.noToolsDefined")),1)),r("button",{class:"w-full rounded-lg border border-dashed border-border-default px-3 py-1.5 text-[11px] text-text-muted hover:border-accent hover:text-text-primary transition-colors",onClick:k[17]||(k[17]=x=>b($e).push("/tools"))},u(p.$t("dashboard.settings.manageInToolWorkshop")),1)])):E("",!0)],64)):E("",!0),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:k[18]||(k[18]=x=>I.value=!I.value)},[r("span",null,[Ae(u(p.$t("dashboard.memory.memory"))+" ",1),b(j).factCount>0?(g(),f("span",oi," ("+u(b(j).factCount)+" "+u(p.$t("dashboard.memory.facts"))+") ",1)):E("",!0)]),r("span",{class:P(["transition-transform",{"rotate-180":I.value}])},"▾",2)]),I.value?(g(),f("div",ai,[r("div",ri,[r("div",null,[r("p",ii,u(p.$t("dashboard.memory.slidingWindow")),1),r("p",li,u(p.$t("dashboard.memory.slidingWindowHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.slidingWindow.enabled?"bg-accent":"bg-surface-overlay"]),onClick:k[19]||(k[19]=x=>b(j).settings.slidingWindow.enabled=!b(j).settings.slidingWindow.enabled)},[r("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",ci,[r("div",ui,[r("label",di,u(p.$t("dashboard.memory.maxMessages")),1),r("span",pi,u(b(j).settings.slidingWindow.maxMessages),1)]),Z(r("input",{"onUpdate:modelValue":k[20]||(k[20]=x=>b(j).settings.slidingWindow.maxMessages=x),type:"range",min:"10",max:"200",step:"10",class:"w-full accent-accent"},null,512),[[te,b(j).settings.slidingWindow.maxMessages,void 0,{number:!0}]])])):E("",!0),r("div",hi,[r("div",null,[r("p",mi,u(p.$t("dashboard.memory.autoSummarize")),1),r("p",gi,u(p.$t("dashboard.memory.autoSummarizeHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.autoSummarize.enabled?"bg-accent":"bg-surface-overlay"]),onClick:k[21]||(k[21]=x=>b(j).settings.autoSummarize.enabled=!b(j).settings.autoSummarize.enabled)},[r("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",fi,[r("div",bi,[r("label",xi,u(p.$t("dashboard.memory.triggerAfter")),1),r("span",vi,u(b(j).settings.autoSummarize.triggerThreshold)+" "+u(p.$t("dashboard.memory.messages")),1)]),Z(r("input",{"onUpdate:modelValue":k[22]||(k[22]=x=>b(j).settings.autoSummarize.triggerThreshold=x),type:"range",min:"10",max:"100",step:"5",class:"w-full accent-accent"},null,512),[[te,b(j).settings.autoSummarize.triggerThreshold,void 0,{number:!0}]])])):E("",!0),r("div",yi,[r("div",null,[r("p",ki,u(p.$t("dashboard.memory.userMemories")),1),r("p",wi,u(p.$t("dashboard.memory.userMemoriesHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.userFacts.enabled?"bg-accent":"bg-surface-overlay"]),onClick:k[23]||(k[23]=x=>b(j).settings.userFacts.enabled=!b(j).settings.userFacts.enabled)},[r("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",$i,[(g(!0),f(W,null,X(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]"},[r("span",Si,u(x.content),1),r("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:oe=>b(j).removeFact(x.id)},[L(b(tt),{class:"h-3 w-3"})],8,_i)]))),128))])):E("",!0),r("div",Ci,[r("div",null,[r("p",Ti,u(p.$t("dashboard.memory.messageMemoryRag")),1),r("p",Mi,u(p.$t("dashboard.memory.messageMemoryHint")),1)]),r("button",{class:P(["h-4 w-7 shrink-0 rounded-full transition-colors",b(j).settings.ragMemory.enabled?"bg-accent":"bg-surface-overlay"]),onClick:k[24]||(k[24]=x=>b(j).settings.ragMemory.enabled=!b(j).settings.ragMemory.enabled)},[r("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",Ri,[r("div",null,[r("label",Ai,u(p.$t("dashboard.memory.embeddingModel")),1),Z(r("select",{"onUpdate:modelValue":k[25]||(k[25]=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"},[r("option",Ni,u(p.$t("dashboard.memory.selectEmbeddingModel")),1),(g(!0),f(W,null,X(b(ne).embeddingModelNames,x=>(g(),f("option",{key:x,value:x},u(x)+" "+u(b(ne).capabilityIcons(x)),9,zi))),128))],512),[[He,b(j).settings.ragMemory.embeddingModel]])]),b(ne).embeddingModelNames.length===0?(g(),f("div",Ei,[r("p",ji,u(p.$t("dashboard.memory.noEmbeddingModels")),1),r("div",Pi,[(g(),f(W,null,X(Se,x=>r("div",{key:x.name,class:"flex items-center gap-2"},[r("div",Di,[r("p",Ii,u(x.name),1),r("p",Li,u(x.description)+" ("+u(x.size)+")",1)]),r("button",{disabled:ee.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:oe=>de(x.name)},u(ee.value&&ce.value===x.name?p.$t("dashboard.settings.pulling"):p.$t("dashboard.settings.pull")),9,Fi)])),64))]),F.value?(g(),f("p",Bi,u(F.value),1)):E("",!0)])):E("",!0),r("div",null,[r("div",Oi,[r("label",qi,u(p.$t("dashboard.memory.retrieveTop")),1),r("span",Vi,u(b(j).settings.ragMemory.topK)+" "+u(p.$t("dashboard.memory.messages")),1)]),Z(r("input",{"onUpdate:modelValue":k[26]||(k[26]=x=>b(j).settings.ragMemory.topK=x),type:"range",min:"1",max:"10",step:"1",class:"w-full accent-accent"},null,512),[[te,b(j).settings.ragMemory.topK,void 0,{number:!0}]])])])):E("",!0)])):E("",!0)])]))}}),Ki={class:"flex h-full flex-col"},Hi={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"},Wi={class:"flex items-start gap-3"},Gi={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},Zi={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},Ji={class:"flex items-center gap-3"},Qi={class:"relative"},Xi={key:0,class:"text-text-muted"},Yi={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"},el=["onMousedown"],tl={key:0,class:"flex items-center"},sl=["title"],nl={class:"truncate"},ol={class:"flex items-center gap-2"},al={class:"relative"},rl={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"},il={class:"flex flex-1 min-h-0"},ll={key:0,class:"w-64 shrink-0 border-e border-border-default bg-surface-raised flex flex-col"},cl={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},ul={class:"text-xs font-medium text-text-secondary"},dl={class:"flex-1 overflow-y-auto p-2"},pl={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},hl={key:1,class:"space-y-0.5"},ml=["onClick"],gl={key:0,class:"flex-1 min-w-0"},fl=["onBlur","onKeydown"],bl={class:"flex-1 min-w-0"},xl={class:"truncate text-[11px]"},vl={class:"truncate text-[9px] text-text-muted"},yl={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},kl=["title","onClick"],wl=["title","onClick"],$l={class:"flex flex-1 flex-col min-w-0"},Sl={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"},_l={class:"font-medium"},Cl={key:1,class:"w-72 shrink-0 border-s border-border-default bg-surface-raised"},Tl={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},Ml={class:"text-xs font-medium text-text-secondary"},Rl=le({__name:"ChatConversation",setup(t){const{t:e}=Ht(),s=Gt(),o=Zt(),n=dt(),i=st(),a=Xt(),c=ut(),l=pt(),h=ss(),d=Qt(),m=ns(),{isStreaming:v,currentSessionId:T,startChatStream:S,cancel:_}=xn(),M=A(""),J=A(!1);function G(){setTimeout(()=>{J.value=!1},150)}const V=A(!0),H=A(!1),U=A(!1),K=A(!1);function ue(){const y=de.value;if(!y||y.messages.length===0)return;const $=JSON.stringify(y.messages,null,2),w=new Blob([$],{type:"application/json"}),z=URL.createObjectURL(w),N=document.createElement("a");N.href=z,N.download=`chat-${y.id}.json`,N.click(),URL.revokeObjectURL(z),K.value=!1}function $e(){const y=de.value;if(!y||y.messages.length===0)return;const $=y.messages.map(ae=>{const ke=ae.role.charAt(0).toUpperCase()+ae.role.slice(1),pe=new Date(ae.timestamp).toLocaleString();return`### ${ke}
91
+ *${pe}*
92
+
93
+ ${ae.content}`}),w=`# Chat Export — ${y.name}
94
+
95
+ ${$.join(`
96
+
97
+ ---
98
+
99
+ `)}
100
+
101
+ ---
102
+ *Generated by LLMxRay — Local LLM Observatory*
103
+ `,z=new Blob([w],{type:"text/markdown"}),N=URL.createObjectURL(z),O=document.createElement("a");O.href=N,O.download=`chat-${y.id}.md`,O.click(),URL.revokeObjectURL(N),K.value=!1}function j(){const y=de.value;if(!y||y.messages.length===0)return;const $=y.messages.map(O=>`[${O.role}] ${O.content}`).join(`
104
+
105
+ `),w=new Blob([$],{type:"text/plain"}),z=URL.createObjectURL(w),N=document.createElement("a");N.href=z,N.download=`chat-${y.id}.txt`,N.click(),URL.revokeObjectURL(z),K.value=!1}const ne=A(null),Y=A("");function Ne(y){o.setActiveConversation(y)}function ze(y,$){ne.value=y,Y.value=$}function xe(y){const $=Y.value.trim();$&&o.renameConversation(y,$),ne.value=null}function C(){ne.value=null}function I(y,$){y.key==="Enter"?xe($):y.key==="Escape"&&C()}function ee(y){const w=Date.now()-y,z=Math.floor(w/6e4);if(z<1)return e("common.time.justNow");if(z<60)return e("dashboard.conversation.minutesAgo",{n:z});const N=Math.floor(z/60);if(N<24)return e("dashboard.conversation.hoursAgo",{n:N});const O=Math.floor(N/24);return O<7?e("dashboard.conversation.daysAgo",{n:O}):new Date(y).toLocaleDateString()}const F=A({systemPrompt:"",options:{}}),ce=A(null);let Se=null;const de=B(()=>o.activeConversation),p=B(()=>de.value?.messages??[]),k=B(()=>n.isVisionModel(M.value)),x=B(()=>{const y=oe.value??T.value;if(!y)return null;const $=i.sessionById(y);return $?.status==="error"&&$.error?$.error:null}),oe=B(()=>{const y=p.value;for(let $=y.length-1;$>=0;$--)if(y[$].sessionId)return y[$].sessionId;return null}),ye=A(e("dashboard.conversation.untitled")),Ee=A(!1),qe=A(""),wt=B(()=>de.value?.name??ye.value);function vs(){qe.value=wt.value,Ee.value=!0}function $t(){const y=qe.value.trim();if(!y){Ee.value=!1;return}de.value?o.renameConversation(de.value.id,y):ye.value=y,Ee.value=!1}function ys(){Ee.value=!1}function ks(y){y.key==="Enter"?$t():y.key==="Escape"&&ys()}Wt(async()=>{await n.fetchModels(),n.chatModelNames.length>0&&!M.value&&(M.value=n.chatModelNames[0]),await a.loadDocuments()}),ie(M,y=>{if(!y)return;const $=n.getModelDefaults(y);Object.keys($).length>0&&(F.value={systemPrompt:F.value.systemPrompt,options:{...$}})}),ie(()=>o.activeConversationId,async y=>{if(!y)return;const $=o.conversations.get(y);if($){$.model&&n.chatModelNames.includes($.model)&&(M.value=$.model);try{const w=await qs.getSessionsByConversation(y);for(const z of w)i.sessionById(z.id)||(i.sessions.set(z.id,{id:z.id,mode:z.mode,model:z.model,status:z.status,createdAt:z.createdAt,prompt:z.prompt,messages:z.messages,options:z.options,outputText:z.outputText,metrics:z.metrics,error:z.error,doneReason:z.doneReason}),i.linkSessionToConversation(z.id,y)),await d.loadTokens(z.id)}catch(w){console.error("Failed to restore sessions for conversation:",w)}}});async function St(y,$=[]){if(!M.value)return;let w=o.activeConversationId;w||(w=o.createConversation(M.value),ye.value!==e("dashboard.conversation.untitled")&&o.renameConversation(w,ye.value),ye.value=e("dashboard.conversation.untitled"));const z=o.conversations.get(w);z&&z.model!==M.value&&(z.model=M.value);const N=$.filter(Q=>Q.type==="document"&&Q.content),O=$.filter(Q=>Q.type==="image"&&Q.content);let ae=y;N.length>0&&(ae=N.map(re=>`[Attached: ${re.name}]
106
+ ${re.content}`).join(`
107
+
108
+ `)+`
109
+
110
+ ---
111
+
112
+ `+y);const ke={id:we(),conversationId:w,role:"user",content:ae,timestamp:Date.now(),isStreaming:!1,attachments:$.length>0?$:void 0};o.addMessage(w,ke);const pe=we(),Ve={id:pe,conversationId:w,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};o.addMessage(w,Ve);const ve=o.getMessagesAsOllamaFormat(w).slice(0,-1);if(O.length>0){const Q=[...ve].reverse().find(re=>re.role==="user");Q&&(Q.images=O.map(re=>re.content.replace(/^data:[^;]+;base64,/,"")))}if(F.value.systemPrompt.trim()&&ve.unshift({role:"system",content:F.value.systemPrompt.trim()}),V.value&&a.enabledDocuments.length>0)try{const Q=await a.getContextForQuery(y,M.value,5);Q&&ve.unshift({role:"system",content:Q})}catch{}let _t=ve;try{const Q=h.getSummary(w)?.summary,re=await An({conversationId:w,messages:ve,model:M.value,settings:h.settings,userFactsPrompt:h.getFactsAsSystemPrompt(),existingSummary:Q});if(_t=re.messages,re.newSummary){const he=ve.filter(Ct=>Ct.role!=="system");h.setSummary(w,re.newSummary,he.length)}}catch{}try{const Q={...de.value?.options,...F.value.options},re=l.enabledDefinitions,he=await S(M.value,_t,Q,re.length>0?re:void 0,{think:n.isThinkingModel(M.value)?F.value.think:void 0,format:F.value.format}),Tt=o.conversations.get(w)?.messages.find(fe=>fe.id===pe);Tt&&(Tt.sessionId=he),i.linkSessionToConversation(he,w);const Ms=ie(()=>i.sessionById(he)?.outputText,fe=>{fe!==void 0&&o.updateAssistantContent(w,pe,fe)}),Mt=w,Rs=y,As=ie(()=>i.sessionById(he)?.status,fe=>{if(fe==="completed"||fe==="error"||fe==="cancelled"){if(o.finalizeMessage(Mt,pe),v.value=!1,Ms(),As(),d.persistTokens(he),fe==="completed"){const Ke=i.sessionById(he),Ns=(Ke?.outputText??"").replace(/<think>[\s\S]*?<\/think>/g,"").trim(),zs=c.getMetrics(he),Es=Rn(pe,he,Ns,zs?.completionTokenCount??0,F.value.options.num_predict,Ke?.doneReason);m.setReport(pe,Es)}if(fe==="completed"&&h.settings.ragMemory.enabled&&h.settings.ragMemory.embeddingModel){const Ke=i.sessionById(he)?.outputText??"";Nn(Mt,[{role:"user",content:Rs,timestamp:ke.timestamp},{role:"assistant",content:Ke,timestamp:Date.now()}],h.settings.ragMemory.embeddingModel).catch(()=>{})}}})}catch{o.finalizeMessage(w,pe)}}function ws(){_()}function $s(){o.setActiveConversation(null),ye.value=e("dashboard.conversation.untitled")}function Ss(y){s.push({name:"session",params:{id:y}})}function _e(y){ce.value=y,Se&&clearTimeout(Se),Se=setTimeout(()=>{ce.value=null},5e3)}function _s(){ce.value=null,Se&&clearTimeout(Se)}const Cs={systemPrompt:"",options:{}};async function Ts(y,$){const w=yn(y);if(!w){_e(e("dashboard.slashCommands.notifications.unknownCommand",{name:y}));return}const z={clearConversation:()=>o.setActiveConversation(null),newChat:()=>o.setActiveConversation(null),sendAsUser:N=>St(N),copyLastResponse:()=>{const N=p.value.filter(ae=>ae.role==="assistant"),O=N[N.length-1];O?.content?(navigator.clipboard.writeText(O.content),_e(e("dashboard.slashCommands.notifications.copiedToClipboard"))):_e(e("dashboard.slashCommands.notifications.noAssistantResponseToCopy"))},exportConversation:N=>{const O=de.value;if(!O||O.messages.length===0){_e(e("dashboard.slashCommands.notifications.noConversationToExport"));return}let ae,ke;N==="json"?(ae=JSON.stringify(O.messages,null,2),ke=`chat-${O.id}.json`):(ae=O.messages.map(ve=>`[${ve.role}] ${ve.content}`).join(`
113
+
114
+ `),ke=`chat-${O.id}.txt`);const pe=new Blob([ae],{type:"text/plain"}),Ve=URL.createObjectURL(pe),Ue=document.createElement("a");Ue.href=Ve,Ue.download=ke,Ue.click(),URL.revokeObjectURL(Ve)},setSystemPrompt:N=>{F.value={...F.value,systemPrompt:N}},setOption:(N,O)=>{F.value={...F.value,options:{...F.value.options,[N]:O}}},resetSettings:()=>{F.value={...Cs}},setJsonFormat:N=>{_e(e("dashboard.slashCommands.notifications.jsonFormatToggled"))},switchModel:N=>{M.value=N},availableModels:n.chatModelNames,currentModel:M.value,toggleRag:()=>{V.value=!V.value},ragEnabled:V.value,navigate:N=>s.push(N),openSettings:()=>{H.value=!0},openSessionDetails:()=>{const N=oe.value;N?s.push({name:"session",params:{id:N}}):_e(e("dashboard.slashCommands.notifications.noActiveSession"))},addFact:N=>h.addFact(N),removeFact:N=>h.removeFactByContent(N),getFacts:()=>h.facts,showNotification:_e,messages:p.value,chatSettings:F,currentSessionId:oe.value??T.value,getSessionTokenCount:()=>{const N=oe.value??T.value;if(!N)return null;const O=c.getMetrics(N);return O?{prompt:O.promptTokenCount,completion:O.completionTokenCount}:null},getAverageSpeed:()=>{const N=c.aggregate;return N.totalSessions>0?N.avgTps:null},getOllamaStatus:async()=>{try{return{connected:(await fetch("/api/tags")).ok,model:M.value}}catch{return{connected:!1,model:M.value}}},t:(N,O)=>e(N,O??{})};await w.execute($,z)}return(y,$)=>(g(),f("div",Ki,[L(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(()=>[ce.value?(g(),f("div",Hi,[r("div",Wi,[r("p",Gi,u(ce.value),1),r("button",{class:"shrink-0 text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Dismiss notification",onClick:_s}," ✕ ")])])):E("",!0)]),_:1}),r("div",Zi,[r("div",Ji,[r("div",Qi,[r("button",{class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none hover:border-accent/50 focus:border-accent",onClick:$[0]||($[0]=w=>J.value=!J.value),onBlur:G},[M.value?(g(),f(W,{key:1},[r("span",null,u(M.value),1),L(Rt,{"model-name":M.value},null,8,["model-name"])],64)):(g(),f("span",Xi,u(y.$t("common.model.noModels")),1)),L(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",Yi,[(g(!0),f(W,null,X(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===M.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:Ze(z=>{M.value=w,J.value=!1},["prevent"])},[r("span",null,u(w),1),L(Rt,{"model-name":w},null,8,["model-name"])],42,el))),128))])):E("",!0)]),Ee.value?(g(),f("div",tl,[Z(r("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),[[te,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:y.$t("dashboard.conversation.clickToRename"),onClick:vs},[r("span",nl,u(wt.value),1),L(b(At),{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100"})],8,sl))]),r("div",ol,[oe.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(oe.value))},u(y.$t("dashboard.conversation.viewSessionDetails")),1)):E("",!0),r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",U.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[4]||($[4]=w=>U.value=!U.value)},[L(b(sn),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("dashboard.conversation.history")),1)],2),r("div",al,[r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",K.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[5]||($[5]=w=>K.value=!K.value)},[L(b(tn),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("common.actions.export")),1)],2),K.value?(g(),f("div",{key:0,class:"fixed inset-0 z-10",onClick:$[6]||($[6]=w=>K.value=!1)})):E("",!0),K.value?(g(),f("div",rl,[r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:ue},u(y.$t("dashboard.export.downloadJson")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:$e},u(y.$t("dashboard.export.downloadMarkdown")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:j},u(y.$t("dashboard.export.downloadText")),1)])):E("",!0)]),r("button",{class:"rounded-lg px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-overlay hover:text-text-primary transition-colors",onClick:$s},u(y.$t("dashboard.conversation.newChatButton")),1),r("button",{class:P(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",H.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:$[7]||($[7]=w=>H.value=!H.value)},[L(b(Os),{class:"h-3.5 w-3.5"}),r("span",null,u(y.$t("dashboard.settings.chatSettings")),1)],2)])]),r("div",il,[U.value?(g(),f("div",ll,[r("div",cl,[r("span",ul,u(y.$t("dashboard.conversation.chatHistory")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs","aria-label":"Close history",onClick:$[8]||($[8]=w=>U.value=!1)}," ✕ ")]),r("div",dl,[b(o).recentConversations.length===0?(g(),f("p",pl,u(y.$t("dashboard.conversation.noConversationsYet")),1)):(g(),f("div",hl,[(g(!0),f(W,null,X(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:z=>Ne(w.id)},[ne.value===w.id?(g(),f("div",gl,[Z(r("input",{"onUpdate:modelValue":$[9]||($[9]=z=>Y.value=z),class:"w-full rounded bg-surface px-1.5 py-0.5 text-xs text-text-primary outline-none border border-accent",onBlur:z=>xe(w.id),onKeydown:z=>I(z,w.id),onVnodeMounted:$[10]||($[10]=z=>{z.el.focus(),z.el.select()})},null,40,fl),[[te,Y.value]])])):(g(),f(W,{key:1},[r("div",bl,[r("p",xl,u(w.name),1),r("p",vl,u(w.model)+" · "+u(ee(w.updatedAt)),1)]),r("div",yl,[r("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:y.$t("dashboard.conversation.rename"),onClick:Ze(z=>ze(w.id,w.name),["stop"])},[L(b(At),{class:"h-3 w-3"})],8,kl),r("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:y.$t("common.actions.delete"),onClick:Ze(z=>b(o).deleteConversation(w.id),["stop"])},[L(b(tt),{class:"h-3 w-3"})],8,wl)])],64))],10,ml))),128))]))])])):E("",!0),r("div",$l,[x.value?(g(),f("div",Sl,[r("span",_l,u(y.$t("common.status.error"))+":",1),Ae(" "+u(x.value),1)])):E("",!0),L(na,{messages:p.value},null,8,["messages"]),L(Da,{"is-streaming":b(v),"selected-model":M.value,"is-vision-model":k.value,onSend:St,onCommand:Ts,onCancel:ws},null,8,["is-streaming","selected-model","is-vision-model"])]),H.value?(g(),f("div",Cl,[r("div",Tl,[r("span",Ml,u(y.$t("dashboard.settings.chatSettings")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:$[11]||($[11]=w=>H.value=!1)}," ✕ ")]),L(Ui,{modelValue:F.value,"onUpdate:modelValue":$[12]||($[12]=w=>F.value=w),"selected-model":M.value,"rag-enabled":V.value,"onUpdate:ragEnabled":$[13]||($[13]=w=>V.value=w)},null,8,["modelValue","selected-model","rag-enabled"])])):E("",!0)])]))}}),Al={class:"rounded-lg border border-border-default bg-surface-raised"},Nl={class:"overflow-x-auto"},zl={class:"w-full text-sm"},El=["onClick"],jl={class:"px-4 py-2 font-medium text-text-primary"},Pl={class:"px-4 py-2"},Dl={class:"px-4 py-2 text-text-secondary"},Il={class:"px-4 py-2 text-text-secondary"},Ll={class:"px-4 py-2 text-text-secondary"},Fl={class:"px-4 py-2 text-text-muted"},Bl={key:0},Ol=le({__name:"SessionHistoryTable",setup(t){const e=st();return(s,o)=>(g(),f("div",Al,[o[2]||(o[2]=r("div",{class:"px-4 py-3 border-b border-border-default"},[r("h3",{class:"text-sm font-medium text-text-secondary"},"Recent Sessions")],-1)),r("div",Nl,[r("table",zl,[o[1]||(o[1]=r("thead",null,[r("tr",{class:"border-b border-border-default text-left text-xs text-text-muted uppercase tracking-wide"},[r("th",{class:"px-4 py-2"},"Model"),r("th",{class:"px-4 py-2"},"Status"),r("th",{class:"px-4 py-2"},"Tokens"),r("th",{class:"px-4 py-2"},"Speed"),r("th",{class:"px-4 py-2"},"Duration"),r("th",{class:"px-4 py-2"},"When")])],-1)),r("tbody",null,[(g(!0),f(W,null,X(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}})},[r("td",jl,u(n.model),1),r("td",Pl,[L(Gs,{status:n.status,detail:n.error},null,8,["status","detail"])]),r("td",Dl,u(n.metrics?n.metrics.totalTokenCount:"—"),1),r("td",Il,u(n.metrics?b(Je)(n.metrics.tokensPerSecond):"—"),1),r("td",Ll,u(n.metrics?b(Jt)(n.metrics.totalDurationMs):"—"),1),r("td",Fl,u(b(Vs)(n.createdAt)),1)],8,El))),128)),b(e).recentSessions.length===0?(g(),f("tr",Bl,[...o[0]||(o[0]=[r("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):E("",!0)])])])]))}}),ql={class:"flex h-full flex-col"},Vl={class:"flex-1 min-h-0"},Ul={key:0,class:"border-t border-border-default"},Kl={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Hl={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Wl={key:1,class:"border-t border-border-default px-4 py-2"},Gl={class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},Zl={class:"flex gap-2 overflow-x-auto pb-1"},Jl=["onClick"],mc=le({__name:"DashboardPage",setup(t){const e=ut(),s=Zt(),o=A(!1),n=B(()=>e.aggregate),i=B(()=>n.value.totalSessions>0),a=B(()=>s.recentConversations);return(c,l)=>(g(),f("div",ql,[r("div",Vl,[L(Rl)]),i.value?(g(),f("div",Ul,[r("button",{class:"flex w-full items-center justify-between px-4 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:l[0]||(l[0]=h=>o.value=!o.value)},[r("span",null,u(n.value.totalSessions)+" "+u(c.$t("dashboard.metrics.sessions"))+" · Avg "+u(b(Je)(n.value.avgTps)),1),r("span",{class:P(["transition-transform",{"rotate-180":o.value}])},"▾",2)]),o.value?(g(),f("div",Kl,[r("div",Hl,[L(We,{label:c.$t("dashboard.metrics.totalSessions"),value:n.value.totalSessions},null,8,["label","value"]),L(We,{label:c.$t("dashboard.metrics.avgTtft"),value:b(Jt)(n.value.avgTtftMs)},null,8,["label","value"]),L(We,{label:c.$t("dashboard.metrics.avgSpeed"),value:b(Je)(n.value.avgTps)},null,8,["label","value"]),L(We,{label:c.$t("dashboard.metrics.totalTokens"),value:b(Re)(n.value.totalTokensGenerated),unit:"tok"},null,8,["label","value"])]),L(Ol)])):E("",!0)])):E("",!0),a.value.length>1?(g(),f("div",Wl,[r("p",Gl,u(c.$t("dashboard.metrics.recentChats")),1),r("div",Zl,[(g(!0),f(W,null,X(a.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,Jl))),128))])])):E("",!0)]))}});export{mc as default};
@@ -0,0 +1 @@
1
+ import{d as ie,r as _,a as E,o as re,n as de,b as H,e as l,g as J,f as e,j as a,B as ne,w as se,t,i as B,l as Z,W as ce,F,k as L,Y as ue,p as N,x as O,s as Q,h as P,y as oe,A as me,C as W,G as ee,u as R,D as K,q as ve,Z as pe,v as ae}from"./index-S2vqeDf7.js";import{c as I}from"./format-BqVZ9rwM.js";import{u as fe}from"./storage-store-GsT1cPEh.js";import{_ as ge}from"./StorageGauge.vue_vue_type_style_index_0_lang-BvYHZigP.js";import{_ as be}from"./_plugin-vue_export-helper-DlAUqK2U.js";const xe=ie("embeddings",()=>{const y=_([]),n=_(!1),s=_(null),b=E(()=>[...y.value].sort((v,c)=>c.timestamp-v.timestamp));async function m(v,c,p){n.value=!0,s.value=null;const S=Date.now();try{const f=(await re.embed({model:v,input:c,dimensions:p})).embeddings[0];if(!f)throw new Error("No embedding returned");const r={id:de(),model:v,input:c,vector:f,dimensions:f.length,timestamp:Date.now(),durationMs:Date.now()-S};return y.value.push(r),r}catch(M){throw s.value=M instanceof Error?M.message:"Embedding failed",M}finally{n.value=!1}}function g(v,c){if(v.length!==c.length)return 0;let p=0,S=0,M=0;for(let r=0;r<v.length;r++)p+=v[r]*c[r],S+=v[r]*v[r],M+=c[r]*c[r];const f=Math.sqrt(S)*Math.sqrt(M);return f===0?0:p/f}function x(v,c){return{score:g(v.vector,c.vector),a:v,b:c}}function z(){y.value=[]}function T(v){y.value=y.value.filter(c=>c.id!==v)}return{results:y,recentResults:b,loading:n,error:s,embed:m,cosineSimilarity:g,comparePair:x,clearResults:z,removeResult:T}}),te=H({__name:"LoadingSpinner",props:{size:{}},setup(y){return(n,s)=>(a(),l("div",{class:J(["inline-block animate-spin rounded-full border-2 border-current border-t-transparent text-accent",{"h-4 w-4":y.size==="sm"||!y.size,"h-6 w-6":y.size==="md","h-8 w-8":y.size==="lg"}]),role:"status"},[...s[0]||(s[0]=[e("span",{class:"sr-only"},"Loading...",-1)])],2))}}),he={class:"space-y-1"},ye={key:0,class:"text-xs text-text-muted"},_e=["height"],$e={class:"text-text-muted"},ke={class:"flex items-center justify-between text-[10px] text-text-muted"},G=H({__name:"EmbeddingVectorViz",props:{vector:{},label:{},height:{}},setup(y){const n=y,s=_(null),b=_(null),m=_(null),g=E(()=>n.height??120);function x(){const v=s.value,c=b.value;if(!v||!c)return;const p=v.getContext("2d");if(!p)return;const S=n.vector,M=c.clientWidth,f=g.value,r=window.devicePixelRatio||1;v.width=M*r,v.height=f*r,v.style.width=`${M}px`,v.style.height=`${f}px`,p.scale(r,r),p.clearRect(0,0,M,f);const u=M/S.length,d=f/2;let h=0;for(const w of S)Math.abs(w)>h&&(h=Math.abs(w));h===0&&(h=1);for(let w=0;w<S.length;w++){const k=S[w],C=k/h,D=Math.abs(C)*(d-2),A=.3+Math.abs(C)*.7;k>=0?(p.fillStyle=`rgba(139, 92, 246, ${A})`,p.fillRect(w*u,d-D,Math.max(u,.5),D)):(p.fillStyle=`rgba(251, 146, 60, ${A})`,p.fillRect(w*u,d,Math.max(u,.5),D))}p.strokeStyle="rgba(100, 116, 139, 0.3)",p.lineWidth=1,p.beginPath(),p.moveTo(0,d),p.lineTo(M,d),p.stroke()}function z(v){const c=s.value;if(!c)return;const p=c.getBoundingClientRect(),S=v.clientX-p.left,M=p.width/n.vector.length,f=Math.floor(S/M);f>=0&&f<n.vector.length?m.value={index:f,value:n.vector[f],x:v.clientX-p.left,y:v.clientY-p.top}:m.value=null}function T(){m.value=null}return ne(x),se(()=>n.vector,x),(v,c)=>(a(),l("div",he,[y.label?(a(),l("div",ye,t(y.label),1)):B("",!0),e("div",{ref_key:"containerRef",ref:b,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface"},[e("canvas",{ref_key:"canvasRef",ref:s,height:g.value,class:"w-full cursor-crosshair",onMousemove:z,onMouseleave:T},null,40,_e),m.value?(a(),l("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:Z({left:`${Math.min(m.value.x,(b.value?.clientWidth??200)-120)}px`,top:`${m.value.y-36}px`})},[e("span",$e,"dim["+t(m.value.index)+"]",1),e("span",{class:J(["ms-1.5 font-mono",m.value.value>=0?"text-accent":"text-warning"])},t(m.value.value.toFixed(6)),3)],4)):B("",!0)],512),e("div",ke,[c[0]||(c[0]=ce('<div class="flex items-center gap-3"><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(139,92,246)]"></span> Positive </span><span class="flex items-center gap-1"><span class="inline-block h-1.5 w-1.5 rounded-full bg-[rgb(251,146,60)]"></span> Negative </span></div>',1)),e("span",null,"All "+t(y.vector.length)+" dimensions",1)])]))}}),we={class:"grid grid-cols-4 gap-2 text-xs lg:grid-cols-8"},Me={class:"text-text-muted"},Se={class:"font-medium text-text-primary"},Ce={class:"pointer-events-none absolute bottom-full left-1/2 z-50 mb-2 -translate-x-1/2 opacity-0 transition-opacity group-hover:opacity-100"},Re={class:"w-52 rounded-lg border border-border-default bg-surface-raised px-3 py-2 text-[10px] leading-relaxed text-text-secondary shadow-lg"},ze=H({__name:"EmbeddingStats",props:{result:{}},setup(y){const n=y,s=E(()=>{const m=n.result.vector;let g=1/0,x=-1/0,z=0,T=0,v=0;for(const f of m)f<g&&(g=f),f>x&&(x=f),z+=f,T+=f*f,Math.abs(f)<.001&&v++;const c=z/m.length,p=T/m.length-c*c,S=Math.sqrt(T),M=v/m.length*100;return{dimensions:m.length,min:g.toFixed(4),max:x.toFixed(4),mean:c.toFixed(4),stdDev:Math.sqrt(Math.max(0,p)).toFixed(4),l2Norm:S.toFixed(4),sparsity:M.toFixed(1),duration:I(n.result.durationMs),memoryBytes:m.length*8}}),b=E(()=>[{key:"dims",label:"Dims",value:s.value.dimensions,tooltip:"Number of dimensions in the embedding vector. Higher dimensions capture more semantic nuance but use more memory."},{key:"min",label:"Min",value:s.value.min,tooltip:"Smallest value across all dimensions. Shows the negative activation floor of the embedding space."},{key:"max",label:"Max",value:s.value.max,tooltip:"Largest value across all dimensions. Shows the positive activation ceiling of the embedding space."},{key:"mean",label:"Mean",value:s.value.mean,tooltip:"Average value across all dimensions. Near-zero means the vector is well-centered, which is typical for normalized embeddings."},{key:"stdDev",label:"Std Dev",value:s.value.stdDev,tooltip:"Standard deviation — measures how spread out the values are. Higher means more varied activations across dimensions."},{key:"l2Norm",label:"L2 Norm",value:s.value.l2Norm,tooltip:"Euclidean length of the vector. Normalized embeddings have L2 norm close to 1.0, making cosine similarity equivalent to dot product."},{key:"sparsity",label:"Sparsity",value:`${s.value.sparsity}%`,tooltip:"Percentage of dimensions with near-zero values (|v| < 0.001). High sparsity means the text activates only a subset of the semantic dimensions."},{key:"duration",label:"Time",value:s.value.duration,tooltip:"Time taken by the model to compute the embedding vector from the input text."}]);return(m,g)=>(a(),l("div",we,[(a(!0),l(F,null,L(b.value,x=>(a(),l("div",{key:x.key,class:"group relative rounded-lg bg-surface p-2 cursor-help"},[e("div",Me,t(x.label),1),e("div",Se,t(x.value),1),e("div",Ce,[e("div",Re,t(x.tooltip),1),g[0]||(g[0]=e("div",{class:"mx-auto h-2 w-2 -translate-y-1 rotate-45 border-b border-e border-border-default bg-surface-raised"},null,-1))])]))),128))]))}}),Be={key:0,class:"relative overflow-hidden rounded-lg border border-border-default bg-surface p-4"},Te={class:"mb-3 flex items-center justify-between text-[10px] text-text-muted"},Ae={key:0},De={key:1},Ve={key:2},Fe={key:3,class:"font-mono"},Ne={class:"relative h-24 flex items-center justify-center"},Ee={key:0,class:"absolute inset-0 flex flex-wrap items-center justify-center gap-1.5 px-4"},je={key:0,class:"absolute inset-0 flex items-center justify-center"},qe={class:"flex items-end gap-px h-16"},Pe={class:"text-text-muted"},We={class:"mt-3 flex items-center justify-between"},Le={class:"flex items-center gap-3 text-[10px] text-text-muted"},Ue={key:0,class:"text-text-muted"},Ie={class:"flex items-center gap-2 text-[10px] text-text-muted shrink-0"},He=H({__name:"EmbeddingTransformViz",props:{inputText:{},isEmbedding:{type:Boolean},vector:{}},setup(y){const n=y,s=_("idle"),b=_(0),m=_(null),g=_(null),x=_(null);let z=0,T=0;const v=E(()=>n.inputText.split(/\s+/).filter(Boolean).slice(0,20)),c=E(()=>{if(!n.vector)return null;let r=0,u=0;for(const w of n.vector)w>=0?r++:u++;const d=r/n.vector.length;let h;return d>.7?h="Mostly positive activations":d<.3?h="Mostly negative activations":h="Balanced activation spread",{positive:r,negative:u,character:h}});function p(){const r=g.value,u=x.value;if(!r||!u||!n.vector)return;const d=r.getContext("2d");if(!d)return;const h=n.vector,w=u.clientWidth,k=96,C=window.devicePixelRatio||1;r.width=w*C,r.height=k*C,r.style.width=`${w}px`,r.style.height=`${k}px`,d.scale(C,C),d.clearRect(0,0,w,k);const D=w/h.length,A=k/2;let U=0;for(const j of h)Math.abs(j)>U&&(U=Math.abs(j));U===0&&(U=1);for(let j=0;j<h.length;j++){const V=h[j],X=V/U,Y=Math.abs(X)*(A-2),o=.3+Math.abs(X)*.7;V>=0?(d.fillStyle=`rgba(139, 92, 246, ${o})`,d.fillRect(j*D,A-Y,Math.max(D,.5),Y)):(d.fillStyle=`rgba(251, 146, 60, ${o})`,d.fillRect(j*D,A,Math.max(D,.5),Y))}d.strokeStyle="rgba(100, 116, 139, 0.3)",d.lineWidth=1,d.beginPath(),d.moveTo(0,A),d.lineTo(w,A),d.stroke()}function S(r){const u=g.value;if(!u||!n.vector)return;const d=u.getBoundingClientRect(),h=r.clientX-d.left,w=d.width/n.vector.length,k=Math.floor(h/w);k>=0&&k<n.vector.length?m.value={index:k,value:n.vector[k],x:r.clientX-d.left,y:r.clientY-d.top}:m.value=null}function M(){m.value=null}function f(r){T||(T=r);const u=r-T;u<600?(s.value="decomposing",b.value=u/600):u<1200&&(s.value="transforming",b.value=(u-600)/600),n.isEmbedding&&(z=requestAnimationFrame(f))}return se(()=>n.isEmbedding,r=>{r?(T=0,b.value=0,m.value=null,s.value="decomposing",z=requestAnimationFrame(f)):(cancelAnimationFrame(z),n.vector?(s.value="complete",b.value=1,oe(p)):(s.value="idle",b.value=0))}),se(()=>n.vector,()=>{s.value==="complete"&&n.vector&&oe(p)}),ue(()=>cancelAnimationFrame(z)),(r,u)=>s.value!=="idle"||y.vector?(a(),l("div",Be,[e("div",Te,[s.value==="decomposing"?(a(),l("span",Ae,"Tokenizing text...")):s.value==="transforming"?(a(),l("span",De,"Projecting into embedding space...")):s.value==="complete"&&c.value?(a(),l("span",Ve,t(c.value.character),1)):B("",!0),y.vector?(a(),l("span",Fe,t(y.vector.length)+" dimensions · "+t(c.value?.positive)+" positive · "+t(c.value?.negative)+" negative ",1)):B("",!0)]),e("div",Ne,[N(O,{name:"fade"},{default:Q(()=>[s.value==="decomposing"||s.value==="idle"&&!y.vector?(a(),l("div",Ee,[(a(!0),l(F,null,L(v.value,(d,h)=>(a(),l("span",{key:h,class:"inline-block rounded bg-accent/10 px-1.5 py-0.5 font-mono text-xs text-accent transition-all duration-500",style:Z({opacity:s.value==="decomposing"?Math.max(0,1-b.value*1.5+h*.1):1,transform:s.value==="decomposing"?`translateY(${b.value*20*(h%2===0?-1:1)}px) scale(${1-b.value*.3})`:"none"})},t(d),5))),128))])):B("",!0)]),_:1}),N(O,{name:"fade"},{default:Q(()=>[s.value==="transforming"?(a(),l("div",je,[e("div",qe,[(a(),l(F,null,L(60,d=>e("div",{key:d,class:"w-1 rounded-full transition-all duration-300",style:Z({height:`${Math.abs(Math.sin(d*.5+b.value*10))*b.value*100}%`,backgroundColor:Math.sin(d*.5+b.value*10)>=0?`rgba(139, 92, 246, ${.3+b.value*.5})`:`rgba(251, 146, 60, ${.3+b.value*.5})`,opacity:Math.min(1,b.value*2)})},null,4)),64))])])):B("",!0)]),_:1}),N(O,{name:"fade"},{default:Q(()=>[s.value==="complete"&&y.vector?(a(),l("div",{key:0,ref_key:"canvasContainerRef",ref:x,class:"absolute inset-0"},[e("canvas",{ref_key:"canvasRef",ref:g,class:"w-full h-full cursor-crosshair",onMousemove:S,onMouseleave:M},null,544),m.value?(a(),l("div",{key:0,class:"pointer-events-none absolute z-10 rounded border border-border-default bg-surface-raised px-2 py-1 text-[10px] shadow-lg",style:Z({left:`${Math.min(m.value.x,(x.value?.clientWidth??200)-120)}px`,top:`${m.value.y-36}px`})},[e("span",Pe,"dim["+t(m.value.index)+"]",1),e("span",{class:J(["ms-1.5 font-mono",m.value.value>=0?"text-accent":"text-warning"])},t(m.value.value.toFixed(6)),3)],4)):B("",!0)],512)):B("",!0)]),_:1})]),e("div",We,[e("div",Le,[u[0]||(u[0]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(139,92,246)]"}),P(" Positive activation ")],-1)),u[1]||(u[1]=e("span",{class:"flex items-center gap-1"},[e("span",{class:"inline-block h-2 w-2 rounded-full bg-[rgb(251,146,60)]"}),P(" Negative activation ")],-1)),s.value==="complete"?(a(),l("span",Ue," · Each bar = one semantic dimension. Taller = stronger signal. ")):B("",!0)]),e("div",Ie,[u[2]||(u[2]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Text",-1)),u[3]||(u[3]=e("span",null,"→",-1)),u[4]||(u[4]=e("span",{class:"rounded bg-surface-overlay px-1.5 py-0.5"},"Tokens",-1)),u[5]||(u[5]=e("span",null,"→",-1)),e("span",{class:J(["rounded px-1.5 py-0.5",s.value==="complete"?"bg-accent/10 text-accent":"bg-surface-overlay"])}," Vector ",2)])])])):B("",!0)}}),Xe=be(He,[["__scopeId","data-v-07aa1650"]]),Ye={class:"flex flex-col items-center gap-2"},Ke={class:"relative h-32 w-32"},Ze={viewBox:"0 0 100 100",class:"h-full w-full -rotate-90"},Ge=["stroke","stroke-dasharray"],Je={class:"absolute inset-0 flex flex-col items-center justify-center"},Oe={class:"text-2xl font-bold text-text-primary"},le=H({__name:"SimilarityMeter",props:{score:{}},setup(y){const n=y,s=E(()=>Math.round(n.score*100)),b=E(()=>n.score>=.8?"#4ade80":n.score>=.5?"#fbbf24":"#f87171"),m=E(()=>n.score>=.9?"Very Similar":n.score>=.7?"Similar":n.score>=.5?"Somewhat Similar":n.score>=.3?"Weakly Related":"Dissimilar");return(g,x)=>(a(),l("div",Ye,[e("div",Ke,[(a(),l("svg",Ze,[x[0]||(x[0]=e("circle",{cx:"50",cy:"50",r:"42",fill:"none",class:"stroke-surface-overlay","stroke-width":"8"},null,-1)),e("circle",{cx:"50",cy:"50",r:"42",fill:"none",stroke:b.value,"stroke-width":"8","stroke-linecap":"round","stroke-dasharray":`${s.value*2.64} 264`},null,8,Ge)])),e("div",Je,[e("span",Oe,t(s.value)+"%",1)])]),e("span",{class:"text-sm font-medium",style:Z({color:b.value})},t(m.value),5),x[1]||(x[1]=e("span",{class:"text-xs text-text-muted"},"Cosine Similarity",-1))]))}}),Qe={class:"space-y-8"},et={class:"flex items-center gap-3"},tt={key:0,value:"",disabled:""},st=["value"],ot={key:0,class:"text-xs text-warning"},at={class:"flex items-center gap-2"},lt={for:"embed-dimensions",class:"text-xs font-medium text-text-secondary"},nt=["placeholder"],it={class:"text-[11px] text-text-muted"},rt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},dt={class:"text-base font-semibold text-text-primary"},ct={class:"text-sm text-text-muted"},ut=["placeholder","disabled","onKeydown"],mt={class:"flex items-center gap-3"},vt=["disabled"],pt={key:0,class:"flex items-center gap-2"},ft={key:1},gt={key:0,class:"text-sm text-error"},bt={class:"text-xs"},xt={class:"cursor-pointer text-text-muted hover:text-text-secondary"},ht={class:"mt-2 grid grid-cols-5 gap-1 font-mono text-text-secondary"},yt=["title"],_t={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},$t={class:"text-base font-semibold text-text-primary"},kt={class:"text-sm text-text-muted"},wt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Mt={class:"block text-xs font-medium text-text-muted mb-1"},St=["placeholder","disabled"],Ct={class:"block text-xs font-medium text-text-muted mb-1"},Rt=["placeholder","disabled"],zt=["disabled"],Bt={key:0,class:"flex items-center gap-2"},Tt={key:1},At={key:0,class:"flex flex-col items-center gap-6 py-4 lg:flex-row lg:items-start lg:justify-center"},Dt={class:"flex-1 space-y-2"},Vt={class:"text-xs font-medium text-text-muted"},Ft={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},Nt={class:"flex-1 space-y-2"},Et={class:"text-xs font-medium text-text-muted"},jt={class:"rounded-lg bg-surface p-3 text-sm text-text-secondary"},qt={class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},Pt={class:"text-base font-semibold text-text-primary"},Wt={class:"text-sm text-text-muted"},Lt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},Ut={class:"block text-xs font-medium text-text-muted mb-1"},It=["disabled"],Ht=["value"],Xt={class:"block text-xs font-medium text-text-muted mb-1"},Yt=["disabled"],Kt=["value"],Zt=["placeholder","disabled"],Gt=["disabled"],Jt={key:0,class:"flex items-center gap-2"},Ot={key:1},Qt={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},es={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},ts={class:"flex items-center justify-between"},ss={class:"text-xs font-medium text-accent"},os={class:"text-[10px] text-text-muted"},as={class:"grid grid-cols-4 gap-1.5 text-[10px]"},ls={class:"rounded bg-surface-overlay p-1.5"},ns={class:"text-text-muted"},is={class:"font-medium text-text-primary"},rs={class:"rounded bg-surface-overlay p-1.5"},ds={class:"text-text-muted"},cs={class:"font-medium text-text-primary"},us={class:"rounded bg-surface-overlay p-1.5"},ms={class:"text-text-muted"},vs={class:"font-medium text-text-primary"},ps={class:"rounded bg-surface-overlay p-1.5"},fs={class:"text-text-muted"},gs={class:"font-medium text-text-primary"},bs={class:"space-y-3 rounded-lg border border-border-default bg-surface p-3"},xs={class:"flex items-center justify-between"},hs={class:"text-xs font-medium text-accent"},ys={class:"text-[10px] text-text-muted"},_s={class:"grid grid-cols-4 gap-1.5 text-[10px]"},$s={class:"rounded bg-surface-overlay p-1.5"},ks={class:"text-text-muted"},ws={class:"font-medium text-text-primary"},Ms={class:"rounded bg-surface-overlay p-1.5"},Ss={class:"text-text-muted"},Cs={class:"font-medium text-text-primary"},Rs={class:"rounded bg-surface-overlay p-1.5"},zs={class:"text-text-muted"},Bs={class:"font-medium text-text-primary"},Ts={class:"rounded bg-surface-overlay p-1.5"},As={class:"text-text-muted"},Ds={class:"font-medium text-text-primary"},Vs={class:"rounded-lg border border-border-default bg-surface p-4 text-center"},Fs={class:"mt-2 text-xs text-text-muted"},Ns={class:"text-sm text-text-muted py-2"},Es={class:"text-xs text-text-muted"},js={key:1,class:"rounded-lg border border-border-default bg-surface-raised p-5 space-y-4"},qs={class:"flex items-center justify-between"},Ps={class:"text-base font-semibold text-text-primary"},Ws={class:"space-y-2"},Ls=["onClick"],Us={class:"flex-1 min-w-0"},Is={class:"truncate text-sm text-text-primary"},Hs={class:"flex gap-3 text-xs text-text-muted mt-0.5"},Xs=["onClick"],Os=H({__name:"EmbeddingsPage",setup(y){const n=me(),s=xe(),b=fe(),m=E(()=>b.getDatabaseById("message-memory")),g=_(""),x=_(""),z=_(null),T=_(0),v=E(()=>g.value?n.getEmbeddingLength(g.value):void 0),c=E(()=>T.value>0?T.value:void 0),p=_(""),S=_(""),M=_(null),f=_(null),r=_(null),u=_(!1),d=_(""),h=_(""),w=_(""),k=_(null),C=_(null),D=_(null),A=_(!1);async function U(){if(!(!d.value||!h.value||!w.value.trim())){A.value=!0,D.value=null,k.value=null,C.value=null;try{const[o,$]=await Promise.all([s.embed(d.value,w.value.trim(),c.value),s.embed(h.value,w.value.trim(),c.value)]);k.value=o,C.value=$,o.dimensions===$.dimensions&&(D.value=s.cosineSimilarity(o.vector,$.vector))}catch{}finally{A.value=!1}}}const j=E(()=>{const o=new Set(n.embeddingModelNames);return n.models.filter($=>o.has($.name))}),V=E(()=>j.value.length>0?j.value:n.models);async function X(){if(!(!g.value||!x.value.trim()))try{z.value=await s.embed(g.value,x.value.trim(),c.value)}catch{}}async function Y(){if(!(!g.value||!p.value.trim()||!S.value.trim())){u.value=!0,r.value=null;try{const[o,$]=await Promise.all([s.embed(g.value,p.value.trim(),c.value),s.embed(g.value,S.value.trim(),c.value)]);M.value=o,f.value=$,r.value=s.cosineSimilarity(o.vector,$.vector)}catch{}finally{u.value=!1}}}return ne(async()=>{n.models.length===0&&await n.fetchModels(),V.value.length>0&&!g.value&&(g.value=V.value[0].name),V.value.length>=2?(d.value=V.value[0].name,h.value=V.value[1].name):V.value.length===1&&(d.value=V.value[0].name,h.value=V.value[0].name),await b.refreshIfStale()}),(o,$)=>(a(),l("div",Qe,[e("div",et,[W(e("select",{"onUpdate:modelValue":$[0]||($[0]=i=>g.value=i),class:"rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"},[V.value.length===0?(a(),l("option",tt,t(o.$t("embeddings.modelSelector.noModels")),1)):B("",!0),(a(!0),l(F,null,L(V.value,i=>(a(),l("option",{key:i.name,value:i.name},t(i.name)+" "+t(R(n).capabilityIcons(i.name)),9,st))),128))],512),[[ee,g.value]]),j.value.length===0&&R(n).models.length>0?(a(),l("span",ot,t(o.$t("embeddings.modelSelector.noEmbeddingModels")),1)):B("",!0),e("div",at,[e("label",lt,t(o.$t("embeddings.dimensions.label")),1),W(e("input",{id:"embed-dimensions","onUpdate:modelValue":$[1]||($[1]=i=>T.value=i),type:"number",min:"0",step:"1",class:"w-24 rounded-lg border border-border-default bg-surface px-2 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:v.value?String(v.value):o.$t("embeddings.dimensions.native")},null,8,nt),[[K,T.value,void 0,{number:!0}]]),e("span",it,t(c.value?o.$t("embeddings.dimensions.truncated"):o.$t("embeddings.dimensions.hint")),1)])]),R(b).origin&&m.value?(a(),ve(ge,{key:0,used:m.value.totalBytes,total:R(b).origin.quota,compact:"",label:`${o.$t("embeddings.storage.embeddingMemory")} · ${m.value.recordCount.toLocaleString()} ${o.$t("embeddings.storage.records")}`},null,8,["used","total","label"])):B("",!0),e("section",rt,[e("h2",dt,t(o.$t("embeddings.playground.title")),1),e("p",ct,t(o.$t("embeddings.playground.description")),1),W(e("textarea",{"onUpdate:modelValue":$[2]||($[2]=i=>x.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:o.$t("embeddings.playground.placeholder"),disabled:R(s).loading,onKeydown:pe(ae(X,["ctrl"]),["enter"])},null,40,ut),[[K,x.value]]),e("div",mt,[e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:R(s).loading||!g.value||!x.value.trim(),onClick:X},[R(s).loading?(a(),l("span",pt,[N(te,{size:"sm"}),P(" "+t(o.$t("embeddings.playground.embedding")),1)])):(a(),l("span",ft,t(o.$t("embeddings.playground.embed")),1))],8,vt),R(s).error?(a(),l("span",gt,t(R(s).error),1)):B("",!0)]),N(Xe,{"input-text":x.value,"is-embedding":R(s).loading,vector:z.value?.vector??null},null,8,["input-text","is-embedding","vector"]),z.value?(a(),l(F,{key:0},[N(ze,{result:z.value},null,8,["result"]),e("details",bt,[e("summary",xt,t(o.$t("embeddings.playground.showRawValues",{total:z.value.dimensions})),1),e("div",ht,[(a(!0),l(F,null,L(z.value.vector.slice(0,50),(i,q)=>(a(),l("span",{key:q,class:"rounded bg-surface px-1.5 py-0.5",title:`dim[${q}]`},t(i.toFixed(4)),9,yt))),128))])])],64)):B("",!0)]),e("section",_t,[e("h2",$t,t(o.$t("embeddings.similarity.title")),1),e("p",kt,t(o.$t("embeddings.similarity.description")),1),e("div",wt,[e("div",null,[e("label",Mt,t(o.$t("embeddings.similarity.textA")),1),W(e("textarea",{"onUpdate:modelValue":$[3]||($[3]=i=>p.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:o.$t("embeddings.similarity.placeholderA"),disabled:u.value},null,8,St),[[K,p.value]])]),e("div",null,[e("label",Ct,t(o.$t("embeddings.similarity.textB")),1),W(e("textarea",{"onUpdate:modelValue":$[4]||($[4]=i=>S.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"3",placeholder:o.$t("embeddings.similarity.placeholderB"),disabled:u.value},null,8,Rt),[[K,S.value]])])]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:u.value||!g.value||!p.value.trim()||!S.value.trim(),onClick:Y},[u.value?(a(),l("span",Bt,[N(te,{size:"sm"}),P(" "+t(o.$t("embeddings.similarity.comparing")),1)])):(a(),l("span",Tt,t(o.$t("embeddings.similarity.compare")),1))],8,zt),r.value!==null&&M.value&&f.value?(a(),l("div",At,[e("div",Dt,[e("div",Vt,t(o.$t("embeddings.similarity.textA")),1),e("div",Ft,t(M.value.input),1),N(G,{vector:M.value.vector,height:80},null,8,["vector"])]),N(le,{score:r.value},null,8,["score"]),e("div",Nt,[e("div",Et,t(o.$t("embeddings.similarity.textB")),1),e("div",jt,t(f.value.input),1),N(G,{vector:f.value.vector,height:80},null,8,["vector"])])])):B("",!0)]),e("section",qt,[e("h2",Pt,t(o.$t("embeddings.modelComparison.title")),1),e("p",Wt,t(o.$t("embeddings.modelComparison.description")),1),e("div",Lt,[e("div",null,[e("label",Ut,t(o.$t("embeddings.modelComparison.modelA")),1),W(e("select",{"onUpdate:modelValue":$[5]||($[5]=i=>d.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:A.value},[(a(!0),l(F,null,L(V.value,i=>(a(),l("option",{key:i.name,value:i.name},t(i.name)+" "+t(R(n).capabilityIcons(i.name)),9,Ht))),128))],8,It),[[ee,d.value]])]),e("div",null,[e("label",Xt,t(o.$t("embeddings.modelComparison.modelB")),1),W(e("select",{"onUpdate:modelValue":$[6]||($[6]=i=>h.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary outline-none focus:border-accent",disabled:A.value},[(a(!0),l(F,null,L(V.value,i=>(a(),l("option",{key:i.name,value:i.name},t(i.name)+" "+t(R(n).capabilityIcons(i.name)),9,Kt))),128))],8,Yt),[[ee,h.value]])])]),W(e("textarea",{"onUpdate:modelValue":$[7]||($[7]=i=>w.value=i),class:"w-full rounded-lg border border-border-default bg-surface px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",rows:"2",placeholder:o.$t("embeddings.modelComparison.placeholder"),disabled:A.value},null,8,Zt),[[K,w.value]]),e("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors disabled:opacity-50",disabled:A.value||!d.value||!h.value||!w.value.trim(),onClick:U},[A.value?(a(),l("span",Jt,[N(te,{size:"sm"}),P(" "+t(o.$t("embeddings.modelComparison.comparingModels")),1)])):(a(),l("span",Ot,t(o.$t("embeddings.modelComparison.compareModels")),1))],8,Gt),k.value&&C.value?(a(),l(F,{key:0},[e("div",Qt,[e("div",es,[e("div",ts,[e("span",ss,t(k.value.model),1),e("span",os,t(k.value.dimensions)+"d · "+t(R(I)(k.value.durationMs)),1)]),N(G,{vector:k.value.vector,height:80},null,8,["vector"]),e("div",as,[e("div",ls,[e("div",ns,t(o.$t("embeddings.stats.dims")),1),e("div",is,t(k.value.dimensions),1)]),e("div",rs,[e("div",ds,t(o.$t("embeddings.stats.l2Norm")),1),e("div",cs,t(Math.sqrt(k.value.vector.reduce((i,q)=>i+q*q,0)).toFixed(2)),1)]),e("div",us,[e("div",ms,t(o.$t("embeddings.stats.sparsity")),1),e("div",vs,t((k.value.vector.filter(i=>Math.abs(i)<.001).length/k.value.dimensions*100).toFixed(1))+"%",1)]),e("div",ps,[e("div",fs,t(o.$t("embeddings.stats.time")),1),e("div",gs,t(R(I)(k.value.durationMs)),1)])])]),e("div",bs,[e("div",xs,[e("span",hs,t(C.value.model),1),e("span",ys,t(C.value.dimensions)+"d · "+t(R(I)(C.value.durationMs)),1)]),N(G,{vector:C.value.vector,height:80},null,8,["vector"]),e("div",_s,[e("div",$s,[e("div",ks,t(o.$t("embeddings.stats.dims")),1),e("div",ws,t(C.value.dimensions),1)]),e("div",Ms,[e("div",Ss,t(o.$t("embeddings.stats.l2Norm")),1),e("div",Cs,t(Math.sqrt(C.value.vector.reduce((i,q)=>i+q*q,0)).toFixed(2)),1)]),e("div",Rs,[e("div",zs,t(o.$t("embeddings.stats.sparsity")),1),e("div",Bs,t((C.value.vector.filter(i=>Math.abs(i)<.001).length/C.value.dimensions*100).toFixed(1))+"%",1)]),e("div",Ts,[e("div",As,t(o.$t("embeddings.stats.time")),1),e("div",Ds,t(R(I)(C.value.durationMs)),1)])])])]),e("div",Vs,[D.value!==null?(a(),l(F,{key:0},[N(le,{score:D.value},null,8,["score"]),e("p",Fs,[P(t(o.$t("embeddings.modelComparison.crossModelSimilarity"))+" ",1),D.value<.5?(a(),l(F,{key:0},[P(t(o.$t("embeddings.modelComparison.veryDifferent")),1)],64)):D.value<.8?(a(),l(F,{key:1},[P(t(o.$t("embeddings.modelComparison.moderateAgreement")),1)],64)):(a(),l(F,{key:2},[P(t(o.$t("embeddings.modelComparison.highAgreement")),1)],64))])],64)):(a(),l(F,{key:1},[e("p",Ns,t(o.$t("embeddings.modelComparison.dimensionsMismatch",{dimA:k.value.dimensions,dimB:C.value.dimensions})),1),e("p",Es,t(o.$t("embeddings.modelComparison.compareStats")),1)],64))])],64)):B("",!0)]),R(s).recentResults.length>0?(a(),l("section",js,[e("div",qs,[e("h2",Ps,t(o.$t("embeddings.history.title")),1),e("button",{class:"text-xs text-text-muted hover:text-error transition-colors",onClick:$[8]||($[8]=i=>R(s).clearResults())},t(o.$t("embeddings.history.clearAll")),1)]),e("div",Ws,[(a(!0),l(F,null,L(R(s).recentResults.slice(0,10),i=>(a(),l("div",{key:i.id,class:"flex items-center justify-between rounded-lg bg-surface px-4 py-2 hover:bg-surface-overlay transition-colors cursor-pointer",onClick:q=>z.value=i},[e("div",Us,[e("div",Is,t(i.input),1),e("div",Hs,[e("span",null,t(i.model),1),e("span",null,t(i.dimensions)+"d",1),e("span",null,t(R(I)(i.durationMs)),1)])]),e("button",{class:"ms-3 text-text-muted hover:text-error text-xs",onClick:ae(q=>R(s).removeResult(i.id),["stop"])}," ✕ ",8,Xs)],8,Ls))),128))])])):B("",!0)]))}});export{Os as default};
@@ -1,4 +1,4 @@
1
- import{b as R,z as U,A as O,B as j,e as l,f as e,t as o,p as $,u as v,C,G as J,F as V,k as F,i as u,D as z,h as E,r as m,a as y,o as L,j as a}from"./index-CZ4a6rAU.js";import{I as W}from"./info-C9qZFgvQ.js";import{P as H}from"./play-CYCSil_U.js";import{S as K}from"./square-Dtyb8Nls.js";const Q={class:"flex h-full flex-col overflow-y-auto p-6"},X={class:"mx-auto w-full max-w-4xl space-y-4"},Y={class:"text-lg font-semibold text-text-primary"},Z={class:"mt-1 text-xs text-text-muted"},ee={class:"flex gap-2 rounded-lg border border-accent/20 bg-accent/5 p-3 text-xs text-text-secondary"},te={class:"mb-1 block text-xs text-text-muted"},oe=["label"],se=["value"],le=["label"],ae=["value"],re={key:0,class:"mt-1 text-[10px] text-warning"},ne={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},de={class:"mb-1 block text-xs text-text-muted"},ie=["placeholder"],ce={class:"mb-1 block text-xs text-text-muted"},ue=["placeholder"],me={class:"flex gap-2"},fe=["disabled"],pe={key:0},xe={class:"mb-1 block text-xs text-text-muted"},ve={class:"rounded-lg border border-border-default bg-surface px-3 py-2 font-mono text-xs whitespace-pre-wrap"},be={key:0,class:"text-accent"},_e={key:1,class:"text-text-muted italic"},he={key:2,class:"text-error"},ge={key:0,class:"mt-3"},ye={class:"mb-1 block text-xs text-text-muted"},ke={class:"rounded-lg border border-border-default bg-surface px-3 py-2 font-mono text-xs whitespace-pre-wrap"},we={class:"text-text-secondary"},$e={class:"bg-accent/10 text-accent"},Ce={class:"text-text-secondary"},Me={key:1,class:"grid grid-cols-2 gap-3 sm:grid-cols-4"},De={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ne={class:"text-[10px] text-text-muted"},Se={class:"mt-0.5 text-sm font-medium text-text-primary"},Pe={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ve={class:"text-[10px] text-text-muted"},Fe={class:"mt-0.5 text-sm font-medium text-text-primary"},ze={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ee={class:"text-[10px] text-text-muted"},Ie={class:"mt-0.5 text-sm font-medium text-text-primary"},Te={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ae={class:"text-[10px] text-text-muted"},Be={class:"mt-0.5 text-sm font-medium text-text-primary"},je=R({__name:"FimPlaygroundPage",setup(qe){const{t:M}=U(),p=O(),d=m(""),b=m(`def fibonacci(n):
1
+ import{b as R,z as U,A as O,B as j,e as l,f as e,t as o,p as $,u as v,C,G as J,F as V,k as F,i as u,D as z,h as E,r as m,a as y,o as L,j as a}from"./index-S2vqeDf7.js";import{I as W}from"./info-47X0r1B2.js";import{P as H}from"./play-DT41vD7M.js";import{S as K}from"./square-CbKkOlNA.js";const Q={class:"flex h-full flex-col overflow-y-auto p-6"},X={class:"mx-auto w-full max-w-4xl space-y-4"},Y={class:"text-lg font-semibold text-text-primary"},Z={class:"mt-1 text-xs text-text-muted"},ee={class:"flex gap-2 rounded-lg border border-accent/20 bg-accent/5 p-3 text-xs text-text-secondary"},te={class:"mb-1 block text-xs text-text-muted"},oe=["label"],se=["value"],le=["label"],ae=["value"],re={key:0,class:"mt-1 text-[10px] text-warning"},ne={class:"grid grid-cols-1 gap-4 lg:grid-cols-2"},de={class:"mb-1 block text-xs text-text-muted"},ie=["placeholder"],ce={class:"mb-1 block text-xs text-text-muted"},ue=["placeholder"],me={class:"flex gap-2"},fe=["disabled"],pe={key:0},xe={class:"mb-1 block text-xs text-text-muted"},ve={class:"rounded-lg border border-border-default bg-surface px-3 py-2 font-mono text-xs whitespace-pre-wrap"},be={key:0,class:"text-accent"},_e={key:1,class:"text-text-muted italic"},he={key:2,class:"text-error"},ge={key:0,class:"mt-3"},ye={class:"mb-1 block text-xs text-text-muted"},ke={class:"rounded-lg border border-border-default bg-surface px-3 py-2 font-mono text-xs whitespace-pre-wrap"},we={class:"text-text-secondary"},$e={class:"bg-accent/10 text-accent"},Ce={class:"text-text-secondary"},Me={key:1,class:"grid grid-cols-2 gap-3 sm:grid-cols-4"},De={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ne={class:"text-[10px] text-text-muted"},Se={class:"mt-0.5 text-sm font-medium text-text-primary"},Pe={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ve={class:"text-[10px] text-text-muted"},Fe={class:"mt-0.5 text-sm font-medium text-text-primary"},ze={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ee={class:"text-[10px] text-text-muted"},Ie={class:"mt-0.5 text-sm font-medium text-text-primary"},Te={class:"rounded-lg border border-border-default bg-surface px-3 py-2"},Ae={class:"text-[10px] text-text-muted"},Be={class:"mt-0.5 text-sm font-medium text-text-primary"},je=R({__name:"FimPlaygroundPage",setup(qe){const{t:M}=U(),p=O(),d=m(""),b=m(`def fibonacci(n):
2
2
  if n <= 1:
3
3
  return n
4
4
  `),_=m(`
@@ -1 +1 @@
1
- import{b as g,B as p,e as n,f as t,F as i,h as b,t as x,u as c,av as v,H as y,r as f,j as a}from"./index-CZ4a6rAU.js";import{u as k}from"./google-auth-store-LaJFtciC.js";import"./google-auth-CfEcVMA7.js";const w={class:"flex items-center justify-center h-full"},C={class:"rounded-xl border border-border-default bg-surface-raised p-8 shadow-lg w-[400px] text-center"},G={class:"text-xs text-text-muted mt-2"},h={class:"text-text-primary font-medium"},B={class:"text-xs text-error mt-2"},z=g({__name:"GoogleCallbackPage",setup(S){const u=v(),d=y(),m=k(),s=f("loading"),r=f("");return p(async()=>{const l=u.query.code,e=u.query.error;if(e){s.value="error",r.value=`Google authorization was denied: ${e}`;return}if(!l){s.value="error",r.value="No authorization code received from Google.";return}try{await m.handleOAuthCallback(l),s.value="success",setTimeout(()=>d.replace("/settings"),1500)}catch(o){s.value="error",r.value=o instanceof Error?o.message:String(o)}}),(l,e)=>(a(),n("div",w,[t("div",C,[s.value==="loading"?(a(),n(i,{key:0},[e[1]||(e[1]=t("div",{class:"inline-block h-8 w-8 rounded-full border-2 border-accent border-t-transparent animate-spin mb-4"},null,-1)),e[2]||(e[2]=t("h3",{class:"text-sm font-medium text-text-primary"},"Connecting Google Account",-1)),e[3]||(e[3]=t("p",{class:"text-xs text-text-muted mt-2"},"Exchanging authorization code for tokens...",-1))],64)):s.value==="success"?(a(),n(i,{key:1},[e[5]||(e[5]=t("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-success/10 mb-4"},[t("span",{class:"text-success text-lg"},"✓")],-1)),e[6]||(e[6]=t("h3",{class:"text-sm font-medium text-text-primary"},"Google Account Connected",-1)),t("p",G,[e[4]||(e[4]=b(" Connected as ",-1)),t("span",h,x(c(m).userEmail??"unknown"),1)]),e[7]||(e[7]=t("p",{class:"text-[10px] text-text-muted mt-3"},"Redirecting to Settings...",-1))],64)):(a(),n(i,{key:2},[e[8]||(e[8]=t("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-error/10 mb-4"},[t("span",{class:"text-error text-lg"},"✗")],-1)),e[9]||(e[9]=t("h3",{class:"text-sm font-medium text-text-primary"},"Connection Failed",-1)),t("p",B,x(r.value),1),t("button",{class:"mt-4 rounded-lg bg-surface-overlay px-4 py-2 text-xs text-text-primary hover:bg-border-default transition-colors",onClick:e[0]||(e[0]=o=>c(d).push("/settings"))}," Back to Settings ")],64))])]))}});export{z as default};
1
+ import{b as g,B as p,e as n,f as t,F as i,h as b,t as x,u as c,av as v,H as y,r as f,j as a}from"./index-S2vqeDf7.js";import{u as k}from"./google-auth-store-Db6JKC8L.js";import"./google-auth-CfEcVMA7.js";const w={class:"flex items-center justify-center h-full"},C={class:"rounded-xl border border-border-default bg-surface-raised p-8 shadow-lg w-[400px] text-center"},G={class:"text-xs text-text-muted mt-2"},h={class:"text-text-primary font-medium"},B={class:"text-xs text-error mt-2"},z=g({__name:"GoogleCallbackPage",setup(S){const u=v(),d=y(),m=k(),s=f("loading"),r=f("");return p(async()=>{const l=u.query.code,e=u.query.error;if(e){s.value="error",r.value=`Google authorization was denied: ${e}`;return}if(!l){s.value="error",r.value="No authorization code received from Google.";return}try{await m.handleOAuthCallback(l),s.value="success",setTimeout(()=>d.replace("/settings"),1500)}catch(o){s.value="error",r.value=o instanceof Error?o.message:String(o)}}),(l,e)=>(a(),n("div",w,[t("div",C,[s.value==="loading"?(a(),n(i,{key:0},[e[1]||(e[1]=t("div",{class:"inline-block h-8 w-8 rounded-full border-2 border-accent border-t-transparent animate-spin mb-4"},null,-1)),e[2]||(e[2]=t("h3",{class:"text-sm font-medium text-text-primary"},"Connecting Google Account",-1)),e[3]||(e[3]=t("p",{class:"text-xs text-text-muted mt-2"},"Exchanging authorization code for tokens...",-1))],64)):s.value==="success"?(a(),n(i,{key:1},[e[5]||(e[5]=t("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-success/10 mb-4"},[t("span",{class:"text-success text-lg"},"✓")],-1)),e[6]||(e[6]=t("h3",{class:"text-sm font-medium text-text-primary"},"Google Account Connected",-1)),t("p",G,[e[4]||(e[4]=b(" Connected as ",-1)),t("span",h,x(c(m).userEmail??"unknown"),1)]),e[7]||(e[7]=t("p",{class:"text-[10px] text-text-muted mt-3"},"Redirecting to Settings...",-1))],64)):(a(),n(i,{key:2},[e[8]||(e[8]=t("div",{class:"inline-flex items-center justify-center h-10 w-10 rounded-full bg-error/10 mb-4"},[t("span",{class:"text-error text-lg"},"✗")],-1)),e[9]||(e[9]=t("h3",{class:"text-sm font-medium text-text-primary"},"Connection Failed",-1)),t("p",B,x(r.value),1),t("button",{class:"mt-4 rounded-lg bg-surface-overlay px-4 py-2 text-xs text-text-primary hover:bg-border-default transition-colors",onClick:e[0]||(e[0]=o=>c(d).push("/settings"))}," Back to Settings ")],64))])]))}});export{z as default};
@@ -1,4 +1,4 @@
1
- import{b as S,r as L,e as g,l as O,u as w,v as E,g as v,f as d,t as m,i as j,F as k,k as R,q as C,am as x,j as h}from"./index-CZ4a6rAU.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";function H(e,c="json"){if(e.length===0)return`return ${c}`;const t=e.map(a=>K(a)),s=new Map;for(const a of t)s.set(a,(s.get(a)??0)+1);const r=e.map((a,y)=>{let f=t[y];return(s.get(f)??0)>1&&(f=N(a)),` ${f}: ${c}.${a}`});return r.length===1?`return {${r[0].trim().replace(/^/," ").replace(/$/," ")}}`:`return {
1
+ import{b as S,r as L,e as g,l as O,u as w,v as E,g as v,f as d,t as m,i as j,F as k,k as R,q as C,am as x,j as h}from"./index-S2vqeDf7.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";function H(e,c="json"){if(e.length===0)return`return ${c}`;const t=e.map(a=>K(a)),s=new Map;for(const a of t)s.set(a,(s.get(a)??0)+1);const r=e.map((a,y)=>{let f=t[y];return(s.get(f)??0)>1&&(f=N(a)),` ${f}: ${c}.${a}`});return r.length===1?`return {${r[0].trim().replace(/^/," ").replace(/$/," ")}}`:`return {
2
2
  ${r.join(`,
3
3
  `)}
4
4
  }`}function K(e){const t=e.replace(/\[\d+\]/g,"").split(".");return t[t.length-1]??e}function N(e){const t=e.replace(/\[\d+\]/g,"").split(".");return t.length>=2?`${t[t.length-2]}_${t[t.length-1]}`:t[t.length-1]??e}function ne(e){if(e.length===0)return[];const c=e.map(s=>K(s)),t=new Map;for(const s of c)t.set(s,(t.get(s)??0)+1);return e.map((s,r)=>{let a=c[r];return(t.get(a)??0)>1&&(a=N(s)),{jsonPath:s,returnKey:a}})}function se(e,c){const t={},s=[];for(const r of e){const a=V(c,r.jsonPath);t[r.returnKey]={type:I(a)},s.push(r.returnKey)}return{type:"object",properties:t,required:s}}function V(e,c){const t=c.replace(/\[(\d+)\]/g,".$1").split(".");let s=e;for(const r of t){if(s==null||typeof s!="object")return;s=s[r]}return s}function I(e){return e==null||typeof e=="string"?"string":typeof e=="number"?Number.isInteger(e)?"integer":"number":typeof e=="boolean"?"boolean":Array.isArray(e)?"array":typeof e=="object"?"object":"string"}function re(e,c,t){const s=H(c),r=[],a=t?.method??"GET",y=t?.headers??{},f=t?.body,T=new Set(t?.secretHeaders??[]),u={};for(const[o,i]of Object.entries(y)){if(T.has(o)){const p=o.replace(/-/g,"_").toUpperCase();u[o]=`__ENV_${p}__`;continue}const l=o.toLowerCase();l==="authorization"?i.toLowerCase().startsWith("bearer ")?(r.push({name:"apiKey",type:"string"}),u[o]="__BEARER_PARAM__"):(r.push({name:"apiKey",type:"string"}),u[o]="__AUTH_PARAM__"):l.startsWith("x-api")||l.includes("api-key")||l.includes("apikey")?(r.push({name:"apiKey",type:"string"}),u[o]="__APIKEY_PARAM__"):u[o]=i}const $=Object.keys(u).length>0,b=f&&(a==="POST"||a==="PUT"),P=a!=="GET"||$||b;let _;if(!P)_=`const res = await fetch("${e}")`;else{const o=[];if(a!=="GET"&&o.push(` method: "${a}"`),$){const i=Object.entries(u).map(([l,p])=>{if(p==="__BEARER_PARAM__")return` "${l}": "Bearer " + apiKey`;if(p==="__AUTH_PARAM__")return` "${l}": apiKey`;if(p==="__APIKEY_PARAM__")return` "${l}": apiKey`;if(p.startsWith("__ENV_")&&p.endsWith("__")){const M=p.slice(6,-2);return` "${l}": process.env.${M}`}return` "${l}": "${p}"`});o.push(` headers: {