@versot/vaguspi 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +42 -4
- package/dist/bin.js.map +2 -2
- package/gui/assets/index-DRbNBgQ5.js +19 -0
- package/gui/index.html +9 -2
- package/package.json +1 -1
- package/gui/assets/index-DL6d29Yn.js +0 -19
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-B-1r6vjG.js","assets/vendor-D5Ls3_dM.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var tr=Object.defineProperty;var nr=(n,r,t)=>r in n?tr(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t;var Be=(n,r,t)=>nr(n,typeof r!="symbol"?r+"":r,t);import{j as e,a as K,r as a,t as T,u as Ze,R as tn,d as nn,L as rr,D as or,h as sr,e as rn,J as ir,I as lr,b as ar,T as dr,A as cr,f as ur,g as fr,i as hr}from"./vendor-D5Ls3_dM.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();const pr="modulepreload",gr=function(n){return"/"+n},Nt={},on=function(r,t,o){let s=Promise.resolve();if(t&&t.length>0){let l=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),g=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(t.map(u=>{if(u=gr(u),u in Nt)return;Nt[u]=!0;const f=u.endsWith(".css"),m=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${m}`))return;const x=document.createElement("link");if(x.rel=f?"stylesheet":pr,f||(x.as="script"),x.crossOrigin="",x.href=u,g&&x.setAttribute("nonce",g),document.head.appendChild(x),f)return new Promise((h,j)=>{x.addEventListener("load",h),x.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return r().catch(i)})},he="background 0.15s, color 0.15s";function sn(n){const r=new Date(n).getTime();if(Number.isNaN(r))return"";const t=Math.max(0,Math.round((Date.now()-r)/6e4));if(t<1)return"now";if(t<60)return`${t}m`;const o=Math.round(t/60);return o<24?`${o}h`:`${Math.round(o/24)}d`}function ln(n){const r=n.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]??n}function kt(n,r){return e.jsx("div",{style:{display:"grid",gridTemplateRows:n?"1fr":"0fr",transition:"grid-template-rows 0.2s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:r})})}function jt({size:n=14,color:r}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{flexShrink:0,color:r},children:e.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function xr(n){const r=K(),[t,o]=a.useState(!1),s=a.useMemo(()=>n.archivedProjects.filter(i=>i.sessions.length>0).toSorted((i,l)=>l.sessions[0].modified.localeCompare(i.sessions[0].modified)),[n.archivedProjects]);return n.archivedProjects.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>o(i=>!i),onContextMenu:i=>{n.onSectionContextMenu&&(i.preventDefault(),n.onSectionContextMenu(i))},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.88em",fontWeight:500,color:r.color.muted,marginTop:8,transition:he},onMouseEnter:i=>{i.currentTarget.style.background=r.color.sidebarHover},onMouseLeave:i=>{i.currentTarget.style.background="transparent"},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0},children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"}),e.jsx("path",{d:"M12 13v3"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:T("已归档")}),e.jsx("span",{style:{fontSize:"0.75em",color:r.color.muted,background:r.color.sidebarHover,borderRadius:8,padding:"1px 7px"},children:n.archivedProjects.length}),e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,transform:t?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(t,e.jsx("div",{style:{paddingLeft:6},children:s.map(({cwd:i,dirKey:l,sessions:c})=>{const g=!n.collapsed.has(`arch:${l}`);return e.jsxs("div",{style:{marginBottom:1},children:[e.jsxs("div",{onClick:()=>n.onToggleProject(`arch:${l}`),onContextMenu:u=>n.onProjectContextMenu(u,i,l),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.9em",fontWeight:500,color:r.color.muted,opacity:.85,transition:he},onMouseEnter:u=>{u.currentTarget.style.background=r.color.sidebarHover,u.currentTarget.style.opacity="1"},onMouseLeave:u=>{u.currentTarget.style.background="transparent",u.currentTarget.style.opacity="0.85"},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0},children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ln(i)}),e.jsx("span",{style:{fontSize:"0.75em",color:r.color.muted,flexShrink:0},children:c.length}),e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,transform:g?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(g,e.jsx("div",{style:{paddingLeft:30},children:c.map(u=>e.jsxs("div",{onClick:()=>n.onOpenSession(u.path),onContextMenu:f=>n.onSessionContextMenu(f,u,!0),onMouseEnter:f=>f.currentTarget.style.background=r.color.sidebarHover,onMouseLeave:f=>f.currentTarget.style.background="transparent",style:{display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.89em",color:r.color.muted,overflow:"hidden",whiteSpace:"nowrap",transition:he},children:[e.jsx(jt,{}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1},children:(u.name??u.firstMessage.slice(0,40))||"(空会话)"}),n.busyPaths.has(u.path)&&e.jsx("span",{title:T("工作中"),style:{width:7,height:7,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",animation:"vagus-pulse 1.2s ease-in-out infinite",flexShrink:0,display:"inline-block"}}),e.jsx("span",{style:{fontSize:"0.79em",color:r.color.muted,flexShrink:0},children:sn(u.modified)})]},u.id))}))]},l)})}))]})}const Re="#6366f1",Je="#8b5cf6",Vt="0 0 0 2px rgba(99,102,241,0.4)";function gt({text:n,style:r}){const t=a.useRef(null),[o,s]=a.useState(!1),i=a.useRef(0),l=32;return e.jsx("span",{ref:t,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,...r},onMouseEnter:()=>{requestAnimationFrame(()=>{const g=t.current,u=g==null?void 0:g.firstChild;if(!g||!u)return;const f=u.offsetWidth;i.current=f,f-g.clientWidth>2&&s(!0)})},onMouseLeave:()=>s(!1),children:o?e.jsxs("span",{style:{display:"inline-block",whiteSpace:"nowrap",animation:`vagus-marquee ${((i.current+l)/30).toFixed(2)}s linear infinite`},children:[e.jsx("span",{style:{paddingRight:l},children:n}),e.jsx("span",{style:{paddingRight:l},children:n})]}):e.jsx("span",{style:{display:"inline-block",whiteSpace:"nowrap"},children:n})})}function Ut({sessions:n,activePath:r,onNewSession:t,onOpenSession:o,onOpenSettings:s,onOpenPlugins:i,onRenameSession:l,onDeleteSession:c,onArchiveSession:g,onClearAllArchived:u,onCollapsedChange:f,onRestoreSession:m,onDeleteArchivedSession:x,onTogglePin:h,pinnedSessions:j=new Set,archivedProjects:S=[],onArchiveProject:v,onUnarchiveProject:p,onDeleteProject:k,busyPaths:R=new Set,pendingDialogPaths:B=new Set}){const I=K(),{theme:_}=Ze(),Y="vagus.sidebar.collapsedProjects",[q,M]=a.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem(Y)??"[]"))}catch{return new Set}}),[z,H]=a.useState(null),[oe,G]=a.useState(),[te,ne]=a.useState(""),N=a.useMemo(()=>{const y=new Map;for(const O of n){const A=y.get(O.cwd)??[];A.push(O),y.set(O.cwd,A)}return[...y.entries()].toSorted((O,A)=>A[1][0].modified.localeCompare(O[1][0].modified)).map(([O,A])=>[O,A.toSorted((V,J)=>Number(j.has(J.path))-Number(j.has(V.path))||J.modified.localeCompare(V.modified))])},[n,j]),b=y=>{M(O=>{const A=new Set(O);A.has(y)?A.delete(y):A.add(y);try{localStorage.setItem(Y,JSON.stringify([...A]))}catch{}return A})},W=(y,O,A=!1)=>{y.preventDefault(),H({x:y.clientX,y:y.clientY,kind:"session",session:O,archived:A})},P=(y,O)=>{y.preventDefault(),H({x:y.clientX,y:y.clientY,kind:"project",cwd:O})},F=()=>H(null);a.useEffect(()=>{if(!z)return;const y=A=>{A.target.closest("[data-context-menu]")||F()},O=A=>{A.key==="Escape"&&F()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",O)}},[z]);const se=y=>{G(y.path),ne(y.name??y.firstMessage.slice(0,40)),H(null)},X={display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderRadius:7,cursor:"pointer",userSelect:"none",fontSize:"0.89em",color:I.color.fg,transition:"background 0.15s"},Se=y=>{const O=te.trim();G(void 0),O&&l&&l(y,O)},Ie=n.find(y=>y.path===r),Fe=Ie==null?void 0:Ie.cwd,Ae=280,fe=48,Ce="vagus.sidebar.collapsed",[We,Le]=a.useState(()=>{try{return localStorage.getItem(Ce)==="1"}catch{return!1}}),Me=y=>{Le(y),f==null||f(y);try{localStorage.setItem(Ce,y?"1":"0")}catch{}},Te=_==="light"?"rgba(99,102,241,0.10)":"rgba(99,102,241,0.16)",ae={display:"flex",alignItems:"center",gap:8,height:40,padding:"0 14px",borderRadius:12,background:`linear-gradient(135deg, ${Re}, ${Je})`,border:"none",color:"#fff",fontSize:"0.96em",fontWeight:600,cursor:"pointer",userSelect:"none",transition:"filter 0.15s, box-shadow 0.15s, transform 0.15s",boxShadow:"0 2px 10px rgba(99,102,241,0.35)",width:"100%",outline:"none"};return e.jsx("aside",{style:{width:We?fe:Ae,flexShrink:0,borderRight:`1px solid ${I.color.border}`,background:I.color.sidebarBg,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",position:"relative",transition:"width 0.18s ease"},children:We?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:"none",height:54,display:"flex",alignItems:"center",justifyContent:"center",borderBottom:`1px solid ${I.color.border}`},children:e.jsx("button",{title:T("展开侧栏"),onClick:()=>Me(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:8,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:he,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})})}),e.jsxs("div",{style:{flex:"none",padding:"14px 8px 4px",display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[e.jsx("button",{title:T("新对话"),onClick:t,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",cursor:"pointer",outline:"none",background:`linear-gradient(135deg, ${Re}, ${Je})`,color:"#fff",boxShadow:"0 2px 10px rgba(99,102,241,0.35)"},children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})})}),e.jsx("button",{title:T("插件"),onClick:i,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:he,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-3 3a5 5 0 0 0-.5 7.5z"}),e.jsx("path",{d:"M14 10a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l3-3a5 5 0 0 0 .5-7.5z"})]})})]}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{style:{flex:"none",borderTop:`1px solid ${I.color.border}`,padding:8,display:"flex",justifyContent:"center"},children:e.jsx("button",{title:T("设置"),onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:9,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:he,outline:"none"},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{flex:"none",height:54,display:"flex",alignItems:"center",gap:8,padding:"0 16px",borderBottom:`1px solid ${I.color.border}`},children:[e.jsx("span",{style:{width:26,height:26,borderRadius:7,background:`linear-gradient(135deg,${Re},${Je})`,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:"0.93em",fontWeight:700,flexShrink:0,boxShadow:"0 2px 6px rgba(99,102,241,0.4)"},children:"◈"}),e.jsx("span",{style:{fontSize:"1.05em",fontWeight:700,color:I.color.fg},children:"vagusPI"}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{title:T("收起侧栏"),onClick:()=>Me(!0),style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:8,border:"none",background:"transparent",color:I.color.muted,cursor:"pointer",transition:he,outline:"none",flexShrink:0},onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})})]}),e.jsxs("div",{style:{flex:"none",padding:"14px 16px 4px",display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("button",{style:ae,onClick:t,onMouseEnter:y=>{y.currentTarget.style.filter="brightness(1.08)",y.currentTarget.style.boxShadow="0 4px 16px rgba(99,102,241,0.45)"},onMouseLeave:y=>{y.currentTarget.style.filter="none",y.currentTarget.style.boxShadow="0 2px 10px rgba(99,102,241,0.35)"},onMouseDown:y=>{y.currentTarget.style.transform="scale(0.98)"},onMouseUp:y=>{y.currentTarget.style.transform="scale(1)"},onFocus:y=>{y.currentTarget.style.boxShadow=`${Vt}, 0 2px 10px rgba(99,102,241,0.35)`},onBlur:y=>{y.currentTarget.style.boxShadow="0 2px 10px rgba(99,102,241,0.35)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:T("新对话")}),e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M12 8v8M8 12h8"})]})]}),e.jsxs("button",{onClick:i,onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",width:"100%",border:"none",background:"transparent",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.93em",color:I.color.muted,transition:he,outline:"none"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-3 3a5 5 0 0 0-.5 7.5z"}),e.jsx("path",{d:"M14 10a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l3-3a5 5 0 0 0 .5-7.5z"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:T("插件")})]})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"4px 8px 8px"},children:[e.jsx("div",{style:{fontSize:"0.79em",fontWeight:600,color:I.color.muted,textTransform:"uppercase",letterSpacing:"0.08em",padding:"12px 10px 6px"},children:T("项目")}),N.length===0&&e.jsx("div",{style:{fontSize:"0.85em",color:I.color.muted,padding:"8px 10px",lineHeight:1.5},children:T("暂无会话 — 点击“新对话”开始。")}),N.map(([y,O])=>{const A=!q.has(y),V=Fe===y;return e.jsxs("div",{style:{marginBottom:2},children:[e.jsxs("div",{onClick:()=>b(y),onContextMenu:J=>P(J,y),style:{position:"relative",display:"flex",alignItems:"center",gap:8,padding:"7px 8px",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.96em",fontWeight:500,color:I.color.fg,background:V?I.color.sidebarHover:"transparent",transition:he},onMouseEnter:J=>{V||(J.currentTarget.style.background=I.color.sidebarHover)},onMouseLeave:J=>{V||(J.currentTarget.style.background="transparent")},children:[V&&e.jsx("span",{style:{position:"absolute",left:0,top:8,bottom:8,width:3,borderRadius:3,background:`linear-gradient(180deg,${Re},${Je})`}}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{flexShrink:0,color:V?Re:I.color.muted},children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx(gt,{text:ln(y),style:{flex:1}}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,color:I.color.muted,transform:A?"rotate(0)":"rotate(-90deg)",transition:"transform 0.15s ease"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]}),kt(A,e.jsx("div",{style:{paddingLeft:30},children:O.map(J=>{const pe=J.path===r,be=oe===J.path;return e.jsxs("div",{className:"vagus-session-row",onClick:()=>o(J.path),onContextMenu:Q=>W(Q,J),onMouseEnter:Q=>{pe||(Q.currentTarget.style.background=I.color.sidebarHover)},onMouseLeave:Q=>{pe||(Q.currentTarget.style.background="transparent")},style:{position:"relative",display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.91em",color:pe?I.color.fg:I.color.muted,fontWeight:pe?500:400,background:pe?Te:"transparent",overflow:"hidden",whiteSpace:"nowrap",transition:he},children:[pe&&e.jsx("span",{style:{position:"absolute",left:0,top:8,bottom:8,width:3,borderRadius:3,background:`linear-gradient(180deg,${Re},${Je})`}}),e.jsx(jt,{color:pe?Re:void 0}),be?e.jsx("input",{autoFocus:!0,value:te,onChange:Q=>ne(Q.target.value),onBlur:Q=>{Q.currentTarget.style.boxShadow="none",Se(J.path)},onKeyDown:Q=>{Q.key==="Enter"&&Se(J.path),Q.key==="Escape"&&G(void 0)},onClick:Q=>Q.stopPropagation(),onFocus:Q=>{Q.currentTarget.style.boxShadow=Vt},style:{flex:1,minWidth:0,fontSize:"0.89em",padding:"2px 6px",background:I.color.bg,border:`1px solid ${I.color.border}`,borderRadius:6,color:I.color.fg,outline:"none"}}):e.jsx(gt,{text:(J.name??J.firstMessage.slice(0,40))||"(空会话)"}),e.jsx("span",{style:{width:14,display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:j.has(J.path)&&e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",style:{color:Re},children:e.jsx("path",{d:"M12 17l-5.88 3.09.87-6.02L2.6 9.43l6.44-.94L12 2.5l2.96 5.99 6.44.94-4.39 4.64.87 6.02z"})})}),e.jsx("span",{style:{width:12,display:"inline-flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:(R.has(J.path)||B.has(J.path))&&e.jsx("span",{title:T("工作中"),style:{width:7,height:7,borderRadius:"50%",background:I.color.primary,animation:"vagus-pulse 1.2s ease-in-out infinite",display:"inline-block"}})}),e.jsx("span",{className:"vagus-row-time",style:{fontSize:"0.79em",color:I.color.muted,flexShrink:0},children:sn(J.modified)})]},J.id)})}))]},y)}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:"0.79em",fontWeight:600,color:I.color.muted,textTransform:"uppercase",letterSpacing:"0.08em",padding:"16px 10px 6px"},children:T("最近")}),e.jsx("div",{style:{paddingLeft:0},children:n.slice(0,5).map(y=>e.jsxs("div",{onClick:()=>o(y.path),onContextMenu:O=>W(O,y),onMouseEnter:O=>O.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:O=>O.currentTarget.style.background="transparent",style:{display:"flex",alignItems:"center",gap:7,padding:"6px 10px",borderRadius:10,cursor:"pointer",userSelect:"none",fontSize:"0.91em",color:I.color.muted,overflow:"hidden",whiteSpace:"nowrap",transition:he},children:[e.jsx(jt,{}),e.jsx(gt,{text:y.name??y.firstMessage.slice(0,40)})]},y.id))})]}),e.jsx(xr,{archivedProjects:S,busyPaths:R,collapsed:q,onToggleProject:b,onOpenSession:o,onSessionContextMenu:(y,O,A)=>W(y,O,A),onProjectContextMenu:(y,O,A)=>{y.preventDefault(),H({x:y.clientX,y:y.clientY,kind:"archived",cwd:O,dirKey:A})},onSectionContextMenu:y=>H({x:y.clientX,y:y.clientY,kind:"archivedAll"})})]}),e.jsx("div",{style:{flex:"none",borderTop:`1px solid ${I.color.border}`,padding:8,background:I.color.sidebarBg},children:e.jsxs("button",{onClick:s,onMouseEnter:y=>{y.currentTarget.style.background=I.color.sidebarHover,y.currentTarget.style.color=I.color.fg},onMouseLeave:y=>{y.currentTarget.style.background="transparent",y.currentTarget.style.color=I.color.muted},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",width:"100%",border:"none",background:"transparent",borderRadius:8,cursor:"pointer",userSelect:"none",fontSize:"0.93em",color:I.color.muted,transition:he},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:T("设置")})]})}),z&&e.jsxs("div",{"data-context-menu":!0,style:{position:"fixed",left:z.x,top:z.y,zIndex:1e3,minWidth:140,background:I.color.surface,border:`1px solid ${I.color.border}`,borderRadius:10,boxShadow:"0 12px 40px rgba(0,0,0,0.2)",padding:4},children:[z.kind==="session"&&!z.archived&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:()=>se(z.session),style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"})}),T("重命名")]}),h&&e.jsxs("div",{onClick:()=>{H(null),h(z.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:j.has(z.session.path)?"#6366f1":"none",stroke:j.has(z.session.path)?"#6366f1":"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 17l-5.88 3.09.87-6.02L2.6 9.43l6.44-.94L12 2.5l2.96 5.99 6.44.94-4.39 4.64.87 6.02z"})}),T("置顶")]}),g&&e.jsxs("div",{onClick:()=>{H(null),g(z.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),T("归档")]})]}),z.kind==="session"&&z.archived&&e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{onClick:()=>{H(null),m(z.session.path)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),T("恢复")]}),x&&e.jsxs("div",{onClick:()=>{H(null),x(z.session.path)},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),T("删除")]})]}),z.kind==="project"&&v&&e.jsxs("div",{onClick:()=>{H(null),v(z.cwd)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"})]}),T("归档项目")]}),z.kind==="archivedAll"&&e.jsxs("div",{onClick:()=>{H(null),u==null||u()},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),e.jsx("path",{d:"M10 11v6M14 11v6"})]}),T("清空全部归档")]}),z.kind==="archived"&&e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{onClick:()=>{H(null),p(z.dirKey)},style:X,onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M21 8l-2-4H5L3 8v2h18V8z"}),e.jsx("path",{d:"M3 10v8a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8"}),e.jsx("path",{d:"M12 13v3"})]}),T("恢复项目")]}),k&&e.jsxs("div",{onClick:()=>{H(null),k(z.dirKey)},style:{...X,color:"#E5484D"},onMouseEnter:y=>y.currentTarget.style.background=I.color.sidebarHover,onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),T("彻底删除")]})]})]})]})})}function wt(n,r){switch(n){case"extension":return r.color.success;case"skill":return r.color.warning;case"template":return r.color.accent;default:return r.color.primary}}const mr={builtin:"pi 原生指令",extension:"工具指令",skill:"Skills",template:"模板"};function yr({commands:n,onPick:r}){const t=K(),[o,s]=a.useState(""),i=o.toLowerCase().replace(/^\//,""),l=n.filter(m=>m.name.toLowerCase().includes(i)||m.description.toLowerCase().includes(i)),c=["builtin","extension","skill","template"],g={position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},u={width:480,maxHeight:"70vh",background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},f={display:"flex",alignItems:"center",gap:10,height:36,padding:"0 10px",borderRadius:8,cursor:"pointer",fontSize:"0.89em",color:t.color.fg};return e.jsx("div",{style:g,onMouseDown:m=>{m.target===m.currentTarget&&r(null)},children:e.jsxs("div",{style:u,onMouseDown:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"14px 16px 10px",borderBottom:`1px solid ${t.color.border}`,flexShrink:0},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:t.color.muted},children:[e.jsx("path",{d:"M4 17l6-6-6-6"}),e.jsx("path",{d:"M12 19h8"})]}),e.jsx("input",{autoFocus:!0,value:o,onChange:m=>s(m.target.value),onKeyDown:m=>{m.key==="Escape"&&r(null)},placeholder:T("输入 / 命令…"),style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"0.96em",color:t.color.fg,fontFamily:"inherit"}}),e.jsxs("span",{style:{fontSize:"0.72em",color:t.color.muted,flexShrink:0},children:[l.length," 项"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,minHeight:160},children:l.length===0?e.jsx("div",{style:{padding:"16px 10px",color:t.color.muted,fontSize:"0.86em"},children:T("(没有匹配的命令)")}):c.flatMap(m=>{const x=l.filter(h=>h.type===m);return x.length===0?[]:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.4,textTransform:"uppercase",color:t.color.muted},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:wt(m,t),flexShrink:0}}),mr[m]]},m),...x.map(h=>e.jsxs("div",{onClick:()=>r(`/${h.name}`),style:f,onMouseEnter:j=>{j.currentTarget.style.background=t.color.surface},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:[e.jsxs("span",{style:{color:wt(m,t),fontWeight:600,flexShrink:0,fontSize:"0.86em"},children:["/",h.name]}),e.jsx("span",{style:{color:t.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.description})]},`${m}:${h.name}`))]})})]})})}function Kt(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(Math.round(n))}function br({value:n,onChange:r,onSubmit:t,usage:o,providers:s,onSwitchModel:i,onSetThinking:l,thinkingLevel:c="off",permissionMode:g,onTogglePermission:u,attachments:f=[],fileAttachments:m=[],onAttach:x,onRemoveAttachment:h,onCommand:j,commands:S=[],onPickCommand:v,onRefreshCommands:p,focusSignal:k,busy:R=!1,hasPendingDialog:B=!1,onRestoreDialog:I,onStop:_,selectedModel:Y,queuedMessages:q=[]}){var Pe,et,Ne;const M=K(),[z,H]=a.useState(!1),[oe,G]=a.useState(!1),[te,ne]=a.useState(0),[N,b]=a.useState(!1);a.useEffect(()=>{if(q.length===0){b(!1);return}const C=window.setTimeout(()=>b(!0),300);return()=>window.clearTimeout(C)},[q.length]),a.useEffect(()=>{const C=X.current;C&&(C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,200)}px`)},[n]);const[W,P]=a.useState(!1),[F,se]=a.useState(!1),X=a.useRef(null),Se=a.useRef(null),Ie=a.useRef(null),Fe=a.useRef(null),Ae=a.useRef(null);a.useEffect(()=>{var C;k&&k>0&&((C=X.current)==null||C.focus())},[k]),a.useEffect(()=>{if(!z)return;const C=Z=>{var ce,$e;const re=Z.target;(ce=Fe.current)!=null&&ce.contains(re)||($e=Ie.current)!=null&&$e.contains(re)||H(!1)},D=Z=>{Z.key==="Escape"&&H(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",D)}},[z]),a.useEffect(()=>{if(!W)return;const C=Z=>{var ce;const re=Z.target;(ce=Ae.current)!=null&&ce.contains(re)||P(!1)},D=Z=>{Z.key==="Escape"&&P(!1)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",D)}},[W]);const fe=a.useMemo(()=>{for(const C of s){const D=C.models.find(Z=>(o==null?void 0:o.activeProvider)===C.id&&Z.id===(o==null?void 0:o.model));if(D)return{provider:C,model:D}}},[s,o==null?void 0:o.activeProvider,o==null?void 0:o.model]),Ce=(fe==null?void 0:fe.model.contextWindow)??1e6,We=((Pe=fe==null?void 0:fe.model.input)==null?void 0:Pe.includes("image"))??!0,Le=((et=o==null?void 0:o.contextUsage)==null?void 0:et.tokens)??null,Me=Le!==null,Te=Le??0,ae=Math.min(1,Te/Ce),y=o==null?void 0:o.latestCacheHitRate,O=7,A=2*Math.PI*O,V=A*(1-ae),J={width:34,height:34,borderRadius:10,border:"none",background:"transparent",color:M.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},pe={display:"flex",alignItems:"center",gap:5,fontSize:"0.89em",color:M.color.muted,padding:"5px 10px",borderRadius:8,cursor:"pointer",background:"transparent",border:"none",fontFamily:"inherit"},be={position:"absolute",bottom:42,left:0,zIndex:50,minWidth:190,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,boxShadow:"0 12px 40px rgba(0,0,0,0.14)",padding:4},Q=()=>{t()},me=oe&&n.startsWith("/"),He=me?n.slice(1).split(/\s+/)[0]??"":"",de=me?S.filter(C=>C.name.toLowerCase().includes(He.toLowerCase())):[];a.useEffect(()=>{te>=de.length&&ne(Math.max(0,de.length-1))},[de.length]);const ze=C=>{const D=n.slice(He.length+1),Z=`/${C} ${D.replace(/^\s+/,"")}`;r(Z),G(!1),v==null||v(C)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",position:"relative"},onMouseDown:C=>{C.target.closest("button, input, textarea, select, [contenteditable], [role='button']")||C.preventDefault()},children:[N&&q.length>0&&e.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.78em",fontWeight:600,letterSpacing:.3,color:M.color.muted},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#8b5cf6",display:"inline-block",animation:"vagus-pulse 1.2s ease-in-out infinite",flexShrink:0}}),"排队中 · ",q.length," 条"]}),q.map((C,D)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,height:30,padding:"0 12px 0 8px",borderRadius:9,background:"rgba(99,102,241,0.07)",border:"1px solid rgba(99,102,241,0.18)",fontSize:"0.86em",color:M.color.fg},children:[e.jsx("span",{style:{fontSize:"0.7em",fontWeight:700,color:"#6366f1",background:"rgba(99,102,241,0.12)",width:18,height:18,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:D+1}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.text})]},C.id))]}),(f.length>0||m.length>0)&&e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:8,alignItems:"center"},children:[f.map((C,D)=>e.jsxs("div",{style:{position:"relative"},children:[e.jsx("img",{src:C.dataUrl,alt:C.name??"",style:{width:48,height:48,objectFit:"cover",borderRadius:8,border:`1px solid ${M.color.border}`}}),e.jsx("button",{onClick:()=>h==null?void 0:h(D),title:T("移除"),style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",border:"none",background:"#E5484D",color:"#fff",fontSize:"0.71em",lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"✕"})]},D)),m.map((C,D)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,height:26,padding:"0 8px",borderRadius:8,background:M.color.surface,border:`1px solid ${M.color.border}`,fontSize:"0.82em",color:M.color.muted},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"}),e.jsx("path",{d:"M14 2v6h6"})]}),C.name,e.jsx("button",{onClick:()=>h==null?void 0:h(D+f.length),style:{width:14,height:14,borderRadius:"50%",border:"none",background:"transparent",color:M.color.muted,cursor:"pointer",fontSize:"0.79em",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"✕"})]},C.name))]}),me&&de.length>0&&e.jsx("div",{style:{position:"absolute",bottom:"calc(100% + 6px)",left:4,right:4,zIndex:60,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",maxHeight:300,overflowY:"auto",padding:4},children:de.map((C,D)=>e.jsxs("button",{onClick:()=>ze(C.name),onMouseEnter:()=>ne(D),style:{display:"flex",alignItems:"center",gap:10,width:"100%",height:34,padding:"0 10px",border:"none",borderRadius:8,cursor:"pointer",textAlign:"left",fontFamily:"inherit",fontSize:"0.88em",background:D===te?M.color.surface:"transparent",color:M.color.fg},children:[e.jsxs("span",{style:{color:wt(C.type,M),fontWeight:600,flexShrink:0,fontSize:"0.84em"},children:["/",C.name]}),e.jsx("span",{style:{color:M.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.description})]},`${C.type}:${C.name}`))}),e.jsx("textarea",{ref:X,value:n,onChange:C=>{r(C.target.value),oe&&!C.target.value.startsWith("/")&&G(!1)},onKeyDown:C=>{if(C.key==="Tab"){if(me&&de.length>0){C.preventDefault();const D=de[te];D&&ze(D.name)}return}if(C.key==="Enter"&&!C.shiftKey){if(C.nativeEvent.isComposing)return;if(me&&de.length>0){C.preventDefault();const D=de[te];D&&ze(D.name);return}C.preventDefault(),Q()}if(C.key==="Escape"){if(me){G(!1),C.preventDefault();return}r("")}me&&(C.key==="ArrowDown"&&(C.preventDefault(),ne(D=>Math.min(D+1,de.length-1))),C.key==="ArrowUp"&&(C.preventDefault(),ne(D=>Math.max(D-1,0)))),C.key==="/"&&!C.shiftKey&&!C.ctrlKey&&!C.metaKey&&!C.altKey&&C.currentTarget.selectionStart===0&&(G(!0),p==null||p())},onPaste:C=>{var re;const D=(re=C.clipboardData)==null?void 0:re.items;if(!D)return;const Z=[];for(const ce of Array.from(D))if(ce.kind==="file"&&ce.type.startsWith("image/")){const $e=ce.getAsFile();$e&&Z.push($e)}Z.length>0&&(C.preventDefault(),x==null||x(Z))},rows:1,style:{width:"100%",minHeight:34,maxHeight:200,overflow:"auto",overflowX:"hidden",background:"transparent",border:"none",outline:"none",resize:"none",fontFamily:M.font.sans,fontSize:"1.04em",lineHeight:1.5,color:M.color.fg,padding:"2px 0 6px",scrollbarWidth:"none",msOverflowStyle:"none"}}),e.jsx("style",{children:"textarea::-webkit-scrollbar{display:none}"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:6},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{ref:Ie,title:T("添加上下文"),style:J,onClick:()=>{H(C=>!C),P(!1)},children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),z&&e.jsx("div",{ref:Fe,style:be,onMouseDown:C=>C.stopPropagation(),children:[{icon:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),label:"添加附件",title:We?void 0:"当前模型不支持图片,仅可添加文本文件",action:()=>{var C;return(C=Se.current)==null?void 0:C.click()}},{icon:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M4 17l6-6-6-6"}),e.jsx("path",{d:"M12 19h8"})]}),label:"使用 / 选择命令或能力",action:()=>j==null?void 0:j()}].map(C=>e.jsxs("button",{title:C.title,onClick:()=>{H(!1),C.action()},style:{display:"flex",alignItems:"center",gap:10,width:"100%",height:34,padding:"0 10px",border:"none",background:"transparent",borderRadius:8,fontSize:"0.89em",color:M.color.fg,cursor:"pointer",textAlign:"left"},onMouseEnter:D=>{D.currentTarget.style.background=M.color.surface},onMouseLeave:D=>{D.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{color:M.color.muted,display:"flex"},children:C.icon}),C.label]},C.label))}),e.jsx("input",{ref:Se,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:C=>{const D=Array.from(C.target.files??[]);D.length>0&&(x==null||x(D)),C.target.value=""}})]}),e.jsx("div",{style:{flex:1}}),o&&e.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>se(!0),onMouseLeave:()=>se(!1),children:[e.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:42}}),e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"4px 4px",borderRadius:9,cursor:"default"},children:e.jsxs("svg",{width:18,height:18,viewBox:"0 0 18 18",style:{flexShrink:0},children:[e.jsx("circle",{cx:"9",cy:"9",r:O,fill:"none",stroke:M.color.border,strokeWidth:"2.5"}),e.jsx("circle",{cx:"9",cy:"9",r:O,fill:"none",stroke:ae>.9?"#E5484D":ae>.7?"#B7791F":M.color.primary,strokeWidth:"2.5",strokeLinecap:"round",strokeDasharray:`${A} ${A}`,strokeDashoffset:V,transform:"rotate(-90 9 9)"})]})}),F&&e.jsxs("div",{style:{position:"absolute",bottom:34,right:0,zIndex:60,width:280,background:M.color.bg,border:`1px solid ${M.color.border}`,borderRadius:12,padding:"12px 14px",boxShadow:"0 10px 32px rgba(0,0,0,0.14)",fontSize:"0.82em",color:M.color.fg,display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:M.color.muted},children:T("上下文容量")}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:o?Me?`${Kt(Te)} / ${Kt(Ce)} (${(ae*100).toFixed(2)}%)`:"未知 · 待下次响应":"—"})]}),e.jsx("div",{style:{height:6,borderRadius:3,background:M.color.border,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:Me?`${ae*100}%`:"0%",background:ae>.9?"#E5484D":ae>.7?"#B7791F":M.color.primary,transition:"width 0.3s"}})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:M.color.muted},children:T("缓存命中率")}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:y!==void 0?`${y.toFixed(1)}%`:"—"})]})]})]}),e.jsxs("div",{ref:Ae,style:{position:"relative"},children:[e.jsxs("button",{style:pe,onClick:()=>{P(C=>!C),H(!1)},title:T("切换模型"),children:[((Ne=o==null?void 0:o.model)==null?void 0:Ne.split("/").pop())??Y??"选择模型",e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),W&&e.jsxs("div",{style:{...be,left:"auto",right:0,width:250,maxHeight:320,overflowY:"auto"},onMouseDown:C=>C.stopPropagation(),children:[s.length===0&&e.jsx("div",{style:{padding:"10px 12px",fontSize:"0.86em",color:M.color.muted},children:T("暂无已配置模型")}),s.map(C=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.4,textTransform:"uppercase",color:M.color.muted},children:C.id}),C.models.map(D=>{const Z=(o==null?void 0:o.activeProvider)===C.id&&(o==null?void 0:o.model)===D.id;return e.jsxs("button",{onClick:()=>{i(C.id,D.id),P(!1)},style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:32,padding:"0 10px",border:"none",background:Z?M.color.surface:"transparent",borderRadius:8,fontSize:"0.89em",color:M.color.fg,cursor:"pointer",textAlign:"left"},onMouseEnter:re=>{Z||(re.currentTarget.style.background=M.color.surface)},onMouseLeave:re=>{Z||(re.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{fontSize:"0.79em",color:M.color.muted,flexShrink:0},children:"◆"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.name??D.id}),Z&&e.jsx("span",{style:{fontSize:"0.79em",color:M.color.primary},children:"✓"})]},D.id)})]},C.id))]})]}),e.jsxs("button",{onClick:()=>l(c==="off"?"high":"off"),title:c==="off"?"开启思考模式":"关闭思考模式",style:{display:"flex",alignItems:"center",gap:6,height:30,padding:"0 10px 0 8px",borderRadius:9,border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:"0.88em",background:c==="off"?"transparent":"rgba(99,102,241,0.10)",color:c==="off"?M.color.muted:"#6366f1",fontWeight:c==="off"?400:600,transition:"all 0.15s"},children:[e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M12 4.5a2.5 2.5 0 0 0-4.96-.46 2.5 2.5 0 0 0-1.98 3 2.5 2.5 0 0 0-1.32 4.24 3 3 0 0 0 .34 5.58 2.5 2.5 0 0 0 2.96 3.08A2.5 2.5 0 0 0 12 19.5a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 12 4.5z"})}),c==="off"?"思考关闭":"思考中"]}),e.jsx("button",{onClick:B?I:R?_:Q,title:B?"恢复待处理的弹窗":R?"停止":"发送",style:{width:38,height:38,borderRadius:"50%",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:B?M.color.warning:R?"#E8833D":"linear-gradient(135deg,#6366f1,#8b5cf6)",color:"#fff",boxShadow:B||R?"none":"0 4px 14px rgba(99,102,241,0.35)",transition:"transform 0.15s, box-shadow 0.15s"},children:B?e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}):R?e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})}function vr({projects:n,value:r,onChange:t,onNewProject:o}){const s=K(),[i,l]=a.useState(!1),[c,g]=a.useState(""),u=a.useRef(null),f=a.useRef(null);a.useEffect(()=>{if(!i)return;const k=B=>{var _,Y;const I=B.target;(_=f.current)!=null&&_.contains(I)||(Y=u.current)!=null&&Y.contains(I)||l(!1)},R=B=>{B.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",k),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",R)}},[i]);const m=n.find(k=>k.id===r),x=r?r.split(/[\\/]/).filter(Boolean).pop()??r:void 0,h=(m==null?void 0:m.name)??x??"选择项目",j=n.filter(k=>k.name.toLowerCase().includes(c.toLowerCase())),S=r!==void 0,v={display:"inline-flex",alignItems:"center",gap:6,background:S?"rgba(99,102,241,0.08)":s.color.surface,color:S?"#6366f1":s.color.muted,fontSize:"0.89em",fontWeight:S?600:500,padding:"6px 10px 6px 8px",borderRadius:9,cursor:"pointer",border:`1px solid ${S?"rgba(99,102,241,0.4)":s.color.border}`,marginBottom:-1,zIndex:2,position:"relative",transition:"background 0.15s, border-color 0.15s, color 0.15s"},p={position:"absolute",bottom:36,left:0,zIndex:20,width:325,height:275,background:s.color.bg,border:`1px solid ${s.color.border}`,borderRadius:16,boxShadow:"0 16px 48px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.05)",display:i?"flex":"none",flexDirection:"column",overflow:"hidden"};return e.jsxs("div",{style:{position:"relative",alignSelf:"flex-start",zIndex:10},children:[e.jsxs("div",{ref:u,style:v,onClick:k=>{k.stopPropagation(),l(R=>!R)},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx("span",{children:h}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:i?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),e.jsxs("div",{ref:f,style:p,onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 14px 8px",flexShrink:0},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:s.color.muted},children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{value:c,onChange:k=>g(k.target.value),placeholder:T("搜索项目"),style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"0.93em",color:s.color.fg}})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 6px",minHeight:0},children:j.map(k=>{const R=k.id===r;return e.jsxs("div",{onClick:()=>{t(k.id),l(!1)},style:{display:"flex",alignItems:"center",gap:10,height:36,padding:"0 10px",borderRadius:9,cursor:"pointer",fontSize:"0.93em",color:s.color.fg,background:R?s.color.surface:"transparent",opacity:k.available===!1?.45:1},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{flexShrink:0,color:s.color.muted},children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"})}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.name})]},k.id)})}),e.jsx("div",{style:{borderTop:`1px solid ${s.color.border}`,flexShrink:0,padding:4},children:e.jsxs("button",{onClick:()=>{o(),l(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"0 10px",height:36,width:"100%",border:"none",background:"transparent",borderRadius:8,fontSize:"0.93em",color:s.color.fg,cursor:"pointer"},children:[e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{color:s.color.muted},children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),T("新建项目")]})})]})]})}const an="vagus.picker.lastDir",dn="vagus.picker.recent";function cn(){try{const n=localStorage.getItem(dn);return(n?JSON.parse(n):[]).slice(0,8)}catch{return[]}}function kr(n){try{const r=cn().filter(t=>t!==n);r.unshift(n),localStorage.setItem(dn,JSON.stringify(r.slice(0,8))),localStorage.setItem(an,n)}catch{}}const jr={Desktop:"🖥️",Downloads:"📥",Documents:"📄",Pictures:"🖼️",Music:"🎵",Videos:"🎬",Home:"🏠",Root:"💿"};function wr({listDir:n,roots:r,onPick:t}){const o=K(),[s,i]=a.useState(()=>{const b=localStorage.getItem(an);return b&&b.length>0?b:"~"}),[l,c]=a.useState([]),[g,u]=a.useState(null),[f,m]=a.useState(!0),[x,h]=a.useState(null),[j,S]=a.useState(!1),[v,p]=a.useState(""),[k,R]=a.useState({places:[],drives:[]}),[B]=a.useState(cn);a.useEffect(()=>{r().then(b=>R(b)).catch(()=>{})},[]),a.useEffect(()=>{m(!0),h(null),u(null),n(s).then(b=>{i(b.path),c(b.entries)}).catch(b=>h(String(b))).finally(()=>m(!1))},[s]),a.useEffect(()=>{const b=W=>{W.key==="Enter"&&!j&&z(),W.key==="Escape"&&t(null)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[j,s]);const I=/^[A-Za-z]:[\\/]/.test(s),_=a.useMemo(()=>s.split(/[\\/]+/).filter(Boolean),[s]);function Y(b){if(I){const W=_[0];return b===0?`${W}\\`:`${W}\\${_.slice(1,b+1).join("\\")}`}return`/${_.slice(0,b+1).join("/")}`}function q(b){if(/^[A-Za-z]:[\\/]?$/.test(b))return b;const W=b.replace(/[\\/][^\\/]+$/,"");return W.length===0?"/":I&&W.length===2&&W.endsWith(":")?`${W}\\`:W}function M(b){S(!1),i(b)}function z(){const b=g??s;b&&(kr(b),t(b))}function H(){const b=v.trim();b?M(b):S(!1)}const oe=q(s),G=oe===s,te={position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.35)",display:"flex",alignItems:"center",justifyContent:"center"},ne={width:640,maxHeight:"72vh",background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column",overflow:"hidden"},N={width:30,height:30,borderRadius:8,border:"none",background:"transparent",color:o.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0};return e.jsx("div",{style:te,onMouseDown:b=>{b.target===b.currentTarget&&t(null)},children:e.jsxs("div",{style:ne,onMouseDown:b=>b.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px 8px",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.96em",fontWeight:600,color:o.color.fg},children:T("选择项目文件夹")}),e.jsx("button",{style:N,onClick:()=>t(null),title:T("关闭"),children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 16px 10px",flexShrink:0},children:[e.jsx("button",{style:{...N,opacity:G?.35:1,cursor:G?"default":"pointer"},disabled:G,onClick:()=>M(oe),title:T("上一级"),children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),j?e.jsx("form",{style:{flex:1,display:"flex"},onSubmit:b=>{b.preventDefault(),H()},children:e.jsx("input",{autoFocus:!0,value:v,onChange:b=>p(b.target.value),onBlur:()=>S(!1),placeholder:T("输入路径(如 ~/projects/app)"),style:{flex:1,height:30,border:`1px solid ${o.color.border}`,borderRadius:8,outline:"none",padding:"0 10px",fontSize:"0.89em",background:o.color.surface,color:o.color.fg,fontFamily:"inherit"}})}):e.jsxs("div",{style:{flex:1,height:30,display:"flex",alignItems:"center",gap:2,padding:"0 10px",borderRadius:8,background:o.color.surface,border:`1px solid ${o.color.border}`,fontSize:"0.89em",color:o.color.fg,cursor:"text",overflow:"hidden",whiteSpace:"nowrap"},onClick:()=>{p(s),S(!0)},title:s,children:[e.jsx("span",{style:{color:o.color.muted,flexShrink:0},children:I?_[0]:"/"}),_.slice(I?1:0).map((b,W)=>{const P=I?W+1:W,F=P===_.length-1;return e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[e.jsx("span",{style:{color:o.color.muted,fontSize:"0.71em"},children:"▸"}),e.jsx("span",{style:{color:F?o.color.fg:o.color.muted,fontWeight:F?500:400,cursor:F?"default":"pointer",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis"},onClick:se=>{F||(se.stopPropagation(),M(Y(P)))},children:b})]},`${b}-${W}`)})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,borderTop:`1px solid ${o.color.border}`},children:[e.jsxs("aside",{style:{width:150,flexShrink:0,borderRight:`1px solid ${o.color.border}`,padding:"6px 4px",overflowY:"auto",display:"flex",flexDirection:"column"},children:[e.jsx("div",{style:{padding:"6px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:T("位置")}),k.places.map(b=>e.jsxs("button",{onClick:()=>M(b.path),title:b.path,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:s===b.path?o.color.surface:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:jr[b.name]??"📁"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name})]},b.path)),k.drives.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:T("驱动器")}),k.drives.map(b=>e.jsxs("button",{onClick:()=>M(b.path),title:b.path,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:s===b.path?o.color.surface:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:"💽"}),e.jsx("span",{children:b.name})]},b.path))]}),B.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 10px 4px",fontSize:"0.75em",fontWeight:600,letterSpacing:.5,textTransform:"uppercase",color:o.color.muted},children:T("最近")}),B.map(b=>e.jsxs("button",{onClick:()=>M(b),title:b,style:{display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px",borderRadius:8,border:"none",background:"transparent",cursor:"pointer",fontSize:"0.89em",color:o.color.fg,textAlign:"left",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.93em",flexShrink:0},children:"⭐"}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.split(/[\\/]/).filter(Boolean).pop()??b})]},b))]})]}),e.jsx("div",{style:{flex:1,minWidth:0,overflowY:"auto",padding:10,display:"flex",flexDirection:"column"},children:f?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:o.color.muted,fontSize:"0.93em"},children:T("加载中…")}):x?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:"#E5484D",fontSize:"0.93em"},children:x}):l.length===0?e.jsx("div",{style:{padding:"32px 0",textAlign:"center",color:o.color.muted,fontSize:"0.93em"},children:T("(空文件夹)")}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))",gap:4},children:l.map(b=>e.jsxs("div",{onClick:()=>b.isDirectory&&u(b.path),onDoubleClick:()=>b.isDirectory&&M(b.path),title:b.path,style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:"10px 4px",borderRadius:10,cursor:b.isDirectory?"pointer":"default",background:g===b.path?o.color.surface:"transparent",userSelect:"none",overflow:"hidden"},children:[e.jsx("span",{style:{fontSize:26,lineHeight:1},children:b.isDirectory?"📁":"📄"}),e.jsx("span",{style:{fontSize:"0.82em",color:b.isDirectory?o.color.fg:o.color.muted,textAlign:"center",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name})]},b.path))})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"10px 16px",borderTop:`1px solid ${o.color.border}`,flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.82em",color:o.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:s,children:s}),e.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[e.jsx("button",{onClick:()=>t(null),style:{height:30,padding:"0 16px",borderRadius:8,border:`1px solid ${o.color.border}`,background:"transparent",color:o.color.muted,fontSize:"0.89em",cursor:"pointer"},children:T("取消")}),e.jsxs("button",{onClick:z,disabled:!s,style:{height:30,padding:"0 16px",borderRadius:8,border:"none",background:"#3A3A3A",color:"#fff",fontSize:"0.89em",cursor:"pointer",fontWeight:500},children:["选择",g?` “${g.split(/[\\/]/).filter(Boolean).pop()??g}”`:"此文件夹"]})]})]})]})})}function le(n,r){switch(r.type){case"clear":return[];case"toolCallStarted":return[...n,{id:r.id,kind:"tool",toolCallId:r.toolCallId,name:r.name,args:r.args,status:"running",collapsed:!0}];case"toolCallFinished":{const t=[...n];for(let o=t.length-1;o>=0;o--){const s=t[o];if(!(!s||s.kind!=="tool"||s.toolCallId!==r.toolCallId)){t[o]={...s,status:r.isError?"failed":"succeeded",result:r.result,...r.diff!==void 0?{diff:r.diff}:{},...r.patch!==void 0?{patch:r.patch}:{},collapsed:!0};break}}return t}case"thinkingDelta":{const t=n[n.length-1];if(t&&t.kind==="thinking"){const o=[...n];return o[o.length-1]={...t,text:`${t.text}${r.text}`,collapsed:!1},o}return[...n,{id:r.id,kind:"thinking",text:r.text}]}case"thinkingDone":return n;case"collapseAll":return n.map(t=>t.kind==="thinking"||t.kind==="tool"?{...t,collapsed:!0}:t);case"setCollapse":{const t=new Set(r.ids);return n.map(o=>!t.has(o.id)||o.kind!=="thinking"&&o.kind!=="tool"?o:{...o,collapsed:r.collapsed})}case"toggleCollapse":return n.map(t=>t.id!==r.id||t.kind!=="thinking"&&t.kind!=="tool"?t:{...t,collapsed:!t.collapsed});case"turnEnd":{const t=[...n];for(let o=t.length-1;o>=0;o--){const s=t[o];if(!(!s||s.kind!=="thinking"&&s.kind!=="tool")){t[o]={...s,turnDurationMs:Math.max(0,r.endedAt-r.startedAt)};break}}return t}case"historyLoaded":{const t=[];let o;for(let s=0;s<r.messages.length;s++){const i=r.messages[s],l=r.id+1+s*10,c=[];if(i.role==="user"&&!i.toolCalls&&(o=void 0,c.push({id:l+100,kind:"user",text:i.text,...i.images&&i.images.length>0?{images:i.images}:{}})),i.thinking&&(c.push({id:l,kind:"thinking",text:i.thinking,collapsed:!0}),o=t.length+c.length-1),i.toolCalls)for(let g=0;g<i.toolCalls.length;g++){const u=i.toolCalls[g];c.push({id:l+1+g,kind:"tool",toolCallId:u.id||`hist-${s}-${g}`,name:u.name,args:u.args,status:u.isError===!0?"failed":"succeeded",result:u.result,...u.diff!==void 0?{diff:u.diff}:{},...u.patch!==void 0?{patch:u.patch}:{},collapsed:!0}),o=t.length+c.length-1}if(i.role==="assistant"&&c.push({id:l+100,kind:"assistant",text:i.text}),i.role==="system"&&c.push({id:l+100,kind:"system",text:i.text}),t.push(...c),i.turnDurationMs!==void 0&&o!==void 0){const g=t[o];g&&(g.kind==="thinking"||g.kind==="tool")&&(t[o]={...g,turnDurationMs:i.turnDurationMs})}}return t}case"prependHistory":{const t=[];let o;for(let s=0;s<r.messages.length;s++){const i=r.messages[s],l=-(r.id+1+s*10),c=[];if(i.role==="user"&&!i.toolCalls&&(o=void 0,c.push({id:l+100,kind:"user",text:i.text,...i.images&&i.images.length>0?{images:i.images}:{}})),i.thinking&&(c.push({id:l,kind:"thinking",text:i.thinking,collapsed:!0}),o=t.length+c.length-1),i.toolCalls)for(let g=0;g<i.toolCalls.length;g++){const u=i.toolCalls[g];c.push({id:l+1+g,kind:"tool",toolCallId:u.id||`hist-${s}-${g}`,name:u.name,args:u.args,status:u.isError===!0?"failed":"succeeded",result:u.result,...u.diff!==void 0?{diff:u.diff}:{},...u.patch!==void 0?{patch:u.patch}:{},collapsed:!0}),o=t.length+c.length-1}if(i.role==="assistant"&&c.push({id:l+100,kind:"assistant",text:i.text}),i.role==="system"&&c.push({id:l+100,kind:"system",text:i.text}),t.push(...c),i.turnDurationMs!==void 0&&o!==void 0){const g=t[o];g&&(g.kind==="thinking"||g.kind==="tool")&&(t[o]={...g,turnDurationMs:i.turnDurationMs})}}return[...t,...n]}case"userMessageEntryId":return n.map(t=>t.id!==r.id||t.kind!=="user"?t:{...t,entryId:r.entryId});case"userMessage":return[...n,{id:r.id,kind:"user",text:r.text,...r.skillTag?{skillTag:r.skillTag}:{},...r.images&&r.images.length>0?{images:r.images}:{}}];case"assistantDelta":{const t=n[n.length-1];if(t&&t.kind==="assistant"){const o=[...n];return o[o.length-1]={...t,text:`${t.text}${r.text}`},o}return[...n,{id:r.id,kind:"assistant",text:r.text}]}case"system":return[...n,{id:r.id,kind:"system",text:r.text}];case"removeMessage":return n.filter(t=>t.id!==r.id)}}const Yt=/^(#{1,6})\s+(.*)$/,it=/^```(\w*)\s*$/,Jt=/^\s*(---+|\*\*\*+|___+)\s*$/,Xe=/^\s*>\s?(.*)$/,lt=/^(\s*)([-*+]|\d+\.)\s+(.*)$/,xt=/^\s*\|(.+)\|\s*$/,Xt=/^[\s:|:-]+$/;function un(n){var s;const r=n.replace(/\r\n/g,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`),t=[];let o=0;for(;o<r.length;){const i=r[o]??"",l=i.match(it);if(l){const f=l[1]??"",m=[];for(o+=1;o<r.length;){if(it.test(r[o]??"")){o+=1;break}m.push(r[o]??""),o+=1}t.push({type:"code",lang:f,text:m.join(`
|
|
5
|
-
`)});continue}const c=i.match(Yt);if(c){t.push({type:"heading",level:c[1].length,content:xe(c[2]??"")}),o+=1;continue}if(Jt.test(i)){t.push({type:"hr"}),o+=1;continue}if(Xe.test(i)){const f=[];for(;o<r.length&&Xe.test(r[o]??"");)f.push((r[o]??"").replace(Xe,"$1")),o+=1;t.push({type:"quote",content:un(f.join(`
|
|
6
|
-
`))});continue}const g=i.match(lt);if(g){const f=/\d+\./.test(g[2]??""),m=[],x=(g[1]??"").length;for(;o<r.length;){const h=(s=r[o])==null?void 0:s.match(lt),j=((h==null?void 0:h[1])??"").length,S=h!=null&&/\d+\./.test(h[2]??"");if(!h||j!==x||S!==f)break;const p=[(h[3]??"").trim()];for(;o+1<r.length;){const k=r[o+1]??"";if(k.length>0&&!/^\s*$/.test(k)&&!lt.test(k)&&!Xe.test(k)&&!it.test(k))p.push(k.replace(/^\s+/,"")),o+=1;else break}m.push(xe(p.join(" "))),o+=1}t.push({type:"list",ordered:f,items:m});continue}if(xt.test(i)){const f=Gt(i),m=r[o+1]??"";if(f.length>1&&Xt.test(m)&&m.includes("-")){const x=f.map(j=>xe(j)),h=[];for(o+=2;o<r.length&&xt.test(r[o]??"");)h.push(Gt(r[o]??"").map(j=>xe(j))),o+=1;t.push({type:"table",headers:x,rows:h});continue}}if(/^\s*$/.test(i)){o+=1;continue}const u=[i.trim()];for(o+=1;o<r.length;){const f=r[o]??"";if(/^\s*$/.test(f)||Yt.test(f)||it.test(f)||Jt.test(f)||Xe.test(f)||lt.test(f)||xt.test(f)&&(r[o+1]??"").includes("-")&&Xt.test(r[o+1]??""))break;u.push(f.trim()),o+=1}t.push({type:"paragraph",content:xe(u.join(" "))})}return t}function Gt(n){return n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}const Sr=/^(https?|mailto):/i;function xe(n){const r=/(`[^`\n]+`)|(\*\*(?=\S).+?\*\*(?!\*))|(__[^_\n]+__)|(\*(?=\S)[^*\n]+?\*)|(_[^_\n\s][^_\n]*_)|(~~[^~\n]+~~)|(\[[^\]\n]+\]\([^)\n\s]+\))/g,t=[];let o=0,s;for(;(s=r.exec(n))!==null;){s.index>o&&t.push({kind:"text",text:n.slice(o,s.index)}),o=r.lastIndex;const[i,l,c,g,u,f,m,x]=s;if(l!==void 0)t.push({kind:"code",text:l.slice(1,-1)});else if(c!==void 0)t.push({kind:"bold",children:xe(c.slice(2,-2))});else if(g!==void 0)t.push({kind:"bold",children:xe(g.slice(2,-2))});else if(u!==void 0)t.push({kind:"italic",children:xe(u.slice(1,-1))});else if(f!==void 0)t.push({kind:"italic",children:xe(f.slice(1,-1))});else if(m!==void 0)t.push({kind:"strike",children:xe(m.slice(2,-2))});else if(x!==void 0){const h=x.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);if(h){const j=h[2]??"";t.push(Sr.test(j)?{kind:"link",href:j,children:xe(h[1]??"")}:{kind:"text",text:i})}else t.push({kind:"text",text:i})}}return o<n.length&&t.push({kind:"text",text:n.slice(o)}),t}const Ir="rgba(79, 140, 255, 0.08)",Cr="rgba(79, 140, 255, 0.18)",Ge=new Map,Mr=4e3;function Tr(n,r){const t=`${n.length}:${n}`,o=Ge.get(t);if(o)return o;const s=sr(n,r);if(Ge.size>=Mr){const i=Ge.keys().next().value;i!==void 0&&Ge.delete(i)}return Ge.set(t,s),s}function ye({nodes:n}){const r=K();return e.jsx(e.Fragment,{children:n.map((t,o)=>{switch(t.kind){case"text":return e.jsx(tn.Fragment,{children:t.text},o);case"code":return e.jsx("code",{style:{fontFamily:r.font.mono,fontSize:"0.85em",background:Ir,border:`1px solid ${Cr}`,borderRadius:4,padding:"0.1em 0.35em",color:r.color.accent,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:t.text},o);case"bold":return e.jsx("strong",{style:{fontWeight:700},children:e.jsx(ye,{nodes:t.children})},o);case"italic":return e.jsx("em",{children:e.jsx(ye,{nodes:t.children})},o);case"strike":return e.jsx("s",{style:{opacity:.6},children:e.jsx(ye,{nodes:t.children})},o);case"link":return e.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",style:{color:r.color.accent,textDecoration:"underline"},children:e.jsx(ye,{nodes:t.children})},o)}})})}const Qe={margin:"0 0 10px"};function Er({text:n,lang:r}){const{theme:t}=Ze(),o=nn(),[s,i]=a.useState(!1),l=t==="light"?rr:or,c=n.split(`
|
|
7
|
-
`),g=async()=>{try{await navigator.clipboard.writeText(n)}catch{const u=document.createElement("textarea");u.value=n,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}i(!0),window.setTimeout(()=>i(!1),1600)};return e.jsxs("div",{style:{margin:Qe.margin,background:l.bg,border:`1px solid ${l.border}`,borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 10px 5px 14px",borderBottom:`1px solid ${l.border}`,background:"linear-gradient(90deg, rgba(99,102,241,0.08), rgba(99,102,241,0.02))"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:0},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",flexShrink:0}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.78em",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:l.text,opacity:.75},children:r||"code"})]}),e.jsxs("button",{onClick:()=>void g(),onMouseEnter:u=>{u.currentTarget.style.opacity="1",u.currentTarget.style.background="rgba(99,102,241,0.12)",u.currentTarget.style.borderColor="rgba(99,102,241,0.45)",u.currentTarget.style.color="#6366f1"},onMouseLeave:u=>{u.currentTarget.style.opacity="0.85",u.currentTarget.style.background="transparent",u.currentTarget.style.borderColor=l.border,u.currentTarget.style.color=s?"#16a34a":l.text},style:{display:"flex",alignItems:"center",gap:5,background:"transparent",border:`1px solid ${l.border}`,color:s?"#16a34a":l.text,borderRadius:6,padding:"3px 9px",fontSize:"0.76em",cursor:"pointer",opacity:.85,transition:"all 0.15s",flexShrink:0,fontFamily:"inherit"},children:[s?e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),s?"已复制":"复制"]})]}),e.jsx("pre",{style:{margin:0,padding:"10px 14px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:o.codeFontSize,lineHeight:1.6,overflowX:o.wrapLongLines?"hidden":"auto",color:l.text,whiteSpace:o.wrapLongLines?"pre-wrap":"pre"},children:c.map((u,f)=>e.jsxs("div",{style:{display:"flex",minHeight:"1.6em"},children:[o.showLineNumbers&&e.jsx("span",{style:{width:30,flexShrink:0,textAlign:"right",marginRight:14,color:l.text,opacity:.35,userSelect:"none",fontVariantNumeric:"tabular-nums"},children:f+1}),e.jsx("span",{style:{whiteSpace:o.wrapLongLines?"pre-wrap":"pre",minWidth:0},children:Tr(u,l).map((m,x)=>m.color!==void 0?e.jsx("span",{style:{color:m.color},children:m.text},x):e.jsx(tn.Fragment,{children:m.text},x))})]},f))})]})}function Rr({block:n}){const{tokens:r}=Ze();switch(n.type){case"code":return e.jsx(Er,{text:n.text,lang:n.lang});case"paragraph":return e.jsx("p",{style:Qe,children:e.jsx(ye,{nodes:n.content})});case"heading":return e.jsx("div",{style:{margin:"14px 0 8px",fontWeight:700,fontSize:n.level===1?20:n.level===2?17:15,color:r.color.fg},children:e.jsx(ye,{nodes:n.content})});case"list":return e.jsx("div",{style:Qe,children:n.items.map((t,o)=>n.ordered?e.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0"},children:[e.jsxs("span",{style:{color:r.color.muted,minWidth:22,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[o+1,"."]}),e.jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:e.jsx(ye,{nodes:t})})]},o):e.jsxs("div",{style:{display:"flex",gap:8,padding:"2px 0"},children:[e.jsx("span",{style:{color:r.color.primary,minWidth:14},children:"•"}),e.jsx("span",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:e.jsx(ye,{nodes:t})})]},o))});case"quote":return e.jsx("blockquote",{style:{margin:Qe.margin,padding:"2px 0 2px 12px",borderLeft:`3px solid ${r.color.primary}`,color:r.color.muted},children:e.jsx(fn,{blocks:n.content})});case"table":return e.jsx("div",{style:{margin:Qe.margin,overflowX:"auto"},children:e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:13,border:`1px solid ${r.color.border}`,borderRadius:6},children:[e.jsx("thead",{children:e.jsx("tr",{children:n.headers.map((t,o)=>e.jsx("th",{style:{border:`1px solid ${r.color.border}`,padding:"6px 10px",background:r.color.surface,fontWeight:600,textAlign:"left"},children:e.jsx(ye,{nodes:t})},o))})}),e.jsx("tbody",{children:n.rows.map((t,o)=>e.jsx("tr",{children:t.map((s,i)=>e.jsx("td",{style:{border:`1px solid ${r.color.border}`,padding:"5px 10px"},children:e.jsx(ye,{nodes:s})},i))},o))})]})});case"hr":return e.jsx("hr",{style:{border:"none",borderTop:`1px solid ${r.color.border}`,margin:"14px 0"}})}}function fn({blocks:n}){return e.jsx(e.Fragment,{children:n.map((r,t)=>e.jsx(Rr,{block:r},t))})}function Wr({text:n}){const r=a.useMemo(()=>un(n),[n]);return e.jsx("div",{style:{overflowWrap:"anywhere",wordBreak:"break-word",minWidth:0},children:e.jsx(fn,{blocks:r})})}const Lr=720,mt="#6366f1",zr="#8b5cf6";function $r({text:n}){const r=K(),t=/剩余\s*([\d.]+)\s*K/.exec(n);return e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"4px 0"},children:e.jsxs("div",{style:{maxWidth:Lr,width:"100%",display:"flex",alignItems:"center",gap:8,position:"relative",overflow:"hidden",background:"linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.02))",border:"1px solid rgba(99,102,241,0.14)",borderRadius:10,padding:"8px 12px 8px 16px"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,bottom:0,width:3,background:`linear-gradient(180deg, ${mt}, ${zr})`}}),e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:mt,strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M4 9h6V3M20 15h-6v6M20 9h-6V3M4 15h6v6"})}),e.jsxs("span",{style:{color:r.color.muted,fontSize:"0.85em",lineHeight:1.5},children:[e.jsx("span",{style:{color:mt,fontWeight:600},children:T("前文已摘要")}),t?e.jsxs("span",{style:{opacity:.75},children:[" · 剩余 ",t[1],"K 上下文"]}):null]})]})})}function Br(n){let r;try{const t=JSON.parse(n);r=typeof t.file_path=="string"?t.file_path:typeof t.path=="string"?t.path:void 0}catch{}if(!r){const t=n.match(/"file_path"\s*:\s*"([^"]+)"|"path"\s*:\s*"([^"]+)"/);r=t?t[1]??t[2]:void 0}return r?De(r):"未知文件"}function De(n){return n.replace(/\\/g,"/").replace(/^\/mnt\/([a-zA-Z])\//,(r,t)=>`${t.toUpperCase()}:/`)}function Dr(n){let r=0,t=0;for(const o of n.split(`
|
|
8
|
-
`)){const s=o[0];s==="+"?r+=1:s==="-"&&(t+=1)}return{added:r,removed:t}}function Fr(n){const r=[];for(const t of n)t.kind!=="tool"||!t.diff||!t.toolCallId||r.push({file:Br(t.args),toolCallId:t.toolCallId,diff:t.diff,patch:t.patch,...Dr(t.diff)});return r}const Ar=/<skill\s+name="([^"]+)"[^>]*>\s*(?:References are relative to[^\n]*\n\n)?([\s\S]*?)<\/skill>/g;function Hr({parts:n}){const r=K();return e.jsx(e.Fragment,{children:n.map((t,o)=>t.type==="skill"?e.jsxs("span",{title:`skill: ${t.name}`,style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:6,fontSize:"0.85em",background:"rgba(210,153,34,0.10)",border:"1px solid rgba(210,153,34,0.30)",color:r.color.warning,fontFamily:r.font.mono},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V5.5a.5.5 0 0 0-.5-.5H6.5A2.5 2.5 0 0 0 4 7.5v12z"}),e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5"}),e.jsx("path",{d:"M12 6.5l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"})]}),t.name]},o):e.jsx("span",{children:t.text},o))})}function Pr(n){const r=n.text??"";if(n.skillTag){const o=r.replace(/^\/skill:[^\s]*\s*/,"");return{skillTag:n.skillTag,args:o,copyText:r.trim()}}const t=/<skill\s+name="([^"]+)"[^>]*>[\s\S]*?<\/skill>\s*([\s\S]*)$/.exec(r);if(t){const o=(t[2]??"").replace(/^\s*\n\s*/,"").trim();return{skillTag:t[1],args:o,copyText:`/skill:${t[1]}${o?" "+o:""}`}}return{args:r,copyText:r}}function Or(n){const r=[];let t=0,o;const s=new RegExp(Ar.source,"g");for(;(o=s.exec(n))!==null;)o.index>t&&r.push({type:"text",text:n.slice(t,o.index)}),r.push({type:"skill",name:o[1]}),t=o.index+o[0].length;return t<n.length&&r.push({type:"text",text:n.slice(t)}),r.length>0?e.jsx(Hr,{parts:r}):e.jsx(e.Fragment,{children:n})}function _r({text:n}){const r=K();return e.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"4px 0"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",borderRadius:999,border:"1px solid rgba(99,102,241,0.18)",background:"linear-gradient(135deg, rgba(99,102,241,0.07), rgba(139,92,246,0.03))",color:r.color.muted,fontSize:"0.85em"},children:[e.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:"2px solid rgba(99,102,241,0.25)",borderTopColor:"#6366f1",animation:"vagus-spin 0.8s linear infinite",display:"inline-block",flexShrink:0}}),n]})})}const yt=1e3;function hn(n){const r=[];let t=[],o=[],s=new Set;const i=()=>{t.length>0&&r.push({kind:"work",work:t});for(const c of o)r.push({kind:"item",item:c});const l=Fr(t);if(l.length>0){const c=new Map;for(const f of l){const m=c.get(f.file)??{file:f.file,added:0,removed:0};m.added+=f.added,m.removed+=f.removed,f.diff&&(m.diff=m.diff?`${m.diff}
|
|
9
|
-
${f.diff}`:f.diff),f.patch&&(m.patch=m.patch?`${m.patch}
|
|
10
|
-
${f.patch}`:f.patch),c.set(f.file,m)}const g=l[l.length-1].toolCallId,u=[...c.values()].map(f=>({...f,turnToolCallId:g}));r.push({kind:"turnSummary",files:u})}t=[],o=[],s=new Set};for(let l=0;l<n.length;l++){const c=n[l];if(c.kind==="thinking"||c.kind==="tool"){if(c.kind==="thinking"){if(s.has(c.text))continue;s.add(c.text)}t.push(c)}else if(c.kind==="assistant"){let g=!0,u=t.length>0;for(let f=l+1;f<n.length;f++){const m=n[f];if(m.kind==="user"||m.kind==="system")break;if(m.kind==="thinking"||m.kind==="tool"){u=!0,g=!1;break}if(m.kind==="assistant"){g=!1;break}}g||!u?o.push(c):t.push(c)}else i(),r.push({kind:"item",item:c})}return i(),r}function qr(n){const r=[];let t=new Set;for(const o of n)if(o.kind==="user")t=new Set,r.push(o);else if(o.kind==="thinking"){if(t.has(o.text))continue;t.add(o.text),r.push(o)}else r.push(o);return r}function Nr({item:n,onToggleCard:r,onCopy:t,onEditSubmit:o,showCopy:s,onFork:i}){const l=K(),[c,g]=a.useState(!1);if(n.kind==="user")return e.jsx(Ur,{item:n,onCopy:t,onEditSubmit:o,onFork:i});if(n.kind==="assistant"){const u=()=>{const f=n.text;t?t(f):navigator.clipboard.writeText(f),g(!0),setTimeout(()=>g(!1),1800)};return e.jsx("div",{style:{display:"flex",justifyContent:"flex-start"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,maxWidth:yt,minWidth:0},children:[e.jsx("div",{style:{overflowWrap:"anywhere",wordBreak:"break-word",fontSize:"1em",lineHeight:1.65,color:l.color.fg},children:e.jsx(Wr,{text:n.text})}),s&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",minHeight:20},children:e.jsx("button",{onClick:u,title:c?"已复制":"复制回答",style:{width:26,height:26,borderRadius:6,border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",color:c?"#16a34a":l.color.muted,transition:"color 0.15s",opacity:.4},onMouseEnter:f=>{f.currentTarget.style.opacity="1"},onMouseLeave:f=>{f.currentTarget.style.opacity="0.4"},children:c?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})})]})})}return n.kind==="thinking"?e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",maxWidth:yt,width:"100%"},children:e.jsx(Gr,{item:n,onToggle:()=>r==null?void 0:r(n.id)})}):n.kind==="tool"?e.jsx("div",{style:{display:"flex",justifyContent:"flex-start",maxWidth:yt,width:"100%"},children:e.jsx(Qr,{item:n,onToggle:()=>r==null?void 0:r(n.id)})}):n.text.startsWith("◌ 前文已摘要")||n.text.startsWith("◔ 分支摘要")?e.jsx($r,{text:n.text}):n.text.startsWith("正在压缩")?e.jsx(_r,{text:n.text}):e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:e.jsx("span",{style:{color:l.color.muted,fontSize:"0.86em"},children:n.text})})}const St=a.memo(Nr,(n,r)=>n.item===r.item),Vr={width:26,height:26,borderRadius:6,border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit"};function Ur({item:n,onCopy:r,onEditSubmit:t,onFork:o}){const s=K(),i=Pr(n),[l,c]=a.useState(!1),[g,u]=a.useState(i.copyText),[f,m]=a.useState(!1),[x,h]=a.useState(null),j=a.useRef(null);a.useEffect(()=>{var p;l&&((p=j.current)==null||p.focus())},[l]),a.useEffect(()=>{if(x===null)return;const p=k=>{k.key==="Escape"&&h(null)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[x]);const S=()=>{r==null||r(i.copyText),m(!0),window.setTimeout(()=>m(!1),1600)},v=p=>({...Vr,color:p});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,maxWidth:"100%"},children:[l?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{ref:j,value:g,onChange:p=>u(p.target.value),rows:3,style:{width:"100%",maxWidth:520,minHeight:64,background:s.color.bg,border:"1px solid #6366f1",borderRadius:12,padding:"8px 10px",fontSize:"0.95em",lineHeight:1.5,color:s.color.fg,outline:"none",resize:"vertical",fontFamily:"inherit"}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:()=>{c(!1),u(i.copyText)},style:{height:30,padding:"0 12px",borderRadius:8,border:`1px solid ${s.color.border}`,background:"transparent",color:s.color.muted,fontSize:"0.86em",cursor:"pointer",fontFamily:"inherit"},children:T("取消")}),e.jsx("button",{onClick:()=>{g.trim()&&(t==null||t(g.trim())),c(!1)},style:{height:30,padding:"0 14px",borderRadius:8,border:"none",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",color:"#fff",fontSize:"0.86em",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:T("发送")})]})]}):e.jsxs(e.Fragment,{children:[n.images&&n.images.length>0&&e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end",maxWidth:"70%"},children:n.images.map((p,k)=>e.jsx("img",{src:p.dataUrl,alt:"附件",style:{width:80,height:80,borderRadius:8,border:`1px solid ${s.color.border}`,objectFit:"cover",background:s.color.bg,cursor:"zoom-in"},onClick:()=>h(p.dataUrl),title:T("点击查看大图")},k))}),e.jsx("div",{style:{background:s.color.surface,border:`1px solid ${s.color.border}`,borderRadius:"14px 14px 4px 14px",padding:"10px 14px",maxWidth:"70%",color:s.color.fg,whiteSpace:"pre-wrap",wordBreak:"break-word",fontSize:"1em",lineHeight:1.55},children:i.skillTag?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:6,fontSize:"0.85em",background:"rgba(210,153,34,0.10)",border:"1px solid rgba(210,153,34,0.30)",color:s.color.warning,fontFamily:s.font.mono},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20V5.5a.5.5 0 0 0-.5-.5H6.5A2.5 2.5 0 0 0 4 7.5v12z"}),e.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 0 6.5 22H20v-5"}),e.jsx("path",{d:"M12 6.5l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"})]}),i.skillTag]}),e.jsx("span",{children:i.args})]}):n.text&&/<skill\s/.test(n.text)?Or(n.text):i.args}),(r||t||o)&&e.jsxs("div",{style:{display:"flex",gap:4},children:[o&&e.jsx("button",{onClick:()=>o(n.id,n.text,i.copyText),title:T("从此处派生新对话(创建新会话保留到此为止的上下文)"),style:{...v(s.color.muted),opacity:.5,transition:"opacity 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.opacity="1"},onMouseLeave:p=>{p.currentTarget.style.opacity="0.5"},children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M6 3v12a4 4 0 0 0 4 4h4"}),e.jsx("path",{d:"M14 19l3-3-3-3"}),e.jsx("path",{d:"M6 3a3 3 0 1 0 0 6 3 3 0 0 0 0-6z"})]})}),r&&e.jsx("button",{onClick:S,title:f?"已复制":"复制",style:{...v(f?"#16a34a":s.color.muted),transition:"color 0.15s"},children:f?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),t&&e.jsx("button",{onClick:()=>{u(i.copyText),c(!0)},title:T("编辑"),style:v(s.color.muted),children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"})})})]})]}),x!==null&&rn.createPortal(e.jsx("div",{onClick:()=>h(null),style:{position:"fixed",inset:0,zIndex:300,background:"rgba(0,0,0,0.78)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:e.jsx("img",{src:x,alt:"查看大图",onClick:p=>p.stopPropagation(),style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain",borderRadius:10,boxShadow:"0 12px 48px rgba(0,0,0,0.5)"}})}),document.body)]})}function Kr(n){const r=n/1e3;if(r<1)return`${Math.round(n)}ms`;if(r<60)return r<10?`${r.toFixed(1)}s`:`${Math.round(r)}s`;const t=Math.floor(r/60),o=Math.round(r%60);return o===0?`${t}m`:`${t}m ${o}s`}function Yr({stampedMs:n,startMs:r}){const[,t]=a.useState(0),o=n>0;a.useEffect(()=>{if(o)return;const i=window.setInterval(()=>t(l=>l+1),250);return()=>window.clearInterval(i)},[o]);const s=o?n:r!==void 0?Math.max(0,Date.now()-r):0;return s<=0?null:e.jsx(e.Fragment,{children:Kr(s)})}function Jr({work:n,onToggleItem:r,live:t,startMs:o,attached:s,attachedAnchor:i}){const l=K(),[c,g]=a.useState(!1),u=a.useRef(!1),f=a.useRef(!1);if(a.useEffect(()=>{t?(u.current=!0,f.current||g(!0)):u.current&&(u.current=!1,g(!1),f.current=!1)},[t]),n.length===0)return null;const m=n.filter(p=>p.kind==="tool").length,x=n.filter(p=>p.kind==="thinking").length,h=n.reduce((p,k)=>Math.max(p,k.kind==="thinking"||k.kind==="tool"?k.turnDurationMs??0:0),0),j=h>0||o!==void 0,v=m>0?`${m} 个工具`+(x>0?` · ${x} 次思考`:""):x>0?`${x} 次思考`:"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("button",{onClick:()=>{g(p=>{const k=!p;return k||(f.current=!0),k})},title:c?"收起工作内容":"展开工作内容",style:{display:"flex",alignItems:"center",gap:6,width:"fit-content",textAlign:"left",border:"none",background:"transparent",padding:"2px 0",cursor:"pointer",color:l.color.muted,fontSize:"0.89em"},children:[e.jsx("span",{style:{fontSize:"0.71em",color:l.color.muted,flexShrink:0,transition:"transform 0.15s",transform:c?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),e.jsx("span",{style:{color:"#6366f1",fontWeight:600},children:T("工作内容")}),e.jsxs("span",{style:{color:l.color.muted},children:[v,v!==""&&j&&" · ",e.jsx(Yr,{stampedMs:h,startMs:o})]})]}),c&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:2},children:n.map((p,k)=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx(St,{item:p,onToggleCard:()=>r(p.id)}),s&&k===i&&s]},`w${p.id}`))})]})}const Xr=a.memo(Jr,(n,r)=>n.live===r.live&&n.startMs===r.startMs&&n.attachedAnchor===r.attachedAnchor&&n.attached===r.attached&&n.work.length===r.work.length&&n.work.every((t,o)=>t===r.work[o]));function Gr({item:n,onToggle:r}){const t=K(),o=n.collapsed===!0;return e.jsxs("button",{onClick:r,title:o?"展开思考":"收起思考",style:{display:"block",width:"100%",textAlign:"left",border:"1px solid rgba(99,102,241,0.2)",borderRadius:8,background:"linear-gradient(135deg, rgba(99,102,241,0.07), rgba(139,92,246,0.04))",padding:"8px 12px",cursor:"pointer",color:t.color.fg},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.color.muted,fontSize:"0.86em"},children:o?"▶":"▼"}),e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#6366f1",strokeWidth:"1.8",style:{flexShrink:0},children:e.jsx("path",{d:"M12 4.5a2.5 2.5 0 0 0-4.96-.46 2.5 2.5 0 0 0-1.98 3 2.5 2.5 0 0 0-1.32 4.24 3 3 0 0 0 .34 5.58 2.5 2.5 0 0 0 2.96 3.08A2.5 2.5 0 0 0 12 19.5a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 12 4.5z"})}),e.jsx("span",{style:{color:"#6366f1",fontSize:"0.88em",fontWeight:600,letterSpacing:"0.02em"},children:T("思考")}),e.jsxs("span",{style:{marginLeft:"auto",color:t.color.muted,fontSize:"0.79em"},children:[n.text.length," chars"]})]}),!o&&e.jsx("div",{style:{marginTop:6,color:t.color.muted,fontSize:"0.86em",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:260,overflowY:"auto"},children:n.text})]})}function Qr({item:n,onToggle:r}){const t=K(),o=n.collapsed===!0,s=n.status==="succeeded"?t.color.success:n.status==="failed"?t.color.error:t.color.warning;return e.jsxs("div",{style:{border:"1px solid rgba(99,102,241,0.18)",borderRadius:8,background:"linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.03))",padding:"8px 12px",display:"flex",flexDirection:"column",gap:4,minWidth:"100%"},children:[e.jsxs("button",{onClick:r,title:o?"展开详情":"收起详情",style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",padding:0,cursor:"pointer",color:"inherit",textAlign:"left"},children:[e.jsx("span",{style:{color:t.color.muted,fontSize:"0.86em"},children:o?"▶":"▼"}),e.jsx("span",{style:{color:s,fontSize:"0.86em"},children:"⚙"}),e.jsx("span",{style:{color:"#6366f1",fontSize:"0.93em",fontWeight:600,flexShrink:0},children:n.name}),n.args&&e.jsx("span",{style:{color:t.color.muted,fontSize:"0.79em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:n.args}),e.jsx("span",{style:{marginLeft:"auto",width:72,flexShrink:0,textAlign:"right",whiteSpace:"nowrap",fontSize:"0.86em",color:s,fontWeight:600},children:n.status==="running"?"● running":n.status==="succeeded"?"✓ done":"✗ failed"})]}),!o&&e.jsx(e.Fragment,{children:n.diff?e.jsx(pn,{diff:n.diff,t,full:!0,maxHeight:400}):n.result&&e.jsx("pre",{style:{background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:6,padding:"8px 10px",margin:0,maxHeight:240,overflow:"auto",fontSize:"0.79em",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",color:t.color.muted},children:n.result})})]})}function Zr(n){const r=n.split(`
|
|
11
|
-
`);return r.some(o=>o.startsWith("--- ")||o.startsWith("diff --git"))?to(r):eo(r)}function eo(n){const r=[];let t=[],o=null;for(const s of n){const i=s[0]??"",l=s.indexOf(" ",1),c=l===-1?"":s.slice(1,l).trim(),g=l===-1?s.slice(1):s.slice(l+1);if(g.trim()==="...")continue;const u=i==="+"||i==="-"?"change":"context";u!==o&&(t.length>0&&o&&r.push({kind:o,lines:t}),t=[],o=u),t.push({marker:i,lineNum:c,content:g})}return t.length>0&&o&&r.push({kind:o,lines:t}),r}function to(n){const r=[];let t=[],o=null,s=0,i=0;const l=()=>{t.length>0&&o&&r.push({kind:o,lines:t}),t=[],o=null};for(const c of n){if(c.startsWith("--- ")||c.startsWith("+++ ")||c.startsWith("diff --git")||c.startsWith("index ")||c.startsWith("\\"))continue;const g=c.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(g){l(),s=Number(g[1])-1,i=Number(g[2])-1;continue}const u=c[0]??"",f=u===" "||u==="+"||u==="-"?c.slice(1):c,m=u==="+"||u==="-"?"change":"context";m!==o&&(l(),o=m);let x="";u==="+"?(i++,x=String(i)):u==="-"?(s++,x=String(s)):(s++,i++,x=String(i)),t.push({marker:u,lineNum:x,content:f})}return l(),r}function pn({diff:n,t:r,maxHeight:t,full:o}){const{theme:s}=Ze(),i=s==="dark",l=a.useMemo(()=>Zr(n),[n]),c=i?{addBg:"rgba(34,197,94,0.15)",addFg:"#4ade80",addEdge:"#4ade80",delBg:"rgba(239,68,68,0.15)",delFg:"#f87171",delEdge:"#f87171",foldBg:"rgba(255,255,255,0.05)",foldFg:"#9ca3af",text:r.color.fg,numFg:"#6b7280",border:r.color.border}:{addBg:"#f0fdf4",addFg:"#16a34a",addEdge:"#16a34a",delBg:"#fef2f2",delFg:"#ef4444",delEdge:"#ef4444",foldBg:"#f3f4f6",foldFg:"#6b7280",text:"#1f2937",numFg:"#9ca3af",border:"#e5e7eb"},g=(f,m,x)=>{const h=f.marker==="+",j=f.marker==="-",S=h?c.addBg:j?c.delBg:"transparent",v=h?c.addEdge:j?c.delEdge:"transparent",p=h?c.addFg:j?c.delFg:c.numFg;return e.jsxs("div",{style:{display:"flex",whiteSpace:"pre",background:S,minWidth:"100%",borderLeft:`3px solid ${v}`,lineHeight:"26px",minHeight:26,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",color:c.text},children:[e.jsx("span",{style:{flexShrink:0,width:50,textAlign:"right",paddingRight:10,userSelect:"none",color:p},children:f.lineNum}),e.jsx("span",{style:{flexShrink:0,width:18,textAlign:"center",userSelect:"none",color:p},children:f.marker===" "?" ":f.marker}),e.jsx("span",{style:{whiteSpace:"pre",background:S},children:f.content})]},`${x}-${m}`)},u=(f,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",padding:"2px 10px",background:c.foldBg,borderRadius:6,margin:"2px 0",color:c.foldFg,fontSize:"0.75em",fontFamily:"system-ui, -apple-system, sans-serif",userSelect:"none"},children:[f," unmodified lines"]},m);return e.jsx("div",{style:{background:i?r.color.bg:"#ffffff",border:`1px solid ${c.border}`,borderRadius:8,margin:0,maxHeight:t??"none",overflowX:"auto",overflowY:t!==void 0?"auto":"hidden",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:"0.92em",lineHeight:"26px"},children:e.jsxs("div",{style:{width:"max-content",minWidth:"100%"},children:[l.map((f,m)=>{if(f.kind==="change")return e.jsx("div",{children:f.lines.map((x,h)=>g(x,h,`s${m}`))},`s${m}`);if(o)return null;if(!o&&f.lines.length>2){const x=[f.lines[0],f.lines[f.lines.length-1]],h=f.lines.length-2;return e.jsxs("div",{children:[g(x[0],0,`s${m}-a`),u(h,`s${m}-f`),g(x[1],1,`s${m}-b`)]},`s${m}`)}return e.jsx("div",{children:f.lines.map((x,h)=>g(x,h,`s${m}-c`))},`s${m}`)}),l.length===0&&e.jsx("div",{style:{padding:"8px 10px",color:c.numFg,fontSize:"0.85em",fontFamily:"system-ui, sans-serif"},children:T("(无 diff)")})]})})}function no({ext:n,muted:r,accent:t}){return n==="py"?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M14.5 3.5c3.4.4 4.7 2 4.7 4.2v3.2c0 1.7-1.3 2.8-2.8 2.8h-4.2c-2.3 0-4 1.7-4 4v3.4c0 2 1 3.4 3.9 3.4h3.3",stroke:"#3776ab",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.5 20.5c-3.4-.4-4.7-2-4.7-4.2v-3.2c0-1.7 1.3-2.8 2.8-2.8h4.2c2.3 0 4-1.7 4-4V3",stroke:"#ffd43b",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})]}):n==="md"?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M5 3.5h14a1.5 1.5 0 0 1 1.5 1.5v14a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 19V5A1.5 1.5 0 0 1 5 3.5z",stroke:t,strokeWidth:"1.5"}),e.jsx("path",{d:"M7.5 15.5v-6l2.5 2.5 2.5-2.5v6",stroke:t,strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14.5 15.5V10M14.5 12h3.5M14.5 15.5h3.5",stroke:t,strokeWidth:"1.6",strokeLinecap:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M7 3h7l5 5v13H7z",stroke:r,strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 3v5h5",stroke:r,strokeWidth:"1.6",strokeLinejoin:"round"})]})}const ro=a.memo(function({files:r,onOpenFile:t,onRevertAll:o,reverting:s,onExpand:i}){const l=K(),[c,g]=a.useState(!1);if(r.length===0)return null;const u=r.reduce((x,h)=>x+h.added,0),f=r.reduce((x,h)=>x+h.removed,0),m={height:22,padding:"0 10px",borderRadius:5,border:`1px solid ${l.color.border}`,background:l.color.surface,color:l.color.muted,fontSize:"0.72em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",flexShrink:0,transition:"background 0.15s, color 0.15s, border-color 0.15s"};return e.jsxs("div",{style:{border:`1px solid ${l.color.border}`,borderRadius:8,overflow:"hidden",background:l.color.bg,fontFamily:"inherit"},children:[e.jsxs("div",{onClick:()=>{g(x=>{const h=!x;return i==null||i(h),h})},style:{display:"flex",alignItems:"center",gap:8,padding:"7px 12px",background:l.color.surface,cursor:"pointer",borderBottom:c?`1px solid ${l.color.border}`:"none",userSelect:"none"},children:[e.jsx("span",{style:{color:l.color.muted,fontSize:"0.7em",flexShrink:0,transition:"transform 0.15s",transform:c?"rotate(90deg)":"none"},children:"▶"}),e.jsxs("span",{style:{color:l.color.fg,fontSize:"0.85em",fontWeight:600,flexShrink:0},children:[r.length," 个文件已更改"]}),e.jsxs("span",{style:{color:l.color.success,fontSize:"0.8em",fontWeight:600,flexShrink:0},children:["+",u]}),e.jsxs("span",{style:{color:l.color.error,fontSize:"0.8em",fontWeight:600,flexShrink:0},children:["-",f]}),e.jsx("span",{style:{flex:1}}),e.jsx("button",{onClick:x=>{x.stopPropagation(),o()},disabled:s,title:T("撤销本轮的全部更改"),style:{background:"none",border:"none",cursor:s?"wait":"pointer",color:l.color.muted,fontSize:"0.78em",fontWeight:600,fontFamily:"inherit",padding:"2px 6px",borderRadius:4,flexShrink:0,opacity:s?.55:1,transition:"color 0.15s, background 0.15s"},onMouseEnter:x=>{x.currentTarget.style.background=l.color.sidebarHover,x.currentTarget.style.color=l.color.fg},onMouseLeave:x=>{x.currentTarget.style.background="none",x.currentTarget.style.color=l.color.muted},children:s?"撤销中…":"撤销"})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:c?"1fr":"0fr",transition:"grid-template-rows 0.22s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{padding:"3px 0",display:"flex",flexDirection:"column"},children:r.map(x=>{const h=x.file.lastIndexOf("/"),j=h>=0?x.file.slice(0,h+1):"",S=h>=0?x.file.slice(h+1):x.file,v=S.toLowerCase(),p=v.endsWith(".py")?"py":v.endsWith(".md")?"md":"other";return e.jsxs("div",{onClick:()=>t(x.file,r),title:T("在右侧面板查看本轮的 diff"),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"transparent",cursor:"pointer"},onMouseEnter:k=>{k.currentTarget.style.background=l.color.sidebarHover},onMouseLeave:k=>{k.currentTarget.style.background="transparent"},children:[e.jsx(no,{ext:p,muted:l.color.muted,accent:l.color.accent}),e.jsxs("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.8em"},children:[e.jsx("span",{style:{color:l.color.fg,fontWeight:600},children:S}),j&&e.jsxs("span",{style:{color:l.color.muted},children:[" ",j]})]}),e.jsxs("span",{style:{color:l.color.success,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["+",x.added]}),e.jsxs("span",{style:{color:l.color.error,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["-",x.removed]}),e.jsx("button",{onClick:k=>{k.stopPropagation(),t(x.file,r)},title:T("在右侧面板查看本轮的 diff"),style:m,onMouseEnter:k=>{k.currentTarget.style.background=l.color.sidebarHover,k.currentTarget.style.color=l.color.fg},onMouseLeave:k=>{k.currentTarget.style.background=l.color.surface,k.currentTarget.style.color=l.color.muted},children:T("审查")})]},x.file)})})})})]})},(n,r)=>{if(n.files.length!==r.files.length)return!1;for(let t=0;t<n.files.length;t++){const o=n.files[t],s=r.files[t];if(o.file!==s.file||o.added!==s.added||o.removed!==s.removed||o.turnToolCallId!==s.turnToolCallId)return!1}return!0}),qe="__welcome__";function dt(){return{items:[],busy:!1,queued:[],thinkingLevel:void 0,info:void 0,historyHasMore:!1,historyTotal:0,historyStartIndex:0}}function at(n){return n.activeId??qe}function we(n,r,t){const o=n.slots[r]??dt(),s=t(o);return s===o?n:{...n,slots:{...n.slots,[r]:s}}}function oo(n,r){switch(r.type){case"activate":return{...n,activeId:r.sessionId};case"clearActive":return{...n,activeId:void 0};case"loadHistory":return we(n,r.sessionId,t=>({...dt(),items:le([],{type:"historyLoaded",id:r.id,messages:r.messages}),info:t.info,thinkingLevel:t.thinkingLevel,historyHasMore:r.hasMore??!1,historyTotal:r.total??r.messages.length,historyStartIndex:r.startIndex??Math.max(0,(r.total??r.messages.length)-r.messages.length)}));case"prependHistory":return we(n,r.sessionId,t=>({...t,items:le(t.items,{type:"prependHistory",id:r.id,messages:r.messages}),historyHasMore:r.hasMore,historyTotal:r.total,historyStartIndex:r.startIndex}));case"localSystem":return we(n,at(n),t=>({...t,items:le(t.items,{type:"system",id:r.id,text:r.text})}));case"removeMessage":return we(n,at(n),t=>({...t,items:le(t.items,{type:"removeMessage",id:r.id})}));case"userMessage":return we(n,r.sessionId,t=>({...t,items:le(t.items,{type:"userMessage",id:r.id,text:r.text,...r.skillTag?{skillTag:r.skillTag}:{},...r.images&&r.images.length>0?{images:r.images}:{}})}));case"setInfo":return we(n,r.sessionId,t=>({...t,info:r.info,thinkingLevel:r.thinkingLevel??t.thinkingLevel}));case"toggleCollapse":return we(n,at(n),t=>({...t,items:le(t.items,{type:"toggleCollapse",id:r.id})}));case"forceIdle":return we(n,at(n),t=>t.busy||t.turnStart!==void 0?{...t,busy:!1,turnStart:void 0}:t);case"moveWelcome":{const t=n.slots[qe];if(!t||t.items.length===0)return n;const o=n.slots[r.sessionId]??dt(),s={...n.slots};return s[r.sessionId]={...o,items:[...o.items,...t.items],thinkingLevel:o.thinkingLevel??t.thinkingLevel},delete s[qe],{...n,slots:s}}case"applyEvent":{const{sessionId:t,id:o,event:s}=r;return we(n,t,i=>so(i,o,s))}}}function so(n,r,t){switch(t.type){case"session.turn":if(t.kind==="start")return{...n,busy:!0,turnStart:Date.now()};if(n.turnStart!==void 0){const o=le(n.items,{type:"turnEnd",startedAt:n.turnStart,endedAt:Date.now()});return{...n,busy:!1,turnStart:void 0,items:o}}return{...n,busy:!1,turnStart:void 0};case"session.message":if(t.kind==="text_delta")return{...n,items:le(n.items,{type:"assistantDelta",id:r,text:t.text})};if(t.kind==="text_done")return{...n,items:le(n.items,{type:"collapseAll"})};if(t.kind==="user_queued"){const o=t.images;return{...n,items:le(n.items,{type:"userMessage",id:r,text:t.text,...o&&o.length>0?{images:o}:{}})}}return t.kind==="error"?{...n,items:le(n.items,{type:"system",id:r,text:`⚠ ${t.text}`})}:n;case"session.thinking":return t.kind==="delta"?{...n,items:le(n.items,{type:"thinkingDelta",id:r,text:t.text})}:{...n,items:le(n.items,{type:"thinkingDone",id:r})};case"session.tool_call":return{...n,items:le(n.items,{type:"toolCallStarted",id:r,toolCallId:t.toolCallId,name:t.name,args:t.args})};case"session.tool_result":return{...n,items:le(n.items,{type:"toolCallFinished",toolCallId:t.toolCallId,result:t.result,isError:t.isError,...t.diff!==void 0?{diff:t.diff}:{},...t.patch!==void 0?{patch:t.patch}:{}})};case"session.queue_update":{const o=t.steering??[],s=new Map;let i=0;for(const c of n.queued)s.set(c.text,c.id),c.id>i&&(i=c.id);let l=i+1;return{...n,queued:o.map(c=>({id:s.get(c)??l++,text:c}))}}case"session.subagent":{const o=t.kind,s=t.agentType?`[${t.agentType}] `:"";let i="";if(o==="created"||o==="started")i=`🧩 子代理 ${s}开始:${t.description??t.agentId??""}`;else if(o==="completed")i=`✅ 子代理 ${s}完成:${(t.result??"").slice(0,500)}`;else if(o==="failed")i=`❌ 子代理 ${s}失败:${t.error??t.result??""}`;else if(o==="steered")i=`📮 子代理 ${s}收到指示:${t.description??""}`;else if(o==="compacted")i=`🧹 子代理 ${s}已压缩上下文`;else return n;return{...n,items:le(n.items,{type:"system",id:r,text:i})}}default:return n}}function io(){const[n,r]=a.useReducer(oo,{activeId:void 0,slots:{}}),t=n.slots[n.activeId??qe]??dt();return{state:n,dispatch:r,active:t}}const Qt=n=>1-Math.pow(1-n,3);function lo(n,r){const t=a.useRef(null),o=a.useRef(!0),s=a.useRef(!1),i=a.useRef(!1),l=a.useRef(0),c=a.useRef(0),[g,u]=a.useState(!1);a.useEffect(()=>{const v=t.current;if(!v)return;const p=()=>{const k=v.scrollHeight-v.scrollTop-v.clientHeight<60;o.current=k,u(!k),i.current||(v.scrollTop<l.current?s.current=!0:k&&(s.current=!1)),l.current=v.scrollTop};return v.addEventListener("scroll",p,{passive:!0}),p(),()=>v.removeEventListener("scroll",p)},[r]),a.useEffect(()=>{c.current=0,s.current=!1;let v=0,p=0;return v=requestAnimationFrame(()=>{S(!1),p=requestAnimationFrame(()=>S(!1))}),()=>{cancelAnimationFrame(v),cancelAnimationFrame(p)}},[r]),a.useEffect(()=>{const v=c.current;c.current=n,n>v&&!s.current&&o.current&&(v===0?requestAnimationFrame(()=>{S(!1),requestAnimationFrame(()=>S(!1))}):S(!1))},[n]);const f=()=>{s.current||o.current&&S(!1)},m=(v=!0)=>{s.current||S(v)},x=(v=!0,p)=>{if(s.current=!1,p!==void 0&&p>0){const k=t.current;if(!k)return;const R=k.scrollTop;i.current=!0;const B=performance.now(),I=_=>{const Y=Math.min(1,(_-B)/p),q=k.scrollHeight-k.clientHeight;k.scrollTop=R+(q-R)*Qt(Y),Y<1?requestAnimationFrame(I):requestAnimationFrame(()=>{i.current=!1})};requestAnimationFrame(I)}else S(v)},h=(v,p=500)=>{const k=t.current;if(!k||v===0)return;const R=k.scrollTop,B=Math.max(0,R+v);i.current=!0;const I=performance.now(),_=Y=>{const q=Math.min(1,(Y-I)/p);k.scrollTop=R+(B-R)*Qt(q),q<1?requestAnimationFrame(_):requestAnimationFrame(()=>{i.current=!1})};requestAnimationFrame(_)},j=()=>{c.current=0},S=v=>{const p=t.current;if(p){i.current=!0,o.current=!0;try{v?p.scrollTo({top:p.scrollHeight,behavior:"smooth"}):p.scrollTop=p.scrollHeight}finally{requestAnimationFrame(()=>{i.current=!1})}}};return{scrollRef:t,nearBottomRef:o,scrollLockedRef:s,lastItemCountRef:c,showBottomBtn:g,followStream:f,scrollToBottom:m,forceScrollToBottom:x,animatedScrollBy:h,resetSnap:j}}function ao(){const[n,r]=a.useState(""),[t,o]=a.useState([]),[s,i]=a.useState([]);return{input:n,setInput:r,attachments:t,fileAttachments:s,attachFiles:u=>{const f=[],m=[];let x=0;for(const h of u)if(h.type.startsWith("image/")){x++;const j=new FileReader;j.addEventListener("load",()=>{f.push({dataUrl:String(j.result),mimeType:h.type,name:h.name}),x-=1,x===0&&(o(S=>[...S,...f]),i(S=>[...S,...m]))}),j.readAsDataURL(h)}else{x++;const j=new FileReader;j.addEventListener("load",()=>{m.push({name:h.name,content:String(j.result)}),x-=1,x===0&&(o(S=>[...S,...f]),i(S=>[...S,...m]))}),j.readAsText(h)}x===0&&(o(h=>[...h,...f]),i(h=>[...h,...m]))},removeAttachment:u=>{const f=t.length;u<f?o(m=>m.filter((x,h)=>h!==u)):i(m=>m.filter((x,h)=>h!==u-f))},submit:u=>{const f=n.trim();if(!f&&t.length===0&&s.length===0)return;r("");const m=t;o([]);const x=s.map(j=>`<file name="${j.name}">
|
|
12
|
-
${j.content}
|
|
13
|
-
</file>`).join(`
|
|
14
|
-
`),h=[f,x].filter(Boolean).join(`
|
|
15
|
-
|
|
16
|
-
`);i([]),u(h,m)}}}class co{constructor({url:r,onOpen:t,onClose:o}){Be(this,"ws");Be(this,"listeners",new Set);Be(this,"onOpen");Be(this,"onClose");Be(this,"pendingFrames",[]);Be(this,"opened",!1);this.onOpen=t,this.onClose=o,this.ws=new WebSocket(r),this.ws.addEventListener("open",()=>{var s;this.opened=!0;for(const i of this.pendingFrames)this.ws.send(JSON.stringify(i));this.pendingFrames.length=0,(s=this.onOpen)==null||s.call(this)}),this.ws.addEventListener("message",s=>{try{const i=JSON.parse(String(s.data));for(const l of this.listeners)l(i)}catch{}}),this.ws.addEventListener("close",s=>{var i;(i=this.onClose)==null||i.call(this,s.code,s.reason)})}send(r){this.opened||this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(r)):this.pendingFrames.push(r)}onFrame(r){return this.listeners.add(r),()=>this.listeners.delete(r)}close(){this.ws.close(),this.listeners.clear()}}const uo=`ws://${location.host}`;function fo(n){const[r,t]=a.useState(null),o=a.useRef(null),s=a.useRef(()=>{}),i=a.useCallback(l=>{s.current=l},[]);return a.useEffect(()=>{const l=n??new co({url:uo,onOpen:()=>{}}),c=new ir(l);t(c),o.current=c;const g=c.onEvent(u=>{s.current(u)});return()=>{g(),l.close()}},[n]),{client:r,registerOnEvent:i,clientRef:o}}function ho(n,r,t,o){const[s,i]=a.useState([]),l=a.useCallback(async j=>{try{const S=await j.request("project.archived",{});Array.isArray(S)&&i(S)}catch{}},[]),c=a.useCallback(j=>{i(S=>S.filter(v=>v.dirKey!==j))},[]),g=a.useCallback(j=>{i(S=>S.map(v=>({...v,sessions:v.sessions.filter(p=>p.path!==j)})).filter(v=>v.sessions.length>0))},[]),u=a.useCallback(async j=>{if(n)try{await n.request("project.archive",{cwd:j}),l(n),r(n)}catch{}},[n,l,r]),f=a.useCallback(async j=>{if(n)try{await n.request("project.unarchive",{dirKey:j}),c(j),l(n),r(n)}catch{}},[n,l,r,c]),m=a.useCallback(async(j,S,v)=>{n&&t(T("彻底删除项目"),T("将永久删除该归档会话文件,不可恢复。"),T("彻底删除"),()=>{(async()=>{var p;try{await n.request("project.delete",{dirKey:j}),i(R=>R.filter(B=>B.dirKey!==j));const k=s.find(R=>R.dirKey===j);v&&k&&((p=S.find(R=>R.path===v))==null?void 0:p.cwd)===k.cwd&&o(v),r(n)}catch{}})()})},[n,t,o,r,s]),x=a.useCallback(async j=>{n&&t(T("删除归档会话"),T("将永久删除该归档会话,不可恢复。"),"删除",()=>{(async()=>{try{await n.request("session.deleteArchived",{sessionFile:j}),i(S=>S.map(v=>({...v,sessions:v.sessions.filter(p=>p.path!==j)})).filter(v=>v.sessions.length>0)),l(n)}catch{}})()})},[n,t,l]),h=a.useCallback(()=>{n&&t(T("清空全部归档"),T("将永久删除全部 {n} 个归档项目的会话文件,不可恢复。",{n:s.length}),T("全部删除"),()=>{(async()=>{try{await Promise.allSettled(s.map(j=>n.request("project.delete",{dirKey:j.dirKey}))),i([]),l(n)}catch{}})()})},[n,t,s,l]);return{archivedProjects:s,syncArchived:l,archiveProject:u,unarchiveProject:f,deleteProject:m,deleteArchivedSession:x,removeArchivedProject:c,removeArchivedSession:g,clearAllArchived:h}}function po({items:n,scrollRef:r,activeId:t}){const o=K(),s=a.useMemo(()=>{const f=[];let m=0,x="";for(const h of n)h.kind==="user"?(f.push({msgIndex:m,question:h.text,answer:""}),x="",m++):h.kind==="assistant"&&(x=h.text,f.length>0&&(f[f.length-1].answer=x));return f},[n]),[i,l]=a.useState(null),[c,g]=a.useState(-1),u=a.useRef(null);return a.useEffect(()=>{const f=u.current;f&&(f.scrollTop=f.scrollHeight)},[t]),s.length===0?null:e.jsxs("div",{ref:u,className:"vagus-nav-scroll",style:{position:"absolute",left:6,top:"50%",transform:"translateY(-50%)",width:24,maxHeight:300,overflowY:"auto",pointerEvents:"auto",zIndex:5,display:"flex",flexDirection:"column",padding:"2px 0"},children:[s.map(({msgIndex:f,question:m,answer:x},h)=>{const j=c===-1?99:Math.abs(h-c),S=j===0?26:j===1?19:13,v=j===0?"#6366f1":j===1?"rgba(99,102,241,0.55)":o.color.border;return e.jsx("div",{onMouseDown:p=>p.preventDefault(),onMouseEnter:p=>{g(h),l({index:f,question:m,answer:x,x:p.clientX,y:p.clientY})},onMouseLeave:()=>{g(-1),l(null)},onClick:p=>{var B;p.preventDefault(),p.stopPropagation();const k=document.activeElement;k instanceof HTMLElement&&k.blur();const R=(B=r.current)==null?void 0:B.querySelector(`[data-msg-index="${f}"]`);R&&R.scrollIntoView({behavior:"smooth",block:"start"})},style:{height:15,flexShrink:0,display:"flex",alignItems:"center",cursor:"pointer",pointerEvents:"auto"},children:e.jsx("div",{style:{width:S,height:3,borderRadius:2,background:v,transition:"width 0.15s, background 0.15s",flexShrink:0}})},f)}),i&&rn.createPortal(e.jsxs("div",{style:{position:"fixed",left:i.x+18,top:Math.max(8,Math.min(i.y-12,window.innerHeight-80)),zIndex:1e3,pointerEvents:"none",background:o.color.surface,border:`1px solid ${o.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:"0.78em",color:o.color.fg,maxWidth:300,lineHeight:1.5,boxShadow:"0 8px 24px rgba(0,0,0,0.15)"},children:[e.jsx("div",{style:{wordBreak:"break-word"},children:i.question.length>60?`${i.question.slice(0,60)}…`:i.question||"(空消息)"}),e.jsx("div",{style:{marginTop:6,color:o.color.muted,wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:i.answer.replace(/\s+/g," ")||"(暂无回答)"})]}),document.body)]})}function gn(n){const r=K(),{theme:t}=Ze(),[o,s]=a.useState(!1),i=n.variant==="welcome",l=t==="light"?"#ffffff":r.color.surface;return e.jsx("div",{className:"vagus-input-card",style:{background:l,border:`1px solid ${i&&o?"rgba(99,102,241,0.55)":r.color.border}`,borderRadius:i?22:18,boxShadow:i?o?"0 8px 40px rgba(99,102,241,0.12), 0 0 0 4px rgba(99,102,241,0.08)":"0 6px 28px rgba(0,0,0,0.05)":void 0,transition:"border-color 0.2s ease, box-shadow 0.2s ease",animation:i&&!o?"vagus-breath 3s ease-in-out infinite":void 0,display:"flex",flexDirection:"column",padding:i?"20px 24px 14px":"14px 18px 10px"},onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseDown:c=>{c.target.closest("button, input, textarea, select, [contenteditable], [role='button']")||c.preventDefault()},children:e.jsx(br,{value:n.value,onChange:n.onChange,onSubmit:n.onSubmit,usage:n.usage,providers:n.providers,onSwitchModel:n.onSwitchModel,onSetThinking:n.onSetThinking,thinkingLevel:n.thinkingLevel,permissionMode:n.permissionMode,onTogglePermission:n.onTogglePermission,attachments:n.attachments,fileAttachments:n.fileAttachments,onAttach:n.onAttach,onRemoveAttachment:n.onRemoveAttachment,busy:n.busy,onStop:n.onStop,selectedModel:n.selectedModel,onCommand:n.onCommand,commands:n.commands,onPickCommand:n.onPickCommand,onRefreshCommands:n.onRefreshCommands,focusSignal:n.focusSignal,hasPendingDialog:n.hasPendingDialog,onRestoreDialog:n.onRestoreDialog,queuedMessages:n.queuedMessages})})}const go={confirm:"确认",select:"请选择",input:"输入"};function Zt({card:n,onRespond:r}){var f;const t=K(),{event:o}=n,[s,i]=a.useState(""),l=a.useRef(null);a.useEffect(()=>{var m;o.method==="input"&&n.status==="pending"&&((m=l.current)==null||m.focus())},[o.method,n.status]);const c=n.result?n.result.cancelled?"已取消":n.result.confirmed?"已确认":n.result.value??"":"",g=n.status==="answered",u={height:34,padding:"0 14px",borderRadius:9,fontSize:"0.9em",cursor:g?"default":"pointer",fontFamily:"inherit"};return e.jsxs("div",{style:{maxWidth:520,margin:"10px 0 6px",background:g?t.color.bg:t.color.surface,border:`1px solid ${g?t.color.border:t.color.primary}`,borderRadius:14,padding:"14px 16px",boxShadow:g?"none":"0 2px 12px rgba(0,0,0,0.12)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:g?8:10},children:[e.jsx("span",{style:{fontSize:"0.72em",fontWeight:700,letterSpacing:"0.04em",padding:"2px 8px",borderRadius:999,background:g?"transparent":t.color.primary,color:g?t.color.muted:"#fff",border:g?`1px solid ${t.color.border}`:"none"},children:o.method.toUpperCase()}),e.jsx("span",{style:{fontSize:"0.95em",fontWeight:600,color:t.color.fg},children:o.title??go[o.method]??o.method})]}),o.message&&e.jsx("div",{style:{fontSize:"0.92em",color:t.color.fg,lineHeight:1.6,whiteSpace:"pre-wrap",marginBottom:g?0:12},children:o.message}),g?e.jsxs("div",{style:{fontSize:"0.88em",color:t.color.muted,background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:8,padding:"6px 10px",display:"inline-block"},children:["你的回答:",c||"—"]}):o.method==="select"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,maxHeight:300,overflowY:"auto",marginBottom:4},children:[(o.options??[]).map(m=>e.jsx("button",{onClick:()=>r({value:m}),style:{...u,width:"100%",textAlign:"left",height:38,padding:"0 14px",border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg},onMouseEnter:x=>{x.currentTarget.style.background=t.color.bg},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:m},m)),((f=o.options)==null?void 0:f.length)===0&&e.jsx("div",{style:{fontSize:"0.86em",color:t.color.muted,padding:"12px 4px"},children:T("(没有可用选项)")})]}):o.method==="input"?e.jsx("div",{style:{marginBottom:4},children:e.jsx("input",{ref:l,value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&r({value:s})},placeholder:o.placeholder??"输入…",style:{width:"100%",height:38,padding:"0 12px",borderRadius:9,border:`1px solid ${t.color.border}`,background:t.color.bg,color:t.color.fg,fontSize:"0.92em",outline:"none",fontFamily:"inherit"}})}):null,!g&&e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:6},children:[e.jsx("button",{onClick:()=>r({cancelled:!0}),style:{...u,border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg},children:T("取消")}),o.method==="confirm"&&e.jsx("button",{onClick:()=>r({confirmed:!0}),style:{...u,border:"none",background:t.color.primary,color:"#fff",fontWeight:600},children:T("确认")}),o.method==="input"&&e.jsx("button",{onClick:()=>r({value:s}),disabled:s.trim().length===0,style:{...u,border:"none",background:t.color.primary,color:"#fff",fontWeight:600,opacity:s.trim().length===0?.4:1,cursor:s.trim().length===0?"not-allowed":"pointer"},children:T("确定")})]})]})}function xo(n){const r=K(),{items:t,busy:o,turnStartTs:s,autoscroll:i}=n,{scrollRef:l,showBottomBtn:c}=i,g=n.uiCards??[],u=g.filter(v=>v.status==="pending").map(v=>v.event.id).join(","),[f,m]=a.useState("");a.useEffect(()=>{if(u.length>0&&u!==f){m(u);const v=l.current;if(!v)return;const p=v.querySelectorAll('[data-uicard-status="pending"]'),k=p[p.length-1];if(!k)return;const R=v.getBoundingClientRect(),B=k.getBoundingClientRect(),I=B.bottom-R.bottom;if(I<=0&&B.top>=R.top)return;const _=72,Y=I>0?I+_:B.top-R.top-_;i.animatedScrollBy(Y,750)}},[u,i]),a.useEffect(()=>{const v=l.current,p=n.onLoadMore;if(!v||!p)return;const k=()=>{v.scrollTop<200&&!n.loadingMore&&p()};return v.addEventListener("scroll",k,{passive:!0}),()=>v.removeEventListener("scroll",k)});const x=a.useRef(0),h=a.useRef(0);a.useLayoutEffect(()=>{const v=l.current;if(!v)return;const p=x.current,k=t.length>h.current;if(h.current=t.length,k&&p>0&&v.scrollTop<400){const R=v.scrollHeight-p;R>300&&(v.scrollTop+=R)}x.current=v.scrollHeight});const j=a.useMemo(()=>hn(qr(t)),[t]),S=a.useMemo(()=>{const v=new Map,p=new Map;let k=0,R=-1,B=-1;for(let q=0;q<j.length;q++){const M=j[q];if(M.kind==="item"&&M.item.kind==="user"){k++;continue}if(M.kind==="work"){R=q,p.has(k)||p.set(k,q);for(const z of M.work)z.kind==="tool"&&z.toolCallId&&v.set(z.toolCallId,q);M.work.some(z=>z.kind==="tool")&&(B=q)}}const I=new Map,_=new Set;for(const q of g){const M=q.event;let z=M.toolCallId?v.get(M.toolCallId):void 0;if(z===void 0&&(z=M.turn===void 0?void 0:p.get(M.turn)),z===void 0&&(z=B>=0?B:R>=0?R:void 0),z!==void 0){const H=I.get(z)??[];H.push(q),I.set(z,H),_.add(q.event.id)}}const Y=g.filter(q=>!_.has(q.event.id));return{byIdx:I,unmatched:Y}},[j,g]);return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,position:"relative"},children:[e.jsxs("header",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:10,height:54,padding:"0 24px",background:r.color.bg,borderBottom:`1px solid ${r.color.border}`},children:[n.sessionName?e.jsx("span",{style:{fontSize:"0.92em",fontWeight:600,color:r.color.fg,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"38%"},children:n.sessionName}):null,n.sessionName&&n.sessionCwd?e.jsx("span",{style:{color:r.color.border,flexShrink:0,fontSize:"0.85em"},children:"|"}):null,n.sessionCwd?e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,color:r.color.muted,fontSize:"0.85em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",style:{flexShrink:0},children:[e.jsx("path",{d:"M7 3h7l5 5v13H7z",strokeLinejoin:"round"}),e.jsx("path",{d:"M14 3v5h5",strokeLinejoin:"round"})]}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.sessionCwd})]}):null]}),e.jsx("main",{ref:l,style:{flex:1,overflowY:"auto",minHeight:0,padding:"28px 0"},children:e.jsxs("div",{style:{maxWidth:n.wide?1280:1050,margin:"0 auto",padding:"0 28px",display:"flex",flexDirection:"column",gap:6},children:[n.loadingMore&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"center",padding:"10px 0",color:r.color.muted,fontSize:"0.82em"},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",border:`2px solid ${r.color.border}`,borderTopColor:r.color.primary,animation:"vagus-spin 0.8s linear infinite",display:"inline-block"}}),T("加载更早消息…")]}),t.length===0&&(n.showLoading?e.jsx("div",{style:{color:r.color.muted,fontSize:"1em",textAlign:"center",marginTop:40},children:T("加载会话…")}):n.sessionLoading?null:e.jsx("div",{style:{color:r.color.muted,fontSize:"1em",textAlign:"center",marginTop:40},children:T("已连接 · 输入消息开始新会话")})),(()=>{var q;let v=-1;for(let M=t.length-1;M>=0;M--)if(t[M].kind==="user"){v=M;break}let p;for(let M=t.length-1;M>v;M--){const z=t[M];if(z.kind==="thinking"||z.kind==="tool"){p=z;break}}const k=o&&p!==void 0?j.find(M=>M.kind==="work"&&M.work.some(z=>z.id===(p==null?void 0:p.id))):void 0,R=[];let B=0,I=0;const _={contentVisibility:"auto",containIntrinsicSize:"auto 120px"},Y=new Set;{let M;for(const z of j)z.kind==="item"?z.item.kind==="assistant"?M=z.item.id:z.item.kind==="user"&&M!==void 0&&(Y.add(M),M=void 0):(z.kind==="work"||z.kind==="turnSummary")&&(M!==void 0&&Y.add(M),M=void 0);M!==void 0&&Y.add(M)}for(const M of j){if(M.kind==="item"){const z=M.item;z.kind==="user"?R.push(e.jsx("div",{"data-msg-index":I++,style:{maxWidth:"100%",..._},children:e.jsx(St,{item:z,onToggleCard:n.onToggleCard,onCopy:n.copyMessage,onEditSubmit:n.editSubmit,onFork:n.onFork})},`g${B}`)):R.push(e.jsx("div",{style:_,children:e.jsx(St,{item:z,onToggleCard:n.onToggleCard,onCopy:n.copyMessage,onEditSubmit:n.editSubmit,onFork:n.onFork,showCopy:z.kind==="assistant"&&Y.has(z.id)&&!o})},`g${B}`))}else if(M.kind==="turnSummary")R.push(e.jsx("div",{style:_,children:e.jsx(ro,{files:M.files,onOpenFile:n.onOpenFile,onRevertAll:()=>n.onRevertAll(M.files.map(z=>z.file)),onExpand:z=>{z&&n.autoscroll.forceScrollToBottom(!0,400)}})},`t${B}`));else{const{work:z}=M,H=((q=z[0])==null?void 0:q.id)??B,oe=M===k,G=S.byIdx.get(B)??[],te=G.length>0?G.map((N,b)=>e.jsx("div",{"data-uicard-id":N.event.id,"data-uicard-status":N.status,children:e.jsx(Zt,{card:N,onRespond:W=>{var P;return(P=n.onUiCardRespond)==null?void 0:P.call(n,N,W)}})},`uicardwrap-${N.event.id??b}`)):void 0;let ne=-1;if(G.length>0){for(let N=M.work.length-1;N>=0;N--)if(M.work[N].kind==="tool"){ne=N;break}}R.push(e.jsx("div",{style:_,children:e.jsx(Xr,{work:z,onToggleItem:N=>n.onToggleCard(N),live:oe,startMs:s,attached:te,attachedAnchor:ne>=0?ne:void 0})},`w${H}`))}B++}return e.jsx(e.Fragment,{children:R})})(),S.unmatched.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:S.unmatched.map((v,p)=>e.jsx("div",{"data-uicard-id":v.event.id,"data-uicard-status":v.status,children:e.jsx(Zt,{card:v,onRespond:k=>{var R;return(R=n.onUiCardRespond)==null?void 0:R.call(n,v,k)}})},`uicardwrap-${v.event.id??p}`))}),o&&t.length>0&&t[t.length-1].kind==="user"&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 0",color:r.color.muted,fontSize:"0.88em"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"linear-gradient(135deg,#6366f1,#8b5cf6)",animation:"vagus-pulse 1.2s ease-in-out infinite",display:"inline-block"}}),T("等待响应…")]}),e.jsx("div",{})]})}),e.jsx(po,{items:t,scrollRef:l,activeId:n.activeId}),c&&e.jsx("button",{onClick:()=>i.forceScrollToBottom(),title:T("回到底部"),style:{position:"absolute",right:18,bottom:96,zIndex:6,width:36,height:36,borderRadius:"50%",background:r.color.surface,border:`1px solid ${r.color.border}`,color:r.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",transition:"background 0.15s, color 0.15s",fontFamily:"inherit"},onMouseEnter:v=>{v.currentTarget.style.background=r.color.sidebarHover,v.currentTarget.style.color=r.color.fg},onMouseLeave:v=>{v.currentTarget.style.background=r.color.surface,v.currentTarget.style.color=r.color.muted},children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})}),e.jsx("div",{style:{padding:"10px 28px 10px",background:r.color.bg,flexShrink:0},children:e.jsxs("div",{style:{maxWidth:n.wide?1180:960,margin:"0 auto"},children:[(()=>{const v=Object.entries(n.aboveEditorStatuses??{}).filter(([,k])=>k.length>0),p=Object.entries(n.aboveEditorWidgets??{}).filter(([,k])=>k.lines.length>0);return v.length===0&&p.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[v.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"},children:v.map(([k,R])=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:999,background:r.color.surface,border:`1px solid ${r.color.border}`,fontSize:"0.8em",color:r.color.fg},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:r.color.primary}}),e.jsx("span",{style:{color:r.color.muted,fontWeight:600},children:k}),e.jsx("span",{children:R})]},k))}),p.map(([k,R])=>e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 10px",fontSize:"0.8em",color:r.color.muted,alignItems:"center"},children:R.lines.map((B,I)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:B},I))},k))]})})(),e.jsx(gn,{...n.inputCard,variant:"chat"})]})})]})}function mo(n){const r=K();return e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,justifyContent:"center"},children:e.jsxs("div",{style:{width:"100%",maxWidth:n.wide?900:760,margin:"0 auto",padding:"32px 28px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:22,userSelect:"none"},children:[e.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"linear-gradient(135deg,#6366f1,#8b5cf6)",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:21,fontWeight:700,boxShadow:"0 6px 24px rgba(99,102,241,0.35)"},children:"◈"}),e.jsx("div",{style:{fontSize:"1.4em",fontWeight:700,color:r.color.fg,marginTop:12,letterSpacing:"-0.01em"},children:"vagusPI"}),e.jsx("div",{style:{fontSize:"0.92em",color:r.color.muted,marginTop:5},children:T("你的编码智能体工作台 —— 发送第一条消息开始新的对话")})]}),e.jsx(vr,{projects:n.projects,value:n.activeProject,onChange:n.onSelectProject,onNewProject:n.onNewProject}),e.jsxs("div",{style:{marginTop:10},children:[(()=>{const t=Object.entries(n.aboveEditorStatuses??{}).filter(([,s])=>s.length>0),o=Object.entries(n.aboveEditorWidgets??{}).filter(([,s])=>s.lines.length>0);return t.length===0&&o.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[t.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"},children:t.map(([s,i])=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:999,background:r.color.surface,border:`1px solid ${r.color.border}`,fontSize:"0.8em",color:r.color.fg},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:r.color.primary}}),e.jsx("span",{style:{color:r.color.muted,fontWeight:600},children:s}),e.jsx("span",{children:i})]},s))}),o.map(([s,i])=>e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 10px",fontSize:"0.8em",color:r.color.muted,alignItems:"center",justifyContent:"center"},children:i.lines.map((l,c)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:l},c))},s))]})})(),e.jsx(gn,{...n.inputCard,variant:"welcome"})]})]})})}function yo({state:n,onClose:r}){const t=K();return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:o=>{o.target===o.currentTarget&&r()},children:e.jsxs("div",{style:{width:380,maxWidth:"calc(100vw - 48px)",background:t.color.surface,border:`1px solid ${t.color.border}`,borderRadius:16,padding:"20px 22px",boxShadow:"0 24px 80px rgba(0,0,0,0.35)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,fontSize:"1.02em",fontWeight:600,color:"#E5484D"},children:[e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"})}),n.title]}),e.jsx("div",{style:{fontSize:"0.92em",color:t.color.muted,margin:"12px 0 22px",lineHeight:1.6},children:n.message}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:r,style:{height:34,padding:"0 16px",borderRadius:9,border:`1px solid ${t.color.border}`,background:"transparent",color:t.color.fg,fontSize:"0.9em",cursor:"pointer",fontFamily:"inherit"},children:T("取消")}),e.jsx("button",{onClick:()=>{const o=n.onConfirm;r(),o()},style:{height:34,padding:"0 16px",borderRadius:9,border:"none",background:"#E5484D",color:"#fff",fontSize:"0.9em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",boxShadow:"0 2px 10px rgba(229,72,77,0.35)"},children:n.confirmLabel})]})]})})}function bo(n){const r=K(),{tabs:t,activeId:o,collapsed:s,onActivate:i,onClose:l,onToggleCollapse:c,render:g,width:u=380,onWidthChange:f}=n,m=14,[x,h]=a.useState(!1),j=a.useRef(null),S=p=>{if(s)return;p.preventDefault(),j.current={startX:p.clientX,startW:u},h(!0);const k=B=>{if(!j.current)return;const I=j.current.startX-B.clientX,_=Math.min(900,Math.max(260,j.current.startW+I));f==null||f(_)},R=()=>{j.current=null,h(!1),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",R)},v=t.find(p=>p.id===o)??t[0]??null;return e.jsx("aside",{style:{width:s?m:u,flexShrink:0,minWidth:0,borderLeft:`1px solid ${r.color.border}`,background:r.color.bg,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",transition:"width 0.3s cubic-bezier(0.25, 1, 0.5, 1)"},children:s?e.jsx("div",{onClick:c,title:T("展开右侧面板"),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",background:r.color.surface,color:"#6366f1",transition:"background 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.1)"},onMouseLeave:p=>{p.currentTarget.style.background=r.color.surface},children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}):e.jsxs("div",{style:{flex:1,display:"flex",minHeight:0},children:[e.jsx("div",{onMouseDown:S,title:T("拖动调整宽度"),style:{width:4,flexShrink:0,cursor:"col-resize",background:x?"rgba(99,102,241,0.25)":"transparent",transition:"background 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.15)"},onMouseLeave:p=>{p.currentTarget.style.background=x?"rgba(99,102,241,0.25)":"transparent"}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,padding:"0 6px",background:r.color.bg,borderBottom:`1px solid ${r.color.border}`,flexShrink:0,height:54,overflowX:"auto",scrollbarWidth:"none"},children:[t.map(p=>{const k=v!==null&&p.id===v.id;return e.jsxs("div",{onClick:()=>i(p.id),style:{display:"flex",alignItems:"center",gap:6,height:36,padding:"0 14px 0 20px",borderRadius:9,background:k?r.color.surface:"transparent",cursor:"pointer",userSelect:"none",flexShrink:0,maxWidth:220,transition:"background 0.15s"},onMouseEnter:R=>{k||(R.currentTarget.style.background=r.color.surface)},onMouseLeave:R=>{k||(R.currentTarget.style.background="transparent")},children:[p.icon,e.jsx("span",{style:{fontSize:"0.9em",fontWeight:k?600:500,color:k?r.color.fg:r.color.muted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.label}),e.jsx("button",{onClick:R=>{R.stopPropagation(),l(p.id)},title:`关闭 ${p.label}`,style:{width:17,height:17,borderRadius:5,border:"none",background:"transparent",color:r.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,fontFamily:"inherit",opacity:k?.85:.45,transition:"background 0.15s, color 0.15s, opacity 0.15s"},onMouseEnter:R=>{R.currentTarget.style.background=r.color.sidebarHover,R.currentTarget.style.color=r.color.fg,R.currentTarget.style.opacity="1"},onMouseLeave:R=>{R.currentTarget.style.background="transparent",R.currentTarget.style.color=r.color.muted,R.currentTarget.style.opacity=k?"0.8":"0.4"},children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]},p.id)}),e.jsx("div",{style:{flex:1}})]}),e.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden",background:r.color.bg},children:v?g(v):e.jsx("div",{style:{height:"100%"}})})]}),e.jsx("div",{onClick:c,title:T("收起右侧面板"),style:{width:14,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:r.color.surface,borderLeft:`1px solid ${r.color.border}`,cursor:"pointer",userSelect:"none",color:r.color.muted,transition:"background 0.15s, color 0.15s"},onMouseEnter:p=>{p.currentTarget.style.background="rgba(99,102,241,0.12)",p.currentTarget.style.color="#6366f1"},onMouseLeave:p=>{p.currentTarget.style.background=r.color.surface,p.currentTarget.style.color=r.color.muted},children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})})]})})}const en={id:"diff",label:"审阅",icon:e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 12l3 3 3-6 4 9 3-5 2 2"})})};function vo({items:n,selected:r,turnId:t,expandedFiles:o,onOpenChange:s}){const i=K(),l=a.useMemo(()=>{if(!t)return[];const x=hn(n);for(let h=x.length-1;h>=0;h--){const j=x[h];if(j.kind==="turnSummary"&&j.files.some(S=>S.turnToolCallId===t))return j.files}return[]},[t,n]),[c,g]=a.useState(()=>{const x=new Set;if(o!==void 0)for(const h of o)l.some(j=>De(j.file)===De(h))&&x.add(h);else l.length>0&&x.add(l[0].file);return x}),u=x=>[...c].some(h=>De(h)===De(x)),f=x=>{const h=new Set(c);u(x)?h.delete([...h].find(j=>De(j)===De(x))):h.add(x),g(h),s==null||s(h.size>0?[...h]:void 0)},m=e.jsx("div",{style:{height:"100%"}});return l.length===0?m:e.jsx("div",{style:{display:"flex",flexDirection:"column",padding:"6px 0"},children:l.map((x,h)=>{const j=x.file.lastIndexOf("/"),S=j>=0?x.file.slice(0,j+1):"",v=j>=0?x.file.slice(j+1):x.file,p=u(x.file),k=ko(x.diff??"");return e.jsxs("div",{style:{borderBottom:h<l.length-1?`1px solid ${i.color.border}20`:"none"},children:[e.jsxs("div",{onClick:()=>f(x.file),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",cursor:"pointer",userSelect:"none",background:h%2===1?i.color.surface:"transparent"},onMouseEnter:R=>{R.currentTarget.style.background=i.color.sidebarHover},onMouseLeave:R=>{R.currentTarget.style.background=h%2===1?i.color.surface:"transparent"},children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:i.color.success,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:"transform 0.15s",transform:p?"rotate(90deg)":"none"},children:e.jsx("path",{d:"M9 18l6-6-6-6"})}),e.jsxs("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.8em"},children:[e.jsx("span",{style:{color:i.color.muted},children:S}),e.jsx("span",{style:{color:i.color.fg,fontWeight:700},children:v})]}),e.jsxs("span",{style:{color:i.color.success,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["+",k.added]}),e.jsxs("span",{style:{color:i.color.error,fontSize:"0.75em",fontWeight:600,flexShrink:0},children:["-",k.removed]})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:p?"1fr":"0fr",transition:"grid-template-rows 0.22s ease"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{padding:"2px 8px 8px",background:i.color.bg},children:x.diff?e.jsx(pn,{diff:x.diff,t:i}):e.jsx("div",{style:{color:i.color.muted,fontSize:"0.78em",padding:6},children:T("该轮无 diff")})})})})]},x.file)})})}function ko(n){let r=0,t=0;for(const o of n.split(`
|
|
17
|
-
`))o.startsWith("+")&&!o.startsWith("+++")?r+=1:o.startsWith("-")&&!o.startsWith("---")&&(t+=1);return{added:r,removed:t}}const jo={id:"widget",label:"面板",icon:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18M3 12h18"})]})};function wo({widgets:n}){const r=K(),t=Object.entries(n).filter(([,o])=>o.lines.length>0);return t.length===0?e.jsx("div",{style:{padding:"16px 18px",fontSize:"0.86em",color:r.color.muted},children:T("(没有活动的面板)")}):e.jsx("div",{style:{padding:"10px 14px",display:"flex",flexDirection:"column",gap:10,fontFamily:r.font.mono,fontSize:"0.82em",lineHeight:1.6,color:r.color.fg},children:t.map(([o,s])=>e.jsx("div",{style:{background:r.color.bg,border:`1px solid ${r.color.border}`,borderRadius:10,padding:"8px 10px"},children:s.lines.map((i,l)=>e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i},l))},o))})}const bt="cubic-bezier(0.25, 1, 0.5, 1)";function So({state:n}){const r=K(),t=n==="ok"?r.color.success:n==="partial"?r.color.warning:r.color.error,o=n==="ok"?["M20 6L9 17l-5-5"]:n==="partial"?["M12 9v4","M12 17h.01","M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"]:["M18 6L6 18","M6 6l12 12"];return e.jsx("div",{style:{width:44,height:44,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:`${t}1f`,color:t},children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:o.map(s=>e.jsx("path",{d:s},s))})})}function Io({result:n}){const r=K(),t=n.file.lastIndexOf("/"),o=t>=0?n.file.slice(0,t+1):"",s=t>=0?n.file.slice(t+1):n.file;return e.jsxs("div",{style:{padding:"7px 10px",borderRadius:8,background:n.ok?"transparent":`${r.color.error}0d`,fontFamily:"inherit"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.82em"},children:[e.jsx("span",{style:{color:r.color.muted},children:o}),e.jsx("span",{style:{color:r.color.fg,fontWeight:500},children:s})]}),n.ok?e.jsx("span",{style:{flexShrink:0,color:r.color.success,fontSize:"0.72em",fontWeight:600,whiteSpace:"nowrap"},children:T("✓ 已回退")}):e.jsx("span",{style:{flexShrink:0,color:r.color.error,fontSize:"0.72em",fontWeight:600,whiteSpace:"nowrap"},children:T("✗ 回退失败")})]}),!n.ok&&n.error&&e.jsx("div",{style:{marginTop:4,color:r.color.error,fontSize:"0.7em",lineHeight:1.5,whiteSpace:"normal",wordBreak:"break-word"},children:n.error})]})}function Co({report:n,onClose:r}){const t=K(),[o,s]=a.useState(!1),i=n.results.filter(h=>h.ok).length,l=n.results.length-i,c=l===0?"ok":i===0?"fail":"partial",g=new Map;for(const h of n.results){const j=g.get(h.file);g.set(h.file,{ok:((j==null?void 0:j.ok)??!0)&&h.ok,error:h.ok?j==null?void 0:j.error:h.error??(j==null?void 0:j.error)})}const u=[...g.entries()].map(([h,j])=>({file:h,...j}));a.useEffect(()=>{const h=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(h)},[]),a.useEffect(()=>{const h=j=>{j.key==="Escape"&&r()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[r]);const f=c==="ok"?t.color.success:c==="partial"?t.color.warning:t.color.error,m=c==="ok"?`已回退 ${i} 个文件`:c==="partial"?"回退部分失败":"回退失败",x=c==="ok"?"所有改动已还原到编辑前状态":c==="partial"?`成功 ${i} 个 · 失败 ${l} 个`:l===1?"1 个文件未还原":`${l} 个文件未还原`;return e.jsx("div",{onClick:r,style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.45)",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",opacity:o?1:0,transition:`opacity 0.25s ${bt}`,fontFamily:t.font.sans},children:e.jsxs("div",{onClick:h=>h.stopPropagation(),style:{width:500,maxWidth:"calc(100vw - 40px)",background:t.color.surface,border:`1px solid ${t.color.border}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.45)",padding:"20px 22px 18px",opacity:o?1:0,transform:o?"none":"translateY(10px) scale(0.97)",transition:`opacity 0.3s ${bt}, transform 0.3s ${bt}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx(So,{state:c}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.color.fg,fontSize:"1.02em",fontWeight:700},children:m}),e.jsx("button",{onClick:r,"aria-label":T("关闭"),style:{marginLeft:"auto",width:26,height:26,borderRadius:7,border:"none",background:"transparent",color:t.color.muted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit",flexShrink:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:h=>{h.currentTarget.style.background=t.color.bg,h.currentTarget.style.color=t.color.fg},onMouseLeave:h=>{h.currentTarget.style.background="transparent",h.currentTarget.style.color=t.color.muted},children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]}),e.jsx("div",{style:{color:t.color.muted,fontSize:"0.82em",marginTop:2},children:x}),e.jsx("div",{style:{height:2,background:`linear-gradient(90deg, ${f}, transparent)`,borderRadius:2,marginTop:10,opacity:.5}})]})]}),u.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2,marginTop:14,maxHeight:240,overflowY:"auto"},children:u.map(h=>e.jsx(Io,{result:h},h.file))}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:18},children:e.jsx("button",{onClick:r,style:{height:32,padding:"0 18px",borderRadius:8,border:"none",background:`linear-gradient(135deg, ${t.color.primary}, #6366f1)`,color:"#fff",fontSize:"0.84em",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"filter 0.15s"},onMouseEnter:h=>{h.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:h=>{h.currentTarget.style.filter="none"},children:T("关闭")})})]})})}function Mo(n){const{activeId:r,hasEdits:t}=n,[o,s]=a.useState([]),[i,l]=a.useState(void 0),[c,g]=a.useState(!1),[u,f]=a.useState(420),[m,x]=a.useState(new Set),[h,j]=a.useState(void 0),[S,v]=a.useState(void 0),[p,k]=a.useState(void 0),[R,B]=a.useState(!1),I="vagus.rightPanel.v1",_="vagus.rightPanel.review.v1",Y=b=>{try{const W=localStorage.getItem(_),F=(W?JSON.parse(W):{})[b];return{turnId:F==null?void 0:F.turnId,selected:F==null?void 0:F.selected,open:F==null?void 0:F.open}}catch{return{}}},q=(b,W,P,F)=>{try{const se=localStorage.getItem(_),X=se?JSON.parse(se):{};X[b]={turnId:W,selected:P,open:F},localStorage.setItem(_,JSON.stringify(X))}catch{}},M=b=>{try{const W=localStorage.getItem(I),F=(W?JSON.parse(W):{})[b];return{collapsed:(F==null?void 0:F.collapsed)===!0,width:(F==null?void 0:F.width)??420,activeTab:F==null?void 0:F.activeTab,diffClosed:(F==null?void 0:F.diffClosed)===!0,has:F!==void 0}}catch{return{collapsed:!0,width:420,has:!1}}},z=(b,W)=>{try{const P=localStorage.getItem(I),F=P?JSON.parse(P):{};F[b]=W,localStorage.setItem(I,JSON.stringify(F))}catch{}},H="vagus.rightPanel.handled.v2",oe=b=>{try{const W=localStorage.getItem(H),P=W?JSON.parse(W):{};return new Set(Array.isArray(P[b])?P[b]:[])}catch{return new Set}},G=(b,W)=>{try{const P=localStorage.getItem(H),F=P?JSON.parse(P):{};F[b]=[...W],localStorage.setItem(H,JSON.stringify(F))}catch{}};a.useLayoutEffect(()=>{if(!r)return;const b=M(r);f(b.width),g(b.has?b.collapsed:!0),b.activeTab!==void 0&&l(b.activeTab),B(b.diffClosed===!0);const W=Y(r);v(W.turnId||void 0),k(Array.isArray(W.open)?W.open:void 0),W.selected&&j(W.selected),x(oe(r))},[r]),a.useEffect(()=>{r&&z(r,{collapsed:c,width:u,activeTab:i,diffClosed:R})},[c,u,i,R,r]),a.useEffect(()=>{r&&G(r,m)},[m,r]),a.useEffect(()=>{t?R||(s(b=>b.some(W=>W.id==="diff")?b:[...b,en]),l(b=>b??"diff")):(s(b=>b.some(W=>W.id==="diff")?b.filter(W=>W.id!=="diff"):b),l(b=>b==="diff"?void 0:b))},[t,R]);const te=a.useCallback((b,W)=>{var F;B(!1),j(b);const P=(F=W==null?void 0:W[0])==null?void 0:F.turnToolCallId;v(P),k([b]),r&&q(r,P,b,[b]),g(!1),s(se=>se.some(X=>X.id==="diff")?se:[...se,en]),l("diff")},[r]),ne=a.useCallback(b=>{b==="diff"&&B(!0),s(W=>W.filter(P=>P.id!==b)),l(W=>W===b?void 0:W)},[]),N=a.useCallback(b=>{k(b),r&&S&&q(r,S,h??(b==null?void 0:b[0])??"",b??[])},[r,S,h]);return{rightTabs:o,rightTabId:i,rightCollapsed:c,rightPanelWidth:u,handledFiles:m,diffSelection:h,reviewTurnId:S,reviewOpen:p,setRightTabs:s,setRightTabId:l,setRightCollapsed:g,setRightPanelWidth:f,setHandledFiles:x,setDiffSelection:j,setReviewOpen:N,openFileDiff:te,closeRightTab:ne}}function To(n){const{client:r,registerOnEvent:t,dispatch:o,nextId:s,activeId:i,autoscroll:l,followAnswerRef:c,effects:g}=n,u=()=>{c!=null&&c.current&&(c.current=!1,l.scrollToBottom(!0))},f=a.useRef({sessionId:"",text:"",raf:null}),m=()=>{const S=f.current;if(!S.text)return;const v=S.text,p=S.sessionId;S.text="",S.raf=null,o({type:"applyEvent",sessionId:p,id:s(),event:{type:"session.message",sessionId:p,kind:"text_delta",text:v}}),u(),l.followStream()},x=(S,v)=>{const p=f.current;p.sessionId!==S&&(p.raf!==null&&cancelAnimationFrame(p.raf),p.text="",p.sessionId=S),p.text+=v,p.raf===null&&(p.raf=requestAnimationFrame(m))},h=()=>{const S=f.current;S.raf!==null&&(cancelAnimationFrame(S.raf),S.raf=null),S.text&&m()};t(S=>{var k,R,B;const v=r;if(!v)return;const p=i!==void 0&&S.sessionId===i;switch(S.type){case"session.created":g.fetchSessionInfo(v,S.sessionId,{updateActivePath:!1}),g.refreshHistory(v);return;case"session.turn":S.kind==="end"&&h(),o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.kind==="end"&&(g.fetchSessionInfo(v,S.sessionId),g.refreshHistory(v),v.request("usage.stats",{}).then(I=>g.setUsageStats(I)).catch(()=>{}));return;case"session.message":if(S.kind==="user_queued"&&/<skill\s+name="/.test(S.text)){const I=(k=/<skill\s+name="([^"]+)"/.exec(S.text))==null?void 0:k[1],_=(R=g.shiftSkillText)==null?void 0:R.call(g);o({type:"userMessage",sessionId:S.sessionId,id:s(),text:_??S.text,...I?{skillTag:I}:{}})}else S.kind==="text_delta"?x(S.sessionId,S.text):S.kind==="text_done"?(h(),o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S})):o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S});p&&(S.kind==="user_queued"||S.kind==="error")&&l.scrollToBottom(!1);return;case"session.thinking":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.kind==="delta"&&(u(),l.followStream());return;case"session.tool_call":case"session.tool_result":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S}),p&&S.type==="session.tool_call"&&g.fetchSessionInfo(v,S.sessionId);return;case"session.queue_update":o({type:"applyEvent",sessionId:S.sessionId,id:s(),event:S});return;default:S.type==="ui.request"&&((B=g.onUiRequest)==null||B.call(g,S));return}})}function Eo(n){const[r,t]=a.useState([]),o=a.useCallback(async()=>{if(n)try{const c=await n.request("models.config");Array.isArray(c)&&t(c)}catch{}},[n]),s=a.useCallback(async c=>{if(n)try{await n.request("models.save",{providers:c}),o()}catch{}},[n,o]),i=a.useCallback(async c=>{if(!n)return{ok:!1};try{return await n.request("models.test",c)}catch{return{ok:!1}}},[n]),l=a.useMemo(()=>r.filter(c=>c.enabled!==!1),[r]);return{modelsConfig:r,enabledProviders:l,refreshModels:o,saveModels:s,testModel:i}}const Ro=a.lazy(()=>on(()=>import("./settings-B-1r6vjG.js"),__vite__mapDeps([0,1])).then(n=>({default:n.SettingsView}))),Wo=a.lazy(()=>on(()=>import("./settings-B-1r6vjG.js"),__vite__mapDeps([0,1])).then(n=>({default:n.PluginsView}))),Lo=n=>{navigator.clipboard.writeText(n).catch(()=>{})},vt=n=>n.trim().replace(/\s+/g," "),_e=[{type:"builtin",name:"compact",description:T("压缩上下文,摘要历史对话,腾出上下文空间")},{type:"builtin",name:"reload",description:T("重新加载扩展、技能、提示词(装包后让 agent 感知新能力)")}];function zo({transport:n}){var _t,qt;const r=K(),{client:t,registerOnEvent:o}=fo(n),{state:s,dispatch:i,active:l}=io(),c=lo(l.items.length,s.activeId),g=ao(),u=l.items.some(d=>d.kind==="tool"&&d.diff!==void 0),[f,m]=a.useState(null),{rightTabs:x,rightTabId:h,rightCollapsed:j,rightPanelWidth:S,diffSelection:v,reviewTurnId:p,reviewOpen:k,setRightTabs:R,setRightTabId:B,setRightCollapsed:I,setRightPanelWidth:_,setReviewOpen:Y,openFileDiff:q,closeRightTab:M}=Mo({activeId:s.activeId,hasEdits:u}),z=a.useRef(0),H=()=>++z.current,oe=a.useRef(0),G=a.useRef(0),te=a.useRef(void 0),ne=d=>{oe.current++;const w=oe.current;te.current!==void 0&&clearTimeout(te.current),te.current=setTimeout(()=>{te.current=void 0,t&&Lt(t,d,w)},80)},[N,b]=a.useState([]),[W,P]=a.useState(),[F,se]=a.useState(()=>sessionStorage.getItem("vagus.view.settings")==="1"),[X,Se]=a.useState(()=>sessionStorage.getItem("vagus.view.plugins")==="1");a.useEffect(()=>{try{sessionStorage.setItem("vagus.view.settings",F?"1":"0"),sessionStorage.setItem("vagus.view.plugins",X?"1":"0")}catch{}},[F,X]);const[Ie,Fe]=a.useState("appearance"),[Ae,fe]=a.useState(null),[Ce,We]=a.useState(new Set),[Le,Me]=a.useState(null),[Te,ae]=a.useState({}),y=Te[s.activeId??""]??Te.global??[],[O,A]=a.useState(null),V=a.useRef(null),[J,pe]=a.useState({}),[be,Q]=a.useState({}),me=a.useRef([]),He=a.useMemo(()=>{const d={};for(const[w,E]of Object.entries(be))E.lines.length>0&&(!E.sessionId||E.sessionId===s.activeId)&&(d[w]={lines:E.lines});return d},[be,s.activeId]),de=a.useMemo(()=>{const d={};for(const[w,E]of Object.entries(be))E.placement==="aboveEditor"&&E.lines.length>0&&(!E.sessionId||E.sessionId===s.activeId)&&(d[w]={lines:E.lines});return d},[be,s.activeId]);a.useEffect(()=>{Object.keys(He).length>0?(R(w=>w.some(E=>E.id==="widget")?w:[...w,jo]),B(w=>w??"widget")):(R(w=>w.some(E=>E.id==="widget")?w.filter(E=>E.id!=="widget"):w),B(w=>w==="widget"?void 0:w))},[He]);const[ze,Pe]=a.useState(),[et,Ne]=a.useState(!1),[C,D]=a.useState(_e),[Z,re]=a.useState(0),ce=a.useRef(!1);a.useEffect(()=>{if(F||X){ce.current=!0;return}ce.current&&(ce.current=!1,re(d=>d+1))},[F,X]);const[$e,It]=a.useState(!1),[mn,yn]=a.useState("ask"),[Ee,ct]=a.useState(void 0),[tt,Ct]=a.useState(!1),[bn,nt]=a.useState(!1),[Mt,Tt]=a.useState(null),[Et,Rt]=a.useState(!1),Ve=a.useRef(new Map),ut="vagus.lastSession",Wt=a.useRef(!1),Ue=Eo(t),ft=a.useCallback((d,w,E,L)=>{Me({title:d,message:w,confirmLabel:E,onConfirm:L})},[]),{modelsConfig:vn,enabledProviders:Ke}=Ue;a.useEffect(()=>{if(!s.activeId&&!Ee&&Ke.length>0&&Ke[0].models.length>0){const d=Ke[0];ct({providerId:d.id,modelId:d.models[0].id})}},[s.activeId,Ee,Ke]);const ie=a.useCallback(async d=>{try{const w=await d.request("session.history",{});if(Array.isArray(w)){const E=w;b(E);for(const L of E)L.id&&L.path&&Ve.current.set(L.id,L.path)}}catch{}},[]),ge=ho(t,ie,ft,d=>{W===d&&(i({type:"activate",sessionId:void 0}),P(void 0))}),{archivedProjects:kn}=ge;a.useEffect(()=>{if(!tt){nt(!1);return}const d=window.setTimeout(()=>nt(!0),300);return()=>window.clearTimeout(d)},[tt]);const Ye=(d,w,E)=>{d.request("session.info",{sessionId:w}).then(L=>{var ee;const $=L;$!=null&&$.sessionFile&&(Ve.current.set(w,$.sessionFile),(E==null?void 0:E.updateActivePath)!==!1&&P($.sessionFile)),typeof((ee=$==null?void 0:$.contextUsage)==null?void 0:ee.tokens)=="number"&&Tt(null),i({type:"setInfo",sessionId:w,info:$,thinkingLevel:$==null?void 0:$.thinkingLevel})}).catch(()=>{})},Lt=async(d,w,E)=>{const L=E??++oe.current,$=new Map;for(const U of N)$.set(U.path,U.id);const ee=$.get(w),ue=ee?s.slots[ee]:void 0;if(ee&&ue&&ue.items.length>0){P(w),c.resetSnap(),i({type:"activate",sessionId:ee}),Ye(d,ee),ie(d),re(U=>U+1);return}G.current++,Ct(!0),i({type:"clearActive"}),nt(!0);try{P(w);const U=await d.request("session.open",{sessionFile:w,limit:200}),ke=U.sessionId;if(L!==oe.current){const Oe=s.slots[ke];(!Oe||Oe.items.length===0)&&i({type:"loadHistory",sessionId:ke,id:H(),messages:U.messages,hasMore:U.hasMore,total:U.total,startIndex:U.startIndex});return}const rt=s.slots[ke];(!rt||rt.items.length===0)&&i({type:"loadHistory",sessionId:ke,id:H(),messages:U.messages,hasMore:U.hasMore,total:U.total,startIndex:U.startIndex}),c.resetSnap(),i({type:"activate",sessionId:ke}),U.sessionFile&&P(U.sessionFile),Ye(d,ke),ie(d),re(Oe=>Oe+1)}catch(U){i({type:"localSystem",id:H(),text:`无法打开会话: ${U instanceof Error?U.message:String(U)}`})}finally{G.current--,G.current<=0&&(G.current=0,Ct(!1),nt(!1))}},ht=a.useRef(!1),[jn,zt]=a.useState(!1),wn=a.useCallback(async()=>{if(!t||!s.activeId||ht.current)return;const d=s.activeId,w=s.slots[d];if(!(w!=null&&w.historyHasMore)||!w.historyStartIndex||w.items.length===0)return;ht.current=!0,zt(!0);const E=Ve.current.get(d)??W;try{const L=await t.request("session.page",{sessionFile:E,limit:200,beforeIndex:w.historyStartIndex});i({type:"prependHistory",sessionId:d,id:H(),messages:L.messages,hasMore:L.hasMore,total:L.total,startIndex:L.startIndex})}catch{}finally{ht.current=!1,zt(!1)}},[t,s.activeId,s.slots,W]),$t=a.useRef(!0);a.useEffect(()=>{if($t.current){$t.current=!1;return}try{W?localStorage.setItem(ut,W):localStorage.removeItem(ut)}catch{}},[W]),a.useEffect(()=>{if(!t||Wt.current)return;Wt.current=!0;let d;try{d=localStorage.getItem(ut)??void 0}catch{d=void 0}d&&(async()=>{try{await Lt(t,d)}catch{}})()},[t]);const Sn=d=>{switch(d){case"compact":return Un(),!0;case"reload":return A({text:T("正在重新加载扩展与技能…"),type:"info"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),2500),t&&s.activeId&&t.request("session.reload",{sessionId:s.activeId}).then(()=>{pt(),A({text:T("✅ 已重新加载扩展与技能"),type:"info"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),2500)}).catch(w=>{A({text:`reload 失败:${w instanceof Error?w.message:String(w)}`,type:"error"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),4e3)}),!0;default:return!1}},Bt=(d,w)=>{d.trim().startsWith("/skill:")&&me.current.push(d.trim()),t&&(async()=>{var E;try{const L=d.split(/\s+/)[0]??"";if(L.startsWith("/")&&Sn(L.slice(1)))return;let $=s.activeId;if(!$||$===qe){if($=(await t.request("session.create",{cwd:ze??void 0})).sessionId,(E=s.slots[qe])!=null&&E.items.length&&i({type:"moveWelcome",sessionId:$}),i({type:"activate",sessionId:$}),Ye(t,$),Ee){try{await t.request("session.model.set",{sessionId:$,providerId:Ee.providerId,modelId:Ee.modelId})}catch{}ct(void 0)}ie(t)}await t.request("session.prompt",{sessionId:$,text:d,images:w}),ie(t)}catch(L){i({type:"forceIdle"}),i({type:"localSystem",id:H(),text:`error: ${L instanceof Error?L.message:String(L)}`})}})()},In=d=>{Bt(d,[])},Dt=a.useRef(()=>{}),Cn=a.useCallback((d,w,E)=>{ft(T("派生新会话"),T(`从这条消息开始创建一条新的会话,原会话保持不变。
|
|
18
|
-
新会话只包含到此为止的上下文。`),T("确认派生"),()=>{Dt.current(w,E)})},[ft]),Mn=a.useCallback(async(d,w)=>{const E=t,L=s.activeId;if(!(!E||!L)){A({text:T("正在派生新会话…"),type:"info"}),V.current&&clearTimeout(V.current);try{const $=await E.request("session.forkPoints",{sessionId:L}),ee=($??[]).findLast(je=>vt(je.text)===vt(d));if(!ee){const je=($??[]).slice(0,3).map(st=>JSON.stringify(st.text.slice(0,60))).join(", ");A({text:`未找到匹配的派生点 (${($??[]).length} 个点,样本: ${je})`,type:"error"}),console.log("[fork] match failed. user text:",JSON.stringify(d),"| normText:",vt(d)),console.log("[fork] first 3 fork points:",($??[]).slice(0,3).map(st=>({id:st.entryId,text:st.text.slice(0,80)})));return}const ue=await E.request("session.fork",{sessionId:L,entryId:ee.entryId});if(!(ue!=null&&ue.sessionId)){A({text:T("派生失败:daemon 未返回新会话"),type:"error"});return}const U=N.find(je=>je.id===L||je.path===W),ke=(U==null?void 0:U.name)||(U==null?void 0:U.firstMessage)||T("新会话"),rt=N.filter(je=>(je.name||je.firstMessage||"").startsWith(ke)).length,Oe=`${ke} (${rt+1})`;try{await E.request("session.renameFile",{sessionFile:ue.sessionFile,name:Oe})}catch{}ie(E);const ot=await E.request("session.open",{sessionFile:ue.sessionFile,limit:200});i({type:"loadHistory",sessionId:ue.sessionId,id:H(),messages:ot.messages,hasMore:ot.hasMore,total:ot.total,startIndex:ot.startIndex}),i({type:"activate",sessionId:ue.sessionId}),P(ue.sessionFile),ie(E),c.resetSnap(),g.setInput(w),A({text:T("✅ 新会话已派生,可编辑消息后发送"),type:"info"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),2500)}catch($){A({text:`派生失败:${$ instanceof Error?$.message:String($)}`,type:"error"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),4e3)}}},[t,s.activeId,i,ie,P,c,N,W,A,V,g]);Dt.current=Mn;const Tn=a.useCallback(async d=>{if(!(!t||!s.activeId||d.length===0))try{const w=await t.request("tool.revertBatch",{sessionId:s.activeId,files:d}),E=((w==null?void 0:w.results)??[]).map(L=>({file:L.file,toolCallId:L.file,ok:L.ok,error:L.error}));m({results:E})}catch(w){console.log("[frontend revertBatch catch]",String(w)),m({results:d.map(E=>({file:E,toolCallId:E,ok:!1,error:w instanceof Error?w.message:String(w)}))})}},[t,s.activeId,m]),En=()=>{c.resetSnap(),i({type:"activate",sessionId:void 0}),P(void 0),re(d=>d+1)},Rn=async(d,w)=>{if(t)try{await t.request("session.renameFile",{sessionFile:d,name:w}),ie(t)}catch{}},Wn=async d=>{if(t)try{const w=N.find(E=>E.path===d);await t.request("session.delete",{sessionFile:d,sessionId:w==null?void 0:w.id}),W===d&&(i({type:"activate",sessionId:void 0}),P(void 0)),ie(t)}catch{}},Ln=async d=>{if(t)try{await t.request("session.archive",{sessionFile:d}),b(w=>w.filter(E=>E.path!==d)),W===d&&(i({type:"activate",sessionId:void 0}),P(void 0)),ie(t),ge.syncArchived(t)}catch{}},zn=async d=>{if(t)try{await t.request("session.restore",{sessionFile:d}),ge.removeArchivedSession(d),ie(t),ge.syncArchived(t)}catch{}},$n=async d=>{if(t)try{const w=Ce.has(d);await t.request("session.pin",{sessionFile:d,pinned:!w}),We(E=>{const L=new Set(E);return w?L.delete(d):L.add(d),L}),ie(t)}catch{}},Bn=a.useMemo(()=>{const d=new Set,w=[];for(const E of N){if(d.has(E.cwd))continue;d.add(E.cwd);const L=E.cwd.replace(/\\/g,"/").split("/").filter(Boolean);w.push({id:E.cwd,name:L[L.length-1]??E.cwd,available:!0})}return w},[N]),Dn=a.useMemo(()=>{const d=new Set;for(const[w,E]of Object.entries(s.slots))if(E.busy){const L=Ve.current.get(w);L&&d.add(L)}return d},[s.slots]),Fn=((_t=l.info)==null?void 0:_t.model)??(Ee==null?void 0:Ee.modelId),An=d=>{if(d.method==="widgetLines"){Q(E=>{const L=d.widgetKey??"";if(!L)return E;const $={...E};if(!d.lines||d.lines.length===0)delete $[L];else{const ee=Array.isArray(d.lines)?d.lines:String(d.lines??"").split(`
|
|
19
|
-
`);$[L]={lines:ee,placement:d.placement??"aboveEditor",sessionId:d.sessionId}}return $});return}if(d.method==="setStatus"){pe(E=>{const L=d.statusKey??"";if(!L)return E;const $={...E};return d.statusText==null?delete $[L]:$[L]=d.statusText,$});return}if(d.method==="notify"){A({text:d.message??d.title??"",type:d.notifyType??"info"}),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>A(null),3500);return}if(!t)return;const w=d.sessionId??"global";ae(E=>({...E,[w]:[...E[w]??[],{event:d,sessionId:d.sessionId,status:"pending"}]}))},Ft=a.useRef(!1),Hn=(d,w)=>{const E=d.sessionId??"global";ae(L=>({...L,[E]:(L[E]??[]).map($=>$.event.id===d.event.id?{...$,status:"answered",result:w}:$)})),Ft.current=!0,t==null||t.request("ui.respond",{id:d.event.id,...w}).catch(()=>{})};To({client:t,registerOnEvent:o,followAnswerRef:Ft,dispatch:i,nextId:H,activeId:s.activeId,autoscroll:c,effects:{fetchSessionInfo:Ye,refreshHistory:ie,setUsageStats:fe,onUiRequest:An,shiftSkillText:()=>me.current.shift()}}),a.useEffect(()=>{t&&(t.request("ping").then(()=>{}).catch(()=>{}),Ue.refreshModels(),t.request("usage.stats",{}).then(d=>fe(d)).catch(()=>{}),t.request("session.pins").then(d=>{Array.isArray(d)&&We(new Set(d))}).catch(()=>{}),t.request("ui.widgets",{}).then(d=>{const w=d;if(w){const E={};for(const[L,$]of Object.entries(w))$!=null&&$.lines&&$.lines.length>0&&(E[L]={lines:$.lines,placement:$.placement==="belowEditor"?"belowEditor":"aboveEditor",sessionId:$.sessionId});Q(E)}}).catch(()=>{}),t.request("ui.pending",{}).then(d=>{const w=d;if(w&&w.length>0){const E={};for(const L of w){const $=L.request,ee=$.sessionId??"global";E[ee]=[...E[ee]??[],{event:$,sessionId:$.sessionId,status:"pending"}]}ae(E)}}).catch(()=>{}),t.request("ui.history",{}).then(d=>{const w=d;w&&ae(E=>{const L={...E};for(const[$,ee]of Object.entries(w)){const ue=ee.map(U=>({event:U.request,sessionId:U.request.sessionId,status:"answered",result:U.result}));L[$]=[...L[$]??[],...ue]}return L})}).catch(()=>{}),ge.syncArchived(t),ie(t))},[t]),a.useEffect(()=>{const d=w=>{if(w.target.closest("textarea, input, button, [role='menu'], [role='menuitem'], [contenteditable]"))return;const L=document.activeElement;L instanceof HTMLElement&&L.blur()};return document.addEventListener("mousedown",d,!0),()=>document.removeEventListener("mousedown",d,!0)},[]);const Pn=d=>{Pe(d),localStorage.setItem("vagus.activeProject",d)};a.useEffect(()=>{const d=localStorage.getItem("vagus.activeProject");d&&Pe(d)},[]);const On=async d=>{if(Ne(!1),!(!d||!t)){Pe(d),localStorage.setItem("vagus.activeProject",d);try{const w=await t.request("session.create",{cwd:d});i({type:"activate",sessionId:w.sessionId}),ie(t),re(E=>E+1)}catch{}}},_n=async(d,w)=>{if(ct({providerId:d,modelId:w}),s.activeId&&i({type:"setInfo",sessionId:s.activeId,info:l.info?{...l.info,model:w,activeProvider:d}:void 0}),!(!t||!s.activeId))try{await t.request("session.model.set",{sessionId:s.activeId,providerId:d,modelId:w})}catch{}},qn=()=>{!t||!s.activeId||t.request("session.abort",{sessionId:s.activeId}).catch(()=>{})},Nn=()=>{!t||!s.activeId||t.request("session.abortCompaction",{sessionId:s.activeId}).catch(()=>{})},Vn=async d=>{if(s.activeId&&i({type:"setInfo",sessionId:s.activeId,info:l.info,thinkingLevel:d}),!(!t||!s.activeId))try{await t.request("session.thinking.set",{sessionId:s.activeId,level:d})}catch{}},Un=async()=>{if(!t||!s.activeId)return;const d=s.activeId,w=H();Rt(!0),i({type:"localSystem",id:w,text:T("正在压缩上下文…")});try{const E=await t.request("session.compact",{sessionId:d});i({type:"removeMessage",id:w});const L=E==null?void 0:E.estimatedTokensAfter,$=typeof L=="number"&&L>0?`${(L/1e3).toFixed(1)}K`:"";Tt(typeof L=="number"?L:null),i({type:"localSystem",id:H(),text:`◌ 前文已摘要${$?` · 剩余 ${$} 上下文`:""}`}),Ye(t,d),t.request("usage.stats",{}).then(ee=>fe(ee)).catch(()=>{})}catch(E){i({type:"removeMessage",id:w});const L=E instanceof Error?E.message:String(E),$=L.includes("Nothing to compact")||L.includes("Already compacted")?"上下文还没大到需要压缩(会话内容太少,或刚刚已经压缩过)":`压缩失败:${L}`;i({type:"localSystem",id:H(),text:$})}finally{Rt(!1)}},Kn=async()=>t?await t.request("project.roots",{}):{places:[],drives:[]},Yn=async d=>t?await t.request("project.listDir",{dir:d}):{path:d,entries:[]},At=async()=>{if(!t)return _e;try{const d=await t.request("commands.list",{sessionId:s.activeId??void 0});return[..._e,...(d.extensions??[]).map(w=>({type:"extension",name:w.name,description:w.description??""})),...(d.templates??[]).map(w=>({type:"template",name:w.name,description:w.description??""})),...(d.skills??[]).map(w=>({type:"skill",name:`skill:${w.name}`,description:w.description??""}))]}catch{return _e}};a.useEffect(()=>{t&&At().then(D).catch(()=>D(_e))},[t,s.activeId]);const pt=()=>{At().then(D).catch(()=>D(_e))},Jn=d=>{It(!1),d&&g.setInput(w=>`${w}${d} `)},Ht={value:g.input,onChange:g.setInput,onSubmit:()=>g.submit((d,w)=>{c.forceScrollToBottom(!1,750),Bt(d,w)}),usage:l.info?Mt!==null?{...l.info,contextUsage:{tokens:Mt,contextWindow:((qt=l.info.contextUsage)==null?void 0:qt.contextWindow)??1e6,percent:null}}:l.info:null,providers:Ke,onSwitchModel:(d,w)=>void _n(d,w),onSetThinking:d=>void Vn(d),thinkingLevel:l.thinkingLevel??"low",permissionMode:mn,onTogglePermission:()=>yn(d=>d==="ask"?"auto":"ask"),attachments:g.attachments,fileAttachments:g.fileAttachments,onAttach:g.attachFiles,onRemoveAttachment:g.removeAttachment,busy:l.busy||Et,onStop:Et?Nn:qn,hasPendingDialog:y.some(d=>d.status==="pending"),selectedModel:Fn,onCommand:()=>{pt(),It(!0)},onRefreshCommands:pt,commands:C,onPickCommand:()=>{},focusSignal:Z,queuedMessages:l.queued},[Pt,Xn]=a.useState(()=>{try{return localStorage.getItem("vagus.sidebar.collapsed")==="1"}catch{return!1}}),Ot={sessions:N,activePath:W,onNewSession:En,onCollapsedChange:Xn,onClearAllArchived:()=>ge.clearAllArchived(),onOpenSession:ne,onOpenSettings:()=>se(!0),onOpenPlugins:()=>Se(!0),onRenameSession:Rn,onDeleteSession:Wn,onArchiveSession:Ln,onRestoreSession:zn,onDeleteArchivedSession:ge.deleteArchivedSession,onTogglePin:$n,pinnedSessions:Ce,archivedProjects:kn,onArchiveProject:async d=>{b(w=>w.filter(E=>E.cwd!==d)),await ge.archiveProject(d)},onUnarchiveProject:async d=>{ge.removeArchivedProject(d),await ge.unarchiveProject(d)},onDeleteProject:d=>ge.deleteProject(d,N,W),busyPaths:Dn,pendingDialogPaths:new Set(Object.entries(Te).filter(([,d])=>d.some(w=>w.status==="pending")).map(([d])=>Ve.current.get(d)).filter(d=>!!d))},{uiFontSize:Gn}=nn(),Qn=!s.activeId&&!F&&!tt,ve=N.find(d=>d.path===W),Zn=(ve==null?void 0:ve.name)??(ve==null?void 0:ve.firstMessage)??"",er=ve==null?void 0:ve.cwd;return e.jsxs("div",{style:{height:"100dvh",margin:0,display:"flex",overflow:"hidden",background:r.color.bg,color:r.color.fg,fontFamily:r.font.sans,fontSize:Gn},children:[F?e.jsx(a.Suspense,{fallback:null,children:e.jsx(Ro,{providers:vn,usageStats:Ae,onClose:()=>se(!1),onSave:Ue.saveModels,onRefresh:Ue.refreshModels,onTest:Ue.testModel,cat:Ie,onCatChange:Fe,projectCwd:ze,request:(d,w)=>t.request(d,w),onProbe:async d=>t?await t.request("models.probe",d):{ok:!1}})}):X?e.jsx(a.Suspense,{fallback:null,children:e.jsx(Wo,{request:(d,w)=>t.request(d,w),onClose:()=>Se(!1),t:r})}):Qn?e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0},children:[e.jsx(Ut,{...Ot}),e.jsx(mo,{wide:Pt,activeProject:ze,projects:Bn,onSelectProject:Pn,onNewProject:()=>Ne(!0),inputCard:Ht,aboveEditorWidgets:de,aboveEditorStatuses:J})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"row",minWidth:0},children:[e.jsx(Ut,{...Ot}),e.jsx(xo,{wide:Pt,items:l.items,busy:l.busy,turnStartTs:l.turnStart,sessionLoading:tt,showLoading:bn,autoscroll:c,sessionName:Zn,sessionCwd:er,activeId:s.activeId,onToggleCard:d=>i({type:"toggleCollapse",id:d}),copyMessage:Lo,editSubmit:In,onFork:Cn,inputCard:Ht,uiCards:y,onUiCardRespond:Hn,onLoadMore:wn,loadingMore:jn,aboveEditorWidgets:de,aboveEditorStatuses:J,onOpenFile:q,onRevertAll:d=>void Tn(d)}),e.jsx(bo,{tabs:x,activeId:h,collapsed:j,onActivate:d=>B(d),onClose:d=>M(d),onToggleCollapse:()=>I(d=>!d),width:S,onWidthChange:_,render:d=>d.id==="diff"?e.jsx(vo,{items:l.items,selected:v,turnId:p,expandedFiles:k,onOpenChange:w=>Y(w)},`${s.activeId}-${p??"none"}`):d.id==="widget"?e.jsx(wo,{widgets:He}):null})]}),et&&e.jsx(wr,{listDir:Yn,roots:Kn,onPick:d=>void On(d)}),$e&&e.jsx(yr,{commands:C,onPick:Jn}),Le&&e.jsx(yo,{state:Le,onClose:()=>Me(null)}),O&&e.jsxs("div",{style:{position:"fixed",bottom:24,left:"50%",transform:"translateX(-50%)",zIndex:10001,display:"flex",alignItems:"flex-start",gap:9,padding:"10px 16px",borderRadius:12,background:r.color.surface,border:`1px solid ${r.color.border}`,boxShadow:"0 12px 40px rgba(0,0,0,0.25)",fontSize:"0.88em",color:r.color.fg,animation:"vagus-toast-in 0.2s ease",maxWidth:"min(90vw, 560px)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",flexShrink:0,marginTop:5,background:O.type==="error"?"#E5484D":O.type==="warning"?"#B7791F":r.color.primary}}),e.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:O.text})]}),f&&e.jsx(Co,{report:f,onClose:()=>m(null)})]})}ur("en",fr);function $o(){return e.jsx(lr,{children:e.jsx(Bo,{})})}function Bo(){const{locale:n}=ar();return e.jsx(dr,{children:e.jsx(cr,{children:e.jsx(zo,{},n)})})}const xn=document.getElementById("root");if(!xn)throw new Error("missing #root element — index.html is malformed");hr.createRoot(xn).render(e.jsx($o,{}));
|