@kaitranntt/ccs 6.7.1 → 6.7.2-dev.1

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,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-CDmNFLQ6.js","assets/radix-ui-CV3R9pD6.js","assets/react-vendor-FspHSO0w.js","assets/index-C6Dah-xh.js","assets/tanstack-Df9bCj5R.js","assets/notifications-B2Pz7lik.js","assets/utils-CzKF5WmX.js","assets/icons-ZmwVoUeR.js","assets/form-utils-DP6ILe7Z.js","assets/code-highlight-BoHWVYut.js","assets/index-It66SkKf.css"])))=>i.map(i=>d[i]);
2
- import{j as e}from"./radix-ui-CV3R9pD6.js";import{e as y,B as N,r as le,s as oe,t as re,v as ce,H as je,J as ve,w as Q,n as Y,i as $,L as b,I as te,k as de,a1 as Ne,a2 as we,S as w,T as ye,l as be,m as z,c as W}from"./index-C6Dah-xh.js";import{u as Ce,a as M,b as C}from"./tanstack-Df9bCj5R.js";import{S as X,C as Se}from"./confirm-dialog-CaiDQikc.js";import{a2 as me,L as Z,a6 as ke,j as Fe,_ as Pe,Z as ae,I as Me,X as Le,a7 as Te,a as Ae,u as Ee,$ as Re,ak as _e,ag as ne,K as Oe,a1 as Ie,al as qe,k as ue,l as xe}from"./icons-ZmwVoUeR.js";import{S as B}from"./switch-BQ6sBBUv.js";import{r as v}from"./react-vendor-FspHSO0w.js";import{t as H}from"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";const f="/api";async function De(){const s=await fetch(`${f}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Ue(){const s=await fetch(`${f}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Je(){const s=await fetch(`${f}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Qe(){const s=await fetch(`${f}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function $e(s){const t=await fetch(`${f}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function Ke(s){const t=await fetch(`${f}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Error("CONFLICT");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ge(){const s=await fetch(`${f}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function ze(){const s=await fetch(`${f}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function Be(){const s=await fetch(`${f}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function He(){const s=await fetch(`${f}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ve(s){const t=await fetch(`${f}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function he(){const s=Ce(),t=M({queryKey:["copilot-status"],queryFn:De,refetchInterval:5e3}),l=M({queryKey:["copilot-config"],queryFn:Ue}),o=M({queryKey:["copilot-models"],queryFn:Je}),a=M({queryKey:["copilot-raw-settings"],queryFn:Qe}),d=M({queryKey:["copilot-info"],queryFn:He}),r=C({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:Ke,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:Ge,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),p=C({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=C({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return{status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:o.data?.models??[],currentModel:o.data?.current,modelsLoading:o.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}}function We({rawSettings:s,rawSettingsLoading:t,isUpdating:l,isSavingRawSettings:o,hasChanges:a,isRawJsonValid:d,onRefresh:r,onSave:i}){return 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"}),s&&e.jsx(y,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:i,disabled:l||o||!a||!d,children:l||o?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const Xe=[{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"}],Ye=[{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 Ze(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:l,onChange:o,models:a,disabled:d}){const r=a.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}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(le,{value:l||"",onValueChange:o,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}),r?.minPlan&&e.jsx(y,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(r.minPlan)}`,children:r.minPlan})]})})}),e.jsx(ce,{className:"max-h-[300px]",children:e.jsxs(je,{children:[e.jsxs(ve,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{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(y,{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:Ze(i.multiplier)}),i.preview&&e.jsx(y,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),l===i.id&&e.jsx(Fe,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function es({currentModel:s,opusModel:t,sonnetModel:l,haikuModel:o,models:a,modelsLoading:d,onApplyPreset:r,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:p,onUpdateHaikuModel:x}){return e.jsx(Y,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{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(Pe,{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(y,{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:Xe.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{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:Ye.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(X,{}),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(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||s,onChange:p,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ss({enabled:s,autoStart:t,port:l,accountType:o,rateLimit:a,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:p,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(Y,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{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(b,{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(B,{id:"enabled",checked:s,onCheckedChange:r})]}),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(b,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:l,onChange:j=>u(parseInt(j.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:o,onValueChange:p,children:[e.jsx(oe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(X,{}),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(b,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:j=>x(j.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(b,{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(B,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(X,{}),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(b,{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(B,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({label:s,command:t}){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:t}),e.jsx(de,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function ts({rawSettings:s}){return e.jsx(Y,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($,{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(Me,{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"})]}),s&&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:s.path}),e.jsx(de,{value:s.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(y,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const as=v.lazy(()=>we(()=>import("./code-editor-CDmNFLQ6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.CodeEditor})));function ns({rawJsonContent:s,isRawJsonValid:t,rawJsonEdits:l,rawSettingsEnv:o,onChange:a}){return e.jsx(v.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(Z,{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:[!t&&l!==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(Le,{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(as,{value:s,onChange:a,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(Ne,{profileEnv:o})})})]})})}function is(){const{config:s,configLoading:t,models:l,modelsLoading:o,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:p,refetchRawSettings:x}=he(),[n,j]=v.useState({}),[g,S]=v.useState(null),[K,L]=v.useState(!1),T=n.enabled??s?.enabled??!1,A=n.autoStart??s?.auto_start??!1,k=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",R=n.model??s?.model??"claude-opus-4-5-20250514",h=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,O=n.opusModel??s?.opus_model??"",I=n.sonnetModel??s?.sonnet_model??"",F=n.haikuModel??s?.haiku_model??"",G=(m,P)=>{j(ge=>({...ge,[m]:P}))},c=m=>{j(P=>({...P,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),H.success(`Applied "${m.name}" preset`)},q=v.useMemo(()=>g!==null?g:a?.settings?JSON.stringify(a.settings,null,2):`{
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/code-editor-DHMiWzkZ.js","assets/radix-ui-CV3R9pD6.js","assets/react-vendor-FspHSO0w.js","assets/index-Z0MOeRTp.js","assets/tanstack-Df9bCj5R.js","assets/notifications-B2Pz7lik.js","assets/utils-CzKF5WmX.js","assets/icons-ZmwVoUeR.js","assets/form-utils-DP6ILe7Z.js","assets/code-highlight-BoHWVYut.js","assets/index-It66SkKf.css"])))=>i.map(i=>d[i]);
2
+ import{j as e}from"./radix-ui-CV3R9pD6.js";import{e as y,B as N,r as le,s as oe,t as re,v as ce,H as je,J as ve,w as Q,n as Y,i as $,L as b,I as te,k as de,a1 as Ne,a2 as we,S as w,T as ye,l as be,m as z,c as W}from"./index-Z0MOeRTp.js";import{u as Ce,a as M,b as C}from"./tanstack-Df9bCj5R.js";import{S as X,C as Se}from"./confirm-dialog-B6derovv.js";import{a2 as me,L as Z,a6 as ke,j as Fe,_ as Pe,Z as ae,I as Me,X as Le,a7 as Te,a as Ae,u as Ee,$ as Re,ak as _e,ag as ne,K as Oe,a1 as Ie,al as qe,k as ue,l as xe}from"./icons-ZmwVoUeR.js";import{S as B}from"./switch-BjiEIbUJ.js";import{r as v}from"./react-vendor-FspHSO0w.js";import{t as H}from"./notifications-B2Pz7lik.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";const f="/api";async function De(){const s=await fetch(`${f}/copilot/status`);if(!s.ok)throw new Error("Failed to fetch copilot status");return s.json()}async function Ue(){const s=await fetch(`${f}/copilot/config`);if(!s.ok)throw new Error("Failed to fetch copilot config");return s.json()}async function Je(){const s=await fetch(`${f}/copilot/models`);if(!s.ok)throw new Error("Failed to fetch copilot models");return s.json()}async function Qe(){const s=await fetch(`${f}/copilot/settings/raw`);if(!s.ok)throw new Error("Failed to fetch copilot raw settings");return s.json()}async function $e(s){const t=await fetch(`${f}/copilot/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update copilot config");return t.json()}async function Ke(s){const t=await fetch(`${f}/copilot/settings/raw`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Error("CONFLICT");if(!t.ok)throw new Error("Failed to save copilot raw settings");return t.json()}async function Ge(){const s=await fetch(`${f}/copilot/auth/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start auth");return s.json()}async function ze(){const s=await fetch(`${f}/copilot/daemon/start`,{method:"POST"});if(!s.ok)throw new Error("Failed to start daemon");return s.json()}async function Be(){const s=await fetch(`${f}/copilot/daemon/stop`,{method:"POST"});if(!s.ok)throw new Error("Failed to stop daemon");return s.json()}async function He(){const s=await fetch(`${f}/copilot/info`);if(!s.ok)throw new Error("Failed to fetch copilot info");return s.json()}async function Ve(s){const t=await fetch(`${f}/copilot/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{version:s}:{})});if(!t.ok)throw new Error("Failed to install copilot-api");return t.json()}function he(){const s=Ce(),t=M({queryKey:["copilot-status"],queryFn:De,refetchInterval:5e3}),l=M({queryKey:["copilot-config"],queryFn:Ue}),o=M({queryKey:["copilot-models"],queryFn:Je}),a=M({queryKey:["copilot-raw-settings"],queryFn:Qe}),d=M({queryKey:["copilot-info"],queryFn:He}),r=C({mutationFn:$e,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:Ke,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-config"]}),s.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:Ge,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),p=C({mutationFn:ze,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),x=C({mutationFn:Be,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:Ve,onSuccess:()=>{s.invalidateQueries({queryKey:["copilot-status"]}),s.invalidateQueries({queryKey:["copilot-info"]})}});return{status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:l.data,configLoading:l.isLoading,models:o.data?.models??[],currentModel:o.data?.current,modelsLoading:o.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:r.mutate,updateConfigAsync:r.mutateAsync,isUpdating:r.isPending,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending,startAuth:u.mutate,startAuthAsync:u.mutateAsync,isAuthenticating:u.isPending,authResult:u.data,startDaemon:p.mutate,isStartingDaemon:p.isPending,stopDaemon:x.mutate,isStoppingDaemon:x.isPending,info:d.data,infoLoading:d.isLoading,refetchInfo:d.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}}function We({rawSettings:s,rawSettingsLoading:t,isUpdating:l,isSavingRawSettings:o,hasChanges:a,isRawJsonValid:d,onRefresh:r,onSave:i}){return 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"}),s&&e.jsx(y,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",s.exists?new Date(s.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:r,disabled:t,children:e.jsx(me,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),e.jsx(N,{size:"sm",onClick:i,disabled:l||o||!a||!d,children:l||o?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const Xe=[{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"}],Ye=[{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 Ze(s){return s==null?null:s===0?"Free":s<1?`${s}x`:s===1?"1x":`${s}x`}function D({label:s,description:t,value:l,onChange:o,models:a,disabled:d}){const r=a.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}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsxs(le,{value:l||"",onValueChange:o,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}),r?.minPlan&&e.jsx(y,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${ie(r.minPlan)}`,children:r.minPlan})]})})}),e.jsx(ce,{className:"max-h-[300px]",children:e.jsxs(je,{children:[e.jsxs(ve,{className:"text-xs text-muted-foreground",children:["Available Models (",a.length,")"]}),a.map(i=>e.jsx(Q,{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(y,{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:Ze(i.multiplier)}),i.preview&&e.jsx(y,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:"Preview"}),l===i.id&&e.jsx(Fe,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function es({currentModel:s,opusModel:t,sonnetModel:l,haikuModel:o,models:a,modelsLoading:d,onApplyPreset:r,onUpdateModel:i,onUpdateOpusModel:u,onUpdateSonnetModel:p,onUpdateHaikuModel:x}){return e.jsx(Y,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{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(Pe,{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(y,{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:Xe.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{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:Ye.map(n=>e.jsxs(N,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>r(n),title:n.description,children:[e.jsx(ae,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(X,{}),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(D,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:i,models:a,disabled:d}),e.jsx(D,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:t||s,onChange:u,models:a,disabled:d}),e.jsx(D,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:l||s,onChange:p,models:a,disabled:d}),e.jsx(D,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o||s,onChange:x,models:a,disabled:d})]})]})]})})})}function ss({enabled:s,autoStart:t,port:l,accountType:o,rateLimit:a,waitOnLimit:d,onUpdateEnabled:r,onUpdateAutoStart:i,onUpdatePort:u,onUpdateAccountType:p,onUpdateRateLimit:x,onUpdateWaitOnLimit:n}){return e.jsx(Y,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx($,{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(b,{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(B,{id:"enabled",checked:s,onCheckedChange:r})]}),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(b,{htmlFor:"port",className:"text-xs",children:"Port"}),e.jsx(te,{id:"port",type:"number",value:l,onChange:j=>u(parseInt(j.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"account-type",className:"text-xs",children:"Account Type"}),e.jsxs(le,{value:o,onValueChange:p,children:[e.jsx(oe,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(Q,{value:"individual",children:"Individual"}),e.jsx(Q,{value:"business",children:"Business"}),e.jsx(Q,{value:"enterprise",children:"Enterprise"})]})]})]})]}),e.jsx(X,{}),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(b,{htmlFor:"rate-limit",className:"text-xs",children:"Rate Limit (seconds)"}),e.jsx(te,{id:"rate-limit",type:"number",value:a,onChange:j=>x(j.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(b,{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(B,{id:"wait-on-limit",checked:d,onCheckedChange:n})]})]}),e.jsx(X,{}),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(b,{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(B,{id:"auto-start",checked:t,onCheckedChange:i})]})]})]})})})}function U({label:s,command:t}){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:t}),e.jsx(de,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function ts({rawSettings:s}){return e.jsx(Y,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($,{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(Me,{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"})]}),s&&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:s.path}),e.jsx(de,{value:s.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(y,{variant:"outline",className:s.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:s.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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const as=v.lazy(()=>we(()=>import("./code-editor-DHMiWzkZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(s=>({default:s.CodeEditor})));function ns({rawJsonContent:s,isRawJsonValid:t,rawJsonEdits:l,rawSettingsEnv:o,onChange:a}){return e.jsx(v.Suspense,{fallback:e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(Z,{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:[!t&&l!==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(Le,{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(as,{value:s,onChange:a,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(Ne,{profileEnv:o})})})]})})}function is(){const{config:s,configLoading:t,models:l,modelsLoading:o,rawSettings:a,rawSettingsLoading:d,updateConfigAsync:r,isUpdating:i,saveRawSettingsAsync:u,isSavingRawSettings:p,refetchRawSettings:x}=he(),[n,j]=v.useState({}),[g,S]=v.useState(null),[K,L]=v.useState(!1),T=n.enabled??s?.enabled??!1,A=n.autoStart??s?.auto_start??!1,k=n.port??s?.port??4141,E=n.accountType??s?.account_type??"individual",R=n.model??s?.model??"claude-opus-4-5-20250514",h=n.rateLimit??s?.rate_limit?.toString()??"",_=n.waitOnLimit??s?.wait_on_limit??!0,O=n.opusModel??s?.opus_model??"",I=n.sonnetModel??s?.sonnet_model??"",F=n.haikuModel??s?.haiku_model??"",G=(m,P)=>{j(ge=>({...ge,[m]:P}))},c=m=>{j(P=>({...P,model:m.default,opusModel:m.opus,sonnetModel:m.sonnet,haikuModel:m.haiku})),H.success(`Applied "${m.name}" preset`)},q=v.useMemo(()=>g!==null?g:a?.settings?JSON.stringify(a.settings,null,2):`{
3
3
  "env": {}
4
4
  }`,[g,a]),pe=v.useCallback(m=>{S(m)},[]),ee=v.useMemo(()=>{try{return JSON.parse(q),!0}catch{return!1}},[q]),fe=v.useMemo(()=>{const m=Object.keys(n).length>0,P=g!==null&&g!==JSON.stringify(a?.settings,null,2);return m||P},[n,g,a]),se=async()=>{try{if(Object.keys(n).length>0&&await r({enabled:T,auto_start:A,port:k,account_type:E,model:R,rate_limit:h?parseInt(h,10):null,wait_on_limit:_,opus_model:O||void 0,sonnet_model:I||void 0,haiku_model:F||void 0}),g!==null&&ee){const m=JSON.parse(q);await u({settings:m,expectedMtime:a?.mtime})}j({}),S(null),H.success("Copilot configuration saved")}catch(m){m.message==="CONFLICT"?L(!0):H.error("Failed to save settings")}};return{configLoading:t,rawSettingsLoading:d,modelsLoading:o,isUpdating:i,isSavingRawSettings:p,models:l,rawSettings:a,rawJsonContent:q,rawJsonEdits:g,enabled:T,autoStart:A,port:k,accountType:E,currentModel:R,rateLimit:h,waitOnLimit:_,opusModel:O,sonnetModel:I,haikuModel:F,isRawJsonValid:ee,hasChanges:fe,conflictDialog:K,updateField:G,applyPreset:c,handleRawJsonChange:pe,handleSave:se,handleConflictResolve:async m=>{L(!1),m?(await x(),se()):S(null)},refetchRawSettings:x}}function ls(){const{configLoading:s,rawSettingsLoading:t,modelsLoading:l,isUpdating:o,isSavingRawSettings:a,models:d,rawSettings:r,rawJsonContent:i,rawJsonEdits:u,enabled:p,autoStart:x,port:n,accountType:j,currentModel:g,rateLimit:S,waitOnLimit:K,opusModel:L,sonnetModel:T,haikuModel:A,isRawJsonValid:k,hasChanges:E,conflictDialog:R,updateField:h,applyPreset:_,handleRawJsonChange:O,handleSave:I,handleConflictResolve:F,refetchRawSettings:G}=is();return s||t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"}),e.jsx(w,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(We,{rawSettings:r,rawSettingsLoading:t,isUpdating:o,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:k,onRefresh:()=>G(),onSave:I}),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: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(z,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(z,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(z,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(es,{currentModel:g,opusModel:L,sonnetModel:T,haikuModel:A,models:d,modelsLoading:l,onApplyPreset:_,onUpdateModel:c=>h("model",c),onUpdateOpusModel:c=>h("opusModel",c),onUpdateSonnetModel:c=>h("sonnetModel",c),onUpdateHaikuModel:c=>h("haikuModel",c)}),e.jsx(ss,{enabled:p,autoStart:x,port:n,accountType:j,rateLimit:S,waitOnLimit:K,onUpdateEnabled:c=>h("enabled",c),onUpdateAutoStart:c=>h("autoStart",c),onUpdatePort:c=>h("port",c),onUpdateAccountType:c=>h("accountType",c),onUpdateRateLimit:c=>h("rateLimit",c),onUpdateWaitOnLimit:c=>h("waitOnLimit",c)}),e.jsx(ts,{rawSettings:r})]})]})})}),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(Te,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(ns,{rawJsonContent:i,isRawJsonValid:k,rawJsonEdits:u,rawSettingsEnv:r?.settings?.env,onChange:O})]})]}),e.jsx(Se,{open:R,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>F(!0),onCancel:()=>F(!1)})]})}function V({title:s,children:t}){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:t})]})}function J({icon:s,label:t,status:l,statusText:o,variant:a="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:t})}),e.jsx("div",{className:"flex items-center gap-1.5",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:W("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:W("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:o||"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:o||"No"})]})})]})}function os(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(w,{className:"h-8 w-full"}),e.jsx(w,{className:"h-12 w-full"}),e.jsx(w,{className:"h-12 w-full"}),e.jsx(w,{className:"h-12 w-full"})]})}function Ns(){const{status:s,statusLoading:t,refetchStatus:l,startAuth:o,isAuthenticating:a,startDaemon:d,isStartingDaemon:r,stopDaemon:i,isStoppingDaemon:u,install:p,isInstalling:x}=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(Ae,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"Copilot"})]}),e.jsx(N,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(),disabled:t,children:e.jsx(me,{className:W("w-4 h-4",t&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"GitHub Copilot proxy"})]}),e.jsx($,{className:"flex-1",children:t?e.jsx(os,{}):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(Ee,{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(V,{title:"Setup",children:[e.jsx(J,{icon:Re,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:"Installed":"Missing"}),!s?.installed&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>p(void 0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Installing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"w-3.5 h-3.5 mr-1.5"}),"Install copilot-api"]})}),s?.installed&&e.jsx(J,{icon:ne,label:"Integration",status:s?.enabled??!1,statusText:s?.enabled?"Enabled":"Disabled"})]}),s?.installed&&e.jsxs(V,{title:"Auth",children:[e.jsx(J,{icon:Oe,label:"GitHub",status:s?.authenticated??!1,statusText:s?.authenticated?"Connected":"Not Connected"}),!s?.authenticated&&e.jsx(N,{size:"sm",className:"w-full mt-2",onClick:()=>o(),disabled:a,children:a?"Authenticating...":"Authenticate"})]}),s?.authenticated&&e.jsxs(V,{title:"Daemon",children:[e.jsx(J,{icon:Ie,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(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:u,children:[e.jsx(qe,{className:"w-3.5 h-3.5 mr-1.5"}),u?"Stopping...":"Stop"]}):e.jsxs(N,{size:"sm",variant:"outline",className:"w-full",onClick:()=>d(),disabled:r,children:[e.jsx(ne,{className:"w-3.5 h-3.5 mr-1.5"}),r?"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(ls,{})})]})}export{Ns as CopilotPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-CV3R9pD6.js";import{c as l,B as p,aa as w,ab as y,ac as k,e as z,S as h}from"./index-C6Dah-xh.js";import{a as M,u as R,b as W}from"./tanstack-Df9bCj5R.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,q as S,Z as P,f as O,U as $,S as T,ar as I,y as H,a1 as F,a2 as q}from"./icons-ZmwVoUeR.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";const A={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"}},B={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=A[o],d=B[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:T,Users:$,Shield:O,Zap:P};function V({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(H,{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 J(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?J(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(q,{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(V,{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-CV3R9pD6.js";import{c as l,B as p,aa as w,ab as y,ac as k,e as z,S as h}from"./index-Z0MOeRTp.js";import{a as M,u as R,b as W}from"./tanstack-Df9bCj5R.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,q as S,Z as P,f as O,U as $,S as T,ar as I,y as H,a1 as F,a2 as q}from"./icons-ZmwVoUeR.js";import"./utils-CzKF5WmX.js";import"./form-utils-DP6ILe7Z.js";import"./code-highlight-BoHWVYut.js";const A={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"}},B={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=A[o],d=B[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:T,Users:$,Shield:O,Zap:P};function V({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(H,{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 J(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?J(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(q,{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(V,{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};