@axhub/genie 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{App-BfaNALgf.js → App-Cay5kE3A.js} +2 -2
- package/dist/assets/{ReviewApp-DIT2yWk-.js → ReviewApp-Bp_y3xff.js} +1 -1
- package/dist/assets/{_basePickBy-Dz3NcIVK.js → _basePickBy-C5f221Kr.js} +1 -1
- package/dist/assets/{_baseUniq-DON_Sg7x.js → _baseUniq-CeEXFlBh.js} +1 -1
- package/dist/assets/{arc-Y4G80q-l.js → arc-CZVQXROF.js} +1 -1
- package/dist/assets/{architectureDiagram-2XIMDMQ5-D_qR4657.js → architectureDiagram-2XIMDMQ5-D91MBXeh.js} +1 -1
- package/dist/assets/{blockDiagram-WCTKOSBZ-NsmAlV5_.js → blockDiagram-WCTKOSBZ-CsHP3zT2.js} +1 -1
- package/dist/assets/{c4Diagram-IC4MRINW-cbOJM4yr.js → c4Diagram-IC4MRINW-DakKlk21.js} +1 -1
- package/dist/assets/channel-CnzaP2H9.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-bLBhl74J.js → chunk-4BX2VUAB-BXZoxrtv.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-D8kNkDUO.js → chunk-55IACEB6-V9_WXk3w.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-BjR6UbXB.js → chunk-FMBD7UC4-IgdHo6Dd.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-luNqWn64.js → chunk-JSJVCQXG-CnaAsDTd.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-CNnKm6dK.js → chunk-KX2RTZJC-D0qksU2H.js} +1 -1
- package/dist/assets/{chunk-NQ4KR5QH-Cp9gb43u.js → chunk-NQ4KR5QH-rd6KG4-c.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-HlVYo2Oq.js → chunk-QZHKN3VN-Cyltgv4l.js} +1 -1
- package/dist/assets/{chunk-WL4C6EOR-CjSZoOGO.js → chunk-WL4C6EOR-DkNtSo86.js} +1 -1
- package/dist/assets/classDiagram-VBA2DB6C-CUcYxMZ8.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-CUcYxMZ8.js +1 -0
- package/dist/assets/clone-DJXJGSg2.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-DZWRjeEd.js → cose-bilkent-S5V4N54A-D_Wsd3iv.js} +1 -1
- package/dist/assets/{dagre-KLK3FWXG-yAzUmqI7.js → dagre-KLK3FWXG-CrrmZeGu.js} +1 -1
- package/dist/assets/{diagram-E7M64L7V-CvzlIvDJ.js → diagram-E7M64L7V-WzO26pGn.js} +1 -1
- package/dist/assets/{diagram-IFDJBPK2-DFMIJpuM.js → diagram-IFDJBPK2-COynsdO3.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-KL-J3gyb.js → diagram-P4PSJMXO-CSqD5HJx.js} +1 -1
- package/dist/assets/{erDiagram-INFDFZHY-BXszHbTM.js → erDiagram-INFDFZHY-BiFhS6xi.js} +1 -1
- package/dist/assets/{flowDiagram-PKNHOUZH-Ba43NVp6.js → flowDiagram-PKNHOUZH-9jdAJSs0.js} +1 -1
- package/dist/assets/{ganttDiagram-A5KZAMGK-uLHfhCrg.js → ganttDiagram-A5KZAMGK-pGyMKWCo.js} +1 -1
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-BTEuFaiL.js → gitGraphDiagram-K3NZZRJ6-D4jvwoW1.js} +1 -1
- package/dist/assets/{graph-h2nuWjx4.js → graph-DMknFkkX.js} +1 -1
- package/dist/assets/{highlighted-body-TPN3WLV5-C6BY7XZJ.js → highlighted-body-TPN3WLV5-DhMGh1O7.js} +1 -1
- package/dist/assets/{index-C6Bb2jGF.js → index-EMGPq9Uy.js} +2 -2
- package/dist/assets/{infoDiagram-LFFYTUFH-BOLfvCIq.js → infoDiagram-LFFYTUFH-CP5zYiVP.js} +1 -1
- package/dist/assets/{ishikawaDiagram-PHBUUO56-BRzQ1ee5.js → ishikawaDiagram-PHBUUO56-BplLZAQ5.js} +1 -1
- package/dist/assets/{journeyDiagram-4ABVD52K-DXm_VcMy.js → journeyDiagram-4ABVD52K-CYVgkl-y.js} +1 -1
- package/dist/assets/{kanban-definition-K7BYSVSG-D_oyzopl.js → kanban-definition-K7BYSVSG-D3on0q66.js} +1 -1
- package/dist/assets/{layout-Q8YoR_E1.js → layout-DoKWZNVk.js} +1 -1
- package/dist/assets/{linear-B3qNg7di.js → linear-D4YTLdon.js} +1 -1
- package/dist/assets/{mermaid-O7DHMXV3-BVZ_4MKo.js → mermaid-O7DHMXV3-KLW3VWsF.js} +5 -5
- package/dist/assets/{mindmap-definition-YRQLILUH-CjulgYdi.js → mindmap-definition-YRQLILUH-EEAggxM3.js} +1 -1
- package/dist/assets/{pieDiagram-SKSYHLDU-8VzrefxA.js → pieDiagram-SKSYHLDU-Da-_fmYg.js} +1 -1
- package/dist/assets/{quadrantDiagram-337W2JSQ-CFh-ijm2.js → quadrantDiagram-337W2JSQ-Dq4gr7Sw.js} +1 -1
- package/dist/assets/{requirementDiagram-Z7DCOOCP-BNPlTs5Q.js → requirementDiagram-Z7DCOOCP-DNSXyCNU.js} +1 -1
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-C5l_hYst.js → sankeyDiagram-WA2Y5GQK-CT4ST2HW.js} +1 -1
- package/dist/assets/{sequenceDiagram-2WXFIKYE-B4a_rQw8.js → sequenceDiagram-2WXFIKYE-CshVYjrF.js} +1 -1
- package/dist/assets/{stateDiagram-RAJIS63D-Bt4mMmKB.js → stateDiagram-RAJIS63D-hsG5Yi2A.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-BQa1Ppoo.js +1 -0
- package/dist/assets/{timeline-definition-YZTLITO2-CLYvSw_R.js → timeline-definition-YZTLITO2-EztFFK5F.js} +1 -1
- package/dist/assets/{treemap-KZPCXAKY-ksND0hZK.js → treemap-KZPCXAKY-D5UZCcq_.js} +1 -1
- package/dist/assets/{vennDiagram-LZ73GAT5-CaQg4oZK.js → vennDiagram-LZ73GAT5-9Qwv8UTR.js} +1 -1
- package/dist/assets/{xychartDiagram-JWTSCODW-C8dCbTeM.js → xychartDiagram-JWTSCODW-BBjpC1Qv.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/cli.js +1 -1
- package/dist/assets/channel-C6KNnXlA.js +0 -1
- package/dist/assets/classDiagram-VBA2DB6C-BQlzzlH7.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-BQlzzlH7.js +0 -1
- package/dist/assets/clone-DMxS3qWP.js +0 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-6NYMazfq.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,S as Qn,F as to,T as Ac,P as _c,E as fr,V as ro,a as Ya,g as Xp,D as Rr,R as Ws,G as Xa,W as Qa,l as Mc,h as ba,b as Dc,C as Qp,c as Zp,d as em,e as In,f as tm,i as rm,u as nm,k as cl,s as sm,m as om,n as am,o as im,p as lm,q as cm,r as dm,t as um,v as pm,w as mm,x as fm,y as hm}from"./vendor-codemirror-Dz7_EqNA.js";import{a as i,c as gm,R as dn,d as Qo,g as Rc,B as xm,e as ym,f as Zo,u as vm,h as bm,i as wm}from"./vendor-react-Cpt6D04s.js";import{bJ as Ie,bK as tr,bL as wa,bM as un,bN as Pc,bO as Us,bP as Fe,bQ as no,bR as Za,bS as vr,bT as Lc,bU as km,bV as jm,bW as Nm,bX as Sm,bY as Cm,bZ as Em,b_ as Im,b$ as Tm,c0 as Am,c1 as _m,c2 as Mm,c3 as ut,c4 as ei,c5 as Lt,c6 as Gt,c7 as Dm,c8 as _e,c9 as qr,ca as sn,cb as Ar,cc as pn,cd as ti,ce as Oc,cf as Rm,cg as Pm,ch as Lm,ci as Om,cj as Fm,ck as dl,cl as ul,cm as pl,cn as ea,co as $m,cp as zm,cq as Bm,cr as Wm,cs as Um,ct as Hm,cu as Gm,cv as qm,cw as Km,cx as Vm,cy as Fc,cz as ri,cA as Jm,cB as Ym,I as Xm,T as Qm,U as Zm}from"./mermaid-O7DHMXV3-
|
|
1
|
+
import{j as t,S as Qn,F as to,T as Ac,P as _c,E as fr,V as ro,a as Ya,g as Xp,D as Rr,R as Ws,G as Xa,W as Qa,l as Mc,h as ba,b as Dc,C as Qp,c as Zp,d as em,e as In,f as tm,i as rm,u as nm,k as cl,s as sm,m as om,n as am,o as im,p as lm,q as cm,r as dm,t as um,v as pm,w as mm,x as fm,y as hm}from"./vendor-codemirror-Dz7_EqNA.js";import{a as i,c as gm,R as dn,d as Qo,g as Rc,B as xm,e as ym,f as Zo,u as vm,h as bm,i as wm}from"./vendor-react-Cpt6D04s.js";import{bJ as Ie,bK as tr,bL as wa,bM as un,bN as Pc,bO as Us,bP as Fe,bQ as no,bR as Za,bS as vr,bT as Lc,bU as km,bV as jm,bW as Nm,bX as Sm,bY as Cm,bZ as Em,b_ as Im,b$ as Tm,c0 as Am,c1 as _m,c2 as Mm,c3 as ut,c4 as ei,c5 as Lt,c6 as Gt,c7 as Dm,c8 as _e,c9 as qr,ca as sn,cb as Ar,cc as pn,cd as ti,ce as Oc,cf as Rm,cg as Pm,ch as Lm,ci as Om,cj as Fm,ck as dl,cl as ul,cm as pl,cn as ea,co as $m,cp as zm,cq as Bm,cr as Wm,cs as Um,ct as Hm,cu as Gm,cv as qm,cw as Km,cx as Vm,cy as Fc,cz as ri,cA as Jm,cB as Ym,I as Xm,T as Qm,U as Zm}from"./mermaid-O7DHMXV3-KLW3VWsF.js";import{r as ef,a as tf,b as rf}from"./vendor-xterm-DfaPXD3y.js";import{l as ml,i as nf}from"./index-EMGPq9Uy.js";/**
|
|
2
2
|
* @license lucide-react v0.515.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -468,7 +468,7 @@ ${xe}`:xe:Je.push({type:"assistant",content:xe,timestamp:new Date,isStreaming:!0
|
|
|
468
468
|
`,onClick:x,disabled:L,children:w}),o&&t.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
469
469
|
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
470
470
|
animate-fade-in`,children:o}),n==="recording"&&t.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&t.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function Cc({diff:e,fileName:r,isMobile:n,wrapText:s}){if(!e)return t.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,l)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return t.jsx("div",{className:`font-mono text-xs p-2 ${n&&s?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-300":d?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300":u?"bg-primary/10 dark:bg-primary/20 text-primary":"text-gray-600 dark:text-gray-400"}`,children:a},l)};return t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[r&&t.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:r}),e.split(`
|
|
471
|
-
`).map((a,l)=>o(a,l))]})}function qb({selectedProject:e,isMobile:r,onFileOpen:n}){const[s,o]=i.useState(null),[a,l]=i.useState({}),[c,d]=i.useState(!1),[u,m]=i.useState(""),[p,h]=i.useState(new Set),[g,x]=i.useState(new Set),[k,w]=i.useState(!1),[A,L]=i.useState(""),[j,S]=i.useState([]),[D,b]=i.useState(!0),[I,G]=i.useState(!1),[P,V]=i.useState(!1),[ve,ae]=i.useState(!1),[R,q]=i.useState(""),[de,se]=i.useState(!1),[he,Se]=i.useState("changes"),[B,z]=i.useState([]),[_,N]=i.useState(new Set),[O,ne]=i.useState({}),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(null),[nt,De]=i.useState(!1),[fe,Ge]=i.useState(!1),[bt,st]=i.useState(!1),[Be,Ze]=i.useState(!1),[xt,wt]=i.useState(r),[ye,qe]=i.useState(null),[Nt,X]=i.useState(!1),Te=i.useRef(null),W=i.useRef(null),[Z,we]=i.useState(()=>localStorage.getItem("selected-provider")||"claude");i.useEffect(()=>{const C=()=>{const F=localStorage.getItem("selected-provider")||"claude";we(F)};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),i.useEffect(()=>{e&&(Ae(),Xe(),Qe(),he==="history"&&rr())},[e,he]),i.useEffect(()=>{const C=F=>{W.current&&!W.current.contains(F.target)&&V(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const Ae=async()=>{if(e){d(!0);try{const F=await(await ee(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(F.error)console.error("Git status error:",F.error),o({error:F.error,details:F.details});else{o(F),L(F.branch||"main");const pe=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(pe);for(const je of F.modified||[])yt(je);for(const je of F.added||[])yt(je);for(const je of F.deleted||[])yt(je);for(const je of F.untracked||[])yt(je)}}catch(C){console.error("Error fetching git status:",C)}finally{d(!1)}}},Xe=async()=>{try{const F=await(await ee(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&S(F.branches)}catch(C){console.error("Error fetching branches:",C)}},Qe=async()=>{if(e)try{const F=await(await ee(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?Ee(null):Ee(F)}catch(C){console.error("Error fetching remote status:",C),Ee(null)}},We=async C=>{try{const pe=await(await ee("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:C})})).json();pe.success?(L(C),V(!1),Ae()):console.error("Failed to switch branch:",pe.error)}catch(F){console.error("Error switching branch:",F)}},Et=async()=>{if(R.trim()){se(!0);try{const F=await(await ee("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:R.trim()})})).json();F.success?(L(R.trim()),ae(!1),V(!1),q(""),Xe(),Ae()):console.error("Failed to create branch:",F.error)}catch(C){console.error("Error creating branch:",C)}finally{se(!1)}}},ie=async()=>{De(!0);try{const F=await(await ee("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Fetch failed:",F.error)}catch(C){console.error("Error fetching from remote:",C)}finally{De(!1)}},St=async()=>{Ge(!0);try{const F=await(await ee("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Pull failed:",F.error)}catch(C){console.error("Error pulling from remote:",C)}finally{Ge(!1)}},et=async()=>{st(!0);try{const F=await(await ee("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Push failed:",F.error)}catch(C){console.error("Error pushing to remote:",C)}finally{st(!1)}},ot=async()=>{Ze(!0);try{const F=await(await ee("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:A})})).json();F.success?(Ae(),Qe()):console.error("Publish failed:",F.error)}catch(C){console.error("Error publishing branch:",C)}finally{Ze(!1)}},Ke=async C=>{try{const pe=await(await ee("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Discard failed:",pe.error)}catch(F){console.error("Error discarding changes:",F)}},Tt=async C=>{try{const pe=await(await ee("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Delete failed:",pe.error)}catch(F){console.error("Error deleting untracked file:",F)}},Ot=async()=>{if(!ye)return;const{type:C,file:F,message:pe}=ye;qe(null);try{switch(C){case"discard":await Ke(F);break;case"delete":await Tt(F);break;case"commit":await Bt();break;case"pull":await St();break;case"push":await et();break;case"publish":await ot();break}}catch(je){console.error(`Error executing ${C}:`,je)}},yt=async C=>{try{const pe=await(await ee(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();!pe.error&&pe.diff&&l(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching file diff:",F)}},At=async C=>{if(n)try{const pe=await(await ee(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();if(pe.error){console.error("Error fetching file with diff:",pe.error),n(C);return}const je={old_string:pe.oldContent||"",new_string:pe.currentContent||""};n(C,je)}catch(F){console.error("Error opening file:",F),n(C)}},rr=async()=>{try{const F=await(await ee(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&z(F.commits)}catch(C){console.error("Error fetching commits:",C)}},tt=async C=>{try{const pe=await(await ee(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${C}`)).json();!pe.error&&pe.diff&&ne(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},Ft=async()=>{be(!0);try{const F=await(await ee("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:Z})})).json();F.message?m(F.message):console.error("Failed to generate commit message:",F.error)}catch(C){console.error("Error generating commit message:",C)}finally{be(!1)}},It=C=>{h(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},$t=C=>{N(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):(pe.add(C),O[C]||tt(C)),pe})},nr=C=>{x(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},Bt=async()=>{if(!(!u.trim()||g.size===0)){w(!0);try{const F=await(await ee("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();F.success?(m(""),x(new Set),Ae(),Qe()):console.error("Commit failed:",F.error)}catch(C){console.error("Error committing changes:",C)}finally{w(!1)}}},M=async()=>{X(!0);try{const F=await(await ee("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):(console.error("Initial commit failed:",F.error),alert(F.error||"Failed to create initial commit"))}catch(C){console.error("Error creating initial commit:",C),alert("Failed to create initial commit")}finally{X(!1)}},ge=C=>{switch(C){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return C}},Re=C=>{const F=_.has(C.hash),pe=O[C.hash];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>$t(C.hash),children:[t.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:C.message}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[C.author," • ",C.date]})]}),t.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.hash.substring(0,7)})]})})]}),F&&pe&&t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[t.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:C.stats}),t.jsx(Cc,{diff:pe,fileName:"commit",isMobile:r,wrapText:D})]})})]},C.hash)},Q=(C,F)=>{const pe=p.has(C),je=g.has(C),mt=a[C];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${r?"px-2 py-1.5":"px-3 py-2"}`,children:[t.jsx("input",{type:"checkbox",checked:je,onChange:()=>nr(C),onClick:H=>H.stopPropagation(),className:`rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:focus:ring-ring dark:bg-gray-800 dark:checked:bg-primary ${r?"mr-1.5":"mr-2"}`}),t.jsxs("div",{className:"flex items-center flex-1",children:[t.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${r?"mr-1":"mr-2"}`,onClick:H=>{H.stopPropagation(),It(C)},children:t.jsx(sn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${pe?"rotate-90":"rotate-0"}`})}),t.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:H=>{H.stopPropagation(),At(C)},title:"Click to open file",children:C}),t.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"discard",file:C,message:`Discard all changes to "${C}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Discard changes",children:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Discard"})]}),F==="U"&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"delete",file:C,message:`Delete untracked file "${C}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Delete untracked file",children:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Delete"})]}),t.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:ge(F),children:F})]})]})]}),t.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${pe&&mt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:F}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ge(F)})]}),r&&t.jsx("button",{onClick:H=>{H.stopPropagation(),b(!D)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:D?"Switch to horizontal scroll":"Switch to text wrap",children:D?"↔️ Scroll":"↩️ Wrap"})]}),t.jsx("div",{className:"max-h-96 overflow-y-auto",children:mt&&t.jsx(Cc,{diff:mt,fileName:C,isMobile:r,wrapText:D})})]})]},C)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${r?"px-3 py-2":"px-4 py-3"}`,children:[t.jsxs("div",{className:"relative",ref:W,children:[t.jsxs("button",{onClick:()=>V(!P),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${r?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[t.jsx(Kr,{className:`text-gray-600 dark:text-gray-400 ${r?"w-3 h-3":"w-4 h-4"}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`font-medium ${r?"text-xs":"text-sm"}`,children:A}),re?.hasRemote&&t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[re.ahead>0&&t.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${re.ahead} commit${re.ahead!==1?"s":""} ahead`,children:["↑",re.ahead]}),re.behind>0&&t.jsxs("span",{className:"text-primary",title:`${re.behind} commit${re.behind!==1?"s":""} behind`,children:["↓",re.behind]}),re.isUpToDate&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),t.jsx(Ar,{className:`w-3 h-3 text-gray-500 transition-transform ${P?"rotate-180":""}`})]}),P&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[t.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:j.map(C=>t.jsx("button",{onClick:()=>We(C),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${C===A?"bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[C===A&&t.jsx(Gt,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),t.jsx("span",{className:C===A?"font-medium":"",children:C})]})},C))}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:t.jsxs("button",{onClick:()=>{ae(!0),V(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center space-x-2",children:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create new branch"})]})})]})]}),t.jsxs("div",{className:`flex items-center ${r?"gap-1":"gap-2"}`,children:[re?.hasRemote&&t.jsxs(t.Fragment,{children:[!re?.hasUpstream&&t.jsxs("button",{onClick:()=>qe({type:"publish",message:`Publish branch "${A}" to ${re.remoteName}?`}),disabled:Be,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1",title:`Publish branch "${A}" to ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${Be?"animate-pulse":""}`}),t.jsx("span",{children:Be?"Publishing...":"Publish"})]}),re?.hasUpstream&&!re?.isUpToDate&&t.jsxs(t.Fragment,{children:[re.behind>0&&t.jsxs("button",{onClick:()=>qe({type:"pull",message:`Pull ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}?`}),disabled:fe,className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 flex items-center gap-1",title:`Pull ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}`,children:[t.jsx(ka,{className:`w-3 h-3 ${fe?"animate-pulse":""}`}),t.jsx("span",{children:fe?"Pulling...":`Pull ${re.behind}`})]}),re.ahead>0&&t.jsxs("button",{onClick:()=>qe({type:"push",message:`Push ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}?`}),disabled:bt,className:"px-2 py-1 text-xs bg-orange-600 text-white rounded hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1",title:`Push ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${bt?"animate-pulse":""}`}),t.jsx("span",{children:bt?"Pushing...":`Push ${re.ahead}`})]}),(re.ahead>0||re.behind>0&&re.ahead>0)&&t.jsxs("button",{onClick:ie,disabled:nt,className:"px-2 py-1 text-xs bg-primary text-white rounded hover:bg-primary/80 disabled:opacity-50 flex items-center gap-1",title:`Fetch from ${re.remoteName}`,children:[t.jsx(Tr,{className:`w-3 h-3 ${nt?"animate-spin":""}`}),t.jsx("span",{children:nt?"Fetching...":"Fetch"})]})]})]}),t.jsx("button",{onClick:()=>{Ae(),Xe(),Qe()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${r?"p-1":"p-1.5"}`,children:t.jsx(Tr,{className:`${c?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[t.jsx(Kr,{className:"w-20 h-20 mb-6 opacity-30"}),t.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&t.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),t.jsx("div",{className:"p-4 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/60 max-w-md",children:t.jsxs("p",{className:"text-sm text-primary text-center",children:[t.jsx("strong",{children:"Tip:"})," Run ",t.jsx("code",{className:"bg-primary/15 dark:bg-primary/30 px-2 py-1 rounded font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.jsx("button",{onClick:()=>Se("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="changes"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(oi,{className:"w-4 h-4"}),t.jsx("span",{children:"Changes"})]})}),t.jsx("button",{onClick:()=>Se("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="history"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(hl,{className:"w-4 h-4"}),t.jsx("span",{children:"History"})]})})]}),he==="changes"&&t.jsx(t.Fragment,{children:t.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&xt?t.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:t.jsxs("button",{onClick:()=>wt(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80",children:[t.jsx(ra,{className:"w-4 h-4"}),t.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),t.jsx(Ar,{className:"w-3 h-3"})]})}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[r&&t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),t.jsx("button",{onClick:()=>wt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:t.jsx(Ar,{className:"w-4 h-4 rotate-180"})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("textarea",{ref:Te,value:u,onChange:C=>m(C.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&Bt()}}),t.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[t.jsx("button",{onClick:Ft,disabled:g.size===0||Ce,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:Ce?t.jsx(Tr,{className:"w-4 h-4 animate-spin"}):t.jsx(ri,{className:"w-4 h-4"})}),t.jsx("div",{style:{display:"none"},children:t.jsx(Gb,{onTranscript:C=>m(C),mode:"default",className:"p-1.5"})})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),t.jsxs("button",{onClick:()=>qe({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||k,className:"px-3 py-1 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",children:[t.jsx(Gt,{className:"w-3 h-3"}),t.jsx("span",{children:k?"Committing...":"Commit"})]})]})]})})})}),he==="changes"&&s&&!s.error&&t.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${r?"px-3 py-1.5":"px-4 py-2"} ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[g.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",r?"":"files"," selected"]}),t.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[t.jsx("button",{onClick:()=>{const C=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);x(C)},className:"text-primary hover:text-primary text-xs",children:r?"All":"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:r?"None":"Deselect All"})]})]}),!s?.error&&!r&&t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>G(!I),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[t.jsx(Mf,{className:"w-3 h-3"}),t.jsx("span",{children:"File Status Guide"}),I?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})]}),I&&t.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:t.jsxs("div",{className:`${r?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),he==="changes"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx(Kr,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),t.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),t.jsx("button",{onClick:M,disabled:Nt,className:"px-4 py-2 bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:Nt?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-4 h-4 animate-spin"}),t.jsx("span",{children:"Creating Initial Commit..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ra,{className:"w-4 h-4"}),t.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(ra,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No changes detected"})]}):t.jsxs("div",{className:r?"pb-4":"",children:[s.modified?.map(C=>Q(C,"M")),s.added?.map(C=>Q(C,"A")),s.deleted?.map(C=>Q(C,"D")),s.untracked?.map(C=>Q(C,"U"))]})}),he==="history"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):B.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(hl,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No commits found"})]}):t.jsx("div",{className:r?"pb-4":"",children:B.map(C=>Re(C))})}),ve&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>ae(!1)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),t.jsx("input",{type:"text",value:R,onChange:C=>q(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!de&&Et()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-ring",autoFocus:!0})]}),t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:["This will create a new branch from the current branch (",A,")"]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>{ae(!1),q("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),t.jsx("button",{onClick:Et,disabled:!R.trim()||de,className:"px-4 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:de?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-3 h-3 animate-spin"}),t.jsx("span",{children:"Creating..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create Branch"})]})})]})]})})]}),ye&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>qe(null)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:`p-2 rounded-full mr-3 ${ye.type==="discard"||ye.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:t.jsx(Ea,{className:`w-5 h-5 ${ye.type==="discard"||ye.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),t.jsx("h3",{className:"text-lg font-semibold",children:ye.type==="discard"?"Discard Changes":ye.type==="delete"?"Delete File":ye.type==="commit"?"Confirm Commit":ye.type==="pull"?"Confirm Pull":ye.type==="publish"?"Publish Branch":"Confirm Push"})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:ye.message}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>qe(null),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),t.jsx("button",{onClick:Ot,className:`px-4 py-2 text-sm text-white rounded-md ${ye.type==="discard"||ye.type==="delete"?"bg-red-600 hover:bg-red-700":ye.type==="commit"?"bg-primary hover:bg-primary/90":ye.type==="pull"?"bg-green-600 hover:bg-green-700":ye.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:ye.type==="discard"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Discard"})]}):ye.type==="delete"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Delete"})]}):ye.type==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(Gt,{className:"w-4 h-4"}),t.jsx("span",{children:"Commit"})]}):ye.type==="pull"?t.jsxs(t.Fragment,{children:[t.jsx(ka,{className:"w-4 h-4"}),t.jsx("span",{children:"Pull"})]}):ye.type==="publish"?t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Publish"})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Push"})]})})]})]})})]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:t.jsx("p",{children:"Select a project to view source control"})})}class Kb extends dn.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,n){console.error("ErrorBoundary caught an error:",r,n),this.setState({error:r,errorInfo:n})}render(){return this.state.hasError?t.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:t.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:t.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"})})}),t.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),t.jsxs("div",{className:"text-sm text-red-700",children:[t.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&t.jsxs("details",{className:"mt-4",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),t.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]})]})]}),t.jsx("div",{className:"mt-4",children:t.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:"Try Again"})})]})}):this.props.children}}const Vb=Xx,rp=i.forwardRef(({className:e,...r},n)=>t.jsx(tu,{ref:n,className:ut("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...r}));rp.displayName=tu.displayName;const np=i.forwardRef(({className:e,...r},n)=>t.jsx(ru,{ref:n,className:ut("inline-flex items-center justify-center whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...r}));np.displayName=ru.displayName;const Jb=i.forwardRef(({className:e,...r},n)=>t.jsx(nu,{ref:n,className:ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...r}));Jb.displayName=nu.displayName;function Yb({selectedProject:e,selectedSession:r,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:l,isMobile:c,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,onShowNewProject:he,onNewSession:Se,newSessionResetNonce:B}){const{t:z}=Lt(),[_,N]=i.useState(null),[O,ne]=i.useState(600),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(!1),nt=i.useRef(null),De=(ye,qe=null)=>{const Nt={name:ye.split("/").pop(),path:ye,projectName:e?.name,diffInfo:qe};N(Nt)},fe=()=>{N(null),Ee(!1)},Ge=()=>{Ee(!re)},bt=ye=>{c||(be(!0),ye.preventDefault())};if(i.useEffect(()=>{n==="files"&&s("chat")},[n,s]),i.useEffect(()=>{const ye=Nt=>{if(!Ce)return;const X=nt.current?.parentElement;if(!X)return;const Te=X.getBoundingClientRect(),W=Te.right-Nt.clientX,Z=300,we=Te.width*.8;W>=Z&&W<=we&&ne(W)},qe=()=>{be(!1)};return Ce&&(document.addEventListener("mousemove",ye),document.addEventListener("mouseup",qe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",qe),document.body.style.cursor="",document.body.style.userSelect=""}},[Ce]),m)return t.jsxs("div",{className:"h-full flex flex-col",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.jsx("button",{onClick:u,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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:t.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),t.jsx("h2",{className:"text-xl font-semibold",children:z("mainContent.loading")})]})})]});if(!e)return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.jsx("button",{onClick:u,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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:t.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[t.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:z("mainContent.chooseProject")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:z("mainContent.selectProjectDescription")}),t.jsx("div",{className:"mx-auto flex w-fit items-center",children:t.jsxs("button",{onClick:he,className:"inline-flex items-center gap-2 rounded-xl bg-foreground px-4 py-2 text-sm font-medium text-background transition hover:opacity-90",title:z("tooltips.createProject")||"New Chat",children:[t.jsx(Sn,{className:"w-5 h-5"}),t.jsx("span",{children:z("tooltips.createProject")||"New Chat"})]})})]})})]});const st=r?.__provider||r?.provider||"claude",Be=st==="openai"?"codex":st,Ze=Be==="codex"&&typeof r?.id=="string"?r.id.trim():"",xt=Ze?`codex://threads/${encodeURIComponent(Ze)}`:"",wt=()=>{xt&&(window.location.href=xt)};return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[t.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:t.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&t.jsx("button",{onClick:u,onTouchStart:ye=>{ye.preventDefault(),u()},className:"pwa-menu-button flex-shrink-0 rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground touch-manipulation active:scale-95",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),t.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&r&&t.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:Be==="codex"?t.jsx(ss,{className:"w-4 h-4"}):Be==="gemini"?t.jsx(mo,{className:"w-4 h-4"}):Be==="opencode"?t.jsx(fo,{className:"h-4 w-auto max-w-full"}):t.jsx(Pn,{className:"w-4 h-4"})}),t.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:Be==="codex"?r.summary||r.name||"Codex Session":Be==="gemini"?r.summary||r.name||"Gemini Session":Be==="opencode"?r.summary||r.name||"OpenCode Session":r.summary||"New Session"}),t.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:z("mainContent.newSession")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?z("tabs.git"):"Project"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&Be==="codex"&&xt&&t.jsx("button",{onClick:wt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:z("mainContent.openInCodexClient"),"aria-label":z("mainContent.openInCodexClient"),children:t.jsx(ja,{className:"w-5 h-5"})}),t.jsx("button",{onClick:()=>Se&&Se(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:z("tooltips.newChat","New Chat"),children:t.jsx(Wf,{className:"w-5 h-5"})}),t.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:t.jsx(Vb,{value:n,onValueChange:s,children:t.jsx(rp,{children:t.jsx(Hn,{content:z("tabs.chat"),position:"bottom",children:t.jsx(np,{value:"chat",children:t.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[t.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:t.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"})}),t.jsx("span",{className:"hidden lg:inline",children:z("tabs.chat")})]})})})})})})]})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[t.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${_?"mr-0":""} ${re?"hidden":""}`,children:[t.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:t.jsx(Kb,{showDetails:!0,children:t.jsx(Vv,{selectedProject:e,selectedSession:r,ws:o,sendMessage:a,latestMessage:l,onFileOpen:De,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,newSessionResetNonce:B},`${e?.name||"no-project"}:${r?.id||`new-${B}`}`)})}),n==="shell"&&t.jsx("div",{className:"h-full w-full overflow-hidden",children:t.jsx(tp,{project:e,session:r,showHeader:!1})}),n==="git"&&t.jsx("div",{className:"chat-surface h-full overflow-hidden",children:t.jsx(qb,{selectedProject:e,isMobile:c,onFileOpen:De})}),t.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),_&&!c&&t.jsxs(t.Fragment,{children:[!re&&t.jsx("div",{ref:nt,onMouseDown:bt,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:t.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-primary dark:bg-primary opacity-0 group-hover:opacity-100 transition-opacity"})}),t.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${re?"flex-1":""}`,style:re?{}:{width:`${O}px`},children:t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!0,isExpanded:re,onToggleExpand:Ge})})]})]}),_&&c&&t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!1})]})}const Xb=dn.memo(Yb),sp="0.2.0",op=()=>{const[e,r]=i.useState(!1),[n,s]=i.useState(null),[o,a]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const c=await ee("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");s(u),r(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else r(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),r(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:sp,releaseInfo:o}};function Qb(){const{t:e}=Lt("settings"),[r,n]=i.useState([]),[s,o]=i.useState([]),[a,l]=i.useState(!0),[c,d]=i.useState(!1),[u,m]=i.useState(!1),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(""),[A,L]=i.useState(""),[j,S]=i.useState({}),[D,b]=i.useState(null),[I,G]=i.useState(null),{updateAvailable:P,latestVersion:V,releaseInfo:ve}=op();i.useEffect(()=>{ae()},[]);const ae=async()=>{try{l(!0);const _=await(await ee("/api/settings/api-keys")).json();n(_.apiKeys||[]);const O=await(await ee("/api/settings/credentials?type=github_token")).json();o(O.credentials||[])}catch(z){console.error("Error fetching settings:",z)}finally{l(!1)}},R=async()=>{if(p.trim())try{const _=await(await ee("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();_.success&&(G(_.apiKey),h(""),d(!1),ae())}catch(z){console.error("Error creating API key:",z)}},q=async z=>{if(confirm(e("apiKeys.confirmDelete")))try{await ee(`/api/settings/api-keys/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting API key:",_)}},de=async(z,_)=>{try{await ee(`/api/settings/api-keys/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling API key:",N)}},se=async()=>{if(!(!g.trim()||!k.trim()))try{(await(await ee("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:g,credentialType:"github_token",credentialValue:k,description:A})})).json()).success&&(x(""),w(""),L(""),m(!1),ae())}catch(z){console.error("Error creating GitHub credential:",z)}},he=async z=>{if(confirm(e("apiKeys.github.confirmDelete")))try{await ee(`/api/settings/credentials/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting GitHub credential:",_)}},Se=async(z,_)=>{try{await ee(`/api/settings/credentials/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling GitHub credential:",N)}},B=(z,_)=>{navigator.clipboard.writeText(z),b(_),setTimeout(()=>b(null),2e3)};return a?t.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):t.jsxs("div",{className:"space-y-8",children:[I&&t.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[t.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>B(I.apiKey,"new"),children:D==="new"?t.jsx(Gt,{className:"h-4 w-4"}):t.jsx(Jm,{className:"h-4 w-4"})})]}),t.jsx(_e,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>G(null),children:e("apiKeys.newKey.iveSavedIt")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>d(!c),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),t.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),t.jsx(ja,{className:"h-3 w-3"})]})]}),c&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[t.jsx(gt,{placeholder:e("apiKeys.form.placeholder"),value:p,onChange:z=>h(z.target.value),className:"mb-2"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:R,children:e("apiKeys.form.createButton")}),t.jsx(_e,{variant:"outline",onClick:()=>d(!1),children:e("apiKeys.form.cancelButton")})]})]}),t.jsx("div",{className:"space-y-2",children:r.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):r.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.key_name}),t.jsx("code",{className:"text-xs text-muted-foreground",children:z.api_key}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(z.created_at).toLocaleDateString(),z.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(z.last_used).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>de(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>q(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cf,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.github.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>m(!u),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.github.addButton")]})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("apiKeys.github.descriptionAlt")}),u&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[t.jsx(gt,{placeholder:e("apiKeys.github.form.namePlaceholder"),value:g,onChange:z=>x(z.target.value)}),t.jsxs("div",{className:"relative",children:[t.jsx(gt,{type:j.new?"text":"password",placeholder:e("apiKeys.github.form.tokenPlaceholder"),value:k,onChange:z=>w(z.target.value),className:"pr-10"}),t.jsx("button",{type:"button",onClick:()=>S({...j,new:!j.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:j.new?t.jsx($c,{className:"h-4 w-4"}):t.jsx(si,{className:"h-4 w-4"})})]}),t.jsx(gt,{placeholder:e("apiKeys.github.form.descriptionPlaceholder"),value:A,onChange:z=>L(z.target.value)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:se,children:e("apiKeys.github.form.addButton")}),t.jsx(_e,{variant:"outline",onClick:()=>{m(!1),x(""),w(""),L("")},children:e("apiKeys.github.form.cancelButton")})]}),t.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:e("apiKeys.github.form.howToCreate")})]}),t.jsx("div",{className:"space-y-2",children:s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.github.empty")}):s.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.credential_name}),z.description&&t.jsx("div",{className:"text-xs text-muted-foreground",children:z.description}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.github.added")," ",new Date(z.created_at).toLocaleDateString()]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>Se(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>he(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsx("div",{className:"pt-6 border-t border-border/50",children:t.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[t.jsxs("a",{href:ve?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",sp]}),P&&V&&t.jsxs("a",{href:ve?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[t.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:V})}),t.jsx(ja,{className:"h-2.5 w-2.5"})]})]})})]})}function Zb(){const{t:e}=Lt("settings"),[r,n]=i.useState(""),[s,o]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(!1),[u,m]=i.useState(null);i.useEffect(()=>{p()},[]);const p=async()=>{try{l(!0);const g=await ee("/api/user/git-config");if(g.ok){const x=await g.json();n(x.gitName||""),o(x.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{l(!1)}},h=async()=>{try{d(!0);const g=await ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:s})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const x=await g.json();m("error"),console.error("Failed to save git config:",x.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{d(!1)}};return t.jsx("div",{className:"space-y-8",children:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Kr,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("git.title")})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("git.description")}),t.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:e("git.name.label")}),t.jsx(gt,{id:"settings-git-name",type:"text",value:r,onChange:g=>n(g.target.value),placeholder:"John Doe",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.name.help")})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:e("git.email.label")}),t.jsx(gt,{id:"settings-git-email",type:"email",value:s,onChange:g=>o(g.target.value),placeholder:"john@example.com",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.email.help")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:h,disabled:c||!r||!s,children:e(c?"git.actions.saving":"git.actions.save")}),u==="success"&&t.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[t.jsx(Gt,{className:"w-4 h-4"}),e("git.status.success")]})]})]})]})})}const ew=["claude","cursor","codex","gemini","opencode"],Ec=["lark","dingtalk"],Ic={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},va={running:!1,status:"stopped",error:null};function tw({projects:e=[]}){const{t:r}=Lt("settings"),[n,s]=i.useState("lark"),[o,a]=i.useState(Ic),[l,c]=i.useState({lark:{...va},dingtalk:{...va}}),[d,u]=i.useState({lark:[],dingtalk:[]}),[m,p]=i.useState(!1),[h,g]=i.useState(!1),[x,k]=i.useState(!1),[w,A]=i.useState(!1),[L,j]=i.useState(null),[S,D]=i.useState(null),[b,I]=i.useState({userId:"",displayName:"",note:""}),G=i.useMemo(()=>e.map(N=>({label:N.displayName||N.name||N.path||N.fullPath,value:N.path||N.fullPath||""})).filter(N=>N.value),[e]),P=o[n]||Ic[n],V=l[n]||va,ve=d[n]||[],ae=async(N,O=!1)=>{O||D(null);const[ne,Ce,be]=await Promise.all([ee(`/api/channels/${N}/config`),ee(`/api/channels/${N}/status`),ee(`/api/channels/${N}/allowed-users`)]),re=await ne.json(),Ee=await Ce.json(),nt=await be.json();re?.success&&re?.config&&a(De=>({...De,[N]:{...De[N],...re.config}})),Ee?.success&&Ee?.status&&c(De=>({...De,[N]:Ee.status})),nt?.success&&u(De=>({...De,[N]:nt.users||[]}))},R=async(N=!1)=>{p(!0);try{await Promise.all(Ec.map(O=>ae(O,N)))}catch(O){D(O.message||r("channels.errors.loadFailed","加载渠道设置失败"))}finally{p(!1)}};i.useEffect(()=>{R()},[]);const q=N=>{a(O=>({...O,[n]:{...O[n],...N}}))},de=async()=>{p(!0),j(null),D(null);try{const N=n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath}:{appId:P.appId,appSecret:P.appSecret,encryptKey:P.encryptKey,verificationToken:P.verificationToken,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath},O=await ee(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(N)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.saveFailed","保存失败"));q(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),j(r(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.saveFailed","保存失败"))}finally{p(!1)}},se=async()=>{if(n==="dingtalk"){const N=String(P.clientId||"").trim(),O=String(P.clientSecret||"").trim();if(!N||!O&&!P.hasClientSecret){D(r("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const N=String(P.appId||"").trim(),O=String(P.appSecret||"").trim();if(!N||!O&&!P.hasAppSecret){D(r("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret}:{appId:P.appId,appSecret:P.appSecret})}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.testFailed","连接测试失败"));j(r(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(N){D(N.message||r("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},he=async()=>{k(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/start`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.startFailed","启动失败"))}finally{k(!1)}},Se=async()=>{A(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/stop`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.stopFailed","停止失败"))}finally{A(!1)}},B=async()=>{if(!b.userId.trim()){D(r("channels.errors.userIdRequired","请输入用户ID"));return}p(!0),D(null),j(null);try{const O=await ee(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.addUserFailed","新增用户失败"));I({userId:"",displayName:"",note:""}),j(r("channels.messages.userAdded","用户已添加")),await ae(n,!0)}catch(O){D(O.message||r("channels.errors.addUserFailed","新增用户失败"))}finally{p(!1)}},z=async N=>{p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N.isActive})}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.toggleUserFailed","更新用户状态失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{p(!1)}},_=async N=>{if(window.confirm(r("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N}`,{method:"DELETE"}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.deleteUserFailed","删除用户失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.deleteUserFailed","删除用户失败"))}finally{p(!1)}}};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:r("channels.title","第三方 IM")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:r(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),t.jsx("div",{className:"border-b border-border",children:t.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":r("channels.title","第三方 IM"),children:Ec.map(N=>{const O=N===n;return t.jsx("button",{type:"button",role:"tab","aria-selected":O,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors rounded-t-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 ${O?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(N),j(null),D(null)},children:r(`channels.platforms.${N}`,N==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},N)})})}),(L||S)&&t.jsx("div",{className:`rounded-lg border p-3 text-sm ${S?"border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300":"border-green-300 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300"}`,children:S||L}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.connection.title","连接配置")}),n==="dingtalk"?t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),t.jsx(gt,{value:P.clientId,onChange:N=>q({clientId:N.target.value}),placeholder:"dingxxxxxxxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),t.jsx(gt,{type:"password",value:P.clientSecret,onChange:N=>q({clientSecret:N.target.value}),placeholder:P.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),t.jsx(gt,{value:P.appId,onChange:N=>q({appId:N.target.value}),placeholder:"cli_xxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),t.jsx(gt,{type:"password",value:P.appSecret,onChange:N=>q({appSecret:N.target.value}),placeholder:P.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.backend","默认后端")}),t.jsx("select",{value:P.defaultBackend,onChange:N=>q({defaultBackend:N.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",children:ew.map(N=>t.jsx("option",{value:N,children:N},N))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.project","默认项目")}),t.jsxs("select",{value:P.defaultProjectPath,onChange:N=>q({defaultProjectPath:N.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",children:[t.jsx("option",{value:"",children:r("channels.defaults.projectPlaceholder","请选择项目")}),G.map(N=>t.jsx("option",{value:N.value,children:N.label},N.value))]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:de,disabled:m,children:r("channels.actions.saveConfig","保存配置")}),t.jsx(_e,{variant:"outline",onClick:se,disabled:h,children:h?r("channels.actions.testing","测试中..."):r("channels.actions.test","测试连接")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.runtime.title","运行状态")}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[r("channels.runtime.currentStatus","当前状态"),": ",t.jsx("span",{className:"font-medium text-foreground",children:V.status||"stopped"}),V.error?t.jsx("span",{className:"text-red-500 ml-2",children:V.error}):null]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:he,disabled:x||V.running,children:x?r("channels.actions.starting","启动中..."):r("channels.actions.start","启动")}),t.jsx(_e,{variant:"outline",onClick:Se,disabled:w||!V.running,children:w?r("channels.actions.stopping","停止中..."):r("channels.actions.stop","停止")}),t.jsx(_e,{variant:"ghost",onClick:()=>void ae(n),disabled:m,children:r("channels.actions.refresh","刷新")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.allowedUsers.title","允许用户ID(白名单)")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[t.jsx(gt,{placeholder:r("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:N=>I(O=>({...O,userId:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:N=>I(O=>({...O,displayName:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:N=>I(O=>({...O,note:N.target.value}))}),t.jsx(_e,{onClick:B,disabled:m,children:r("channels.allowedUsers.add","新增")})]}),t.jsx("div",{className:"space-y-2",children:ve.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:r("channels.allowedUsers.empty","暂无白名单用户")}):ve.map(N=>t.jsxs("div",{className:"border border-border rounded-lg p-3 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:N.userId}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[N.displayName||"-",N.note?` · ${N.note}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-xs px-2 py-1 rounded ${N.isActive?"bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:N.isActive?r("channels.allowedUsers.active","启用"):r("channels.allowedUsers.inactive","停用")}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>void z(N),children:N.isActive?r("channels.allowedUsers.disable","停用"):r("channels.allowedUsers.enable","启用")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>void _(N.id),children:r("channels.allowedUsers.delete","删除")})]})]},N.id))})]}),t.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[t.jsx("h5",{className:"font-medium text-foreground mb-2",children:r("channels.help.title","使用说明")}),t.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[t.jsx("li",{children:r(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),t.jsx("li",{children:r(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),t.jsx("li",{children:r(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function ap({isOpen:e,onClose:r,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:l=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=m=>{o?.(m),m===0&&r()};return t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),t.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:t.jsx(lr,{className:"w-6 h-6"})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(tp,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function ip({compact:e=!1}){const{i18n:r,t:n}=Lt("settings"),s=o=>{const a=o.target.value;r.changeLanguage(a)};return e?t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(zc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),t.jsx("select",{value:r.language,onChange:s,className:"w-[100px] 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-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),t.jsx("select",{value:r.language,onChange:s,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-ring focus:border-primary p-2 w-36",children:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function rw({isOpen:e,onClose:r,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=ei(),{t:l}=Lt("settings"),[c,d]=i.useState([]),[u,m]=i.useState([]),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(!1),[A,L]=i.useState(!1),[j,S]=i.useState(null),[D,b]=i.useState("name"),[I,G]=i.useState([]),[P,V]=i.useState(!1),[ve,ae]=i.useState(null),[R,q]=i.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[de,se]=i.useState(!1),[he,Se]=i.useState({}),[B,z]=i.useState({}),[_,N]=i.useState({}),[O,ne]=i.useState(s),[Ce,be]=i.useState(""),re=["appearance","git","api","channels"],[Ee,nt]=i.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[De,fe]=i.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ge,bt]=i.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[st,Be]=i.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ze,xt]=i.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[wt,ye]=i.useState([]),[qe,Nt]=i.useState("default"),[X,Te]=i.useState(!1),[W,Z]=i.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[we,Ae]=i.useState(null),[Xe,Qe]=i.useState(!1),[We,Et]=i.useState(!1),[ie,St]=i.useState(""),[et,ot]=i.useState(null),[Ke,Tt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ot,yt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[At,rr]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),tt=async()=>{try{const $=await ee("/api/codex/mcp/config/read");if($.ok){const le=await $.json();if(le.success&&le.servers){ye(le.servers);return}}const U=await ee("/api/codex/mcp/cli/list");if(U.ok){const le=await U.json();if(le.success&&le.servers){const Oe=le.servers.map(T=>({id:T.name,name:T.name,type:T.type||"stdio",scope:"user",config:{command:T.command||"",args:T.args||[],env:T.env||{}}}));ye(Oe)}}}catch($){console.error("Error fetching Codex MCP servers:",$)}},Ft=async()=>{try{const $=await ee("/api/mcp/config/read");if($.ok){const Oe=await $.json();if(Oe.success&&Oe.servers){G(Oe.servers);return}}const U=await ee("/api/mcp/cli/list");if(U.ok){const Oe=await U.json();if(Oe.success&&Oe.servers){const T=Oe.servers.map(te=>({id:te.name,name:te.name,type:te.type,scope:"user",config:{command:te.command||"",args:te.args||[],env:te.env||{},url:te.url||"",headers:te.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));G(T);return}}const le=await ee("/api/mcp/servers?scope=user");if(le.ok){const Oe=await le.json();G(Oe.servers||[])}else console.error("Failed to fetch MCP servers")}catch($){console.error("Error fetching MCP servers:",$)}},It=async $=>{try{ve&&await $t(ve.id,"user");const U=await ee("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,type:$.type,scope:$.scope,projectPath:$.projectPath,command:$.config?.command,args:$.config?.args||[],url:$.config?.url,headers:$.config?.headers||{},env:$.config?.env||{}})});if(U.ok){const le=await U.json();if(le.success)return await Ft(),!0;throw new Error(le.error||"Failed to save server via Claude CLI")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving MCP server:",U),U}},$t=async($,U="user")=>{try{const le=await ee(`/api/mcp/cli/remove/${$}?scope=${U}`,{method:"DELETE"});if(le.ok){const Oe=await le.json();if(Oe.success)return await Ft(),!0;throw new Error(Oe.error||"Failed to delete server via Claude CLI")}else{const Oe=await le.json();throw new Error(Oe.error||"Failed to delete server")}}catch(le){throw console.error("Error deleting MCP server:",le),le}},nr=async $=>{try{we&&await Bt(we.id);const U=await ee("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,command:$.config?.command,args:$.config?.args||[],env:$.config?.env||{}})});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to save Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving Codex MCP server:",U),U}},Bt=async $=>{try{const U=await ee(`/api/codex/mcp/cli/remove/${$}`,{method:"DELETE"});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to delete Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to delete server")}}catch(U){throw console.error("Error deleting Codex MCP server:",U),U}},M=()=>{Z({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Ae(null),Te(!1)},ge=async $=>{$.preventDefault(),Qe(!0);try{we&&await Bt(we.name),await nr(W),M(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{Qe(!1)}};i.useEffect(()=>{e&&(Re(),Q(),C(),F(),ne(re.includes(s)?s:"appearance"))},[e,s]),i.useEffect(()=>{localStorage.setItem("codeEditorTheme",Ee),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ee]),i.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",De.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[De]),i.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ge]),i.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",st.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[st]),i.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]);const Re=async()=>{try{const $=localStorage.getItem("claude-settings");if($){const le=JSON.parse($);d(le.allowedTools||[]),m(le.disallowedTools||[]),w(le.skipPermissions||!1),b(le.projectSortOrder||"name")}else d([]),m([]),w(!1),b("name");const U=localStorage.getItem("codex-settings");if(U){const le=JSON.parse(U);Nt(le.permissionMode||"default")}else Nt("default");await Ft(),await tt()}catch($){console.error("Error loading tool settings:",$),d([]),m([]),w(!1),b("name")}},Q=async()=>{try{const $=await ee("/api/cli/claude/status");if($.ok){const U=await $.json();Tt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else Tt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Claude auth status:",$),Tt({authenticated:!1,email:null,loading:!1,error:$.message})}},C=async()=>{try{const $=await ee("/api/cli/codex/status");if($.ok){const U=await $.json();yt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else yt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Codex auth status:",$),yt({authenticated:!1,email:null,loading:!1,error:$.message})}},F=async()=>{try{const $=await ee("/api/cli/gemini/status");if($.ok){const U=await $.json();rr({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else rr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Gemini auth status:",$),rr({authenticated:!1,email:null,loading:!1,error:$.message})}},pe=$=>{$===0&&(S("success"),ie==="claude"?Q():ie==="codex"?C():ie==="gemini"&&F())},je=()=>{L(!0),S(null);try{const $={allowedTools:c,disallowedTools:u,skipPermissions:k,projectSortOrder:D,lastUpdated:new Date().toISOString()},U={permissionMode:qe,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify($)),localStorage.setItem("codex-settings",JSON.stringify(U)),S("success"),setTimeout(()=>{r()},1e3)}catch($){console.error("Error saving tool settings:",$),S("error")}finally{L(!1)}},mt=()=>{q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),ae(null),V(!1),be("")},H=async $=>{$.preventDefault(),se(!0);try{if(R.importMode==="json"){const U=await ee("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:R.name,jsonConfig:R.jsonInput,scope:R.scope,projectPath:R.projectPath})});if(U.ok){const le=await U.json();if(le.success)await Ft(),mt(),S("success");else throw new Error(le.error||"Failed to add server via JSON")}else{const le=await U.json();throw new Error(le.error||"Failed to add server")}}else await It(R),mt(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{se(!1)}},_t=($,U)=>{q(le=>({...le,config:{...le.config,[$]:U}}))};return e?t.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Wc,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),t.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:l("title")})]}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:t.jsx(lr,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"border-b border-border",children:t.jsxs("div",{className:"flex px-4 md:px-6",children:[t.jsx("button",{onClick:()=>ne("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:l("mainTabs.appearance")}),t.jsxs("button",{onClick:()=>ne("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="git"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(Kr,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.git")]}),t.jsxs("button",{onClick:()=>ne("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(ai,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.apiTokens")]}),t.jsxs("button",{onClick:()=>ne("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(rh,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.channels","Channels")]})]})}),t.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&t.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="appearance"&&t.jsxs("div",{className:"space-y-6 md:space-y-8",children:[t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.darkMode.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.darkMode.description")})]}),t.jsxs("button",{onClick:a,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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":o,"aria-label":"Toggle dark mode",children:[t.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),t.jsx("span",{className:`${o?"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:o?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),t.jsx("div",{className:"space-y-4",children:t.jsx(ip,{})}),t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.projectSorting.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.projectSorting.description")})]}),t.jsxs("select",{value:D,onChange:$=>b($.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-ring focus:border-primary p-2 w-32",children:[t.jsx("option",{value:"name",children:l("appearanceSettings.projectSorting.alphabetical")}),t.jsx("option",{value:"date",children:l("appearanceSettings.projectSorting.recentActivity")})]})]})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:l("appearanceSettings.codeEditor.title")}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.theme.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.theme.description")})]}),t.jsxs("button",{onClick:()=>nt(Ee==="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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ee==="dark","aria-label":"Toggle editor theme",children:[t.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),t.jsx("span",{className:`${Ee==="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:Ee==="dark"?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.wordWrap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.wordWrap.description")})]}),t.jsxs("button",{onClick:()=>fe(!De),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":De,"aria-label":"Toggle word wrap",children:[t.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),t.jsx("span",{className:`${De?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.showMinimap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.showMinimap.description")})]}),t.jsxs("button",{onClick:()=>bt(!Ge),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ge,"aria-label":"Toggle minimap",children:[t.jsx("span",{className:"sr-only",children:"Toggle minimap"}),t.jsx("span",{className:`${Ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.description")})]}),t.jsxs("button",{onClick:()=>Be(!st),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":st,"aria-label":"Toggle line numbers",children:[t.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),t.jsx("span",{className:`${st?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.fontSize.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.fontSize.description")})]}),t.jsxs("select",{value:Ze,onChange:$=>xt($.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-ring focus:border-primary p-2 w-24",children:[t.jsx("option",{value:"10",children:"10px"}),t.jsx("option",{value:"11",children:"11px"}),t.jsx("option",{value:"12",children:"12px"}),t.jsx("option",{value:"13",children:"13px"}),t.jsx("option",{value:"14",children:"14px"}),t.jsx("option",{value:"15",children:"15px"}),t.jsx("option",{value:"16",children:"16px"}),t.jsx("option",{value:"18",children:"18px"}),t.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),O==="git"&&t.jsx(Zb,{}),P&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:t.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[t.jsx("h3",{className:"text-lg font-medium text-foreground",children:l(ve?"mcpForm.title.edit":"mcpForm.title.add")}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:mt,children:t.jsx(lr,{className:"w-4 h-4"})})]}),t.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[!ve&&t.jsxs("div",{className:"flex gap-2 mb-4",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="form"?"bg-primary 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:l("mcpForm.importMode.form")}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="json"?"bg-primary 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:l("mcpForm.importMode.json")})]}),R.importMode==="form"&&ve&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.scope.label")}),t.jsxs("div",{className:"flex items-center gap-2",children:[R.scope==="user"?t.jsx(fl,{className:"w-4 h-4"}):t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm",children:R.scope==="user"?l("mcpForm.scope.userGlobal"):l("mcpForm.scope.projectLocal")}),R.scope==="local"&&R.projectPath&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",R.projectPath]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:l("mcpForm.scope.cannotChange")})]}),R.importMode==="form"&&!ve&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.scope.label")," *"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="user"?"bg-primary 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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(fl,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.userGlobal")})]})}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="local"?"bg-primary 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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.projectLocal")})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:R.scope==="user"?l("mcpForm.scope.userDescription"):l("mcpForm.scope.projectDescription")})]}),R.scope==="local"&&!ve&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.selectProject")," *"]}),t.jsxs("select",{value:R.projectPath,onChange:$=>q(U=>({...U,projectPath:$.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-ring focus:border-primary",required:R.scope==="local",children:[t.jsxs("option",{value:"",children:[l("mcpForm.fields.selectProject"),"..."]}),n.map($=>t.jsx("option",{value:$.path||$.fullPath,children:$.displayName||$.name},$.name))]}),R.projectPath&&t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:l("mcpForm.projectPath",{path:R.projectPath})})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:R.importMode==="json"?"md:col-span-2":"",children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.serverName")," *"]}),t.jsx(gt,{value:R.name,onChange:$=>{q(U=>({...U,name:$.target.value}))},placeholder:l("mcpForm.placeholders.serverName"),required:!0})]}),R.importMode==="form"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.transportType")," *"]}),t.jsxs("select",{value:R.type,onChange:$=>{q(U=>({...U,type:$.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-ring focus:border-primary",children:[t.jsx("option",{value:"stdio",children:"stdio"}),t.jsx("option",{value:"sse",children:"SSE"}),t.jsx("option",{value:"http",children:"HTTP"})]})]})]}),ve&&R.raw&&R.importMode==="form"&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:l("mcpForm.configDetails",{configFile:ve.scope==="global"?"~/.claude.json":"project config"})}),t.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(R.raw,null,2)})]}),R.importMode==="json"&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.jsonConfig")," *"]}),t.jsx("textarea",{value:R.jsonInput,onChange:$=>{q(U=>({...U,jsonInput:$.target.value}));try{if($.target.value.trim()){const U=JSON.parse($.target.value);U.type?U.type==="stdio"&&!U.command?be(l("mcpForm.validation.stdioRequiresCommand")):(U.type==="http"||U.type==="sse")&&!U.url?be(l("mcpForm.validation.httpRequiresUrl",{type:U.type})):be(""):be(l("mcpForm.validation.missingType"))}}catch{$.target.value.trim()?be(l("mcpForm.validation.invalidJson")):be("")}},className:`w-full px-3 py-2 border ${Ce?"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-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
|
|
471
|
+
`).map((a,l)=>o(a,l))]})}function qb({selectedProject:e,isMobile:r,onFileOpen:n}){const[s,o]=i.useState(null),[a,l]=i.useState({}),[c,d]=i.useState(!1),[u,m]=i.useState(""),[p,h]=i.useState(new Set),[g,x]=i.useState(new Set),[k,w]=i.useState(!1),[A,L]=i.useState(""),[j,S]=i.useState([]),[D,b]=i.useState(!0),[I,G]=i.useState(!1),[P,V]=i.useState(!1),[ve,ae]=i.useState(!1),[R,q]=i.useState(""),[de,se]=i.useState(!1),[he,Se]=i.useState("changes"),[B,z]=i.useState([]),[_,N]=i.useState(new Set),[O,ne]=i.useState({}),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(null),[nt,De]=i.useState(!1),[fe,Ge]=i.useState(!1),[bt,st]=i.useState(!1),[Be,Ze]=i.useState(!1),[xt,wt]=i.useState(r),[ye,qe]=i.useState(null),[Nt,X]=i.useState(!1),Te=i.useRef(null),W=i.useRef(null),[Z,we]=i.useState(()=>localStorage.getItem("selected-provider")||"claude");i.useEffect(()=>{const C=()=>{const F=localStorage.getItem("selected-provider")||"claude";we(F)};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),i.useEffect(()=>{e&&(Ae(),Xe(),Qe(),he==="history"&&rr())},[e,he]),i.useEffect(()=>{const C=F=>{W.current&&!W.current.contains(F.target)&&V(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const Ae=async()=>{if(e){d(!0);try{const F=await(await ee(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(F.error)console.error("Git status error:",F.error),o({error:F.error,details:F.details});else{o(F),L(F.branch||"main");const pe=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(pe);for(const je of F.modified||[])yt(je);for(const je of F.added||[])yt(je);for(const je of F.deleted||[])yt(je);for(const je of F.untracked||[])yt(je)}}catch(C){console.error("Error fetching git status:",C)}finally{d(!1)}}},Xe=async()=>{try{const F=await(await ee(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&S(F.branches)}catch(C){console.error("Error fetching branches:",C)}},Qe=async()=>{if(e)try{const F=await(await ee(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?Ee(null):Ee(F)}catch(C){console.error("Error fetching remote status:",C),Ee(null)}},We=async C=>{try{const pe=await(await ee("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:C})})).json();pe.success?(L(C),V(!1),Ae()):console.error("Failed to switch branch:",pe.error)}catch(F){console.error("Error switching branch:",F)}},Et=async()=>{if(R.trim()){se(!0);try{const F=await(await ee("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:R.trim()})})).json();F.success?(L(R.trim()),ae(!1),V(!1),q(""),Xe(),Ae()):console.error("Failed to create branch:",F.error)}catch(C){console.error("Error creating branch:",C)}finally{se(!1)}}},ie=async()=>{De(!0);try{const F=await(await ee("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Fetch failed:",F.error)}catch(C){console.error("Error fetching from remote:",C)}finally{De(!1)}},St=async()=>{Ge(!0);try{const F=await(await ee("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Pull failed:",F.error)}catch(C){console.error("Error pulling from remote:",C)}finally{Ge(!1)}},et=async()=>{st(!0);try{const F=await(await ee("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):console.error("Push failed:",F.error)}catch(C){console.error("Error pushing to remote:",C)}finally{st(!1)}},ot=async()=>{Ze(!0);try{const F=await(await ee("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:A})})).json();F.success?(Ae(),Qe()):console.error("Publish failed:",F.error)}catch(C){console.error("Error publishing branch:",C)}finally{Ze(!1)}},Ke=async C=>{try{const pe=await(await ee("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Discard failed:",pe.error)}catch(F){console.error("Error discarding changes:",F)}},Tt=async C=>{try{const pe=await(await ee("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();pe.success?(x(je=>{const mt=new Set(je);return mt.delete(C),mt}),Ae()):console.error("Delete failed:",pe.error)}catch(F){console.error("Error deleting untracked file:",F)}},Ot=async()=>{if(!ye)return;const{type:C,file:F,message:pe}=ye;qe(null);try{switch(C){case"discard":await Ke(F);break;case"delete":await Tt(F);break;case"commit":await Bt();break;case"pull":await St();break;case"push":await et();break;case"publish":await ot();break}}catch(je){console.error(`Error executing ${C}:`,je)}},yt=async C=>{try{const pe=await(await ee(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();!pe.error&&pe.diff&&l(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching file diff:",F)}},At=async C=>{if(n)try{const pe=await(await ee(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();if(pe.error){console.error("Error fetching file with diff:",pe.error),n(C);return}const je={old_string:pe.oldContent||"",new_string:pe.currentContent||""};n(C,je)}catch(F){console.error("Error opening file:",F),n(C)}},rr=async()=>{try{const F=await(await ee(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&z(F.commits)}catch(C){console.error("Error fetching commits:",C)}},tt=async C=>{try{const pe=await(await ee(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${C}`)).json();!pe.error&&pe.diff&&ne(je=>({...je,[C]:pe.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},Ft=async()=>{be(!0);try{const F=await(await ee("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:Z})})).json();F.message?m(F.message):console.error("Failed to generate commit message:",F.error)}catch(C){console.error("Error generating commit message:",C)}finally{be(!1)}},It=C=>{h(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},$t=C=>{N(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):(pe.add(C),O[C]||tt(C)),pe})},nr=C=>{x(F=>{const pe=new Set(F);return pe.has(C)?pe.delete(C):pe.add(C),pe})},Bt=async()=>{if(!(!u.trim()||g.size===0)){w(!0);try{const F=await(await ee("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();F.success?(m(""),x(new Set),Ae(),Qe()):console.error("Commit failed:",F.error)}catch(C){console.error("Error committing changes:",C)}finally{w(!1)}}},M=async()=>{X(!0);try{const F=await(await ee("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),Qe()):(console.error("Initial commit failed:",F.error),alert(F.error||"Failed to create initial commit"))}catch(C){console.error("Error creating initial commit:",C),alert("Failed to create initial commit")}finally{X(!1)}},ge=C=>{switch(C){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return C}},Re=C=>{const F=_.has(C.hash),pe=O[C.hash];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>$t(C.hash),children:[t.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:C.message}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[C.author," • ",C.date]})]}),t.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.hash.substring(0,7)})]})})]}),F&&pe&&t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:t.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[t.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:C.stats}),t.jsx(Cc,{diff:pe,fileName:"commit",isMobile:r,wrapText:D})]})})]},C.hash)},Q=(C,F)=>{const pe=p.has(C),je=g.has(C),mt=a[C];return t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[t.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${r?"px-2 py-1.5":"px-3 py-2"}`,children:[t.jsx("input",{type:"checkbox",checked:je,onChange:()=>nr(C),onClick:H=>H.stopPropagation(),className:`rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:focus:ring-ring dark:bg-gray-800 dark:checked:bg-primary ${r?"mr-1.5":"mr-2"}`}),t.jsxs("div",{className:"flex items-center flex-1",children:[t.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${r?"mr-1":"mr-2"}`,onClick:H=>{H.stopPropagation(),It(C)},children:t.jsx(sn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${pe?"rotate-90":"rotate-0"}`})}),t.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:H=>{H.stopPropagation(),At(C)},title:"Click to open file",children:C}),t.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"discard",file:C,message:`Discard all changes to "${C}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Discard changes",children:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Discard"})]}),F==="U"&&t.jsxs("button",{onClick:H=>{H.stopPropagation(),qe({type:"delete",file:C,message:`Delete untracked file "${C}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Delete untracked file",children:[t.jsx(ir,{className:"w-3 h-3"}),r&&t.jsx("span",{children:"Delete"})]}),t.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:ge(F),children:F})]})]})]}),t.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${pe&&mt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:F}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ge(F)})]}),r&&t.jsx("button",{onClick:H=>{H.stopPropagation(),b(!D)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:D?"Switch to horizontal scroll":"Switch to text wrap",children:D?"↔️ Scroll":"↩️ Wrap"})]}),t.jsx("div",{className:"max-h-96 overflow-y-auto",children:mt&&t.jsx(Cc,{diff:mt,fileName:C,isMobile:r,wrapText:D})})]})]},C)};return e?t.jsxs("div",{className:"h-full flex flex-col bg-background",children:[t.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${r?"px-3 py-2":"px-4 py-3"}`,children:[t.jsxs("div",{className:"relative",ref:W,children:[t.jsxs("button",{onClick:()=>V(!P),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${r?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[t.jsx(Kr,{className:`text-gray-600 dark:text-gray-400 ${r?"w-3 h-3":"w-4 h-4"}`}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:`font-medium ${r?"text-xs":"text-sm"}`,children:A}),re?.hasRemote&&t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[re.ahead>0&&t.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${re.ahead} commit${re.ahead!==1?"s":""} ahead`,children:["↑",re.ahead]}),re.behind>0&&t.jsxs("span",{className:"text-primary",title:`${re.behind} commit${re.behind!==1?"s":""} behind`,children:["↓",re.behind]}),re.isUpToDate&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),t.jsx(Ar,{className:`w-3 h-3 text-gray-500 transition-transform ${P?"rotate-180":""}`})]}),P&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[t.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:j.map(C=>t.jsx("button",{onClick:()=>We(C),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${C===A?"bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[C===A&&t.jsx(Gt,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),t.jsx("span",{className:C===A?"font-medium":"",children:C})]})},C))}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:t.jsxs("button",{onClick:()=>{ae(!0),V(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center space-x-2",children:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create new branch"})]})})]})]}),t.jsxs("div",{className:`flex items-center ${r?"gap-1":"gap-2"}`,children:[re?.hasRemote&&t.jsxs(t.Fragment,{children:[!re?.hasUpstream&&t.jsxs("button",{onClick:()=>qe({type:"publish",message:`Publish branch "${A}" to ${re.remoteName}?`}),disabled:Be,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1",title:`Publish branch "${A}" to ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${Be?"animate-pulse":""}`}),t.jsx("span",{children:Be?"Publishing...":"Publish"})]}),re?.hasUpstream&&!re?.isUpToDate&&t.jsxs(t.Fragment,{children:[re.behind>0&&t.jsxs("button",{onClick:()=>qe({type:"pull",message:`Pull ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}?`}),disabled:fe,className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 flex items-center gap-1",title:`Pull ${re.behind} commit${re.behind!==1?"s":""} from ${re.remoteName}`,children:[t.jsx(ka,{className:`w-3 h-3 ${fe?"animate-pulse":""}`}),t.jsx("span",{children:fe?"Pulling...":`Pull ${re.behind}`})]}),re.ahead>0&&t.jsxs("button",{onClick:()=>qe({type:"push",message:`Push ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}?`}),disabled:bt,className:"px-2 py-1 text-xs bg-orange-600 text-white rounded hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1",title:`Push ${re.ahead} commit${re.ahead!==1?"s":""} to ${re.remoteName}`,children:[t.jsx(Ns,{className:`w-3 h-3 ${bt?"animate-pulse":""}`}),t.jsx("span",{children:bt?"Pushing...":`Push ${re.ahead}`})]}),(re.ahead>0||re.behind>0&&re.ahead>0)&&t.jsxs("button",{onClick:ie,disabled:nt,className:"px-2 py-1 text-xs bg-primary text-white rounded hover:bg-primary/80 disabled:opacity-50 flex items-center gap-1",title:`Fetch from ${re.remoteName}`,children:[t.jsx(Tr,{className:`w-3 h-3 ${nt?"animate-spin":""}`}),t.jsx("span",{children:nt?"Fetching...":"Fetch"})]})]})]}),t.jsx("button",{onClick:()=>{Ae(),Xe(),Qe()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${r?"p-1":"p-1.5"}`,children:t.jsx(Tr,{className:`${c?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[t.jsx(Kr,{className:"w-20 h-20 mb-6 opacity-30"}),t.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&t.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),t.jsx("div",{className:"p-4 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/60 max-w-md",children:t.jsxs("p",{className:"text-sm text-primary text-center",children:[t.jsx("strong",{children:"Tip:"})," Run ",t.jsx("code",{className:"bg-primary/15 dark:bg-primary/30 px-2 py-1 rounded font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.jsx("button",{onClick:()=>Se("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="changes"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(oi,{className:"w-4 h-4"}),t.jsx("span",{children:"Changes"})]})}),t.jsx("button",{onClick:()=>Se("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${he==="history"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(hl,{className:"w-4 h-4"}),t.jsx("span",{children:"History"})]})})]}),he==="changes"&&t.jsx(t.Fragment,{children:t.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&xt?t.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:t.jsxs("button",{onClick:()=>wt(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80",children:[t.jsx(ra,{className:"w-4 h-4"}),t.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),t.jsx(Ar,{className:"w-3 h-3"})]})}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[r&&t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),t.jsx("button",{onClick:()=>wt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:t.jsx(Ar,{className:"w-4 h-4 rotate-180"})})]}),t.jsxs("div",{className:"relative",children:[t.jsx("textarea",{ref:Te,value:u,onChange:C=>m(C.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&Bt()}}),t.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[t.jsx("button",{onClick:Ft,disabled:g.size===0||Ce,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:Ce?t.jsx(Tr,{className:"w-4 h-4 animate-spin"}):t.jsx(ri,{className:"w-4 h-4"})}),t.jsx("div",{style:{display:"none"},children:t.jsx(Gb,{onTranscript:C=>m(C),mode:"default",className:"p-1.5"})})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),t.jsxs("button",{onClick:()=>qe({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||k,className:"px-3 py-1 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",children:[t.jsx(Gt,{className:"w-3 h-3"}),t.jsx("span",{children:k?"Committing...":"Commit"})]})]})]})})})}),he==="changes"&&s&&!s.error&&t.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${r?"px-3 py-1.5":"px-4 py-2"} ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[t.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[g.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",r?"":"files"," selected"]}),t.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[t.jsx("button",{onClick:()=>{const C=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);x(C)},className:"text-primary hover:text-primary text-xs",children:r?"All":"Select All"}),t.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),t.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:r?"None":"Deselect All"})]})]}),!s?.error&&!r&&t.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[t.jsxs("button",{onClick:()=>G(!I),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[t.jsx(Mf,{className:"w-3 h-3"}),t.jsx("span",{children:"File Status Guide"}),I?t.jsx(Ar,{className:"w-3 h-3"}):t.jsx(sn,{className:"w-3 h-3"})]}),I&&t.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:t.jsxs("div",{className:`${r?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),t.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),he==="changes"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[t.jsx(Kr,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),t.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),t.jsx("button",{onClick:M,disabled:Nt,className:"px-4 py-2 bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:Nt?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-4 h-4 animate-spin"}),t.jsx("span",{children:"Creating Initial Commit..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ra,{className:"w-4 h-4"}),t.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(ra,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No changes detected"})]}):t.jsxs("div",{className:r?"pb-4":"",children:[s.modified?.map(C=>Q(C,"M")),s.added?.map(C=>Q(C,"A")),s.deleted?.map(C=>Q(C,"D")),s.untracked?.map(C=>Q(C,"U"))]})}),he==="history"&&!s?.error&&t.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:c?t.jsx("div",{className:"flex items-center justify-center h-32",children:t.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):B.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[t.jsx(hl,{className:"w-12 h-12 mb-2 opacity-50"}),t.jsx("p",{className:"text-sm",children:"No commits found"})]}):t.jsx("div",{className:r?"pb-4":"",children:B.map(C=>Re(C))})}),ve&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>ae(!1)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),t.jsx("input",{type:"text",value:R,onChange:C=>q(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!de&&Et()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-ring",autoFocus:!0})]}),t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:["This will create a new branch from the current branch (",A,")"]}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>{ae(!1),q("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),t.jsx("button",{onClick:Et,disabled:!R.trim()||de,className:"px-4 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:de?t.jsxs(t.Fragment,{children:[t.jsx(Tr,{className:"w-3 h-3 animate-spin"}),t.jsx("span",{children:"Creating..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(ln,{className:"w-3 h-3"}),t.jsx("span",{children:"Create Branch"})]})})]})]})})]}),ye&&t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>qe(null)}),t.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:`p-2 rounded-full mr-3 ${ye.type==="discard"||ye.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:t.jsx(Ea,{className:`w-5 h-5 ${ye.type==="discard"||ye.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),t.jsx("h3",{className:"text-lg font-semibold",children:ye.type==="discard"?"Discard Changes":ye.type==="delete"?"Delete File":ye.type==="commit"?"Confirm Commit":ye.type==="pull"?"Confirm Pull":ye.type==="publish"?"Publish Branch":"Confirm Push"})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:ye.message}),t.jsxs("div",{className:"flex justify-end space-x-3",children:[t.jsx("button",{onClick:()=>qe(null),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),t.jsx("button",{onClick:Ot,className:`px-4 py-2 text-sm text-white rounded-md ${ye.type==="discard"||ye.type==="delete"?"bg-red-600 hover:bg-red-700":ye.type==="commit"?"bg-primary hover:bg-primary/90":ye.type==="pull"?"bg-green-600 hover:bg-green-700":ye.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:ye.type==="discard"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Discard"})]}):ye.type==="delete"?t.jsxs(t.Fragment,{children:[t.jsx(ir,{className:"w-4 h-4"}),t.jsx("span",{children:"Delete"})]}):ye.type==="commit"?t.jsxs(t.Fragment,{children:[t.jsx(Gt,{className:"w-4 h-4"}),t.jsx("span",{children:"Commit"})]}):ye.type==="pull"?t.jsxs(t.Fragment,{children:[t.jsx(ka,{className:"w-4 h-4"}),t.jsx("span",{children:"Pull"})]}):ye.type==="publish"?t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Publish"})]}):t.jsxs(t.Fragment,{children:[t.jsx(Ns,{className:"w-4 h-4"}),t.jsx("span",{children:"Push"})]})})]})]})})]})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:t.jsx("p",{children:"Select a project to view source control"})})}class Kb extends dn.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,n){console.error("ErrorBoundary caught an error:",r,n),this.setState({error:r,errorInfo:n})}render(){return this.state.hasError?t.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:t.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[t.jsxs("div",{className:"flex items-center mb-4",children:[t.jsx("div",{className:"flex-shrink-0",children:t.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:t.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"})})}),t.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),t.jsxs("div",{className:"text-sm text-red-700",children:[t.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&t.jsxs("details",{className:"mt-4",children:[t.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),t.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]})]})]}),t.jsx("div",{className:"mt-4",children:t.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:"Try Again"})})]})}):this.props.children}}const Vb=Xx,rp=i.forwardRef(({className:e,...r},n)=>t.jsx(tu,{ref:n,className:ut("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...r}));rp.displayName=tu.displayName;const np=i.forwardRef(({className:e,...r},n)=>t.jsx(ru,{ref:n,className:ut("inline-flex items-center justify-center whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...r}));np.displayName=ru.displayName;const Jb=i.forwardRef(({className:e,...r},n)=>t.jsx(nu,{ref:n,className:ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...r}));Jb.displayName=nu.displayName;function Yb({selectedProject:e,selectedSession:r,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:l,isMobile:c,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,onShowNewProject:he,onNewSession:Se,newSessionResetNonce:B}){const{t:z}=Lt(),[_,N]=i.useState(null),[O,ne]=i.useState(600),[Ce,be]=i.useState(!1),[re,Ee]=i.useState(!1),nt=i.useRef(null),De=(ye,qe=null)=>{const Nt={name:ye.split("/").pop(),path:ye,projectName:e?.name,diffInfo:qe};N(Nt)},fe=()=>{N(null),Ee(!1)},Ge=()=>{Ee(!re)},bt=ye=>{c||(be(!0),ye.preventDefault())};if(i.useEffect(()=>{n==="files"&&s("chat")},[n,s]),i.useEffect(()=>{const ye=Nt=>{if(!Ce)return;const X=nt.current?.parentElement;if(!X)return;const Te=X.getBoundingClientRect(),W=Te.right-Nt.clientX,Z=300,we=Te.width*.8;W>=Z&&W<=we&&ne(W)},qe=()=>{be(!1)};return Ce&&(document.addEventListener("mousemove",ye),document.addEventListener("mouseup",qe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",qe),document.body.style.cursor="",document.body.style.userSelect=""}},[Ce]),m)return t.jsxs("div",{className:"h-full flex flex-col",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.jsx("button",{onClick:u,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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[t.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:t.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),t.jsx("h2",{className:"text-xl font-semibold",children:z("mainContent.loading")})]})})]});if(!e)return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&t.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:t.jsx("button",{onClick:u,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:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),t.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:t.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[t.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:t.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.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"})})}),t.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:z("mainContent.chooseProject")}),t.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:z("mainContent.selectProjectDescription")}),t.jsx("div",{className:"mx-auto flex w-fit items-center",children:t.jsxs("button",{onClick:he,className:"inline-flex items-center gap-2 rounded-xl bg-foreground px-4 py-2 text-sm font-medium text-background transition hover:opacity-90",title:z("tooltips.createProject")||"New Chat",children:[t.jsx(Sn,{className:"w-5 h-5"}),t.jsx("span",{children:z("tooltips.createProject")||"New Chat"})]})})]})})]});const st=r?.__provider||r?.provider||"claude",Be=st==="openai"?"codex":st,Ze=Be==="codex"&&typeof r?.id=="string"?r.id.trim():"",xt=Ze?`codex://threads/${encodeURIComponent(Ze)}`:"",wt=()=>{xt&&(window.location.href=xt)};return t.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[t.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:t.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&t.jsx("button",{onClick:u,onTouchStart:ye=>{ye.preventDefault(),u()},className:"pwa-menu-button flex-shrink-0 rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground touch-manipulation active:scale-95",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),t.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&r&&t.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:Be==="codex"?t.jsx(ss,{className:"w-4 h-4"}):Be==="gemini"?t.jsx(mo,{className:"w-4 h-4"}):Be==="opencode"?t.jsx(fo,{className:"h-4 w-auto max-w-full"}):t.jsx(Pn,{className:"w-4 h-4"})}),t.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:Be==="codex"?r.summary||r.name||"Codex Session":Be==="gemini"?r.summary||r.name||"Gemini Session":Be==="opencode"?r.summary||r.name||"OpenCode Session":r.summary||"New Session"}),t.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!r?t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:z("mainContent.newSession")}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?z("tabs.git"):"Project"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&Be==="codex"&&xt&&t.jsx("button",{onClick:wt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:z("mainContent.openInCodexClient"),"aria-label":z("mainContent.openInCodexClient"),children:t.jsx(ja,{className:"w-5 h-5"})}),t.jsx("button",{onClick:()=>Se&&Se(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:z("tooltips.newChat","New Chat"),children:t.jsx(Wf,{className:"w-5 h-5"})}),t.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:t.jsx(Vb,{value:n,onValueChange:s,children:t.jsx(rp,{children:t.jsx(Hn,{content:z("tabs.chat"),position:"bottom",children:t.jsx(np,{value:"chat",children:t.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[t.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:t.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"})}),t.jsx("span",{className:"hidden lg:inline",children:z("tabs.chat")})]})})})})})})]})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[t.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${_?"mr-0":""} ${re?"hidden":""}`,children:[t.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:t.jsx(Kb,{showDetails:!0,children:t.jsx(Vv,{selectedProject:e,selectedSession:r,ws:o,sendMessage:a,latestMessage:l,onFileOpen:De,onInputFocusChange:p,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:k,processingSessions:w,onReplaceTemporarySession:A,onNavigateToSession:L,onShowSettings:j,autoExpandTools:S,showRawParameters:D,showThinking:b,autoScrollToBottom:I,sendByCtrlEnter:G,externalMessageUpdate:P,urlProvider:V,urlModel:ve,urlContext:ae,urlPrompt:R,integrationClientId:q,latestIntegrationMessage:de,sendIntegrationMessage:se,newSessionResetNonce:B},`${e?.name||"no-project"}:${r?.id||`new-${B}`}`)})}),n==="shell"&&t.jsx("div",{className:"h-full w-full overflow-hidden",children:t.jsx(tp,{project:e,session:r,showHeader:!1})}),n==="git"&&t.jsx("div",{className:"chat-surface h-full overflow-hidden",children:t.jsx(qb,{selectedProject:e,isMobile:c,onFileOpen:De})}),t.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),_&&!c&&t.jsxs(t.Fragment,{children:[!re&&t.jsx("div",{ref:nt,onMouseDown:bt,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:t.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-primary dark:bg-primary opacity-0 group-hover:opacity-100 transition-opacity"})}),t.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${re?"flex-1":""}`,style:re?{}:{width:`${O}px`},children:t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!0,isExpanded:re,onToggleExpand:Ge})})]})]}),_&&c&&t.jsx(Nc,{file:_,onClose:fe,projectPath:e?.path,isSidebar:!1})]})}const Xb=dn.memo(Yb),sp="0.2.1",op=()=>{const[e,r]=i.useState(!1),[n,s]=i.useState(null),[o,a]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const c=await ee("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");s(u),r(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else r(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),r(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:sp,releaseInfo:o}};function Qb(){const{t:e}=Lt("settings"),[r,n]=i.useState([]),[s,o]=i.useState([]),[a,l]=i.useState(!0),[c,d]=i.useState(!1),[u,m]=i.useState(!1),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(""),[A,L]=i.useState(""),[j,S]=i.useState({}),[D,b]=i.useState(null),[I,G]=i.useState(null),{updateAvailable:P,latestVersion:V,releaseInfo:ve}=op();i.useEffect(()=>{ae()},[]);const ae=async()=>{try{l(!0);const _=await(await ee("/api/settings/api-keys")).json();n(_.apiKeys||[]);const O=await(await ee("/api/settings/credentials?type=github_token")).json();o(O.credentials||[])}catch(z){console.error("Error fetching settings:",z)}finally{l(!1)}},R=async()=>{if(p.trim())try{const _=await(await ee("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();_.success&&(G(_.apiKey),h(""),d(!1),ae())}catch(z){console.error("Error creating API key:",z)}},q=async z=>{if(confirm(e("apiKeys.confirmDelete")))try{await ee(`/api/settings/api-keys/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting API key:",_)}},de=async(z,_)=>{try{await ee(`/api/settings/api-keys/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling API key:",N)}},se=async()=>{if(!(!g.trim()||!k.trim()))try{(await(await ee("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:g,credentialType:"github_token",credentialValue:k,description:A})})).json()).success&&(x(""),w(""),L(""),m(!1),ae())}catch(z){console.error("Error creating GitHub credential:",z)}},he=async z=>{if(confirm(e("apiKeys.github.confirmDelete")))try{await ee(`/api/settings/credentials/${z}`,{method:"DELETE"}),ae()}catch(_){console.error("Error deleting GitHub credential:",_)}},Se=async(z,_)=>{try{await ee(`/api/settings/credentials/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!_})}),ae()}catch(N){console.error("Error toggling GitHub credential:",N)}},B=(z,_)=>{navigator.clipboard.writeText(z),b(_),setTimeout(()=>b(null),2e3)};return a?t.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):t.jsxs("div",{className:"space-y-8",children:[I&&t.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[t.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>B(I.apiKey,"new"),children:D==="new"?t.jsx(Gt,{className:"h-4 w-4"}):t.jsx(Jm,{className:"h-4 w-4"})})]}),t.jsx(_e,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>G(null),children:e("apiKeys.newKey.iveSavedIt")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>d(!c),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),t.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),t.jsx(ja,{className:"h-3 w-3"})]})]}),c&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[t.jsx(gt,{placeholder:e("apiKeys.form.placeholder"),value:p,onChange:z=>h(z.target.value),className:"mb-2"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:R,children:e("apiKeys.form.createButton")}),t.jsx(_e,{variant:"outline",onClick:()=>d(!1),children:e("apiKeys.form.cancelButton")})]})]}),t.jsx("div",{className:"space-y-2",children:r.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):r.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.key_name}),t.jsx("code",{className:"text-xs text-muted-foreground",children:z.api_key}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(z.created_at).toLocaleDateString(),z.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(z.last_used).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>de(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>q(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cf,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.github.title")})]}),t.jsxs(_e,{size:"sm",onClick:()=>m(!u),children:[t.jsx(ln,{className:"h-4 w-4 mr-1"}),e("apiKeys.github.addButton")]})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("apiKeys.github.descriptionAlt")}),u&&t.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[t.jsx(gt,{placeholder:e("apiKeys.github.form.namePlaceholder"),value:g,onChange:z=>x(z.target.value)}),t.jsxs("div",{className:"relative",children:[t.jsx(gt,{type:j.new?"text":"password",placeholder:e("apiKeys.github.form.tokenPlaceholder"),value:k,onChange:z=>w(z.target.value),className:"pr-10"}),t.jsx("button",{type:"button",onClick:()=>S({...j,new:!j.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:j.new?t.jsx($c,{className:"h-4 w-4"}):t.jsx(si,{className:"h-4 w-4"})})]}),t.jsx(gt,{placeholder:e("apiKeys.github.form.descriptionPlaceholder"),value:A,onChange:z=>L(z.target.value)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(_e,{onClick:se,children:e("apiKeys.github.form.addButton")}),t.jsx(_e,{variant:"outline",onClick:()=>{m(!1),x(""),w(""),L("")},children:e("apiKeys.github.form.cancelButton")})]}),t.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:e("apiKeys.github.form.howToCreate")})]}),t.jsx("div",{className:"space-y-2",children:s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.github.empty")}):s.map(z=>t.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium",children:z.credential_name}),z.description&&t.jsx("div",{className:"text-xs text-muted-foreground",children:z.description}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.github.added")," ",new Date(z.created_at).toLocaleDateString()]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>Se(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>he(z.id),children:t.jsx(ir,{className:"h-4 w-4"})})]})]},z.id))})]}),t.jsx("div",{className:"pt-6 border-t border-border/50",children:t.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[t.jsxs("a",{href:ve?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",sp]}),P&&V&&t.jsxs("a",{href:ve?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[t.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:V})}),t.jsx(ja,{className:"h-2.5 w-2.5"})]})]})})]})}function Zb(){const{t:e}=Lt("settings"),[r,n]=i.useState(""),[s,o]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(!1),[u,m]=i.useState(null);i.useEffect(()=>{p()},[]);const p=async()=>{try{l(!0);const g=await ee("/api/user/git-config");if(g.ok){const x=await g.json();n(x.gitName||""),o(x.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{l(!1)}},h=async()=>{try{d(!0);const g=await ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:s})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const x=await g.json();m("error"),console.error("Failed to save git config:",x.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{d(!1)}};return t.jsx("div",{className:"space-y-8",children:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Kr,{className:"h-5 w-5"}),t.jsx("h3",{className:"text-lg font-semibold",children:e("git.title")})]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("git.description")}),t.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:e("git.name.label")}),t.jsx(gt,{id:"settings-git-name",type:"text",value:r,onChange:g=>n(g.target.value),placeholder:"John Doe",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.name.help")})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:e("git.email.label")}),t.jsx(gt,{id:"settings-git-email",type:"email",value:s,onChange:g=>o(g.target.value),placeholder:"john@example.com",disabled:a,className:"w-full"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.email.help")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:h,disabled:c||!r||!s,children:e(c?"git.actions.saving":"git.actions.save")}),u==="success"&&t.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[t.jsx(Gt,{className:"w-4 h-4"}),e("git.status.success")]})]})]})]})})}const ew=["claude","cursor","codex","gemini","opencode"],Ec=["lark","dingtalk"],Ic={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},va={running:!1,status:"stopped",error:null};function tw({projects:e=[]}){const{t:r}=Lt("settings"),[n,s]=i.useState("lark"),[o,a]=i.useState(Ic),[l,c]=i.useState({lark:{...va},dingtalk:{...va}}),[d,u]=i.useState({lark:[],dingtalk:[]}),[m,p]=i.useState(!1),[h,g]=i.useState(!1),[x,k]=i.useState(!1),[w,A]=i.useState(!1),[L,j]=i.useState(null),[S,D]=i.useState(null),[b,I]=i.useState({userId:"",displayName:"",note:""}),G=i.useMemo(()=>e.map(N=>({label:N.displayName||N.name||N.path||N.fullPath,value:N.path||N.fullPath||""})).filter(N=>N.value),[e]),P=o[n]||Ic[n],V=l[n]||va,ve=d[n]||[],ae=async(N,O=!1)=>{O||D(null);const[ne,Ce,be]=await Promise.all([ee(`/api/channels/${N}/config`),ee(`/api/channels/${N}/status`),ee(`/api/channels/${N}/allowed-users`)]),re=await ne.json(),Ee=await Ce.json(),nt=await be.json();re?.success&&re?.config&&a(De=>({...De,[N]:{...De[N],...re.config}})),Ee?.success&&Ee?.status&&c(De=>({...De,[N]:Ee.status})),nt?.success&&u(De=>({...De,[N]:nt.users||[]}))},R=async(N=!1)=>{p(!0);try{await Promise.all(Ec.map(O=>ae(O,N)))}catch(O){D(O.message||r("channels.errors.loadFailed","加载渠道设置失败"))}finally{p(!1)}};i.useEffect(()=>{R()},[]);const q=N=>{a(O=>({...O,[n]:{...O[n],...N}}))},de=async()=>{p(!0),j(null),D(null);try{const N=n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath}:{appId:P.appId,appSecret:P.appSecret,encryptKey:P.encryptKey,verificationToken:P.verificationToken,defaultBackend:P.defaultBackend,defaultModel:P.defaultModel,defaultProjectPath:P.defaultProjectPath},O=await ee(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(N)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.saveFailed","保存失败"));q(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),j(r(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.saveFailed","保存失败"))}finally{p(!1)}},se=async()=>{if(n==="dingtalk"){const N=String(P.clientId||"").trim(),O=String(P.clientSecret||"").trim();if(!N||!O&&!P.hasClientSecret){D(r("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const N=String(P.appId||"").trim(),O=String(P.appSecret||"").trim();if(!N||!O&&!P.hasAppSecret){D(r("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:P.clientId,clientSecret:P.clientSecret}:{appId:P.appId,appSecret:P.appSecret})}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.testFailed","连接测试失败"));j(r(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(N){D(N.message||r("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},he=async()=>{k(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/start`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.startFailed","启动失败"))}finally{k(!1)}},Se=async()=>{A(!0),D(null),j(null);try{const N=await ee(`/api/channels/${n}/stop`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||r("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),j(r(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await ae(n,!0)}catch(N){D(N.message||r("channels.errors.stopFailed","停止失败"))}finally{A(!1)}},B=async()=>{if(!b.userId.trim()){D(r("channels.errors.userIdRequired","请输入用户ID"));return}p(!0),D(null),j(null);try{const O=await ee(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.addUserFailed","新增用户失败"));I({userId:"",displayName:"",note:""}),j(r("channels.messages.userAdded","用户已添加")),await ae(n,!0)}catch(O){D(O.message||r("channels.errors.addUserFailed","新增用户失败"))}finally{p(!1)}},z=async N=>{p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N.isActive})}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.toggleUserFailed","更新用户状态失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{p(!1)}},_=async N=>{if(window.confirm(r("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){p(!0),D(null);try{const O=await ee(`/api/channels/${n}/allowed-users/${N}`,{method:"DELETE"}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||r("channels.errors.deleteUserFailed","删除用户失败"));await ae(n,!0)}catch(O){D(O.message||r("channels.errors.deleteUserFailed","删除用户失败"))}finally{p(!1)}}};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:r("channels.title","第三方 IM")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:r(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),t.jsx("div",{className:"border-b border-border",children:t.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":r("channels.title","第三方 IM"),children:Ec.map(N=>{const O=N===n;return t.jsx("button",{type:"button",role:"tab","aria-selected":O,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors rounded-t-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 ${O?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(N),j(null),D(null)},children:r(`channels.platforms.${N}`,N==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},N)})})}),(L||S)&&t.jsx("div",{className:`rounded-lg border p-3 text-sm ${S?"border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300":"border-green-300 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300"}`,children:S||L}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.connection.title","连接配置")}),n==="dingtalk"?t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),t.jsx(gt,{value:P.clientId,onChange:N=>q({clientId:N.target.value}),placeholder:"dingxxxxxxxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),t.jsx(gt,{type:"password",value:P.clientSecret,onChange:N=>q({clientSecret:N.target.value}),placeholder:P.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),t.jsx(gt,{value:P.appId,onChange:N=>q({appId:N.target.value}),placeholder:"cli_xxx"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),t.jsx(gt,{type:"password",value:P.appSecret,onChange:N=>q({appSecret:N.target.value}),placeholder:P.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.backend","默认后端")}),t.jsx("select",{value:P.defaultBackend,onChange:N=>q({defaultBackend:N.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",children:ew.map(N=>t.jsx("option",{value:N,children:N},N))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm mb-1 text-foreground",children:r("channels.defaults.project","默认项目")}),t.jsxs("select",{value:P.defaultProjectPath,onChange:N=>q({defaultProjectPath:N.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",children:[t.jsx("option",{value:"",children:r("channels.defaults.projectPlaceholder","请选择项目")}),G.map(N=>t.jsx("option",{value:N.value,children:N.label},N.value))]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:de,disabled:m,children:r("channels.actions.saveConfig","保存配置")}),t.jsx(_e,{variant:"outline",onClick:se,disabled:h,children:h?r("channels.actions.testing","测试中..."):r("channels.actions.test","测试连接")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.runtime.title","运行状态")}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[r("channels.runtime.currentStatus","当前状态"),": ",t.jsx("span",{className:"font-medium text-foreground",children:V.status||"stopped"}),V.error?t.jsx("span",{className:"text-red-500 ml-2",children:V.error}):null]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{onClick:he,disabled:x||V.running,children:x?r("channels.actions.starting","启动中..."):r("channels.actions.start","启动")}),t.jsx(_e,{variant:"outline",onClick:Se,disabled:w||!V.running,children:w?r("channels.actions.stopping","停止中..."):r("channels.actions.stop","停止")}),t.jsx(_e,{variant:"ghost",onClick:()=>void ae(n),disabled:m,children:r("channels.actions.refresh","刷新")})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsx("h4",{className:"font-medium text-foreground",children:r("channels.allowedUsers.title","允许用户ID(白名单)")}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[t.jsx(gt,{placeholder:r("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:N=>I(O=>({...O,userId:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:N=>I(O=>({...O,displayName:N.target.value}))}),t.jsx(gt,{placeholder:r("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:N=>I(O=>({...O,note:N.target.value}))}),t.jsx(_e,{onClick:B,disabled:m,children:r("channels.allowedUsers.add","新增")})]}),t.jsx("div",{className:"space-y-2",children:ve.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:r("channels.allowedUsers.empty","暂无白名单用户")}):ve.map(N=>t.jsxs("div",{className:"border border-border rounded-lg p-3 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:N.userId}),t.jsxs("div",{className:"text-sm text-muted-foreground",children:[N.displayName||"-",N.note?` · ${N.note}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`text-xs px-2 py-1 rounded ${N.isActive?"bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:N.isActive?r("channels.allowedUsers.active","启用"):r("channels.allowedUsers.inactive","停用")}),t.jsx(_e,{size:"sm",variant:"outline",onClick:()=>void z(N),children:N.isActive?r("channels.allowedUsers.disable","停用"):r("channels.allowedUsers.enable","启用")}),t.jsx(_e,{size:"sm",variant:"ghost",onClick:()=>void _(N.id),children:r("channels.allowedUsers.delete","删除")})]})]},N.id))})]}),t.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[t.jsx("h5",{className:"font-medium text-foreground mb-2",children:r("channels.help.title","使用说明")}),t.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[t.jsx("li",{children:r(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),t.jsx("li",{children:r(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),t.jsx("li",{children:r(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function ap({isOpen:e,onClose:r,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:l=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=m=>{o?.(m),m===0&&r()};return t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:t.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[t.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),t.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:t.jsx(lr,{className:"w-6 h-6"})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(tp,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function ip({compact:e=!1}){const{i18n:r,t:n}=Lt("settings"),s=o=>{const a=o.target.value;r.changeLanguage(a)};return e?t.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:[t.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[t.jsx(zc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),t.jsx("select",{value:r.language,onChange:s,className:"w-[100px] 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-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),t.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),t.jsx("select",{value:r.language,onChange:s,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-ring focus:border-primary p-2 w-36",children:ml.map(o=>t.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function rw({isOpen:e,onClose:r,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=ei(),{t:l}=Lt("settings"),[c,d]=i.useState([]),[u,m]=i.useState([]),[p,h]=i.useState(""),[g,x]=i.useState(""),[k,w]=i.useState(!1),[A,L]=i.useState(!1),[j,S]=i.useState(null),[D,b]=i.useState("name"),[I,G]=i.useState([]),[P,V]=i.useState(!1),[ve,ae]=i.useState(null),[R,q]=i.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[de,se]=i.useState(!1),[he,Se]=i.useState({}),[B,z]=i.useState({}),[_,N]=i.useState({}),[O,ne]=i.useState(s),[Ce,be]=i.useState(""),re=["appearance","git","api","channels"],[Ee,nt]=i.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[De,fe]=i.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ge,bt]=i.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[st,Be]=i.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ze,xt]=i.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[wt,ye]=i.useState([]),[qe,Nt]=i.useState("default"),[X,Te]=i.useState(!1),[W,Z]=i.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[we,Ae]=i.useState(null),[Xe,Qe]=i.useState(!1),[We,Et]=i.useState(!1),[ie,St]=i.useState(""),[et,ot]=i.useState(null),[Ke,Tt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ot,yt]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),[At,rr]=i.useState({authenticated:!1,email:null,loading:!0,error:null}),tt=async()=>{try{const $=await ee("/api/codex/mcp/config/read");if($.ok){const le=await $.json();if(le.success&&le.servers){ye(le.servers);return}}const U=await ee("/api/codex/mcp/cli/list");if(U.ok){const le=await U.json();if(le.success&&le.servers){const Oe=le.servers.map(T=>({id:T.name,name:T.name,type:T.type||"stdio",scope:"user",config:{command:T.command||"",args:T.args||[],env:T.env||{}}}));ye(Oe)}}}catch($){console.error("Error fetching Codex MCP servers:",$)}},Ft=async()=>{try{const $=await ee("/api/mcp/config/read");if($.ok){const Oe=await $.json();if(Oe.success&&Oe.servers){G(Oe.servers);return}}const U=await ee("/api/mcp/cli/list");if(U.ok){const Oe=await U.json();if(Oe.success&&Oe.servers){const T=Oe.servers.map(te=>({id:te.name,name:te.name,type:te.type,scope:"user",config:{command:te.command||"",args:te.args||[],env:te.env||{},url:te.url||"",headers:te.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));G(T);return}}const le=await ee("/api/mcp/servers?scope=user");if(le.ok){const Oe=await le.json();G(Oe.servers||[])}else console.error("Failed to fetch MCP servers")}catch($){console.error("Error fetching MCP servers:",$)}},It=async $=>{try{ve&&await $t(ve.id,"user");const U=await ee("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,type:$.type,scope:$.scope,projectPath:$.projectPath,command:$.config?.command,args:$.config?.args||[],url:$.config?.url,headers:$.config?.headers||{},env:$.config?.env||{}})});if(U.ok){const le=await U.json();if(le.success)return await Ft(),!0;throw new Error(le.error||"Failed to save server via Claude CLI")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving MCP server:",U),U}},$t=async($,U="user")=>{try{const le=await ee(`/api/mcp/cli/remove/${$}?scope=${U}`,{method:"DELETE"});if(le.ok){const Oe=await le.json();if(Oe.success)return await Ft(),!0;throw new Error(Oe.error||"Failed to delete server via Claude CLI")}else{const Oe=await le.json();throw new Error(Oe.error||"Failed to delete server")}}catch(le){throw console.error("Error deleting MCP server:",le),le}},nr=async $=>{try{we&&await Bt(we.id);const U=await ee("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:$.name,command:$.config?.command,args:$.config?.args||[],env:$.config?.env||{}})});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to save Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to save server")}}catch(U){throw console.error("Error saving Codex MCP server:",U),U}},Bt=async $=>{try{const U=await ee(`/api/codex/mcp/cli/remove/${$}`,{method:"DELETE"});if(U.ok){const le=await U.json();if(le.success)return await tt(),!0;throw new Error(le.error||"Failed to delete Codex MCP server")}else{const le=await U.json();throw new Error(le.error||"Failed to delete server")}}catch(U){throw console.error("Error deleting Codex MCP server:",U),U}},M=()=>{Z({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Ae(null),Te(!1)},ge=async $=>{$.preventDefault(),Qe(!0);try{we&&await Bt(we.name),await nr(W),M(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{Qe(!1)}};i.useEffect(()=>{e&&(Re(),Q(),C(),F(),ne(re.includes(s)?s:"appearance"))},[e,s]),i.useEffect(()=>{localStorage.setItem("codeEditorTheme",Ee),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ee]),i.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",De.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[De]),i.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ge]),i.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",st.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[st]),i.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]);const Re=async()=>{try{const $=localStorage.getItem("claude-settings");if($){const le=JSON.parse($);d(le.allowedTools||[]),m(le.disallowedTools||[]),w(le.skipPermissions||!1),b(le.projectSortOrder||"name")}else d([]),m([]),w(!1),b("name");const U=localStorage.getItem("codex-settings");if(U){const le=JSON.parse(U);Nt(le.permissionMode||"default")}else Nt("default");await Ft(),await tt()}catch($){console.error("Error loading tool settings:",$),d([]),m([]),w(!1),b("name")}},Q=async()=>{try{const $=await ee("/api/cli/claude/status");if($.ok){const U=await $.json();Tt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else Tt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Claude auth status:",$),Tt({authenticated:!1,email:null,loading:!1,error:$.message})}},C=async()=>{try{const $=await ee("/api/cli/codex/status");if($.ok){const U=await $.json();yt({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else yt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Codex auth status:",$),yt({authenticated:!1,email:null,loading:!1,error:$.message})}},F=async()=>{try{const $=await ee("/api/cli/gemini/status");if($.ok){const U=await $.json();rr({authenticated:U.authenticated,email:U.email,loading:!1,error:U.error||null})}else rr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch($){console.error("Error checking Gemini auth status:",$),rr({authenticated:!1,email:null,loading:!1,error:$.message})}},pe=$=>{$===0&&(S("success"),ie==="claude"?Q():ie==="codex"?C():ie==="gemini"&&F())},je=()=>{L(!0),S(null);try{const $={allowedTools:c,disallowedTools:u,skipPermissions:k,projectSortOrder:D,lastUpdated:new Date().toISOString()},U={permissionMode:qe,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify($)),localStorage.setItem("codex-settings",JSON.stringify(U)),S("success"),setTimeout(()=>{r()},1e3)}catch($){console.error("Error saving tool settings:",$),S("error")}finally{L(!1)}},mt=()=>{q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),ae(null),V(!1),be("")},H=async $=>{$.preventDefault(),se(!0);try{if(R.importMode==="json"){const U=await ee("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:R.name,jsonConfig:R.jsonInput,scope:R.scope,projectPath:R.projectPath})});if(U.ok){const le=await U.json();if(le.success)await Ft(),mt(),S("success");else throw new Error(le.error||"Failed to add server via JSON")}else{const le=await U.json();throw new Error(le.error||"Failed to add server")}}else await It(R),mt(),S("success")}catch(U){alert(`Error: ${U.message}`),S("error")}finally{se(!1)}},_t=($,U)=>{q(le=>({...le,config:{...le.config,[$]:U}}))};return e?t.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[t.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:[t.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Wc,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),t.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:l("title")})]}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:t.jsx(lr,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[t.jsx("div",{className:"border-b border-border",children:t.jsxs("div",{className:"flex px-4 md:px-6",children:[t.jsx("button",{onClick:()=>ne("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:l("mainTabs.appearance")}),t.jsxs("button",{onClick:()=>ne("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="git"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(Kr,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.git")]}),t.jsxs("button",{onClick:()=>ne("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(ai,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.apiTokens")]}),t.jsxs("button",{onClick:()=>ne("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.jsx(rh,{className:"w-4 h-4 inline mr-2"}),l("mainTabs.channels","Channels")]})]})}),t.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&t.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="appearance"&&t.jsxs("div",{className:"space-y-6 md:space-y-8",children:[t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.darkMode.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.darkMode.description")})]}),t.jsxs("button",{onClick:a,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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":o,"aria-label":"Toggle dark mode",children:[t.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),t.jsx("span",{className:`${o?"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:o?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),t.jsx("div",{className:"space-y-4",children:t.jsx(ip,{})}),t.jsx("div",{className:"space-y-4",children:t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.projectSorting.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.projectSorting.description")})]}),t.jsxs("select",{value:D,onChange:$=>b($.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-ring focus:border-primary p-2 w-32",children:[t.jsx("option",{value:"name",children:l("appearanceSettings.projectSorting.alphabetical")}),t.jsx("option",{value:"date",children:l("appearanceSettings.projectSorting.recentActivity")})]})]})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:l("appearanceSettings.codeEditor.title")}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.theme.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.theme.description")})]}),t.jsxs("button",{onClick:()=>nt(Ee==="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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ee==="dark","aria-label":"Toggle editor theme",children:[t.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),t.jsx("span",{className:`${Ee==="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:Ee==="dark"?t.jsx(Na,{className:"w-3.5 h-3.5 text-gray-700"}):t.jsx(Ca,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.wordWrap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.wordWrap.description")})]}),t.jsxs("button",{onClick:()=>fe(!De),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":De,"aria-label":"Toggle word wrap",children:[t.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),t.jsx("span",{className:`${De?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.showMinimap.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.showMinimap.description")})]}),t.jsxs("button",{onClick:()=>bt(!Ge),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ge,"aria-label":"Toggle minimap",children:[t.jsx("span",{className:"sr-only",children:"Toggle minimap"}),t.jsx("span",{className:`${Ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.lineNumbers.description")})]}),t.jsxs("button",{onClick:()=>Be(!st),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-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":st,"aria-label":"Toggle line numbers",children:[t.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),t.jsx("span",{className:`${st?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),t.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-foreground",children:l("appearanceSettings.codeEditor.fontSize.label")}),t.jsx("div",{className:"text-sm text-muted-foreground",children:l("appearanceSettings.codeEditor.fontSize.description")})]}),t.jsxs("select",{value:Ze,onChange:$=>xt($.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-ring focus:border-primary p-2 w-24",children:[t.jsx("option",{value:"10",children:"10px"}),t.jsx("option",{value:"11",children:"11px"}),t.jsx("option",{value:"12",children:"12px"}),t.jsx("option",{value:"13",children:"13px"}),t.jsx("option",{value:"14",children:"14px"}),t.jsx("option",{value:"15",children:"15px"}),t.jsx("option",{value:"16",children:"16px"}),t.jsx("option",{value:"18",children:"18px"}),t.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),O==="git"&&t.jsx(Zb,{}),P&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:t.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[t.jsx("h3",{className:"text-lg font-medium text-foreground",children:l(ve?"mcpForm.title.edit":"mcpForm.title.add")}),t.jsx(_e,{variant:"ghost",size:"sm",onClick:mt,children:t.jsx(lr,{className:"w-4 h-4"})})]}),t.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[!ve&&t.jsxs("div",{className:"flex gap-2 mb-4",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="form"?"bg-primary 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:l("mcpForm.importMode.form")}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${R.importMode==="json"?"bg-primary 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:l("mcpForm.importMode.json")})]}),R.importMode==="form"&&ve&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[t.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:l("mcpForm.scope.label")}),t.jsxs("div",{className:"flex items-center gap-2",children:[R.scope==="user"?t.jsx(fl,{className:"w-4 h-4"}):t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm",children:R.scope==="user"?l("mcpForm.scope.userGlobal"):l("mcpForm.scope.projectLocal")}),R.scope==="local"&&R.projectPath&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",R.projectPath]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:l("mcpForm.scope.cannotChange")})]}),R.importMode==="form"&&!ve&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.scope.label")," *"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="user"?"bg-primary 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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(fl,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.userGlobal")})]})}),t.jsx("button",{type:"button",onClick:()=>q($=>({...$,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${R.scope==="local"?"bg-primary 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:t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(on,{className:"w-4 h-4"}),t.jsx("span",{children:l("mcpForm.scope.projectLocal")})]})})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:R.scope==="user"?l("mcpForm.scope.userDescription"):l("mcpForm.scope.projectDescription")})]}),R.scope==="local"&&!ve&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.selectProject")," *"]}),t.jsxs("select",{value:R.projectPath,onChange:$=>q(U=>({...U,projectPath:$.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-ring focus:border-primary",required:R.scope==="local",children:[t.jsxs("option",{value:"",children:[l("mcpForm.fields.selectProject"),"..."]}),n.map($=>t.jsx("option",{value:$.path||$.fullPath,children:$.displayName||$.name},$.name))]}),R.projectPath&&t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:l("mcpForm.projectPath",{path:R.projectPath})})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{className:R.importMode==="json"?"md:col-span-2":"",children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.serverName")," *"]}),t.jsx(gt,{value:R.name,onChange:$=>{q(U=>({...U,name:$.target.value}))},placeholder:l("mcpForm.placeholders.serverName"),required:!0})]}),R.importMode==="form"&&t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.transportType")," *"]}),t.jsxs("select",{value:R.type,onChange:$=>{q(U=>({...U,type:$.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-ring focus:border-primary",children:[t.jsx("option",{value:"stdio",children:"stdio"}),t.jsx("option",{value:"sse",children:"SSE"}),t.jsx("option",{value:"http",children:"HTTP"})]})]})]}),ve&&R.raw&&R.importMode==="form"&&t.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[t.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:l("mcpForm.configDetails",{configFile:ve.scope==="global"?"~/.claude.json":"project config"})}),t.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(R.raw,null,2)})]}),R.importMode==="json"&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[l("mcpForm.fields.jsonConfig")," *"]}),t.jsx("textarea",{value:R.jsonInput,onChange:$=>{q(U=>({...U,jsonInput:$.target.value}));try{if($.target.value.trim()){const U=JSON.parse($.target.value);U.type?U.type==="stdio"&&!U.command?be(l("mcpForm.validation.stdioRequiresCommand")):(U.type==="http"||U.type==="sse")&&!U.url?be(l("mcpForm.validation.httpRequiresUrl",{type:U.type})):be(""):be(l("mcpForm.validation.missingType"))}}catch{$.target.value.trim()?be(l("mcpForm.validation.invalidJson")):be("")}},className:`w-full px-3 py-2 border ${Ce?"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-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
|
|
472
472
|
"type": "stdio",
|
|
473
473
|
"command": "/path/to/server",
|
|
474
474
|
"args": ["--api-key", "abc123"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-codemirror-Dz7_EqNA.js";import"./vendor-react-Cpt6D04s.js";import{I as r,T as i,U as o}from"./mermaid-O7DHMXV3-
|
|
1
|
+
import{j as e}from"./vendor-codemirror-Dz7_EqNA.js";import"./vendor-react-Cpt6D04s.js";import{I as r,T as i,U as o}from"./mermaid-O7DHMXV3-KLW3VWsF.js";import{i as s}from"./index-EMGPq9Uy.js";function p(){return e.jsx(r,{i18n:s,children:e.jsx(i,{children:e.jsx(o,{})})})}export{p as default};
|