llmxray 0.2.0 → 0.3.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.
- package/README.md +1 -1
- package/dist/assets/AITrainingPage-6EIRz3kX.js +1 -0
- package/dist/assets/{BenchmarkPage-yZ1Kt8KK.js → BenchmarkPage-B7ahJqyh.js} +2 -2
- package/dist/assets/ComparisonPage-Cg4Ut59Z.js +1 -0
- package/dist/assets/DashboardPage-BrCHJN4q.js +101 -0
- package/dist/assets/EmbeddingsPage-CpsFUo1d.js +1 -0
- package/dist/assets/{GoogleCallbackPage-DqfqxXhg.js → GoogleCallbackPage-CN8CaZK-.js} +1 -1
- package/dist/assets/{JsonTreeNode-BE6Ps90W.js → JsonTreeNode-BvAGKM9G.js} +2 -2
- package/dist/assets/ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-Cu2p2PDw.js +1 -0
- package/dist/assets/RAGPage-BKtz_PYd.js +1 -0
- package/dist/assets/SessionPage-BR4SPR1L.js +14 -0
- package/dist/assets/SettingsPage-BMhdIE_y.js +1 -0
- package/dist/assets/StatusBadge.vue_vue_type_script_setup_true_lang-Do1APUFY.js +1 -0
- package/dist/assets/StorageGauge.vue_vue_type_style_index_0_lang-DJFKaJRi.js +1 -0
- package/dist/assets/SystemPage-BoP1hvPb.js +2 -0
- package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-CnQ8vq8x.js → TabBar.vue_vue_type_script_setup_true_lang-DEYUQ8oI.js} +1 -1
- package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-CJW7ndOY.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-DTGfuxgU.js} +1 -1
- package/dist/assets/{ToolWorkshopPage-gO5DvECk.css → ToolWorkshopPage-7TRbWVVL.css} +1 -1
- package/dist/assets/{ToolWorkshopPage-DoVwZp_3.js → ToolWorkshopPage-WPcjRasF.js} +88 -88
- package/dist/assets/{agent-store-_RIMRfEn.js → agent-store-DHWdued4.js} +1 -1
- package/dist/assets/{generate-service-mPYQA7Xh.js → generate-service-Cek8un6v.js} +1 -1
- package/dist/assets/{google-auth-store-BnEs-xLw.js → google-auth-store-DZ-3XsJA.js} +1 -1
- package/dist/assets/{index-D87kMEMb.js → index-B19rmHaK.js} +1 -1
- package/dist/assets/index-CgqXFXWk.js +6 -0
- package/dist/assets/index-DL68effo.css +1 -0
- package/dist/assets/{metrics-store-HzdMIV8O.js → metrics-store-eda0zEsH.js} +1 -1
- package/dist/assets/{rag-store-VWnttX_x.js → rag-store-lxO_mW3a.js} +1 -1
- package/dist/assets/{storage-store-B1XevdC4.js → storage-store-B9VvK961.js} +1 -1
- package/dist/assets/{stream-handler-29OjEvbo.js → stream-handler-D3rNjxe3.js} +2 -2
- package/dist/assets/{tool-workshop-store-Btx8DDqg.js → tool-workshop-store-XDULj1FM.js} +1 -1
- package/dist/assets/{toolcall-store-BumXt8DE.js → toolcall-store-CFB1O-_8.js} +1 -1
- package/dist/assets/trash-2-BLyRKRSt.js +1 -0
- package/dist/favicon.svg +104 -3
- package/dist/index.html +2 -2
- package/dist/social-card.svg +150 -0
- package/package.json +5 -2
- package/dist/assets/AITrainingPage-BbRryhHe.js +0 -1
- package/dist/assets/ComparisonPage-BnBp-VsC.js +0 -1
- package/dist/assets/DashboardPage-DTXPIpEx.js +0 -101
- package/dist/assets/EmbeddingsPage-CghkdGEr.js +0 -1
- package/dist/assets/ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CsL7aDHj.js +0 -1
- package/dist/assets/RAGPage-B_c1Nogo.js +0 -1
- package/dist/assets/SessionPage-lWGESxx3.js +0 -14
- package/dist/assets/SettingsPage-k9HWgy9B.js +0 -1
- package/dist/assets/StatusBadge.vue_vue_type_script_setup_true_lang-f9O-U2FX.js +0 -1
- package/dist/assets/StorageGauge.vue_vue_type_style_index_0_lang-hO4dId5t.js +0 -1
- package/dist/assets/SystemPage-BgwBHFJB.js +0 -2
- package/dist/assets/index-BqB3FY2M.js +0 -4
- package/dist/assets/index-C0qd34Zo.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as H,r as h,c as I,a as D,e as p,f as e,t as m,m as R,u,i as $,k as Q,F as A,j as S,b as c,g as w,h as j,B as E,C as L,p as N,v as X,M as V,A as Y,s as Z,ab as _}from"./index-BqB3FY2M.js";import{canvasAiDB as P}from"./canvas-ai-db-BolM-_G7.js";import{b as ee,d as z}from"./format-BqVZ9rwM.js";import{_ as te}from"./StorageGauge.vue_vue_type_style_index_0_lang-hO4dId5t.js";const se=H("training",()=>{const s=h([]),l=h(!1),g=h(new Set),o=h(null),f=h({phase:null,model:null,accepted:null,toolName:null,tag:null,search:"",sortBy:"timestamp",sortDir:"desc"}),n=I(()=>{let r=[...s.value];const i=f.value;if(i.phase&&(r=r.filter(x=>x.phase===i.phase)),i.model&&(r=r.filter(x=>x.model===i.model)),i.accepted!==null&&(r=r.filter(x=>x.accepted===i.accepted)),i.toolName&&(r=r.filter(x=>x.toolName===i.toolName)),i.tag&&(r=r.filter(x=>x.tags?.includes(i.tag)??!1)),i.search){const x=i.search.toLowerCase();r=r.filter(v=>v.userPrompt.toLowerCase().includes(x)||v.response.toLowerCase().includes(x)||v.toolName.toLowerCase().includes(x))}return r.sort((x,v)=>{let k=0;return i.sortBy==="timestamp"?k=x.timestamp-v.timestamp:i.sortBy==="phase"?k=x.phase.localeCompare(v.phase):i.sortBy==="model"&&(k=x.model.localeCompare(v.model)),i.sortDir==="desc"?-k:k}),r}),d=I(()=>{const r=s.value,i=new Map,x=new Map;let v=0,k=0;for(const T of r)T.accepted&&v++,i.set(T.phase,(i.get(T.phase)??0)+1),x.set(T.model,(x.get(T.model)??0)+1),k+=T.systemPrompt.length+T.userPrompt.length+T.response.length;return{total:r.length,accepted:v,rejected:r.length-v,phaseBreakdown:i,modelBreakdown:x,estimatedBytes:k*2}}),t=I(()=>{const r=new Set;for(const i of s.value)for(const x of i.tags??[])r.add(x);return[...r].sort()}),a=I(()=>[...new Set(s.value.map(r=>r.model))].sort()),b=I(()=>[...new Set(s.value.map(r=>r.toolName))].sort());async function C(){l.value=!0;try{s.value=await P.getAllPairs()}catch(r){console.error("Failed to load training pairs:",r)}finally{l.value=!1}}async function M(r,i){await P.updatePairResponse(r,i);const x=s.value.find(v=>v.id===r);x&&(x.response=i)}async function U(r,i){await P.updatePairTags(r,i);const x=s.value.find(v=>v.id===r);x&&(x.tags=i)}async function y(r){const i=s.value.find(v=>v.id===r);if(!i)return;const x=!i.accepted;await P.updateAccepted(r,x),i.accepted=x}async function B(r){await P.deletePairs(r);const i=new Set(r);s.value=s.value.filter(x=>!i.has(x.id));for(const x of r)g.value.delete(x);o.value&&i.has(o.value)&&(o.value=null)}async function F(r,i){for(const x of r){await P.updateAccepted(x,i);const v=s.value.find(k=>k.id===x);v&&(v.accepted=i)}}async function K(r,i){for(const x of r){const v=s.value.find(T=>T.id===x);if(!v)continue;const k=[...v.tags??[]];k.includes(i)||(k.push(i),await P.updatePairTags(x,k),v.tags=k)}}function J(r){P.exportSelectedAsJsonl(r)}function O(r){const i=new Set(g.value);i.has(r)?i.delete(r):i.add(r),g.value=i}function W(){g.value=new Set(n.value.map(r=>r.id))}function q(){g.value=new Set}function G(r){o.value=o.value===r?null:r}return{pairs:s,loading:l,selectedIds:g,expandedId:o,filters:f,filteredPairs:n,stats:d,allTags:t,allModels:a,allToolNames:b,loadPairs:C,updateResponse:M,updateTags:U,toggleAccepted:y,deletePairs:B,bulkSetAccepted:F,bulkAddTag:K,exportSelected:J,toggleSelection:O,selectAll:W,deselectAll:q,setExpanded:G}}),oe={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ae={class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},le={class:"text-xl font-bold text-text-primary"},ne={class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},re={class:"text-xl font-bold text-text-primary"},de={class:"flex items-center gap-2 text-[10px]"},ie={class:"text-success"},ue={class:"text-error"},ce={key:0,class:"h-1.5 rounded-full bg-surface-overlay overflow-hidden"},xe={class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},pe={class:"flex flex-wrap gap-1.5"},me={class:"rounded-lg border border-border-default bg-surface-raised p-3 space-y-2"},ge={key:0,class:"space-y-1"},fe={class:"text-text-secondary truncate"},ve={class:"text-text-muted shrink-0"},be={key:1,class:"text-[10px] text-text-muted italic"},ye=D({__name:"TrainingDashboard",props:{stats:{}},setup(s){const l=s,g=I(()=>["draft","insights","automap","fix"].map(t=>({key:t,count:l.stats.phaseBreakdown.get(t)??0}))),o=I(()=>[...l.stats.modelBreakdown.entries()].sort((d,t)=>t[1]-d[1]).slice(0,3)),f=I(()=>l.stats.total>0?Math.round(l.stats.accepted/l.stats.total*100):0),n={draft:"bg-blue-500/20 text-blue-400",insights:"bg-amber-500/20 text-amber-400",automap:"bg-emerald-500/20 text-emerald-400",fix:"bg-rose-500/20 text-rose-400"};return(d,t)=>(c(),p("div",oe,[e("div",ae,[t[0]||(t[0]=e("p",{class:"text-[10px] text-text-muted uppercase tracking-wider"},"Training Pairs",-1)),e("p",le,m(s.stats.total),1),s.stats.estimatedBytes>0?(c(),R(te,{key:0,used:s.stats.estimatedBytes,total:s.stats.estimatedBytes*5,compact:"",label:`~${u(ee)(s.stats.estimatedBytes)} dataset`},null,8,["used","total","label"])):$("",!0)]),e("div",ne,[t[2]||(t[2]=e("p",{class:"text-[10px] text-text-muted uppercase tracking-wider"},"Acceptance Rate",-1)),e("p",re,m(f.value)+"%",1),e("div",de,[e("span",ie,m(s.stats.accepted)+" accepted",1),t[1]||(t[1]=e("span",{class:"text-text-muted"},"/",-1)),e("span",ue,m(s.stats.rejected)+" rejected",1)]),s.stats.total>0?(c(),p("div",ce,[e("div",{class:"h-full rounded-full bg-success transition-all duration-500",style:Q({width:`${f.value}%`})},null,4)])):$("",!0)]),e("div",xe,[t[3]||(t[3]=e("p",{class:"text-[10px] text-text-muted uppercase tracking-wider"},"By Phase",-1)),e("div",pe,[(c(!0),p(A,null,S(g.value,a=>(c(),p("span",{key:a.key,class:w(["rounded-full px-2 py-0.5 text-[10px] font-medium",n[a.key]])},m(a.key)+" "+m(a.count),3))),128))])]),e("div",me,[t[4]||(t[4]=e("p",{class:"text-[10px] text-text-muted uppercase tracking-wider"},"Top Models",-1)),o.value.length>0?(c(),p("div",ge,[(c(!0),p(A,null,S(o.value,([a,b])=>(c(),p("div",{key:a,class:"flex items-center justify-between text-[10px]"},[e("span",fe,m(a),1),e("span",ve,m(b),1)]))),128))])):(c(),p("p",be,"No data"))])]))}}),ke={class:"flex flex-wrap items-center gap-2"},he=["value"],we=["value"],$e=["value"],Ce=["value"],Te=["value"],Ae=["value"],Se={class:"flex rounded-lg border border-border-default overflow-hidden"},Pe=["value"],Ie=["value"],Be=["value"],De=["value"],Ne=["title"],je=D({__name:"TrainingFilters",props:{filters:{},models:{},toolNames:{},tags:{}},emits:["update:filters"],setup(s,{emit:l}){const g=s,o=l;function f(d){o("update:filters",{...g.filters,...d})}const n=[{value:"",label:"All phases"},{value:"draft",label:"Draft"},{value:"insights",label:"Insights"},{value:"automap",label:"Auto-map"},{value:"fix",label:"Fix"}];return(d,t)=>(c(),p("div",ke,[e("select",{value:s.filters.phase??"",class:"rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary outline-none focus:border-accent",onChange:t[0]||(t[0]=a=>f({phase:a.target.value||null}))},[(c(),p(A,null,S(n,a=>e("option",{key:a.label,value:a.value},m(a.label),9,we)),64))],40,he),e("select",{value:s.filters.model??"",class:"rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary outline-none focus:border-accent",onChange:t[1]||(t[1]=a=>f({model:a.target.value||null}))},[t[10]||(t[10]=e("option",{value:""},"All models",-1)),(c(!0),p(A,null,S(s.models,a=>(c(),p("option",{key:a,value:a},m(a),9,Ce))),128))],40,$e),e("select",{value:s.filters.toolName??"",class:"rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary outline-none focus:border-accent",onChange:t[2]||(t[2]=a=>f({toolName:a.target.value||null}))},[t[11]||(t[11]=e("option",{value:""},"All tools",-1)),(c(!0),p(A,null,S(s.toolNames,a=>(c(),p("option",{key:a,value:a},m(a),9,Ae))),128))],40,Te),e("div",Se,[e("button",{class:w(["px-2.5 py-1.5 text-[10px] transition-colors",s.filters.accepted===null?"bg-accent/10 text-accent":"bg-surface text-text-muted hover:text-text-primary"]),onClick:t[3]||(t[3]=a=>f({accepted:null}))},"All",2),e("button",{class:w(["px-2.5 py-1.5 text-[10px] transition-colors border-l border-border-default",s.filters.accepted===!0?"bg-success/10 text-success":"bg-surface text-text-muted hover:text-text-primary"]),onClick:t[4]||(t[4]=a=>f({accepted:!0}))},"Accepted",2),e("button",{class:w(["px-2.5 py-1.5 text-[10px] transition-colors border-l border-border-default",s.filters.accepted===!1?"bg-error/10 text-error":"bg-surface text-text-muted hover:text-text-primary"]),onClick:t[5]||(t[5]=a=>f({accepted:!1}))},"Rejected",2)]),s.tags.length>0?(c(),p("select",{key:0,value:s.filters.tag??"",class:"rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary outline-none focus:border-accent",onChange:t[6]||(t[6]=a=>f({tag:a.target.value||null}))},[t[12]||(t[12]=e("option",{value:""},"All tags",-1)),(c(!0),p(A,null,S(s.tags,a=>(c(),p("option",{key:a,value:a},m(a),9,Ie))),128))],40,Pe)):$("",!0),e("input",{value:s.filters.search,type:"text",placeholder:"Search prompts...",class:"flex-1 min-w-[150px] rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary placeholder-text-muted outline-none focus:border-accent",onInput:t[7]||(t[7]=a=>f({search:a.target.value}))},null,40,Be),e("select",{value:s.filters.sortBy,class:"rounded-lg border border-border-default bg-surface px-2.5 py-1.5 text-xs text-text-primary outline-none focus:border-accent",onChange:t[8]||(t[8]=a=>f({sortBy:a.target.value}))},[...t[13]||(t[13]=[e("option",{value:"timestamp"},"Sort by time",-1),e("option",{value:"phase"},"Sort by phase",-1),e("option",{value:"model"},"Sort by model",-1)])],40,De),e("button",{class:"rounded-lg border border-border-default bg-surface px-2 py-1.5 text-xs text-text-muted hover:text-text-primary transition-colors",title:s.filters.sortDir==="desc"?"Newest first":"Oldest first",onClick:t[9]||(t[9]=a=>f({sortDir:s.filters.sortDir==="desc"?"asc":"desc"}))},m(s.filters.sortDir==="desc"?"↓":"↑"),9,Ne)]))}}),Me={class:"flex flex-wrap items-center gap-1.5"},Re=["onClick"],Ee=D({__name:"TrainingTagEditor",props:{tags:{},allTags:{}},emits:["update:tags"],setup(s,{emit:l}){const g=l,o=h("");function f(d,t){if(d.key==="Enter"||d.key===","){d.preventDefault();const a=o.value.trim().toLowerCase();a&&!t.includes(a)&&g("update:tags",[...t,a]),o.value=""}}function n(d,t){g("update:tags",d.filter(a=>a!==t))}return(d,t)=>(c(),p("div",Me,[(c(!0),p(A,null,S(s.tags,a=>(c(),p("span",{key:a,class:"flex items-center gap-1 rounded-full bg-accent/10 px-2 py-0.5 text-[10px] text-accent"},[j(m(a)+" ",1),e("button",{class:"text-accent/60 hover:text-accent transition-colors",onClick:b=>n(s.tags,a)},[...t[2]||(t[2]=[e("svg",{class:"h-2.5 w-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3"},[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,Re)]))),128)),E(e("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>o.value=a),type:"text",placeholder:"Add tag...",class:"w-20 bg-transparent text-[10px] text-text-primary placeholder-text-muted outline-none",onKeydown:t[1]||(t[1]=a=>f(a,s.tags))},null,544),[[L,o.value]])]))}}),Le={class:"rounded-lg border border-accent/30 bg-surface-raised p-4 space-y-4"},Ue={class:"flex items-center justify-between"},Ve={class:"flex items-center gap-2"},ze={class:"text-xs text-text-secondary"},Fe={class:"text-[10px] text-text-muted"},Ke={class:"text-[10px] text-text-muted"},Je={class:"flex items-center gap-2"},Oe={class:"max-h-32 overflow-auto rounded-lg bg-surface p-3 text-xs text-text-secondary whitespace-pre-wrap font-mono"},We={class:"max-h-32 overflow-auto rounded-lg bg-surface p-3 text-xs text-text-secondary whitespace-pre-wrap font-mono"},qe={key:0},Ge={class:"max-h-40 overflow-auto rounded-lg bg-accent/5 border border-accent/20 p-3 text-xs text-text-secondary whitespace-pre-wrap font-mono italic"},He={class:"mb-1 flex items-center justify-between"},Qe={key:1,class:"max-h-64 overflow-auto rounded-lg bg-surface p-3 text-xs text-text-secondary whitespace-pre-wrap font-mono"},Xe={key:2,class:"mt-2 flex gap-2"},Ye={class:"flex items-center justify-end border-t border-border-default pt-3"},Ze=D({__name:"TrainingDetailPanel",props:{pair:{},allTags:{}},emits:["close","update:response","update:tags","toggle-accepted","delete"],setup(s,{emit:l}){const g=s,o=l,f=h(!1),n=h(""),d=h(!1);function t(){n.value=g.pair.response,f.value=!0}function a(){o("update:response",g.pair.id,n.value),f.value=!1}function b(){f.value=!1}function C(){d.value?(o("delete",g.pair.id),d.value=!1):(d.value=!0,setTimeout(()=>{d.value=!1},3e3))}const M={draft:"bg-blue-500/20 text-blue-400",insights:"bg-amber-500/20 text-amber-400",automap:"bg-emerald-500/20 text-emerald-400",fix:"bg-rose-500/20 text-rose-400"};return(U,y)=>(c(),p("div",Le,[e("div",Ue,[e("div",Ve,[e("span",{class:w(["rounded-full px-2 py-0.5 text-[10px] font-medium",M[s.pair.phase]])},m(s.pair.phase),3),e("span",ze,m(s.pair.toolName),1),e("span",Fe,m(s.pair.model),1),e("span",Ke,m(u(z)(s.pair.timestamp)),1)]),e("div",Je,[e("button",{class:w(["rounded px-2 py-1 text-[10px] transition-colors",s.pair.accepted?"bg-success/10 text-success":"bg-error/10 text-error"]),onClick:y[0]||(y[0]=B=>o("toggle-accepted",s.pair.id))},m(s.pair.accepted?"Accepted":"Rejected"),3),e("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:y[1]||(y[1]=B=>o("close"))}," ✕ ")])]),e("div",null,[y[4]||(y[4]=e("p",{class:"mb-1 text-[10px] font-medium uppercase tracking-wider text-text-muted"},"System Prompt",-1)),e("pre",Oe,m(s.pair.systemPrompt),1)]),e("div",null,[y[5]||(y[5]=e("p",{class:"mb-1 text-[10px] font-medium uppercase tracking-wider text-text-muted"},"User Prompt",-1)),e("pre",We,m(s.pair.userPrompt),1)]),s.pair.reasoning?(c(),p("div",qe,[y[6]||(y[6]=e("p",{class:"mb-1 text-[10px] font-medium uppercase tracking-wider text-accent"},"Reasoning",-1)),e("pre",Ge,m(s.pair.reasoning),1)])):$("",!0),e("div",null,[e("div",He,[y[7]||(y[7]=e("p",{class:"text-[10px] font-medium uppercase tracking-wider text-text-muted"},"AI Response",-1)),f.value?$("",!0):(c(),p("button",{key:0,class:"text-[10px] text-accent hover:underline",onClick:t}," Edit response "))]),f.value?E((c(),p("textarea",{key:0,"onUpdate:modelValue":y[2]||(y[2]=B=>n.value=B),rows:"8",class:"w-full rounded-lg border border-accent bg-surface px-3 py-2 text-xs text-text-primary font-mono outline-none resize-y"},null,512)),[[L,n.value]]):(c(),p("pre",Qe,m(s.pair.response),1)),f.value?(c(),p("div",Xe,[e("button",{class:"rounded-lg bg-accent px-3 py-1 text-xs text-white hover:bg-accent-hover transition-colors",onClick:a}," Save "),e("button",{class:"rounded-lg px-3 py-1 text-xs text-text-muted hover:text-text-primary transition-colors",onClick:b}," Cancel ")])):$("",!0)]),e("div",null,[y[8]||(y[8]=e("p",{class:"mb-1.5 text-[10px] font-medium uppercase tracking-wider text-text-muted"},"Tags",-1)),N(Ee,{tags:s.pair.tags??[],"all-tags":s.allTags,"onUpdate:tags":y[3]||(y[3]=B=>o("update:tags",s.pair.id,B))},null,8,["tags","all-tags"])]),e("div",Ye,[e("button",{class:w(["rounded-lg px-3 py-1 text-xs transition-colors",d.value?"bg-error/10 text-error":"text-text-muted hover:text-error"]),onClick:C},m(d.value?"Confirm delete?":"Delete pair"),3)])]))}}),_e={key:0,class:"rounded-lg bg-surface-overlay p-8 text-center"},et={key:1,class:"space-y-1"},tt=["onClick"],st=["onClick"],ot={key:0,class:"text-[8px]"},at={class:"shrink-0 text-text-secondary w-24 truncate"},lt={class:"shrink-0 text-text-muted w-28 truncate"},nt={class:"flex items-center gap-1 shrink-0"},rt={key:0,class:"text-[8px] text-text-muted"},dt={class:"flex-1 min-w-0 truncate text-text-muted"},it={class:"shrink-0 text-[10px] text-text-muted"},ut=D({__name:"TrainingTable",props:{pairs:{},selectedIds:{},expandedId:{},allTags:{}},emits:["toggle-selection","set-expanded","update:response","update:tags","toggle-accepted","delete"],setup(s,{emit:l}){const g=l,o={draft:"bg-blue-500/20 text-blue-400",insights:"bg-amber-500/20 text-amber-400",automap:"bg-emerald-500/20 text-emerald-400",fix:"bg-rose-500/20 text-rose-400"};return(f,n)=>s.pairs.length===0?(c(),p("div",_e,[...n[5]||(n[5]=[e("p",{class:"text-sm text-text-muted"},"No training pairs match your filters.",-1)])])):(c(),p("div",et,[(c(!0),p(A,null,S(s.pairs,d=>(c(),p("div",{key:d.id},[e("div",{class:w(["flex items-center gap-3 rounded-lg border border-border-default bg-surface-raised px-3 py-2.5 text-xs transition-colors cursor-pointer hover:border-accent/30",s.expandedId===d.id?"border-accent/50":""]),onClick:t=>g("set-expanded",d.id)},[e("button",{class:w(["flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors",s.selectedIds.has(d.id)?"border-accent bg-accent text-white":"border-border-default hover:border-accent"]),onClick:X(t=>g("toggle-selection",d.id),["stop"])},[s.selectedIds.has(d.id)?(c(),p("span",ot,"✓")):$("",!0)],10,st),e("span",{class:w(["shrink-0 rounded-full px-2 py-0.5 text-[9px] font-medium",o[d.phase]])},m(d.phase),3),e("span",at,m(d.toolName),1),e("span",lt,m(d.model),1),e("span",{class:w(["shrink-0 rounded-full px-1.5 py-0.5 text-[9px]",d.accepted?"bg-success/10 text-success":"bg-error/10 text-error"])},m(d.accepted?"accepted":"rejected"),3),e("div",nt,[(c(!0),p(A,null,S((d.tags??[]).slice(0,2),t=>(c(),p("span",{key:t,class:"rounded-full bg-accent/10 px-1.5 py-0.5 text-[8px] text-accent"},m(t),1))),128)),(d.tags??[]).length>2?(c(),p("span",rt,"+"+m((d.tags??[]).length-2),1)):$("",!0)]),e("span",dt,m(d.userPrompt.slice(0,80))+m(d.userPrompt.length>80?"...":""),1),e("span",it,m(u(z)(d.timestamp)),1)],10,tt),s.expandedId===d.id?(c(),R(Ze,{key:0,pair:d,"all-tags":s.allTags,class:"mt-1 ml-7",onClose:n[0]||(n[0]=t=>g("set-expanded",null)),"onUpdate:response":n[1]||(n[1]=(t,a)=>g("update:response",t,a)),"onUpdate:tags":n[2]||(n[2]=(t,a)=>g("update:tags",t,a)),onToggleAccepted:n[3]||(n[3]=t=>g("toggle-accepted",t)),onDelete:n[4]||(n[4]=t=>g("delete",t))},null,8,["pair","all-tags"])):$("",!0)]))),128))]))}}),ct={class:"flex items-center gap-2 rounded-lg border border-accent/30 bg-surface-raised px-4 py-2.5"},xt={class:"text-xs font-medium text-accent"},pt={class:"ml-auto flex items-center gap-2"},mt={key:0,class:"flex items-center gap-1"},gt=D({__name:"TrainingBulkActions",props:{selectedCount:{}},emits:["export","mark-accepted","mark-rejected","add-tag","delete","deselect-all"],setup(s,{emit:l}){const g=l,o=h(!1),f=h(""),n=h(!1);function d(){const a=f.value.trim().toLowerCase();a&&(g("add-tag",a),f.value="",o.value=!1)}function t(){n.value?(g("delete"),n.value=!1):(n.value=!0,setTimeout(()=>{n.value=!1},3e3))}return(a,b)=>(c(),p("div",ct,[e("span",xt,m(s.selectedCount)+" selected",1),e("div",pt,[e("button",{class:"rounded-lg bg-surface-overlay px-3 py-1 text-[10px] text-text-secondary hover:text-text-primary transition-colors",onClick:b[0]||(b[0]=C=>g("export"))}," Export JSONL "),e("button",{class:"rounded-lg bg-success/10 px-3 py-1 text-[10px] text-success hover:bg-success/20 transition-colors",onClick:b[1]||(b[1]=C=>g("mark-accepted"))}," Mark Accepted "),e("button",{class:"rounded-lg bg-error/10 px-3 py-1 text-[10px] text-error hover:bg-error/20 transition-colors",onClick:b[2]||(b[2]=C=>g("mark-rejected"))}," Mark Rejected "),o.value?(c(),p("div",mt,[E(e("input",{"onUpdate:modelValue":b[3]||(b[3]=C=>f.value=C),type:"text",placeholder:"Tag name...",class:"w-24 rounded border border-accent bg-surface px-2 py-0.5 text-[10px] text-text-primary outline-none",onKeydown:[V(d,["enter"]),b[4]||(b[4]=V(C=>o.value=!1,["escape"]))]},null,544),[[L,f.value]]),e("button",{class:"text-[10px] text-accent hover:underline",onClick:d},"Add")])):(c(),p("button",{key:1,class:"rounded-lg bg-accent/10 px-3 py-1 text-[10px] text-accent hover:bg-accent/20 transition-colors",onClick:b[5]||(b[5]=C=>o.value=!0)}," Add Tag ")),e("button",{class:w(["rounded-lg px-3 py-1 text-[10px] transition-colors",n.value?"bg-error/10 text-error":"text-text-muted hover:text-error"]),onClick:t},m(n.value?"Confirm?":"Delete"),3),e("button",{class:"text-[10px] text-text-muted hover:text-text-primary transition-colors",onClick:b[6]||(b[6]=C=>g("deselect-all"))}," Deselect ")])]))}}),ft={class:"mx-auto max-w-6xl space-y-6"},vt={key:1,class:"flex items-center gap-3"},bt={class:"text-[10px] text-text-muted"},yt={key:2,class:"rounded-lg border border-border-default bg-surface-raised p-8 text-center"},kt={class:"text-xs text-text-muted"},Tt=D({__name:"AITrainingPage",setup(s){const l=se();return Y(()=>{l.loadPairs()}),(g,o)=>{const f=_("RouterLink");return c(),p("div",ft,[o[18]||(o[18]=e("div",null,[e("h2",{class:"text-lg font-semibold text-text-primary"},"AI Training"),e("p",{class:"text-sm text-text-muted"},"Browse, curate, and export your training data from the Tool Workshop.")],-1)),N(ye,{stats:u(l).stats},null,8,["stats"]),N(je,{filters:u(l).filters,models:u(l).allModels,"tool-names":u(l).allToolNames,tags:u(l).allTags,"onUpdate:filters":o[0]||(o[0]=n=>u(l).filters=n)},null,8,["filters","models","tool-names","tags"]),u(l).selectedIds.size>0?(c(),R(gt,{key:0,"selected-count":u(l).selectedIds.size,onExport:o[1]||(o[1]=n=>u(l).exportSelected([...u(l).selectedIds])),onMarkAccepted:o[2]||(o[2]=n=>u(l).bulkSetAccepted([...u(l).selectedIds],!0)),onMarkRejected:o[3]||(o[3]=n=>u(l).bulkSetAccepted([...u(l).selectedIds],!1)),onAddTag:o[4]||(o[4]=n=>u(l).bulkAddTag([...u(l).selectedIds],n)),onDelete:o[5]||(o[5]=n=>u(l).deletePairs([...u(l).selectedIds])),onDeselectAll:o[6]||(o[6]=n=>u(l).deselectAll())},null,8,["selected-count"])):$("",!0),u(l).filteredPairs.length>0?(c(),p("div",vt,[e("button",{class:"text-[10px] text-text-muted hover:text-accent transition-colors",onClick:o[7]||(o[7]=n=>u(l).selectedIds.size===u(l).filteredPairs.length?u(l).deselectAll():u(l).selectAll())},m(u(l).selectedIds.size===u(l).filteredPairs.length?"Deselect all":`Select all ${u(l).filteredPairs.length}`),1),e("span",bt,m(u(l).filteredPairs.length)+" of "+m(u(l).pairs.length)+" pairs shown ",1)])):$("",!0),N(ut,{pairs:u(l).filteredPairs,"selected-ids":u(l).selectedIds,"expanded-id":u(l).expandedId,"all-tags":u(l).allTags,onToggleSelection:o[8]||(o[8]=n=>u(l).toggleSelection(n)),onSetExpanded:o[9]||(o[9]=n=>u(l).setExpanded(n)),"onUpdate:response":o[10]||(o[10]=(n,d)=>u(l).updateResponse(n,d)),"onUpdate:tags":o[11]||(o[11]=(n,d)=>u(l).updateTags(n,d)),onToggleAccepted:o[12]||(o[12]=n=>u(l).toggleAccepted(n)),onDelete:o[13]||(o[13]=n=>u(l).deletePairs([n]))},null,8,["pairs","selected-ids","expanded-id","all-tags"]),u(l).pairs.length===0&&!u(l).loading?(c(),p("div",yt,[o[17]||(o[17]=e("p",{class:"text-sm text-text-muted mb-2"},"No training data collected yet.",-1)),e("p",kt,[o[15]||(o[15]=j(" Training pairs are generated automatically when you use AI features in the ",-1)),N(f,{to:"/tools",class:"text-accent hover:underline"},{default:Z(()=>[...o[14]||(o[14]=[j("Tool Workshop",-1)])]),_:1}),o[16]||(o[16]=j(" (draft generation, code analysis, auto-mapping, and AI fix). ",-1))])])):$("",!0)])}}});export{Tt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as X,r as C,c as k,n as j,a as F,z as Y,K,A as ee,e as v,f as t,i as I,h as T,F as w,j as $,t as y,b as m,u as z,g as M,p as P,m as D,w as te,B as O,E as V,k as A,C as se}from"./index-BqB3FY2M.js";import{u as oe}from"./toolcall-store-BumXt8DE.js";import{s as ne}from"./generate-service-mPYQA7Xh.js";import{u as Z}from"./metrics-store-HzdMIV8O.js";import{c as le,a as re}from"./format-BqVZ9rwM.js";import{_ as H,b as N}from"./StatusBadge.vue_vue_type_script_setup_true_lang-f9O-U2FX.js";import{_ as ae}from"./TokenStreamDisplay.vue_vue_type_script_setup_true_lang-CJW7ndOY.js";import{D as ue}from"./base-CrPFMexR.js";import"./stream-handler-29OjEvbo.js";import"./agent-store-_RIMRfEn.js";const ie=X("comparison",()=>{const o=C(new Map),e=C(null),s=k(()=>e.value?o.value.get(e.value)??null:null);function n(c,i){const f=j(),g=i.map(p=>({slotId:p.slotId,model:p.model,label:p.label,sessionId:"",status:"idle",outputText:"",metrics:null}));return o.value.set(f,{id:f,prompt:c,slots:i,createdAt:Date.now(),status:"running",executions:g}),e.value=f,f}function r(c,i,f){const g=o.value.get(c);if(!g)return;const p=g.executions.find(b=>b.slotId===i);p&&Object.assign(p,f)}function u(c){const i=o.value.get(c);if(i){const f=i.executions.every(g=>g.status==="completed"||g.status==="error");i.status=f?"completed":"partial"}}function a(c,i){return o.value.get(c)?.executions.find(f=>f.slotId===i)}return{runs:o,activeRunId:e,activeRun:s,createRun:n,updateExecution:r,finalizeRun:u,getExecution:a}});function de(o,e){const s=e.filter(c=>c.model===o.model);if(s.length<=1)return o.model;if(new Set(s.map(c=>c.options.temperature??.7)).size===s.length)return`${o.model} @ ${(o.options.temperature??.7).toFixed(2)}`;if(new Set(s.map(c=>c.system)).size===s.length&&o.system){const c=o.system.split(/\s+/)[0]??"",i=c.length>12?c.slice(0,12)+"...":c;return`${o.model} (${i})`}if(new Set(s.map(c=>c.options.seed)).size===s.length&&o.options.seed!=null)return`${o.model} seed:${o.options.seed}`;const a=s.findIndex(c=>c.slotId===o.slotId);return`${o.model} #${a+1}`}const ce={class:"rounded-lg border border-border-default bg-surface-raised p-4 space-y-4"},pe={class:"flex items-center justify-between"},xe={class:"flex items-center gap-2"},me={class:"group relative"},fe={class:"group relative"},ve={class:"flex items-center gap-3"},ge={class:"flex items-center justify-center h-5 w-5 rounded-full bg-surface-overlay text-[10px] font-bold text-text-secondary shrink-0"},be=["value","onChange"],he=["value"],ye=["onClick"],_e={class:"flex items-center gap-2"},ke=["onClick"],we={class:"text-[10px] text-text-muted"},Ie={key:0,class:"space-y-3 pt-1 border-t border-border-default/50"},$e=["value","onInput"],Ce={class:"flex items-center justify-between mb-1"},Se={class:"text-[11px] text-text-primary font-medium"},Me=["value","onInput"],Te={class:"flex items-center justify-between mb-1"},Pe={class:"text-[11px] text-text-primary font-medium"},Fe=["value","onInput"],We=["value","onInput"],Ee={class:"text-[11px]"},De={class:"mt-2 space-y-2"},Re={class:"flex items-center gap-2"},je=["value","onInput"],ze={class:"flex items-center gap-2"},Ae=["value","onInput"],Ne={class:"flex items-center gap-2"},Oe=["value","onChange"],Le={class:"flex items-center gap-2"},Be=["value","onInput"],Ve={class:"flex items-center gap-2"},Je=["value","onInput"],Ue={key:0,class:"rounded-lg border border-dashed border-border-default py-8 text-center space-y-3"},Ge=F({__name:"ComparisonSlotConfigurator",props:{slots:{default:()=>[]},slotsModifiers:{}},emits:["update:slots"],setup(o){const e=Y(),s=K(o,"slots"),n=C({});function r(){if(s.value.length>=4)return;const d=e.chatModelNames[0]??"",l={slotId:j(),model:d,label:"",system:"",options:{temperature:.7}},x=[...s.value,l];s.value=f(x)}function u(d){delete n.value[d];const l=s.value.filter(x=>x.slotId!==d);s.value=f(l)}function a(){n.value={},s.value=[]}function c(d,l){const x=s.value.map(_=>_.slotId===d?{..._,...l}:_);s.value=f(x)}function i(d,l){const x=s.value.map(_=>_.slotId===d?{..._,options:{..._.options,...l}}:_);s.value=f(x)}function f(d){return d.map(l=>({...l,label:de(l,d)}))}function g(d){n.value[d]=!n.value[d]}function p(d){const l=e.chatModelNames[0]??"";if(!l)return;let x;if(d==="temp-sweep")x=[.2,.7,1.2].map(_=>({slotId:j(),model:l,label:"",system:"",options:{temperature:_}}));else{const _=Math.floor(Math.random()*1e5);x=[.3,1].map(h=>({slotId:j(),model:l,label:"",system:"",options:{temperature:h,seed:_}}))}s.value=f(x)}function b(d){const l=[],x=d.options.temperature;return x!=null&&l.push(`temp ${x.toFixed(2)}`),d.options.top_p!=null&&l.push(`top_p ${d.options.top_p}`),d.options.seed!=null&&l.push(`seed ${d.options.seed}`),d.system&&l.push("system prompt"),l.join(", ")||"defaults"}return ee(async()=>{e.models.length===0&&await e.fetchModels()}),(d,l)=>(m(),v("div",ce,[t("div",pe,[l[2]||(l[2]=t("div",null,[t("h3",{class:"text-sm font-medium text-text-primary"},"Comparison Slots"),t("p",{class:"text-[11px] text-text-muted mt-0.5"}," Each slot is a model + settings combination. Add the same model multiple times with different settings to compare behavior. ")],-1)),s.value.length>0?(m(),v("button",{key:0,class:"rounded-md border border-border-default px-2.5 py-1 text-[11px] text-text-muted hover:border-error hover:text-error transition-colors shrink-0 self-start",onClick:a}," Clear All ")):I("",!0)]),t("div",xe,[l[5]||(l[5]=t("span",{class:"text-[11px] text-text-muted"},"Quick start:",-1)),t("div",me,[t("button",{class:"rounded-md border border-border-default px-2.5 py-1 text-[11px] text-text-secondary hover:border-accent hover:text-text-primary transition-colors",onClick:l[0]||(l[0]=x=>p("temp-sweep"))}," Temperature Sweep "),l[3]||(l[3]=t("div",{class:"pointer-events-none absolute left-0 top-full z-10 mt-1.5 w-64 rounded-lg border border-border-default bg-surface-raised p-3 text-xs text-text-secondary opacity-0 shadow-lg transition-opacity group-hover:pointer-events-auto group-hover:opacity-100"},[t("p",{class:"font-medium text-text-primary mb-1"},"Temperature Sweep"),t("p",null,[T("Creates 3 slots of the same model at temperatures "),t("strong",null,"0.2"),T(" (focused), "),t("strong",null,"0.7"),T(" (balanced), and "),t("strong",null,"1.2"),T(" (creative). See how temperature changes the output for the exact same prompt.")])],-1))]),t("div",fe,[t("button",{class:"rounded-md border border-border-default px-2.5 py-1 text-[11px] text-text-secondary hover:border-accent hover:text-text-primary transition-colors",onClick:l[1]||(l[1]=x=>p("deterministic-pair"))}," Deterministic Pair "),l[4]||(l[4]=t("div",{class:"pointer-events-none absolute left-0 top-full z-10 mt-1.5 w-64 rounded-lg border border-border-default bg-surface-raised p-3 text-xs text-text-secondary opacity-0 shadow-lg transition-opacity group-hover:pointer-events-auto group-hover:opacity-100"},[t("p",{class:"font-medium text-text-primary mb-1"},"Deterministic Pair"),t("p",null,[T("Creates 2 slots of the same model with the "),t("strong",null,"same seed"),T(" but different temperatures (0.3 and 1.0). The shared seed means any difference in the output is purely from temperature, not randomness.")])],-1))])]),(m(!0),v(w,null,$(s.value,(x,_)=>(m(),v("div",{key:x.slotId,class:"rounded-lg border border-border-default bg-surface p-3 space-y-2"},[t("div",ve,[t("span",ge,y(_+1),1),t("select",{value:x.model,class:"flex-1 rounded-lg border border-border-default bg-surface-raised px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",onChange:h=>c(x.slotId,{model:h.target.value})},[(m(!0),v(w,null,$(z(e).chatModelNames,h=>(m(),v("option",{key:h,value:h},y(h)+" "+y(z(e).capabilityIcons(h)),9,he))),128))],40,be),t("button",{class:"rounded-md p-1 text-text-muted hover:text-error transition-colors",title:"Remove slot",onClick:h=>u(x.slotId)},[...l[6]||(l[6]=[t("svg",{class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[t("path",{d:"M18 6L6 18M6 6l12 12"})],-1)])],8,ye)]),t("div",_e,[t("button",{class:"flex items-center gap-1.5 text-[11px] text-text-secondary hover:text-text-primary transition-colors",onClick:h=>g(x.slotId)},[(m(),v("svg",{class:M(["h-3 w-3 transition-transform",n.value[x.slotId]?"rotate-90":""]),viewBox:"0 0 24 24",fill:"currentColor"},[...l[7]||(l[7]=[t("path",{d:"M8 5l8 7-8 7z"},null,-1)])],2)),l[8]||(l[8]=T(" Settings ",-1))],8,ke),t("span",we,y(b(x)),1)]),n.value[x.slotId]?(m(),v("div",Ie,[t("div",null,[l[9]||(l[9]=t("label",{class:"text-[11px] text-text-muted block mb-1"},"System Prompt",-1)),t("textarea",{value:x.system,rows:"2",class:"w-full rounded-md border border-border-default bg-surface-raised px-2.5 py-1.5 text-xs text-text-primary placeholder-text-muted focus:border-accent focus:outline-none resize-none",placeholder:"Optional system prompt...",onInput:h=>c(x.slotId,{system:h.target.value})},null,40,$e)]),t("div",null,[t("div",Ce,[l[10]||(l[10]=t("label",{class:"text-[11px] text-text-muted"},"Temperature",-1)),t("span",Se,y((x.options.temperature??.7).toFixed(1)),1)]),t("input",{type:"range",min:"0",max:"2",step:"0.1",value:x.options.temperature??.7,class:"w-full",onInput:h=>i(x.slotId,{temperature:parseFloat(h.target.value)})},null,40,Me)]),t("div",null,[t("div",Te,[l[11]||(l[11]=t("label",{class:"text-[11px] text-text-muted"},"Top-P",-1)),t("span",Pe,y((x.options.top_p??.9).toFixed(2)),1)]),t("input",{type:"range",min:"0",max:"1",step:"0.05",value:x.options.top_p??.9,class:"w-full",onInput:h=>i(x.slotId,{top_p:parseFloat(h.target.value)})},null,40,Fe)]),t("div",null,[l[12]||(l[12]=t("label",{class:"text-[11px] text-text-muted block mb-1"},"Seed",-1)),t("input",{type:"number",value:x.options.seed??"",class:"w-full rounded-md border border-border-default bg-surface-raised px-2.5 py-1.5 text-xs text-text-primary placeholder-text-muted focus:border-accent focus:outline-none",placeholder:"Random (leave empty)",onInput:h=>i(x.slotId,{seed:h.target.value?parseInt(h.target.value,10):void 0})},null,40,We)]),t("details",Ee,[l[19]||(l[19]=t("summary",{class:"text-text-muted cursor-pointer hover:text-text-secondary"},"Advanced",-1)),t("div",De,[t("div",Re,[l[13]||(l[13]=t("label",{class:"text-text-muted w-24 shrink-0"},"Top-K",-1)),t("input",{type:"number",value:x.options.top_k??"",class:"flex-1 rounded-md border border-border-default bg-surface-raised px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none",placeholder:"40",onInput:h=>i(x.slotId,{top_k:h.target.value?parseInt(h.target.value,10):void 0})},null,40,je)]),t("div",ze,[l[14]||(l[14]=t("label",{class:"text-text-muted w-24 shrink-0"},"Repeat Penalty",-1)),t("input",{type:"number",step:"0.1",value:x.options.repeat_penalty??"",class:"flex-1 rounded-md border border-border-default bg-surface-raised px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none",placeholder:"1.1",onInput:h=>i(x.slotId,{repeat_penalty:h.target.value?parseFloat(h.target.value):void 0})},null,40,Ae)]),t("div",Ne,[l[16]||(l[16]=t("label",{class:"text-text-muted w-24 shrink-0"},"Mirostat",-1)),t("select",{value:x.options.mirostat??0,class:"flex-1 rounded-md border border-border-default bg-surface-raised px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none",onChange:h=>i(x.slotId,{mirostat:parseInt(h.target.value,10)||void 0})},[...l[15]||(l[15]=[t("option",{value:0},"Off",-1),t("option",{value:1},"Mirostat 1",-1),t("option",{value:2},"Mirostat 2",-1)])],40,Oe)]),t("div",Le,[l[17]||(l[17]=t("label",{class:"text-text-muted w-24 shrink-0"},"Max Tokens",-1)),t("input",{type:"number",value:x.options.num_predict??"",class:"flex-1 rounded-md border border-border-default bg-surface-raised px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none",placeholder:"Default",onInput:h=>i(x.slotId,{num_predict:h.target.value?parseInt(h.target.value,10):void 0})},null,40,Be)]),t("div",Ve,[l[18]||(l[18]=t("label",{class:"text-text-muted w-24 shrink-0"},"Context Length",-1)),t("input",{type:"number",value:x.options.num_ctx??"",class:"flex-1 rounded-md border border-border-default bg-surface-raised px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none",placeholder:"Default",onInput:h=>i(x.slotId,{num_ctx:h.target.value?parseInt(h.target.value,10):void 0})},null,40,Je)])])])])):I("",!0)]))),128)),s.value.length===0?(m(),v("div",Ue,[l[20]||(l[20]=t("p",{class:"text-sm text-text-secondary"},"No slots configured yet",-1)),l[21]||(l[21]=t("p",{class:"text-xs text-text-muted max-w-sm mx-auto"}," Add a slot to pick a model and settings, or use a quick-start preset above to get going. ",-1)),t("button",{class:"rounded-lg bg-accent px-4 py-2 text-sm font-medium text-surface hover:bg-accent-hover transition-colors",onClick:r}," + Add First Slot ")])):s.value.length<4?(m(),v("button",{key:1,class:"w-full rounded-lg border border-dashed border-border-default py-2.5 text-sm text-text-muted hover:border-accent hover:text-text-primary transition-colors",onClick:r}," + Add Slot ("+y(s.value.length)+"/4) ",1)):I("",!0)]))}}),qe={class:"rounded-lg border border-border-default bg-surface-raised overflow-hidden"},Qe={class:"border-b border-border-default px-4 py-3 space-y-1"},Ze={class:"flex items-center justify-between"},He={class:"text-sm font-semibold text-text-primary"},Xe={key:0,class:"flex flex-wrap gap-1"},Ye={class:"p-4 space-y-3"},Ke={key:1,class:"grid grid-cols-3 gap-2"},et=F({__name:"ComparisonColumn",props:{execution:{},slotConfig:{}},setup(o){const e=o,s=Z(),n=k(()=>e.execution.sessionId?s.getMetrics(e.execution.sessionId):null),r=k(()=>e.execution.label||e.execution.model),u=k(()=>{if(!e.slotConfig)return[];const a=[],c=e.slotConfig.options;return c.temperature!=null&&a.push(`temp ${c.temperature.toFixed(1)}`),c.top_p!=null&&a.push(`top_p ${c.top_p}`),c.seed!=null&&a.push(`seed ${c.seed}`),e.slotConfig.system&&a.push("sys prompt"),a});return(a,c)=>(m(),v("div",qe,[t("div",Qe,[t("div",Ze,[t("span",He,y(r.value),1),P(H,{status:o.execution.status},null,8,["status"])]),u.value.length>0?(m(),v("div",Xe,[(m(!0),v(w,null,$(u.value,i=>(m(),v("span",{key:i,class:"rounded-full bg-surface-overlay px-2 py-0.5 text-[10px] text-text-muted"},y(i),1))),128))])):I("",!0)]),t("div",Ye,[o.execution.sessionId?(m(),D(ae,{key:0,"session-id":o.execution.sessionId},null,8,["session-id"])):I("",!0),n.value?(m(),v("div",Ke,[P(N,{label:"TTFT",value:z(le)(n.value.ttftMs)},null,8,["value"]),P(N,{label:"Speed",value:z(re)(n.value.tokensPerSecond)},null,8,["value"]),P(N,{label:"Tokens",value:n.value.completionTokenCount},null,8,["value"])])):I("",!0)])]))}}),tt=F({__name:"ComparisonGrid",props:{executions:{},slots:{}},setup(o){const e=o;function s(n){return e.slots.find(r=>r.slotId===n.slotId)}return(n,r)=>(m(),v("div",{class:M(["grid gap-4",{"grid-cols-1":o.executions.length===1,"grid-cols-2":o.executions.length===2,"grid-cols-2 xl:grid-cols-3":o.executions.length===3,"grid-cols-2 xl:grid-cols-4":o.executions.length>=4}])},[(m(!0),v(w,null,$(o.executions,u=>(m(),D(et,{key:u.slotId,execution:u,"slot-config":s(u)},null,8,["execution","slot-config"]))),128))],2))}});function J(o,e){let s;for(s=0;s<o.length&&s<e.length;s++)if(o[s]!=e[s])return o.slice(0,s);return o.slice(0,s)}function U(o,e){let s;if(!o||!e||o[o.length-1]!=e[e.length-1])return"";for(s=0;s<o.length&&s<e.length;s++)if(o[o.length-(s+1)]!=e[e.length-(s+1)])return o.slice(-s);return o.slice(-s)}function L(o,e,s){if(o.slice(0,e.length)!=e)throw Error(`string ${JSON.stringify(o)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);return s+o.slice(e.length)}function B(o,e,s){if(!e)return o+s;if(o.slice(-e.length)!=e)throw Error(`string ${JSON.stringify(o)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);return o.slice(0,-e.length)+s}function W(o,e){return L(o,e,"")}function R(o,e){return B(o,e,"")}function G(o,e){return e.slice(0,st(o,e))}function st(o,e){let s=0;o.length>e.length&&(s=o.length-e.length);let n=e.length;o.length<e.length&&(n=o.length);const r=Array(n);let u=0;r[0]=0;for(let a=1;a<n;a++){for(e[a]==e[u]?r[a]=r[u]:r[a]=u;u>0&&e[a]!=e[u];)u=r[u];e[a]==e[u]&&u++}u=0;for(let a=s;a<o.length;a++){for(;u>0&&o[a]!=e[u];)u=r[u];o[a]==e[u]&&u++}return u}function E(o){let e;for(e=o.length-1;e>=0&&o[e].match(/\s/);e--);return o.substring(e+1)}function S(o){const e=o.match(/^\s*/);return e?e[0]:""}const q="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",ot=new RegExp(`[${q}]+|\\s+|[^${q}]`,"ug");class nt extends ue{equals(e,s,n){return n.ignoreCase&&(e=e.toLowerCase(),s=s.toLowerCase()),e.trim()===s.trim()}tokenize(e,s={}){let n;if(s.intlSegmenter){const a=s.intlSegmenter;if(a.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');n=[];for(const c of Array.from(a.segment(e))){const i=c.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(i)?n[n.length-1]+=i:n.push(i)}}else n=e.match(ot)||[];const r=[];let u=null;return n.forEach(a=>{/\s/.test(a)?u==null?r.push(a):r.push(r.pop()+a):u!=null&&/\s/.test(u)?r[r.length-1]==u?r.push(r.pop()+a):r.push(u+a):r.push(a),u=a}),r}join(e){return e.map((s,n)=>n==0?s:s.replace(/^\s+/,"")).join("")}postProcess(e,s){if(!e||s.oneChangePerToken)return e;let n=null,r=null,u=null;return e.forEach(a=>{a.added?r=a:a.removed?u=a:((r||u)&&Q(n,u,r,a),n=a,r=null,u=null)}),(r||u)&&Q(n,u,r,null),e}}const lt=new nt;function rt(o,e,s){return lt.diff(o,e,s)}function Q(o,e,s,n){if(e&&s){const r=S(e.value),u=E(e.value),a=S(s.value),c=E(s.value);if(o){const i=J(r,a);o.value=B(o.value,a,i),e.value=W(e.value,i),s.value=W(s.value,i)}if(n){const i=U(u,c);n.value=L(n.value,c,i),e.value=R(e.value,i),s.value=R(s.value,i)}}else if(s){if(o){const r=S(s.value);s.value=s.value.substring(r.length)}if(n){const r=S(n.value);n.value=n.value.substring(r.length)}}else if(o&&n){const r=S(n.value),u=S(e.value),a=E(e.value),c=J(r,u);e.value=W(e.value,c);const i=U(W(r,c),a);e.value=R(e.value,i),n.value=L(n.value,r,i),o.value=B(o.value,r,r.slice(0,r.length-i.length))}else if(n){const r=S(n.value),u=E(e.value),a=G(u,r);e.value=R(e.value,a)}else if(o){const r=E(o.value),u=S(e.value),a=G(r,u);e.value=W(e.value,a)}}const at={class:"rounded-lg border border-border-default bg-surface-raised p-4 space-y-3"},ut={key:0,class:"text-sm text-text-muted text-center py-4"},it={key:0,class:"flex items-center gap-3 text-sm"},dt=["value","disabled"],ct=["value","disabled"],pt={class:"flex items-center gap-4 text-[11px]"},xt={class:"flex items-center gap-1.5"},mt={class:"text-text-muted"},ft={class:"flex items-center gap-1.5"},vt={class:"text-text-muted"},gt={class:"rounded-md border border-border-default bg-surface p-3 text-sm leading-relaxed max-h-96 overflow-y-auto"},bt=F({__name:"ComparisonDiffView",props:{executions:{}},setup(o){const e=o,s=k(()=>e.executions.filter(i=>i.status==="completed"&&i.outputText)),n=C(0),r=C(1);te(s,i=>{i.length>=2&&(n.value=0,r.value=1)},{immediate:!0});const u=k(()=>{const i=s.value[n.value],f=s.value[r.value];if(!i||!f)return[];const g=i.outputText.replace(/<think>[\s\S]*?<\/think>/g,"").trim(),p=f.outputText.replace(/<think>[\s\S]*?<\/think>/g,"").trim();return rt(g,p)}),a=k(()=>s.value[n.value]?.label||s.value[n.value]?.model||""),c=k(()=>s.value[r.value]?.label||s.value[r.value]?.model||"");return(i,f)=>(m(),v("div",at,[s.value.length<2?(m(),v("div",ut," Need at least 2 completed results to show a diff. ")):(m(),v(w,{key:1},[s.value.length>2?(m(),v("div",it,[f[2]||(f[2]=t("span",{class:"text-text-muted text-xs"},"Compare:",-1)),O(t("select",{"onUpdate:modelValue":f[0]||(f[0]=g=>n.value=g),class:"rounded-md border border-border-default bg-surface px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none"},[(m(!0),v(w,null,$(s.value,(g,p)=>(m(),v("option",{key:g.slotId,value:p,disabled:p===r.value},y(g.label||g.model),9,dt))),128))],512),[[V,n.value,void 0,{number:!0}]]),f[3]||(f[3]=t("span",{class:"text-text-muted text-xs"},"vs",-1)),O(t("select",{"onUpdate:modelValue":f[1]||(f[1]=g=>r.value=g),class:"rounded-md border border-border-default bg-surface px-2 py-1 text-xs text-text-primary focus:border-accent focus:outline-none"},[(m(!0),v(w,null,$(s.value,(g,p)=>(m(),v("option",{key:g.slotId,value:p,disabled:p===n.value},y(g.label||g.model),9,ct))),128))],512),[[V,r.value,void 0,{number:!0}]])])):I("",!0),t("div",pt,[t("div",xt,[f[4]||(f[4]=t("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-success/30"},null,-1)),t("span",mt,y(a.value)+" only",1)]),t("div",ft,[f[5]||(f[5]=t("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-error/30"},null,-1)),t("span",vt,y(c.value)+" only",1)])]),t("div",gt,[(m(!0),v(w,null,$(u.value,(g,p)=>(m(),v("span",{key:p,class:M({"bg-success/20 text-success":g.removed,"bg-error/20 text-error":g.added,"text-text-primary":!g.added&&!g.removed})},y(g.value),3))),128))])],64))]))}}),ht={key:0,class:"rounded-lg border border-border-default bg-surface-raised p-4 space-y-4"},yt={class:"space-y-1.5"},_t={class:"text-[10px] text-text-secondary w-28 truncate shrink-0"},kt={class:"flex-1 h-3 bg-surface rounded-full overflow-hidden"},wt={class:"text-[10px] text-text-muted w-14 text-right shrink-0"},It={class:"space-y-1.5"},$t={class:"text-[10px] text-text-secondary w-28 truncate shrink-0"},Ct={class:"flex-1 h-3 bg-surface rounded-full overflow-hidden"},St={class:"text-[10px] text-text-muted w-14 text-right shrink-0"},Mt={class:"space-y-1.5"},Tt={class:"text-[10px] text-text-secondary w-28 truncate shrink-0"},Pt={class:"flex-1 h-3 bg-surface rounded-full overflow-hidden"},Ft={class:"text-[10px] text-text-muted w-14 text-right shrink-0"},Wt=F({__name:"ComparisonMetricsBar",props:{executions:{}},setup(o){const e=o,s=Z(),n=k(()=>e.executions.filter(p=>p.status==="completed"&&p.sessionId).map(p=>{const b=s.getMetrics(p.sessionId);return{label:p.label||p.model,slotId:p.slotId,ttftMs:b?.ttftMs??0,tokensPerSecond:b?.tokensPerSecond??0,totalTokens:b?.completionTokenCount??0}})),r=k(()=>Math.max(...n.value.map(p=>p.ttftMs),1)),u=k(()=>Math.max(...n.value.map(p=>p.tokensPerSecond),1)),a=k(()=>Math.max(...n.value.map(p=>p.totalTokens),1)),c=k(()=>n.value.length===0?"":n.value.reduce((p,b)=>p.ttftMs<b.ttftMs&&p.ttftMs>0?p:b).slotId),i=k(()=>n.value.length===0?"":n.value.reduce((p,b)=>p.tokensPerSecond>b.tokensPerSecond?p:b).slotId),f=["bg-accent","bg-success","bg-warning","bg-error"];function g(p){return f[p%f.length]??"bg-accent"}return(p,b)=>n.value.length>=2?(m(),v("div",ht,[b[3]||(b[3]=t("h4",{class:"text-xs font-medium text-text-secondary"},"Performance Comparison",-1)),t("div",yt,[b[0]||(b[0]=t("div",{class:"flex items-center justify-between"},[t("span",{class:"text-[11px] text-text-muted"},"Time to First Token"),t("span",{class:"text-[10px] text-text-muted"},"lower is better")],-1)),(m(!0),v(w,null,$(n.value,(d,l)=>(m(),v("div",{key:d.slotId+"-ttft",class:"flex items-center gap-2"},[t("span",_t,y(d.label),1),t("div",kt,[t("div",{class:M(["h-full rounded-full transition-all duration-500",[g(l),d.slotId===c.value?"opacity-100":"opacity-50"]]),style:A({width:`${d.ttftMs/r.value*100}%`})},null,6)]),t("span",wt,y(d.ttftMs.toFixed(0))+"ms",1)]))),128))]),t("div",It,[b[1]||(b[1]=t("div",{class:"flex items-center justify-between"},[t("span",{class:"text-[11px] text-text-muted"},"Tokens/sec"),t("span",{class:"text-[10px] text-text-muted"},"higher is better")],-1)),(m(!0),v(w,null,$(n.value,(d,l)=>(m(),v("div",{key:d.slotId+"-tps",class:"flex items-center gap-2"},[t("span",$t,y(d.label),1),t("div",Ct,[t("div",{class:M(["h-full rounded-full transition-all duration-500",[g(l),d.slotId===i.value?"opacity-100":"opacity-50"]]),style:A({width:`${d.tokensPerSecond/u.value*100}%`})},null,6)]),t("span",St,y(d.tokensPerSecond.toFixed(1)),1)]))),128))]),t("div",Mt,[b[2]||(b[2]=t("div",{class:"flex items-center justify-between"},[t("span",{class:"text-[11px] text-text-muted"},"Total Tokens")],-1)),(m(!0),v(w,null,$(n.value,(d,l)=>(m(),v("div",{key:d.slotId+"-tokens",class:"flex items-center gap-2"},[t("span",Tt,y(d.label),1),t("div",Pt,[t("div",{class:M(["h-full rounded-full transition-all duration-500",g(l)]),style:A({width:`${d.totalTokens/a.value*100}%`})},null,6)]),t("span",Ft,y(d.totalTokens),1)]))),128))])])):I("",!0)}}),Et={class:"space-y-6"},Dt={class:"rounded-lg border border-border-default bg-surface-raised p-4 space-y-3"},Rt=["disabled"],jt={class:"flex items-center justify-between"},zt={class:"text-xs text-text-muted"},At=["disabled"],Nt={key:0,class:"space-y-4"},Ot={class:"flex items-center gap-3"},Lt={key:0,class:"ml-auto flex gap-1 rounded-lg border border-border-default p-0.5"},Yt=F({__name:"ComparisonPage",setup(o){const e=ie(),s=oe(),n=C([]),r=C(""),u=C(!1),a=C("grid"),c=k(()=>e.activeRun),i=k(()=>n.value.length>0&&r.value.trim().length>0&&!u.value),f=k(()=>c.value?.executions.some(p=>p.status==="completed")??!1);async function g(){if(!i.value)return;u.value=!0,a.value="grid";const p=e.createRun(r.value.trim(),n.value),b=n.value.map(async d=>{try{const l=await ne({model:d.model,prompt:r.value.trim(),system:d.system||void 0,options:d.options});e.updateExecution(p,d.slotId,{sessionId:l.sessionId,status:"streaming"});const x=setInterval(()=>{const _=s.sessionById(l.sessionId);_&&(_.status==="completed"||_.status==="error")&&(e.updateExecution(p,d.slotId,{status:_.status,outputText:_.outputText,metrics:_.metrics}),clearInterval(x),e.finalizeRun(p))},500)}catch{e.updateExecution(p,d.slotId,{status:"error"})}});await Promise.allSettled(b),u.value=!1}return(p,b)=>(m(),v("div",Et,[P(Ge,{slots:n.value,"onUpdate:slots":b[0]||(b[0]=d=>n.value=d)},null,8,["slots"]),t("div",Dt,[O(t("textarea",{"onUpdate:modelValue":b[1]||(b[1]=d=>r.value=d),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",disabled:u.value,rows:"3",placeholder:"Enter prompt to compare across slots..."},null,8,Rt),[[se,r.value]]),t("div",jt,[t("span",zt,y(n.value.length)+" slot"+y(n.value.length!==1?"s":"")+" configured ",1),t("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:!i.value,onClick:g},y(u.value?"Running...":"Compare"),9,At)])]),c.value?(m(),v("div",Nt,[t("div",Ot,[b[4]||(b[4]=t("h3",{class:"text-sm font-medium text-text-secondary"},"Results",-1)),P(H,{status:c.value.status},null,8,["status"]),f.value?(m(),v("div",Lt,[t("button",{class:M(["rounded-md px-2.5 py-1 text-[11px] transition-colors",a.value==="grid"?"bg-surface-overlay text-text-primary":"text-text-muted hover:text-text-secondary"]),onClick:b[2]||(b[2]=d=>a.value="grid")}," Grid ",2),t("button",{class:M(["rounded-md px-2.5 py-1 text-[11px] transition-colors",a.value==="diff"?"bg-surface-overlay text-text-primary":"text-text-muted hover:text-text-secondary"]),onClick:b[3]||(b[3]=d=>a.value="diff")}," Diff ",2)])):I("",!0)]),a.value==="grid"?(m(),D(tt,{key:0,executions:c.value.executions,slots:c.value.slots},null,8,["executions","slots"])):(m(),D(bt,{key:1,executions:c.value.executions},null,8,["executions"])),f.value?(m(),D(Wt,{key:2,executions:c.value.executions},null,8,["executions"])):I("",!0)])):I("",!0)]))}});export{Yt as default};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import{u as et}from"./metrics-store-HzdMIV8O.js";import{_ as xs,o as ze,n as pe,r as M,d as vs,w as ee,c as j,a as te,b as h,e as g,f as r,g as D,t as S,h as Se,i as A,F as O,j as Q,k as bs,u as x,l as ys,m as Ae,T as ks,p as G,q as zt,s as Et,v as Le,x as ws,y as Ss,z as tt,A as It,B as U,C as Z,D as Pt,E as Ke,G as Dt,H as $s}from"./index-BqB3FY2M.js";import{f as we,a as Fe,b as Ze,c as Bt,d as Cs}from"./format-BqVZ9rwM.js";import{u as He,a as Ts}from"./toolcall-store-BumXt8DE.js";import{a as _s,s as Ms}from"./generate-service-mPYQA7Xh.js";import{u as Rs,a as As,_ as Ns,b as Be}from"./StatusBadge.vue_vue_type_script_setup_true_lang-f9O-U2FX.js";import{u as st}from"./tool-workshop-store-Btx8DDqg.js";import{u as zs,a as jt,b as Es}from"./agent-store-_RIMRfEn.js";import{e as Is}from"./stream-handler-29OjEvbo.js";import{d as Ps,p as Ds,u as Lt}from"./rag-store-VWnttX_x.js";import{messageMemoryDB as Ft}from"./message-memory-db-C3Ifhs2B.js";import{_ as bt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CsL7aDHj.js";import"./vector-db-ChAzHl5A.js";async function Bs(s,e){const t=performance.now();try{let o;return s.implementation.mode==="code"?o=await js(s.implementation.code,e):o=await Ls(s.implementation.blocks,e),{success:!0,result:o,durationMs:performance.now()-t}}catch(o){return{success:!1,result:null,durationMs:performance.now()-t,error:o instanceof Error?o.message:String(o)}}}async function js(s,e){if(!s.trim())throw new Error("Tool has no implementation code");const t=Object.getPrototypeOf(async function(){}).constructor;return await new t("args","fetch","getGoogleToken",s)(e,fetch.bind(globalThis),qs)}async function Ls(s,e){if(s.length===0)throw new Error("Tool has no action blocks");const t=new Map;for(const[l,a]of Object.entries(e))t.set(l,a);const o=[...s].sort((l,a)=>l.order-a.order);let n=null;for(const l of o)switch(l.type){case"http_request":await Fs(l.config,t);break;case"extract_field":Os(l.config,t);break;case"template":Vs(l.config,t);break;case"return_value":n=Us(l.config,t);break}return n}async function Fs(s,e){const t=Ne(s.url,e),o=s.body?Ne(s.body,e):void 0,n={};for(const[i,d]of Object.entries(s.headers))n[i]=Ne(d,e);const l=await fetch(t,{method:s.method,headers:n,body:s.method!=="GET"?o:void 0});let a;(l.headers.get("content-type")??"").includes("application/json")?a=await l.json():a=await l.text(),e.set(s.outputVariable||"response",a)}function Os(s,e){const t=e.get(s.input);if(t==null){e.set(s.outputVariable||"value",null);return}const o=s.fieldPath.split(".");let n=t;for(const l of o){if(n==null||typeof n!="object"){n=null;break}n=n[l]}e.set(s.outputVariable||"value",n)}function Vs(s,e){const t=Ne(s.template,e);e.set(s.outputVariable||"text",t)}function Us(s,e){const t=s.expression.trim();return e.has(t)?e.get(t):Ne(t,e)}async function qs(){const{getAccessToken:s,isConnected:e}=await xs(async()=>{const{getAccessToken:t,isConnected:o}=await import("./google-auth-CfEcVMA7.js");return{getAccessToken:t,isConnected:o}},[]);if(!e())throw new Error("Google account not connected. Go to Settings to connect your Google account.");return s()}function Ne(s,e){return s.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g,(t,o)=>{const n=o.split(".");let l=e.get(n[0]??"");for(let a=1;a<n.length;a++){if(l==null||typeof l!="object")return"";l=l[n[a]??""]}return l==null?"":typeof l=="object"?JSON.stringify(l):String(l)})}const Hs=5;async function Gs(s){const e=He(),t=Rs(),o=s.messages.map(c=>`[${c.role}] ${c.content}`).join(`
|
|
2
|
-
`),n=e.createSession({mode:"chat",model:s.model,prompt:o,messages:s.messages,options:s.options});e.setActiveSession(n);const l=_s(n,s.messages);t.setAnatomy(n,l);const a=new AbortController;return Ws(n,s.model,[...s.messages],s.tools,s.options,a.signal).catch(c=>{a.signal.aborted||e.setSessionError(n,c instanceof Error?c.message:"Chat failed")}),{sessionId:n,abort:()=>{a.abort(),e.cancelSession(n)}}}async function Ws(s,e,t,o,n,l){const a=Ts(),c=st(),i=zs();let d=0,p=0;for(;d<Hs;){if(l.aborted)return;const m=await ze.streamChat({model:e,messages:t,tools:o,options:n,logprobs:!0},l),b=await Is(s,m,l);if(b.toolCalls.length===0)return;t.push({role:"assistant",content:"",tool_calls:b.toolCalls});for(const k of b.toolCalls){const f=c.findByFunctionName(k.function.name),$=a.getToolCalls(s).find(V=>V.functionName===k.function.name&&V.status==="pending");if(!f){const V=`Tool "${k.function.name}" has no implementation`;i.addNode(s,{id:pe(),type:"error",label:`No impl: ${k.function.name}`,sessionId:s,stepIndex:p++,state:{tool:k.function.name,error:V},timestamp:Date.now()}),$&&a.updateToolCall(s,$.id,{status:"failed",error:V,completedAt:Date.now()}),t.push({role:"tool",content:JSON.stringify({error:V})});continue}$&&a.updateToolCall(s,$.id,{status:"executing"});const I=await Bs(f,k.function.arguments);i.addNode(s,{id:pe(),type:I.success?"output":"error",label:I.success?`Tool Result: ${k.function.name}`:`Tool Failed: ${k.function.name}`,sessionId:s,stepIndex:p++,state:{tool:k.function.name,success:I.success,durationMs:I.durationMs},timestamp:Date.now()}),$&&a.updateToolCall(s,$.id,{status:I.success?"completed":"failed",result:I.result,error:I.error,completedAt:Date.now(),durationMs:I.durationMs});const L=I.success?typeof I.result=="string"?I.result:JSON.stringify(I.result):JSON.stringify({error:I.error});t.push({role:"tool",content:L})}i.addNode(s,{id:pe(),type:"llm_call",label:`LLM Round ${d+2} (with tool results)`,sessionId:s,stepIndex:p++,state:{round:d+1},timestamp:Date.now()}),d++}}function Ks(){const s=M(!1),e=M(null),t=M(null);let o=null;async function n(c,i,d,p){s.value=!0,e.value=null;try{const m=await Ms({model:c,prompt:i,system:p,options:d});return t.value=m.sessionId,o=m.abort,m.sessionId}catch(m){throw e.value=m instanceof Error?m.message:"Failed to start generation",s.value=!1,m}}async function l(c,i,d,p){s.value=!0,e.value=null;try{const m=await Gs({model:c,messages:i,tools:p,options:d});return t.value=m.sessionId,o=m.abort,m.sessionId}catch(m){throw e.value=m instanceof Error?m.message:"Failed to start chat",s.value=!1,m}}function a(){o&&(o(),o=null),s.value=!1}return{isStreaming:s,error:e,currentSessionId:t,startGenerate:n,startChatStream:l,cancel:a}}const Oe=[{name:"help",description:"Show all available commands",usage:"/help",category:"chat",execute(s,e){const t=Ot(),o=[`Available commands:
|
|
3
|
-
`];for(const[n,l]of Object.entries(t)){o.push(`**${n}**`);for(const a of l)o.push(` ${a.usage} — ${a.description}`);o.push("")}e.showNotification(o.join(`
|
|
4
|
-
`))}},{name:"clear",description:"Clear current conversation",usage:"/clear",category:"chat",execute(s,e){e.clearConversation(),e.showNotification("Conversation cleared.")}},{name:"new",description:"Start a new chat session",usage:"/new",category:"chat",execute(s,e){e.newChat(),e.showNotification("New chat started.")}},{name:"summarize",description:"Ask the model to summarize the conversation",usage:"/summarize",category:"chat",execute(s,e){if(e.messages.length===0){e.showNotification("Nothing to summarize — conversation is empty.");return}e.sendAsUser("Please summarize our conversation so far in a concise way.")}},{name:"save",description:"Export conversation as JSON or text",usage:"/save [json|text]",category:"chat",execute(s,e){const t=s.trim()==="text"?"text":"json";e.exportConversation(t),e.showNotification(`Conversation exported as ${t}.`)}},{name:"copy",description:"Copy last assistant response to clipboard",usage:"/copy",category:"chat",execute(s,e){e.copyLastResponse()}},{name:"history",description:"Show recent conversations",usage:"/history",category:"chat",execute(s,e){e.showNotification("Scroll down to the recent chats section, or start a /new chat.")}},{name:"model",description:"Switch model or list available models",usage:"/model [name]",category:"settings",execute(s,e){const t=s.trim();if(!t){const n=e.availableModels.join(", ");e.showNotification(`Available models: ${n}
|
|
5
|
-
Current: ${e.currentModel}`);return}const o=e.availableModels.find(n=>n===t||n.startsWith(t));o?(e.switchModel(o),e.showNotification(`Switched to ${o}.`)):e.showNotification(`Model "${t}" not found. Available: ${e.availableModels.join(", ")}`)}},{name:"system",description:"Set the system prompt",usage:"/system <prompt>",category:"settings",execute(s,e){const t=s.trim();if(!t){const o=e.chatSettings.value.systemPrompt||"(none)";e.showNotification(`Current system prompt: ${o}`);return}e.setSystemPrompt(t),e.showNotification("System prompt updated.")}},{name:"temperature",description:"Set temperature (0-2)",usage:"/temperature <value>",category:"settings",execute(s,e){const t=parseFloat(s.trim());if(isNaN(t)||t<0||t>2){e.showNotification(`Current: ${e.chatSettings.value.options.temperature??.7}. Usage: /temperature 0.0-2.0`);return}e.setOption("temperature",t),e.showNotification(`Temperature set to ${t}.`)}},{name:"top_p",description:"Set top-p / nucleus sampling (0-1)",usage:"/top_p <value>",category:"settings",execute(s,e){const t=parseFloat(s.trim());if(isNaN(t)||t<0||t>1){e.showNotification(`Current: ${e.chatSettings.value.options.top_p??.9}. Usage: /top_p 0.0-1.0`);return}e.setOption("top_p",t),e.showNotification(`Top-p set to ${t}.`)}},{name:"top_k",description:"Set top-k sampling (1-100)",usage:"/top_k <value>",category:"settings",execute(s,e){const t=parseInt(s.trim(),10);if(isNaN(t)||t<1||t>100){e.showNotification(`Current: ${e.chatSettings.value.options.top_k??40}. Usage: /top_k 1-100`);return}e.setOption("top_k",t),e.showNotification(`Top-k set to ${t}.`)}},{name:"context",description:"Set context window size",usage:"/context <size>",category:"settings",execute(s,e){const t=parseInt(s.trim(),10),o=[2048,4096,8192,16384,32768,65536,131072];if(isNaN(t)||!o.includes(t)){e.showNotification(`Current: ${we(e.chatSettings.value.options.num_ctx??4096)}. Valid sizes: ${o.join(", ")}`);return}e.setOption("num_ctx",t),e.showNotification(`Context window set to ${we(t)}.`)}},{name:"repeat_penalty",description:"Set repeat penalty (1.0-2.0)",usage:"/repeat_penalty <value>",category:"settings",execute(s,e){const t=parseFloat(s.trim());if(isNaN(t)||t<1||t>2){e.showNotification(`Current: ${e.chatSettings.value.options.repeat_penalty??1.1}. Usage: /repeat_penalty 1.0-2.0`);return}e.setOption("repeat_penalty",t),e.showNotification(`Repeat penalty set to ${t}.`)}},{name:"seed",description:"Set seed for reproducibility (-1 for random)",usage:"/seed <value>",category:"settings",execute(s,e){const t=parseInt(s.trim(),10);if(isNaN(t)){e.showNotification(`Current: ${e.chatSettings.value.options.seed??-1}. Usage: /seed <number>`);return}e.setOption("seed",t===-1?void 0:t),e.showNotification(t===-1?"Seed set to random.":`Seed set to ${t}.`)}},{name:"stop",description:"Set stop sequences (comma-separated)",usage:"/stop <sequences>",category:"settings",execute(s,e){const t=s.trim();if(!t){const n=e.chatSettings.value.options.stop?.join(", ")||"(none)";e.showNotification(`Current stop sequences: ${n}`);return}const o=t.split(",").map(n=>n.trim()).filter(Boolean);e.setOption("stop",o.length>0?o:void 0),e.showNotification(`Stop sequences set: ${o.join(", ")}`)}},{name:"mirostat",description:"Set mirostat mode (0=off, 1=v1, 2=v2)",usage:"/mirostat <0|1|2>",category:"settings",execute(s,e){const t=parseInt(s.trim(),10);if(![0,1,2].includes(t)){e.showNotification(`Current: ${e.chatSettings.value.options.mirostat??0}. Usage: /mirostat 0|1|2`);return}e.setOption("mirostat",t),e.showNotification(t===0?"Mirostat disabled.":`Mirostat v${t} enabled.`)}},{name:"format",description:"Toggle JSON output format",usage:"/format [json]",category:"settings",execute(s,e){const t=s.trim().toLowerCase()==="json";e.setJsonFormat(t),e.showNotification(t?"JSON format enabled.":"JSON format disabled.")}},{name:"reset",description:"Reset all settings to defaults",usage:"/reset",category:"settings",execute(s,e){e.resetSettings(),e.showNotification("All settings reset to defaults.")}},{name:"rag",description:"Toggle RAG context on/off",usage:"/rag",category:"navigation",execute(s,e){e.toggleRag(),e.showNotification(e.ragEnabled?"RAG context disabled.":"RAG context enabled.")}},{name:"tools",description:"Open tools settings panel",usage:"/tools",category:"navigation",execute(s,e){e.openSettings(),e.showNotification("Settings panel opened.")}},{name:"status",description:"Show Ollama connection status and model info",usage:"/status",category:"navigation",async execute(s,e){const t=await e.getOllamaStatus();e.showNotification(`Ollama: ${t.connected?"Connected":"Disconnected"}
|
|
6
|
-
Model: ${t.model||"(none)"}`)}},{name:"tokens",description:"Show token count for current session",usage:"/tokens",category:"navigation",execute(s,e){const t=e.getSessionTokenCount();if(!t){e.showNotification("No active session.");return}e.showNotification(`Prompt tokens: ${we(t.prompt)}
|
|
7
|
-
Completion tokens: ${we(t.completion)}
|
|
8
|
-
Total: ${we(t.prompt+t.completion)}`)}},{name:"speed",description:"Show average generation speed across sessions",usage:"/speed",category:"navigation",execute(s,e){const t=e.getAverageSpeed();if(t===null){e.showNotification("No sessions recorded yet.");return}e.showNotification(`Average speed: ${Fe(t)}`)}},{name:"compare",description:"Navigate to the Compare page",usage:"/compare",category:"navigation",execute(s,e){e.navigate("/compare")}},{name:"session",description:"View current session details",usage:"/session",category:"navigation",execute(s,e){e.openSessionDetails()}},{name:"remember",description:"Remember a fact about you across conversations",usage:"/remember <fact>",category:"memory",execute(s,e){const t=s.trim();if(!t){e.showNotification(`Usage: /remember <something to remember>
|
|
9
|
-
Example: /remember I prefer TypeScript over JavaScript`);return}e.addFact(t),e.showNotification(`Remembered: "${t}"`)}},{name:"forget",description:"Forget a previously remembered fact",usage:"/forget <search>",category:"memory",execute(s,e){const t=s.trim();if(!t){e.showNotification(`Usage: /forget <part of the fact to remove>
|
|
10
|
-
Example: /forget TypeScript`);return}e.removeFact(t)?e.showNotification(`Forgot fact matching "${t}".`):e.showNotification(`No fact found matching "${t}". Use /memories to see all facts.`)}},{name:"memories",description:"Show all remembered facts",usage:"/memories",category:"memory",execute(s,e){const t=e.getFacts();if(t.length===0){e.showNotification("No memories stored yet. Use /remember <fact> to add one.");return}const o=t.map((n,l)=>`${l+1}. ${n.content}`);e.showNotification(`Your memories (${t.length}):
|
|
11
|
-
${o.join(`
|
|
12
|
-
`)}`)}}];function Zs(s){const e=s.toLowerCase().replace(/^\//,"");return e?Oe.filter(t=>t.name.startsWith(e)):Oe}function Qs(s){return Oe.find(e=>e.name===s.toLowerCase())}function Ot(){const s={};for(const e of Oe){const t=e.category==="chat"?"Chat & Conversation":e.category==="settings"?"Model & Settings":e.category==="memory"?"Memory":"Features & Navigation";(s[t]??=[]).push(e)}return s}const yt={slidingWindow:{enabled:!0,maxMessages:50},autoSummarize:{enabled:!1,triggerThreshold:30},ragMemory:{enabled:!1,embeddingModel:"",topK:3},userFacts:{enabled:!0}},kt="llmxray-memory-settings",wt="llmxray-user-facts";function St(s,e){try{const t=localStorage.getItem(s);return t?JSON.parse(t):e}catch{return e}}function $t(s,e){localStorage.setItem(s,JSON.stringify(e))}const Vt=vs("memory",()=>{const s=M(St(kt,{...yt}));ee(s,f=>$t(kt,f),{deep:!0});function e(f){s.value={...s.value,...f}}function t(){s.value={...yt}}const o=M(St(wt,[]));ee(o,f=>$t(wt,f),{deep:!0});const n=j(()=>o.value.length);function l(f){const z={id:pe(),content:f.trim(),createdAt:Date.now()};return o.value=[...o.value,z],z}function a(f){o.value=o.value.filter(z=>z.id!==f)}function c(f){const z=f.toLowerCase().trim(),$=o.value.findIndex(I=>I.content.toLowerCase().includes(z));return $===-1?!1:(o.value=[...o.value.slice(0,$),...o.value.slice($+1)],!0)}function i(){o.value=[]}function d(){return o.value.length===0?"":`The user has asked you to remember these facts about them:
|
|
13
|
-
${o.value.map(z=>`- ${z.content}`).join(`
|
|
14
|
-
`)}
|
|
15
|
-
|
|
16
|
-
Keep these in mind when responding.`}const p=M(new Map);function m(f,z,$){p.value.set(f,{conversationId:f,summary:z,messageCount:$,createdAt:Date.now()})}function b(f){return p.value.get(f)}function k(f){p.value.delete(f)}return{settings:s,updateSettings:e,resetSettings:t,facts:o,factCount:n,addFact:l,removeFact:a,removeFactByContent:c,clearFacts:i,getFactsAsSystemPrompt:d,summaries:p,setSummary:m,getSummary:b,clearSummary:k}});async function Js(s){let e=[...s.messages],t;s.settings.userFacts.enabled&&s.userFactsPrompt&&e.unshift({role:"system",content:s.userFactsPrompt});const o=e.filter(n=>n.role!=="system");if(s.settings.autoSummarize.enabled&&o.length>s.settings.autoSummarize.triggerThreshold){const n=Math.floor(s.settings.autoSummarize.triggerThreshold/3),l=e.filter(p=>p.role==="system"),a=o.slice(0,-n),c=o.slice(-n),i=s.existingSummary?`Previous summary:
|
|
17
|
-
${s.existingSummary}
|
|
18
|
-
|
|
19
|
-
New messages to incorporate:
|
|
20
|
-
`:"",d=await Ys(s.model,i+a.map(p=>`${p.role}: ${p.content}`).join(`
|
|
21
|
-
`));d&&(t=d,e=[...l,{role:"system",content:`Summary of earlier conversation:
|
|
22
|
-
${d}`},...c])}if(s.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),l=e.filter(c=>c.role!=="system"),a=s.settings.slidingWindow.maxMessages;if(l.length>a){const c=l.slice(-a);e=[...n,...c]}}if(s.settings.ragMemory.enabled&&s.settings.ragMemory.embeddingModel)try{const n=await en(s.conversationId,e,s.settings.ragMemory.embeddingModel,s.settings.ragMemory.topK);if(n){const l=e.filter(c=>c.role==="system"),a=e.filter(c=>c.role!=="system");e=[...l,{role:"system",content:n},...a]}}catch{}return{messages:e,newSummary:t}}async function Xs(s,e,t){if(!t||e.length===0)return;const o=e.map(a=>a.content),n=await ze.embed({model:t,input:o}),l=[];for(let a=0;a<e.length;a++){const c=n.embeddings[a];if(!c)continue;const i=e[a];l.push({id:pe(),conversationId:s,role:i.role,content:i.content,embedding:c,timestamp:i.timestamp})}await Ft.storeMessages(l)}async function Ys(s,e){try{return(await ze.chat({model:s,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(s,e,t,o){const n=e.filter(m=>m.role==="user"),l=n[n.length-1];if(!l)return null;const c=(await ze.embed({model:t,input:[l.content]})).embeddings[0];if(!c)return null;const d=(await Ft.search(c,o,s)).filter(m=>m.score>.5);return d.length===0?null:`Relevant messages from past conversations:
|
|
23
|
-
${d.map(m=>`[${m.message.role}, relevance: ${(m.score*100).toFixed(0)}%] ${m.message.content}`).join(`
|
|
24
|
-
|
|
25
|
-
`)}
|
|
26
|
-
|
|
27
|
-
Use this context if helpful, but prioritize the current conversation.`}function nt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var be=nt();function Ut(s){be=s}var xe={exec:()=>null};function P(s,e=""){let t=typeof s=="string"?s:s.source,o={replace:(n,l)=>{let a=typeof l=="string"?l:l.source;return a=a.replace(W.caret,"$1"),t=t.replace(n,a),o},getRegex:()=>new RegExp(t,e)};return o}var tn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),W={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:s=>new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}#`),htmlBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}>`)},sn=/^(?:[ \t]*(?:\n|$))+/,nn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,on=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ee=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,rn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ot=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,qt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ht=P(qt).replace(/bull/g,ot).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(),an=P(qt).replace(/bull/g,ot).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(),rt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ln=/^[^\n]+/,at=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,cn=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",at).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),un=P(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ot).getRegex(),Ge="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",lt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,dn=P("^ {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",lt).replace("tag",Ge).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Gt=P(rt).replace("hr",Ee).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",Ge).getRegex(),pn=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Gt).getRegex(),it={blockquote:pn,code:nn,def:cn,fences:on,heading:rn,hr:Ee,html:dn,lheading:Ht,list:un,newline:sn,paragraph:Gt,table:xe,text:ln},Ct=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ee).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",Ge).getRegex(),mn={...it,lheading:an,table:Ct,paragraph:P(rt).replace("hr",Ee).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ct).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",Ge).getRegex()},hn={...it,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",lt).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:xe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(rt).replace("hr",Ee).replace("heading",` *#{1,6} *[^
|
|
28
|
-
]`).replace("lheading",Ht).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},gn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,fn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wt=/^( {2,}|\\)\n(?!\s*$)/,xn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,We=/[\p{P}\p{S}]/u,ct=/[\s\p{P}\p{S}]/u,Kt=/[^\s\p{P}\p{S}]/u,vn=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ct).getRegex(),Zt=/(?!~)[\p{P}\p{S}]/u,bn=/(?!~)[\s\p{P}\p{S}]/u,yn=/(?:[^\s\p{P}\p{S}]|~)/u,Qt=/(?![*_])[\p{P}\p{S}]/u,kn=/(?![*_])[\s\p{P}\p{S}]/u,wn=/(?:[^\s\p{P}\p{S}]|[*_])/u,Sn=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",tn?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Jt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,$n=P(Jt,"u").replace(/punct/g,We).getRegex(),Cn=P(Jt,"u").replace(/punct/g,Zt).getRegex(),Xt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Tn=P(Xt,"gu").replace(/notPunctSpace/g,Kt).replace(/punctSpace/g,ct).replace(/punct/g,We).getRegex(),_n=P(Xt,"gu").replace(/notPunctSpace/g,yn).replace(/punctSpace/g,bn).replace(/punct/g,Zt).getRegex(),Mn=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Kt).replace(/punctSpace/g,ct).replace(/punct/g,We).getRegex(),Rn=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Qt).getRegex(),An="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Nn=P(An,"gu").replace(/notPunctSpace/g,wn).replace(/punctSpace/g,kn).replace(/punct/g,Qt).getRegex(),zn=P(/\\(punct)/,"gu").replace(/punct/g,We).getRegex(),En=P(/^<(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(),In=P(lt).replace("(?:-->|$)","-->").getRegex(),Pn=P("^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",In).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ve=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Dn=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ve).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yt=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Ve).replace("ref",at).getRegex(),es=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",at).getRegex(),Bn=P("reflink|nolink(?!\\()","g").replace("reflink",Yt).replace("nolink",es).getRegex(),Tt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ut={_backpedal:xe,anyPunctuation:zn,autolink:En,blockSkip:Sn,br:Wt,code:fn,del:xe,delLDelim:xe,delRDelim:xe,emStrongLDelim:$n,emStrongRDelimAst:Tn,emStrongRDelimUnd:Mn,escape:gn,link:Dn,nolink:es,punctuation:vn,reflink:Yt,reflinkSearch:Bn,tag:Pn,text:xn,url:xe},jn={...ut,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Ve).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ve).getRegex()},Qe={...ut,emStrongRDelimAst:_n,emStrongLDelim:Cn,delLDelim:Rn,delRDelim:Nn,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Tt).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:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Tt).getRegex()},Ln={...Qe,br:P(Wt).replace("{2,}","*").getRegex(),text:P(Qe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},je={normal:it,gfm:mn,pedantic:hn},_e={normal:ut,gfm:Qe,breaks:Ln,pedantic:jn},Fn={"&":"&","<":"<",">":">",'"':""","'":"'"},_t=s=>Fn[s];function re(s,e){if(e){if(W.escapeTest.test(s))return s.replace(W.escapeReplace,_t)}else if(W.escapeTestNoEncode.test(s))return s.replace(W.escapeReplaceNoEncode,_t);return s}function Mt(s){try{s=encodeURI(s).replace(W.percentDecode,"%")}catch{return null}return s}function Rt(s,e){let t=s.replace(W.findPipe,(l,a,c)=>{let i=!1,d=a;for(;--d>=0&&c[d]==="\\";)i=!i;return i?"|":" |"}),o=t.split(W.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(W.slashPipe,"|");return o}function Me(s,e,t){let o=s.length;if(o===0)return"";let n=0;for(;n<o&&s.charAt(o-n-1)===e;)n++;return s.slice(0,o-n)}function On(s,e){if(s.indexOf(e[1])===-1)return-1;let t=0;for(let o=0;o<s.length;o++)if(s[o]==="\\")o++;else if(s[o]===e[0])t++;else if(s[o]===e[1]&&(t--,t<0))return o;return t>0?-2:-1}function Vn(s,e=0){let t=e,o="";for(let n of s)if(n===" "){let l=4-t%4;o+=" ".repeat(l),t+=l}else o+=n,t++;return o}function At(s,e,t,o,n){let l=e.href,a=e.title||null,c=s[1].replace(n.other.outputLinkReplace,"$1");o.state.inLink=!0;let i={type:s[0].charAt(0)==="!"?"image":"link",raw:t,href:l,title:a,text:c,tokens:o.inlineTokens(c)};return o.state.inLink=!1,i}function Un(s,e,t){let o=s.match(t.other.indentCodeCompensation);if(o===null)return e;let n=o[1];return e.split(`
|
|
29
|
-
`).map(l=>{let a=l.match(t.other.beginningSpace);if(a===null)return l;let[c]=a;return c.length>=n.length?l.slice(n.length):l}).join(`
|
|
30
|
-
`)}var Ue=class{options;rules;lexer;constructor(s){this.options=s||be}space(s){let e=this.rules.block.newline.exec(s);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(s){let e=this.rules.block.code.exec(s);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:Me(t,`
|
|
31
|
-
`)}}}fences(s){let e=this.rules.block.fences.exec(s);if(e){let t=e[0],o=Un(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(s){let e=this.rules.block.heading.exec(s);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let o=Me(t,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(t=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(s){let e=this.rules.block.hr.exec(s);if(e)return{type:"hr",raw:Me(e[0],`
|
|
32
|
-
`)}}blockquote(s){let e=this.rules.block.blockquote.exec(s);if(e){let t=Me(e[0],`
|
|
33
|
-
`).split(`
|
|
34
|
-
`),o="",n="",l=[];for(;t.length>0;){let a=!1,c=[],i;for(i=0;i<t.length;i++)if(this.rules.other.blockquoteStart.test(t[i]))c.push(t[i]),a=!0;else if(!a)c.push(t[i]);else break;t=t.slice(i);let d=c.join(`
|
|
35
|
-
`),p=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
36
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
37
|
-
${d}`:d,n=n?`${n}
|
|
38
|
-
${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,l,!0),this.lexer.state.top=m,t.length===0)break;let b=l.at(-1);if(b?.type==="code")break;if(b?.type==="blockquote"){let k=b,f=k.raw+`
|
|
39
|
-
`+t.join(`
|
|
40
|
-
`),z=this.blockquote(f);l[l.length-1]=z,o=o.substring(0,o.length-k.raw.length)+z.raw,n=n.substring(0,n.length-k.text.length)+z.text;break}else if(b?.type==="list"){let k=b,f=k.raw+`
|
|
41
|
-
`+t.join(`
|
|
42
|
-
`),z=this.list(f);l[l.length-1]=z,o=o.substring(0,o.length-b.raw.length)+z.raw,n=n.substring(0,n.length-k.raw.length)+z.raw,t=f.substring(l.at(-1).raw.length).split(`
|
|
43
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:l,text:n}}}list(s){let e=this.rules.block.list.exec(s);if(e){let t=e[1].trim(),o=t.length>1,n={type:"list",raw:"",ordered:o,start:o?+t.slice(0,-1):"",loose:!1,items:[]};t=o?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=o?t:"[*+-]");let l=this.rules.other.listItemRegex(t),a=!1;for(;s;){let i=!1,d="",p="";if(!(e=l.exec(s))||this.rules.block.hr.test(s))break;d=e[0],s=s.substring(d.length);let m=Vn(e[2].split(`
|
|
44
|
-
`,1)[0],e[1].length),b=s.split(`
|
|
45
|
-
`,1)[0],k=!m.trim(),f=0;if(this.options.pedantic?(f=2,p=m.trimStart()):k?f=e[1].length+1:(f=m.search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=m.slice(f),f+=e[1].length),k&&this.rules.other.blankLine.test(b)&&(d+=b+`
|
|
46
|
-
`,s=s.substring(b.length+1),i=!0),!i){let z=this.rules.other.nextBulletRegex(f),$=this.rules.other.hrRegex(f),I=this.rules.other.fencesBeginRegex(f),L=this.rules.other.headingBeginRegex(f),V=this.rules.other.htmlBeginRegex(f),J=this.rules.other.blockquoteBeginRegex(f);for(;s;){let q=s.split(`
|
|
47
|
-
`,1)[0],K;if(b=q,this.options.pedantic?(b=b.replace(this.rules.other.listReplaceNesting," "),K=b):K=b.replace(this.rules.other.tabCharGlobal," "),I.test(b)||L.test(b)||V.test(b)||J.test(b)||z.test(b)||$.test(b))break;if(K.search(this.rules.other.nonSpaceChar)>=f||!b.trim())p+=`
|
|
48
|
-
`+K.slice(f);else{if(k||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||I.test(m)||L.test(m)||$.test(m))break;p+=`
|
|
49
|
-
`+b}k=!b.trim(),d+=q+`
|
|
50
|
-
`,s=s.substring(q.length+1),m=K.slice(f)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(a=!0)),n.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),n.raw+=d}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 i of n.items){if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),i.task){if(i.text=i.text.replace(this.rules.other.listReplaceTask,""),i.tokens[0]?.type==="text"||i.tokens[0]?.type==="paragraph"){i.tokens[0].raw=i.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),i.tokens[0].text=i.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(i.raw);if(d){let p={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};i.checked=p.checked,n.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=p.raw+i.tokens[0].raw,i.tokens[0].text=p.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(p)):i.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):i.tokens.unshift(p)}}if(!n.loose){let d=i.tokens.filter(m=>m.type==="space"),p=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));n.loose=p}}if(n.loose)for(let i of n.items){i.loose=!0;for(let d of i.tokens)d.type==="text"&&(d.type="paragraph")}return n}}html(s){let e=this.rules.block.html.exec(s);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(s){let e=this.rules.block.def.exec(s);if(e){let t=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:t,raw:e[0],href:o,title:n}}}table(s){let e=this.rules.block.table.exec(s);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=Rt(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
51
|
-
`):[],l={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===o.length){for(let a of o)this.rules.other.tableAlignRight.test(a)?l.align.push("right"):this.rules.other.tableAlignCenter.test(a)?l.align.push("center"):this.rules.other.tableAlignLeft.test(a)?l.align.push("left"):l.align.push(null);for(let a=0;a<t.length;a++)l.header.push({text:t[a],tokens:this.lexer.inline(t[a]),header:!0,align:l.align[a]});for(let a of n)l.rows.push(Rt(a,l.header.length).map((c,i)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:l.align[i]})));return l}}lheading(s){let e=this.rules.block.lheading.exec(s);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(s){let e=this.rules.block.paragraph.exec(s);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
52
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(s){let e=this.rules.block.text.exec(s);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(s){let e=this.rules.inline.escape.exec(s);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(s){let e=this.rules.inline.tag.exec(s);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(s){let e=this.rules.inline.link.exec(s);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let l=Me(t.slice(0,-1),"\\");if((t.length-l.length)%2===0)return}else{let l=On(e[2],"()");if(l===-2)return;if(l>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+l;e[2]=e[2].substring(0,l),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],n="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(o);l&&(o=l[1],n=l[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(t)?o=o.slice(1):o=o.slice(1,-1)),At(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(s,e){let t;if((t=this.rules.inline.reflink.exec(s))||(t=this.rules.inline.nolink.exec(s))){let o=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[o.toLowerCase()];if(!n){let l=t[0].charAt(0);return{type:"text",raw:l,text:l}}return At(t,n,t[0],this.lexer,this.rules)}}emStrong(s,e,t=""){let o=this.rules.inline.emStrongLDelim.exec(s);if(!(!o||o[3]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(o[1]||o[2])||!t||this.rules.inline.punctuation.exec(t))){let n=[...o[0]].length-1,l,a,c=n,i=0,d=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*s.length+n);(o=d.exec(e))!=null;){if(l=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!l)continue;if(a=[...l].length,o[3]||o[4]){c+=a;continue}else if((o[5]||o[6])&&n%3&&!((n+a)%3)){i+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+i);let p=[...o[0]][0].length,m=s.slice(0,n+o.index+p+a);if(Math.min(n,a)%2){let k=m.slice(1,-1);return{type:"em",raw:m,text:k,tokens:this.lexer.inlineTokens(k)}}let b=m.slice(2,-2);return{type:"strong",raw:m,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(s){let e=this.rules.inline.code.exec(s);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return o&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(s){let e=this.rules.inline.br.exec(s);if(e)return{type:"br",raw:e[0]}}del(s,e,t=""){let o=this.rules.inline.delLDelim.exec(s);if(o&&(!o[1]||!t||this.rules.inline.punctuation.exec(t))){let n=[...o[0]].length-1,l,a,c=n,i=this.rules.inline.delRDelim;for(i.lastIndex=0,e=e.slice(-1*s.length+n);(o=i.exec(e))!=null;){if(l=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!l||(a=[...l].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 d=[...o[0]][0].length,p=s.slice(0,n+o.index+d+a),m=p.slice(n,-n);return{type:"del",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(s){let e=this.rules.inline.autolink.exec(s);if(e){let t,o;return e[2]==="@"?(t=e[1],o="mailto:"+t):(t=e[1],o=t),{type:"link",raw:e[0],text:t,href:o,tokens:[{type:"text",raw:t,text:t}]}}}url(s){let e;if(e=this.rules.inline.url.exec(s)){let t,o;if(e[2]==="@")t=e[0],o="mailto:"+t;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);t=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:t,href:o,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(s){let e=this.rules.inline.text.exec(s);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},se=class Je{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||be,this.options.tokenizer=this.options.tokenizer||new Ue,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 t={other:W,block:je.normal,inline:_e.normal};this.options.pedantic?(t.block=je.pedantic,t.inline=_e.pedantic):this.options.gfm&&(t.block=je.gfm,this.options.breaks?t.inline=_e.breaks:t.inline=_e.gfm),this.tokenizer.rules=t}static get rules(){return{block:je,inline:_e}}static lex(e,t){return new Je(t).lex(e)}static lexInline(e,t){return new Je(t).inlineTokens(e)}lex(e){e=e.replace(W.carriageReturn,`
|
|
53
|
-
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let o=this.inlineQueue[t];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],o=!1){for(this.options.pedantic&&(e=e.replace(W.tabCharGlobal," ").replace(W.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(a=>(n=a.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let a=t.at(-1);n.raw.length===1&&a!==void 0?a.raw+=`
|
|
54
|
-
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
55
|
-
`)?"":`
|
|
56
|
-
`)+n.raw,a.text+=`
|
|
57
|
-
`+n.text,this.inlineQueue.at(-1).src=a.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
58
|
-
`)?"":`
|
|
59
|
-
`)+n.raw,a.text+=`
|
|
60
|
-
`+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},t.push(n));continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}let l=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),i;this.options.extensions.startBlock.forEach(d=>{i=d.call({lexer:this},c),typeof i=="number"&&i>=0&&(a=Math.min(a,i))}),a<1/0&&a>=0&&(l=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(l))){let a=t.at(-1);o&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
61
|
-
`)?"":`
|
|
62
|
-
`)+n.raw,a.text+=`
|
|
63
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(n),o=l.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let a=t.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
64
|
-
`)?"":`
|
|
65
|
-
`)+n.raw,a.text+=`
|
|
66
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.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,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let o=e,n=null;if(this.tokens.links){let i=Object.keys(this.tokens.links);if(i.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)i.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 l;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)l=n[2]?n[2].length:0,o=o.slice(0,n.index+l)+"["+"a".repeat(n[0].length-l-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 i;if(this.options.extensions?.inline?.some(p=>(i=p.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let p=t.at(-1);i.type==="text"&&p?.type==="text"?(p.raw+=i.raw,p.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,o,c)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e,o,c)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let d=e;if(this.options.extensions?.startInline){let p=1/0,m=e.slice(1),b;this.options.extensions.startInline.forEach(k=>{b=k.call({lexer:this},m),typeof b=="number"&&b>=0&&(p=Math.min(p,b))}),p<1/0&&p>=0&&(d=e.substring(0,p+1))}if(i=this.tokenizer.inlineText(d)){e=e.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(c=i.raw.slice(-1)),a=!0;let p=t.at(-1);p?.type==="text"?(p.raw+=i.raw,p.text+=i.text):t.push(i);continue}if(e){let p="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(p);break}else throw new Error(p)}}return t}},qe=class{options;parser;constructor(s){this.options=s||be}space(s){return""}code({text:s,lang:e,escaped:t}){let o=(e||"").match(W.notSpaceStart)?.[0],n=s.replace(W.endingNewline,"")+`
|
|
67
|
-
`;return o?'<pre><code class="language-'+re(o)+'">'+(t?n:re(n,!0))+`</code></pre>
|
|
68
|
-
`:"<pre><code>"+(t?n:re(n,!0))+`</code></pre>
|
|
69
|
-
`}blockquote({tokens:s}){return`<blockquote>
|
|
70
|
-
${this.parser.parse(s)}</blockquote>
|
|
71
|
-
`}html({text:s}){return s}def(s){return""}heading({tokens:s,depth:e}){return`<h${e}>${this.parser.parseInline(s)}</h${e}>
|
|
72
|
-
`}hr(s){return`<hr>
|
|
73
|
-
`}list(s){let e=s.ordered,t=s.start,o="";for(let a=0;a<s.items.length;a++){let c=s.items[a];o+=this.listitem(c)}let n=e?"ol":"ul",l=e&&t!==1?' start="'+t+'"':"";return"<"+n+l+`>
|
|
74
|
-
`+o+"</"+n+`>
|
|
75
|
-
`}listitem(s){return`<li>${this.parser.parse(s.tokens)}</li>
|
|
76
|
-
`}checkbox({checked:s}){return"<input "+(s?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:s}){return`<p>${this.parser.parseInline(s)}</p>
|
|
77
|
-
`}table(s){let e="",t="";for(let n=0;n<s.header.length;n++)t+=this.tablecell(s.header[n]);e+=this.tablerow({text:t});let o="";for(let n=0;n<s.rows.length;n++){let l=s.rows[n];t="";for(let a=0;a<l.length;a++)t+=this.tablecell(l[a]);o+=this.tablerow({text:t})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
78
|
-
<thead>
|
|
79
|
-
`+e+`</thead>
|
|
80
|
-
`+o+`</table>
|
|
81
|
-
`}tablerow({text:s}){return`<tr>
|
|
82
|
-
${s}</tr>
|
|
83
|
-
`}tablecell(s){let e=this.parser.parseInline(s.tokens),t=s.header?"th":"td";return(s.align?`<${t} align="${s.align}">`:`<${t}>`)+e+`</${t}>
|
|
84
|
-
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${re(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:e,tokens:t}){let o=this.parser.parseInline(t),n=Mt(s);if(n===null)return o;s=n;let l='<a href="'+s+'"';return e&&(l+=' title="'+re(e)+'"'),l+=">"+o+"</a>",l}image({href:s,title:e,text:t,tokens:o}){o&&(t=this.parser.parseInline(o,this.parser.textRenderer));let n=Mt(s);if(n===null)return re(t);s=n;let l=`<img src="${s}" alt="${re(t)}"`;return e&&(l+=` title="${re(e)}"`),l+=">",l}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:re(s.text)}},dt=class{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}checkbox({raw:s}){return s}},ne=class Xe{options;renderer;textRenderer;constructor(e){this.options=e||be,this.options.renderer=this.options.renderer||new qe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dt}static parse(e,t){return new Xe(t).parse(e)}static parseInline(e,t){return new Xe(t).parseInline(e)}parse(e){let t="";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)){t+=c||"";continue}}let l=n;switch(l.type){case"space":{t+=this.renderer.space(l);break}case"hr":{t+=this.renderer.hr(l);break}case"heading":{t+=this.renderer.heading(l);break}case"code":{t+=this.renderer.code(l);break}case"table":{t+=this.renderer.table(l);break}case"blockquote":{t+=this.renderer.blockquote(l);break}case"list":{t+=this.renderer.list(l);break}case"checkbox":{t+=this.renderer.checkbox(l);break}case"html":{t+=this.renderer.html(l);break}case"def":{t+=this.renderer.def(l);break}case"paragraph":{t+=this.renderer.paragraph(l);break}case"text":{t+=this.renderer.text(l);break}default:{let a='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return t}parseInline(e,t=this.renderer){let o="";for(let n=0;n<e.length;n++){let l=e[n];if(this.options.extensions?.renderers?.[l.type]){let c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){o+=c||"";continue}}let a=l;switch(a.type){case"escape":{o+=t.text(a);break}case"html":{o+=t.html(a);break}case"link":{o+=t.link(a);break}case"image":{o+=t.image(a);break}case"checkbox":{o+=t.checkbox(a);break}case"strong":{o+=t.strong(a);break}case"em":{o+=t.em(a);break}case"codespan":{o+=t.codespan(a);break}case"br":{o+=t.br(a);break}case"del":{o+=t.del(a);break}case"text":{o+=t.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}},Re=class{options;block;constructor(s){this.options=s||be}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}emStrongMask(s){return s}provideLexer(){return this.block?se.lex:se.lexInline}provideParser(){return this.block?ne.parse:ne.parseInline}},ts=class{defaults=nt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ne;Renderer=qe;TextRenderer=dt;Lexer=se;Tokenizer=Ue;Hooks=Re;constructor(...s){this.use(...s)}walkTokens(s,e){let t=[];for(let o of s)switch(t=t.concat(e.call(this,o)),o.type){case"table":{let n=o;for(let l of n.header)t=t.concat(this.walkTokens(l.tokens,e));for(let l of n.rows)for(let a of l)t=t.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=o;t=t.concat(this.walkTokens(n.items,e));break}default:{let n=o;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(l=>{let a=n[l].flat(1/0);t=t.concat(this.walkTokens(a,e))}):n.tokens&&(t=t.concat(this.walkTokens(n.tokens,e)))}}return t}use(...s){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(t=>{let o={...t};if(o.async=this.defaults.async||o.async||!1,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let l=e.renderers[n.name];l?e.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=l.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 l=e[n.level];l?l.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),t.renderer){let n=this.defaults.renderer||new qe(this.defaults);for(let l in t.renderer){if(!(l in n))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let a=l,c=t.renderer[a],i=n[a];n[a]=(...d)=>{let p=c.apply(n,d);return p===!1&&(p=i.apply(n,d)),p||""}}o.renderer=n}if(t.tokenizer){let n=this.defaults.tokenizer||new Ue(this.defaults);for(let l in t.tokenizer){if(!(l in n))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let a=l,c=t.tokenizer[a],i=n[a];n[a]=(...d)=>{let p=c.apply(n,d);return p===!1&&(p=i.apply(n,d)),p}}o.tokenizer=n}if(t.hooks){let n=this.defaults.hooks||new Re;for(let l in t.hooks){if(!(l in n))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let a=l,c=t.hooks[a],i=n[a];Re.passThroughHooks.has(l)?n[a]=d=>{if(this.defaults.async&&Re.passThroughHooksRespectAsync.has(l))return(async()=>{let m=await c.call(n,d);return i.call(n,m)})();let p=c.call(n,d);return i.call(n,p)}:n[a]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(n,d);return m===!1&&(m=await i.apply(n,d)),m})();let p=c.apply(n,d);return p===!1&&(p=i.apply(n,d)),p}}o.hooks=n}if(t.walkTokens){let n=this.defaults.walkTokens,l=t.walkTokens;o.walkTokens=function(a){let c=[];return c.push(l.call(this,a)),n&&(c=c.concat(n.call(this,a))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,e){return se.lex(s,e??this.defaults)}parser(s,e){return ne.parse(s,e??this.defaults)}parseMarkdown(s){return(e,t)=>{let o={...t},n={...this.defaults,...o},l=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&o.async===!1)return l(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 l(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return l(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=s),n.async)return(async()=>{let a=n.hooks?await n.hooks.preprocess(e):e,c=await(n.hooks?await n.hooks.provideLexer():s?se.lex:se.lexInline)(a,n),i=n.hooks?await n.hooks.processAllTokens(c):c;n.walkTokens&&await Promise.all(this.walkTokens(i,n.walkTokens));let d=await(n.hooks?await n.hooks.provideParser():s?ne.parse:ne.parseInline)(i,n);return n.hooks?await n.hooks.postprocess(d):d})().catch(l);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer():s?se.lex:se.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():s?ne.parse:ne.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return l(a)}}}onError(s,e){return t=>{if(t.message+=`
|
|
85
|
-
Please report this to https://github.com/markedjs/marked.`,s){let o="<p>An error occurred:</p><pre>"+re(t.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(t);throw t}}},ve=new ts;function B(s,e){return ve.parse(s,e)}B.options=B.setOptions=function(s){return ve.setOptions(s),B.defaults=ve.defaults,Ut(B.defaults),B};B.getDefaults=nt;B.defaults=be;B.use=function(...s){return ve.use(...s),B.defaults=ve.defaults,Ut(B.defaults),B};B.walkTokens=function(s,e){return ve.walkTokens(s,e)};B.parseInline=ve.parseInline;B.Parser=ne;B.parser=ne.parse;B.Renderer=qe;B.TextRenderer=dt;B.Lexer=se;B.lexer=se.lex;B.Tokenizer=Ue;B.Hooks=Re;B.parse=B;B.options;B.setOptions;B.use;B.walkTokens;B.parseInline;ne.parse;se.lex;const qn=new ts({breaks:!0,gfm:!0});function Hn(s){return s?qn.parse(s):""}const Gn={key:0,class:"my-2"},Wn={key:0,class:"relative inline-flex h-4 w-4 items-center justify-center"},Kn={key:1,class:"text-text-muted"},Zn={key:0,class:"mt-1 ml-2 rounded-lg border-l-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"},Qn={key:0,class:"inline-flex items-center gap-0.5 ml-1 align-text-bottom"},Jn=te({__name:"InlineThinkingBlock",props:{isThinking:{type:Boolean},content:{},completed:{type:Boolean}},setup(s){const e=M(!1);return(t,o)=>s.isThinking||s.completed&&s.content?(h(),g("div",Gn,[r("button",{class:D(["flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-colors",s.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)},[s.isThinking?(h(),g("span",Wn,[...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)])])):(h(),g("span",Kn,"💭")),r("span",null,S(s.isThinking?"Thinking...":"Thought process"),1),r("span",{class:D(["text-text-muted transition-transform",{"rotate-180":e.value}])},"▾",2)],2),e.value?(h(),g("div",Zn,[Se(S(s.content)+" ",1),s.isThinking?(h(),g("span",Qn,[...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)])])):A("",!0)])):A("",!0)])):A("",!0)}}),Xn={class:"text-sm leading-relaxed text-text-primary"},Yn=te({__name:"AssistantTokenStream",props:{sessionId:{}},setup(s){const e=s,t=jt(),{getColor:o}=As(ys(e,"sessionId")),n=j(()=>t.getTokens(e.sessionId)),l=j(()=>{const a=n.value,c=[];let i=!1,d="";for(const p of a){if(d+=p.text,!i&&d.includes("<think>")){i=!0;const m=d.split("<think>")[0]??"";m&&c.length===0&&c.push({...p,text:m});continue}if(i){if(d.includes("</think>")){i=!1;const m=d.split("</think>").pop()??"",b=p.text;if(m.endsWith(b)&&b.includes("</think>")){const k=b.split("</think>").pop()??"";k&&c.push({...p,text:k})}}continue}c.push(p)}return c});return(a,c)=>(h(),g("div",Xn,[(h(!0),g(O,null,Q(l.value,i=>(h(),g("span",{key:i.id,class:"inline",style:bs({borderBottom:`2px solid ${x(o)(i.confidence)}`})},S(i.text),5))),128))]))}}),eo={key:0,class:"mb-1.5 space-y-1.5"},to=["src","alt","onClick"],so={class:"mt-0.5 flex items-center gap-1.5 text-[10px] opacity-60"},no={class:"truncate"},oo={class:"flex flex-wrap gap-1.5"},ro={class:"max-w-[100px] truncate opacity-90"},ao={class:"opacity-60"},lo=["src"],io=te({__name:"AttachmentBubble",props:{attachments:{}},setup(s){const e=M(null);function t(n){n.content&&(e.value=n.content)}function o(){e.value=null}return(n,l)=>s.attachments.length>0?(h(),g("div",eo,[(h(!0),g(O,null,Q(s.attachments.filter(a=>a.type==="image"&&a.content),a=>(h(),g("div",{key:a.id},[r("img",{src:a.content,alt:a.name,class:"max-h-48 max-w-full cursor-pointer rounded-lg object-contain",onClick:c=>t(a)},null,8,to),r("div",so,[r("span",no,S(a.name),1),r("span",null,S(x(Ze)(a.sizeBytes)),1)])]))),128)),r("div",oo,[(h(!0),g(O,null,Q(s.attachments.filter(a=>a.type==="document"),a=>(h(),g("div",{key:a.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[l[1]||(l[1]=r("svg",{class:"h-3.5 w-3.5 opacity-70",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r("polyline",{points:"14 2 14 8 20 8"})],-1)),r("span",ro,S(a.name),1),r("span",ao,S(x(Ze)(a.sizeBytes)),1)]))),128))]),(h(),Ae(ks,{to:"body"},[G(zt,{"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:Et(()=>[e.value?(h(),g("div",{key:0,class:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:o},[r("img",{src:e.value,class:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl",onClick:l[0]||(l[0]=Le(()=>{},["stop"]))},null,8,lo),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",onClick:o},[...l[2]||(l[2]=[r("svg",{class:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])):A("",!0)]),_:1})]))])):A("",!0)}}),co={class:"text-sm leading-relaxed whitespace-pre-wrap"},uo=["innerHTML"],po={key:3,class:"inline-flex items-center gap-1 py-1"},mo={key:4,class:"mt-1 text-[10px] text-warning"},ho={key:2,class:"mt-1.5 flex items-center gap-2 text-[10px] text-text-muted"},go={class:"text-[10px] opacity-50"},fo=te({__name:"ChatBubble",props:{message:{}},setup(s){const e=s,t=He(),o=Es(),n=et(),l=j(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),a=j(()=>e.message.sessionId?t.sessionById(e.message.sessionId)?.doneReason==="length":!1),c=j(()=>e.message.sessionId?o.getThinking(e.message.sessionId):{isThinking:!1,content:""}),i=j(()=>e.message.role==="user"),d=j(()=>{if(i.value){if(e.message.attachments?.length){const b=`
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
`,k=e.message.content.lastIndexOf(b);if(k!==-1)return e.message.content.slice(k+b.length)}return e.message.content}return e.message.isStreaming?"":e.message.content.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}),p=j(()=>i.value||!d.value?"":Hn(d.value)),m=j(()=>new Date(e.message.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}));return(b,k)=>(h(),g("div",{class:D(["flex w-full",i.value?"justify-end":"justify-start"])},[r("div",{class:D(["max-w-[80%] rounded-2xl px-4 py-2.5",i.value?"bg-accent text-white rounded-br-md":"bg-surface-raised border border-border-default rounded-bl-md"])},[i.value?(h(),g(O,{key:0},[s.message.attachments?.length?(h(),Ae(io,{key:0,attachments:s.message.attachments},null,8,["attachments"])):A("",!0),r("p",co,S(d.value),1)],64)):(h(),g(O,{key:1},[s.message.sessionId?(h(),Ae(Jn,{key:0,"is-thinking":c.value.isThinking,content:c.value.content,completed:!s.message.isStreaming},null,8,["is-thinking","content","completed"])):A("",!0),s.message.isStreaming&&s.message.sessionId?(h(),Ae(Yn,{key:1,"session-id":s.message.sessionId},null,8,["session-id"])):d.value?(h(),g("div",{key:2,class:"markdown-prose",innerHTML:p.value},null,8,uo)):A("",!0),s.message.isStreaming&&!d.value?(h(),g("span",po,[...k[0]||(k[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)])])):A("",!0),a.value&&!s.message.isStreaming?(h(),g("div",mo," Response was truncated — increase num_predict in settings for longer responses ")):A("",!0)],64)),!i.value&&!s.message.isStreaming&&l.value?(h(),g("div",ho,[r("span",null,S(l.value.completionTokenCount)+" tokens",1),k[1]||(k[1]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,S(l.value.tokensPerSecond.toFixed(1))+" tok/s",1),k[2]||(k[2]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,S(l.value.ttftMs<1e3?l.value.ttftMs.toFixed(0)+"ms":(l.value.ttftMs/1e3).toFixed(1)+"s")+" TTFT",1)])):A("",!0),r("div",{class:D(["mt-1",i.value?"text-right":""])},[r("span",go,S(m.value),1)],2)],2)],2))}}),xo={key:0,class:"flex items-center justify-center"},vo=te({__name:"ChatMessageList",props:{messages:{}},setup(s,{expose:e}){const t=s,o=M(null);function n(){Ss(()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight)})}return ee(()=>t.messages.length,()=>n()),ee(()=>t.messages[t.messages.length-1]?.content,()=>n()),e({scrollToBottom:n}),(l,a)=>(h(),g("div",{ref_key:"containerRef",ref:o,class:"flex-1 overflow-y-auto px-4 py-6"},[r("div",{class:D(["mx-auto max-w-3xl space-y-4",s.messages.length===0?"flex min-h-full flex-col justify-center":""])},[s.messages.length===0?(h(),g("div",xo,[...a[0]||(a[0]=[ws('<div class="text-center"><svg class="mx-auto mb-4 h-20 w-20 text-text-muted/20" viewBox="0 0 297.5 297.5"><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"></path></svg><p class="text-2xl font-semibold text-text-primary mb-2">LLMxRay</p><p class="text-sm text-text-muted">Start a conversation with a local model</p></div>',1)])])):A("",!0),(h(!0),g(O,null,Q(s.messages,c=>(h(),Ae(fo,{key:c.id,message:c},null,8,["message"]))),128))],2)],512))}}),bo=new Set(["png","jpg","jpeg","gif","webp"]),yo=new Set(["pdf","docx","txt","md","csv"]);function ss(s){return s.split(".").pop()?.toLowerCase()??""}function Ye(s){return bo.has(ss(s))}function ns(s){return yo.has(ss(s))}function ko(s){return Ye(s)||ns(s)}const wo=".pdf,.docx,.txt,.md,.csv,.png,.jpg,.jpeg,.gif,.webp",Nt=8e3;function So(){const s=M([]),e=j(()=>s.value.some(c=>c.status==="parsing"));async function t(c){for(const i of c){if(!ko(i.name))continue;const d={id:pe(),name:i.name,type:Ye(i.name)?"image":"document",mimeType:i.type,sizeBytes:i.size,status:"pending"};s.value.push(d),Ye(i.name)?o(i,d):ns(i.name)&&n(i,d)}}function o(c,i){i.status="parsing";const d=i.id,p=new FileReader;p.onload=()=>{const m=s.value.find(b=>b.id===d);m&&(m.content=p.result,m.status="ready")},p.onerror=()=>{const m=s.value.find(b=>b.id===d);m&&(m.error="Failed to read image",m.status="error")},p.readAsDataURL(c)}async function n(c,i){i.status="parsing";const d=i.id;try{const p=Ps(c.name);if(!p){const k=s.value.find(f=>f.id===d);k&&(k.error="Unsupported format",k.status="error");return}let m=await Ds(c,p);m.length>Nt&&(m=m.slice(0,Nt)+`
|
|
90
|
-
|
|
91
|
-
[... truncated]`);const b=s.value.find(k=>k.id===d);b&&(b.content=m,b.status="ready")}catch(p){const m=s.value.find(b=>b.id===d);m&&(m.error=p instanceof Error?p.message:"Parse failed",m.status="error")}}function l(c){s.value=s.value.filter(i=>i.id!==c)}function a(){s.value=[]}return{attachments:s,isProcessing:e,addFiles:t,removeAttachment:l,clearAttachments:a}}const $o={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"},Co={class:"p-1.5"},To=["onMouseenter","onClick"],_o={class:"shrink-0 font-mono text-xs text-accent"},Mo={class:"truncate text-xs text-text-muted"},Ro={class:"ml-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 text-[10px] text-text-muted"},Ao=te({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(s,{expose:e,emit:t}){const o=s,n=t,l=M(0),a=j(()=>{if(!o.visible)return[];const d=o.filter.replace(/^\//,"");return d?Zs(d):Object.values(Ot()).flat()});ee(()=>o.filter,()=>{l.value=0});function c(d){return!o.visible||a.value.length===0?!1:d.key==="ArrowDown"?(d.preventDefault(),l.value=(l.value+1)%a.value.length,!0):d.key==="ArrowUp"?(d.preventDefault(),l.value=l.value<=0?a.value.length-1:l.value-1,!0):d.key==="Tab"||d.key==="Enter"&&a.value.length>0?(d.preventDefault(),n("select",a.value[l.value]),!0):d.key==="Escape"?(d.preventDefault(),n("close"),!0):!1}e({handleKeydown:c});const i={chat:"Chat & Conversation",settings:"Model & Settings",navigation:"Features & Navigation"};return(d,p)=>s.visible&&a.value.length>0?(h(),g("div",$o,[r("div",Co,[(h(!0),g(O,null,Q(a.value,(m,b)=>(h(),g("button",{key:m.name,class:D(["flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm transition-colors",b===l.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMouseenter:k=>l.value=b,onClick:k=>d.$emit("select",m)},[r("span",_o,"/"+S(m.name),1),r("span",Mo,S(m.description),1),r("span",Ro,S(i[m.category]??m.category),1)],42,To))),128))])])):A("",!0)}}),No={key:0,class:"flex flex-wrap gap-2 px-2.5 pb-1.5 pt-1"},zo=["src","alt"],Eo={key:1,class:"text-text-muted"},Io={class:"max-w-[120px] truncate text-text-primary"},Po={class:"text-text-muted"},Do={key:2,class:"h-3 w-3 animate-spin rounded-full border-2 border-accent border-t-transparent"},Bo={key:3,class:"text-error",title:"Parse error"},jo=["onClick"],Lo=te({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(s){return(e,t)=>s.attachments.length>0?(h(),g("div",No,[(h(!0),g(O,null,Q(s.attachments,o=>(h(),g("div",{key:o.id,class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface-overlay px-2.5 py-1.5 text-xs"},[o.type==="image"&&o.content?(h(),g("img",{key:0,src:o.content,alt:o.name,class:"h-6 w-6 rounded object-cover"},null,8,zo)):o.type==="document"?(h(),g("span",Eo,[...t[0]||(t[0]=[r("svg",{class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r("polyline",{points:"14 2 14 8 20 8"})],-1)])])):A("",!0),r("span",Io,S(o.name),1),r("span",Po,S(x(Ze)(o.sizeBytes)),1),o.status==="parsing"?(h(),g("span",Do)):o.status==="error"?(h(),g("span",Bo,"!")):A("",!0),r("button",{class:"text-text-muted hover:text-error transition-colors",onClick:n=>e.$emit("remove",o.id)},[...t[1]||(t[1]=[r("svg",{class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,jo)]))),128))])):A("",!0)}}),Fo={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"},Oo={class:"relative mx-auto max-w-3xl"},Vo=["accept"],Uo={class:"mx-auto flex max-w-3xl flex-col rounded-xl border border-border-default bg-surface transition-colors focus-within:border-accent"},qo=["disabled","title"],Ho={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:"Vision model — can process images"},Go=["disabled"],Wo=["disabled","placeholder"],Ko=["disabled"],Zo=te({__name:"ChatInput",props:{isStreaming:{type:Boolean},selectedModel:{},isVisionModel:{type:Boolean}},emits:["send","command","cancel"],setup(s,{expose:e,emit:t}){const o=t;e({focus:L});const n=tt(),l=M(""),a=M(null),c=M(null),i=M(null),d=M(!1),{attachments:p,isProcessing:m,addFiles:b,removeAttachment:k,clearAttachments:f}=So();It(()=>{n.fetchModels()});const z=j(()=>{const C=l.value;return C.startsWith("/")&&!C.includes(`
|
|
92
|
-
`)}),$=j(()=>{if(!z.value)return"";const C=l.value.indexOf(" ");return C===-1?l.value:l.value.slice(0,C)}),I=j(()=>{const C=l.value.trim().length>0,R=p.value.length>0;return(C||R)&&!m.value});function L(){a.value?.focus()}function V(C){z.value&&i.value&&i.value.handleKeydown(C)||C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),q())}function J(C){l.value=`/${C.name} `,a.value?.focus()}function q(){const C=l.value.trim();if(!(!C&&p.value.length===0)){if(C.startsWith("/")&&p.value.length===0){const R=C.indexOf(" "),oe=R===-1?C.slice(1):C.slice(1,R),he=R===-1?"":C.slice(R+1);o("command",oe,he)}else o("send",C,[...p.value]),f();l.value="",a.value&&(a.value.style.height="auto")}}function K(C){const R=C.target;R.style.height="auto",R.style.height=Math.min(R.scrollHeight,200)+"px"}function ce(){l.value=""}function X(){l.value="/",a.value?.focus()}function me(){c.value?.click()}function $e(C){const R=C.target;R.files&&R.files.length>0&&(b(R.files),R.value="")}function Ce(C){C.preventDefault(),d.value=!0}function T(){d.value=!1}function u(C){C.preventDefault(),d.value=!1,C.dataTransfer?.files&&C.dataTransfer.files.length>0&&b(C.dataTransfer.files)}function y(C){const R=C.clipboardData?.items;if(!R)return;const oe=[];for(const he of R)if(he.type.startsWith("image/")){const ae=he.getAsFile();ae&&oe.push(ae)}oe.length>0&&(C.preventDefault(),b(oe))}return(C,R)=>(h(),g("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:Ce,onDragleave:T,onDrop:u},[d.value?(h(),g("div",Fo,[...R[2]||(R[2]=[r("span",{class:"text-sm text-accent"},"Drop files to attach",-1)])])):A("",!0),r("div",Oo,[G(Ao,{ref_key:"dropdownRef",ref:i,filter:$.value,visible:z.value,onSelect:J,onClose:ce},null,8,["filter","visible"])]),r("input",{ref_key:"fileInputRef",ref:c,type:"file",multiple:"",accept:x(wo),class:"hidden",onChange:$e},null,40,Vo),r("div",Uo,[G(Lo,{attachments:x(p),onRemove:x(k)},null,8,["attachments","onRemove"]),r("div",{class:D(["flex items-end gap-2 p-1.5",{"pt-0":x(p).length>0}])},[r("button",{disabled:s.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:s.isVisionModel?"Attach files or images":"Attach files",onClick:me},[R[4]||(R[4]=r("svg",{class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})],-1)),s.isVisionModel?(h(),g("span",Ho,[...R[3]||(R[3]=[r("svg",{class:"h-2.5 w-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3"},[r("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r("circle",{cx:"12",cy:"12",r:"3"})],-1)])])):A("",!0)],8,qo),r("button",{disabled:s.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:"Commands",onClick:X},[...R[5]||(R[5]=[r("svg",{class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[r("line",{x1:"17",y1:"4",x2:"7",y2:"20"})],-1)])],8,Go),U(r("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":R[0]||(R[0]=oe=>l.value=oe),disabled:s.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:s.isVisionModel?"Send a message or paste/drop an image...":"Send a message... (Shift+Enter for new line)",onKeydown:V,onInput:K,onPaste:y},null,40,Wo),[[Z,l.value]]),s.isStreaming?(h(),g("button",{key:0,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-error text-white transition-colors hover:bg-error/80",title:"Stop generating",onClick:R[1]||(R[1]=oe=>C.$emit("cancel"))},[...R[6]||(R[6]=[r("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-white"},null,-1)])])):(h(),g("button",{key:1,disabled:!I.value||!s.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:"Send message",onClick:q},[...R[7]||(R[7]=[r("svg",{class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"})],-1)])],8,Ko))],2)])],32))}}),Qo={class:"flex h-full flex-col overflow-y-auto"},Jo={class:"space-y-5 p-4 pb-12"},Xo={class:"flex items-center justify-between"},Yo={class:"flex items-center gap-2"},er=["disabled"],tr={key:0,class:"text-[10px] text-text-muted -mt-3"},sr={key:1,class:"text-[10px] text-text-muted -mt-3"},nr={class:"mb-1.5 flex items-center justify-between"},or={class:"text-xs text-text-muted"},rr={class:"mb-1.5 flex items-center justify-between"},ar={class:"text-xs text-text-muted"},lr={class:"mb-1.5 flex items-center justify-between"},ir={class:"text-xs text-text-muted"},cr={key:2,class:"space-y-4 pl-1"},ur={class:"mb-1.5 flex items-center justify-between"},dr={class:"text-xs text-text-muted"},pr={class:"mb-1.5 flex items-center justify-between"},mr={class:"text-xs text-text-muted"},hr={class:"mb-1.5 flex items-center justify-between"},gr={class:"text-xs text-text-muted"},fr={class:"mb-1.5 flex items-center justify-between"},xr={class:"text-xs text-text-muted"},vr={class:"mb-1.5 flex items-center justify-between"},br={class:"text-xs text-text-muted"},yr={key:0,class:"ml-1 text-accent"},kr={key:0,class:"pl-1 space-y-2"},wr={key:0,class:"space-y-1"},Sr=["onClick"],$r={key:1,class:"text-[10px] text-text-muted px-2"},Cr={key:0,class:"ml-1 text-accent"},Tr={key:4,class:"space-y-4 pl-1"},_r={class:"flex items-center justify-between"},Mr={key:0},Rr={class:"mb-1 flex items-center justify-between"},Ar={class:"text-[10px] text-text-muted"},Nr={class:"flex items-center justify-between"},zr={key:1},Er={class:"mb-1 flex items-center justify-between"},Ir={class:"text-[10px] text-text-muted"},Pr={class:"flex items-center justify-between"},Dr={key:2,class:"space-y-1"},Br={class:"flex-1 text-text-secondary"},jr=["onClick"],Lr={class:"flex items-center justify-between"},Fr={key:3,class:"space-y-2"},Or=["value"],Vr={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},Ur={class:"space-y-1.5"},qr={class:"min-w-0 flex-1"},Hr={class:"truncate text-[11px] font-mono text-text-primary"},Gr={class:"text-[9px] text-text-muted"},Wr=["disabled","onClick"],Kr={key:0,class:"mt-2 text-[9px] text-text-muted"},Zr={class:"mb-1 flex items-center justify-between"},Qr={class:"text-[10px] text-text-muted"},Jr=te({__name:"ChatSettingsPanel",props:{modelValue:{},selectedModel:{},ragEnabled:{type:Boolean}},emits:["update:modelValue","update:ragEnabled"],setup(s,{emit:e}){const t=s,o=e,n=M(t.modelValue.systemPrompt),l=M(t.modelValue.options.temperature??.7),a=M(t.modelValue.options.num_predict??-1),c=M(t.modelValue.options.num_ctx??4096),i=M(t.modelValue.options.top_p??.9),d=M(t.modelValue.options.top_k??40),p=M(t.modelValue.options.repeat_penalty??1.1),m=M(t.modelValue.options.seed??-1),b=M(t.modelValue.options.stop?.join(", ")??""),k=M(t.modelValue.options.mirostat??0);ee(()=>t.modelValue.options,T=>{l.value=T.temperature??.7,a.value=T.num_predict??-1,c.value=T.num_ctx??4096,i.value=T.top_p??.9,d.value=T.top_k??40,p.value=T.repeat_penalty??1.1,m.value=T.seed??-1,b.value=T.stop?.join(", ")??"",k.value=T.mirostat??0},{deep:!0}),ee([n,l,a,c,i,d,p,m,b,k],()=>{const T=b.value.split(",").map(u=>u.trim()).filter(Boolean);o("update:modelValue",{systemPrompt:n.value,options:{temperature:l.value,num_predict:a.value===-1?void 0:a.value,num_ctx:c.value,top_p:i.value,top_k:d.value,repeat_penalty:p.value,seed:m.value===-1?void 0:m.value,stop:T.length>0?T:void 0,mirostat:k.value}})},{deep:!0}),ee(()=>t.modelValue,T=>{n.value=T.systemPrompt,l.value=T.options.temperature??.7,a.value=T.options.num_predict??-1,c.value=T.options.num_ctx??4096,i.value=T.options.top_p??.9,d.value=T.options.top_k??40,p.value=T.options.repeat_penalty??1.1,m.value=T.options.seed??-1,k.value=T.options.mirostat??0});const f=st(),z=Pt(),$=Vt(),I=tt(),L=Lt(),V=j(()=>I.supportsTools(t.selectedModel));ee(()=>t.selectedModel,T=>{T&&!I.supportsTools(T)&&f.enabledTools.length>0&&f.disableAll()});const J=M(!1),q=M(!1),K=M(!1),ce=M(!1),X=M(""),me=M(""),$e=[{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 Ce(T){ce.value=!0,me.value=T,X.value="Starting download...";try{await ze.pullModel(T,(u,y,C)=>{if(y&&C){const R=Math.round(y/C*100);X.value=`${u} ${R}%`}else X.value=u}),X.value="Done!",await I.fetchModels(),$.settings.ragMemory.embeddingModel=T}catch(u){X.value=`Failed: ${u instanceof Error?u.message:"Unknown error"}`}finally{ce.value=!1,setTimeout(()=>{X.value="",me.value=""},3e3)}}return(T,u)=>(h(),g("div",Qo,[r("div",Jo,[r("div",null,[u[25]||(u[25]=r("label",{class:"mb-1.5 block text-xs font-medium text-text-secondary"},"System Prompt",-1)),U(r("textarea",{"onUpdate:modelValue":u[0]||(u[0]=y=>n.value=y),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:"You are a helpful assistant..."},null,512),[[Z,n.value]]),u[26]||(u[26]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Instructions sent before the conversation. Sets the model's behavior and persona. ",-1))]),r("div",Xo,[r("div",Yo,[u[27]||(u[27]=r("span",{class:"text-xs font-medium text-text-secondary"},"Knowledge Base",-1)),r("span",{class:D(["rounded-full px-1.5 py-0.5 text-[9px] font-medium",s.ragEnabled&&x(L).readyDocuments.length>0?"bg-accent/10 text-accent":"bg-surface-overlay text-text-muted"])},S(s.ragEnabled&&x(L).readyDocuments.length>0?"KB Enabled":"KB Disabled"),3)]),r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",s.ragEnabled&&x(L).readyDocuments.length>0?"bg-accent":"bg-surface-overlay"]),disabled:x(L).readyDocuments.length===0,onClick:u[1]||(u[1]=y=>o("update:ragEnabled",!s.ragEnabled))},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",s.ragEnabled&&x(L).readyDocuments.length>0?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,er)]),x(L).readyDocuments.length>0?(h(),g("p",tr,[Se(S(x(L).enabledDocuments.length)+"/"+S(x(L).readyDocuments.length)+" documents · ",1),r("button",{class:"text-accent hover:underline",onClick:u[2]||(u[2]=y=>x(z).push("/rag"))},"Manage")])):(h(),g("p",sr,[u[28]||(u[28]=Se(" No documents ingested · ",-1)),r("button",{class:"text-accent hover:underline",onClick:u[3]||(u[3]=y=>x(z).push("/rag"))},"Add documents")])),r("div",null,[r("div",nr,[u[29]||(u[29]=r("label",{class:"text-xs font-medium text-text-secondary"},"Temperature",-1)),r("span",or,S(l.value.toFixed(2)),1)]),U(r("input",{"onUpdate:modelValue":u[4]||(u[4]=y=>l.value=y),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[Z,l.value,void 0,{number:!0}]]),u[30]||(u[30]=r("div",{class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},[r("span",null,"Precise"),r("span",null,"Creative")],-1))]),r("div",null,[r("div",rr,[u[31]||(u[31]=r("label",{class:"text-xs font-medium text-text-secondary"},"Max Tokens",-1)),r("span",ar,S(a.value===-1?"Unlimited":a.value),1)]),U(r("input",{"onUpdate:modelValue":u[5]||(u[5]=y=>a.value=y),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:"-1 for unlimited"},null,512),[[Z,a.value,void 0,{number:!0}]]),u[32]||(u[32]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Maximum response length. -1 = unlimited. ",-1))]),r("div",null,[r("div",lr,[u[33]||(u[33]=r("label",{class:"text-xs font-medium text-text-secondary"},"Context Window",-1)),r("span",ir,S(c.value.toLocaleString()),1)]),U(r("select",{"onUpdate:modelValue":u[6]||(u[6]=y=>c.value=y),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"},[...u[34]||(u[34]=[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),[[Ke,c.value,void 0,{number:!0}]]),u[35]||(u[35]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Total context the model can see. Higher = more memory, slower. ",-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:u[7]||(u[7]=y=>J.value=!J.value)},[u[36]||(u[36]=r("span",null,"Advanced Sampling",-1)),r("span",{class:D(["transition-transform",{"rotate-180":J.value}])},"▾",2)]),J.value?(h(),g("div",cr,[r("div",null,[r("div",ur,[u[37]||(u[37]=r("label",{class:"text-xs font-medium text-text-secondary"},"Top-P",-1)),r("span",dr,S(i.value.toFixed(2)),1)]),U(r("input",{"onUpdate:modelValue":u[8]||(u[8]=y=>i.value=y),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[Z,i.value,void 0,{number:!0}]]),u[38]||(u[38]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Nucleus sampling. Lower = more focused on likely tokens. ",-1))]),r("div",null,[r("div",pr,[u[39]||(u[39]=r("label",{class:"text-xs font-medium text-text-secondary"},"Top-K",-1)),r("span",mr,S(d.value),1)]),U(r("input",{"onUpdate:modelValue":u[9]||(u[9]=y=>d.value=y),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[Z,d.value,void 0,{number:!0}]]),u[40]||(u[40]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Limits sampling to the top K tokens at each step. ",-1))]),r("div",null,[r("div",hr,[u[41]||(u[41]=r("label",{class:"text-xs font-medium text-text-secondary"},"Repeat Penalty",-1)),r("span",gr,S(p.value.toFixed(2)),1)]),U(r("input",{"onUpdate:modelValue":u[10]||(u[10]=y=>p.value=y),type:"range",min:"1.0",max:"2.0",step:"0.05",class:"w-full accent-accent"},null,512),[[Z,p.value,void 0,{number:!0}]]),u[42]||(u[42]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Penalizes tokens that already appeared. Higher = less repetition. ",-1))]),r("div",null,[r("div",fr,[u[43]||(u[43]=r("label",{class:"text-xs font-medium text-text-secondary"},"Mirostat",-1)),r("span",xr,S(k.value===0?"Off":`v${k.value}`),1)]),U(r("select",{"onUpdate:modelValue":u[11]||(u[11]=y=>k.value=y),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"},[...u[44]||(u[44]=[r("option",{value:0},"Disabled",-1),r("option",{value:1},"Mirostat v1",-1),r("option",{value:2},"Mirostat v2",-1)])],512),[[Ke,k.value,void 0,{number:!0}]]),u[45]||(u[45]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Adaptive perplexity-based sampling. Overrides top-p/top-k when enabled. ",-1))]),r("div",null,[r("div",vr,[u[46]||(u[46]=r("label",{class:"text-xs font-medium text-text-secondary"},"Seed",-1)),r("span",br,S(m.value===-1?"Random":m.value),1)]),U(r("input",{"onUpdate:modelValue":u[12]||(u[12]=y=>m.value=y),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:"-1 for random"},null,512),[[Z,m.value,void 0,{number:!0}]]),u[47]||(u[47]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Fixed seed for reproducible outputs. -1 = random. ",-1))]),r("div",null,[u[48]||(u[48]=r("label",{class:"mb-1.5 block text-xs font-medium text-text-secondary"},"Stop Sequences",-1)),U(r("input",{"onUpdate:modelValue":u[13]||(u[13]=y=>b.value=y),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:"e.g. Human:, \\n\\n"},null,512),[[Z,b.value]]),u[49]||(u[49]=r("p",{class:"mt-1 text-[10px] text-text-muted"}," Comma-separated strings that stop generation when produced. ",-1))])])):A("",!0),V.value?(h(),g(O,{key:3},[r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:u[14]||(u[14]=y=>q.value=!q.value)},[r("span",null,[u[50]||(u[50]=Se(" Tools ",-1)),x(f).enabledDefinitions.length>0?(h(),g("span",yr," ("+S(x(f).enabledDefinitions.length)+" active) ",1)):A("",!0)]),r("span",{class:D(["transition-transform",{"rotate-180":q.value}])},"▾",2)]),q.value?(h(),g("div",kr,[x(f).allTools.length>0?(h(),g("div",wr,[(h(!0),g(O,null,Q(x(f).allTools,y=>(h(),g("div",{key:y.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1.5 text-[11px]"},[r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",y.enabled?"bg-accent":"bg-surface-overlay"]),onClick:C=>x(f).toggleEnabled(y.id)},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",y.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,Sr),r("span",{class:D(["font-mono",y.enabled?"text-text-primary":"text-text-muted"])},S(y.definition.function.name),3)]))),128))])):(h(),g("p",$r,"No tools defined yet")),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:u[15]||(u[15]=y=>x(z).push("/tools"))}," Manage in Tool Workshop... ")])):A("",!0)],64)):A("",!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:u[16]||(u[16]=y=>K.value=!K.value)},[r("span",null,[u[51]||(u[51]=Se(" Memory ",-1)),x($).factCount>0?(h(),g("span",Cr," ("+S(x($).factCount)+" facts) ",1)):A("",!0)]),r("span",{class:D(["transition-transform",{"rotate-180":K.value}])},"▾",2)]),K.value?(h(),g("div",Tr,[r("div",_r,[u[52]||(u[52]=r("div",null,[r("p",{class:"text-xs font-medium text-text-secondary"},"Sliding Window"),r("p",{class:"text-[10px] text-text-muted"},"Keep only the last N messages")],-1)),r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",x($).settings.slidingWindow.enabled?"bg-accent":"bg-surface-overlay"]),onClick:u[17]||(u[17]=y=>x($).settings.slidingWindow.enabled=!x($).settings.slidingWindow.enabled)},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",x($).settings.slidingWindow.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x($).settings.slidingWindow.enabled?(h(),g("div",Mr,[r("div",Rr,[u[53]||(u[53]=r("label",{class:"text-[10px] text-text-muted"},"Max messages",-1)),r("span",Ar,S(x($).settings.slidingWindow.maxMessages),1)]),U(r("input",{"onUpdate:modelValue":u[18]||(u[18]=y=>x($).settings.slidingWindow.maxMessages=y),type:"range",min:"10",max:"200",step:"10",class:"w-full accent-accent"},null,512),[[Z,x($).settings.slidingWindow.maxMessages,void 0,{number:!0}]])])):A("",!0),r("div",Nr,[u[54]||(u[54]=r("div",null,[r("p",{class:"text-xs font-medium text-text-secondary"},"Auto-Summarize"),r("p",{class:"text-[10px] text-text-muted"},"Summarize older messages automatically")],-1)),r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",x($).settings.autoSummarize.enabled?"bg-accent":"bg-surface-overlay"]),onClick:u[19]||(u[19]=y=>x($).settings.autoSummarize.enabled=!x($).settings.autoSummarize.enabled)},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",x($).settings.autoSummarize.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x($).settings.autoSummarize.enabled?(h(),g("div",zr,[r("div",Er,[u[55]||(u[55]=r("label",{class:"text-[10px] text-text-muted"},"Trigger after",-1)),r("span",Ir,S(x($).settings.autoSummarize.triggerThreshold)+" messages",1)]),U(r("input",{"onUpdate:modelValue":u[20]||(u[20]=y=>x($).settings.autoSummarize.triggerThreshold=y),type:"range",min:"10",max:"100",step:"5",class:"w-full accent-accent"},null,512),[[Z,x($).settings.autoSummarize.triggerThreshold,void 0,{number:!0}]])])):A("",!0),r("div",Pr,[u[56]||(u[56]=r("div",null,[r("p",{class:"text-xs font-medium text-text-secondary"},"User Memories"),r("p",{class:"text-[10px] text-text-muted"},"/remember facts injected into context")],-1)),r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",x($).settings.userFacts.enabled?"bg-accent":"bg-surface-overlay"]),onClick:u[21]||(u[21]=y=>x($).settings.userFacts.enabled=!x($).settings.userFacts.enabled)},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",x($).settings.userFacts.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x($).settings.userFacts.enabled&&x($).facts.length>0?(h(),g("div",Dr,[(h(!0),g(O,null,Q(x($).facts,y=>(h(),g("div",{key:y.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1 text-[11px]"},[r("span",Br,S(y.content),1),r("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:C=>x($).removeFact(y.id)},[...u[57]||(u[57]=[r("svg",{class:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,jr)]))),128))])):A("",!0),r("div",Lr,[u[58]||(u[58]=r("div",null,[r("p",{class:"text-xs font-medium text-text-secondary"},"Message Memory (RAG)"),r("p",{class:"text-[10px] text-text-muted"},"Retrieve relevant past messages via embeddings")],-1)),r("button",{class:D(["h-4 w-7 shrink-0 rounded-full transition-colors",x($).settings.ragMemory.enabled?"bg-accent":"bg-surface-overlay"]),onClick:u[22]||(u[22]=y=>x($).settings.ragMemory.enabled=!x($).settings.ragMemory.enabled)},[r("span",{class:D(["block h-3 w-3 rounded-full bg-white transition-transform",x($).settings.ragMemory.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x($).settings.ragMemory.enabled?(h(),g("div",Fr,[r("div",null,[u[60]||(u[60]=r("label",{class:"mb-1 block text-[10px] text-text-muted"},"Embedding Model",-1)),U(r("select",{"onUpdate:modelValue":u[23]||(u[23]=y=>x($).settings.ragMemory.embeddingModel=y),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"},[u[59]||(u[59]=r("option",{value:"",disabled:""},"Select embedding model...",-1)),(h(!0),g(O,null,Q(x(I).embeddingModelNames,y=>(h(),g("option",{key:y,value:y},S(y)+" "+S(x(I).capabilityIcons(y)),9,Or))),128))],512),[[Ke,x($).settings.ragMemory.embeddingModel]])]),x(I).embeddingModelNames.length===0?(h(),g("div",Vr,[u[61]||(u[61]=r("p",{class:"mb-2 text-[10px] text-accent"},"No embedding models found. Pull one:",-1)),r("div",Ur,[(h(),g(O,null,Q($e,y=>r("div",{key:y.name,class:"flex items-center gap-2"},[r("div",qr,[r("p",Hr,S(y.name),1),r("p",Gr,S(y.description)+" ("+S(y.size)+")",1)]),r("button",{disabled:ce.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:C=>Ce(y.name)},S(ce.value&&me.value===y.name?"Pulling...":"Pull"),9,Wr)])),64))]),X.value?(h(),g("p",Kr,S(X.value),1)):A("",!0)])):A("",!0),r("div",null,[r("div",Zr,[u[62]||(u[62]=r("label",{class:"text-[10px] text-text-muted"},"Retrieve top",-1)),r("span",Qr,S(x($).settings.ragMemory.topK)+" messages",1)]),U(r("input",{"onUpdate:modelValue":u[24]||(u[24]=y=>x($).settings.ragMemory.topK=y),type:"range",min:"1",max:"10",step:"1",class:"w-full accent-accent"},null,512),[[Z,x($).settings.ragMemory.topK,void 0,{number:!0}]])])])):A("",!0)])):A("",!0)])]))}}),Xr={class:"flex h-full flex-col"},Yr={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"},ea={class:"flex items-start gap-3"},ta={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},sa={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},na={class:"flex items-center gap-3"},oa={class:"relative"},ra={key:0,class:"text-text-muted"},aa={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"},la=["onMousedown"],ia={key:0,class:"flex items-center"},ca={class:"truncate"},ua={class:"flex items-center gap-2"},da={class:"flex flex-1 min-h-0"},pa={key:0,class:"w-64 shrink-0 border-r border-border-default bg-surface-raised flex flex-col"},ma={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},ha={class:"flex-1 overflow-y-auto p-2"},ga={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},fa={key:1,class:"space-y-0.5"},xa=["onClick"],va={key:0,class:"flex-1 min-w-0"},ba=["onBlur","onKeydown"],ya={class:"flex-1 min-w-0"},ka={class:"truncate text-[11px]"},wa={class:"truncate text-[9px] text-text-muted"},Sa={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},$a=["onClick"],Ca=["onClick"],Ta={class:"flex flex-1 flex-col min-w-0"},_a={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"},Ma={key:1,class:"w-72 shrink-0 border-l border-border-default bg-surface-raised"},Ra={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},Aa=te({__name:"ChatConversation",setup(s){const e=Pt(),t=Dt(),o=tt(),n=He(),l=Lt(),a=et(),c=st(),i=Vt(),d=jt(),{isStreaming:p,currentSessionId:m,startChatStream:b,cancel:k}=Ks(),f=M(""),z=M(!1);function $(){setTimeout(()=>{z.value=!1},150)}const I=M(!0),L=M(!1),V=M(!1),J=M(null),q=M("");function K(_){t.setActiveConversation(_)}function ce(_,v){J.value=_,q.value=v}function X(_){const v=q.value.trim();v&&t.renameConversation(_,v),J.value=null}function me(){J.value=null}function $e(_,v){_.key==="Enter"?X(v):_.key==="Escape"&&me()}function Ce(_){const w=Date.now()-_,N=Math.floor(w/6e4);if(N<1)return"Just now";if(N<60)return`${N}m ago`;const E=Math.floor(N/60);if(E<24)return`${E}h ago`;const F=Math.floor(E/24);return F<7?`${F}d ago`:new Date(_).toLocaleDateString()}const T=M({systemPrompt:"",options:{}}),u=M(null);let y=null;const C=j(()=>t.activeConversation),R=j(()=>C.value?.messages??[]),oe=j(()=>o.isVisionModel(f.value)),he=j(()=>{const _=ae.value??m.value;if(!_)return null;const v=n.sessionById(_);return v?.status==="error"&&v.error?v.error:null}),ae=j(()=>{const _=R.value;for(let v=_.length-1;v>=0;v--)if(_[v].sessionId)return _[v].sessionId;return null}),ye=M("Untitled"),Te=M(!1),Ie=M(""),pt=j(()=>C.value?.name??ye.value);function os(){Ie.value=pt.value,Te.value=!0}function mt(){const _=Ie.value.trim();if(!_){Te.value=!1;return}C.value?t.renameConversation(C.value.id,_):ye.value=_,Te.value=!1}function rs(){Te.value=!1}function as(_){_.key==="Enter"?mt():_.key==="Escape"&&rs()}It(async()=>{await o.fetchModels(),o.chatModelNames.length>0&&!f.value&&(f.value=o.chatModelNames[0]),await l.loadDocuments()}),ee(f,_=>{if(!_)return;const v=o.getModelDefaults(_);Object.keys(v).length>0&&(T.value={systemPrompt:T.value.systemPrompt,options:{...v}})}),ee(()=>t.activeConversationId,async _=>{if(!_)return;const v=t.conversations.get(_);if(v){v.model&&o.chatModelNames.includes(v.model)&&(f.value=v.model);try{const w=await $s.getSessionsByConversation(_);for(const N of w)n.sessionById(N.id)||(n.sessions.set(N.id,{id:N.id,mode:N.mode,model:N.model,status:N.status,createdAt:N.createdAt,prompt:N.prompt,messages:N.messages,options:N.options,outputText:N.outputText,metrics:N.metrics,error:N.error,doneReason:N.doneReason}),n.linkSessionToConversation(N.id,_)),await d.loadTokens(N.id)}catch(w){console.error("Failed to restore sessions for conversation:",w)}}});async function ht(_,v=[]){if(!f.value)return;let w=t.activeConversationId;w||(w=t.createConversation(f.value),ye.value!=="Untitled"&&t.renameConversation(w,ye.value),ye.value="Untitled");const N=t.conversations.get(w);N&&N.model!==f.value&&(N.model=f.value);const E=v.filter(H=>H.type==="document"&&H.content),F=v.filter(H=>H.type==="image"&&H.content);let ue=_;E.length>0&&(ue=E.map(Y=>`[Attached: ${Y.name}]
|
|
93
|
-
${Y.content}`).join(`
|
|
94
|
-
|
|
95
|
-
`)+`
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
`+_);const ke={id:pe(),conversationId:w,role:"user",content:ue,timestamp:Date.now(),isStreaming:!1,attachments:v.length>0?v:void 0};t.addMessage(w,ke);const fe=pe(),Pe={id:fe,conversationId:w,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};t.addMessage(w,Pe);const le=t.getMessagesAsOllamaFormat(w).slice(0,-1);if(F.length>0){const H=[...le].reverse().find(Y=>Y.role==="user");H&&(H.images=F.map(Y=>Y.content.replace(/^data:[^;]+;base64,/,"")))}if(T.value.systemPrompt.trim()&&le.unshift({role:"system",content:T.value.systemPrompt.trim()}),I.value&&l.enabledDocuments.length>0)try{const H=await l.getContextForQuery(_,f.value,5);H&&le.unshift({role:"system",content:H})}catch{}let gt=le;try{const H=i.getSummary(w)?.summary,Y=await Js({conversationId:w,messages:le,model:f.value,settings:i.settings,userFactsPrompt:i.getFactsAsSystemPrompt(),existingSummary:H});if(gt=Y.messages,Y.newSummary){const de=le.filter(ft=>ft.role!=="system");i.setSummary(w,Y.newSummary,de.length)}}catch{}try{const H={...C.value?.options,...T.value.options},Y=c.enabledDefinitions,de=await b(f.value,gt,H,Y.length>0?Y:void 0),xt=t.conversations.get(w)?.messages.find(ie=>ie.id===fe);xt&&(xt.sessionId=de),n.linkSessionToConversation(de,w);const ms=ee(()=>n.sessionById(de)?.outputText,ie=>{ie!==void 0&&t.updateAssistantContent(w,fe,ie)}),vt=w,hs=_,gs=ee(()=>n.sessionById(de)?.status,ie=>{if((ie==="completed"||ie==="error"||ie==="cancelled")&&(t.finalizeMessage(vt,fe),p.value=!1,ms(),gs(),d.persistTokens(de),ie==="completed"&&i.settings.ragMemory.enabled&&i.settings.ragMemory.embeddingModel)){const fs=n.sessionById(de)?.outputText??"";Xs(vt,[{role:"user",content:hs,timestamp:ke.timestamp},{role:"assistant",content:fs,timestamp:Date.now()}],i.settings.ragMemory.embeddingModel).catch(()=>{})}})}catch{t.finalizeMessage(w,fe)}}function ls(){k()}function is(){t.setActiveConversation(null),ye.value="Untitled"}function cs(_){e.push({name:"session",params:{id:_}})}function ge(_){u.value=_,y&&clearTimeout(y),y=setTimeout(()=>{u.value=null},5e3)}function us(){u.value=null,y&&clearTimeout(y)}const ds={systemPrompt:"",options:{}};async function ps(_,v){const w=Qs(_);if(!w){ge(`Unknown command: /${_}. Type /help for available commands.`);return}const N={clearConversation:()=>t.setActiveConversation(null),newChat:()=>t.setActiveConversation(null),sendAsUser:E=>ht(E),copyLastResponse:()=>{const E=R.value.filter(ue=>ue.role==="assistant"),F=E[E.length-1];F?.content?(navigator.clipboard.writeText(F.content),ge("Copied to clipboard.")):ge("No assistant response to copy.")},exportConversation:E=>{const F=C.value;if(!F||F.messages.length===0){ge("No conversation to export.");return}let ue,ke;E==="json"?(ue=JSON.stringify(F.messages,null,2),ke=`chat-${F.id}.json`):(ue=F.messages.map(le=>`[${le.role}] ${le.content}`).join(`
|
|
100
|
-
|
|
101
|
-
`),ke=`chat-${F.id}.txt`);const fe=new Blob([ue],{type:"text/plain"}),Pe=URL.createObjectURL(fe),De=document.createElement("a");De.href=Pe,De.download=ke,De.click(),URL.revokeObjectURL(Pe)},setSystemPrompt:E=>{T.value={...T.value,systemPrompt:E}},setOption:(E,F)=>{T.value={...T.value,options:{...T.value.options,[E]:F}}},resetSettings:()=>{T.value={...ds}},setJsonFormat:E=>{ge("JSON format toggled. This affects the next request.")},switchModel:E=>{f.value=E},availableModels:o.chatModelNames,currentModel:f.value,toggleRag:()=>{I.value=!I.value},ragEnabled:I.value,navigate:E=>e.push(E),openSettings:()=>{L.value=!0},openSessionDetails:()=>{const E=ae.value;E?e.push({name:"session",params:{id:E}}):ge("No active session.")},addFact:E=>i.addFact(E),removeFact:E=>i.removeFactByContent(E),getFacts:()=>i.facts,showNotification:ge,messages:R.value,chatSettings:T,currentSessionId:ae.value??m.value,getSessionTokenCount:()=>{const E=ae.value??m.value;if(!E)return null;const F=a.getMetrics(E);return F?{prompt:F.promptTokenCount,completion:F.completionTokenCount}:null},getAverageSpeed:()=>{const E=a.aggregate;return E.totalSessions>0?E.avgTps:null},getOllamaStatus:async()=>{try{return{connected:(await fetch("/api/tags")).ok,model:f.value}}catch{return{connected:!1,model:f.value}}}};await w.execute(v,N)}return(_,v)=>(h(),g("div",Xr,[G(zt,{"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:Et(()=>[u.value?(h(),g("div",Yr,[r("div",ea,[r("p",ta,S(u.value),1),r("button",{class:"shrink-0 text-text-muted hover:text-text-primary transition-colors text-xs",onClick:us}," ✕ ")])])):A("",!0)]),_:1}),r("div",sa,[r("div",na,[r("div",oa,[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:v[0]||(v[0]=w=>z.value=!z.value),onBlur:$},[f.value?(h(),g(O,{key:1},[r("span",null,S(f.value),1),G(bt,{"model-name":f.value},null,8,["model-name"])],64)):(h(),g("span",ra,"No models")),(h(),g("svg",{class:D(["h-3 w-3 text-text-muted transition-transform",z.value?"rotate-180":""]),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[...v[12]||(v[12]=[r("path",{d:"M6 9l6 6 6-6"},null,-1)])],2))],32),z.value?(h(),g("div",aa,[(h(!0),g(O,null,Q(x(o).chatModelNames,w=>(h(),g("button",{key:w,class:D(["flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",w===f.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:Le(N=>{f.value=w,z.value=!1},["prevent"])},[r("span",null,S(w),1),G(bt,{"model-name":w},null,8,["model-name"])],42,la))),128))])):A("",!0)]),Te.value?(h(),g("div",ia,[U(r("input",{"onUpdate:modelValue":v[1]||(v[1]=w=>Ie.value=w),class:"w-48 rounded border border-accent bg-surface px-2 py-0.5 text-xs text-text-primary outline-none",onBlur:mt,onKeydown:as,onVnodeMounted:v[2]||(v[2]=w=>{w.el.focus(),w.el.select()})},null,544),[[Z,Ie.value]])])):(h(),g("button",{key:1,class:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-text-muted hover:text-text-primary hover:bg-surface-overlay transition-colors truncate max-w-[200px]",title:"Click to rename",onClick:os},[r("span",ca,S(pt.value),1),v[13]||(v[13]=r("svg",{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})],-1))]))]),r("div",ua,[ae.value?(h(),g("button",{key:0,class:"rounded-lg px-3 py-1.5 text-xs text-accent hover:bg-surface-overlay transition-colors",onClick:v[3]||(v[3]=w=>cs(ae.value))}," View session details ")):A("",!0),r("button",{class:D(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",V.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:v[4]||(v[4]=w=>V.value=!V.value)},[...v[14]||(v[14]=[r("svg",{class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M12 8v4l3 3"}),r("circle",{cx:"12",cy:"12",r:"10"})],-1),r("span",null,"History",-1)])],2),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:is}," + New Chat "),r("button",{class:D(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",L.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:v[5]||(v[5]=w=>L.value=!L.value)},[...v[15]||(v[15]=[r("svg",{class:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),r("circle",{cx:"12",cy:"12",r:"3"})],-1),r("span",null,"Settings",-1)])],2)])]),r("div",da,[V.value?(h(),g("div",pa,[r("div",ma,[v[16]||(v[16]=r("span",{class:"text-xs font-medium text-text-secondary"},"Chat History",-1)),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:v[6]||(v[6]=w=>V.value=!1)}," ✕ ")]),r("div",ha,[x(t).recentConversations.length===0?(h(),g("p",ga," No conversations yet. ")):(h(),g("div",fa,[(h(!0),g(O,null,Q(x(t).recentConversations,w=>(h(),g("div",{key:w.id,class:D(["group flex items-center gap-1 rounded-lg px-2.5 py-2 text-xs transition-colors cursor-pointer",w.id===x(t).activeConversationId?"bg-surface-overlay text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:N=>K(w.id)},[J.value===w.id?(h(),g("div",va,[U(r("input",{"onUpdate:modelValue":v[7]||(v[7]=N=>q.value=N),class:"w-full rounded bg-surface px-1.5 py-0.5 text-xs text-text-primary outline-none border border-accent",onBlur:N=>X(w.id),onKeydown:N=>$e(N,w.id),onVnodeMounted:v[8]||(v[8]=N=>{N.el.focus(),N.el.select()})},null,40,ba),[[Z,q.value]])])):(h(),g(O,{key:1},[r("div",ya,[r("p",ka,S(w.name),1),r("p",wa,S(w.model)+" · "+S(Ce(w.updatedAt)),1)]),r("div",Sa,[r("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:"Rename",onClick:Le(N=>ce(w.id,w.name),["stop"])},[...v[17]||(v[17]=[r("svg",{class:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})],-1)])],8,$a),r("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:"Delete",onClick:Le(N=>x(t).deleteConversation(w.id),["stop"])},[...v[18]||(v[18]=[r("svg",{class:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,Ca)])],64))],10,xa))),128))]))])])):A("",!0),r("div",Ta,[he.value?(h(),g("div",_a,[v[19]||(v[19]=r("span",{class:"font-medium"},"Error:",-1)),Se(" "+S(he.value),1)])):A("",!0),G(vo,{messages:R.value},null,8,["messages"]),G(Zo,{"is-streaming":x(p),"selected-model":f.value,"is-vision-model":oe.value,onSend:ht,onCommand:ps,onCancel:ls},null,8,["is-streaming","selected-model","is-vision-model"])]),L.value?(h(),g("div",Ma,[r("div",Ra,[v[20]||(v[20]=r("span",{class:"text-xs font-medium text-text-secondary"},"Chat Settings",-1)),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:v[9]||(v[9]=w=>L.value=!1)}," ✕ ")]),G(Jr,{modelValue:T.value,"onUpdate:modelValue":v[10]||(v[10]=w=>T.value=w),"selected-model":f.value,"rag-enabled":I.value,"onUpdate:ragEnabled":v[11]||(v[11]=w=>I.value=w)},null,8,["modelValue","selected-model","rag-enabled"])])):A("",!0)])]))}}),Na={class:"rounded-lg border border-border-default bg-surface-raised"},za={class:"overflow-x-auto"},Ea={class:"w-full text-sm"},Ia=["onClick"],Pa={class:"px-4 py-2 font-medium text-text-primary"},Da={class:"px-4 py-2"},Ba={class:"px-4 py-2 text-text-secondary"},ja={class:"px-4 py-2 text-text-secondary"},La={class:"px-4 py-2 text-text-secondary"},Fa={class:"px-4 py-2 text-text-muted"},Oa={key:0},Va=te({__name:"SessionHistoryTable",setup(s){const e=He();return(t,o)=>(h(),g("div",Na,[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",za,[r("table",Ea,[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,[(h(!0),g(O,null,Q(x(e).recentSessions.slice(0,20),n=>(h(),g("tr",{key:n.id,class:"border-b border-border-default last:border-0 hover:bg-surface-overlay cursor-pointer transition-colors",onClick:l=>t.$router.push({name:"session",params:{id:n.id}})},[r("td",Pa,S(n.model),1),r("td",Da,[G(Ns,{status:n.status,detail:n.error},null,8,["status","detail"])]),r("td",Ba,S(n.metrics?n.metrics.totalTokenCount:"—"),1),r("td",ja,S(n.metrics?x(Fe)(n.metrics.tokensPerSecond):"—"),1),r("td",La,S(n.metrics?x(Bt)(n.metrics.totalDurationMs):"—"),1),r("td",Fa,S(x(Cs)(n.createdAt)),1)],8,Ia))),128)),x(e).recentSessions.length===0?(h(),g("tr",Oa,[...o[0]||(o[0]=[r("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):A("",!0)])])])]))}}),Ua={class:"flex h-full flex-col"},qa={class:"flex-1 min-h-0"},Ha={key:0,class:"border-t border-border-default"},Ga={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Wa={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Ka={key:1,class:"border-t border-border-default px-4 py-2"},Za={class:"flex gap-2 overflow-x-auto pb-1"},Qa=["onClick"],ul=te({__name:"DashboardPage",setup(s){const e=et(),t=Dt(),o=M(!1),n=j(()=>e.aggregate),l=j(()=>n.value.totalSessions>0),a=j(()=>t.recentConversations);return(c,i)=>(h(),g("div",Ua,[r("div",qa,[G(Aa)]),l.value?(h(),g("div",Ha,[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:i[0]||(i[0]=d=>o.value=!o.value)},[r("span",null,S(n.value.totalSessions)+" sessions · Avg "+S(x(Fe)(n.value.avgTps)),1),r("span",{class:D(["transition-transform",{"rotate-180":o.value}])},"▾",2)]),o.value?(h(),g("div",Ga,[r("div",Wa,[G(Be,{label:"Total Sessions",value:n.value.totalSessions},null,8,["value"]),G(Be,{label:"Avg TTFT",value:x(Bt)(n.value.avgTtftMs)},null,8,["value"]),G(Be,{label:"Avg Speed",value:x(Fe)(n.value.avgTps)},null,8,["value"]),G(Be,{label:"Total Tokens",value:x(we)(n.value.totalTokensGenerated),unit:"tok"},null,8,["value"])]),G(Va)])):A("",!0)])):A("",!0),a.value.length>1?(h(),g("div",Ka,[i[1]||(i[1]=r("p",{class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},"Recent Chats",-1)),r("div",Za,[(h(!0),g(O,null,Q(a.value.slice(0,5),d=>(h(),g("button",{key:d.id,class:D(["shrink-0 rounded-lg px-3 py-1.5 text-xs transition-colors",x(t).activeConversationId===d.id?"bg-accent/10 text-accent":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:p=>x(t).setActiveConversation(d.id)},S(d.name),11,Qa))),128))])])):A("",!0)]))}});export{ul as default};
|