@kaitranntt/ccs 7.56.0-dev.2 → 7.56.0-dev.4
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/README.md +20 -11
- package/dist/bin/droid-runtime.d.ts +1 -0
- package/dist/bin/droid-runtime.d.ts.map +1 -0
- package/dist/bin/droid-runtime.js +5 -0
- package/dist/bin/droid-runtime.js.map +1 -0
- package/dist/commands/api-command/create-command.d.ts.map +1 -1
- package/dist/commands/api-command/create-command.js +8 -4
- package/dist/commands/api-command/create-command.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +12 -6
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +9 -7
- package/dist/commands/help-command.js.map +1 -1
- package/dist/targets/target-resolver.d.ts +2 -2
- package/dist/targets/target-resolver.d.ts.map +1 -1
- package/dist/targets/target-resolver.js +68 -18
- package/dist/targets/target-resolver.js.map +1 -1
- package/dist/ui/assets/{accounts-BikRyqcT.js → accounts-BSknYWh4.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CwEJfEUX.js → alert-dialog-BsXoK0Gt.js} +1 -1
- package/dist/ui/assets/api-C-ZXD7TW.js +4 -0
- package/dist/ui/assets/{auth-section-CrFrby6w.js → auth-section-CjGg1fit.js} +1 -1
- package/dist/ui/assets/{backups-section-CdMvSnSm.js → backups-section-fHW6gGBE.js} +1 -1
- package/dist/ui/assets/{checkbox-CC0rU-9-.js → checkbox-K93r237H.js} +1 -1
- package/dist/ui/assets/claude-extension-feiyhDgC.js +1 -0
- package/dist/ui/assets/{cliproxy-BSNSGNOv.js → cliproxy-CVv_-PsP.js} +2 -2
- package/dist/ui/assets/{cliproxy-ai-providers-D-U6NKfV.js → cliproxy-ai-providers-0JQCQ6YS.js} +12 -12
- package/dist/ui/assets/{cliproxy-control-panel-BCexyz40.js → cliproxy-control-panel-CrHA_sjo.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-Bee0kh6i.js → confirm-dialog-_wN3tR_n.js} +1 -1
- package/dist/ui/assets/{copilot-BZRAvPLD.js → copilot-Cao_05p3.js} +2 -2
- package/dist/ui/assets/cursor-Cbe1L5vq.js +1 -0
- package/dist/ui/assets/{droid-CcKqoQtO.js → droid-Cu3rERcX.js} +2 -2
- package/dist/ui/assets/{globalenv-section-CBRvmZbS.js → globalenv-section-CtzXlKoL.js} +1 -1
- package/dist/ui/assets/{health-DgrTQESI.js → health-CjuQlQLu.js} +1 -1
- package/dist/ui/assets/{index-BOhcsuQK.js → index-17YWpyV1.js} +1 -1
- package/dist/ui/assets/{index-D90gSn57.js → index-B4MTOnn6.js} +1 -1
- package/dist/ui/assets/index-CKpdevWy.css +1 -0
- package/dist/ui/assets/{index-DJCPwAoe.js → index-CtS8lmbp.js} +1 -1
- package/dist/ui/assets/{index-CursmDny.js → index-DRuiCZZ-.js} +1 -1
- package/dist/ui/assets/index-gjtWXRc2.js +47 -0
- package/dist/ui/assets/{proxy-status-widget-C8cOlsqE.js → proxy-status-widget-9CJglirI.js} +1 -1
- package/dist/ui/assets/{searchable-select-CF22qEzz.js → searchable-select-CGOND84a.js} +1 -1
- package/dist/ui/assets/{separator-CAoIlNuN.js → separator-2e8ySql0.js} +1 -1
- package/dist/ui/assets/{shared-zeFjETE6.js → shared-598yR3xg.js} +1 -1
- package/dist/ui/assets/{switch-BeqpDfK5.js → switch-BUqDuRxm.js} +1 -1
- package/dist/ui/assets/{updates-By9S46EJ.js → updates-CQW2-eYw.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +3 -2
- package/scripts/add-shebang.js +33 -20
- package/dist/ui/assets/api-BYSEdQYh.js +0 -4
- package/dist/ui/assets/claude-extension-CzGeZYz8.js +0 -1
- package/dist/ui/assets/cursor-CO2rCNKC.js +0 -1
- package/dist/ui/assets/index-kGiBvBM-.css +0 -1
- package/dist/ui/assets/index-sCtK1kDn.js +0 -47
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b0 as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-gjtWXRc2.js";import{u as K,a as J,b as V}from"./tanstack-B8i0evp-.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a4 as Pe,a3 as ke,L as U,aj as De,ai as Be,R as Ie,T as oe,aE as Te,a2 as Re}from"./icons-DR-ORtNe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function ce(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(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 me(s){return s?.state==="applied"}function Me({state:s}){const a=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(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&")}function o({label:s,value:a,mono:n=!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:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(o,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"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(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=c||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(c?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(ce(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!c&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!c&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}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(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:c?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"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:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),c?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),c?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"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:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!c,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"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(se,{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:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,c?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"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(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:c||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(oe,{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(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:c,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:c,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(o,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(o,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(o,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(o,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(o,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," 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.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"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:"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:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"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(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>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(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):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(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):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(de,{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(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{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(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Be,u as gs,b as $s}from"./tanstack-B8i0evp-.js";import{d as L,C as fs,b as js,c as V,P as Ae,a as Z,a8 as se,L as Y,I as le,r as vs,s as Ns,t as ys,v as bs,w as Ie,a9 as ws,aa as Qs,ab as zs,ac as Js,u as ks,ad as Ve,ae as Ge,af as $e,ag as Qe,ah as Cs,ai as as,aj as Ws,ak as Xs,W as As,al as Fe,am as Ss,Y as we,B,an as Ue,ao as ns,ap as Ys,aq as Zs,ar as et,as as st,x as Ps,n as ze,at as Je,m as tt,au as at,av as nt,aw as it,ax as rt,ay as ot,az as lt,aA as ct,aB as pe,T as he,p as ge,q as fe,aC as dt,aD as ut,aE as mt,aF as is,aG as xt,aH as pt,aI as ht,aJ as gt,aK as ft,aL as jt,aM as vt,Q as Nt,R as yt,U as rs,V as os,aN as bt,aO as wt,aP as kt,aQ as Ct,aR as At,aS as St,aT as Pt,aU as Mt,aV as Tt,aW as Dt,aX as Ot,aY as Et,S as _t}from"./index-sCtK1kDn.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as K}from"./notifications-B2HqRBj7.js";import{C as Ms,L as J,o as me,Q as Rt,l as ce,n as Ts,at as We,R as Xe,p as xe,a4 as ve,T as Se,a2 as Lt,au as Ds,as as It,av as Pe,Z as Ne,O as Os,h as Ft,t as Es,aw as Ut,aj as Ht,X as Ye,a3 as _s,m as Kt,x as qt,y as Rs,z as Ke,ax as Bt,u as ls,ay as Vt,ai as Ls,v as Gt,az as cs,am as $t,aA as Is}from"./icons-DR-ORtNe.js";import{R as ke,A as ds,D as _e,i as Qt,a as zt}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ce}from"./checkbox-CC0rU-9-.js";import{C as Jt}from"./confirm-dialog-Bee0kh6i.js";import{S as Ze}from"./separator-CAoIlNuN.js";import{S as Wt}from"./searchable-select-CF22qEzz.js";import{S as Fs}from"./switch-BeqpDfK5.js";import{P as Xt}from"./proxy-status-widget-C8cOlsqE.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CwEJfEUX.js";const je={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:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-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-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-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-5",models:[{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-6",name:"Claude Opus 4.6",description:"Latest 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"}]}},Re="ccs-internal-managed";async function Yt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function qe(s,t){const a=je[s];if(!a)return{success:!1};const i=a.models.find(l=>l.id===a.defaultModel)||a.models[0],r=i?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},p=await Yt(),c={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:p,ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:c})})).ok,presetName:i?.name||a.defaultModel}}catch{return{success:!1}}}function Zt({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=i?"bg-primary":"bg-muted"}`},a))})}function ea({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.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:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function sa({selectedProvider:s,providers:t,authCommand:a,isRefreshing:i,isPending:r,onBack:p,onStartAuth:x,onRefresh:c}){const[l,u]=o.useState(!1),g=async f=>{await navigator.clipboard.writeText(f),u(!0),setTimeout(()=>u(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(f=>f.id===s)?.name," to add an account"]}),e.jsx(L,{onClick:x,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Rt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(L,{variant:"outline",size:"icon",onClick:()=>g(a),children:l?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(Ts,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{variant:"ghost",onClick:p,disabled:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(L,{variant:"outline",onClick:c,disabled:i||r,children:[e.jsx(Xe,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),i?"Checking...":"Refresh Status"]})]})]})}function ta({accounts:s,privacyMode:t,onSelect:a,onAddNew:i,onBack:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>e.jsxs("button",{type:"button",onClick:()=>a(p),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(xe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:V("font-medium",t&&Ae),children:p.email||p.id}),p.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},p.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(L,{variant:"ghost",onClick:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const us="__custom__";function aa({selectedProvider:s,selectedAccount:t,variantName:a,modelName:i,isPending:r,privacyMode:p,onVariantNameChange:x,onModelChange:c,onBack:l,onSkip:u,onCreate:g}){const{t:f}=Z(),h=je[s]?.models||[],y=i&&!h.some(n=>n.id===i),[P,w]=o.useState(y),C=s==="agy"&&i.trim().length>0?se(i):!1,D=n=>{n===us?(w(!0),c("")):(w(!1),c(n))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(xe,{className:"w-4 h-4"}),e.jsxs("span",{children:[f("setupVariant.using")," ",e.jsx("span",{className:V(p&&Ae),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:f("setupVariant.variantNameRequired")}),e.jsx(le,{id:"variant-name",value:a,onChange:n=>x(n.target.value),placeholder:f("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[f("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:f("setupVariant.model")}),P?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{value:i,onChange:n=>c(n.target.value),placeholder:f("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{w(!1),s==="agy"&&se(i)&&c("")},children:f("setupVariant.choosePresetInstead")})]}):e.jsxs(vs,{value:h.some(n=>n.id===i)?i:"",onValueChange:D,children:[e.jsx(Ns,{children:e.jsx(ys,{placeholder:f("setupVariant.selectModel")})}),e.jsxs(bs,{children:[h.map(n=>e.jsx(Ie,{value:n.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:n.name}),n.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",n.description]})]})},n.id)),e.jsx(Ie,{value:us,children:e.jsx("span",{className:"text-primary",children:f("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:P?f("setupVariant.enterAnyModel"):f("setupVariant.defaultModel",{model:je[s]?.defaultModel||f("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(L,{variant:"ghost",onClick:l,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),f("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",onClick:u,children:f("setupVariant.skip")}),e.jsx(L,{onClick:g,disabled:!a||r||C,children:f(r?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:f("setupVariant.skipHint")})]})}function na({variantName:s,onClose:t}){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(ce,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(L,{onClick:t,className:"w-full",children:"Done"})]})}function ia({open:s,onClose:t}){const[a,i]=o.useState("provider"),[r,p]=o.useState(""),[x,c]=o.useState(null),[l,u]=o.useState(""),[g,f]=o.useState(""),[h,y]=o.useState(!1),[P,w]=o.useState(!1),{data:C,refetch:D}=ws(),n=Qs(),b=zs(),v=Js(),{privacyMode:F}=ks(),O=C?.authStatus.find(E=>E.provider===r),m=o.useMemo(()=>O?.accounts||[],[O?.accounts]);o.useEffect(()=>{if(!s){const E=setTimeout(()=>{i("provider"),p(""),c(null),u(""),f(""),w(!1)},0);return()=>clearTimeout(E)}},[s]),o.useEffect(()=>{if(a==="auth"&&m.length>0&&!P){const E=setTimeout(()=>{i("account")},0);return()=>clearTimeout(E)}},[a,m,P]);const S=async()=>{y(!0),await D(),y(!1)},N=()=>{const E=(O?.accounts?.length||0)===0;b.mutate({provider:r},{onSuccess:async R=>{if(E){const H=await qe(r);H.success&&H.presetName?K.success(`Applied "${H.presetName}" preset`):H.success||K.warning(As.t("commonToast.accountAddedPresetFailed"))}R.account&&(c(R.account),i("variant")),D()}})},k=E=>{p(E),(C?.authStatus.find(G=>G.provider===E)?.accounts||[]).length===0?i("auth"):i("account")},M=E=>{c(E),i("variant")},j=async()=>{if(!(!l||!r))try{await n.mutateAsync({name:l,provider:r,model:g||void 0,account:x?.id}),i("success")}catch(E){console.error("Failed to create variant:",E)}},A=`ccs ${r} --auth --add`,q=Xs(a),U=E=>{if(!E&&(b.isPending&&r&&v.mutate(r),a==="success"||a==="provider")){t();return}};return e.jsx(Ve,{open:s,onOpenChange:U,children:e.jsxs(Ge,{className:"sm:max-w-lg",onPointerDownOutside:E=>{a!=="success"&&a!=="provider"&&E.preventDefault()},onEscapeKeyDown:E=>{(b.isPending||n.isPending)&&E.preventDefault()},children:[e.jsxs($e,{children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Cs,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(ea,{providers:as,onSelect:k}),a==="auth"&&e.jsx(sa,{selectedProvider:r,providers:as,authCommand:A,isRefreshing:h,isPending:b.isPending,onBack:()=>i("provider"),onStartAuth:N,onRefresh:S}),a==="account"&&e.jsx(ta,{accounts:m,privacyMode:F,onSelect:M,onAddNew:()=>{w(!0),i("auth")},onBack:()=>i("provider")}),a==="variant"&&e.jsx(aa,{selectedProvider:r,selectedAccount:x,variantName:l,modelName:g,isPending:n.isPending,privacyMode:F,onVariantNameChange:u,onModelChange:f,onBack:()=>m.length>0?i("account"):i("provider"),onSkip:t,onCreate:j}),a==="success"&&e.jsx(na,{variantName:l,onClose:t})]}),e.jsx(Zt,{currentProgress:q,allSteps:Ws})]})})}const ra=3e3,oa=300*1e3,la=3;async function Le(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const oe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ca(){const[s,t]=o.useState(oe),a=o.useRef(0),i=o.useRef(null),r=o.useRef(null),p=o.useRef(0),x=o.useRef(0),c=o.useRef(!1),l=Be(),u=o.useCallback(w=>w===a.current,[]),g=o.useCallback(()=>{r.current&&(clearInterval(r.current),r.current=null),x.current=0},[]);o.useEffect(()=>()=>{i.current?.abort(),g(),c.current=!1},[g]);const f=o.useCallback(async(w,C,D)=>{if(u(D)){if(Date.now()-p.current>oa){g(),u(D)&&t(n=>({...n,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const n=await fetch(`/api/cliproxy/auth/${w}/status?state=${encodeURIComponent(C)}`);if(!u(D))return;const b=await n.json();if(x.current=0,b.status==="ok")g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${w} authentication successful`),c.current=!1,t(oe);else if(b.status==="auth_url"){const v=b.url||b.auth_url;v&&(t(F=>({...F,authUrl:v})),c.current||(c.current=!0,window.open(v,"_blank")))}else if(b.status==="device_code"){g();const v=b.user_code&&b.verification_url?`Open ${b.verification_url} and enter code: ${b.user_code}`:"Switch to Device Code method and try again.";K.error("Provider returned Device Code flow in callback mode"),t(F=>({...F,isAuthenticating:!1,error:v}))}else if(b.status==="error"){g();const v=b.error||"Authentication failed";K.error(v),t(F=>({...F,isAuthenticating:!1,error:v}))}}catch(n){if(!u(D)||(x.current+=1,x.current<la))return;g();const b=n instanceof Error&&n.message.trim().length>0?n.message:"Lost contact with the auth status endpoint";K.error(b),t(v=>({...v,isAuthenticating:!1,error:b}))}}},[u,l,g]),h=o.useCallback(async(w,C)=>{if(!Fe(w)){t({...oe,error:`Unknown provider: ${w}`});return}i.current?.abort(),g(),c.current=!1,x.current=0;const D=new AbortController,n=a.current+1;a.current=n,i.current=D;const v=(C?.flowType||(Ss(w)?"device_code":"authorization_code"))==="device_code",F=C?.startEndpoint||(v?"start":"start-url"),O={nickname:C?.nickname,kiroMethod:C?.kiroMethod,riskAcknowledgement:C?.riskAcknowledgement};t({provider:w,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:v});try{if(F==="start")fetch(`/api/cliproxy/auth/${w}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal}).then(async m=>{if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(m.ok&&N)l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),c.current=!1,t(oe);else{const k=typeof S.error=="string"?S.error:"Authentication failed";K.error(k),t(M=>({...M,isAuthenticating:!1,error:k}))}}).catch(m=>{if(!u(n)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${w}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal});if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(!m.ok||!N){const j=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(j)}const k=typeof S.authUrl=="string"?S.authUrl:null,M=typeof S.state=="string"?S.state:null;t(j=>({...j,authUrl:k,oauthState:M})),k&&(c.current=!0,window.open(k,"_blank")),M&&(p.current=Date.now(),r.current=setInterval(()=>{f(w,M,n)},ra))}}catch(m){if(!u(n))return;if(m instanceof Error&&m.name==="AbortError"){c.current=!1,t(oe);return}const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))}},[u,f,g,l]),y=o.useCallback(()=>{const w=s.provider;a.current+=1,i.current?.abort(),g(),c.current=!1,t(oe),w&&we.cliproxy.auth.cancel(w).catch(()=>{})},[s.provider,g]),P=o.useCallback(async w=>{if(!s.provider)return;const C=a.current,D=s.provider;t(n=>({...n,isSubmittingCallback:!0,error:null}));try{const n=await fetch(`/api/cliproxy/auth/${D}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:w})});if(!u(C))return;const b=await Le(n);if(!u(C))return;const v=b.success===!0,F=typeof b.account=="object"&&b.account!==null;if(n.ok&&v&&F)g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${D} authentication successful`),t(oe);else{const O=typeof b.error=="string"?b.error:v?"Authenticated account could not be registered":"Callback submission failed";throw new Error(O)}}catch(n){if(!u(C))return;const b=n instanceof Error?n.message:"Failed to submit callback";K.error(b),t(v=>({...v,isSubmittingCallback:!1,error:b}))}},[u,s.provider,l,g]);return o.useMemo(()=>({...s,startAuth:h,cancelAuth:y,submitCallback:P}),[s,h,y,P])}function Us({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=ke,acknowledgementText:i="",onAcknowledgementTextChange:r,disabled:p=!1,showProxySettingsLink:x=!1}){const{t:c}=Z(),l=c("accountSafetyWarning.title"),u=c("accountSafetyWarning.subtitle"),g=c("accountSafetyWarning.firstLine"),f=c("accountSafetyWarning.secondLine"),h="https://github.com/kaitranntt/ccs/issues/509",y=c("accountSafetyWarning.issueLabel"),P=c("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:V("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",s),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(Se,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})]}),e.jsx(B,{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:g}),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:[y,e.jsx(me,{className:"h-3.5 w-3.5"})]}),x&&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(Lt,{className:"h-3.5 w-3.5"}),P]}),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"})]}),t&&r&&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:a})]}),e.jsx(le,{id:"account-risk-ack-text",value:i,onChange:w=>r(w.target.value),placeholder:a,disabled:p,className:"mt-2 font-mono text-xs"})]})]})]})}function da({className:s,value:t,onChange:a,disabled:i=!1}){const{t:r}=Z(),p=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===ds].filter(Boolean).length,x=p/4*100,c=l=>{a({...t,...l})};return e.jsxs("section",{role:"alert",className:V("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",s),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(Se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:r("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("antigravityChecklist.subtitle")})]})]}),e.jsx(B,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:r("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:r("antigravityChecklist.completion")}),e.jsx("span",{children:r("antigravityChecklist.stepsCount",{current:p})})]}),e.jsx(Ue,{value:x,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(Ce,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:l=>c({reviewedIssue509:!!l}),disabled:i}),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(Ce,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:l=>c({understandsBanRisk:!!l}),disabled:i}),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(Ce,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:l=>c({acceptsFullResponsibility:!!l}),disabled:i}),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(le,{value:t.typedPhrase,onChange:l=>c({typedPhrase:l.target.value}),placeholder:ds,disabled:i,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(me,{className:"h-3.5 w-3.5"})]})})]})]})}function ua(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ma({open:s,onClose:t,provider:a,displayName:i,isFirstAccount:r=!1}){const[p,x]=o.useState(""),[c,l]=o.useState(""),[u,g]=o.useState(!1),[f,h]=o.useState(null),[y,P]=o.useState(""),[w,C]=o.useState(_e),[D,n]=o.useState(!1),[b,v]=o.useState(!1),[F,O]=o.useState(ns),{t:m}=Z(),S=o.useRef(!1),N=ca(),k=Ys(),M=a==="kiro",j=a==="gemini",A=a==="agy"&&!D,q=a==="agy"&&b,U=Qt(w),E=ua(y)===ke,R=Ss(a),H=Zs(F),G=M?H.flowType==="device_code":R,$=N.isAuthenticating||k.isPending,ae=p.trim(),ee=f||N.error,W=o.useCallback(async()=>{const T=await fetch("/api/settings/auth/antigravity-risk");if(!T.ok)throw new Error("Failed to load Antigravity power user setting");return(await T.json()).antigravityAckBypass===!0},[]),d=()=>{x(""),l(""),g(!1),h(null),P(""),C(_e),n(!1),v(!1),O(ns),S.current=!1,t()};o.useEffect(()=>{s&&(P(""),C(_e),h(null))},[a,s]),o.useEffect(()=>{let T=!1;if(!s||a!=="agy"){n(!1),v(!1);return}return(async()=>{try{v(!0);const ne=await W();T||n(ne)}catch{T||n(!1)}finally{T||v(!1)}})(),()=>{T=!0}},[W,s,a]),o.useEffect(()=>{if(!s||a!=="agy"||!N.error||!D)return;const T=N.error.toLowerCase();if(!(T.includes("agy_risk_ack_required")||T.includes("responsibility acknowledgement")||T.includes("responsibility checklist")))return;let ne=!1;return(async()=>{try{v(!0);const ye=await W();if(ne)return;n(ye),ye||h("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ne)return;n(!1),h("Power user mode is off. Complete the AGY checklist and retry.")}finally{ne||v(!1)}})(),()=>{ne=!0}},[D,N.error,W,s,a]),o.useEffect(()=>{!N.isAuthenticating&&!N.error&&N.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const te=await qe(a);te.success&&te.presetName&&r&&K.success(`Applied "${te.presetName}" preset`)}catch{}d()})())},[N.isAuthenticating,N.error,N.provider]);const _=()=>{N.cancelAuth(),d()},z=async()=>{N.authUrl&&(await navigator.clipboard.writeText(N.authUrl),g(!0),setTimeout(()=>g(!1),2e3))},de=()=>{c.trim()&&N.submitCallback(c.trim())},Me=()=>{if(q){h("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(A&&!U){h("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(j&&!E){h(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}h(null),S.current=!0,N.startAuth(a,{nickname:ae||void 0,kiroMethod:M?F:void 0,flowType:M?H.flowType:void 0,startEndpoint:M?H.startEndpoint:void 0,riskAcknowledgement:A?{version:zt,reviewedIssue509:w.reviewedIssue509,understandsBanRisk:w.understandsBanRisk,acceptsFullResponsibility:w.acceptsFullResponsibility,typedPhrase:w.typedPhrase}:void 0})},Te=()=>{S.current=!0,k.mutate(void 0,{onSuccess:async()=>{const T=await qe("kiro");T.success&&T.presetName&&r&&K.success(`Applied "${T.presetName}" preset`),d()}})},De=T=>{T||_()},X=N.isAuthenticating;return e.jsx(Ve,{open:s,onOpenChange:De,children:e.jsxs(Ge,{className:"sm:max-w-md",onInteractOutside:T=>{X&&T.preventDefault()},children:[e.jsxs($e,{children:[e.jsx(Qe,{children:m("addAccountDialog.title",{displayName:i})}),e.jsx(Cs,{children:m(M?"addAccountDialog.descKiro":G?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[A&&!X&&e.jsx(da,{value:w,onChange:T=>{C(T),h(null)},disabled:$}),a==="agy"&&D&&!X&&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"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),j&&!X&&e.jsx(Us,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:y,onAcknowledgementTextChange:T=>{P(T),h(null)},disabled:$}),M&&!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(vs,{value:F,onValueChange:T=>{O(T),h(null)},children:[e.jsx(Ns,{id:"kiro-auth-method",children:e.jsx(ys,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(bs,{children:et.map(T=>e.jsx(Ie,{value:T.id,children:T.label},T.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H.description})]}),!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(le,{id:"nickname",value:p,onChange:T=>{x(T.target.value),h(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:$,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("addAccountDialog.nicknameOptionalHint")})]}),X&&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(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),N.authUrl&&!N.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:m("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:N.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:z,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{if(!N.authUrl)return;const T=window.open(N.authUrl,"_blank");(!T||T.closed||typeof T.closed>"u")&&K.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(le,{id:"callback-url",value:c,onChange:T=>l(T.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(L,{variant:"secondary",size:"sm",onClick:de,disabled:!c.trim()||N.isSubmittingCallback,children:N.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!N.authUrl&&!N.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),k.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(L,{variant:"ghost",onClick:_,children:m("addAccountDialog.cancel")}),M&&!X&&e.jsx(L,{variant:"outline",onClick:Te,disabled:$,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!X&&e.jsxs(L,{onClick:Me,disabled:$||q||A&&!U||j&&!E,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const es="[1m]";function xa(s){return s.toLowerCase().startsWith("gemini-")}function ss(s){return s.toLowerCase().endsWith(es.toLowerCase())}function pa(s){return!s||ss(s)?s:`${s}${es}`}function Hs(s){return s&&(ss(s)?s.slice(0,-es.length):s)}const ms=["ANTHROPIC_MODEL"],ha=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function ga(s){const t=s?.env||{};return ha.filter(a=>!t[a]?.trim())}function fa(s){const[t,a]=o.useState(null),[i,r]=o.useState(!1),p=Be(),{data:x,isLoading:c,refetch:l}=gs({queryKey:["settings",s],queryFn:async()=>{const k=await fetch(`/api/settings/${s}/raw`);return k.ok?k.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),u=x?.settings,g=o.useMemo(()=>t!==null?t:u?JSON.stringify(u,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Be,u as gs,b as $s}from"./tanstack-B8i0evp-.js";import{d as L,C as fs,b as js,c as V,P as Ae,a as Z,a8 as se,L as Y,I as le,r as vs,s as Ns,t as ys,v as bs,w as Ie,a9 as ws,aa as Qs,ab as zs,ac as Js,u as ks,ad as Ve,ae as Ge,af as $e,ag as Qe,ah as Cs,ai as as,aj as Ws,ak as Xs,W as As,al as Fe,am as Ss,Y as we,B,an as Ue,ao as ns,ap as Ys,aq as Zs,ar as et,as as st,x as Ps,n as ze,at as Je,m as tt,au as at,av as nt,aw as it,ax as rt,ay as ot,az as lt,aA as ct,aB as pe,T as he,p as ge,q as fe,aC as dt,aD as ut,aE as mt,aF as is,aG as xt,aH as pt,aI as ht,aJ as gt,aK as ft,aL as jt,aM as vt,Q as Nt,R as yt,U as rs,V as os,aN as bt,aO as wt,aP as kt,aQ as Ct,aR as At,aS as St,aT as Pt,aU as Mt,aV as Tt,aW as Dt,aX as Ot,aY as Et,S as _t}from"./index-gjtWXRc2.js";import{C as He}from"./default-ports-1QQSffYX.js";import{t as K}from"./notifications-B2HqRBj7.js";import{C as Ms,L as J,o as me,Q as Rt,l as ce,n as Ts,at as We,R as Xe,p as xe,a4 as ve,T as Se,a2 as Lt,au as Ds,as as It,av as Pe,Z as Ne,O as Os,h as Ft,t as Es,aw as Ut,aj as Ht,X as Ye,a3 as _s,m as Kt,x as qt,y as Rs,z as Ke,ax as Bt,u as ls,ay as Vt,ai as Ls,v as Gt,az as cs,am as $t,aA as Is}from"./icons-DR-ORtNe.js";import{R as ke,A as ds,D as _e,i as Qt,a as zt}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ce}from"./checkbox-K93r237H.js";import{C as Jt}from"./confirm-dialog-_wN3tR_n.js";import{S as Ze}from"./separator-2e8ySql0.js";import{S as Wt}from"./searchable-select-CGOND84a.js";import{S as Fs}from"./switch-BUqDuRxm.js";import{P as Xt}from"./proxy-status-widget-9CJglirI.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BsXoK0Gt.js";const je={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:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-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-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-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-5",models:[{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-6",name:"Claude Opus 4.6",description:"Latest 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"}]}},Re="ccs-internal-managed";async function Yt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??Re:Re}catch{return Re}}async function qe(s,t){const a=je[s];if(!a)return{success:!1};const i=a.models.find(l=>l.id===a.defaultModel)||a.models[0],r=i?.presetMapping||{default:a.defaultModel,opus:a.defaultModel,sonnet:a.defaultModel,haiku:a.defaultModel},p=await Yt(),c={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${He}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:p,ANTHROPIC_MODEL:r.default,ANTHROPIC_DEFAULT_OPUS_MODEL:r.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:r.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:r.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:c})})).ok,presetName:i?.name||a.defaultModel}}catch{return{success:!1}}}function Zt({currentProgress:s,allSteps:t}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:t.map((a,i)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=i?"bg-primary":"bg-muted"}`},a))})}function ea({providers:s,onSelect:t}){return e.jsx("div",{className:"grid gap-2",children:s.map(a=>e.jsxs("button",{onClick:()=>t(a.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:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function sa({selectedProvider:s,providers:t,authCommand:a,isRefreshing:i,isPending:r,onBack:p,onStartAuth:x,onRefresh:c}){const[l,u]=o.useState(!1),g=async f=>{await navigator.clipboard.writeText(f),u(!0),setTimeout(()=>u(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",t.find(f=>f.id===s)?.name," to add an account"]}),e.jsx(L,{onClick:x,disabled:r,className:"w-full gap-2",size:"lg",children:r?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Rt,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(L,{variant:"outline",size:"icon",onClick:()=>g(a),children:l?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(Ts,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(L,{variant:"ghost",onClick:p,disabled:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(L,{variant:"outline",onClick:c,disabled:i||r,children:[e.jsx(Xe,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),i?"Checking...":"Refresh Status"]})]})]})}function ta({accounts:s,privacyMode:t,onSelect:a,onAddNew:i,onBack:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:s.map(p=>e.jsxs("button",{type:"button",onClick:()=>a(p),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(xe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:V("font-medium",t&&Ae),children:p.email||p.id}),p.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Ms,{className:"w-4 h-4 text-muted-foreground"})]},p.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:i,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(L,{variant:"ghost",onClick:r,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const us="__custom__";function aa({selectedProvider:s,selectedAccount:t,variantName:a,modelName:i,isPending:r,privacyMode:p,onVariantNameChange:x,onModelChange:c,onBack:l,onSkip:u,onCreate:g}){const{t:f}=Z(),h=je[s]?.models||[],y=i&&!h.some(n=>n.id===i),[P,w]=o.useState(y),C=s==="agy"&&i.trim().length>0?se(i):!1,D=n=>{n===us?(w(!0),c("")):(w(!1),c(n))};return e.jsxs("div",{className:"space-y-4",children:[t&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(xe,{className:"w-4 h-4"}),e.jsxs("span",{children:[f("setupVariant.using")," ",e.jsx("span",{className:V(p&&Ae),children:t.email||t.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:f("setupVariant.variantNameRequired")}),e.jsx(le,{id:"variant-name",value:a,onChange:n=>x(n.target.value),placeholder:f("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[f("setupVariant.invokeHintPrefix")," ccs ",a||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:f("setupVariant.model")}),P?e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{value:i,onChange:n=>c(n.target.value),placeholder:f("setupVariant.modelPlaceholder")}),C&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{w(!1),s==="agy"&&se(i)&&c("")},children:f("setupVariant.choosePresetInstead")})]}):e.jsxs(vs,{value:h.some(n=>n.id===i)?i:"",onValueChange:D,children:[e.jsx(Ns,{children:e.jsx(ys,{placeholder:f("setupVariant.selectModel")})}),e.jsxs(bs,{children:[h.map(n=>e.jsx(Ie,{value:n.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:n.name}),n.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",n.description]})]})},n.id)),e.jsx(Ie,{value:us,children:e.jsx("span",{className:"text-primary",children:f("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:P?f("setupVariant.enterAnyModel"):f("setupVariant.defaultModel",{model:je[s]?.defaultModel||f("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(L,{variant:"ghost",onClick:l,children:[e.jsx(We,{className:"w-4 h-4 mr-2"}),f("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",onClick:u,children:f("setupVariant.skip")}),e.jsx(L,{onClick:g,disabled:!a||r||C,children:f(r?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:f("setupVariant.skipHint")})]})}function na({variantName:s,onClose:t}){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(ce,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(fs,{children:e.jsxs(js,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(L,{onClick:t,className:"w-full",children:"Done"})]})}function ia({open:s,onClose:t}){const[a,i]=o.useState("provider"),[r,p]=o.useState(""),[x,c]=o.useState(null),[l,u]=o.useState(""),[g,f]=o.useState(""),[h,y]=o.useState(!1),[P,w]=o.useState(!1),{data:C,refetch:D}=ws(),n=Qs(),b=zs(),v=Js(),{privacyMode:F}=ks(),O=C?.authStatus.find(E=>E.provider===r),m=o.useMemo(()=>O?.accounts||[],[O?.accounts]);o.useEffect(()=>{if(!s){const E=setTimeout(()=>{i("provider"),p(""),c(null),u(""),f(""),w(!1)},0);return()=>clearTimeout(E)}},[s]),o.useEffect(()=>{if(a==="auth"&&m.length>0&&!P){const E=setTimeout(()=>{i("account")},0);return()=>clearTimeout(E)}},[a,m,P]);const S=async()=>{y(!0),await D(),y(!1)},N=()=>{const E=(O?.accounts?.length||0)===0;b.mutate({provider:r},{onSuccess:async R=>{if(E){const H=await qe(r);H.success&&H.presetName?K.success(`Applied "${H.presetName}" preset`):H.success||K.warning(As.t("commonToast.accountAddedPresetFailed"))}R.account&&(c(R.account),i("variant")),D()}})},k=E=>{p(E),(C?.authStatus.find(G=>G.provider===E)?.accounts||[]).length===0?i("auth"):i("account")},M=E=>{c(E),i("variant")},j=async()=>{if(!(!l||!r))try{await n.mutateAsync({name:l,provider:r,model:g||void 0,account:x?.id}),i("success")}catch(E){console.error("Failed to create variant:",E)}},A=`ccs ${r} --auth --add`,q=Xs(a),U=E=>{if(!E&&(b.isPending&&r&&v.mutate(r),a==="success"||a==="provider")){t();return}};return e.jsx(Ve,{open:s,onOpenChange:U,children:e.jsxs(Ge,{className:"sm:max-w-lg",onPointerDownOutside:E=>{a!=="success"&&a!=="provider"&&E.preventDefault()},onEscapeKeyDown:E=>{(b.isPending||n.isPending)&&E.preventDefault()},children:[e.jsxs($e,{children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Cs,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(ea,{providers:as,onSelect:k}),a==="auth"&&e.jsx(sa,{selectedProvider:r,providers:as,authCommand:A,isRefreshing:h,isPending:b.isPending,onBack:()=>i("provider"),onStartAuth:N,onRefresh:S}),a==="account"&&e.jsx(ta,{accounts:m,privacyMode:F,onSelect:M,onAddNew:()=>{w(!0),i("auth")},onBack:()=>i("provider")}),a==="variant"&&e.jsx(aa,{selectedProvider:r,selectedAccount:x,variantName:l,modelName:g,isPending:n.isPending,privacyMode:F,onVariantNameChange:u,onModelChange:f,onBack:()=>m.length>0?i("account"):i("provider"),onSkip:t,onCreate:j}),a==="success"&&e.jsx(na,{variantName:l,onClose:t})]}),e.jsx(Zt,{currentProgress:q,allSteps:Ws})]})})}const ra=3e3,oa=300*1e3,la=3;async function Le(s){const t=await s.text();if(!t)return{};try{return JSON.parse(t)}catch{const a=s.status>=400?`Request failed with status ${s.status}`:void 0;return a?{error:a}:{}}}const oe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ca(){const[s,t]=o.useState(oe),a=o.useRef(0),i=o.useRef(null),r=o.useRef(null),p=o.useRef(0),x=o.useRef(0),c=o.useRef(!1),l=Be(),u=o.useCallback(w=>w===a.current,[]),g=o.useCallback(()=>{r.current&&(clearInterval(r.current),r.current=null),x.current=0},[]);o.useEffect(()=>()=>{i.current?.abort(),g(),c.current=!1},[g]);const f=o.useCallback(async(w,C,D)=>{if(u(D)){if(Date.now()-p.current>oa){g(),u(D)&&t(n=>({...n,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const n=await fetch(`/api/cliproxy/auth/${w}/status?state=${encodeURIComponent(C)}`);if(!u(D))return;const b=await n.json();if(x.current=0,b.status==="ok")g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${w} authentication successful`),c.current=!1,t(oe);else if(b.status==="auth_url"){const v=b.url||b.auth_url;v&&(t(F=>({...F,authUrl:v})),c.current||(c.current=!0,window.open(v,"_blank")))}else if(b.status==="device_code"){g();const v=b.user_code&&b.verification_url?`Open ${b.verification_url} and enter code: ${b.user_code}`:"Switch to Device Code method and try again.";K.error("Provider returned Device Code flow in callback mode"),t(F=>({...F,isAuthenticating:!1,error:v}))}else if(b.status==="error"){g();const v=b.error||"Authentication failed";K.error(v),t(F=>({...F,isAuthenticating:!1,error:v}))}}catch(n){if(!u(D)||(x.current+=1,x.current<la))return;g();const b=n instanceof Error&&n.message.trim().length>0?n.message:"Lost contact with the auth status endpoint";K.error(b),t(v=>({...v,isAuthenticating:!1,error:b}))}}},[u,l,g]),h=o.useCallback(async(w,C)=>{if(!Fe(w)){t({...oe,error:`Unknown provider: ${w}`});return}i.current?.abort(),g(),c.current=!1,x.current=0;const D=new AbortController,n=a.current+1;a.current=n,i.current=D;const v=(C?.flowType||(Ss(w)?"device_code":"authorization_code"))==="device_code",F=C?.startEndpoint||(v?"start":"start-url"),O={nickname:C?.nickname,kiroMethod:C?.kiroMethod,riskAcknowledgement:C?.riskAcknowledgement};t({provider:w,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:v});try{if(F==="start")fetch(`/api/cliproxy/auth/${w}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal}).then(async m=>{if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(m.ok&&N)l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),c.current=!1,t(oe);else{const k=typeof S.error=="string"?S.error:"Authentication failed";K.error(k),t(M=>({...M,isAuthenticating:!1,error:k}))}}).catch(m=>{if(!u(n)||m instanceof Error&&m.name==="AbortError")return;const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))});else{const m=await fetch(`/api/cliproxy/auth/${w}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O),signal:D.signal});if(!u(n))return;const S=await Le(m);if(!u(n))return;const N=S.success===!0;if(!m.ok||!N){const j=typeof S.error=="string"?S.error:"Failed to start OAuth";throw new Error(j)}const k=typeof S.authUrl=="string"?S.authUrl:null,M=typeof S.state=="string"?S.state:null;t(j=>({...j,authUrl:k,oauthState:M})),k&&(c.current=!0,window.open(k,"_blank")),M&&(p.current=Date.now(),r.current=setInterval(()=>{f(w,M,n)},ra))}}catch(m){if(!u(n))return;if(m instanceof Error&&m.name==="AbortError"){c.current=!1,t(oe);return}const S=m instanceof Error?m.message:"Authentication failed";K.error(S),t(N=>({...N,isAuthenticating:!1,error:S}))}},[u,f,g,l]),y=o.useCallback(()=>{const w=s.provider;a.current+=1,i.current?.abort(),g(),c.current=!1,t(oe),w&&we.cliproxy.auth.cancel(w).catch(()=>{})},[s.provider,g]),P=o.useCallback(async w=>{if(!s.provider)return;const C=a.current,D=s.provider;t(n=>({...n,isSubmittingCallback:!0,error:null}));try{const n=await fetch(`/api/cliproxy/auth/${D}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:w})});if(!u(C))return;const b=await Le(n);if(!u(C))return;const v=b.success===!0,F=typeof b.account=="object"&&b.account!==null;if(n.ok&&v&&F)g(),l.invalidateQueries({queryKey:["cliproxy-auth"]}),l.invalidateQueries({queryKey:["account-quota"]}),K.success(`${D} authentication successful`),t(oe);else{const O=typeof b.error=="string"?b.error:v?"Authenticated account could not be registered":"Callback submission failed";throw new Error(O)}}catch(n){if(!u(C))return;const b=n instanceof Error?n.message:"Failed to submit callback";K.error(b),t(v=>({...v,isSubmittingCallback:!1,error:b}))}},[u,s.provider,l,g]);return o.useMemo(()=>({...s,startAuth:h,cancelAuth:y,submitCallback:P}),[s,h,y,P])}function Us({className:s,showAcknowledgement:t=!1,acknowledgementPhrase:a=ke,acknowledgementText:i="",onAcknowledgementTextChange:r,disabled:p=!1,showProxySettingsLink:x=!1}){const{t:c}=Z(),l=c("accountSafetyWarning.title"),u=c("accountSafetyWarning.subtitle"),g=c("accountSafetyWarning.firstLine"),f=c("accountSafetyWarning.secondLine"),h="https://github.com/kaitranntt/ccs/issues/509",y=c("accountSafetyWarning.issueLabel"),P=c("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:V("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",s),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(Se,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]})]}),e.jsx(B,{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:g}),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:[y,e.jsx(me,{className:"h-3.5 w-3.5"})]}),x&&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(Lt,{className:"h-3.5 w-3.5"}),P]}),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"})]}),t&&r&&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:a})]}),e.jsx(le,{id:"account-risk-ack-text",value:i,onChange:w=>r(w.target.value),placeholder:a,disabled:p,className:"mt-2 font-mono text-xs"})]})]})]})}function da({className:s,value:t,onChange:a,disabled:i=!1}){const{t:r}=Z(),p=[t.reviewedIssue509,t.understandsBanRisk,t.acceptsFullResponsibility,t.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===ds].filter(Boolean).length,x=p/4*100,c=l=>{a({...t,...l})};return e.jsxs("section",{role:"alert",className:V("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",s),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(Se,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:r("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("antigravityChecklist.subtitle")})]})]}),e.jsx(B,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:r("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:r("antigravityChecklist.completion")}),e.jsx("span",{children:r("antigravityChecklist.stepsCount",{current:p})})]}),e.jsx(Ue,{value:x,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(Ce,{id:"agy-step-reviewed-issue",checked:t.reviewedIssue509,onCheckedChange:l=>c({reviewedIssue509:!!l}),disabled:i}),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(Ce,{id:"agy-step-understands-risk",checked:t.understandsBanRisk,onCheckedChange:l=>c({understandsBanRisk:!!l}),disabled:i}),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(Ce,{id:"agy-step-accept-responsibility",checked:t.acceptsFullResponsibility,onCheckedChange:l=>c({acceptsFullResponsibility:!!l}),disabled:i}),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(le,{value:t.typedPhrase,onChange:l=>c({typedPhrase:l.target.value}),placeholder:ds,disabled:i,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(me,{className:"h-3.5 w-3.5"})]})})]})]})}function ua(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ma({open:s,onClose:t,provider:a,displayName:i,isFirstAccount:r=!1}){const[p,x]=o.useState(""),[c,l]=o.useState(""),[u,g]=o.useState(!1),[f,h]=o.useState(null),[y,P]=o.useState(""),[w,C]=o.useState(_e),[D,n]=o.useState(!1),[b,v]=o.useState(!1),[F,O]=o.useState(ns),{t:m}=Z(),S=o.useRef(!1),N=ca(),k=Ys(),M=a==="kiro",j=a==="gemini",A=a==="agy"&&!D,q=a==="agy"&&b,U=Qt(w),E=ua(y)===ke,R=Ss(a),H=Zs(F),G=M?H.flowType==="device_code":R,$=N.isAuthenticating||k.isPending,ae=p.trim(),ee=f||N.error,W=o.useCallback(async()=>{const T=await fetch("/api/settings/auth/antigravity-risk");if(!T.ok)throw new Error("Failed to load Antigravity power user setting");return(await T.json()).antigravityAckBypass===!0},[]),d=()=>{x(""),l(""),g(!1),h(null),P(""),C(_e),n(!1),v(!1),O(ns),S.current=!1,t()};o.useEffect(()=>{s&&(P(""),C(_e),h(null))},[a,s]),o.useEffect(()=>{let T=!1;if(!s||a!=="agy"){n(!1),v(!1);return}return(async()=>{try{v(!0);const ne=await W();T||n(ne)}catch{T||n(!1)}finally{T||v(!1)}})(),()=>{T=!0}},[W,s,a]),o.useEffect(()=>{if(!s||a!=="agy"||!N.error||!D)return;const T=N.error.toLowerCase();if(!(T.includes("agy_risk_ack_required")||T.includes("responsibility acknowledgement")||T.includes("responsibility checklist")))return;let ne=!1;return(async()=>{try{v(!0);const ye=await W();if(ne)return;n(ye),ye||h("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ne)return;n(!1),h("Power user mode is off. Complete the AGY checklist and retry.")}finally{ne||v(!1)}})(),()=>{ne=!0}},[D,N.error,W,s,a]),o.useEffect(()=>{!N.isAuthenticating&&!N.error&&N.provider===null&&s&&S.current&&(S.current=!1,(async()=>{try{const te=await qe(a);te.success&&te.presetName&&r&&K.success(`Applied "${te.presetName}" preset`)}catch{}d()})())},[N.isAuthenticating,N.error,N.provider]);const _=()=>{N.cancelAuth(),d()},z=async()=>{N.authUrl&&(await navigator.clipboard.writeText(N.authUrl),g(!0),setTimeout(()=>g(!1),2e3))},de=()=>{c.trim()&&N.submitCallback(c.trim())},Me=()=>{if(q){h("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(A&&!U){h("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(j&&!E){h(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}h(null),S.current=!0,N.startAuth(a,{nickname:ae||void 0,kiroMethod:M?F:void 0,flowType:M?H.flowType:void 0,startEndpoint:M?H.startEndpoint:void 0,riskAcknowledgement:A?{version:zt,reviewedIssue509:w.reviewedIssue509,understandsBanRisk:w.understandsBanRisk,acceptsFullResponsibility:w.acceptsFullResponsibility,typedPhrase:w.typedPhrase}:void 0})},Te=()=>{S.current=!0,k.mutate(void 0,{onSuccess:async()=>{const T=await qe("kiro");T.success&&T.presetName&&r&&K.success(`Applied "${T.presetName}" preset`),d()}})},De=T=>{T||_()},X=N.isAuthenticating;return e.jsx(Ve,{open:s,onOpenChange:De,children:e.jsxs(Ge,{className:"sm:max-w-md",onInteractOutside:T=>{X&&T.preventDefault()},children:[e.jsxs($e,{children:[e.jsx(Qe,{children:m("addAccountDialog.title",{displayName:i})}),e.jsx(Cs,{children:m(M?"addAccountDialog.descKiro":G?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[A&&!X&&e.jsx(da,{value:w,onChange:T=>{C(T),h(null)},disabled:$}),a==="agy"&&D&&!X&&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"}),m("addAccountDialog.powerUserEnabled")]}),m("addAccountDialog.powerUserSkipped")]}),j&&!X&&e.jsx(Us,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:y,onAcknowledgementTextChange:T=>{P(T),h(null)},disabled:$}),M&&!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:m("addAccountDialog.authMethod")}),e.jsxs(vs,{value:F,onValueChange:T=>{O(T),h(null)},children:[e.jsx(Ns,{id:"kiro-auth-method",children:e.jsx(ys,{placeholder:m("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(bs,{children:et.map(T=>e.jsx(Ie,{value:T.id,children:T.label},T.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H.description})]}),!X&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:m("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(le,{id:"nickname",value:p,onChange:T=>{x(T.target.value),h(null)},placeholder:m("addAccountDialog.nicknamePlaceholder"),disabled:$,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("addAccountDialog.nicknameOptionalHint")})]}),X&&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(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.isDeviceCodeFlow?m("addAccountDialog.deviceCodeHint"):m("addAccountDialog.browserHint")})]}),N.authUrl&&!N.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:m("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:N.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:z,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.copy")]})}),e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{if(!N.authUrl)return;const T=window.open(N.authUrl,"_blank");(!T||T.closed||typeof T.closed>"u")&&K.warning(m("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),m("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:m("addAccountDialog.redirectPasteLabel")}),e.jsx(le,{id:"callback-url",value:c,onChange:T=>l(T.target.value),placeholder:m("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(L,{variant:"secondary",size:"sm",onClick:de,disabled:!c.trim()||N.isSubmittingCallback,children:N.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3 h-3 mr-1 animate-spin"}),m("addAccountDialog.submitting")]}):m("addAccountDialog.submitCallback")})]})]}),!N.authUrl&&!N.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:m("addAccountDialog.preparingUrl")})]}),ee&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ee}),k.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(J,{className:"w-4 h-4 inline mr-2 animate-spin"}),m("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(L,{variant:"ghost",onClick:_,children:m("addAccountDialog.cancel")}),M&&!X&&e.jsx(L,{variant:"outline",onClick:Te,disabled:$,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-2 animate-spin"}),m("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(It,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.importFromIde")]})}),!X&&e.jsxs(L,{onClick:Me,disabled:$||q||A&&!U||j&&!E,children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),m("addAccountDialog.authenticate")]})]})]})]})})}const es="[1m]";function xa(s){return s.toLowerCase().startsWith("gemini-")}function ss(s){return s.toLowerCase().endsWith(es.toLowerCase())}function pa(s){return!s||ss(s)?s:`${s}${es}`}function Hs(s){return s&&(ss(s)?s.slice(0,-es.length):s)}const ms=["ANTHROPIC_MODEL"],ha=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function ga(s){const t=s?.env||{};return ha.filter(a=>!t[a]?.trim())}function fa(s){const[t,a]=o.useState(null),[i,r]=o.useState(!1),p=Be(),{data:x,isLoading:c,refetch:l}=gs({queryKey:["settings",s],queryFn:async()=>{const k=await fetch(`/api/settings/${s}/raw`);return k.ok?k.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),u=x?.settings,g=o.useMemo(()=>t!==null?t:u?JSON.stringify(u,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
|
-
}`,[t,u]),f=o.useCallback(k=>{a(k)},[]),h=o.useMemo(()=>{try{return JSON.parse(g)}catch{return u||{env:{}}}},[g,u]),y=h?.env?.ANTHROPIC_MODEL,P=h?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=h?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,C=h?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,D=o.useMemo(()=>{const k=h?.env||{};return ms.some(M=>{const j=k[M];return j&&ss(j)})},[h]),n=o.useCallback((k,M)=>{const j={...h?.env||{},[k]:M},A={...h,env:j};a(JSON.stringify(A,null,2))},[h]),b=o.useCallback(k=>{const M=h?.env||{},j={};for(const U of ms){const E=M[U];E&&(j[U]=k?pa(E):Hs(E))}const A={...M,...j};delete A.CCS_EXTENDED_CONTEXT;const q={...h,env:A};a(JSON.stringify(q,null,2))},[h]),v=o.useCallback(k=>{const M={...h?.env||{},...k},j={...h,env:M};a(JSON.stringify(j,null,2))},[h]),F=o.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),O=o.useMemo(()=>t===null?!1:t!==JSON.stringify(u,null,2),[t,u]),m=o.useMemo(()=>ga(h),[h]),S=$s({mutationFn:async()=>{const k=JSON.parse(g),M=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:k,expectedMtime:x?.mtime})});if(M.status===409)throw new Error("CONFLICT");if(!M.ok)throw new Error("Failed to save");return M.json()},onSuccess:k=>{p.invalidateQueries({queryKey:["settings",s]}),a(null),k?.warning?K.success("Settings saved",{description:k.warning}):K.success("Settings saved")},onError:k=>{k.message==="CONFLICT"?r(!0):K.error(k.message)}}),N=async k=>{r(!1),k?(await l(),S.mutate()):a(null)};return{data:x,isLoading:c,refetch:l,rawJsonContent:g,rawJsonEdits:t,isRawJsonValid:F,hasChanges:O,currentSettings:h,currentModel:y,opusModel:P,sonnetModel:w,haikuModel:C,extendedContextEnabled:D,toggleExtendedContext:b,handleRawJsonChange:f,updateEnvValue:n,updateEnvValues:v,saveMutation:{mutate:()=>S.mutate(),isPending:S.isPending},conflictDialog:i,setConflictDialog:r,handleConflictResolve:N,missingRequiredFields:m}}const ja=/-(medium|high|xhigh)$/i;function va(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function Na(s){if(!s)return null;const t=va(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function be({modelId:s}){const t=Na(s);return t?e.jsx(B,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function re({label:s,description:t,value:a,onChange:i,catalog:r,allModels:p,disabled:x}){const{t:c}=Z(),l=new Set(r?.models.map(y=>y.id)||[]),u=r?.provider==="codex",g=(r?.models??[]).map(y=>({value:y.id,groupKey:"recommended",searchText:`${y.id} ${y.name}`,keywords:[y.tier??"",r?.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:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),y.tier==="paid"&&e.jsx(ya,{label:c("providerModelSelector.paid")}),u&&e.jsx(be,{modelId:y.id})]})})),f=p.filter(y=>!l.has(y.id)).map(y=>({value:y.id,groupKey:"all",searchText:y.id,keywords:[y.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:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),u&&e.jsx(be,{modelId:y.id})]})})),h=g.length+f.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:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(Wt,{value:a||void 0,onChange:i,disabled:x,placeholder:c("providerModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c(h?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:c("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:c("providerModelSelector.allModelsCount",{count:p.length})})}],options:[...g,...f]})]})}function ba({open:s,onClose:t,currentValues:a,onApply:i,onSave:r,isSaving:p,catalog:x,allModels:c}){const{t:l}=Z(),[u,g]=o.useState(a),[f,h]=o.useState(""),y=P=>{P?(g(a),h("")):t()};return e.jsx(Ve,{open:s,onOpenChange:y,children:e.jsxs(Ge,{className:"sm:max-w-md",children:[e.jsx($e,{children:e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),l("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:l("customPresetDialog.presetNameOptional")}),e.jsx(le,{id:"preset-name",value:f,onChange:P=>h(P.target.value),placeholder:l("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Ze,{}),x?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[l("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",l("customPresetDialog.codexTipSuffix")]}),e.jsx(re,{label:l("customPresetDialog.defaultModel"),description:l("customPresetDialog.defaultModelDesc"),value:u.default,onChange:P=>g({...u,default:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.opusModel"),description:l("customPresetDialog.opusModelDesc"),value:u.opus,onChange:P=>g({...u,opus:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.sonnetModel"),description:l("customPresetDialog.sonnetModelDesc"),value:u.sonnet,onChange:P=>g({...u,sonnet:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.haikuModel"),description:l("customPresetDialog.haikuModelDesc"),value:u.haiku,onChange:P=>g({...u,haiku:P}),catalog:x,allModels:c})]}),e.jsxs(st,{className:"gap-2 sm:gap-0",children:[e.jsx(L,{variant:"outline",onClick:t,children:l("customPresetDialog.cancel")}),r&&e.jsxs(L,{variant:"secondary",onClick:()=>r(u,f||void 0),disabled:p||!f.trim(),children:[p?e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Pe,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.savePreset")]}),e.jsxs(L,{onClick:()=>i(u,f||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.applyPreset")]})]})]})})}function ue({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(Ps,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function wa({provider:s,displayName:t,defaultTarget:a,data:i,authStatus:r}){const p=a||"claude",x=p==="droid";return e.jsx(ze,{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(Os,{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:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),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:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i.path}),e.jsx(Ps,{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:"Last Modified"}),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:"Status"}),r.authenticated?e.jsxs(B,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ft,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(B,{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:"Default Target"}),e.jsx("span",{className:"font-mono",children:p})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ue,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ue,{label:x?"Droid alias (explicit)":"Run on Droid",command:x?`ccsd ${s} "your prompt"`:`ccs ${s} --target droid "your prompt"`}),e.jsx(ue,{label:x?"Override to Claude":"Override target",command:`ccs ${s} --target claude "your prompt"`}),e.jsx(ue,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ue,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ue,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:i,isLoading:r,hasChanges:p,isRawJsonValid:x,isSaving:c,isRemoteMode:l,port:u,onRefetch:g,onSave:f}){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(Je,{provider:t||a,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:s}),l&&e.jsxs(B,{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(Es,{className:"w-3 h-3"}),"Remote"]}),u&&e.jsxs(B,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Ut,{className:"w-3 h-3"}),":",u]}),!l&&i?.path&&e.jsx(B,{variant:"outline",className:"text-xs",children:i.path.replace(/^.*[\\/]/,"")})]}),l?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",size:"sm",onClick:g,disabled:r,children:e.jsx(Xe,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(L,{size:"sm",onClick:f,disabled:c||!p||!x,children:c?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ca({model:s,provider:t,enabled:a,onToggle:i,disabled:r,className:p}){if(!s?.extendedContext)return null;const x=xa(s.id);return e.jsxs("div",{className:V("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",p),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:V("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(B,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Fs,{checked:a,onCheckedChange:i,disabled:r})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Os,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Enables 1M token context window instead of default 200K."}),e.jsx("p",{className:"text-[10px]",children:x?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",t," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",t," Claude models via --1m flag"]})}),a&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function Aa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Sa({catalog:s,savedPresets:t,currentModel:a,opusModel:i,sonnetModel:r,haikuModel:p,providerModels:x,provider:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}){const w=o.useMemo(()=>{if(!s||!a)return;const n=Hs(a);return s.models.find(b=>b.id===n)},[s,a]),C=o.useMemo(()=>{const n=(s?.models??[]).filter(v=>v.presetMapping);return n.length===0?[]:n.some(v=>v.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:n.filter(v=>v.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:n.filter(v=>v.tier==="paid")}].filter(v=>v.models.length>0):[{key:"default",models:n.slice(0,4)}]},[s]),D=C.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[C.map(n=>e.jsxs("div",{children:["label"in n&&n.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{variant:"outline",className:n.badgeClassName,children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:n.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.models.map(b=>e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>g(Aa(b)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in n?n.iconClassName:""}`}),b.name]},b.id))})]},n.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(n=>e.jsxs("div",{className:"group relative",children:[e.jsxs(L,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{g({ANTHROPIC_MODEL:n.default,ANTHROPIC_DEFAULT_OPUS_MODEL:n.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:n.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:n.haiku})},children:[e.jsx(Pe,{className:"w-3 h-3 fill-current"}),n.name]}),e.jsx(L,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:b=>{b.stopPropagation(),y(n.name)},disabled:P,children:e.jsx(Ye,{className:"w-3 h-3"})})]},n.name)),e.jsxs(L,{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(_s,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Ze,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),c==="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. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:n=>f("ANTHROPIC_MODEL",n),catalog:s,allModels:x}),w?.extendedContext&&u&&e.jsx(Ca,{model:w,provider:c,enabled:l??!1,onToggle:u}),e.jsx(re,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:n=>f("ANTHROPIC_DEFAULT_OPUS_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:n=>f("ANTHROPIC_DEFAULT_SONNET_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:p,onChange:n=>f("ANTHROPIC_DEFAULT_HAIKU_MODEL",n),catalog:s,allModels:x})]})]})]})}function xs(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function ps(s){if(!s)return"";try{const t=new Date(s),i=new Date().getTime()-t.getTime();if(i<0)return"just now";const r=Math.floor(i/(1e3*60)),p=Math.floor(i/(1e3*60*60)),x=Math.floor(i/(1e3*60*60*24));return x>0?`${x}d ago`:p>0?`${p}h ago`:r>0?`${r}m ago`:"just now"}catch{return""}}function Pa(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ma({account:s,onSetDefault:t,onRemove:a,onPauseToggle:i,isRemoving:r,isPausingAccount:p,privacyMode:x,showQuota:c,selectable:l,selected:u,onSelectChange:g}){const{t:f}=Z(),h=s.provider.toLowerCase(),y=h==="codex",P=h==="claude"||h==="anthropic",{data:w}=tt(c),{data:C,isLoading:D}=at(h,s.id,c),n=w?.accountStats?.[s.email||s.id]?.lastUsedAt,b=Pa(n),v=nt(s.provider,C),F=it(s.provider,C),O=y&&C&&rt(C)?ot(C.windows):null,m=[{label:"5h",value:O?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:O?.weeklyWindow?.remainingPercent??null}].filter(U=>U.value!==null),S=P&&C&<(C)?[{label:"5h",value:C.coreUsage?.fiveHour?.remainingPercent??C.windows.find(U=>U.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:C.coreUsage?.weekly?.remainingPercent??C.windows.find(U=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(U.rateLimitType))?.remainingPercent??null}].filter(U=>U.value!==null):[],N=y?m:P?S:[],k=v!==null?xt(v):null,M=k!==null?Number(k):null,j=ct(C),A=j?.label==="Reauth"?Kt:j?.tone==="warning"?Se:qt,q=j?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":j?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:V("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",u&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l&&e.jsx("button",{type:"button",onClick:()=>g?.(!u),className:V("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",u?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":u?"Deselect account":"Select account",children:u&&e.jsx(ce,{className:"w-3 h-3"})}),i&&e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!s.paused),disabled:p,children:p?e.jsx(J,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Rs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(Ke,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(fe,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:V("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(xe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:V("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:V("font-medium text-sm truncate",x&&Ae),children:s.email||s.id}),s.isDefault&&e.jsxs(B,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(Pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(B,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(Ke,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Bt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:V("font-mono max-w-[180px] truncate",x&&Ae),title:s.projectId,children:s.projectId})]})}),e.jsx(fe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Se,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(fe,{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:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(ls,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(dt,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Vt,{className:"w-4 h-4"})})}),e.jsxs(mt,{align:"end",children:[!s.isDefault&&e.jsxs(is,{onClick:t,children:[e.jsx(Pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(is,{className:"text-destructive focus:text-destructive",onClick:a,disabled:r,children:[e.jsx(Ls,{className:"w-4 h-4 mr-2"}),r?"Removing...":"Remove account"]})]})]})]}),c&&e.jsx("div",{className:"pl-11",children:D?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):M!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ps(n)]})]}):n?e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ps(n)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:N.length>0?e.jsx("div",{className:"space-y-1.5",children:N.map(U=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:U.label}),e.jsx(Ue,{value:Math.max(0,Math.min(100,U.value)),className:"h-2 flex-1",indicatorClassName:xs(U.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[U.value,"%"]})]},U.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{value:Math.max(0,Math.min(100,M)),className:"h-2 flex-1",indicatorClassName:xs(M)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[k,"%"]})]})}),e.jsx(fe,{side:"bottom",className:"max-w-xs",children:e.jsx(pt,{quota:C,resetTime:F})})]})})]}):C?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(cs,{className:"w-3 h-3"}),f("accountCard.quotaUnavailable")]})}):j?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:V("text-[10px] h-5 px-2 gap-1",q),children:[e.jsx(A,{className:"w-3 h-3"}),j.label]})})}),e.jsx(fe,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:j.summary}),j.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:j.actionHint}),j.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:j.technicalDetail}),j.rawDetail&&e.jsx("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 px-2 py-1 font-mono text-[10px] text-muted-foreground",children:j.rawDetail})]})})]})}):null})]})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:i,isPausing:r,isResuming:p}){if(s<1)return null;const x=r||p;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:[s," selected"]}),e.jsx(L,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:x,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:x,children:[r?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:x,children:[p?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Rs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Da({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:i,onPauseToggle:r,onSoloMode:p,onBulkPause:x,onBulkResume:c,isRemovingAccount:l,isPausingAccount:u,isSoloingAccount:g,isBulkPausing:f,isBulkResuming:h,privacyMode:y,showQuota:P,isKiro:w,kiroNoIncognito:C,onKiroNoIncognitoChange:D,kiroSettingsLoading:n}){const[b,v]=o.useState(new Set),F=o.useMemo(()=>new Set(s.map(R=>R.id)),[s]),O=o.useMemo(()=>new Set([...b].filter(R=>F.has(R))),[b,F]),m=!!(x&&c),S=O.size,N=s.length>0&&O.size===s.length,k=O.size>0&&O.size<s.length,M=o.useCallback(R=>{v(H=>{const G=new Set(H);return G.has(R)?G.delete(R):G.add(R),G})},[]),j=o.useCallback(()=>{v(new Set(s.map(R=>R.id)))},[s]),A=o.useCallback(()=>{v(new Set)},[]),q=o.useCallback(()=>{N?A():j()},[N,j,A]),U=o.useCallback(()=>{x&&O.size>0&&(x(Array.from(O)),v(new Set))},[x,O]),E=o.useCallback(()=>{c&&O.size>0&&(c(Array.from(O)),v(new Set))},[c,O]);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:[m&&s.length>0&&e.jsx(Ce,{checked:N,onCheckedChange:q,"aria-label":"Select all accounts",className:k?"data-[state=checked]:bg-primary/50":"",...k?{"data-state":"indeterminate"}:{}}),e.jsx(xe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(B,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(L,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(_s,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Ta,{selectedCount:S,onPauseSelected:U,onResumeSelected:E,onClearSelection:A,isPausing:!!f,isResuming:!!h}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(R=>e.jsx(Ma,{account:R,onSetDefault:()=>a(R.id),onRemove:()=>i(R.id),onPauseToggle:r?H=>r(R.id,H):void 0,onSoloMode:p?()=>p(R.id):void 0,isRemoving:l,isPausingAccount:u,isSoloingAccount:g,privacyMode:y,showQuota:P,selectable:m,selected:O.has(R.id),onSelectChange:()=>M(R.id)},R.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&D&&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(Es,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Fs,{checked:!C,onCheckedChange:R=>D(!R),disabled:n,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P,accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,isRemoteMode:A}){const q=s.toLowerCase(),U=(ht.includes(q)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(q))&&!A,E=s==="kiro",[R,H]=o.useState(!0),[G,$]=o.useState(!0),[ae,ee]=o.useState(!1),W=o.useCallback(async()=>{if(E)try{$(!0);const z=(await we.config.get()).cliproxy;H(z?.kiro_no_incognito??!0)}catch{H(!0)}finally{$(!1)}},[E]),d=o.useCallback(async _=>{H(_),ee(!0);try{const z=await we.config.get(),de=z.cliproxy??{};await we.config.update({...z,cliproxy:{...de,kiro_no_incognito:_}})}catch{H(!_)}finally{ee(!1)}},[]);return o.useEffect(()=>{W()},[W]),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Sa,{catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,provider:s,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}),e.jsx(Ze,{}),e.jsx(Da,{accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,showQuota:U,isKiro:E,kiroNoIncognito:R,onKiroNoIncognitoChange:d,kiroSettingsLoading:G||ae})]})})}function hs({provider:s,displayName:t,authStatus:a,catalog:i,logoProvider:r,baseProvider:p,isRemoteMode:x,port:c,defaultTarget:l,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v}){const[F,O]=o.useState(!1),{privacyMode:m}=ks(),{data:S}=gt(),{data:N}=ft(s),k=jt(),M=vt(),j=p||s,A=j.toLowerCase()==="agy",q=o.useMemo(()=>{const I=N?.presets||[];return A?I.filter(Q=>!se(Q.default)&&!se(Q.opus)&&!se(Q.sonnet)&&!se(Q.haiku)):I},[A,N?.presets]),U=o.useMemo(()=>{if(!S?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[j.toLowerCase()]||[j.toLowerCase()];return S.models.filter(ie=>Q.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?A?!se(ie.id):!0:!1)},[A,S,j]),E=(p||s).toLowerCase(),{data:R,isLoading:H,refetch:G,rawJsonContent:$,rawJsonEdits:ae,isRawJsonValid:ee,hasChanges:W,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,extendedContextEnabled:Me,toggleExtendedContext:Te,handleRawJsonChange:De,updateEnvValue:X,updateEnvValues:T,saveMutation:te,conflictDialog:ne,handleConflictResolve:Oe,missingRequiredFields:ye}=fa(s),Ks=o.useMemo(()=>(a.accounts||[]).map(I=>({...I,provider:I.provider||p||s})),[a.accounts,p,s]),{data:qs}=gs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const I=await fetch("/api/settings/auth/tokens/raw");return I.ok?I.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),ts=qs?.apiKey?.value??"ccs-internal-managed",Bs=I=>{if(A&&[I.ANTHROPIC_MODEL,I.ANTHROPIC_DEFAULT_OPUS_MODEL,I.ANTHROPIC_DEFAULT_SONNET_MODEL,I.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,...I}),K.success(`Applied "${I.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Vs=(I,Q)=>{if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(Ee=>se(Ee))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,ANTHROPIC_MODEL:I.default,ANTHROPIC_DEFAULT_OPUS_MODEL:I.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:I.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:I.haiku}),K.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),O(!1)},Gs=(I,Q)=>{if(!Q){K.error(As.t("commonToast.enterPresetName"));return}if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(ie=>se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}k.mutate({profile:s,data:{name:Q,...I}}),O(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:r,data:R,isLoading:H,hasChanges:W,isRawJsonValid:ee,isSaving:te.isPending,isRemoteMode:x,port:c,onRefetch:G,onSave:()=>te.mutate()}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(J,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(Nt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(yt,{className:"w-full",children:[e.jsx(rs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(rs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(os,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:i,savedPresets:q,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,providerModels:U,extendedContextEnabled:Me,onExtendedContextToggle:Te,onApplyPreset:Bs,onUpdateEnvValue:X,onOpenCustomPreset:()=>O(!0),onDeletePreset:I=>M.mutate({profile:s,name:I}),isDeletePending:M.isPending,accounts:Ks,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v,privacyMode:m,isRemoteMode:x})}),e.jsx(os,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(wa,{provider:s,displayName:t,defaultTarget:l,data:R,authStatus:a})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($t,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(bt,{rawJsonContent:$,isRawJsonValid:ee,rawJsonEdits:ae,onRawJsonChange:De,profileEnv:R?.settings?.env,missingRequiredFields:ye})]})]}),e.jsx(Jt,{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:()=>Oe(!0),onCancel:()=>Oe(!1)}),e.jsx(ba,{open:F,onClose:()=>O(!1),currentValues:{default:d||"",opus:_||"",sonnet:z||"",haiku:de||""},onApply:Vs,onSave:Gs,isSaving:k.isPending,catalog:i,allModels:U})]})}function Ea({status:s,isSelected:t,onSelect:a}){const{t:i}=Z(),r=s.accounts?.length||0;return e.jsxs("button",{className:V("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Je,{provider:s.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:s.displayName}),r>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:i("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("cliproxyPage.notConnected")})]})})]})]})}function _a({variant:s,parentAuth:t,isSelected:a,onSelect:i,onDelete:r,isDeleting:p}){const{t:x}=Z(),c=()=>{i()};return e.jsxs("div",{role:"button",tabIndex:0,className:V("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:c,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),c())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{provider:s.provider,size:"sm"}),e.jsx(Is,{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:s.name}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:x("cliproxyPage.variant")}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:x("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:x("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),r()},disabled:p,children:e.jsx(Ls,{className:"w-3 h-3"})})]})}function Ra({onSetup:s}){const{t}=Z();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(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(L,{onClick:s,className:"gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function en(){const{t:s}=Z(),t=Be(),{data:a,isLoading:i}=ws(),{data:r,isFetching:p}=wt(),{data:x}=kt(),c=Ct(),l=At(),u=St(),g=Pt(),f=Mt(),h=Tt(),y=Dt(),P=Ot(),[w,C]=o.useState(()=>{if(typeof window<"u"){const _=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return _&&Fe(_)?_:localStorage.getItem("cliproxy-selected-provider")}return null}),[D,n]=o.useState(null),[b,v]=o.useState(!1),[F,O]=o.useState(()=>{if(typeof window>"u")return null;const d=new URLSearchParams(window.location.search),_=d.get("provider")?.trim().toLowerCase();return d.get("action")!=="auth"||!_||!Fe(_)?null:{provider:_,displayName:Et(_),isFirstAccount:!1}}),m=o.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",N=o.useMemo(()=>r?.variants||[],[r?.variants]),k=d=>{C(d),d&&localStorage.setItem("cliproxy-selected-provider",d)},M=o.useMemo(()=>D?null:w&&m.some(d=>d.provider===w)?w:m.length>0&&(m.find(_=>(_.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[w,D,m]),j=m.find(d=>d.provider===M),A=N.find(d=>d.name===D),q=A?m.find(d=>d.provider===A.provider):void 0,U=(A?.provider||j?.provider||"").toLowerCase().trim(),E=U==="gemini"||U==="agy",R=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},H=(d,_,z)=>{u.isPending||g.isPending||(z?u.mutate({provider:d,accountId:_}):g.mutate({provider:d,accountId:_}))},G=(d,_)=>{f.isPending||f.mutate({provider:d,accountId:_})},$=(d,_)=>{h.isPending||h.mutate({provider:d,accountIds:_})},ae=(d,_)=>{y.isPending||y.mutate({provider:d,accountIds:_})},ee=d=>{k(d),n(null)},W=d=>{n(d),k(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:x?.backendLabel??"CLIProxy"})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,disabled:p,children:e.jsx(Xe,{className:V("w-4 h-4",p&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(L,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>v(!0),children:[e.jsx(ve,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(ze,{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:s("cliproxyPage.providers")}),i?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(d=>e.jsx(_t,{className:"h-14 w-full rounded-lg"},d))}):e.jsx("div",{className:"space-y-1",children:m.map(d=>e.jsx(Ea,{status:d,isSelected:M===d.provider,onSelect:()=>ee(d.provider)},d.provider))}),N.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(Is,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:N.map(d=>e.jsx(_a,{variant:d,parentAuth:m.find(_=>_.provider===d.provider),isSelected:D===d.name,onSelect:()=>W(d.name),onDelete:()=>P.mutate(d.name),isDeleting:P.isPending},d.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Xt,{})}),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:s("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(d=>d.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[E&&e.jsx(Us,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),A&&q?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:A.name,displayName:s("cliproxyPage.variantDisplay",{name:A.name,provider:A.provider}),authStatus:q,catalog:je[A.provider],logoProvider:A.provider,baseProvider:A.provider,defaultTarget:A.target,isRemoteMode:S,port:A.port,onAddAccount:()=>O({provider:A.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:A.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:A.provider,accountId:d}),onPauseToggle:(d,_)=>H(A.provider,d,_),onSoloMode:d=>G(A.provider,d),onBulkPause:d=>$(A.provider,d),onBulkResume:d=>ae(A.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):j?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:j.provider,displayName:j.displayName,authStatus:j,catalog:je[j.provider],isRemoteMode:S,onAddAccount:()=>O({provider:j.provider,displayName:j.displayName,isFirstAccount:(j.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:j.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:j.provider,accountId:d}),onPauseToggle:(d,_)=>H(j.provider,d,_),onSoloMode:d=>G(j.provider,d),onBulkPause:d=>$(j.provider,d),onBulkResume:d=>ae(j.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):e.jsx(Ra,{onSetup:()=>v(!0)})]}),e.jsx(ia,{open:b,onClose:()=>v(!1)}),e.jsx(ma,{open:F!==null,onClose:()=>O(null),provider:F?.provider||"",displayName:F?.displayName||"",isFirstAccount:F?.isFirstAccount||!1})]})}export{en as CliproxyPage};
|
|
3
|
+
}`,[t,u]),f=o.useCallback(k=>{a(k)},[]),h=o.useMemo(()=>{try{return JSON.parse(g)}catch{return u||{env:{}}}},[g,u]),y=h?.env?.ANTHROPIC_MODEL,P=h?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,w=h?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,C=h?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,D=o.useMemo(()=>{const k=h?.env||{};return ms.some(M=>{const j=k[M];return j&&ss(j)})},[h]),n=o.useCallback((k,M)=>{const j={...h?.env||{},[k]:M},A={...h,env:j};a(JSON.stringify(A,null,2))},[h]),b=o.useCallback(k=>{const M=h?.env||{},j={};for(const U of ms){const E=M[U];E&&(j[U]=k?pa(E):Hs(E))}const A={...M,...j};delete A.CCS_EXTENDED_CONTEXT;const q={...h,env:A};a(JSON.stringify(q,null,2))},[h]),v=o.useCallback(k=>{const M={...h?.env||{},...k},j={...h,env:M};a(JSON.stringify(j,null,2))},[h]),F=o.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),O=o.useMemo(()=>t===null?!1:t!==JSON.stringify(u,null,2),[t,u]),m=o.useMemo(()=>ga(h),[h]),S=$s({mutationFn:async()=>{const k=JSON.parse(g),M=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:k,expectedMtime:x?.mtime})});if(M.status===409)throw new Error("CONFLICT");if(!M.ok)throw new Error("Failed to save");return M.json()},onSuccess:k=>{p.invalidateQueries({queryKey:["settings",s]}),a(null),k?.warning?K.success("Settings saved",{description:k.warning}):K.success("Settings saved")},onError:k=>{k.message==="CONFLICT"?r(!0):K.error(k.message)}}),N=async k=>{r(!1),k?(await l(),S.mutate()):a(null)};return{data:x,isLoading:c,refetch:l,rawJsonContent:g,rawJsonEdits:t,isRawJsonValid:F,hasChanges:O,currentSettings:h,currentModel:y,opusModel:P,sonnetModel:w,haikuModel:C,extendedContextEnabled:D,toggleExtendedContext:b,handleRawJsonChange:f,updateEnvValue:n,updateEnvValues:v,saveMutation:{mutate:()=>S.mutate(),isPending:S.isPending},conflictDialog:i,setConflictDialog:r,handleConflictResolve:N,missingRequiredFields:m}}const ja=/-(medium|high|xhigh)$/i;function va(s){if(!s)return;const t=s.trim().match(ja);if(t?.[1])return t[1].toLowerCase()}function Na(s){if(!s)return null;const t=va(s);return t?{label:`Pinned ${t}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function ya({label:s}){return e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:s})}function be({modelId:s}){const t=Na(s);return t?e.jsx(B,{variant:t.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.label}):null}function re({label:s,description:t,value:a,onChange:i,catalog:r,allModels:p,disabled:x}){const{t:c}=Z(),l=new Set(r?.models.map(y=>y.id)||[]),u=r?.provider==="codex",g=(r?.models??[]).map(y=>({value:y.id,groupKey:"recommended",searchText:`${y.id} ${y.name}`,keywords:[y.tier??"",r?.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:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),y.tier==="paid"&&e.jsx(ya,{label:c("providerModelSelector.paid")}),u&&e.jsx(be,{modelId:y.id})]})})),f=p.filter(y=>!l.has(y.id)).map(y=>({value:y.id,groupKey:"all",searchText:y.id,keywords:[y.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:y.id}),u&&e.jsx(be,{modelId:y.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:y.id}),u&&e.jsx(be,{modelId:y.id})]})})),h=g.length+f.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:s}),t&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(Wt,{value:a||void 0,onChange:i,disabled:x,placeholder:c("providerModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c(h?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:c("providerModelSelector.recommended")})},{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:c("providerModelSelector.allModelsCount",{count:p.length})})}],options:[...g,...f]})]})}function ba({open:s,onClose:t,currentValues:a,onApply:i,onSave:r,isSaving:p,catalog:x,allModels:c}){const{t:l}=Z(),[u,g]=o.useState(a),[f,h]=o.useState(""),y=P=>{P?(g(a),h("")):t()};return e.jsx(Ve,{open:s,onOpenChange:y,children:e.jsxs(Ge,{className:"sm:max-w-md",children:[e.jsx($e,{children:e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),l("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:l("customPresetDialog.presetNameOptional")}),e.jsx(le,{id:"preset-name",value:f,onChange:P=>h(P.target.value),placeholder:l("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(Ze,{}),x?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[l("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",l("customPresetDialog.codexTipSuffix")]}),e.jsx(re,{label:l("customPresetDialog.defaultModel"),description:l("customPresetDialog.defaultModelDesc"),value:u.default,onChange:P=>g({...u,default:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.opusModel"),description:l("customPresetDialog.opusModelDesc"),value:u.opus,onChange:P=>g({...u,opus:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.sonnetModel"),description:l("customPresetDialog.sonnetModelDesc"),value:u.sonnet,onChange:P=>g({...u,sonnet:P}),catalog:x,allModels:c}),e.jsx(re,{label:l("customPresetDialog.haikuModel"),description:l("customPresetDialog.haikuModelDesc"),value:u.haiku,onChange:P=>g({...u,haiku:P}),catalog:x,allModels:c})]}),e.jsxs(st,{className:"gap-2 sm:gap-0",children:[e.jsx(L,{variant:"outline",onClick:t,children:l("customPresetDialog.cancel")}),r&&e.jsxs(L,{variant:"secondary",onClick:()=>r(u,f||void 0),disabled:p||!f.trim(),children:[p?e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Pe,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.savePreset")]}),e.jsxs(L,{onClick:()=>i(u,f||void 0),children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),l("customPresetDialog.applyPreset")]})]})]})})}function ue({label:s,command:t}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t}),e.jsx(Ps,{value:t,size:"icon",className:"h-6 w-6"})]})]})}function wa({provider:s,displayName:t,defaultTarget:a,data:i,authStatus:r}){const p=a||"claude",x=p==="droid";return e.jsx(ze,{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(Os,{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:"Provider"}),e.jsx("span",{className:"font-mono",children:t})]}),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:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i.path}),e.jsx(Ps,{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:"Last Modified"}),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:"Status"}),r.authenticated?e.jsxs(B,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ft,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(B,{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:"Default Target"}),e.jsx("span",{className:"font-mono",children:p})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ue,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ue,{label:x?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${s} "your prompt"`}),e.jsx(ue,{label:x?"Override to Claude":"Run on Droid (--target)",command:`ccs ${s} --target ${x?"claude":"droid"} "your prompt"`}),e.jsx(ue,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ue,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ue,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}function ka({displayName:s,logoProvider:t,provider:a,data:i,isLoading:r,hasChanges:p,isRawJsonValid:x,isSaving:c,isRemoteMode:l,port:u,onRefetch:g,onSave:f}){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(Je,{provider:t||a,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:s}),l&&e.jsxs(B,{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(Es,{className:"w-3 h-3"}),"Remote"]}),u&&e.jsxs(B,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Ut,{className:"w-3 h-3"}),":",u]}),!l&&i?.path&&e.jsx(B,{variant:"outline",className:"text-xs",children:i.path.replace(/^.*[\\/]/,"")})]}),l?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(i.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"ghost",size:"sm",onClick:g,disabled:r,children:e.jsx(Xe,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),e.jsx(L,{size:"sm",onClick:f,disabled:c||!p||!x,children:c?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ca({model:s,provider:t,enabled:a,onToggle:i,disabled:r,className:p}){if(!s?.extendedContext)return null;const x=xa(s.id);return e.jsxs("div",{className:V("rounded-lg border p-3 space-y-2",a?"border-primary/50 bg-primary/5":"border-border bg-muted/30",p),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:V("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(B,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Fs,{checked:a,onCheckedChange:i,disabled:r})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Os,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Enables 1M token context window instead of default 200K."}),e.jsx("p",{className:"text-[10px]",children:x?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",t," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",t," Claude models via --1m flag"]})}),a&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function Aa(s){const t=s.presetMapping||{default:s.id,opus:s.id,sonnet:s.id,haiku:s.id};return{ANTHROPIC_MODEL:t.default,ANTHROPIC_DEFAULT_OPUS_MODEL:t.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:t.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:t.haiku}}function Sa({catalog:s,savedPresets:t,currentModel:a,opusModel:i,sonnetModel:r,haikuModel:p,providerModels:x,provider:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}){const w=o.useMemo(()=>{if(!s||!a)return;const n=Hs(a);return s.models.find(b=>b.id===n)},[s,a]),C=o.useMemo(()=>{const n=(s?.models??[]).filter(v=>v.presetMapping);return n.length===0?[]:n.some(v=>v.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:n.filter(v=>v.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:n.filter(v=>v.tier==="paid")}].filter(v=>v.models.length>0):[{key:"default",models:n.slice(0,4)}]},[s]),D=C.length>0||t.length>0;return e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[C.map(n=>e.jsxs("div",{children:["label"in n&&n.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(B,{variant:"outline",className:n.badgeClassName,children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:n.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.models.map(b=>e.jsxs(L,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>g(Aa(b)),children:[e.jsx(Ne,{className:`w-3 h-3 ${"iconClassName"in n?n.iconClassName:""}`}),b.name]},b.id))})]},n.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.map(n=>e.jsxs("div",{className:"group relative",children:[e.jsxs(L,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{g({ANTHROPIC_MODEL:n.default,ANTHROPIC_DEFAULT_OPUS_MODEL:n.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:n.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:n.haiku})},children:[e.jsx(Pe,{className:"w-3 h-3 fill-current"}),n.name]}),e.jsx(L,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:b=>{b.stopPropagation(),y(n.name)},disabled:P,children:e.jsx(Ye,{className:"w-3 h-3"})})]},n.name)),e.jsxs(L,{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(_s,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(Ze,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),c==="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. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:n=>f("ANTHROPIC_MODEL",n),catalog:s,allModels:x}),w?.extendedContext&&u&&e.jsx(Ca,{model:w,provider:c,enabled:l??!1,onToggle:u}),e.jsx(re,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:i,onChange:n=>f("ANTHROPIC_DEFAULT_OPUS_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:r,onChange:n=>f("ANTHROPIC_DEFAULT_SONNET_MODEL",n),catalog:s,allModels:x}),e.jsx(re,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:p,onChange:n=>f("ANTHROPIC_DEFAULT_HAIKU_MODEL",n),catalog:s,allModels:x})]})]})]})}function xs(s){const t=Math.max(0,Math.min(100,s));return t<=20?"bg-destructive":t<=50?"bg-yellow-500":"bg-green-500"}function ps(s){if(!s)return"";try{const t=new Date(s),i=new Date().getTime()-t.getTime();if(i<0)return"just now";const r=Math.floor(i/(1e3*60)),p=Math.floor(i/(1e3*60*60)),x=Math.floor(i/(1e3*60*60*24));return x>0?`${x}d ago`:p>0?`${p}h ago`:r>0?`${r}m ago`:"just now"}catch{return""}}function Pa(s){if(!s)return!1;try{const t=new Date(s);return new Date().getTime()-t.getTime()<3600*1e3}catch{return!1}}function Ma({account:s,onSetDefault:t,onRemove:a,onPauseToggle:i,isRemoving:r,isPausingAccount:p,privacyMode:x,showQuota:c,selectable:l,selected:u,onSelectChange:g}){const{t:f}=Z(),h=s.provider.toLowerCase(),y=h==="codex",P=h==="claude"||h==="anthropic",{data:w}=tt(c),{data:C,isLoading:D}=at(h,s.id,c),n=w?.accountStats?.[s.email||s.id]?.lastUsedAt,b=Pa(n),v=nt(s.provider,C),F=it(s.provider,C),O=y&&C&&rt(C)?ot(C.windows):null,m=[{label:"5h",value:O?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:O?.weeklyWindow?.remainingPercent??null}].filter(U=>U.value!==null),S=P&&C&<(C)?[{label:"5h",value:C.coreUsage?.fiveHour?.remainingPercent??C.windows.find(U=>U.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:C.coreUsage?.weekly?.remainingPercent??C.windows.find(U=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(U.rateLimitType))?.remainingPercent??null}].filter(U=>U.value!==null):[],N=y?m:P?S:[],k=v!==null?xt(v):null,M=k!==null?Number(k):null,j=ct(C),A=j?.label==="Reauth"?Kt:j?.tone==="warning"?Se:qt,q=j?.tone==="warning"?"border-amber-500/50 text-amber-600 dark:text-amber-400":j?.tone==="destructive"?"border-destructive/50 text-destructive":"border-muted-foreground/50 text-muted-foreground";return e.jsxs("div",{className:V("flex flex-col gap-2 p-3 rounded-lg border transition-colors overflow-hidden",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",u&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l&&e.jsx("button",{type:"button",onClick:()=>g?.(!u),className:V("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",u?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":u?"Deselect account":"Select account",children:u&&e.jsx(ce,{className:"w-3 h-3"})}),i&&e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>i(!s.paused),disabled:p,children:p?e.jsx(J,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Rs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(Ke,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(fe,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:V("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(xe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:V("absolute -bottom-0.5 -right-0.5 text-[7px] font-bold uppercase px-1 py-px rounded","ring-1 ring-background",s.tier==="ultra"?"bg-violet-500/20 text-violet-600 dark:bg-violet-500/30 dark:text-violet-300":"bg-yellow-500/20 text-yellow-700 dark:bg-yellow-500/25 dark:text-yellow-400"),children:s.tier==="ultra"?"U":"P"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:V("font-medium text-sm truncate",x&&Ae),children:s.email||s.id}),s.isDefault&&e.jsxs(B,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(Pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(B,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(Ke,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Bt,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:V("font-mono max-w-[180px] truncate",x&&Ae),title:s.projectId,children:s.projectId})]})}),e.jsx(fe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(Se,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(fe,{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:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(ls,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(dt,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Vt,{className:"w-4 h-4"})})}),e.jsxs(mt,{align:"end",children:[!s.isDefault&&e.jsxs(is,{onClick:t,children:[e.jsx(Pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(is,{className:"text-destructive focus:text-destructive",onClick:a,disabled:r,children:[e.jsx(Ls,{className:"w-4 h-4 mr-2"}),r?"Removing...":"Remove account"]})]})]})]}),c&&e.jsx("div",{className:"pl-11",children:D?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(J,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):M!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:b?e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ps(n)]})]}):n?e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ps(n)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(cs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:N.length>0?e.jsx("div",{className:"space-y-1.5",children:N.map(U=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:U.label}),e.jsx(Ue,{value:Math.max(0,Math.min(100,U.value)),className:"h-2 flex-1",indicatorClassName:xs(U.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[U.value,"%"]})]},U.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{value:Math.max(0,Math.min(100,M)),className:"h-2 flex-1",indicatorClassName:xs(M)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[k,"%"]})]})}),e.jsx(fe,{side:"bottom",className:"max-w-xs",children:e.jsx(pt,{quota:C,resetTime:F})})]})})]}):C?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(cs,{className:"w-3 h-3"}),f("accountCard.quotaUnavailable")]})}):j?e.jsx(pe,{children:e.jsxs(he,{children:[e.jsx(ge,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(B,{variant:"outline",className:V("text-[10px] h-5 px-2 gap-1",q),children:[e.jsx(A,{className:"w-3 h-3"}),j.label]})})}),e.jsx(fe,{side:"bottom",className:"max-w-[260px]",children:e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:j.summary}),j.actionHint&&e.jsx("p",{className:"text-muted-foreground",children:j.actionHint}),j.technicalDetail&&e.jsx("p",{className:"font-mono text-[11px] text-muted-foreground",children:j.technicalDetail}),j.rawDetail&&e.jsx("pre",{className:"whitespace-pre-wrap break-all rounded bg-muted/40 px-2 py-1 font-mono text-[10px] text-muted-foreground",children:j.rawDetail})]})})]})}):null})]})}function Ta({selectedCount:s,onPauseSelected:t,onResumeSelected:a,onClearSelection:i,isPausing:r,isResuming:p}){if(s<1)return null;const x=r||p;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:[s," selected"]}),e.jsx(L,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:i,disabled:x,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:x,children:[r?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:x,children:[p?e.jsx(J,{className:"w-3 h-3 animate-spin"}):e.jsx(Rs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Da({accounts:s,onAddAccount:t,onSetDefault:a,onRemoveAccount:i,onPauseToggle:r,onSoloMode:p,onBulkPause:x,onBulkResume:c,isRemovingAccount:l,isPausingAccount:u,isSoloingAccount:g,isBulkPausing:f,isBulkResuming:h,privacyMode:y,showQuota:P,isKiro:w,kiroNoIncognito:C,onKiroNoIncognitoChange:D,kiroSettingsLoading:n}){const[b,v]=o.useState(new Set),F=o.useMemo(()=>new Set(s.map(R=>R.id)),[s]),O=o.useMemo(()=>new Set([...b].filter(R=>F.has(R))),[b,F]),m=!!(x&&c),S=O.size,N=s.length>0&&O.size===s.length,k=O.size>0&&O.size<s.length,M=o.useCallback(R=>{v(H=>{const G=new Set(H);return G.has(R)?G.delete(R):G.add(R),G})},[]),j=o.useCallback(()=>{v(new Set(s.map(R=>R.id)))},[s]),A=o.useCallback(()=>{v(new Set)},[]),q=o.useCallback(()=>{N?A():j()},[N,j,A]),U=o.useCallback(()=>{x&&O.size>0&&(x(Array.from(O)),v(new Set))},[x,O]),E=o.useCallback(()=>{c&&O.size>0&&(c(Array.from(O)),v(new Set))},[c,O]);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:[m&&s.length>0&&e.jsx(Ce,{checked:N,onCheckedChange:q,"aria-label":"Select all accounts",className:k?"data-[state=checked]:bg-primary/50":"",...k?{"data-state":"indeterminate"}:{}}),e.jsx(xe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(B,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(L,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:t,children:[e.jsx(_s,{className:"w-3 h-3"}),"Add"]})]}),m&&S>0&&e.jsx(Ta,{selectedCount:S,onPauseSelected:U,onResumeSelected:E,onClearSelection:A,isPausing:!!f,isResuming:!!h}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(R=>e.jsx(Ma,{account:R,onSetDefault:()=>a(R.id),onRemove:()=>i(R.id),onPauseToggle:r?H=>r(R.id,H):void 0,onSoloMode:p?()=>p(R.id):void 0,isRemoving:l,isPausingAccount:u,isSoloingAccount:g,privacyMode:y,showQuota:P,selectable:m,selected:O.has(R.id),onSelectChange:()=>M(R.id)},R.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),w&&D&&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(Es,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Fs,{checked:!C,onCheckedChange:R=>D(!R),disabled:n,className:"scale-90"})]})})]})}function Oa({provider:s,catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P,accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,isRemoteMode:A}){const q=s.toLowerCase(),U=(ht.includes(q)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(q))&&!A,E=s==="kiro",[R,H]=o.useState(!0),[G,$]=o.useState(!0),[ae,ee]=o.useState(!1),W=o.useCallback(async()=>{if(E)try{$(!0);const z=(await we.config.get()).cliproxy;H(z?.kiro_no_incognito??!0)}catch{H(!0)}finally{$(!1)}},[E]),d=o.useCallback(async _=>{H(_),ee(!0);try{const z=await we.config.get(),de=z.cliproxy??{};await we.config.update({...z,cliproxy:{...de,kiro_no_incognito:_}})}catch{H(!_)}finally{ee(!1)}},[]);return o.useEffect(()=>{W()},[W]),e.jsx(ze,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Sa,{catalog:t,savedPresets:a,currentModel:i,opusModel:r,sonnetModel:p,haikuModel:x,providerModels:c,provider:s,extendedContextEnabled:l,onExtendedContextToggle:u,onApplyPreset:g,onUpdateEnvValue:f,onOpenCustomPreset:h,onDeletePreset:y,isDeletePending:P}),e.jsx(Ze,{}),e.jsx(Da,{accounts:w,onAddAccount:C,onSetDefault:D,onRemoveAccount:n,onPauseToggle:b,onSoloMode:v,onBulkPause:F,onBulkResume:O,isRemovingAccount:m,isPausingAccount:S,isSoloingAccount:N,isBulkPausing:k,isBulkResuming:M,privacyMode:j,showQuota:U,isKiro:E,kiroNoIncognito:R,onKiroNoIncognitoChange:d,kiroSettingsLoading:G||ae})]})})}function hs({provider:s,displayName:t,authStatus:a,catalog:i,logoProvider:r,baseProvider:p,isRemoteMode:x,port:c,defaultTarget:l,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v}){const[F,O]=o.useState(!1),{privacyMode:m}=ks(),{data:S}=gt(),{data:N}=ft(s),k=jt(),M=vt(),j=p||s,A=j.toLowerCase()==="agy",q=o.useMemo(()=>{const I=N?.presets||[];return A?I.filter(Q=>!se(Q.default)&&!se(Q.opus)&&!se(Q.sonnet)&&!se(Q.haiku)):I},[A,N?.presets]),U=o.useMemo(()=>{if(!S?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[j.toLowerCase()]||[j.toLowerCase()];return S.models.filter(ie=>Q.some(Ee=>ie.owned_by.toLowerCase().includes(Ee))?A?!se(ie.id):!0:!1)},[A,S,j]),E=(p||s).toLowerCase(),{data:R,isLoading:H,refetch:G,rawJsonContent:$,rawJsonEdits:ae,isRawJsonValid:ee,hasChanges:W,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,extendedContextEnabled:Me,toggleExtendedContext:Te,handleRawJsonChange:De,updateEnvValue:X,updateEnvValues:T,saveMutation:te,conflictDialog:ne,handleConflictResolve:Oe,missingRequiredFields:ye}=fa(s),Ks=o.useMemo(()=>(a.accounts||[]).map(I=>({...I,provider:I.provider||p||s})),[a.accounts,p,s]),{data:qs}=gs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const I=await fetch("/api/settings/auth/tokens/raw");return I.ok?I.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),ts=qs?.apiKey?.value??"ccs-internal-managed",Bs=I=>{if(A&&[I.ANTHROPIC_MODEL,I.ANTHROPIC_DEFAULT_OPUS_MODEL,I.ANTHROPIC_DEFAULT_SONNET_MODEL,I.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(ie=>typeof ie=="string"&&se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,...I}),K.success(`Applied "${I.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Vs=(I,Q)=>{if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(Ee=>se(Ee))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}T({ANTHROPIC_BASE_URL:`http://127.0.0.1:${c??He}/api/provider/${E}`,ANTHROPIC_AUTH_TOKEN:ts,ANTHROPIC_MODEL:I.default,ANTHROPIC_DEFAULT_OPUS_MODEL:I.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:I.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:I.haiku}),K.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),O(!1)},Gs=(I,Q)=>{if(!Q){K.error(As.t("commonToast.enterPresetName"));return}if(A&&[I.default,I.opus,I.sonnet,I.haiku].some(ie=>se(ie))){K.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}k.mutate({profile:s,data:{name:Q,...I}}),O(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ka,{provider:s,displayName:t,logoProvider:r,data:R,isLoading:H,hasChanges:W,isRawJsonValid:ee,isSaving:te.isPending,isRemoteMode:x,port:c,onRefetch:G,onSave:()=>te.mutate()}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(J,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(Nt,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(yt,{className:"w-full",children:[e.jsx(rs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(rs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(os,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Oa,{provider:s,catalog:i,savedPresets:q,currentModel:d,opusModel:_,sonnetModel:z,haikuModel:de,providerModels:U,extendedContextEnabled:Me,onExtendedContextToggle:Te,onApplyPreset:Bs,onUpdateEnvValue:X,onOpenCustomPreset:()=>O(!0),onDeletePreset:I=>M.mutate({profile:s,name:I}),isDeletePending:M.isPending,accounts:Ks,onAddAccount:u,onSetDefault:g,onRemoveAccount:f,onPauseToggle:h,onSoloMode:y,onBulkPause:P,onBulkResume:w,isRemovingAccount:C,isPausingAccount:D,isSoloingAccount:n,isBulkPausing:b,isBulkResuming:v,privacyMode:m,isRemoteMode:x})}),e.jsx(os,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(wa,{provider:s,displayName:t,defaultTarget:l,data:R,authStatus:a})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($t,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(bt,{rawJsonContent:$,isRawJsonValid:ee,rawJsonEdits:ae,onRawJsonChange:De,profileEnv:R?.settings?.env,missingRequiredFields:ye})]})]}),e.jsx(Jt,{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:()=>Oe(!0),onCancel:()=>Oe(!1)}),e.jsx(ba,{open:F,onClose:()=>O(!1),currentValues:{default:d||"",opus:_||"",sonnet:z||"",haiku:de||""},onApply:Vs,onSave:Gs,isSaving:k.isPending,catalog:i,allModels:U})]})}function Ea({status:s,isSelected:t,onSelect:a}){const{t:i}=Z(),r=s.accounts?.length||0;return e.jsxs("button",{className:V("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(Je,{provider:s.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:s.displayName}),r>0&&e.jsx(B,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:i("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i("cliproxyPage.notConnected")})]})})]})]})}function _a({variant:s,parentAuth:t,isSelected:a,onSelect:i,onDelete:r,isDeleting:p}){const{t:x}=Z(),c=()=>{i()};return e.jsxs("div",{role:"button",tabIndex:0,className:V("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:c,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),c())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{provider:s.provider,size:"sm"}),e.jsx(Is,{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:s.name}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1",children:x("cliproxyPage.variant")}),e.jsx(B,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:x("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:x("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),r()},disabled:p,children:e.jsx(Ls,{className:"w-3 h-3"})})]})}function Ra({onSetup:s}){const{t}=Z();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(Ne,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:t("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:t("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[t("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:t("cliproxyPage.controlPanel")}),"."]}),e.jsxs(L,{onClick:s,className:"gap-2",children:[e.jsx(ve,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]})})}function en(){const{t:s}=Z(),t=Be(),{data:a,isLoading:i}=ws(),{data:r,isFetching:p}=wt(),{data:x}=kt(),c=Ct(),l=At(),u=St(),g=Pt(),f=Mt(),h=Tt(),y=Dt(),P=Ot(),[w,C]=o.useState(()=>{if(typeof window<"u"){const _=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return _&&Fe(_)?_:localStorage.getItem("cliproxy-selected-provider")}return null}),[D,n]=o.useState(null),[b,v]=o.useState(!1),[F,O]=o.useState(()=>{if(typeof window>"u")return null;const d=new URLSearchParams(window.location.search),_=d.get("provider")?.trim().toLowerCase();return d.get("action")!=="auth"||!_||!Fe(_)?null:{provider:_,displayName:Et(_),isFirstAccount:!1}}),m=o.useMemo(()=>a?.authStatus||[],[a?.authStatus]),S=a?.source==="remote",N=o.useMemo(()=>r?.variants||[],[r?.variants]),k=d=>{C(d),d&&localStorage.setItem("cliproxy-selected-provider",d)},M=o.useMemo(()=>D?null:w&&m.some(d=>d.provider===w)?w:m.length>0&&(m.find(_=>(_.accounts?.length||0)>0)?.provider||m[0]?.provider)||null,[w,D,m]),j=m.find(d=>d.provider===M),A=N.find(d=>d.name===D),q=A?m.find(d=>d.provider===A.provider):void 0,U=(A?.provider||j?.provider||"").toLowerCase().trim(),E=U==="gemini"||U==="agy",R=()=>{t.invalidateQueries({queryKey:["cliproxy"]}),t.invalidateQueries({queryKey:["cliproxy-auth"]})},H=(d,_,z)=>{u.isPending||g.isPending||(z?u.mutate({provider:d,accountId:_}):g.mutate({provider:d,accountId:_}))},G=(d,_)=>{f.isPending||f.mutate({provider:d,accountId:_})},$=(d,_)=>{h.isPending||h.mutate({provider:d,accountIds:_})},ae=(d,_)=>{y.isPending||y.mutate({provider:d,accountIds:_})},ee=d=>{k(d),n(null)},W=d=>{n(d),k(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(Ne,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:x?.backendLabel??"CLIProxy"})]}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:R,disabled:p,children:e.jsx(Xe,{className:V("w-4 h-4",p&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(L,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>v(!0),children:[e.jsx(ve,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(ze,{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:s("cliproxyPage.providers")}),i?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(d=>e.jsx(_t,{className:"h-14 w-full rounded-lg"},d))}):e.jsx("div",{className:"space-y-1",children:m.map(d=>e.jsx(Ea,{status:d,isSelected:M===d.provider,onSelect:()=>ee(d.provider)},d.provider))}),N.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(Is,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:N.map(d=>e.jsx(_a,{variant:d,parentAuth:m.find(_=>_.provider===d.provider),isSelected:D===d.name,onSelect:()=>W(d.name),onDelete:()=>P.mutate(d.name),isDeleting:P.isPending},d.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Xt,{})}),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:s("cliproxyPage.providerCount",{count:m.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:m.filter(d=>d.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[E&&e.jsx(Us,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),A&&q?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:A.name,displayName:s("cliproxyPage.variantDisplay",{name:A.name,provider:A.provider}),authStatus:q,catalog:je[A.provider],logoProvider:A.provider,baseProvider:A.provider,defaultTarget:A.target,isRemoteMode:S,port:A.port,onAddAccount:()=>O({provider:A.provider,displayName:q.displayName,isFirstAccount:(q.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:A.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:A.provider,accountId:d}),onPauseToggle:(d,_)=>H(A.provider,d,_),onSoloMode:d=>G(A.provider,d),onBulkPause:d=>$(A.provider,d),onBulkResume:d=>ae(A.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):j?e.jsx(e.Fragment,{children:e.jsx(hs,{provider:j.provider,displayName:j.displayName,authStatus:j,catalog:je[j.provider],isRemoteMode:S,onAddAccount:()=>O({provider:j.provider,displayName:j.displayName,isFirstAccount:(j.accounts?.length||0)===0}),onSetDefault:d=>c.mutate({provider:j.provider,accountId:d}),onRemoveAccount:d=>l.mutate({provider:j.provider,accountId:d}),onPauseToggle:(d,_)=>H(j.provider,d,_),onSoloMode:d=>G(j.provider,d),onBulkPause:d=>$(j.provider,d),onBulkResume:d=>ae(j.provider,d),isRemovingAccount:l.isPending,isPausingAccount:u.isPending||g.isPending,isSoloingAccount:f.isPending,isBulkPausing:h.isPending,isBulkResuming:y.isPending})}):e.jsx(Ra,{onSetup:()=>v(!0)})]}),e.jsx(ia,{open:b,onClose:()=>v(!1)}),e.jsx(ma,{open:F!==null,onClose:()=>O(null),provider:F?.provider||"",displayName:F?.displayName||"",isFirstAccount:F?.isFirstAccount||!1})]})}export{en as CliproxyPage};
|