@ian2018cs/agenthub 0.1.25 → 0.1.27

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.
@@ -1,8 +1,8 @@
1
- import{j as e,s as Da,R as Ta,o as Pa,E as Ra,m as za,b as $a,c as Aa,h as Oa,p as _a,d as Fa}from"./vendor-codemirror-C_VWDoZS.js";import{b as Wa,g as Jr,a as s,d as Ba,R as et,u as $s,B as Ua,e as Ha,f as ms,h as qa}from"./vendor-react-BeVl62c0.js";import{t as Ja,c as Ka,a as As,F as Ga}from"./vendor-utils-00TdZexr.js";import{F as Tr,X as Ue,C as Va,L as ft,M as Pt,R as or,S as Rt,a as rt,b as wt,c as kr,d as us,T as Ze,P as Jt,e as Nr,f as Dt,g as Pr,h as Ya,i as st,j as zt,k as Qa,l as Za,m as nr,B as Os,D as Tt,n as Xa,o as en,p as _s,U as ps,q as tn,E as Fs,r as rn,s as sn,t as Ws,u as xs,v as mr,I as Bs,w as $t,x as ur,y as pr,G as Rr,Z as an,z as nn,A as on,H as Us,J as Hs,K as qs,N as ln,O as cn,Q as ir,V as xr,W as dn,Y as mn,_ as Js,$ as un,a0 as pn,a1 as zr,a2 as $r,a3 as Ar,a4 as xn,a5 as hn,a6 as gn,a7 as fn,a8 as bn,a9 as yn,aa as vn}from"./vendor-icons-_JvlqdUe.js";import{r as jn,a as wn,b as kn,M as Nn}from"./vendor-markdown-VwNYkg_0.js";import{h as Sn}from"./vendor-syntax-CdGaPJRS.js";import{r as Cn,a as En,b as Mn,c as Ln}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 n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();var tr={},hs;function In(){if(hs)return tr;hs=1;var t=Wa();return tr.createRoot=t.createRoot,tr.hydrateRoot=t.hydrateRoot,tr}var Dn=In();const Tn=Jr(Dn);function We(...t){return Ja(Ka(t))}function Pn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Kr=s.forwardRef(({className:t,children:r,...a},o)=>e.jsx("div",{ref:o,className:We("relative overflow-hidden",t),...a,children:e.jsx("div",{className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Kr.displayName="ScrollArea";const Rn=As("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"}}),J=s.forwardRef(({className:t,variant:r,size:a,...o},n)=>e.jsx("button",{className:We(Rn({variant:r,size:a,className:t})),ref:n,...o}));J.displayName="Button";const zn=As("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 Xe({className:t,variant:r,...a}){return e.jsx("div",{className:We(zn({variant:r}),t),...a})}const Qe=s.forwardRef(({className:t,type:r,...a},o)=>e.jsx("input",{type:r,className:We("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:o,...a}));Qe.displayName="Input";const ot=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),se=(t,r={})=>{const a=localStorage.getItem("auth-token"),o={};return r.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...r,headers:{...o,...r.headers}})},be={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:()=>se("/api/auth/user"),logout:()=>se("/api/auth/logout",{method:"POST"}),limitStatus:()=>se("/api/auth/limit-status"),changePassword:(t,r)=>se("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:r})})},admin:{getUsers:()=>se("/api/admin/users"),createUser:(t,r)=>se("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:r})}),updateUserStatus:(t,r)=>se(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:r})}),deleteUser:t=>se(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>se("/api/admin/email-domains"),addEmailDomain:t=>se("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>se(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>se(`/api/admin/users/${t}/limits`),updateUserLimits:(t,r)=>se(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(r)}),resetUserPassword:(t,r)=>se(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:r})})},projects:()=>se("/api/projects"),sessions:(t,r=5,a=0)=>se(`/api/projects/${t}/sessions?limit=${r}&offset=${a}`),sessionMessages:(t,r,a=null,o=0)=>{const n=new URLSearchParams;a!==null&&(n.append("limit",a),n.append("offset",o));const l=n.toString(),i=`/api/projects/${t}/sessions/${r}/messages${l?`?${l}`:""}`;return se(i)},renameProject:(t,r)=>se(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(t,r)=>se(`/api/projects/${t}/sessions/${r}`,{method:"DELETE"}),deleteProject:t=>se(`/api/projects/${t}`,{method:"DELETE"}),createProject:t=>se("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>se("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,r)=>se(`/api/projects/${t}/file?filePath=${encodeURIComponent(r)}`),saveFile:(t,r,a)=>se(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:a})}),getFiles:(t,r={})=>{const a=new URLSearchParams;r.dirPath&&a.set("dirPath",r.dirPath),r.depth&&a.set("depth",r.depth.toString());const o=a.toString();return se(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,r)=>se(`/api/projects/${t}/upload-files`,{method:"POST",body:r,headers:{}}),deleteFile:(t,r)=>se(`/api/projects/${t}/files?filePath=${encodeURIComponent(r)}`,{method:"DELETE"}),getFileContent:(t,r)=>se(`/api/projects/${t}/files/content?path=${encodeURIComponent(r)}`),transcribe:t=>se("/api/transcribe",{method:"POST",body:t,headers:{}}),settings:{getAgentPermissions:()=>se("/api/settings/agent-permissions"),saveAgentPermissions:t=>se("/api/settings/agent-permissions",{method:"PUT",body:JSON.stringify({agentPermissions:t})})},get:t=>se(`/api${t}`)},$n=/^[a-zA-Z0-9_-]+$/,An=({onClose:t,onProjectCreated:r})=>{const[a,o]=s.useState(""),[n,l]=s.useState(""),[i,m]=s.useState(!1),[g,x]=s.useState(null),b=y=>y.trim()?$n.test(y.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",S=async()=>{x(null);const y=b(a);if(y){x(y);return}m(!0);try{const h={name:a.trim()};n.trim()&&(h.githubUrl=n.trim());const z=await be.createWorkspace(h),$=await z.json();if(!z.ok)throw new Error($.error||"Failed to create project");r&&r($.project),t()}catch(h){console.error("Error creating project:",h),x(h.message||"Failed to create project")}finally{m(!1)}},v=y=>{y.key==="Enter"&&!i&&S()};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(Tr,{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:i,children:e.jsx(Ue,{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(Va,{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(Qe,{type:"text",value:a,onChange:y=>o(y.target.value),onKeyDown:v,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(Qe,{type:"text",value:n,onChange:y=>l(y.target.value),onKeyDown:v,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(J,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(J,{onClick:S,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},gs=(t,r)=>{const a=new Date(t),o=r;if(isNaN(a.getTime()))return"Unknown";const n=o-a,l=Math.floor(n/1e3),i=Math.floor(n/(1e3*60)),m=Math.floor(n/(1e3*60*60)),g=Math.floor(n/(1e3*60*60*24));return l<60?"Just now":i===1?"1 min ago":i<60?`${i} mins ago`:m===1?"1 hour ago":m<24?`${m} hours ago`:g===1?"1 day ago":g<7?`${g} days ago`:a.toLocaleDateString()};function fs({projects:t,selectedProject:r,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:l,onSessionDelete:i,onProjectDelete:m,isLoading:g,onRefresh:x,onShowSettings:b,isPWA:S,isMobile:v,onToggleSidebar:y}){const[h,z]=s.useState(new Set),[$,D]=s.useState(null),[C,p]=s.useState(!1),[d,j]=s.useState(""),[w,I]=s.useState({}),[B,W]=s.useState({}),[Z,le]=s.useState(new Set),[X,ne]=s.useState(new Date),[U,L]=s.useState("name"),[_,Q]=s.useState(!1),[he,ie]=s.useState(null),[Y,ge]=s.useState(""),[Ne,Le]=s.useState({}),[je,Oe]=s.useState(""),[pe,Se]=s.useState(()=>{try{const u=localStorage.getItem("starredProjects");return u?new Set(JSON.parse(u)):new Set}catch(u){return console.error("Error loading starred projects:",u),new Set}}),we=u=>A=>{A.target.closest(".overflow-y-auto")||A.target.closest("[data-scroll-container]")||(A.preventDefault(),A.stopPropagation(),u())};s.useEffect(()=>{const u=setInterval(()=>{ne(new Date)},6e4);return()=>clearInterval(u)},[]),s.useEffect(()=>{W({}),le(new Set)},[t]),s.useEffect(()=>{a&&r&&z(u=>new Set([...u,r.name]))},[a,r]),s.useEffect(()=>{if(t.length>0&&!g){const u=new Set;t.forEach(A=>{A.sessions&&A.sessions.length>=0&&u.add(A.name)}),le(u)}},[t,g]),s.useEffect(()=>{const u=()=>{try{const re=localStorage.getItem("claude-settings");if(re){const M=JSON.parse(re);L(M.projectSortOrder||"name")}}catch(re){console.error("Error loading sort order:",re)}};u();const A=re=>{re.key==="claude-settings"&&u()};window.addEventListener("storage",A);const oe=setInterval(()=>{document.hasFocus()&&u()},1e3);return()=>{window.removeEventListener("storage",A),clearInterval(oe)}},[]);const Ie=u=>{const A=new Set;h.has(u)||A.add(u),z(A)},xe=(u,A)=>{n({...u,__projectName:A})},Ce=u=>{const A=new Set(pe);A.has(u)?A.delete(u):A.add(u),Se(A);try{localStorage.setItem("starredProjects",JSON.stringify([...A]))}catch(oe){console.error("Error saving starred projects:",oe)}},Re=u=>pe.has(u),Ee=u=>[...u.sessions||[],...B[u.name]||[]].map(oe=>({...oe,__provider:"claude"})).sort((oe,re)=>new Date(re.lastActivity)-new Date(oe.lastActivity)),Be=u=>{const A=Ee(u);return A.length===0?new Date(0):A.reduce((re,M)=>{const De=new Date(M.lastActivity);return De>re?De:re},new Date(0))},P=[...t].sort((u,A)=>{const oe=Re(u.name),re=Re(A.name);if(oe&&!re)return-1;if(!oe&&re)return 1;if(U==="date")return Be(A)-Be(u);{const M=u.displayName||u.name,De=A.displayName||A.name;return M.localeCompare(De)}}),O=u=>{D(u.name),j(u.displayName)},F=()=>{D(null),j("")},f=async u=>{try{(await be.renameProject(u,d)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(A){console.error("Error renaming project:",A)}D(null),j("")},H=async(u,A,oe="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:u,sessionId:A,provider:oe});const re=await be.deleteSession(u,A);if(console.log("[Sidebar] Delete response:",{ok:re.ok,status:re.status}),re.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(A):console.warn("[Sidebar] No onSessionDelete callback provided");else{const M=await re.text();console.error("[Sidebar] Failed to delete session:",{status:re.status,error:M}),alert("Failed to delete session. Please try again.")}}catch(re){console.error("[Sidebar] Error deleting session:",re),alert("Error deleting session. Please try again.")}},de=async u=>{if(confirm("Are you sure you want to delete this empty project? This action cannot be undone."))try{const A=await be.deleteProject(u);if(A.ok)m&&m(u);else{const oe=await A.json();console.error("Failed to delete project"),alert(oe.error||"Failed to delete project. Please try again.")}}catch(A){console.error("Error deleting project:",A),alert("Error deleting project. Please try again.")}},Me=async u=>{if(!(!(u.sessionMeta?.hasMore!==!1)||w[u.name])){I(oe=>({...oe,[u.name]:!0}));try{const oe=(u.sessions?.length||0)+(B[u.name]?.length||0),re=await be.sessions(u.name,5,oe);if(re.ok){const M=await re.json();W(De=>({...De,[u.name]:[...De[u.name]||[],...M.sessions]})),M.hasMore===!1&&(u.sessionMeta={...u.sessionMeta,hasMore:!1})}}catch(oe){console.error("Error loading more sessions:",oe)}finally{I(oe=>({...oe,[u.name]:!1}))}}},$e=P.filter(u=>{if(!je.trim())return!0;const A=je.toLowerCase(),oe=(u.displayName||u.name).toLowerCase(),re=u.name.toLowerCase();return oe.includes(A)||re.includes(A)}),Ke=u=>{o(u)};return e.jsxs(e.Fragment,{children:[C&&Ba.createPortal(e.jsx(An,{onClose:()=>p(!1),onProjectCreated:u=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:S&&v?{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(Pt,{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 助手"})]})]}),y&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:y,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:S&&v?{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(Pt,{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()=>{Q(!0);try{await x()}finally{Q(!1)}},disabled:_,children:e.jsx(or,{className:`w-4 h-4 text-foreground ${_?"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(Tr,{className:"w-4 h-4"})})]})]})})]}),!g&&!v&&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(J,{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(Tr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(J,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{Q(!0);try{await x()}finally{Q(!1)}},disabled:_,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(or,{className:`w-3.5 h-3.5 ${_?"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(Rt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索项目...",value:je,onChange:u=>Oe(u.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),je&&e.jsx("button",{onClick:()=>Oe(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Kr,{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(rt,{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 以开始使用"})]}):$e.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(Rt,{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:"尝试调整搜索条件"})]}):$e.map(u=>{const A=h.has(u.name),oe=r?.name===u.name,re=Re(u.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:We("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",oe&&"bg-primary/5 border-primary/20",re&&!oe&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Ie(u.name)},onTouchEnd:we(()=>Ie(u.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:We("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",A?"bg-primary/10":"bg-muted"),children:A?e.jsx(wt,{className:"w-4 h-4 text-primary"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:$===u.name?e.jsx("input",{type:"text",value:d,onChange:M=>j(M.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:M=>M.stopPropagation(),onKeyDown:M=>{M.key==="Enter"&&f(u.name),M.key==="Escape"&&F()},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:u.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const M=Ee(u).length;return`${u.sessionMeta?.hasMore!==!1&&M>=5?`${M}+`:M} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:$===u.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:M=>{M.stopPropagation(),f(u.name)},children:e.jsx(kr,{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:M=>{M.stopPropagation(),F()},children:e.jsx(Ue,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:We("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",re?"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:M=>{M.stopPropagation(),Ce(u.name)},onTouchEnd:we(()=>Ce(u.name)),title:re?"从收藏中移除":"添加到收藏",children:e.jsx(us,{className:We("w-4 h-4 transition-colors",re?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),Ee(u).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:M=>{M.stopPropagation(),de(u.name)},onTouchEnd:we(()=>de(u.name)),children:e.jsx(Ze,{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:M=>{M.stopPropagation(),O(u)},onTouchEnd:we(()=>O(u)),children:e.jsx(Jt,{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:A?e.jsx(Nr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(J,{variant:"ghost",className:We("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",oe&&"bg-accent text-accent-foreground",re&&!oe&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{r?.name!==u.name&&Ke(u),Ie(u.name)},onTouchEnd:we(()=>{r?.name!==u.name&&Ke(u),Ie(u.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[A?e.jsx(wt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:$===u.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:d,onChange:M=>j(M.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:M=>{M.key==="Enter"&&f(u.name),M.key==="Escape"&&F()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:u.fullPath,children:u.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:u.displayName,children:u.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const M=Ee(u).length;return u.sessionMeta?.hasMore!==!1&&M>=5?`${M}+`:M})(),u.fullPath!==u.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:u.fullPath,children:["• ",u.fullPath.length>25?"..."+u.fullPath.slice(-22):u.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:$===u.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:M=>{M.stopPropagation(),f(u.name)},children:e.jsx(kr,{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:M=>{M.stopPropagation(),F()},children:e.jsx(Ue,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:We("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",re?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:M=>{M.stopPropagation(),Ce(u.name)},title:re?"从收藏中移除":"添加到收藏",children:e.jsx(us,{className:We("w-3 h-3 transition-colors",re?"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:M=>{M.stopPropagation(),O(u)},title:"重命名项目 (F2)",children:e.jsx(Jt,{className:"w-3 h-3"})}),Ee(u).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:M=>{M.stopPropagation(),de(u.name)},title:"删除空项目 (Delete)",children:e.jsx(Ze,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),A?e.jsx(Nr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),A&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[Z.has(u.name)?Ee(u).length===0&&!w[u.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):Ee(u).map(M=>{const De=new Date(M.lastActivity),Te=Math.floor((X-De)/(1e3*60))<10,K=M.summary||"新会话",ue=M.lastActivity,te=M.messageCount||0;return e.jsxs("div",{className:"group relative",children:[Te&&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:We("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===M.id?"bg-primary/5 border-primary/20":Te?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{Ke(u),xe(M,u.name)},onTouchEnd:we(()=>{Ke(u),xe(M,u.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:We("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===M.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(ot,{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:K}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Pr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(ue,X)}),te>0&&e.jsx(Xe,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:te}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:ce=>{ce.stopPropagation(),H(u.name,M.id)},onTouchEnd:we(()=>H(u.name,M.id)),children:e.jsx(Ze,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(J,{variant:"ghost",className:We("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===M.id&&"bg-accent text-accent-foreground"),onClick:()=>xe(M,u.name),onTouchEnd:we(()=>xe(M,u.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(ot,{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:K}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Pr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(ue,X)}),te>0&&e.jsx(Xe,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:te}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:he===M.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:Y,onChange:ce=>ge(ce.target.value),onKeyDown:ce=>{ce.stopPropagation(),ce.key==="Enter"?updateSessionSummary(u.name,M.id,Y):ce.key==="Escape"&&(ie(null),ge(""))},onClick:ce=>ce.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:ce=>{ce.stopPropagation(),updateSessionSummary(u.name,M.id,Y)},title:"Save",children:e.jsx(kr,{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:ce=>{ce.stopPropagation(),ie(null),ge("")},title:"Cancel",children:e.jsx(Ue,{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:ce=>{ce.stopPropagation(),ie(M.id),ge(M.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Ya,{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:ce=>{ce.stopPropagation(),H(u.name,M.id)},title:"永久删除此会话",children:e.jsx(Ze,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},M.id)}):Array.from({length:3}).map((M,De)=>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+De*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},De)),Ee(u).length>0&&u.sessionMeta?.hasMore!==!1&&e.jsx(J,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>Me(u),disabled:w[u.name],children:w[u.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(Nr,{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:()=>{Ke(u),l(u)},children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(J,{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:()=>l(u),children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})]})]},u.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:b,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(zt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(J,{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:b,children:[e.jsx(zt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const On={'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 Sr={exports:{}},Cr,bs;function _n(){if(bs)return Cr;bs=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Cr=t,Cr}var Er,ys;function Fn(){if(ys)return Er;ys=1;var t=_n();function r(){}function a(){}return a.resetWarningCache=r,Er=function(){function o(i,m,g,x,b,S){if(S!==t){var v=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 v.name="Invariant Violation",v}}o.isRequired=o;function n(){return o}var l={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:n,element:o,elementType:o,instanceOf:n,node:o,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:r};return l.PropTypes=l,l},Er}var vs;function Wn(){return vs||(vs=1,Sr.exports=Fn()()),Sr.exports}var Bn=Wn();const ze=Jr(Bn);function kt(t,r,a,o){function n(l){return l instanceof a?l:new a(function(i){i(l)})}return new(a||(a=Promise))(function(l,i){function m(b){try{x(o.next(b))}catch(S){i(S)}}function g(b){try{x(o.throw(b))}catch(S){i(S)}}function x(b){b.done?l(b.value):n(b.value).then(m,g)}x((o=o.apply(t,r||[])).next())})}const Un=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 At(t,r,a){const o=Hn(t),{webkitRelativePath:n}=t,l=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&js(o,"path",l),js(o,"relativePath",l),o}function Hn(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const o=r.split(".").pop().toLowerCase(),n=Un.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function js(t,r,a){Object.defineProperty(t,r,{value:a,writable:!1,configurable:!1,enumerable:!0})}const qn=[".DS_Store","Thumbs.db"];function Jn(t){return kt(this,void 0,void 0,function*(){return lr(t)&&Kn(t.dataTransfer)?Qn(t.dataTransfer,t.type):Gn(t)?Vn(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Yn(t):[]})}function Kn(t){return lr(t)}function Gn(t){return lr(t)&&lr(t.target)}function lr(t){return typeof t=="object"&&t!==null}function Vn(t){return Or(t.target.files).map(r=>At(r))}function Yn(t){return kt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>At(a))})}function Qn(t,r){return kt(this,void 0,void 0,function*(){if(t.items){const a=Or(t.items).filter(n=>n.kind==="file");if(r!=="drop")return a;const o=yield Promise.all(a.map(Zn));return ws(Ks(o))}return ws(Or(t.files).map(a=>At(a)))})}function ws(t){return t.filter(r=>qn.indexOf(r.name)===-1)}function Or(t){if(t===null)return[];const r=[];for(let a=0;a<t.length;a++){const o=t[a];r.push(o)}return r}function Zn(t){if(typeof t.webkitGetAsEntry!="function")return ks(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Gs(r):ks(t,r)}function Ks(t){return t.reduce((r,a)=>[...r,...Array.isArray(a)?Ks(a):[a]],[])}function ks(t,r){return kt(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const l=yield t.getAsFileSystemHandle();if(l===null)throw new Error(`${t} is not a File`);if(l!==void 0){const i=yield l.getFile();return i.handle=l,At(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return At(o,(a=r?.fullPath)!==null&&a!==void 0?a:void 0)})}function Xn(t){return kt(this,void 0,void 0,function*(){return t.isDirectory?Gs(t):eo(t)})}function Gs(t){const r=t.createReader();return new Promise((a,o)=>{const n=[];function l(){r.readEntries(i=>kt(this,void 0,void 0,function*(){if(i.length){const m=Promise.all(i.map(Xn));n.push(m),l()}else try{const m=yield Promise.all(n);a(m)}catch(m){o(m)}}),i=>{o(i)})}l()})}function eo(t){return kt(this,void 0,void 0,function*(){return new Promise((r,a)=>{t.file(o=>{const n=At(o,t.fullPath);r(n)},o=>{a(o)})})})}var rr={},Ns;function to(){return Ns||(Ns=1,rr.__esModule=!0,rr.default=function(t,r){if(t&&r){var a=Array.isArray(r)?r:r.split(",");if(a.length===0)return!0;var o=t.name||"",n=(t.type||"").toLowerCase(),l=n.replace(/\/.*$/,"");return a.some(function(i){var m=i.trim().toLowerCase();return m.charAt(0)==="."?o.toLowerCase().endsWith(m):m.endsWith("/*")?l===m.replace(/\/.*$/,""):n===m})}return!0}),rr}var ro=to();const Mr=Jr(ro);function Ss(t){return no(t)||ao(t)||Ys(t)||so()}function so(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{j as e,s as Da,R as Ta,o as Pa,E as Ra,m as za,b as $a,c as Aa,h as Oa,p as _a,d as Fa}from"./vendor-codemirror-C_VWDoZS.js";import{b as Wa,g as Jr,a as s,d as Ba,R as et,u as $s,B as Ua,e as Ha,f as ms,h as qa}from"./vendor-react-BeVl62c0.js";import{t as Ja,c as Ka,a as As,F as Ga}from"./vendor-utils-00TdZexr.js";import{F as Tr,X as Ue,C as Va,L as ft,M as Pt,R as or,S as Rt,a as rt,b as wt,c as kr,d as us,T as Ze,P as Jt,e as Nr,f as Dt,g as Pr,h as Ya,i as st,j as zt,k as Qa,l as Za,m as nr,B as Os,D as Tt,n as Xa,o as en,p as _s,U as ps,q as tn,E as Fs,r as rn,s as sn,t as Ws,u as xs,v as mr,I as Bs,w as $t,x as ur,y as pr,G as Rr,Z as an,z as nn,A as on,H as Us,J as Hs,K as qs,N as ln,O as cn,Q as ir,V as xr,W as dn,Y as mn,_ as Js,$ as un,a0 as pn,a1 as zr,a2 as $r,a3 as Ar,a4 as xn,a5 as hn,a6 as gn,a7 as fn,a8 as bn,a9 as yn,aa as vn}from"./vendor-icons-_JvlqdUe.js";import{r as jn,a as wn,b as kn,M as Nn}from"./vendor-markdown-VwNYkg_0.js";import{h as Sn}from"./vendor-syntax-CdGaPJRS.js";import{r as Cn,a as En,b as Mn,c as Ln}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 n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();var tr={},hs;function In(){if(hs)return tr;hs=1;var t=Wa();return tr.createRoot=t.createRoot,tr.hydrateRoot=t.hydrateRoot,tr}var Dn=In();const Tn=Jr(Dn);function We(...t){return Ja(Ka(t))}function Pn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Kr=s.forwardRef(({className:t,children:r,...a},o)=>e.jsx("div",{ref:o,className:We("relative overflow-hidden",t),...a,children:e.jsx("div",{className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Kr.displayName="ScrollArea";const Rn=As("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"}}),J=s.forwardRef(({className:t,variant:r,size:a,...o},n)=>e.jsx("button",{className:We(Rn({variant:r,size:a,className:t})),ref:n,...o}));J.displayName="Button";const zn=As("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 Xe({className:t,variant:r,...a}){return e.jsx("div",{className:We(zn({variant:r}),t),...a})}const Qe=s.forwardRef(({className:t,type:r,...a},o)=>e.jsx("input",{type:r,className:We("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:o,...a}));Qe.displayName="Input";const ot=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),re=(t,r={})=>{const a=localStorage.getItem("auth-token"),o={};return r.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...r,headers:{...o,...r.headers}})},be={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:()=>re("/api/auth/user"),logout:()=>re("/api/auth/logout",{method:"POST"}),limitStatus:()=>re("/api/auth/limit-status"),changePassword:(t,r)=>re("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:r})})},admin:{getUsers:()=>re("/api/admin/users"),createUser:(t,r)=>re("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:r})}),updateUserStatus:(t,r)=>re(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:r})}),deleteUser:t=>re(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>re("/api/admin/email-domains"),addEmailDomain:t=>re("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>re(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>re(`/api/admin/users/${t}/limits`),updateUserLimits:(t,r)=>re(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(r)}),resetUserPassword:(t,r)=>re(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:r})})},projects:()=>re("/api/projects"),sessions:(t,r=5,a=0)=>re(`/api/projects/${t}/sessions?limit=${r}&offset=${a}`),sessionMessages:(t,r,a=null,o=0)=>{const n=new URLSearchParams;a!==null&&(n.append("limit",a),n.append("offset",o));const l=n.toString(),i=`/api/projects/${t}/sessions/${r}/messages${l?`?${l}`:""}`;return re(i)},renameProject:(t,r)=>re(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(t,r)=>re(`/api/projects/${t}/sessions/${r}`,{method:"DELETE"}),deleteProject:t=>re(`/api/projects/${t}`,{method:"DELETE"}),createProject:t=>re("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>re("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,r)=>re(`/api/projects/${t}/file?filePath=${encodeURIComponent(r)}`),saveFile:(t,r,a)=>re(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:a})}),getFiles:(t,r={})=>{const a=new URLSearchParams;r.dirPath&&a.set("dirPath",r.dirPath),r.depth&&a.set("depth",r.depth.toString());const o=a.toString();return re(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,r)=>re(`/api/projects/${t}/upload-files`,{method:"POST",body:r,headers:{}}),deleteFile:(t,r)=>re(`/api/projects/${t}/files?filePath=${encodeURIComponent(r)}`,{method:"DELETE"}),getFileContent:(t,r)=>re(`/api/projects/${t}/files/content?path=${encodeURIComponent(r)}`),transcribe:t=>re("/api/transcribe",{method:"POST",body:t,headers:{}}),settings:{getAgentPermissions:()=>re("/api/settings/agent-permissions"),saveAgentPermissions:t=>re("/api/settings/agent-permissions",{method:"PUT",body:JSON.stringify({agentPermissions:t})})},get:t=>re(`/api${t}`)},$n=/^[a-zA-Z0-9_-]+$/,An=({onClose:t,onProjectCreated:r})=>{const[a,o]=s.useState(""),[n,l]=s.useState(""),[i,m]=s.useState(!1),[g,x]=s.useState(null),b=y=>y.trim()?$n.test(y.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",S=async()=>{x(null);const y=b(a);if(y){x(y);return}m(!0);try{const h={name:a.trim()};n.trim()&&(h.githubUrl=n.trim());const z=await be.createWorkspace(h),$=await z.json();if(!z.ok)throw new Error($.error||"Failed to create project");r&&r($.project),t()}catch(h){console.error("Error creating project:",h),x(h.message||"Failed to create project")}finally{m(!1)}},v=y=>{y.key==="Enter"&&!i&&S()};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(Tr,{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:i,children:e.jsx(Ue,{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(Va,{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(Qe,{type:"text",value:a,onChange:y=>o(y.target.value),onKeyDown:v,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(Qe,{type:"text",value:n,onChange:y=>l(y.target.value),onKeyDown:v,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(J,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(J,{onClick:S,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},gs=(t,r)=>{const a=new Date(t),o=r;if(isNaN(a.getTime()))return"Unknown";const n=o-a,l=Math.floor(n/1e3),i=Math.floor(n/(1e3*60)),m=Math.floor(n/(1e3*60*60)),g=Math.floor(n/(1e3*60*60*24));return l<60?"Just now":i===1?"1 min ago":i<60?`${i} mins ago`:m===1?"1 hour ago":m<24?`${m} hours ago`:g===1?"1 day ago":g<7?`${g} days ago`:a.toLocaleDateString()};function fs({projects:t,selectedProject:r,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:l,onSessionDelete:i,onProjectDelete:m,isLoading:g,onRefresh:x,onShowSettings:b,isPWA:S,isMobile:v,onToggleSidebar:y}){const[h,z]=s.useState(new Set),[$,D]=s.useState(null),[C,p]=s.useState(!1),[d,j]=s.useState(""),[w,L]=s.useState({}),[B,W]=s.useState({}),[Z,le]=s.useState(new Set),[X,ne]=s.useState(new Date),[U,I]=s.useState("name"),[_,Q]=s.useState(!1),[he,ie]=s.useState(null),[Y,ge]=s.useState(""),[Ne,Le]=s.useState({}),[je,Oe]=s.useState(""),[pe,Se]=s.useState(()=>{try{const u=localStorage.getItem("starredProjects");return u?new Set(JSON.parse(u)):new Set}catch(u){return console.error("Error loading starred projects:",u),new Set}}),we=u=>A=>{A.target.closest(".overflow-y-auto")||A.target.closest("[data-scroll-container]")||(A.preventDefault(),A.stopPropagation(),u())};s.useEffect(()=>{const u=setInterval(()=>{ne(new Date)},6e4);return()=>clearInterval(u)},[]),s.useEffect(()=>{W({}),le(new Set)},[t]),s.useEffect(()=>{a&&r&&z(u=>new Set([...u,r.name]))},[a,r]),s.useEffect(()=>{if(t.length>0&&!g){const u=new Set;t.forEach(A=>{A.sessions&&A.sessions.length>=0&&u.add(A.name)}),le(u)}},[t,g]),s.useEffect(()=>{const u=()=>{try{const se=localStorage.getItem("claude-settings");if(se){const M=JSON.parse(se);I(M.projectSortOrder||"name")}}catch(se){console.error("Error loading sort order:",se)}};u();const A=se=>{se.key==="claude-settings"&&u()};window.addEventListener("storage",A);const oe=setInterval(()=>{document.hasFocus()&&u()},1e3);return()=>{window.removeEventListener("storage",A),clearInterval(oe)}},[]);const Ie=u=>{const A=new Set;h.has(u)||A.add(u),z(A)},xe=(u,A)=>{n({...u,__projectName:A})},Ce=u=>{const A=new Set(pe);A.has(u)?A.delete(u):A.add(u),Se(A);try{localStorage.setItem("starredProjects",JSON.stringify([...A]))}catch(oe){console.error("Error saving starred projects:",oe)}},Re=u=>pe.has(u),Ee=u=>[...u.sessions||[],...B[u.name]||[]].map(oe=>({...oe,__provider:"claude"})).sort((oe,se)=>new Date(se.lastActivity)-new Date(oe.lastActivity)),Be=u=>{const A=Ee(u);return A.length===0?new Date(0):A.reduce((se,M)=>{const De=new Date(M.lastActivity);return De>se?De:se},new Date(0))},P=[...t].sort((u,A)=>{const oe=Re(u.name),se=Re(A.name);if(oe&&!se)return-1;if(!oe&&se)return 1;if(U==="date")return Be(A)-Be(u);{const M=u.displayName||u.name,De=A.displayName||A.name;return M.localeCompare(De)}}),O=u=>{D(u.name),j(u.displayName)},F=()=>{D(null),j("")},f=async u=>{try{(await be.renameProject(u,d)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(A){console.error("Error renaming project:",A)}D(null),j("")},H=async(u,A,oe="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:u,sessionId:A,provider:oe});const se=await be.deleteSession(u,A);if(console.log("[Sidebar] Delete response:",{ok:se.ok,status:se.status}),se.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(A):console.warn("[Sidebar] No onSessionDelete callback provided");else{const M=await se.text();console.error("[Sidebar] Failed to delete session:",{status:se.status,error:M}),alert("Failed to delete session. Please try again.")}}catch(se){console.error("[Sidebar] Error deleting session:",se),alert("Error deleting session. Please try again.")}},de=async u=>{if(confirm("Are you sure you want to delete this empty project? This action cannot be undone."))try{const A=await be.deleteProject(u);if(A.ok)m&&m(u);else{const oe=await A.json();console.error("Failed to delete project"),alert(oe.error||"Failed to delete project. Please try again.")}}catch(A){console.error("Error deleting project:",A),alert("Error deleting project. Please try again.")}},Me=async u=>{if(!(!(u.sessionMeta?.hasMore!==!1)||w[u.name])){L(oe=>({...oe,[u.name]:!0}));try{const oe=(u.sessions?.length||0)+(B[u.name]?.length||0),se=await be.sessions(u.name,5,oe);if(se.ok){const M=await se.json();W(De=>({...De,[u.name]:[...De[u.name]||[],...M.sessions]})),M.hasMore===!1&&(u.sessionMeta={...u.sessionMeta,hasMore:!1})}}catch(oe){console.error("Error loading more sessions:",oe)}finally{L(oe=>({...oe,[u.name]:!1}))}}},$e=P.filter(u=>{if(!je.trim())return!0;const A=je.toLowerCase(),oe=(u.displayName||u.name).toLowerCase(),se=u.name.toLowerCase();return oe.includes(A)||se.includes(A)}),Ke=u=>{o(u)};return e.jsxs(e.Fragment,{children:[C&&Ba.createPortal(e.jsx(An,{onClose:()=>p(!1),onProjectCreated:u=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:S&&v?{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(Pt,{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 助手"})]})]}),y&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:y,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:S&&v?{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(Pt,{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()=>{Q(!0);try{await x()}finally{Q(!1)}},disabled:_,children:e.jsx(or,{className:`w-4 h-4 text-foreground ${_?"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(Tr,{className:"w-4 h-4"})})]})]})})]}),!g&&!v&&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(J,{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(Tr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(J,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{Q(!0);try{await x()}finally{Q(!1)}},disabled:_,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(or,{className:`w-3.5 h-3.5 ${_?"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(Rt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索项目...",value:je,onChange:u=>Oe(u.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),je&&e.jsx("button",{onClick:()=>Oe(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Kr,{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(rt,{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 以开始使用"})]}):$e.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(Rt,{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:"尝试调整搜索条件"})]}):$e.map(u=>{const A=h.has(u.name),oe=r?.name===u.name,se=Re(u.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:We("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",oe&&"bg-primary/5 border-primary/20",se&&!oe&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Ie(u.name)},onTouchEnd:we(()=>Ie(u.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:We("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",A?"bg-primary/10":"bg-muted"),children:A?e.jsx(wt,{className:"w-4 h-4 text-primary"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:$===u.name?e.jsx("input",{type:"text",value:d,onChange:M=>j(M.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:M=>M.stopPropagation(),onKeyDown:M=>{M.key==="Enter"&&f(u.name),M.key==="Escape"&&F()},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:u.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const M=Ee(u).length;return`${u.sessionMeta?.hasMore!==!1&&M>=5?`${M}+`:M} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:$===u.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:M=>{M.stopPropagation(),f(u.name)},children:e.jsx(kr,{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:M=>{M.stopPropagation(),F()},children:e.jsx(Ue,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:We("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",se?"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:M=>{M.stopPropagation(),Ce(u.name)},onTouchEnd:we(()=>Ce(u.name)),title:se?"从收藏中移除":"添加到收藏",children:e.jsx(us,{className:We("w-4 h-4 transition-colors",se?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),Ee(u).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:M=>{M.stopPropagation(),de(u.name)},onTouchEnd:we(()=>de(u.name)),children:e.jsx(Ze,{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:M=>{M.stopPropagation(),O(u)},onTouchEnd:we(()=>O(u)),children:e.jsx(Jt,{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:A?e.jsx(Nr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(J,{variant:"ghost",className:We("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",oe&&"bg-accent text-accent-foreground",se&&!oe&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{r?.name!==u.name&&Ke(u),Ie(u.name)},onTouchEnd:we(()=>{r?.name!==u.name&&Ke(u),Ie(u.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[A?e.jsx(wt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:$===u.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:d,onChange:M=>j(M.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:M=>{M.key==="Enter"&&f(u.name),M.key==="Escape"&&F()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:u.fullPath,children:u.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:u.displayName,children:u.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const M=Ee(u).length;return u.sessionMeta?.hasMore!==!1&&M>=5?`${M}+`:M})(),u.fullPath!==u.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:u.fullPath,children:["• ",u.fullPath.length>25?"..."+u.fullPath.slice(-22):u.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:$===u.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:M=>{M.stopPropagation(),f(u.name)},children:e.jsx(kr,{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:M=>{M.stopPropagation(),F()},children:e.jsx(Ue,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:We("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",se?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:M=>{M.stopPropagation(),Ce(u.name)},title:se?"从收藏中移除":"添加到收藏",children:e.jsx(us,{className:We("w-3 h-3 transition-colors",se?"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:M=>{M.stopPropagation(),O(u)},title:"重命名项目 (F2)",children:e.jsx(Jt,{className:"w-3 h-3"})}),Ee(u).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:M=>{M.stopPropagation(),de(u.name)},title:"删除空项目 (Delete)",children:e.jsx(Ze,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),A?e.jsx(Nr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),A&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[Z.has(u.name)?Ee(u).length===0&&!w[u.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):Ee(u).map(M=>{const De=new Date(M.lastActivity),Te=Math.floor((X-De)/(1e3*60))<10,K=M.summary||"新会话",ue=M.lastActivity,te=M.messageCount||0;return e.jsxs("div",{className:"group relative",children:[Te&&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:We("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===M.id?"bg-primary/5 border-primary/20":Te?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{Ke(u),xe(M,u.name)},onTouchEnd:we(()=>{Ke(u),xe(M,u.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:We("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===M.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(ot,{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:K}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Pr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(ue,X)}),te>0&&e.jsx(Xe,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:te}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:ce=>{ce.stopPropagation(),H(u.name,M.id)},onTouchEnd:we(()=>H(u.name,M.id)),children:e.jsx(Ze,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(J,{variant:"ghost",className:We("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===M.id&&"bg-accent text-accent-foreground"),onClick:()=>xe(M,u.name),onTouchEnd:we(()=>xe(M,u.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(ot,{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:K}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Pr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:gs(ue,X)}),te>0&&e.jsx(Xe,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:te}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:he===M.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:Y,onChange:ce=>ge(ce.target.value),onKeyDown:ce=>{ce.stopPropagation(),ce.key==="Enter"?updateSessionSummary(u.name,M.id,Y):ce.key==="Escape"&&(ie(null),ge(""))},onClick:ce=>ce.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:ce=>{ce.stopPropagation(),updateSessionSummary(u.name,M.id,Y)},title:"Save",children:e.jsx(kr,{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:ce=>{ce.stopPropagation(),ie(null),ge("")},title:"Cancel",children:e.jsx(Ue,{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:ce=>{ce.stopPropagation(),ie(M.id),ge(M.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Ya,{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:ce=>{ce.stopPropagation(),H(u.name,M.id)},title:"永久删除此会话",children:e.jsx(Ze,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},M.id)}):Array.from({length:3}).map((M,De)=>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+De*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},De)),Ee(u).length>0&&u.sessionMeta?.hasMore!==!1&&e.jsx(J,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>Me(u),disabled:w[u.name],children:w[u.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(Nr,{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:()=>{Ke(u),l(u)},children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(J,{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:()=>l(u),children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})]})]},u.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:b,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(zt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(J,{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:b,children:[e.jsx(zt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const On={'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 Sr={exports:{}},Cr,bs;function _n(){if(bs)return Cr;bs=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Cr=t,Cr}var Er,ys;function Fn(){if(ys)return Er;ys=1;var t=_n();function r(){}function a(){}return a.resetWarningCache=r,Er=function(){function o(i,m,g,x,b,S){if(S!==t){var v=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 v.name="Invariant Violation",v}}o.isRequired=o;function n(){return o}var l={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:n,element:o,elementType:o,instanceOf:n,node:o,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:r};return l.PropTypes=l,l},Er}var vs;function Wn(){return vs||(vs=1,Sr.exports=Fn()()),Sr.exports}var Bn=Wn();const ze=Jr(Bn);function kt(t,r,a,o){function n(l){return l instanceof a?l:new a(function(i){i(l)})}return new(a||(a=Promise))(function(l,i){function m(b){try{x(o.next(b))}catch(S){i(S)}}function g(b){try{x(o.throw(b))}catch(S){i(S)}}function x(b){b.done?l(b.value):n(b.value).then(m,g)}x((o=o.apply(t,r||[])).next())})}const Un=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 At(t,r,a){const o=Hn(t),{webkitRelativePath:n}=t,l=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&js(o,"path",l),js(o,"relativePath",l),o}function Hn(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const o=r.split(".").pop().toLowerCase(),n=Un.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function js(t,r,a){Object.defineProperty(t,r,{value:a,writable:!1,configurable:!1,enumerable:!0})}const qn=[".DS_Store","Thumbs.db"];function Jn(t){return kt(this,void 0,void 0,function*(){return lr(t)&&Kn(t.dataTransfer)?Qn(t.dataTransfer,t.type):Gn(t)?Vn(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Yn(t):[]})}function Kn(t){return lr(t)}function Gn(t){return lr(t)&&lr(t.target)}function lr(t){return typeof t=="object"&&t!==null}function Vn(t){return Or(t.target.files).map(r=>At(r))}function Yn(t){return kt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>At(a))})}function Qn(t,r){return kt(this,void 0,void 0,function*(){if(t.items){const a=Or(t.items).filter(n=>n.kind==="file");if(r!=="drop")return a;const o=yield Promise.all(a.map(Zn));return ws(Ks(o))}return ws(Or(t.files).map(a=>At(a)))})}function ws(t){return t.filter(r=>qn.indexOf(r.name)===-1)}function Or(t){if(t===null)return[];const r=[];for(let a=0;a<t.length;a++){const o=t[a];r.push(o)}return r}function Zn(t){if(typeof t.webkitGetAsEntry!="function")return ks(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Gs(r):ks(t,r)}function Ks(t){return t.reduce((r,a)=>[...r,...Array.isArray(a)?Ks(a):[a]],[])}function ks(t,r){return kt(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const l=yield t.getAsFileSystemHandle();if(l===null)throw new Error(`${t} is not a File`);if(l!==void 0){const i=yield l.getFile();return i.handle=l,At(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return At(o,(a=r?.fullPath)!==null&&a!==void 0?a:void 0)})}function Xn(t){return kt(this,void 0,void 0,function*(){return t.isDirectory?Gs(t):eo(t)})}function Gs(t){const r=t.createReader();return new Promise((a,o)=>{const n=[];function l(){r.readEntries(i=>kt(this,void 0,void 0,function*(){if(i.length){const m=Promise.all(i.map(Xn));n.push(m),l()}else try{const m=yield Promise.all(n);a(m)}catch(m){o(m)}}),i=>{o(i)})}l()})}function eo(t){return kt(this,void 0,void 0,function*(){return new Promise((r,a)=>{t.file(o=>{const n=At(o,t.fullPath);r(n)},o=>{a(o)})})})}var rr={},Ns;function to(){return Ns||(Ns=1,rr.__esModule=!0,rr.default=function(t,r){if(t&&r){var a=Array.isArray(r)?r:r.split(",");if(a.length===0)return!0;var o=t.name||"",n=(t.type||"").toLowerCase(),l=n.replace(/\/.*$/,"");return a.some(function(i){var m=i.trim().toLowerCase();return m.charAt(0)==="."?o.toLowerCase().endsWith(m):m.endsWith("/*")?l===m.replace(/\/.*$/,""):n===m})}return!0}),rr}var ro=to();const Mr=Jr(ro);function Ss(t){return no(t)||ao(t)||Ys(t)||so()}function so(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ao(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function no(t){if(Array.isArray(t))return _r(t)}function Cs(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Es(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Cs(Object(a),!0).forEach(function(o){Vs(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Cs(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Vs(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function Kt(t,r){return lo(t)||io(t,r)||Ys(t,r)||oo()}function oo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ys(t,r){if(t){if(typeof t=="string")return _r(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _r(t,r)}}function _r(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function io(t,r){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,m;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(r&&o.length===r));n=!0);}catch(g){l=!0,m=g}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw m}}return o}}function lo(t){if(Array.isArray(t))return t}var co=typeof Mr=="function"?Mr:Mr.default,mo="file-invalid-type",uo="file-too-large",po="file-too-small",xo="too-many-files",ho=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",a=r.split(","),o=a.length>1?"one of ".concat(a.join(", ")):a[0];return{code:mo,message:"File type must be ".concat(o)}},Ms=function(r){return{code:uo,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},Ls=function(r){return{code:po,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},go={code:xo,message:"Too many files"};function Qs(t,r){var a=t.type==="application/x-moz-file"||co(t,r);return[a,a?null:ho(r)]}function Zs(t,r,a){if(jt(t.size))if(jt(r)&&jt(a)){if(t.size>a)return[!1,Ms(a)];if(t.size<r)return[!1,Ls(r)]}else{if(jt(r)&&t.size<r)return[!1,Ls(r)];if(jt(a)&&t.size>a)return[!1,Ms(a)]}return[!0,null]}function jt(t){return t!=null}function fo(t){var r=t.files,a=t.accept,o=t.minSize,n=t.maxSize,l=t.multiple,i=t.maxFiles,m=t.validator;return!l&&r.length>1||l&&i>=1&&r.length>i?!1:r.every(function(g){var x=Qs(g,a),b=Kt(x,1),S=b[0],v=Zs(g,o,n),y=Kt(v,1),h=y[0],z=m?m(g):null;return S&&h&&!z})}function cr(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function sr(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 Is(t){t.preventDefault()}function bo(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function yo(t){return t.indexOf("Edge/")!==-1}function vo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return bo(t)||yo(t)}function nt(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return function(o){for(var n=arguments.length,l=new Array(n>1?n-1:0),i=1;i<n;i++)l[i-1]=arguments[i];return r.some(function(m){return!cr(o)&&m&&m.apply(void 0,[o].concat(l)),cr(o)})}}function jo(){return"showOpenFilePicker"in window}function wo(t){if(jt(t)){var r=Object.entries(t).filter(function(a){var o=Kt(a,2),n=o[0],l=o[1],i=!0;return Xs(n)||(console.warn('Skipped "'.concat(n,'" 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.')),i=!1),(!Array.isArray(l)||!l.every(ea))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(a,o){var n=Kt(o,2),l=n[0],i=n[1];return Es(Es({},a),{},Vs({},l,i))},{});return[{description:"Files",accept:r}]}return t}function ko(t){if(jt(t))return Object.entries(t).reduce(function(r,a){var o=Kt(a,2),n=o[0],l=o[1];return[].concat(Ss(r),[n],Ss(l))},[]).filter(function(r){return Xs(r)||ea(r)}).join(",")}function No(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function So(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Xs(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function ea(t){return/^.*\.[\w]+$/.test(t)}var Co=["children"],Eo=["open"],Mo=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Lo=["refKey","onChange","onClick"];function Io(t){return Po(t)||To(t)||ta(t)||Do()}function Do(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Po(t){if(Array.isArray(t))return Fr(t)}function Lr(t,r){return $o(t)||zo(t,r)||ta(t,r)||Ro()}function Ro(){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 ta(t,r){if(t){if(typeof t=="string")return Fr(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Fr(t,r)}}function Fr(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function zo(t,r){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,m;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(r&&o.length===r));n=!0);}catch(g){l=!0,m=g}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw m}}return o}}function $o(t){if(Array.isArray(t))return t}function Ds(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function _e(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Ds(Object(a),!0).forEach(function(o){Wr(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ds(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Wr(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function dr(t,r){if(t==null)return{};var a=Ao(t,r),o,n;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(n=0;n<l.length;n++)o=l[n],!(r.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function Ao(t,r){if(t==null)return{};var a={},o=Object.keys(t),n,l;for(l=0;l<o.length;l++)n=o[l],!(r.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Gr=s.forwardRef(function(t,r){var a=t.children,o=dr(t,Co),n=Vr(o),l=n.open,i=dr(n,Eo);return s.useImperativeHandle(r,function(){return{open:l}},[l]),et.createElement(s.Fragment,null,a(_e(_e({},i),{},{open:l})))});Gr.displayName="Dropzone";var ra={disabled:!1,getFilesFromEvent:Jn,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};Gr.defaultProps=ra;Gr.propTypes={children:ze.func,accept:ze.objectOf(ze.arrayOf(ze.string)),multiple:ze.bool,preventDropOnDocument:ze.bool,noClick:ze.bool,noKeyboard:ze.bool,noDrag:ze.bool,noDragEventsBubbling:ze.bool,minSize:ze.number,maxSize:ze.number,maxFiles:ze.number,disabled:ze.bool,getFilesFromEvent:ze.func,onFileDialogCancel:ze.func,onFileDialogOpen:ze.func,useFsAccessApi:ze.bool,autoFocus:ze.bool,onDragEnter:ze.func,onDragLeave:ze.func,onDragOver:ze.func,onDrop:ze.func,onDropAccepted:ze.func,onDropRejected:ze.func,onError:ze.func,validator:ze.func};var Br={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Vr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=_e(_e({},ra),t),a=r.accept,o=r.disabled,n=r.getFilesFromEvent,l=r.maxSize,i=r.minSize,m=r.multiple,g=r.maxFiles,x=r.onDragEnter,b=r.onDragLeave,S=r.onDragOver,v=r.onDrop,y=r.onDropAccepted,h=r.onDropRejected,z=r.onFileDialogCancel,$=r.onFileDialogOpen,D=r.useFsAccessApi,C=r.autoFocus,p=r.preventDropOnDocument,d=r.noClick,j=r.noKeyboard,w=r.noDrag,I=r.noDragEventsBubbling,B=r.onError,W=r.validator,Z=s.useMemo(function(){return ko(a)},[a]),le=s.useMemo(function(){return wo(a)},[a]),X=s.useMemo(function(){return typeof $=="function"?$:Ts},[$]),ne=s.useMemo(function(){return typeof z=="function"?z:Ts},[z]),U=s.useRef(null),L=s.useRef(null),_=s.useReducer(Oo,Br),Q=Lr(_,2),he=Q[0],ie=Q[1],Y=he.isFocused,ge=he.isFileDialogActive,Ne=s.useRef(typeof window<"u"&&window.isSecureContext&&D&&jo()),Le=function(){!Ne.current&&ge&&setTimeout(function(){if(L.current){var A=L.current.files;A.length||(ie({type:"closeDialog"}),ne())}},300)};s.useEffect(function(){return window.addEventListener("focus",Le,!1),function(){window.removeEventListener("focus",Le,!1)}},[L,ge,ne,Ne]);var je=s.useRef([]),Oe=function(A){U.current&&U.current.contains(A.target)||(A.preventDefault(),je.current=[])};s.useEffect(function(){return p&&(document.addEventListener("dragover",Is,!1),document.addEventListener("drop",Oe,!1)),function(){p&&(document.removeEventListener("dragover",Is),document.removeEventListener("drop",Oe))}},[U,p]),s.useEffect(function(){return!o&&C&&U.current&&U.current.focus(),function(){}},[U,C,o]);var pe=s.useCallback(function(u){B?B(u):console.error(u)},[B]),Se=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u),je.current=[].concat(Io(je.current),[u.target]),sr(u)&&Promise.resolve(n(u)).then(function(A){if(!(cr(u)&&!I)){var oe=A.length,re=oe>0&&fo({files:A,accept:Z,minSize:i,maxSize:l,multiple:m,maxFiles:g,validator:W}),M=oe>0&&!re;ie({isDragAccept:re,isDragReject:M,isDragActive:!0,type:"setDraggedFiles"}),x&&x(u)}}).catch(function(A){return pe(A)})},[n,x,pe,I,Z,i,l,m,g,W]),we=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u);var A=sr(u);if(A&&u.dataTransfer)try{u.dataTransfer.dropEffect="copy"}catch{}return A&&S&&S(u),!1},[S,I]),Ie=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u);var A=je.current.filter(function(re){return U.current&&U.current.contains(re)}),oe=A.indexOf(u.target);oe!==-1&&A.splice(oe,1),je.current=A,!(A.length>0)&&(ie({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),sr(u)&&b&&b(u))},[U,b,I]),xe=s.useCallback(function(u,A){var oe=[],re=[];u.forEach(function(M){var De=Qs(M,Z),qe=Lr(De,2),Te=qe[0],K=qe[1],ue=Zs(M,i,l),te=Lr(ue,2),ce=te[0],ve=te[1],Ae=W?W(M):null;if(Te&&ce&&!Ae)oe.push(M);else{var fe=[K,ve];Ae&&(fe=fe.concat(Ae)),re.push({file:M,errors:fe.filter(function(He){return He})})}}),(!m&&oe.length>1||m&&g>=1&&oe.length>g)&&(oe.forEach(function(M){re.push({file:M,errors:[go]})}),oe.splice(0)),ie({acceptedFiles:oe,fileRejections:re,isDragReject:re.length>0,type:"setFiles"}),v&&v(oe,re,A),re.length>0&&h&&h(re,A),oe.length>0&&y&&y(oe,A)},[ie,m,Z,i,l,g,v,y,h,W]),Ce=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u),je.current=[],sr(u)&&Promise.resolve(n(u)).then(function(A){cr(u)&&!I||xe(A,u)}).catch(function(A){return pe(A)}),ie({type:"reset"})},[n,xe,pe,I]),Re=s.useCallback(function(){if(Ne.current){ie({type:"openDialog"}),X();var u={multiple:m,types:le};window.showOpenFilePicker(u).then(function(A){return n(A)}).then(function(A){xe(A,null),ie({type:"closeDialog"})}).catch(function(A){No(A)?(ne(A),ie({type:"closeDialog"})):So(A)?(Ne.current=!1,L.current?(L.current.value=null,L.current.click()):pe(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."))):pe(A)});return}L.current&&(ie({type:"openDialog"}),X(),L.current.value=null,L.current.click())},[ie,X,ne,D,xe,pe,le,m]),Ee=s.useCallback(function(u){!U.current||!U.current.isEqualNode(u.target)||(u.key===" "||u.key==="Enter"||u.keyCode===32||u.keyCode===13)&&(u.preventDefault(),Re())},[U,Re]),Be=s.useCallback(function(){ie({type:"focus"})},[]),P=s.useCallback(function(){ie({type:"blur"})},[]),O=s.useCallback(function(){d||(vo()?setTimeout(Re,0):Re())},[d,Re]),F=function(A){return o?null:A},f=function(A){return j?null:F(A)},H=function(A){return w?null:F(A)},de=function(A){I&&A.stopPropagation()},Me=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,oe=A===void 0?"ref":A,re=u.role,M=u.onKeyDown,De=u.onFocus,qe=u.onBlur,Te=u.onClick,K=u.onDragEnter,ue=u.onDragOver,te=u.onDragLeave,ce=u.onDrop,ve=dr(u,Mo);return _e(_e(Wr({onKeyDown:f(nt(M,Ee)),onFocus:f(nt(De,Be)),onBlur:f(nt(qe,P)),onClick:F(nt(Te,O)),onDragEnter:H(nt(K,Se)),onDragOver:H(nt(ue,we)),onDragLeave:H(nt(te,Ie)),onDrop:H(nt(ce,Ce)),role:typeof re=="string"&&re!==""?re:"presentation"},oe,U),!o&&!j?{tabIndex:0}:{}),ve)}},[U,Ee,Be,P,O,Se,we,Ie,Ce,j,w,o]),$e=s.useCallback(function(u){u.stopPropagation()},[]),Ke=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,oe=A===void 0?"ref":A,re=u.onChange,M=u.onClick,De=dr(u,Lo),qe=Wr({accept:Z,multiple:m,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:F(nt(re,Ce)),onClick:F(nt(M,$e)),tabIndex:-1},oe,L);return _e(_e({},qe),De)}},[L,a,m,Ce,o]);return _e(_e({},he),{},{isFocused:Y&&!o,getRootProps:Me,getInputProps:Ke,rootRef:U,inputRef:L,open:F(Re)})}function Oo(t,r){switch(r.type){case"focus":return _e(_e({},t),{},{isFocused:!0});case"blur":return _e(_e({},t),{},{isFocused:!1});case"openDialog":return _e(_e({},Br),{},{isFileDialogActive:!0});case"closeDialog":return _e(_e({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return _e(_e({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return _e(_e({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return _e({},Br);default:return t}}function Ts(){}const Ir=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const a=l=>{switch(l){case"completed":return e.jsx(Za,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Pr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Qa,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},o=l=>{switch(l){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"}},n=l=>{switch(l){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((l,i)=>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:a(l.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 ${l.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:l.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Xe,{variant:"outline",className:`text-xs px-2 py-0.5 ${n(l.priority)}`,children:l.priority}),e.jsx(Xe,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(l.status)}`,children:l.status.replace("_"," ")})]})]})})]},l.id||`todo-${i}`))]})};function _o({status:t,onAbort:r,isLoading:a,provider:o="claude"}){const[n,l]=s.useState(0),[i,m]=s.useState(0),[g,x]=s.useState(0);if(s.useEffect(()=>{if(!a){l(0),x(0);return}const D=Date.now(),C=30+Math.random()*20,p=setInterval(()=>{const d=Math.floor((Date.now()-D)/1e3);l(d),x(Math.floor(d*C))},1e3);return()=>clearInterval(p)},[a]),s.useEffect(()=>{if(!a)return;const D=setInterval(()=>{m(C=>(C+1)%4)},500);return()=>clearInterval(D)},[a]),!a)return null;const b=["思考中","处理中","分析中","工作中","计算中","推理中"],S=Math.floor(n/3)%b.length,v=t?.text||b[S],y=t?.tokens||g,h=t?.can_interrupt!==!1,$=["✻","✹","✸","✶"][i];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:We("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:$}),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:[v,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),y>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:["⚒ ",y.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 停止"})]})})]})}),h&&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:"停止"})]})]})})}async function Fo(t,r){const a=new FormData,o=`recording_${Date.now()}.webm`,n=new File([t],o,{type:t.type});a.append("audio",n);const l=window.localStorage.getItem("whisperMode")||"default";a.append("mode",l);try{const i=await be.transcribe(a);if(!i.ok){const g=await i.json().catch(()=>({}));throw new Error(g.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Wo({onTranscript:t,className:r=""}){const[a,o]=s.useState("idle"),[n,l]=s.useState(null),[i,m]=s.useState(!0),g=s.useRef(null),x=s.useRef(null),b=s.useRef([]),S=s.useRef(0);s.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){m(!1),l("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){m(!1),l("Microphone requires HTTPS. Please use a secure connection.");return}m(!0),l(null)})()},[]);const v=async()=>{try{if(console.log("Starting recording..."),l(null),b.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});x.current=p;const d=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",j=new MediaRecorder(p,{mimeType:d});g.current=j,j.ondataavailable=w=>{w.data.size>0&&b.current.push(w.data)},j.onstop=async()=>{console.log("Recording stopped, creating blob...");const w=new Blob(b.current,{type:d});x.current&&(x.current.getTracks().forEach(Z=>Z.stop()),x.current=null),o("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",B=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let W;B&&(W=setTimeout(()=>{o("processing")},2e3));try{const Z=await Fo(w);Z&&t&&t(Z)}catch(Z){console.error("Transcription error:",Z),l(Z.message)}finally{W&&clearTimeout(W),o("idle")}},j.start(),o("recording"),console.log("Recording started successfully")}catch(p){console.error("Failed to start recording:",p);let d="Microphone access failed";p.name==="NotAllowedError"?d="Microphone access denied. Please allow microphone permissions.":p.name==="NotFoundError"?d="No microphone found. Please check your audio devices.":p.name==="NotSupportedError"?d="Microphone not supported by this browser.":p.name==="NotReadableError"?d="Microphone is being used by another application.":p.message.includes("HTTPS")&&(d=p.message),l(d),o("idle")}},y=()=>{console.log("Stopping recording..."),g.current&&g.current.state==="recording"?g.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),x.current&&(x.current.getTracks().forEach(p=>p.stop()),x.current=null),o("idle"))},h=p=>{if(p&&(p.preventDefault(),p.stopPropagation()),!i)return;const d=Date.now();if(d-S.current<300){console.log("Ignoring rapid tap");return}S.current=d,console.log("Button clicked, current state:",a),a==="idle"?v():a==="recording"&&y()};s.useEffect(()=>()=>{x.current&&x.current.getTracks().forEach(p=>p.stop())},[]);const z=()=>{if(!i)return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(nr,{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(ft,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Os,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:$,className:D,disabled:C}=z();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:a==="recording"?"#ef4444":a==="transcribing"?"#3b82f6":a==="processing"?"#a855f7":"#374151"},className:`
5
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ta(t,r){if(t){if(typeof t=="string")return Fr(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Fr(t,r)}}function Fr(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function zo(t,r){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,m;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(r&&o.length===r));n=!0);}catch(g){l=!0,m=g}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw m}}return o}}function $o(t){if(Array.isArray(t))return t}function Ds(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function _e(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Ds(Object(a),!0).forEach(function(o){Wr(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ds(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Wr(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function dr(t,r){if(t==null)return{};var a=Ao(t,r),o,n;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(n=0;n<l.length;n++)o=l[n],!(r.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function Ao(t,r){if(t==null)return{};var a={},o=Object.keys(t),n,l;for(l=0;l<o.length;l++)n=o[l],!(r.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Gr=s.forwardRef(function(t,r){var a=t.children,o=dr(t,Co),n=Vr(o),l=n.open,i=dr(n,Eo);return s.useImperativeHandle(r,function(){return{open:l}},[l]),et.createElement(s.Fragment,null,a(_e(_e({},i),{},{open:l})))});Gr.displayName="Dropzone";var ra={disabled:!1,getFilesFromEvent:Jn,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};Gr.defaultProps=ra;Gr.propTypes={children:ze.func,accept:ze.objectOf(ze.arrayOf(ze.string)),multiple:ze.bool,preventDropOnDocument:ze.bool,noClick:ze.bool,noKeyboard:ze.bool,noDrag:ze.bool,noDragEventsBubbling:ze.bool,minSize:ze.number,maxSize:ze.number,maxFiles:ze.number,disabled:ze.bool,getFilesFromEvent:ze.func,onFileDialogCancel:ze.func,onFileDialogOpen:ze.func,useFsAccessApi:ze.bool,autoFocus:ze.bool,onDragEnter:ze.func,onDragLeave:ze.func,onDragOver:ze.func,onDrop:ze.func,onDropAccepted:ze.func,onDropRejected:ze.func,onError:ze.func,validator:ze.func};var Br={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Vr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=_e(_e({},ra),t),a=r.accept,o=r.disabled,n=r.getFilesFromEvent,l=r.maxSize,i=r.minSize,m=r.multiple,g=r.maxFiles,x=r.onDragEnter,b=r.onDragLeave,S=r.onDragOver,v=r.onDrop,y=r.onDropAccepted,h=r.onDropRejected,z=r.onFileDialogCancel,$=r.onFileDialogOpen,D=r.useFsAccessApi,C=r.autoFocus,p=r.preventDropOnDocument,d=r.noClick,j=r.noKeyboard,w=r.noDrag,L=r.noDragEventsBubbling,B=r.onError,W=r.validator,Z=s.useMemo(function(){return ko(a)},[a]),le=s.useMemo(function(){return wo(a)},[a]),X=s.useMemo(function(){return typeof $=="function"?$:Ts},[$]),ne=s.useMemo(function(){return typeof z=="function"?z:Ts},[z]),U=s.useRef(null),I=s.useRef(null),_=s.useReducer(Oo,Br),Q=Lr(_,2),he=Q[0],ie=Q[1],Y=he.isFocused,ge=he.isFileDialogActive,Ne=s.useRef(typeof window<"u"&&window.isSecureContext&&D&&jo()),Le=function(){!Ne.current&&ge&&setTimeout(function(){if(I.current){var A=I.current.files;A.length||(ie({type:"closeDialog"}),ne())}},300)};s.useEffect(function(){return window.addEventListener("focus",Le,!1),function(){window.removeEventListener("focus",Le,!1)}},[I,ge,ne,Ne]);var je=s.useRef([]),Oe=function(A){U.current&&U.current.contains(A.target)||(A.preventDefault(),je.current=[])};s.useEffect(function(){return p&&(document.addEventListener("dragover",Is,!1),document.addEventListener("drop",Oe,!1)),function(){p&&(document.removeEventListener("dragover",Is),document.removeEventListener("drop",Oe))}},[U,p]),s.useEffect(function(){return!o&&C&&U.current&&U.current.focus(),function(){}},[U,C,o]);var pe=s.useCallback(function(u){B?B(u):console.error(u)},[B]),Se=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u),je.current=[].concat(Io(je.current),[u.target]),sr(u)&&Promise.resolve(n(u)).then(function(A){if(!(cr(u)&&!L)){var oe=A.length,se=oe>0&&fo({files:A,accept:Z,minSize:i,maxSize:l,multiple:m,maxFiles:g,validator:W}),M=oe>0&&!se;ie({isDragAccept:se,isDragReject:M,isDragActive:!0,type:"setDraggedFiles"}),x&&x(u)}}).catch(function(A){return pe(A)})},[n,x,pe,L,Z,i,l,m,g,W]),we=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u);var A=sr(u);if(A&&u.dataTransfer)try{u.dataTransfer.dropEffect="copy"}catch{}return A&&S&&S(u),!1},[S,L]),Ie=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u);var A=je.current.filter(function(se){return U.current&&U.current.contains(se)}),oe=A.indexOf(u.target);oe!==-1&&A.splice(oe,1),je.current=A,!(A.length>0)&&(ie({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),sr(u)&&b&&b(u))},[U,b,L]),xe=s.useCallback(function(u,A){var oe=[],se=[];u.forEach(function(M){var De=Qs(M,Z),qe=Lr(De,2),Te=qe[0],K=qe[1],ue=Zs(M,i,l),te=Lr(ue,2),ce=te[0],ve=te[1],Ae=W?W(M):null;if(Te&&ce&&!Ae)oe.push(M);else{var fe=[K,ve];Ae&&(fe=fe.concat(Ae)),se.push({file:M,errors:fe.filter(function(He){return He})})}}),(!m&&oe.length>1||m&&g>=1&&oe.length>g)&&(oe.forEach(function(M){se.push({file:M,errors:[go]})}),oe.splice(0)),ie({acceptedFiles:oe,fileRejections:se,isDragReject:se.length>0,type:"setFiles"}),v&&v(oe,se,A),se.length>0&&h&&h(se,A),oe.length>0&&y&&y(oe,A)},[ie,m,Z,i,l,g,v,y,h,W]),Ce=s.useCallback(function(u){u.preventDefault(),u.persist(),de(u),je.current=[],sr(u)&&Promise.resolve(n(u)).then(function(A){cr(u)&&!L||xe(A,u)}).catch(function(A){return pe(A)}),ie({type:"reset"})},[n,xe,pe,L]),Re=s.useCallback(function(){if(Ne.current){ie({type:"openDialog"}),X();var u={multiple:m,types:le};window.showOpenFilePicker(u).then(function(A){return n(A)}).then(function(A){xe(A,null),ie({type:"closeDialog"})}).catch(function(A){No(A)?(ne(A),ie({type:"closeDialog"})):So(A)?(Ne.current=!1,I.current?(I.current.value=null,I.current.click()):pe(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."))):pe(A)});return}I.current&&(ie({type:"openDialog"}),X(),I.current.value=null,I.current.click())},[ie,X,ne,D,xe,pe,le,m]),Ee=s.useCallback(function(u){!U.current||!U.current.isEqualNode(u.target)||(u.key===" "||u.key==="Enter"||u.keyCode===32||u.keyCode===13)&&(u.preventDefault(),Re())},[U,Re]),Be=s.useCallback(function(){ie({type:"focus"})},[]),P=s.useCallback(function(){ie({type:"blur"})},[]),O=s.useCallback(function(){d||(vo()?setTimeout(Re,0):Re())},[d,Re]),F=function(A){return o?null:A},f=function(A){return j?null:F(A)},H=function(A){return w?null:F(A)},de=function(A){L&&A.stopPropagation()},Me=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,oe=A===void 0?"ref":A,se=u.role,M=u.onKeyDown,De=u.onFocus,qe=u.onBlur,Te=u.onClick,K=u.onDragEnter,ue=u.onDragOver,te=u.onDragLeave,ce=u.onDrop,ve=dr(u,Mo);return _e(_e(Wr({onKeyDown:f(nt(M,Ee)),onFocus:f(nt(De,Be)),onBlur:f(nt(qe,P)),onClick:F(nt(Te,O)),onDragEnter:H(nt(K,Se)),onDragOver:H(nt(ue,we)),onDragLeave:H(nt(te,Ie)),onDrop:H(nt(ce,Ce)),role:typeof se=="string"&&se!==""?se:"presentation"},oe,U),!o&&!j?{tabIndex:0}:{}),ve)}},[U,Ee,Be,P,O,Se,we,Ie,Ce,j,w,o]),$e=s.useCallback(function(u){u.stopPropagation()},[]),Ke=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,oe=A===void 0?"ref":A,se=u.onChange,M=u.onClick,De=dr(u,Lo),qe=Wr({accept:Z,multiple:m,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:F(nt(se,Ce)),onClick:F(nt(M,$e)),tabIndex:-1},oe,I);return _e(_e({},qe),De)}},[I,a,m,Ce,o]);return _e(_e({},he),{},{isFocused:Y&&!o,getRootProps:Me,getInputProps:Ke,rootRef:U,inputRef:I,open:F(Re)})}function Oo(t,r){switch(r.type){case"focus":return _e(_e({},t),{},{isFocused:!0});case"blur":return _e(_e({},t),{},{isFocused:!1});case"openDialog":return _e(_e({},Br),{},{isFileDialogActive:!0});case"closeDialog":return _e(_e({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return _e(_e({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return _e(_e({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return _e({},Br);default:return t}}function Ts(){}const Ir=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const a=l=>{switch(l){case"completed":return e.jsx(Za,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Pr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Qa,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},o=l=>{switch(l){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"}},n=l=>{switch(l){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((l,i)=>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:a(l.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 ${l.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:l.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Xe,{variant:"outline",className:`text-xs px-2 py-0.5 ${n(l.priority)}`,children:l.priority}),e.jsx(Xe,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(l.status)}`,children:l.status.replace("_"," ")})]})]})})]},l.id||`todo-${i}`))]})};function _o({status:t,onAbort:r,isLoading:a,provider:o="claude"}){const[n,l]=s.useState(0),[i,m]=s.useState(0),[g,x]=s.useState(0);if(s.useEffect(()=>{if(!a){l(0),x(0);return}const D=Date.now(),C=30+Math.random()*20,p=setInterval(()=>{const d=Math.floor((Date.now()-D)/1e3);l(d),x(Math.floor(d*C))},1e3);return()=>clearInterval(p)},[a]),s.useEffect(()=>{if(!a)return;const D=setInterval(()=>{m(C=>(C+1)%4)},500);return()=>clearInterval(D)},[a]),!a)return null;const b=["思考中","处理中","分析中","工作中","计算中","推理中"],S=Math.floor(n/3)%b.length,v=t?.text||b[S],y=t?.tokens||g,h=t?.can_interrupt!==!1,$=["✻","✹","✸","✶"][i];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:We("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:$}),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:[v,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),y>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:["⚒ ",y.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 停止"})]})})]})}),h&&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:"停止"})]})]})})}async function Fo(t,r){const a=new FormData,o=`recording_${Date.now()}.webm`,n=new File([t],o,{type:t.type});a.append("audio",n);const l=window.localStorage.getItem("whisperMode")||"default";a.append("mode",l);try{const i=await be.transcribe(a);if(!i.ok){const g=await i.json().catch(()=>({}));throw new Error(g.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Wo({onTranscript:t,className:r=""}){const[a,o]=s.useState("idle"),[n,l]=s.useState(null),[i,m]=s.useState(!0),g=s.useRef(null),x=s.useRef(null),b=s.useRef([]),S=s.useRef(0);s.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){m(!1),l("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){m(!1),l("Microphone requires HTTPS. Please use a secure connection.");return}m(!0),l(null)})()},[]);const v=async()=>{try{if(console.log("Starting recording..."),l(null),b.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});x.current=p;const d=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",j=new MediaRecorder(p,{mimeType:d});g.current=j,j.ondataavailable=w=>{w.data.size>0&&b.current.push(w.data)},j.onstop=async()=>{console.log("Recording stopped, creating blob...");const w=new Blob(b.current,{type:d});x.current&&(x.current.getTracks().forEach(Z=>Z.stop()),x.current=null),o("transcribing");const L=window.localStorage.getItem("whisperMode")||"default",B=L==="prompt"||L==="vibe"||L==="instructions"||L==="architect";let W;B&&(W=setTimeout(()=>{o("processing")},2e3));try{const Z=await Fo(w);Z&&t&&t(Z)}catch(Z){console.error("Transcription error:",Z),l(Z.message)}finally{W&&clearTimeout(W),o("idle")}},j.start(),o("recording"),console.log("Recording started successfully")}catch(p){console.error("Failed to start recording:",p);let d="Microphone access failed";p.name==="NotAllowedError"?d="Microphone access denied. Please allow microphone permissions.":p.name==="NotFoundError"?d="No microphone found. Please check your audio devices.":p.name==="NotSupportedError"?d="Microphone not supported by this browser.":p.name==="NotReadableError"?d="Microphone is being used by another application.":p.message.includes("HTTPS")&&(d=p.message),l(d),o("idle")}},y=()=>{console.log("Stopping recording..."),g.current&&g.current.state==="recording"?g.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),x.current&&(x.current.getTracks().forEach(p=>p.stop()),x.current=null),o("idle"))},h=p=>{if(p&&(p.preventDefault(),p.stopPropagation()),!i)return;const d=Date.now();if(d-S.current<300){console.log("Ignoring rapid tap");return}S.current=d,console.log("Button clicked, current state:",a),a==="idle"?v():a==="recording"&&y()};s.useEffect(()=>()=>{x.current&&x.current.getTracks().forEach(p=>p.stop())},[]);const z=()=>{if(!i)return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(nr,{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(ft,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Os,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:$,className:D,disabled:C}=z();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:a==="recording"?"#ef4444":a==="transcribing"?"#3b82f6":a==="processing"?"#a855f7":"#374151"},className:`
6
6
  flex items-center justify-center
7
7
  w-12 h-12 rounded-full
8
8
  text-white transition-all duration-200
@@ -50,12 +50,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
50
50
  }
51
51
  }
52
52
  `})]})},Ps={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"}],DEFAULT:"sonnet"};function Mt(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function Uo(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function ar(t){if(!t||typeof t!="string")return t;const r=[],a="__MATH_BLOCK_",o="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,l=>{const i=r.length;return r.push(l),`${a}${i}${o}`});return n=n.replace(/\\n/g,`
53
- `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${a}(\\d+)${o}`,"g"),(l,i)=>r[parseInt(i)]),n}const Lt=({children:t,className:r})=>{const a=Uo(String(t??"")),o=s.useMemo(()=>[jn,wn],[]),n=s.useMemo(()=>[kn],[]);return e.jsx("div",{className:r,children:e.jsx(Nn,{remarkPlugins:o,rehypePlugins:n,components:Jo,children:a})})};function Ur(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,a)=>{let o=parseInt(a,10);if(!Number.isFinite(o))return r;o<1e12&&(o*=1e3);const n=new Date(o),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),m=i>=0?"+":"-",g=Math.abs(i),x=Math.floor(g/60),b=g%60,S=`GMT${m}${x}${b?":"+String(b).padStart(2,"0"):""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,C=>C.toUpperCase()),z=h?`${S} (${h})`:S,$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],D=`${n.getDate()} ${$[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${l} ${z}** - ${D}`})}catch{return t}}const Ye={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const a=JSON.parse(r);if(Array.isArray(a)&&a.length>50){console.warn(`Truncating chat history for ${t} from ${a.length} to 50 messages`);const o=a.slice(-50);r=JSON.stringify(o)}}catch(a){console.warn("Could not parse chat messages for truncation:",a)}localStorage.setItem(t,r)}catch(a){if(a.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const o=Object.keys(localStorage),n=o.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const m=JSON.parse(r);if(Array.isArray(m)&&m.length>10){const g=m.slice(-10);localStorage.setItem(t,JSON.stringify(g)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(m){console.error("Final save attempt failed:",m)}}}else console.error("localStorage error:",a)}},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)}}},sa="claude-settings";function Yr(){const t=Ye.getItem(sa);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 Hr(t,r){if(!t)return null;if(t!=="Bash")return t;const a=Pn(r),o=typeof a?.command=="string"?a.command.trim():"";if(!o)return t;const n=o.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function Rs(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ho(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const a=t?.toolName,o=Hr(a,t.toolInput);if(!o)return null;const l=Yr().allowedTools.includes(o);return{toolName:a,entry:o,isAllowed:l}}function qo(t){if(!t)return{success:!1};const r=Yr(),a=r.allowedTools.includes(t),o=a?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),l={...r,allowedTools:o,disallowedTools:n,lastUpdated:new Date().toISOString()};return Ye.setItem(sa,JSON.stringify(l)),{success:!0,alreadyAllowed:a,updatedSettings:l}}const Jo={code:({node:t,inline:r,className:a,children:o,...n})=>{const[l,i]=et.useState(!1),m=Array.isArray(o)?o.join(""):String(o??""),g=/[\r\n]/.test(m);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 ${a||""}`,...n,children:o});const S=/language-(\w+)/.exec(a||""),v=S?S[1]:"text",y=m,h=()=>{const z=()=>{i(!0),setTimeout(()=>i(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(y).then(z).catch(()=>{const $=document.createElement("textarea");$.value=y,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy")}catch{}document.body.removeChild($),z()});else{const $=document.createElement("textarea");$.value=y,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy")}catch{}document.body.removeChild($),z()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[v&&v!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:v}),e.jsx("button",{type:"button",onClick:h,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:l?"已复制":"复制代码","aria-label":l?"已复制":"复制代码",children:l?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(Sn,{language:v,style:On,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:v&&v!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:m})]})},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})};function Ko({request:t,onSubmit:r,onSkip:a}){const o=t.input?.questions||[],[n,l]=et.useState(()=>Object.fromEntries(o.map(x=>[x.question,[]]))),i=(x,b,S)=>{l(v=>{const y=v[x]||[];return S?{...v,[x]:y.includes(b)?y.filter(h=>h!==b):[...y,b]}:{...v,[x]:[b]}})},m=o.every(x=>(n[x.question]||[]).length>0),g=()=>{const x={};o.forEach(b=>{x[b.question]=(n[b.question]||[]).join(", ")}),r(x)};return e.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 p-3 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3",children:"Claude 需要您的回答"}),o.map((x,b)=>e.jsxs("div",{className:b<o.length-1?"mb-4":"mb-0",children:[e.jsxs("div",{className:"text-sm font-medium text-blue-800 dark:text-blue-200 mb-2",children:[x.question,x.multiSelect&&e.jsx("span",{className:"ml-2 text-xs font-normal opacity-60",children:"(可多选)"})]}),e.jsx("div",{className:"space-y-1",children:x.options.map((S,v)=>{const y=(n[x.question]||[]).includes(S.label);return e.jsxs("button",{type:"button",onClick:()=>i(x.question,S.label,x.multiSelect),className:`w-full text-left px-3 py-2 rounded-md text-xs border transition-colors ${y?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-800 border-blue-200 dark:border-blue-700 text-blue-800 dark:text-blue-200 hover:bg-blue-50 dark:hover:bg-blue-900/30"}`,children:[e.jsx("span",{className:"font-medium",children:S.label}),S.description&&e.jsxs("span",{className:"ml-1 opacity-70",children:[" — ",S.description]})]},v)})})]},b)),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:g,disabled:!m,className:"inline-flex items-center gap-2 rounded-md bg-blue-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"提交答案"}),e.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/30 transition-colors",children:"跳过"})]})]})}const Go=s.memo(({message:t,index:r,prevMessage:a,createDiff:o,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,autoExpandTools:m,showRawParameters:g,showThinking:x,selectedProject:b,provider:S})=>{const v=a&&a.type===t.type&&(a.type==="assistant"||a.type==="user"||a.type==="tool"||a.type==="error"),y=et.useRef(null),[h,z]=et.useState(!1),$=Ho(t,S),[D,C]=et.useState("idle");return et.useEffect(()=>{C("idle")},[$?.entry,t.toolId]),et.useEffect(()=>{if(!m||!y.current||!t.isToolUse)return;const p=new IntersectionObserver(d=>{d.forEach(j=>{j.isIntersecting&&!h&&(z(!0),y.current.querySelectorAll("details").forEach(I=>{I.open=!0}))})},{threshold:.1});return p.observe(y.current),()=>{y.current&&p.unobserve(y.current)}},[m,h,t.isToolUse]),e.jsx("div",{ref:y,className:`chat-message ${t.type} ${v?"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,d)=>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")},d))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:new Date(t.timestamp).toLocaleTimeString()})]}),!v&&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:[!v&&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(ot,{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 d=JSON.parse(t.toolInput);return e.jsxs("span",{className:"font-mono truncate flex-1 min-w-0",children:[d.pattern&&e.jsxs("span",{children:["pattern: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:d.pattern})]}),d.path&&e.jsxs("span",{className:"ml-2",children:["in: ",d.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})]})]}),l&&e.jsx("button",{onClick:d=>{d.stopPropagation(),l()},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 d=JSON.parse(t.toolInput);if(d.file_path&&d.old_string&&d.new_string)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,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 j=>{if(j.preventDefault(),j.stopPropagation(),!!n)try{const w=await be.readFile(b?.name,d.file_path),I=await w.json();if(!w.ok||I.error){console.error("Failed to fetch file:",I.error),n(d.file_path);return}const B=I.content||"",W=B.replace(d.new_string,d.old_string);n(d.file_path,{old_string:W,new_string:B})}catch(w){console.error("Error preparing diff:",w),n(d.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:d.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(n)try{const j=await be.readFile(b?.name,d.file_path),w=await j.json();if(!j.ok||w.error){console.error("Failed to fetch file:",w.error),n(d.file_path);return}const I=w.content||"",B=I.replace(d.new_string,d.old_string);n(d.file_path,{old_string:B,new_string:I})}catch(j){console.error("Error preparing diff:",j),n(d.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:d.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:o(d.old_string,d.new_string).map((j,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${j.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:j.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${j.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:j.content})]},w))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,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:m,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 d;if(typeof t.toolInput=="string"?d=JSON.parse(t.toolInput):d=t.toolInput,d.file_path&&d.content!==void 0)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,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 j=>{if(j.preventDefault(),j.stopPropagation(),!!n)try{const w=await be.readFile(b?.name,d.file_path),I=await w.json(),B=w.ok&&!I.error?I.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:B})}catch(w){console.error("Error preparing diff:",w),n(d.file_path,{old_string:"",new_string:d.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:d.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(n)try{const j=await be.readFile(b?.name,d.file_path),w=await j.json(),I=j.ok&&!w.error?w.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:I})}catch(j){console.error("Error preparing diff:",j),n(d.file_path,{old_string:"",new_string:d.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:d.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:o("",d.content).map((j,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${j.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:j.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${j.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:j.content})]},w))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,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 d=JSON.parse(t.toolInput);if(d.todos&&Array.isArray(d.todos))return e.jsxs("details",{className:"relative mt-3 group/todo",open:m,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(Ir,{todos:d.todos}),g&&e.jsxs("details",{className:"relative mt-3 group/raw",open:m,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 d=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:d.command})]}),d.description&&e.jsx("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic ml-1",children:d.description})]})}catch{}if(t.toolName==="Read")try{const d=JSON.parse(t.toolInput);if(d.file_path){const j=d.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:()=>n&&n(d.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-mono",children:j})]})}}catch{}if(t.toolName==="exit_plan_mode")try{const d=JSON.parse(t.toolInput);if(d.plan){const j=d.plan.replace(/\\n/g,`
53
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${a}(\\d+)${o}`,"g"),(l,i)=>r[parseInt(i)]),n}const Lt=({children:t,className:r})=>{const a=Uo(String(t??"")),o=s.useMemo(()=>[jn,wn],[]),n=s.useMemo(()=>[kn],[]);return e.jsx("div",{className:r,children:e.jsx(Nn,{remarkPlugins:o,rehypePlugins:n,components:Jo,children:a})})};function Ur(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,a)=>{let o=parseInt(a,10);if(!Number.isFinite(o))return r;o<1e12&&(o*=1e3);const n=new Date(o),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),m=i>=0?"+":"-",g=Math.abs(i),x=Math.floor(g/60),b=g%60,S=`GMT${m}${x}${b?":"+String(b).padStart(2,"0"):""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,C=>C.toUpperCase()),z=h?`${S} (${h})`:S,$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],D=`${n.getDate()} ${$[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${l} ${z}** - ${D}`})}catch{return t}}const Ye={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const a=JSON.parse(r);if(Array.isArray(a)&&a.length>50){console.warn(`Truncating chat history for ${t} from ${a.length} to 50 messages`);const o=a.slice(-50);r=JSON.stringify(o)}}catch(a){console.warn("Could not parse chat messages for truncation:",a)}localStorage.setItem(t,r)}catch(a){if(a.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const o=Object.keys(localStorage),n=o.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const m=JSON.parse(r);if(Array.isArray(m)&&m.length>10){const g=m.slice(-10);localStorage.setItem(t,JSON.stringify(g)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(m){console.error("Final save attempt failed:",m)}}}else console.error("localStorage error:",a)}},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)}}},sa="claude-settings";function Yr(){const t=Ye.getItem(sa);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 Hr(t,r){if(!t)return null;if(t!=="Bash")return t;const a=Pn(r),o=typeof a?.command=="string"?a.command.trim():"";if(!o)return t;const n=o.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function Rs(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ho(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const a=t?.toolName,o=Hr(a,t.toolInput);if(!o)return null;const l=Yr().allowedTools.includes(o);return{toolName:a,entry:o,isAllowed:l}}function qo(t){if(!t)return{success:!1};const r=Yr(),a=r.allowedTools.includes(t),o=a?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),l={...r,allowedTools:o,disallowedTools:n,lastUpdated:new Date().toISOString()};return Ye.setItem(sa,JSON.stringify(l)),{success:!0,alreadyAllowed:a,updatedSettings:l}}const Jo={code:({node:t,inline:r,className:a,children:o,...n})=>{const[l,i]=et.useState(!1),m=Array.isArray(o)?o.join(""):String(o??""),g=/[\r\n]/.test(m);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 ${a||""}`,...n,children:o});const S=/language-(\w+)/.exec(a||""),v=S?S[1]:"text",y=m,h=()=>{const z=()=>{i(!0),setTimeout(()=>i(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(y).then(z).catch(()=>{const $=document.createElement("textarea");$.value=y,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy")}catch{}document.body.removeChild($),z()});else{const $=document.createElement("textarea");$.value=y,$.style.position="fixed",$.style.opacity="0",document.body.appendChild($),$.select();try{document.execCommand("copy")}catch{}document.body.removeChild($),z()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[v&&v!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:v}),e.jsx("button",{type:"button",onClick:h,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:l?"已复制":"复制代码","aria-label":l?"已复制":"复制代码",children:l?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(Sn,{language:v,style:On,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:v&&v!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:m})]})},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})};function Ko({request:t,onSubmit:r,onSkip:a}){const o=t.input?.questions||[],[n,l]=et.useState(()=>Object.fromEntries(o.map(x=>[x.question,[]]))),i=(x,b,S)=>{l(v=>{const y=v[x]||[];return S?{...v,[x]:y.includes(b)?y.filter(h=>h!==b):[...y,b]}:{...v,[x]:[b]}})},m=o.every(x=>(n[x.question]||[]).length>0),g=()=>{const x={};o.forEach(b=>{x[b.question]=(n[b.question]||[]).join(", ")}),r(x)};return e.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 p-3 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3",children:"Claude 需要您的回答"}),o.map((x,b)=>e.jsxs("div",{className:b<o.length-1?"mb-4":"mb-0",children:[e.jsxs("div",{className:"text-sm font-medium text-blue-800 dark:text-blue-200 mb-2",children:[x.question,x.multiSelect&&e.jsx("span",{className:"ml-2 text-xs font-normal opacity-60",children:"(可多选)"})]}),e.jsx("div",{className:"space-y-1",children:x.options.map((S,v)=>{const y=(n[x.question]||[]).includes(S.label);return e.jsxs("button",{type:"button",onClick:()=>i(x.question,S.label,x.multiSelect),className:`w-full text-left px-3 py-2 rounded-md text-xs border transition-colors ${y?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-800 border-blue-200 dark:border-blue-700 text-blue-800 dark:text-blue-200 hover:bg-blue-50 dark:hover:bg-blue-900/30"}`,children:[e.jsx("span",{className:"font-medium",children:S.label}),S.description&&e.jsxs("span",{className:"ml-1 opacity-70",children:[" — ",S.description]})]},v)})})]},b)),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:g,disabled:!m,className:"inline-flex items-center gap-2 rounded-md bg-blue-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"提交答案"}),e.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/30 transition-colors",children:"跳过"})]})]})}const Go=s.memo(({message:t,index:r,prevMessage:a,createDiff:o,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,autoExpandTools:m,showRawParameters:g,showThinking:x,selectedProject:b,provider:S})=>{const v=a&&a.type===t.type&&(a.type==="assistant"||a.type==="user"||a.type==="tool"||a.type==="error"),y=et.useRef(null),[h,z]=et.useState(!1),$=Ho(t,S),[D,C]=et.useState("idle");return et.useEffect(()=>{C("idle")},[$?.entry,t.toolId]),et.useEffect(()=>{if(!m||!y.current||!t.isToolUse)return;const p=new IntersectionObserver(d=>{d.forEach(j=>{j.isIntersecting&&!h&&(z(!0),y.current.querySelectorAll("details").forEach(L=>{L.open=!0}))})},{threshold:.1});return p.observe(y.current),()=>{y.current&&p.unobserve(y.current)}},[m,h,t.isToolUse]),e.jsx("div",{ref:y,className:`chat-message ${t.type} ${v?"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,d)=>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")},d))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:new Date(t.timestamp).toLocaleTimeString()})]}),!v&&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:[!v&&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(ot,{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 d=JSON.parse(t.toolInput);return e.jsxs("span",{className:"font-mono truncate flex-1 min-w-0",children:[d.pattern&&e.jsxs("span",{children:["pattern: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:d.pattern})]}),d.path&&e.jsxs("span",{className:"ml-2",children:["in: ",d.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})]})]}),l&&e.jsx("button",{onClick:d=>{d.stopPropagation(),l()},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 d=JSON.parse(t.toolInput);if(d.file_path&&d.old_string&&d.new_string)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,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 j=>{if(j.preventDefault(),j.stopPropagation(),!!n)try{const w=await be.readFile(b?.name,d.file_path),L=await w.json();if(!w.ok||L.error){console.error("Failed to fetch file:",L.error),n(d.file_path);return}const B=L.content||"",W=B.replace(d.new_string,d.old_string);n(d.file_path,{old_string:W,new_string:B})}catch(w){console.error("Error preparing diff:",w),n(d.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:d.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(n)try{const j=await be.readFile(b?.name,d.file_path),w=await j.json();if(!j.ok||w.error){console.error("Failed to fetch file:",w.error),n(d.file_path);return}const L=w.content||"",B=L.replace(d.new_string,d.old_string);n(d.file_path,{old_string:B,new_string:L})}catch(j){console.error("Error preparing diff:",j),n(d.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:d.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:o(d.old_string,d.new_string).map((j,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${j.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:j.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${j.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:j.content})]},w))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,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:m,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 d;if(typeof t.toolInput=="string"?d=JSON.parse(t.toolInput):d=t.toolInput,d.file_path&&d.content!==void 0)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,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 j=>{if(j.preventDefault(),j.stopPropagation(),!!n)try{const w=await be.readFile(b?.name,d.file_path),L=await w.json(),B=w.ok&&!L.error?L.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:B})}catch(w){console.error("Error preparing diff:",w),n(d.file_path,{old_string:"",new_string:d.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:d.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(n)try{const j=await be.readFile(b?.name,d.file_path),w=await j.json(),L=j.ok&&!w.error?w.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:L})}catch(j){console.error("Error preparing diff:",j),n(d.file_path,{old_string:"",new_string:d.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:d.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:o("",d.content).map((j,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${j.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:j.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${j.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:j.content})]},w))})]}),g&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,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 d=JSON.parse(t.toolInput);if(d.todos&&Array.isArray(d.todos))return e.jsxs("details",{className:"relative mt-3 group/todo",open:m,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(Ir,{todos:d.todos}),g&&e.jsxs("details",{className:"relative mt-3 group/raw",open:m,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 d=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:d.command})]}),d.description&&e.jsx("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic ml-1",children:d.description})]})}catch{}if(t.toolName==="Read")try{const d=JSON.parse(t.toolInput);if(d.file_path){const j=d.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:()=>n&&n(d.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-mono",children:j})]})}}catch{}if(t.toolName==="exit_plan_mode")try{const d=JSON.parse(t.toolInput);if(d.plan){const j=d.plan.replace(/\\n/g,`
54
54
  `);return e.jsxs("details",{className:"mt-2",open:m,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(Lt,{className:"mt-3 prose prose-sm max-w-none dark:prose-invert",children:j})]})}}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:m,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 j=String(t.toolResult.content||"");if((t.toolName==="TodoWrite"||t.toolName==="TodoRead")&&(j.includes("Todos have been modified successfully")||j.includes("Todo list")||j.startsWith("[")&&j.includes('"content"')&&j.includes('"status"')))try{let B=null;if(j.startsWith("["))B=JSON.parse(j);else if(j.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(Ir,{todos:B,isResult:!0})]})}catch{}if(t.toolName==="exit_plan_mode")try{const B=JSON.parse(j);if(B.plan){const W=B.plan.replace(/\\n/g,`
55
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(Lt,{className:"prose prose-sm max-w-none dark:prose-invert",children:W})]})}}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((W,Z)=>{const le=W.split("/").pop(),X=W.substring(0,W.lastIndexOf("/"));return e.jsxs("div",{onClick:()=>{n&&n(W)},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:le}),e.jsx("div",{className:"font-mono text-xs text-green-600/70 dark:text-green-400/70 truncate",children:X})]}),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"})})]},Z)})})]})}if(j.includes("Do you want to proceed?")&&t.toolName==="Bash"){const B=j.split(`
56
56
  `),W=B.findIndex(_=>_.includes("Do you want to proceed?")),Z=B.slice(0,W).join(`
57
- `),le=B.slice(W),X=le.find(_=>_.includes("Do you want to proceed?"))||"",ne=[];le.forEach(_=>{const Q=_.match(/^\s*(\d+)\.\s+(.+)$/);Q&&ne.push({number:Q[1],text:Q[2].trim()})});const U=j.match(/>\s*(\d+)/),L=U?U[1]:null;return e.jsxs("div",{className:"space-y-3",children:[Z&&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:Z})}),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:X}),e.jsx("div",{className:"space-y-2 mb-4",children:ne.map(_=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${L===_.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"} ${L?"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 ${L===_.number?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:_.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:_.text}),L===_.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"})})]})},_.number))}),L&&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 选择了选项 ",L]}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"在 CLI 中,您可以使用方向键或输入数字来交互式地选择此选项。"})]})]})]})})]})}const w=j.match(/The file (.+?) has been updated\./);if(w)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:()=>{n&&n(w[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:w[1]})]});const I=j.match(/(?:The file|File) (.+?) has been (?:created|written)(?: successfully)?\.?/);return I?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:()=>{n&&n(I[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:I[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:"文件内容显示在上方的差异视图中"})]}):j.includes("cat -n")&&j.includes("→")?e.jsxs("details",{open:m,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:j})})]}):j.length>300?e.jsxs("details",{open:m,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"})}),"查看完整输出 (",j.length," 字符)"]}),e.jsx(Lt,{className:"mt-2 prose prose-sm max-w-none prose-green dark:prose-invert",children:j})]}):e.jsx(Lt,{className:"prose prose-sm max-w-none prose-green dark:prose-invert",children:j})})(),$&&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(!i)return;i($)?.success?C("granted"):C("error")},disabled:$.isAllowed||D==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${$.isAllowed||D==="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:$.isAllowed||D==="granted"?"权限已添加":`授予权限 ${$.toolName}`}),l&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l()},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:$.entry})," 到允许的工具列表。"]}),D==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"无法更新权限。请重试。"}),($.isAllowed||D==="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(w=>w.trim()),d=p.find(w=>w.includes("?"))||p[0]||"",j=[];return p.forEach(w=>{const I=w.match(/[❯\s]*(\d+)\.\s+(.+)/);if(I){const B=w.includes("❯");j.push({number:I[1],text:I[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:d}),e.jsx("div",{className:"space-y-2 mb-4",children:j.map(w=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${w.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 ${w.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:w.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:w.text}),w.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},w.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 d=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:()=>n&&n(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:d})]})})}}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(Ir,{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(Lt,{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:[x&&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=Ur(String(t.content||"")),d=p.trim();if((d.startsWith("{")||d.startsWith("["))&&(d.endsWith("}")||d.endsWith("]")))try{const j=JSON.parse(d),w=JSON.stringify(j,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:w})})})]})}catch{}return t.type==="assistant"?e.jsx(Lt,{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 ${v?"opacity-0 group-hover:opacity-100":""}`,children:new Date(t.timestamp).toLocaleTimeString()})]})]})})}),Vo=({file:t,onRemove:r,uploadProgress:a,error:o})=>{const[n,l]=s.useState(null);return s.useEffect(()=>{const i=URL.createObjectURL(t);return l(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),a!==void 0&&a<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:[a,"%"]})}),o&&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 Yo({selectedProject:t,selectedSession:r,ws:a,sendMessage:o,messages:n,onFileOpen:l,onInputFocusChange:i,onSessionActive:m,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:b,processingSessions:S,onReplaceTemporarySession:v,onNavigateToSession:y,onShowSettings:h,autoExpandTools:z,showRawParameters:$,showThinking:D,autoScrollToBottom:C,sendByCtrlEnter:p,externalMessageUpdate:d,onTaskClick:j,limitStatus:w,onLimitExceeded:I,checkLimitStatus:B}){const[W,Z]=s.useState(()=>typeof window<"u"&&t&&Ye.getItem(`draft_input_${t.name}`)||""),[le,X]=s.useState(()=>{if(typeof window<"u"&&t){const c=Ye.getItem(`chat_messages_${t.name}`);return c?JSON.parse(c):[]}return[]}),[ne,U]=s.useState(!1),[L,_]=s.useState(r?.id||null),[Q,he]=s.useState(!1),[ie,Y]=s.useState([]),[ge,Ne]=s.useState(!1),[Le,je]=s.useState(!1),[Oe,pe]=s.useState(0),[Se,we]=s.useState(!1),[Ie,xe]=s.useState(0),Ce=20,Re=s.useCallback(c=>{ve.current=c,pe(c)},[]),[Ee,Be]=s.useState(!1),[P,O]=s.useState("default"),[F,f]=s.useState([]),[H,de]=s.useState([]),[Me,$e]=s.useState(new Map),[Ke,u]=s.useState(new Map),[A,oe]=s.useState(!1),re=s.useRef(null),M=s.useRef(null),De=s.useRef(null),qe=s.useRef(null),Te=s.useRef(null),K=s.useRef(!1),ue=s.useRef(!1),te=s.useRef(!1),ce=s.useRef(null),ve=s.useRef(0),Ae=s.useRef(""),fe=s.useRef(null),He=s.useRef(null),[ut,tt]=s.useState(""),[Nt,bt]=s.useState(!1),[Gt,hr]=s.useState([]),[at,gr]=s.useState([]),[_t,it]=s.useState(-1),[Ft,St]=s.useState(0),[Vt,Ct]=s.useState(-1),[fr,Ge]=s.useState(!1),[T,G]=s.useState(!1),ae=s.useRef({height:0,top:0}),[ke,Ve]=s.useState(!1),[Fe,br]=s.useState([]),[yt,Yt]=s.useState([]),[Qt,lt]=s.useState(""),[ia,pt]=s.useState(!1),[rs,Et]=s.useState(null),[yr,ct]=s.useState(-1),[ss,xt]=s.useState(-1),[Wt,la]=s.useState(100),[ca,ht]=s.useState(null),[gt,as]=s.useState(()=>localStorage.getItem("claude-model")||Ps.DEFAULT),dt="claude";s.useEffect(()=>{if(r?.id){const c=localStorage.getItem(`permissionMode-${r.id}`);O(c||"default")}},[r?.id]),s.useEffect(()=>{f(c=>c.filter(k=>!k.sessionId||k.sessionId===r?.id))},[r?.id]),s.useEffect(()=>{(async()=>{if(t)try{const k=await se("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!k.ok)throw new Error("Failed to fetch commands");const E=await k.json(),N=[...(E.builtIn||[]).map(me=>({...me,type:"built-in"})),...(E.custom||[]).map(me=>({...me,type:"custom"}))];br(N);const R=`command_history_${t.name}`,V=Ye.getItem(R);if(V)try{const me=JSON.parse(V),q=N.sort((ee,ye)=>{const Pe=me[ee.name]||0;return(me[ye.name]||0)-Pe});br(q)}catch(me){console.error("Error parsing command history:",me)}}catch(k){console.error("Error fetching slash commands:",k),br([])}})()},[t]);const vr=s.useMemo(()=>Fe.length?new Ga(Fe,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Fe]);s.useEffect(()=>{if(!Qt){Yt(Fe);return}if(!vr){Yt([]);return}const c=vr.search(Qt);Yt(c.map(k=>k.item))},[Qt,Fe,vr]);const da=s.useMemo(()=>{if(!t||Fe.length===0)return[];const c=`command_history_${t.name}`,k=Ye.getItem(c);if(!k)return[];try{const E=JSON.parse(k);return Fe.map(R=>({...R,usageCount:E[R.name]||0})).filter(R=>R.usageCount>0).sort((R,V)=>V.usageCount-R.usageCount).slice(0,5)}catch(E){return console.error("Error parsing command history:",E),[]}},[t,Fe]),ma=s.useCallback((c,k,E)=>{if(!c||!t)return;if(E){ct(k);return}const N=`command_history_${t.name}`,R=Ye.getItem(N);let V={};try{V=R?JSON.parse(R):{}}catch(me){console.error("Error parsing command history:",me)}V[c.name]=(V[c.name]||0)+1,Ye.setItem(N,JSON.stringify(V)),Zt(c)},[t]),ua=s.useCallback(c=>{const{action:k,data:E}=c;switch(k){case"help":X(N=>[...N,{type:"assistant",content:E.content,timestamp:Date.now()}]);break;case"model":{const N=E.available.claude,R=E.message?.includes("Switching to model:")?E.message.replace("Switching to model: ","").trim():null;R&&N.includes(R)?(as(R),localStorage.setItem("claude-model",R),X(V=>[...V,{type:"assistant",content:`已切换到模型: **${R}**`,timestamp:Date.now()}])):X(R?V=>[...V,{type:"assistant",content:`无效的模型: ${R}
57
+ `),le=B.slice(W),X=le.find(_=>_.includes("Do you want to proceed?"))||"",ne=[];le.forEach(_=>{const Q=_.match(/^\s*(\d+)\.\s+(.+)$/);Q&&ne.push({number:Q[1],text:Q[2].trim()})});const U=j.match(/>\s*(\d+)/),I=U?U[1]:null;return e.jsxs("div",{className:"space-y-3",children:[Z&&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:Z})}),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:X}),e.jsx("div",{className:"space-y-2 mb-4",children:ne.map(_=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${I===_.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"} ${I?"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 ${I===_.number?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:_.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:_.text}),I===_.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"})})]})},_.number))}),I&&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 选择了选项 ",I]}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"在 CLI 中,您可以使用方向键或输入数字来交互式地选择此选项。"})]})]})]})})]})}const w=j.match(/The file (.+?) has been updated\./);if(w)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:()=>{n&&n(w[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:w[1]})]});const L=j.match(/(?:The file|File) (.+?) has been (?:created|written)(?: successfully)?\.?/);return L?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:()=>{n&&n(L[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:L[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:"文件内容显示在上方的差异视图中"})]}):j.includes("cat -n")&&j.includes("→")?e.jsxs("details",{open:m,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:j})})]}):j.length>300?e.jsxs("details",{open:m,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"})}),"查看完整输出 (",j.length," 字符)"]}),e.jsx(Lt,{className:"mt-2 prose prose-sm max-w-none prose-green dark:prose-invert",children:j})]}):e.jsx(Lt,{className:"prose prose-sm max-w-none prose-green dark:prose-invert",children:j})})(),$&&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(!i)return;i($)?.success?C("granted"):C("error")},disabled:$.isAllowed||D==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${$.isAllowed||D==="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:$.isAllowed||D==="granted"?"权限已添加":`授予权限 ${$.toolName}`}),l&&e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l()},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:$.entry})," 到允许的工具列表。"]}),D==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"无法更新权限。请重试。"}),($.isAllowed||D==="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(w=>w.trim()),d=p.find(w=>w.includes("?"))||p[0]||"",j=[];return p.forEach(w=>{const L=w.match(/[❯\s]*(\d+)\.\s+(.+)/);if(L){const B=w.includes("❯");j.push({number:L[1],text:L[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:d}),e.jsx("div",{className:"space-y-2 mb-4",children:j.map(w=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${w.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 ${w.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:w.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:w.text}),w.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},w.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 d=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:()=>n&&n(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:d})]})})}}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(Ir,{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(Lt,{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:[x&&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=Ur(String(t.content||"")),d=p.trim();if((d.startsWith("{")||d.startsWith("["))&&(d.endsWith("}")||d.endsWith("]")))try{const j=JSON.parse(d),w=JSON.stringify(j,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:w})})})]})}catch{}return t.type==="assistant"?e.jsx(Lt,{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 ${v?"opacity-0 group-hover:opacity-100":""}`,children:new Date(t.timestamp).toLocaleTimeString()})]})]})})}),Vo=({file:t,onRemove:r,uploadProgress:a,error:o})=>{const[n,l]=s.useState(null);return s.useEffect(()=>{const i=URL.createObjectURL(t);return l(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),a!==void 0&&a<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:[a,"%"]})}),o&&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 Yo({selectedProject:t,selectedSession:r,ws:a,sendMessage:o,messages:n,onFileOpen:l,onInputFocusChange:i,onSessionActive:m,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:b,processingSessions:S,onReplaceTemporarySession:v,onNavigateToSession:y,onShowSettings:h,autoExpandTools:z,showRawParameters:$,showThinking:D,autoScrollToBottom:C,sendByCtrlEnter:p,externalMessageUpdate:d,onTaskClick:j,limitStatus:w,onLimitExceeded:L,checkLimitStatus:B}){const[W,Z]=s.useState(()=>typeof window<"u"&&t&&Ye.getItem(`draft_input_${t.name}`)||""),[le,X]=s.useState(()=>{if(typeof window<"u"&&t){const c=Ye.getItem(`chat_messages_${t.name}`);return c?JSON.parse(c):[]}return[]}),[ne,U]=s.useState(!1),[I,_]=s.useState(r?.id||null),[Q,he]=s.useState(!1),[ie,Y]=s.useState([]),[ge,Ne]=s.useState(!1),[Le,je]=s.useState(!1),[Oe,pe]=s.useState(0),[Se,we]=s.useState(!1),[Ie,xe]=s.useState(0),Ce=20,Re=s.useCallback(c=>{ve.current=c,pe(c)},[]),[Ee,Be]=s.useState(!1),[P,O]=s.useState("default"),[F,f]=s.useState([]),[H,de]=s.useState([]),[Me,$e]=s.useState(new Map),[Ke,u]=s.useState(new Map),[A,oe]=s.useState(!1),se=s.useRef(null),M=s.useRef(null),De=s.useRef(null),qe=s.useRef(null),Te=s.useRef(null),K=s.useRef(!1),ue=s.useRef(!1),te=s.useRef(!1),ce=s.useRef(null),ve=s.useRef(0),Ae=s.useRef(""),fe=s.useRef(null),He=s.useRef(null),[ut,tt]=s.useState(""),[Nt,bt]=s.useState(!1),[Gt,hr]=s.useState([]),[at,gr]=s.useState([]),[_t,it]=s.useState(-1),[Ft,St]=s.useState(0),[Vt,Ct]=s.useState(-1),[fr,Ge]=s.useState(!1),[T,G]=s.useState(!1),ae=s.useRef({height:0,top:0}),[ke,Ve]=s.useState(!1),[Fe,br]=s.useState([]),[yt,Yt]=s.useState([]),[Qt,lt]=s.useState(""),[ia,pt]=s.useState(!1),[rs,Et]=s.useState(null),[yr,ct]=s.useState(-1),[ss,xt]=s.useState(-1),[Wt,la]=s.useState(100),[ca,ht]=s.useState(null),[gt,as]=s.useState(()=>localStorage.getItem("claude-model")||Ps.DEFAULT),dt="claude";s.useEffect(()=>{if(r?.id){const c=localStorage.getItem(`permissionMode-${r.id}`);O(c||"default")}},[r?.id]),s.useEffect(()=>{f(c=>c.filter(k=>!k.sessionId||k.sessionId===r?.id))},[r?.id]),s.useEffect(()=>{(async()=>{if(t)try{const k=await re("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!k.ok)throw new Error("Failed to fetch commands");const E=await k.json(),N=[...(E.builtIn||[]).map(me=>({...me,type:"built-in"})),...(E.custom||[]).map(me=>({...me,type:"custom"}))];br(N);const R=`command_history_${t.name}`,V=Ye.getItem(R);if(V)try{const me=JSON.parse(V),q=N.sort((ee,ye)=>{const Pe=me[ee.name]||0;return(me[ye.name]||0)-Pe});br(q)}catch(me){console.error("Error parsing command history:",me)}}catch(k){console.error("Error fetching slash commands:",k),br([])}})()},[t]);const vr=s.useMemo(()=>Fe.length?new Ga(Fe,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Fe]);s.useEffect(()=>{if(!Qt){Yt(Fe);return}if(!vr){Yt([]);return}const c=vr.search(Qt);Yt(c.map(k=>k.item))},[Qt,Fe,vr]);const da=s.useMemo(()=>{if(!t||Fe.length===0)return[];const c=`command_history_${t.name}`,k=Ye.getItem(c);if(!k)return[];try{const E=JSON.parse(k);return Fe.map(R=>({...R,usageCount:E[R.name]||0})).filter(R=>R.usageCount>0).sort((R,V)=>V.usageCount-R.usageCount).slice(0,5)}catch(E){return console.error("Error parsing command history:",E),[]}},[t,Fe]),ma=s.useCallback((c,k,E)=>{if(!c||!t)return;if(E){ct(k);return}const N=`command_history_${t.name}`,R=Ye.getItem(N);let V={};try{V=R?JSON.parse(R):{}}catch(me){console.error("Error parsing command history:",me)}V[c.name]=(V[c.name]||0)+1,Ye.setItem(N,JSON.stringify(V)),Zt(c)},[t]),ua=s.useCallback(c=>{const{action:k,data:E}=c;switch(k){case"help":X(N=>[...N,{type:"assistant",content:E.content,timestamp:Date.now()}]);break;case"model":{const N=E.available.claude,R=E.message?.includes("Switching to model:")?E.message.replace("Switching to model: ","").trim():null;R&&N.includes(R)?(as(R),localStorage.setItem("claude-model",R),X(V=>[...V,{type:"assistant",content:`已切换到模型: **${R}**`,timestamp:Date.now()}])):X(R?V=>[...V,{type:"assistant",content:`无效的模型: ${R}
59
59
 
60
60
  **可用模型**: ${N.join(", ")}`,timestamp:Date.now()}]:V=>[...V,{type:"assistant",content:`**当前模型**: ${gt}
61
61
 
@@ -65,16 +65,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
65
65
 
66
66
  **剩余**: ${E.usage.remaining.toLocaleString()} tokens`:N=E.message||"无可用的 Token 使用数据。",X(R=>[...R,{type:"assistant",content:N,timestamp:Date.now()}]);break}case"memory":E.error?X(N=>[...N,{type:"assistant",content:`⚠️ ${E.message}`,timestamp:Date.now()}]):(X(N=>[...N,{type:"assistant",content:`📝 ${E.message}
67
67
 
68
- Path: \`${E.path}\``,timestamp:Date.now()}]),E.exists&&l&&l(E.path));break;case"config":h&&h();break;default:console.warn("Unknown built-in command action:",k)}},[l,h,gt]),jr=s.useRef(null),pa=s.useCallback(async(c,k)=>{const{content:E,hasBashCommands:N,hasFileIncludes:R}=c;if(N&&!window.confirm("此命令包含将被执行的 bash 命令。是否继续?")){X(me=>[...me,{type:"assistant",content:"❌ 命令执行已取消",timestamp:Date.now()}]);return}Z(E),setTimeout(()=>{if(jr.current){const V={preventDefault:()=>{}};jr.current(V)}},50)},[]),Zt=s.useCallback(async c=>{if(!(!c||!t))try{const k=W.match(new RegExp(`${c.name}\\s*(.*)`)),E=k&&k[1]?k[1].trim().split(/\s+/):[],N={projectPath:t.path,projectName:t.name,sessionId:L,provider:dt,model:gt,tokenUsage:rs},R=await se("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:c.name,commandPath:c.path,args:E,context:N})});if(!R.ok)throw new Error("Failed to execute command");const V=await R.json();V.type==="builtin"?ua(V):V.type==="custom"&&await pa(V,E),Z(""),Ve(!1),xt(-1),lt(""),ct(-1)}catch(k){console.error("Error executing command:",k),X(E=>[...E,{type:"assistant",content:`Error executing command: ${k.message}`,timestamp:Date.now()}])}},[W,t,L,dt,gt,rs]),xa=s.useMemo(()=>{const c=new Map;return(k,E)=>{const N=`${k.length}-${E.length}-${k.slice(0,50)}`;if(c.has(N))return c.get(N);const R=ha(k,E);if(c.set(N,R),c.size>100){const V=c.keys().next().value;c.delete(V)}return R}},[]),Bt=s.useCallback(async(c,k,E=!1,N="claude")=>{if(!c||!k)return[];const R=!E;R?Ne(!0):je(!0);try{const V=E?ve.current:0,me=await be.sessionMessages(c,k,Ce,V,N);if(!me.ok)throw new Error("Failed to load session messages");const q=await me.json();if(R&&q.tokenUsage&&Et(q.tokenUsage),q.hasMore!==void 0)return we(q.hasMore),xe(q.total),Re(V+(q.messages?.length||0)),q.messages||[];{const ee=q.messages||[];return we(!1),xe(ee.length),ee}}catch(V){return console.error("Error loading session messages:",V),[]}finally{R?Ne(!1):je(!1)}},[Re]),ha=(c,k)=>{const E=c.split(`
68
+ Path: \`${E.path}\``,timestamp:Date.now()}]),E.exists&&l&&l(E.path));break;case"config":h&&h();break;default:console.warn("Unknown built-in command action:",k)}},[l,h,gt]),jr=s.useRef(null),pa=s.useCallback(async(c,k)=>{const{content:E,hasBashCommands:N,hasFileIncludes:R}=c;if(N&&!window.confirm("此命令包含将被执行的 bash 命令。是否继续?")){X(me=>[...me,{type:"assistant",content:"❌ 命令执行已取消",timestamp:Date.now()}]);return}Z(E),setTimeout(()=>{if(jr.current){const V={preventDefault:()=>{}};jr.current(V)}},50)},[]),Zt=s.useCallback(async c=>{if(!(!c||!t))try{const k=W.match(new RegExp(`${c.name}\\s*(.*)`)),E=k&&k[1]?k[1].trim().split(/\s+/):[],N={projectPath:t.path,projectName:t.name,sessionId:I,provider:dt,model:gt,tokenUsage:rs},R=await re("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:c.name,commandPath:c.path,args:E,context:N})});if(!R.ok)throw new Error("Failed to execute command");const V=await R.json();V.type==="builtin"?ua(V):V.type==="custom"&&await pa(V,E),Z(""),Ve(!1),xt(-1),lt(""),ct(-1)}catch(k){console.error("Error executing command:",k),X(E=>[...E,{type:"assistant",content:`Error executing command: ${k.message}`,timestamp:Date.now()}])}},[W,t,I,dt,gt,rs]),xa=s.useMemo(()=>{const c=new Map;return(k,E)=>{const N=`${k.length}-${E.length}-${k.slice(0,50)}`;if(c.has(N))return c.get(N);const R=ha(k,E);if(c.set(N,R),c.size>100){const V=c.keys().next().value;c.delete(V)}return R}},[]),Bt=s.useCallback(async(c,k,E=!1,N="claude")=>{if(!c||!k)return[];const R=!E;R?Ne(!0):je(!0);try{const V=E?ve.current:0,me=await be.sessionMessages(c,k,Ce,V,N);if(!me.ok)throw new Error("Failed to load session messages");const q=await me.json();if(R&&q.tokenUsage&&Et(q.tokenUsage),q.hasMore!==void 0)return we(q.hasMore),xe(q.total),Re(V+(q.messages?.length||0)),q.messages||[];{const ee=q.messages||[];return we(!1),xe(ee.length),ee}}catch(V){return console.error("Error loading session messages:",V),[]}finally{R?Ne(!1):je(!1)}},[Re]),ha=(c,k)=>{const E=c.split(`
69
69
  `),N=k.split(`
70
70
  `),R=[];let V=0,me=0;for(;V<E.length||me<N.length;){const q=E[V],ee=N[me];V>=E.length?(R.push({type:"added",content:ee,lineNum:me+1}),me++):me>=N.length?(R.push({type:"removed",content:q,lineNum:V+1}),V++):q===ee?(V++,me++):(R.push({type:"removed",content:q,lineNum:V+1}),R.push({type:"added",content:ee,lineNum:me+1}),V++,me++)}return R},ga=c=>{const k=[],E=new Map;for(const N of c)if(N.message?.role==="user"&&Array.isArray(N.message?.content))for(const R of N.message.content)R.type==="tool_result"&&E.set(R.tool_use_id,{content:R.content,isError:R.is_error,timestamp:new Date(N.timestamp||Date.now()),toolUseResult:N.toolUseResult||null});for(const N of c)if(!N.isMeta){if(N.message?.role==="user"&&N.message?.content){let R="",V="user";if(Array.isArray(N.message.content)){const ee=[];for(const ye of N.message.content)ye.type==="text"&&ee.push(Mt(ye.text));R=ee.join(`
71
- `)}else typeof N.message.content=="string"?R=Mt(N.message.content):R=Mt(String(N.message.content));const me=R.match(/<command-name>(\/[^<]+)<\/command-name>/);me&&(R=me[1]),!R||R.startsWith("<command-args>")||R.startsWith("<local-command-stdout>")||R.startsWith("<system-reminder>")||R.startsWith("Caveat:")||R.startsWith("This session is being continued from a previous")||R.startsWith("[Request interrupted")||(R=ar(R),k.push({type:V,content:R,timestamp:N.timestamp||new Date().toISOString()}))}else if(N.type==="thinking"&&N.message?.content)k.push({type:"assistant",content:ar(N.message.content),timestamp:N.timestamp||new Date().toISOString(),isThinking:!0});else if(N.type==="tool_use"&&N.toolName)k.push({type:"assistant",content:"",timestamp:N.timestamp||new Date().toISOString(),isToolUse:!0,toolName:N.toolName,toolInput:N.toolInput||"",toolCallId:N.toolCallId});else if(N.type==="tool_result"){for(let R=k.length-1;R>=0;R--)if(k[R].isToolUse&&!k[R].toolResult&&(!N.toolCallId||k[R].toolCallId===N.toolCallId)){k[R].toolResult={content:N.output||"",isError:!1};break}}else if(N.message?.role==="assistant"&&N.message?.content){if(Array.isArray(N.message.content)){for(const R of N.message.content)if(R.type==="text"){let V=R.text;typeof V=="string"&&(V=ar(V)),k.push({type:"assistant",content:V,timestamp:N.timestamp||new Date().toISOString()})}else if(R.type==="tool_use"){const V=E.get(R.id);k.push({type:"assistant",content:"",timestamp:N.timestamp||new Date().toISOString(),isToolUse:!0,toolName:R.name,toolInput:JSON.stringify(R.input),toolResult:V?{content:typeof V.content=="string"?V.content:JSON.stringify(V.content),isError:V.isError,toolUseResult:V.toolUseResult}:null,toolError:V?.isError||!1,toolResultTimestamp:V?.timestamp||new Date})}}else if(typeof N.message.content=="string"){let R=N.message.content;R=ar(R),k.push({type:"assistant",content:R,timestamp:N.timestamp||new Date().toISOString()})}}}return k},ns=s.useMemo(()=>ga(ie),[ie]),mt=s.useCallback(()=>{Te.current&&(Te.current.scrollTop=Te.current.scrollHeight)},[]),Xt=s.useCallback(()=>{if(!Te.current)return!1;const{scrollTop:c,scrollHeight:k,clientHeight:E}=Te.current;return k-c-E<50},[]),os=s.useCallback(async c=>{if(!c||ue.current||Le||!Se||!r||!t)return!1;ue.current=!0;const k=c.scrollHeight,E=c.scrollTop;try{const N=await Bt(t.name,r.id,!0,"claude");return N.length>0?(ce.current={height:k,top:E},Y(R=>[...N,...R]),!0):!1}finally{ue.current=!1}},[Se,Le,r,t,Bt]),Ut=s.useCallback(async()=>{if(Te.current){const c=Te.current,k=Xt();G(!k),c.scrollTop<100?te.current||await os(c)&&(te.current=!0):te.current=!1}},[Xt,os]);s.useLayoutEffect(()=>{if(!ce.current||!Te.current)return;const{height:c,top:k}=ce.current,E=Te.current,R=E.scrollHeight-c;E.scrollTop=k+Math.max(R,0),ce.current=null,setTimeout(()=>{Te.current&&Te.current.scrollTop>=100&&(te.current=!1)},300)},[le.length]),s.useEffect(()=>{(async()=>{if(r&&t){const k=localStorage.getItem("selected-provider")||"claude";if(K.current=!0,L!==null&&L!==r.id?(Re(0),we(!1),xe(0),Et(null),U(!1),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:k})):L===null&&(Re(0),we(!1),xe(0),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:k})),_(r.id),Ee)Be(!1);else{const N=await Bt(t.name,r.id,!1,"claude");Y(N)}}else!Ee&&!ne&&(X([]),Y([])),_(null),Re(0),we(!1),xe(0);setTimeout(()=>{K.current=!1},250)})()},[r,t,mt,Ee]),s.useEffect(()=>{d>0&&r&&t&&(async()=>{try{const k=await Bt(t.name,r.id,!1,"claude");Y(k),C&&Xt()&&setTimeout(()=>mt(),200)}catch(k){console.error("Error reloading messages from external update:",k)}})()},[d,r,t,Bt,Xt,C,mt]),s.useEffect(()=>{ie.length>0&&!ne&&X(ns)},[ns,ie,ne]),s.useEffect(()=>{i&&i(Q)},[Q,i]),s.useEffect(()=>{t&&W!==""?Ye.setItem(`draft_input_${t.name}`,W):t&&W===""&&Ye.removeItem(`draft_input_${t.name}`)},[W,t]),s.useEffect(()=>{t&&le.length>0&&Ye.setItem(`chat_messages_${t.name}`,JSON.stringify(le))},[le,t]),s.useEffect(()=>{if(t){const c=Ye.getItem(`draft_input_${t.name}`)||"";c!==W&&Z(c)}},[t?.name]),s.useEffect(()=>{L&&ne&&x&&x(L)},[ne,L,x]),s.useEffect(()=>{L&&S&&S.has(L)&&!ne&&(U(!0),Ge(!0))},[L,S]),s.useEffect(()=>{if(n.length>0){const c=n[n.length-1];if(!["projects_updated","session-created","claude-complete"].includes(c.type)&&c.sessionId&&L&&c.sessionId!==L){console.log("⏭️ Skipping message for different session:",c.sessionId,"current:",L);return}switch(c.type){case"session-created":c.sessionId&&!L&&(sessionStorage.setItem("pendingSessionId",c.sessionId),Be(!0),v&&v(c.sessionId),f(q=>q.map(ee=>ee.sessionId?ee:{...ee,sessionId:c.sessionId})));break;case"token-budget":c.data&&Et(c.data);break;case"claude-response":const N=c.data.message||c.data;if(N&&typeof N=="object"&&N.type){if(N.type==="content_block_delta"&&N.delta?.text){const q=Mt(N.delta.text);Ae.current+=q,fe.current||(fe.current=setTimeout(()=>{const ee=Ae.current;Ae.current="",fe.current=null,ee&&X(ye=>{const Pe=[...ye],Je=Pe[Pe.length-1];return Je&&Je.type==="assistant"&&!Je.isToolUse&&Je.isStreaming?Je.content=(Je.content||"")+ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Pe})},100));return}if(N.type==="content_block_stop"){fe.current&&(clearTimeout(fe.current),fe.current=null);const q=Ae.current;Ae.current="",q&&X(ee=>{const ye=[...ee],Pe=ye[ye.length-1];return Pe&&Pe.type==="assistant"&&!Pe.isToolUse&&Pe.isStreaming?Pe.content=(Pe.content||"")+q:ye.push({type:"assistant",content:q,timestamp:new Date,isStreaming:!0}),ye}),X(ee=>{const ye=[...ee],Pe=ye[ye.length-1];return Pe&&Pe.type==="assistant"&&Pe.isStreaming&&(Pe.isStreaming=!1),ye});return}}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&L&&c.data.session_id!==L){console.log("🔄 Claude CLI session duplication detected:",{originalSession:L,newSession:c.data.session_id}),Be(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&!L){console.log("🔄 New session init detected:",{newSession:c.data.session_id}),Be(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&L&&c.data.session_id===L){console.log("🔄 System init message for current session, ignoring");return}if(Array.isArray(N.content)){for(const q of N.content)if(q.type==="tool_use"){const ee=q.input?JSON.stringify(q.input,null,2):"";X(ye=>[...ye,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:q.name,toolInput:ee,toolId:q.id,toolResult:null}])}else if(q.type==="text"&&q.text?.trim()){let ee=Mt(q.text);ee=Ur(ee),X(ye=>[...ye,{type:"assistant",content:ee,timestamp:new Date}])}}else if(typeof N.content=="string"&&N.content.trim()){let q=Mt(N.content);q=Ur(q),X(ee=>[...ee,{type:"assistant",content:q,timestamp:new Date}])}if(N.role==="user"&&Array.isArray(N.content))for(const q of N.content)q.type==="tool_result"&&X(ee=>ee.map(ye=>ye.isToolUse&&ye.toolId===q.tool_use_id?{...ye,toolResult:{content:q.content,isError:q.is_error,timestamp:new Date}}:ye));break;case"claude-output":{const q=String(c.data||"");q.trim()&&(Ae.current+=Ae.current?`
71
+ `)}else typeof N.message.content=="string"?R=Mt(N.message.content):R=Mt(String(N.message.content));const me=R.match(/<command-name>(\/[^<]+)<\/command-name>/);me&&(R=me[1]),!R||R.startsWith("<command-args>")||R.startsWith("<local-command-stdout>")||R.startsWith("<system-reminder>")||R.startsWith("Caveat:")||R.startsWith("This session is being continued from a previous")||R.startsWith("[Request interrupted")||(R=ar(R),k.push({type:V,content:R,timestamp:N.timestamp||new Date().toISOString()}))}else if(N.type==="thinking"&&N.message?.content)k.push({type:"assistant",content:ar(N.message.content),timestamp:N.timestamp||new Date().toISOString(),isThinking:!0});else if(N.type==="tool_use"&&N.toolName)k.push({type:"assistant",content:"",timestamp:N.timestamp||new Date().toISOString(),isToolUse:!0,toolName:N.toolName,toolInput:N.toolInput||"",toolCallId:N.toolCallId});else if(N.type==="tool_result"){for(let R=k.length-1;R>=0;R--)if(k[R].isToolUse&&!k[R].toolResult&&(!N.toolCallId||k[R].toolCallId===N.toolCallId)){k[R].toolResult={content:N.output||"",isError:!1};break}}else if(N.message?.role==="assistant"&&N.message?.content){if(Array.isArray(N.message.content)){for(const R of N.message.content)if(R.type==="text"){let V=R.text;typeof V=="string"&&(V=ar(V)),k.push({type:"assistant",content:V,timestamp:N.timestamp||new Date().toISOString()})}else if(R.type==="tool_use"){const V=E.get(R.id);k.push({type:"assistant",content:"",timestamp:N.timestamp||new Date().toISOString(),isToolUse:!0,toolName:R.name,toolInput:JSON.stringify(R.input),toolResult:V?{content:typeof V.content=="string"?V.content:JSON.stringify(V.content),isError:V.isError,toolUseResult:V.toolUseResult}:null,toolError:V?.isError||!1,toolResultTimestamp:V?.timestamp||new Date})}}else if(typeof N.message.content=="string"){let R=N.message.content;R=ar(R),k.push({type:"assistant",content:R,timestamp:N.timestamp||new Date().toISOString()})}}}return k},ns=s.useMemo(()=>ga(ie),[ie]),mt=s.useCallback(()=>{Te.current&&(Te.current.scrollTop=Te.current.scrollHeight)},[]),Xt=s.useCallback(()=>{if(!Te.current)return!1;const{scrollTop:c,scrollHeight:k,clientHeight:E}=Te.current;return k-c-E<50},[]),os=s.useCallback(async c=>{if(!c||ue.current||Le||!Se||!r||!t)return!1;ue.current=!0;const k=c.scrollHeight,E=c.scrollTop;try{const N=await Bt(t.name,r.id,!0,"claude");return N.length>0?(ce.current={height:k,top:E},Y(R=>[...N,...R]),!0):!1}finally{ue.current=!1}},[Se,Le,r,t,Bt]),Ut=s.useCallback(async()=>{if(Te.current){const c=Te.current,k=Xt();G(!k),c.scrollTop<100?te.current||await os(c)&&(te.current=!0):te.current=!1}},[Xt,os]);s.useLayoutEffect(()=>{if(!ce.current||!Te.current)return;const{height:c,top:k}=ce.current,E=Te.current,R=E.scrollHeight-c;E.scrollTop=k+Math.max(R,0),ce.current=null,setTimeout(()=>{Te.current&&Te.current.scrollTop>=100&&(te.current=!1)},300)},[le.length]),s.useEffect(()=>{(async()=>{if(r&&t){const k=localStorage.getItem("selected-provider")||"claude";if(K.current=!0,I!==null&&I!==r.id?(Re(0),we(!1),xe(0),Et(null),U(!1),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:k})):I===null&&(Re(0),we(!1),xe(0),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:k})),_(r.id),Ee)Be(!1);else{const N=await Bt(t.name,r.id,!1,"claude");Y(N)}}else!Ee&&!ne&&(X([]),Y([])),_(null),Re(0),we(!1),xe(0);setTimeout(()=>{K.current=!1},250)})()},[r,t,mt,Ee]),s.useEffect(()=>{d>0&&r&&t&&(async()=>{try{const k=await Bt(t.name,r.id,!1,"claude");Y(k),C&&Xt()&&setTimeout(()=>mt(),200)}catch(k){console.error("Error reloading messages from external update:",k)}})()},[d,r,t,Bt,Xt,C,mt]),s.useEffect(()=>{ie.length>0&&!ne&&X(ns)},[ns,ie,ne]),s.useEffect(()=>{i&&i(Q)},[Q,i]),s.useEffect(()=>{t&&W!==""?Ye.setItem(`draft_input_${t.name}`,W):t&&W===""&&Ye.removeItem(`draft_input_${t.name}`)},[W,t]),s.useEffect(()=>{t&&le.length>0&&Ye.setItem(`chat_messages_${t.name}`,JSON.stringify(le))},[le,t]),s.useEffect(()=>{if(t){const c=Ye.getItem(`draft_input_${t.name}`)||"";c!==W&&Z(c)}},[t?.name]),s.useEffect(()=>{I&&ne&&x&&x(I)},[ne,I,x]),s.useEffect(()=>{I&&S&&S.has(I)&&!ne&&(U(!0),Ge(!0))},[I,S]),s.useEffect(()=>{if(n.length>0){const c=n[n.length-1];if(!["projects_updated","session-created","claude-complete"].includes(c.type)&&c.sessionId&&I&&c.sessionId!==I){console.log("⏭️ Skipping message for different session:",c.sessionId,"current:",I);return}switch(c.type){case"session-created":c.sessionId&&!I&&(sessionStorage.setItem("pendingSessionId",c.sessionId),Be(!0),v&&v(c.sessionId),f(q=>q.map(ee=>ee.sessionId?ee:{...ee,sessionId:c.sessionId})));break;case"token-budget":c.data&&Et(c.data);break;case"claude-response":const N=c.data.message||c.data;if(N&&typeof N=="object"&&N.type){if(N.type==="content_block_delta"&&N.delta?.text){const q=Mt(N.delta.text);Ae.current+=q,fe.current||(fe.current=setTimeout(()=>{const ee=Ae.current;Ae.current="",fe.current=null,ee&&X(ye=>{const Pe=[...ye],Je=Pe[Pe.length-1];return Je&&Je.type==="assistant"&&!Je.isToolUse&&Je.isStreaming?Je.content=(Je.content||"")+ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Pe})},100));return}if(N.type==="content_block_stop"){fe.current&&(clearTimeout(fe.current),fe.current=null);const q=Ae.current;Ae.current="",q&&X(ee=>{const ye=[...ee],Pe=ye[ye.length-1];return Pe&&Pe.type==="assistant"&&!Pe.isToolUse&&Pe.isStreaming?Pe.content=(Pe.content||"")+q:ye.push({type:"assistant",content:q,timestamp:new Date,isStreaming:!0}),ye}),X(ee=>{const ye=[...ee],Pe=ye[ye.length-1];return Pe&&Pe.type==="assistant"&&Pe.isStreaming&&(Pe.isStreaming=!1),ye});return}}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&I&&c.data.session_id!==I){console.log("🔄 Claude CLI session duplication detected:",{originalSession:I,newSession:c.data.session_id}),Be(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&!I){console.log("🔄 New session init detected:",{newSession:c.data.session_id}),Be(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&I&&c.data.session_id===I){console.log("🔄 System init message for current session, ignoring");return}if(Array.isArray(N.content)){for(const q of N.content)if(q.type==="tool_use"){const ee=q.input?JSON.stringify(q.input,null,2):"";X(ye=>[...ye,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:q.name,toolInput:ee,toolId:q.id,toolResult:null}])}else if(q.type==="text"&&q.text?.trim()){let ee=Mt(q.text);ee=Ur(ee),X(ye=>[...ye,{type:"assistant",content:ee,timestamp:new Date}])}}else if(typeof N.content=="string"&&N.content.trim()){let q=Mt(N.content);q=Ur(q),X(ee=>[...ee,{type:"assistant",content:q,timestamp:new Date}])}if(N.role==="user"&&Array.isArray(N.content))for(const q of N.content)q.type==="tool_result"&&X(ee=>ee.map(ye=>ye.isToolUse&&ye.toolId===q.tool_use_id?{...ye,toolResult:{content:q.content,isError:q.is_error,timestamp:new Date}}:ye));break;case"claude-output":{const q=String(c.data||"");q.trim()&&(Ae.current+=Ae.current?`
72
72
  ${q}`:q,fe.current||(fe.current=setTimeout(()=>{const ee=Ae.current;Ae.current="",fe.current=null,ee&&X(ye=>{const Pe=[...ye],Je=Pe[Pe.length-1];return Je&&Je.type==="assistant"&&!Je.isToolUse&&Je.isStreaming?Je.content=Je.content?`${Je.content}
73
- ${ee}`:ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Pe})},100)))}break;case"claude-interactive-prompt":X(q=>[...q,{type:"assistant",content:c.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(!c.requestId)break;f(q=>q.some(ee=>ee.requestId===c.requestId)?q:[...q,{requestId:c.requestId,toolName:c.toolName||"UnknownTool",input:c.input,context:c.context,sessionId:c.sessionId||null,receivedAt:new Date}]),U(!0),Ge(!0),ht({text:"等待权限",tokens:0,can_interrupt:!0});break}case"claude-permission-cancelled":{if(!c.requestId)break;f(q=>q.filter(ee=>ee.requestId!==c.requestId));break}case"claude-error":X(q=>[...q,{type:"error",content:`错误: ${c.error}`,timestamp:new Date}]),U(!1),Ge(!1),ht(null),f([]),L&&(g&&g(L),b&&b(L));break;case"claude-complete":const R=c.sessionId||L||sessionStorage.getItem("pendingSessionId");(R===L||!L)&&(U(!1),Ge(!1),ht(null)),R&&(g&&g(R),b&&b(R));const V=sessionStorage.getItem("pendingSessionId");V&&!L&&c.exitCode===0&&(_(V),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",V)),t&&c.exitCode===0&&Ye.removeItem(`chat_messages_${t.name}`),f([]);break;case"session-aborted":{const q=c.sessionId||L;q===L&&(U(!1),Ge(!1),ht(null)),q&&(g&&g(q),b&&b(q)),f([]),X(ee=>[...ee,{type:"assistant",content:"会话已被用户中断。",timestamp:new Date}]);break}case"session-status":{const q=c.sessionId;(q===L||r&&q===r.id)&&c.isProcessing&&(U(!0),Ge(!0),x&&x(q));break}case"claude-status":const me=c.data;if(me){let q={text:"处理中...",tokens:0,can_interrupt:!0};me.message?q.text=me.message:me.status?q.text=me.status:typeof me=="string"&&(q.text=me),me.tokens?q.tokens=me.tokens:me.token_count&&(q.tokens=me.token_count),me.can_interrupt!==void 0&&(q.can_interrupt=me.can_interrupt),ht(q),U(!0),Ge(q.can_interrupt)}break}}},[n]),s.useEffect(()=>{t&&fa()},[t]);const fa=async()=>{try{const c=await be.getFiles(t.name);if(c.ok){const k=await c.json(),E=is(k);hr(E)}}catch(c){console.error("Error fetching files:",c)}},is=(c,k="")=>{let E=[];for(const N of c){const R=k?`${k}/${N.name}`:N.name;N.type==="directory"&&N.children?E=E.concat(is(N.children,R)):N.type==="file"&&E.push({name:N.name,path:R,relativePath:N.path})}return E};s.useEffect(()=>{const c=W.slice(0,Ft),k=c.lastIndexOf("@");if(k!==-1){const E=c.slice(k+1);if(E.includes(" "))bt(!1),Ct(-1);else{Ct(k),bt(!0);const N=Gt.filter(R=>R.name.toLowerCase().includes(E.toLowerCase())||R.path.toLowerCase().includes(E.toLowerCase())).slice(0,10);gr(N),it(-1)}}else bt(!1),Ct(-1)},[W,Ft,Gt]),s.useEffect(()=>{const c=setTimeout(()=>{tt(W)},150);return()=>clearTimeout(c)},[W]);const ls=s.useMemo(()=>le.length<=Wt?le:le.slice(-Wt),[le,Wt]);s.useEffect(()=>{if(!C&&Te.current){const c=Te.current;ae.current={height:c.scrollHeight,top:c.scrollTop}}}),s.useEffect(()=>{if(Te.current&&le.length>0)if(C)T||setTimeout(()=>mt(),50);else{const c=Te.current,k=ae.current.height,E=ae.current.top,R=c.scrollHeight-k;R>0&&E>0&&(c.scrollTop=E+R)}},[le.length,T,mt,C]),s.useEffect(()=>{Te.current&&le.length>0&&!K.current&&(G(!1),setTimeout(()=>{mt()},200))},[r?.id,t?.name]),s.useEffect(()=>{const c=Te.current;if(c)return c.addEventListener("scroll",Ut),()=>c.removeEventListener("scroll",Ut)},[Ut]),s.useEffect(()=>{if(M.current){M.current.style.height="auto",M.current.style.height=M.current.scrollHeight+"px";const c=parseInt(window.getComputedStyle(M.current).lineHeight),k=M.current.scrollHeight>c*2;pt(k)}},[]),s.useEffect(()=>{M.current&&!W.trim()&&(M.current.style.height="auto",pt(!1))},[W]),s.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){Et(null);return}(async()=>{try{const k=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,E=await se(k);if(E.ok){const N=await E.json();Et(N)}else Et(null)}catch(k){console.error("Failed to fetch initial token usage:",k)}})()},[r?.id,r?.__provider,t?.path]);const ba=s.useCallback(c=>{c.trim()&&Z(k=>{const E=k.trim()?`${k} ${c}`:c;return setTimeout(()=>{if(M.current){M.current.style.height="auto",M.current.style.height=M.current.scrollHeight+"px";const N=parseInt(window.getComputedStyle(M.current).lineHeight),R=M.current.scrollHeight>N*2;pt(R)}},0),E})},[]),ya=s.useCallback(()=>{la(c=>c+100)},[]),er=s.useCallback(c=>{const k=c.filter(E=>{try{if(!E||typeof E!="object")return console.warn("Invalid file object:",E),!1;if(!E.type||!E.type.startsWith("image/"))return!1;if(!E.size||E.size>5242880){const N=E.name||"Unknown file";return u(R=>{const V=new Map(R);return V.set(N,"文件太大(最大 5MB)"),V}),!1}return!0}catch(N){return console.error("Error validating file:",N,E),!1}});k.length>0&&de(E=>[...E,...k].slice(0,5))},[]),va=s.useCallback(async c=>{const k=c.target.files;if(!(!k||k.length===0||!t)){oe(!0);try{const E=new FormData;Array.from(k).forEach(V=>{E.append("files",V)});const N=await be.uploadFiles(t.name,E);if(!N.ok){const V=await N.json();throw new Error(V.error||"上传失败")}const R=await N.json();if(R.files&&R.files.length>0){const V=R.files.map(q=>`@${q.name}`).join(" "),me=W?`${W} ${V} `:`${V} `;Z(me),M.current&&M.current.focus()}}catch(E){console.error("File upload failed:",E)}finally{oe(!1),De.current&&(De.current.value="")}}},[t,W]),ja=s.useCallback(async c=>{const k=Array.from(c.clipboardData.items);for(const E of k)if(E.type.startsWith("image/")){const N=E.getAsFile();N&&er([N])}if(k.length===0&&c.clipboardData.files.length>0){const N=Array.from(c.clipboardData.files).filter(R=>R.type.startsWith("image/"));N.length>0&&er(N)}},[er]),{getRootProps:wa,getInputProps:ka,isDragActive:Na,open:Sa}=Vr({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:er,noClick:!0,noKeyboard:!0}),vt=s.useCallback(async c=>{if(c.preventDefault(),!W.trim()||ne||!t)return;const k=W.trim();if(k.startsWith("/")){const ee=k.indexOf(" "),ye=ee!==-1?k.slice(0,ee):k,Pe=Fe.find(Je=>Je.name===ye&&Je.namespace==="builtin");if(Pe){Zt(Pe);return}}if(B){const ee=await B();if(ee&&!ee.allowed){I?.(ee.reason);return}}let E=[];if(H.length>0){const ee=new FormData;H.forEach(ye=>{ee.append("images",ye)});try{const ye=await se(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:ee});if(!ye.ok)throw new Error("图片上传失败");E=(await ye.json()).images}catch(ye){console.error("Image upload failed:",ye),X(Pe=>[...Pe,{type:"error",content:`图片上传失败: ${ye.message}`,timestamp:new Date}]);return}}const N={type:"user",content:W,images:E,timestamp:new Date};X(ee=>[...ee,N]),U(!0),Ge(!0),ht({text:"处理中",tokens:0,can_interrupt:!0}),G(!1),setTimeout(()=>mt(),100);const V=L||r?.id||`new-session-${Date.now()}`;m&&m(V);const q=(()=>{try{const ee=Ye.getItem("claude-settings");if(ee)return JSON.parse(ee)}catch(ee){console.error("Error loading tools settings:",ee)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();o({type:"claude-command",command:W,options:{projectPath:t.path,cwd:t.fullPath,sessionId:L,resume:!!L,toolsSettings:q,permissionMode:P,model:gt,images:E}}),Z(""),de([]),$e(new Map),u(new Map),pt(!1),M.current&&(M.current.style.height="auto"),t&&Ye.removeItem(`draft_input_${t.name}`)},[W,ne,t,H,L,r,dt,P,m,gt,o,Z,de,$e,u,pt,M,X,U,Ge,ht,G,mt,B,I,Zt,Fe]),cs=s.useCallback(c=>!c||dt!=="claude"?{success:!1}:qo(c.entry),[dt]),Ht=s.useCallback((c,k)=>{const N=(Array.isArray(c)?c:[c]).filter(Boolean);N.length!==0&&(N.forEach(R=>{o({type:"claude-permission-response",requestId:R,allow:!!k?.allow,updatedInput:k?.updatedInput,message:k?.message,rememberEntry:k?.rememberEntry})}),f(R=>{const V=R.filter(me=>!N.includes(me.requestId));return V.length===0&&ht(null),V}))},[o]);s.useEffect(()=>{jr.current=vt},[vt]);const ds=c=>{if(!c)return;const k=W.slice(0,ss),E=W.slice(ss),N=E.indexOf(" "),R=N!==-1?E.slice(N):"",V=k+c.name+" "+R;Z(V),Ve(!1),xt(-1),lt(""),ct(-1),He.current&&clearTimeout(He.current),Zt(c)},Ca=c=>{if(ke&&yt.length>0){if(c.key==="ArrowDown"){c.preventDefault(),ct(k=>k<yt.length-1?k+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),ct(k=>k>0?k-1:yt.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),yr>=0?ds(yt[yr]):yt.length>0&&ds(yt[0]);return}if(c.key==="Escape"){c.preventDefault(),Ve(!1),xt(-1),lt(""),ct(-1),He.current&&clearTimeout(He.current);return}}if(Nt&&at.length>0){if(c.key==="ArrowDown"){c.preventDefault(),it(k=>k<at.length-1?k+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),it(k=>k>0?k-1:at.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),_t>=0?wr(at[_t]):at.length>0&&wr(at[0]);return}if(c.key==="Escape"){c.preventDefault(),bt(!1);return}}if(c.key==="Tab"&&!Nt&&!ke){c.preventDefault();const k=["default","acceptEdits","bypassPermissions","plan"],N=(k.indexOf(P)+1)%k.length,R=k[N];O(R),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,R);return}if(c.key==="Enter"){if(c.nativeEvent.isComposing)return;(c.ctrlKey||c.metaKey)&&!c.shiftKey?(c.preventDefault(),vt(c)):!c.shiftKey&&!c.ctrlKey&&!c.metaKey&&(p||(c.preventDefault(),vt(c)))}},wr=c=>{const k=W.slice(0,Vt),E=W.slice(Vt),N=E.indexOf(" "),R=N!==-1?E.slice(N):"",V=k+"@"+c.path+" "+R,me=k.length+1+c.path.length+1;M.current&&!M.current.matches(":focus")&&M.current.focus(),Z(V),St(me),bt(!1),Ct(-1),M.current&&requestAnimationFrame(()=>{M.current&&(M.current.setSelectionRange(me,me),M.current.matches(":focus")||M.current.focus())})},Ea=c=>{const k=c.target.value,E=c.target.selectionStart;if(!L&&k.trim(),Z(k),St(E),!k.trim()){c.target.style.height="auto",pt(!1),Ve(!1),xt(-1),lt("");return}const N=k.slice(0,E);if((N.match(/```/g)||[]).length%2===1){Ve(!1),xt(-1),lt("");return}const me=/(^|\s)\/(\S*)$/,q=N.match(me);if(q){const ee=q.index+q[1].length,ye=q[2];xt(ee),Ve(!0),ct(-1),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{lt(ye)},150)}else Ve(!1),xt(-1),lt(""),He.current&&clearTimeout(He.current)},Ma=c=>{St(c.target.selectionStart)},La=()=>{L&&fr&&o({type:"abort-session",sessionId:L,provider:dt})},Ia=()=>{const c=["default","acceptEdits","bypassPermissions","plan"],E=(c.indexOf(P)+1)%c.length,N=c[E];O(N),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,N)};return t?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
73
+ ${ee}`:ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Pe})},100)))}break;case"claude-interactive-prompt":X(q=>[...q,{type:"assistant",content:c.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(!c.requestId)break;f(q=>q.some(ee=>ee.requestId===c.requestId)?q:[...q,{requestId:c.requestId,toolName:c.toolName||"UnknownTool",input:c.input,context:c.context,sessionId:c.sessionId||null,receivedAt:new Date}]),U(!0),Ge(!0),ht({text:"等待权限",tokens:0,can_interrupt:!0});break}case"claude-permission-cancelled":{if(!c.requestId)break;f(q=>q.filter(ee=>ee.requestId!==c.requestId));break}case"claude-error":X(q=>[...q,{type:"error",content:`错误: ${c.error}`,timestamp:new Date}]),U(!1),Ge(!1),ht(null),f([]),I&&(g&&g(I),b&&b(I));break;case"claude-complete":const R=c.sessionId||I||sessionStorage.getItem("pendingSessionId");(R===I||!I)&&(U(!1),Ge(!1),ht(null)),R&&(g&&g(R),b&&b(R));const V=sessionStorage.getItem("pendingSessionId");V&&!I&&c.exitCode===0&&(_(V),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",V)),t&&c.exitCode===0&&Ye.removeItem(`chat_messages_${t.name}`),f([]);break;case"session-aborted":{const q=c.sessionId||I;q===I&&(U(!1),Ge(!1),ht(null)),q&&(g&&g(q),b&&b(q)),f([]),X(ee=>[...ee,{type:"assistant",content:"会话已被用户中断。",timestamp:new Date}]);break}case"session-status":{const q=c.sessionId;(q===I||r&&q===r.id)&&c.isProcessing&&(U(!0),Ge(!0),x&&x(q));break}case"claude-status":const me=c.data;if(me){let q={text:"处理中...",tokens:0,can_interrupt:!0};me.message?q.text=me.message:me.status?q.text=me.status:typeof me=="string"&&(q.text=me),me.tokens?q.tokens=me.tokens:me.token_count&&(q.tokens=me.token_count),me.can_interrupt!==void 0&&(q.can_interrupt=me.can_interrupt),ht(q),U(!0),Ge(q.can_interrupt)}break}}},[n]),s.useEffect(()=>{t&&fa()},[t]);const fa=async()=>{try{const c=await be.getFiles(t.name);if(c.ok){const k=await c.json(),E=is(k);hr(E)}}catch(c){console.error("Error fetching files:",c)}},is=(c,k="")=>{let E=[];for(const N of c){const R=k?`${k}/${N.name}`:N.name;N.type==="directory"&&N.children?E=E.concat(is(N.children,R)):N.type==="file"&&E.push({name:N.name,path:R,relativePath:N.path})}return E};s.useEffect(()=>{const c=W.slice(0,Ft),k=c.lastIndexOf("@");if(k!==-1){const E=c.slice(k+1);if(E.includes(" "))bt(!1),Ct(-1);else{Ct(k),bt(!0);const N=Gt.filter(R=>R.name.toLowerCase().includes(E.toLowerCase())||R.path.toLowerCase().includes(E.toLowerCase())).slice(0,10);gr(N),it(-1)}}else bt(!1),Ct(-1)},[W,Ft,Gt]),s.useEffect(()=>{const c=setTimeout(()=>{tt(W)},150);return()=>clearTimeout(c)},[W]);const ls=s.useMemo(()=>le.length<=Wt?le:le.slice(-Wt),[le,Wt]);s.useEffect(()=>{if(!C&&Te.current){const c=Te.current;ae.current={height:c.scrollHeight,top:c.scrollTop}}}),s.useEffect(()=>{if(Te.current&&le.length>0)if(C)T||setTimeout(()=>mt(),50);else{const c=Te.current,k=ae.current.height,E=ae.current.top,R=c.scrollHeight-k;R>0&&E>0&&(c.scrollTop=E+R)}},[le.length,T,mt,C]),s.useEffect(()=>{Te.current&&le.length>0&&!K.current&&(G(!1),setTimeout(()=>{mt()},200))},[r?.id,t?.name]),s.useEffect(()=>{const c=Te.current;if(c)return c.addEventListener("scroll",Ut),()=>c.removeEventListener("scroll",Ut)},[Ut]),s.useEffect(()=>{if(M.current){M.current.style.height="auto",M.current.style.height=M.current.scrollHeight+"px";const c=parseInt(window.getComputedStyle(M.current).lineHeight),k=M.current.scrollHeight>c*2;pt(k)}},[]),s.useEffect(()=>{M.current&&!W.trim()&&(M.current.style.height="auto",pt(!1))},[W]),s.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){Et(null);return}(async()=>{try{const k=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,E=await re(k);if(E.ok){const N=await E.json();Et(N)}else Et(null)}catch(k){console.error("Failed to fetch initial token usage:",k)}})()},[r?.id,r?.__provider,t?.path]);const ba=s.useCallback(c=>{c.trim()&&Z(k=>{const E=k.trim()?`${k} ${c}`:c;return setTimeout(()=>{if(M.current){M.current.style.height="auto",M.current.style.height=M.current.scrollHeight+"px";const N=parseInt(window.getComputedStyle(M.current).lineHeight),R=M.current.scrollHeight>N*2;pt(R)}},0),E})},[]),ya=s.useCallback(()=>{la(c=>c+100)},[]),er=s.useCallback(c=>{const k=c.filter(E=>{try{if(!E||typeof E!="object")return console.warn("Invalid file object:",E),!1;if(!E.type||!E.type.startsWith("image/"))return!1;if(!E.size||E.size>5242880){const N=E.name||"Unknown file";return u(R=>{const V=new Map(R);return V.set(N,"文件太大(最大 5MB)"),V}),!1}return!0}catch(N){return console.error("Error validating file:",N,E),!1}});k.length>0&&de(E=>[...E,...k].slice(0,5))},[]),va=s.useCallback(async c=>{const k=c.target.files;if(!(!k||k.length===0||!t)){oe(!0);try{const E=new FormData;Array.from(k).forEach(V=>{E.append("files",V)});const N=await be.uploadFiles(t.name,E);if(!N.ok){const V=await N.json();throw new Error(V.error||"上传失败")}const R=await N.json();if(R.files&&R.files.length>0){const V=R.files.map(q=>`@${q.name}`).join(" "),me=W?`${W} ${V} `:`${V} `;Z(me),M.current&&M.current.focus()}}catch(E){console.error("File upload failed:",E)}finally{oe(!1),De.current&&(De.current.value="")}}},[t,W]),ja=s.useCallback(async c=>{const k=Array.from(c.clipboardData.items);for(const E of k)if(E.type.startsWith("image/")){const N=E.getAsFile();N&&er([N])}if(k.length===0&&c.clipboardData.files.length>0){const N=Array.from(c.clipboardData.files).filter(R=>R.type.startsWith("image/"));N.length>0&&er(N)}},[er]),{getRootProps:wa,getInputProps:ka,isDragActive:Na,open:Sa}=Vr({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:er,noClick:!0,noKeyboard:!0}),vt=s.useCallback(async c=>{if(c.preventDefault(),!W.trim()||ne||!t)return;const k=W.trim();if(k.startsWith("/")){const ee=k.indexOf(" "),ye=ee!==-1?k.slice(0,ee):k,Pe=Fe.find(Je=>Je.name===ye&&Je.namespace==="builtin");if(Pe){Zt(Pe);return}}if(B){const ee=await B();if(ee&&!ee.allowed){L?.(ee.reason);return}}let E=[];if(H.length>0){const ee=new FormData;H.forEach(ye=>{ee.append("images",ye)});try{const ye=await re(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:ee});if(!ye.ok)throw new Error("图片上传失败");E=(await ye.json()).images}catch(ye){console.error("Image upload failed:",ye),X(Pe=>[...Pe,{type:"error",content:`图片上传失败: ${ye.message}`,timestamp:new Date}]);return}}const N={type:"user",content:W,images:E,timestamp:new Date};X(ee=>[...ee,N]),U(!0),Ge(!0),ht({text:"处理中",tokens:0,can_interrupt:!0}),G(!1),setTimeout(()=>mt(),100);const V=I||r?.id||`new-session-${Date.now()}`;m&&m(V);const q=(()=>{try{const ee=Ye.getItem("claude-settings");if(ee)return JSON.parse(ee)}catch(ee){console.error("Error loading tools settings:",ee)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();o({type:"claude-command",command:W,options:{projectPath:t.path,cwd:t.fullPath,sessionId:I,resume:!!I,toolsSettings:q,permissionMode:P,model:gt,images:E}}),Z(""),de([]),$e(new Map),u(new Map),pt(!1),M.current&&(M.current.style.height="auto"),t&&Ye.removeItem(`draft_input_${t.name}`)},[W,ne,t,H,I,r,dt,P,m,gt,o,Z,de,$e,u,pt,M,X,U,Ge,ht,G,mt,B,L,Zt,Fe]),cs=s.useCallback(c=>!c||dt!=="claude"?{success:!1}:qo(c.entry),[dt]),Ht=s.useCallback((c,k)=>{const N=(Array.isArray(c)?c:[c]).filter(Boolean);N.length!==0&&(N.forEach(R=>{o({type:"claude-permission-response",requestId:R,allow:!!k?.allow,updatedInput:k?.updatedInput,message:k?.message,rememberEntry:k?.rememberEntry})}),f(R=>{const V=R.filter(me=>!N.includes(me.requestId));return V.length===0&&ht(null),V}))},[o]);s.useEffect(()=>{jr.current=vt},[vt]);const ds=c=>{if(!c)return;const k=W.slice(0,ss),E=W.slice(ss),N=E.indexOf(" "),R=N!==-1?E.slice(N):"",V=k+c.name+" "+R;Z(V),Ve(!1),xt(-1),lt(""),ct(-1),He.current&&clearTimeout(He.current),Zt(c)},Ca=c=>{if(ke&&yt.length>0){if(c.key==="ArrowDown"){c.preventDefault(),ct(k=>k<yt.length-1?k+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),ct(k=>k>0?k-1:yt.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),yr>=0?ds(yt[yr]):yt.length>0&&ds(yt[0]);return}if(c.key==="Escape"){c.preventDefault(),Ve(!1),xt(-1),lt(""),ct(-1),He.current&&clearTimeout(He.current);return}}if(Nt&&at.length>0){if(c.key==="ArrowDown"){c.preventDefault(),it(k=>k<at.length-1?k+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),it(k=>k>0?k-1:at.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),_t>=0?wr(at[_t]):at.length>0&&wr(at[0]);return}if(c.key==="Escape"){c.preventDefault(),bt(!1);return}}if(c.key==="Tab"&&!Nt&&!ke){c.preventDefault();const k=["default","acceptEdits","bypassPermissions","plan"],N=(k.indexOf(P)+1)%k.length,R=k[N];O(R),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,R);return}if(c.key==="Enter"){if(c.nativeEvent.isComposing)return;(c.ctrlKey||c.metaKey)&&!c.shiftKey?(c.preventDefault(),vt(c)):!c.shiftKey&&!c.ctrlKey&&!c.metaKey&&(p||(c.preventDefault(),vt(c)))}},wr=c=>{const k=W.slice(0,Vt),E=W.slice(Vt),N=E.indexOf(" "),R=N!==-1?E.slice(N):"",V=k+"@"+c.path+" "+R,me=k.length+1+c.path.length+1;M.current&&!M.current.matches(":focus")&&M.current.focus(),Z(V),St(me),bt(!1),Ct(-1),M.current&&requestAnimationFrame(()=>{M.current&&(M.current.setSelectionRange(me,me),M.current.matches(":focus")||M.current.focus())})},Ea=c=>{const k=c.target.value,E=c.target.selectionStart;if(!I&&k.trim(),Z(k),St(E),!k.trim()){c.target.style.height="auto",pt(!1),Ve(!1),xt(-1),lt("");return}const N=k.slice(0,E);if((N.match(/```/g)||[]).length%2===1){Ve(!1),xt(-1),lt("");return}const me=/(^|\s)\/(\S*)$/,q=N.match(me);if(q){const ee=q.index+q[1].length,ye=q[2];xt(ee),Ve(!0),ct(-1),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{lt(ye)},150)}else Ve(!1),xt(-1),lt(""),He.current&&clearTimeout(He.current)},Ma=c=>{St(c.target.selectionStart)},La=()=>{I&&fr&&o({type:"abort-session",sessionId:I,provider:dt})},Ia=()=>{const c=["default","acceptEdits","bypassPermissions","plan"],E=(c.indexOf(P)+1)%c.length,N=c[E];O(N),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,N)};return t?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
74
74
  details[open] .details-chevron {
75
75
  transform: rotate(180deg);
76
76
  }
77
- `}),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:Te,onWheel:Ut,onTouchMove:Ut,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:[ge&&le.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:"正在加载会话消息..."})]})}):le.length===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[!r&&!L&&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(ot,{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:gt,onChange:c=>{const k=c.target.value;as(k),localStorage.setItem("claude-model",k)},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:Ps.OPTIONS.map(({value:c,label:k})=>e.jsx("option",{value:c,children:k},c))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["已准备好使用 Claude ",gt,"。请在下方输入您的消息。"]})]}),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:[Le&&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:"正在加载历史消息..."})]})}),Se&&!Le&&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:Ie>0&&e.jsxs("span",{children:["显示 ",ie.length," 条 / 共 ",Ie," 条消息 •",e.jsx("span",{className:"text-xs",children:"向上滚动加载更多"})]})}),!Se&&le.length>Wt&&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:["显示最近 ",Wt," 条消息(共 ",le.length," 条) •",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:ya,children:"加载更早的消息"})]}),ls.map((c,k)=>{const E=k>0?ls[k-1]:null,N=c.id||`${c.type}-${c.timestamp?.getTime?.()||k}-${k}`;return e.jsx(Go,{message:c,index:k,prevMessage:E,createDiff:xa,onFileOpen:l,onShowSettings:h,onGrantToolPermission:cs,autoExpandTools:z,showRawParameters:$,showThinking:D,selectedProject:t,provider:dt},N)})]}),ne&&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(ot,{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:re})]}),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(_o,{status:ca,isLoading:ne,onAbort:La,provider:dt,showThinking:D})}),e.jsxs("div",{ref:qe,className:"max-w-4xl mx-auto mb-3",children:[F.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:F.map(c=>{const k=Rs(c.input),E=Hr(c.toolName,k),N=Yr(),R=E?N.allowedTools.includes(E):!1,V=R?"已允许(已保存)":"允许并记住",me=E?F.filter(q=>Hr(q.toolName,Rs(q.input))===E).map(q=>q.requestId):[c.requestId];return c.toolName==="AskUserQuestion"?e.jsx(Ko,{request:c,onSubmit:q=>{Ht(c.requestId,{allow:!0,updatedInput:{...c.input,answers:q}})},onSkip:()=>Ht(c.requestId,{allow:!1,message:"用户跳过问题"})},c.requestId):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:c.toolName})]})]}),E&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["允许规则: ",e.jsx("span",{className:"font-mono",children:E})]})]}),k&&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:k})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ht(c.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:()=>{E&&!R&&cs({entry:E,toolName:c.toolName}),Ht(me,{allow:!0,rememberEntry:E})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${E?"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:!E,children:V}),e.jsx("button",{type:"button",onClick:()=>Ht(c.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:"拒绝"})]})]},c.requestId)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",onClick:Ia,className:`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${P==="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":P==="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":P==="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 ${P==="default"?"bg-gray-500":P==="acceptEdits"?"bg-green-500":P==="bypassPermissions"?"bg-orange-500":"bg-blue-500"}`}),e.jsxs("span",{children:[P==="default"&&"默认模式",P==="acceptEdits"&&"接受编辑",P==="bypassPermissions"&&"跳过权限",P==="plan"&&"计划模式"]})]})}),e.jsxs("button",{type:"button",onClick:()=>{const c=!ke;Ve(c),lt(""),ct(-1),c&&Yt(Fe),M.current&&M.current.focus()},disabled:w&&!w.allowed,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 disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"显示所有命令",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"})}),Fe.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:Fe.length})]}),W.trim()&&e.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),Z(""),M.current&&(M.current.style.height="auto",M.current.focus()),pt(!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"})})}),T&&le.length>0&&e.jsx("button",{onClick:mt,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:vt,className:"relative max-w-4xl mx-auto",children:[Na&&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:"将图片拖放到这里"})]})}),H.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:H.map((c,k)=>e.jsx(Vo,{file:c,onRemove:()=>{de(E=>E.filter((N,R)=>R!==k))},uploadProgress:Me.get(c.name),error:Ke.get(c.name)},k))})}),Nt&&at.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:at.map((c,k)=>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 ${k===_t?"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:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.preventDefault(),E.stopPropagation(),wr(c)},children:[e.jsx("div",{className:"font-medium text-sm",children:c.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:c.path})]},c.path))}),e.jsx(Bo,{commands:yt,selectedIndex:yr,onSelect:ma,onClose:()=>{Ve(!1),xt(-1),lt(""),ct(-1)},position:{top:M.current?Math.max(16,M.current.getBoundingClientRect().top-316):0,left:M.current?M.current.getBoundingClientRect().left:16,bottom:M.current?window.innerHeight-M.current.getBoundingClientRect().top+8:90},isOpen:ke,frequentCommands:Qt?[]:da}),e.jsxs("div",{...wa(),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 ${ia?"chat-input-expanded":""}`,children:[e.jsx("input",{...ka()}),e.jsx("textarea",{ref:M,value:W,onChange:Ea,onClick:Ma,onKeyDown:Ca,onPaste:ja,onFocus:()=>he(!0),onBlur:()=>he(!1),onInput:c=>{c.target.style.height="auto",c.target.style.height=c.target.scrollHeight+"px",St(c.target.selectionStart);const k=parseInt(window.getComputedStyle(c.target).lineHeight),E=c.target.scrollHeight>k*2;pt(E)},placeholder:w&&!w.allowed?w.reason==="total_limit_exceeded"?"使用上限已达到,请联系管理员":"今日使用上限已达到":"输入 / 使用命令,@ 引用文件,或向 Claude 提问...",disabled:ne||w&&!w.allowed,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:Sa,disabled:w&&!w.allowed,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 disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"添加图片",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:De,onChange:va,className:"hidden",multiple:!0}),e.jsx("button",{type:"button",onClick:()=>De.current?.click(),disabled:A||!t||w&&!w.allowed,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 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"上传文件并引用",children:A?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(Wo,{onTranscript:ba,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!W.trim()||ne,onMouseDown:c=>{c.preventDefault(),vt(c)},onTouchStart:c=>{c.preventDefault(),vt(c)},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 ${W.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 Qo=et.memo(Yo);function qr({file:t,onClose:r,projectPath:a,isSidebar:o=!1,isExpanded:n=!1,onToggleExpand:l=null}){const[i,m]=s.useState(""),[g,x]=s.useState(!0),[b,S]=s.useState(!1),[v,y]=s.useState(!1),[h,z]=s.useState(()=>{const U=localStorage.getItem("codeEditorTheme");return U?U==="dark":!0}),[$,D]=s.useState(!1),[C,p]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[d,j]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[w,I]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),B=s.useRef(null),W=s.useMemo(()=>{const U=()=>{const L=document.createElement("div");L.className="cm-editor-toolbar-panel";const _=()=>{let Q='<div style="display: flex; align-items: center; justify-content: flex-end; width: 100%;">';Q+='<div style="display: flex; align-items: center; gap: 4px;">',Q+=`
77
+ `}),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:Te,onWheel:Ut,onTouchMove:Ut,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:[ge&&le.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:"正在加载会话消息..."})]})}):le.length===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[!r&&!I&&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(ot,{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:gt,onChange:c=>{const k=c.target.value;as(k),localStorage.setItem("claude-model",k)},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:Ps.OPTIONS.map(({value:c,label:k})=>e.jsx("option",{value:c,children:k},c))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["已准备好使用 Claude ",gt,"。请在下方输入您的消息。"]})]}),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:[Le&&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:"正在加载历史消息..."})]})}),Se&&!Le&&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:Ie>0&&e.jsxs("span",{children:["显示 ",ie.length," 条 / 共 ",Ie," 条消息 •",e.jsx("span",{className:"text-xs",children:"向上滚动加载更多"})]})}),!Se&&le.length>Wt&&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:["显示最近 ",Wt," 条消息(共 ",le.length," 条) •",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:ya,children:"加载更早的消息"})]}),ls.map((c,k)=>{const E=k>0?ls[k-1]:null,N=c.id||`${c.type}-${c.timestamp?.getTime?.()||k}-${k}`;return e.jsx(Go,{message:c,index:k,prevMessage:E,createDiff:xa,onFileOpen:l,onShowSettings:h,onGrantToolPermission:cs,autoExpandTools:z,showRawParameters:$,showThinking:D,selectedProject:t,provider:dt},N)})]}),ne&&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(ot,{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:se})]}),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(_o,{status:ca,isLoading:ne,onAbort:La,provider:dt,showThinking:D})}),e.jsxs("div",{ref:qe,className:"max-w-4xl mx-auto mb-3",children:[F.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:F.map(c=>{const k=Rs(c.input),E=Hr(c.toolName,k),N=Yr(),R=E?N.allowedTools.includes(E):!1,V=R?"已允许(已保存)":"允许并记住",me=E?F.filter(q=>Hr(q.toolName,Rs(q.input))===E).map(q=>q.requestId):[c.requestId];return c.toolName==="AskUserQuestion"?e.jsx(Ko,{request:c,onSubmit:q=>{Ht(c.requestId,{allow:!0,updatedInput:{...c.input,answers:q}})},onSkip:()=>Ht(c.requestId,{allow:!1,message:"用户跳过问题"})},c.requestId):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:c.toolName})]})]}),E&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["允许规则: ",e.jsx("span",{className:"font-mono",children:E})]})]}),k&&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:k})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ht(c.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:()=>{E&&!R&&cs({entry:E,toolName:c.toolName}),Ht(me,{allow:!0,rememberEntry:E})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${E?"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:!E,children:V}),e.jsx("button",{type:"button",onClick:()=>Ht(c.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:"拒绝"})]})]},c.requestId)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",onClick:Ia,className:`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${P==="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":P==="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":P==="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 ${P==="default"?"bg-gray-500":P==="acceptEdits"?"bg-green-500":P==="bypassPermissions"?"bg-orange-500":"bg-blue-500"}`}),e.jsxs("span",{children:[P==="default"&&"默认模式",P==="acceptEdits"&&"接受编辑",P==="bypassPermissions"&&"跳过权限",P==="plan"&&"计划模式"]})]})}),e.jsxs("button",{type:"button",onClick:()=>{const c=!ke;Ve(c),lt(""),ct(-1),c&&Yt(Fe),M.current&&M.current.focus()},disabled:w&&!w.allowed,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 disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"显示所有命令",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"})}),Fe.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:Fe.length})]}),W.trim()&&e.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),Z(""),M.current&&(M.current.style.height="auto",M.current.focus()),pt(!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"})})}),T&&le.length>0&&e.jsx("button",{onClick:mt,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:vt,className:"relative max-w-4xl mx-auto",children:[Na&&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:"将图片拖放到这里"})]})}),H.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:H.map((c,k)=>e.jsx(Vo,{file:c,onRemove:()=>{de(E=>E.filter((N,R)=>R!==k))},uploadProgress:Me.get(c.name),error:Ke.get(c.name)},k))})}),Nt&&at.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:at.map((c,k)=>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 ${k===_t?"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:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.preventDefault(),E.stopPropagation(),wr(c)},children:[e.jsx("div",{className:"font-medium text-sm",children:c.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:c.path})]},c.path))}),e.jsx(Bo,{commands:yt,selectedIndex:yr,onSelect:ma,onClose:()=>{Ve(!1),xt(-1),lt(""),ct(-1)},position:{top:M.current?Math.max(16,M.current.getBoundingClientRect().top-316):0,left:M.current?M.current.getBoundingClientRect().left:16,bottom:M.current?window.innerHeight-M.current.getBoundingClientRect().top+8:90},isOpen:ke,frequentCommands:Qt?[]:da}),e.jsxs("div",{...wa(),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 ${ia?"chat-input-expanded":""}`,children:[e.jsx("input",{...ka()}),e.jsx("textarea",{ref:M,value:W,onChange:Ea,onClick:Ma,onKeyDown:Ca,onPaste:ja,onFocus:()=>he(!0),onBlur:()=>he(!1),onInput:c=>{c.target.style.height="auto",c.target.style.height=c.target.scrollHeight+"px",St(c.target.selectionStart);const k=parseInt(window.getComputedStyle(c.target).lineHeight),E=c.target.scrollHeight>k*2;pt(E)},placeholder:w&&!w.allowed?w.reason==="total_limit_exceeded"?"使用上限已达到,请联系管理员":"今日使用上限已达到":"输入 / 使用命令,@ 引用文件,或向 Claude 提问...",disabled:ne||w&&!w.allowed,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:Sa,disabled:w&&!w.allowed,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 disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"添加图片",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:De,onChange:va,className:"hidden",multiple:!0}),e.jsx("button",{type:"button",onClick:()=>De.current?.click(),disabled:A||!t||w&&!w.allowed,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 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"上传文件并引用",children:A?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(Wo,{onTranscript:ba,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!W.trim()||ne,onMouseDown:c=>{c.preventDefault(),vt(c)},onTouchStart:c=>{c.preventDefault(),vt(c)},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 ${W.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 Qo=et.memo(Yo);function qr({file:t,onClose:r,projectPath:a,isSidebar:o=!1,isExpanded:n=!1,onToggleExpand:l=null}){const[i,m]=s.useState(""),[g,x]=s.useState(!0),[b,S]=s.useState(!1),[v,y]=s.useState(!1),[h,z]=s.useState(()=>{const U=localStorage.getItem("codeEditorTheme");return U?U==="dark":!0}),[$,D]=s.useState(!1),[C,p]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[d,j]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[w,L]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),B=s.useRef(null),W=s.useMemo(()=>{const U=()=>{const I=document.createElement("div");I.className="cm-editor-toolbar-panel";const _=()=>{let Q='<div style="display: flex; align-items: center; justify-content: flex-end; width: 100%;">';Q+='<div style="display: flex; align-items: center; gap: 4px;">',Q+=`
78
78
  <button class="cm-toolbar-btn cm-settings-btn" title="Editor Settings">
79
79
  <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
80
80
  <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" />
@@ -86,9 +86,9 @@ ${ee}`:ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0
86
86
  ${n?'<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" />'}
87
87
  </svg>
88
88
  </button>
89
- `),Q+="</div>",Q+="</div>",L.innerHTML=Q,L.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&l&&L.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{l()})};return _(),{top:!0,dom:L,update:_}};return[Da.of(U)]},[o,n,l]),Z=U=>{const L=U.split(".").pop()?.toLowerCase();switch(L){case"js":case"jsx":case"ts":case"tsx":return[Fa({jsx:!0,typescript:L.includes("ts")})];case"py":return[_a()];case"html":case"htm":return[Oa()];case"css":case"scss":case"less":return[Aa()];case"json":return[$a()];case"md":case"markdown":return[za()];default:return[]}};s.useEffect(()=>{(async()=>{try{x(!0);const L=await be.readFile(t.projectName,t.path);if(!L.ok)throw new Error(`Failed to load file: ${L.status} ${L.statusText}`);const _=await L.json();m(_.content)}catch(L){console.error("Error loading file:",L),m(`// Error loading file: ${L.message}
89
+ `),Q+="</div>",Q+="</div>",I.innerHTML=Q,I.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&l&&I.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{l()})};return _(),{top:!0,dom:I,update:_}};return[Da.of(U)]},[o,n,l]),Z=U=>{const I=U.split(".").pop()?.toLowerCase();switch(I){case"js":case"jsx":case"ts":case"tsx":return[Fa({jsx:!0,typescript:I.includes("ts")})];case"py":return[_a()];case"html":case"htm":return[Oa()];case"css":case"scss":case"less":return[Aa()];case"json":return[$a()];case"md":case"markdown":return[za()];default:return[]}};s.useEffect(()=>{(async()=>{try{x(!0);const I=await be.readFile(t.projectName,t.path);if(!I.ok)throw new Error(`Failed to load file: ${I.status} ${I.statusText}`);const _=await I.json();m(_.content)}catch(I){console.error("Error loading file:",I),m(`// Error loading file: ${I.message}
90
90
  // File: ${t.name}
91
- // Path: ${t.path}`)}finally{x(!1)}})()},[t,a]);const le=async()=>{S(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:i?.length});const U=await be.saveFile(t.projectName,t.path,i);if(console.log("Save response:",{status:U.status,ok:U.ok,contentType:U.headers.get("content-type")}),!U.ok){const _=U.headers.get("content-type");if(_&&_.includes("application/json")){const Q=await U.json();throw new Error(Q.error||`Save failed: ${U.status}`)}else{const Q=await U.text();throw console.error("Non-JSON error response:",Q),new Error(`Save failed: ${U.status} ${U.statusText}`)}}const L=await U.json();console.log("Save successful:",L),D(!0),setTimeout(()=>D(!1),2e3)}catch(U){console.error("Error saving file:",U),alert(`Error saving file: ${U.message}`)}finally{S(!1)}},X=()=>{const U=new Blob([i],{type:"text/plain"}),L=URL.createObjectURL(U),_=document.createElement("a");_.href=L,_.download=t.name,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(L)},ne=()=>{y(!v)};return s.useEffect(()=>{localStorage.setItem("codeEditorTheme",h?"dark":"light")},[h]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",C.toString())},[C]),s.useEffect(()=>{const U=()=>{const L=localStorage.getItem("codeEditorTheme");L&&z(L==="dark");const _=localStorage.getItem("codeEditorWordWrap");_!==null&&p(_==="true");const Q=localStorage.getItem("codeEditorLineNumbers");Q!==null&&j(Q!=="false");const he=localStorage.getItem("codeEditorFontSize");he&&I(he)};return window.addEventListener("storage",U),window.addEventListener("codeEditorSettingsChanged",U),()=>{window.removeEventListener("storage",U),window.removeEventListener("codeEditorSettingsChanged",U)}},[]),s.useEffect(()=>{const U=L=>{(L.ctrlKey||L.metaKey)&&(L.key==="s"?(L.preventDefault(),le()):L.key==="Escape"&&(L.preventDefault(),r()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),g?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
91
+ // Path: ${t.path}`)}finally{x(!1)}})()},[t,a]);const le=async()=>{S(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:i?.length});const U=await be.saveFile(t.projectName,t.path,i);if(console.log("Save response:",{status:U.status,ok:U.ok,contentType:U.headers.get("content-type")}),!U.ok){const _=U.headers.get("content-type");if(_&&_.includes("application/json")){const Q=await U.json();throw new Error(Q.error||`Save failed: ${U.status}`)}else{const Q=await U.text();throw console.error("Non-JSON error response:",Q),new Error(`Save failed: ${U.status} ${U.statusText}`)}}const I=await U.json();console.log("Save successful:",I),D(!0),setTimeout(()=>D(!1),2e3)}catch(U){console.error("Error saving file:",U),alert(`Error saving file: ${U.message}`)}finally{S(!1)}},X=()=>{const U=new Blob([i],{type:"text/plain"}),I=URL.createObjectURL(U),_=document.createElement("a");_.href=I,_.download=t.name,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(I)},ne=()=>{y(!v)};return s.useEffect(()=>{localStorage.setItem("codeEditorTheme",h?"dark":"light")},[h]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",C.toString())},[C]),s.useEffect(()=>{const U=()=>{const I=localStorage.getItem("codeEditorTheme");I&&z(I==="dark");const _=localStorage.getItem("codeEditorWordWrap");_!==null&&p(_==="true");const Q=localStorage.getItem("codeEditorLineNumbers");Q!==null&&j(Q!=="false");const he=localStorage.getItem("codeEditorFontSize");he&&L(he)};return window.addEventListener("storage",U),window.addEventListener("codeEditorSettingsChanged",U),()=>{window.removeEventListener("storage",U),window.removeEventListener("codeEditorSettingsChanged",U)}},[]),s.useEffect(()=>{const U=I=>{(I.ctrlKey||I.metaKey)&&(I.key==="s"?(I.preventDefault(),le()):I.key==="Escape"&&(I.preventDefault(),r()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),g?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
92
92
  .code-editor-loading {
93
93
  background-color: ${h?"#111827":"#ffffff"} !important;
94
94
  }
@@ -122,7 +122,7 @@ ${ee}`:ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0
122
122
  background-color: ${h?"#374151":"#f3f4f6"};
123
123
  }
124
124
  `}),e.jsx("div",{className:o?"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 ${v?"md:p-0":""}`,children:e.jsxs("div",{className:o?"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"+(v?" 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:X,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(Tt,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:le,disabled:b,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 ${$?"bg-green-600 hover:bg-green-700":"bg-blue-600 hover:bg-blue-700"}`,children:$?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(Xa,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:b?"Saving...":"Save"})]})}),!o&&e.jsx("button",{onClick:ne,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:v?"Exit fullscreen":"Fullscreen",children:v?e.jsx(en,{className:"w-4 h-4"}):e.jsx(_s,{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(Ue,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ta,{ref:B,value:i,onChange:m,extensions:[...Z(t.name),...W,...C?[Ra.lineWrapping]:[]],theme:h?Pa:void 0,height:"100%",style:{fontSize:`${w}px`,height:"100%"},basicSetup:{lineNumbers:d,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: ",i.split(`
125
- `).length]}),e.jsxs("span",{children:["Characters: ",i.length]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]})})]})}function Zo({file:t,onClose:r}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=s.useState(null),[l,i]=s.useState(null),[m,g]=s.useState(!0);return s.useEffect(()=>{let x;const b=new AbortController;return(async()=>{try{g(!0),i(null),n(null);const v=await se(a,{signal:b.signal});if(!v.ok)throw new Error(`Request failed with status ${v.status}`);const y=await v.blob();x=URL.createObjectURL(y),n(x)}catch(v){if(v.name==="AbortError")return;console.error("Error loading image:",v),i("无法加载图像")}finally{g(!1)}})(),()=>{b.abort(),x&&URL.revokeObjectURL(x)}},[a]),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(J,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(Ue,{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:[m&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!m&&o&&e.jsx("img",{src:o,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!m&&!o&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:l||"无法加载图像"}),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 Xo({selectedProject:t}){const[r,a]=s.useState([]),[o,n]=s.useState(!1),[l,i]=s.useState(new Set),[m,g]=s.useState(new Set),[x,b]=s.useState(new Set),[S,v]=s.useState(null),[y,h]=s.useState(null),[z,$]=s.useState("detailed"),[D,C]=s.useState(""),[p,d]=s.useState([]),[j,w]=s.useState(!1),[I,B]=s.useState(!1),[W,Z]=s.useState(null),[le,X]=s.useState({}),[ne,U]=s.useState(null);s.useEffect(()=>{t&&(i(new Set),b(new Set),g(new Set),_())},[t]),s.useEffect(()=>{const O=localStorage.getItem("file-tree-view-mode");O&&["simple","detailed","compact"].includes(O)&&$(O)},[]),s.useEffect(()=>{if(!D.trim())d(r);else{const O=L(r,D.toLowerCase());d(O);const F=f=>{f.forEach(H=>{H.type==="directory"&&H.children&&H.children.length>0&&(i(de=>new Set(de.add(H.path))),F(H.children))})};F(O)}},[r,D]);const L=(O,F)=>O.reduce((f,H)=>{const de=H.name.toLowerCase().includes(F);let Me=[];return H.type==="directory"&&H.children&&(Me=L(H.children,F)),(de||Me.length>0)&&f.push({...H,children:Me}),f},[]),_=async()=>{n(!0);try{const O=await be.getFiles(t.name,{depth:1});if(!O.ok){const f=await O.text();console.error("❌ File fetch failed:",O.status,f),a([]);return}const F=await O.json();a(F)}catch(O){console.error("❌ Error fetching files:",O),a([])}finally{n(!1)}},Q=async O=>{if(!(x.has(O)||m.has(O))){g(F=>new Set([...F,O]));try{const F=await be.getFiles(t.name,{dirPath:O,depth:1});if(!F.ok){console.error("Failed to load directory:",O);return}const f=await F.json();a(H=>he(H,O,f)),b(H=>new Set([...H,O]))}catch(F){console.error("Error loading directory:",F)}finally{g(F=>{const f=new Set(F);return f.delete(O),f})}}},he=(O,F,f)=>O.map(H=>H.path===F?{...H,children:f}:H.type==="directory"&&H.children&&H.children.length>0?{...H,children:he(H.children,F,f)}:H),ie=s.useCallback(async O=>{if(!t||O.length===0)return;B(!0),Z(null);const F=new FormData;O.forEach(H=>{F.append("files",H)});const f={};O.forEach(H=>{f[H.name]=0}),X(f);try{const H=await be.uploadFiles(t.name,F);if(!H.ok){const Me=await H.json();throw new Error(Me.error||"Upload failed")}const de={};O.forEach(Me=>{de[Me.name]=100}),X(de),await _(),setTimeout(()=>{w(!1),X({})},1e3)}catch(H){console.error("Upload failed:",H),Z(H.message)}finally{B(!1)}},[t]),{getRootProps:Y,getInputProps:ge,isDragActive:Ne,open:Le}=Vr({onDrop:ie,noClick:!0,noKeyboard:!0}),je=async O=>{if(t)try{const F=await be.deleteFile(t.name,O);if(!F.ok){const f=await F.json();throw new Error(f.error||"Delete failed")}await _(),U(null)}catch(F){console.error("Delete failed:",F),alert(`Failed to delete: ${F.message}`)}},Oe=async(O,F)=>{const f=new Set(l);f.has(O)?f.delete(O):(f.add(O),F&&!x.has(O)&&await Q(O)),i(f)},pe=O=>{$(O),localStorage.setItem("file-tree-view-mode",O)},Se=O=>{if(!O||O===0)return"0 B";const F=1024,f=["B","KB","MB","GB"],H=Math.floor(Math.log(O)/Math.log(F));return parseFloat((O/Math.pow(F,H)).toFixed(1))+" "+f[H]},we=O=>{if(!O)return"-";const F=new Date,f=new Date(O),H=Math.floor((F-f)/1e3);return H<60?"just now":H<3600?`${Math.floor(H/60)} min ago`:H<86400?`${Math.floor(H/3600)} hours ago`:H<2592e3?`${Math.floor(H/86400)} days ago`:f.toLocaleDateString()},Ie=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("w-full flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?Ie(f.children,F+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:"空文件夹"})})]},f.path)}),xe=O=>{const F=O.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(F)},Ce=O=>{const F=O.toLowerCase(),f=["dockerfile","makefile","gemfile","rakefile","procfile","vagrantfile","jenkinsfile"];if(!O.includes("."))return f.includes(F);const H=O.split(".").pop()?.toLowerCase();return new Set(["js","jsx","ts","tsx","mjs","cjs","py","pyw","pyi","java","kt","kts","scala","groovy","cpp","cxx","cc","c","h","hpp","hxx","cs","fs","fsx","go","rs","swift","php","rb","lua","pl","pm","r","dart","elm","clj","cljs","ex","exs","sh","bash","zsh","fish","ps1","bat","cmd","html","htm","xhtml","css","scss","sass","less","vue","svelte","astro","json","json5","jsonc","yaml","yml","toml","ini","cfg","conf","config","env","properties","xml","xsd","xsl","csv","tsv","graphql","gql","proto","sql","md","mdx","markdown","txt","text","rst","adoc","tex","log","lock","gitignore","gitattributes","gitmodules","editorconfig","prettierrc","eslintrc","babelrc","htaccess"]).has(H)},Re=async O=>{try{const F=await be.getFileContent(t.name,O.path);if(!F.ok)throw new Error("Download failed");const f=await F.blob(),H=URL.createObjectURL(f),de=document.createElement("a");de.href=H,de.download=O.name,document.body.appendChild(de),de.click(),document.body.removeChild(de),URL.revokeObjectURL(H)}catch(F){console.error("Download failed:",F)}},Ee=O=>{const F=O.split(".").pop()?.toLowerCase(),f=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],H=["md","txt","doc","pdf"],de=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return f.includes(F)?e.jsx(sn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):H.includes(F)?e.jsx(Ws,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):de.includes(F)?e.jsx(xs,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(xs,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},Be=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("grid grid-cols-12 gap-2 p-2 hover:bg-accent items-center",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:f.type==="file"?Se(f.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:we(f.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:f.permissionsRwx||"-"}),e.jsxs("div",{className:"col-span-1 flex justify-end items-center gap-0.5",children:[f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(F+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):f.children&&f.children.length>0?Be(f.children,F+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},f.path)}),P=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[f.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(f.size)}),e.jsx("span",{className:"font-mono",children:f.permissionsRwx})]}),f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?P(f.children,F+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:"空文件夹"})})]},f.path)});return o?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",{...Y(),className:We("h-full flex flex-col bg-card relative",Ne&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...ge()}),Ne&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>w(!0),title:"上传文件",children:e.jsx(ps,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("simple"),title:"简单视图",children:e.jsx(tn,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("compact"),title:"紧凑视图",children:e.jsx(Fs,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("detailed"),title:"详细视图",children:e.jsx(rn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索文件和文件夹...",value:D,onChange:O=>C(O.target.value),className:"pl-8 pr-8 h-8 text-sm"}),D&&e.jsx(J,{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:()=>C(""),title:"清除搜索",children:e.jsx(Ue,{className:"w-3 h-3"})})]})]}),z==="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(Kr,{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(rt,{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&&D?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(Rt,{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:z==="detailed"?"":"space-y-1",children:[z==="simple"&&Ie(p),z==="compact"&&P(p),z==="detailed"&&Be(p)]})}),S&&e.jsx(qr,{file:S,onClose:()=>v(null),projectPath:S.projectPath}),y&&e.jsx(Zo,{file:y,onClose:()=>h(null)}),j&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{w(!1),Z(null),X({})},children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:Le,className:We("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(ps,{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(le).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(le).map(([O,F])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:O}),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:`${F}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[F,"%"]})]},O))}),W&&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:W})}),I&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),ne&&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:["确定要删除",ne.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',ne.name,'"']}),"?",ne.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{variant:"outline",size:"sm",onClick:()=>U(null),children:"取消"}),e.jsx(J,{variant:"destructive",size:"sm",onClick:()=>je(ne.path),children:"删除"})]})]})})]})}var Qr=Cn(),Zr=En(),Xr=Mn(),es=Ln();const ei=`
125
+ `).length]}),e.jsxs("span",{children:["Characters: ",i.length]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]})})]})}function Zo({file:t,onClose:r}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=s.useState(null),[l,i]=s.useState(null),[m,g]=s.useState(!0);return s.useEffect(()=>{let x;const b=new AbortController;return(async()=>{try{g(!0),i(null),n(null);const v=await re(a,{signal:b.signal});if(!v.ok)throw new Error(`Request failed with status ${v.status}`);const y=await v.blob();x=URL.createObjectURL(y),n(x)}catch(v){if(v.name==="AbortError")return;console.error("Error loading image:",v),i("无法加载图像")}finally{g(!1)}})(),()=>{b.abort(),x&&URL.revokeObjectURL(x)}},[a]),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(J,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(Ue,{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:[m&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!m&&o&&e.jsx("img",{src:o,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!m&&!o&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:l||"无法加载图像"}),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 Xo({selectedProject:t}){const[r,a]=s.useState([]),[o,n]=s.useState(!1),[l,i]=s.useState(new Set),[m,g]=s.useState(new Set),[x,b]=s.useState(new Set),[S,v]=s.useState(null),[y,h]=s.useState(null),[z,$]=s.useState("detailed"),[D,C]=s.useState(""),[p,d]=s.useState([]),[j,w]=s.useState(!1),[L,B]=s.useState(!1),[W,Z]=s.useState(null),[le,X]=s.useState({}),[ne,U]=s.useState(null);s.useEffect(()=>{t&&(i(new Set),b(new Set),g(new Set),_())},[t]),s.useEffect(()=>{const O=localStorage.getItem("file-tree-view-mode");O&&["simple","detailed","compact"].includes(O)&&$(O)},[]),s.useEffect(()=>{if(!D.trim())d(r);else{const O=I(r,D.toLowerCase());d(O);const F=f=>{f.forEach(H=>{H.type==="directory"&&H.children&&H.children.length>0&&(i(de=>new Set(de.add(H.path))),F(H.children))})};F(O)}},[r,D]);const I=(O,F)=>O.reduce((f,H)=>{const de=H.name.toLowerCase().includes(F);let Me=[];return H.type==="directory"&&H.children&&(Me=I(H.children,F)),(de||Me.length>0)&&f.push({...H,children:Me}),f},[]),_=async()=>{n(!0);try{const O=await be.getFiles(t.name,{depth:1});if(!O.ok){const f=await O.text();console.error("❌ File fetch failed:",O.status,f),a([]);return}const F=await O.json();a(F)}catch(O){console.error("❌ Error fetching files:",O),a([])}finally{n(!1)}},Q=async O=>{if(!(x.has(O)||m.has(O))){g(F=>new Set([...F,O]));try{const F=await be.getFiles(t.name,{dirPath:O,depth:1});if(!F.ok){console.error("Failed to load directory:",O);return}const f=await F.json();a(H=>he(H,O,f)),b(H=>new Set([...H,O]))}catch(F){console.error("Error loading directory:",F)}finally{g(F=>{const f=new Set(F);return f.delete(O),f})}}},he=(O,F,f)=>O.map(H=>H.path===F?{...H,children:f}:H.type==="directory"&&H.children&&H.children.length>0?{...H,children:he(H.children,F,f)}:H),ie=s.useCallback(async O=>{if(!t||O.length===0)return;B(!0),Z(null);const F=new FormData;O.forEach(H=>{F.append("files",H)});const f={};O.forEach(H=>{f[H.name]=0}),X(f);try{const H=await be.uploadFiles(t.name,F);if(!H.ok){const Me=await H.json();throw new Error(Me.error||"Upload failed")}const de={};O.forEach(Me=>{de[Me.name]=100}),X(de),await _(),setTimeout(()=>{w(!1),X({})},1e3)}catch(H){console.error("Upload failed:",H),Z(H.message)}finally{B(!1)}},[t]),{getRootProps:Y,getInputProps:ge,isDragActive:Ne,open:Le}=Vr({onDrop:ie,noClick:!0,noKeyboard:!0}),je=async O=>{if(t)try{const F=await be.deleteFile(t.name,O);if(!F.ok){const f=await F.json();throw new Error(f.error||"Delete failed")}await _(),U(null)}catch(F){console.error("Delete failed:",F),alert(`Failed to delete: ${F.message}`)}},Oe=async(O,F)=>{const f=new Set(l);f.has(O)?f.delete(O):(f.add(O),F&&!x.has(O)&&await Q(O)),i(f)},pe=O=>{$(O),localStorage.setItem("file-tree-view-mode",O)},Se=O=>{if(!O||O===0)return"0 B";const F=1024,f=["B","KB","MB","GB"],H=Math.floor(Math.log(O)/Math.log(F));return parseFloat((O/Math.pow(F,H)).toFixed(1))+" "+f[H]},we=O=>{if(!O)return"-";const F=new Date,f=new Date(O),H=Math.floor((F-f)/1e3);return H<60?"just now":H<3600?`${Math.floor(H/60)} min ago`:H<86400?`${Math.floor(H/3600)} hours ago`:H<2592e3?`${Math.floor(H/86400)} days ago`:f.toLocaleDateString()},Ie=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("w-full flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?Ie(f.children,F+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:"空文件夹"})})]},f.path)}),xe=O=>{const F=O.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(F)},Ce=O=>{const F=O.toLowerCase(),f=["dockerfile","makefile","gemfile","rakefile","procfile","vagrantfile","jenkinsfile"];if(!O.includes("."))return f.includes(F);const H=O.split(".").pop()?.toLowerCase();return new Set(["js","jsx","ts","tsx","mjs","cjs","py","pyw","pyi","java","kt","kts","scala","groovy","cpp","cxx","cc","c","h","hpp","hxx","cs","fs","fsx","go","rs","swift","php","rb","lua","pl","pm","r","dart","elm","clj","cljs","ex","exs","sh","bash","zsh","fish","ps1","bat","cmd","html","htm","xhtml","css","scss","sass","less","vue","svelte","astro","json","json5","jsonc","yaml","yml","toml","ini","cfg","conf","config","env","properties","xml","xsd","xsl","csv","tsv","graphql","gql","proto","sql","md","mdx","markdown","txt","text","rst","adoc","tex","log","lock","gitignore","gitattributes","gitmodules","editorconfig","prettierrc","eslintrc","babelrc","htaccess"]).has(H)},Re=async O=>{try{const F=await be.getFileContent(t.name,O.path);if(!F.ok)throw new Error("Download failed");const f=await F.blob(),H=URL.createObjectURL(f),de=document.createElement("a");de.href=H,de.download=O.name,document.body.appendChild(de),de.click(),document.body.removeChild(de),URL.revokeObjectURL(H)}catch(F){console.error("Download failed:",F)}},Ee=O=>{const F=O.split(".").pop()?.toLowerCase(),f=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],H=["md","txt","doc","pdf"],de=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return f.includes(F)?e.jsx(sn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):H.includes(F)?e.jsx(Ws,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):de.includes(F)?e.jsx(xs,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(xs,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},Be=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("grid grid-cols-12 gap-2 p-2 hover:bg-accent items-center",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:f.type==="file"?Se(f.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:we(f.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:f.permissionsRwx||"-"}),e.jsxs("div",{className:"col-span-1 flex justify-end items-center gap-0.5",children:[f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(F+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):f.children&&f.children.length>0?Be(f.children,F+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},f.path)}),P=(O,F=0)=>O.map(f=>{const H=m.has(f.path),de=l.has(f.path),Me=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:We("flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||xe(f.name)||Ce(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${F*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Me):xe(f.name)?h({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Ce(f.name)&&v({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Me?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Ee(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Me&&!de&&!H&&e.jsx(Dt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[f.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(f.size)}),e.jsx("span",{className:"font-mono",children:f.permissionsRwx})]}),f.type==="file"&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),Re(f)},title:"下载文件",children:e.jsx(Tt,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:$e=>{$e.stopPropagation(),U({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?P(f.children,F+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(F+1)*16+12}px`},children:"空文件夹"})})]},f.path)});return o?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",{...Y(),className:We("h-full flex flex-col bg-card relative",Ne&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...ge()}),Ne&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>w(!0),title:"上传文件",children:e.jsx(ps,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("simple"),title:"简单视图",children:e.jsx(tn,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("compact"),title:"紧凑视图",children:e.jsx(Fs,{className:"w-4 h-4"})}),e.jsx(J,{variant:z==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>pe("detailed"),title:"详细视图",children:e.jsx(rn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索文件和文件夹...",value:D,onChange:O=>C(O.target.value),className:"pl-8 pr-8 h-8 text-sm"}),D&&e.jsx(J,{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:()=>C(""),title:"清除搜索",children:e.jsx(Ue,{className:"w-3 h-3"})})]})]}),z==="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(Kr,{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(rt,{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&&D?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(Rt,{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:z==="detailed"?"":"space-y-1",children:[z==="simple"&&Ie(p),z==="compact"&&P(p),z==="detailed"&&Be(p)]})}),S&&e.jsx(qr,{file:S,onClose:()=>v(null),projectPath:S.projectPath}),y&&e.jsx(Zo,{file:y,onClose:()=>h(null)}),j&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{w(!1),Z(null),X({})},children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:Le,className:We("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(ps,{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(le).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(le).map(([O,F])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:O}),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:`${F}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[F,"%"]})]},O))}),W&&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:W})}),L&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),ne&&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:["确定要删除",ne.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',ne.name,'"']}),"?",ne.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{variant:"outline",size:"sm",onClick:()=>U(null),children:"取消"}),e.jsx(J,{variant:"destructive",size:"sm",onClick:()=>je(ne.path),children:"删除"})]})]})})]})}var Qr=Cn(),Zr=En(),Xr=Mn(),es=Ln();const ei=`
126
126
  .xterm .xterm-screen {
127
127
  outline: none !important;
128
128
  }
@@ -132,7 +132,7 @@ ${ee}`:ee:Pe.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0
132
132
  .xterm-screen:focus {
133
133
  outline: none !important;
134
134
  }
135
- `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=ei,document.head.appendChild(t)}function ti({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:l=!1,autoConnect:i=!1}){const m=s.useRef(null),g=s.useRef(null),x=s.useRef(null),b=s.useRef(null),[S,v]=s.useState(!1),[y,h]=s.useState(!1),[z,$]=s.useState(!1),[D,C]=s.useState(null),[p,d]=s.useState(!1),j=s.useRef(t),w=s.useRef(r),I=s.useRef(a),B=s.useRef(o),W=s.useRef(n);s.useEffect(()=>{j.current=t,w.current=r,I.current=a,B.current=o,W.current=n});const Z=s.useCallback(async()=>{if(!(p||S))try{let he;{const ie=localStorage.getItem("auth-token");if(!ie){console.error("No authentication token found for Shell WebSocket connection");return}he=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ie)}`}b.current=new WebSocket(he),b.current.onopen=()=>{v(!0),d(!1),setTimeout(()=>{x.current&&g.current&&(x.current.fit(),b.current.send(JSON.stringify({type:"init",projectPath:j.current.fullPath||j.current.path,sessionId:B.current?null:w.current?.id,hasSession:B.current?!1:!!w.current,provider:B.current?"plain-shell":w.current?.__provider||"claude",cols:g.current.cols,rows:g.current.rows,initialCommand:I.current,isPlainShell:B.current})))},100)},b.current.onmessage=ie=>{try{const Y=JSON.parse(ie.data);if(Y.type==="output"){let ge=Y.data;if(B.current&&W.current){const Ne=ge.replace(/\x1b\[[0-9;]*m/g,"");if(Ne.includes("Process exited with code 0"))W.current(0);else if(Ne.match(/Process exited with code (\d+)/)){const Le=parseInt(Ne.match(/Process exited with code (\d+)/)[1]);Le!==0&&W.current(Le)}}g.current&&g.current.write(ge)}else Y.type==="url_open"&&window.open(Y.url,"_blank")}catch(Y){console.error("[Shell] Error handling WebSocket message:",Y,ie.data)}},b.current.onclose=ie=>{v(!1),d(!1),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H"))},b.current.onerror=ie=>{v(!1),d(!1)}}catch{v(!1),d(!1)}},[p,S]),le=s.useCallback(()=>{!y||S||p||(d(!0),Z())},[y,S,p,Z]),X=s.useCallback(()=>{b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H")),v(!1),d(!1)},[]),ne=s.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),U=s.useMemo(()=>ne?ne.slice(0,30):null,[ne]),L=s.useMemo(()=>ne?ne.slice(0,50):null,[ne]),_=()=>{$(!0),b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),g.current&&(g.current.dispose(),g.current=null,x.current=null),v(!1),h(!1),setTimeout(()=>{$(!1)},200)};return s.useEffect(()=>{const Q=r?.id||null;D!==null&&D!==Q&&y&&X(),C(Q)},[r?.id,y,X]),s.useEffect(()=>{if(!m.current||!t||z||g.current)return;g.current=new Qr.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"]}}),x.current=new Zr.FitAddon;const Q=new Xr.WebglAddon,he=new es.WebLinksAddon;g.current.loadAddon(x.current),g.current.loadAddon(he);try{g.current.loadAddon(Q)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}g.current.open(m.current),g.current.attachCustomKeyEventHandler(Y=>(Y.ctrlKey||Y.metaKey)&&Y.key==="c"&&g.current.hasSelection()?(document.execCommand("copy"),!1):(Y.ctrlKey||Y.metaKey)&&Y.key==="v"?(navigator.clipboard.readText().then(ge=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:ge}))}).catch(()=>{}),!1):!0),setTimeout(()=>{x.current&&(x.current.fit(),g.current&&b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows})))},100),h(!0),g.current.onData(Y=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:Y}))});const ie=new ResizeObserver(()=>{x.current&&g.current&&setTimeout(()=>{x.current.fit(),b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows}))},50)});return m.current&&ie.observe(m.current),()=>{ie.disconnect(),b.current&&(b.current.readyState===WebSocket.OPEN||b.current.readyState===WebSocket.CONNECTING)&&b.current.close(),b.current=null,g.current&&(g.current.dispose(),g.current=null)}},[t?.path||t?.fullPath,z]),s.useEffect(()=>{!i||!y||p||S||le()},[i,y,p,S,le]),t?l?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:m,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 ${S?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",U,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!y&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),z&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[S&&e.jsxs("button",{onClick:X,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:_,disabled:z||S,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:m,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!y&&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:"加载终端中..."})}),y&&!S&&!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:le,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:o?`Run ${a||"command"} in ${t.displayName}`:r?`Resume session: ${L}...`:"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:o?`Running ${a||"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 ri({project:t,session:r=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:l=null,onClose:i=null,title:m=null,className:g="",showHeader:x=!0,compact:b=!1,minimal:S=!1}){const[v,y]=s.useState(!1),h=o!==null?o:a!==null,z=s.useCallback($=>{y(!0),l&&l($)},[l]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${g}`,children:[!S&&x&&m&&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:m}),v&&e.jsx("span",{className:"text-xs text-green-400",children:"(已完成)"})]}),i&&e.jsx("button",{onClick:i,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(ti,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:h,onProcessComplete:z,minimal:S,autoConnect:S?!0:n})})]}):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 需要一个项目"})]})})}function si({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(!1),[y,h]=s.useState(!1),z=s.useRef(t);s.useEffect(()=>{z.current=t});const $=s.useCallback(async()=>{if(!(y||m))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Codex WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{g(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:z.current.fullPath||z.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const I=JSON.parse(w.data);I.type==="output"?n.current&&n.current.write(I.data):I.type==="url_open"&&window.open(I.url,"_blank")}catch(I){console.error("[CodexShell] Error handling WebSocket message:",I)}},i.current.onclose=()=>{g(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{g(!1),h(!1)}}catch{g(!1),h(!1)}},[y,m]),D=s.useCallback(()=>{!x||m||y||(h(!0),$())},[x,m,y,$]),C=s.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),g(!1),h(!1)},[]),p=()=>{v(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),g(!1),b(!1),setTimeout(()=>v(!1),200)};return s.useEffect(()=>{if(!o.current||!t||S||n.current)return;n.current=new Qr.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"}}),l.current=new Zr.FitAddon;const d=new Xr.WebglAddon,j=new es.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(d)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(I=>(I.ctrlKey||I.metaKey)&&I.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(I.ctrlKey||I.metaKey)&&I.key==="v"?(navigator.clipboard.readText().then(B=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:B}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),b(!0),n.current.onData(I=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:I}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,S]),s.useEffect(()=>{!a||!x||y||m||D()},[a,x,y,m,D]),t?r?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,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 ${m?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Codex"}),!x&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),S&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[m&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Codex 连接",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:p,disabled:S||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Codex(先断开连接)",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:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&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:"加载终端中..."})}),x&&!m&&!y&&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:D,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",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:"启动 Codex"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Codex CLI"]})]})}),y&&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:"连接到 Codex..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Codex CLI"]})]})})]})]}):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:"选择一个项目以在该目录中打开 Codex"})]})})}function ai({project:t,autoConnect:r=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&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.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Codex"}),e.jsx("button",{onClick:a,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(si,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,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:"打开 Codex 需要一个项目"})]})})}function ni({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(!1),[y,h]=s.useState(!1),z=s.useRef(t);s.useEffect(()=>{z.current=t});const $=s.useCallback(async()=>{if(!(y||m))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Gemini WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/gemini?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{g(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:z.current.fullPath||z.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const I=JSON.parse(w.data);I.type==="output"?n.current&&n.current.write(I.data):I.type==="url_open"&&window.open(I.url,"_blank")}catch(I){console.error("[GeminiShell] Error handling WebSocket message:",I)}},i.current.onclose=()=>{g(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{g(!1),h(!1)}}catch{g(!1),h(!1)}},[y,m]),D=s.useCallback(()=>{!x||m||y||(h(!0),$())},[x,m,y,$]),C=s.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),g(!1),h(!1)},[]),p=()=>{v(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),g(!1),b(!1),setTimeout(()=>v(!1),200)};return s.useEffect(()=>{if(!o.current||!t||S||n.current)return;n.current=new Qr.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"}}),l.current=new Zr.FitAddon;const d=new Xr.WebglAddon,j=new es.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(d)}catch{console.warn("[GeminiShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(I=>(I.ctrlKey||I.metaKey)&&I.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(I.ctrlKey||I.metaKey)&&I.key==="v"?(navigator.clipboard.readText().then(B=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:B}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),b(!0),n.current.onData(I=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:I}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,S]),s.useEffect(()=>{!a||!x||y||m||D()},[a,x,y,m,D]),t?r?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,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 ${m?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Gemini"}),!x&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),S&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[m&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Gemini 连接",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:p,disabled:S||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Gemini(先断开连接)",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:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&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:"加载终端中..."})}),x&&!m&&!y&&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:D,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",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:"启动 Gemini"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Gemini CLI"]})]})}),y&&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:"连接到 Gemini..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Gemini CLI"]})]})})]})]}):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:"选择一个项目以在该目录中打开 Gemini"})]})})}function oi({project:t,autoConnect:r=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&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.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Gemini"}),e.jsx("button",{onClick:a,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(ni,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,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:"打开 Gemini 需要一个项目"})]})})}class ii extends et.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,a){console.error("ErrorBoundary caught an error:",r,a),this.setState({error:r,errorInfo:a})}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 qt=({children:t,content:r,position:a="top",className:o="",delay:n=500})=>{const[l,i]=s.useState(!1),[m,g]=s.useState(null),x=()=>{const y=setTimeout(()=>{i(!0)},n);g(y)},b=()=>{m&&(clearTimeout(m),g(null)),i(!1)},S=()=>{switch(a){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"}},v=()=>{switch(a){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:x,onMouseLeave:b,children:[t,l&&e.jsxs("div",{className:We("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",S(),o),children:[r,e.jsx("div",{className:We("absolute w-0 h-0 border-4 border-transparent",v())})]})]}):t};function li({selectedProject:t,selectedSession:r,activeTab:a,setActiveTab:o,ws:n,sendMessage:l,messages:i,isMobile:m,isPWA:g,onMenuClick:x,isLoading:b,onInputFocusChange:S,onSessionActive:v,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:z,processingSessions:$,onReplaceTemporarySession:D,onNavigateToSession:C,onShowSettings:p,autoExpandTools:d,showRawParameters:j,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:B,externalMessageUpdate:W,limitStatus:Z,onLimitBlocked:le,checkLimitStatus:X}){const[ne,U]=s.useState(null),[L,_]=s.useState(600),[Q,he]=s.useState(!1),[ie,Y]=s.useState(!1),ge=s.useRef(null);s.useEffect(()=>{a==="shell"&&X&&X()},[a,X]);const Ne=(pe,Se=null)=>{const we={name:pe.split("/").pop(),path:pe,projectName:t?.name,diffInfo:Se};U(we)},Le=()=>{U(null),Y(!1)},je=()=>{Y(!ie)},Oe=pe=>{m||(he(!0),pe.preventDefault())};return s.useEffect(()=>{const pe=we=>{if(!Q)return;const Ie=ge.current?.parentElement;if(!Ie)return;const xe=Ie.getBoundingClientRect(),Ce=xe.right-we.clientX,Re=300,Ee=xe.width*.8;Ce>=Re&&Ce<=Ee&&_(Ce)},Se=()=>{he(!1)};return Q&&(document.addEventListener("mousemove",pe),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[Q]),b?e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:x,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:[m&&e.jsx("button",{onClick:x,onTouchStart:pe=>{pe.preventDefault(),x()},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:[a==="chat"&&r&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ot,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="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})]}):a==="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:a==="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(qt,{content:"Chat",position:"bottom",children:e.jsx("button",{onClick:()=>o("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${a==="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(qt,{content:"Files",position:"bottom",children:e.jsx("button",{onClick:()=>o("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="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.jsx(qt,{content:Z&&!Z.allowed?"使用已达上限":"Claude Code",position:"bottom",children:e.jsx("button",{onClick:()=>{if(Z&&!Z.allowed){le?.(Z.reason);return}o("shell")},className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${Z&&!Z.allowed?"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-500":a==="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",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z",fill:"#D97757",fillRule:"nonzero"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Claude Code"})]})})}),e.jsx(qt,{content:"Codex",position:"bottom",children:e.jsx("button",{onClick:()=>o("codex"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="codex"?"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:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})}),e.jsx(qt,{content:"Gemini CLI",position:"bottom",children:e.jsx("button",{onClick:()=>o("gemini"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="gemini"?"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.jsxs("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-0)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-1)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-2)"}),e.jsxs("defs",{children:[e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[e.jsx("stop",{stopColor:"#08B962"}),e.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[e.jsx("stop",{stopColor:"#F94543"}),e.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[e.jsx("stop",{stopColor:"#FABC12"}),e.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Gemini CLI"})]})})})]})})]})}),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 ${ne?"mr-0":""} ${ie?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(ii,{showDetails:!0,children:e.jsx(Qo,{selectedProject:t,selectedSession:r,ws:n,sendMessage:l,messages:i,onFileOpen:Ne,onInputFocusChange:S,onSessionActive:v,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:z,processingSessions:$,onReplaceTemporarySession:D,onNavigateToSession:C,onShowSettings:p,autoExpandTools:d,showRawParameters:j,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:B,externalMessageUpdate:W,limitStatus:Z,onLimitExceeded:le,checkLimitStatus:X})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Xo,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(ri,{project:t,session:r,showHeader:!1}),Z&&!Z.allowed&&e.jsx("div",{className:"absolute inset-0 bg-black/60 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl p-6 mx-4 max-w-md text-center",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:Z.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:Z.reason==="total_limit_exceeded"?"您已达到使用上限,请联系管理员提升额度。":"您已达到今日使用上限,请明日再来或联系管理员提升额度。"}),e.jsx("button",{onClick:()=>o("chat"),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"返回 Chat"})]})})]}),a==="codex"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ai,{project:t,showHeader:!1})}),a==="gemini"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(oi,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),ne&&!m&&e.jsxs(e.Fragment,{children:[!ie&&e.jsx("div",{ref:ge,onMouseDown:Oe,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 ${ie?"flex-1":""}`,style:ie?{}:{width:`${L}px`},children:e.jsx(qr,{file:ne,onClose:Le,projectPath:t?.path,isSidebar:!0,isExpanded:ie,onToggleExpand:je})})]})]}),ne&&m&&e.jsx(qr,{file:ne,onClose:Le,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:x,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:"提示:"})," ",m?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const ci=et.memo(li);function di({activeTab:t,setActiveTab:r,isInputFocused:a}){const o=[{id:"chat",icon:Pt,onClick:()=>r("chat")},{id:"shell",icon:mr,onClick:()=>r("shell")},{id:"files",icon:rt,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 ${a?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"flex items-center justify-around py-1",children:o.map(n=>{const l=n.icon,i=t===n.id;return e.jsxs("button",{onClick:n.onClick,onTouchStart:m=>{m.preventDefault(),n.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${i?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":n.id,children:[e.jsx(l,{className:"w-5 h-5"}),i&&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"})]},n.id)})})})}const aa=s.createContext(),ts=()=>{const t=s.useContext(aa);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},mi=({children:t})=>{const[r,a]=s.useState(()=>{const l=localStorage.getItem("theme");return l?l==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});s.useEffect(()=>{if(r){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","black-translucent");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#0c1117")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","default");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#ffffff")}},[r]),s.useEffect(()=>{if(!window.matchMedia)return;const l=window.matchMedia("(prefers-color-scheme: dark)"),i=m=>{localStorage.getItem("theme")||a(m.matches)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]);const n={isDarkMode:r,toggleDarkMode:()=>{a(l=>!l)}};return e.jsx(aa.Provider,{value:n,children:t})},na=s.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),Ot=()=>{const t=s.useContext(na);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t};async function Dr(){try{const t=await be.settings.getAgentPermissions();if(t.ok){const r=await t.json();r.agentPermissions&&localStorage.setItem("claude-settings",JSON.stringify(r.agentPermissions))}}catch{}}const ui=({children:t})=>{const[r,a]=s.useState(null),[o,n]=s.useState(localStorage.getItem("auth-token")),[l,i]=s.useState(!0),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(null),[y,h]=s.useState({allowed:!0});s.useEffect(()=>{z()},[]);const z=async()=>{try{i(!0),v(null);const I=await(await be.auth.status()).json();if(b(I.smtpConfigured||!1),I.needsSetup){g(!0),i(!1);return}if(o)try{const B=await be.auth.user();if(B.ok){const W=await B.json();a(W.user),g(!1),await Dr()}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(B){console.error("Token verification failed:",B),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(w){console.error("[AuthContext] Auth status check failed:",w),v("Failed to check authentication status")}finally{i(!1)}},$=async w=>{try{v(null);const I=await be.auth.sendCode(w),B=await I.json();return I.ok?{success:!0,type:B.type}:{success:!1,error:B.error||"发送验证码失败",waitSeconds:B.waitSeconds}}catch(I){return console.error("Send code error:",I),{success:!1,error:"网络错误,请稍后再试"}}},D=async(w,I)=>{try{v(null);const B=await be.auth.verifyCode(w,I),W=await B.json();return B.ok?(n(W.token),a(W.user),g(!1),localStorage.setItem("auth-token",W.token),await Dr(),{success:!0}):(v(W.error||"验证失败"),{success:!1,error:W.error||"验证失败"})}catch(B){return console.error("Verify code error:",B),{success:!1,error:"网络错误,请稍后再试"}}},C=async(w,I)=>{try{v(null);const B=await be.auth.login(w,I),W=await B.json();return B.ok?(n(W.token),a(W.user),localStorage.setItem("auth-token",W.token),await Dr(),{success:!0}):(v(W.error||"登录失败"),{success:!1,error:W.error||"登录失败"})}catch(B){console.error("Login error:",B);const W="网络错误,请稍后再试";return v(W),{success:!1,error:W}}},p=()=>{n(null),a(null),h({allowed:!0}),localStorage.removeItem("auth-token"),o&&be.auth.logout().catch(w=>{console.error("Logout endpoint error:",w)})},d=async()=>{if(!r)return{allowed:!0};try{const w=await be.auth.limitStatus();if(w.ok){const I=await w.json();return h(I),I}}catch(w){console.error("Error checking limit status:",w)}return{allowed:!0}};s.useEffect(()=>{r&&!l&&d()},[r,l]);const j={user:r,token:o,login:C,sendCode:$,verifyCode:D,logout:p,isLoading:l,needsSetup:m,smtpConfigured:x,error:S,isAdmin:r?.role==="admin",limitStatus:y,checkLimitStatus:d,setLimitStatus:h};return e.jsx(na.Provider,{value:j,children:t})},pi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],xi=["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 hi({skipPermissions:t,setSkipPermissions:r,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:l,newAllowedTool:i,setNewAllowedTool:m,newDisallowedTool:g,setNewDisallowedTool:x}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),m(""))},S=h=>{o(a.filter(z=>z!==h))},v=h=>{h&&!n.includes(h)&&(l([...n,h]),x(""))},y=h=>{l(n.filter(z=>z!==h))};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(Bs,{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($t,{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:h=>r(h.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(ur,{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(Qe,{value:i,onChange:h=>m(h.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:pi.map(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>S(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),a.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($t,{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(Qe,{value:g,onChange:h=>x(h.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),v(g))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:[n.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),n.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 gi({skipPermissions:t,setSkipPermissions:r,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:l,newAllowedCommand:i,setNewAllowedCommand:m,newDisallowedCommand:g,setNewDisallowedCommand:x}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),m(""))},S=h=>{o(a.filter(z=>z!==h))},v=h=>{h&&!n.includes(h)&&(l([...n,h]),x(""))},y=h=>{l(n.filter(z=>z!==h))};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($t,{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:h=>r(h.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(ur,{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(Qe,{value:i,onChange:h=>m(h.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:xi.map(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>S(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),a.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($t,{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(Qe,{value:g,onChange:h=>x(h.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),v(g))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:[n.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),n.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 fi({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(ur,{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($t,{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 bi({agent:t,...r}){return t==="claude"?e.jsx(hi,{...r}):t==="cursor"?e.jsx(gi,{...r}):t==="codex"?e.jsx(fi,{...r}):null}const yi=t=>{switch(t){case"stdio":return e.jsx(mr,{className:"w-4 h-4"});case"sse":return e.jsx(an,{className:"w-4 h-4"});case"http":return e.jsx(Rr,{className:"w-4 h-4"});default:return e.jsx(pr,{className:"w-4 h-4"})}};function vi({servers:t,onAdd:r,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:l,testResults:i,serverTools:m,toolsLoading:g}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(x=>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:[yi(x.type),e.jsx("span",{className:"font-medium text-foreground",children:x.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:x.type}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:x.scope==="local"?"local":x.scope==="user"?"user":x.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[x.type==="stdio"&&x.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:x.config.command})]}),(x.type==="sse"||x.type==="http")&&x.config?.url&&e.jsxs("div",{children:["URL:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:x.config.url})]}),x.config?.args&&x.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:x.config.args.join(" ")})]})]}),i?.[x.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[x.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:i[x.id].message})}),m?.[x.id]&&m[x.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:["工具(",m[x.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m[x.id].tools.slice(0,5).map((b,S)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:b.name},S)),m[x.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",m[x.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(x),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(x.id,x.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},x.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function ji({servers:t,onAdd:r,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},n.name||n.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function wi({servers:t,onAdd:r,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{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(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]}),n.config?.args&&n.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:n.config.args.join(" ")})]}),n.config?.env&&Object.keys(n.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(n.config.env).map(([l,i])=>`${l}=${i}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},n.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 ki({agent:t,...r}){return t==="claude"?e.jsx(vi,{...r}):t==="cursor"?e.jsx(ji,{...r}):t==="codex"?e.jsx(wi,{...r}):null}const Ni=[{key:"ANTHROPIC_DEFAULT_OPUS_MODEL",label:"Opus 模型",placeholder:"例如: claude-opus-4-6",description:"覆盖 opus 别名使用的模型,Plan Mode 激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_SONNET_MODEL",label:"Sonnet 模型",placeholder:"例如: claude-sonnet-4-5-20250929",description:"覆盖 sonnet 别名使用的模型,Plan Mode 未激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_HAIKU_MODEL",label:"Haiku 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖 haiku 别名使用的模型,也用于后台功能"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖子代理(subagents)使用的模型"}],Si=s.forwardRef(function({onStatusChange:r},a){const[o,n]=s.useState({}),[l,i]=s.useState({}),[m,g]=s.useState(!0),[x,b]=s.useState(!1),[S,v]=s.useState(null),[y,h]=s.useState(null),z=JSON.stringify(o)!==JSON.stringify(l);s.useEffect(()=>{r?.({saving:x,hasChanges:z})},[x,z,r]),s.useEffect(()=>{$()},[]),s.useEffect(()=>{if(S){const p=setTimeout(()=>v(null),3e3);return()=>clearTimeout(p)}},[S]);const $=async()=>{try{g(!0),h(null);const p=await se("/api/settings/models");if(p.ok){const d=await p.json();n(d.models||{}),i(d.models||{})}else{const d=await p.json();h(d.error||"加载模型配置失败")}}catch(p){h(p.message)}finally{g(!1)}},D=async()=>{try{b(!0),v(null);const p=await se("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:o})});if(p.ok)return v("success"),i({...o}),!0;{const d=await p.json();return v("error"),h(d.error||"保存失败"),!1}}catch(p){return v("error"),h(p.message),!1}finally{b(!1)}},C=()=>{n({...l}),v(null)};return s.useImperativeHandle(a,()=>({save:D,reset:C,get hasChanges(){return z},get saving(){return x}}),[z,x,o,l]),m?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载模型配置..."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[e.jsx(Bs,{className:"w-4 h-4 text-blue-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{children:"自定义模型 ID 来覆盖 Claude Code 使用的默认模型。留空表示使用默认模型。"}),e.jsx("p",{className:"mt-1 text-blue-600 dark:text-blue-400",children:"非 Claude 模型将按 Sonnet 定价计费,但统计中会记录实际模型 ID。"})]})]}),y&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-600 dark:text-red-400",children:y}),S==="success"&&e.jsx("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),Ni.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:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"font-medium text-sm text-foreground",children:p.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),e.jsx("input",{type:"text",value:o[p.key]||"",onChange:d=>n(j=>({...j,[p.key]:d.target.value})),placeholder:p.placeholder,className:"w-full text-sm bg-white 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 px-3 py-2"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:p.key})]})},p.key))]})});function Ci({onNavigateToUsage:t}){const[r,a]=s.useState([]),[o,n]=s.useState({}),[l,i]=s.useState(!0),[m,g]=s.useState(null),[x,b]=s.useState(!1),[S,v]=s.useState(""),[y,h]=s.useState(""),[z,$]=s.useState(""),[D,C]=s.useState(!1),[p,d]=s.useState(null),[j,w]=s.useState({total_limit_usd:"",daily_limit_usd:""}),[I,B]=s.useState(""),[W,Z]=s.useState(!1),[le,X]=s.useState(null),[ne,U]=s.useState(""),[L,_]=s.useState(""),[Q,he]=s.useState(""),[ie,Y]=s.useState(!1),ge=async()=>{try{const P=await se("/api/admin/users");if(P.ok){const O=await P.json();a(O.users)}}catch(P){console.error("Error fetching users:",P)}finally{i(!1)}},Ne=async()=>{try{const P=await se("/api/admin/usage/summary");if(P.ok){const O=await P.json(),F={};for(const f of O.users)F[f.user_uuid]={total_cost:f.total_cost||0,total_requests:f.total_requests||0,last_active:f.last_active};n(F)}}catch(P){console.error("Error fetching usage data:",P)}};s.useEffect(()=>{ge(),Ne()},[]);const Le=P=>!P||P===0?"$0.00":P<.01?`$${P.toFixed(4)}`:`$${P.toFixed(2)}`,je=async(P,O)=>{const F=O==="active"?"disabled":"active";g(P);try{(await se(`/api/admin/users/${P}`,{method:"PATCH",body:JSON.stringify({status:F})})).ok&&a(r.map(H=>H.id===P?{...H,status:F}:H))}catch(f){console.error("Error updating user status:",f)}finally{g(null)}},Oe=async(P,O)=>{if(confirm(`确定要删除用户 "${O}"?这将删除其所有数据。`)){g(P);try{(await se(`/api/admin/users/${P}`,{method:"DELETE"})).ok&&a(r.filter(f=>f.id!==P))}catch(F){console.error("Error deleting user:",F)}finally{g(null)}}},pe=async P=>{if(P.preventDefault(),$(""),!S||!y){$("用户名和密码不能为空");return}if(S.length<3){$("用户名至少3个字符");return}if(y.length<6){$("密码至少6个字符");return}C(!0);try{const O=await be.admin.createUser(S,y),F=await O.json();O.ok?(await ge(),b(!1),v(""),h("")):$(F.error||"创建用户失败")}catch(O){console.error("Error creating user:",O),$("网络错误,请稍后再试")}finally{C(!1)}},Se=()=>{b(!1),v(""),h(""),$("")},we=P=>{d(P),w({total_limit_usd:P.total_limit_usd!==null&&P.total_limit_usd!==void 0?String(P.total_limit_usd):"",daily_limit_usd:P.daily_limit_usd!==null&&P.daily_limit_usd!==void 0?String(P.daily_limit_usd):""}),B("")},Ie=()=>{d(null),w({total_limit_usd:"",daily_limit_usd:""}),B("")},xe=async P=>{P.preventDefault(),B("");const O=j.total_limit_usd.trim()===""?null:parseFloat(j.total_limit_usd),F=j.daily_limit_usd.trim()===""?null:parseFloat(j.daily_limit_usd);if(O!==null&&(isNaN(O)||O<0)){B("总额度限制必须是正数或留空");return}if(F!==null&&(isNaN(F)||F<0)){B("每日额度限制必须是正数或留空");return}Z(!0);try{const f=await be.admin.updateUserLimits(p.id,{total_limit_usd:O,daily_limit_usd:F}),H=await f.json();f.ok?(a(r.map(de=>de.id===p.id?{...de,total_limit_usd:O,daily_limit_usd:F}:de)),Ie()):B(H.error||"更新限制失败")}catch(f){console.error("Error updating limits:",f),B("网络错误,请稍后再试")}finally{Z(!1)}},Ce=P=>P==null?"无限制":`$${P.toFixed(2)}`,Re=P=>{X(P),U(""),_(""),he("")},Ee=()=>{X(null),U(""),_(""),he("")},Be=async P=>{if(P.preventDefault(),he(""),!ne){he("请输入新密码");return}if(ne.length<6){he("密码至少需要6个字符");return}if(ne!==L){he("两次输入的密码不一致");return}Y(!0);try{const O=await be.admin.resetUserPassword(le.id,ne),F=await O.json();O.ok?Ee():he(F.error||"重置密码失败")}catch(O){console.error("Error resetting password:",O),he("网络错误,请稍后再试")}finally{Y(!1)}};return l?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(J,{variant:"default",size:"sm",onClick:()=>b(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(J,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(on,{className:"w-4 h-4"}),"使用量统计"]})]})]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[700px]",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground",children:"用户"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"角色"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"状态"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"费用"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-28",children:"额度限制"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground w-24",children:"创建时间"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(P=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[P.role==="admin"?e.jsx(ur,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Us,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground text-sm truncate",children:P.username||P.email}),P.email&&P.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:P.email})]})]})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block px-1.5 py-0.5 text-xs rounded whitespace-nowrap ${P.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:P.role==="admin"?"管理员":"用户"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${P.status==="active"?"bg-green-500":"bg-red-500"}`,title:P.status==="active"?"活跃":"已禁用"})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:"font-mono text-xs text-foreground whitespace-nowrap",children:Le(o[P.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:P.role!=="admin"?e.jsx("button",{onClick:()=>we(P),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:P.total_limit_usd!==null||P.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Ce(P.total_limit_usd)]}),e.jsxs("span",{children:["日:",Ce(P.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Hs,{className:"w-3 h-3"}),"限额"]})}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground whitespace-nowrap",children:new Date(P.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:P.role!=="admin"&&e.jsxs(e.Fragment,{children:[P.username&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Re(P),disabled:m===P.id,title:"重置密码",children:e.jsx(qs,{className:"w-4 h-4 text-blue-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>je(P.id,P.status),disabled:m===P.id,title:P.status==="active"?"禁用用户":"启用用户",children:P.status==="active"?e.jsx(ln,{className:"w-4 h-4 text-orange-500"}):e.jsx(cn,{className:"w-4 h-4 text-green-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Oe(P.id,P.username||P.email),disabled:m===P.id,title:"删除用户",children:e.jsx(Ze,{className:"w-4 h-4 text-red-500"})})]})})})]},P.id))})]})}),x&&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:Se,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:pe,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:S,onChange:P=>v(P.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:D})]}),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:y,onChange:P=>h(P.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:D})]}),z&&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:z})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Se,disabled:D,children:"取消"}),e.jsx(J,{type:"submit",disabled:D,children:D?"创建中...":"创建"})]})]})]})}),p&&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.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["设置额度限制 - ",p.username||p.email]}),e.jsx("button",{onClick:Ie,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"totalLimit",className:"block text-sm font-medium text-foreground mb-1",children:"总额度上限 (USD)"}),e.jsx("input",{type:"number",id:"totalLimit",step:"0.01",min:"0",value:j.total_limit_usd,onChange:P=>w(O=>({...O,total_limit_usd:P.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:W}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户累计使用金额达到此限制后,将无法继续使用"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dailyLimit",className:"block text-sm font-medium text-foreground mb-1",children:"每日额度上限 (USD)"}),e.jsx("input",{type:"number",id:"dailyLimit",step:"0.01",min:"0",value:j.daily_limit_usd,onChange:P=>w(O=>({...O,daily_limit_usd:P.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:W}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户每日使用金额达到此限制后,需等待次日重置"})]}),o[p.uuid]&&e.jsx("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["当前已使用:",e.jsx("span",{className:"font-mono text-foreground",children:Le(o[p.uuid]?.total_cost)})]})}),I&&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:I})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Ie,disabled:W,children:"取消"}),e.jsx(J,{type:"submit",disabled:W,children:W?"保存中...":"保存"})]})]})]})}),le&&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.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["重置密码 - ",le.username]}),e.jsx("button",{onClick:Ee,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:Be,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"resetNewPassword",value:ne,onChange:P=>U(P.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:"请输入新密码(至少6个字符)",disabled:ie})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetConfirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"resetConfirmPassword",value:L,onChange:P=>_(P.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:ie})]}),Q&&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:Q})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Ee,disabled:ie,children:"取消"}),e.jsx(J,{type:"submit",disabled:ie,children:ie?"重置中...":"重置密码"})]})]})]})})]})}function Ei(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,m]=s.useState(!1),[g,x]=s.useState(""),[b,S]=s.useState(""),[v,y]=s.useState(!1),h=async()=>{try{const C=await be.admin.getEmailDomains();if(C.ok){const p=await C.json();r(p.domains)}}catch(C){console.error("Error fetching email domains:",C)}finally{o(!1)}};s.useEffect(()=>{h()},[]);const z=async C=>{if(C.preventDefault(),S(""),!g){S("域名不能为空");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)){S("域名格式无效,例如: example.com");return}y(!0);try{const d=await be.admin.addEmailDomain(g.toLowerCase()),j=await d.json();d.ok?(await h(),m(!1),x("")):S(j.error||"添加域名失败")}catch(d){console.error("Error adding domain:",d),S("网络错误,请稍后再试")}finally{y(!1)}},$=async(C,p)=>{if(confirm(`确定要删除域名 "${p}"?删除后该域名的邮箱将无法注册。`)){l(C);try{(await be.admin.removeEmailDomain(C)).ok&&r(t.filter(j=>j.id!==C))}catch(d){console.error("Error removing domain:",d)}finally{l(null)}}},D=()=>{m(!1),x(""),S("")};return a?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(J,{variant:"default",size:"sm",onClick:()=>m(!0),className:"flex items-center gap-2",children:[e.jsx(st,{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(C=>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(ir,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:C.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(C.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>$(C.id,C.domain),disabled:n===C.id,title:"删除域名",children:e.jsx(Ze,{className:"w-4 h-4 text-red-500"})})})})]},C.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(ir,{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:"添加域名后,只有白名单内的域名邮箱可以注册"})]}),i&&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:D,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:z,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:C=>x(C.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:v}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),b&&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:b})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:D,disabled:v,children:"取消"}),e.jsx(J,{type:"submit",disabled:v,children:v?"添加中...":"添加"})]})]})]})})]})}function Mi({onBack:t}){const[r,a]=s.useState("week"),[o,n]=s.useState(null),[l,i]=s.useState(!0),[m,g]=s.useState(!1),x=async()=>{try{const D=await se(`/api/admin/usage/dashboard?period=${r}`);if(D.ok){const C=await D.json();n(C)}}catch(D){console.error("Error fetching dashboard data:",D)}finally{i(!1),g(!1)}};s.useEffect(()=>{i(!0),x()},[r]);const b=async()=>{try{g(!0),await se("/api/admin/usage/scan",{method:"POST"}),await x()}catch(D){console.error("Error triggering scan:",D),g(!1)}},S=D=>!D||D===0?"$0.00":D<.01?`$${D.toFixed(4)}`:`$${D.toFixed(2)}`,v=D=>D?D>=1e6?`${(D/1e6).toFixed(1)}M`:D>=1e3?`${(D/1e3).toFixed(1)}K`:D.toString():"0";if(l)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:y,dailyTrend:h,modelDistribution:z,topUsers:$}=o||{};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(J,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(xr,{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(D=>e.jsx("button",{onClick:()=>a(D),className:`px-4 py-2 text-sm font-medium transition-colors ${r===D?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:D==="week"?"周":"月"},D))}),e.jsx(J,{variant:"outline",size:"sm",onClick:b,disabled:m,title:"扫描新的使用数据",children:e.jsx(or,{className:`w-4 h-4 ${m?"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(Hs,{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:S(y?.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(dn,{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:[y?.activeUsers||0," / ",y?.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(Pt,{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:v(y?.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(mn,{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:v(y?.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:"每日成本趋势"}),h&&h.length>0?e.jsx("div",{className:"space-y-2",children:h.map(D=>{const C=Math.max(...h.map(d=>d.cost||0),.01),p=(D.cost||0)/C*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(D.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:S(D.cost)})]},D.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:"模型成本"}),z&&z.length>0?e.jsx("div",{className:"space-y-3",children:z.map(D=>{const C=z.reduce((I,B)=>I+(B.cost||0),0)||1,p=(D.cost||0)/C*100,d=(D.normalized_model||D.model||"").toLowerCase(),w=(I=>I.includes("codex")?"bg-orange-500":I.includes("opus")?"bg-purple-500":I.includes("sonnet")?"bg-blue-500":I.includes("haiku")?"bg-green-500":"bg-gray-500")(d);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 min-w-0",children:[e.jsx(Xe,{variant:"secondary",className:"truncate max-w-[200px]",title:D.model,children:D.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[v(D.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:S(D.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${w} rounded`,style:{width:`${p}%`}})})]},D.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:"用户成本"}),$&&$.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:$.map((D,C)=>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:["#",C+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:D.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:v(D.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:S(D.total_cost)})]},D.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Li({onClose:t,onInstalled:r,onOpenRepoManager:a}){const[o,n]=s.useState([]),[l,i]=s.useState([]),[m,g]=s.useState(!0),[x,b]=s.useState(null),[S,v]=s.useState(""),[y,h]=s.useState("all"),[z,$]=s.useState(null);s.useEffect(()=>{D()},[]);const D=async()=>{try{g(!0),b(null);const[d,j]=await Promise.all([se("/api/skills/available"),se("/api/skills/repos")]);if(d.ok){const w=await d.json();n(w.skills||[])}if(j.ok){const w=await j.json();i(w.repos||[])}}catch(d){b(d.message)}finally{g(!1)}},C=async d=>{try{$(d.name);const j=await se(`/api/skills/install/${d.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:d.path})});if(j.ok)D(),r?.();else{const w=await j.json();alert(w.error||"Failed to install skill")}}catch(j){alert(j.message)}finally{$(null)}},p=o.filter(d=>{if(S){const j=S.toLowerCase();if(!d.name.toLowerCase().includes(j)&&!d.title?.toLowerCase().includes(j)&&!d.description?.toLowerCase().includes(j))return!1}return!(y!=="all"&&d.repository!==y)});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(J,{variant:"ghost",size:"sm",onClick:D,disabled:m,children:[e.jsx(or,{className:`w-4 h-4 ${m?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(J,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(zt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Ue,{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(Rt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索技能名称或描述...",value:S,onChange:d=>v(d.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:y,onChange:d=>h(d.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:"全部"}),l.map(d=>e.jsxs("option",{value:`${d.owner}/${d.repo}`,children:[d.owner,"/",d.repo]},`${d.owner}/${d.repo}`))]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-4 pb-4",children:[x&&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:x}),m?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:o.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"没有可用的技能"}),e.jsx("p",{className:"text-xs mt-2",children:"请先添加技能仓库"}),e.jsxs(J,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(zt,{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(d=>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:d.title||d.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",d.name]}),e.jsx(Xe,{variant:"outline",className:"text-xs ml-2",children:d.repository})]})]}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${d.repository}`,"_blank"),children:[e.jsx(Js,{className:"w-4 h-4 mr-1"}),"查看"]}),d.installed?e.jsx(J,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(J,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>C(d),disabled:z===d.name,children:[e.jsx(Tt,{className:"w-4 h-4 mr-1"}),z===d.name?"安装中...":"安装"]})]})]})},`${d.repository}-${d.name}`))})]})]})})}function Ii({onClose:t,onChanged:r}){const[a,o]=s.useState([]),[n,l]=s.useState(!0),[i,m]=s.useState(null),[g,x]=s.useState(""),[b,S]=s.useState("main"),[v,y]=s.useState(!1),[h,z]=s.useState(null);s.useEffect(()=>{$()},[]);const $=async()=>{try{l(!0),m(null);const p=await se("/api/skills/repos");if(p.ok){const d=await p.json();o(d.repos||[])}else{const d=await p.json();m(d.error||"Failed to fetch repos")}}catch(p){m(p.message)}finally{l(!1)}},D=async p=>{if(p.preventDefault(),!g.trim()){m("请输入仓库 URL");return}try{y(!0),m(null);const d=await se("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:g.trim(),branch:b.trim()||"main"})});if(d.ok)x(""),S("main"),$(),r?.();else{const j=await d.json();m(j.error||"Failed to add repo")}}catch(d){m(d.message)}finally{y(!1)}},C=async(p,d)=>{if(confirm(`确定要移除仓库 "${p}/${d}" 吗?`))try{z(`${p}/${d}`);const j=await se(`/api/skills/repos/${p}/${d}`,{method:"DELETE"});if(j.ok)$(),r?.();else{const w=await j.json();alert(w.error||"Failed to remove repo")}}catch(j){alert(j.message)}finally{z(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(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(xr,{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:D,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(Qe,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:g,onChange:p=>x(p.target.value),disabled:v})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Qe,{type:"text",placeholder:"main",value:b,onChange:p=>S(p.target.value),disabled:v})]}),e.jsxs(J,{type:"submit",disabled:v||!g.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),v?"添加中...":"添加仓库"]})]})]}),i&&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:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"已添加的仓库"}),n?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"加载中..."}):a.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有添加任何仓库"})]}):a.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(pn,{className:"w-3 h-3"}),"分支: main"]}),e.jsxs(Xe,{variant:"outline",className:"text-xs",children:["识别到 ",p.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>window.open(p.url,"_blank"),children:e.jsx(Js,{className:"w-4 h-4"})}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>C(p.owner,p.repo),disabled:h===`${p.owner}/${p.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},`${p.owner}/${p.repo}`))]})]})]})})}function Di(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,m]=s.useState(!1),[g,x]=s.useState(!1),[b,S]=s.useState(!1),v=s.useRef(null);s.useEffect(()=>{y()},[]);const y=async()=>{try{o(!0),l(null);const C=await se("/api/skills");if(C.ok){const p=await C.json();r(p.skills||[])}else{const p=await C.json();l(p.error||"Failed to fetch skills")}}catch(C){l(C.message)}finally{o(!1)}},h=async C=>{if(confirm(`确定要删除技能 "${C}" 吗?`))try{const p=await se(`/api/skills/${C}`,{method:"DELETE"});if(p.ok)y();else{const d=await p.json();alert(d.error||"Failed to delete skill")}}catch(p){alert(p.message)}},z=()=>{v.current?.click()},$=async C=>{const p=C.target.files?.[0];if(p)try{S(!0);const d=new FormData;d.append("skillZip",p);const j=await se("/api/skills/import",{method:"POST",body:d});if(j.ok)y();else{const w=await j.json();alert(w.error||"Failed to import skill")}}catch(d){alert(d.message)}finally{S(!1),v.current&&(v.current.value="")}},D=(C,p)=>{switch(C){case"repo":return e.jsx(Xe,{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(Xe,{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(Xe,{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(zr,{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:v,type:"file",accept:".zip",className:"hidden",onChange:$}),e.jsxs(J,{onClick:z,variant:"outline",size:"sm",disabled:b,children:[e.jsx(Tt,{className:"w-4 h-4 mr-2"}),b?"导入中...":"导入已有"]}),e.jsxs(J,{onClick:()=>m(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(Rt,{className:"w-4 h-4 mr-2"}),"发现技能"]})]})]}),n&&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:n}),e.jsx("div",{className:"space-y-2",children:a?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(zr,{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(C=>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:C.title||C.name}),D(C.source,C.repository)]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:C.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>h(C.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ze,{className:"w-4 h-4"})})})]})},C.name))}),i&&e.jsx(Li,{onClose:()=>m(!1),onInstalled:y,onOpenRepoManager:()=>{m(!1),x(!0)}}),g&&e.jsx(Ii,{onClose:()=>x(!1),onChanged:()=>{}})]})}function Ti({isOpen:t,onClose:r,projects:a=[],initialTab:o="agents"}){const n=$s(),{isDarkMode:l,toggleDarkMode:i}=ts(),{user:m,logout:g}=Ot(),x=m?.role==="admin",[b,S]=s.useState([]),[v,y]=s.useState([]),[h,z]=s.useState(""),[$,D]=s.useState(""),[C,p]=s.useState(!1),[d,j]=s.useState(!1),[w,I]=s.useState(null),[B,W]=s.useState("name"),[Z,le]=s.useState([]),[X,ne]=s.useState(!1),[U,L]=s.useState(null),[_,Q]=s.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[he,ie]=s.useState(!1),[Y,ge]=s.useState({}),[Ne,Le]=s.useState({}),[je,Oe]=s.useState({}),[pe,Se]=s.useState(o),[we,Ie]=s.useState(""),[xe,Ce]=s.useState("permissions"),[Re,Ee]=s.useState(!1),Be=s.useRef(null),[P,O]=s.useState({saving:!1,hasChanges:!1}),F=s.useCallback(T=>O(T),[]),[f,H]=s.useState(""),[de,Me]=s.useState(""),[$e,Ke]=s.useState(""),[u,A]=s.useState(""),[oe,re]=s.useState(""),[M,De]=s.useState(!1),[qe,Te]=s.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[K,ue]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[te,ce]=s.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[ve,Ae]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[fe,He]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),ut=async()=>{try{const T=await se("/api/mcp/config/read");if(T.ok){const ke=await T.json();if(ke.success&&ke.servers){le(ke.servers);return}}const G=await se("/api/mcp/cli/list");if(G.ok){const ke=await G.json();if(ke.success&&ke.servers){const Ve=ke.servers.map(Fe=>({id:Fe.name,name:Fe.name,type:Fe.type,scope:"user",config:{command:Fe.command||"",args:Fe.args||[],env:Fe.env||{},url:Fe.url||"",headers:Fe.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));le(Ve);return}}const ae=await se("/api/mcp/servers?scope=user");if(ae.ok){const ke=await ae.json();le(ke.servers||[])}else console.error("Failed to fetch MCP servers")}catch(T){console.error("Error fetching MCP servers:",T)}},tt=async T=>{try{U&&await Nt(U.id,"user");const G=await se("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:T.name,type:T.type,scope:T.scope,projectPath:T.projectPath,command:T.config?.command,args:T.config?.args||[],url:T.config?.url,headers:T.config?.headers||{},env:T.config?.env||{}})});if(G.ok){const ae=await G.json();if(ae.success)return await ut(),!0;throw new Error(ae.error||"Failed to save server via Claude CLI")}else{const ae=await G.json();throw new Error(ae.error||"Failed to save server")}}catch(G){throw console.error("Error saving MCP server:",G),G}},Nt=async(T,G="user")=>{try{const ae=await se(`/api/mcp/cli/remove/${T}?scope=${G}`,{method:"DELETE"});if(ae.ok){const ke=await ae.json();if(ke.success)return await ut(),!0;throw new Error(ke.error||"Failed to delete server via Claude CLI")}else{const ke=await ae.json();throw new Error(ke.error||"Failed to delete server")}}catch(ae){throw console.error("Error deleting MCP server:",ae),ae}},bt=async(T,G="user")=>{try{const ae=await se(`/api/mcp/servers/${T}/test?scope=${G}`,{method:"POST"});if(ae.ok)return(await ae.json()).testResult;{const ke=await ae.json();throw new Error(ke.error||"Failed to test server")}}catch(ae){throw console.error("Error testing MCP server:",ae),ae}},Gt=async(T,G="user")=>{try{const ae=await se(`/api/mcp/servers/${T}/tools?scope=${G}`,{method:"POST"});if(ae.ok)return(await ae.json()).toolsResult;{const ke=await ae.json();throw new Error(ke.error||"Failed to discover tools")}}catch(ae){throw console.error("Error discovering MCP tools:",ae),ae}};s.useEffect(()=>{t&&(hr(),Se(o),Ee(!1))},[t,o]),s.useEffect(()=>{localStorage.setItem("codeEditorTheme",qe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[qe]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",K.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[K]),s.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",te.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[te]),s.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",ve.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ve]),s.useEffect(()=>{localStorage.setItem("codeEditorFontSize",fe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[fe]);const hr=async()=>{try{let T=null;try{const G=await be.settings.getAgentPermissions();G.ok&&(T=(await G.json()).agentPermissions)}catch{}if(T)S(T.allowedTools||[]),y(T.disallowedTools||[]),p(T.skipPermissions||!1),W(T.projectSortOrder||"name"),localStorage.setItem("claude-settings",JSON.stringify(T));else{const G=localStorage.getItem("claude-settings");if(G){const ae=JSON.parse(G);S(ae.allowedTools||[]),y(ae.disallowedTools||[]),p(ae.skipPermissions||!1),W(ae.projectSortOrder||"name")}else S([]),y([]),p(!1),W("name")}await ut()}catch(T){console.error("Error loading tool settings:",T),S([]),y([]),p(!1),W("name")}},at=async()=>{j(!0),I(null);try{const T={allowedTools:b,disallowedTools:v,skipPermissions:C,projectSortOrder:B,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(T));try{await be.settings.saveAgentPermissions(T)}catch(G){console.warn("Failed to sync agent permissions to server:",G)}I("success"),setTimeout(()=>{r()},1e3)}catch(T){console.error("Error saving tool settings:",T),I("error")}finally{j(!1)}},gr=async T=>{if(T.preventDefault(),A(""),re(""),!f){A("请输入当前密码");return}if(!de){A("请输入新密码");return}if(de.length<6){A("新密码至少需要6个字符");return}if(de!==$e){A("两次输入的新密码不一致");return}De(!0);try{const G=await be.auth.changePassword(f,de),ae=await G.json();G.ok?(re("密码修改成功"),H(""),Me(""),Ke("")):A(ae.error||"修改密码失败")}catch(G){console.error("Error changing password:",G),A("网络错误,请稍后再试")}finally{De(!1)}},_t=m?.username&&!m.username.includes("@"),it=()=>{Q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),L(null),ne(!1),Ie("")},Ft=(T=null)=>{T?(L(T),Q({name:T.name,type:T.type,scope:T.scope,projectPath:T.projectPath||"",config:{...T.config},raw:T.raw,importMode:"form",jsonInput:""})):it(),ne(!0)},St=async T=>{T.preventDefault(),ie(!0);try{if(_.importMode==="json"){const G=await se("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:_.name,jsonConfig:_.jsonInput,scope:_.scope,projectPath:_.projectPath})});if(G.ok){const ae=await G.json();if(ae.success)await ut(),it(),I("success");else throw new Error(ae.error||"Failed to add server via JSON")}else{const ae=await G.json();throw new Error(ae.error||"Failed to add server")}}else await tt(_),it(),I("success")}catch(G){alert(`Error: ${G.message}`),I("error")}finally{ie(!1)}},Vt=async(T,G)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await Nt(T,G),I("success")}catch(ae){alert(`Error: ${ae.message}`),I("error")}},Ct=async(T,G)=>{try{ge({...Y,[T]:{loading:!0}});const ae=await bt(T,G);ge({...Y,[T]:ae})}catch(ae){ge({...Y,[T]:{success:!1,message:ae.message,details:[]}})}},fr=async(T,G)=>{try{Oe({...je,[T]:!0});const ae=await Gt(T,G);Le({...Ne,[T]:ae})}catch{Le({...Ne,[T]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{Oe({...je,[T]:!1})}},Ge=(T,G)=>{Q(ae=>({...ae,config:{...ae.config,[T]: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(zt,{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(J,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ue,{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:()=>Se("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agent"}),e.jsx("button",{onClick:()=>Se("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"外观"}),x&&e.jsx("button",{onClick:()=>Se("users"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="users"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"用户"}),e.jsx("button",{onClick:()=>Se("account"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="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:[pe==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:pe==="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:i,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":l,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${l?"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:l?e.jsx($r,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ar,{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:T=>W(T.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:()=>Te(qe==="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":qe==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${qe==="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:qe==="dark"?e.jsx($r,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ar,{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:()=>ue(!K),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":K,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${K?"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:()=>ce(!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 minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),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:()=>Ae(!ve),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":ve,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${ve?"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:fe,onChange:T=>He(T.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"})]})]})})]})]})}),pe==="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:()=>Ce("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 ${xe==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Ce("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 ${xe==="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:()=>Ce("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 ${xe==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Ce("models"),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 ${xe==="models"?"border-blue-600 text-blue-600 dark:text-blue-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:[xe==="permissions"&&e.jsx(bi,{agent:"claude",skipPermissions:C,setSkipPermissions:p,allowedTools:b,setAllowedTools:S,disallowedTools:v,setDisallowedTools:y,newAllowedTool:h,setNewAllowedTool:z,newDisallowedTool:$,setNewDisallowedTool:D}),xe==="mcp"&&e.jsx(ki,{agent:"claude",servers:Z,onAdd:()=>Ft(),onEdit:T=>Ft(T),onDelete:(T,G)=>Vt(T,G),onTest:(T,G)=>Ct(T,G),onDiscoverTools:(T,G)=>fr(T,G),testResults:Y,serverTools:Ne,toolsLoading:je}),xe==="skills"&&e.jsx(Di,{}),xe==="models"&&e.jsx(Si,{ref:Be,onStatusChange:F})]})]})}),pe==="users"&&x&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Re?e.jsx(Mi,{onBack:()=>Ee(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ci,{onNavigateToUsage:()=>Ee(!0)}),e.jsx(Ei,{})]})}),pe==="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:m?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:m?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m?.role==="admin"?"管理员":"用户"})]})]})}),_t&&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("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(qs,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:gr,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"currentPassword",className:"block text-sm font-medium text-foreground mb-1",children:"当前密码"}),e.jsx("input",{type:"password",id:"currentPassword",value:f,onChange:T=>H(T.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:M})]}),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:de,onChange:T=>Me(T.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:"请输入新密码(至少6个字符)",disabled:M})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"confirmNewPassword",value:$e,onChange:T=>Ke(T.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:M})]}),u&&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:u})}),oe&&e.jsx("div",{className:"p-3 bg-green-100 dark:bg-green-900/20 border border-green-300 dark:border-green-800 rounded-md",children:e.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:oe})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{type:"submit",disabled:M,className:"bg-blue-600 hover:bg-blue-700",children:M?"修改中...":"修改密码"})})]})]}),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(J,{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(),n("/"),g())},children:[e.jsx(xn,{className:"w-4 h-4"}),"退出"]})]})})]})}),X&&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:U?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(J,{variant:"ghost",size:"sm",onClick:it,children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:St,className:"p-4 space-y-4",children:[!U&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>Q(T=>({...T,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.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:()=>Q(T=>({...T,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.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 导入"})]}),_.importMode==="form"&&U&&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:[_.scope==="user"?e.jsx(Rr,{className:"w-4 h-4"}):e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:_.scope==="user"?"用户(全局)":"项目(本地)"}),_.scope==="local"&&_.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",_.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),_.importMode==="form"&&!U&&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:()=>Q(T=>({...T,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.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(Rr,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>Q(T=>({...T,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.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(wt,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:_.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),_.scope==="local"&&!U&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:_.projectPath,onChange:T=>Q(G=>({...G,projectPath:T.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:_.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),a.map(T=>e.jsx("option",{value:T.path||T.fullPath,children:T.displayName||T.name},T.name))]}),_.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",_.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:_.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(Qe,{value:_.name,onChange:T=>{Q(G=>({...G,name:T.target.value}))},placeholder:"my-server",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:_.type,onChange:T=>{Q(G=>({...G,type:T.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"})]})]})]}),U&&_.raw&&_.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 ",U.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(_.raw,null,2)})]}),_.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:_.jsonInput,onChange:T=>{Q(G=>({...G,jsonInput:T.target.value}));try{if(T.target.value.trim()){const G=JSON.parse(T.target.value);G.type?G.type==="stdio"&&!G.command?Ie("stdio 类型需要 command 字段"):(G.type==="http"||G.type==="sse")&&!G.url?Ie(`${G.type} 类型需要 url 字段`):Ie(""):Ie("缺少必填字段:type")}}catch{T.target.value.trim()?Ie("无效的 JSON 格式"):Ie("")}},className:`w-full px-3 py-2 border ${we?"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:`{
135
+ `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=ei,document.head.appendChild(t)}function ti({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:l=!1,autoConnect:i=!1}){const m=s.useRef(null),g=s.useRef(null),x=s.useRef(null),b=s.useRef(null),[S,v]=s.useState(!1),[y,h]=s.useState(!1),[z,$]=s.useState(!1),[D,C]=s.useState(null),[p,d]=s.useState(!1),j=s.useRef(t),w=s.useRef(r),L=s.useRef(a),B=s.useRef(o),W=s.useRef(n);s.useEffect(()=>{j.current=t,w.current=r,L.current=a,B.current=o,W.current=n});const Z=s.useCallback(async()=>{if(!(p||S))try{let he;{const ie=localStorage.getItem("auth-token");if(!ie){console.error("No authentication token found for Shell WebSocket connection");return}he=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ie)}`}b.current=new WebSocket(he),b.current.onopen=()=>{v(!0),d(!1),setTimeout(()=>{x.current&&g.current&&(x.current.fit(),b.current.send(JSON.stringify({type:"init",projectPath:j.current.fullPath||j.current.path,sessionId:B.current?null:w.current?.id,hasSession:B.current?!1:!!w.current,provider:B.current?"plain-shell":w.current?.__provider||"claude",cols:g.current.cols,rows:g.current.rows,initialCommand:L.current,isPlainShell:B.current})))},100)},b.current.onmessage=ie=>{try{const Y=JSON.parse(ie.data);if(Y.type==="output"){let ge=Y.data;if(B.current&&W.current){const Ne=ge.replace(/\x1b\[[0-9;]*m/g,"");if(Ne.includes("Process exited with code 0"))W.current(0);else if(Ne.match(/Process exited with code (\d+)/)){const Le=parseInt(Ne.match(/Process exited with code (\d+)/)[1]);Le!==0&&W.current(Le)}}g.current&&g.current.write(ge)}else Y.type==="url_open"&&window.open(Y.url,"_blank")}catch(Y){console.error("[Shell] Error handling WebSocket message:",Y,ie.data)}},b.current.onclose=ie=>{v(!1),d(!1),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H"))},b.current.onerror=ie=>{v(!1),d(!1)}}catch{v(!1),d(!1)}},[p,S]),le=s.useCallback(()=>{!y||S||p||(d(!0),Z())},[y,S,p,Z]),X=s.useCallback(()=>{b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),g.current&&(g.current.clear(),g.current.write("\x1B[2J\x1B[H")),v(!1),d(!1)},[]),ne=s.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),U=s.useMemo(()=>ne?ne.slice(0,30):null,[ne]),I=s.useMemo(()=>ne?ne.slice(0,50):null,[ne]),_=()=>{$(!0),b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),g.current&&(g.current.dispose(),g.current=null,x.current=null),v(!1),h(!1),setTimeout(()=>{$(!1)},200)};return s.useEffect(()=>{const Q=r?.id||null;D!==null&&D!==Q&&y&&X(),C(Q)},[r?.id,y,X]),s.useEffect(()=>{if(!m.current||!t||z||g.current)return;g.current=new Qr.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"]}}),x.current=new Zr.FitAddon;const Q=new Xr.WebglAddon,he=new es.WebLinksAddon;g.current.loadAddon(x.current),g.current.loadAddon(he);try{g.current.loadAddon(Q)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}g.current.open(m.current),g.current.attachCustomKeyEventHandler(Y=>(Y.ctrlKey||Y.metaKey)&&Y.key==="c"&&g.current.hasSelection()?(document.execCommand("copy"),!1):(Y.ctrlKey||Y.metaKey)&&Y.key==="v"?(navigator.clipboard.readText().then(ge=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:ge}))}).catch(()=>{}),!1):!0),setTimeout(()=>{x.current&&(x.current.fit(),g.current&&b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows})))},100),h(!0),g.current.onData(Y=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:Y}))});const ie=new ResizeObserver(()=>{x.current&&g.current&&setTimeout(()=>{x.current.fit(),b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:g.current.cols,rows:g.current.rows}))},50)});return m.current&&ie.observe(m.current),()=>{ie.disconnect(),b.current&&(b.current.readyState===WebSocket.OPEN||b.current.readyState===WebSocket.CONNECTING)&&b.current.close(),b.current=null,g.current&&(g.current.dispose(),g.current=null)}},[t?.path||t?.fullPath,z]),s.useEffect(()=>{!i||!y||p||S||le()},[i,y,p,S,le]),t?l?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:m,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 ${S?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",U,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!y&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),z&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[S&&e.jsxs("button",{onClick:X,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:_,disabled:z||S,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:m,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!y&&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:"加载终端中..."})}),y&&!S&&!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:le,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:o?`Run ${a||"command"} in ${t.displayName}`:r?`Resume session: ${I}...`:"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:o?`Running ${a||"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 ri({project:t,session:r=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:l=null,onClose:i=null,title:m=null,className:g="",showHeader:x=!0,compact:b=!1,minimal:S=!1}){const[v,y]=s.useState(!1),h=o!==null?o:a!==null,z=s.useCallback($=>{y(!0),l&&l($)},[l]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${g}`,children:[!S&&x&&m&&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:m}),v&&e.jsx("span",{className:"text-xs text-green-400",children:"(已完成)"})]}),i&&e.jsx("button",{onClick:i,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(ti,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:h,onProcessComplete:z,minimal:S,autoConnect:S?!0:n})})]}):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 需要一个项目"})]})})}function si({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(!1),[y,h]=s.useState(!1),z=s.useRef(t);s.useEffect(()=>{z.current=t});const $=s.useCallback(async()=>{if(!(y||m))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Codex WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{g(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:z.current.fullPath||z.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[CodexShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{g(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{g(!1),h(!1)}}catch{g(!1),h(!1)}},[y,m]),D=s.useCallback(()=>{!x||m||y||(h(!0),$())},[x,m,y,$]),C=s.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),g(!1),h(!1)},[]),p=()=>{v(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),g(!1),b(!1),setTimeout(()=>v(!1),200)};return s.useEffect(()=>{if(!o.current||!t||S||n.current)return;n.current=new Qr.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"}}),l.current=new Zr.FitAddon;const d=new Xr.WebglAddon,j=new es.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(d)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(B=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:B}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),b(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,S]),s.useEffect(()=>{!a||!x||y||m||D()},[a,x,y,m,D]),t?r?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,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 ${m?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Codex"}),!x&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),S&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[m&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Codex 连接",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:p,disabled:S||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Codex(先断开连接)",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:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&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:"加载终端中..."})}),x&&!m&&!y&&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:D,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",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:"启动 Codex"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Codex CLI"]})]})}),y&&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:"连接到 Codex..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Codex CLI"]})]})})]})]}):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:"选择一个项目以在该目录中打开 Codex"})]})})}function ai({project:t,autoConnect:r=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&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.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Codex"}),e.jsx("button",{onClick:a,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(si,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,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:"打开 Codex 需要一个项目"})]})})}function ni({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(!1),[y,h]=s.useState(!1),z=s.useRef(t);s.useEffect(()=>{z.current=t});const $=s.useCallback(async()=>{if(!(y||m))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Gemini WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/gemini?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{g(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:z.current.fullPath||z.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[GeminiShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{g(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{g(!1),h(!1)}}catch{g(!1),h(!1)}},[y,m]),D=s.useCallback(()=>{!x||m||y||(h(!0),$())},[x,m,y,$]),C=s.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),g(!1),h(!1)},[]),p=()=>{v(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),g(!1),b(!1),setTimeout(()=>v(!1),200)};return s.useEffect(()=>{if(!o.current||!t||S||n.current)return;n.current=new Qr.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"}}),l.current=new Zr.FitAddon;const d=new Xr.WebglAddon,j=new es.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(d)}catch{console.warn("[GeminiShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(B=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:B}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),b(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,S]),s.useEffect(()=>{!a||!x||y||m||D()},[a,x,y,m,D]),t?r?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,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 ${m?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Gemini"}),!x&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),S&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[m&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Gemini 连接",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:p,disabled:S||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Gemini(先断开连接)",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:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&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:"加载终端中..."})}),x&&!m&&!y&&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:D,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",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:"启动 Gemini"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Gemini CLI"]})]})}),y&&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:"连接到 Gemini..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Gemini CLI"]})]})})]})]}):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:"选择一个项目以在该目录中打开 Gemini"})]})})}function oi({project:t,autoConnect:r=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&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.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Gemini"}),e.jsx("button",{onClick:a,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(ni,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,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:"打开 Gemini 需要一个项目"})]})})}class ii extends et.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,a){console.error("ErrorBoundary caught an error:",r,a),this.setState({error:r,errorInfo:a})}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 qt=({children:t,content:r,position:a="top",className:o="",delay:n=500})=>{const[l,i]=s.useState(!1),[m,g]=s.useState(null),x=()=>{const y=setTimeout(()=>{i(!0)},n);g(y)},b=()=>{m&&(clearTimeout(m),g(null)),i(!1)},S=()=>{switch(a){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"}},v=()=>{switch(a){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:x,onMouseLeave:b,children:[t,l&&e.jsxs("div",{className:We("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",S(),o),children:[r,e.jsx("div",{className:We("absolute w-0 h-0 border-4 border-transparent",v())})]})]}):t};function li({selectedProject:t,selectedSession:r,activeTab:a,setActiveTab:o,ws:n,sendMessage:l,messages:i,isMobile:m,isPWA:g,onMenuClick:x,isLoading:b,onInputFocusChange:S,onSessionActive:v,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:z,processingSessions:$,onReplaceTemporarySession:D,onNavigateToSession:C,onShowSettings:p,autoExpandTools:d,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:B,externalMessageUpdate:W,limitStatus:Z,onLimitBlocked:le,checkLimitStatus:X}){const[ne,U]=s.useState(null),[I,_]=s.useState(600),[Q,he]=s.useState(!1),[ie,Y]=s.useState(!1),ge=s.useRef(null);s.useEffect(()=>{a==="shell"&&X&&X()},[a,X]);const Ne=(pe,Se=null)=>{const we={name:pe.split("/").pop(),path:pe,projectName:t?.name,diffInfo:Se};U(we)},Le=()=>{U(null),Y(!1)},je=()=>{Y(!ie)},Oe=pe=>{m||(he(!0),pe.preventDefault())};return s.useEffect(()=>{const pe=we=>{if(!Q)return;const Ie=ge.current?.parentElement;if(!Ie)return;const xe=Ie.getBoundingClientRect(),Ce=xe.right-we.clientX,Re=300,Ee=xe.width*.8;Ce>=Re&&Ce<=Ee&&_(Ce)},Se=()=>{he(!1)};return Q&&(document.addEventListener("mousemove",pe),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[Q]),b?e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:x,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:[m&&e.jsx("button",{onClick:x,onTouchStart:pe=>{pe.preventDefault(),x()},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:[a==="chat"&&r&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ot,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="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})]}):a==="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:a==="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(qt,{content:"Chat",position:"bottom",children:e.jsx("button",{onClick:()=>o("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${a==="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(qt,{content:"Files",position:"bottom",children:e.jsx("button",{onClick:()=>o("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="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.jsx(qt,{content:Z&&!Z.allowed?"使用已达上限":"Claude Code",position:"bottom",children:e.jsx("button",{onClick:()=>{if(Z&&!Z.allowed){le?.(Z.reason);return}o("shell")},className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${Z&&!Z.allowed?"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-500":a==="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",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z",fill:"#D97757",fillRule:"nonzero"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Claude Code"})]})})}),e.jsx(qt,{content:"Codex",position:"bottom",children:e.jsx("button",{onClick:()=>o("codex"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="codex"?"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:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})}),e.jsx(qt,{content:"Gemini CLI",position:"bottom",children:e.jsx("button",{onClick:()=>o("gemini"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="gemini"?"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.jsxs("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-0)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-1)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-2)"}),e.jsxs("defs",{children:[e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[e.jsx("stop",{stopColor:"#08B962"}),e.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[e.jsx("stop",{stopColor:"#F94543"}),e.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[e.jsx("stop",{stopColor:"#FABC12"}),e.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Gemini CLI"})]})})})]})})]})}),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 ${ne?"mr-0":""} ${ie?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(ii,{showDetails:!0,children:e.jsx(Qo,{selectedProject:t,selectedSession:r,ws:n,sendMessage:l,messages:i,onFileOpen:Ne,onInputFocusChange:S,onSessionActive:v,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:z,processingSessions:$,onReplaceTemporarySession:D,onNavigateToSession:C,onShowSettings:p,autoExpandTools:d,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:B,externalMessageUpdate:W,limitStatus:Z,onLimitExceeded:le,checkLimitStatus:X})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Xo,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(ri,{project:t,session:r,showHeader:!1}),Z&&!Z.allowed&&e.jsx("div",{className:"absolute inset-0 bg-black/60 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl p-6 mx-4 max-w-md text-center",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:Z.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:Z.reason==="total_limit_exceeded"?"您已达到使用上限,请联系管理员提升额度。":"您已达到今日使用上限,请明日再来或联系管理员提升额度。"}),e.jsx("button",{onClick:()=>o("chat"),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"返回 Chat"})]})})]}),a==="codex"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ai,{project:t,showHeader:!1})}),a==="gemini"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(oi,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),ne&&!m&&e.jsxs(e.Fragment,{children:[!ie&&e.jsx("div",{ref:ge,onMouseDown:Oe,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 ${ie?"flex-1":""}`,style:ie?{}:{width:`${I}px`},children:e.jsx(qr,{file:ne,onClose:Le,projectPath:t?.path,isSidebar:!0,isExpanded:ie,onToggleExpand:je})})]})]}),ne&&m&&e.jsx(qr,{file:ne,onClose:Le,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:x,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:"提示:"})," ",m?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const ci=et.memo(li);function di({activeTab:t,setActiveTab:r,isInputFocused:a}){const o=[{id:"chat",icon:Pt,onClick:()=>r("chat")},{id:"shell",icon:mr,onClick:()=>r("shell")},{id:"files",icon:rt,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 ${a?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"flex items-center justify-around py-1",children:o.map(n=>{const l=n.icon,i=t===n.id;return e.jsxs("button",{onClick:n.onClick,onTouchStart:m=>{m.preventDefault(),n.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${i?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":n.id,children:[e.jsx(l,{className:"w-5 h-5"}),i&&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"})]},n.id)})})})}const aa=s.createContext(),ts=()=>{const t=s.useContext(aa);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},mi=({children:t})=>{const[r,a]=s.useState(()=>{const l=localStorage.getItem("theme");return l?l==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});s.useEffect(()=>{if(r){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","black-translucent");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#0c1117")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","default");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#ffffff")}},[r]),s.useEffect(()=>{if(!window.matchMedia)return;const l=window.matchMedia("(prefers-color-scheme: dark)"),i=m=>{localStorage.getItem("theme")||a(m.matches)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]);const n={isDarkMode:r,toggleDarkMode:()=>{a(l=>!l)}};return e.jsx(aa.Provider,{value:n,children:t})},na=s.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),Ot=()=>{const t=s.useContext(na);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t};async function Dr(){try{const t=await be.settings.getAgentPermissions();if(t.ok){const r=await t.json();r.agentPermissions&&localStorage.setItem("claude-settings",JSON.stringify(r.agentPermissions))}}catch{}}const ui=({children:t})=>{const[r,a]=s.useState(null),[o,n]=s.useState(localStorage.getItem("auth-token")),[l,i]=s.useState(!0),[m,g]=s.useState(!1),[x,b]=s.useState(!1),[S,v]=s.useState(null),[y,h]=s.useState({allowed:!0});s.useEffect(()=>{z()},[]);const z=async()=>{try{i(!0),v(null);const L=await(await be.auth.status()).json();if(b(L.smtpConfigured||!1),L.needsSetup){g(!0),i(!1);return}if(o)try{const B=await be.auth.user();if(B.ok){const W=await B.json();a(W.user),g(!1),await Dr()}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(B){console.error("Token verification failed:",B),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(w){console.error("[AuthContext] Auth status check failed:",w),v("Failed to check authentication status")}finally{i(!1)}},$=async w=>{try{v(null);const L=await be.auth.sendCode(w),B=await L.json();return L.ok?{success:!0,type:B.type}:{success:!1,error:B.error||"发送验证码失败",waitSeconds:B.waitSeconds}}catch(L){return console.error("Send code error:",L),{success:!1,error:"网络错误,请稍后再试"}}},D=async(w,L)=>{try{v(null);const B=await be.auth.verifyCode(w,L),W=await B.json();return B.ok?(n(W.token),a(W.user),g(!1),localStorage.setItem("auth-token",W.token),await Dr(),{success:!0}):(v(W.error||"验证失败"),{success:!1,error:W.error||"验证失败"})}catch(B){return console.error("Verify code error:",B),{success:!1,error:"网络错误,请稍后再试"}}},C=async(w,L)=>{try{v(null);const B=await be.auth.login(w,L),W=await B.json();return B.ok?(n(W.token),a(W.user),localStorage.setItem("auth-token",W.token),await Dr(),{success:!0}):(v(W.error||"登录失败"),{success:!1,error:W.error||"登录失败"})}catch(B){console.error("Login error:",B);const W="网络错误,请稍后再试";return v(W),{success:!1,error:W}}},p=()=>{n(null),a(null),h({allowed:!0}),localStorage.removeItem("auth-token"),o&&be.auth.logout().catch(w=>{console.error("Logout endpoint error:",w)})},d=async()=>{if(!r)return{allowed:!0};try{const w=await be.auth.limitStatus();if(w.ok){const L=await w.json();return h(L),L}}catch(w){console.error("Error checking limit status:",w)}return{allowed:!0}};s.useEffect(()=>{r&&!l&&d()},[r,l]);const j={user:r,token:o,login:C,sendCode:$,verifyCode:D,logout:p,isLoading:l,needsSetup:m,smtpConfigured:x,error:S,isAdmin:r?.role==="admin",limitStatus:y,checkLimitStatus:d,setLimitStatus:h};return e.jsx(na.Provider,{value:j,children:t})},pi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],xi=["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 hi({skipPermissions:t,setSkipPermissions:r,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:l,newAllowedTool:i,setNewAllowedTool:m,newDisallowedTool:g,setNewDisallowedTool:x}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),m(""))},S=h=>{o(a.filter(z=>z!==h))},v=h=>{h&&!n.includes(h)&&(l([...n,h]),x(""))},y=h=>{l(n.filter(z=>z!==h))};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(Bs,{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($t,{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:h=>r(h.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(ur,{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(Qe,{value:i,onChange:h=>m(h.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:pi.map(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>S(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),a.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($t,{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(Qe,{value:g,onChange:h=>x(h.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),v(g))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:[n.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),n.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 gi({skipPermissions:t,setSkipPermissions:r,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:l,newAllowedCommand:i,setNewAllowedCommand:m,newDisallowedCommand:g,setNewDisallowedCommand:x}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),m(""))},S=h=>{o(a.filter(z=>z!==h))},v=h=>{h&&!n.includes(h)&&(l([...n,h]),x(""))},y=h=>{l(n.filter(z=>z!==h))};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($t,{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:h=>r(h.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(ur,{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(Qe,{value:i,onChange:h=>m(h.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:xi.map(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>S(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),a.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($t,{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(Qe,{value:g,onChange:h=>x(h.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),v(g))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(g),disabled:!g,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:[n.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},h)),n.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 fi({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(ur,{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($t,{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 bi({agent:t,...r}){return t==="claude"?e.jsx(hi,{...r}):t==="cursor"?e.jsx(gi,{...r}):t==="codex"?e.jsx(fi,{...r}):null}const yi=t=>{switch(t){case"stdio":return e.jsx(mr,{className:"w-4 h-4"});case"sse":return e.jsx(an,{className:"w-4 h-4"});case"http":return e.jsx(Rr,{className:"w-4 h-4"});default:return e.jsx(pr,{className:"w-4 h-4"})}};function vi({servers:t,onAdd:r,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:l,testResults:i,serverTools:m,toolsLoading:g}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(x=>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:[yi(x.type),e.jsx("span",{className:"font-medium text-foreground",children:x.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:x.type}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:x.scope==="local"?"local":x.scope==="user"?"user":x.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[x.type==="stdio"&&x.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:x.config.command})]}),(x.type==="sse"||x.type==="http")&&x.config?.url&&e.jsxs("div",{children:["URL:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:x.config.url})]}),x.config?.args&&x.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:x.config.args.join(" ")})]})]}),i?.[x.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[x.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:i[x.id].message})}),m?.[x.id]&&m[x.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:["工具(",m[x.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m[x.id].tools.slice(0,5).map((b,S)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:b.name},S)),m[x.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",m[x.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(x),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(x.id,x.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},x.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function ji({servers:t,onAdd:r,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},n.name||n.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function wi({servers:t,onAdd:r,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{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(st,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Xe,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]}),n.config?.args&&n.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:n.config.args.join(" ")})]}),n.config?.env&&Object.keys(n.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(n.config.env).map(([l,i])=>`${l}=${i}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Jt,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},n.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 ki({agent:t,...r}){return t==="claude"?e.jsx(vi,{...r}):t==="cursor"?e.jsx(ji,{...r}):t==="codex"?e.jsx(wi,{...r}):null}const Ni=[{key:"ANTHROPIC_DEFAULT_OPUS_MODEL",label:"Opus 模型",placeholder:"例如: claude-opus-4-6",description:"覆盖 opus 别名使用的模型,Plan Mode 激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_SONNET_MODEL",label:"Sonnet 模型",placeholder:"例如: claude-sonnet-4-5-20250929",description:"覆盖 sonnet 别名使用的模型,Plan Mode 未激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_HAIKU_MODEL",label:"Haiku 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖 haiku 别名使用的模型,也用于后台功能"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖子代理(subagents)使用的模型"}],Si=s.forwardRef(function({onStatusChange:r},a){const[o,n]=s.useState({}),[l,i]=s.useState({}),[m,g]=s.useState(!0),[x,b]=s.useState(!1),[S,v]=s.useState(null),[y,h]=s.useState(null),z=JSON.stringify(o)!==JSON.stringify(l);s.useEffect(()=>{r?.({saving:x,hasChanges:z})},[x,z,r]),s.useEffect(()=>{$()},[]),s.useEffect(()=>{if(S){const p=setTimeout(()=>v(null),3e3);return()=>clearTimeout(p)}},[S]);const $=async()=>{try{g(!0),h(null);const p=await re("/api/settings/models");if(p.ok){const d=await p.json();n(d.models||{}),i(d.models||{})}else{const d=await p.json();h(d.error||"加载模型配置失败")}}catch(p){h(p.message)}finally{g(!1)}},D=async()=>{try{b(!0),v(null);const p=await re("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:o})});if(p.ok)return v("success"),i({...o}),!0;{const d=await p.json();return v("error"),h(d.error||"保存失败"),!1}}catch(p){return v("error"),h(p.message),!1}finally{b(!1)}},C=()=>{n({...l}),v(null)};return s.useImperativeHandle(a,()=>({save:D,reset:C,get hasChanges(){return z},get saving(){return x}}),[z,x,o,l]),m?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载模型配置..."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[e.jsx(Bs,{className:"w-4 h-4 text-blue-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{children:"自定义模型 ID 来覆盖 Claude Code 使用的默认模型。留空表示使用默认模型。"}),e.jsx("p",{className:"mt-1 text-blue-600 dark:text-blue-400",children:"非 Claude 模型将按 Sonnet 定价计费,但统计中会记录实际模型 ID。"})]})]}),y&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-600 dark:text-red-400",children:y}),S==="success"&&e.jsx("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),Ni.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:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"font-medium text-sm text-foreground",children:p.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),e.jsx("input",{type:"text",value:o[p.key]||"",onChange:d=>n(j=>({...j,[p.key]:d.target.value})),placeholder:p.placeholder,className:"w-full text-sm bg-white 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 px-3 py-2"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:p.key})]})},p.key))]})});function Ci({onNavigateToUsage:t}){const[r,a]=s.useState([]),[o,n]=s.useState({}),[l,i]=s.useState(!0),[m,g]=s.useState(null),[x,b]=s.useState(!1),[S,v]=s.useState(""),[y,h]=s.useState(""),[z,$]=s.useState(""),[D,C]=s.useState(!1),[p,d]=s.useState(null),[j,w]=s.useState({total_limit_usd:"",daily_limit_usd:""}),[L,B]=s.useState(""),[W,Z]=s.useState(!1),[le,X]=s.useState(null),[ne,U]=s.useState(""),[I,_]=s.useState(""),[Q,he]=s.useState(""),[ie,Y]=s.useState(!1),ge=async()=>{try{const P=await re("/api/admin/users");if(P.ok){const O=await P.json();a(O.users)}}catch(P){console.error("Error fetching users:",P)}finally{i(!1)}},Ne=async()=>{try{const P=await re("/api/admin/usage/summary");if(P.ok){const O=await P.json(),F={};for(const f of O.users)F[f.user_uuid]={total_cost:f.total_cost||0,total_requests:f.total_requests||0,last_active:f.last_active};n(F)}}catch(P){console.error("Error fetching usage data:",P)}};s.useEffect(()=>{ge(),Ne()},[]);const Le=P=>!P||P===0?"$0.00":P<.01?`$${P.toFixed(4)}`:`$${P.toFixed(2)}`,je=async(P,O)=>{const F=O==="active"?"disabled":"active";g(P);try{(await re(`/api/admin/users/${P}`,{method:"PATCH",body:JSON.stringify({status:F})})).ok&&a(r.map(H=>H.id===P?{...H,status:F}:H))}catch(f){console.error("Error updating user status:",f)}finally{g(null)}},Oe=async(P,O)=>{if(confirm(`确定要删除用户 "${O}"?这将删除其所有数据。`)){g(P);try{(await re(`/api/admin/users/${P}`,{method:"DELETE"})).ok&&a(r.filter(f=>f.id!==P))}catch(F){console.error("Error deleting user:",F)}finally{g(null)}}},pe=async P=>{if(P.preventDefault(),$(""),!S||!y){$("用户名和密码不能为空");return}if(S.length<3){$("用户名至少3个字符");return}if(y.length<6){$("密码至少6个字符");return}C(!0);try{const O=await be.admin.createUser(S,y),F=await O.json();O.ok?(await ge(),b(!1),v(""),h("")):$(F.error||"创建用户失败")}catch(O){console.error("Error creating user:",O),$("网络错误,请稍后再试")}finally{C(!1)}},Se=()=>{b(!1),v(""),h(""),$("")},we=P=>{d(P),w({total_limit_usd:P.total_limit_usd!==null&&P.total_limit_usd!==void 0?String(P.total_limit_usd):"",daily_limit_usd:P.daily_limit_usd!==null&&P.daily_limit_usd!==void 0?String(P.daily_limit_usd):""}),B("")},Ie=()=>{d(null),w({total_limit_usd:"",daily_limit_usd:""}),B("")},xe=async P=>{P.preventDefault(),B("");const O=j.total_limit_usd.trim()===""?null:parseFloat(j.total_limit_usd),F=j.daily_limit_usd.trim()===""?null:parseFloat(j.daily_limit_usd);if(O!==null&&(isNaN(O)||O<0)){B("总额度限制必须是正数或留空");return}if(F!==null&&(isNaN(F)||F<0)){B("每日额度限制必须是正数或留空");return}Z(!0);try{const f=await be.admin.updateUserLimits(p.id,{total_limit_usd:O,daily_limit_usd:F}),H=await f.json();f.ok?(a(r.map(de=>de.id===p.id?{...de,total_limit_usd:O,daily_limit_usd:F}:de)),Ie()):B(H.error||"更新限制失败")}catch(f){console.error("Error updating limits:",f),B("网络错误,请稍后再试")}finally{Z(!1)}},Ce=P=>P==null?"无限制":`$${P.toFixed(2)}`,Re=P=>{X(P),U(""),_(""),he("")},Ee=()=>{X(null),U(""),_(""),he("")},Be=async P=>{if(P.preventDefault(),he(""),!ne){he("请输入新密码");return}if(ne.length<6){he("密码至少需要6个字符");return}if(ne!==I){he("两次输入的密码不一致");return}Y(!0);try{const O=await be.admin.resetUserPassword(le.id,ne),F=await O.json();O.ok?Ee():he(F.error||"重置密码失败")}catch(O){console.error("Error resetting password:",O),he("网络错误,请稍后再试")}finally{Y(!1)}};return l?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(J,{variant:"default",size:"sm",onClick:()=>b(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(J,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(on,{className:"w-4 h-4"}),"使用量统计"]})]})]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[700px]",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground",children:"用户"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"角色"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"状态"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"费用"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-28",children:"额度限制"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground w-24",children:"创建时间"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(P=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[P.role==="admin"?e.jsx(ur,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Us,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground text-sm truncate",children:P.username||P.email}),P.email&&P.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:P.email})]})]})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block px-1.5 py-0.5 text-xs rounded whitespace-nowrap ${P.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:P.role==="admin"?"管理员":"用户"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${P.status==="active"?"bg-green-500":"bg-red-500"}`,title:P.status==="active"?"活跃":"已禁用"})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:"font-mono text-xs text-foreground whitespace-nowrap",children:Le(o[P.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:P.role!=="admin"?e.jsx("button",{onClick:()=>we(P),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:P.total_limit_usd!==null||P.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Ce(P.total_limit_usd)]}),e.jsxs("span",{children:["日:",Ce(P.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Hs,{className:"w-3 h-3"}),"限额"]})}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground whitespace-nowrap",children:new Date(P.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:P.role!=="admin"&&e.jsxs(e.Fragment,{children:[P.username&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Re(P),disabled:m===P.id,title:"重置密码",children:e.jsx(qs,{className:"w-4 h-4 text-blue-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>je(P.id,P.status),disabled:m===P.id,title:P.status==="active"?"禁用用户":"启用用户",children:P.status==="active"?e.jsx(ln,{className:"w-4 h-4 text-orange-500"}):e.jsx(cn,{className:"w-4 h-4 text-green-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Oe(P.id,P.username||P.email),disabled:m===P.id,title:"删除用户",children:e.jsx(Ze,{className:"w-4 h-4 text-red-500"})})]})})})]},P.id))})]})}),x&&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:Se,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:pe,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:S,onChange:P=>v(P.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:D})]}),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:y,onChange:P=>h(P.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:D})]}),z&&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:z})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Se,disabled:D,children:"取消"}),e.jsx(J,{type:"submit",disabled:D,children:D?"创建中...":"创建"})]})]})]})}),p&&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.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["设置额度限制 - ",p.username||p.email]}),e.jsx("button",{onClick:Ie,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"totalLimit",className:"block text-sm font-medium text-foreground mb-1",children:"总额度上限 (USD)"}),e.jsx("input",{type:"number",id:"totalLimit",step:"0.01",min:"0",value:j.total_limit_usd,onChange:P=>w(O=>({...O,total_limit_usd:P.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:W}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户累计使用金额达到此限制后,将无法继续使用"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dailyLimit",className:"block text-sm font-medium text-foreground mb-1",children:"每日额度上限 (USD)"}),e.jsx("input",{type:"number",id:"dailyLimit",step:"0.01",min:"0",value:j.daily_limit_usd,onChange:P=>w(O=>({...O,daily_limit_usd:P.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:W}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户每日使用金额达到此限制后,需等待次日重置"})]}),o[p.uuid]&&e.jsx("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["当前已使用:",e.jsx("span",{className:"font-mono text-foreground",children:Le(o[p.uuid]?.total_cost)})]})}),L&&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:L})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Ie,disabled:W,children:"取消"}),e.jsx(J,{type:"submit",disabled:W,children:W?"保存中...":"保存"})]})]})]})}),le&&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.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["重置密码 - ",le.username]}),e.jsx("button",{onClick:Ee,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:Be,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"resetNewPassword",value:ne,onChange:P=>U(P.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:"请输入新密码(至少6个字符)",disabled:ie})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetConfirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"resetConfirmPassword",value:I,onChange:P=>_(P.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:ie})]}),Q&&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:Q})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Ee,disabled:ie,children:"取消"}),e.jsx(J,{type:"submit",disabled:ie,children:ie?"重置中...":"重置密码"})]})]})]})})]})}function Ei(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,m]=s.useState(!1),[g,x]=s.useState(""),[b,S]=s.useState(""),[v,y]=s.useState(!1),h=async()=>{try{const C=await be.admin.getEmailDomains();if(C.ok){const p=await C.json();r(p.domains)}}catch(C){console.error("Error fetching email domains:",C)}finally{o(!1)}};s.useEffect(()=>{h()},[]);const z=async C=>{if(C.preventDefault(),S(""),!g){S("域名不能为空");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)){S("域名格式无效,例如: example.com");return}y(!0);try{const d=await be.admin.addEmailDomain(g.toLowerCase()),j=await d.json();d.ok?(await h(),m(!1),x("")):S(j.error||"添加域名失败")}catch(d){console.error("Error adding domain:",d),S("网络错误,请稍后再试")}finally{y(!1)}},$=async(C,p)=>{if(confirm(`确定要删除域名 "${p}"?删除后该域名的邮箱将无法注册。`)){l(C);try{(await be.admin.removeEmailDomain(C)).ok&&r(t.filter(j=>j.id!==C))}catch(d){console.error("Error removing domain:",d)}finally{l(null)}}},D=()=>{m(!1),x(""),S("")};return a?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(J,{variant:"default",size:"sm",onClick:()=>m(!0),className:"flex items-center gap-2",children:[e.jsx(st,{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(C=>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(ir,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:C.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(C.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>$(C.id,C.domain),disabled:n===C.id,title:"删除域名",children:e.jsx(Ze,{className:"w-4 h-4 text-red-500"})})})})]},C.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(ir,{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:"添加域名后,只有白名单内的域名邮箱可以注册"})]}),i&&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:D,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:z,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:C=>x(C.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:v}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),b&&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:b})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:D,disabled:v,children:"取消"}),e.jsx(J,{type:"submit",disabled:v,children:v?"添加中...":"添加"})]})]})]})})]})}function Mi({onBack:t}){const[r,a]=s.useState("week"),[o,n]=s.useState(null),[l,i]=s.useState(!0),[m,g]=s.useState(!1),x=async()=>{try{const D=await re(`/api/admin/usage/dashboard?period=${r}`);if(D.ok){const C=await D.json();n(C)}}catch(D){console.error("Error fetching dashboard data:",D)}finally{i(!1),g(!1)}};s.useEffect(()=>{i(!0),x()},[r]);const b=async()=>{try{g(!0),await re("/api/admin/usage/scan",{method:"POST"}),await x()}catch(D){console.error("Error triggering scan:",D),g(!1)}},S=D=>!D||D===0?"$0.00":D<.01?`$${D.toFixed(4)}`:`$${D.toFixed(2)}`,v=D=>D?D>=1e6?`${(D/1e6).toFixed(1)}M`:D>=1e3?`${(D/1e3).toFixed(1)}K`:D.toString():"0";if(l)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:y,dailyTrend:h,modelDistribution:z,topUsers:$}=o||{};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(J,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(xr,{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(D=>e.jsx("button",{onClick:()=>a(D),className:`px-4 py-2 text-sm font-medium transition-colors ${r===D?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:D==="week"?"周":"月"},D))}),e.jsx(J,{variant:"outline",size:"sm",onClick:b,disabled:m,title:"扫描新的使用数据",children:e.jsx(or,{className:`w-4 h-4 ${m?"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(Hs,{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:S(y?.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(dn,{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:[y?.activeUsers||0," / ",y?.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(Pt,{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:v(y?.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(mn,{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:v(y?.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:"每日成本趋势"}),h&&h.length>0?e.jsx("div",{className:"space-y-2",children:h.map(D=>{const C=Math.max(...h.map(d=>d.cost||0),.01),p=(D.cost||0)/C*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(D.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:S(D.cost)})]},D.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:"模型成本"}),z&&z.length>0?e.jsx("div",{className:"space-y-3",children:z.map(D=>{const C=z.reduce((L,B)=>L+(B.cost||0),0)||1,p=(D.cost||0)/C*100,d=(D.normalized_model||D.model||"").toLowerCase(),w=(L=>L.includes("codex")?"bg-orange-500":L.includes("opus")?"bg-purple-500":L.includes("sonnet")?"bg-blue-500":L.includes("haiku")?"bg-green-500":"bg-gray-500")(d);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 min-w-0",children:[e.jsx(Xe,{variant:"secondary",className:"truncate max-w-[200px]",title:D.model,children:D.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[v(D.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:S(D.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${w} rounded`,style:{width:`${p}%`}})})]},D.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:"用户成本"}),$&&$.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:$.map((D,C)=>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:["#",C+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:D.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:v(D.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:S(D.total_cost)})]},D.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Li({onClose:t,onInstalled:r,onOpenRepoManager:a}){const[o,n]=s.useState([]),[l,i]=s.useState([]),[m,g]=s.useState(!0),[x,b]=s.useState(null),[S,v]=s.useState(""),[y,h]=s.useState("all"),[z,$]=s.useState(null);s.useEffect(()=>{D()},[]);const D=async(d=!1)=>{try{g(!0),b(null),d&&await re("/api/skills/repos/refresh",{method:"POST"});const[j,w]=await Promise.all([re("/api/skills/available"),re("/api/skills/repos")]);if(j.ok){const L=await j.json();n(L.skills||[])}if(w.ok){const L=await w.json();i(L.repos||[])}}catch(j){b(j.message)}finally{g(!1)}},C=async d=>{try{$(d.name);const j=await re(`/api/skills/install/${d.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:d.path})});if(j.ok)D(),r?.();else{const w=await j.json();alert(w.error||"Failed to install skill")}}catch(j){alert(j.message)}finally{$(null)}},p=o.filter(d=>{if(S){const j=S.toLowerCase();if(!d.name.toLowerCase().includes(j)&&!d.title?.toLowerCase().includes(j)&&!d.description?.toLowerCase().includes(j))return!1}return!(y!=="all"&&d.repository!==y)});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(J,{variant:"ghost",size:"sm",onClick:()=>D(!0),disabled:m,children:[e.jsx(or,{className:`w-4 h-4 ${m?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(J,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(zt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Ue,{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(Rt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Qe,{type:"text",placeholder:"搜索技能名称或描述...",value:S,onChange:d=>v(d.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:y,onChange:d=>h(d.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:"全部"}),l.map(d=>e.jsxs("option",{value:`${d.owner}/${d.repo}`,children:[d.owner,"/",d.repo]},`${d.owner}/${d.repo}`))]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-4 pb-4",children:[x&&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:x}),m?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:o.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"没有可用的技能"}),e.jsx("p",{className:"text-xs mt-2",children:"请先添加技能仓库"}),e.jsxs(J,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(zt,{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(d=>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:d.title||d.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",d.name]}),e.jsx(Xe,{variant:"outline",className:"text-xs ml-2",children:d.repository})]})]}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${d.repository}`,"_blank"),children:[e.jsx(Js,{className:"w-4 h-4 mr-1"}),"查看"]}),d.installed?e.jsx(J,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(J,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>C(d),disabled:z===d.name,children:[e.jsx(Tt,{className:"w-4 h-4 mr-1"}),z===d.name?"安装中...":"安装"]})]})]})},`${d.repository}-${d.name}`))})]})]})})}function Ii({onClose:t,onChanged:r}){const[a,o]=s.useState([]),[n,l]=s.useState(!0),[i,m]=s.useState(null),[g,x]=s.useState(""),[b,S]=s.useState("main"),[v,y]=s.useState(!1),[h,z]=s.useState(null);s.useEffect(()=>{$()},[]);const $=async()=>{try{l(!0),m(null);const p=await re("/api/skills/repos");if(p.ok){const d=await p.json();o(d.repos||[])}else{const d=await p.json();m(d.error||"Failed to fetch repos")}}catch(p){m(p.message)}finally{l(!1)}},D=async p=>{if(p.preventDefault(),!g.trim()){m("请输入仓库 URL");return}try{y(!0),m(null);const d=await re("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:g.trim(),branch:b.trim()||"main"})});if(d.ok)x(""),S("main"),$(),r?.();else{const j=await d.json();m(j.error||"Failed to add repo")}}catch(d){m(d.message)}finally{y(!1)}},C=async(p,d)=>{if(confirm(`确定要移除仓库 "${p}/${d}" 吗?`))try{z(`${p}/${d}`);const j=await re(`/api/skills/repos/${p}/${d}`,{method:"DELETE"});if(j.ok)$(),r?.();else{const w=await j.json();alert(w.error||"Failed to remove repo")}}catch(j){alert(j.message)}finally{z(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(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(xr,{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:D,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(Qe,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:g,onChange:p=>x(p.target.value),disabled:v})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Qe,{type:"text",placeholder:"main",value:b,onChange:p=>S(p.target.value),disabled:v})]}),e.jsxs(J,{type:"submit",disabled:v||!g.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),v?"添加中...":"添加仓库"]})]})]}),i&&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:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"已添加的仓库"}),n?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"加载中..."}):a.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有添加任何仓库"})]}):a.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(pn,{className:"w-3 h-3"}),"分支: main"]}),e.jsxs(Xe,{variant:"outline",className:"text-xs",children:["识别到 ",p.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>window.open(p.url,"_blank"),children:e.jsx(Js,{className:"w-4 h-4"})}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>C(p.owner,p.repo),disabled:h===`${p.owner}/${p.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]})},`${p.owner}/${p.repo}`))]})]})]})})}function Di(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,m]=s.useState(!1),[g,x]=s.useState(!1),[b,S]=s.useState(!1),v=s.useRef(null);s.useEffect(()=>{y()},[]);const y=async()=>{try{o(!0),l(null);const C=await re("/api/skills");if(C.ok){const p=await C.json();r(p.skills||[])}else{const p=await C.json();l(p.error||"Failed to fetch skills")}}catch(C){l(C.message)}finally{o(!1)}},h=async C=>{if(confirm(`确定要删除技能 "${C}" 吗?`))try{const p=await re(`/api/skills/${C}`,{method:"DELETE"});if(p.ok)y();else{const d=await p.json();alert(d.error||"Failed to delete skill")}}catch(p){alert(p.message)}},z=()=>{v.current?.click()},$=async C=>{const p=C.target.files?.[0];if(p)try{S(!0);const d=new FormData;d.append("skillZip",p);const j=await re("/api/skills/import",{method:"POST",body:d});if(j.ok)y();else{const w=await j.json();alert(w.error||"Failed to import skill")}}catch(d){alert(d.message)}finally{S(!1),v.current&&(v.current.value="")}},D=(C,p)=>{switch(C){case"repo":return e.jsx(Xe,{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(Xe,{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(Xe,{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(zr,{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:v,type:"file",accept:".zip",className:"hidden",onChange:$}),e.jsxs(J,{onClick:z,variant:"outline",size:"sm",disabled:b,children:[e.jsx(Tt,{className:"w-4 h-4 mr-2"}),b?"导入中...":"导入已有"]}),e.jsxs(J,{onClick:()=>m(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(Rt,{className:"w-4 h-4 mr-2"}),"发现技能"]})]})]}),n&&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:n}),e.jsx("div",{className:"space-y-2",children:a?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(zr,{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(C=>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:C.title||C.name}),D(C.source,C.repository)]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:C.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>h(C.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ze,{className:"w-4 h-4"})})})]})},C.name))}),i&&e.jsx(Li,{onClose:()=>m(!1),onInstalled:y,onOpenRepoManager:()=>{m(!1),x(!0)}}),g&&e.jsx(Ii,{onClose:()=>x(!1),onChanged:()=>{}})]})}function Ti({isOpen:t,onClose:r,projects:a=[],initialTab:o="agents"}){const n=$s(),{isDarkMode:l,toggleDarkMode:i}=ts(),{user:m,logout:g}=Ot(),x=m?.role==="admin",[b,S]=s.useState([]),[v,y]=s.useState([]),[h,z]=s.useState(""),[$,D]=s.useState(""),[C,p]=s.useState(!1),[d,j]=s.useState(!1),[w,L]=s.useState(null),[B,W]=s.useState("name"),[Z,le]=s.useState([]),[X,ne]=s.useState(!1),[U,I]=s.useState(null),[_,Q]=s.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[he,ie]=s.useState(!1),[Y,ge]=s.useState({}),[Ne,Le]=s.useState({}),[je,Oe]=s.useState({}),[pe,Se]=s.useState(o),[we,Ie]=s.useState(""),[xe,Ce]=s.useState("permissions"),[Re,Ee]=s.useState(!1),Be=s.useRef(null),[P,O]=s.useState({saving:!1,hasChanges:!1}),F=s.useCallback(T=>O(T),[]),[f,H]=s.useState(""),[de,Me]=s.useState(""),[$e,Ke]=s.useState(""),[u,A]=s.useState(""),[oe,se]=s.useState(""),[M,De]=s.useState(!1),[qe,Te]=s.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[K,ue]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[te,ce]=s.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[ve,Ae]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[fe,He]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),ut=async()=>{try{const T=await re("/api/mcp/config/read");if(T.ok){const ke=await T.json();if(ke.success&&ke.servers){le(ke.servers);return}}const G=await re("/api/mcp/cli/list");if(G.ok){const ke=await G.json();if(ke.success&&ke.servers){const Ve=ke.servers.map(Fe=>({id:Fe.name,name:Fe.name,type:Fe.type,scope:"user",config:{command:Fe.command||"",args:Fe.args||[],env:Fe.env||{},url:Fe.url||"",headers:Fe.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));le(Ve);return}}const ae=await re("/api/mcp/servers?scope=user");if(ae.ok){const ke=await ae.json();le(ke.servers||[])}else console.error("Failed to fetch MCP servers")}catch(T){console.error("Error fetching MCP servers:",T)}},tt=async T=>{try{U&&await Nt(U.id,"user");const G=await re("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:T.name,type:T.type,scope:T.scope,projectPath:T.projectPath,command:T.config?.command,args:T.config?.args||[],url:T.config?.url,headers:T.config?.headers||{},env:T.config?.env||{}})});if(G.ok){const ae=await G.json();if(ae.success)return await ut(),!0;throw new Error(ae.error||"Failed to save server via Claude CLI")}else{const ae=await G.json();throw new Error(ae.error||"Failed to save server")}}catch(G){throw console.error("Error saving MCP server:",G),G}},Nt=async(T,G="user")=>{try{const ae=await re(`/api/mcp/cli/remove/${T}?scope=${G}`,{method:"DELETE"});if(ae.ok){const ke=await ae.json();if(ke.success)return await ut(),!0;throw new Error(ke.error||"Failed to delete server via Claude CLI")}else{const ke=await ae.json();throw new Error(ke.error||"Failed to delete server")}}catch(ae){throw console.error("Error deleting MCP server:",ae),ae}},bt=async(T,G="user")=>{try{const ae=await re(`/api/mcp/servers/${T}/test?scope=${G}`,{method:"POST"});if(ae.ok)return(await ae.json()).testResult;{const ke=await ae.json();throw new Error(ke.error||"Failed to test server")}}catch(ae){throw console.error("Error testing MCP server:",ae),ae}},Gt=async(T,G="user")=>{try{const ae=await re(`/api/mcp/servers/${T}/tools?scope=${G}`,{method:"POST"});if(ae.ok)return(await ae.json()).toolsResult;{const ke=await ae.json();throw new Error(ke.error||"Failed to discover tools")}}catch(ae){throw console.error("Error discovering MCP tools:",ae),ae}};s.useEffect(()=>{t&&(hr(),Se(o),Ee(!1))},[t,o]),s.useEffect(()=>{localStorage.setItem("codeEditorTheme",qe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[qe]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",K.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[K]),s.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",te.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[te]),s.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",ve.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ve]),s.useEffect(()=>{localStorage.setItem("codeEditorFontSize",fe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[fe]);const hr=async()=>{try{let T=null;try{const G=await be.settings.getAgentPermissions();G.ok&&(T=(await G.json()).agentPermissions)}catch{}if(T)S(T.allowedTools||[]),y(T.disallowedTools||[]),p(T.skipPermissions||!1),W(T.projectSortOrder||"name"),localStorage.setItem("claude-settings",JSON.stringify(T));else{const G=localStorage.getItem("claude-settings");if(G){const ae=JSON.parse(G);S(ae.allowedTools||[]),y(ae.disallowedTools||[]),p(ae.skipPermissions||!1),W(ae.projectSortOrder||"name")}else S([]),y([]),p(!1),W("name")}await ut()}catch(T){console.error("Error loading tool settings:",T),S([]),y([]),p(!1),W("name")}},at=async()=>{j(!0),L(null);try{const T={allowedTools:b,disallowedTools:v,skipPermissions:C,projectSortOrder:B,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(T));try{await be.settings.saveAgentPermissions(T)}catch(G){console.warn("Failed to sync agent permissions to server:",G)}L("success"),setTimeout(()=>{r()},1e3)}catch(T){console.error("Error saving tool settings:",T),L("error")}finally{j(!1)}},gr=async T=>{if(T.preventDefault(),A(""),se(""),!f){A("请输入当前密码");return}if(!de){A("请输入新密码");return}if(de.length<6){A("新密码至少需要6个字符");return}if(de!==$e){A("两次输入的新密码不一致");return}De(!0);try{const G=await be.auth.changePassword(f,de),ae=await G.json();G.ok?(se("密码修改成功"),H(""),Me(""),Ke("")):A(ae.error||"修改密码失败")}catch(G){console.error("Error changing password:",G),A("网络错误,请稍后再试")}finally{De(!1)}},_t=m?.username&&!m.username.includes("@"),it=()=>{Q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),I(null),ne(!1),Ie("")},Ft=(T=null)=>{T?(I(T),Q({name:T.name,type:T.type,scope:T.scope,projectPath:T.projectPath||"",config:{...T.config},raw:T.raw,importMode:"form",jsonInput:""})):it(),ne(!0)},St=async T=>{T.preventDefault(),ie(!0);try{if(_.importMode==="json"){const G=await re("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:_.name,jsonConfig:_.jsonInput,scope:_.scope,projectPath:_.projectPath})});if(G.ok){const ae=await G.json();if(ae.success)await ut(),it(),L("success");else throw new Error(ae.error||"Failed to add server via JSON")}else{const ae=await G.json();throw new Error(ae.error||"Failed to add server")}}else await tt(_),it(),L("success")}catch(G){alert(`Error: ${G.message}`),L("error")}finally{ie(!1)}},Vt=async(T,G)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await Nt(T,G),L("success")}catch(ae){alert(`Error: ${ae.message}`),L("error")}},Ct=async(T,G)=>{try{ge({...Y,[T]:{loading:!0}});const ae=await bt(T,G);ge({...Y,[T]:ae})}catch(ae){ge({...Y,[T]:{success:!1,message:ae.message,details:[]}})}},fr=async(T,G)=>{try{Oe({...je,[T]:!0});const ae=await Gt(T,G);Le({...Ne,[T]:ae})}catch{Le({...Ne,[T]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{Oe({...je,[T]:!1})}},Ge=(T,G)=>{Q(ae=>({...ae,config:{...ae.config,[T]: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(zt,{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(J,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ue,{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:()=>Se("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agent"}),e.jsx("button",{onClick:()=>Se("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"外观"}),x&&e.jsx("button",{onClick:()=>Se("users"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="users"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"用户"}),e.jsx("button",{onClick:()=>Se("account"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${pe==="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:[pe==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:pe==="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:i,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":l,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${l?"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:l?e.jsx($r,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ar,{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:T=>W(T.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:()=>Te(qe==="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":qe==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${qe==="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:qe==="dark"?e.jsx($r,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ar,{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:()=>ue(!K),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":K,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${K?"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:()=>ce(!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 minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),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:()=>Ae(!ve),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":ve,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${ve?"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:fe,onChange:T=>He(T.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"})]})]})})]})]})}),pe==="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:()=>Ce("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 ${xe==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Ce("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 ${xe==="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:()=>Ce("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 ${xe==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Ce("models"),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 ${xe==="models"?"border-blue-600 text-blue-600 dark:text-blue-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:[xe==="permissions"&&e.jsx(bi,{agent:"claude",skipPermissions:C,setSkipPermissions:p,allowedTools:b,setAllowedTools:S,disallowedTools:v,setDisallowedTools:y,newAllowedTool:h,setNewAllowedTool:z,newDisallowedTool:$,setNewDisallowedTool:D}),xe==="mcp"&&e.jsx(ki,{agent:"claude",servers:Z,onAdd:()=>Ft(),onEdit:T=>Ft(T),onDelete:(T,G)=>Vt(T,G),onTest:(T,G)=>Ct(T,G),onDiscoverTools:(T,G)=>fr(T,G),testResults:Y,serverTools:Ne,toolsLoading:je}),xe==="skills"&&e.jsx(Di,{}),xe==="models"&&e.jsx(Si,{ref:Be,onStatusChange:F})]})]})}),pe==="users"&&x&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Re?e.jsx(Mi,{onBack:()=>Ee(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ci,{onNavigateToUsage:()=>Ee(!0)}),e.jsx(Ei,{})]})}),pe==="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:m?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:m?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m?.role==="admin"?"管理员":"用户"})]})]})}),_t&&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("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(qs,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:gr,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"currentPassword",className:"block text-sm font-medium text-foreground mb-1",children:"当前密码"}),e.jsx("input",{type:"password",id:"currentPassword",value:f,onChange:T=>H(T.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:M})]}),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:de,onChange:T=>Me(T.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:"请输入新密码(至少6个字符)",disabled:M})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"confirmNewPassword",value:$e,onChange:T=>Ke(T.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:M})]}),u&&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:u})}),oe&&e.jsx("div",{className:"p-3 bg-green-100 dark:bg-green-900/20 border border-green-300 dark:border-green-800 rounded-md",children:e.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:oe})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{type:"submit",disabled:M,className:"bg-blue-600 hover:bg-blue-700",children:M?"修改中...":"修改密码"})})]})]}),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(J,{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(),n("/"),g())},children:[e.jsx(xn,{className:"w-4 h-4"}),"退出"]})]})})]})}),X&&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:U?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(J,{variant:"ghost",size:"sm",onClick:it,children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:St,className:"p-4 space-y-4",children:[!U&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>Q(T=>({...T,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.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:()=>Q(T=>({...T,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.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 导入"})]}),_.importMode==="form"&&U&&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:[_.scope==="user"?e.jsx(Rr,{className:"w-4 h-4"}):e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:_.scope==="user"?"用户(全局)":"项目(本地)"}),_.scope==="local"&&_.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",_.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),_.importMode==="form"&&!U&&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:()=>Q(T=>({...T,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.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(Rr,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>Q(T=>({...T,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.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(wt,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:_.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),_.scope==="local"&&!U&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:_.projectPath,onChange:T=>Q(G=>({...G,projectPath:T.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:_.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),a.map(T=>e.jsx("option",{value:T.path||T.fullPath,children:T.displayName||T.name},T.name))]}),_.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",_.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:_.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(Qe,{value:_.name,onChange:T=>{Q(G=>({...G,name:T.target.value}))},placeholder:"my-server",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:_.type,onChange:T=>{Q(G=>({...G,type:T.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"})]})]})]}),U&&_.raw&&_.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 ",U.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(_.raw,null,2)})]}),_.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:_.jsonInput,onChange:T=>{Q(G=>({...G,jsonInput:T.target.value}));try{if(T.target.value.trim()){const G=JSON.parse(T.target.value);G.type?G.type==="stdio"&&!G.command?Ie("stdio 类型需要 command 字段"):(G.type==="http"||G.type==="sse")&&!G.url?Ie(`${G.type} 类型需要 url 字段`):Ie(""):Ie("缺少必填字段:type")}}catch{T.target.value.trim()?Ie("无效的 JSON 格式"):Ie("")}},className:`w-full px-3 py-2 border ${we?"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:`{
136
136
  "type": "stdio",
137
137
  "command": "/path/to/server",
138
138
  "args": ["--api-key", "abc123"],
@@ -148,4 +148,4 @@ abc123`})]})]}),_.importMode==="form"&&(_.type==="sse"||_.type==="http")&&e.jsxs
148
148
  DEBUG=true`})]}),_.importMode==="form"&&(_.type==="sse"||_.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(_.config.headers||{}).map(([T,G])=>`${T}=${G}`).join(`
149
149
  `),onChange:T=>{const G={};T.target.value.split(`
150
150
  `).forEach(ae=>{const[ke,...Ve]=ae.split("=");ke&&ke.trim()&&(G[ke.trim()]=Ve.join("=").trim())}),Ge("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
151
- X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(J,{type:"button",variant:"outline",onClick:it,children:"取消"}),e.jsx(J,{type:"submit",disabled:he,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:he?"保存中...":U?"更新服务器":"添加服务器"})]})]})]})})]})]}),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.jsx("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:pe==="agents"&&xe==="models"?P.saving?e.jsx("span",{className:"text-sm text-muted-foreground",children:"保存中..."}):null:e.jsxs(e.Fragment,{children:[w==="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"})}),"设置保存成功!"]}),w==="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:[pe==="agents"&&xe==="models"&&P.hasChanges&&e.jsx(J,{variant:"outline",onClick:()=>Be.current?.reset(),disabled:P.saving,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"重置"}),e.jsx(J,{variant:"outline",onClick:r,disabled:d||P.saving,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"取消"}),e.jsx(J,{onClick:pe==="agents"&&xe==="models"?()=>Be.current?.save():at,disabled:pe==="agents"&&xe==="models"?P.saving||!P.hasChanges:d,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:d||P.saving?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 Pi(){const{isDarkMode:t,toggleDarkMode:r}=ts();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 Ri=({isOpen:t,onToggle:r,autoExpandTools:a,onAutoExpandChange:o,showRawParameters:n,onShowRawParametersChange:l,showThinking:i,onShowThinkingChange:m,autoScrollToBottom:g,onAutoScrollChange:x,sendByCtrlEnter:b,onSendByCtrlEnterChange:S,isMobile:v})=>{const[y,h]=s.useState(t),[z,$]=s.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:D}=ts(),[C,p]=s.useState(()=>{const Y=localStorage.getItem("quickSettingsHandlePosition");if(Y)try{return JSON.parse(Y).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[d,j]=s.useState(!1),[w,I]=s.useState(0),[B,W]=s.useState(0),[Z,le]=s.useState(!1),X=s.useRef(null),ne=s.useRef({min:10,max:90}),U=5;s.useEffect(()=>{h(t)},[t]),s.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:C}))},[C]);const L=s.useCallback(()=>v?{bottom:`${window.innerHeight*C/100}px`}:{top:`${C}%`,transform:"translateY(-50%)"},[C,v]),_=s.useCallback(Y=>{Y.stopPropagation();const ge=Y.type.includes("touch")?Y.touches[0].clientY:Y.clientY;I(ge),W(C),le(!1),j(!1)},[C]),Q=s.useCallback(Y=>{if(w===0)return;const ge=Y.type.includes("touch")?Y.touches[0].clientY:Y.clientY,Ne=Math.abs(ge-w);if(!d&&Ne>U&&(j(!0),le(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",Y.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!d)return;Y.type.includes("touch")&&Y.preventDefault();const Le=ge-w;let je;v?je=-(Le/window.innerHeight)*100:je=Le/window.innerHeight*100;let Oe=B+je;Oe=Math.max(ne.current.min,Math.min(ne.current.max,Oe)),p(Oe)},[d,w,B,v,U]),he=s.useCallback(()=>{j(!1),I(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);s.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),s.useEffect(()=>{if(w!==0){const Y=je=>Q(je),ge=()=>he(),Ne=je=>Q(je),Le=()=>he();return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",ge),document.addEventListener("touchmove",Ne,{passive:!1}),document.addEventListener("touchend",Le),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",ge),document.removeEventListener("touchmove",Ne),document.removeEventListener("touchend",Le)}}},[w,Q,he]);const ie=Y=>{if(Z){Y.preventDefault(),le(!1);return}const ge=!y;h(ge),r(ge)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:X,onClick:ie,onMouseDown:Y=>{_(Y)},onTouchStart:Y=>{_(Y)},className:`fixed ${y?"right-64":"right-0"} z-50 ${d?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${d?"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 ${d?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...L(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":d?"拖动手柄":y?"关闭设置面板":"打开设置面板",title:d?"拖动中...":"点击切换,拖动移动",children:d?e.jsx(hn,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):y?e.jsx(Dt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(gn,{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 ${y?"translate-x-0":"translate-x-full"} ${v?"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(fn,{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 ${v?"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:[D?e.jsx($r,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Ar,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"深色模式"]}),e.jsx(Pi,{})]})]}),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(_s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动展开工具"]}),e.jsx("input",{type:"checkbox",checked:a,onChange:Y=>o(Y.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(Fs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示原始参数"]}),e.jsx("input",{type:"checkbox",checked:n,onChange:Y=>l(Y.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(Os,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示思考过程"]}),e.jsx("input",{type:"checkbox",checked:i,onChange:Y=>m(Y.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(bn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动滚动到底部"]}),e.jsx("input",{type:"checkbox",checked:g,onChange:Y=>x(Y.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(yn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"使用 Ctrl+Enter 发送"]}),e.jsx("input",{type:"checkbox",checked:b,onChange:Y=>S(Y.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:z==="default",onChange:()=>{$("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(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:"直接转录您的语音"})]})]}),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:z==="prompt",onChange:()=>{$("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(zr,{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:z==="vibe"||z==="instructions"||z==="architect",onChange:()=>{$("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(Ws,{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:"将想法格式化为带有详细说明的代理指令"})]})]})]})]})]})]})}),y&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:ie})]})};function zi({isOpen:t,limitType:r,onClose:a}){if(!t)return null;const o=r==="total_limit_exceeded";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[100]",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-6 mx-4 animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o?"使用上限已达到":"今日使用上限已达到"})})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"mb-6 text-muted-foreground space-y-3",children:o?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您的账户已达到使用总额度上限。"}),e.jsx("p",{className:"text-sm",children:"请联系管理员提升您的额度限制,以继续使用 Claude 服务。"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您已达到今日使用额度上限。"}),e.jsx("p",{className:"text-sm",children:"您可以等待明日额度重置后继续使用,或联系管理员提升您的每日额度限制。"})]})}),e.jsx("div",{className:"mb-6 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"请联系您的管理员,申请提升使用额度。"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"每日额度将在次日 00:00 自动重置,您也可以联系管理员调整限额。"]})})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{variant:"default",onClick:a,children:"我知道了"})})]})})}function $i(){const[t,r]=s.useState(null),[a,o]=s.useState([]),[n,l]=s.useState(!1),i=s.useRef(null),m=s.useRef(null),{token:g}=Ot();s.useEffect(()=>(i.current&&(clearTimeout(i.current),i.current=null),m.current&&(m.current.close(),m.current=null),g||!1?x():(l(!1),r(null)),()=>{i.current&&clearTimeout(i.current),m.current&&m.current.close()}),[g]);const x=()=>{try{let v;{const h=g||localStorage.getItem("auth-token");if(!h){console.warn("No authentication token found for WebSocket connection");return}v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?token=${encodeURIComponent(h)}`}const y=new WebSocket(v);m.current=y,y.onopen=()=>{l(!0),r(y)},y.onmessage=h=>{try{const z=JSON.parse(h.data);o($=>[...$,z])}catch(z){console.error("Error parsing WebSocket message:",z)}},y.onclose=()=>{l(!1),r(null),m.current=null,localStorage.getItem("auth-token")&&(i.current=setTimeout(()=>{x()},3e3))},y.onerror=h=>{console.error("WebSocket error:",h)}}catch(S){console.error("Error creating WebSocket connection:",S)}};return{ws:t,sendMessage:S=>{t&&n?t.send(JSON.stringify(S)):console.warn("WebSocket not connected")},messages:a,isConnected:n}}const oa=s.createContext({ws:null,sendMessage:()=>{},messages:[],isConnected:!1}),Ai=()=>{const t=s.useContext(oa);if(!t)throw new Error("useWebSocketContext must be used within a WebSocketProvider");return t},Oi=({children:t})=>{const r=$i();return e.jsx(oa.Provider,{value:r,children:t})},_i=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState(""),[n,l]=s.useState(""),[i,m]=s.useState(!1),[g,x]=s.useState(""),[b,S]=s.useState(0),{sendCode:v,verifyCode:y,smtpConfigured:h}=Ot();s.useEffect(()=>{if(b>0){const p=setTimeout(()=>S(b-1),1e3);return()=>clearTimeout(p)}},[b]);const z=async p=>{if(p.preventDefault(),x(""),!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){x("请输入有效的邮箱地址");return}m(!0);const j=await v(a);j.success?(r("code"),S(60)):(x(j.error),j.waitSeconds&&S(j.waitSeconds)),m(!1)},$=async p=>{if(p.preventDefault(),x(""),!n||n.length!==6){x("请输入6位验证码");return}m(!0);const d=await y(a,n);d.success||x(d.error),m(!1)},D=async()=>{if(b>0)return;x(""),m(!0);const p=await v(a);p.success?S(60):x(p.error),m(!1)},C=()=>{r("email"),l(""),x("")};return h?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(ot,{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"?"输入邮箱创建管理员账户":`验证码已发送至 ${a}`})]}),t==="email"&&e.jsxs("form",{onSubmit:z,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(ir,{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:a,onChange:p=>o(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:i,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:i||b>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:i?"发送中...":b>0?`${b}秒后可重新发送`:"获取验证码"})]}),t==="code"&&e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:C,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{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:n,onChange:p=>l(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:i,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:i||n.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:i?"创建中...":"创建管理员账户"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:D,disabled:b>0||i,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:b>0?`${b}秒后可重新发送`:"重新发送验证码"})})]}),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(ot,{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"})]})]})]})})})},Fi=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState("email"),[n,l]=s.useState(""),[i,m]=s.useState(""),[g,x]=s.useState(""),[b,S]=s.useState(""),[v,y]=s.useState(!1),[h,z]=s.useState(""),[$,D]=s.useState(0),[C,p]=s.useState(!1),{login:d,sendCode:j,verifyCode:w,smtpConfigured:I}=Ot();s.useEffect(()=>{if($>0){const L=setTimeout(()=>D($-1),1e3);return()=>clearTimeout(L)}},[$]),s.useEffect(()=>{I||r("password")},[I]);const B=async L=>{if(L.preventDefault(),z(""),!n||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){z("请输入有效的邮箱地址");return}y(!0);const Q=await j(n);Q.success?(o("code"),D(60),p(Q.type==="register")):(z(Q.error),Q.waitSeconds&&D(Q.waitSeconds)),y(!1)},W=async L=>{if(L.preventDefault(),z(""),!i||i.length!==6){z("请输入6位验证码");return}y(!0);const _=await w(n,i);_.success||z(_.error),y(!1)},Z=async()=>{if($>0)return;z(""),y(!0);const L=await j(n);L.success?D(60):z(L.error),y(!1)},le=async L=>{if(L.preventDefault(),z(""),!g||!b){z("请输入用户名和密码");return}y(!0);const _=await d(g,b);_.success||z(_.error),y(!1)},X=()=>{o("email"),m(""),z("")},ne=()=>{r("email"),o("email"),z("")},U=()=>{r("password"),z("")};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(Pt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?a==="email"?"欢迎使用 AgentHub":C?"创建您的账户":"验证您的身份":"欢迎回来"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?a==="email"?"输入邮箱以接收验证码":`验证码已发送至 ${n}`:"使用账号密码登录"})]}),t==="email"&&a==="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(ir,{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:n,onChange:L=>l(L.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:v,autoComplete:"email"})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v||$>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:v?"发送中...":$>0?`${$}秒后可重新发送`:"获取验证码"})]}),t==="email"&&a==="code"&&e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:X,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{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:i,onChange:L=>m(L.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:v,maxLength:6,autoComplete:"one-time-code"})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v||i.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:v?"验证中...":C?"创建账户并登录":"登录"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:Z,disabled:$>0||v,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:$>0?`${$}秒后可重新发送`:"重新发送验证码"})})]}),t==="password"&&e.jsxs("form",{onSubmit:le,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(Us,{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:L=>x(L.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:v})]})]}),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(vn,{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:b,onChange:L=>S(L.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:v})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v,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:v?"登录中...":"登录"})]}),e.jsx("div",{className:"text-center pt-4 border-t border-border",children:t==="email"&&I?e.jsx("button",{type:"button",onClick:U,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用账号密码登录"}):t==="password"&&I?e.jsx("button",{type:"button",onClick:ne,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用邮箱验证码登录"}):null})]})})})},Wi=()=>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(Pt,{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:"加载中..."})]})}),Bi=({children:t})=>{const{user:r,isLoading:a,needsSetup:o}=Ot();return a?e.jsx(Wi,{}):o?e.jsx(_i,{}):r?t:e.jsx(Fi,{})};function It(t,r){const[a,o]=s.useState(()=>{if(typeof window>"u")return r;try{const l=window.localStorage.getItem(t);return l?JSON.parse(l):r}catch(l){return console.log(l),r}});return[a,l=>{if(!(typeof window>"u"))try{const i=l instanceof Function?l(a):l;window.localStorage.setItem(t,JSON.stringify(i)),o(i)}catch(i){console.log(i)}}]}function zs(){const t=$s(),{sessionId:r}=qa(),{limitStatus:a,setLimitStatus:o,checkLimitStatus:n}=Ot(),[l,i]=s.useState([]),[m,g]=s.useState(null),[x,b]=s.useState(null),[S,v]=s.useState("chat"),[y,h]=s.useState(!1),[z,$]=s.useState(!1),[D,C]=s.useState(!0),[p,d]=s.useState(!1),[j,w]=s.useState(!1),[I,B]=s.useState("agents"),[W,Z]=s.useState(!1),[le,X]=It("autoExpandTools",!1),[ne,U]=It("showRawParameters",!1),[L,_]=It("showThinking",!0),[Q,he]=It("autoScrollToBottom",!0),[ie,Y]=It("sendByCtrlEnter",!1),[ge,Ne]=It("sidebarVisible",!0),[Le,je]=s.useState(!1),[Oe,pe]=s.useState(null),[Se,we]=s.useState(new Set),[Ie,xe]=s.useState(new Set),[Ce,Re]=s.useState(0),{ws:Ee,sendMessage:Be,messages:P}=Ai(),O=s.useCallback(K=>{pe(K),je(!0)},[]),[F,f]=s.useState(!1);s.useEffect(()=>{const K=()=>{const ue=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");f(ue),document.addEventListener("touchstart",{}),ue?(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 K(),window.matchMedia("(display-mode: standalone)").addEventListener("change",K),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",K)}},[]),s.useEffect(()=>{const K=()=>{h(window.innerWidth<768)};return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[]),s.useEffect(()=>{de()},[]);const H=(K,ue,te,ce)=>{if(!te||!ce)return!0;const ve=K?.find(tt=>tt.name===te.name),Ae=ue?.find(tt=>tt.name===te.name);if(!ve||!Ae)return!1;const fe=ve.sessions?.find(tt=>tt.id===ce.id),He=Ae.sessions?.find(tt=>tt.id===ce.id);return!fe||!He?!1:fe.id===He.id&&fe.title===He.title&&fe.created_at===He.created_at&&fe.updated_at===He.updated_at};s.useEffect(()=>{if(P.length>0){const K=P[P.length-1];if(K.type==="projects_updated"){if(K.changedFile&&x&&m){const ve=K.changedFile.replace(/\\/g,"/").split("/");ve.length>=2&&ve[ve.length-1].replace(".jsonl","")===x.id&&(Se.has(x.id)||Re(ut=>ut+1))}if(x&&Se.has(x.id)||Se.size>0&&Array.from(Se).some(ce=>ce.startsWith("new-session-"))){const ce=K.projects;if(!H(l,ce,m,x))return}const te=K.projects;if(i(te),m){const ce=te.find(ve=>ve.name===m.name);ce&&(JSON.stringify(ce)!==JSON.stringify(m)&&g(ce),x&&([...ce.sessions||[]].find(fe=>fe.id===x.id)||b(null)))}}}},[P,m,x,Se]);const de=async()=>{try{C(!0);const ue=await(await be.projects()).json();i(te=>te.length===0||ue.some((ve,Ae)=>{const fe=te[Ae];return fe?ve.name!==fe.name||ve.displayName!==fe.displayName||ve.fullPath!==fe.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(fe.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(fe.sessions):!0})||ue.length!==te.length?ue:te)}catch(K){console.error("Error fetching projects:",K)}finally{C(!1)}};window.refreshProjects=de,window.openSettings=s.useCallback((K="tools")=>{B(K),w(!0)},[]),s.useEffect(()=>{if(r&&l.length>0){const K=!x||x.id!==r;for(const ue of l){let te=ue.sessions?.find(ce=>ce.id===r);if(te){g(ue),b({...te,__provider:"claude"}),K&&v("chat");return}}}},[r,l,t]);const Me=K=>{g(K),b(null),t("/"),y&&$(!1)},$e=K=>{if(b(K),S!=="git"&&S!=="preview"&&v("chat"),y){const ue=K.__projectName,te=m?.name;ue!==te&&$(!1)}t(`/session/${K.id}`)},Ke=K=>{g(K),b(null),v("chat"),t("/"),y&&$(!1)},u=K=>{x?.id===K&&(b(null),t("/")),i(ue=>ue.map(te=>({...te,sessions:te.sessions?.filter(ce=>ce.id!==K)||[],sessionMeta:{...te.sessionMeta,total:Math.max(0,(te.sessionMeta?.total||0)-1)}})))},A=async()=>{try{const ue=await(await be.projects()).json();if(i(te=>ue.some((ve,Ae)=>{const fe=te[Ae];return fe?ve.name!==fe.name||ve.displayName!==fe.displayName||ve.fullPath!==fe.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(fe.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(fe.sessions):!0})||ue.length!==te.length?ue:te),m){const te=ue.find(ce=>ce.name===m.name);if(te&&(JSON.stringify(te)!==JSON.stringify(m)&&g(te),x)){const ce=te.sessions?.find(ve=>ve.id===x.id);ce&&JSON.stringify(ce)!==JSON.stringify(x)&&b(ce)}}}catch(K){console.error("Error refreshing sidebar:",K)}},oe=K=>{m?.name===K&&(g(null),b(null),t("/")),i(ue=>ue.filter(te=>te.name!==K))},re=s.useCallback(K=>{K&&we(ue=>new Set([...ue,K]))},[]),M=s.useCallback(K=>{K&&we(ue=>{const te=new Set(ue);return te.delete(K),te})},[]),De=s.useCallback(K=>{K&&xe(ue=>new Set([...ue,K]))},[]),qe=s.useCallback(K=>{K&&xe(ue=>{const te=new Set(ue);return te.delete(K),te})},[]),Te=s.useCallback(K=>{K&&we(ue=>{const te=new Set;for(const ce of ue)ce.startsWith("new-session-")||te.add(ce);return te.add(K),te})},[]);return e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[!y&&e.jsx("div",{className:`h-full flex-shrink-0 border-r border-border bg-card transition-all duration-300 ${ge?"w-80":"w-14"}`,children:e.jsx("div",{className:"h-full overflow-hidden",children:ge?e.jsx(fs,{projects:l,selectedProject:m,selectedSession:x,onProjectSelect:Me,onSessionSelect:$e,onNewSession:Ke,onSessionDelete:u,onProjectDelete:oe,isLoading:D,onRefresh:A,onShowSettings:()=>w(!0),isPWA:F,isMobile:y,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:()=>w(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200","aria-label":"Settings",title:"Settings",children:e.jsx(zt,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})})]})})}),y&&e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${z?"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:K=>{K.stopPropagation(),$(!1)},onTouchStart:K=>{K.preventDefault(),K.stopPropagation(),$(!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 ${z?"translate-x-0":"-translate-x-full"}`,onClick:K=>K.stopPropagation(),onTouchStart:K=>K.stopPropagation(),children:e.jsx(fs,{projects:l,selectedProject:m,selectedSession:x,onProjectSelect:Me,onSessionSelect:$e,onNewSession:Ke,onSessionDelete:u,onProjectDelete:oe,isLoading:D,onRefresh:A,onShowSettings:()=>w(!0),isPWA:F,isMobile:y,onToggleSidebar:()=>Ne(!1)})})]}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${y&&!p?"pb-mobile-nav":""}`,children:e.jsx(ci,{selectedProject:m,selectedSession:x,activeTab:S,setActiveTab:v,ws:Ee,sendMessage:Be,messages:P,isMobile:y,isPWA:F,onMenuClick:()=>$(!0),isLoading:D,onInputFocusChange:d,onSessionActive:re,onSessionInactive:M,onSessionProcessing:De,onSessionNotProcessing:qe,processingSessions:Ie,onReplaceTemporarySession:Te,onNavigateToSession:K=>t(`/session/${K}`),onShowSettings:()=>w(!0),autoExpandTools:le,showRawParameters:ne,showThinking:L,autoScrollToBottom:Q,sendByCtrlEnter:ie,externalMessageUpdate:Ce,limitStatus:a,onLimitBlocked:O,checkLimitStatus:n})}),y&&e.jsx(di,{activeTab:S,setActiveTab:v,isInputFocused:p}),S==="chat"&&e.jsx(Ri,{isOpen:W,onToggle:Z,autoExpandTools:le,onAutoExpandChange:X,showRawParameters:ne,onShowRawParametersChange:U,showThinking:L,onShowThinkingChange:_,autoScrollToBottom:Q,onAutoScrollChange:he,sendByCtrlEnter:ie,onSendByCtrlEnterChange:Y,isMobile:y}),e.jsx(Ti,{isOpen:j,onClose:()=>w(!1),projects:l,initialTab:I}),e.jsx(zi,{isOpen:Le,limitType:Oe,onClose:()=>je(!1)})]})}function Ui(){return e.jsx(mi,{children:e.jsx(ui,{children:e.jsx(Oi,{children:e.jsx(Bi,{children:e.jsx(Ua,{children:e.jsxs(Ha,{children:[e.jsx(ms,{path:"/",element:e.jsx(zs,{})}),e.jsx(ms,{path:"/session/:sessionId",element:e.jsx(zs,{})})]})})})})})})}"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(r=>{r.unregister()})}).catch(t=>{console.warn("Failed to unregister service workers:",t)});Tn.createRoot(document.getElementById("root")).render(e.jsx(et.StrictMode,{children:e.jsx(Ui,{})}));
151
+ X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(J,{type:"button",variant:"outline",onClick:it,children:"取消"}),e.jsx(J,{type:"submit",disabled:he,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:he?"保存中...":U?"更新服务器":"添加服务器"})]})]})]})})]})]}),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.jsx("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:pe==="agents"&&xe==="models"?P.saving?e.jsx("span",{className:"text-sm text-muted-foreground",children:"保存中..."}):null:e.jsxs(e.Fragment,{children:[w==="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"})}),"设置保存成功!"]}),w==="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:[pe==="agents"&&xe==="models"&&P.hasChanges&&e.jsx(J,{variant:"outline",onClick:()=>Be.current?.reset(),disabled:P.saving,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"重置"}),e.jsx(J,{variant:"outline",onClick:r,disabled:d||P.saving,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"取消"}),e.jsx(J,{onClick:pe==="agents"&&xe==="models"?()=>Be.current?.save():at,disabled:pe==="agents"&&xe==="models"?P.saving||!P.hasChanges:d,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:d||P.saving?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 Pi(){const{isDarkMode:t,toggleDarkMode:r}=ts();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 Ri=({isOpen:t,onToggle:r,autoExpandTools:a,onAutoExpandChange:o,showRawParameters:n,onShowRawParametersChange:l,showThinking:i,onShowThinkingChange:m,autoScrollToBottom:g,onAutoScrollChange:x,sendByCtrlEnter:b,onSendByCtrlEnterChange:S,isMobile:v})=>{const[y,h]=s.useState(t),[z,$]=s.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:D}=ts(),[C,p]=s.useState(()=>{const Y=localStorage.getItem("quickSettingsHandlePosition");if(Y)try{return JSON.parse(Y).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[d,j]=s.useState(!1),[w,L]=s.useState(0),[B,W]=s.useState(0),[Z,le]=s.useState(!1),X=s.useRef(null),ne=s.useRef({min:10,max:90}),U=5;s.useEffect(()=>{h(t)},[t]),s.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:C}))},[C]);const I=s.useCallback(()=>v?{bottom:`${window.innerHeight*C/100}px`}:{top:`${C}%`,transform:"translateY(-50%)"},[C,v]),_=s.useCallback(Y=>{Y.stopPropagation();const ge=Y.type.includes("touch")?Y.touches[0].clientY:Y.clientY;L(ge),W(C),le(!1),j(!1)},[C]),Q=s.useCallback(Y=>{if(w===0)return;const ge=Y.type.includes("touch")?Y.touches[0].clientY:Y.clientY,Ne=Math.abs(ge-w);if(!d&&Ne>U&&(j(!0),le(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",Y.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!d)return;Y.type.includes("touch")&&Y.preventDefault();const Le=ge-w;let je;v?je=-(Le/window.innerHeight)*100:je=Le/window.innerHeight*100;let Oe=B+je;Oe=Math.max(ne.current.min,Math.min(ne.current.max,Oe)),p(Oe)},[d,w,B,v,U]),he=s.useCallback(()=>{j(!1),L(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);s.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),s.useEffect(()=>{if(w!==0){const Y=je=>Q(je),ge=()=>he(),Ne=je=>Q(je),Le=()=>he();return document.addEventListener("mousemove",Y),document.addEventListener("mouseup",ge),document.addEventListener("touchmove",Ne,{passive:!1}),document.addEventListener("touchend",Le),()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",ge),document.removeEventListener("touchmove",Ne),document.removeEventListener("touchend",Le)}}},[w,Q,he]);const ie=Y=>{if(Z){Y.preventDefault(),le(!1);return}const ge=!y;h(ge),r(ge)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:X,onClick:ie,onMouseDown:Y=>{_(Y)},onTouchStart:Y=>{_(Y)},className:`fixed ${y?"right-64":"right-0"} z-50 ${d?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${d?"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 ${d?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...I(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":d?"拖动手柄":y?"关闭设置面板":"打开设置面板",title:d?"拖动中...":"点击切换,拖动移动",children:d?e.jsx(hn,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):y?e.jsx(Dt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(gn,{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 ${y?"translate-x-0":"translate-x-full"} ${v?"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(fn,{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 ${v?"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:[D?e.jsx($r,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Ar,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"深色模式"]}),e.jsx(Pi,{})]})]}),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(_s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动展开工具"]}),e.jsx("input",{type:"checkbox",checked:a,onChange:Y=>o(Y.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(Fs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示原始参数"]}),e.jsx("input",{type:"checkbox",checked:n,onChange:Y=>l(Y.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(Os,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示思考过程"]}),e.jsx("input",{type:"checkbox",checked:i,onChange:Y=>m(Y.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(bn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动滚动到底部"]}),e.jsx("input",{type:"checkbox",checked:g,onChange:Y=>x(Y.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(yn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"使用 Ctrl+Enter 发送"]}),e.jsx("input",{type:"checkbox",checked:b,onChange:Y=>S(Y.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:z==="default",onChange:()=>{$("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(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:"直接转录您的语音"})]})]}),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:z==="prompt",onChange:()=>{$("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(zr,{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:z==="vibe"||z==="instructions"||z==="architect",onChange:()=>{$("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(Ws,{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:"将想法格式化为带有详细说明的代理指令"})]})]})]})]})]})]})}),y&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:ie})]})};function zi({isOpen:t,limitType:r,onClose:a}){if(!t)return null;const o=r==="total_limit_exceeded";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[100]",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-6 mx-4 animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o?"使用上限已达到":"今日使用上限已达到"})})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"mb-6 text-muted-foreground space-y-3",children:o?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您的账户已达到使用总额度上限。"}),e.jsx("p",{className:"text-sm",children:"请联系管理员提升您的额度限制,以继续使用 Claude 服务。"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您已达到今日使用额度上限。"}),e.jsx("p",{className:"text-sm",children:"您可以等待明日额度重置后继续使用,或联系管理员提升您的每日额度限制。"})]})}),e.jsx("div",{className:"mb-6 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"请联系您的管理员,申请提升使用额度。"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"每日额度将在次日 00:00 自动重置,您也可以联系管理员调整限额。"]})})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{variant:"default",onClick:a,children:"我知道了"})})]})})}function $i(){const[t,r]=s.useState(null),[a,o]=s.useState([]),[n,l]=s.useState(!1),i=s.useRef(null),m=s.useRef(null),{token:g}=Ot();s.useEffect(()=>(i.current&&(clearTimeout(i.current),i.current=null),m.current&&(m.current.close(),m.current=null),g||!1?x():(l(!1),r(null)),()=>{i.current&&clearTimeout(i.current),m.current&&m.current.close()}),[g]);const x=()=>{try{let v;{const h=g||localStorage.getItem("auth-token");if(!h){console.warn("No authentication token found for WebSocket connection");return}v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?token=${encodeURIComponent(h)}`}const y=new WebSocket(v);m.current=y,y.onopen=()=>{l(!0),r(y)},y.onmessage=h=>{try{const z=JSON.parse(h.data);o($=>[...$,z])}catch(z){console.error("Error parsing WebSocket message:",z)}},y.onclose=()=>{l(!1),r(null),m.current=null,localStorage.getItem("auth-token")&&(i.current=setTimeout(()=>{x()},3e3))},y.onerror=h=>{console.error("WebSocket error:",h)}}catch(S){console.error("Error creating WebSocket connection:",S)}};return{ws:t,sendMessage:S=>{t&&n?t.send(JSON.stringify(S)):console.warn("WebSocket not connected")},messages:a,isConnected:n}}const oa=s.createContext({ws:null,sendMessage:()=>{},messages:[],isConnected:!1}),Ai=()=>{const t=s.useContext(oa);if(!t)throw new Error("useWebSocketContext must be used within a WebSocketProvider");return t},Oi=({children:t})=>{const r=$i();return e.jsx(oa.Provider,{value:r,children:t})},_i=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState(""),[n,l]=s.useState(""),[i,m]=s.useState(!1),[g,x]=s.useState(""),[b,S]=s.useState(0),{sendCode:v,verifyCode:y,smtpConfigured:h}=Ot();s.useEffect(()=>{if(b>0){const p=setTimeout(()=>S(b-1),1e3);return()=>clearTimeout(p)}},[b]);const z=async p=>{if(p.preventDefault(),x(""),!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){x("请输入有效的邮箱地址");return}m(!0);const j=await v(a);j.success?(r("code"),S(60)):(x(j.error),j.waitSeconds&&S(j.waitSeconds)),m(!1)},$=async p=>{if(p.preventDefault(),x(""),!n||n.length!==6){x("请输入6位验证码");return}m(!0);const d=await y(a,n);d.success||x(d.error),m(!1)},D=async()=>{if(b>0)return;x(""),m(!0);const p=await v(a);p.success?S(60):x(p.error),m(!1)},C=()=>{r("email"),l(""),x("")};return h?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(ot,{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"?"输入邮箱创建管理员账户":`验证码已发送至 ${a}`})]}),t==="email"&&e.jsxs("form",{onSubmit:z,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(ir,{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:a,onChange:p=>o(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:i,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:i||b>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:i?"发送中...":b>0?`${b}秒后可重新发送`:"获取验证码"})]}),t==="code"&&e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:C,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{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:n,onChange:p=>l(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:i,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:i||n.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:i?"创建中...":"创建管理员账户"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:D,disabled:b>0||i,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:b>0?`${b}秒后可重新发送`:"重新发送验证码"})})]}),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(ot,{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"})]})]})]})})})},Fi=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState("email"),[n,l]=s.useState(""),[i,m]=s.useState(""),[g,x]=s.useState(""),[b,S]=s.useState(""),[v,y]=s.useState(!1),[h,z]=s.useState(""),[$,D]=s.useState(0),[C,p]=s.useState(!1),{login:d,sendCode:j,verifyCode:w,smtpConfigured:L}=Ot();s.useEffect(()=>{if($>0){const I=setTimeout(()=>D($-1),1e3);return()=>clearTimeout(I)}},[$]),s.useEffect(()=>{L||r("password")},[L]);const B=async I=>{if(I.preventDefault(),z(""),!n||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){z("请输入有效的邮箱地址");return}y(!0);const Q=await j(n);Q.success?(o("code"),D(60),p(Q.type==="register")):(z(Q.error),Q.waitSeconds&&D(Q.waitSeconds)),y(!1)},W=async I=>{if(I.preventDefault(),z(""),!i||i.length!==6){z("请输入6位验证码");return}y(!0);const _=await w(n,i);_.success||z(_.error),y(!1)},Z=async()=>{if($>0)return;z(""),y(!0);const I=await j(n);I.success?D(60):z(I.error),y(!1)},le=async I=>{if(I.preventDefault(),z(""),!g||!b){z("请输入用户名和密码");return}y(!0);const _=await d(g,b);_.success||z(_.error),y(!1)},X=()=>{o("email"),m(""),z("")},ne=()=>{r("email"),o("email"),z("")},U=()=>{r("password"),z("")};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(Pt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?a==="email"?"欢迎使用 AgentHub":C?"创建您的账户":"验证您的身份":"欢迎回来"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?a==="email"?"输入邮箱以接收验证码":`验证码已发送至 ${n}`:"使用账号密码登录"})]}),t==="email"&&a==="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(ir,{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:n,onChange:I=>l(I.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:v,autoComplete:"email"})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v||$>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:v?"发送中...":$>0?`${$}秒后可重新发送`:"获取验证码"})]}),t==="email"&&a==="code"&&e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:X,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{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:i,onChange:I=>m(I.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:v,maxLength:6,autoComplete:"one-time-code"})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v||i.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:v?"验证中...":C?"创建账户并登录":"登录"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:Z,disabled:$>0||v,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:$>0?`${$}秒后可重新发送`:"重新发送验证码"})})]}),t==="password"&&e.jsxs("form",{onSubmit:le,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(Us,{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:I=>x(I.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:v})]})]}),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(vn,{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:b,onChange:I=>S(I.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:v})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:v,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:v?"登录中...":"登录"})]}),e.jsx("div",{className:"text-center pt-4 border-t border-border",children:t==="email"&&L?e.jsx("button",{type:"button",onClick:U,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用账号密码登录"}):t==="password"&&L?e.jsx("button",{type:"button",onClick:ne,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用邮箱验证码登录"}):null})]})})})},Wi=()=>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(Pt,{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:"加载中..."})]})}),Bi=({children:t})=>{const{user:r,isLoading:a,needsSetup:o}=Ot();return a?e.jsx(Wi,{}):o?e.jsx(_i,{}):r?t:e.jsx(Fi,{})};function It(t,r){const[a,o]=s.useState(()=>{if(typeof window>"u")return r;try{const l=window.localStorage.getItem(t);return l?JSON.parse(l):r}catch(l){return console.log(l),r}});return[a,l=>{if(!(typeof window>"u"))try{const i=l instanceof Function?l(a):l;window.localStorage.setItem(t,JSON.stringify(i)),o(i)}catch(i){console.log(i)}}]}function zs(){const t=$s(),{sessionId:r}=qa(),{limitStatus:a,setLimitStatus:o,checkLimitStatus:n}=Ot(),[l,i]=s.useState([]),[m,g]=s.useState(null),[x,b]=s.useState(null),[S,v]=s.useState("chat"),[y,h]=s.useState(!1),[z,$]=s.useState(!1),[D,C]=s.useState(!0),[p,d]=s.useState(!1),[j,w]=s.useState(!1),[L,B]=s.useState("agents"),[W,Z]=s.useState(!1),[le,X]=It("autoExpandTools",!1),[ne,U]=It("showRawParameters",!1),[I,_]=It("showThinking",!0),[Q,he]=It("autoScrollToBottom",!0),[ie,Y]=It("sendByCtrlEnter",!1),[ge,Ne]=It("sidebarVisible",!0),[Le,je]=s.useState(!1),[Oe,pe]=s.useState(null),[Se,we]=s.useState(new Set),[Ie,xe]=s.useState(new Set),[Ce,Re]=s.useState(0),{ws:Ee,sendMessage:Be,messages:P}=Ai(),O=s.useCallback(K=>{pe(K),je(!0)},[]),[F,f]=s.useState(!1);s.useEffect(()=>{const K=()=>{const ue=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");f(ue),document.addEventListener("touchstart",{}),ue?(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 K(),window.matchMedia("(display-mode: standalone)").addEventListener("change",K),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",K)}},[]),s.useEffect(()=>{const K=()=>{h(window.innerWidth<768)};return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[]),s.useEffect(()=>{de()},[]);const H=(K,ue,te,ce)=>{if(!te||!ce)return!0;const ve=K?.find(tt=>tt.name===te.name),Ae=ue?.find(tt=>tt.name===te.name);if(!ve||!Ae)return!1;const fe=ve.sessions?.find(tt=>tt.id===ce.id),He=Ae.sessions?.find(tt=>tt.id===ce.id);return!fe||!He?!1:fe.id===He.id&&fe.title===He.title&&fe.created_at===He.created_at&&fe.updated_at===He.updated_at};s.useEffect(()=>{if(P.length>0){const K=P[P.length-1];if(K.type==="projects_updated"){if(K.changedFile&&x&&m){const ve=K.changedFile.replace(/\\/g,"/").split("/");ve.length>=2&&ve[ve.length-1].replace(".jsonl","")===x.id&&(Se.has(x.id)||Re(ut=>ut+1))}if(x&&Se.has(x.id)||Se.size>0&&Array.from(Se).some(ce=>ce.startsWith("new-session-"))){const ce=K.projects;if(!H(l,ce,m,x))return}const te=K.projects;if(i(te),m){const ce=te.find(ve=>ve.name===m.name);ce&&(JSON.stringify(ce)!==JSON.stringify(m)&&g(ce),x&&([...ce.sessions||[]].find(fe=>fe.id===x.id)||b(null)))}}}},[P,m,x,Se]);const de=async()=>{try{C(!0);const ue=await(await be.projects()).json();i(te=>te.length===0||ue.some((ve,Ae)=>{const fe=te[Ae];return fe?ve.name!==fe.name||ve.displayName!==fe.displayName||ve.fullPath!==fe.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(fe.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(fe.sessions):!0})||ue.length!==te.length?ue:te)}catch(K){console.error("Error fetching projects:",K)}finally{C(!1)}};window.refreshProjects=de,window.openSettings=s.useCallback((K="tools")=>{B(K),w(!0)},[]),s.useEffect(()=>{if(r&&l.length>0){const K=!x||x.id!==r;for(const ue of l){let te=ue.sessions?.find(ce=>ce.id===r);if(te){g(ue),b({...te,__provider:"claude"}),K&&v("chat");return}}}},[r,l,t]);const Me=K=>{g(K),b(null),t("/"),y&&$(!1)},$e=K=>{if(b(K),S!=="git"&&S!=="preview"&&v("chat"),y){const ue=K.__projectName,te=m?.name;ue!==te&&$(!1)}t(`/session/${K.id}`)},Ke=K=>{g(K),b(null),v("chat"),t("/"),y&&$(!1)},u=K=>{x?.id===K&&(b(null),t("/")),i(ue=>ue.map(te=>({...te,sessions:te.sessions?.filter(ce=>ce.id!==K)||[],sessionMeta:{...te.sessionMeta,total:Math.max(0,(te.sessionMeta?.total||0)-1)}})))},A=async()=>{try{const ue=await(await be.projects()).json();if(i(te=>ue.some((ve,Ae)=>{const fe=te[Ae];return fe?ve.name!==fe.name||ve.displayName!==fe.displayName||ve.fullPath!==fe.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(fe.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(fe.sessions):!0})||ue.length!==te.length?ue:te),m){const te=ue.find(ce=>ce.name===m.name);if(te&&(JSON.stringify(te)!==JSON.stringify(m)&&g(te),x)){const ce=te.sessions?.find(ve=>ve.id===x.id);ce&&JSON.stringify(ce)!==JSON.stringify(x)&&b(ce)}}}catch(K){console.error("Error refreshing sidebar:",K)}},oe=K=>{m?.name===K&&(g(null),b(null),t("/")),i(ue=>ue.filter(te=>te.name!==K))},se=s.useCallback(K=>{K&&we(ue=>new Set([...ue,K]))},[]),M=s.useCallback(K=>{K&&we(ue=>{const te=new Set(ue);return te.delete(K),te})},[]),De=s.useCallback(K=>{K&&xe(ue=>new Set([...ue,K]))},[]),qe=s.useCallback(K=>{K&&xe(ue=>{const te=new Set(ue);return te.delete(K),te})},[]),Te=s.useCallback(K=>{K&&we(ue=>{const te=new Set;for(const ce of ue)ce.startsWith("new-session-")||te.add(ce);return te.add(K),te})},[]);return e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[!y&&e.jsx("div",{className:`h-full flex-shrink-0 border-r border-border bg-card transition-all duration-300 ${ge?"w-80":"w-14"}`,children:e.jsx("div",{className:"h-full overflow-hidden",children:ge?e.jsx(fs,{projects:l,selectedProject:m,selectedSession:x,onProjectSelect:Me,onSessionSelect:$e,onNewSession:Ke,onSessionDelete:u,onProjectDelete:oe,isLoading:D,onRefresh:A,onShowSettings:()=>w(!0),isPWA:F,isMobile:y,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:()=>w(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200","aria-label":"Settings",title:"Settings",children:e.jsx(zt,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})})]})})}),y&&e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${z?"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:K=>{K.stopPropagation(),$(!1)},onTouchStart:K=>{K.preventDefault(),K.stopPropagation(),$(!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 ${z?"translate-x-0":"-translate-x-full"}`,onClick:K=>K.stopPropagation(),onTouchStart:K=>K.stopPropagation(),children:e.jsx(fs,{projects:l,selectedProject:m,selectedSession:x,onProjectSelect:Me,onSessionSelect:$e,onNewSession:Ke,onSessionDelete:u,onProjectDelete:oe,isLoading:D,onRefresh:A,onShowSettings:()=>w(!0),isPWA:F,isMobile:y,onToggleSidebar:()=>Ne(!1)})})]}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${y&&!p?"pb-mobile-nav":""}`,children:e.jsx(ci,{selectedProject:m,selectedSession:x,activeTab:S,setActiveTab:v,ws:Ee,sendMessage:Be,messages:P,isMobile:y,isPWA:F,onMenuClick:()=>$(!0),isLoading:D,onInputFocusChange:d,onSessionActive:se,onSessionInactive:M,onSessionProcessing:De,onSessionNotProcessing:qe,processingSessions:Ie,onReplaceTemporarySession:Te,onNavigateToSession:K=>t(`/session/${K}`),onShowSettings:()=>w(!0),autoExpandTools:le,showRawParameters:ne,showThinking:I,autoScrollToBottom:Q,sendByCtrlEnter:ie,externalMessageUpdate:Ce,limitStatus:a,onLimitBlocked:O,checkLimitStatus:n})}),y&&e.jsx(di,{activeTab:S,setActiveTab:v,isInputFocused:p}),S==="chat"&&e.jsx(Ri,{isOpen:W,onToggle:Z,autoExpandTools:le,onAutoExpandChange:X,showRawParameters:ne,onShowRawParametersChange:U,showThinking:I,onShowThinkingChange:_,autoScrollToBottom:Q,onAutoScrollChange:he,sendByCtrlEnter:ie,onSendByCtrlEnterChange:Y,isMobile:y}),e.jsx(Ti,{isOpen:j,onClose:()=>w(!1),projects:l,initialTab:L}),e.jsx(zi,{isOpen:Le,limitType:Oe,onClose:()=>je(!1)})]})}function Ui(){return e.jsx(mi,{children:e.jsx(ui,{children:e.jsx(Oi,{children:e.jsx(Bi,{children:e.jsx(Ua,{children:e.jsxs(Ha,{children:[e.jsx(ms,{path:"/",element:e.jsx(zs,{})}),e.jsx(ms,{path:"/session/:sessionId",element:e.jsx(zs,{})})]})})})})})})}"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(r=>{r.unregister()})}).catch(t=>{console.warn("Failed to unregister service workers:",t)});Tn.createRoot(document.getElementById("root")).render(e.jsx(et.StrictMode,{children:e.jsx(Ui,{})}));