@kaitranntt/ccs 6.7.0-dev.1 → 6.7.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-DFHQr9A5.js";import{r as u}from"./react-vendor-FspHSO0w.js";import{u as je}from"./tanstack-C4gT2P7V.js";import{r as Z,s as ve,t as X,u as Ne,D as ee,v as se,w as te,x as ae,y as ne,B as l,c as v,d as B,L as T,I as ie,z as we,A as ye,E as be,F as Ce,G as Se,H as Ae,J as ke,K as Pe,M as De,e as I,N as Me,O as Fe,Q as Re,R as Ve,i as Le,S as Te,T as E,U as re}from"./index-eojxvUPJ.js";import{C as K,a as W}from"./card-CpMqDjRa.js";import{Y as U,b as Y,L as ce,D as O,t as Oe,j as D,o as Ge,ae as L,J as A,$ as G,af as _,A as Ie,ag as H,U as Ue,r as ze,ah as $e,ai as Qe,Z as de,aj as oe,X as le,N as qe}from"./icons-BOsxPbiD.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const F={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.1-codex-max",models:[{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]}},J=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"}];function Be({open:n,onClose:d}){const[t,i]=u.useState("provider"),[r,o]=u.useState(""),[c,x]=u.useState(null),[h,f]=u.useState(""),[N,k]=u.useState(""),[R,w]=u.useState(!1),[y,C]=u.useState(!1),[p,S]=u.useState(!1),{data:P,refetch:g}=Z(),m=ve(),j=X(),{privacyMode:M}=Ne(),b=P?.authStatus.find(s=>s.provider===r)?.accounts||[];u.useEffect(()=>{if(!n){const s=setTimeout(()=>{i("provider"),o(""),x(null),f(""),k(""),w(!1),S(!1)},0);return()=>clearTimeout(s)}},[n]),u.useEffect(()=>{if(t==="auth"&&b.length>0&&!p){const s=setTimeout(()=>{i("account")},0);return()=>clearTimeout(s)}},[t,b,p]);const a=async s=>{await navigator.clipboard.writeText(s),w(!0),setTimeout(()=>w(!1),2e3)},V=async()=>{C(!0),await g(),C(!1)},me=()=>{j.mutate({provider:r},{onSuccess:s=>{s.account&&(x(s.account),i("variant")),g()}})},ue=s=>{o(s),(P?.authStatus.find(fe=>fe.provider===s)?.accounts||[]).length===0?i("auth"):i("account")},xe=s=>{x(s),i("variant")},he=async()=>{if(!(!h||!r))try{await m.mutateAsync({name:h,provider:r,model:N||void 0,account:c?.id}),i("success")}catch(s){console.error("Failed to create variant:",s)}},$=`ccs ${r} --auth --add`,Q=["provider","auth","variant","success"],pe=(s=>s==="account"?1:Q.indexOf(s))(t),ge=s=>{if(!s&&(t==="success"||t==="provider")){d();return}};return e.jsx(ee,{open:n,onOpenChange:ge,children:e.jsxs(se,{className:"sm:max-w-lg",onPointerDownOutside:s=>{t!=="success"&&t!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(j.isPending||m.isPending)&&s.preventDefault()},children:[e.jsxs(te,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ne,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx("div",{className:"grid gap-2",children:J.map(s=>e.jsxs("button",{onClick:()=>ue(s.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),t==="auth"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",J.find(s=>s.id===r)?.name," to add an account"]}),e.jsx(l,{onClick:me,disabled:j.isPending,className:"w-full gap-2",size:"lg",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),j.isPending&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(K,{children:e.jsxs(W,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Oe,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:$}),e.jsx(l,{variant:"outline",size:"icon",onClick:()=>a($),children:R?e.jsx(D,{className:"w-4 h-4 text-green-500"}):e.jsx(Ge,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(l,{variant:"ghost",onClick:()=>i("provider"),disabled:j.isPending,children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(l,{variant:"outline",onClick:V,disabled:y||j.isPending,children:[e.jsx(A,{className:`w-4 h-4 mr-2 ${y?"animate-spin":""}`}),y?"Checking...":"Refresh Status"]})]})]}),t==="account"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",b.length,")"]}),e.jsx("div",{className:"grid gap-2",children:b.map(s=>e.jsxs("button",{type:"button",onClick:()=>xe(s),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(G,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:v("font-medium",M&&B),children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:()=>{S(!0),i("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(O,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(l,{variant:"ghost",onClick:()=>i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),t==="variant"&&e.jsxs("div",{className:"space-y-4",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(G,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:v(M&&B),children:c.email||c.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:h,onChange:s=>f(s.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",h||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(we,{value:N,onValueChange:k,children:[e.jsx(ye,{children:e.jsx(be,{placeholder:"Select a model"})}),e.jsx(Ce,{children:F[r]?.models.map(s=>e.jsx(Se,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",F[r]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(l,{variant:"ghost",onClick:()=>b.length>0?i("account"):i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{variant:"ghost",onClick:d,children:"Skip"}),e.jsx(l,{onClick:he,disabled:!h||m.isPending,children:m.isPending?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]}),t==="success"&&e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(D,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(K,{children:e.jsxs(W,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",h,' "your prompt here"']})]})}),e.jsx(l,{onClick:d,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:Q.map((s,q)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${pe>=q?"bg-primary":"bg-muted"}`},s))})]})})}function Ee({open:n,onClose:d,provider:t,displayName:i}){const[r,o]=u.useState(""),c=X(),x=()=>{c.mutate({provider:t,nickname:r.trim()||void 0},{onSuccess:()=>{o(""),d()}})},h=f=>{!f&&!c.isPending&&(o(""),d())};return e.jsx(ee,{open:n,onOpenChange:h,children:e.jsxs(se,{className:"sm:max-w-md",children:[e.jsxs(te,{children:[e.jsxs(ae,{children:["Add ",i," Account"]}),e.jsx(ne,{children:"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:r,onChange:f=>o(f.target.value),placeholder:"e.g., work, personal",disabled:c.isPending,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(l,{variant:"ghost",onClick:d,disabled:c.isPending,children:"Cancel"}),e.jsx(l,{onClick:x,disabled:c.isPending,children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),c.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function Ke(n){if(!n)return"";const d=new Date(n).getTime(),i=Date.now()-d,r=Math.floor(i/(1e3*60*60)),o=Math.floor(i%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${o}m`:`${o}m`}function We(n){if(!n)return"";const d=Date.now()-n,t=Math.floor(d/(1e3*60)),i=Math.floor(d/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${i}h ago`}function Ye(){const{data:n,isLoading:d}=Ae(),{data:t}=ke(),i=Pe(),r=De(),o=n?.running??!1,c=i.isPending||r.isPending,x=t?.hasUpdate??!1,h=async()=>{await r.mutateAsync(),await new Promise(f=>setTimeout(f,500)),i.mutate()};return e.jsxs("div",{className:v("rounded-lg border p-3 transition-colors",o?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:v("w-2 h-2 rounded-full",o?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Service"}),x&&e.jsxs(I,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",title:`Update: v${t?.currentVersion} -> v${t?.latestVersion}`,children:[e.jsx(_,{className:"w-2.5 h-2.5"}),"Update"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:d?e.jsx(A,{className:"w-3 h-3 animate-spin text-muted-foreground"}):o?e.jsx(Ie,{className:"w-3 h-3 text-green-600"}):e.jsx(H,{className:"w-3 h-3 text-muted-foreground"})})]}),o&&n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",n.port]}),n.sessionCount!==void 0&&n.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ue,{className:"w-3 h-3"}),n.sessionCount," session",n.sessionCount!==1?"s":""]}),n.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{className:"w-3 h-3"}),Ke(n.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs(l,{variant:x?"default":"outline",size:"sm",className:v("h-7 text-xs gap-1 flex-1",x&&"bg-sidebar-accent hover:bg-sidebar-accent/90 text-sidebar-accent-foreground"),onClick:h,disabled:c,title:x?`Restart to update: v${t?.currentVersion} -> v${t?.latestVersion}`:"Restart CLIProxy service",children:[c?e.jsx(A,{className:"w-3 h-3 animate-spin"}):x?e.jsx(_,{className:"w-3 h-3"}):e.jsx($e,{className:"w-3 h-3"}),x?"Update":"Restart"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",onClick:()=>r.mutate(),disabled:c,title:"Stop CLIProxy service",children:[r.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(Qe,{className:"w-3 h-3"}),"Stop"]})]})]}):e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(H,{className:"w-3 h-3"}),"Start"]})]}),t?.currentVersion&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-muted flex items-center justify-between text-[10px] text-muted-foreground/70",children:[e.jsxs("span",{children:["v",t.currentVersion]}),t.checkedAt&&e.jsxs("span",{title:new Date(t.checkedAt).toLocaleString(),children:["Synced ",We(t.checkedAt)]})]})]})}function _e({status:n,isSelected:d,onSelect:t}){const i=n.accounts?.length||0;return e.jsxs("button",{className:v("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",d?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(re,{provider:n.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:n.displayName}),i>0&&e.jsx(I,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:n.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function He({variant:n,parentAuth:d,isSelected:t,onSelect:i,onDelete:r,isDeleting:o}){return e.jsxs("button",{className:v("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(re,{provider:n.provider,size:"sm"}),e.jsx(oe,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:n.name}),e.jsx(I,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:d?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",n.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),r()},disabled:o,children:e.jsx(qe,{className:"w-3 h-3"})})]})}function Je({onSetup:n}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(de,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(l,{onClick:n,className:"gap-2",children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ls(){const n=je(),{data:d,isLoading:t}=Z(),{data:i,isFetching:r}=Me(),o=Fe(),c=Re(),x=Ve(),[h,f]=u.useState(null),[N,k]=u.useState(null),[R,w]=u.useState(!1),[y,C]=u.useState(null),p=d?.authStatus||[],S=i?.variants||[],P=u.useMemo(()=>N?null:h&&p.some(a=>a.provider===h)?h:p.length>0?p[0].provider:null,[h,N,p]),g=p.find(a=>a.provider===P),m=S.find(a=>a.name===N),j=m?p.find(a=>a.provider===m.provider):void 0,M=()=>{n.invalidateQueries({queryKey:["cliproxy"]}),n.invalidateQueries({queryKey:["cliproxy-auth"]})},z=a=>{f(a),k(null)},b=a=>{k(a),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M,disabled:r,children:e.jsx(A,{className:v("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(l,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>w(!0),children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Le,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(a=>e.jsx(Te,{className:"h-14 w-full rounded-lg"},a))}):e.jsx("div",{className:"space-y-1",children:p.map(a=>e.jsx(_e,{status:a,isSelected:P===a.provider,onSelect:()=>z(a.provider)},a.provider))}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(oe,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:S.map(a=>e.jsx(He,{variant:a,parentAuth:p.find(V=>V.provider===a.provider),isSelected:N===a.name,onSelect:()=>b(a.name),onDelete:()=>x.mutate(a.name),isDeleting:x.isPending},a.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ye,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[p.length," provider",p.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),p.filter(a=>a.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:m&&j?e.jsx(E,{provider:m.name,displayName:`${m.name} (${m.provider} variant)`,authStatus:j,catalog:F[m.provider],logoProvider:m.provider,onAddAccount:()=>C({provider:m.provider,displayName:j.displayName}),onSetDefault:a=>o.mutate({provider:m.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:m.provider,accountId:a}),isRemovingAccount:c.isPending}):g?e.jsx(E,{provider:g.provider,displayName:g.displayName,authStatus:g,catalog:F[g.provider],onAddAccount:()=>C({provider:g.provider,displayName:g.displayName}),onSetDefault:a=>o.mutate({provider:g.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:g.provider,accountId:a}),isRemovingAccount:c.isPending}):e.jsx(Je,{onSetup:()=>w(!0)})}),e.jsx(Be,{open:R,onClose:()=>w(!1)}),e.jsx(Ee,{open:y!==null,onClose:()=>C(null),provider:y?.provider||"",displayName:y?.displayName||""})]})}export{ls as CliproxyPage};
1
+ import{j as e}from"./radix-ui-DFHQr9A5.js";import{r as u}from"./react-vendor-FspHSO0w.js";import{u as je}from"./tanstack-C4gT2P7V.js";import{r as Z,s as ve,t as X,u as Ne,D as ee,v as se,w as te,x as ae,y as ne,B as l,c as v,d as B,L as T,I as ie,z as we,A as ye,E as be,F as Ce,G as Se,H as Ae,J as ke,K as Pe,M as De,e as I,N as Me,O as Fe,Q as Re,R as Ve,i as Le,S as Te,T as E,U as re}from"./index-DlEL4vYD.js";import{C as K,a as W}from"./card-DQcAIoan.js";import{Y as U,b as Y,L as ce,D as O,t as Oe,j as D,o as Ge,ae as L,J as A,$ as G,af as _,A as Ie,ag as H,U as Ue,r as ze,ah as $e,ai as Qe,Z as de,aj as oe,X as le,N as qe}from"./icons-BOsxPbiD.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const F={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.1-codex-max",models:[{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]}},J=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"}];function Be({open:n,onClose:d}){const[t,i]=u.useState("provider"),[r,o]=u.useState(""),[c,x]=u.useState(null),[h,f]=u.useState(""),[N,k]=u.useState(""),[R,w]=u.useState(!1),[y,C]=u.useState(!1),[p,S]=u.useState(!1),{data:P,refetch:g}=Z(),m=ve(),j=X(),{privacyMode:M}=Ne(),b=P?.authStatus.find(s=>s.provider===r)?.accounts||[];u.useEffect(()=>{if(!n){const s=setTimeout(()=>{i("provider"),o(""),x(null),f(""),k(""),w(!1),S(!1)},0);return()=>clearTimeout(s)}},[n]),u.useEffect(()=>{if(t==="auth"&&b.length>0&&!p){const s=setTimeout(()=>{i("account")},0);return()=>clearTimeout(s)}},[t,b,p]);const a=async s=>{await navigator.clipboard.writeText(s),w(!0),setTimeout(()=>w(!1),2e3)},V=async()=>{C(!0),await g(),C(!1)},me=()=>{j.mutate({provider:r},{onSuccess:s=>{s.account&&(x(s.account),i("variant")),g()}})},ue=s=>{o(s),(P?.authStatus.find(fe=>fe.provider===s)?.accounts||[]).length===0?i("auth"):i("account")},xe=s=>{x(s),i("variant")},he=async()=>{if(!(!h||!r))try{await m.mutateAsync({name:h,provider:r,model:N||void 0,account:c?.id}),i("success")}catch(s){console.error("Failed to create variant:",s)}},$=`ccs ${r} --auth --add`,Q=["provider","auth","variant","success"],pe=(s=>s==="account"?1:Q.indexOf(s))(t),ge=s=>{if(!s&&(t==="success"||t==="provider")){d();return}};return e.jsx(ee,{open:n,onOpenChange:ge,children:e.jsxs(se,{className:"sm:max-w-lg",onPointerDownOutside:s=>{t!=="success"&&t!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(j.isPending||m.isPending)&&s.preventDefault()},children:[e.jsxs(te,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ne,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx("div",{className:"grid gap-2",children:J.map(s=>e.jsxs("button",{onClick:()=>ue(s.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),t==="auth"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",J.find(s=>s.id===r)?.name," to add an account"]}),e.jsx(l,{onClick:me,disabled:j.isPending,className:"w-full gap-2",size:"lg",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),j.isPending&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(K,{children:e.jsxs(W,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Oe,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:$}),e.jsx(l,{variant:"outline",size:"icon",onClick:()=>a($),children:R?e.jsx(D,{className:"w-4 h-4 text-green-500"}):e.jsx(Ge,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(l,{variant:"ghost",onClick:()=>i("provider"),disabled:j.isPending,children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(l,{variant:"outline",onClick:V,disabled:y||j.isPending,children:[e.jsx(A,{className:`w-4 h-4 mr-2 ${y?"animate-spin":""}`}),y?"Checking...":"Refresh Status"]})]})]}),t==="account"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",b.length,")"]}),e.jsx("div",{className:"grid gap-2",children:b.map(s=>e.jsxs("button",{type:"button",onClick:()=>xe(s),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(G,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:v("font-medium",M&&B),children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Y,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:()=>{S(!0),i("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(O,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(l,{variant:"ghost",onClick:()=>i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),t==="variant"&&e.jsxs("div",{className:"space-y-4",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(G,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:v(M&&B),children:c.email||c.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:h,onChange:s=>f(s.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",h||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(we,{value:N,onValueChange:k,children:[e.jsx(ye,{children:e.jsx(be,{placeholder:"Select a model"})}),e.jsx(Ce,{children:F[r]?.models.map(s=>e.jsx(Se,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",F[r]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(l,{variant:"ghost",onClick:()=>b.length>0?i("account"):i("provider"),children:[e.jsx(L,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{variant:"ghost",onClick:d,children:"Skip"}),e.jsx(l,{onClick:he,disabled:!h||m.isPending,children:m.isPending?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]}),t==="success"&&e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(D,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(K,{children:e.jsxs(W,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",h,' "your prompt here"']})]})}),e.jsx(l,{onClick:d,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:Q.map((s,q)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${pe>=q?"bg-primary":"bg-muted"}`},s))})]})})}function Ee({open:n,onClose:d,provider:t,displayName:i}){const[r,o]=u.useState(""),c=X(),x=()=>{c.mutate({provider:t,nickname:r.trim()||void 0},{onSuccess:()=>{o(""),d()}})},h=f=>{!f&&!c.isPending&&(o(""),d())};return e.jsx(ee,{open:n,onOpenChange:h,children:e.jsxs(se,{className:"sm:max-w-md",children:[e.jsxs(te,{children:[e.jsxs(ae,{children:["Add ",i," Account"]}),e.jsx(ne,{children:"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:r,onChange:f=>o(f.target.value),placeholder:"e.g., work, personal",disabled:c.isPending,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(l,{variant:"ghost",onClick:d,disabled:c.isPending,children:"Cancel"}),e.jsx(l,{onClick:x,disabled:c.isPending,children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),c.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function Ke(n){if(!n)return"";const d=new Date(n).getTime(),i=Date.now()-d,r=Math.floor(i/(1e3*60*60)),o=Math.floor(i%(1e3*60*60)/(1e3*60));return r>0?`${r}h ${o}m`:`${o}m`}function We(n){if(!n)return"";const d=Date.now()-n,t=Math.floor(d/(1e3*60)),i=Math.floor(d/(1e3*60*60));return t<1?"just now":t<60?`${t}m ago`:`${i}h ago`}function Ye(){const{data:n,isLoading:d}=Ae(),{data:t}=ke(),i=Pe(),r=De(),o=n?.running??!1,c=i.isPending||r.isPending,x=t?.hasUpdate??!1,h=async()=>{await r.mutateAsync(),await new Promise(f=>setTimeout(f,500)),i.mutate()};return e.jsxs("div",{className:v("rounded-lg border p-3 transition-colors",o?"border-green-500/30 bg-green-500/5":"border-muted bg-muted/30"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:v("w-2 h-2 rounded-full",o?"bg-green-500 animate-pulse":"bg-muted-foreground/30")}),e.jsx("span",{className:"text-sm font-medium",children:"CLIProxy Service"}),x&&e.jsxs(I,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",title:`Update: v${t?.currentVersion} -> v${t?.latestVersion}`,children:[e.jsx(_,{className:"w-2.5 h-2.5"}),"Update"]})]}),e.jsx("div",{className:"flex items-center gap-1",children:d?e.jsx(A,{className:"w-3 h-3 animate-spin text-muted-foreground"}):o?e.jsx(Ie,{className:"w-3 h-3 text-green-600"}):e.jsx(H,{className:"w-3 h-3 text-muted-foreground"})})]}),o&&n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["Port ",n.port]}),n.sessionCount!==void 0&&n.sessionCount>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ue,{className:"w-3 h-3"}),n.sessionCount," session",n.sessionCount!==1?"s":""]}),n.startedAt&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{className:"w-3 h-3"}),Ke(n.startedAt)]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs(l,{variant:x?"default":"outline",size:"sm",className:v("h-7 text-xs gap-1 flex-1",x&&"bg-sidebar-accent hover:bg-sidebar-accent/90 text-sidebar-accent-foreground"),onClick:h,disabled:c,title:x?`Restart to update: v${t?.currentVersion} -> v${t?.latestVersion}`:"Restart CLIProxy service",children:[c?e.jsx(A,{className:"w-3 h-3 animate-spin"}):x?e.jsx(_,{className:"w-3 h-3"}):e.jsx($e,{className:"w-3 h-3"}),x?"Update":"Restart"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 hover:bg-destructive/10 hover:text-destructive hover:border-destructive/30",onClick:()=>r.mutate(),disabled:c,title:"Stop CLIProxy service",children:[r.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(Qe,{className:"w-3 h-3"}),"Stop"]})]})]}):e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not running"}),e.jsxs(l,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>i.mutate(),disabled:i.isPending,children:[i.isPending?e.jsx(A,{className:"w-3 h-3 animate-spin"}):e.jsx(H,{className:"w-3 h-3"}),"Start"]})]}),t?.currentVersion&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-muted flex items-center justify-between text-[10px] text-muted-foreground/70",children:[e.jsxs("span",{children:["v",t.currentVersion]}),t.checkedAt&&e.jsxs("span",{title:new Date(t.checkedAt).toLocaleString(),children:["Synced ",We(t.checkedAt)]})]})]})}function _e({status:n,isSelected:d,onSelect:t}){const i=n.accounts?.length||0;return e.jsxs("button",{className:v("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",d?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(re,{provider:n.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:n.displayName}),i>0&&e.jsx(I,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:n.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function He({variant:n,parentAuth:d,isSelected:t,onSelect:i,onDelete:r,isDeleting:o}){return e.jsxs("button",{className:v("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:i,children:[e.jsxs("div",{className:"relative",children:[e.jsx(re,{provider:n.provider,size:"sm"}),e.jsx(oe,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:n.name}),e.jsx(I,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:d?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",n.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),r()},disabled:o,children:e.jsx(qe,{className:"w-3 h-3"})})]})}function Je({onSetup:n}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(de,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(l,{onClick:n,className:"gap-2",children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ls(){const n=je(),{data:d,isLoading:t}=Z(),{data:i,isFetching:r}=Me(),o=Fe(),c=Re(),x=Ve(),[h,f]=u.useState(null),[N,k]=u.useState(null),[R,w]=u.useState(!1),[y,C]=u.useState(null),p=d?.authStatus||[],S=i?.variants||[],P=u.useMemo(()=>N?null:h&&p.some(a=>a.provider===h)?h:p.length>0?p[0].provider:null,[h,N,p]),g=p.find(a=>a.provider===P),m=S.find(a=>a.name===N),j=m?p.find(a=>a.provider===m.provider):void 0,M=()=>{n.invalidateQueries({queryKey:["cliproxy"]}),n.invalidateQueries({queryKey:["cliproxy-auth"]})},z=a=>{f(a),k(null)},b=a=>{k(a),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M,disabled:r,children:e.jsx(A,{className:v("w-4 h-4",r&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(l,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>w(!0),children:[e.jsx(U,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Le,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(a=>e.jsx(Te,{className:"h-14 w-full rounded-lg"},a))}):e.jsx("div",{className:"space-y-1",children:p.map(a=>e.jsx(_e,{status:a,isSelected:P===a.provider,onSelect:()=>z(a.provider)},a.provider))}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(oe,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:S.map(a=>e.jsx(He,{variant:a,parentAuth:p.find(V=>V.provider===a.provider),isSelected:N===a.name,onSelect:()=>b(a.name),onDelete:()=>x.mutate(a.name),isDeleting:x.isPending},a.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ye,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[p.length," provider",p.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-green-600"}),p.filter(a=>a.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:m&&j?e.jsx(E,{provider:m.name,displayName:`${m.name} (${m.provider} variant)`,authStatus:j,catalog:F[m.provider],logoProvider:m.provider,onAddAccount:()=>C({provider:m.provider,displayName:j.displayName}),onSetDefault:a=>o.mutate({provider:m.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:m.provider,accountId:a}),isRemovingAccount:c.isPending}):g?e.jsx(E,{provider:g.provider,displayName:g.displayName,authStatus:g,catalog:F[g.provider],onAddAccount:()=>C({provider:g.provider,displayName:g.displayName}),onSetDefault:a=>o.mutate({provider:g.provider,accountId:a}),onRemoveAccount:a=>c.mutate({provider:g.provider,accountId:a}),isRemovingAccount:c.isPending}):e.jsx(Je,{onSetup:()=>w(!0)})}),e.jsx(Be,{open:R,onClose:()=>w(!1)}),e.jsx(Ee,{open:y!==null,onClose:()=>C(null),provider:y?.provider||"",displayName:y?.displayName||""})]})}export{ls as CliproxyPage};
@@ -1,2 +1,2 @@
1
- import{j as e}from"./radix-ui-DFHQr9A5.js";import{r as p}from"./react-vendor-FspHSO0w.js";import{ad as $,c as d,ae as A,B as I}from"./index-eojxvUPJ.js";import{H as w,t as E}from"./code-highlight-BoHWVYut.js";import{d as K,E as O,l as M,ac as P}from"./icons-BOsxPbiD.js";import"./tanstack-C4gT2P7V.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";const F=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function H(t){return F.some(n=>n.test(t))}function V(t){if(!t.trim())return{valid:!0};try{return JSON.parse(t),{valid:!0}}catch(n){const r=n.message,u=r.match(/position (\d+)/);if(u){const m=parseInt(u[1],10),o=t.substring(0,m).split(`
1
+ import{j as e}from"./radix-ui-DFHQr9A5.js";import{r as p}from"./react-vendor-FspHSO0w.js";import{ad as $,c as d,ae as A,B as I}from"./index-DlEL4vYD.js";import{H as w,t as E}from"./code-highlight-BoHWVYut.js";import{d as K,E as O,l as M,ac as P}from"./icons-BOsxPbiD.js";import"./tanstack-C4gT2P7V.js";import"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";const F=[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/_SECRET$/,/_SECRET_KEY$/,/^API_KEY$/,/^AUTH_TOKEN$/,/^SECRET$/,/_PASSWORD$/,/^PASSWORD$/,/_CREDENTIAL$/,/_PRIVATE_KEY$/];function H(t){return F.some(n=>n.test(t))}function V(t){if(!t.trim())return{valid:!0};try{return JSON.parse(t),{valid:!0}}catch(n){const r=n.message,u=r.match(/position (\d+)/);if(u){const m=parseInt(u[1],10),o=t.substring(0,m).split(`
2
2
  `);return{valid:!1,error:r,line:o.length}}return{valid:!1,error:r}}}function q({value:t,onChange:n,language:a="json",readonly:r=!1,className:u,minHeight:m="300px"}){const{isDark:o}=$(),[N,h]=p.useState(!1),[l,j]=p.useState(!0),i=p.useMemo(()=>a==="json"?V(t):{valid:!0},[t,a]),b=p.useCallback(S=>e.jsx(w,{theme:o?E.nightOwl:E.github,code:S,language:a,children:({tokens:_,getLineProps:C,getTokenProps:T})=>{let c=!1;return e.jsx(e.Fragment,{children:_.map((x,g)=>e.jsx("div",{...C({line:x}),className:d(i.line===g+1&&"bg-destructive/20"),children:x.map((s,y)=>{let v=!1;if(s.types.includes("property")){const R=s.content.replace(/['"]/g,"");H(R)?c=!0:c=!1}else(s.types.includes("string")||s.types.includes("number")||s.types.includes("boolean"))&&c?(v=!0,c=!1):s.types.includes("punctuation")&&s.content!==":"&&s.content!=="["&&s.content!=="{"&&(c=!1);const f=T({token:s});return v&&l&&(f.className=d(f.className,"blur-[3px] select-none opacity-70 transition-all duration-200")),e.jsx("span",{...f},y)})},g))})}}),[o,a,i.line,l]);return e.jsxs("div",{className:d("flex flex-col",u),children:[e.jsxs("div",{className:d("relative rounded-md border overflow-hidden","bg-muted/30",N&&"ring-2 ring-ring ring-offset-2 ring-offset-background",r&&"opacity-70 cursor-not-allowed",!i.valid&&"border-destructive"),style:{minHeight:m},children:[e.jsx(A,{value:t,onValueChange:r?()=>{}:n,highlight:b,padding:12,disabled:r,onFocus:()=>h(!0),onBlur:()=>h(!1),textareaClassName:d("focus:outline-none font-mono text-sm",r&&"cursor-not-allowed"),preClassName:"font-mono text-sm",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:"0.875rem",minHeight:m}},o?"dark-editor":"light-editor"),e.jsx("div",{className:"absolute top-2 right-2 z-10 opacity-50 hover:opacity-100 transition-opacity",children:e.jsx(I,{variant:"ghost",size:"icon",className:"h-6 w-6 bg-background/50 hover:bg-background border shadow-sm rounded-full",onClick:()=>j(!l),title:l?"Reveal sensitive values":"Mask sensitive values",children:l?e.jsx(K,{className:"h-3 w-3"}):e.jsx(O,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 text-xs",children:[i.valid?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(M,{className:"w-3 h-3 text-green-500"}),"Valid ",a.toUpperCase()]}):e.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[e.jsx(P,{className:"w-3 h-3"}),i.error,i.line&&` (line ${i.line})`]}),r&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:"(Read-only)"})]})]})}export{q as CodeEditor};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-DmM_bX-t.js","assets/radix-ui-DFHQr9A5.js","assets/react-vendor-FspHSO0w.js","assets/index-eojxvUPJ.js","assets/tanstack-C4gT2P7V.js","assets/notifications-B2Pz7lik.js","assets/utils-CzKF5WmX.js","assets/icons-BOsxPbiD.js","assets/form-utils-BuXDJb0w.js","assets/code-highlight-BoHWVYut.js","assets/index-Brq6EBKZ.css"])))=>i.map(i=>d[i]);
2
- import{j as e}from"./radix-ui-DFHQr9A5.js";import{S as j,e as v,B as p,o as we,V as ye,W as be,X as R,Y as O,i as A,q,L as w,I as te,z as le,A as oe,E as re,F as ce,G as L,p as de,Z as Se,_ as Ce,$ as ke,a0 as Fe,c as K}from"./index-eojxvUPJ.js";import{u as Pe,a as C,b as y}from"./tanstack-C4gT2P7V.js";import{r as h}from"./react-vendor-FspHSO0w.js";import{S as D}from"./switch-K-cpw7I2.js";import{t as Q}from"./notifications-B2Pz7lik.js";import{J as me,L as J,O as Me,Q as Ae,Y as Le,Z as ae,I as Ee,X as Te,j as _e,a as Ie,T as Re,a6 as Oe,ak as qe,ag as ne,K as De,a8 as Qe,al as $e,l as ue,m as xe}from"./icons-BOsxPbiD.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const m="/api";async function Ke(){const s=await fetch(`${m}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Je(){const s=await fetch(`${m}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Ge(){const s=await fetch(`${m}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function ze(){const s=await fetch(`${m}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function Be(s){const a=await fetch(`${m}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update copilot config");return a.json()}async function Ue(s){const a=await fetch(`${m}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Error("CONFLICT");if(!a.ok)throw new Error("Failed to save copilot raw settings");return a.json()}async function Ve(){const s=await fetch(`${m}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function He(){const s=await fetch(`${m}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function Xe(){const s=await fetch(`${m}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Ye(){const s=await fetch(`${m}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function We(s){const a=await fetch(`${m}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!a.ok)throw new Error("Failed to install copilot-api");return a.json()}function he(){const s=Pe(),a=C({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),l=C({queryKey:["copilot-config"],queryFn:Je}),r=C({queryKey:["copilot-models"],queryFn:Ge}),n=C({queryKey:["copilot-raw-settings"],queryFn:ze}),d=C({queryKey:["copilot-info"],queryFn:Ye}),c=y({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=y({mutationFn:Ue,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=y({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),N=y({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),f=y({mutationFn:Xe,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),o=y({mutationFn:We,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return{status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:l.data,configLoading:l.isLoading,models:r.data?.models??[],currentModel:r.data?.current,modelsLoading:r.isLoading,rawSettings:n.data,rawSettingsLoading:n.isLoading,refetchRawSettings:n.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:N.mutate,isStartingDaemon:N.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}}const Ze=h.lazy(()=>Fe(()=>import("./code-editor-DmM_bX-t.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.CodeEditor}))),es=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],ss=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ie(s){switch(s){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ts(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function F({label:s,description:a,value:l,onChange:r,models:n,disabled:d}){const c=n.find(i=>i.id===l);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(le,{value:l||"",onValueChange:r,disabled:d,children:[e.jsx(oe,{className:"h-9",children:e.jsx(re,{placeholder:"Select model",children:l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l}),c?.minPlan&&e.jsx(v,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(c.minPlan)}`,children:c.minPlan})]})})}),e.jsx(ce,{className:"max-h-[300px]",children:e.jsxs(Ce,{children:[e.jsxs(ke,{className:"text-xs text-muted-foreground",children:["Available Models (",n.length,")"]}),n.map(i=>e.jsx(L,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(v,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ts(i.multiplier)}),i.preview&&e.jsx(v,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),l===i.id&&e.jsx(_e,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function as(){const{config:s,configLoading:a,models:l,modelsLoading:r,rawSettings:n,rawSettingsLoading:d,updateConfigAsync:c,isUpdating:i,saveRawSettingsAsync:x,isSavingRawSettings:N,refetchRawSettings:f}=he(),[o,E]=h.useState({}),[g,T]=h.useState(null),[pe,G]=h.useState(!1),z=o.enabled??s?.enabled??!1,B=o.autoStart??s?.auto_start??!1,U=o.port??s?.port??4141,V=o.accountType??s?.account_type??"individual",b=o.model??s?.model??"claude-opus-4-5-20250514",_=o.rateLimit??s?.rate_limit?.toString()??"",H=o.waitOnLimit??s?.wait_on_limit??!0,X=o.opusModel??s?.opus_model??"",Y=o.sonnetModel??s?.sonnet_model??"",W=o.haikuModel??s?.haiku_model??"",u=(t,S)=>{E(ve=>({...ve,[t]:S}))},Z=t=>{E(S=>({...S,model:t.default,opusModel:t.opus,sonnetModel:t.sonnet,haikuModel:t.haiku})),Q.success(`Applied "${t.name}" preset`)},k=h.useMemo(()=>g!==null?g:n?.settings?JSON.stringify(n.settings,null,2):`{
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-DxImO7VE.js","assets/radix-ui-DFHQr9A5.js","assets/react-vendor-FspHSO0w.js","assets/index-DlEL4vYD.js","assets/tanstack-C4gT2P7V.js","assets/notifications-B2Pz7lik.js","assets/utils-CzKF5WmX.js","assets/icons-BOsxPbiD.js","assets/form-utils-BuXDJb0w.js","assets/code-highlight-BoHWVYut.js","assets/index-Brq6EBKZ.css"])))=>i.map(i=>d[i]);
2
+ import{j as e}from"./radix-ui-DFHQr9A5.js";import{S as j,e as v,B as p,o as we,V as ye,W as be,X as R,Y as O,i as A,q,L as w,I as te,z as le,A as oe,E as re,F as ce,G as L,p as de,Z as Se,_ as Ce,$ as ke,a0 as Fe,c as K}from"./index-DlEL4vYD.js";import{u as Pe,a as C,b as y}from"./tanstack-C4gT2P7V.js";import{r as h}from"./react-vendor-FspHSO0w.js";import{S as D}from"./switch-D391CjDF.js";import{t as Q}from"./notifications-B2Pz7lik.js";import{J as me,L as J,O as Me,Q as Ae,Y as Le,Z as ae,I as Ee,X as Te,j as _e,a as Ie,T as Re,a6 as Oe,ak as qe,ag as ne,K as De,a8 as Qe,al as $e,l as ue,m as xe}from"./icons-BOsxPbiD.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const m="/api";async function Ke(){const s=await fetch(`${m}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Je(){const s=await fetch(`${m}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Ge(){const s=await fetch(`${m}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function ze(){const s=await fetch(`${m}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function Be(s){const a=await fetch(`${m}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update copilot config");return a.json()}async function Ue(s){const a=await fetch(`${m}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new Error("CONFLICT");if(!a.ok)throw new Error("Failed to save copilot raw settings");return a.json()}async function Ve(){const s=await fetch(`${m}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function He(){const s=await fetch(`${m}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function Xe(){const s=await fetch(`${m}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function Ye(){const s=await fetch(`${m}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function We(s){const a=await fetch(`${m}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!a.ok)throw new Error("Failed to install copilot-api");return a.json()}function he(){const s=Pe(),a=C({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),l=C({queryKey:["copilot-config"],queryFn:Je}),r=C({queryKey:["copilot-models"],queryFn:Ge}),n=C({queryKey:["copilot-raw-settings"],queryFn:ze}),d=C({queryKey:["copilot-info"],queryFn:Ye}),c=y({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=y({mutationFn:Ue,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=y({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),N=y({mutationFn:He,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),f=y({mutationFn:Xe,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),o=y({mutationFn:We,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return{status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:l.data,configLoading:l.isLoading,models:r.data?.models??[],currentModel:r.data?.current,modelsLoading:r.isLoading,rawSettings:n.data,rawSettingsLoading:n.isLoading,refetchRawSettings:n.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:N.mutate,isStartingDaemon:N.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:o.mutate,installAsync:o.mutateAsync,isInstalling:o.isPending}}const Ze=h.lazy(()=>Fe(()=>import("./code-editor-DxImO7VE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.CodeEditor}))),es=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],ss=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function ie(s){switch(s){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ts(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function F({label:s,description:a,value:l,onChange:r,models:n,disabled:d}){const c=n.find(i=>i.id===l);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(le,{value:l||"",onValueChange:r,disabled:d,children:[e.jsx(oe,{className:"h-9",children:e.jsx(re,{placeholder:"Select model",children:l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:l}),c?.minPlan&&e.jsx(v,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(c.minPlan)}`,children:c.minPlan})]})})}),e.jsx(ce,{className:"max-h-[300px]",children:e.jsxs(Ce,{children:[e.jsxs(ke,{className:"text-xs text-muted-foreground",children:["Available Models (",n.length,")"]}),n.map(i=>e.jsx(L,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(v,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ts(i.multiplier)}),i.preview&&e.jsx(v,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),l===i.id&&e.jsx(_e,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function as(){const{config:s,configLoading:a,models:l,modelsLoading:r,rawSettings:n,rawSettingsLoading:d,updateConfigAsync:c,isUpdating:i,saveRawSettingsAsync:x,isSavingRawSettings:N,refetchRawSettings:f}=he(),[o,E]=h.useState({}),[g,T]=h.useState(null),[pe,G]=h.useState(!1),z=o.enabled??s?.enabled??!1,B=o.autoStart??s?.auto_start??!1,U=o.port??s?.port??4141,V=o.accountType??s?.account_type??"individual",b=o.model??s?.model??"claude-opus-4-5-20250514",_=o.rateLimit??s?.rate_limit?.toString()??"",H=o.waitOnLimit??s?.wait_on_limit??!0,X=o.opusModel??s?.opus_model??"",Y=o.sonnetModel??s?.sonnet_model??"",W=o.haikuModel??s?.haiku_model??"",u=(t,S)=>{E(ve=>({...ve,[t]:S}))},Z=t=>{E(S=>({...S,model:t.default,opusModel:t.opus,sonnetModel:t.sonnet,haikuModel:t.haiku})),Q.success(`Applied "${t.name}" preset`)},k=h.useMemo(()=>g!==null?g:n?.settings?JSON.stringify(n.settings,null,2):`{
3
3
  "env": {}
4
4
  }`,[g,n]),fe=h.useCallback(t=>{T(t)},[]),I=h.useMemo(()=>{try{return JSON.parse(k),!0}catch{return!1}},[k]),ge=h.useMemo(()=>{const t=Object.keys(o).length>0,S=g!==null&&g!==JSON.stringify(n?.settings,null,2);return t||S},[o,g,n]),ee=async()=>{try{if(Object.keys(o).length>0&&await c({enabled:z,auto_start:B,port:U,account_type:V,model:b,rate_limit:_?parseInt(_,10):null,wait_on_limit:H,opus_model:X||void 0,sonnet_model:Y||void 0,haiku_model:W||void 0}),g!==null&&I){const t=JSON.parse(k);await x({settings:t,expectedMtime:n?.mtime})}E({}),T(null),Q.success("Copilot configuration saved")}catch(t){t.message==="CONFLICT"?G(!0):Q.error("Failed to save settings")}},se=async t=>{G(!1),t?(await f(),ee()):T(null)};if(a||d)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(j,{className:"h-10 w-full"}),e.jsx(j,{className:"h-10 w-full"}),e.jsx(j,{className:"h-10 w-full"}),e.jsx(j,{className:"h-10 w-full"})]});const je=()=>e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(ye,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(be,{className:"w-full",children:[e.jsx(R,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(R,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(R,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(O,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(A,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:es.map(t=>e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z(t),title:t.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),t.name]},t.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(t=>e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>Z(t),title:t.description,children:[e.jsx(ae,{className:"w-3 h-3"}),t.name]},t.name))})]})]}),e.jsx(q,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(F,{label:"Default Model",description:"Used when no specific tier is requested",value:b,onChange:t=>u("model",t),models:l,disabled:r}),e.jsx(F,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:X||b,onChange:t=>u("opusModel",t),models:l,disabled:r}),e.jsx(F,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:Y||b,onChange:t=>u("sonnetModel",t),models:l,disabled:r}),e.jsx(F,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:W||b,onChange:t=>u("haikuModel",t),models:l,disabled:r})]})]})]})})}),e.jsx(O,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(A,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(w,{htmlFor:"enabled",className:"text-sm font-medium",children:"Enable Copilot"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow using GitHub Copilot subscription"})]}),e.jsx(D,{id:"enabled",checked:z,onCheckedChange:t=>u("enabled",t)})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Basic Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:U,onChange:t=>u("port",parseInt(t.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:V,onValueChange:t=>u("accountType",t),children:[e.jsx(oe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(L,{value:"individual",children:"Individual"}),e.jsx(L,{value:"business",children:"Business"}),e.jsx(L,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(q,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Rate Limiting"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:_,onChange:t=>u("rateLimit",t.target.value),placeholder:"No limit",min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(w,{htmlFor:"wait-on-limit",className:"text-xs",children:"Wait on Rate Limit"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Wait instead of error when limit hit"})]}),e.jsx(D,{id:"wait-on-limit",checked:H,onCheckedChange:t=>u("waitOnLimit",t)})]})]}),e.jsx(q,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Daemon Settings"}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(w,{htmlFor:"auto-start",className:"text-xs",children:"Auto-start Daemon"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Start copilot-api when using profile"})]}),e.jsx(D,{id:"auto-start",checked:B,onCheckedChange:t=>u("autoStart",t)})]})]})]})})}),e.jsx(O,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(Ee,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(de,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),e.jsx(v,{variant:"outline",className:n.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:n.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(P,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(P,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(P,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(P,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})]})]})}),Ne=()=>e.jsx(h.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(J,{className:"w-6 h-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading editor..."})]}),children:e.jsxs("div",{className:"h-full flex flex-col",children:[!I&&g!==null&&e.jsxs("div",{className:"mb-2 px-3 py-2 bg-destructive/10 text-destructive text-sm rounded-md flex items-center gap-2 mx-6 mt-4 shrink-0",children:[e.jsx(Te,{className:"w-4 h-4"}),"Invalid JSON syntax"]}),e.jsx("div",{className:"flex-1 overflow-hidden px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full border rounded-md overflow-hidden bg-background",children:e.jsx(Ze,{value:k,onChange:fe,language:"json",minHeight:"100%"})})}),e.jsx("div",{className:"mx-6 mb-4",children:e.jsx("div",{className:"border rounded-md overflow-hidden",children:e.jsx(Se,{profileEnv:n?.settings?.env})})})]})});return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),n&&e.jsx(v,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",n.exists?new Date(n.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>f(),disabled:d,children:e.jsx(me,{className:`w-4 h-4 ${d?"animate-spin":""}`})}),e.jsx(p,{size:"sm",onClick:ee,disabled:i||N||!ge||!I,children:i||N?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:je()}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ae,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),Ne()]})]}),e.jsx(we,{open:pe,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>se(!0),onCancel:()=>se(!1)})]})}function P({label:s,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(de,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function $({title:s,children:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:s}),e.jsx("div",{className:"space-y-1",children:a})]})}function M({icon:s,label:a,status:l,statusText:r,variant:n="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(s,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:a})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:K("w-4 h-4",n==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:K("text-xs",n==="warning"?"text-yellow-500":"text-green-500"),children:r||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r||"No"})]})})]})}function ns(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(j,{className:"h-8 w-full"}),e.jsx(j,{className:"h-12 w-full"}),e.jsx(j,{className:"h-12 w-full"}),e.jsx(j,{className:"h-12 w-full"})]})}function ps(){const{status:s,statusLoading:a,refetchStatus:l,startAuth:r,isAuthenticating:n,startDaemon:d,isStartingDaemon:c,stopDaemon:i,isStoppingDaemon:x,install:N,isInstalling:f}=he();return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"Copilot"})]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(),disabled:a,children:e.jsx(me,{className:K("w-4 h-4",a&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GitHub Copilot proxy"})]}),e.jsx(A,{className:"flex-1",children:a?e.jsx(ns,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:"Unofficial API - Use at Your Own Risk"})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:"Reverse-engineered API - may break anytime"}),e.jsx("li",{children:"Excessive use may trigger account restrictions"}),e.jsx("li",{children:"No warranty, no responsibility from CCS"})]})]}),e.jsxs($,{title:"Setup",children:[e.jsx(M,{icon:Oe,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:"Installed":"Missing"}),!s?.installed&&e.jsx(p,{size:"sm",className:"w-full mt-2",onClick:()=>N(void 0),disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Installing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{className:"w-3.5 h-3.5 mr-1.5"}),"Install copilot-api"]})}),s?.installed&&e.jsx(M,{icon:ne,label:"Integration",status:s?.enabled??!1,statusText:s?.enabled?"Enabled":"Disabled"})]}),s?.installed&&e.jsxs($,{title:"Auth",children:[e.jsx(M,{icon:De,label:"GitHub",status:s?.authenticated??!1,statusText:s?.authenticated?"Connected":"Not Connected"}),!s?.authenticated&&e.jsx(p,{size:"sm",className:"w-full mt-2",onClick:()=>r(),disabled:n,children:n?"Authenticating...":"Authenticate"})]}),s?.authenticated&&e.jsxs($,{title:"Daemon",children:[e.jsx(M,{icon:Qe,label:"Status",status:s?.daemon_running??!1,statusText:s?.daemon_running?"Running":"Stopped"}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:["Port: ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(p,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:x,children:[e.jsx($e,{className:"w-3.5 h-3.5 mr-1.5"}),x?"Stopping...":"Stop"]}):e.jsxs(p,{size:"sm",variant:"outline",className:"w-full",onClick:()=>d(),disabled:c,children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),c?"Starting...":"Start"]})})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Proxy"}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3 text-green-500"}),"Active"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xe,{className:"w-3 h-3 text-muted-foreground"}),"Inactive"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(as,{})})]})}export{ps as CopilotPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-DFHQr9A5.js";import{c as l,B as p,a7 as w,a8 as y,a9 as k,e as z,S as h}from"./index-eojxvUPJ.js";import{a as M,u as R,b as W}from"./tanstack-C4gT2P7V.js";import{t as g}from"./notifications-B2Pz7lik.js";import{r as j}from"./react-vendor-FspHSO0w.js";import{aq as v,b as E,t as C,o as S,Z as P,f as O,U as $,S as H,ar as I,y as T,a8 as F,J as A}from"./icons-BOsxPbiD.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const B={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},q={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function D({passed:s,total:t,status:a,size:o="md"}){const n=B[o],d=q[a],i=t>0?Math.round(s/t*100):0,r=(n.dimension-n.strokeWidth)/2,c=2*Math.PI*r,f=c-i/100*c,x=n.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:n.dimension,height:n.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${d.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r,fill:"none",stroke:"currentColor",strokeWidth:n.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r,fill:"none",stroke:d.stroke,strokeWidth:n.strokeWidth,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),i>0&&e.jsx("circle",{cx:x+r*Math.cos(i/100*2*Math.PI-Math.PI/2),cy:x+r*Math.sin(i/100*2*Math.PI-Math.PI/2),r:n.strokeWidth/2,fill:d.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${d.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",n.fontSize),children:i}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",n.labelSize),children:"health"})]})]})}function b({label:s,value:t,color:a,bgColor:o}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",o)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:o,info:n}){const d=t/s*100,i=a/s*100,r=o/s*100,c=n/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[r>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${r}%`}}),i>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${i}%`}}),c>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${c}%`}}),d>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${d}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Checks"}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:o,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:n,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function G(){return M({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function K(){const s=R();return W({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),o=await a.json();if(!a.ok)throw new Error(o.message);return o},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function U({check:s}){const t=K(),a=Q[s.status],[o,n]=j.useState(!1),d=s.details||s.fix,i=r=>{navigator.clipboard.writeText(r),g.success("Copied to clipboard")};return d?e.jsx(w,{open:o,onOpenChange:n,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",o?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",a.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",a.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",a.labelColor),children:["[",a.label,"]"]}),e.jsx(E,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",o&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(C,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&i(s.fix),className:"h-5 w-5 p-0",children:e.jsx(S,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Apply Fix"]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",a.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",a.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",a.labelColor),children:["[",a.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Fix"]})]})}const Z={Monitor:I,Settings:H,Users:$,Shield:O,Zap:P};function J({group:s,defaultOpen:t=!0}){const[a,o]=j.useState(t),n=Z[s.icon]||I,d=s.checks.filter(m=>m.status==="ok").length,i=s.checks.length,r=s.checks.some(m=>m.status==="error"),c=s.checks.some(m=>m.status==="warning"),f=Math.round(d/i*100),x=r?"text-red-500":c?"text-yellow-500":"text-green-500",u=r?"bg-red-500":c?"bg-yellow-500":"bg-green-500";return e.jsx(w,{open:a,onOpenChange:o,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",r?"border-red-500/30":c?"border-yellow-500/30":"border-border"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",r?"bg-red-500/10 text-red-500":c?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(n,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",u),style:{width:`${f}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",x),children:[d,"/",i]}),e.jsx(T,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(k,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(U,{check:m},m.id))})})]})})}function V(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function X(s){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;const a=Math.floor(t/60);return a<60?`${a}m ago`:`${Math.floor(a/60)}h ago`}function Y(s){return[...s].sort((t,a)=>{const o=t.checks.filter(r=>r.status==="error").length,n=a.checks.filter(r=>r.status==="error").length,d=t.checks.filter(r=>r.status==="warning").length,i=a.checks.filter(r=>r.status==="warning").length;return o!==n?n-o:i-d})}function _(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function ee(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function ce(){const{data:s,isLoading:t,refetch:a,dataUpdatedAt:o}=G(),n=o,[d,i]=j.useState(0);j.useEffect(()=>{const u=setInterval(()=>i(m=>m+1),1e3);return()=>clearInterval(u)},[]);const r=()=>{navigator.clipboard.writeText("ccs doctor"),g.success("Copied to clipboard")},c=()=>{a(),g.info("Refreshing health checks...")};if(t&&!s)return e.jsx(ee,{});const f=s?V(s.summary):"ok",x=s?.groups?Y(s.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[s&&e.jsx("div",{className:"shrink-0",children:e.jsx(D,{passed:s.summary.passed,total:s.summary.total-s.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(_,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:"System Health"}),s?.version&&e.jsxs(z,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:["build ",s.version]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(F,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Last scan:"}),e.jsx("span",{className:"font-mono",children:n?X(n):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:"Auto-refresh:"}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:r,className:"gap-2 font-mono text-xs",children:[e.jsx(C,{className:"w-3 h-3"}),"ccs doctor",e.jsx(S,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:c,disabled:t,className:"gap-2",children:[e.jsx(A,{className:l("w-4 h-4",t&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),s&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:s.summary.total,passed:s.summary.passed,warnings:s.summary.warnings,errors:s.summary.errors,info:s.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((u,m)=>e.jsx(J,{group:u,defaultOpen:m<2||u.checks.some(N=>N.status==="error"||N.status==="warning")},u.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Version ",e.jsx("span",{className:"font-mono",children:s?.version??"--"})]}),e.jsxs("span",{children:["Platform"," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:"Live monitoring active"})]})]})]})}export{ce as HealthPage};
1
+ import{j as e}from"./radix-ui-DFHQr9A5.js";import{c as l,B as p,a7 as w,a8 as y,a9 as k,e as z,S as h}from"./index-DlEL4vYD.js";import{a as M,u as R,b as W}from"./tanstack-C4gT2P7V.js";import{t as g}from"./notifications-B2Pz7lik.js";import{r as j}from"./react-vendor-FspHSO0w.js";import{aq as v,b as E,t as C,o as S,Z as P,f as O,U as $,S as H,ar as I,y as T,a8 as F,J as A}from"./icons-BOsxPbiD.js";import"./utils-CzKF5WmX.js";import"./form-utils-BuXDJb0w.js";import"./code-highlight-BoHWVYut.js";const B={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},q={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function D({passed:s,total:t,status:a,size:o="md"}){const n=B[o],d=q[a],i=t>0?Math.round(s/t*100):0,r=(n.dimension-n.strokeWidth)/2,c=2*Math.PI*r,f=c-i/100*c,x=n.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:n.dimension,height:n.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${d.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r,fill:"none",stroke:"currentColor",strokeWidth:n.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r,fill:"none",stroke:d.stroke,strokeWidth:n.strokeWidth,strokeLinecap:"round",strokeDasharray:c,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),i>0&&e.jsx("circle",{cx:x+r*Math.cos(i/100*2*Math.PI-Math.PI/2),cy:x+r*Math.sin(i/100*2*Math.PI-Math.PI/2),r:n.strokeWidth/2,fill:d.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${d.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",n.fontSize),children:i}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",n.labelSize),children:"health"})]})]})}function b({label:s,value:t,color:a,bgColor:o}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",o)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:o,info:n}){const d=t/s*100,i=a/s*100,r=o/s*100,c=n/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[r>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${r}%`}}),i>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${i}%`}}),c>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${c}%`}}),d>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${d}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Checks"}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:o,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:n,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function G(){return M({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function K(){const s=R();return W({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),o=await a.json();if(!a.ok)throw new Error(o.message);return o},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Q={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function U({check:s}){const t=K(),a=Q[s.status],[o,n]=j.useState(!1),d=s.details||s.fix,i=r=>{navigator.clipboard.writeText(r),g.success("Copied to clipboard")};return d?e.jsx(w,{open:o,onOpenChange:n,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",o?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",a.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",a.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",a.labelColor),children:["[",a.label,"]"]}),e.jsx(E,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",o&&"rotate-90")})]})}),e.jsx(k,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(C,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&i(s.fix),className:"h-5 w-5 p-0",children:e.jsx(S,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Apply Fix"]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",a.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",a.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",a.labelColor),children:["[",a.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>t.mutate(s.id),disabled:t.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(v,{className:"w-3 h-3 mr-1"}),"Fix"]})]})}const Z={Monitor:I,Settings:H,Users:$,Shield:O,Zap:P};function J({group:s,defaultOpen:t=!0}){const[a,o]=j.useState(t),n=Z[s.icon]||I,d=s.checks.filter(m=>m.status==="ok").length,i=s.checks.length,r=s.checks.some(m=>m.status==="error"),c=s.checks.some(m=>m.status==="warning"),f=Math.round(d/i*100),x=r?"text-red-500":c?"text-yellow-500":"text-green-500",u=r?"bg-red-500":c?"bg-yellow-500":"bg-green-500";return e.jsx(w,{open:a,onOpenChange:o,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",r?"border-red-500/30":c?"border-yellow-500/30":"border-border"),children:[e.jsx(y,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",r?"bg-red-500/10 text-red-500":c?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(n,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",u),style:{width:`${f}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",x),children:[d,"/",i]}),e.jsx(T,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(k,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(U,{check:m},m.id))})})]})})}function V(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function X(s){const t=Math.floor((Date.now()-s)/1e3);if(t<5)return"just now";if(t<60)return`${t}s ago`;const a=Math.floor(t/60);return a<60?`${a}m ago`:`${Math.floor(a/60)}h ago`}function Y(s){return[...s].sort((t,a)=>{const o=t.checks.filter(r=>r.status==="error").length,n=a.checks.filter(r=>r.status==="error").length,d=t.checks.filter(r=>r.status==="warning").length,i=a.checks.filter(r=>r.status==="warning").length;return o!==n?n-o:i-d})}function _(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function ee(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function ce(){const{data:s,isLoading:t,refetch:a,dataUpdatedAt:o}=G(),n=o,[d,i]=j.useState(0);j.useEffect(()=>{const u=setInterval(()=>i(m=>m+1),1e3);return()=>clearInterval(u)},[]);const r=()=>{navigator.clipboard.writeText("ccs doctor"),g.success("Copied to clipboard")},c=()=>{a(),g.info("Refreshing health checks...")};if(t&&!s)return e.jsx(ee,{});const f=s?V(s.summary):"ok",x=s?.groups?Y(s.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[s&&e.jsx("div",{className:"shrink-0",children:e.jsx(D,{passed:s.summary.passed,total:s.summary.total-s.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(_,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:"System Health"}),s?.version&&e.jsxs(z,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:["build ",s.version]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(F,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Last scan:"}),e.jsx("span",{className:"font-mono",children:n?X(n):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:"Auto-refresh:"}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:r,className:"gap-2 font-mono text-xs",children:[e.jsx(C,{className:"w-3 h-3"}),"ccs doctor",e.jsx(S,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:c,disabled:t,className:"gap-2",children:[e.jsx(A,{className:l("w-4 h-4",t&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),s&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:s.summary.total,passed:s.summary.passed,warnings:s.summary.warnings,errors:s.summary.errors,info:s.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((u,m)=>e.jsx(J,{group:u,defaultOpen:m<2||u.checks.some(N=>N.status==="error"||N.status==="warning")},u.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Version ",e.jsx("span",{className:"font-mono",children:s?.version??"--"})]}),e.jsxs("span",{children:["Platform"," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:"Live monitoring active"})]})]})]})}export{ce as HealthPage};