@ian2018cs/agenthub 0.1.0 → 0.1.2
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/assets/index-BITEl9tD.js +154 -0
- package/dist/assets/index-BWbEF217.css +32 -0
- package/dist/assets/{vendor-icons-CJV4dnDL.js → vendor-icons-q7OlK-Uk.js} +76 -61
- package/dist/index.html +3 -3
- package/package.json +2 -1
- package/server/builtin-skills/.gitkeep +0 -0
- package/server/builtin-skills/deploy-frontend/SKILL.md +220 -0
- package/server/builtin-skills/deploy-frontend/scripts/cleanup.py +158 -0
- package/server/builtin-skills/deploy-frontend/scripts/deploy.py +216 -0
- package/server/cli.js +7 -6
- package/server/database/db.js +262 -17
- package/server/database/init.sql +35 -3
- package/server/middleware/auth.js +5 -4
- package/server/routes/admin.js +113 -2
- package/server/routes/auth.js +113 -38
- package/server/routes/skills.js +8 -0
- package/server/services/builtin-skills.js +147 -0
- package/server/services/email.js +90 -0
- package/server/services/user-directories.js +4 -0
- package/dist/assets/index-B4ru3EJb.css +0 -32
- package/dist/assets/index-DDFuyrpY.js +0 -154
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import{j as e,s as bs,R as vs,o as ys,E as js,m as ks,b as ws,c as Ns,h as Ss,p as Cs,d as Es}from"./vendor-codemirror-C_VWDoZS.js";import{b as Ms,g as zr,a,d as Ds,R as Ge,u as wa,B as Is,e as Ls,f as Zr,h as Ts}from"./vendor-react-BeVl62c0.js";import{t as $s,c as Rs,a as Na,F as zs}from"./vendor-utils-00TdZexr.js";import{F as yr,X as Pe,C as Ps,L as Sa,M as kt,R as Kt,S as wt,a as lt,b as gt,c as mr,d as Xr,T as Ue,P as Dt,e as ur,f as jr,g as kr,h as As,i as Ye,j as Nt,k as Fs,l as Os,m as Jt,B as Ca,D as Pr,n as _s,o as Ws,p as Ea,U as ea,q as Bs,E as Ma,r as Us,s as qs,t as Da,u as ta,v as Zt,I as Hs,w as It,x as Xt,y as er,G as wr,Z as Js,z as Ks,A as Vs,H as Ia,J as Gs,K as Ys,N as Vt,O as tr,Q as Qs,V as Zs,W as Xs,Y as La,_ as en,$ as tn,a0 as Nr,a1 as Sr,a2 as Cr,a3 as rn,a4 as an,a5 as sn,a6 as nn,a7 as on,a8 as ln,a9 as cn}from"./vendor-icons-q7OlK-Uk.js";import{r as dn,a as mn,b as un,M as pn}from"./vendor-markdown-VwNYkg_0.js";import{h as xn}from"./vendor-syntax-CdGaPJRS.js";import{r as gn,a as hn,b as fn,c as bn}from"./vendor-xterm-CvdiG4-n.js";import"./vendor-katex-DK8hFnhL.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();var Bt={},ra;function vn(){if(ra)return Bt;ra=1;var t=Ms();return Bt.createRoot=t.createRoot,Bt.hydrateRoot=t.hydrateRoot,Bt}var yn=vn();const jn=zr(yn);function Ie(...t){return $s(Rs(t))}function kn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Ar=a.forwardRef(({className:t,children:r,...s},i)=>e.jsx("div",{ref:i,className:Ie("relative overflow-hidden",t),...s,children:e.jsx("div",{className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Ar.displayName="ScrollArea";const wn=Na("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),V=a.forwardRef(({className:t,variant:r,size:s,...i},o)=>e.jsx("button",{className:Ie(wn({variant:r,size:s,className:t})),ref:o,...i}));V.displayName="Button";const Nn=Na("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",success:"border-transparent bg-green-500 text-white shadow hover:bg-green-500/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ae({className:t,variant:r,...s}){return e.jsx("div",{className:Ie(Nn({variant:r}),t),...s})}const We=a.forwardRef(({className:t,type:r,...s},i)=>e.jsx("input",{type:r,className:Ie("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:i,...s}));We.displayName="Input";const Xe=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),ae=(t,r={})=>{const s=localStorage.getItem("auth-token"),i={};return r.body instanceof FormData||(i["Content-Type"]="application/json"),s&&(i.Authorization=`Bearer ${s}`),fetch(t,{...r,headers:{...i,...r.headers}})},fe={auth:{status:()=>fetch("/api/auth/status"),login:(t,r)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})}),sendCode:t=>fetch("/api/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),verifyCode:(t,r)=>fetch("/api/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,code:r})}),user:()=>ae("/api/auth/user"),logout:()=>ae("/api/auth/logout",{method:"POST"})},admin:{getUsers:()=>ae("/api/admin/users"),createUser:(t,r)=>ae("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:r})}),updateUserStatus:(t,r)=>ae(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:r})}),deleteUser:t=>ae(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>ae("/api/admin/email-domains"),addEmailDomain:t=>ae("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>ae(`/api/admin/email-domains/${t}`,{method:"DELETE"})},projects:()=>ae("/api/projects"),sessions:(t,r=5,s=0)=>ae(`/api/projects/${t}/sessions?limit=${r}&offset=${s}`),sessionMessages:(t,r,s=null,i=0)=>{const o=new URLSearchParams;s!==null&&(o.append("limit",s),o.append("offset",i));const c=o.toString(),d=`/api/projects/${t}/sessions/${r}/messages${c?`?${c}`:""}`;return ae(d)},renameProject:(t,r)=>ae(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(t,r)=>ae(`/api/projects/${t}/sessions/${r}`,{method:"DELETE"}),deleteProject:t=>ae(`/api/projects/${t}`,{method:"DELETE"}),createProject:t=>ae("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>ae("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,r)=>ae(`/api/projects/${t}/file?filePath=${encodeURIComponent(r)}`),saveFile:(t,r,s)=>ae(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:s})}),getFiles:t=>ae(`/api/projects/${t}/files`),uploadFiles:(t,r)=>ae(`/api/projects/${t}/upload-files`,{method:"POST",body:r,headers:{}}),deleteFile:(t,r)=>ae(`/api/projects/${t}/files?filePath=${encodeURIComponent(r)}`,{method:"DELETE"}),transcribe:t=>ae("/api/transcribe",{method:"POST",body:t,headers:{}}),get:t=>ae(`/api${t}`)},Sn=/^[a-zA-Z0-9_-]+$/,Cn=({onClose:t,onProjectCreated:r})=>{const[s,i]=a.useState(""),[o,c]=a.useState(""),[d,u]=a.useState(!1),[g,v]=a.useState(null),f=C=>C.trim()?Sn.test(C.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",E=async()=>{v(null);const C=f(s);if(C){v(C);return}u(!0);try{const x={name:s.trim()};o.trim()&&(x.githubUrl=o.trim());const P=await fe.createWorkspace(x),z=await P.json();if(!P.ok)throw new Error(z.error||"Failed to create project");r&&r(z.project),t()}catch(x){console.error("Error creating project:",x),v(x.message||"Failed to create project")}finally{u(!1)}},N=C=>{C.key==="Enter"&&!d&&E()};return e.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-md border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(yr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"创建新项目"})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:d,children:e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[g&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ps,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:g})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["项目名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(We,{type:"text",value:s,onChange:C=>i(C.target.value),onKeyDown:N,placeholder:"my-awesome-project",className:"w-full",autoFocus:!0}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"仅允许字母、数字、连字符和下划线"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"GitHub 链接(可选)"}),e.jsx(We,{type:"text",value:o,onChange:C=>c(C.target.value),onKeyDown:N,placeholder:"https://github.com/user/repo",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"留空以创建空项目,或输入公共仓库链接以克隆"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(V,{variant:"outline",onClick:t,disabled:d,children:"取消"}),e.jsx(V,{onClick:E,disabled:d||!s.trim(),children:d?e.jsxs(e.Fragment,{children:[e.jsx(Sa,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},aa=(t,r)=>{const s=new Date(t),i=r;if(isNaN(s.getTime()))return"Unknown";const o=i-s,c=Math.floor(o/1e3),d=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),g=Math.floor(o/(1e3*60*60*24));return c<60?"Just now":d===1?"1 min ago":d<60?`${d} mins ago`:u===1?"1 hour ago":u<24?`${u} hours ago`:g===1?"1 day ago":g<7?`${g} days ago`:s.toLocaleDateString()};function sa({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:i,onSessionSelect:o,onNewSession:c,onSessionDelete:d,onProjectDelete:u,isLoading:g,onRefresh:v,onShowSettings:f,isPWA:E,isMobile:N,onToggleSidebar:C}){const[x,P]=a.useState(new Set),[z,R]=a.useState(null),[S,p]=a.useState(!1),[m,h]=a.useState(""),[j,U]=a.useState({}),[B,q]=a.useState({}),[$,ee]=a.useState(new Set),[J,oe]=a.useState(new Date),[W,_]=a.useState("name"),[T,X]=a.useState(!1),[pe,ne]=a.useState(null),[H,ie]=a.useState(""),[ye,me]=a.useState({}),[le,ve]=a.useState(""),[xe,we]=a.useState(()=>{try{const n=localStorage.getItem("starredProjects");return n?new Set(JSON.parse(n)):new Set}catch(n){return console.error("Error loading starred projects:",n),new Set}}),K=n=>k=>{k.target.closest(".overflow-y-auto")||k.target.closest("[data-scroll-container]")||(k.preventDefault(),k.stopPropagation(),n())};a.useEffect(()=>{const n=setInterval(()=>{oe(new Date)},6e4);return()=>clearInterval(n)},[]),a.useEffect(()=>{q({}),ee(new Set)},[t]),a.useEffect(()=>{s&&r&&P(n=>new Set([...n,r.name]))},[s,r]),a.useEffect(()=>{if(t.length>0&&!g){const n=new Set;t.forEach(k=>{k.sessions&&k.sessions.length>=0&&n.add(k.name)}),ee(n)}},[t,g]),a.useEffect(()=>{const n=()=>{try{const A=localStorage.getItem("claude-settings");if(A){const D=JSON.parse(A);_(D.projectSortOrder||"name")}}catch(A){console.error("Error loading sort order:",A)}};n();const k=A=>{A.key==="claude-settings"&&n()};window.addEventListener("storage",k);const F=setInterval(()=>{document.hasFocus()&&n()},1e3);return()=>{window.removeEventListener("storage",k),clearInterval(F)}},[]);const Q=n=>{const k=new Set;x.has(n)||k.add(n),P(k)},I=(n,k)=>{o({...n,__projectName:k})},Z=n=>{const k=new Set(xe);k.has(n)?k.delete(n):k.add(n),we(k);try{localStorage.setItem("starredProjects",JSON.stringify([...k]))}catch(F){console.error("Error saving starred projects:",F)}},be=n=>xe.has(n),he=n=>[...n.sessions||[],...B[n.name]||[]].map(F=>({...F,__provider:"claude"})).sort((F,A)=>new Date(A.lastActivity)-new Date(F.lastActivity)),Ce=n=>{const k=he(n);return k.length===0?new Date(0):k.reduce((A,D)=>{const ue=new Date(D.lastActivity);return ue>A?ue:A},new Date(0))},Fe=[...t].sort((n,k)=>{const F=be(n.name),A=be(k.name);if(F&&!A)return-1;if(!F&&A)return 1;if(W==="date")return Ce(k)-Ce(n);{const D=n.displayName||n.name,ue=k.displayName||k.name;return D.localeCompare(ue)}}),Te=n=>{R(n.name),h(n.displayName)},ze=()=>{R(null),h("")},$e=async n=>{try{(await fe.renameProject(n,m)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(k){console.error("Error renaming project:",k)}R(null),h("")},Be=async(n,k,F="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:n,sessionId:k,provider:F});const A=await fe.deleteSession(n,k);if(console.log("[Sidebar] Delete response:",{ok:A.ok,status:A.status}),A.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),d?d(k):console.warn("[Sidebar] No onSessionDelete callback provided");else{const D=await A.text();console.error("[Sidebar] Failed to delete session:",{status:A.status,error:D}),alert("Failed to delete session. Please try again.")}}catch(A){console.error("[Sidebar] Error deleting session:",A),alert("Error deleting session. Please try again.")}},Re=async n=>{if(confirm("Are you sure you want to delete this empty project? This action cannot be undone."))try{const k=await fe.deleteProject(n);if(k.ok)u&&u(n);else{const F=await k.json();console.error("Failed to delete project"),alert(F.error||"Failed to delete project. Please try again.")}}catch(k){console.error("Error deleting project:",k),alert("Error deleting project. Please try again.")}},Qe=async n=>{if(!(!(n.sessionMeta?.hasMore!==!1)||j[n.name])){U(F=>({...F,[n.name]:!0}));try{const F=(n.sessions?.length||0)+(B[n.name]?.length||0),A=await fe.sessions(n.name,5,F);if(A.ok){const D=await A.json();q(ue=>({...ue,[n.name]:[...ue[n.name]||[],...D.sessions]})),D.hasMore===!1&&(n.sessionMeta={...n.sessionMeta,hasMore:!1})}}catch(F){console.error("Error loading more sessions:",F)}finally{U(F=>({...F,[n.name]:!1}))}}},qe=Fe.filter(n=>{if(!le.trim())return!0;const k=le.toLowerCase(),F=(n.displayName||n.name).toLowerCase(),A=n.name.toLowerCase();return F.includes(k)||A.includes(k)}),He=n=>{i(n)};return e.jsxs(e.Fragment,{children:[S&&Ds.createPortal(e.jsx(Cn,{onClose:()=>p(!1),onProjectCreated:n=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:E&&N?{paddingTop:"44px"}:{},children:[e.jsxs("div",{className:"md:p-4 md:border-b md:border-border",children:[e.jsxs("div",{className:"hidden md:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(kt,{className:"w-4 h-4 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"你的 AI 助手"})]})]}),C&&e.jsx(V,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:C,title:"收起侧边栏",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),e.jsx("div",{className:"md:hidden p-3 border-b border-border",style:E&&N?{paddingTop:"16px"}:{},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:e.jsx(kt,{className:"w-4 h-4 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"项目"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"w-8 h-8 rounded-md bg-background border border-border flex items-center justify-center active:scale-95 transition-all duration-150",onClick:async()=>{X(!0);try{await v()}finally{X(!1)}},disabled:T,children:e.jsx(Kt,{className:`w-4 h-4 text-foreground ${T?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-md bg-primary text-primary-foreground flex items-center justify-center active:scale-95 transition-all duration-150",onClick:()=>p(!0),children:e.jsx(yr,{className:"w-4 h-4"})})]})]})})]}),!g&&!N&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(V,{variant:"default",size:"sm",className:"flex-1 h-8 text-xs bg-primary hover:bg-primary/90 transition-all duration-200",onClick:()=>p(!0),title:"创建新项目",children:[e.jsx(yr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(V,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{X(!0);try{await v()}finally{X(!1)}},disabled:T,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(Kt,{className:`w-3.5 h-3.5 ${T?"animate-spin":""} group-hover:rotate-180 transition-transform duration-300`})})]})}),t.length>0&&!g&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(wt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(We,{type:"text",placeholder:"搜索项目...",value:le,onChange:n=>ve(n.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),le&&e.jsx("button",{onClick:()=>ve(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Pe,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Ar,{className:"flex-1 md:px-2 md:py-3 overflow-y-auto overscroll-contain",children:e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:g?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"加载项目中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取您的 Claude 项目和会话"})]}):t.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(lt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"未找到项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在项目目录中运行 Claude CLI 以开始使用"})]}):qe.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(wt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"无匹配的项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试调整搜索条件"})]}):qe.map(n=>{const k=x.has(n.name),F=r?.name===n.name,A=be(n.name);return e.jsxs("div",{className:"md:space-y-1",children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Ie("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",F&&"bg-primary/5 border-primary/20",A&&!F&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Q(n.name)},onTouchEnd:K(()=>Q(n.name)),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:Ie("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",k?"bg-primary/10":"bg-muted"),children:k?e.jsx(gt,{className:"w-4 h-4 text-primary"}):e.jsx(lt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:z===n.name?e.jsx("input",{type:"text",value:m,onChange:D=>h(D.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:"项目名称",autoFocus:!0,autoComplete:"off",onClick:D=>D.stopPropagation(),onKeyDown:D=>{D.key==="Enter"&&$e(n.name),D.key==="Escape"&&ze()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between min-w-0 flex-1",children:e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:n.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const D=he(n).length;return`${n.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:z===n.name?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:D=>{D.stopPropagation(),$e(n.name)},children:e.jsx(mr,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:D=>{D.stopPropagation(),ze()},children:e.jsx(Pe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:Ie("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",A?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:D=>{D.stopPropagation(),Z(n.name)},onTouchEnd:K(()=>Z(n.name)),title:A?"从收藏中移除":"添加到收藏",children:e.jsx(Xr,{className:Ie("w-4 h-4 transition-colors",A?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),he(n).length===0&&e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:D=>{D.stopPropagation(),Re(n.name)},onTouchEnd:K(()=>Re(n.name)),children:e.jsx(Ue,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:D=>{D.stopPropagation(),Te(n)},onTouchEnd:K(()=>Te(n)),children:e.jsx(Dt,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:k?e.jsx(ur,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(jr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(V,{variant:"ghost",className:Ie("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",F&&"bg-accent text-accent-foreground",A&&!F&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{r?.name!==n.name&&He(n),Q(n.name)},onTouchEnd:K(()=>{r?.name!==n.name&&He(n),Q(n.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[k?e.jsx(gt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(lt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:z===n.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:m,onChange:D=>h(D.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:"项目名称",autoFocus:!0,onKeyDown:D=>{D.key==="Enter"&&$e(n.name),D.key==="Escape"&&ze()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:n.fullPath,children:n.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:n.displayName,children:n.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const D=he(n).length;return n.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D})(),n.fullPath!==n.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:n.fullPath,children:["• ",n.fullPath.length>25?"..."+n.fullPath.slice(-22):n.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:z===n.name?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:D=>{D.stopPropagation(),$e(n.name)},children:e.jsx(mr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:D=>{D.stopPropagation(),ze()},children:e.jsx(Pe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Ie("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",A?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:D=>{D.stopPropagation(),Z(n.name)},title:A?"从收藏中移除":"添加到收藏",children:e.jsx(Xr,{className:Ie("w-3 h-3 transition-colors",A?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:D=>{D.stopPropagation(),Te(n)},title:"重命名项目 (F2)",children:e.jsx(Dt,{className:"w-3 h-3"})}),he(n).length===0&&e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:D=>{D.stopPropagation(),Re(n.name)},title:"删除空项目 (Delete)",children:e.jsx(Ue,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),k?e.jsx(ur,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(jr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),k&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[$.has(n.name)?he(n).length===0&&!j[n.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):he(n).map(D=>{const ue=new Date(D.lastActivity),Ne=Math.floor((J-ue)/(1e3*60))<10,De=D.summary||"新会话",ke=D.lastActivity,Le=D.messageCount||0;return e.jsxs("div",{className:"group relative",children:[Ne&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Ie("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",s?.id===D.id?"bg-primary/5 border-primary/20":Ne?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{He(n),I(D,n.name)},onTouchEnd:K(()=>{He(n),I(D,n.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Ie("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",s?.id===D.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(Xe,{className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:De}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(kr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:aa(ke,J)}),Le>0&&e.jsx(Ae,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:Le}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(Xe,{className:"w-3 h-3"})})]})]}),e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:Se=>{Se.stopPropagation(),Be(n.name,D.id)},onTouchEnd:K(()=>Be(n.name,D.id)),children:e.jsx(Ue,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(V,{variant:"ghost",className:Ie("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",s?.id===D.id&&"bg-accent text-accent-foreground"),onClick:()=>I(D,n.name),onTouchEnd:K(()=>I(D,n.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(Xe,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:De}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(kr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:aa(ke,J)}),Le>0&&e.jsx(Ae,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:Le}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(Xe,{className:"w-3 h-3"})})]})]})]})}),e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:pe===D.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:H,onChange:Se=>ie(Se.target.value),onKeyDown:Se=>{Se.stopPropagation(),Se.key==="Enter"?updateSessionSummary(n.name,D.id,H):Se.key==="Escape"&&(ne(null),ie(""))},onClick:Se=>Se.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:Se=>{Se.stopPropagation(),updateSessionSummary(n.name,D.id,H)},title:"Save",children:e.jsx(mr,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:Se=>{Se.stopPropagation(),ne(null),ie("")},title:"Cancel",children:e.jsx(Pe,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:Se=>{Se.stopPropagation(),ne(D.id),ie(D.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(As,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:Se=>{Se.stopPropagation(),Be(n.name,D.id)},title:"永久删除此会话",children:e.jsx(Ue,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},D.id)}):Array.from({length:3}).map((D,ue)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+ue*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},ue)),he(n).length>0&&n.sessionMeta?.hasMore!==!1&&e.jsx(V,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>Qe(n),disabled:j[n.name],children:j[n.name]?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"加载中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ur,{className:"w-3 h-3"}),"显示更多会话"]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{He(n),c(n)},children:[e.jsx(Ye,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(V,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>c(n),children:[e.jsx(Ye,{className:"w-3 h-3"}),"新会话"]})]})]},n.name)})})}),e.jsxs("div",{className:"md:p-2 md:border-t md:border-border flex-shrink-0",children:[e.jsx("div",{className:"md:hidden p-4 pb-20 border-t border-border/50",children:e.jsxs("button",{className:"w-full h-14 bg-muted/50 hover:bg-muted/70 rounded-2xl flex items-center justify-start gap-4 px-4 active:scale-[0.98] transition-all duration-150",onClick:f,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(Nt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(V,{variant:"ghost",className:"hidden md:flex w-full justify-start gap-2 p-2 h-auto font-normal text-muted-foreground hover:text-foreground hover:bg-accent transition-colors duration-200",onClick:f,children:[e.jsx(Nt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const En={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}};var pr={exports:{}},xr,na;function Mn(){if(na)return xr;na=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return xr=t,xr}var gr,oa;function Dn(){if(oa)return gr;oa=1;var t=Mn();function r(){}function s(){}return s.resetWarningCache=r,gr=function(){function i(d,u,g,v,f,E){if(E!==t){var N=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw N.name="Invariant Violation",N}}i.isRequired=i;function o(){return i}var c={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:s,resetWarningCache:r};return c.PropTypes=c,c},gr}var ia;function In(){return ia||(ia=1,pr.exports=Dn()()),pr.exports}var Ln=In();const je=zr(Ln);function ht(t,r,s,i){function o(c){return c instanceof s?c:new s(function(d){d(c)})}return new(s||(s=Promise))(function(c,d){function u(f){try{v(i.next(f))}catch(E){d(E)}}function g(f){try{v(i.throw(f))}catch(E){d(E)}}function v(f){f.done?c(f.value):o(f.value).then(u,g)}v((i=i.apply(t,r||[])).next())})}const Tn=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function St(t,r,s){const i=$n(t),{webkitRelativePath:o}=t,c=typeof r=="string"?r:typeof o=="string"&&o.length>0?o:`./${t.name}`;return typeof i.path!="string"&&la(i,"path",c),la(i,"relativePath",c),i}function $n(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const i=r.split(".").pop().toLowerCase(),o=Tn.get(i);o&&Object.defineProperty(t,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return t}function la(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Rn=[".DS_Store","Thumbs.db"];function zn(t){return ht(this,void 0,void 0,function*(){return Gt(t)&&Pn(t.dataTransfer)?_n(t.dataTransfer,t.type):An(t)?Fn(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?On(t):[]})}function Pn(t){return Gt(t)}function An(t){return Gt(t)&&Gt(t.target)}function Gt(t){return typeof t=="object"&&t!==null}function Fn(t){return Er(t.target.files).map(r=>St(r))}function On(t){return ht(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>St(s))})}function _n(t,r){return ht(this,void 0,void 0,function*(){if(t.items){const s=Er(t.items).filter(o=>o.kind==="file");if(r!=="drop")return s;const i=yield Promise.all(s.map(Wn));return ca(Ta(i))}return ca(Er(t.files).map(s=>St(s)))})}function ca(t){return t.filter(r=>Rn.indexOf(r.name)===-1)}function Er(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const i=t[s];r.push(i)}return r}function Wn(t){if(typeof t.webkitGetAsEntry!="function")return da(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?$a(r):da(t,r)}function Ta(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?Ta(s):[s]],[])}function da(t,r){return ht(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const c=yield t.getAsFileSystemHandle();if(c===null)throw new Error(`${t} is not a File`);if(c!==void 0){const d=yield c.getFile();return d.handle=c,St(d)}}const i=t.getAsFile();if(!i)throw new Error(`${t} is not a File`);return St(i,(s=r?.fullPath)!==null&&s!==void 0?s:void 0)})}function Bn(t){return ht(this,void 0,void 0,function*(){return t.isDirectory?$a(t):Un(t)})}function $a(t){const r=t.createReader();return new Promise((s,i)=>{const o=[];function c(){r.readEntries(d=>ht(this,void 0,void 0,function*(){if(d.length){const u=Promise.all(d.map(Bn));o.push(u),c()}else try{const u=yield Promise.all(o);s(u)}catch(u){i(u)}}),d=>{i(d)})}c()})}function Un(t){return ht(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(i=>{const o=St(i,t.fullPath);r(o)},i=>{s(i)})})})}var Ut={},ma;function qn(){return ma||(ma=1,Ut.__esModule=!0,Ut.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var i=t.name||"",o=(t.type||"").toLowerCase(),c=o.replace(/\/.*$/,"");return s.some(function(d){var u=d.trim().toLowerCase();return u.charAt(0)==="."?i.toLowerCase().endsWith(u):u.endsWith("/*")?c===u.replace(/\/.*$/,""):o===u})}return!0}),Ut}var Hn=qn();const hr=zr(Hn);function ua(t){return Vn(t)||Kn(t)||za(t)||Jn()}function Jn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kn(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Vn(t){if(Array.isArray(t))return Mr(t)}function pa(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);r&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,i)}return s}function xa(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?pa(Object(s),!0).forEach(function(i){Ra(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):pa(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function Ra(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Lt(t,r){return Qn(t)||Yn(t,r)||za(t,r)||Gn()}function Gn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function za(t,r){if(t){if(typeof t=="string")return Mr(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Mr(t,r)}}function Mr(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,i=new Array(r);s<r;s++)i[s]=t[s];return i}function Yn(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var i=[],o=!0,c=!1,d,u;try{for(s=s.call(t);!(o=(d=s.next()).done)&&(i.push(d.value),!(r&&i.length===r));o=!0);}catch(g){c=!0,u=g}finally{try{!o&&s.return!=null&&s.return()}finally{if(c)throw u}}return i}}function Qn(t){if(Array.isArray(t))return t}var Zn=typeof hr=="function"?hr:hr.default,Xn="file-invalid-type",eo="file-too-large",to="file-too-small",ro="too-many-files",ao=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),i=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:Xn,message:"File type must be ".concat(i)}},ga=function(r){return{code:eo,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},ha=function(r){return{code:to,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},so={code:ro,message:"Too many files"};function Pa(t,r){var s=t.type==="application/x-moz-file"||Zn(t,r);return[s,s?null:ao(r)]}function Aa(t,r,s){if(xt(t.size))if(xt(r)&&xt(s)){if(t.size>s)return[!1,ga(s)];if(t.size<r)return[!1,ha(r)]}else{if(xt(r)&&t.size<r)return[!1,ha(r)];if(xt(s)&&t.size>s)return[!1,ga(s)]}return[!0,null]}function xt(t){return t!=null}function no(t){var r=t.files,s=t.accept,i=t.minSize,o=t.maxSize,c=t.multiple,d=t.maxFiles,u=t.validator;return!c&&r.length>1||c&&d>=1&&r.length>d?!1:r.every(function(g){var v=Pa(g,s),f=Lt(v,1),E=f[0],N=Aa(g,i,o),C=Lt(N,1),x=C[0],P=u?u(g):null;return E&&x&&!P})}function Yt(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function qt(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function fa(t){t.preventDefault()}function oo(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function io(t){return t.indexOf("Edge/")!==-1}function lo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return oo(t)||io(t)}function Ze(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(i){for(var o=arguments.length,c=new Array(o>1?o-1:0),d=1;d<o;d++)c[d-1]=arguments[d];return r.some(function(u){return!Yt(i)&&u&&u.apply(void 0,[i].concat(c)),Yt(i)})}}function co(){return"showOpenFilePicker"in window}function mo(t){if(xt(t)){var r=Object.entries(t).filter(function(s){var i=Lt(s,2),o=i[0],c=i[1],d=!0;return Fa(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),d=!1),(!Array.isArray(c)||!c.every(Oa))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),d=!1),d}).reduce(function(s,i){var o=Lt(i,2),c=o[0],d=o[1];return xa(xa({},s),{},Ra({},c,d))},{});return[{description:"Files",accept:r}]}return t}function uo(t){if(xt(t))return Object.entries(t).reduce(function(r,s){var i=Lt(s,2),o=i[0],c=i[1];return[].concat(ua(r),[o],ua(c))},[]).filter(function(r){return Fa(r)||Oa(r)}).join(",")}function po(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function xo(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Fa(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function Oa(t){return/^.*\.[\w]+$/.test(t)}var go=["children"],ho=["open"],fo=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],bo=["refKey","onChange","onClick"];function vo(t){return ko(t)||jo(t)||_a(t)||yo()}function yo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jo(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ko(t){if(Array.isArray(t))return Dr(t)}function fr(t,r){return So(t)||No(t,r)||_a(t,r)||wo()}function wo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _a(t,r){if(t){if(typeof t=="string")return Dr(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Dr(t,r)}}function Dr(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,i=new Array(r);s<r;s++)i[s]=t[s];return i}function No(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var i=[],o=!0,c=!1,d,u;try{for(s=s.call(t);!(o=(d=s.next()).done)&&(i.push(d.value),!(r&&i.length===r));o=!0);}catch(g){c=!0,u=g}finally{try{!o&&s.return!=null&&s.return()}finally{if(c)throw u}}return i}}function So(t){if(Array.isArray(t))return t}function ba(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);r&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,i)}return s}function Me(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?ba(Object(s),!0).forEach(function(i){Ir(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ba(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function Ir(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Qt(t,r){if(t==null)return{};var s=Co(t,r),i,o;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(o=0;o<c.length;o++)i=c[o],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i])}return s}function Co(t,r){if(t==null)return{};var s={},i=Object.keys(t),o,c;for(c=0;c<i.length;c++)o=i[c],!(r.indexOf(o)>=0)&&(s[o]=t[o]);return s}var Fr=a.forwardRef(function(t,r){var s=t.children,i=Qt(t,go),o=Or(i),c=o.open,d=Qt(o,ho);return a.useImperativeHandle(r,function(){return{open:c}},[c]),Ge.createElement(a.Fragment,null,s(Me(Me({},d),{},{open:c})))});Fr.displayName="Dropzone";var Wa={disabled:!1,getFilesFromEvent:zn,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Fr.defaultProps=Wa;Fr.propTypes={children:je.func,accept:je.objectOf(je.arrayOf(je.string)),multiple:je.bool,preventDropOnDocument:je.bool,noClick:je.bool,noKeyboard:je.bool,noDrag:je.bool,noDragEventsBubbling:je.bool,minSize:je.number,maxSize:je.number,maxFiles:je.number,disabled:je.bool,getFilesFromEvent:je.func,onFileDialogCancel:je.func,onFileDialogOpen:je.func,useFsAccessApi:je.bool,autoFocus:je.bool,onDragEnter:je.func,onDragLeave:je.func,onDragOver:je.func,onDrop:je.func,onDropAccepted:je.func,onDropRejected:je.func,onError:je.func,validator:je.func};var Lr={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Or(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Me(Me({},Wa),t),s=r.accept,i=r.disabled,o=r.getFilesFromEvent,c=r.maxSize,d=r.minSize,u=r.multiple,g=r.maxFiles,v=r.onDragEnter,f=r.onDragLeave,E=r.onDragOver,N=r.onDrop,C=r.onDropAccepted,x=r.onDropRejected,P=r.onFileDialogCancel,z=r.onFileDialogOpen,R=r.useFsAccessApi,S=r.autoFocus,p=r.preventDropOnDocument,m=r.noClick,h=r.noKeyboard,j=r.noDrag,U=r.noDragEventsBubbling,B=r.onError,q=r.validator,$=a.useMemo(function(){return uo(s)},[s]),ee=a.useMemo(function(){return mo(s)},[s]),J=a.useMemo(function(){return typeof z=="function"?z:va},[z]),oe=a.useMemo(function(){return typeof P=="function"?P:va},[P]),W=a.useRef(null),_=a.useRef(null),T=a.useReducer(Eo,Lr),X=fr(T,2),pe=X[0],ne=X[1],H=pe.isFocused,ie=pe.isFileDialogActive,ye=a.useRef(typeof window<"u"&&window.isSecureContext&&R&&co()),me=function(){!ye.current&&ie&&setTimeout(function(){if(_.current){var k=_.current.files;k.length||(ne({type:"closeDialog"}),oe())}},300)};a.useEffect(function(){return window.addEventListener("focus",me,!1),function(){window.removeEventListener("focus",me,!1)}},[_,ie,oe,ye]);var le=a.useRef([]),ve=function(k){W.current&&W.current.contains(k.target)||(k.preventDefault(),le.current=[])};a.useEffect(function(){return p&&(document.addEventListener("dragover",fa,!1),document.addEventListener("drop",ve,!1)),function(){p&&(document.removeEventListener("dragover",fa),document.removeEventListener("drop",ve))}},[W,p]),a.useEffect(function(){return!i&&S&&W.current&&W.current.focus(),function(){}},[W,S,i]);var xe=a.useCallback(function(n){B?B(n):console.error(n)},[B]),we=a.useCallback(function(n){n.preventDefault(),n.persist(),Re(n),le.current=[].concat(vo(le.current),[n.target]),qt(n)&&Promise.resolve(o(n)).then(function(k){if(!(Yt(n)&&!U)){var F=k.length,A=F>0&&no({files:k,accept:$,minSize:d,maxSize:c,multiple:u,maxFiles:g,validator:q}),D=F>0&&!A;ne({isDragAccept:A,isDragReject:D,isDragActive:!0,type:"setDraggedFiles"}),v&&v(n)}}).catch(function(k){return xe(k)})},[o,v,xe,U,$,d,c,u,g,q]),K=a.useCallback(function(n){n.preventDefault(),n.persist(),Re(n);var k=qt(n);if(k&&n.dataTransfer)try{n.dataTransfer.dropEffect="copy"}catch{}return k&&E&&E(n),!1},[E,U]),Q=a.useCallback(function(n){n.preventDefault(),n.persist(),Re(n);var k=le.current.filter(function(A){return W.current&&W.current.contains(A)}),F=k.indexOf(n.target);F!==-1&&k.splice(F,1),le.current=k,!(k.length>0)&&(ne({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),qt(n)&&f&&f(n))},[W,f,U]),I=a.useCallback(function(n,k){var F=[],A=[];n.forEach(function(D){var ue=Pa(D,$),ce=fr(ue,2),Ne=ce[0],De=ce[1],ke=Aa(D,d,c),Le=fr(ke,2),Se=Le[0],ct=Le[1],Je=q?q(D):null;if(Ne&&Se&&!Je)F.push(D);else{var L=[De,ct];Je&&(L=L.concat(Je)),A.push({file:D,errors:L.filter(function(G){return G})})}}),(!u&&F.length>1||u&&g>=1&&F.length>g)&&(F.forEach(function(D){A.push({file:D,errors:[so]})}),F.splice(0)),ne({acceptedFiles:F,fileRejections:A,isDragReject:A.length>0,type:"setFiles"}),N&&N(F,A,k),A.length>0&&x&&x(A,k),F.length>0&&C&&C(F,k)},[ne,u,$,d,c,g,N,C,x,q]),Z=a.useCallback(function(n){n.preventDefault(),n.persist(),Re(n),le.current=[],qt(n)&&Promise.resolve(o(n)).then(function(k){Yt(n)&&!U||I(k,n)}).catch(function(k){return xe(k)}),ne({type:"reset"})},[o,I,xe,U]),be=a.useCallback(function(){if(ye.current){ne({type:"openDialog"}),J();var n={multiple:u,types:ee};window.showOpenFilePicker(n).then(function(k){return o(k)}).then(function(k){I(k,null),ne({type:"closeDialog"})}).catch(function(k){po(k)?(oe(k),ne({type:"closeDialog"})):xo(k)?(ye.current=!1,_.current?(_.current.value=null,_.current.click()):xe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):xe(k)});return}_.current&&(ne({type:"openDialog"}),J(),_.current.value=null,_.current.click())},[ne,J,oe,R,I,xe,ee,u]),he=a.useCallback(function(n){!W.current||!W.current.isEqualNode(n.target)||(n.key===" "||n.key==="Enter"||n.keyCode===32||n.keyCode===13)&&(n.preventDefault(),be())},[W,be]),Ce=a.useCallback(function(){ne({type:"focus"})},[]),Fe=a.useCallback(function(){ne({type:"blur"})},[]),Te=a.useCallback(function(){m||(lo()?setTimeout(be,0):be())},[m,be]),ze=function(k){return i?null:k},$e=function(k){return h?null:ze(k)},Be=function(k){return j?null:ze(k)},Re=function(k){U&&k.stopPropagation()},Qe=a.useMemo(function(){return function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=n.refKey,F=k===void 0?"ref":k,A=n.role,D=n.onKeyDown,ue=n.onFocus,ce=n.onBlur,Ne=n.onClick,De=n.onDragEnter,ke=n.onDragOver,Le=n.onDragLeave,Se=n.onDrop,ct=Qt(n,fo);return Me(Me(Ir({onKeyDown:$e(Ze(D,he)),onFocus:$e(Ze(ue,Ce)),onBlur:$e(Ze(ce,Fe)),onClick:ze(Ze(Ne,Te)),onDragEnter:Be(Ze(De,we)),onDragOver:Be(Ze(ke,K)),onDragLeave:Be(Ze(Le,Q)),onDrop:Be(Ze(Se,Z)),role:typeof A=="string"&&A!==""?A:"presentation"},F,W),!i&&!h?{tabIndex:0}:{}),ct)}},[W,he,Ce,Fe,Te,we,K,Q,Z,h,j,i]),qe=a.useCallback(function(n){n.stopPropagation()},[]),He=a.useMemo(function(){return function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=n.refKey,F=k===void 0?"ref":k,A=n.onChange,D=n.onClick,ue=Qt(n,bo),ce=Ir({accept:$,multiple:u,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:ze(Ze(A,Z)),onClick:ze(Ze(D,qe)),tabIndex:-1},F,_);return Me(Me({},ce),ue)}},[_,s,u,Z,i]);return Me(Me({},pe),{},{isFocused:H&&!i,getRootProps:Qe,getInputProps:He,rootRef:W,inputRef:_,open:ze(be)})}function Eo(t,r){switch(r.type){case"focus":return Me(Me({},t),{},{isFocused:!0});case"blur":return Me(Me({},t),{},{isFocused:!1});case"openDialog":return Me(Me({},Lr),{},{isFileDialogActive:!0});case"closeDialog":return Me(Me({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Me(Me({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Me(Me({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return Me({},Lr);default:return t}}function va(){}const br=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=c=>{switch(c){case"completed":return e.jsx(Os,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(kr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Fs,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},i=c=>{switch(c){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},o=c=>{switch(c){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-3",children:[r&&e.jsxs("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:["待办事项列表 (",t.length," 项)"]}),t.map((c,d)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm hover:shadow-md dark:shadow-gray-900/50 transition-shadow",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(c.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("p",{className:`text-sm font-medium ${c.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:c.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Ae,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(c.priority)}`,children:c.priority}),e.jsx(Ae,{variant:"outline",className:`text-xs px-2 py-0.5 ${i(c.status)}`,children:c.status.replace("_"," ")})]})]})})]},c.id||`todo-${d}`))]})};function Mo({status:t,onAbort:r,isLoading:s,provider:i="claude"}){const[o,c]=a.useState(0),[d,u]=a.useState(0),[g,v]=a.useState(0);if(a.useEffect(()=>{if(!s){c(0),v(0);return}const R=Date.now(),S=30+Math.random()*20,p=setInterval(()=>{const m=Math.floor((Date.now()-R)/1e3);c(m),v(Math.floor(m*S))},1e3);return()=>clearInterval(p)},[s]),a.useEffect(()=>{if(!s)return;const R=setInterval(()=>{u(S=>(S+1)%4)},500);return()=>clearInterval(R)},[s]),!s)return null;const f=["思考中","处理中","分析中","工作中","计算中","推理中"],E=Math.floor(o/3)%f.length,N=t?.text||f[E],C=t?.tokens||g,x=t?.can_interrupt!==!1,z=["✻","✹","✸","✶"][d];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:Ie("text-base sm:text-xl transition-all duration-500 flex-shrink-0",d%2===0?"text-blue-400 scale-110":"text-blue-300"),children:z}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[N,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",o,"s)"]}),C>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",C.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"按 esc 停止"})]})})]})}),x&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"停止"})]})]})})}function Do({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),i=10,o=2*Math.PI*i,c=o-s/100*o,d=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:i,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:i,fill:"none",stroke:d(),strokeWidth:"2",strokeDasharray:o,strokeDashoffset:c,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}async function Io(t,r){const s=new FormData,i=`recording_${Date.now()}.webm`,o=new File([t],i,{type:t.type});s.append("audio",o);const c=window.localStorage.getItem("whisperMode")||"default";s.append("mode",c);try{const d=await fe.transcribe(s);if(!d.ok){const g=await d.json().catch(()=>({}));throw new Error(g.error||`Transcription error: ${d.status} ${d.statusText}`)}return(await d.json()).text||""}catch(d){throw d.name==="TypeError"&&d.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):d}}function Lo({onTranscript:t,className:r=""}){const[s,i]=a.useState("idle"),[o,c]=a.useState(null),[d,u]=a.useState(!0),g=a.useRef(null),v=a.useRef(null),f=a.useRef([]),E=a.useRef(0);a.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){u(!1),c("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){u(!1),c("Microphone requires HTTPS. Please use a secure connection.");return}u(!0),c(null)})()},[]);const N=async()=>{try{if(console.log("Starting recording..."),c(null),f.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const p=await navigator.mediaDevices.getUserMedia({audio:!0});v.current=p;const m=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",h=new MediaRecorder(p,{mimeType:m});g.current=h,h.ondataavailable=j=>{j.data.size>0&&f.current.push(j.data)},h.onstop=async()=>{console.log("Recording stopped, creating blob...");const j=new Blob(f.current,{type:m});v.current&&(v.current.getTracks().forEach($=>$.stop()),v.current=null),i("transcribing");const U=window.localStorage.getItem("whisperMode")||"default",B=U==="prompt"||U==="vibe"||U==="instructions"||U==="architect";let q;B&&(q=setTimeout(()=>{i("processing")},2e3));try{const $=await Io(j);$&&t&&t($)}catch($){console.error("Transcription error:",$),c($.message)}finally{q&&clearTimeout(q),i("idle")}},h.start(),i("recording"),console.log("Recording started successfully")}catch(p){console.error("Failed to start recording:",p);let m="Microphone access failed";p.name==="NotAllowedError"?m="Microphone access denied. Please allow microphone permissions.":p.name==="NotFoundError"?m="No microphone found. Please check your audio devices.":p.name==="NotSupportedError"?m="Microphone not supported by this browser.":p.name==="NotReadableError"?m="Microphone is being used by another application.":p.message.includes("HTTPS")&&(m=p.message),c(m),i("idle")}},C=()=>{console.log("Stopping recording..."),g.current&&g.current.state==="recording"?g.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),v.current&&(v.current.getTracks().forEach(p=>p.stop()),v.current=null),i("idle"))},x=p=>{if(p&&(p.preventDefault(),p.stopPropagation()),!d)return;const m=Date.now();if(m-E.current<300){console.log("Ignoring rapid tap");return}E.current=m,console.log("Button clicked, current state:",s),s==="idle"?N():s==="recording"&&C()};a.useEffect(()=>()=>{v.current&&v.current.getTracks().forEach(p=>p.stop())},[]);const P=()=>{if(!d)return{icon:e.jsx(Jt,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(Jt,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(Sa,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Ca,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(Jt,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:z,className:R,disabled:S}=P();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
|
|
6
|
+
flex items-center justify-center
|
|
7
|
+
w-12 h-12 rounded-full
|
|
8
|
+
text-white transition-all duration-200
|
|
9
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
|
|
10
|
+
dark:ring-offset-gray-800
|
|
11
|
+
touch-action-manipulation
|
|
12
|
+
${S?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
13
|
+
${s==="recording"?"animate-pulse":""}
|
|
14
|
+
hover:opacity-90
|
|
15
|
+
${r}
|
|
16
|
+
`,onClick:x,disabled:S,children:z}),o&&e.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
17
|
+
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
18
|
+
animate-fade-in`,children:o}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const To=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:i,position:o={top:0,left:0},isOpen:c=!1,frequentCommands:d=[]})=>{const u=a.useRef(null),g=a.useRef(null),f=(()=>{const S=window.innerWidth<640,p=window.innerHeight;return S?{position:"fixed",bottom:`${o.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(o.top,p-316))}px`,left:`${o.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(a.useEffect(()=>{const S=p=>{u.current&&!u.current.contains(p.target)&&c&&i()};if(c)return document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[c,i]),a.useEffect(()=>{if(g.current&&u.current){const S=u.current.getBoundingClientRect(),p=g.current.getBoundingClientRect();p.bottom>S.bottom?g.current.scrollIntoView({block:"nearest",behavior:"smooth"}):p.top<S.top&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!c)return null;if(t.length===0)return e.jsx("div",{ref:u,className:"command-menu command-menu-empty",style:{...f,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"暂无可用命令"});const E=d.length>0,N=t.reduce((S,p)=>{const m=p.namespace||p.type||"other";return S[m]||(S[m]=[]),S[m].push(p),S},{});E&&(N.frequent=d);const x=(E?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(S=>N[S]),P={frequent:"⭐ 常用命令",builtin:"内置命令",project:"项目命令",user:"用户命令",other:"其他命令"};let z=0;const R=[];return x.forEach(S=>{N[S].forEach(p=>{R.push({...p,globalIndex:z++,namespace:S})})}),e.jsxs("div",{ref:u,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...f,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:c?1:0,transform:c?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[x.map(S=>e.jsxs("div",{className:"command-group",children:[x.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:P[S]||S}),N[S].map(p=>{const m=R.find(j=>j.name===p.name&&j.namespace===S),h=m&&m.globalIndex===r;return e.jsxs("div",{ref:h?g:null,role:"option","aria-selected":h,className:"command-item",onMouseEnter:()=>s&&s(p,m.globalIndex,!0),onClick:()=>s&&s(p,m.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:h?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:j=>j.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:p.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[S==="builtin"&&"⚡",S==="project"&&"📁",S==="user"&&"👤",S==="other"&&"📝"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:p.name}),p.metadata?.type&&e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:p.metadata.type})]}),p.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.description})]}),h&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${S}-${p.name}`)})]},S)),e.jsx("style",{children:`
|
|
19
|
+
.command-menu {
|
|
20
|
+
background-color: white;
|
|
21
|
+
border: 1px solid #e5e7eb;
|
|
22
|
+
}
|
|
23
|
+
.command-menu-empty {
|
|
24
|
+
color: #6b7280;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (prefers-color-scheme: dark) {
|
|
28
|
+
.command-menu {
|
|
29
|
+
background-color: #1f2937 !important;
|
|
30
|
+
border: 1px solid #374151 !important;
|
|
31
|
+
}
|
|
32
|
+
.command-menu-empty {
|
|
33
|
+
color: #9ca3af !important;
|
|
34
|
+
}
|
|
35
|
+
.command-item[aria-selected="true"] {
|
|
36
|
+
background-color: #1e40af !important;
|
|
37
|
+
}
|
|
38
|
+
.command-item span:not(.command-metadata-badge) {
|
|
39
|
+
color: #f3f4f6 !important;
|
|
40
|
+
}
|
|
41
|
+
.command-metadata-badge {
|
|
42
|
+
background-color: #f3f4f6 !important;
|
|
43
|
+
color: #6b7280 !important;
|
|
44
|
+
}
|
|
45
|
+
.command-item div {
|
|
46
|
+
color: #d1d5db !important;
|
|
47
|
+
}
|
|
48
|
+
.command-group > div:first-child {
|
|
49
|
+
color: #9ca3af !important;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`})]})},ya={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"}],DEFAULT:"sonnet"};function vt(t){return t&&t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function $o(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function Ht(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",i="__";let o=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,c=>{const d=r.length;return r.push(c),`${s}${d}${i}`});return o=o.replace(/\\n/g,`
|
|
53
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r"),o=o.replace(new RegExp(`${s}(\\d+)${i}`,"g"),(c,d)=>r[parseInt(d)]),o}const yt=({children:t,className:r})=>{const s=$o(String(t??"")),i=a.useMemo(()=>[dn,mn],[]),o=a.useMemo(()=>[un],[]);return e.jsx("div",{className:r,children:e.jsx(pn,{remarkPlugins:i,rehypePlugins:o,components:Po,children:s})})};function Tr(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let i=parseInt(s,10);if(!Number.isFinite(i))return r;i<1e12&&(i*=1e3);const o=new Date(i),c=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(o),d=-o.getTimezoneOffset(),u=d>=0?"+":"-",g=Math.abs(d),v=Math.floor(g/60),f=g%60,E=`GMT${u}${v}${f?":"+String(f).padStart(2,"0"):""}`,x=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,S=>S.toUpperCase()),P=x?`${E} (${x})`:E,z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],R=`${o.getDate()} ${z[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${c} ${P}** - ${R}`})}catch{return t}}const _e={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){console.warn(`Truncating chat history for ${t} from ${s.length} to 50 messages`);const i=s.slice(-50);r=JSON.stringify(i)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if(s.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const i=Object.keys(localStorage),o=i.filter(d=>d.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(d=>{localStorage.removeItem(d),console.log(`Removed old chat data: ${d}`)}),i.filter(d=>d.startsWith("draft_input_")).forEach(d=>{localStorage.removeItem(d)});try{localStorage.setItem(t,r)}catch(d){if(console.error("Failed to save to localStorage even after cleanup:",d),t.startsWith("chat_messages_")&&typeof r=="string")try{const u=JSON.parse(r);if(Array.isArray(u)&&u.length>10){const g=u.slice(-10);localStorage.setItem(t,JSON.stringify(g)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(u){console.error("Final save attempt failed:",u)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}},Ba="claude-settings";function _r(){const t=_e.getItem(Ba);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function $r(t,r){if(!t)return null;if(t!=="Bash")return t;const s=kn(r),i=typeof s?.command=="string"?s.command.trim():"";if(!i)return t;const o=i.split(/\s+/);return o.length===0?t:o[0]==="git"&&o[1]?`Bash(${o[0]} ${o[1]}:*)`:`Bash(${o[0]}:*)`}function ja(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ro(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const s=t?.toolName,i=$r(s,t.toolInput);if(!i)return null;const c=_r().allowedTools.includes(i);return{toolName:s,entry:i,isAllowed:c}}function zo(t){if(!t)return{success:!1};const r=_r(),s=r.allowedTools.includes(t),i=s?r.allowedTools:[...r.allowedTools,t],o=r.disallowedTools.filter(d=>d!==t),c={...r,allowedTools:i,disallowedTools:o,lastUpdated:new Date().toISOString()};return _e.setItem(Ba,JSON.stringify(c)),{success:!0,alreadyAllowed:s,updatedSettings:c}}const Po={code:({node:t,inline:r,className:s,children:i,...o})=>{const[c,d]=Ge.useState(!1),u=Array.isArray(i)?i.join(""):String(i??""),g=/[\r\n]/.test(u);if(r||t&&t.type==="inlineCode"||!g)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...o,children:i});const E=/language-(\w+)/.exec(s||""),N=E?E[1]:"text",C=u,x=()=>{const P=()=>{d(!0),setTimeout(()=>d(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(C).then(P).catch(()=>{const z=document.createElement("textarea");z.value=C,z.style.position="fixed",z.style.opacity="0",document.body.appendChild(z),z.select();try{document.execCommand("copy")}catch{}document.body.removeChild(z),P()});else{const z=document.createElement("textarea");z.value=C,z.style.position="fixed",z.style.opacity="0",document.body.appendChild(z),z.select();try{document.execCommand("copy")}catch{}document.body.removeChild(z),P()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[N&&N!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:N}),e.jsx("button",{type:"button",onClick:x,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:c?"已复制":"复制代码","aria-label":c?"已复制":"复制代码",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"已复制"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"复制"]})}),e.jsx(xn,{language:N,style:En,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:N&&N!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:u})]})},blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})},Ao=a.memo(({message:t,index:r,prevMessage:s,createDiff:i,onFileOpen:o,onShowSettings:c,onGrantToolPermission:d,autoExpandTools:u,showRawParameters:g,showThinking:v,selectedProject:f,provider:E})=>{const N=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),C=Ge.useRef(null),[x,P]=Ge.useState(!1),z=Ro(t,E),[R,S]=Ge.useState("idle");return Ge.useEffect(()=>{S("idle")},[z?.entry,t.toolId]),Ge.useEffect(()=>{if(!u||!C.current||!t.isToolUse)return;const p=new IntersectionObserver(m=>{m.forEach(h=>{h.isIntersecting&&!x&&(P(!0),C.current.querySelectorAll("details").forEach(U=>{U.open=!0}))})},{threshold:.1});return p.observe(C.current),()=>{C.current&&p.unobserve(C.current)}},[u,x,t.isToolUse]),e.jsx("div",{ref:C,className:`chat-message ${t.type} ${N?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((p,m)=>e.jsx("img",{src:p.data,alt:p.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(p.data,"_blank")},m))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:new Date(t.timestamp).toLocaleTimeString()})]}),!N&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):e.jsxs("div",{className:"w-full",children:[!N&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(Xe,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?"错误":t.type==="tool"?"工具":"Claude"})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse&&!["Read","TodoWrite","TodoRead"].includes(t.toolName)?["Grep","Glob"].includes(t.toolName)?e.jsx(e.Fragment,{children:e.jsx("div",{className:"group relative bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-blue-400 dark:border-blue-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 flex-1 min-w-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),e.jsx("span",{className:"font-medium flex-shrink-0",children:t.toolName}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),t.toolInput&&(()=>{try{const m=JSON.parse(t.toolInput);return e.jsxs("span",{className:"font-mono truncate flex-1 min-w-0",children:[m.pattern&&e.jsxs("span",{children:["pattern: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:m.pattern})]}),m.path&&e.jsxs("span",{className:"ml-2",children:["in: ",m.path]})]})}catch{return null}})()]}),t.toolResult&&e.jsxs("a",{href:`#tool-result-${t.toolId}`,className:"flex-shrink-0 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium transition-colors flex items-center gap-1",children:[e.jsx("span",{children:"结果"}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]})})}):e.jsxs("div",{className:"group relative bg-gradient-to-br from-blue-50/50 to-indigo-50/50 dark:from-blue-950/20 dark:to-indigo-950/20 border border-blue-100/30 dark:border-blue-800/30 rounded-lg p-3 mb-2",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-500/3 to-indigo-500/3 dark:from-blue-400/3 dark:to-indigo-400/3 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),e.jsxs("div",{className:"relative flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-8 h-8 bg-gradient-to-br from-blue-500 to-indigo-600 dark:from-blue-400 dark:to-indigo-500 rounded-lg flex items-center justify-center shadow-lg shadow-blue-500/20 dark:shadow-blue-400/20",children:[e.jsxs("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-blue-500 dark:bg-blue-400 animate-pulse opacity-20"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:t.toolName}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:t.toolId})]})]}),c&&e.jsx("button",{onClick:m=>{m.stopPropagation(),c()},className:"p-2 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60 transition-all duration-200 group/btn backdrop-blur-sm",title:"工具设置",children:e.jsxs("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-400 group-hover/btn:text-blue-600 dark:group-hover/btn:text-blue-400 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),t.toolInput&&t.toolName==="Edit"&&(()=>{try{const m=JSON.parse(t.toolInput);if(m.file_path&&m.old_string&&m.new_string)return e.jsxs("details",{className:"relative mt-3 group/details",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsx("span",{className:"flex items-center gap-2",children:e.jsx("span",{children:"查看编辑差异"})}),e.jsx("button",{onClick:async h=>{if(h.preventDefault(),h.stopPropagation(),!!o)try{const j=await fe.readFile(f?.name,m.file_path),U=await j.json();if(!j.ok||U.error){console.error("Failed to fetch file:",U.error),o(m.file_path);return}const B=U.content||"",q=B.replace(m.new_string,m.old_string);o(m.file_path,{old_string:q,new_string:B})}catch(j){console.error("Error preparing diff:",j),o(m.file_path)}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:m.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(o)try{const h=await fe.readFile(f?.name,m.file_path),j=await h.json();if(!h.ok||j.error){console.error("Failed to fetch file:",j.error),o(m.file_path);return}const U=j.content||"",B=U.replace(m.new_string,m.old_string);o(m.file_path,{old_string:B,new_string:U})}catch(h){console.error("Error preparing diff:",h),o(m.file_path)}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:m.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-gray-100 dark:bg-gray-700/50 rounded",children:"Diff"})]}),e.jsx("div",{className:"text-xs font-mono",children:i(m.old_string,m.new_string).map((h,j)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${h.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:h.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${h.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:h.content})]},j))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/params:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看输入参数"]}),e.jsx("pre",{className:"mt-3 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})})(),t.toolInput&&t.toolName!=="Edit"&&(()=>{if(t.toolName==="Write")try{let m;if(typeof t.toolInput=="string"?m=JSON.parse(t.toolInput):m=t.toolInput,m.file_path&&m.content!==void 0)return e.jsxs("details",{className:"relative mt-3 group/details",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"📄"}),e.jsx("span",{children:"创建新文件:"})]}),e.jsx("button",{onClick:async h=>{if(h.preventDefault(),h.stopPropagation(),!!o)try{const j=await fe.readFile(f?.name,m.file_path),U=await j.json(),B=j.ok&&!U.error?U.content||"":m.content||"";o(m.file_path,{old_string:"",new_string:B})}catch(j){console.error("Error preparing diff:",j),o(m.file_path,{old_string:"",new_string:m.content||""})}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:m.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(o)try{const h=await fe.readFile(f?.name,m.file_path),j=await h.json(),U=h.ok&&!j.error?j.content||"":m.content||"";o(m.file_path,{old_string:"",new_string:U})}catch(h){console.error("Error preparing diff:",h),o(m.file_path,{old_string:"",new_string:m.content||""})}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:m.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 rounded",children:"新文件"})]}),e.jsx("div",{className:"text-xs font-mono",children:i("",m.content).map((h,j)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${h.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:h.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${h.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:h.content})]},j))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="TodoWrite")try{const m=JSON.parse(t.toolInput);if(m.todos&&Array.isArray(m.todos))return e.jsxs("details",{className:"relative mt-3 group/todo",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/todo:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"✓"}),e.jsx("span",{children:"更新待办列表"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(br,{todos:m.todos}),g&&e.jsxs("details",{className:"relative mt-3 group/raw",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg overflow-x-auto text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="Bash")try{const m=JSON.parse(t.toolInput);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-md px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-gray-100 ml-2",children:m.command})]}),m.description&&e.jsx("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic ml-1",children:m.description})]})}catch{}if(t.toolName==="Read")try{const m=JSON.parse(t.toolInput);if(m.file_path){const h=m.file_path.split("/").pop();return e.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-300",children:["Read"," ",e.jsx("button",{onClick:()=>o&&o(m.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-mono",children:h})]})}}catch{}if(t.toolName==="exit_plan_mode")try{const m=JSON.parse(t.toolInput);if(m.plan){const h=m.plan.replace(/\\n/g,`
|
|
54
|
+
`);return e.jsxs("details",{className:"mt-2",open:u,children:[e.jsxs("summary",{className:"text-sm text-blue-700 dark:text-blue-300 cursor-pointer hover:text-blue-800 dark:hover:text-blue-200 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"📋 查看实现计划"]}),e.jsx(yt,{className:"mt-3 prose prose-sm max-w-none dark:prose-invert",children:h})]})}}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:u,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/params:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看输入参数"]}),e.jsx("pre",{className:"mt-3 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})})(),t.toolResult&&(!t.toolResult.isError&&(t.toolName==="Edit"||t.toolName==="Write"||t.toolName==="ApplyPatch"||t.toolName==="Bash")?null:e.jsxs("div",{id:`tool-result-${t.toolId}`,className:`relative mt-4 p-4 rounded-lg border backdrop-blur-sm scroll-mt-4 ${t.toolResult.isError?"bg-gradient-to-br from-red-50 to-rose-50 dark:from-red-950/20 dark:to-rose-950/20 border-red-200/60 dark:border-red-800/60":"bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-950/20 dark:to-emerald-950/20 border-green-200/60 dark:border-green-800/60"}`,children:[e.jsx("div",{className:`absolute inset-0 rounded-lg opacity-50 ${t.toolResult.isError?"bg-gradient-to-br from-red-500/5 to-rose-500/5 dark:from-red-400/5 dark:to-rose-400/5":"bg-gradient-to-br from-green-500/5 to-emerald-500/5 dark:from-green-400/5 dark:to-emerald-400/5"}`}),e.jsxs("div",{className:"relative flex items-center gap-2.5 mb-3",children:[e.jsx("div",{className:`w-6 h-6 rounded-lg flex items-center justify-center shadow-md ${t.toolResult.isError?"bg-gradient-to-br from-red-500 to-rose-600 dark:from-red-400 dark:to-rose-500 shadow-red-500/20":"bg-gradient-to-br from-green-500 to-emerald-600 dark:from-green-400 dark:to-emerald-500 shadow-green-500/20"}`,children:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.toolResult.isError?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"}):e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:`text-sm font-semibold ${t.toolResult.isError?"text-red-800 dark:text-red-200":"text-green-800 dark:text-green-200"}`,children:t.toolResult.isError?"工具错误":"工具结果"})]}),e.jsxs("div",{className:`relative text-sm ${t.toolResult.isError?"text-red-900 dark:text-red-100":"text-green-900 dark:text-green-100"}`,children:[(()=>{const h=String(t.toolResult.content||"");if((t.toolName==="TodoWrite"||t.toolName==="TodoRead")&&(h.includes("Todos have been modified successfully")||h.includes("Todo list")||h.startsWith("[")&&h.includes('"content"')&&h.includes('"status"')))try{let B=null;if(h.startsWith("["))B=JSON.parse(h);else if(h.includes("Todos have been modified successfully"))return e.jsx("div",{children:e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"待办列表已更新成功"})})});if(B&&Array.isArray(B))return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"font-medium",children:"当前待办列表"})}),e.jsx(br,{todos:B,isResult:!0})]})}catch{}if(t.toolName==="exit_plan_mode")try{const B=JSON.parse(h);if(B.plan){const q=B.plan.replace(/\\n/g,`
|
|
55
|
+
`);return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"font-medium",children:"实现计划"})}),e.jsx(yt,{className:"prose prose-sm max-w-none dark:prose-invert",children:q})]})}}catch{}if((t.toolName==="Grep"||t.toolName==="Glob")&&t.toolResult?.toolUseResult){const B=t.toolResult.toolUseResult;if(B.filenames&&Array.isArray(B.filenames)&&B.filenames.length>0)return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs("span",{className:"font-medium",children:["找到 ",B.numFiles||B.filenames.length," 个文件"]})}),e.jsx("div",{className:"space-y-1 max-h-96 overflow-y-auto",children:B.filenames.map((q,$)=>{const ee=q.split("/").pop(),J=q.substring(0,q.lastIndexOf("/"));return e.jsxs("div",{onClick:()=>{o&&o(q)},className:"group flex items-center gap-2 px-2 py-1.5 rounded hover:bg-green-100/50 dark:hover:bg-green-800/20 cursor-pointer transition-colors",children:[e.jsx("svg",{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-mono text-sm font-medium text-green-800 dark:text-green-200 truncate group-hover:text-green-900 dark:group-hover:text-green-100",children:ee}),e.jsx("div",{className:"font-mono text-xs text-green-600/70 dark:text-green-400/70 truncate",children:J})]}),e.jsx("svg",{className:"w-4 h-4 text-green-600 dark:text-green-400 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]},$)})})]})}if(h.includes("Do you want to proceed?")&&t.toolName==="Bash"){const B=h.split(`
|
|
56
|
+
`),q=B.findIndex(T=>T.includes("Do you want to proceed?")),$=B.slice(0,q).join(`
|
|
57
|
+
`),ee=B.slice(q),J=ee.find(T=>T.includes("Do you want to proceed?"))||"",oe=[];ee.forEach(T=>{const X=T.match(/^\s*(\d+)\.\s+(.+)$/);X&&oe.push({number:X[1],text:X[2].trim()})});const W=h.match(/>\s*(\d+)/),_=W?W[1]:null;return e.jsxs("div",{className:"space-y-3",children:[$&&e.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 text-gray-100 rounded-lg p-3 font-mono text-xs overflow-x-auto",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:$})}),e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-2",children:"交互式提示"}),e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:J}),e.jsx("div",{className:"space-y-2 mb-4",children:oe.map(T=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${_===T.number?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700 hover:border-amber-400 dark:hover:border-amber-600 hover:shadow-sm"} ${_?"cursor-default":"cursor-not-allowed opacity-75"}`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${_===T.number?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:T.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:T.text}),_===T.number&&e.jsx("svg",{className:"w-5 h-5 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]})},T.number))}),_&&e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsxs("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:["✓ Claude 选择了选项 ",_]}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"在 CLI 中,您可以使用方向键或输入数字来交互式地选择此选项。"})]})]})]})})]})}const j=h.match(/The file (.+?) has been updated\./);if(j)return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"文件更新成功"})}),e.jsx("button",{onClick:()=>{o&&o(j[1])},className:"text-xs font-mono bg-green-100 dark:bg-green-800/30 px-2 py-1 rounded text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline cursor-pointer",children:j[1]})]});const U=h.match(/(?:The file|File) (.+?) has been (?:created|written)(?: successfully)?\.?/);return U?e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"文件创建成功"})}),e.jsx("button",{onClick:()=>{o&&o(U[1])},className:"text-xs font-mono bg-green-100 dark:bg-green-800/30 px-2 py-1 rounded text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline cursor-pointer",children:U[1]})]}):t.toolName==="Write"&&!t.toolResult.isError?e.jsxs("div",{className:"text-green-700 dark:text-green-300",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"font-medium",children:"文件写入成功"})]}),e.jsx("p",{className:"text-xs mt-1 text-green-600 dark:text-green-400",children:"文件内容显示在上方的差异视图中"})]}):h.includes("cat -n")&&h.includes("→")?e.jsxs("details",{open:u,children:[e.jsxs("summary",{className:"text-sm text-green-700 dark:text-green-300 cursor-pointer hover:text-green-800 dark:hover:text-green-200 mb-2 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看文件内容"]}),e.jsx("div",{className:"mt-2 bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("div",{className:"text-xs font-mono p-3 whitespace-pre-wrap break-words overflow-hidden",children:h})})]}):h.length>300?e.jsxs("details",{open:u,children:[e.jsxs("summary",{className:"text-sm text-green-700 dark:text-green-300 cursor-pointer hover:text-green-800 dark:hover:text-green-200 mb-2 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看完整输出 (",h.length," 字符)"]}),e.jsx(yt,{className:"mt-2 prose prose-sm max-w-none prose-green dark:prose-invert",children:h})]}):e.jsx(yt,{className:"prose prose-sm max-w-none prose-green dark:prose-invert",children:h})})(),z&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!d)return;d(z)?.success?S("granted"):S("error")},disabled:z.isAllowed||R==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${z.isAllowed||R==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:z.isAllowed||R==="granted"?"权限已添加":`授予权限 ${z.toolName}`}),c&&e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),c()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:"打开设置"})]}),e.jsxs("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:["添加 ",e.jsx("span",{className:"font-mono",children:z.entry})," 到允许的工具列表。"]}),R==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"无法更新权限。请重试。"}),(z.isAllowed||R==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:"权限已保存。请重试请求以使用该工具。"})]})]})]}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:"交互式提示"}),(()=>{const p=t.content.split(`
|
|
58
|
+
`).filter(j=>j.trim()),m=p.find(j=>j.includes("?"))||p[0]||"",h=[];return p.forEach(j=>{const U=j.match(/[❯\s]*(\d+)\.\s+(.+)/);if(U){const B=j.includes("❯");h.push({number:U[1],text:U[2].trim(),isSelected:B})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:m}),e.jsx("div",{className:"space-y-2 mb-4",children:h.map(j=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${j.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${j.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:j.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:j.text}),j.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},j.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:"⏳ 等待您在 CLI 中的响应"}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"请在运行 Claude 的终端中选择一个选项。"})]})]})})()]})]})}):t.isToolUse&&t.toolName==="Read"?(()=>{try{const p=JSON.parse(t.toolInput);if(p.file_path){const m=p.file_path.split("/").pop();return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"Read"}),e.jsx("button",{onClick:()=>o&&o(p.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono transition-colors",children:m})]})})}}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"读取文件"})]})})}})():t.isToolUse&&t.toolName==="TodoWrite"?(()=>{try{const p=JSON.parse(t.toolInput);if(p.todos&&Array.isArray(p.todos))return e.jsxs("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 mb-2",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]}),e.jsx(br,{todos:p.todos})]})}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]})})}})():t.isToolUse&&t.toolName==="TodoRead"?e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsx("span",{className:"font-medium",children:"读取待办列表"})]})}):t.isThinking?e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{children:"💭 思考中..."})]}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(yt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[v&&t.reasoning&&e.jsxs("details",{className:"mb-3",children:[e.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:"💭 思考中..."}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:e.jsx("div",{className:"whitespace-pre-wrap",children:t.reasoning})})]}),(()=>{const p=Tr(String(t.content||"")),m=p.trim();if((m.startsWith("{")||m.startsWith("["))&&(m.endsWith("}")||m.endsWith("]")))try{const h=JSON.parse(m),j=JSON.stringify(h,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:"JSON 响应"})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:j})})})]})}catch{}return t.type==="assistant"?e.jsx(yt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:p}):e.jsx("div",{className:"whitespace-pre-wrap",children:p})})()]}),e.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${N?"opacity-0 group-hover:opacity-100":""}`,children:new Date(t.timestamp).toLocaleTimeString()})]})]})})}),Fo=({file:t,onRemove:r,uploadProgress:s,error:i})=>{const[o,c]=a.useState(null);return a.useEffect(()=>{const d=URL.createObjectURL(t);return c(d),()=>URL.revokeObjectURL(d)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:o,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),i&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})};function Oo({selectedProject:t,selectedSession:r,ws:s,sendMessage:i,messages:o,onFileOpen:c,onInputFocusChange:d,onSessionActive:u,onSessionInactive:g,onSessionProcessing:v,onSessionNotProcessing:f,processingSessions:E,onReplaceTemporarySession:N,onNavigateToSession:C,onShowSettings:x,autoExpandTools:P,showRawParameters:z,showThinking:R,autoScrollToBottom:S,sendByCtrlEnter:p,externalMessageUpdate:m,onTaskClick:h}){const[j,U]=a.useState(()=>typeof window<"u"&&t&&_e.getItem(`draft_input_${t.name}`)||""),[B,q]=a.useState(()=>{if(typeof window<"u"&&t){const l=_e.getItem(`chat_messages_${t.name}`);return l?JSON.parse(l):[]}return[]}),[$,ee]=a.useState(!1),[J,oe]=a.useState(r?.id||null),[W,_]=a.useState(!1),[T,X]=a.useState([]),[pe,ne]=a.useState(!1),[H,ie]=a.useState(!1),[ye,me]=a.useState(0),[le,ve]=a.useState(!1),[xe,we]=a.useState(0),K=20,[Q,I]=a.useState(!1),[Z,be]=a.useState("default"),[he,Ce]=a.useState([]),[Fe,Te]=a.useState([]),[ze,$e]=a.useState(new Map),[Be,Re]=a.useState(new Map),[Qe,qe]=a.useState(!1),He=a.useRef(null),n=a.useRef(null),k=a.useRef(null),F=a.useRef(null),A=a.useRef(null),D=a.useRef(!1),ue=a.useRef(!1),ce=a.useRef(!1),Ne=a.useRef(null),De=a.useRef(""),ke=a.useRef(null),Le=a.useRef(null),[Se,ct]=a.useState(""),[Je,L]=a.useState(!1),[G,se]=a.useState([]),[de,dt]=a.useState([]),[Ke,rr]=a.useState(-1),[Br,$t]=a.useState(0),[Ur,Rt]=a.useState(-1),[Ja,nt]=a.useState(!1),[ar,zt]=a.useState(!1),sr=a.useRef({height:0,top:0}),[Pt,et]=a.useState(!1),[Ve,nr]=a.useState([]),[mt,At]=a.useState([]),[Ft,tt]=a.useState(""),[Ka,ot]=a.useState(!1),[Ot,ft]=a.useState(null),[or,rt]=a.useState(-1),[qr,it]=a.useState(-1),[Ct,Va]=a.useState(100),[Ga,ut]=a.useState(null),[bt,Ya]=a.useState(()=>localStorage.getItem("claude-model")||ya.DEFAULT),at="claude";a.useEffect(()=>{if(r?.id){const l=localStorage.getItem(`permissionMode-${r.id}`);be(l||"default")}},[r?.id]),a.useEffect(()=>{Ce(l=>l.filter(y=>!y.sessionId||y.sessionId===r?.id))},[r?.id]),a.useEffect(()=>{(async()=>{if(t)try{const y=await ae("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!y.ok)throw new Error("Failed to fetch commands");const w=await y.json(),b=[...(w.builtIn||[]).map(te=>({...te,type:"built-in"})),...(w.custom||[]).map(te=>({...te,type:"custom"}))];nr(b);const M=`command_history_${t.name}`,Y=_e.getItem(M);if(Y)try{const te=JSON.parse(Y),O=b.sort((re,ge)=>{const Ee=te[re.name]||0;return(te[ge.name]||0)-Ee});nr(O)}catch(te){console.error("Error parsing command history:",te)}}catch(y){console.error("Error fetching slash commands:",y),nr([])}})()},[t]);const ir=a.useMemo(()=>Ve.length?new zs(Ve,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Ve]);a.useEffect(()=>{if(!Ft){At(Ve);return}if(!ir){At([]);return}const l=ir.search(Ft);At(l.map(y=>y.item))},[Ft,Ve,ir]);const Qa=a.useMemo(()=>{if(!t||Ve.length===0)return[];const l=`command_history_${t.name}`,y=_e.getItem(l);if(!y)return[];try{const w=JSON.parse(y);return Ve.map(M=>({...M,usageCount:w[M.name]||0})).filter(M=>M.usageCount>0).sort((M,Y)=>Y.usageCount-M.usageCount).slice(0,5)}catch(w){return console.error("Error parsing command history:",w),[]}},[t,Ve]),Za=a.useCallback((l,y,w)=>{if(!l||!t)return;if(w){rt(y);return}const b=`command_history_${t.name}`,M=_e.getItem(b);let Y={};try{Y=M?JSON.parse(M):{}}catch(te){console.error("Error parsing command history:",te)}Y[l.name]=(Y[l.name]||0)+1,_e.setItem(b,JSON.stringify(Y)),Hr(l)},[t]),Xa=a.useCallback(l=>{const{action:y,data:w}=l;switch(y){case"clear":q([]),X([]);break;case"help":q(b=>[...b,{type:"assistant",content:w.content,timestamp:Date.now()}]);break;case"model":q(b=>[...b,{type:"assistant",content:`**Current Model**: ${w.current.model}
|
|
59
|
+
|
|
60
|
+
**Available Models**: ${w.available.claude.join(", ")}`,timestamp:Date.now()}]);break;case"cost":{let b;w.usage?b=`**Token 使用量**: ${w.usage.used.toLocaleString()} / ${w.usage.total.toLocaleString()} (${w.usage.percentage}%)
|
|
61
|
+
|
|
62
|
+
**剩余**: ${w.usage.remaining.toLocaleString()} tokens`:b=w.message||"无可用的 Token 使用数据。",q(M=>[...M,{type:"assistant",content:b,timestamp:Date.now()}]);break}case"status":{const b=`**System Status**
|
|
63
|
+
|
|
64
|
+
- Version: ${w.version}
|
|
65
|
+
- Uptime: ${w.uptime}
|
|
66
|
+
- Model: ${w.model}
|
|
67
|
+
- Provider: ${w.provider}
|
|
68
|
+
- Node.js: ${w.nodeVersion}
|
|
69
|
+
- Platform: ${w.platform}`;q(M=>[...M,{type:"assistant",content:b,timestamp:Date.now()}]);break}case"memory":w.error?q(b=>[...b,{type:"assistant",content:`⚠️ ${w.message}`,timestamp:Date.now()}]):(q(b=>[...b,{type:"assistant",content:`📝 ${w.message}
|
|
70
|
+
|
|
71
|
+
Path: \`${w.path}\``,timestamp:Date.now()}]),w.exists&&c&&c(w.path));break;case"config":x&&x();break;case"rewind":w.error?q(b=>[...b,{type:"assistant",content:`⚠️ ${w.message}`,timestamp:Date.now()}]):(q(b=>b.slice(0,-w.steps*2)),q(b=>[...b,{type:"assistant",content:`⏪ ${w.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",y)}},[c,x]),lr=a.useRef(null),es=a.useCallback(async(l,y)=>{const{content:w,hasBashCommands:b,hasFileIncludes:M}=l;if(b&&!window.confirm("此命令包含将被执行的 bash 命令。是否继续?")){q(te=>[...te,{type:"assistant",content:"❌ 命令执行已取消",timestamp:Date.now()}]);return}U(w),setTimeout(()=>{if(lr.current){const Y={preventDefault:()=>{}};lr.current(Y)}},50)},[]),Hr=a.useCallback(async l=>{if(!(!l||!t))try{const y=j.match(new RegExp(`${l.name}\\s*(.*)`)),w=y&&y[1]?y[1].trim().split(/\s+/):[],b={projectPath:t.path,projectName:t.name,sessionId:J,provider:at,model:bt,tokenUsage:Ot},M=await ae("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:l.name,commandPath:l.path,args:w,context:b})});if(!M.ok)throw new Error("Failed to execute command");const Y=await M.json();Y.type==="builtin"?Xa(Y):Y.type==="custom"&&await es(Y,w),U(""),et(!1),it(-1),tt(""),rt(-1)}catch(y){console.error("Error executing command:",y),q(w=>[...w,{type:"assistant",content:`Error executing command: ${y.message}`,timestamp:Date.now()}])}},[j,t,J,at,bt,Ot]),ts=a.useMemo(()=>{const l=new Map;return(y,w)=>{const b=`${y.length}-${w.length}-${y.slice(0,50)}`;if(l.has(b))return l.get(b);const M=rs(y,w);if(l.set(b,M),l.size>100){const Y=l.keys().next().value;l.delete(Y)}return M}},[]),Et=a.useCallback(async(l,y,w=!1,b="claude")=>{if(!l||!y)return[];const M=!w;M?ne(!0):ie(!0);try{const Y=w?ye:0,te=await fe.sessionMessages(l,y,K,Y,b);if(!te.ok)throw new Error("Failed to load session messages");const O=await te.json();if(M&&O.tokenUsage&&ft(O.tokenUsage),O.hasMore!==void 0)return ve(O.hasMore),we(O.total),me(Y+(O.messages?.length||0)),O.messages||[];{const re=O.messages||[];return ve(!1),we(re.length),re}}catch(Y){return console.error("Error loading session messages:",Y),[]}finally{M?ne(!1):ie(!1)}},[ye]),rs=(l,y)=>{const w=l.split(`
|
|
72
|
+
`),b=y.split(`
|
|
73
|
+
`),M=[];let Y=0,te=0;for(;Y<w.length||te<b.length;){const O=w[Y],re=b[te];Y>=w.length?(M.push({type:"added",content:re,lineNum:te+1}),te++):te>=b.length?(M.push({type:"removed",content:O,lineNum:Y+1}),Y++):O===re?(Y++,te++):(M.push({type:"removed",content:O,lineNum:Y+1}),M.push({type:"added",content:re,lineNum:te+1}),Y++,te++)}return M},as=l=>{const y=[],w=new Map;for(const b of l)if(b.message?.role==="user"&&Array.isArray(b.message?.content))for(const M of b.message.content)M.type==="tool_result"&&w.set(M.tool_use_id,{content:M.content,isError:M.is_error,timestamp:new Date(b.timestamp||Date.now()),toolUseResult:b.toolUseResult||null});for(const b of l)if(!b.isMeta){if(b.message?.role==="user"&&b.message?.content){let M="",Y="user";if(Array.isArray(b.message.content)){const re=[];for(const ge of b.message.content)ge.type==="text"&&re.push(vt(ge.text));M=re.join(`
|
|
74
|
+
`)}else typeof b.message.content=="string"?M=vt(b.message.content):M=vt(String(b.message.content));const te=M.match(/<command-name>(\/[^<]+)<\/command-name>/);te&&(M=te[1]),!M||M.startsWith("<command-args>")||M.startsWith("<local-command-stdout>")||M.startsWith("<system-reminder>")||M.startsWith("Caveat:")||M.startsWith("This session is being continued from a previous")||M.startsWith("[Request interrupted")||(M=Ht(M),y.push({type:Y,content:M,timestamp:b.timestamp||new Date().toISOString()}))}else if(b.type==="thinking"&&b.message?.content)y.push({type:"assistant",content:Ht(b.message.content),timestamp:b.timestamp||new Date().toISOString(),isThinking:!0});else if(b.type==="tool_use"&&b.toolName)y.push({type:"assistant",content:"",timestamp:b.timestamp||new Date().toISOString(),isToolUse:!0,toolName:b.toolName,toolInput:b.toolInput||"",toolCallId:b.toolCallId});else if(b.type==="tool_result"){for(let M=y.length-1;M>=0;M--)if(y[M].isToolUse&&!y[M].toolResult&&(!b.toolCallId||y[M].toolCallId===b.toolCallId)){y[M].toolResult={content:b.output||"",isError:!1};break}}else if(b.message?.role==="assistant"&&b.message?.content){if(Array.isArray(b.message.content)){for(const M of b.message.content)if(M.type==="text"){let Y=M.text;typeof Y=="string"&&(Y=Ht(Y)),y.push({type:"assistant",content:Y,timestamp:b.timestamp||new Date().toISOString()})}else if(M.type==="tool_use"){const Y=w.get(M.id);y.push({type:"assistant",content:"",timestamp:b.timestamp||new Date().toISOString(),isToolUse:!0,toolName:M.name,toolInput:JSON.stringify(M.input),toolResult:Y?{content:typeof Y.content=="string"?Y.content:JSON.stringify(Y.content),isError:Y.isError,toolUseResult:Y.toolUseResult}:null,toolError:Y?.isError||!1,toolResultTimestamp:Y?.timestamp||new Date})}}else if(typeof b.message.content=="string"){let M=b.message.content;M=Ht(M),y.push({type:"assistant",content:M,timestamp:b.timestamp||new Date().toISOString()})}}}return y},Jr=a.useMemo(()=>as(T),[T]),st=a.useCallback(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[]),_t=a.useCallback(()=>{if(!A.current)return!1;const{scrollTop:l,scrollHeight:y,clientHeight:w}=A.current;return y-l-w<50},[]),Kr=a.useCallback(async l=>{if(!l||ue.current||H||!le||!r||!t)return!1;ue.current=!0;const y=l.scrollHeight,w=l.scrollTop;try{const b=await Et(t.name,r.id,!0,"claude");return b.length>0&&(Ne.current={height:y,top:w},X(M=>[...b,...M])),!0}finally{ue.current=!1}},[le,H,r,t,Et]),Mt=a.useCallback(async()=>{if(A.current){const l=A.current,y=_t();zt(!y),l.scrollTop<100?ce.current||await Kr(l)&&(ce.current=!0):ce.current=!1}},[_t,Kr]);a.useLayoutEffect(()=>{if(!Ne.current||!A.current)return;const{height:l,top:y}=Ne.current,w=A.current,M=w.scrollHeight-l;w.scrollTop=y+Math.max(M,0),Ne.current=null},[B.length]),a.useEffect(()=>{(async()=>{if(r&&t){const y=localStorage.getItem("selected-provider")||"claude";if(D.current=!0,J!==null&&J!==r.id?(me(0),ve(!1),we(0),ft(null),ee(!1),s&&i&&i({type:"check-session-status",sessionId:r.id,provider:y})):J===null&&(me(0),ve(!1),we(0),s&&i&&i({type:"check-session-status",sessionId:r.id,provider:y})),oe(r.id),Q)I(!1);else{const b=await Et(t.name,r.id,!1,"claude");X(b)}}else!Q&&!$&&(q([]),X([])),oe(null),me(0),ve(!1),we(0);setTimeout(()=>{D.current=!1},250)})()},[r,t,st,Q]),a.useEffect(()=>{m>0&&r&&t&&(async()=>{try{const y=await Et(t.name,r.id,!1,"claude");X(y),S&&_t()&&setTimeout(()=>st(),200)}catch(y){console.error("Error reloading messages from external update:",y)}})()},[m,r,t,Et,_t,S,st]),a.useEffect(()=>{T.length>0&&!$&&q(Jr)},[Jr,T,$]),a.useEffect(()=>{d&&d(W)},[W,d]),a.useEffect(()=>{t&&j!==""?_e.setItem(`draft_input_${t.name}`,j):t&&j===""&&_e.removeItem(`draft_input_${t.name}`)},[j,t]),a.useEffect(()=>{t&&B.length>0&&_e.setItem(`chat_messages_${t.name}`,JSON.stringify(B))},[B,t]),a.useEffect(()=>{if(t){const l=_e.getItem(`draft_input_${t.name}`)||"";l!==j&&U(l)}},[t?.name]),a.useEffect(()=>{J&&$&&v&&v(J)},[$,J,v]),a.useEffect(()=>{J&&E&&E.has(J)&&!$&&(ee(!0),nt(!0))},[J,E]),a.useEffect(()=>{if(o.length>0){const l=o[o.length-1];if(!["projects_updated","session-created","claude-complete"].includes(l.type)&&l.sessionId&&J&&l.sessionId!==J){console.log("⏭️ Skipping message for different session:",l.sessionId,"current:",J);return}switch(l.type){case"session-created":l.sessionId&&!J&&(sessionStorage.setItem("pendingSessionId",l.sessionId),I(!0),N&&N(l.sessionId),Ce(O=>O.map(re=>re.sessionId?re:{...re,sessionId:l.sessionId})));break;case"token-budget":l.data&&ft(l.data);break;case"claude-response":const b=l.data.message||l.data;if(b&&typeof b=="object"&&b.type){if(b.type==="content_block_delta"&&b.delta?.text){const O=vt(b.delta.text);De.current+=O,ke.current||(ke.current=setTimeout(()=>{const re=De.current;De.current="",ke.current=null,re&&q(ge=>{const Ee=[...ge],Oe=Ee[Ee.length-1];return Oe&&Oe.type==="assistant"&&!Oe.isToolUse&&Oe.isStreaming?Oe.content=(Oe.content||"")+re:Ee.push({type:"assistant",content:re,timestamp:new Date,isStreaming:!0}),Ee})},100));return}if(b.type==="content_block_stop"){ke.current&&(clearTimeout(ke.current),ke.current=null);const O=De.current;De.current="",O&&q(re=>{const ge=[...re],Ee=ge[ge.length-1];return Ee&&Ee.type==="assistant"&&!Ee.isToolUse&&Ee.isStreaming?Ee.content=(Ee.content||"")+O:ge.push({type:"assistant",content:O,timestamp:new Date,isStreaming:!0}),ge}),q(re=>{const ge=[...re],Ee=ge[ge.length-1];return Ee&&Ee.type==="assistant"&&Ee.isStreaming&&(Ee.isStreaming=!1),ge});return}}if(l.data.type==="system"&&l.data.subtype==="init"&&l.data.session_id&&J&&l.data.session_id!==J){console.log("🔄 Claude CLI session duplication detected:",{originalSession:J,newSession:l.data.session_id}),I(!0),C&&C(l.data.session_id);return}if(l.data.type==="system"&&l.data.subtype==="init"&&l.data.session_id&&!J){console.log("🔄 New session init detected:",{newSession:l.data.session_id}),I(!0),C&&C(l.data.session_id);return}if(l.data.type==="system"&&l.data.subtype==="init"&&l.data.session_id&&J&&l.data.session_id===J){console.log("🔄 System init message for current session, ignoring");return}if(Array.isArray(b.content)){for(const O of b.content)if(O.type==="tool_use"){const re=O.input?JSON.stringify(O.input,null,2):"";q(ge=>[...ge,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:O.name,toolInput:re,toolId:O.id,toolResult:null}])}else if(O.type==="text"&&O.text?.trim()){let re=vt(O.text);re=Tr(re),q(ge=>[...ge,{type:"assistant",content:re,timestamp:new Date}])}}else if(typeof b.content=="string"&&b.content.trim()){let O=vt(b.content);O=Tr(O),q(re=>[...re,{type:"assistant",content:O,timestamp:new Date}])}if(b.role==="user"&&Array.isArray(b.content))for(const O of b.content)O.type==="tool_result"&&q(re=>re.map(ge=>ge.isToolUse&&ge.toolId===O.tool_use_id?{...ge,toolResult:{content:O.content,isError:O.is_error,timestamp:new Date}}:ge));break;case"claude-output":{const O=String(l.data||"");O.trim()&&(De.current+=De.current?`
|
|
75
|
+
${O}`:O,ke.current||(ke.current=setTimeout(()=>{const re=De.current;De.current="",ke.current=null,re&&q(ge=>{const Ee=[...ge],Oe=Ee[Ee.length-1];return Oe&&Oe.type==="assistant"&&!Oe.isToolUse&&Oe.isStreaming?Oe.content=Oe.content?`${Oe.content}
|
|
76
|
+
${re}`:re:Ee.push({type:"assistant",content:re,timestamp:new Date,isStreaming:!0}),Ee})},100)))}break;case"claude-interactive-prompt":q(O=>[...O,{type:"assistant",content:l.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(!l.requestId)break;Ce(O=>O.some(re=>re.requestId===l.requestId)?O:[...O,{requestId:l.requestId,toolName:l.toolName||"UnknownTool",input:l.input,context:l.context,sessionId:l.sessionId||null,receivedAt:new Date}]),ee(!0),nt(!0),ut({text:"等待权限",tokens:0,can_interrupt:!0});break}case"claude-permission-cancelled":{if(!l.requestId)break;Ce(O=>O.filter(re=>re.requestId!==l.requestId));break}case"claude-error":q(O=>[...O,{type:"error",content:`错误: ${l.error}`,timestamp:new Date}]);break;case"claude-complete":const M=l.sessionId||J||sessionStorage.getItem("pendingSessionId");(M===J||!J)&&(ee(!1),nt(!1),ut(null)),M&&(g&&g(M),f&&f(M));const Y=sessionStorage.getItem("pendingSessionId");Y&&!J&&l.exitCode===0&&(oe(Y),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",Y)),t&&l.exitCode===0&&_e.removeItem(`chat_messages_${t.name}`),Ce([]);break;case"session-aborted":{const O=l.sessionId||J;O===J&&(ee(!1),nt(!1),ut(null)),O&&(g&&g(O),f&&f(O)),Ce([]),q(re=>[...re,{type:"assistant",content:"会话已被用户中断。",timestamp:new Date}]);break}case"session-status":{const O=l.sessionId;(O===J||r&&O===r.id)&&l.isProcessing&&(ee(!0),nt(!0),v&&v(O));break}case"claude-status":const te=l.data;if(te){let O={text:"处理中...",tokens:0,can_interrupt:!0};te.message?O.text=te.message:te.status?O.text=te.status:typeof te=="string"&&(O.text=te),te.tokens?O.tokens=te.tokens:te.token_count&&(O.tokens=te.token_count),te.can_interrupt!==void 0&&(O.can_interrupt=te.can_interrupt),ut(O),ee(!0),nt(O.can_interrupt)}break}}},[o]),a.useEffect(()=>{t&&ss()},[t]);const ss=async()=>{try{const l=await fe.getFiles(t.name);if(l.ok){const y=await l.json(),w=Vr(y);se(w)}}catch(l){console.error("Error fetching files:",l)}},Vr=(l,y="")=>{let w=[];for(const b of l){const M=y?`${y}/${b.name}`:b.name;b.type==="directory"&&b.children?w=w.concat(Vr(b.children,M)):b.type==="file"&&w.push({name:b.name,path:M,relativePath:b.path})}return w};a.useEffect(()=>{const l=j.slice(0,Br),y=l.lastIndexOf("@");if(y!==-1){const w=l.slice(y+1);if(w.includes(" "))L(!1),Rt(-1);else{Rt(y),L(!0);const b=G.filter(M=>M.name.toLowerCase().includes(w.toLowerCase())||M.path.toLowerCase().includes(w.toLowerCase())).slice(0,10);dt(b),rr(-1)}}else L(!1),Rt(-1)},[j,Br,G]),a.useEffect(()=>{const l=setTimeout(()=>{ct(j)},150);return()=>clearTimeout(l)},[j]);const Gr=a.useMemo(()=>B.length<=Ct?B:B.slice(-Ct),[B,Ct]);a.useEffect(()=>{if(!S&&A.current){const l=A.current;sr.current={height:l.scrollHeight,top:l.scrollTop}}}),a.useEffect(()=>{if(A.current&&B.length>0)if(S)ar||setTimeout(()=>st(),50);else{const l=A.current,y=sr.current.height,w=sr.current.top,M=l.scrollHeight-y;M>0&&w>0&&(l.scrollTop=w+M)}},[B.length,ar,st,S]),a.useEffect(()=>{A.current&&B.length>0&&!D.current&&(zt(!1),setTimeout(()=>{st()},200))},[r?.id,t?.name]),a.useEffect(()=>{const l=A.current;if(l)return l.addEventListener("scroll",Mt),()=>l.removeEventListener("scroll",Mt)},[Mt]),a.useEffect(()=>{if(n.current){n.current.style.height="auto",n.current.style.height=n.current.scrollHeight+"px";const l=parseInt(window.getComputedStyle(n.current).lineHeight),y=n.current.scrollHeight>l*2;ot(y)}},[]),a.useEffect(()=>{n.current&&!j.trim()&&(n.current.style.height="auto",ot(!1))},[j]),a.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){ft(null);return}(async()=>{try{const y=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,w=await ae(y);if(w.ok){const b=await w.json();ft(b)}else ft(null)}catch(y){console.error("Failed to fetch initial token usage:",y)}})()},[r?.id,r?.__provider,t?.path]);const ns=a.useCallback(l=>{l.trim()&&U(y=>{const w=y.trim()?`${y} ${l}`:l;return setTimeout(()=>{if(n.current){n.current.style.height="auto",n.current.style.height=n.current.scrollHeight+"px";const b=parseInt(window.getComputedStyle(n.current).lineHeight),M=n.current.scrollHeight>b*2;ot(M)}},0),w})},[]),os=a.useCallback(()=>{Va(l=>l+100)},[]),Wt=a.useCallback(l=>{const y=l.filter(w=>{try{if(!w||typeof w!="object")return console.warn("Invalid file object:",w),!1;if(!w.type||!w.type.startsWith("image/"))return!1;if(!w.size||w.size>5242880){const b=w.name||"Unknown file";return Re(M=>{const Y=new Map(M);return Y.set(b,"文件太大(最大 5MB)"),Y}),!1}return!0}catch(b){return console.error("Error validating file:",b,w),!1}});y.length>0&&Te(w=>[...w,...y].slice(0,5))},[]),is=a.useCallback(async l=>{const y=l.target.files;if(!(!y||y.length===0||!t)){qe(!0);try{const w=new FormData;Array.from(y).forEach(Y=>{w.append("files",Y)});const b=await fe.uploadFiles(t.name,w);if(!b.ok){const Y=await b.json();throw new Error(Y.error||"上传失败")}const M=await b.json();if(M.files&&M.files.length>0){const Y=M.files.map(O=>`@${O.name}`).join(" "),te=j?`${j} ${Y} `:`${Y} `;U(te),n.current&&n.current.focus()}}catch(w){console.error("File upload failed:",w)}finally{qe(!1),k.current&&(k.current.value="")}}},[t,j]),ls=a.useCallback(async l=>{const y=Array.from(l.clipboardData.items);for(const w of y)if(w.type.startsWith("image/")){const b=w.getAsFile();b&&Wt([b])}if(y.length===0&&l.clipboardData.files.length>0){const b=Array.from(l.clipboardData.files).filter(M=>M.type.startsWith("image/"));b.length>0&&Wt(b)}},[Wt]),{getRootProps:cs,getInputProps:ds,isDragActive:ms,open:us}=Or({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Wt,noClick:!0,noKeyboard:!0}),pt=a.useCallback(async l=>{if(l.preventDefault(),!j.trim()||$||!t)return;let y=[];if(Fe.length>0){const O=new FormData;Fe.forEach(re=>{O.append("images",re)});try{const re=await ae(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:O});if(!re.ok)throw new Error("图片上传失败");y=(await re.json()).images}catch(re){console.error("Image upload failed:",re),q(ge=>[...ge,{type:"error",content:`图片上传失败: ${re.message}`,timestamp:new Date}]);return}}const w={type:"user",content:j,images:y,timestamp:new Date};q(O=>[...O,w]),ee(!0),nt(!0),ut({text:"处理中",tokens:0,can_interrupt:!0}),zt(!1),setTimeout(()=>st(),100);const M=J||r?.id||`new-session-${Date.now()}`;u&&u(M);const te=(()=>{try{const O=_e.getItem("claude-settings");if(O)return JSON.parse(O)}catch(O){console.error("Error loading tools settings:",O)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();i({type:"claude-command",command:j,options:{projectPath:t.path,cwd:t.fullPath,sessionId:J,resume:!!J,toolsSettings:te,permissionMode:Z,model:bt,images:y}}),U(""),Te([]),$e(new Map),Re(new Map),ot(!1),n.current&&(n.current.style.height="auto"),t&&_e.removeItem(`draft_input_${t.name}`)},[j,$,t,Fe,J,r,at,Z,u,bt,i,U,Te,$e,Re,ot,n,q,ee,nt,ut,zt,st]),Yr=a.useCallback(l=>!l||at!=="claude"?{success:!1}:zo(l.entry),[at]),cr=a.useCallback((l,y)=>{const b=(Array.isArray(l)?l:[l]).filter(Boolean);b.length!==0&&(b.forEach(M=>{i({type:"claude-permission-response",requestId:M,allow:!!y?.allow,updatedInput:y?.updatedInput,message:y?.message,rememberEntry:y?.rememberEntry})}),Ce(M=>{const Y=M.filter(te=>!b.includes(te.requestId));return Y.length===0&&ut(null),Y}))},[i]);a.useEffect(()=>{lr.current=pt},[pt]);const Qr=l=>{if(!l)return;const y=j.slice(0,qr),w=j.slice(qr),b=w.indexOf(" "),M=b!==-1?w.slice(b):"",Y=y+l.name+" "+M;U(Y),et(!1),it(-1),tt(""),rt(-1),Le.current&&clearTimeout(Le.current),Hr(l)},ps=l=>{if(Pt&&mt.length>0){if(l.key==="ArrowDown"){l.preventDefault(),rt(y=>y<mt.length-1?y+1:0);return}if(l.key==="ArrowUp"){l.preventDefault(),rt(y=>y>0?y-1:mt.length-1);return}if(l.key==="Tab"||l.key==="Enter"){l.preventDefault(),or>=0?Qr(mt[or]):mt.length>0&&Qr(mt[0]);return}if(l.key==="Escape"){l.preventDefault(),et(!1),it(-1),tt(""),rt(-1),Le.current&&clearTimeout(Le.current);return}}if(Je&&de.length>0){if(l.key==="ArrowDown"){l.preventDefault(),rr(y=>y<de.length-1?y+1:0);return}if(l.key==="ArrowUp"){l.preventDefault(),rr(y=>y>0?y-1:de.length-1);return}if(l.key==="Tab"||l.key==="Enter"){l.preventDefault(),Ke>=0?dr(de[Ke]):de.length>0&&dr(de[0]);return}if(l.key==="Escape"){l.preventDefault(),L(!1);return}}if(l.key==="Tab"&&!Je&&!Pt){l.preventDefault();const y=["default","acceptEdits","bypassPermissions","plan"],b=(y.indexOf(Z)+1)%y.length,M=y[b];be(M),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,M);return}if(l.key==="Enter"){if(l.nativeEvent.isComposing)return;(l.ctrlKey||l.metaKey)&&!l.shiftKey?(l.preventDefault(),pt(l)):!l.shiftKey&&!l.ctrlKey&&!l.metaKey&&(p||(l.preventDefault(),pt(l)))}},dr=l=>{const y=j.slice(0,Ur),w=j.slice(Ur),b=w.indexOf(" "),M=b!==-1?w.slice(b):"",Y=y+"@"+l.path+" "+M,te=y.length+1+l.path.length+1;n.current&&!n.current.matches(":focus")&&n.current.focus(),U(Y),$t(te),L(!1),Rt(-1),n.current&&requestAnimationFrame(()=>{n.current&&(n.current.setSelectionRange(te,te),n.current.matches(":focus")||n.current.focus())})},xs=l=>{const y=l.target.value,w=l.target.selectionStart;if(!J&&y.trim(),U(y),$t(w),!y.trim()){l.target.style.height="auto",ot(!1),et(!1),it(-1),tt("");return}const b=y.slice(0,w);if((b.match(/```/g)||[]).length%2===1){et(!1),it(-1),tt("");return}const te=/(^|\s)\/(\S*)$/,O=b.match(te);if(O){const re=O.index+O[1].length,ge=O[2];it(re),et(!0),rt(-1),Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{tt(ge)},150)}else et(!1),it(-1),tt(""),Le.current&&clearTimeout(Le.current)},gs=l=>{$t(l.target.selectionStart)},hs=()=>{J&&Ja&&i({type:"abort-session",sessionId:J,provider:at})},fs=()=>{const l=["default","acceptEdits","bypassPermissions","plan"],w=(l.indexOf(Z)+1)%l.length,b=l[w];be(b),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,b)};return t?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
77
|
+
details[open] .details-chevron {
|
|
78
|
+
transform: rotate(180deg);
|
|
79
|
+
}
|
|
80
|
+
`}),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:A,onWheel:Mt,onTouchMove:Mt,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 space-y-3 sm:space-y-4 relative",children:[pe&&B.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:"正在加载会话消息..."})]})}):B.length===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[!r&&!J&&e.jsxs("div",{className:"text-center px-6 sm:px-4 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-3",children:"开始新对话"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-8",children:"与 Claude 对话以获取代码帮助"}),e.jsx("div",{className:"flex flex-col items-center justify-center mb-8",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(Xe,{className:"w-10 h-10"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-white",children:"Claude"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"by Anthropic"})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"选择模型"}),e.jsx("select",{value:bt,onChange:l=>{const y=l.target.value;Ya(y),localStorage.setItem("claude-model",y)},className:"pl-4 pr-10 py-2 text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 min-w-[140px]",children:ya.OPTIONS.map(({value:l,label:y})=>e.jsx("option",{value:l,children:y},l))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["已准备好使用 Claude ",bt,"。请在下方输入您的消息。"]})]}),r&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 px-6 sm:px-4",children:[e.jsx("p",{className:"font-bold text-lg sm:text-xl mb-3",children:"继续您的对话"}),e.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:"询问代码问题、请求修改或获取开发任务帮助"})]})]}):e.jsxs(e.Fragment,{children:[H&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:"正在加载历史消息..."})]})}),le&&!H&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:xe>0&&e.jsxs("span",{children:["显示 ",T.length," 条 / 共 ",xe," 条消息 •",e.jsx("span",{className:"text-xs",children:"向上滚动加载更多"})]})}),!le&&B.length>Ct&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:["显示最近 ",Ct," 条消息(共 ",B.length," 条) •",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:os,children:"加载更早的消息"})]}),Gr.map((l,y)=>{const w=y>0?Gr[y-1]:null,b=l.id||`${l.type}-${l.timestamp?.getTime?.()||y}-${y}`;return e.jsx(Ao,{message:l,index:y,prevMessage:w,createDiff:ts,onFileOpen:c,onShowSettings:x,onGrantToolPermission:Yr,autoExpandTools:P,showRawParameters:z,showThinking:R,selectedProject:t,provider:at},b)})]}),$&&e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(Xe,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Claude"})]}),e.jsx("div",{className:"w-full text-sm text-gray-500 dark:text-gray-400 pl-3 sm:pl-0",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"animate-pulse",children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"●"}),e.jsx("span",{className:"ml-2",children:"思考中..."})]})})]})}),e.jsx("div",{ref:He})]}),e.jsxs("div",{className:"p-2 sm:p-4 md:p-4 flex-shrink-0 pb-2 sm:pb-4 md:pb-6",children:[e.jsx("div",{className:"flex-1",children:e.jsx(Mo,{status:Ga,isLoading:$,onAbort:hs,provider:at,showThinking:R})}),e.jsxs("div",{ref:F,className:"max-w-4xl mx-auto mb-3",children:[he.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:he.map(l=>{const y=ja(l.input),w=$r(l.toolName,y),b=_r(),M=w?b.allowedTools.includes(w):!1,Y=M?"已允许(已保存)":"允许并记住",te=w?he.filter(O=>$r(O.toolName,ja(O.input))===w).map(O=>O.requestId):[l.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"需要权限"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["工具: ",e.jsx("span",{className:"font-mono",children:l.toolName})]})]}),w&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["允许规则: ",e.jsx("span",{className:"font-mono",children:w})]})]}),y&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"查看工具输入"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:y})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>cr(l.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"允许一次"}),e.jsx("button",{type:"button",onClick:()=>{w&&!M&&Yr({entry:w,toolName:l.toolName}),cr(te,{allow:!0,rememberEntry:w})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${w?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!w,children:Y}),e.jsx("button",{type:"button",onClick:()=>cr(l.requestId,{allow:!1,message:"用户拒绝工具使用"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"拒绝"})]})]},l.requestId)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",onClick:fs,className:`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${Z==="default"?"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-200 dark:hover:bg-gray-600":Z==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 border-green-300 dark:border-green-600 hover:bg-green-100 dark:hover:bg-green-900/30":Z==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 border-orange-300 dark:border-orange-600 hover:bg-orange-100 dark:hover:bg-orange-900/30":"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 border-blue-300 dark:border-blue-600 hover:bg-blue-100 dark:hover:bg-blue-900/30"}`,title:"点击切换权限模式(或在输入框中按 Tab)",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${Z==="default"?"bg-gray-500":Z==="acceptEdits"?"bg-green-500":Z==="bypassPermissions"?"bg-orange-500":"bg-blue-500"}`}),e.jsxs("span",{children:[Z==="default"&&"默认模式",Z==="acceptEdits"&&"接受编辑",Z==="bypassPermissions"&&"跳过权限",Z==="plan"&&"计划模式"]})]})}),e.jsx(Do,{used:Ot?.used||0,total:Ot?.total||parseInt("160000")||16e4}),e.jsxs("button",{type:"button",onClick:()=>{const l=!Pt;et(l),tt(""),rt(-1),l&&At(Ve),n.current&&n.current.focus()},className:"relative w-8 h-8 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",title:"显示所有命令",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),Ve.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-blue-600 text-white text-xs font-bold rounded-full w-5 h-5 flex items-center justify-center",style:{fontSize:"10px"},children:Ve.length})]}),j.trim()&&e.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),U(""),n.current&&(n.current.style.height="auto",n.current.focus()),ot(!1)},className:"w-8 h-8 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-full flex items-center justify-center transition-all duration-200 group shadow-sm",title:"清除输入",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300 group-hover:text-gray-800 dark:group-hover:text-gray-100 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),ar&&B.length>0&&e.jsx("button",{onClick:st,className:"w-8 h-8 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg flex items-center justify-center transition-all duration-200 hover:scale-105 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",title:"滚动到底部",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})]}),e.jsxs("form",{onSubmit:pt,className:"relative max-w-4xl mx-auto",children:[ms&&e.jsx("div",{className:"absolute inset-0 bg-blue-500/20 border-2 border-dashed border-blue-500 rounded-lg flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-4 shadow-lg",children:[e.jsx("svg",{className:"w-8 h-8 text-blue-500 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"将图片拖放到这里"})]})}),Fe.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Fe.map((l,y)=>e.jsx(Fo,{file:l,onRemove:()=>{Te(w=>w.filter((b,M)=>M!==y))},uploadProgress:ze.get(l.name),error:Be.get(l.name)},y))})}),Je&&de.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg max-h-48 overflow-y-auto z-50 backdrop-blur-sm",children:de.map((l,y)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${y===Ke?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:w=>{w.preventDefault(),w.stopPropagation()},onClick:w=>{w.preventDefault(),w.stopPropagation(),dr(l)},children:[e.jsx("div",{className:"font-medium text-sm",children:l.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:l.path})]},l.path))}),e.jsx(To,{commands:mt,selectedIndex:or,onSelect:Za,onClose:()=>{et(!1),it(-1),tt(""),rt(-1)},position:{top:n.current?Math.max(16,n.current.getBoundingClientRect().top-316):0,left:n.current?n.current.getBoundingClientRect().left:16,bottom:n.current?window.innerHeight-n.current.getBoundingClientRect().top+8:90},isOpen:Pt,frequentCommands:Ft?[]:Qa}),e.jsxs("div",{...cs(),className:`relative bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-600 focus-within:ring-2 focus-within:ring-blue-500 dark:focus-within:ring-blue-500 focus-within:border-blue-500 transition-all duration-200 overflow-hidden ${Ka?"chat-input-expanded":""}`,children:[e.jsx("input",{...ds()}),e.jsx("textarea",{ref:n,value:j,onChange:xs,onClick:gs,onKeyDown:ps,onPaste:ls,onFocus:()=>_(!0),onBlur:()=>_(!1),onInput:l=>{l.target.style.height="auto",l.target.style.height=l.target.scrollHeight+"px",$t(l.target.selectionStart);const y=parseInt(window.getComputedStyle(l.target).lineHeight),w=l.target.scrollHeight>y*2;ot(w)},placeholder:"输入 / 使用命令,@ 引用文件,或向 Claude 提问...",disabled:$,className:"chat-input-placeholder block w-full pl-20 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-sm sm:text-base leading-[21px] sm:leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:us,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"添加图片",children:e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("input",{type:"file",ref:k,onChange:is,className:"hidden",multiple:!0}),e.jsx("button",{type:"button",onClick:()=>k.current?.click(),disabled:Qe||!t,className:"absolute left-10 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50",title:"上传文件并引用",children:Qe?e.jsxs("svg",{className:"w-5 h-5 text-gray-500 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),e.jsx("div",{className:"absolute right-16 sm:right-16 top-1/2 transform -translate-y-1/2",style:{display:"none"},children:e.jsx(Lo,{onTranscript:ns,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!j.trim()||$,onMouseDown:l=>{l.preventDefault(),pt(l)},onTouchStart:l=>{l.preventDefault(),pt(l)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-12 h-12 sm:w-12 sm:h-12 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-20 right-14 sm:right-40 text-xs text-gray-400 dark:text-gray-500 pointer-events-none hidden sm:block transition-opacity duration-200 ${j.trim()?"opacity-0":"opacity-100"}`,children:p?"Ctrl+Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令":"Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令"})]})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"选择一个项目开始与 Claude 对话"})})})}const _o=Ge.memo(Oo);function Rr({file:t,onClose:r,projectPath:s,isSidebar:i=!1,isExpanded:o=!1,onToggleExpand:c=null}){const[d,u]=a.useState(""),[g,v]=a.useState(!0),[f,E]=a.useState(!1),[N,C]=a.useState(!1),[x,P]=a.useState(()=>{const W=localStorage.getItem("codeEditorTheme");return W?W==="dark":!0}),[z,R]=a.useState(!1),[S,p]=a.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[m,h]=a.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[j,U]=a.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),B=a.useRef(null),q=a.useMemo(()=>{const W=()=>{const _=document.createElement("div");_.className="cm-editor-toolbar-panel";const T=()=>{let X='<div style="display: flex; align-items: center; justify-content: flex-end; width: 100%;">';X+='<div style="display: flex; align-items: center; gap: 4px;">',X+=`
|
|
81
|
+
<button class="cm-toolbar-btn cm-settings-btn" title="Editor Settings">
|
|
82
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
83
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
84
|
+
</svg>
|
|
85
|
+
</button>
|
|
86
|
+
`,i&&c&&(X+=`
|
|
87
|
+
<button class="cm-toolbar-btn cm-expand-btn" title="${o?"Collapse editor":"Expand editor to full width"}">
|
|
88
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
89
|
+
${o?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
|
|
90
|
+
</svg>
|
|
91
|
+
</button>
|
|
92
|
+
`),X+="</div>",X+="</div>",_.innerHTML=X,_.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),i&&c&&_.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{c()})};return T(),{top:!0,dom:_,update:T}};return[bs.of(W)]},[i,o,c]),$=W=>{const _=W.split(".").pop()?.toLowerCase();switch(_){case"js":case"jsx":case"ts":case"tsx":return[Es({jsx:!0,typescript:_.includes("ts")})];case"py":return[Cs()];case"html":case"htm":return[Ss()];case"css":case"scss":case"less":return[Ns()];case"json":return[ws()];case"md":case"markdown":return[ks()];default:return[]}};a.useEffect(()=>{(async()=>{try{v(!0);const _=await fe.readFile(t.projectName,t.path);if(!_.ok)throw new Error(`Failed to load file: ${_.status} ${_.statusText}`);const T=await _.json();u(T.content)}catch(_){console.error("Error loading file:",_),u(`// Error loading file: ${_.message}
|
|
93
|
+
// File: ${t.name}
|
|
94
|
+
// Path: ${t.path}`)}finally{v(!1)}})()},[t,s]);const ee=async()=>{E(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:d?.length});const W=await fe.saveFile(t.projectName,t.path,d);if(console.log("Save response:",{status:W.status,ok:W.ok,contentType:W.headers.get("content-type")}),!W.ok){const T=W.headers.get("content-type");if(T&&T.includes("application/json")){const X=await W.json();throw new Error(X.error||`Save failed: ${W.status}`)}else{const X=await W.text();throw console.error("Non-JSON error response:",X),new Error(`Save failed: ${W.status} ${W.statusText}`)}}const _=await W.json();console.log("Save successful:",_),R(!0),setTimeout(()=>R(!1),2e3)}catch(W){console.error("Error saving file:",W),alert(`Error saving file: ${W.message}`)}finally{E(!1)}},J=()=>{const W=new Blob([d],{type:"text/plain"}),_=URL.createObjectURL(W),T=document.createElement("a");T.href=_,T.download=t.name,document.body.appendChild(T),T.click(),document.body.removeChild(T),URL.revokeObjectURL(_)},oe=()=>{C(!N)};return a.useEffect(()=>{localStorage.setItem("codeEditorTheme",x?"dark":"light")},[x]),a.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",S.toString())},[S]),a.useEffect(()=>{const W=()=>{const _=localStorage.getItem("codeEditorTheme");_&&P(_==="dark");const T=localStorage.getItem("codeEditorWordWrap");T!==null&&p(T==="true");const X=localStorage.getItem("codeEditorLineNumbers");X!==null&&h(X!=="false");const pe=localStorage.getItem("codeEditorFontSize");pe&&U(pe)};return window.addEventListener("storage",W),window.addEventListener("codeEditorSettingsChanged",W),()=>{window.removeEventListener("storage",W),window.removeEventListener("codeEditorSettingsChanged",W)}},[]),a.useEffect(()=>{const W=_=>{(_.ctrlKey||_.metaKey)&&(_.key==="s"?(_.preventDefault(),ee()):_.key==="Escape"&&(_.preventDefault(),r()))};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[d]),g?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
95
|
+
.code-editor-loading {
|
|
96
|
+
background-color: ${x?"#111827":"#ffffff"} !important;
|
|
97
|
+
}
|
|
98
|
+
.code-editor-loading:hover {
|
|
99
|
+
background-color: ${x?"#111827":"#ffffff"} !important;
|
|
100
|
+
}
|
|
101
|
+
`}),i?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsxs("span",{className:"text-gray-900 dark:text-white",children:["Loading ",t.name,"..."]})]})}):e.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsxs("span",{className:"text-gray-900 dark:text-white",children:["Loading ",t.name,"..."]})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
102
|
+
/* Editor toolbar panel styling */
|
|
103
|
+
.cm-editor-toolbar-panel {
|
|
104
|
+
padding: 8px 12px;
|
|
105
|
+
background-color: ${x?"#1f2937":"#ffffff"};
|
|
106
|
+
border-bottom: 1px solid ${x?"#374151":"#e5e7eb"};
|
|
107
|
+
color: ${x?"#d1d5db":"#374151"};
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.cm-toolbar-btn {
|
|
112
|
+
padding: 4px;
|
|
113
|
+
background: transparent;
|
|
114
|
+
border: none;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
color: inherit;
|
|
121
|
+
transition: background-color 0.2s;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.cm-toolbar-btn:hover {
|
|
125
|
+
background-color: ${x?"#374151":"#f3f4f6"};
|
|
126
|
+
}
|
|
127
|
+
`}),e.jsx("div",{className:i?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${N?"md:p-0":""}`,children:e.jsxs("div",{className:i?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(N?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:t.name})}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:J,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download file",children:e.jsx(Pr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:ee,disabled:f,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${z?"bg-green-600 hover:bg-green-700":"bg-blue-600 hover:bg-blue-700"}`,children:z?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:f?"Saving...":"Save"})]})}),!i&&e.jsx("button",{onClick:oe,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:N?"Exit fullscreen":"Fullscreen",children:N?e.jsx(Ws,{className:"w-4 h-4"}):e.jsx(Ea,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(Pe,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(vs,{ref:B,value:d,onChange:u,extensions:[...$(t.name),...q,...S?[js.lineWrapping]:[]],theme:x?ys:void 0,height:"100%",style:{fontSize:`${j}px`,height:"100%"},basicSetup:{lineNumbers:m,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",d.split(`
|
|
128
|
+
`).length]}),e.jsxs("span",{children:["Characters: ",d.length]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]})})]})}function Wo({file:t,onClose:r}){const s=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[i,o]=a.useState(null),[c,d]=a.useState(null),[u,g]=a.useState(!0);return a.useEffect(()=>{let v;const f=new AbortController;return(async()=>{try{g(!0),d(null),o(null);const N=await ae(s,{signal:f.signal});if(!N.ok)throw new Error(`Request failed with status ${N.status}`);const C=await N.blob();v=URL.createObjectURL(C),o(v)}catch(N){if(N.name==="AbortError")return;console.error("Error loading image:",N),d("无法加载图像")}finally{g(!1)}})(),()=>{f.abort(),v&&URL.revokeObjectURL(v)}},[s]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(V,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(Pe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[u&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!u&&i&&e.jsx("img",{src:i,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!u&&!i&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:c||"无法加载图像"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:t.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.path})})]})})}function Bo({selectedProject:t}){const[r,s]=a.useState([]),[i,o]=a.useState(!1),[c,d]=a.useState(new Set),[u,g]=a.useState(null),[v,f]=a.useState(null),[E,N]=a.useState("detailed"),[C,x]=a.useState(""),[P,z]=a.useState([]),[R,S]=a.useState(!1),[p,m]=a.useState(!1),[h,j]=a.useState(null),[U,B]=a.useState({}),[q,$]=a.useState(null);a.useEffect(()=>{t&&J()},[t]),a.useEffect(()=>{const K=localStorage.getItem("file-tree-view-mode");K&&["simple","detailed","compact"].includes(K)&&N(K)},[]),a.useEffect(()=>{if(!C.trim())z(r);else{const K=ee(r,C.toLowerCase());z(K);const Q=I=>{I.forEach(Z=>{Z.type==="directory"&&Z.children&&Z.children.length>0&&(d(be=>new Set(be.add(Z.path))),Q(Z.children))})};Q(K)}},[r,C]);const ee=(K,Q)=>K.reduce((I,Z)=>{const be=Z.name.toLowerCase().includes(Q);let he=[];return Z.type==="directory"&&Z.children&&(he=ee(Z.children,Q)),(be||he.length>0)&&I.push({...Z,children:he}),I},[]),J=async()=>{o(!0);try{const K=await fe.getFiles(t.name);if(!K.ok){const I=await K.text();console.error("❌ File fetch failed:",K.status,I),s([]);return}const Q=await K.json();s(Q)}catch(K){console.error("❌ Error fetching files:",K),s([])}finally{o(!1)}},oe=a.useCallback(async K=>{if(!t||K.length===0)return;m(!0),j(null);const Q=new FormData;K.forEach(Z=>{Q.append("files",Z)});const I={};K.forEach(Z=>{I[Z.name]=0}),B(I);try{const Z=await fe.uploadFiles(t.name,Q);if(!Z.ok){const he=await Z.json();throw new Error(he.error||"Upload failed")}const be={};K.forEach(he=>{be[he.name]=100}),B(be),await J(),setTimeout(()=>{S(!1),B({})},1e3)}catch(Z){console.error("Upload failed:",Z),j(Z.message)}finally{m(!1)}},[t]),{getRootProps:W,getInputProps:_,isDragActive:T,open:X}=Or({onDrop:oe,noClick:!0,noKeyboard:!0}),pe=async K=>{if(t)try{const Q=await fe.deleteFile(t.name,K);if(!Q.ok){const I=await Q.json();throw new Error(I.error||"Delete failed")}await J(),$(null)}catch(Q){console.error("Delete failed:",Q),alert(`Failed to delete: ${Q.message}`)}},ne=K=>{const Q=new Set(c);Q.has(K)?Q.delete(K):Q.add(K),d(Q)},H=K=>{N(K),localStorage.setItem("file-tree-view-mode",K)},ie=K=>{if(!K||K===0)return"0 B";const Q=1024,I=["B","KB","MB","GB"],Z=Math.floor(Math.log(K)/Math.log(Q));return parseFloat((K/Math.pow(Q,Z)).toFixed(1))+" "+I[Z]},ye=K=>{if(!K)return"-";const Q=new Date,I=new Date(K),Z=Math.floor((Q-I)/1e3);return Z<60?"just now":Z<3600?`${Math.floor(Z/60)} min ago`:Z<86400?`${Math.floor(Z/3600)} hours ago`:Z<2592e3?`${Math.floor(Z/86400)} days ago`:I.toLocaleDateString()},me=(K,Q=0)=>K.map(I=>e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Ie("w-full flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${Q*16+12}px`},onClick:()=>{I.type==="directory"?ne(I.path):le(I.name)?f({name:I.name,path:I.path,projectPath:t.path,projectName:t.name}):g({name:I.name,path:I.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[I.type==="directory"?c.has(I.path)?e.jsx(gt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(lt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):ve(I.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:I.name})]}),e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Z=>{Z.stopPropagation(),$({path:I.path,name:I.name,type:I.type})},title:`删除${I.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ue,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]}),I.type==="directory"&&c.has(I.path)&&I.children&&I.children.length>0&&e.jsx("div",{children:me(I.children,Q+1)})]},I.path)),le=K=>{const Q=K.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(Q)},ve=K=>{const Q=K.split(".").pop()?.toLowerCase(),I=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],Z=["md","txt","doc","pdf"],be=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return I.includes(Q)?e.jsx(qs,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):Z.includes(Q)?e.jsx(Da,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):be.includes(Q)?e.jsx(ta,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(ta,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},xe=(K,Q=0)=>K.map(I=>e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Ie("grid grid-cols-12 gap-2 p-2 hover:bg-accent cursor-pointer items-center"),style:{paddingLeft:`${Q*16+12}px`},onClick:()=>{I.type==="directory"?ne(I.path):le(I.name)?f({name:I.name,path:I.path,projectPath:t.path,projectName:t.name}):g({name:I.name,path:I.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[I.type==="directory"?c.has(I.path)?e.jsx(gt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(lt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):ve(I.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:I.name})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:I.type==="file"?ie(I.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:ye(I.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:I.permissionsRwx||"-"}),e.jsx("div",{className:"col-span-1 flex justify-end",children:e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Z=>{Z.stopPropagation(),$({path:I.path,name:I.name,type:I.type})},title:`删除${I.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ue,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})})]}),I.type==="directory"&&c.has(I.path)&&I.children&&xe(I.children,Q+1)]},I.path)),we=(K,Q=0)=>K.map(I=>e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Ie("flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${Q*16+12}px`},onClick:()=>{I.type==="directory"?ne(I.path):le(I.name)?f({name:I.name,path:I.path,projectPath:t.path,projectName:t.name}):g({name:I.name,path:I.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[I.type==="directory"?c.has(I.path)?e.jsx(gt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(lt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):ve(I.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:I.name})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[I.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ie(I.size)}),e.jsx("span",{className:"font-mono",children:I.permissionsRwx})]}),e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Z=>{Z.stopPropagation(),$({path:I.path,name:I.name,type:I.type})},title:`删除${I.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ue,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),I.type==="directory"&&c.has(I.path)&&I.children&&we(I.children,Q+1)]},I.path));return i?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"加载文件中..."})}):e.jsxs("div",{...W(),className:Ie("h-full flex flex-col bg-card relative",T&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{..._()}),T&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 flex items-center justify-center z-10 pointer-events-none",children:e.jsx("div",{className:"text-primary font-medium",children:"拖放文件以上传"})}),e.jsxs("div",{className:"p-4 border-b border-border space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"文件"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(V,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(!0),title:"上传文件",children:e.jsx(ea,{className:"w-4 h-4"})}),e.jsx(V,{variant:E==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>H("simple"),title:"简单视图",children:e.jsx(Bs,{className:"w-4 h-4"})}),e.jsx(V,{variant:E==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>H("compact"),title:"紧凑视图",children:e.jsx(Ma,{className:"w-4 h-4"})}),e.jsx(V,{variant:E==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>H("detailed"),title:"详细视图",children:e.jsx(Us,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(wt,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(We,{type:"text",placeholder:"搜索文件和文件夹...",value:C,onChange:K=>x(K.target.value),className:"pl-8 pr-8 h-8 text-sm"}),C&&e.jsx(V,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-accent",onClick:()=>x(""),title:"清除搜索",children:e.jsx(Pe,{className:"w-3 h-3"})})]})]}),E==="detailed"&&P.length>0&&e.jsx("div",{className:"px-4 pt-2 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-2 text-xs font-medium text-muted-foreground",children:[e.jsx("div",{className:"col-span-4",children:"名称"}),e.jsx("div",{className:"col-span-2",children:"大小"}),e.jsx("div",{className:"col-span-3",children:"修改时间"}),e.jsx("div",{className:"col-span-2",children:"权限"}),e.jsx("div",{className:"col-span-1"})]})}),e.jsx(Ar,{className:"flex-1 p-4",children:r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(lt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"未找到文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"检查项目路径是否可访问"})]}):P.length===0&&C?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(wt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"无匹配结果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试不同的搜索条件或清除搜索"})]}):e.jsxs("div",{className:E==="detailed"?"":"space-y-1",children:[E==="simple"&&me(P),E==="compact"&&we(P),E==="detailed"&&xe(P)]})}),u&&e.jsx(Rr,{file:u,onClose:()=>g(null),projectPath:u.projectPath}),v&&e.jsx(Wo,{file:v,onClose:()=>f(null)}),R&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-md mx-4 border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"上传文件"}),e.jsx(V,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{S(!1),j(null),B({})},children:e.jsx(Pe,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:X,className:Ie("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(ea,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-foreground",children:"将文件拖到此处或点击浏览"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"每次上传最多 20 个文件"})]}),Object.keys(U).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(U).map(([K,Q])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:K}),e.jsx("div",{className:"w-20 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Q}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[Q,"%"]})]},K))}),h&&e.jsx("div",{className:"mt-4 p-3 bg-destructive/10 border border-destructive/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-destructive",children:h})}),p&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),q&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-sm mx-4 border border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"确认删除"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["确定要删除",q.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',q.name,'"']}),"?",q.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(V,{variant:"outline",size:"sm",onClick:()=>$(null),children:"取消"}),e.jsx(V,{variant:"destructive",size:"sm",onClick:()=>pe(q.path),children:"删除"})]})]})})]})}var Uo=gn(),qo=hn(),Ho=fn(),Jo=bn();const Ko=`
|
|
129
|
+
.xterm .xterm-screen {
|
|
130
|
+
outline: none !important;
|
|
131
|
+
}
|
|
132
|
+
.xterm:focus .xterm-screen {
|
|
133
|
+
outline: none !important;
|
|
134
|
+
}
|
|
135
|
+
.xterm-screen:focus {
|
|
136
|
+
outline: none !important;
|
|
137
|
+
}
|
|
138
|
+
`;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=Ko,document.head.appendChild(t)}function Vo({selectedProject:t,selectedSession:r,initialCommand:s,isPlainShell:i=!1,onProcessComplete:o,minimal:c=!1,autoConnect:d=!1}){const u=a.useRef(null),g=a.useRef(null),v=a.useRef(null),f=a.useRef(null),[E,N]=a.useState(!1),[C,x]=a.useState(!1),[P,z]=a.useState(!1),[R,S]=a.useState(null),[p,m]=a.useState(!1),h=a.useRef(t),j=a.useRef(r),U=a.useRef(s),B=a.useRef(i),q=a.useRef(o);a.useEffect(()=>{h.current=t,j.current=r,U.current=s,B.current=i,q.current=o});const $=a.useCallback(async()=>{if(!(p||E))try{let pe;{const ne=localStorage.getItem("auth-token");if(!ne){console.error("No authentication token found for Shell WebSocket connection");return}pe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ne)}`}f.current=new WebSocket(pe),f.current.onopen=()=>{N(!0),m(!1),setTimeout(()=>{v.current&&g.current&&(v.current.fit(),f.current.send(JSON.stringify({type:"init",projectPath:h.current.fullPath||h.current.path,sessionId:B.current?null:j.current?.id,hasSession:B.current?!1:!!j.current,provider:B.current?"plain-shell":j.current?.__provider||"claude",cols:g.current.cols,rows:g.current.rows,initialCommand:U.current,isPlainShell:B.current})))},100)},f.current.onmessage=ne=>{try{const H=JSON.parse(ne.data);if(H.type==="output"){let ie=H.data;if(B.current&&q.current){const ye=ie.replace(/\x1b\[[0-9;]*m/g,"");if(ye.includes("Process exited with code 0"))q.current(0);else if(ye.match(/Process exited with code (\d+)/)){const me=parseInt(ye.match(/Process exited with code (\d+)/)[1]);me!==0&&q.current(me)}}g.current&&g.current.write(ie)}else H.type==="url_open"&&window.open(H.url,"_blank")}catch(H){console.error("[Shell] Error handling WebSocket message:",H,ne.data)}},f.current.onclose=ne=>{N(!1),m(!1),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H"))},f.current.onerror=ne=>{N(!1),m(!1)}}catch{N(!1),m(!1)}},[p,E]),ee=a.useCallback(()=>{!C||E||p||(m(!0),$())},[C,E,p,$]),J=a.useCallback(()=>{f.current&&(f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"terminate"})),f.current.close(),f.current=null),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H")),N(!1),m(!1)},[]),oe=a.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),W=a.useMemo(()=>oe?oe.slice(0,30):null,[oe]),_=a.useMemo(()=>oe?oe.slice(0,50):null,[oe]),T=()=>{z(!0),f.current&&(f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"terminate"})),f.current.close(),f.current=null),g.current&&(g.current.dispose(),g.current=null,v.current=null),N(!1),x(!1),setTimeout(()=>{z(!1)},200)};return a.useEffect(()=>{const X=r?.id||null;R!==null&&R!==X&&C&&J(),S(X)},[r?.id,C,J]),a.useEffect(()=>{if(!u.current||!t||P||g.current)return;g.current=new Uo.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),v.current=new qo.FitAddon;const X=new Ho.WebglAddon,pe=new Jo.WebLinksAddon;g.current.loadAddon(v.current),g.current.loadAddon(pe);try{g.current.loadAddon(X)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}g.current.open(u.current),g.current.attachCustomKeyEventHandler(H=>(H.ctrlKey||H.metaKey)&&H.key==="c"&&g.current.hasSelection()?(document.execCommand("copy"),!1):(H.ctrlKey||H.metaKey)&&H.key==="v"?(navigator.clipboard.readText().then(ie=>{f.current&&f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"input",data:ie}))}).catch(()=>{}),!1):!0),setTimeout(()=>{v.current&&(v.current.fit(),g.current&&f.current&&f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows})))},100),x(!0),g.current.onData(H=>{f.current&&f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"input",data:H}))});const ne=new ResizeObserver(()=>{v.current&&g.current&&setTimeout(()=>{v.current.fit(),f.current&&f.current.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows}))},50)});return u.current&&ne.observe(u.current),()=>{ne.disconnect(),f.current&&(f.current.readyState===WebSocket.OPEN||f.current.readyState===WebSocket.CONNECTING)&&f.current.close(),f.current=null,g.current&&(g.current.dispose(),g.current=null)}},[t?.path||t?.fullPath,P]),a.useEffect(()=>{!d||!C||p||E||ee()},[d,C,p,E,ee]),t?c?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:u,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${E?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",W,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!C&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),P&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[E&&e.jsxs("button",{onClick:J,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Shell 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:T,disabled:P||E,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Shell(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:u,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!C&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),C&&!E&&!p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:ee,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:"Connect to shell",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"在 Shell 中继续"})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:i?`Run ${s||"command"} in ${t.displayName}`:r?`Resume session: ${_}...`:"Start a new Claude session"})]})}),p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Shell..."})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:i?`Running ${s||"command"} in ${t.displayName}`:`Starting Claude CLI in ${t.displayName}`})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开交互式 Shell"})]})})}function Go({project:t,session:r=null,command:s=null,isPlainShell:i=null,autoConnect:o=!0,onComplete:c=null,onClose:d=null,title:u=null,className:g="",showHeader:v=!0,compact:f=!1,minimal:E=!1}){const[N,C]=a.useState(!1),x=i!==null?i:s!==null,P=a.useCallback(z=>{C(!0),c&&c(z)},[c]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${g}`,children:[!E&&v&&u&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:u}),N&&e.jsx("span",{className:"text-xs text-green-400",children:"(已完成)"})]}),d&&e.jsx("button",{onClick:d,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(Vo,{selectedProject:t,selectedSession:r,initialCommand:s,isPlainShell:x,onProcessComplete:P,minimal:E,autoConnect:E?!0:o})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${g}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Shell 需要一个项目"})]})})}class Yo extends Ge.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){console.error("ErrorBoundary caught an error:",r,s),this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"出现问题"})]}),e.jsxs("div",{className:"text-sm text-red-700",children:[e.jsx("p",{className:"mb-2",children:"加载聊天界面时出现错误。"}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"错误详情"}),e.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"重试"})})]})}):this.props.children}}const vr=({children:t,content:r,position:s="top",className:i="",delay:o=500})=>{const[c,d]=a.useState(!1),[u,g]=a.useState(null),v=()=>{const C=setTimeout(()=>{d(!0)},o);g(C)},f=()=>{u&&(clearTimeout(u),g(null)),d(!1)},E=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},N=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:v,onMouseLeave:f,children:[t,c&&e.jsxs("div",{className:Ie("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",E(),i),children:[r,e.jsx("div",{className:Ie("absolute w-0 h-0 border-4 border-transparent",N())})]})]}):t};function Qo({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:i,ws:o,sendMessage:c,messages:d,isMobile:u,isPWA:g,onMenuClick:v,isLoading:f,onInputFocusChange:E,onSessionActive:N,onSessionInactive:C,onSessionProcessing:x,onSessionNotProcessing:P,processingSessions:z,onReplaceTemporarySession:R,onNavigateToSession:S,onShowSettings:p,autoExpandTools:m,showRawParameters:h,showThinking:j,autoScrollToBottom:U,sendByCtrlEnter:B,externalMessageUpdate:q}){const[$,ee]=a.useState(null),[J,oe]=a.useState(600),[W,_]=a.useState(!1),[T,X]=a.useState(!1),pe=a.useRef(null),ne=(me,le=null)=>{const ve={name:me.split("/").pop(),path:me,projectName:t?.name,diffInfo:le};ee(ve)},H=()=>{ee(null),X(!1)},ie=()=>{X(!T)},ye=me=>{u||(_(!0),me.preventDefault())};return a.useEffect(()=>{const me=ve=>{if(!W)return;const xe=pe.current?.parentElement;if(!xe)return;const we=xe.getBoundingClientRect(),K=we.right-ve.clientX,Q=300,I=we.width*.8;K>=Q&&K<=I&&oe(K)},le=()=>{_(!1)};return W&&(document.addEventListener("mousemove",me),document.addEventListener("mouseup",le),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",le),document.body.style.cursor="",document.body.style.userSelect=""}},[W]),f?e.jsxs("div",{className:"h-full flex flex-col",children:[u&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:v,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"正在加载 AgentHub"}),e.jsx("p",{children:"正在设置您的工作区..."})]})})]}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between relative",children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[u&&e.jsx("button",{onClick:v,onTouchStart:me=>{me.preventDefault(),v()},className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[s==="chat"&&r&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:s==="chat"&&r?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:r.summary||"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):s==="chat"&&!r?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:s==="files"?"项目文件":"项目"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]})})]})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx(vr,{content:"Chat",position:"bottom",children:e.jsx("button",{onClick:()=>i("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${s==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),e.jsx(vr,{content:"Shell",position:"bottom",children:e.jsx("button",{onClick:()=>i("shell"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${s==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),e.jsx(vr,{content:"Files",position:"bottom",children:e.jsx("button",{onClick:()=>i("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${s==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})})]})})]})}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${$?"mr-0":""} ${T?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(Yo,{showDetails:!0,children:e.jsx(_o,{selectedProject:t,selectedSession:r,ws:o,sendMessage:c,messages:d,onFileOpen:ne,onInputFocusChange:E,onSessionActive:N,onSessionInactive:C,onSessionProcessing:x,onSessionNotProcessing:P,processingSessions:z,onReplaceTemporarySession:R,onNavigateToSession:S,onShowSettings:p,autoExpandTools:m,showRawParameters:h,showThinking:j,autoScrollToBottom:U,sendByCtrlEnter:B,externalMessageUpdate:q})})}),s==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Bo,{selectedProject:t})}),s==="shell"&&e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(Go,{project:t,session:r,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="preview"?"block":"hidden"}`})]}),$&&!u&&e.jsxs(e.Fragment,{children:[!T&&e.jsx("div",{ref:pe,onMouseDown:ye,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${T?"flex-1":""}`,style:T?{}:{width:`${J}px`},children:e.jsx(Rr,{file:$,onClose:H,projectPath:t?.path,isSidebar:!0,isExpanded:T,onToggleExpand:ie})})]})]}),$&&u&&e.jsx(Rr,{file:$,onClose:H,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[u&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:v,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),e.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"选择您的项目"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"从侧边栏选择一个项目,开始与 Claude 进行编码。每个项目包含您的聊天会话和文件历史。"}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",e.jsx("strong",{children:"提示:"})," ",u?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const Zo=Ge.memo(Qo);function Xo({activeTab:t,setActiveTab:r,isInputFocused:s}){const i=[{id:"chat",icon:kt,onClick:()=>r("chat")},{id:"shell",icon:Zt,onClick:()=>r("shell")},{id:"files",icon:lt,onClick:()=>r("files")}];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"flex items-center justify-around py-1",children:i.map(o=>{const c=o.icon,d=t===o.id;return e.jsxs("button",{onClick:o.onClick,onTouchStart:u=>{u.preventDefault(),o.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${d?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":o.id,children:[e.jsx(c,{className:"w-5 h-5"}),d&&e.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},o.id)})})})}const Ua=a.createContext(),Wr=()=>{const t=a.useContext(Ua);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},ei=({children:t})=>{const[r,s]=a.useState(()=>{const c=localStorage.getItem("theme");return c?c==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});a.useEffect(()=>{if(r){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const c=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');c&&c.setAttribute("content","black-translucent");const d=document.querySelector('meta[name="theme-color"]');d&&d.setAttribute("content","#0c1117")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const c=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');c&&c.setAttribute("content","default");const d=document.querySelector('meta[name="theme-color"]');d&&d.setAttribute("content","#ffffff")}},[r]),a.useEffect(()=>{if(!window.matchMedia)return;const c=window.matchMedia("(prefers-color-scheme: dark)"),d=u=>{localStorage.getItem("theme")||s(u.matches)};return c.addEventListener("change",d),()=>c.removeEventListener("change",d)},[]);const o={isDarkMode:r,toggleDarkMode:()=>{s(c=>!c)}};return e.jsx(Ua.Provider,{value:o,children:t})},qa=a.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1}),Tt=()=>{const t=a.useContext(qa);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t},ti=({children:t})=>{const[r,s]=a.useState(null),[i,o]=a.useState(localStorage.getItem("auth-token")),[c,d]=a.useState(!0),[u,g]=a.useState(!1),[v,f]=a.useState(!1),[E,N]=a.useState(null);a.useEffect(()=>{C()},[]);const C=async()=>{try{d(!0),N(null);const m=await(await fe.auth.status()).json();if(f(m.smtpConfigured||!1),m.needsSetup){g(!0),d(!1);return}if(i)try{const h=await fe.auth.user();if(h.ok){const j=await h.json();s(j.user),g(!1)}else localStorage.removeItem("auth-token"),o(null),s(null)}catch(h){console.error("Token verification failed:",h),localStorage.removeItem("auth-token"),o(null),s(null)}}catch(p){console.error("[AuthContext] Auth status check failed:",p),N("Failed to check authentication status")}finally{d(!1)}},S={user:r,token:i,login:async(p,m)=>{try{N(null);const h=await fe.auth.login(p,m),j=await h.json();return h.ok?(o(j.token),s(j.user),localStorage.setItem("auth-token",j.token),{success:!0}):(N(j.error||"登录失败"),{success:!1,error:j.error||"登录失败"})}catch(h){console.error("Login error:",h);const j="网络错误,请稍后再试";return N(j),{success:!1,error:j}}},sendCode:async p=>{try{N(null);const m=await fe.auth.sendCode(p),h=await m.json();return m.ok?{success:!0,type:h.type}:{success:!1,error:h.error||"发送验证码失败",waitSeconds:h.waitSeconds}}catch(m){return console.error("Send code error:",m),{success:!1,error:"网络错误,请稍后再试"}}},verifyCode:async(p,m)=>{try{N(null);const h=await fe.auth.verifyCode(p,m),j=await h.json();return h.ok?(o(j.token),s(j.user),g(!1),localStorage.setItem("auth-token",j.token),{success:!0}):(N(j.error||"验证失败"),{success:!1,error:j.error||"验证失败"})}catch(h){return console.error("Verify code error:",h),{success:!1,error:"网络错误,请稍后再试"}}},logout:()=>{o(null),s(null),localStorage.removeItem("auth-token"),i&&fe.auth.logout().catch(p=>{console.error("Logout endpoint error:",p)})},isLoading:c,needsSetup:u,smtpConfigured:v,error:E,isAdmin:r?.role==="admin"};return e.jsx(qa.Provider,{value:S,children:t})},ri=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ai=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function si({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:i,disallowedTools:o,setDisallowedTools:c,newAllowedTool:d,setNewAllowedTool:u,newDisallowedTool:g,setNewDisallowedTool:v}){const f=x=>{x&&!s.includes(x)&&(i([...s,x]),u(""))},E=x=>{i(s.filter(P=>P!==x))},N=x=>{x&&!o.includes(x)&&(c([...o,x]),v(""))},C=x=>{c(o.filter(P=>P!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-sky-50 dark:bg-sky-900/20 border border-sky-200 dark:border-sky-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Hs,{className:"w-5 h-5 text-sky-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-sky-800 dark:text-sky-200",children:[e.jsx("span",{className:"font-medium",children:"提示:"}),"此权限设置仅对 ",e.jsx("span",{className:"font-medium",children:"Chat(聊天)"})," 中的 Claude Agent 生效,对 ",e.jsx("span",{className:"font-medium",children:"Shell(终端)"})," 无效。Shell 是直接的系统终端,不受此权限控制。"]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 --dangerously-skip-permissions 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(We,{value:d,onChange:x=>u(x.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),f(d))},className:"flex-1 h-10"}),e.jsxs(V,{onClick:()=>f(d),disabled:!d,size:"sm",className:"h-10 px-4",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用工具:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ri.map(x=>e.jsx(V,{variant:"outline",size:"sm",onClick:()=>f(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>E(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Pe,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的工具"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(We,{value:g,onChange:x=>v(x.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),N(g))},className:"flex-1 h-10"}),e.jsxs(V,{onClick:()=>N(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[o.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>C(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Pe,{className:"w-4 h-4"})})]},x)),o.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的工具"})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"工具模式示例:"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - 允许所有 git log 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - 允许所有 git diff 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - 允许所有 Write 工具使用"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - 阻止所有 rm 命令(危险)"]})]})]})]})}function ni({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:i,disallowedCommands:o,setDisallowedCommands:c,newAllowedCommand:d,setNewAllowedCommand:u,newDisallowedCommand:g,setNewDisallowedCommand:v}){const f=x=>{x&&!s.includes(x)&&(i([...s,x]),u(""))},E=x=>{i(s.filter(P=>P!==x))},N=x=>{x&&!o.includes(x)&&(c([...o,x]),v(""))},C=x=>{c(o.filter(P=>P!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 Cursor CLI 中的 -f 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(We,{value:d,onChange:x=>u(x.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),f(d))},className:"flex-1 h-10"}),e.jsxs(V,{onClick:()=>f(d),disabled:!d,size:"sm",className:"h-10 px-4",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用命令:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ai.map(x=>e.jsx(V,{variant:"outline",size:"sm",onClick:()=>f(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>E(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Pe,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的命令"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(We,{value:g,onChange:x=>v(x.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),N(g))},className:"flex-1 h-10"}),e.jsxs(V,{onClick:()=>N(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[o.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>C(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Pe,{className:"w-4 h-4"})})]},x)),o.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的命令"})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell 命令示例:"}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - 允许 ls 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - 允许 git status"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - 允许 npm install"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - 阻止递归删除"]})]})]})]})}function oi({permissionMode:t,setPermissionMode:r}){return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限模式"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"控制 Codex 如何处理文件修改和命令执行"}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"默认"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"仅受信任的命令(ls、cat、grep、git status 等)会自动运行。其他命令将被跳过。可以写入工作区。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"接受编辑"}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"所有命令在工作区内自动运行。沙盒执行的完全自动模式。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["跳过权限",e.jsx(It,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"无限制的完全系统访问。所有命令自动运行,具有完全的磁盘和网络访问权限。请谨慎使用。"})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"技术详情"}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),e.jsx("p",{className:"text-xs opacity-75",children:"您可以在聊天界面中使用模式按钮为每个会话覆盖此设置。"})]})]})]})})}function ii({agent:t,...r}){return t==="claude"?e.jsx(si,{...r}):t==="cursor"?e.jsx(ni,{...r}):t==="codex"?e.jsx(oi,{...r}):null}const li=t=>{switch(t){case"stdio":return e.jsx(Zt,{className:"w-4 h-4"});case"sse":return e.jsx(Js,{className:"w-4 h-4"});case"http":return e.jsx(wr,{className:"w-4 h-4"});default:return e.jsx(er,{className:"w-4 h-4"})}};function ci({servers:t,onAdd:r,onEdit:s,onDelete:i,onTest:o,onDiscoverTools:c,testResults:d,serverTools:u,toolsLoading:g}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Claude 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(V,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(v=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[li(v.type),e.jsx("span",{className:"font-medium text-foreground",children:v.name}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:v.type}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:v.scope==="local"?"local":v.scope==="user"?"user":v.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[v.type==="stdio"&&v.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:v.config.command})]}),(v.type==="sse"||v.type==="http")&&v.config?.url&&e.jsxs("div",{children:["URL:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:v.config.url})]}),v.config?.args&&v.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:v.config.args.join(" ")})]})]}),d?.[v.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${d[v.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:d[v.id].message})}),u?.[v.id]&&u[v.id].tools?.length>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:["工具(",u[v.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[u[v.id].tools.slice(0,5).map((f,E)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:f.name},E)),u[v.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",u[v.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(V,{onClick:()=>s(v),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Dt,{className:"w-4 h-4"})}),e.jsx(V,{onClick:()=>i(v.id,v.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ue,{className:"w-4 h-4"})})]})]})},v.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function di({servers:t,onAdd:r,onEdit:s,onDelete:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Cursor 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(V,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Zt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:o.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(V,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Dt,{className:"w-4 h-4"})}),e.jsx(V,{onClick:()=>i(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]})]})},o.name||o.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function mi({servers:t,onAdd:r,onEdit:s,onDelete:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Codex 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(V,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Zt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(Ae,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[o.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),o.config?.args&&o.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),o.config?.env&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:["环境变量:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([c,d])=>`${c}=${d}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(V,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Dt,{className:"w-4 h-4"})}),e.jsx(V,{onClick:()=>i(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ue,{className:"w-4 h-4"})})]})]})},o.name)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"关于 Codex MCP"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex 支持基于 stdio 的 MCP 服务器。您可以添加扩展 Codex 功能的服务器,提供额外的工具和资源。"})]})]})}function ui({agent:t,...r}){return t==="claude"?e.jsx(ci,{...r}):t==="cursor"?e.jsx(di,{...r}):t==="codex"?e.jsx(mi,{...r}):null}function pi({onNavigateToUsage:t}){const[r,s]=a.useState([]),[i,o]=a.useState({}),[c,d]=a.useState(!0),[u,g]=a.useState(null),[v,f]=a.useState(!1),[E,N]=a.useState(""),[C,x]=a.useState(""),[P,z]=a.useState(""),[R,S]=a.useState(!1),p=async()=>{try{const $=await ae("/api/admin/users");if($.ok){const ee=await $.json();s(ee.users)}}catch($){console.error("Error fetching users:",$)}finally{d(!1)}},m=async()=>{try{const $=await ae("/api/admin/usage/summary");if($.ok){const ee=await $.json(),J={};for(const oe of ee.users)J[oe.user_uuid]={total_cost:oe.total_cost||0,total_requests:oe.total_requests||0,last_active:oe.last_active};o(J)}}catch($){console.error("Error fetching usage data:",$)}};a.useEffect(()=>{p(),m()},[]);const h=$=>!$||$===0?"$0.00":$<.01?`$${$.toFixed(4)}`:`$${$.toFixed(2)}`,j=async($,ee)=>{const J=ee==="active"?"disabled":"active";g($);try{(await ae(`/api/admin/users/${$}`,{method:"PATCH",body:JSON.stringify({status:J})})).ok&&s(r.map(W=>W.id===$?{...W,status:J}:W))}catch(oe){console.error("Error updating user status:",oe)}finally{g(null)}},U=async($,ee)=>{if(confirm(`确定要删除用户 "${ee}"?这将删除其所有数据。`)){g($);try{(await ae(`/api/admin/users/${$}`,{method:"DELETE"})).ok&&s(r.filter(oe=>oe.id!==$))}catch(J){console.error("Error deleting user:",J)}finally{g(null)}}},B=async $=>{if($.preventDefault(),z(""),!E||!C){z("用户名和密码不能为空");return}if(E.length<3){z("用户名至少3个字符");return}if(C.length<6){z("密码至少6个字符");return}S(!0);try{const ee=await fe.admin.createUser(E,C),J=await ee.json();ee.ok?(await p(),f(!1),N(""),x("")):z(J.error||"创建用户失败")}catch(ee){console.error("Error creating user:",ee),z("网络错误,请稍后再试")}finally{S(!1)}},q=()=>{f(!1),N(""),x(""),z("")};return c?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载用户..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"用户管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{variant:"default",size:"sm",onClick:()=>f(!0),className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(V,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(Vs,{className:"w-4 h-4"}),"使用量统计"]})]})]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"用户"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"角色"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"状态"}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium text-muted-foreground",children:"费用"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"创建时间"}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium text-muted-foreground",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map($=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[$.role==="admin"?e.jsx(Xt,{className:"w-4 h-4 text-blue-500"}):e.jsx(Ia,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"font-medium text-foreground",children:$.username||$.email})]}),$.email&&$.username&&e.jsx("span",{className:"text-xs text-muted-foreground ml-6",children:$.email})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Ae,{variant:$.role==="admin"?"default":"secondary",children:$.role==="admin"?"管理员":"用户"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Ae,{variant:$.status==="active"?"success":"destructive",children:$.status==="active"?"活跃":"已禁用"})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("span",{className:"font-mono text-sm text-foreground",children:h(i[$.uuid]?.total_cost)})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date($.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:$.role!=="admin"&&e.jsxs(e.Fragment,{children:[e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>j($.id,$.status),disabled:u===$.id,title:$.status==="active"?"禁用用户":"启用用户",children:$.status==="active"?e.jsx(Gs,{className:"w-4 h-4 text-orange-500"}):e.jsx(Ys,{className:"w-4 h-4 text-green-500"})}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>U($.id,$.username||$.email),disabled:u===$.id,title:"删除用户",children:e.jsx(Ue,{className:"w-4 h-4 text-red-500"})})]})})})]},$.id))})]})}),v&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"创建用户"}),e.jsx("button",{onClick:q,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newUsername",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsx("input",{type:"text",id:"newUsername",value:E,onChange:$=>N($.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",disabled:R})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsx("input",{type:"password",id:"newPassword",value:C,onChange:$=>x($.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",disabled:R})]}),P&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:P})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:q,disabled:R,children:"取消"}),e.jsx(V,{type:"submit",disabled:R,children:R?"创建中...":"创建"})]})]})]})})]})}function xi(){const[t,r]=a.useState([]),[s,i]=a.useState(!0),[o,c]=a.useState(null),[d,u]=a.useState(!1),[g,v]=a.useState(""),[f,E]=a.useState(""),[N,C]=a.useState(!1),x=async()=>{try{const S=await fe.admin.getEmailDomains();if(S.ok){const p=await S.json();r(p.domains)}}catch(S){console.error("Error fetching email domains:",S)}finally{i(!1)}};a.useEffect(()=>{x()},[]);const P=async S=>{if(S.preventDefault(),E(""),!g){E("域名不能为空");return}if(!/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(g)){E("域名格式无效,例如: example.com");return}C(!0);try{const m=await fe.admin.addEmailDomain(g.toLowerCase()),h=await m.json();m.ok?(await x(),u(!1),v("")):E(h.error||"添加域名失败")}catch(m){console.error("Error adding domain:",m),E("网络错误,请稍后再试")}finally{C(!1)}},z=async(S,p)=>{if(confirm(`确定要删除域名 "${p}"?删除后该域名的邮箱将无法注册。`)){c(S);try{(await fe.admin.removeEmailDomain(S)).ok&&r(t.filter(h=>h.id!==S))}catch(m){console.error("Error removing domain:",m)}finally{c(null)}}},R=()=>{u(!1),v(""),E("")};return s?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"邮箱域名白名单"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.length===0?"未设置白名单,所有邮箱域名均可注册":"只有白名单内的域名邮箱可以注册"})]}),e.jsxs(V,{variant:"default",size:"sm",onClick:()=>u(!0),className:"flex items-center gap-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),"添加域名"]})]}),t.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"域名"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"添加时间"}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium text-muted-foreground",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:t.map(S=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vt,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:S.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(S.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>z(S.id,S.domain),disabled:o===S.id,title:"删除域名",children:e.jsx(Ue,{className:"w-4 h-4 text-red-500"})})})})]},S.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(Vt,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"暂无域名白名单,所有邮箱域名均可注册"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"添加域名后,只有白名单内的域名邮箱可以注册"})]}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"添加域名"}),e.jsx("button",{onClick:R,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newDomain",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱域名"}),e.jsx("input",{type:"text",id:"newDomain",value:g,onChange:S=>v(S.target.value.toLowerCase()),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"例如: example.com",disabled:N}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),f&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:f})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:R,disabled:N,children:"取消"}),e.jsx(V,{type:"submit",disabled:N,children:N?"添加中...":"添加"})]})]})]})})]})}function gi({onBack:t}){const[r,s]=a.useState("week"),[i,o]=a.useState(null),[c,d]=a.useState(!0),[u,g]=a.useState(!1),v=async()=>{try{const R=await ae(`/api/admin/usage/dashboard?period=${r}`);if(R.ok){const S=await R.json();o(S)}}catch(R){console.error("Error fetching dashboard data:",R)}finally{d(!1),g(!1)}};a.useEffect(()=>{d(!0),v()},[r]);const f=async()=>{try{g(!0),await ae("/api/admin/usage/scan",{method:"POST"}),await v()}catch(R){console.error("Error triggering scan:",R),g(!1)}},E=R=>!R||R===0?"$0.00":R<.01?`$${R.toFixed(4)}`:`$${R.toFixed(2)}`,N=R=>R?R>=1e6?`${(R/1e6).toFixed(1)}M`:R>=1e3?`${(R/1e3).toFixed(1)}K`:R.toString():"0";if(c)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:C,dailyTrend:x,modelDistribution:P,topUsers:z}=i||{};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsxs(V,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(tr,{className:"w-4 h-4 mr-2"}),"返回"]}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"使用情况仪表板"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:["week","month"].map(R=>e.jsx("button",{onClick:()=>s(R),className:`px-4 py-2 text-sm font-medium transition-colors ${r===R?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:R==="week"?"周":"月"},R))}),e.jsx(V,{variant:"outline",size:"sm",onClick:f,disabled:u,title:"扫描新的使用数据",children:e.jsx(Kt,{className:`w-4 h-4 ${u?"animate-spin":""}`})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-100 dark:bg-green-900/30 rounded-lg",children:e.jsx(Qs,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总成本"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:E(C?.totalCost)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(Zs,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"活跃用户"}),e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[C?.activeUsers||0," / ",C?.totalUsers||0]})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-100 dark:bg-purple-900/30 rounded-lg",children:e.jsx(kt,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总请求数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:N(C?.totalRequests)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-100 dark:bg-orange-900/30 rounded-lg",children:e.jsx(Xs,{className:"w-5 h-5 text-orange-600 dark:text-orange-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"会话数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:N(C?.totalSessions)})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"每日成本趋势"}),x&&x.length>0?e.jsx("div",{className:"space-y-2",children:x.map(R=>{const S=Math.max(...x.map(m=>m.cost||0),.01),p=(R.cost||0)/S*100;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground w-20 shrink-0",children:new Date(R.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),e.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-600 rounded",style:{width:`${p}%`}})}),e.jsx("span",{className:"text-sm font-mono text-foreground w-16 text-right",children:E(R.cost)})]},R.date)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"模型成本"}),P&&P.length>0?e.jsx("div",{className:"space-y-3",children:P.map(R=>{const S=P.reduce((j,U)=>j+(U.cost||0),0)||1,p=(R.cost||0)/S*100,h={opus:"bg-purple-500",sonnet:"bg-blue-500",haiku:"bg-green-500"}[R.model]||"bg-gray-500";return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{variant:"secondary",className:"capitalize",children:R.model}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[N(R.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground",children:E(R.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${h} rounded`,style:{width:`${p}%`}})})]},R.model)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"用户成本"}),z&&z.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"排名"}),e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"用户名"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"请求数"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"成本"})]})}),e.jsx("tbody",{children:z.map((R,S)=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 last:border-0",children:[e.jsxs("td",{className:"py-2 text-sm text-muted-foreground",children:["#",S+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:R.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:N(R.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:E(R.total_cost)})]},R.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function hi({onClose:t,onInstalled:r,onOpenRepoManager:s}){const[i,o]=a.useState([]),[c,d]=a.useState([]),[u,g]=a.useState(!0),[v,f]=a.useState(null),[E,N]=a.useState(""),[C,x]=a.useState("all"),[P,z]=a.useState(null);a.useEffect(()=>{R()},[]);const R=async()=>{try{g(!0),f(null);const[m,h]=await Promise.all([ae("/api/skills/available"),ae("/api/skills/repos")]);if(m.ok){const j=await m.json();o(j.skills||[])}if(h.ok){const j=await h.json();d(j.repos||[])}}catch(m){f(m.message)}finally{g(!1)}},S=async m=>{try{z(m.name);const h=await ae(`/api/skills/install/${m.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:m.path})});if(h.ok)R(),r?.();else{const j=await h.json();alert(j.error||"Failed to install skill")}}catch(h){alert(h.message)}finally{z(null)}},p=i.filter(m=>{if(E){const h=E.toLowerCase();if(!m.name.toLowerCase().includes(h)&&!m.title?.toLowerCase().includes(h)&&!m.description?.toLowerCase().includes(h))return!1}return!(C!=="all"&&m.repository!==C)});return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-4xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Skills 管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(V,{variant:"ghost",size:"sm",onClick:R,disabled:u,children:[e.jsx(Kt,{className:`w-4 h-4 ${u?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(V,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Nt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(V,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Pe,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsx("h3",{className:"text-amber-500 font-medium",children:"发现技能"})}),e.jsxs("div",{className:"px-4 pb-4 flex flex-wrap gap-3",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsxs("div",{className:"relative",children:[e.jsx(wt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(We,{type:"text",placeholder:"搜索技能名称或描述...",value:E,onChange:m=>N(m.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:C,onChange:m=>x(m.target.value),className:"px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm min-w-[120px]",children:[e.jsx("option",{value:"all",children:"全部"}),c.map(m=>e.jsxs("option",{value:`${m.owner}/${m.repo}`,children:[m.owner,"/",m.repo]},`${m.owner}/${m.repo}`))]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-4 pb-4",children:[v&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm mb-4",children:v}),u?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):p.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:i.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"没有可用的技能"}),e.jsx("p",{className:"text-xs mt-2",children:"请先添加技能仓库"}),e.jsxs(V,{variant:"outline",size:"sm",className:"mt-4",onClick:s,children:[e.jsx(Nt,{className:"w-4 h-4 mr-2"}),"管理仓库"]})]}):e.jsx("p",{children:"没有找到匹配的技能"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:p.map(m=>e.jsx("div",{className:"border border-border rounded-lg p-4 hover:border-amber-500/50 transition-colors",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:m.title||m.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",m.name]}),e.jsx(Ae,{variant:"outline",className:"text-xs ml-2",children:m.repository})]})]}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:m.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${m.repository}`,"_blank"),children:[e.jsx(La,{className:"w-4 h-4 mr-1"}),"查看"]}),m.installed?e.jsx(V,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(V,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>S(m),disabled:P===m.name,children:[e.jsx(Pr,{className:"w-4 h-4 mr-1"}),P===m.name?"安装中...":"安装"]})]})]})},`${m.repository}-${m.name}`))})]})]})})}function fi({onClose:t,onChanged:r}){const[s,i]=a.useState([]),[o,c]=a.useState(!0),[d,u]=a.useState(null),[g,v]=a.useState(""),[f,E]=a.useState("main"),[N,C]=a.useState(!1),[x,P]=a.useState(null);a.useEffect(()=>{z()},[]);const z=async()=>{try{c(!0),u(null);const p=await ae("/api/skills/repos");if(p.ok){const m=await p.json();i(m.repos||[])}else{const m=await p.json();u(m.error||"Failed to fetch repos")}}catch(p){u(p.message)}finally{c(!1)}},R=async p=>{if(p.preventDefault(),!g.trim()){u("请输入仓库 URL");return}try{C(!0),u(null);const m=await ae("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:g.trim(),branch:f.trim()||"main"})});if(m.ok)v(""),E("main"),z(),r?.();else{const h=await m.json();u(h.error||"Failed to add repo")}}catch(m){u(m.message)}finally{C(!1)}},S=async(p,m)=>{if(confirm(`确定要移除仓库 "${p}/${m}" 吗?`))try{P(`${p}/${m}`);const h=await ae(`/api/skills/repos/${p}/${m}`,{method:"DELETE"});if(h.ok)z(),r?.();else{const j=await h.json();alert(j.error||"Failed to remove repo")}}catch(h){alert(h.message)}finally{P(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-border",children:[e.jsx(V,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(tr,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"管理技能仓库"})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 space-y-4",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"添加技能仓库"}),e.jsxs("form",{onSubmit:R,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"仓库 URL"}),e.jsx(We,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:g,onChange:p=>v(p.target.value),disabled:N})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(We,{type:"text",placeholder:"main",value:f,onChange:p=>E(p.target.value),disabled:N})]}),e.jsxs(V,{type:"submit",disabled:N||!g.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),N?"添加中...":"添加仓库"]})]})]}),d&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:d}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"已添加的仓库"}),o?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"加载中..."}):s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(en,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有添加任何仓库"})]}):s.map(p=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"font-medium text-foreground",children:[p.owner,"/",p.repo]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(tn,{className:"w-3 h-3"}),"分支: main"]}),e.jsxs(Ae,{variant:"outline",className:"text-xs",children:["识别到 ",p.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>window.open(p.url,"_blank"),children:e.jsx(La,{className:"w-4 h-4"})}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>S(p.owner,p.repo),disabled:x===`${p.owner}/${p.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ue,{className:"w-4 h-4"})})]})]})},`${p.owner}/${p.repo}`))]})]})]})})}function bi(){const[t,r]=a.useState([]),[s,i]=a.useState(!0),[o,c]=a.useState(null),[d,u]=a.useState(!1),[g,v]=a.useState(!1),[f,E]=a.useState(!1),N=a.useRef(null);a.useEffect(()=>{C()},[]);const C=async()=>{try{i(!0),c(null);const S=await ae("/api/skills");if(S.ok){const p=await S.json();r(p.skills||[])}else{const p=await S.json();c(p.error||"Failed to fetch skills")}}catch(S){c(S.message)}finally{i(!1)}},x=async S=>{if(confirm(`确定要删除技能 "${S}" 吗?`))try{const p=await ae(`/api/skills/${S}`,{method:"DELETE"});if(p.ok)C();else{const m=await p.json();alert(m.error||"Failed to delete skill")}}catch(p){alert(p.message)}},P=()=>{N.current?.click()},z=async S=>{const p=S.target.files?.[0];if(p)try{E(!0);const m=new FormData;m.append("skillZip",p);const h=await ae("/api/skills/import",{method:"POST",body:m});if(h.ok)C();else{const j=await h.json();alert(j.error||"Failed to import skill")}}catch(m){alert(m.message)}finally{E(!1),N.current&&(N.current.value="")}},R=(S,p)=>{switch(S){case"repo":return e.jsx(Ae,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300",children:p||"仓库"});case"imported":return e.jsx(Ae,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",children:"导入"});default:return e.jsx(Ae,{variant:"outline",className:"text-xs",children:"本地"})}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nr,{className:"w-5 h-5 text-amber-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Skills 管理"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills 是 Claude Code 的扩展能力,可以通过 SKILLS.md 文件定义自定义指令和工作流程"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["已安装:Claude: ",e.jsx("span",{className:"font-medium text-foreground",children:t.length})," 个技能"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("input",{ref:N,type:"file",accept:".zip",className:"hidden",onChange:z}),e.jsxs(V,{onClick:P,variant:"outline",size:"sm",disabled:f,children:[e.jsx(Pr,{className:"w-4 h-4 mr-2"}),f?"导入中...":"导入已有"]}),e.jsxs(V,{onClick:()=>u(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),"发现技能"]})]})]}),o&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:o}),e.jsx("div",{className:"space-y-2",children:s?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有安装任何技能"}),e.jsx("p",{className:"text-xs mt-2",children:'点击"发现技能"从仓库安装,或"导入已有"上传本地技能'})]}):t.map(S=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:S.title||S.name}),R(S.source,S.repository)]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:S.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>x(S.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ue,{className:"w-4 h-4"})})})]})},S.name))}),d&&e.jsx(hi,{onClose:()=>u(!1),onInstalled:C,onOpenRepoManager:()=>{u(!1),v(!0)}}),g&&e.jsx(fi,{onClose:()=>v(!1),onChanged:()=>{}})]})}function vi({isOpen:t,onClose:r,projects:s=[],initialTab:i="agents"}){const o=wa(),{isDarkMode:c,toggleDarkMode:d}=Wr(),{user:u,logout:g}=Tt(),v=u?.role==="admin",[f,E]=a.useState([]),[N,C]=a.useState([]),[x,P]=a.useState(""),[z,R]=a.useState(""),[S,p]=a.useState(!1),[m,h]=a.useState(!1),[j,U]=a.useState(null),[B,q]=a.useState("name"),[$,ee]=a.useState([]),[J,oe]=a.useState(!1),[W,_]=a.useState(null),[T,X]=a.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[pe,ne]=a.useState(!1),[H,ie]=a.useState({}),[ye,me]=a.useState({}),[le,ve]=a.useState({}),[xe,we]=a.useState(i),[K,Q]=a.useState(""),[I,Z]=a.useState("permissions"),[be,he]=a.useState(!1),[Ce,Fe]=a.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Te,ze]=a.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[$e,Be]=a.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Re,Qe]=a.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[qe,He]=a.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),n=async()=>{try{const L=await ae("/api/mcp/config/read");if(L.ok){const de=await L.json();if(de.success&&de.servers){ee(de.servers);return}}const G=await ae("/api/mcp/cli/list");if(G.ok){const de=await G.json();if(de.success&&de.servers){const dt=de.servers.map(Ke=>({id:Ke.name,name:Ke.name,type:Ke.type,scope:"user",config:{command:Ke.command||"",args:Ke.args||[],env:Ke.env||{},url:Ke.url||"",headers:Ke.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));ee(dt);return}}const se=await ae("/api/mcp/servers?scope=user");if(se.ok){const de=await se.json();ee(de.servers||[])}else console.error("Failed to fetch MCP servers")}catch(L){console.error("Error fetching MCP servers:",L)}},k=async L=>{try{W&&await F(W.id,"user");const G=await ae("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath,command:L.config?.command,args:L.config?.args||[],url:L.config?.url,headers:L.config?.headers||{},env:L.config?.env||{}})});if(G.ok){const se=await G.json();if(se.success)return await n(),!0;throw new Error(se.error||"Failed to save server via Claude CLI")}else{const se=await G.json();throw new Error(se.error||"Failed to save server")}}catch(G){throw console.error("Error saving MCP server:",G),G}},F=async(L,G="user")=>{try{const se=await ae(`/api/mcp/cli/remove/${L}?scope=${G}`,{method:"DELETE"});if(se.ok){const de=await se.json();if(de.success)return await n(),!0;throw new Error(de.error||"Failed to delete server via Claude CLI")}else{const de=await se.json();throw new Error(de.error||"Failed to delete server")}}catch(se){throw console.error("Error deleting MCP server:",se),se}},A=async(L,G="user")=>{try{const se=await ae(`/api/mcp/servers/${L}/test?scope=${G}`,{method:"POST"});if(se.ok)return(await se.json()).testResult;{const de=await se.json();throw new Error(de.error||"Failed to test server")}}catch(se){throw console.error("Error testing MCP server:",se),se}},D=async(L,G="user")=>{try{const se=await ae(`/api/mcp/servers/${L}/tools?scope=${G}`,{method:"POST"});if(se.ok)return(await se.json()).toolsResult;{const de=await se.json();throw new Error(de.error||"Failed to discover tools")}}catch(se){throw console.error("Error discovering MCP tools:",se),se}};a.useEffect(()=>{t&&(ue(),we(i),he(!1))},[t,i]),a.useEffect(()=>{localStorage.setItem("codeEditorTheme",Ce),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ce]),a.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Te.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Te]),a.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",$e.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[$e]),a.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Re.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Re]),a.useEffect(()=>{localStorage.setItem("codeEditorFontSize",qe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[qe]);const ue=async()=>{try{const L=localStorage.getItem("claude-settings");if(L){const G=JSON.parse(L);E(G.allowedTools||[]),C(G.disallowedTools||[]),p(G.skipPermissions||!1),q(G.projectSortOrder||"name")}else E([]),C([]),p(!1),q("name");await n()}catch(L){console.error("Error loading tool settings:",L),E([]),C([]),p(!1),q("name")}},ce=()=>{h(!0),U(null);try{const L={allowedTools:f,disallowedTools:N,skipPermissions:S,projectSortOrder:B,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(L)),U("success"),setTimeout(()=>{r()},1e3)}catch(L){console.error("Error saving tool settings:",L),U("error")}finally{h(!1)}},Ne=()=>{X({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),_(null),oe(!1),Q("")},De=(L=null)=>{L?(_(L),X({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath||"",config:{...L.config},raw:L.raw,importMode:"form",jsonInput:""})):Ne(),oe(!0)},ke=async L=>{L.preventDefault(),ne(!0);try{if(T.importMode==="json"){const G=await ae("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:T.name,jsonConfig:T.jsonInput,scope:T.scope,projectPath:T.projectPath})});if(G.ok){const se=await G.json();if(se.success)await n(),Ne(),U("success");else throw new Error(se.error||"Failed to add server via JSON")}else{const se=await G.json();throw new Error(se.error||"Failed to add server")}}else await k(T),Ne(),U("success")}catch(G){alert(`Error: ${G.message}`),U("error")}finally{ne(!1)}},Le=async(L,G)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await F(L,G),U("success")}catch(se){alert(`Error: ${se.message}`),U("error")}},Se=async(L,G)=>{try{ie({...H,[L]:{loading:!0}});const se=await A(L,G);ie({...H,[L]:se})}catch(se){ie({...H,[L]:{success:!1,message:se.message,details:[]}})}},ct=async(L,G)=>{try{ve({...le,[L]:!0});const se=await D(L,G);me({...ye,[L]:se})}catch{me({...ye,[L]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{ve({...le,[L]:!1})}},Je=(L,G)=>{X(se=>({...se,config:{...se.config,[L]:G}}))};return t?e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"设置"})]}),e.jsx(V,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Pe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex px-4 md:px-6",children:[e.jsx("button",{onClick:()=>we("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"代理"}),e.jsx("button",{onClick:()=>we("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"外观"}),v&&e.jsx("button",{onClick:()=>we("users"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="users"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"用户"}),e.jsx("button",{onClick:()=>we("account"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"账户"})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[xe==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:xe==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"深色模式"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"切换浅色和深色主题"})]}),e.jsxs("button",{onClick:d,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":c,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${c?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:c?e.jsx(Sr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Cr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"项目排序"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"侧边栏中项目的排序方式"})]}),e.jsxs("select",{value:B,onChange:L=>q(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:"按字母顺序"}),e.jsx("option",{value:"date",children:"按最近活动"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"代码编辑器"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"编辑器主题"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"代码编辑器的默认主题"})]}),e.jsxs("button",{onClick:()=>Fe(Ce==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ce==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Ce==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Ce==="dark"?e.jsx(Sr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Cr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"自动换行"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中默认启用自动换行"})]}),e.jsxs("button",{onClick:()=>ze(!Te),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Te,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${Te?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示小地图"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在差异视图中显示小地图以便于导航"})]}),e.jsxs("button",{onClick:()=>Be(!$e),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":$e,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${$e?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示行号"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中显示行号"})]}),e.jsxs("button",{onClick:()=>Qe(!Re),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Re,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Re?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"字体大小"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"编辑器字体大小(像素)"})]}),e.jsxs("select",{value:qe,onChange:L=>He(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),xe==="agents"&&e.jsx("div",{className:"flex flex-col h-full min-h-[400px] md:min-h-[500px]",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>Z("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${I==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Z("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${I==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP 服务器"}),e.jsx("button",{onClick:()=>Z("skills"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${I==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[I==="permissions"&&e.jsx(ii,{agent:"claude",skipPermissions:S,setSkipPermissions:p,allowedTools:f,setAllowedTools:E,disallowedTools:N,setDisallowedTools:C,newAllowedTool:x,setNewAllowedTool:P,newDisallowedTool:z,setNewDisallowedTool:R}),I==="mcp"&&e.jsx(ui,{agent:"claude",servers:$,onAdd:()=>De(),onEdit:L=>De(L),onDelete:(L,G)=>Le(L,G),onTest:(L,G)=>Se(L,G),onDiscoverTools:(L,G)=>ct(L,G),testResults:H,serverTools:ye,toolsLoading:le}),I==="skills"&&e.jsx(bi,{})]})]})}),xe==="users"&&v&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:be?e.jsx(gi,{onBack:()=>he(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(pi,{onNavigateToUsage:()=>he(!0)}),e.jsx(xi,{})]})}),xe==="account"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"账户"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:u?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:u?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:u?.role==="admin"?"管理员":"用户"})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"退出登录"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"结束当前会话"})]}),e.jsxs(V,{variant:"outline",className:"gap-2 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:()=>{confirm("确定要退出登录吗?")&&(r(),o("/"),g())},children:[e.jsx(rn,{className:"w-4 h-4"}),"退出"]})]})})]})}),J&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:W?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(V,{variant:"ghost",size:"sm",onClick:Ne,children:e.jsx(Pe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:ke,className:"p-4 space-y-4",children:[!W&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>X(L=>({...L,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${T.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"表单输入"}),e.jsx("button",{type:"button",onClick:()=>X(L=>({...L,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${T.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"JSON 导入"})]}),T.importMode==="form"&&W&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域"}),e.jsxs("div",{className:"flex items-center gap-2",children:[T.scope==="user"?e.jsx(wr,{className:"w-4 h-4"}):e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:T.scope==="user"?"用户(全局)":"项目(本地)"}),T.scope==="local"&&T.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",T.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),T.importMode==="form"&&!W&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域 *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>X(L=>({...L,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${T.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(wr,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>X(L=>({...L,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${T.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:T.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),T.scope==="local"&&!W&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:T.projectPath,onChange:L=>X(G=>({...G,projectPath:L.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:T.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),s.map(L=>e.jsx("option",{value:L.path||L.fullPath,children:L.displayName||L.name},L.name))]}),T.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",T.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:T.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(We,{value:T.name,onChange:L=>{X(G=>({...G,name:L.target.value}))},placeholder:"my-server",required:!0})]}),T.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:T.type,onChange:L=>{X(G=>({...G,type:L.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),W&&T.raw&&T.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["配置详情 (from ",W.scope==="global"?"~/.claude.json":"project config",")"]}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(T.raw,null,2)})]}),T.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON 配置 *"}),e.jsx("textarea",{value:T.jsonInput,onChange:L=>{X(G=>({...G,jsonInput:L.target.value}));try{if(L.target.value.trim()){const G=JSON.parse(L.target.value);G.type?G.type==="stdio"&&!G.command?Q("stdio 类型需要 command 字段"):(G.type==="http"||G.type==="sse")&&!G.url?Q(`${G.type} 类型需要 url 字段`):Q(""):Q("缺少必填字段:type")}}catch{L.target.value.trim()?Q("无效的 JSON 格式"):Q("")}},className:`w-full px-3 py-2 border ${K?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
|
|
139
|
+
"type": "stdio",
|
|
140
|
+
"command": "/path/to/server",
|
|
141
|
+
"args": ["--api-key", "abc123"],
|
|
142
|
+
"env": {
|
|
143
|
+
"CACHE_DIR": "/tmp"
|
|
144
|
+
}
|
|
145
|
+
}`,required:!0}),K&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:K}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["以 JSON 格式粘贴您的 MCP 服务器配置。示例格式:",e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),T.importMode==="form"&&T.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"命令 *"}),e.jsx(We,{value:T.config.command,onChange:L=>Je("command",L.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"参数(每行一个)"}),e.jsx("textarea",{value:Array.isArray(T.config.args)?T.config.args.join(`
|
|
146
|
+
`):"",onChange:L=>Je("args",L.target.value.split(`
|
|
147
|
+
`).filter(G=>G.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`--api-key
|
|
148
|
+
abc123`})]})]}),T.importMode==="form"&&(T.type==="sse"||T.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"URL *"}),e.jsx(We,{value:T.config.url,onChange:L=>Je("url",L.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),T.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"环境变量(KEY=value,每行一个)"}),e.jsx("textarea",{value:Object.entries(T.config.env||{}).map(([L,G])=>`${L}=${G}`).join(`
|
|
149
|
+
`),onChange:L=>{const G={};L.target.value.split(`
|
|
150
|
+
`).forEach(se=>{const[de,...dt]=se.split("=");de&&de.trim()&&(G[de.trim()]=dt.join("=").trim())}),Je("env",G)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`API_KEY=your-key
|
|
151
|
+
DEBUG=true`})]}),T.importMode==="form"&&(T.type==="sse"||T.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"请求头(KEY=value,每行一个)"}),e.jsx("textarea",{value:Object.entries(T.config.headers||{}).map(([L,G])=>`${L}=${G}`).join(`
|
|
152
|
+
`),onChange:L=>{const G={};L.target.value.split(`
|
|
153
|
+
`).forEach(se=>{const[de,...dt]=se.split("=");de&&de.trim()&&(G[de.trim()]=dt.join("=").trim())}),Je("headers",G)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`Authorization=Bearer token
|
|
154
|
+
X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(V,{type:"button",variant:"outline",onClick:Ne,children:"取消"}),e.jsx(V,{type:"submit",disabled:pe,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:pe?"保存中...":W?"更新服务器":"添加服务器"})]})]})]})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[j==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"设置保存成功!"]}),j==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),"保存设置失败"]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(V,{variant:"outline",onClick:r,disabled:m,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"取消"}),e.jsx(V,{onClick:ce,disabled:m,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:m?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"保存中..."]}):"保存设置"})]})]})]})}):null}function yi(){const{isDarkMode:t,toggleDarkMode:r}=Wr();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const ji=({isOpen:t,onToggle:r,autoExpandTools:s,onAutoExpandChange:i,showRawParameters:o,onShowRawParametersChange:c,showThinking:d,onShowThinkingChange:u,autoScrollToBottom:g,onAutoScrollChange:v,sendByCtrlEnter:f,onSendByCtrlEnterChange:E,isMobile:N})=>{const[C,x]=a.useState(t),[P,z]=a.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:R}=Wr(),[S,p]=a.useState(()=>{const H=localStorage.getItem("quickSettingsHandlePosition");if(H)try{return JSON.parse(H).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[m,h]=a.useState(!1),[j,U]=a.useState(0),[B,q]=a.useState(0),[$,ee]=a.useState(!1),J=a.useRef(null),oe=a.useRef({min:10,max:90}),W=5;a.useEffect(()=>{x(t)},[t]),a.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:S}))},[S]);const _=a.useCallback(()=>N?{bottom:`${window.innerHeight*S/100}px`}:{top:`${S}%`,transform:"translateY(-50%)"},[S,N]),T=a.useCallback(H=>{H.stopPropagation();const ie=H.type.includes("touch")?H.touches[0].clientY:H.clientY;U(ie),q(S),ee(!1),h(!1)},[S]),X=a.useCallback(H=>{if(j===0)return;const ie=H.type.includes("touch")?H.touches[0].clientY:H.clientY,ye=Math.abs(ie-j);if(!m&&ye>W&&(h(!0),ee(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",H.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!m)return;H.type.includes("touch")&&H.preventDefault();const me=ie-j;let le;N?le=-(me/window.innerHeight)*100:le=me/window.innerHeight*100;let ve=B+le;ve=Math.max(oe.current.min,Math.min(oe.current.max,ve)),p(ve)},[m,j,B,N,W]),pe=a.useCallback(()=>{h(!1),U(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);a.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),a.useEffect(()=>{if(j!==0){const H=le=>X(le),ie=()=>pe(),ye=le=>X(le),me=()=>pe();return document.addEventListener("mousemove",H),document.addEventListener("mouseup",ie),document.addEventListener("touchmove",ye,{passive:!1}),document.addEventListener("touchend",me),()=>{document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",ie),document.removeEventListener("touchmove",ye),document.removeEventListener("touchend",me)}}},[j,X,pe]);const ne=H=>{if($){H.preventDefault(),ee(!1);return}const ie=!C;x(ie),r(ie)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:J,onClick:ne,onMouseDown:H=>{T(H)},onTouchStart:H=>{T(H)},className:`fixed ${C?"right-64":"right-0"} z-50 ${m?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${m?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${m?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{..._(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":m?"拖动手柄":C?"关闭设置面板":"打开设置面板",title:m?"拖动中...":"点击切换,拖动移动",children:m?e.jsx(an,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):C?e.jsx(jr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(sn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${C?"translate-x-0":"translate-x-full"} ${N?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(nn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),"快速设置"]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${N?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"外观"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[R?e.jsx(Sr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Cr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"深色模式"]}),e.jsx(yi,{})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"工具显示"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Ea,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动展开工具"]}),e.jsx("input",{type:"checkbox",checked:s,onChange:H=>i(H.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Ma,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示原始参数"]}),e.jsx("input",{type:"checkbox",checked:o,onChange:H=>c(H.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Ca,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示思考过程"]}),e.jsx("input",{type:"checkbox",checked:d,onChange:H=>u(H.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"视图选项"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(on,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动滚动到底部"]}),e.jsx("input",{type:"checkbox",checked:g,onChange:H=>v(H.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"输入设置"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ln,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"使用 Ctrl+Enter 发送"]}),e.jsx("input",{type:"checkbox",checked:f,onChange:H=>E(H.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:"启用后,按 Ctrl+Enter 发送消息而不是 Enter。这对于输入法用户很有用,可以避免误发送。"})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"语音输入"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:P==="default",onChange:()=>{z("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Jt,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"默认模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"直接转录您的语音"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:P==="prompt",onChange:()=>{z("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Nr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"提示词增强"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将粗略的想法转化为清晰、详细的 AI 提示词"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:P==="vibe"||P==="instructions"||P==="architect",onChange:()=>{z("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Da,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"氛围模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将想法格式化为带有详细说明的代理指令"})]})]})]})]})]})]})}),C&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:ne})]})};function ki(){const[t,r]=a.useState(null),[s,i]=a.useState([]),[o,c]=a.useState(!1),d=a.useRef(null),u=a.useRef(null),{token:g}=Tt();a.useEffect(()=>(d.current&&(clearTimeout(d.current),d.current=null),u.current&&(u.current.close(),u.current=null),g||!1?v():(c(!1),r(null)),()=>{d.current&&clearTimeout(d.current),u.current&&u.current.close()}),[g]);const v=()=>{try{let N;{const x=g||localStorage.getItem("auth-token");if(!x){console.warn("No authentication token found for WebSocket connection");return}N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?token=${encodeURIComponent(x)}`}const C=new WebSocket(N);u.current=C,C.onopen=()=>{c(!0),r(C)},C.onmessage=x=>{try{const P=JSON.parse(x.data);i(z=>[...z,P])}catch(P){console.error("Error parsing WebSocket message:",P)}},C.onclose=()=>{c(!1),r(null),u.current=null,localStorage.getItem("auth-token")&&(d.current=setTimeout(()=>{v()},3e3))},C.onerror=x=>{console.error("WebSocket error:",x)}}catch(E){console.error("Error creating WebSocket connection:",E)}};return{ws:t,sendMessage:E=>{t&&o?t.send(JSON.stringify(E)):console.warn("WebSocket not connected")},messages:s,isConnected:o}}const Ha=a.createContext({ws:null,sendMessage:()=>{},messages:[],isConnected:!1}),wi=()=>{const t=a.useContext(Ha);if(!t)throw new Error("useWebSocketContext must be used within a WebSocketProvider");return t},Ni=({children:t})=>{const r=ki();return e.jsx(Ha.Provider,{value:r,children:t})},Si=()=>{const[t,r]=a.useState("email"),[s,i]=a.useState(""),[o,c]=a.useState(""),[d,u]=a.useState(!1),[g,v]=a.useState(""),[f,E]=a.useState(0),{sendCode:N,verifyCode:C,smtpConfigured:x}=Tt();a.useEffect(()=>{if(f>0){const p=setTimeout(()=>E(f-1),1e3);return()=>clearTimeout(p)}},[f]);const P=async p=>{if(p.preventDefault(),v(""),!s||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)){v("请输入有效的邮箱地址");return}u(!0);const h=await N(s);h.success?(r("code"),E(60)):(v(h.error),h.waitSeconds&&E(h.waitSeconds)),u(!1)},z=async p=>{if(p.preventDefault(),v(""),!o||o.length!==6){v("请输入6位验证码");return}u(!0);const m=await C(s,o);m.success||v(m.error),u(!1)},R=async()=>{if(f>0)return;v(""),u(!0);const p=await N(s);p.success?E(60):v(p.error),u(!1)},S=()=>{r("email"),c(""),v("")};return x?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Xe,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?"欢迎使用 AgentHub":"创建管理员账户"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?"输入邮箱创建管理员账户":`验证码已发送至 ${s}`})]}),t==="email"&&e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:s,onChange:p=>i(p.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:d,autoComplete:"email"})]})]}),g&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:g})}),e.jsx("button",{type:"submit",disabled:d||f>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:d?"发送中...":f>0?`${f}秒后可重新发送`:"获取验证码"})]}),t==="code"&&e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:S,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(tr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:o,onChange:p=>c(p.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:d,maxLength:6,autoComplete:"one-time-code"})]}),g&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:g})}),e.jsx("button",{type:"submit",disabled:d||o.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:d?"创建中...":"创建管理员账户"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:R,disabled:f>0||d,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:f>0?`${f}秒后可重新发送`:"重新发送验证码"})})]}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"首个注册的用户将成为管理员"})})]})})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(Xe,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"欢迎使用 AgentHub"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"系统初始化"})]}),e.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-400",children:"SMTP 邮件服务未配置。请联系管理员配置以下环境变量后重启服务:"}),e.jsxs("ul",{className:"mt-2 text-sm text-yellow-700 dark:text-yellow-400 list-disc list-inside",children:[e.jsx("li",{children:"SMTP_SERVER"}),e.jsx("li",{children:"SMTP_PORT"}),e.jsx("li",{children:"SMTP_USERNAME"}),e.jsx("li",{children:"SMTP_PASSWORD"})]})]})]})})})},Ci=()=>{const[t,r]=a.useState("email"),[s,i]=a.useState("email"),[o,c]=a.useState(""),[d,u]=a.useState(""),[g,v]=a.useState(""),[f,E]=a.useState(""),[N,C]=a.useState(!1),[x,P]=a.useState(""),[z,R]=a.useState(0),[S,p]=a.useState(!1),{login:m,sendCode:h,verifyCode:j,smtpConfigured:U}=Tt();a.useEffect(()=>{if(z>0){const _=setTimeout(()=>R(z-1),1e3);return()=>clearTimeout(_)}},[z]),a.useEffect(()=>{U||r("password")},[U]);const B=async _=>{if(_.preventDefault(),P(""),!o||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)){P("请输入有效的邮箱地址");return}C(!0);const X=await h(o);X.success?(i("code"),R(60),p(X.type==="register")):(P(X.error),X.waitSeconds&&R(X.waitSeconds)),C(!1)},q=async _=>{if(_.preventDefault(),P(""),!d||d.length!==6){P("请输入6位验证码");return}C(!0);const T=await j(o,d);T.success||P(T.error),C(!1)},$=async()=>{if(z>0)return;P(""),C(!0);const _=await h(o);_.success?R(60):P(_.error),C(!1)},ee=async _=>{if(_.preventDefault(),P(""),!g||!f){P("请输入用户名和密码");return}C(!0);const T=await m(g,f);T.success||P(T.error),C(!1)},J=()=>{i("email"),u(""),P("")},oe=()=>{r("email"),i("email"),P("")},W=()=>{r("password"),P("")};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(kt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?s==="email"?"欢迎使用 AgentHub":S?"创建您的账户":"验证您的身份":"欢迎回来"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?s==="email"?"输入邮箱以接收验证码":`验证码已发送至 ${o}`:"使用账号密码登录"})]}),t==="email"&&s==="email"&&e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:o,onChange:_=>c(_.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:N,autoComplete:"email"})]})]}),x&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:x})}),e.jsx("button",{type:"submit",disabled:N||z>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:N?"发送中...":z>0?`${z}秒后可重新发送`:"获取验证码"})]}),t==="email"&&s==="code"&&e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:J,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(tr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:d,onChange:_=>u(_.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:N,maxLength:6,autoComplete:"one-time-code"})]}),x&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:x})}),e.jsx("button",{type:"submit",disabled:N||d.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:N?"验证中...":S?"创建账户并登录":"登录"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:$,disabled:z>0||N,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:z>0?`${z}秒后可重新发送`:"重新发送验证码"})})]}),t==="password"&&e.jsxs("form",{onSubmit:ee,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ia,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"text",id:"username",value:g,onChange:_=>v(_.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",required:!0,disabled:N})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsxs("div",{className:"relative",children:[e.jsx(cn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"password",id:"password",value:f,onChange:_=>E(_.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",required:!0,disabled:N})]})]}),x&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:x})}),e.jsx("button",{type:"submit",disabled:N,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:N?"登录中...":"登录"})]}),e.jsx("div",{className:"text-center pt-4 border-t border-border",children:t==="email"&&U?e.jsx("button",{type:"button",onClick:W,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用账号密码登录"}):t==="password"&&U?e.jsx("button",{type:"button",onClick:oe,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用邮箱验证码登录"}):null})]})})})},Ei=()=>e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(kt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"AgentHub"}),e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"加载中..."})]})}),Mi=({children:t})=>{const{user:r,isLoading:s,needsSetup:i}=Tt();return s?e.jsx(Ei,{}):i?e.jsx(Si,{}):r?t:e.jsx(Ci,{})};function jt(t,r){const[s,i]=a.useState(()=>{if(typeof window>"u")return r;try{const c=window.localStorage.getItem(t);return c?JSON.parse(c):r}catch(c){return console.log(c),r}});return[s,c=>{if(!(typeof window>"u"))try{const d=c instanceof Function?c(s):c;window.localStorage.setItem(t,JSON.stringify(d)),i(d)}catch(d){console.log(d)}}]}function ka(){const t=wa(),{sessionId:r}=Ts(),[s,i]=a.useState([]),[o,c]=a.useState(null),[d,u]=a.useState(null),[g,v]=a.useState("chat"),[f,E]=a.useState(!1),[N,C]=a.useState(!1),[x,P]=a.useState(!0),[z,R]=a.useState(!1),[S,p]=a.useState(!1),[m,h]=a.useState("agents"),[j,U]=a.useState(!1),[B,q]=jt("autoExpandTools",!1),[$,ee]=jt("showRawParameters",!1),[J,oe]=jt("showThinking",!0),[W,_]=jt("autoScrollToBottom",!0),[T,X]=jt("sendByCtrlEnter",!1),[pe,ne]=jt("sidebarVisible",!0),[H,ie]=a.useState(new Set),[ye,me]=a.useState(new Set),[le,ve]=a.useState(0),{ws:xe,sendMessage:we,messages:K}=wi(),[Q,I]=a.useState(!1);a.useEffect(()=>{const n=()=>{const k=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");I(k),document.addEventListener("touchstart",{}),k?(document.documentElement.classList.add("pwa-mode"),document.body.classList.add("pwa-mode")):(document.documentElement.classList.remove("pwa-mode"),document.body.classList.remove("pwa-mode"))};return n(),window.matchMedia("(display-mode: standalone)").addEventListener("change",n),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",n)}},[]),a.useEffect(()=>{const n=()=>{E(window.innerWidth<768)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),a.useEffect(()=>{be()},[]);const Z=(n,k,F,A)=>{if(!F||!A)return!0;const D=n?.find(ke=>ke.name===F.name),ue=k?.find(ke=>ke.name===F.name);if(!D||!ue)return!1;const ce=D.sessions?.find(ke=>ke.id===A.id),Ne=ue.sessions?.find(ke=>ke.id===A.id);return!ce||!Ne?!1:ce.id===Ne.id&&ce.title===Ne.title&&ce.created_at===Ne.created_at&&ce.updated_at===Ne.updated_at};a.useEffect(()=>{if(K.length>0){const n=K[K.length-1];if(n.type==="projects_updated"){if(n.changedFile&&d&&o){const D=n.changedFile.replace(/\\/g,"/").split("/");D.length>=2&&D[D.length-1].replace(".jsonl","")===d.id&&(H.has(d.id)||ve(De=>De+1))}if(d&&H.has(d.id)||H.size>0&&Array.from(H).some(A=>A.startsWith("new-session-"))){const A=n.projects;if(!Z(s,A,o,d))return}const F=n.projects;if(i(F),o){const A=F.find(D=>D.name===o.name);A&&(JSON.stringify(A)!==JSON.stringify(o)&&c(A),d&&([...A.sessions||[]].find(ce=>ce.id===d.id)||u(null)))}}}},[K,o,d,H]);const be=async()=>{try{P(!0);const k=await(await fe.projects()).json();i(F=>F.length===0||k.some((D,ue)=>{const ce=F[ue];return ce?D.name!==ce.name||D.displayName!==ce.displayName||D.fullPath!==ce.fullPath||JSON.stringify(D.sessionMeta)!==JSON.stringify(ce.sessionMeta)||JSON.stringify(D.sessions)!==JSON.stringify(ce.sessions):!0})||k.length!==F.length?k:F)}catch(n){console.error("Error fetching projects:",n)}finally{P(!1)}};window.refreshProjects=be,window.openSettings=a.useCallback((n="tools")=>{h(n),p(!0)},[]),a.useEffect(()=>{if(r&&s.length>0){const n=!d||d.id!==r;for(const k of s){let F=k.sessions?.find(A=>A.id===r);if(F){c(k),u({...F,__provider:"claude"}),n&&v("chat");return}}}},[r,s,t]);const he=n=>{c(n),u(null),t("/"),f&&C(!1)},Ce=n=>{if(u(n),g!=="git"&&g!=="preview"&&v("chat"),f){const k=n.__projectName,F=o?.name;k!==F&&C(!1)}t(`/session/${n.id}`)},Fe=n=>{c(n),u(null),v("chat"),t("/"),f&&C(!1)},Te=n=>{d?.id===n&&(u(null),t("/")),i(k=>k.map(F=>({...F,sessions:F.sessions?.filter(A=>A.id!==n)||[],sessionMeta:{...F.sessionMeta,total:Math.max(0,(F.sessionMeta?.total||0)-1)}})))},ze=async()=>{try{const k=await(await fe.projects()).json();if(i(F=>k.some((D,ue)=>{const ce=F[ue];return ce?D.name!==ce.name||D.displayName!==ce.displayName||D.fullPath!==ce.fullPath||JSON.stringify(D.sessionMeta)!==JSON.stringify(ce.sessionMeta)||JSON.stringify(D.sessions)!==JSON.stringify(ce.sessions):!0})||k.length!==F.length?k:F),o){const F=k.find(A=>A.name===o.name);if(F&&(JSON.stringify(F)!==JSON.stringify(o)&&c(F),d)){const A=F.sessions?.find(D=>D.id===d.id);A&&JSON.stringify(A)!==JSON.stringify(d)&&u(A)}}}catch(n){console.error("Error refreshing sidebar:",n)}},$e=n=>{o?.name===n&&(c(null),u(null),t("/")),i(k=>k.filter(F=>F.name!==n))},Be=a.useCallback(n=>{n&&ie(k=>new Set([...k,n]))},[]),Re=a.useCallback(n=>{n&&ie(k=>{const F=new Set(k);return F.delete(n),F})},[]),Qe=a.useCallback(n=>{n&&me(k=>new Set([...k,n]))},[]),qe=a.useCallback(n=>{n&&me(k=>{const F=new Set(k);return F.delete(n),F})},[]),He=a.useCallback(n=>{n&&ie(k=>{const F=new Set;for(const A of k)A.startsWith("new-session-")||F.add(A);return F.add(n),F})},[]);return e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[!f&&e.jsx("div",{className:`h-full flex-shrink-0 border-r border-border bg-card transition-all duration-300 ${pe?"w-80":"w-14"}`,children:e.jsx("div",{className:"h-full overflow-hidden",children:pe?e.jsx(sa,{projects:s,selectedProject:o,selectedSession:d,onProjectSelect:he,onSessionSelect:Ce,onNewSession:Fe,onSessionDelete:Te,onProjectDelete:$e,isLoading:x,onRefresh:ze,onShowSettings:()=>p(!0),isPWA:Q,isMobile:f,onToggleSidebar:()=>ne(!1)}):e.jsxs("div",{className:"h-full flex flex-col items-center py-4 gap-4",children:[e.jsx("button",{onClick:()=>ne(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200 group","aria-label":"Show sidebar",title:"Show sidebar",children:e.jsx("svg",{className:"w-5 h-5 text-foreground group-hover:scale-110 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M5 5l7 7-7 7"})})}),e.jsx("button",{onClick:()=>p(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200","aria-label":"Settings",title:"Settings",children:e.jsx(Nt,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})})]})})}),f&&e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${N?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:n=>{n.stopPropagation(),C(!1)},onTouchStart:n=>{n.preventDefault(),n.stopPropagation(),C(!1)},"aria-label":"Close sidebar"}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border transform transition-transform duration-150 ease-out ${N?"translate-x-0":"-translate-x-full"}`,onClick:n=>n.stopPropagation(),onTouchStart:n=>n.stopPropagation(),children:e.jsx(sa,{projects:s,selectedProject:o,selectedSession:d,onProjectSelect:he,onSessionSelect:Ce,onNewSession:Fe,onSessionDelete:Te,onProjectDelete:$e,isLoading:x,onRefresh:ze,onShowSettings:()=>p(!0),isPWA:Q,isMobile:f,onToggleSidebar:()=>ne(!1)})})]}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${f&&!z?"pb-mobile-nav":""}`,children:e.jsx(Zo,{selectedProject:o,selectedSession:d,activeTab:g,setActiveTab:v,ws:xe,sendMessage:we,messages:K,isMobile:f,isPWA:Q,onMenuClick:()=>C(!0),isLoading:x,onInputFocusChange:R,onSessionActive:Be,onSessionInactive:Re,onSessionProcessing:Qe,onSessionNotProcessing:qe,processingSessions:ye,onReplaceTemporarySession:He,onNavigateToSession:n=>t(`/session/${n}`),onShowSettings:()=>p(!0),autoExpandTools:B,showRawParameters:$,showThinking:J,autoScrollToBottom:W,sendByCtrlEnter:T,externalMessageUpdate:le})}),f&&e.jsx(Xo,{activeTab:g,setActiveTab:v,isInputFocused:z}),g==="chat"&&e.jsx(ji,{isOpen:j,onToggle:U,autoExpandTools:B,onAutoExpandChange:q,showRawParameters:$,onShowRawParametersChange:ee,showThinking:J,onShowThinkingChange:oe,autoScrollToBottom:W,onAutoScrollChange:_,sendByCtrlEnter:T,onSendByCtrlEnterChange:X,isMobile:f}),e.jsx(vi,{isOpen:S,onClose:()=>p(!1),projects:s,initialTab:m})]})}function Di(){return e.jsx(ei,{children:e.jsx(ti,{children:e.jsx(Ni,{children:e.jsx(Mi,{children:e.jsx(Is,{children:e.jsxs(Ls,{children:[e.jsx(Zr,{path:"/",element:e.jsx(ka,{})}),e.jsx(Zr,{path:"/session/:sessionId",element:e.jsx(ka,{})})]})})})})})})}"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(r=>{r.unregister()})}).catch(t=>{console.warn("Failed to unregister service workers:",t)});jn.createRoot(document.getElementById("root")).render(e.jsx(Ge.StrictMode,{children:e.jsx(Di,{})}));
|