@kaitranntt/ccs 7.77.1-dev.8 → 7.77.1-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.js +2 -2
- package/dist/cliproxy/ai-providers/codex-plan-compatibility.js.map +1 -1
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts +8 -2
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js +82 -33
- package/dist/cliproxy/ai-providers/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/model-id-normalizer.js +28 -11
- package/dist/cliproxy/ai-providers/model-id-normalizer.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +9 -8
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts +2 -0
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +2 -0
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +44 -12
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/ui/assets/{accounts-lNkLHFUi.js → accounts-DkID6f81.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BOlM9Aos.js → alert-dialog-BM9gIsRp.js} +1 -1
- package/dist/ui/assets/{api-BWy6e4S8.js → api-0YJdilQb.js} +1 -1
- package/dist/ui/assets/{auth-section-DAnXkqYR.js → auth-section-C1ljCo7W.js} +1 -1
- package/dist/ui/assets/{backups-section-D7XUs1JS.js → backups-section-C-iLf1kg.js} +1 -1
- package/dist/ui/assets/{channels-BKV3tSfv.js → channels-DDSqllsQ.js} +1 -1
- package/dist/ui/assets/{checkbox-D1-_INjR.js → checkbox-5R1YTubE.js} +1 -1
- package/dist/ui/assets/{claude-extension-BwjQl7ol.js → claude-extension-CEGefl3-.js} +1 -1
- package/dist/ui/assets/cliproxy-R4kPUeL-.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-DQMqXzRz.js → cliproxy-ai-providers-DVF3FnXM.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-CH75qKU4.js → cliproxy-control-panel-CIsKyGK6.js} +1 -1
- package/dist/ui/assets/{codex-ClRFRCla.js → codex-BiEEUC4Y.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DXJ0kUrp.js → confirm-dialog-BhJV4F_d.js} +1 -1
- package/dist/ui/assets/{copilot-CMc1hybe.js → copilot-DgRLuQfV.js} +1 -1
- package/dist/ui/assets/{cursor-CXlPaY62.js → cursor-BuOjfajj.js} +1 -1
- package/dist/ui/assets/{droid-D0o0ta28.js → droid-BPiviAW2.js} +1 -1
- package/dist/ui/assets/{globalenv-section-Crb3uFp7.js → globalenv-section-DAqbiNI1.js} +1 -1
- package/dist/ui/assets/{health-CD_qC6wG.js → health-B_CfF7J0.js} +1 -1
- package/dist/ui/assets/{index-CL6vCSY9.js → index-BEGD-4HR.js} +1 -1
- package/dist/ui/assets/{index-HwlgKSWH.js → index-BJl0cazY.js} +2 -2
- package/dist/ui/assets/{index-Dhaeoa8x.js → index-Bc-AbZRU.js} +1 -1
- package/dist/ui/assets/{index-Co9qZEzY.js → index-BqR6NZDE.js} +1 -1
- package/dist/ui/assets/{index-CvFZqcdh.js → index-Cj4mWFVK.js} +1 -1
- package/dist/ui/assets/{index-4oChbCyf.js → index-CzKdWNe5.js} +1 -1
- package/dist/ui/assets/{index-Dk0xIiPX.js → index-LJitUhfE.js} +1 -1
- package/dist/ui/assets/{logs-BnlWbg68.js → logs-Lqv-I3_T.js} +1 -1
- package/dist/ui/assets/{masked-input-CslqD0_2.js → masked-input-CgCDYXYf.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-YonTNEFL.js → proxy-status-widget-Df-4cfdm.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-5LcbOkxh.js → raw-json-settings-editor-panel-BpXdUisD.js} +1 -1
- package/dist/ui/assets/{searchable-select-DgyFlHas.js → searchable-select-DCOfw3f0.js} +1 -1
- package/dist/ui/assets/{separator-cIuCN-Pq.js → separator-Ct6a34bG.js} +1 -1
- package/dist/ui/assets/{shared-CbYgYS7o.js → shared-D-JFc_Cw.js} +1 -1
- package/dist/ui/assets/{table-CtOCg1DT.js → table-DsU2UX-e.js} +1 -1
- package/dist/ui/assets/{updates-K_8t_A_F.js → updates-D-0gOqSU.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-Dq9zVZRT.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r}from"./react-vendor-Bjx91N7w.js";import{a as S,bA as E,n as b,S as n,C as g,bi as R,bk as D,B as T,d as C}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r}from"./react-vendor-Bjx91N7w.js";import{a as S,bA as E,n as b,S as n,C as g,bi as R,bk as D,B as T,d as C}from"./index-BJl0cazY.js";import{A as O,a as _,b as F,c as I,d as P,e as z,f as L,g as U}from"./alert-dialog-BM9gIsRp.js";import{w as $,x as H,af as v,v as M,Q as Y,R as J}from"./icons-DIVjDO-z.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const Q=3e3,q=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,y]=r.useState([]),[f,N]=r.useState(!0),[u,w]=r.useState(null),[i,l]=r.useState(null),[c,k]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();y(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{w(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}k(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{w(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>k(null),Q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),q);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(b,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(I,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(P,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(z,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as d}from"./react-vendor-Bjx91N7w.js";import{a as R,bA as F,bi as b,bk as k,n as L,B as E,L as A,aI as D,I as B,d as K}from"./index-HwlgKSWH.js";import{R as M,w as N,x as O,ac as _,au as q,at as Y,aH as H}from"./icons-DIVjDO-z.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const U={selected:[],unattended:!1};async function S(t,l){try{const a=await t.json();return typeof a.error=="string"&&a.error.trim().length>0?a.error:l}catch{return l}}function J(){const[t,l]=d.useState(U),[a,j]=d.useState(null),[h,v]=d.useState(!0),[y,c]=d.useState(!1),[w,u]=d.useState(null),[C,m]=d.useState(null),f=d.useCallback(n=>{m(n),window.setTimeout(()=>m(null),1500)},[]),x=d.useCallback(async()=>{try{v(!0),u(null);const n=await fetch("/api/channels");if(!n.ok)throw new Error(await S(n,"Failed to load Official Channels settings"));const i=await n.json();return l(i.config??U),j(i.status??null),!0}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{v(!1)}},[]),P=d.useCallback(async(n,i="Settings saved")=>{try{c(!0),u(null);const r=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(await S(r,"Failed to save Official Channels settings"));const s=await r.json();return l(o=>s.config??{...o,...n}),f(i),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{c(!1)}},[f]),V=d.useCallback(async(n,i)=>{try{c(!0),u(null);const r=await fetch(`/api/channels/${n}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})});if(!r.ok)throw new Error(await S(r,`Failed to save ${n} token`));return await x()?(f(`${n} token saved`),!0):!1}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{c(!1)}},[x,f]),T=d.useCallback(async n=>{try{c(!0),u(null);const i=await fetch(`/api/channels/${n}/token`,{method:"DELETE"});if(!i.ok)throw new Error(await S(i,`Failed to clear ${n} token`));return await x()?(f(`${n} token cleared`),!0):!1}catch(i){return u(i instanceof Error?i.message:"Unknown error"),!1}finally{c(!1)}},[x,f]);return{config:t,status:a,loading:h,saving:y,error:w,success:C,fetchConfig:x,updateConfig:P,saveToken:V,clearToken:T}}const z={telegram:"",discord:"",imessage:""};function G(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function Q(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function W(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function X(t,l){return t.length===0?"None selected":t.map(a=>l?.find(j=>j.id===a)?.displayName??a).join(", ")}function le(){const{t}=R(),{config:l,status:a,loading:j,saving:h,error:v,success:y,fetchConfig:c,updateConfig:w,saveToken:u,clearToken:C}=J(),{fetchRawConfig:m}=F(),[f,x]=d.useState(z),P=X(l.selected,a?.channels);d.useEffect(()=>{c(),m()},[c,m]);const V=async()=>{await Promise.all([c(),m()])},T=async(s,o)=>{const g=o?[...new Set([...l.selected,s])]:l.selected.filter($=>$!==s);await w({selected:g},o?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([c(),m()])},n=(s,o)=>{x(g=>({...g,[s]:o}))},i=async s=>{await u(s,f[s])&&(x(g=>({...g,[s]:""})),await m())},r=async s=>{await C(s)&&(x(g=>({...g,[s]:""})),await m())};return j?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||y?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(b,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:v})]}),y&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(O,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:y})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsPage.channelsSection.configureDescription",{defaultValue:"Configure official Claude channels here, then run `ccs` normally on a supported native Claude session."})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsPage.channelsSection.storageDescription",{defaultValue:"CCS stores only channel selection in `config.yaml`. Claude keeps the machine-level channel state under `~/.claude/channels/`."})})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${G(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:P})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.machineChecks",{defaultValue:"Machine checks"})}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?t("settingsPage.channelsSection.installed",{defaultValue:"Installed"}):t("settingsPage.channelsSection.missing",{defaultValue:"Missing"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod||t("settingsPage.channelsSection.unknown",{defaultValue:"Unknown"})})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.fastestPath",{defaultValue:"Fastest path"})}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep1",{defaultValue:"1. Turn on the channels you want below."})}),e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep2",{defaultValue:"2. Save Telegram or Discord bot tokens here if that channel needs one."})}),e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep3",{defaultValue:"3. Run `ccs` or a native Claude account profile. CCS adds `--channels` for you on supported runs."})}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:t("settingsPage.channelsSection.advancedNotes",{defaultValue:"Advanced notes and scope"})}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.ifYouRunNow",{defaultValue:"If you run `ccs` now"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx(E,{variant:W(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t("settingsPage.thinkingSection.youType")})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:t("settingsPage.thinkingSection.ccsAdds")})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):t("settingsPage.channelsSection.nothingYet",{defaultValue:"(nothing yet)"})]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const o=l.selected.includes(s.id),g=f[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E,{variant:Q(s.setup.state),children:s.setup.label}),e.jsx(D,{checked:o,disabled:h||!!s.unavailableReason&&!o,onCheckedChange:p=>void T(s.id,p)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?t("settingsPage.channelsSection.tokenFromProcessEnv",{envKey:s.envKey,defaultValue:"The current CCS process already has {{envKey}}. Save it here only if you want persistent Claude channel state."}):s.tokenConfigured&&s.processEnvAvailable?t("settingsPage.channelsSection.tokenSavedAndProcessEnv",{envKey:s.envKey,defaultValue:"{{envKey}} is saved in Claude channel state, and the current CCS process env also provides it."}):t("settingsPage.channelsSection.tokenSaveHint",{envKey:s.envKey,defaultValue:"Save {{envKey}} in Claude's official channel env file. The dashboard never reads the token value back after save."})}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(B,{type:"password",value:g,onChange:p=>n(s.id,p.target.value),placeholder:s.tokenConfigured?t("settingsPage.channelsSection.tokenConfiguredPlaceholder",{envKey:s.envKey,defaultValue:"Configured. Enter a new {{envKey}} to replace it."}):!s.tokenConfigured&&s.tokenSource==="process_env"?t("settingsPage.channelsSection.tokenProcessEnvPlaceholder",{envKey:s.envKey,defaultValue:"Using current CCS process env. Enter a new {{envKey}} to save it for Claude."}):t("settingsPage.channelsSection.tokenPastePlaceholder",{envKey:s.envKey,defaultValue:"Paste {{envKey}}"}),disabled:h}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>void i(s.id),disabled:h||!g.trim(),children:[e.jsx(q,{className:"mr-2 h-4 w-4"}),t("settingsPage.channelsSection.saveToken",{defaultValue:"Save Token"})]}),e.jsxs(K,{variant:"outline",onClick:()=>void r(s.id),disabled:h||!s.tokenConfigured,children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),t("settingsPage.channelsSection.clearSavedToken",{defaultValue:"Clear Saved Token"})]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:t("settingsPage.channelsSection.claudeSideSetupCommands",{defaultValue:"Claude-side setup commands"})}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(p=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:p},p))})]})]},s.id)})}),e.jsx(b,{children:e.jsx(k,{children:t("settingsPage.channelsSection.injectionDisclaimer",{defaultValue:"CCS injects `--channels` only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."})})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(H,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(A,{className:"text-sm font-medium",children:t("profileEditorSections.skipPermissionPrompts")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("settingsPage.channelsSection.skipPermissionDescription",{defaultValue:"Optional advanced behavior. CCS adds `--dangerously-skip-permissions` only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."})})]})]}),e.jsx(D,{checked:l.unattended,disabled:h,onCheckedChange:s=>void(async()=>{await w({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await m()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{variant:"outline",onClick:()=>void V(),disabled:h,children:[e.jsx(M,{className:`mr-2 h-4 w-4 ${h?"animate-spin":""}`}),t("settings.refresh")]})})]})})]})}export{le as default};
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as d}from"./react-vendor-Bjx91N7w.js";import{a as R,bA as F,bi as b,bk as k,n as L,B as E,L as A,aI as D,I as B,d as K}from"./index-BJl0cazY.js";import{R as M,w as N,x as O,ac as _,au as q,at as Y,aH as H}from"./icons-DIVjDO-z.js";import"./tanstack-bhJxV1h8.js";import"./notifications-B4_o8bcr.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const U={selected:[],unattended:!1};async function S(t,l){try{const a=await t.json();return typeof a.error=="string"&&a.error.trim().length>0?a.error:l}catch{return l}}function J(){const[t,l]=d.useState(U),[a,j]=d.useState(null),[h,v]=d.useState(!0),[y,c]=d.useState(!1),[w,u]=d.useState(null),[C,m]=d.useState(null),f=d.useCallback(n=>{m(n),window.setTimeout(()=>m(null),1500)},[]),x=d.useCallback(async()=>{try{v(!0),u(null);const n=await fetch("/api/channels");if(!n.ok)throw new Error(await S(n,"Failed to load Official Channels settings"));const i=await n.json();return l(i.config??U),j(i.status??null),!0}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{v(!1)}},[]),P=d.useCallback(async(n,i="Settings saved")=>{try{c(!0),u(null);const r=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(await S(r,"Failed to save Official Channels settings"));const s=await r.json();return l(o=>s.config??{...o,...n}),f(i),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{c(!1)}},[f]),V=d.useCallback(async(n,i)=>{try{c(!0),u(null);const r=await fetch(`/api/channels/${n}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})});if(!r.ok)throw new Error(await S(r,`Failed to save ${n} token`));return await x()?(f(`${n} token saved`),!0):!1}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{c(!1)}},[x,f]),T=d.useCallback(async n=>{try{c(!0),u(null);const i=await fetch(`/api/channels/${n}/token`,{method:"DELETE"});if(!i.ok)throw new Error(await S(i,`Failed to clear ${n} token`));return await x()?(f(`${n} token cleared`),!0):!1}catch(i){return u(i instanceof Error?i.message:"Unknown error"),!1}finally{c(!1)}},[x,f]);return{config:t,status:a,loading:h,saving:y,error:w,success:C,fetchConfig:x,updateConfig:P,saveToken:V,clearToken:T}}const z={telegram:"",discord:"",imessage:""};function G(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function Q(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function W(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function X(t,l){return t.length===0?"None selected":t.map(a=>l?.find(j=>j.id===a)?.displayName??a).join(", ")}function le(){const{t}=R(),{config:l,status:a,loading:j,saving:h,error:v,success:y,fetchConfig:c,updateConfig:w,saveToken:u,clearToken:C}=J(),{fetchRawConfig:m}=F(),[f,x]=d.useState(z),P=X(l.selected,a?.channels);d.useEffect(()=>{c(),m()},[c,m]);const V=async()=>{await Promise.all([c(),m()])},T=async(s,o)=>{const g=o?[...new Set([...l.selected,s])]:l.selected.filter($=>$!==s);await w({selected:g},o?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([c(),m()])},n=(s,o)=>{x(g=>({...g,[s]:o}))},i=async s=>{await u(s,f[s])&&(x(g=>({...g,[s]:""})),await m())},r=async s=>{await C(s)&&(x(g=>({...g,[s]:""})),await m())};return j?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||y?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(b,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:v})]}),y&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(O,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:y})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsPage.channelsSection.configureDescription",{defaultValue:"Configure official Claude channels here, then run `ccs` normally on a supported native Claude session."})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsPage.channelsSection.storageDescription",{defaultValue:"CCS stores only channel selection in `config.yaml`. Claude keeps the machine-level channel state under `~/.claude/channels/`."})})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${G(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:P})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.machineChecks",{defaultValue:"Machine checks"})}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?t("settingsPage.channelsSection.installed",{defaultValue:"Installed"}):t("settingsPage.channelsSection.missing",{defaultValue:"Missing"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod||t("settingsPage.channelsSection.unknown",{defaultValue:"Unknown"})})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.fastestPath",{defaultValue:"Fastest path"})}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep1",{defaultValue:"1. Turn on the channels you want below."})}),e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep2",{defaultValue:"2. Save Telegram or Discord bot tokens here if that channel needs one."})}),e.jsx("p",{children:t("settingsPage.channelsSection.fastestStep3",{defaultValue:"3. Run `ccs` or a native Claude account profile. CCS adds `--channels` for you on supported runs."})}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:t("settingsPage.channelsSection.advancedNotes",{defaultValue:"Advanced notes and scope"})}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:t("settingsPage.channelsSection.ifYouRunNow",{defaultValue:"If you run `ccs` now"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx(E,{variant:W(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t("settingsPage.thinkingSection.youType")})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:t("settingsPage.thinkingSection.ccsAdds")})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):t("settingsPage.channelsSection.nothingYet",{defaultValue:"(nothing yet)"})]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(b,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(k,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const o=l.selected.includes(s.id),g=f[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E,{variant:Q(s.setup.state),children:s.setup.label}),e.jsx(D,{checked:o,disabled:h||!!s.unavailableReason&&!o,onCheckedChange:p=>void T(s.id,p)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?t("settingsPage.channelsSection.tokenFromProcessEnv",{envKey:s.envKey,defaultValue:"The current CCS process already has {{envKey}}. Save it here only if you want persistent Claude channel state."}):s.tokenConfigured&&s.processEnvAvailable?t("settingsPage.channelsSection.tokenSavedAndProcessEnv",{envKey:s.envKey,defaultValue:"{{envKey}} is saved in Claude channel state, and the current CCS process env also provides it."}):t("settingsPage.channelsSection.tokenSaveHint",{envKey:s.envKey,defaultValue:"Save {{envKey}} in Claude's official channel env file. The dashboard never reads the token value back after save."})}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(B,{type:"password",value:g,onChange:p=>n(s.id,p.target.value),placeholder:s.tokenConfigured?t("settingsPage.channelsSection.tokenConfiguredPlaceholder",{envKey:s.envKey,defaultValue:"Configured. Enter a new {{envKey}} to replace it."}):!s.tokenConfigured&&s.tokenSource==="process_env"?t("settingsPage.channelsSection.tokenProcessEnvPlaceholder",{envKey:s.envKey,defaultValue:"Using current CCS process env. Enter a new {{envKey}} to save it for Claude."}):t("settingsPage.channelsSection.tokenPastePlaceholder",{envKey:s.envKey,defaultValue:"Paste {{envKey}}"}),disabled:h}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>void i(s.id),disabled:h||!g.trim(),children:[e.jsx(q,{className:"mr-2 h-4 w-4"}),t("settingsPage.channelsSection.saveToken",{defaultValue:"Save Token"})]}),e.jsxs(K,{variant:"outline",onClick:()=>void r(s.id),disabled:h||!s.tokenConfigured,children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),t("settingsPage.channelsSection.clearSavedToken",{defaultValue:"Clear Saved Token"})]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:t("settingsPage.channelsSection.claudeSideSetupCommands",{defaultValue:"Claude-side setup commands"})}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(p=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:p},p))})]})]},s.id)})}),e.jsx(b,{children:e.jsx(k,{children:t("settingsPage.channelsSection.injectionDisclaimer",{defaultValue:"CCS injects `--channels` only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."})})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(H,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(A,{className:"text-sm font-medium",children:t("profileEditorSections.skipPermissionPrompts")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t("settingsPage.channelsSection.skipPermissionDescription",{defaultValue:"Optional advanced behavior. CCS adds `--dangerously-skip-permissions` only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."})})]})]}),e.jsx(D,{checked:l.unattended,disabled:h,onCheckedChange:s=>void(async()=>{await w({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await m()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{variant:"outline",onClick:()=>void V(),disabled:h,children:[e.jsx(M,{className:`mr-2 h-4 w-4 ${h?"animate-spin":""}`}),t("settings.refresh")]})})]})})]})}export{le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,a1 as i,a2 as t}from"./radix-ui-nu4wz29m.js";import"./react-vendor-Bjx91N7w.js";import{c as s}from"./index-
|
|
1
|
+
import{j as r,a1 as i,a2 as t}from"./radix-ui-nu4wz29m.js";import"./react-vendor-Bjx91N7w.js";import{c as s}from"./index-BJl0cazY.js";import{m as o}from"./icons-DIVjDO-z.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as W}from"./react-vendor-Bjx91N7w.js";import{a as q,bf as Ce,B as f,d as P,n as te,C as x,j as p,k as v,_ as j,b as g,I as G,r as ne,s as ie,t as le,v as de,w as re,x as $,Q as we,R as Ve,U as oe,V as ce,c as fe,W as ke}from"./index-HwlgKSWH.js";import{u as J,a as K,b as M}from"./tanstack-bhJxV1h8.js";import{t as C}from"./notifications-B4_o8bcr.js";import{aa as De,a9 as Be,L as Q,au as Ie,at as Te,R as Re,T as ue,ai as Ae,a7 as qe}from"./icons-DIVjDO-z.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const U=["claude-extension-bindings"];async function w(s,n){const t=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...n});if(!t.ok){const l=await t.json().catch(()=>null);throw new Error(l?.error||`Request failed (${t.status})`)}return t.status===204?void 0:await t.json()}function Ue(){return J({queryKey:["claude-extension-options"],queryFn:()=>w("/claude-extension/profiles")})}function Fe(s,n="vscode"){return J({queryKey:["claude-extension-setup",s,n],enabled:!!s,queryFn:()=>w(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(n)}`)})}function Le(){return J({queryKey:U,queryFn:()=>w("/claude-extension/bindings")})}function Oe(s){return J({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>w(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Qe(){const s=K();return M({mutationFn:n=>w("/claude-extension/bindings",{method:"POST",body:JSON.stringify(n)}),onSuccess:()=>{s.invalidateQueries({queryKey:U}),C.success("Binding created")},onError:n=>C.error(n.message)})}function $e(){const s=K(),{t:n}=q();return M({mutationFn:({id:t,binding:l})=>w(`/claude-extension/bindings/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(l)}),onSuccess:(t,l)=>{s.invalidateQueries({queryKey:U}),s.invalidateQueries({queryKey:["claude-extension-binding-status",l.id]}),C.success(n("claudeExtensionPage.bindingSaved"))},onError:t=>C.error(t.message)})}function Je(){const s=K(),{t:n}=q();return M({mutationFn:t=>w(`/claude-extension/bindings/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:U}),C.success(n("claudeExtensionPage.bindingDeleted"))},onError:t=>C.error(t.message)})}function pe(s,n){const t=K();return M({mutationFn:({id:l,target:S})=>w(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{t.invalidateQueries({queryKey:U}),t.setQueryData(["claude-extension-binding-status",l.bindingId],l),C.success(n)},onError:l=>C.error(l.message)})}function Ke(){const{t:s}=q();return pe("apply",s("claudeExtensionPage.bindingApplied"))}function Me(){const{t:s}=q();return pe("reset",s("claudeExtensionPage.managedValuesRemoved"))}const He=[];function xe(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function T(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function _e(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function ge(s){return s?.state==="applied"}function ze({state:s}){const n=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(f,{variant:"outline",className:n,children:s})}function We(s){return s.replace(/[\\/]/g,"$&")}function o({label:s,value:n,mono:t=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:We(n)})}),e.jsx($,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:fe("text-left sm:text-right",t&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:n})]})}function me({title:s,description:n,value:t}){return e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s}),e.jsx(j,{className:"mt-1",children:n})]}),e.jsx($,{value:t,label:`Copy ${s}`})]})}),e.jsx(g,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:t})})]})}function he({title:s,description:n,status:t,applyLabel:l,resetLabel:S,onApply:F,onReset:m,disabled:b,busy:V}){return e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s}),e.jsx(j,{className:"mt-1",children:n})]}),t?e.jsx(ze,{state:t.state}):null]})}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{label:"Path",value:t?.path||"Save a binding first",mono:!0,copyValue:t?.path}),e.jsx(o,{label:"File",value:t?t.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:t?.message||ke.t("claudeExtensionPage.verifyAfterSaving",{defaultValue:"Verify the binding after saving to inspect the current file state."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{size:"sm",className:"flex-1",onClick:F,disabled:b||V,children:[V?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(P,{size:"sm",variant:"outline",className:"flex-1",onClick:m,disabled:b||V,children:S})]})]})]})}function Ge({binding:s,isSelected:n,onSelect:t}){return e.jsx("button",{onClick:t,className:fe("w-full rounded-lg border px-3 py-3 text-left transition-colors",n?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(f,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function ls(){const{t:s}=q(),n=Ue(),t=Le(),l=Qe(),S=$e(),F=Je(),m=Ke(),b=Me(),V=n.data?.profiles??[],Y=n.data?.hosts??[],E=t.data?.bindings??He,ve=V[0]?.name??"default",[je,D]=W.useState(!1),[L,B]=W.useState(null),[X,k]=W.useState(()=>xe("default")),c=je||E.length===0,N=!c&&E.length>0?E.find(a=>a.id===L)??(L?null:E[0]):null,h=N?.id??null,d=c||!N||L?X:T(N),Z=Fe(d.profile,d.host),R=Oe(c?void 0:h||void 0),r=Y.find(a=>a.id===d.host),H=V.find(a=>a.name===d.profile),_=n.error||t.error||Z.error||R.error,be=`${E.length} saved`,ee=l.isPending||S.isPending,Ne=m.isPending&&m.variables?.target==="shared"||b.isPending&&b.variables?.target==="shared",ye=m.isPending&&m.variables?.target==="ide"||b.isPending&&b.variables?.target==="ide",se=d.name.trim().length>0&&d.profile.trim().length>0,i=Z.data,u=R.data,ae=Math.max((i?.env.length??0)-6,0),Pe=i?.env.slice(0,6)??[];function z(){D(!0),B(null),k(xe(ve))}async function Se(){if(!se)return;const a=_e(d);if(!c&&h){const O=await S.mutateAsync({id:h,binding:a});D(!1),B(O.binding.id),k(T(O.binding));return}const y=await l.mutateAsync(a);D(!1),B(y.binding.id),k(T(y.binding))}async function Ee(){if(!h||!N||!window.confirm(s("claudeExtensionPage.deleteBindingConfirm",{name:N.name,defaultValue:'Delete binding "{{name}}"?'})))return;await F.mutateAsync(h);const a=E.filter(y=>y.id!==h);a.length>0?(B(a[0].id),D(!1),k(T(a[0]))):z()}function A(a,y){if(!c&&N&&!L){B(N.id),k({...T(N),[a]:y}),D(!1);return}k(O=>({...O,[a]:y}))}function I(a,y){if(h){if(y==="apply"){m.mutate({id:h,target:a});return}b.mutate({id:h,target:a})}}return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(De,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:s("claudeExtensionPage.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("claudeExtensionPage.savedBindingsSubtitle",{defaultValue:"Saved IDE bindings for CCS profiles"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"secondary",children:be}),r?e.jsx(f,{variant:"outline",children:r.label}):null]})]}),e.jsxs(P,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),s("claudeExtensionPage.new",{defaultValue:"New"})]})]})}),e.jsx(te,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:c?s("claudeExtensionPage.createBinding",{defaultValue:"Create binding"}):s("claudeExtensionPage.bindingEditor",{defaultValue:"Binding editor"})}),e.jsx(j,{children:s("claudeExtensionPage.bindingEditorDescription",{defaultValue:"Save a profile + IDE path once, then apply or reset it from the dashboard."})})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.bindingName")}),e.jsx(G,{value:d.name,onChange:a=>A("name",a.target.value),placeholder:s("claudeExtensionPage.bindingNamePlaceholder",{defaultValue:"VS Code · work profile"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("claudeExtensionPage.ccsProfile",{defaultValue:"CCS profile"})}),e.jsxs(ne,{value:d.profile,onValueChange:a=>A("profile",a),children:[e.jsx(ie,{children:e.jsx(le,{placeholder:s("claudeExtensionPage.selectProfile",{defaultValue:"Select a profile"})})}),e.jsx(de,{children:V.map(a=>e.jsxs(re,{value:a.name,children:[a.label," (",a.profileType,")"]},a.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H?.description||s("claudeExtensionPage.chooseProfileHint",{defaultValue:"Choose which CCS profile the IDE should inherit."})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.ideHost")}),e.jsxs(ne,{value:d.host,onValueChange:a=>A("host",a),children:[e.jsx(ie,{children:e.jsx(le,{placeholder:s("claudeExtensionPage.selectHost",{defaultValue:"Select a host"})})}),e.jsx(de,{children:Y.map(a=>e.jsx(re,{value:a.id,children:a.label},a.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.ideSettingsPath")}),e.jsx(G,{value:d.ideSettingsPath,onChange:a=>A("ideSettingsPath",a.target.value),placeholder:r?.defaultSettingsPath||s("claudeExtensionPage.ideSettingsPathPlaceholder",{defaultValue:"Leave blank for the default user settings path"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("claudeExtensionPage.ideSettingsPathHint",{defaultValue:"Leave blank to use the default user settings path for"})," ",r?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.notes")}),e.jsx(G,{value:d.notes,onChange:a=>A("notes",a.target.value),placeholder:s("claudeExtensionPage.notesPlaceholder",{defaultValue:"Optional reminder for this machine or workspace"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{className:"flex-1 gap-1.5",onClick:()=>void Se(),disabled:!se||ee,children:[ee?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"h-3.5 w-3.5"}),c?s("claudeExtensionPage.create",{defaultValue:"Create"}):s("claudeExtensionPage.save",{defaultValue:"Save"})]}),e.jsx(P,{variant:"outline",onClick:z,children:s("claudeExtensionPage.resetForm",{defaultValue:"Reset form"})})]}),c?null:e.jsxs(P,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Ee(),disabled:F.isPending,children:[e.jsx(Te,{className:"h-3.5 w-3.5"}),s("claudeExtensionPage.deleteBinding",{defaultValue:"Delete binding"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("claudeExtensionPage.savedBindings",{defaultValue:"Saved bindings"})}),e.jsx("div",{className:"space-y-2",children:E.length>0?E.map(a=>e.jsx(Ge,{binding:a,isSelected:a.id===h&&!c,onSelect:()=>{D(!1),B(a.id),k(T(a))}},a.id)):e.jsx(x,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(g,{className:"pt-6 text-sm text-muted-foreground",children:s("claudeExtensionPage.emptyBindings",{defaultValue:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(te,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[H?e.jsx(f,{variant:"outline",children:H.label}):null,r?e.jsx(f,{variant:"outline",children:r.label}):null,c?e.jsx(f,{variant:"secondary",children:s("settingsPage.thinkingSection.draft")}):null,u?.sharedSettings&&ge(u.sharedSettings)&&ge(u.ideSettings)?e.jsx(f,{className:"bg-emerald-600 hover:bg-emerald-600",children:s("settingsPage.thinkingSection.inSync")}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:N?.name||s("claudeExtensionPage.defaultBindingName",{defaultValue:"Claude extension binding"})}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s("claudeExtensionPage.bindingDescription",{defaultValue:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{variant:"outline",onClick:()=>void R.refetch(),disabled:c||R.isFetching,children:[R.isFetching?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Re,{className:"mr-1.5 h-3.5 w-3.5"}),s("claudeExtensionPage.verify",{defaultValue:"Verify"})]}),i?e.jsx($,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(x,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(g,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ve,{className:"w-full justify-start",children:[e.jsx(oe,{value:"overview",children:s("claudeExtensionPage.overview",{defaultValue:"Overview"})})," ",e.jsx(oe,{value:"advanced",children:s("settingsPage.thinkingSection.advanced")})]}),e.jsxs(ce,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(he,{title:s("claudeExtensionPage.sharedClaudeSettings",{defaultValue:"Shared Claude settings"}),description:s("claudeExtensionPage.sharedClaudeSettingsDescription",{defaultValue:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned."}),status:u?.sharedSettings,applyLabel:s("claudeExtensionPage.applyShared",{defaultValue:"Apply shared"}),resetLabel:s("claudeExtensionPage.resetShared",{defaultValue:"Reset shared"}),onApply:()=>I("shared","apply"),onReset:()=>I("shared","reset"),disabled:c,busy:Ne}),e.jsx(he,{title:`${r?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:u?.ideSettings,applyLabel:s("claudeExtensionPage.applyIde",{defaultValue:"Apply IDE"}),resetLabel:s("claudeExtensionPage.resetIde",{defaultValue:"Reset IDE"}),onApply:()=>I("ide","apply"),onReset:()=>I("ide","reset"),disabled:c,busy:ye})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.resolvedBinding")}),e.jsx(j,{children:s("claudeExtensionPage.resolvedBindingDescription",{defaultValue:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:s("claudeExtensionPage.profile",{defaultValue:"Profile"}),value:i?.profile.label||d.profile||"Not selected"}),e.jsx(o,{label:s("claudeExtensionPage.profileType",{defaultValue:"Profile type"}),value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:r?.label||"Not selected"}),e.jsx(o,{label:s("claudeExtensionPage.idePathMode",{defaultValue:"IDE path mode"}),value:d.ideSettingsPath.trim()?s("claudeExtensionPage.customPath",{defaultValue:"Custom path"}):s("claudeExtensionPage.defaultUserPath",{defaultValue:"Default user path"})}),e.jsx(o,{label:s("claudeExtensionPage.effectiveIdePath",{defaultValue:"Effective IDE path"}),value:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath}),e.jsx(o,{label:s("claudeExtensionPage.persistCommand",{defaultValue:"Persist command"}),value:i?.sharedSettings.command||s("claudeExtensionPage.saveValidBindingFirst",{defaultValue:"Save a valid binding first"}),mono:!0}),d.notes.trim()?e.jsx(o,{label:s("settingsPage.thinkingSection.notes"),value:d.notes.trim()}):null]})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.managedPayload")}),e.jsx(j,{children:s("claudeExtensionPage.managedPayloadDescription",{defaultValue:"Keep the main view short. The full JSON stays in the Advanced tab."})})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Pe.map(a=>e.jsx(f,{variant:"secondary",className:"font-mono text-[10px]",children:a.name},a.name)),ae>0?e.jsxs(f,{variant:"outline",children:["+",ae," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-medium",children:s("claudeExtensionPage.envInjected",{count:i.env.length,defaultValue:"CCS will inject {{count}} environment values."})}),e.jsx("div",{className:"text-muted-foreground",children:s("claudeExtensionPage.envInjectedDescription",{defaultValue:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})})]}):e.jsx("div",{className:"text-muted-foreground",children:s("claudeExtensionPage.nativeDefaultsDescription",{defaultValue:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:s("claudeExtensionPage.saveDraftToUnlock",{defaultValue:"Save this draft to unlock apply, reset, and verify actions."})}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{className:"flex-1",onClick:()=>I("all","apply"),disabled:m.isPending,children:[m.isPending&&m.variables?.target==="all"?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,s("claudeExtensionPage.applyBothTargets",{defaultValue:"Apply both targets"})]}),e.jsx(P,{variant:"outline",className:"flex-1",onClick:()=>I("all","reset"),disabled:b.isPending,children:s("claudeExtensionPage.resetBothTargets",{defaultValue:"Reset both targets"})})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.warnings")}),e.jsx(j,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(g,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(a=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:a})]},a)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.notes")}),e.jsx(j,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(g,{className:"space-y-3",children:i.notes.length>0?i.notes.map(a=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Ae,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:a})]},a)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(ce,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(me,{title:s("claudeExtensionPage.sharedSettingsJson",{defaultValue:"Shared Claude settings JSON"}),description:s("claudeExtensionPage.sharedSettingsJsonDescription",{defaultValue:"Managed env block for ~/.claude/settings.json."}),value:i.sharedSettings.json}),e.jsx(me,{title:`${r?.label||"IDE"} settings JSON`,description:s("claudeExtensionPage.ideSettingsJsonDescription",{label:r?.settingsTargetLabel||"settings.json",defaultValue:"Anthropic extension snippet for {{label}}."}),value:i.ideSettings.json})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s("claudeExtensionPage.resolvedEnvironmentPayload",{defaultValue:"Resolved environment payload"})}),e.jsx(j,{children:s("claudeExtensionPage.resolvedEnvironmentPayloadDescription",{defaultValue:"Exact environment values that the extension receives after CCS expands this profile."})})]}),e.jsx($,{value:JSON.stringify(i.env,null,2),label:s("claudeExtensionPage.copyEnvironmentPayload",{defaultValue:"Copy environment payload"})})]})}),e.jsx(g,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:"Shared target metadata"}),e.jsx(j,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:u?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:u?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:u?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:"IDE target metadata"}),e.jsx(j,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:r?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:u?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(x,{className:"border-border/60 bg-card/80",children:e.jsxs(g,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(qe,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{ls as ClaudeExtensionPage};
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as W}from"./react-vendor-Bjx91N7w.js";import{a as q,bf as Ce,B as f,d as P,n as te,C as x,j as p,k as v,_ as j,b as g,I as G,r as ne,s as ie,t as le,v as de,w as re,x as $,Q as we,R as Ve,U as oe,V as ce,c as fe,W as ke}from"./index-BJl0cazY.js";import{u as J,a as K,b as M}from"./tanstack-bhJxV1h8.js";import{t as C}from"./notifications-B4_o8bcr.js";import{aa as De,a9 as Be,L as Q,au as Ie,at as Te,R as Re,T as ue,ai as Ae,a7 as qe}from"./icons-DIVjDO-z.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";const U=["claude-extension-bindings"];async function w(s,n){const t=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...n});if(!t.ok){const l=await t.json().catch(()=>null);throw new Error(l?.error||`Request failed (${t.status})`)}return t.status===204?void 0:await t.json()}function Ue(){return J({queryKey:["claude-extension-options"],queryFn:()=>w("/claude-extension/profiles")})}function Fe(s,n="vscode"){return J({queryKey:["claude-extension-setup",s,n],enabled:!!s,queryFn:()=>w(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(n)}`)})}function Le(){return J({queryKey:U,queryFn:()=>w("/claude-extension/bindings")})}function Oe(s){return J({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>w(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Qe(){const s=K();return M({mutationFn:n=>w("/claude-extension/bindings",{method:"POST",body:JSON.stringify(n)}),onSuccess:()=>{s.invalidateQueries({queryKey:U}),C.success("Binding created")},onError:n=>C.error(n.message)})}function $e(){const s=K(),{t:n}=q();return M({mutationFn:({id:t,binding:l})=>w(`/claude-extension/bindings/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(l)}),onSuccess:(t,l)=>{s.invalidateQueries({queryKey:U}),s.invalidateQueries({queryKey:["claude-extension-binding-status",l.id]}),C.success(n("claudeExtensionPage.bindingSaved"))},onError:t=>C.error(t.message)})}function Je(){const s=K(),{t:n}=q();return M({mutationFn:t=>w(`/claude-extension/bindings/${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:U}),C.success(n("claudeExtensionPage.bindingDeleted"))},onError:t=>C.error(t.message)})}function pe(s,n){const t=K();return M({mutationFn:({id:l,target:S})=>w(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{t.invalidateQueries({queryKey:U}),t.setQueryData(["claude-extension-binding-status",l.bindingId],l),C.success(n)},onError:l=>C.error(l.message)})}function Ke(){const{t:s}=q();return pe("apply",s("claudeExtensionPage.bindingApplied"))}function Me(){const{t:s}=q();return pe("reset",s("claudeExtensionPage.managedValuesRemoved"))}const He=[];function xe(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function T(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function _e(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function ge(s){return s?.state==="applied"}function ze({state:s}){const n=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(f,{variant:"outline",className:n,children:s})}function We(s){return s.replace(/[\\/]/g,"$&")}function o({label:s,value:n,mono:t=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:We(n)})}),e.jsx($,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:fe("text-left sm:text-right",t&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:n})]})}function me({title:s,description:n,value:t}){return e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s}),e.jsx(j,{className:"mt-1",children:n})]}),e.jsx($,{value:t,label:`Copy ${s}`})]})}),e.jsx(g,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:t})})]})}function he({title:s,description:n,status:t,applyLabel:l,resetLabel:S,onApply:F,onReset:m,disabled:b,busy:V}){return e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s}),e.jsx(j,{className:"mt-1",children:n})]}),t?e.jsx(ze,{state:t.state}):null]})}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{label:"Path",value:t?.path||"Save a binding first",mono:!0,copyValue:t?.path}),e.jsx(o,{label:"File",value:t?t.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:t?.message||ke.t("claudeExtensionPage.verifyAfterSaving",{defaultValue:"Verify the binding after saving to inspect the current file state."})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{size:"sm",className:"flex-1",onClick:F,disabled:b||V,children:[V?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(P,{size:"sm",variant:"outline",className:"flex-1",onClick:m,disabled:b||V,children:S})]})]})]})}function Ge({binding:s,isSelected:n,onSelect:t}){return e.jsx("button",{onClick:t,className:fe("w-full rounded-lg border px-3 py-3 text-left transition-colors",n?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(f,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function ls(){const{t:s}=q(),n=Ue(),t=Le(),l=Qe(),S=$e(),F=Je(),m=Ke(),b=Me(),V=n.data?.profiles??[],Y=n.data?.hosts??[],E=t.data?.bindings??He,ve=V[0]?.name??"default",[je,D]=W.useState(!1),[L,B]=W.useState(null),[X,k]=W.useState(()=>xe("default")),c=je||E.length===0,N=!c&&E.length>0?E.find(a=>a.id===L)??(L?null:E[0]):null,h=N?.id??null,d=c||!N||L?X:T(N),Z=Fe(d.profile,d.host),R=Oe(c?void 0:h||void 0),r=Y.find(a=>a.id===d.host),H=V.find(a=>a.name===d.profile),_=n.error||t.error||Z.error||R.error,be=`${E.length} saved`,ee=l.isPending||S.isPending,Ne=m.isPending&&m.variables?.target==="shared"||b.isPending&&b.variables?.target==="shared",ye=m.isPending&&m.variables?.target==="ide"||b.isPending&&b.variables?.target==="ide",se=d.name.trim().length>0&&d.profile.trim().length>0,i=Z.data,u=R.data,ae=Math.max((i?.env.length??0)-6,0),Pe=i?.env.slice(0,6)??[];function z(){D(!0),B(null),k(xe(ve))}async function Se(){if(!se)return;const a=_e(d);if(!c&&h){const O=await S.mutateAsync({id:h,binding:a});D(!1),B(O.binding.id),k(T(O.binding));return}const y=await l.mutateAsync(a);D(!1),B(y.binding.id),k(T(y.binding))}async function Ee(){if(!h||!N||!window.confirm(s("claudeExtensionPage.deleteBindingConfirm",{name:N.name,defaultValue:'Delete binding "{{name}}"?'})))return;await F.mutateAsync(h);const a=E.filter(y=>y.id!==h);a.length>0?(B(a[0].id),D(!1),k(T(a[0]))):z()}function A(a,y){if(!c&&N&&!L){B(N.id),k({...T(N),[a]:y}),D(!1);return}k(O=>({...O,[a]:y}))}function I(a,y){if(h){if(y==="apply"){m.mutate({id:h,target:a});return}b.mutate({id:h,target:a})}}return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(De,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:s("claudeExtensionPage.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("claudeExtensionPage.savedBindingsSubtitle",{defaultValue:"Saved IDE bindings for CCS profiles"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"secondary",children:be}),r?e.jsx(f,{variant:"outline",children:r.label}):null]})]}),e.jsxs(P,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),s("claudeExtensionPage.new",{defaultValue:"New"})]})]})}),e.jsx(te,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:c?s("claudeExtensionPage.createBinding",{defaultValue:"Create binding"}):s("claudeExtensionPage.bindingEditor",{defaultValue:"Binding editor"})}),e.jsx(j,{children:s("claudeExtensionPage.bindingEditorDescription",{defaultValue:"Save a profile + IDE path once, then apply or reset it from the dashboard."})})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.bindingName")}),e.jsx(G,{value:d.name,onChange:a=>A("name",a.target.value),placeholder:s("claudeExtensionPage.bindingNamePlaceholder",{defaultValue:"VS Code · work profile"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("claudeExtensionPage.ccsProfile",{defaultValue:"CCS profile"})}),e.jsxs(ne,{value:d.profile,onValueChange:a=>A("profile",a),children:[e.jsx(ie,{children:e.jsx(le,{placeholder:s("claudeExtensionPage.selectProfile",{defaultValue:"Select a profile"})})}),e.jsx(de,{children:V.map(a=>e.jsxs(re,{value:a.name,children:[a.label," (",a.profileType,")"]},a.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H?.description||s("claudeExtensionPage.chooseProfileHint",{defaultValue:"Choose which CCS profile the IDE should inherit."})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.ideHost")}),e.jsxs(ne,{value:d.host,onValueChange:a=>A("host",a),children:[e.jsx(ie,{children:e.jsx(le,{placeholder:s("claudeExtensionPage.selectHost",{defaultValue:"Select a host"})})}),e.jsx(de,{children:Y.map(a=>e.jsx(re,{value:a.id,children:a.label},a.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.ideSettingsPath")}),e.jsx(G,{value:d.ideSettingsPath,onChange:a=>A("ideSettingsPath",a.target.value),placeholder:r?.defaultSettingsPath||s("claudeExtensionPage.ideSettingsPathPlaceholder",{defaultValue:"Leave blank for the default user settings path"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("claudeExtensionPage.ideSettingsPathHint",{defaultValue:"Leave blank to use the default user settings path for"})," ",r?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:s("settingsPage.thinkingSection.notes")}),e.jsx(G,{value:d.notes,onChange:a=>A("notes",a.target.value),placeholder:s("claudeExtensionPage.notesPlaceholder",{defaultValue:"Optional reminder for this machine or workspace"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{className:"flex-1 gap-1.5",onClick:()=>void Se(),disabled:!se||ee,children:[ee?e.jsx(Q,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"h-3.5 w-3.5"}),c?s("claudeExtensionPage.create",{defaultValue:"Create"}):s("claudeExtensionPage.save",{defaultValue:"Save"})]}),e.jsx(P,{variant:"outline",onClick:z,children:s("claudeExtensionPage.resetForm",{defaultValue:"Reset form"})})]}),c?null:e.jsxs(P,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Ee(),disabled:F.isPending,children:[e.jsx(Te,{className:"h-3.5 w-3.5"}),s("claudeExtensionPage.deleteBinding",{defaultValue:"Delete binding"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s("claudeExtensionPage.savedBindings",{defaultValue:"Saved bindings"})}),e.jsx("div",{className:"space-y-2",children:E.length>0?E.map(a=>e.jsx(Ge,{binding:a,isSelected:a.id===h&&!c,onSelect:()=>{D(!1),B(a.id),k(T(a))}},a.id)):e.jsx(x,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(g,{className:"pt-6 text-sm text-muted-foreground",children:s("claudeExtensionPage.emptyBindings",{defaultValue:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(te,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[H?e.jsx(f,{variant:"outline",children:H.label}):null,r?e.jsx(f,{variant:"outline",children:r.label}):null,c?e.jsx(f,{variant:"secondary",children:s("settingsPage.thinkingSection.draft")}):null,u?.sharedSettings&&ge(u.sharedSettings)&&ge(u.ideSettings)?e.jsx(f,{className:"bg-emerald-600 hover:bg-emerald-600",children:s("settingsPage.thinkingSection.inSync")}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:N?.name||s("claudeExtensionPage.defaultBindingName",{defaultValue:"Claude extension binding"})}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s("claudeExtensionPage.bindingDescription",{defaultValue:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{variant:"outline",onClick:()=>void R.refetch(),disabled:c||R.isFetching,children:[R.isFetching?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Re,{className:"mr-1.5 h-3.5 w-3.5"}),s("claudeExtensionPage.verify",{defaultValue:"Verify"})]}),i?e.jsx($,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(x,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(g,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ve,{className:"w-full justify-start",children:[e.jsx(oe,{value:"overview",children:s("claudeExtensionPage.overview",{defaultValue:"Overview"})})," ",e.jsx(oe,{value:"advanced",children:s("settingsPage.thinkingSection.advanced")})]}),e.jsxs(ce,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(he,{title:s("claudeExtensionPage.sharedClaudeSettings",{defaultValue:"Shared Claude settings"}),description:s("claudeExtensionPage.sharedClaudeSettingsDescription",{defaultValue:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned."}),status:u?.sharedSettings,applyLabel:s("claudeExtensionPage.applyShared",{defaultValue:"Apply shared"}),resetLabel:s("claudeExtensionPage.resetShared",{defaultValue:"Reset shared"}),onApply:()=>I("shared","apply"),onReset:()=>I("shared","reset"),disabled:c,busy:Ne}),e.jsx(he,{title:`${r?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:u?.ideSettings,applyLabel:s("claudeExtensionPage.applyIde",{defaultValue:"Apply IDE"}),resetLabel:s("claudeExtensionPage.resetIde",{defaultValue:"Reset IDE"}),onApply:()=>I("ide","apply"),onReset:()=>I("ide","reset"),disabled:c,busy:ye})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.resolvedBinding")}),e.jsx(j,{children:s("claudeExtensionPage.resolvedBindingDescription",{defaultValue:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:s("claudeExtensionPage.profile",{defaultValue:"Profile"}),value:i?.profile.label||d.profile||"Not selected"}),e.jsx(o,{label:s("claudeExtensionPage.profileType",{defaultValue:"Profile type"}),value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:r?.label||"Not selected"}),e.jsx(o,{label:s("claudeExtensionPage.idePathMode",{defaultValue:"IDE path mode"}),value:d.ideSettingsPath.trim()?s("claudeExtensionPage.customPath",{defaultValue:"Custom path"}):s("claudeExtensionPage.defaultUserPath",{defaultValue:"Default user path"})}),e.jsx(o,{label:s("claudeExtensionPage.effectiveIdePath",{defaultValue:"Effective IDE path"}),value:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath}),e.jsx(o,{label:s("claudeExtensionPage.persistCommand",{defaultValue:"Persist command"}),value:i?.sharedSettings.command||s("claudeExtensionPage.saveValidBindingFirst",{defaultValue:"Save a valid binding first"}),mono:!0}),d.notes.trim()?e.jsx(o,{label:s("settingsPage.thinkingSection.notes"),value:d.notes.trim()}):null]})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.managedPayload")}),e.jsx(j,{children:s("claudeExtensionPage.managedPayloadDescription",{defaultValue:"Keep the main view short. The full JSON stays in the Advanced tab."})})]}),e.jsxs(g,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Pe.map(a=>e.jsx(f,{variant:"secondary",className:"font-mono text-[10px]",children:a.name},a.name)),ae>0?e.jsxs(f,{variant:"outline",children:["+",ae," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-medium",children:s("claudeExtensionPage.envInjected",{count:i.env.length,defaultValue:"CCS will inject {{count}} environment values."})}),e.jsx("div",{className:"text-muted-foreground",children:s("claudeExtensionPage.envInjectedDescription",{defaultValue:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})})]}):e.jsx("div",{className:"text-muted-foreground",children:s("claudeExtensionPage.nativeDefaultsDescription",{defaultValue:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:s("claudeExtensionPage.saveDraftToUnlock",{defaultValue:"Save this draft to unlock apply, reset, and verify actions."})}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{className:"flex-1",onClick:()=>I("all","apply"),disabled:m.isPending,children:[m.isPending&&m.variables?.target==="all"?e.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,s("claudeExtensionPage.applyBothTargets",{defaultValue:"Apply both targets"})]}),e.jsx(P,{variant:"outline",className:"flex-1",onClick:()=>I("all","reset"),disabled:b.isPending,children:s("claudeExtensionPage.resetBothTargets",{defaultValue:"Reset both targets"})})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.warnings")}),e.jsx(j,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(g,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(a=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:a})]},a)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:s("settingsPage.thinkingSection.notes")}),e.jsx(j,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(g,{className:"space-y-3",children:i.notes.length>0?i.notes.map(a=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Ae,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:a})]},a)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(ce,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(me,{title:s("claudeExtensionPage.sharedSettingsJson",{defaultValue:"Shared Claude settings JSON"}),description:s("claudeExtensionPage.sharedSettingsJsonDescription",{defaultValue:"Managed env block for ~/.claude/settings.json."}),value:i.sharedSettings.json}),e.jsx(me,{title:`${r?.label||"IDE"} settings JSON`,description:s("claudeExtensionPage.ideSettingsJsonDescription",{label:r?.settingsTargetLabel||"settings.json",defaultValue:"Anthropic extension snippet for {{label}}."}),value:i.ideSettings.json})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{className:"text-base",children:s("claudeExtensionPage.resolvedEnvironmentPayload",{defaultValue:"Resolved environment payload"})}),e.jsx(j,{children:s("claudeExtensionPage.resolvedEnvironmentPayloadDescription",{defaultValue:"Exact environment values that the extension receives after CCS expands this profile."})})]}),e.jsx($,{value:JSON.stringify(i.env,null,2),label:s("claudeExtensionPage.copyEnvironmentPayload",{defaultValue:"Copy environment payload"})})]})}),e.jsx(g,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:"Shared target metadata"}),e.jsx(j,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:u?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:u?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:u?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(x,{className:"border-border/60 bg-card/80",children:[e.jsxs(p,{children:[e.jsx(v,{className:"text-base",children:"IDE target metadata"}),e.jsx(j,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(g,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:u?.ideSettings.path||d.ideSettingsPath.trim()||r?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:r?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:u?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(x,{className:"border-border/60 bg-card/80",children:e.jsxs(g,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(qe,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{ls as ClaudeExtensionPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-nu4wz29m.js";import{r as c}from"./react-vendor-Bjx91N7w.js";import{a as gt,u as Qt,b as Ss}from"./tanstack-bhJxV1h8.js";import{a8 as As,a as W,d as K,C as Jt,b as Xt,a9 as Yt,aa as Zt,c as X,P as vt,B as H,ab as ue,L as Y,I as de,r as ze,s as Ge,t as Be,v as Ve,w as ye,ac as es,ad as ts,ae as Ms,af as Ps,ag as Ds,u as ss,ah as jt,ai as bt,aj as Nt,ak as yt,W as me,al as as,am as Et,an as Is,ao as Ts,ap as Je,aq as ns,Y as $e,ar as Es,as as Rt,at as Ot,au as Rs,av as Os,aw as Ls,ax as _s,ay as Fs,az as Us,aA as Ks,aB as Hs,aC as Lt,aD as qs,x as is,aE as zs,n as kt,aF as Gs,aG as wt,aH as _t,aI as rs,aJ as Bs,m as Vs,aK as $s,aL as Ws,aM as ct,T as ut,p as mt,q as pt,aN as Qs,aO as Js,aP as Xs,aQ as Ft,aR as Ys,aS as Zs,aT as ea,aU as ta,aV as sa,aW as aa,Q as na,R as ia,U as Ut,V as Kt,aX as ra,aY as oa,aZ as la,a_ as da,a$ as ca,b0 as ua,b1 as ma,b2 as pa,b3 as xa,b4 as ha,b5 as fa,b6 as ga,b7 as va,S as ja}from"./index-BJl0cazY.js";import{C as xt}from"./default-ports-1QQSffYX.js";import{t as B}from"./notifications-B4_o8bcr.js";import{C as os,L as ce,p as ke,$ as ba,m as we,o as ls,aG as Ct,R as St,q as Pe,aa as De,T as Xe,a7 as Ht,aH as ds,aF as Na,z as At,Z as Ie,_ as cs,i as ya,u as us,aI as ka,au as wa,X as Mt,a9 as ms,J as ps,D as xs,aJ as Ca,at as hs,aK as Sa,ax as Aa,aL as fs}from"./icons-DIVjDO-z.js";import{R as We,A as qt,D as it,i as Ma,a as Pa}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Qe}from"./checkbox-5R1YTubE.js";import{C as Da}from"./confirm-dialog-BhJV4F_d.js";import{S as Pt}from"./separator-Ct6a34bG.js";import{S as Ia}from"./searchable-select-DCOfw3f0.js";import{P as Ta}from"./proxy-status-widget-Df-4cfdm.js";import"./utils-CzKF5WmX.js";import"./form-utils-CuHzLhJZ.js";import"./code-highlight-D4E79GKQ.js";import"./alert-dialog-BM9gIsRp.js";const se="gemini-3.1-pro-high",Ce="gemini-3.1-pro-low",Ea=Object.freeze({"gemini-3-pro-high":se,"gemini-3.1-pro-high":se,"gemini-3-pro-low":Ce,"gemini-3.1-pro-low":Ce,"gemini-3-pro-preview":se,"gemini-3-pro-preview-customtools":se,"gemini-3.1-pro-preview":se,"gemini-3.1-pro-preview-customtools":se,"gemini-3-1-pro-preview":se,"gemini-3-1-pro-preview-customtools":se}),gs=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),Ra=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i,Oa=["agy/","gcli/"];function J(t){return As(t).toLowerCase()}function La(t){const a=t.trim(),s=a.toLowerCase();for(const n of Oa)if(s.startsWith(n))return a.slice(n.length);return a}function _a(t){return t.replace(/-customtools$/i,"")}function Fa(t){return Ea[J(t)]}function Ye(t){const a=J(t),s=a.match(Ra);if(!s)return null;const[,n,i,d]=s;return{normalizedId:a,version:n.split(/[.-]/).map(o=>Number(o)),family:i,customtools:!!d,dottedVersion:n.includes(".")}}function vs(t,a){const s=Math.max(t.length,a.length);for(let n=0;n<s;n+=1){const i=t[n]??0,d=a[n]??0;if(i!==d)return i>d?1:-1}return 0}function Ua(t,a,s){if(t.customtools!==a.customtools)return t.customtools?1:-1;const n=vs(t.version,a.version);if(n!==0)return n>0?-1:1;const i=+(t.dottedVersion===s.dottedVersion),d=+(a.dottedVersion===s.dottedVersion);return i!==d?d-i:t.normalizedId.localeCompare(a.normalizedId)}function zt(t,a){const s=J(a);return t.find(n=>J(n.id)===s)?.id}function Ka(t,a){const s=Ye(t);return!s||a.length===0?void 0:a.map(i=>{const d=Ye(i.id);return!d||d.family!==s.family?null:{id:i.id,info:d}}).filter(i=>!!i).sort((i,d)=>Ua(i.info,d.info,s))[0]?.id}const xe={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"claude-opus-4-6-thinking",models:[{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",description:"Latest flagship, extended thinking",extendedContext:!1,presetMapping:{default:"claude-opus-4-6-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Latest Sonnet with thinking budget support",presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-6",haiku:"claude-sonnet-4-6"}},{id:se,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:se,opus:se,sonnet:se,haiku:"gemini-3-1-flash-preview"}},{id:Ce,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:Ce,opus:Ce,sonnet:Ce,haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:se,sonnet:se,haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.4",models:[{id:"gpt-5.5",name:"GPT-5.5",tier:"paid",description:"Newest Codex-released GPT-5 family model; falls back to GPT-5.4 on free plans",codexMaxEffort:"xhigh",codexServiceTiers:["fast"],presetMapping:{default:"gpt-5.5",opus:"gpt-5.5",sonnet:"gpt-5.5",haiku:"gpt-5.4-mini"}},{id:"gpt-5.4",name:"GPT-5.4",description:"Recommended Codex default for most coding and agentic tasks",codexMaxEffort:"xhigh",codexServiceTiers:["fast"],presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5.4-mini"}},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini",description:"Fast, lower-cost Codex option for lighter tasks and haiku-tier routing",codexMaxEffort:"high",presetMapping:{default:"gpt-5.4-mini",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5.4-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Previous flagship coding model whose capabilities now power GPT-5.4",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5.4-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Research preview model for ChatGPT Pro subscribers, optimized for near-instant coding iteration",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5.4-mini"}},{id:"gpt-5.2",name:"GPT-5.2",description:"Previous general-purpose Codex model",codexMaxEffort:"xhigh",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.4-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-7",name:"Claude Opus 4.7",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-7",opus:"claude-opus-4-7",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Previous flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function Ae(t,a){if(!t)return;const s=J(a);if(t.provider==="agy"){const o=Fa(s);if(o){const l=t.models.find(r=>r.id===o);if(l)return l}}const n=gs[s.toLowerCase()],i=t.models.find(o=>o.id===s||o.id===n);if(i)return i;const d=Ye(s);if(d)return t.models.map(o=>({model:o,info:Ye(o.id)})).filter(o=>!!(o.info&&o.info.family===d.family)).sort((o,l)=>vs(l.info.version,o.info.version))[0]?.model}function Ha(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function qa(t,a){const s=xe[t.toLowerCase()];if(!a||a.models.length===0)return s;const n=a.models.map(l=>({id:l.id,owned_by:a.provider})),i=a.models.map(l=>{const r=Ae(s,l.id);return{...l,name:l.name||r?.name||l.id,tier:r?.tier??Ha(l.tier),description:l.description??r?.description,broken:r?.broken,issueUrl:r?.issueUrl,deprecated:r?.deprecated,deprecationReason:r?.deprecationReason,extendedContext:l.extendedContext??r?.extendedContext,presetMapping:r?.presetMapping}}),d=s?.defaultModel?Se(s.defaultModel,n):void 0,o=typeof d=="string"&&n.some(l=>J(l.id)===J(d));return{provider:a.provider,displayName:a.displayName||s?.displayName||t,defaultModel:o?d:a.defaultModel,models:i}}function Dt(t){const a={},s=new Set([...Object.keys(xe),...Object.keys(t??{})]);for(const n of s){const i=qa(n,t?.[n]);i&&(a[n]=i)}return a}function js(t,a,s){const n=Ae(s,a);return n||Ae(xe[t.toLowerCase()],a)}function Se(t,a=[]){const s=J(t),n=Ka(s,a);if(n)return n;const i=zt(a,s);if(i)return i;const d=gs[s];return(d?zt(a,d):void 0)??s}function za(t,a=[]){return{default:Se(t.default,a),opus:Se(t.opus,a),sonnet:Se(t.sonnet,a),haiku:Se(t.haiku,a)}}function It(t,a=[]){if(!t)return[];const s=xe[t.provider.toLowerCase()]??t,n=new Set;return s.models.map(i=>{const d=Se(i.id,a),o=i.presetMapping?za(i.presetMapping,a):void 0,l=t.models.find(r=>J(r.id)===J(d));return{...i,id:d,name:l?.name||i.name,description:l?.description??i.description,presetMapping:o}}).filter(i=>n.has(i.id)?!1:(n.add(i.id),!0))}function Ga(t,a,s=[]){const n=t.trim().toLowerCase();if(!a||!n)return[];const i=xe[n]??a,d=It(a,s),o=new Set(d.map(p=>J(p.id))),l=new Set(d.map(p=>Ae(i,p.id)?.id).filter(p=>!!p).map(p=>J(p))),r=new Set,m=new Set(s.map(p=>J(p.id)));return s.filter(p=>{const j=J(p.id),f=La(p.id),h=_a(f),E=Ae(i,f)??Ae(i,h);if(o.has(J(f))||j!==J(f)&&m.has(J(f)))return!1;const k=J(h);if(k!==J(f)&&m.has(k))return!1;const D=E?J(E.id):k;return E&&l.has(D)||r.has(D)||!E&&n==="agy"?!1:(r.add(D),!0)})}function Ba(t,a,s){return js(t,a,s)?.extendedContext===!0}const rt="ccs-internal-managed";async function Va(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??rt:rt}catch{return rt}}async function $a(t,a){if(a)return a;try{const s=await fetch("/api/cliproxy/catalog");if(!s.ok)return xe[t];const n=await s.json();return Dt(n.catalogs)[t]??xe[t]}catch{return xe[t]}}async function ht(t,a,s){const n=await $a(t,s);if(!n)return{success:!1};const i=n.models.find(m=>m.id===n.defaultModel)||n.models[0],d=i?.presetMapping||{default:n.defaultModel,opus:n.defaultModel,sonnet:n.defaultModel,haiku:n.defaultModel},o=await Va(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${xt}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:o,ANTHROPIC_MODEL:d.default,ANTHROPIC_DEFAULT_OPUS_MODEL:d.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:d.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:d.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:i?.name||n.defaultModel}}catch{return{success:!1}}}function Wa({currentProgress:t,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((s,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=n?"bg-primary":"bg-muted"}`},s))})}function Qa({providers:t,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:t.map(s=>e.jsxs("button",{onClick:()=>a(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(os,{className:"w-4 h-4 text-muted-foreground"})]},s.id))})}function Ja({selectedProvider:t,providers:a,authCommand:s,isRefreshing:n,isPending:i,onBack:d,onStartAuth:o,onRefresh:l}){const{t:r}=W(),[m,p]=c.useState(!1),j=async f=>{await navigator.clipboard.writeText(f),p(!0),setTimeout(()=>p(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:r("setupWizard.authStep.authenticateWith",{provider:a.find(f=>f.id===t)?.name})}),e.jsx(K,{onClick:o,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),r("setupWizard.authStep.authenticating")]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-4 h-4"}),r("setupWizard.authStep.authenticateInBrowser")]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("setupWizard.authStep.completeOAuth")})]}),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:r("setupWizard.authStep.orUseTerminal")})})]}),e.jsx(Jt,{children:e.jsxs(Xt,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ba,{className:"w-4 h-4"}),r("setupWizard.authStep.runCommandHint")]}),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:s}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>j(s),children:m?e.jsx(we,{className:"w-4 h-4 text-green-500"}):e.jsx(ls,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(K,{variant:"ghost",onClick:d,disabled:i,children:[e.jsx(Ct,{className:"w-4 h-4 mr-2"}),r("setupWizard.authStep.back")]}),e.jsxs(K,{variant:"outline",onClick:l,disabled:n||i,children:[e.jsx(St,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),r(n?"setupWizard.authStep.checking":"setupWizard.authStep.refreshStatus")]})]})]})}function Xa({accounts:t,privacyMode:a,onSelect:s,onAddNew:n,onBack:i}){const{t:d}=W();return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:d("setupWizard.accountStep.selectAccount",{count:t.length})}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(o=>{const l=Yt(o.id,o.email,o.tokenFile),r=o.provider?.toLowerCase()==="codex"?Zt(l):null;return e.jsxs("button",{type:"button",onClick:()=>s(o),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(Pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:X("font-medium",a&&vt),children:l.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",r.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":r.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:r.label}):l.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",l.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":l.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:l.audienceLabel}):null,!r?.label&&l.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:l.detailLabel}),o.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:d("setupWizard.accountStep.defaultAccount")})]})]})]}),e.jsx(os,{className:"w-4 h-4 text-muted-foreground"})]},o.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:d("setupWizard.accountStep.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:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ke,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:d("setupWizard.accountStep.addNewAccount")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:d("setupWizard.accountStep.addNewAccountDesc")})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(K,{variant:"ghost",onClick:i,children:[e.jsx(Ct,{className:"w-4 h-4 mr-2"}),d("setupWizard.accountStep.back")]})})]})}const Gt="__custom__";function Ya({selectedProvider:t,catalog:a,selectedAccount:s,variantName:n,modelName:i,isPending:d,privacyMode:o,onVariantNameChange:l,onModelChange:r,onBack:m,onSkip:p,onCreate:j}){const{t:f}=W(),h=a||xe[t],E=h?.models||[],k=i&&!E.some(g=>g.id===i),[D,S]=c.useState(k),C=t==="agy"&&i.trim().length>0?ue(i):!1,y=s?Yt(s.id,s.email,s.tokenFile):null,w=t==="codex"&&y?Zt(y):null,x=g=>{g===Gt?(S(!0),r("")):(S(!1),r(g))};return e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(Pe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[f("setupVariant.using")," ",e.jsx("span",{className:X(o&&vt),children:y?.email})]}),(y?.audienceLabel||y?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[w?.label?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",w.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":w.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:w.label}):y?.audienceLabel?e.jsx(H,{variant:"outline",className:X("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":y.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.audienceLabel}):null,!w?.label&&y?.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:y.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:f("setupVariant.variantNameRequired")}),e.jsx(de,{id:"variant-name",value:n,onChange:g=>l(g.target.value),placeholder:f("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[f("setupVariant.invokeHintPrefix")," ccs ",n||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:f("setupVariant.model")}),D?e.jsxs("div",{className:"space-y-2",children:[e.jsx(de,{value:i,onChange:g=>r(g.target.value),placeholder:f("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:f("providerEditor.agyDenylist")}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{S(!1),t==="agy"&&ue(i)&&r("")},children:f("setupVariant.choosePresetInstead")})]}):e.jsxs(ze,{value:E.some(g=>g.id===i)?i:"",onValueChange:x,children:[e.jsx(Ge,{children:e.jsx(Be,{placeholder:f("setupVariant.selectModel")})}),e.jsxs(Ve,{children:[E.map(g=>e.jsx(ye,{value:g.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:g.name}),g.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",g.description]})]})},g.id)),e.jsx(ye,{value:Gt,children:e.jsx("span",{className:"text-primary",children:f("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:D?f("setupVariant.enterAnyModel"):f("setupVariant.defaultModel",{model:h?.defaultModel||f("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(K,{variant:"ghost",onClick:m,children:[e.jsx(Ct,{className:"w-4 h-4 mr-2"}),f("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",onClick:p,children:f("setupVariant.skip")}),e.jsx(K,{onClick:j,disabled:!n||d||C,children:f(d?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:f("setupVariant.skipHint")})]})}function Za({variantName:t,onClose:a}){const{t:s}=W();return 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(we,{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:s("setupWizard.successStep.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.subtitle")})]}),e.jsx(Jt,{children:e.jsxs(Xt,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.usage")}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",t,' "your prompt here"']})]})}),e.jsx(K,{onClick:a,className:"w-full",children:s("setupWizard.successStep.done")})]})}function en({open:t,onClose:a}){const[s,n]=c.useState("provider"),[i,d]=c.useState(""),[o,l]=c.useState(null),[r,m]=c.useState(""),[p,j]=c.useState(""),[f,h]=c.useState(!1),[E,k]=c.useState(!1),{data:D,refetch:S}=es(),{data:C}=ts(),y=Ms(),w=Ps(),x=Ds(),{privacyMode:g}=ss(),I=D?.authStatus.find(R=>R.provider===i),u=c.useMemo(()=>I?.accounts||[],[I?.accounts]),T=c.useMemo(()=>Dt(C?.catalogs),[C?.catalogs]),N=!!C;c.useEffect(()=>{if(!t){const R=setTimeout(()=>{n("provider"),d(""),l(null),m(""),j(""),k(!1)},0);return()=>clearTimeout(R)}},[t]),c.useEffect(()=>{if(s==="auth"&&u.length>0&&!E){const R=setTimeout(()=>{n("account")},0);return()=>clearTimeout(R)}},[s,u,E]);const z=async()=>{h(!0),await S(),h(!1)},P=()=>{const R=(I?.accounts?.length||0)===0;w.mutate({provider:i},{onSuccess:async b=>{if(R){const Q=await ht(i,void 0,N?T[i]:void 0);Q.success&&Q.presetName?B.success(`Applied "${Q.presetName}" preset`):Q.success||B.warning(me.t("commonToast.accountAddedPresetFailed"))}b.account&&(l(b.account),n("variant")),S()}})},O=R=>{d(R),(D?.authStatus.find(te=>te.provider===R)?.accounts||[]).length===0?n("auth"):n("account")},_=R=>{l(R),n("variant")},G=async()=>{if(!(!r||!i))try{await y.mutateAsync({name:r,provider:i,model:p||void 0,account:o?.id}),n("success")}catch(R){console.error("Failed to create variant:",R)}},V=`ccs ${i} --auth --add`,q=Ts(s),A=R=>{if(!R&&(w.isPending&&i&&x.mutate(i),s==="success"||s==="provider")){a();return}};return e.jsx(jt,{open:t,onOpenChange:A,children:e.jsxs(bt,{className:"sm:max-w-lg",onPointerDownOutside:R=>{s!=="success"&&s!=="provider"&&R.preventDefault()},onEscapeKeyDown:R=>{(w.isPending||y.isPending)&&R.preventDefault()},children:[e.jsxs(Nt,{children:[e.jsxs(yt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-5 h-5 text-primary"}),me.t("setupWizard.title")]}),e.jsxs(as,{children:[s==="provider"&&me.t("setupWizard.stepProviderDesc"),s==="auth"&&me.t("setupWizard.stepAuthDesc"),s==="account"&&me.t("setupWizard.stepAccountDesc"),s==="variant"&&me.t("setupWizard.stepVariantDesc"),s==="success"&&me.t("setupWizard.stepSuccessDesc")]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[s==="provider"&&e.jsx(Qa,{providers:Et,onSelect:O}),s==="auth"&&e.jsx(Ja,{selectedProvider:i,providers:Et,authCommand:V,isRefreshing:f,isPending:w.isPending,onBack:()=>n("provider"),onStartAuth:P,onRefresh:z}),s==="account"&&e.jsx(Xa,{accounts:u,privacyMode:g,onSelect:_,onAddNew:()=>{k(!0),n("auth")},onBack:()=>n("provider")}),s==="variant"&&e.jsx(Ya,{selectedProvider:i,catalog:T[i],selectedAccount:o,variantName:r,modelName:p,isPending:y.isPending,privacyMode:g,onVariantNameChange:m,onModelChange:j,onBack:()=>u.length>0?n("account"):n("provider"),onSkip:a,onCreate:G}),s==="success"&&e.jsx(Za,{variantName:r,onClose:a})]}),e.jsx(Wa,{currentProgress:q,allSteps:Is})]})})}const tn=3e3,sn=300*1e3,an=3;function ot(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function lt(t){const a=await t.text();if(!a)return{};try{return JSON.parse(a)}catch{const s=t.status>=400?`Request failed with status ${t.status}`:void 0;return s?{error:s}:{}}}const ge={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function nn(){const{t}=W(),[a,s]=c.useState(ge),n=c.useRef(ge),i=c.useRef(0),d=c.useRef(null),o=c.useRef(null),l=c.useRef(0),r=c.useRef(0),m=c.useRef(!1),p=gt(),j=c.useCallback(S=>S===i.current,[]),f=c.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),r.current=0},[]);c.useEffect(()=>()=>{d.current?.abort(),f(),m.current=!1},[f]),c.useEffect(()=>{n.current=a},[a]);const h=c.useCallback(async(S,C,y)=>{if(j(y)){if(Date.now()-l.current>sn){f(),j(y)&&s(w=>({...w,isAuthenticating:!1,error:t("toasts.providerAuthTimeout")}));return}try{const w=await fetch(`/api/cliproxy/auth/${S}/status?state=${encodeURIComponent(C)}`);if(!j(y))return;const x=await w.json();if(r.current=0,x.status==="ok"){if(!(typeof x.account=="object"&&x.account!==null)){f();const I=t("toasts.providerAccountRegistrationFailed");B.error(I),s(u=>({...u,isAuthenticating:!1,error:I}));return}f(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),ot(p),B.success(t("toasts.providerAuthSuccess",{provider:S})),m.current=!1,s(ge)}else if(x.status==="auth_url"){const g=x.url||x.auth_url;g&&(s(I=>({...I,authUrl:g})),m.current||(m.current=!0,window.open(g,"_blank")))}else if(x.status==="device_code"){f();const g=x.user_code&&x.verification_url?`Open ${x.verification_url} and enter code: ${x.user_code}`:"Switch to Device Code method and try again.";B.error(t("toasts.providerDeviceCodeInCallback")),s(I=>({...I,isAuthenticating:!1,error:g}))}else if(x.status==="error"){f();const g=x.error||"Authentication failed";B.error(g),s(I=>({...I,isAuthenticating:!1,error:g}))}}catch(w){if(!j(y)||(r.current+=1,r.current<an))return;f();const x=w instanceof Error&&w.message.trim().length>0?w.message:t("toasts.providerLostStatusEndpoint");B.error(x),s(g=>({...g,isAuthenticating:!1,error:x}))}}},[j,p,f,t]),E=c.useCallback(async(S,C)=>{if(!Je(S)){s({...ge,error:t("toasts.providerUnknown",{provider:S})});return}d.current?.abort(),f(),m.current=!1,r.current=0;const y=new AbortController,w=i.current+1;i.current=w,d.current=y;const g=(C?.flowType||(ns(S)?"device_code":"authorization_code"))==="device_code",I=C?.startEndpoint||(g?"start":"start-url"),u={nickname:C?.nickname,kiroMethod:C?.kiroMethod,kiroIDCStartUrl:C?.kiroIDCStartUrl,kiroIDCRegion:C?.kiroIDCRegion,kiroIDCFlow:C?.kiroIDCFlow,gitlabAuthMode:C?.gitlabAuthMode,gitlabBaseUrl:C?.gitlabBaseUrl,gitlabPersonalAccessToken:C?.gitlabPersonalAccessToken,riskAcknowledgement:C?.riskAcknowledgement};s({provider:S,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:g});try{if(I==="start")fetch(`/api/cliproxy/auth/${S}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal}).then(async T=>{if(!j(w))return;const N=await lt(T);if(!j(w))return;const z=N.success===!0,P=typeof N.account=="object"&&N.account!==null;if(T.ok&&z&&P)p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),ot(p),m.current=!1,s(ge);else{const O=typeof N.error=="string"?N.error:t(z?"toasts.providerAccountRegistrationFailed":"auth.loginFailed");B.error(O),s(_=>({..._,isAuthenticating:!1,error:O}))}}).catch(T=>{if(!j(w)||T instanceof Error&&T.name==="AbortError")return;const N=T instanceof Error?T.message:"Authentication failed";B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))});else{const T=await fetch(`/api/cliproxy/auth/${S}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u),signal:y.signal});if(!j(w))return;const N=await lt(T);if(!j(w))return;const z=N.success===!0;if(!T.ok||!z){const _=typeof N.error=="string"?N.error:t("toasts.providerStartOAuthFailed");throw new Error(_)}const P=typeof N.authUrl=="string"?N.authUrl:null,O=typeof N.state=="string"?N.state:null;if(s(_=>({..._,authUrl:P,oauthState:O})),P&&(m.current=!0,window.open(P,"_blank")),O){if(l.current=Date.now(),!P){if(await h(S,O,w),!j(w))return;const _=n.current;if(!_.isAuthenticating||_.provider!==S)return}o.current=setInterval(()=>{h(S,O,w)},tn)}}}catch(T){if(!j(w))return;if(T instanceof Error&&T.name==="AbortError"){m.current=!1,s(ge);return}const N=T instanceof Error?T.message:t("auth.loginFailed");B.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))}},[j,h,f,p,t]),k=c.useCallback(()=>{const S=a.provider;i.current+=1,d.current?.abort(),f(),m.current=!1,s(ge),S&&$e.cliproxy.auth.cancel(S).catch(()=>{})},[a.provider,f]),D=c.useCallback(async S=>{if(!a.provider)return;const C=i.current,y=a.provider;s(w=>({...w,isSubmittingCallback:!0,error:null}));try{const w=await fetch(`/api/cliproxy/auth/${y}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:S})});if(!j(C))return;const x=await lt(w);if(!j(C))return;const g=x.success===!0,I=x.status==="wait",u=typeof x.account=="object"&&x.account!==null;if(w.ok&&I)s(T=>({...T,isSubmittingCallback:!1,error:null}));else if(w.ok&&g&&u)f(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),ot(p),B.success(t("toasts.providerAuthSuccess",{provider:y})),s(ge);else{const T=typeof x.error=="string"?x.error:t(g?"toasts.providerAccountRegistrationFailed":"toasts.providerCallbackFailed");throw new Error(T)}}catch(w){if(!j(C))return;const x=w instanceof Error?w.message:t("toasts.providerSubmitCallbackFailed");B.error(x),s(g=>({...g,isSubmittingCallback:!1,error:x}))}},[j,a.provider,p,f,t]);return c.useMemo(()=>({...a,startAuth:E,cancelAuth:k,submitCallback:D}),[a,E,k,D])}function ft({className:t,compact:a=!1,showAcknowledgement:s=!1,acknowledgementPhrase:n=We,acknowledgementText:i="",onAcknowledgementTextChange:d,disabled:o=!1,showProxySettingsLink:l=!1}){const{t:r}=W(),m=r("accountSafetyWarning.title"),p=r("accountSafetyWarning.subtitle"),j=r("accountSafetyWarning.firstLine"),f=r("accountSafetyWarning.secondLine"),h="https://github.com/kaitranntt/ccs/issues/509",E=r("accountSafetyWarning.issueLabel"),k=r("accountSafetyWarning.proxySettingsLabel");return a?e.jsx("section",{role:"alert",className:X("border-b border-amber-200/70 bg-amber-50/45 dark:bg-amber-950/5",t),children:e.jsxs("div",{className:"flex flex-col gap-3 px-6 py-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-6 w-6 items-center justify-center rounded-md bg-amber-500/12 text-amber-700 dark:text-amber-300",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold leading-5",children:m}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:p})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:j}),e.jsx("p",{className:"text-xs font-medium leading-5 text-amber-900 dark:text-amber-200",children:f})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[E,e.jsx(ke,{className:"h-3 w-3"})]}),l?e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[e.jsx(Ht,{className:"h-3 w-3"}),k]}):null,e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:X("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:m}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]})]}),e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:j}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"CCS is provided as-is and does not take responsibility for suspension, bans, or access loss from upstream providers."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[E,e.jsx(ke,{className:"h-3.5 w-3.5"})]}),l&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Ht,{className:"h-3.5 w-3.5"}),k]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),s&&d&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:n})]}),e.jsx(de,{id:"account-risk-ack-text",value:i,onChange:D=>d(D.target.value),placeholder:n,disabled:o,className:"mt-2 font-mono text-xs"})]})]})]})}function rn({className:t,value:a,onChange:s,disabled:n=!1}){const{t:i}=W(),d=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===qt].filter(Boolean).length,o=d/4*100,l=r=>{s({...a,...r})};return e.jsxs("section",{role:"alert",className:X("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:d})})]}),e.jsx(Es,{value:o,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Qe,{id:"agy-step-reviewed-issue",checked:a.reviewedIssue509,onCheckedChange:r=>l({reviewedIssue509:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Qe,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:r=>l({understandsBanRisk:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Qe,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:r=>l({acceptsFullResponsibility:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(ds,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(de,{value:a.typedPhrase,onChange:r=>l({typedPhrase:r.target.value}),placeholder:qt,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(ke,{className:"h-3.5 w-3.5"})]})})]})]})}function on(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function ln({open:t,onClose:a,provider:s,displayName:n,catalog:i,isFirstAccount:d=!1}){const[o,l]=c.useState(""),[r,m]=c.useState(""),[p,j]=c.useState(!1),[f,h]=c.useState(null),[E,k]=c.useState(""),[D,S]=c.useState(it),[C,y]=c.useState(!1),[w,x]=c.useState(!1),[g,I]=c.useState(Rt),[u,T]=c.useState(""),[N,z]=c.useState(""),[P,O]=c.useState(Ot),[_,G]=c.useState("oauth"),[V,q]=c.useState(""),[A,R]=c.useState(""),{t:b}=W(),Q=c.useRef(!1),te=c.useRef(0),ne=c.useRef(!1),U=nn(),ae=Rs(),$=s==="kiro",Z=s==="gitlab",ie=s==="agy"||s==="gemini",v=s==="gemini"&&!C,L=s==="agy"&&!C,be=ie&&w,Te=Ma(D),Ee=on(E)===We,et=ns(s),Re=Os(g),he=$&&g==="idc",Ne=$&&_s(g),Me=$?Ls(g,P):void 0,tt=$?Us(g):void 0,st=$?Me==="device_code":et,re=U.isAuthenticating||ae.isPending,Oe=o.trim(),Le=u.trim(),_e=N.trim(),Fe=V.trim(),F=A.trim(),ee=f||U.error,oe=c.useCallback(async()=>{const M=await fetch("/api/settings/auth/antigravity-risk");if(!M.ok)throw new Error("Failed to load power user mode setting");return(await M.json()).antigravityAckBypass===!0},[]),fe=c.useCallback(async({pendingMessage:M=null,disabledMessage:pe=null}={})=>{const nt=++te.current;x(!0),M!==null&&h(M);try{const Ue=await oe();return te.current!==nt||(y(Ue),pe?h(Ue?null:pe):M!==null&&h(null)),Ue}catch{return te.current!==nt||(y(!1),h(pe??b("addAccountDialog.powerUserLoadFailed")),ne.current||(ne.current=!0,B.error(b("addAccountDialog.powerUserLoadFailed")))),!1}finally{te.current===nt&&x(!1)}},[oe,b]),at=()=>{l(""),m(""),j(!1),h(null),k(""),S(it),y(!1),x(!1),I(Rt),T(""),z(""),O(Ot),G("oauth"),q(""),R(""),te.current+=1,ne.current=!1,Q.current=!1,a()};c.useEffect(()=>{t&&(k(""),S(it),h(null))},[s,t]),c.useEffect(()=>()=>{te.current+=1},[]),c.useEffect(()=>{if(!t||!ie){te.current+=1,y(!1),x(!1);return}fe()},[t,s,ie,fe]),c.useEffect(()=>{if(!t||s!=="agy"||!U.error||!C)return;const M=U.error.toLowerCase();(M.includes("agy_risk_ack_required")||M.includes("responsibility acknowledgement")||M.includes("responsibility checklist"))&&fe({pendingMessage:b("addAccountDialog.powerUserLoading"),disabledMessage:b("addAccountDialog.powerUserUnavailableRetry")})},[U.error,t,C,s,fe,b]),c.useEffect(()=>{!U.isAuthenticating&&!U.error&&U.provider===null&&t&&Q.current&&(Q.current=!1,(async()=>{try{const pe=await ht(s,void 0,i);pe.success&&pe.presetName&&d&&B.success(`Applied "${pe.presetName}" preset`)}catch{}at()})())},[U.isAuthenticating,U.error,U.provider]);const Tt=()=>{U.cancelAuth(),at()},Ns=async()=>{U.authUrl&&(await navigator.clipboard.writeText(U.authUrl),j(!0),setTimeout(()=>j(!1),2e3))},ys=()=>{r.trim()&&U.submitCallback(r.trim())},ks=()=>{if(be){h(b("addAccountDialog.powerUserLoading"));return}if(L&&!Te){h("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(v&&!Ee){h(`Type "${We}" to acknowledge the account safety warning before authenticating this provider.`);return}if(h(null),he&&!Le){h("IDC Start URL is required for Kiro IAM Identity Center login.");return}if(Z&&_==="pat"&&!F){h(b("addAccountDialog.gitlabPatRequired"));return}Q.current=!0,U.startAuth(s,{nickname:Oe||void 0,kiroMethod:$?g:void 0,kiroIDCStartUrl:he?Le:void 0,kiroIDCRegion:he&&_e?_e:void 0,kiroIDCFlow:he?P:void 0,gitlabAuthMode:Z?_:void 0,gitlabBaseUrl:Z&&Fe?Fe:void 0,gitlabPersonalAccessToken:Z&&_==="pat"&&F?F:void 0,flowType:$?Me:void 0,startEndpoint:$?tt:Z&&_==="pat"?"start":void 0,riskAcknowledgement:L?{version:Pa,reviewedIssue509:D.reviewedIssue509,understandsBanRisk:D.understandsBanRisk,acceptsFullResponsibility:D.acceptsFullResponsibility,typedPhrase:D.typedPhrase}:void 0})},ws=()=>{Q.current=!0,ae.mutate(void 0,{onSuccess:async()=>{const M=await ht("kiro",void 0,i);M.success&&M.presetName&&d&&B.success(`Applied "${M.presetName}" preset`),at()}})},Cs=M=>{M||Tt()},le=U.isAuthenticating;return e.jsx(jt,{open:t,onOpenChange:Cs,children:e.jsxs(bt,{className:"sm:max-w-md",onInteractOutside:M=>{le&&M.preventDefault()},children:[e.jsxs(Nt,{children:[e.jsx(yt,{children:b("addAccountDialog.title",{displayName:n})}),e.jsx(as,{children:b($?"addAccountDialog.descKiro":st?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[L&&!le&&e.jsx(rn,{value:D,onChange:M=>{S(M),h(null)},disabled:re}),ie&&C&&!le&&e.jsxs("div",{className:"rounded-lg border border-amber-400/35 bg-amber-50/70 p-3 text-xs text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/25 dark:text-amber-100",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-semibold",children:[e.jsx(ds,{className:"h-3.5 w-3.5"}),b("addAccountDialog.powerUserEnabled")]}),b("addAccountDialog.powerUserSkipped")]}),v&&!le&&e.jsx(ft,{showAcknowledgement:!0,acknowledgementPhrase:We,acknowledgementText:E,onAcknowledgementTextChange:M=>{k(M),h(null)},disabled:re}),$&&!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:b("addAccountDialog.authMethod")}),e.jsxs(ze,{value:g,onValueChange:M=>{I(M),h(null)},children:[e.jsx(Ge,{id:"kiro-auth-method",children:e.jsx(Be,{placeholder:b("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(Ve,{children:Fs.map(M=>e.jsx(ye,{value:M.id,children:M.label},M.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Re.description}),Ne&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If your browser does not return automatically after login, CCS can accept the final",e.jsx("span",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"kiro://..."}),"callback URL in the next step."]})]}),he&&!le&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(de,{id:"kiro-idc-start-url",value:u,onChange:M=>{T(M.target.value),h(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(de,{id:"kiro-idc-region",value:N,onChange:M=>{z(M.target.value),h(null)},placeholder:"us-east-1",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(ze,{value:P,onValueChange:M=>{O(M),h(null)},children:[e.jsx(Ge,{id:"kiro-idc-flow",children:e.jsx(Be,{placeholder:"{/* TODO i18n: missing key */}Select IDC flow"})}),e.jsxs(Ve,{children:[e.jsx(ye,{value:"authcode",children:"Authorization Code"}),e.jsx(ye,{value:"device",children:"Device Code"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auth Code opens a browser and may need the final callback URL pasted back. Device Code shows a verification code instead."})]})]}),Z&&!le&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-auth-mode",children:b("addAccountDialog.gitlabAuthMethod")}),e.jsxs(ze,{value:_,onValueChange:M=>{G(M),h(null)},children:[e.jsx(Ge,{id:"gitlab-auth-mode",children:e.jsx(Be,{placeholder:b("addAccountDialog.selectGitlabAuthMethod")})}),e.jsxs(Ve,{children:[e.jsx(ye,{value:"oauth",children:b("addAccountDialog.gitlabAuthOAuth")}),e.jsx(ye,{value:"pat",children:b("addAccountDialog.gitlabAuthPat")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabAuthHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-base-url",children:b("addAccountDialog.gitlabUrl")}),e.jsx(de,{id:"gitlab-base-url",value:V,onChange:M=>{q(M.target.value),h(null)},placeholder:b("addAccountDialog.gitlabUrlPlaceholder"),disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.gitlabUrlHint")})]}),_==="pat"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"gitlab-pat",children:b("addAccountDialog.gitlabPat")}),e.jsx(de,{id:"gitlab-pat",type:"password",value:A,onChange:M=>{R(M.target.value),h(null)},placeholder:b("addAccountDialog.gitlabPatPlaceholder"),disabled:re}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b("addAccountDialog.gitlabPatHint")," ",e.jsx("span",{className:"font-mono",children:"api"})," and"," ",e.jsx("span",{className:"font-mono",children:"read_user"})," scopes."]})]})]}),!le&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:b("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(de,{id:"nickname",value:o,onChange:M=>{l(M.target.value),h(null)},placeholder:b("addAccountDialog.nicknamePlaceholder"),disabled:re,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:b("addAccountDialog.nicknameOptionalHint")})]}),le&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:U.isDeviceCodeFlow?b("addAccountDialog.deviceCodeHint"):Ne?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":b("addAccountDialog.browserHint")})]}),U.authUrl&&!U.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:b("addAccountDialog.openUrlLabel")}),e.jsxs("div",{className:"p-3 bg-muted rounded-md",children:[e.jsx("p",{className:"text-xs text-muted-foreground break-all font-mono line-clamp-3",children:U.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:Ns,children:p?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.copy")]})}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{if(!U.authUrl)return;const M=window.open(U.authUrl,"_blank");(!M||M.closed||typeof M.closed>"u")&&B.warning(b("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ke,{className:"w-3 h-3 mr-1"}),b("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:Ne?"Browser did not return? Paste the final kiro:// callback URL:":b("addAccountDialog.redirectPasteLabel")}),e.jsx(de,{id:"callback-url",value:r,onChange:M=>m(M.target.value),placeholder:Ne?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":b("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(K,{variant:"secondary",size:"sm",onClick:ys,disabled:!r.trim()||U.isSubmittingCallback,children:U.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1 animate-spin"}),b("addAccountDialog.submitting")]}):b("addAccountDialog.submitCallback")})]})]}),!U.authUrl&&!U.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:Ne?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":b("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),ae.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ce,{className:"w-4 h-4 inline mr-2 animate-spin"}),b("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:Tt,children:b("addAccountDialog.cancel")}),$&&!le&&e.jsx(K,{variant:"outline",onClick:ws,disabled:re,children:ae.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2 animate-spin"}),b("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Na,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.importFromIde")]})}),!le&&e.jsxs(K,{onClick:ks,disabled:re||be||L&&!Te||v&&!Ee,children:[e.jsx(ke,{className:"w-4 h-4 mr-2"}),b("addAccountDialog.authenticate")]})]})]})]})})}const dn=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function cn(t){const a=t?.env||{};return dn.filter(s=>!a[s]?.trim())}function un(t,a){const[s,n]=c.useState(null),[i,d]=c.useState(!1),o=gt(),{data:l,isLoading:r,refetch:m}=Qt({queryKey:["settings",t],queryFn:async()=>{const P=await fetch(`/api/settings/${t}/raw`);if(!P.ok){const O=t==="cursor"?`~/.ccs/cliproxy/providers/${t}.settings.json`:Je(t)?`~/.ccs/${t}.settings.json`:`~/.ccs/profiles/${t}/settings.json`;return{profile:t,settings:{env:{}},mtime:Date.now(),path:O}}return P.json()}}),p=l?.settings,j=c.useMemo(()=>s!==null?s:p?JSON.stringify(p,null,2):`{
|
|
2
|
+
"env": {}
|
|
3
|
+
}`,[s,p]),f=c.useCallback(P=>{n(P)},[]),h=c.useMemo(()=>{try{return JSON.parse(j)}catch{return p||{env:{}}}},[j,p]),E=h?.env?.ANTHROPIC_MODEL,k=h?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,D=h?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,S=h?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,C=c.useMemo(()=>Ks(h?.env||{}),[h]),y=c.useCallback((P,O)=>Hs(P,O,{supportsExtendedContext:_=>Ba(t,_,a)}),[a,t]),w=c.useCallback((P,O)=>{const _={...h?.env||{},[P]:O},G=Lt(P)?y(_,C):_;delete G.CCS_EXTENDED_CONTEXT;const V={...h,env:G};n(JSON.stringify(V,null,2))},[y,h,C]),x=c.useCallback(P=>{const O=h?.env||{},_=y(O,P);delete _.CCS_EXTENDED_CONTEXT;const G={...h,env:_};n(JSON.stringify(G,null,2))},[y,h]),g=c.useCallback(P=>{const O={...h?.env||{},...P},G=Object.keys(P).some(Lt)?y(O,C):O;delete G.CCS_EXTENDED_CONTEXT;const V={...h,env:G};n(JSON.stringify(V,null,2))},[y,h,C]),I=c.useMemo(()=>{try{return JSON.parse(j),!0}catch{return!1}},[j]),u=c.useMemo(()=>s===null?!1:s!==JSON.stringify(p,null,2),[s,p]),T=c.useMemo(()=>cn(h),[h]),N=Ss({mutationFn:async()=>{const P=JSON.parse(j),O=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:P,expectedMtime:l?.mtime})});if(O.status===409)throw new Error("CONFLICT");if(!O.ok)throw new Error("Failed to save");return O.json()},onSuccess:P=>{o.invalidateQueries({queryKey:["settings",t]}),n(null),P?.warning?B.success(me.t("settings.saved"),{description:P.warning}):B.success(me.t("settings.saved"))},onError:P=>{P.message==="CONFLICT"?d(!0):B.error(P.message)}}),z=async P=>{d(!1),P?(await m(),N.mutate()):n(null)};return{data:l,isLoading:r,refetch:m,rawJsonContent:j,rawJsonEdits:s,isRawJsonValid:I,hasChanges:u,currentSettings:h,currentModel:E,opusModel:k,sonnetModel:D,haikuModel:S,extendedContextEnabled:C,toggleExtendedContext:x,handleRawJsonChange:f,updateEnvValue:w,updateEnvValues:g,saveMutation:{mutate:()=>N.mutate(),isPending:N.isPending},conflictDialog:i,setConflictDialog:d,handleConflictResolve:z,missingRequiredFields:T}}const mn=/-(medium|high|xhigh|fast)$/i,pn=["medium","high","xhigh"];function xn(t){return t?.trim()??""}function Ze(t){let a=xn(t),s,n;for(let i=0;i<2;i+=1){const d=a.match(mn);if(!d?.[1])break;const o=d[1].toLowerCase();if(o==="fast"){if(n)break;n="fast"}else{if(s)break;s=o}a=a.slice(0,-d[0].length)}return{baseModel:a,effort:s,serviceTier:n}}function bs(t){return Ze(t).effort}function hn(t){return Ze(t).serviceTier}function fn(t){return Ze(t).baseModel}function Bt(t,a){const s=Ze(t),n=s.baseModel;return!n||!a?s.serviceTier?`${n}-${s.serviceTier}`:n:[n,a,s.serviceTier].filter(Boolean).join("-")}function gn(t,a,s=[]){if(!a){const o=bs(t);return[Bt(t,o)]}const n=fn(t),i=[],d=o=>{const l=o?Bt(n,o):n;i.push(l);for(const r of s)i.push(`${l}-${r}`)};d(void 0);for(const o of pn)if(d(o),o===a)break;return i}function vn(t,a){if(!t)return null;const s=bs(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function jn({label:t}){return e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function Ke({modelId:t}){const a=vn(t);return a?e.jsx(H,{variant:a.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:a.label}):null}function He({modelId:t}){const a=hn(t);return a?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:a}):null}function Vt(t,a){if(!t)return"";if(!a?.prefix)return t;const s=`${a.prefix}/`;return t.startsWith(s)?t.slice(s.length):t}function qe(t,a){return a?.recommendedModelId??t}function dt(t,a,s,n){return n?gn(s,t,a):[s]}function je({label:t,description:a,value:s,onChange:n,catalog:i,allModels:d,routing:o,disabled:l}){const{t:r}=W(),m=i?.provider==="codex",p=c.useMemo(()=>It(i,d),[d,i]),j=c.useMemo(()=>Ga(i?.provider??"",i,d),[d,i]),f=new Set(p.map(x=>x.id)),h=c.useMemo(()=>new Map((o?.models??[]).map(x=>[x.modelId.toLowerCase(),x])),[o]),E=c.useMemo(()=>new Set(p.flatMap(x=>dt(x.codexMaxEffort,x.codexServiceTiers,qe(x.id,h.get(x.id.toLowerCase())),m))),[m,p,h]),k=c.useMemo(()=>h.get(Vt(s,o).toLowerCase()),[o,h,s]),D=p.flatMap(x=>{const g=h.get(x.id.toLowerCase());return dt(x.codexMaxEffort,x.codexServiceTiers,qe(x.id,g),m).map(u=>({value:u,groupKey:"recommended",searchText:`${u} ${x.id} ${x.name} ${g?.recommendedModelId??""}`,keywords:[x.tier??"",i?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),g?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:g.prefix}):null,m&&e.jsx(Ke,{modelId:u}),m&&e.jsx(He,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),x.tier==="paid"&&e.jsx(jn,{label:r("providerModelSelector.paid")}),g?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,g?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,m&&e.jsx(Ke,{modelId:u}),m&&e.jsx(He,{modelId:u})]})}))}),S=j.filter(x=>!f.has(x.id)).filter(x=>!E.has(qe(x.id,h.get(x.id.toLowerCase())))).flatMap(x=>{const g=h.get(x.id.toLowerCase());return dt(void 0,void 0,qe(x.id,g),m).map(u=>({value:u,groupKey:"all",searchText:`${u} ${x.id} ${g?.recommendedModelId??""}`,keywords:[x.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),g?.pinnedAvailable?e.jsx(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:g.prefix}):null,m&&e.jsx(Ke,{modelId:u}),m&&e.jsx(He,{modelId:u})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u}),g?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,g?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,m&&e.jsx(Ke,{modelId:u}),m&&e.jsx(He,{modelId:u})]})}))}),C=!!s&&!D.some(x=>x.value===s)&&!S.some(x=>x.value===s),y=s?{value:s,groupKey:"current",searchText:s,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]})}:null,w=D.length+S.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ia,{value:s||void 0,onChange:n,disabled:l,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(w?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...C&&y?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.currentValue")})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},...S.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:S.length})})}]:[]],options:[...C&&y?[y]:[],...D,...S]}),k?e.jsxs("div",{className:X("rounded-md border px-2.5 py-2 text-[11px]",k.unprefixedStatus==="safe"?"border-border/70 bg-muted/25 text-muted-foreground":"border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100"),children:[e.jsxs("div",{className:"font-medium",children:[k.pinnedAvailable?r("providerModelSelector.preferredPinnedModel"):r("providerModelSelector.pinnedRouteStatus")," ",e.jsx("code",{children:k.pinnedAvailable?k.recommendedModelId:k.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:k.summary})]}):null,s&&!k&&Vt(s,o)!==s?e.jsx("div",{className:"rounded-md border border-amber-300/60 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100",children:r("providerModelSelector.pinnedModelNotAdvertised",{model:s})}):null]})}function $t(t,a){const s=n=>a?.models.find(d=>d.modelId.toLowerCase()===n.toLowerCase())?.recommendedModelId??n;return{default:s(t.default),opus:s(t.opus),sonnet:s(t.sonnet),haiku:s(t.haiku)}}function bn({open:t,onClose:a,currentValues:s,onApply:n,onSave:i,isSaving:d,catalog:o,allModels:l,routing:r}){const{t:m}=W(),[p,j]=c.useState($t(s,r)),[f,h]=c.useState(""),E=k=>{k?(j($t(s,r)),h("")):a()};return e.jsx(jt,{open:t,onOpenChange:E,children:e.jsxs(bt,{className:"sm:max-w-md",children:[e.jsx(Nt,{children:e.jsxs(yt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),m("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:m("customPresetDialog.presetNameOptional")}),e.jsx(de,{id:"preset-name",value:f,onChange:k=>h(k.target.value),placeholder:m("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Pt,{}),o?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[m("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",m("customPresetDialog.codexTipSuffix")]}),e.jsx(je,{label:m("customPresetDialog.defaultModel"),description:m("customPresetDialog.defaultModelDesc"),value:p.default,onChange:k=>j({...p,default:k}),catalog:o,allModels:l,routing:r}),e.jsx(je,{label:m("customPresetDialog.opusModel"),description:m("customPresetDialog.opusModelDesc"),value:p.opus,onChange:k=>j({...p,opus:k}),catalog:o,allModels:l,routing:r}),e.jsx(je,{label:m("customPresetDialog.sonnetModel"),description:m("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:k=>j({...p,sonnet:k}),catalog:o,allModels:l,routing:r}),e.jsx(je,{label:m("customPresetDialog.haikuModel"),description:m("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:k=>j({...p,haiku:k}),catalog:o,allModels:l,routing:r})]}),e.jsxs(qs,{className:"gap-2 sm:gap-0",children:[e.jsx(K,{variant:"outline",onClick:a,children:m("customPresetDialog.cancel")}),i&&e.jsxs(K,{variant:"secondary",onClick:()=>i(p,f||void 0),disabled:d||!f.trim(),children:[d?e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(At,{className:"w-4 h-4 mr-1"}),m("customPresetDialog.savePreset")]}),e.jsxs(K,{onClick:()=>n(p,f||void 0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),m("customPresetDialog.applyPreset")]})]})]})})}function ve({label:t,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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(is,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Nn({provider:t,displayName:a,baseProvider:s,defaultTarget:n,data:i,authStatus:d,supportsModelConfig:o=!1}){const{t:l}=W(),r=n||"claude",m=r==="droid",p=t==="codex",j=s||d.provider||t,f=zs(j),h=r==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,E=`${h} --config`,k=`${h} --auth --add`,D=`${h} --accounts`;return e.jsx(kt,{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(cs,{className:"w-4 h-4"}),"Provider Information"]}),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:l("providerEditor.provider")}),e.jsx("span",{className:"font-mono",children:a})]}),i&&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:l("providerEditor.filePath")}),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:i.path}),e.jsx(is,{value:i.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:l("providerEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(i.mtime).toLocaleString()})]})]}),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:l("providerEditor.status")}),d.authenticated?e.jsxs(H,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(ya,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(H,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),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:l("providerEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]}),f&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-start",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:l("providerConfig.trackLabel")}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"font-mono",children:l(f.labelKey)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l(f.hintKey),Gs(j)?` ${l("providerConfig.plusTrackNote")}`:""]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:l("providerEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ve,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),p&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(ve,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(ve,{label:m?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(ve,{label:m?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${m?"claude":"droid"} "your prompt"`}),o&&e.jsx(ve,{label:r==="claude"?"Change model":"Change model (Claude target)",command:E}),e.jsx(ve,{label:r==="claude"?"Add account":"Add account (Claude target)",command:k}),e.jsx(ve,{label:r==="claude"?"List accounts":"List accounts (Claude target)",command:D}),r!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function yn(t){const a=t.replace(/\\/g,"/"),n=a.lastIndexOf("/cliproxy/providers/");return n!==-1?a.slice(n+1):a.replace(/^.*\//,"")}function kn({displayName:t,logoProvider:a,provider:s,data:n,isLoading:i,hasChanges:d,isRawJsonValid:o,isSaving:l,isRemoteMode:r,port:m,onRefetch:p,onSave:j}){const{t:f}=W();return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wt,{provider:a||s,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t}),r&&e.jsxs(H,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(us,{className:"w-3 h-3"}),"Remote"]}),m&&e.jsxs(H,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(ka,{className:"w-3 h-3"}),":",m]}),!r&&n?.path&&e.jsx(H,{variant:"outline",className:"text-xs",children:yn(n.path)})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[f("providerEditor.lastModified"),": ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:p,disabled:i,children:e.jsx(St,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(K,{size:"sm",onClick:j,disabled:l||!d||!o,children:l?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(wa,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function wn({models:t,provider:a,enabled:s,onToggle:n,disabled:i,className:d}){const{t:o}=W();if(t.length===0)return null;const l=t.some(p=>_t(p.id)),r=t.some(p=>!_t(p.id));let m="Compatible mappings stay on standard context unless you turn this on.";return l&&r?m="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":l&&(m="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:X("rounded-lg border p-3 space-y-2",s?"border-primary/50 bg-primary/5":"border-border bg-muted/30",d),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:X("w-4 h-4",s?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:o("extendedContext.extendedContext")}),e.jsx(H,{variant:s?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(rs,{checked:s,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(cs,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:m}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function Cn(t,a){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:a(s.default),ANTHROPIC_DEFAULT_OPUS_MODEL:a(s.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:a(s.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:a(s.haiku)}}function Sn({catalog:t,savedPresets:a,currentModel:s,opusModel:n,sonnetModel:i,haikuModel:d,providerModels:o,routing:l,provider:r,extendedContextEnabled:m,onExtendedContextToggle:p,onApplyPreset:j,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:E,isDeletePending:k}){const{t:D}=W(),S=(l?.models??[]).some(u=>u.pinnedAvailable),C=c.useMemo(()=>new Map((l?.models??[]).map(u=>[u.modelId.toLowerCase(),u])),[l]),y=u=>C.get(u.toLowerCase())?.recommendedModelId??u,w=c.useMemo(()=>{if(!t)return[];const u=[s,n,i,d].filter(N=>!!N).map(N=>Bs(N));return[...new Set(u)].map(N=>js(t.provider,N,t)).filter(N=>!!N?.extendedContext)},[t,s,n,i,d]),x=c.useMemo(()=>It(t,o),[t,o]),g=c.useMemo(()=>{const u=x.filter(N=>N.presetMapping);return u.length===0?[]:u.some(N=>N.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:u.filter(N=>N.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:u.filter(N=>N.tier==="paid")}].filter(N=>N.models.length>0):[{key:"default",models:u.slice(0,4)}]},[x]),I=g.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[I&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:D("providerEditor.presets")}),e.jsxs("div",{className:"space-y-4",children:[g.map(u=>e.jsxs("div",{children:["label"in u&&u.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(H,{variant:"outline",className:u.badgeClassName,children:u.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.models.map(T=>e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>j(Cn(T,y)),children:[e.jsx(Ie,{className:`w-3 h-3 ${"iconClassName"in u?u.iconClassName:""}`}),T.name]},T.id))})]},u.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.map(u=>e.jsxs("div",{className:"group relative",children:[e.jsxs(K,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{j({ANTHROPIC_MODEL:y(u.default),ANTHROPIC_DEFAULT_OPUS_MODEL:y(u.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:y(u.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:y(u.haiku)})},children:[e.jsx(At,{className:"w-3 h-3 fill-current"}),u.name]}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:T=>{T.stopPropagation(),E(u.name)},disabled:k,children:e.jsx(Mt,{className:"w-3 h-3"})})]},u.name)),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:h,children:[e.jsx(ms,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Pt,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:D("providerEditor.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),l?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:S?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[l.prefix,"/"]})," prefix. Unprefixed names can still resolve to a different backend when providers overlap."]}):e.jsxs(e.Fragment,{children:["Managed pinning for ",e.jsxs("code",{children:[l.prefix,"/"]})," is not currently advertised by the proxy. Unprefixed names may still be ambiguous until prefix repair completes."]})}):null,r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. ",e.jsx("code",{children:"-fast"})," enables the Codex fast service tier on models that support it, including combined forms such as ",e.jsx("code",{children:"gpt-5.4-high-fast"}),"."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:u=>f("ANTHROPIC_MODEL",u),catalog:t,allModels:o,routing:l}),w.length>0&&p&&e.jsx(wn,{models:w,provider:r,enabled:m??!1,onToggle:p}),e.jsx(je,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:u=>f("ANTHROPIC_DEFAULT_OPUS_MODEL",u),catalog:t,allModels:o,routing:l}),e.jsx(je,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:u=>f("ANTHROPIC_DEFAULT_SONNET_MODEL",u),catalog:t,allModels:o,routing:l}),e.jsx(je,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d,onChange:u=>f("ANTHROPIC_DEFAULT_HAIKU_MODEL",u),catalog:t,allModels:o,routing:l})]})]})]})}function An(t,a,s){return t?e.jsx(ct,{children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Sa,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:X("font-mono max-w-[180px] truncate",a&&vt),title:t,children:t})]})}),e.jsx(pt,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s("providerEditor.gcpProjectIdReadonly")})})]})}):e.jsx(ct,{children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Xe,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:s("providerEditor.projectIdNA")})]})}),e.jsx(pt,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:s("providerEditor.missingProjectId")}),e.jsx("p",{children:s("providerEditor.missingProjectIdHint")})]})})]})})}function Mn({account:t,onSetDefault:a,onRemove:s,onPauseToggle:n,isRemoving:i,isPausingAccount:d,privacyMode:o,showQuota:l,selectable:r,selected:m,onSelectChange:p}){const{t:j}=W(),f=t.provider.toLowerCase(),{data:h}=Vs(l),{data:E,isLoading:k}=$s(f,t.id,l),D=Ws(h,t)?.lastUsedAt,S=r||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r&&e.jsx("button",{type:"button",onClick:()=>p?.(!m),className:X("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",m?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":m?"Deselect account":"Select account",children:m&&e.jsx(we,{className:"w-3 h-3"})}),n&&e.jsx(ct,{children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!t.paused),disabled:d,children:d?e.jsx(ce,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(ps,{className:"w-4 h-4 text-emerald-500"}):e.jsx(xs,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(pt,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,C=e.jsxs(Qs,{children:[e.jsx(Js,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Ca,{className:"w-4 h-4"})})}),e.jsxs(Xs,{align:"end",children:[!t.isDefault&&e.jsxs(Ft,{onClick:a,children:[e.jsx(At,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Ft,{className:"text-destructive focus:text-destructive",onClick:s,disabled:i,children:[e.jsx(hs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:X("rounded-lg border p-3 transition-colors overflow-hidden",t.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",t.paused&&"opacity-75",m&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(Ys,{mode:"detailed",provider:t.provider,accountId:t.id,email:t.email,displayEmail:t.email||t.id,tokenFile:t.tokenFile,tier:t.tier,isDefault:t.isDefault,paused:t.paused,privacyMode:o,showQuota:l,quota:E,quotaLoading:k,runtimeLastUsed:D,beforeIdentity:S,headerEnd:C,bodySlot:t.provider==="agy"?An(t.projectId,o,j):null,quotaInsetClassName:"pl-11"})})}function Pn({selectedCount:t,onPauseSelected:a,onResumeSelected:s,onClearSelection:n,isPausing:i,isResuming:d}){if(t<1)return null;const o=i||d;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t," selected"]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:o,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:o,children:[i?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(xs,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:o,children:[d?e.jsx(ce,{className:"w-3 h-3 animate-spin"}):e.jsx(ps,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Dn({accounts:t,onAddAccount:a,onSetDefault:s,onRemoveAccount:n,onPauseToggle:i,onSoloMode:d,onBulkPause:o,onBulkResume:l,isRemovingAccount:r,isPausingAccount:m,isSoloingAccount:p,isBulkPausing:j,isBulkResuming:f,privacyMode:h,showQuota:E,isKiro:k,kiroNoIncognito:D,onKiroNoIncognitoChange:S,kiroSettingsLoading:C}){const{t:y}=W(),[w,x]=c.useState(new Set),g=c.useMemo(()=>new Set(t.map(A=>A.id)),[t]),I=c.useMemo(()=>new Set([...w].filter(A=>g.has(A))),[w,g]),u=!!(o&&l),T=I.size,N=t.length>0&&I.size===t.length,z=I.size>0&&I.size<t.length,P=c.useCallback(A=>{x(R=>{const b=new Set(R);return b.has(A)?b.delete(A):b.add(A),b})},[]),O=c.useCallback(()=>{x(new Set(t.map(A=>A.id)))},[t]),_=c.useCallback(()=>{x(new Set)},[]),G=c.useCallback(()=>{N?_():O()},[N,O,_]),V=c.useCallback(()=>{o&&I.size>0&&(o(Array.from(I)),x(new Set))},[o,I]),q=c.useCallback(()=>{l&&I.size>0&&(l(Array.from(I)),x(new Set))},[l,I]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[u&&t.length>0&&e.jsx(Qe,{checked:N,onCheckedChange:G,"aria-label":"Select all accounts",className:z?"data-[state=checked]:bg-primary/50":"",...z?{"data-state":"indeterminate"}:{}}),e.jsx(Pe,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(H,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(ms,{className:"w-3 h-3"}),"Add"]})]}),u&&T>0&&e.jsx(Pn,{selectedCount:T,onPauseSelected:V,onResumeSelected:q,onClearSelection:_,isPausing:!!j,isResuming:!!f}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(A=>e.jsx(Mn,{account:A,onSetDefault:()=>s(A.id),onRemove:()=>n(A.id),onPauseToggle:i?R=>i(A.id,R):void 0,onSoloMode:d?()=>d(A.id):void 0,isRemoving:r,isPausingAccount:m,isSoloingAccount:p,privacyMode:h,showQuota:E,selectable:u,selected:I.has(A.id),onSelectChange:()=>P(A.id)},A.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Pe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:y("providerEditor.noAccountsConnected")}),e.jsx("p",{className:"text-xs opacity-70",children:y("providerEditor.addAccountToStart")})]}),k&&S&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(us,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y("providerEditor.useIncognito")})]}),e.jsx(rs,{checked:!D,onCheckedChange:A=>S(!A),disabled:C,className:"scale-90"})]})})]})}function In({provider:t,catalog:a,savedPresets:s,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:o,providerModels:l,routing:r,extendedContextEnabled:m,onExtendedContextToggle:p,onApplyPreset:j,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:E,isDeletePending:k,accounts:D,onAddAccount:S,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:x,onBulkPause:g,onBulkResume:I,isRemovingAccount:u,isPausingAccount:T,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:O,isRemoteMode:_}){const G=t.toLowerCase(),V=(Zs.includes(G)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(G))&&!_,q=t==="kiro",[A,R]=c.useState(!0),[b,Q]=c.useState(!0),[te,ne]=c.useState(!1),U=c.useCallback(async()=>{if(q)try{Q(!0);const Z=(await $e.config.get()).cliproxy;R(Z?.kiro_no_incognito??!0)}catch{R(!0)}finally{Q(!1)}},[q]),ae=c.useCallback(async $=>{R($),ne(!0);try{const Z=await $e.config.get(),ie=Z.cliproxy??{};await $e.config.update({...Z,cliproxy:{...ie,kiro_no_incognito:$}})}catch{R(!$)}finally{ne(!1)}},[]);return c.useEffect(()=>{U()},[U]),e.jsx(kt,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Sn,{catalog:a,savedPresets:s,currentModel:n,opusModel:i,sonnetModel:d,haikuModel:o,providerModels:l,routing:r,provider:t,extendedContextEnabled:m,onExtendedContextToggle:p,onApplyPreset:j,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:E,isDeletePending:k}),e.jsx(Pt,{}),e.jsx(Dn,{accounts:D,onAddAccount:S,onSetDefault:C,onRemoveAccount:y,onPauseToggle:w,onSoloMode:x,onBulkPause:g,onBulkResume:I,isRemovingAccount:u,isPausingAccount:T,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:P,privacyMode:O,showQuota:V,isKiro:q,kiroNoIncognito:A,onKiroNoIncognitoChange:ae,kiroSettingsLoading:b||te})]})})}function Wt({provider:t,displayName:a,authStatus:s,catalog:n,routing:i,logoProvider:d,baseProvider:o,isRemoteMode:l,port:r,defaultTarget:m,topNotice:p,onAddAccount:j,onSetDefault:f,onRemoveAccount:h,onPauseToggle:E,onSoloMode:k,onBulkPause:D,onBulkResume:S,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:x,isBulkResuming:g}){const[I,u]=c.useState(!1),{privacyMode:T}=ss(),{t:N}=W(),{data:z}=ea(),{data:P}=ta(t),O=sa(),_=aa(),G=o||t,V=G.toLowerCase()==="agy",q=c.useMemo(()=>{const F=P?.presets||[];return V?F.filter(ee=>!ue(ee.default)&&!ue(ee.opus)&&!ue(ee.sonnet)&&!ue(ee.haiku)):F},[V,P?.presets]),A=c.useMemo(()=>{if(!z?.models)return[];const ee={gemini:["google"],agy:["antigravity"],codex:["openai"],cursor:["cursor"],gitlab:["gitlab","duo"],codebuddy:["codebuddy"],qwen:["alibaba","qwen"],iflow:["iflow"],kilo:["kilo"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[G.toLowerCase()]||[G.toLowerCase()];return z.models.filter(oe=>ee.some(fe=>oe.owned_by.toLowerCase().includes(fe))?V?!ue(oe.id):!0:!1)},[V,z,G]),R=(o||t).toLowerCase(),{data:b,isLoading:Q,refetch:te,rawJsonContent:ne,rawJsonEdits:U,isRawJsonValid:ae,hasChanges:$,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:L,extendedContextEnabled:be,toggleExtendedContext:Te,handleRawJsonChange:Ee,updateEnvValue:et,updateEnvValues:Re,saveMutation:he,conflictDialog:Ne,handleConflictResolve:Me,missingRequiredFields:tt}=un(t,n),st=c.useMemo(()=>(s.accounts||[]).map(F=>({...F,provider:F.provider||o||t})),[s.accounts,o,t]),{data:re}=Qt({queryKey:["auth-tokens-raw"],queryFn:async()=>{const F=await fetch("/api/settings/auth/tokens/raw");return F.ok?F.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Oe=re?.apiKey?.value??"ccs-internal-managed",Le=F=>{if(V&&[F.ANTHROPIC_MODEL,F.ANTHROPIC_DEFAULT_OPUS_MODEL,F.ANTHROPIC_DEFAULT_SONNET_MODEL,F.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(oe=>typeof oe=="string"&&ue(oe))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??xt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Oe,...F}),B.success(`Applied "${F.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},_e=(F,ee)=>{if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(fe=>ue(fe))){B.error(N("providerEditor.agyDenylist"));return}Re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??xt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Oe,ANTHROPIC_MODEL:F.default,ANTHROPIC_DEFAULT_OPUS_MODEL:F.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:F.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:F.haiku}),B.success(`Applied ${ee?`"${ee}"`:"custom"} preset`),u(!1)},Fe=(F,ee)=>{if(!ee){B.error(me.t("commonToast.enterPresetName"));return}if(V&&[F.default,F.opus,F.sonnet,F.haiku].some(oe=>ue(oe))){B.error(N("providerEditor.agyDenylist"));return}O.mutate({profile:t,data:{name:ee,...F}}),u(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(kn,{provider:t,displayName:a,logoProvider:d,data:b,isLoading:Q,hasChanges:$,isRawJsonValid:ae,isSaving:he.isPending,isRemoteMode:l,port:r,onRefetch:te,onSave:()=>he.mutate()}),p?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:p}):null,Q?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ce,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:N("providerEditor.loadingSettings")})]}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(na,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ia,{className:"w-full",children:[e.jsx(Ut,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Ut,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Kt,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(In,{provider:t,catalog:n,savedPresets:q,currentModel:Z,opusModel:ie,sonnetModel:v,haikuModel:L,providerModels:A,routing:i,extendedContextEnabled:be,onExtendedContextToggle:Te,onApplyPreset:Le,onUpdateEnvValue:et,onOpenCustomPreset:()=>u(!0),onDeletePreset:F=>_.mutate({profile:t,name:F}),isDeletePending:_.isPending,accounts:st,onAddAccount:j,onSetDefault:f,onRemoveAccount:h,onPauseToggle:E,onSoloMode:k,onBulkPause:D,onBulkResume:S,isRemovingAccount:C,isPausingAccount:y,isSoloingAccount:w,isBulkPausing:x,isBulkResuming:g,privacyMode:T,isRemoteMode:l})}),e.jsx(Kt,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Nn,{provider:t,displayName:a,baseProvider:o,defaultTarget:m,data:b,authStatus:s,supportsModelConfig:!!n})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 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(Aa,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[N("rawEditorSection.rawConfig")," (JSON)"]})]}),e.jsx(ra,{rawJsonContent:ne,isRawJsonValid:ae,rawJsonEdits:U,onRawJsonChange:Ee,profileEnv:b?.settings?.env,missingRequiredFields:tt})]})]}),e.jsx(Da,{open:Ne,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Me(!0),onCancel:()=>Me(!1)}),e.jsx(bn,{open:I,onClose:()=>u(!1),currentValues:{default:Z||"",opus:ie||"",sonnet:v||"",haiku:L||""},onApply:_e,onSave:Fe,isSaving:O.isPending,catalog:n,allModels:A,routing:i})]})}function Tn({status:t,isSelected:a,onSelect:s}){const{t:n}=W(),i=t.accounts?.length||0;return e.jsxs("button",{className:X("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:s,children:[e.jsx(wt,{provider:t.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:t.displayName}),i>0&&e.jsx(H,{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:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function En({variant:t,parentAuth:a,isSelected:s,onSelect:n,onDelete:i,isDeleting:d}){const{t:o}=W(),l=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:X("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:l,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),l())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(wt,{provider:t.provider,size:"sm"}),e.jsx(fs,{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:t.name}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:o("cliproxyPage.variant")}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:o("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),i()},disabled:d,children:e.jsx(hs,{className:"w-3 h-3"})})]})}function Rn({onSetup:t}){const{t:a}=W();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(Ie,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[a("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:a("cliproxyPage.controlPanel")}),"."]}),e.jsxs(K,{onClick:t,className:"gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),a("cliproxyPage.quickSetup")]})]})})}function Yn(){const{t}=W(),a=gt(),{data:s,isLoading:n}=es(),{data:i,isFetching:d}=oa(),{data:o}=ts(),{data:l}=la(),r=da(),m=ca(),p=ua(),j=ma(),f=pa(),h=xa(),E=ha(),k=fa(),[D,S]=c.useState(()=>{if(typeof window<"u"){const L=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return L&&Je(L)?L:localStorage.getItem("cliproxy-selected-provider")}return null}),[C,y]=c.useState(null),[w,x]=c.useState(!1),[g,I]=c.useState(()=>{if(typeof window>"u")return null;const v=new URLSearchParams(window.location.search),L=v.get("provider")?.trim().toLowerCase();return v.get("action")!=="auth"||!L||!Je(L)?null:{provider:L,displayName:ga(L),isFirstAccount:!1}}),u=c.useMemo(()=>s?.authStatus||[],[s?.authStatus]),T=c.useMemo(()=>va(u,v=>v.provider),[u]),N=s?.source==="remote",z=c.useMemo(()=>i?.variants||[],[i?.variants]),P=c.useMemo(()=>Dt(o?.catalogs),[o?.catalogs]),O=o?.routing??{},_=!!o,G=v=>{S(v),v&&localStorage.setItem("cliproxy-selected-provider",v)},V=c.useMemo(()=>C?null:D&&u.some(v=>v.provider===D)?D:u.length>0&&(u.find(L=>(L.accounts?.length||0)>0)?.provider||u[0]?.provider)||null,[D,C,u]),q=u.find(v=>v.provider===V),A=z.find(v=>v.name===C),R=A?u.find(v=>v.provider===A.provider):void 0,b=(A?.provider||q?.provider||"").toLowerCase().trim(),Q=b==="gemini"||b==="agy",te=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]}),a.invalidateQueries({queryKey:["cliproxy-catalog"]}),a.invalidateQueries({queryKey:["cliproxy-models"]})},ne=(v,L,be)=>{p.isPending||j.isPending||(be?p.mutate({provider:v,accountId:L}):j.mutate({provider:v,accountId:L}))},U=(v,L)=>{f.isPending||f.mutate({provider:v,accountId:L})},ae=(v,L)=>{h.isPending||h.mutate({provider:v,accountIds:L})},$=(v,L)=>{E.isPending||E.mutate({provider:v,accountIds:L})},Z=v=>{G(v),y(null)},ie=v=>{y(v),G(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",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(Ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:l?.backendLabel??"CLIProxy"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:te,disabled:d,children:e.jsx(St,{className:X("w-4 h-4",d&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(K,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>x(!0),children:[e.jsx(De,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]}),e.jsx(kt,{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:t("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(v=>e.jsx(ja,{className:"h-14 w-full rounded-lg"},v))}):e.jsx("div",{className:"space-y-4",children:T.map(v=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"px-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t(v.labelKey)}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:t(v.hintKey)})]}),e.jsx("div",{className:"space-y-1",children:v.items.map(L=>e.jsx(Tn,{status:L,isSelected:V===L.provider,onSelect:()=>Z(L.provider)},L.provider))})]},v.id))}),z.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(fs,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:z.map(v=>e.jsx(En,{variant:v,parentAuth:u.find(L=>L.provider===v.provider),isSelected:C===v.name,onSelect:()=>ie(v.name),onDelete:()=>k.mutate(v.name),isDeleting:k.isPending},v.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Ta,{})}),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:t("cliproxyPage.providerCount",{count:u.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:u.filter(v=>v.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:A&&R?e.jsx(e.Fragment,{children:e.jsx(Wt,{provider:A.name,displayName:t("cliproxyPage.variantDisplay",{name:A.name,provider:A.provider}),authStatus:R,catalog:P[A.provider],routing:O[A.provider],logoProvider:A.provider,baseProvider:A.provider,defaultTarget:A.target,isRemoteMode:N,port:A.port,topNotice:Q?e.jsx(ft,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:A.provider,displayName:R.displayName,isFirstAccount:(R.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:A.provider,accountId:v}),onRemoveAccount:v=>m.mutate({provider:A.provider,accountId:v}),onPauseToggle:(v,L)=>ne(A.provider,v,L),onSoloMode:v=>U(A.provider,v),onBulkPause:v=>ae(A.provider,v),onBulkResume:v=>$(A.provider,v),isRemovingAccount:m.isPending,isPausingAccount:p.isPending||j.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:E.isPending})}):q?e.jsx(e.Fragment,{children:e.jsx(Wt,{provider:q.provider,displayName:q.displayName,authStatus:q,catalog:P[q.provider],routing:O[q.provider],isRemoteMode:N,topNotice:Q?e.jsx(ft,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>I({provider:q.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:v=>r.mutate({provider:q.provider,accountId:v}),onRemoveAccount:v=>m.mutate({provider:q.provider,accountId:v}),onPauseToggle:(v,L)=>ne(q.provider,v,L),onSoloMode:v=>U(q.provider,v),onBulkPause:v=>ae(q.provider,v),onBulkResume:v=>$(q.provider,v),isRemovingAccount:m.isPending,isPausingAccount:p.isPending||j.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:E.isPending})}):e.jsx(Rn,{onSetup:()=>x(!0)})}),e.jsx(en,{open:w,onClose:()=>x(!1)}),e.jsx(ln,{open:g!==null,onClose:()=>I(null),provider:g?.provider||"",displayName:g?.displayName||"",catalog:_&&g?.provider?P[g.provider]:void 0,isFirstAccount:g?.isFirstAccount||!1})]})}export{Yn as CliproxyPage};
|