@kaitranntt/ccs 7.51.0-dev.12 → 7.51.0-dev.13
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 +7 -1
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +2 -0
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +5 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/shared/provider-preset-catalog.d.ts +1 -1
- package/dist/shared/provider-preset-catalog.d.ts.map +1 -1
- package/dist/shared/provider-preset-catalog.js +19 -1
- package/dist/shared/provider-preset-catalog.js.map +1 -1
- package/dist/ui/assets/{accounts-C461-bYH.js → accounts-szAllF_0.js} +1 -1
- package/dist/ui/assets/{alert-dialog-DpjPV6hi.js → alert-dialog-DPdKlUG9.js} +1 -1
- package/dist/ui/assets/api-Bq7TnM0v.js +1 -0
- package/dist/ui/assets/{auth-section-a4QIr8Cu.js → auth-section-DYPWbNRj.js} +1 -1
- package/dist/ui/assets/{backups-section-JcABaxvV.js → backups-section-gIWfCGmR.js} +1 -1
- package/dist/ui/assets/{checkbox-DCwR0qqq.js → checkbox-CcX8-GfD.js} +1 -1
- package/dist/ui/assets/{cliproxy-CvT_CrEG.js → cliproxy-SS8eRAX0.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-DwnkIgNd.js → cliproxy-control-panel-Bu0TtDft.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DY2Ziz3R.js → confirm-dialog-BZj0PYFs.js} +1 -1
- package/dist/ui/assets/{copilot-4Z8LP3vC.js → copilot-DnJj3frU.js} +2 -2
- package/dist/ui/assets/{cursor-DGcuUa4B.js → cursor-rS1S0i_y.js} +1 -1
- package/dist/ui/assets/{droid-C5Rebf4T.js → droid-Dfc2QwbE.js} +2 -2
- package/dist/ui/assets/{globalenv-section-C8zXrVbd.js → globalenv-section-BrHb5lRq.js} +1 -1
- package/dist/ui/assets/{health-B82MeRXO.js → health-B0WQPDXb.js} +1 -1
- package/dist/ui/assets/icons-BYZM_9Gm.js +1 -0
- package/dist/ui/assets/{index-BIAXf19X.js → index-BFTIN2qO.js} +1 -1
- package/dist/ui/assets/{index-z8fzygJg.js → index-BVBXszJi.js} +1 -1
- package/dist/ui/assets/index-DCQkhmoo.js +47 -0
- package/dist/ui/assets/{index-D09dhWOP.js → index-DxKsP0Ke.js} +1 -1
- package/dist/ui/assets/{index-vh-9Yvr6.js → index-LHbr_5SB.js} +1 -1
- package/dist/ui/assets/index-WBo504Wu.css +1 -0
- package/dist/ui/assets/providers/alibabacloud-color.svg +1 -0
- package/dist/ui/assets/{proxy-status-widget-K1IwJ8u6.js → proxy-status-widget-DPXgRGkB.js} +1 -1
- package/dist/ui/assets/{separator-BBQkLglZ.js → separator-DtcqgZIS.js} +1 -1
- package/dist/ui/assets/{shared-bTrmCnMf.js → shared-DPJ_z23p.js} +1 -1
- package/dist/ui/assets/{switch-D9kCIDCe.js → switch-BL5xZtnr.js} +1 -1
- package/dist/ui/assets/{updates-CIkkbMYB.js → updates-B3HKUp7y.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/api-DjGF8-45.js +0 -1
- package/dist/ui/assets/icons-kPbuhVdj.js +0 -1
- package/dist/ui/assets/index-Ck953xpy.css +0 -1
- package/dist/ui/assets/index-CsbQfRnG.js +0 -47
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as x}from"./react-vendor-CNOkPC89.js";import{B as S,c as O,T as Re,p as De,q as Le,r as Ie,s as He,t as Ue,v as Fe,w as re,d as v,I as E,a as D,n as $,L as T,x as R,y as Ne,z as Ke,A as ze,D as Qe,E as $e,S as ne,F,G as X,H as ve,J as Je,K as Be,M as be,N as we,O as Ce,Q as qe,R as Ve,U as ie,V as le,W as K,X as Ye,Y as Ge,Z as se,C as oe,j as ce,k as de,_ as xe,b as me,$ as We,a0 as Xe,a1 as Ze,a2 as es}from"./index-DCQkhmoo.js";import{a as ss,u as ts,b as ue}from"./tanstack-e99Cjjy2.js";import{C as Z}from"./confirm-dialog-BZj0PYFs.js";import{t as H}from"./notifications-B2HqRBj7.js";import{L as z,R as J,ah as ye,ai as as,E as rs,e as ns,a1 as Q,J as is,aj as ke,a2 as te,C as Pe,ak as ls,a0 as os,al as cs,n as ee,X as ds,Z as Te,am as he,an as Ee,l as xs,a5 as ms,a3 as Oe,ao as us,u as Se}from"./icons-BYZM_9Gm.js";import{S as pe}from"./separator-DtcqgZIS.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DPdKlUG9.js";function hs({className:s,showTooltip:t=!0}){const n=e.jsxs(S,{variant:"outline",className:O("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return t?e.jsxs(Re,{children:[e.jsx(De,{asChild:!0,children:n}),e.jsx(Le,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function ge(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function _e(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function ps(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function gs(s,t){const n={...s};return t.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function fs({profileName:s,target:t,data:n,settings:a,isLoading:l,isSaving:p,isTargetSaving:m,hasChanges:g,isRawJsonValid:r,onTargetChange:N,onRefresh:u,onDelete:f,onSave:k}){const b=p||m,j=l||b;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(S,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),_e(a)&&e.jsx(hs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ie,{value:t,onValueChange:w=>{j||N(w)},disabled:j,children:[e.jsx(He,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(Ue,{})}),e.jsxs(Fe,{children:[e.jsx(re,{value:"claude",children:"Claude Code"}),e.jsx(re,{value:"droid",children:"Factory Droid"})]})]}),m&&e.jsx(z,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:u,disabled:j,children:e.jsx(J,{className:`w-4 h-4 ${l?"animate-spin":""}`})}),f&&e.jsx(v,{variant:"ghost",size:"sm",onClick:f,disabled:b,children:e.jsx(ye,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:k,disabled:b||!g||!r,children:p?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ae({label:s,...t}){const[n,a]=x.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(E,{type:n?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>a(!n),tabIndex:-1,children:n?e.jsx(rs,{className:"w-4 h-4"}):e.jsx(ns,{className:"w-4 h-4"})})]})]})}function js({currentSettings:s,newEnvKey:t,newEnvValue:n,onNewEnvKeyChange:a,onNewEnvValueChange:l,onEnvValueChange:p,onAddEnvVar:m}){const{t:g}=D();return e.jsxs(e.Fragment,{children:[e.jsx($,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([r,N])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[r,ge(r)&&e.jsx(S,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:g("envEditor.sensitive")})]}),ge(r)?e.jsx(Ae,{value:N,onChange:u=>p(r,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(E,{value:N,onChange:u=>p(r,u.target.value),className:"font-mono text-sm h-8"})]},r))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:g("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:g("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:g("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(E,{placeholder:g("envEditor.keyPlaceholder"),value:t,onChange:r=>a(r.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:r=>r.key==="Enter"&&t.trim()&&m()}),e.jsx(E,{placeholder:g("envEditor.valuePlaceholder"),value:n,onChange:r=>l(r.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:r=>r.key==="Enter"&&t.trim()&&m()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:m,disabled:!t.trim(),children:e.jsx(Q,{className:"w-4 h-4"})})]})]})]})}function Ns({profileName:s,target:t,data:n}){const{t:a}=D(),l=t==="droid";return e.jsx($,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(is,{className:"w-4 h-4"}),a("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:a("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),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:a("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(R,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:a("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.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:a("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:t})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:a("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(R,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a(l?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),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:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`}),e.jsx(R,{value:l?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a(l?"profileEditor.overrideToClaude":"profileEditor.overrideToClaudeExplicit")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' --target claude "prompt"']}),e.jsx(R,{value:`ccs ${s} --target claude "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:a("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(R,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function vs({value:s,onChange:t,placeholder:n="Search models...",className:a}){const[l,p]=x.useState(""),[m,g]=x.useState(null),{models:r,isLoading:N,isError:u,isFetching:f}=Ne(),k=Ke(),b=x.useMemo(()=>ze(r,l,{category:m??void 0}),[r,l,m]),j=x.useMemo(()=>Qe(r,2),[r]),w=!l.trim()&&!m,_=x.useMemo(()=>{const o={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};b.forEach(c=>{o[c.category].push(c)});for(const c of Object.keys(o))o[c]=$e(o[c]);return o},[b]),A=x.useCallback(()=>{k()},[k]),y=r.find(o=>o.id===s);return N&&r.length===0?e.jsxs("div",{className:O("space-y-2",a),children:[e.jsx(ne,{className:"h-10 w-full"}),e.jsx(ne,{className:"h-32 w-full"})]}):e.jsxs("div",{className:O("space-y-2 w-full min-w-0 overflow-hidden",a),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ke,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(E,{value:l,onChange:o=>p(o.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:A,disabled:f,title:"Refresh models",children:f?e.jsx(z,{className:"h-4 w-4 animate-spin"}):e.jsx(J,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(S,{variant:m===null?"default":"outline",className:"cursor-pointer",onClick:()=>g(null),children:["All (",r.length,")"]}),Object.keys(F).map(o=>{const c=_[o].length;return c===0?null:e.jsxs(S,{variant:m===o?"default":"outline",className:"cursor-pointer",onClick:()=>g(o),children:[F[o]," (",c,")"]},o)})]}),y&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:y.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[X(y.pricing)," |"," ",ve(y.context_length)]})]}),e.jsx($,{className:"h-72 w-full rounded-md border",children:u?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:A,children:"Retry"})]}):b.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',l,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[w&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(te,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(o=>e.jsx(fe,{model:o,isSelected:o.id===s,onClick:()=>t(o.id),showAge:!0},o.id))})]}),Object.keys(F).map(o=>{const c=_[o];return c.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:F[o]}),e.jsx("div",{className:"space-y-1",children:c.map(i=>e.jsx(fe,{model:i,isSelected:i.id===s,onClick:()=>t(i.id)},i.id))})]},o)})]})})]})}function fe({model:s,isSelected:t,onClick:n,showAge:a=!1}){return e.jsxs("button",{type:"button",onClick:n,className:O("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",t&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:O("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[a&&s.created&&e.jsx(S,{variant:"outline",className:O("text-[10px] px-1",t?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:Je(s.created)}),s.isFree?e.jsx(S,{variant:"secondary",className:O("text-[10px] px-1",t?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",className:O("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:X(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:X(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:ve(s.context_length)})]})]})}function bs({selectedModel:s,value:t,onChange:n,className:a}){const{t:l}=D(),{models:p}=Ne(),m=x.useMemo(()=>s?Be(s,p):{},[s,p]),g=()=>{n(m)},r=(u,f)=>{n({...t,[u]:f||void 0})},N=s&&Object.keys(m).length>0;return e.jsxs(be,{className:O("group",a),children:[e.jsxs(we,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Pe,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),l("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",l("modelTierMapping.advanced"),")"]})]}),e.jsxs(Ce,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:l("modelTierMapping.description")}),N&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(ls,{className:"mr-1 h-4 w-4"}),l("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(E,{id:"tier-opus",value:t.opus??"",onChange:u=>r("opus",u.target.value),placeholder:l("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(E,{id:"tier-sonnet",value:t.sonnet??"",onChange:u=>r("sonnet",u.target.value),placeholder:l("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(E,{id:"tier-haiku",value:t.haiku??"",onChange:u=>r("haiku",u.target.value),placeholder:l("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l("modelTierMapping.footer")})]})]})}function ws({profileName:s,target:t,data:n,currentSettings:a,newEnvKey:l,newEnvValue:p,onNewEnvKeyChange:m,onNewEnvValueChange:g,onEnvValueChange:r,onAddEnvVar:N,onEnvBulkChange:u}){const f=_e(a),k=a?.env,b=x.useMemo(()=>ps(k??{}),[k]),j=k??{},w=i=>{if(u){const P={...j,ANTHROPIC_MODEL:i,ANTHROPIC_DEFAULT_OPUS_MODEL:i,ANTHROPIC_DEFAULT_SONNET_MODEL:i,ANTHROPIC_DEFAULT_HAIKU_MODEL:i};u(P)}else r("ANTHROPIC_MODEL",i),r("ANTHROPIC_DEFAULT_OPUS_MODEL",i),r("ANTHROPIC_DEFAULT_SONNET_MODEL",i),r("ANTHROPIC_DEFAULT_HAIKU_MODEL",i);H.success(K.t("commonToast.appliedModelAllTiers"),{duration:2e3})},_=i=>{if(u){const P=gs(j,i);u(P)}else i.opus!==void 0&&r("ANTHROPIC_DEFAULT_OPUS_MODEL",i.opus||""),i.sonnet!==void 0&&r("ANTHROPIC_DEFAULT_SONNET_MODEL",i.sonnet||""),i.haiku!==void 0&&r("ANTHROPIC_DEFAULT_HAIKU_MODEL",i.haiku||"")},[A,y]=x.useState(!1),o=new Set(["ANTHROPIC_AUTH_TOKEN"]),c=Object.entries(j).filter(([i])=>!o.has(i));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(qe,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Ve,{className:"w-full",children:[e.jsx(ie,{value:"env",className:"flex-1",children:f?"Configuration":"Environment Variables"}),e.jsx(ie,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(le,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(vs,{value:j.ANTHROPIC_MODEL,onChange:w,placeholder:"Search OpenRouter models..."})]}),e.jsx(bs,{selectedModel:j.ANTHROPIC_MODEL,value:b,onChange:_}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Ae,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:i=>r("ANTHROPIC_AUTH_TOKEN",i.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),c.length>0&&e.jsxs(be,{open:A,onOpenChange:y,children:[e.jsxs(we,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Pe,{className:O("h-4 w-4 transition-transform",A&&"rotate-90")}),e.jsx(os,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",c.length,")"]})]}),e.jsx(Ce,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:c.map(([i,P])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:i}),e.jsx(E,{value:P,onChange:L=>r(i,L.target.value),className:"font-mono text-xs h-8"})]},i))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(E,{placeholder:"VARIABLE_NAME",value:l,onChange:i=>m(i.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:i=>i.key==="Enter"&&l.trim()&&N()}),e.jsx(E,{placeholder:"value",value:p,onChange:i=>g(i.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:i=>i.key==="Enter"&&l.trim()&&N()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:N,disabled:!l.trim(),children:e.jsx(Q,{className:"w-4 h-4"})})]})]})]}):e.jsx(js,{currentSettings:a,newEnvKey:l,newEnvValue:p,onNewEnvKeyChange:m,onNewEnvValueChange:g,onEnvValueChange:r,onAddEnvVar:N})}),e.jsx(le,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ns,{profileName:s,target:t,data:n})})]})]})})}function Cs({profileName:s,profileTarget:t,onDelete:n,onHasChangesUpdate:a}){const[l,p]=x.useState({}),[m,g]=x.useState(!1),[r,N]=x.useState(null),[u,f]=x.useState(""),[k,b]=x.useState(""),j=ss(),{data:w,isLoading:_,isError:A,refetch:y}=ts({queryKey:["settings",s],queryFn:async()=>{const d=await fetch(`/api/settings/${s}/raw`);if(!d.ok)throw new Error(`Failed to load settings: ${d.status}`);return d.json()}}),o=w?.settings,c=x.useMemo(()=>{if(r!==null)try{return JSON.parse(r)}catch{}if(o)return{...o,env:{...o.env,...l}}},[o,l,r]),i=x.useMemo(()=>r!==null?r:o?JSON.stringify(o,null,2):"",[r,o]),P=x.useCallback(d=>{N(d)},[]),L=(d,C)=>{const M={...c?.env||{},[d]:C};p(I=>({...I,[d]:C})),N(JSON.stringify({...c,env:M},null,2))},B=d=>{const C={...c?.env||{},...d};p(M=>({...M,...d})),N(JSON.stringify({...c,env:C},null,2))},q=()=>{if(!u.trim())return;const d=u.trim(),C=k,M={...c?.env||{},[d]:C};p(I=>({...I,[d]:C})),N(JSON.stringify({...c,env:M},null,2)),f(""),b("")},h=x.useMemo(()=>{try{return JSON.parse(i),!0}catch{return!1}},[i]),V=x.useMemo(()=>r!==null?r!==JSON.stringify(o,null,2):Object.keys(l).length>0,[r,l,o]),Me=x.useMemo(()=>{const d=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],C=c?.env||{};return d.filter(M=>!C[M]?.trim())},[c]);x.useEffect(()=>{a?.(V)},[V,a]);const U=ue({mutationFn:async()=>{let d;try{d=JSON.parse(i)}catch{d={...w?.settings,env:{...w?.settings?.env,...l}}}const C=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:d,expectedMtime:w?.mtime})});if(C.status===409)throw new Error("CONFLICT");if(!C.ok)throw new Error("Failed to save");return C.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),p({}),N(null),H.success(K.t("commonToast.settingsSaved"))},onError:d=>{d.message==="CONFLICT"?g(!0):H.error(d.message)}}),Y=ue({mutationFn:async d=>(await Ge.profiles.update(s,{target:d}),d),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),H.success(K.t("commonToast.defaultTargetUpdated"))},onError:(d,C)=>{const M=C==="droid"?"Factory Droid":"Claude Code",I=d.message.trim()?`: ${d.message}`:"";H.error(K.t("commonToast.failedUpdateDefaultTarget",{target:M,suffix:I}))}}),G=t||"claude",W=U.isPending||Y.isPending,ae=async d=>{g(!1),d?(await y(),U.mutate()):(p({}),N(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(fs,{profileName:s,target:G,data:w,settings:c,isLoading:_,isSaving:U.isPending,isTargetSaving:Y.isPending,hasChanges:V,isRawJsonValid:h,onTargetChange:d=>{W||d!==G&&Y.mutate(d)},onRefresh:()=>{W||y()},onDelete:n,onSave:()=>{W||U.mutate()}}),_?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(z,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):A?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>y(),children:[e.jsx(J,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):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 min-w-0",children:e.jsx(ws,{profileName:s,target:G,data:w,currentSettings:c,newEnvKey:u,newEnvValue:k,onNewEnvKeyChange:f,onNewEnvValueChange:b,onEnvValueChange:L,onEnvBulkChange:B,onAddEnvVar:q})}),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(cs,{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(Ye,{rawJsonContent:i,isRawJsonValid:h,rawJsonEdits:r,settings:o,onChange:P,missingRequiredFields:Me})]})]}),e.jsx(Z,{open:m,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ae(!0),onCancel:()=>ae(!1)})]},s)}const je="ccs:openrouter-banner-dismissed";function ys({onCreateClick:s}){const[t,n]=x.useState(!0),{modelCount:a,isLoading:l}=se();x.useEffect(()=>{const m=localStorage.getItem(je)==="true";n(m)},[]);const p=()=>{localStorage.setItem(je,"true"),n(!0)};return t?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(te,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",l?"300+":`${a}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(ee,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:p,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ds,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ks({onOpenRouterClick:s,onAlibabaCodingPlanClick:t,onCustomClick:n}){const{t:a}=D(),{modelCount:l,isLoading:p}=se();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20 p-8",children:e.jsxs("div",{className:"max-w-lg w-full space-y-6",children:[e.jsxs(oe,{className:"border-accent/30 dark:border-accent/40 bg-gradient-to-br from-accent/5 to-background dark:from-accent/10",children:[e.jsxs(ce,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 dark:bg-accent/20",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"w-6 h-6"})}),e.jsx(S,{variant:"secondary",className:"bg-accent/10 text-accent dark:bg-accent/20 dark:text-accent-foreground",children:a("openrouterQuickStart.recommended")})]}),e.jsx(de,{className:"text-xl",children:a("openrouterQuickStart.title")}),e.jsx(xe,{className:"text-base",children:a("openrouterQuickStart.description",{modelCountLabel:p?"300+":`${l}+`})})]}),e.jsxs(me,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Te,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:a("openrouterQuickStart.featureOneApi")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(te,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:a("openrouterQuickStart.featureTierMapping")})]})]}),e.jsxs(v,{onClick:s,className:"w-full bg-accent hover:bg-accent/90 text-white",size:"lg",children:[a("openrouterQuickStart.createOpenRouterProfile"),e.jsx(he,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:["openrouter.ai/keys",e.jsx(ee,{className:"w-3 h-3"})]})]})]})]}),e.jsxs(oe,{className:"border-orange-500/30 dark:border-orange-500/40 bg-gradient-to-br from-orange-500/5 to-background dark:from-orange-500/10",children:[e.jsxs(ce,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10 dark:bg-orange-500/20",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"w-6 h-6"})}),e.jsx(S,{variant:"secondary",className:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",children:a("alibabaCodingPlanQuickStart.recommended")})]}),e.jsx(de,{className:"text-xl",children:a("alibabaCodingPlanQuickStart.title")}),e.jsx(xe,{className:"text-base",children:a("alibabaCodingPlanQuickStart.description")})]}),e.jsxs(me,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ee,{className:"w-4 h-4 text-orange-600"}),e.jsx("span",{children:a("alibabaCodingPlanQuickStart.featureEndpoint")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(xs,{className:"w-4 h-4 text-orange-600"}),e.jsx("span",{children:a("alibabaCodingPlanQuickStart.featureKeyFormat")})]})]}),e.jsxs(v,{onClick:t,className:"w-full bg-orange-600 hover:bg-orange-600/90 text-white",size:"lg",children:[a("alibabaCodingPlanQuickStart.createAlibabaProfile"),e.jsx(he,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"text-orange-700 dark:text-orange-400 hover:underline inline-flex items-center gap-1",children:["Alibaba Cloud Model Studio",e.jsx(ee,{className:"w-3 h-3"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(pe,{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a("openrouterQuickStart.or")}),e.jsx(pe,{className:"flex-1"})]}),e.jsx(v,{variant:"outline",onClick:n,className:"w-full",children:a("openrouterQuickStart.createCustomProfile")})]})})}function Ps({onCreateClick:s}){const{modelCount:t,isLoading:n}=se();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${t}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Te,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Ts({onCreateClick:s}){const{t}=D();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:t("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ee,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:t("alibabaCodingPlanPromo.add")})]})]})})}function Ks(){const{t:s}=D(),{data:t,isLoading:n,isError:a,refetch:l}=We(),p=Xe(),[m,g]=x.useState(null),[r,N]=x.useState(""),[u,f]=x.useState(!1),[k,b]=x.useState("normal"),[j,w]=x.useState(null),[_,A]=x.useState(!1),[y,o]=x.useState(null);Ze();const c=x.useMemo(()=>t?.profiles||[],[t?.profiles]),i=x.useMemo(()=>c.filter(h=>h.name.toLowerCase().includes(r.toLowerCase())),[c,r]),P=m?c.find(h=>h.name===m):null,L=h=>{p.mutate(h,{onSuccess:()=>{m===h&&g(null),w(null)}})},B=h=>{f(!1),_&&m!==null?o(h):g(h)},q=h=>{_&&m!==h?o(h):g(h)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:[e.jsx(ys,{onCreateClick:()=>f(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0",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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ms,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs(v,{size:"sm",onClick:()=>{f(!0)},children:[e.jsx(Q,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ke,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(E,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:r,onChange:h=>N(h.target.value)})]})]}),e.jsx($,{className:"flex-1",children:n?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):a?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Oe,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>l(),children:[e.jsx(J,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):i.length===0?e.jsx("div",{className:"p-4 text-center",children:c.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(us,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>{f(!0)},children:[e.jsx(Q,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:r})})}):e.jsx("div",{className:"p-2 space-y-1",children:i.map(h=>e.jsx(Es,{profile:h,isSelected:m===h.name,onSelect:()=>q(h.name),onDelete:()=>w(h.name)},h.name))})}),c.length>0&&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("apiProfiles.profileCount",{count:c.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Se,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:c.filter(h=>h.configured).length})]})]})}),e.jsx(Ps,{onCreateClick:()=>{b("openrouter"),f(!0)}}),e.jsx(Ts,{onCreateClick:()=>{b("alibaba-coding-plan"),f(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:P?e.jsx(Cs,{profileName:P.name,profileTarget:P.target,onDelete:()=>w(P.name),onHasChangesUpdate:A},P.name):e.jsx(ks,{onOpenRouterClick:()=>{b("openrouter"),f(!0)},onAlibabaCodingPlanClick:()=>{b("alibaba-coding-plan"),f(!0)},onCustomClick:()=>{b("normal"),f(!0)}})})]}),e.jsx(es,{open:u,onOpenChange:f,onSuccess:B,initialMode:k}),e.jsx(Z,{open:!!j,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:j??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>j&&L(j),onCancel:()=>w(null)}),e.jsx(Z,{open:!!y,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:m??"",next:y??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{A(!1),g(y),o(null)},onCancel:()=>o(null)})]})}function Es({profile:s,isSelected:t,onSelect:n,onDelete:a}){return e.jsxs("div",{className:O("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(Se,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Oe,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(S,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(R,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),a()},children:e.jsx(ye,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{Ks as ApiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bg as W,b7 as X,b9 as Y,n as Z,I as C,d as c}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bg as W,b7 as X,b9 as Y,n as Z,I as C,d as c}from"./index-DCQkhmoo.js";import{R as E,a3 as _,u as ee,l as se,E as K,e as T,k as R,m as z,aA as te,a2 as ae,z as ne,ai as re}from"./icons-BYZM_9Gm.js";import"./tanstack-e99Cjjy2.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,k]=n.useState(!1),[F,b]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const Q=await A.json();throw new Error(Q.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},J=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),k(!0),setTimeout(()=>k(!1),2e3))},L=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),b(!0),setTimeout(()=>b(!1),2e3))},q=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const G=d??a.apiKey.value,H=u??a.managementSecret.value,M=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:G,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:H,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:L,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:B,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:q,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!M||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bg as E,n as k,S as n,C as g,b7 as R,b9 as D,B as T,d as C}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bg as E,n as k,S as n,C as g,b7 as R,b9 as D,B as T,d as C}from"./index-DCQkhmoo.js";import{A as O,a as _,b as z,c as F,d as I,e as P,f as L,g as U}from"./alert-dialog-DPdKlUG9.js";import{a3 as $,u as H,a6 as y,t as M,z as Y,R as J}from"./icons-BYZM_9Gm.js";import"./tanstack-e99Cjjy2.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";const q=3e3,G=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,v]=r.useState([]),[f,N]=r.useState(!0),[u,w]=r.useState(null),[i,l]=r.useState(null),[c,b]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();v(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{w(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}b(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{w(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>b(null),q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),G);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(z,{children:[e.jsx(F,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(I,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(P,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,a0 as i,a1 as t}from"./radix-ui-BR1vy4kf.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-
|
|
1
|
+
import{j as r,a0 as i,a1 as t}from"./radix-ui-BR1vy4kf.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-DCQkhmoo.js";import{k as o}from"./icons-BYZM_9Gm.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{a as Ke,u as bs,b as zs}from"./tanstack-e99Cjjy2.js";import{d as R,C as ks,b as Cs,c as B,P as Ae,a as ee,a3 as Z,L as Y,I as ce,r as Ve,s as Be,t as Ge,v as $e,w as je,a4 as As,a5 as Js,a6 as Ws,a7 as Xs,u as Ss,a8 as Qe,a9 as ze,aa as Je,ab as We,ac as Ps,ad as ls,ae as Ys,af as Zs,W as Ds,ag as Ie,ah as Ms,Y as be,B as H,ai as Fe,aj as cs,ak as et,al as st,am as tt,an as at,ao as ds,ap as us,aq as nt,x as Ts,n as Xe,ar as it,as as rt,at as ot,m as lt,au as ct,av as dt,aw as ut,ax as mt,ay as xt,az as pt,aA as ue,T as me,p as xe,q as pe,aB as ht,aC as gt,aD as ft,aE as ms,aF as jt,aG as vt,aH as Nt,aI as yt,aJ as wt,aK as bt,aL as kt,Q as Ct,R as At,U as xs,V as ps,aM as St,aN as Pt,aO as Dt,aP as Mt,aQ as Tt,aR as Ot,aS as Et,aT as _t,aU as Rt,aV as Lt,aW as It,aX as Ft,S as Ut}from"./index-CsbQfRnG.js";import{C as Ue}from"./default-ports-1QQSffYX.js";import{t as q}from"./notifications-B2HqRBj7.js";import{C as Os,L as W,n as ge,N as qt,k as ne,m as Es,ao as Ye,R as Ze,o as fe,a2 as Ne,T as es,a0 as Ht,ap as _s,aq as Kt,ar as Se,Z as ye,J as Rs,g as Vt,s as Ls,as as Bt,ai as Gt,X as ss,a1 as Is,w as Fs,x as qe,at as $t,t as hs,au as Qt,ah as Us,u as zt,av as gs,l as Jt,a3 as Wt,al as Xt,aw as qs}from"./icons-kPbuhVdj.js";import{R as ke,A as fs,D as Ee,i as Yt,a as Zt,P as ea}from"./proxy-status-widget-K1IwJ8u6.js";import{C as Ce}from"./checkbox-DCwR0qqq.js";import{C as sa}from"./confirm-dialog-DY2Ziz3R.js";import{S as ts}from"./separator-BBQkLglZ.js";import{S as Hs}from"./switch-D9kCIDCe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DpjPV6hi.js";const ve={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.3-codex",models:[{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",description:"Supports up to xhigh effort",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Previous stable Codex model",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high effort (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.3-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",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",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"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-5-20250929",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-5-20250929",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"}]}},_e="ccs-internal-managed";async function ta(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??_e:_e}catch{return _e}}async function He(s,a){const t=ve[s];if(!t)return{success:!1};const n=t.models[0],i=n?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},c=await ta(),o={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${Ue}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:c,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}function aa({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},t))})}function na({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.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:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function ia({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:c,onStartAuth:m,onRefresh:o}){const[p,f]=l.useState(!1),N=async u=>{await navigator.clipboard.writeText(u),f(!0),setTimeout(()=>f(!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 ",a.find(u=>u.id===s)?.name," to add an account"]}),e.jsx(R,{onClick:m,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&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(ks,{children:e.jsxs(Cs,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(qt,{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:t}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>N(t),children:p?e.jsx(ne,{className:"w-4 h-4 text-green-500"}):e.jsx(Es,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(R,{variant:"outline",onClick:o,disabled:n||i,children:[e.jsx(Ze,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function ra({accounts:s,privacyMode:a,onSelect:t,onAddNew:n,onBack:i}){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(c=>e.jsxs("button",{type:"button",onClick:()=>t(c),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(fe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:B("font-medium",a&&Ae),children:c.email||c.id}),c.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"})]},c.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:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ge,{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(R,{variant:"ghost",onClick:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const js="__custom__";function oa({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:c,onVariantNameChange:m,onModelChange:o,onBack:p,onSkip:f,onCreate:N}){const{t:u}=ee(),r=ve[s]?.models||[],b=n&&!r.some(v=>v.id===n),[j,x]=l.useState(b),M=s==="agy"&&n.trim().length>0?Z(n):!1,g=v=>{v===js?(x(!0),o("")):(x(!1),o(v))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsxs("span",{children:[u("setupVariant.using")," ",e.jsx("span",{className:B(c&&Ae),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:u("setupVariant.variantNameRequired")}),e.jsx(ce,{id:"variant-name",value:t,onChange:v=>m(v.target.value),placeholder:u("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[u("setupVariant.invokeHintPrefix")," ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:u("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:n,onChange:v=>o(v.target.value),placeholder:u("setupVariant.modelPlaceholder")}),M&&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:()=>{x(!1),s==="agy"&&Z(n)&&o("")},children:u("setupVariant.choosePresetInstead")})]}):e.jsxs(Ve,{value:r.some(v=>v.id===n)?n:"",onValueChange:g,children:[e.jsx(Be,{children:e.jsx(Ge,{placeholder:u("setupVariant.selectModel")})}),e.jsxs($e,{children:[r.map(v=>e.jsx(je,{value:v.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:v.name}),v.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",v.description]})]})},v.id)),e.jsx(je,{value:js,children:e.jsx("span",{className:"text-primary",children:u("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?u("setupVariant.enterAnyModel"):u("setupVariant.defaultModel",{model:ve[s]?.defaultModel||u("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(R,{variant:"ghost",onClick:p,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),u("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"ghost",onClick:f,children:u("setupVariant.skip")}),e.jsx(R,{onClick:N,disabled:!t||i||M,children:u(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:u("setupVariant.skipHint")})]})}function la({variantName:s,onClose:a}){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(ne,{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(ks,{children:e.jsxs(Cs,{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(R,{onClick:a,className:"w-full",children:"Done"})]})}function ca({open:s,onClose:a}){const[t,n]=l.useState("provider"),[i,c]=l.useState(""),[m,o]=l.useState(null),[p,f]=l.useState(""),[N,u]=l.useState(""),[r,b]=l.useState(!1),[j,x]=l.useState(!1),{data:M,refetch:g}=As(),v=Js(),E=Ws(),C=Xs(),{privacyMode:I}=Ss(),D=M?.authStatus.find(T=>T.provider===i),h=l.useMemo(()=>D?.accounts||[],[D?.accounts]);l.useEffect(()=>{if(!s){const T=setTimeout(()=>{n("provider"),c(""),o(null),f(""),u(""),x(!1)},0);return()=>clearTimeout(T)}},[s]),l.useEffect(()=>{if(t==="auth"&&h.length>0&&!j){const T=setTimeout(()=>{n("account")},0);return()=>clearTimeout(T)}},[t,h,j]);const F=async()=>{b(!0),await g(),b(!1)},y=()=>{const T=(D?.accounts?.length||0)===0;E.mutate({provider:i},{onSuccess:async _=>{if(T){const U=await He(i);U.success&&U.presetName?q.success(`Applied "${U.presetName}" preset`):U.success||q.warning(Ds.t("commonToast.accountAddedPresetFailed"))}_.account&&(o(_.account),n("variant")),g()}})},A=T=>{c(T),(M?.authStatus.find(V=>V.provider===T)?.accounts||[]).length===0?n("auth"):n("account")},w=T=>{o(T),n("variant")},S=async()=>{if(!(!p||!i))try{await v.mutateAsync({name:p,provider:i,model:N||void 0,account:m?.id}),n("success")}catch(T){console.error("Failed to create variant:",T)}},k=`ccs ${i} --auth --add`,K=Zs(t),G=T=>{if(!T&&(E.isPending&&i&&C.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(Qe,{open:s,onOpenChange:G,children:e.jsxs(ze,{className:"sm:max-w-lg",onPointerDownOutside:T=>{t!=="success"&&t!=="provider"&&T.preventDefault()},onEscapeKeyDown:T=>{(E.isPending||v.isPending)&&T.preventDefault()},children:[e.jsxs(Je,{children:[e.jsxs(We,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Ps,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(na,{providers:ls,onSelect:A}),t==="auth"&&e.jsx(ia,{selectedProvider:i,providers:ls,authCommand:k,isRefreshing:r,isPending:E.isPending,onBack:()=>n("provider"),onStartAuth:y,onRefresh:F}),t==="account"&&e.jsx(ra,{accounts:h,privacyMode:I,onSelect:w,onAddNew:()=>{x(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(oa,{selectedProvider:i,selectedAccount:m,variantName:p,modelName:N,isPending:v.isPending,privacyMode:I,onVariantNameChange:f,onModelChange:u,onBack:()=>h.length>0?n("account"):n("provider"),onSkip:a,onCreate:S}),t==="success"&&e.jsx(la,{variantName:p,onClose:a})]}),e.jsx(aa,{currentProgress:K,allSteps:Ys})]})})}const da=3e3,ua=300*1e3;async function Re(s){const a=await s.text();if(!a)return{};try{return JSON.parse(a)}catch{const t=s.status>=400?`Request failed with status ${s.status}`:void 0;return t?{error:t}:{}}}const le={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ma(){const[s,a]=l.useState(le),t=l.useRef(null),n=l.useRef(null),i=l.useRef(0),c=l.useRef(!1),m=Ke(),o=l.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);l.useEffect(()=>()=>{t.current?.abort(),o(),c.current=!1},[o]);const p=l.useCallback(async(r,b)=>{if(Date.now()-i.current>ua){o(),a(j=>({...j,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const x=await(await fetch(`/api/cliproxy/auth/${r}/status?state=${encodeURIComponent(b)}`)).json();if(x.status==="ok")o(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),q.success(`${r} authentication successful`),c.current=!1,a(le);else if(x.status==="auth_url"){const M=x.url||x.auth_url;M&&(a(g=>({...g,authUrl:M})),c.current||(c.current=!0,window.open(M,"_blank")))}else if(x.status==="device_code"){o();const M=x.user_code&&x.verification_url?`Open ${x.verification_url} and enter code: ${x.user_code}`:"Switch to Device Code method and try again.";q.error("Provider returned Device Code flow in callback mode"),a(g=>({...g,isAuthenticating:!1,error:M}))}else if(x.status==="error"){o();const M=x.error||"Authentication failed";q.error(M),a(g=>({...g,isAuthenticating:!1,error:M}))}}catch{}},[m,o]),f=l.useCallback(async(r,b)=>{if(!Ie(r)){a({...le,error:`Unknown provider: ${r}`});return}t.current?.abort(),o(),c.current=!1;const j=new AbortController;t.current=j;const M=(b?.flowType||(Ms(r)?"device_code":"authorization_code"))==="device_code",g=b?.startEndpoint||(M?"start":"start-url"),v={nickname:b?.nickname,kiroMethod:b?.kiroMethod,riskAcknowledgement:b?.riskAcknowledgement};a({provider:r,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:M});try{if(g==="start")fetch(`/api/cliproxy/auth/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:j.signal}).then(async E=>{const C=await Re(E),I=C.success===!0;if(E.ok&&I)m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),c.current=!1,a(le);else{const D=typeof C.error=="string"?C.error:"Authentication failed";q.error(D),a(h=>({...h,isAuthenticating:!1,error:D}))}}).catch(E=>{if(E instanceof Error&&E.name==="AbortError")return;const C=E instanceof Error?E.message:"Authentication failed";q.error(C),a(I=>({...I,isAuthenticating:!1,error:C}))});else{const E=await fetch(`/api/cliproxy/auth/${r}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:j.signal}),C=await Re(E),I=C.success===!0;if(!E.ok||!I){const F=typeof C.error=="string"?C.error:"Failed to start OAuth";throw new Error(F)}const D=typeof C.authUrl=="string"?C.authUrl:null,h=typeof C.state=="string"?C.state:null;a(F=>({...F,authUrl:D,oauthState:h})),D&&(c.current=!0,window.open(D,"_blank")),h&&(i.current=Date.now(),n.current=setInterval(()=>{p(r,h)},da))}}catch(E){if(E instanceof Error&&E.name==="AbortError"){c.current=!1,a(le);return}const C=E instanceof Error?E.message:"Authentication failed";q.error(C),a(I=>({...I,isAuthenticating:!1,error:C}))}},[p,o,m]),N=l.useCallback(()=>{const r=s.provider;t.current?.abort(),o(),c.current=!1,a(le),r&&be.cliproxy.auth.cancel(r).catch(()=>{})},[s.provider,o]),u=l.useCallback(async r=>{if(s.provider){a(b=>({...b,isSubmittingCallback:!0,error:null}));try{const b=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:r})}),j=await Re(b),x=j.success===!0;if(b.ok&&x)o(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),q.success(`${s.provider} authentication successful`),a(le);else{const M=typeof j.error=="string"?j.error:"Callback submission failed";throw new Error(M)}}catch(b){const j=b instanceof Error?b.message:"Failed to submit callback";q.error(j),a(x=>({...x,isSubmittingCallback:!1,error:j}))}}},[s.provider,m,o]);return l.useMemo(()=>({...s,startAuth:f,cancelAuth:N,submitCallback:u}),[s,f,N,u])}function Ks({className:s,showAcknowledgement:a=!1,acknowledgementPhrase:t=ke,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:c=!1,showProxySettingsLink:m=!1}){const{t:o}=ee(),p=o("accountSafetyWarning.title"),f=o("accountSafetyWarning.subtitle"),N=o("accountSafetyWarning.firstLine"),u=o("accountSafetyWarning.secondLine"),r="https://github.com/kaitranntt/ccs/issues/509",b=o("accountSafetyWarning.issueLabel"),j=o("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:B("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(es,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f})]})]}),e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:N}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:u}),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:r,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:[b,e.jsx(ge,{className:"h-3.5 w-3.5"})]}),m&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Ht,{className:"h-3.5 w-3.5"}),j]}),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"})]}),a&&i&&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:t})]}),e.jsx(ce,{id:"account-risk-ack-text",value:n,onChange:x=>i(x.target.value),placeholder:t,disabled:c,className:"mt-2 font-mono text-xs"})]})]})]})}function xa({className:s,value:a,onChange:t,disabled:n=!1}){const{t:i}=ee(),c=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===fs].filter(Boolean).length,m=c/4*100,o=p=>{t({...a,...p})};return e.jsxs("section",{role:"alert",className:B("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(es,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:c})})]}),e.jsx(Fe,{value:m,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:a.reviewedIssue509,onCheckedChange:p=>o({reviewedIssue509:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:p=>o({understandsBanRisk:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:p=>o({acceptsFullResponsibility:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(_s,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(ce,{value:a.typedPhrase,onChange:p=>o({typedPhrase:p.target.value}),placeholder:fs,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(ge,{className:"h-3.5 w-3.5"})]})})]})]})}function pa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ha({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[c,m]=l.useState(""),[o,p]=l.useState(""),[f,N]=l.useState(!1),[u,r]=l.useState(null),[b,j]=l.useState(""),[x,M]=l.useState(Ee),[g,v]=l.useState(!1),[E,C]=l.useState(!1),[I,D]=l.useState(cs),{t:h}=ee(),F=l.useRef(!1),y=ma(),A=et(),w=t==="kiro",S=t==="gemini",k=t==="agy"&&!g,K=t==="agy"&&E,G=Yt(x),T=pa(b)===ke,_=Ms(t),U=st(t),V=tt(I),se=w?V.flowType==="device_code":_,z=y.isAuthenticating||A.isPending,X=c.trim(),te=u||y.error,d=l.useCallback(async()=>{const P=await fetch("/api/settings/auth/antigravity-risk");if(!P.ok)throw new Error("Failed to load Antigravity power user setting");return(await P.json()).antigravityAckBypass===!0},[]),O=()=>{m(""),p(""),N(!1),r(null),j(""),M(Ee),v(!1),C(!1),D(cs),F.current=!1,a()};l.useEffect(()=>{s&&(j(""),M(Ee),r(null))},[t,s]),l.useEffect(()=>{let P=!1;if(!s||t!=="agy"){v(!1),C(!1);return}return(async()=>{try{C(!0);const ae=await d();P||v(ae)}catch{P||v(!1)}finally{P||C(!1)}})(),()=>{P=!0}},[d,s,t]),l.useEffect(()=>{if(!s||t!=="agy"||!y.error||!g)return;const P=y.error.toLowerCase();if(!(P.includes("agy_risk_ack_required")||P.includes("responsibility acknowledgement")||P.includes("responsibility checklist")))return;let ae=!1;return(async()=>{try{C(!0);const we=await d();if(ae)return;v(we),we||r("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ae)return;v(!1),r("Power user mode is off. Complete the AGY checklist and retry.")}finally{ae||C(!1)}})(),()=>{ae=!0}},[g,y.error,d,s,t]),l.useEffect(()=>{!y.isAuthenticating&&!y.error&&y.provider===null&&s&&F.current&&(F.current=!1,(async()=>{try{const ie=await He(t);ie.success&&ie.presetName&&i&&q.success(`Applied "${ie.presetName}" preset`)}catch{}O()})())},[y.isAuthenticating,y.error,y.provider]);const $=()=>{y.cancelAuth(),O()},de=async()=>{y.authUrl&&(await navigator.clipboard.writeText(y.authUrl),N(!0),setTimeout(()=>N(!1),2e3))},Pe=()=>{o.trim()&&y.submitCallback(o.trim())},De=()=>{if(K){r("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(k&&!G){r("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(S&&!T){r(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}if(U&&!X){r(`Nickname is required for ${n} accounts.`);return}r(null),F.current=!0,y.startAuth(t,{nickname:X||void 0,kiroMethod:w?I:void 0,flowType:w?V.flowType:void 0,startEndpoint:w?V.startEndpoint:void 0,riskAcknowledgement:k?{version:Zt,reviewedIssue509:x.reviewedIssue509,understandsBanRisk:x.understandsBanRisk,acceptsFullResponsibility:x.acceptsFullResponsibility,typedPhrase:x.typedPhrase}:void 0})},Me=()=>{F.current=!0,A.mutate(void 0,{onSuccess:async()=>{const P=await He("kiro");P.success&&P.presetName&&i&&q.success(`Applied "${P.presetName}" preset`),O()}})},Te=P=>{P||$()},J=y.isAuthenticating;return e.jsx(Qe,{open:s,onOpenChange:Te,children:e.jsxs(ze,{className:"sm:max-w-md",onInteractOutside:P=>{J&&P.preventDefault()},children:[e.jsxs(Je,{children:[e.jsx(We,{children:h("addAccountDialog.title",{displayName:n})}),e.jsx(Ps,{children:h(w?"addAccountDialog.descKiro":se?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[k&&!J&&e.jsx(xa,{value:x,onChange:P=>{M(P),r(null)},disabled:z}),t==="agy"&&g&&!J&&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(_s,{className:"h-3.5 w-3.5"}),h("addAccountDialog.powerUserEnabled")]}),h("addAccountDialog.powerUserSkipped")]}),S&&!J&&e.jsx(Ks,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:b,onAcknowledgementTextChange:P=>{j(P),r(null)},disabled:z}),w&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:h("addAccountDialog.authMethod")}),e.jsxs(Ve,{value:I,onValueChange:P=>{D(P),r(null)},children:[e.jsx(Be,{id:"kiro-auth-method",children:e.jsx(Ge,{placeholder:h("addAccountDialog.selectKiroAuthMethod")})}),e.jsx($e,{children:at.map(P=>e.jsx(je,{value:P.id,children:P.label},P.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:h(U?"addAccountDialog.nicknameRequired":"addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ce,{id:"nickname",value:c,onChange:P=>{m(P.target.value),r(null)},placeholder:h("addAccountDialog.nicknamePlaceholder"),disabled:z,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h(U?"addAccountDialog.nicknameRequiredHint":"addAccountDialog.nicknameOptionalHint")})]}),J&&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(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:y.isDeviceCodeFlow?h("addAccountDialog.deviceCodeHint"):h("addAccountDialog.browserHint")})]}),y.authUrl&&!y.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:h("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:y.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:de,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Es,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copy")]})}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>{if(!y.authUrl)return;const P=window.open(y.authUrl,"_blank");(!P||P.closed||typeof P.closed>"u")&&q.warning(h("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ge,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:h("addAccountDialog.redirectPasteLabel")}),e.jsx(ce,{id:"callback-url",value:o,onChange:P=>p(P.target.value),placeholder:h("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(R,{variant:"secondary",size:"sm",onClick:Pe,disabled:!o.trim()||y.isSubmittingCallback,children:y.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3 mr-1 animate-spin"}),h("addAccountDialog.submitting")]}):h("addAccountDialog.submitCallback")})]})]}),!y.authUrl&&!y.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:h("addAccountDialog.preparingUrl")})]}),te&&e.jsx("p",{className:"text-xs text-center text-destructive",children:te}),A.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(R,{variant:"ghost",onClick:$,children:h("addAccountDialog.cancel")}),w&&!J&&e.jsx(R,{variant:"outline",onClick:Me,disabled:z,children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),h("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(R,{onClick:De,disabled:z||K||U&&!X||k&&!G||S&&!T,children:[e.jsx(ge,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.authenticate")]})]})]})]})})}const as="[1m]";function ga(s){return s.toLowerCase().startsWith("gemini-")}function ns(s){return s.toLowerCase().endsWith(as.toLowerCase())}function fa(s){return!s||ns(s)?s:`${s}${as}`}function Vs(s){return s&&(ns(s)?s.slice(0,-as.length):s)}const vs=["ANTHROPIC_MODEL"],ja=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function va(s){const a=s?.env||{};return ja.filter(t=>!a[t]?.trim())}function Na(s){const[a,t]=l.useState(null),[n,i]=l.useState(!1),c=Ke(),{data:m,isLoading:o,refetch:p}=bs({queryKey:["settings",s],queryFn:async()=>{const A=await fetch(`/api/settings/${s}/raw`);return A.ok?A.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),f=m?.settings,N=l.useMemo(()=>a!==null?a:f?JSON.stringify(f,null,2):`{
|
|
1
|
+
import{j as e}from"./radix-ui-BR1vy4kf.js";import{r as l}from"./react-vendor-CNOkPC89.js";import{a as Ke,u as bs,b as zs}from"./tanstack-e99Cjjy2.js";import{d as R,C as ks,b as Cs,c as B,P as Ae,a as ee,a3 as Z,L as Y,I as ce,r as Ve,s as Be,t as Ge,v as $e,w as je,a4 as As,a5 as Js,a6 as Ws,a7 as Xs,u as Ss,a8 as Qe,a9 as ze,aa as Je,ab as We,ac as Ps,ad as ls,ae as Ys,af as Zs,W as Ds,ag as Ie,ah as Ms,Y as be,B as H,ai as Fe,aj as cs,ak as et,al as st,am as tt,an as at,ao as ds,ap as us,aq as nt,x as Ts,n as Xe,ar as it,as as rt,at as ot,m as lt,au as ct,av as dt,aw as ut,ax as mt,ay as xt,az as pt,aA as ue,T as me,p as xe,q as pe,aB as ht,aC as gt,aD as ft,aE as ms,aF as jt,aG as vt,aH as Nt,aI as yt,aJ as wt,aK as bt,aL as kt,Q as Ct,R as At,U as xs,V as ps,aM as St,aN as Pt,aO as Dt,aP as Mt,aQ as Tt,aR as Ot,aS as Et,aT as _t,aU as Rt,aV as Lt,aW as It,aX as Ft,S as Ut}from"./index-DCQkhmoo.js";import{C as Ue}from"./default-ports-1QQSffYX.js";import{t as q}from"./notifications-B2HqRBj7.js";import{C as Os,L as W,n as ge,N as qt,k as ne,m as Es,ap as Ye,R as Ze,o as fe,a2 as Ne,T as es,a0 as Ht,aq as _s,ar as Kt,as as Se,Z as ye,J as Rs,g as Vt,s as Ls,at as Bt,ai as Gt,X as ss,a1 as Is,w as Fs,x as qe,au as $t,t as hs,av as Qt,ah as Us,u as zt,aw as gs,l as Jt,a3 as Wt,al as Xt,ax as qs}from"./icons-BYZM_9Gm.js";import{R as ke,A as fs,D as Ee,i as Yt,a as Zt,P as ea}from"./proxy-status-widget-DPXgRGkB.js";import{C as Ce}from"./checkbox-CcX8-GfD.js";import{C as sa}from"./confirm-dialog-BZj0PYFs.js";import{S as ts}from"./separator-DtcqgZIS.js";import{S as Hs}from"./switch-BL5xZtnr.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DPdKlUG9.js";const ve={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.3-codex",models:[{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",description:"Supports up to xhigh effort",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Previous stable Codex model",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high effort (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.3-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",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",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"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-5-20250929",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-5-20250929",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"}]}},_e="ccs-internal-managed";async function ta(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??_e:_e}catch{return _e}}async function He(s,a){const t=ve[s];if(!t)return{success:!1};const n=t.models[0],i=n?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},c=await ta(),o={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${Ue}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:c,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}function aa({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=n?"bg-primary":"bg-muted"}`},t))})}function na({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.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:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function ia({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:c,onStartAuth:m,onRefresh:o}){const[p,f]=l.useState(!1),N=async u=>{await navigator.clipboard.writeText(u),f(!0),setTimeout(()=>f(!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 ",a.find(u=>u.id===s)?.name," to add an account"]}),e.jsx(R,{onClick:m,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&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(ks,{children:e.jsxs(Cs,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(qt,{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:t}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>N(t),children:p?e.jsx(ne,{className:"w-4 h-4 text-green-500"}):e.jsx(Es,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(R,{variant:"outline",onClick:o,disabled:n||i,children:[e.jsx(Ze,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function ra({accounts:s,privacyMode:a,onSelect:t,onAddNew:n,onBack:i}){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(c=>e.jsxs("button",{type:"button",onClick:()=>t(c),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(fe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:B("font-medium",a&&Ae),children:c.email||c.id}),c.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"})]},c.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:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ge,{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(R,{variant:"ghost",onClick:i,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const js="__custom__";function oa({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:c,onVariantNameChange:m,onModelChange:o,onBack:p,onSkip:f,onCreate:N}){const{t:u}=ee(),r=ve[s]?.models||[],b=n&&!r.some(v=>v.id===n),[j,x]=l.useState(b),M=s==="agy"&&n.trim().length>0?Z(n):!1,g=v=>{v===js?(x(!0),o("")):(x(!1),o(v))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsxs("span",{children:[u("setupVariant.using")," ",e.jsx("span",{className:B(c&&Ae),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:u("setupVariant.variantNameRequired")}),e.jsx(ce,{id:"variant-name",value:t,onChange:v=>m(v.target.value),placeholder:u("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[u("setupVariant.invokeHintPrefix")," ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:u("setupVariant.model")}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:n,onChange:v=>o(v.target.value),placeholder:u("setupVariant.modelPlaceholder")}),M&&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:()=>{x(!1),s==="agy"&&Z(n)&&o("")},children:u("setupVariant.choosePresetInstead")})]}):e.jsxs(Ve,{value:r.some(v=>v.id===n)?n:"",onValueChange:g,children:[e.jsx(Be,{children:e.jsx(Ge,{placeholder:u("setupVariant.selectModel")})}),e.jsxs($e,{children:[r.map(v=>e.jsx(je,{value:v.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:v.name}),v.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",v.description]})]})},v.id)),e.jsx(je,{value:js,children:e.jsx("span",{className:"text-primary",children:u("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:j?u("setupVariant.enterAnyModel"):u("setupVariant.defaultModel",{model:ve[s]?.defaultModel||u("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(R,{variant:"ghost",onClick:p,children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),u("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"ghost",onClick:f,children:u("setupVariant.skip")}),e.jsx(R,{onClick:N,disabled:!t||i||M,children:u(i?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:u("setupVariant.skipHint")})]})}function la({variantName:s,onClose:a}){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(ne,{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(ks,{children:e.jsxs(Cs,{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(R,{onClick:a,className:"w-full",children:"Done"})]})}function ca({open:s,onClose:a}){const[t,n]=l.useState("provider"),[i,c]=l.useState(""),[m,o]=l.useState(null),[p,f]=l.useState(""),[N,u]=l.useState(""),[r,b]=l.useState(!1),[j,x]=l.useState(!1),{data:M,refetch:g}=As(),v=Js(),E=Ws(),C=Xs(),{privacyMode:I}=Ss(),D=M?.authStatus.find(T=>T.provider===i),h=l.useMemo(()=>D?.accounts||[],[D?.accounts]);l.useEffect(()=>{if(!s){const T=setTimeout(()=>{n("provider"),c(""),o(null),f(""),u(""),x(!1)},0);return()=>clearTimeout(T)}},[s]),l.useEffect(()=>{if(t==="auth"&&h.length>0&&!j){const T=setTimeout(()=>{n("account")},0);return()=>clearTimeout(T)}},[t,h,j]);const F=async()=>{b(!0),await g(),b(!1)},y=()=>{const T=(D?.accounts?.length||0)===0;E.mutate({provider:i},{onSuccess:async _=>{if(T){const U=await He(i);U.success&&U.presetName?q.success(`Applied "${U.presetName}" preset`):U.success||q.warning(Ds.t("commonToast.accountAddedPresetFailed"))}_.account&&(o(_.account),n("variant")),g()}})},A=T=>{c(T),(M?.authStatus.find(V=>V.provider===T)?.accounts||[]).length===0?n("auth"):n("account")},w=T=>{o(T),n("variant")},S=async()=>{if(!(!p||!i))try{await v.mutateAsync({name:p,provider:i,model:N||void 0,account:m?.id}),n("success")}catch(T){console.error("Failed to create variant:",T)}},k=`ccs ${i} --auth --add`,K=Zs(t),G=T=>{if(!T&&(E.isPending&&i&&C.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(Qe,{open:s,onOpenChange:G,children:e.jsxs(ze,{className:"sm:max-w-lg",onPointerDownOutside:T=>{t!=="success"&&t!=="provider"&&T.preventDefault()},onEscapeKeyDown:T=>{(E.isPending||v.isPending)&&T.preventDefault()},children:[e.jsxs(Je,{children:[e.jsxs(We,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(Ps,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(na,{providers:ls,onSelect:A}),t==="auth"&&e.jsx(ia,{selectedProvider:i,providers:ls,authCommand:k,isRefreshing:r,isPending:E.isPending,onBack:()=>n("provider"),onStartAuth:y,onRefresh:F}),t==="account"&&e.jsx(ra,{accounts:h,privacyMode:I,onSelect:w,onAddNew:()=>{x(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(oa,{selectedProvider:i,selectedAccount:m,variantName:p,modelName:N,isPending:v.isPending,privacyMode:I,onVariantNameChange:f,onModelChange:u,onBack:()=>h.length>0?n("account"):n("provider"),onSkip:a,onCreate:S}),t==="success"&&e.jsx(la,{variantName:p,onClose:a})]}),e.jsx(aa,{currentProgress:K,allSteps:Ys})]})})}const da=3e3,ua=300*1e3;async function Re(s){const a=await s.text();if(!a)return{};try{return JSON.parse(a)}catch{const t=s.status>=400?`Request failed with status ${s.status}`:void 0;return t?{error:t}:{}}}const le={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function ma(){const[s,a]=l.useState(le),t=l.useRef(null),n=l.useRef(null),i=l.useRef(0),c=l.useRef(!1),m=Ke(),o=l.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);l.useEffect(()=>()=>{t.current?.abort(),o(),c.current=!1},[o]);const p=l.useCallback(async(r,b)=>{if(Date.now()-i.current>ua){o(),a(j=>({...j,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const x=await(await fetch(`/api/cliproxy/auth/${r}/status?state=${encodeURIComponent(b)}`)).json();if(x.status==="ok")o(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),q.success(`${r} authentication successful`),c.current=!1,a(le);else if(x.status==="auth_url"){const M=x.url||x.auth_url;M&&(a(g=>({...g,authUrl:M})),c.current||(c.current=!0,window.open(M,"_blank")))}else if(x.status==="device_code"){o();const M=x.user_code&&x.verification_url?`Open ${x.verification_url} and enter code: ${x.user_code}`:"Switch to Device Code method and try again.";q.error("Provider returned Device Code flow in callback mode"),a(g=>({...g,isAuthenticating:!1,error:M}))}else if(x.status==="error"){o();const M=x.error||"Authentication failed";q.error(M),a(g=>({...g,isAuthenticating:!1,error:M}))}}catch{}},[m,o]),f=l.useCallback(async(r,b)=>{if(!Ie(r)){a({...le,error:`Unknown provider: ${r}`});return}t.current?.abort(),o(),c.current=!1;const j=new AbortController;t.current=j;const M=(b?.flowType||(Ms(r)?"device_code":"authorization_code"))==="device_code",g=b?.startEndpoint||(M?"start":"start-url"),v={nickname:b?.nickname,kiroMethod:b?.kiroMethod,riskAcknowledgement:b?.riskAcknowledgement};a({provider:r,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:M});try{if(g==="start")fetch(`/api/cliproxy/auth/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:j.signal}).then(async E=>{const C=await Re(E),I=C.success===!0;if(E.ok&&I)m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),c.current=!1,a(le);else{const D=typeof C.error=="string"?C.error:"Authentication failed";q.error(D),a(h=>({...h,isAuthenticating:!1,error:D}))}}).catch(E=>{if(E instanceof Error&&E.name==="AbortError")return;const C=E instanceof Error?E.message:"Authentication failed";q.error(C),a(I=>({...I,isAuthenticating:!1,error:C}))});else{const E=await fetch(`/api/cliproxy/auth/${r}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),signal:j.signal}),C=await Re(E),I=C.success===!0;if(!E.ok||!I){const F=typeof C.error=="string"?C.error:"Failed to start OAuth";throw new Error(F)}const D=typeof C.authUrl=="string"?C.authUrl:null,h=typeof C.state=="string"?C.state:null;a(F=>({...F,authUrl:D,oauthState:h})),D&&(c.current=!0,window.open(D,"_blank")),h&&(i.current=Date.now(),n.current=setInterval(()=>{p(r,h)},da))}}catch(E){if(E instanceof Error&&E.name==="AbortError"){c.current=!1,a(le);return}const C=E instanceof Error?E.message:"Authentication failed";q.error(C),a(I=>({...I,isAuthenticating:!1,error:C}))}},[p,o,m]),N=l.useCallback(()=>{const r=s.provider;t.current?.abort(),o(),c.current=!1,a(le),r&&be.cliproxy.auth.cancel(r).catch(()=>{})},[s.provider,o]),u=l.useCallback(async r=>{if(s.provider){a(b=>({...b,isSubmittingCallback:!0,error:null}));try{const b=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:r})}),j=await Re(b),x=j.success===!0;if(b.ok&&x)o(),m.invalidateQueries({queryKey:["cliproxy-auth"]}),m.invalidateQueries({queryKey:["account-quota"]}),q.success(`${s.provider} authentication successful`),a(le);else{const M=typeof j.error=="string"?j.error:"Callback submission failed";throw new Error(M)}}catch(b){const j=b instanceof Error?b.message:"Failed to submit callback";q.error(j),a(x=>({...x,isSubmittingCallback:!1,error:j}))}}},[s.provider,m,o]);return l.useMemo(()=>({...s,startAuth:f,cancelAuth:N,submitCallback:u}),[s,f,N,u])}function Ks({className:s,showAcknowledgement:a=!1,acknowledgementPhrase:t=ke,acknowledgementText:n="",onAcknowledgementTextChange:i,disabled:c=!1,showProxySettingsLink:m=!1}){const{t:o}=ee(),p=o("accountSafetyWarning.title"),f=o("accountSafetyWarning.subtitle"),N=o("accountSafetyWarning.firstLine"),u=o("accountSafetyWarning.secondLine"),r="https://github.com/kaitranntt/ccs/issues/509",b=o("accountSafetyWarning.issueLabel"),j=o("accountSafetyWarning.proxySettingsLabel");return e.jsxs("section",{role:"alert",className:B("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(es,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f})]})]}),e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:N}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:u}),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:r,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:[b,e.jsx(ge,{className:"h-3.5 w-3.5"})]}),m&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Ht,{className:"h-3.5 w-3.5"}),j]}),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"})]}),a&&i&&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:t})]}),e.jsx(ce,{id:"account-risk-ack-text",value:n,onChange:x=>i(x.target.value),placeholder:t,disabled:c,className:"mt-2 font-mono text-xs"})]})]})]})}function xa({className:s,value:a,onChange:t,disabled:n=!1}){const{t:i}=ee(),c=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===fs].filter(Boolean).length,m=c/4*100,o=p=>{t({...a,...p})};return e.jsxs("section",{role:"alert",className:B("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(es,{className:"h-4 w-4"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:i("antigravityChecklist.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("antigravityChecklist.subtitle")})]})]}),e.jsx(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:c})})]}),e.jsx(Fe,{value:m,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:a.reviewedIssue509,onCheckedChange:p=>o({reviewedIssue509:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:p=>o({understandsBanRisk:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ce,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:p=>o({acceptsFullResponsibility:!!p}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(_s,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(ce,{value:a.typedPhrase,onChange:p=>o({typedPhrase:p.target.value}),placeholder:fs,disabled:n,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2.5 py-1 font-medium text-rose-800 transition-colors hover:bg-rose-500/15 dark:text-rose-200",children:["Read issue #509",e.jsx(ge,{className:"h-3.5 w-3.5"})]})})]})]})}function pa(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function ha({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[c,m]=l.useState(""),[o,p]=l.useState(""),[f,N]=l.useState(!1),[u,r]=l.useState(null),[b,j]=l.useState(""),[x,M]=l.useState(Ee),[g,v]=l.useState(!1),[E,C]=l.useState(!1),[I,D]=l.useState(cs),{t:h}=ee(),F=l.useRef(!1),y=ma(),A=et(),w=t==="kiro",S=t==="gemini",k=t==="agy"&&!g,K=t==="agy"&&E,G=Yt(x),T=pa(b)===ke,_=Ms(t),U=st(t),V=tt(I),se=w?V.flowType==="device_code":_,z=y.isAuthenticating||A.isPending,X=c.trim(),te=u||y.error,d=l.useCallback(async()=>{const P=await fetch("/api/settings/auth/antigravity-risk");if(!P.ok)throw new Error("Failed to load Antigravity power user setting");return(await P.json()).antigravityAckBypass===!0},[]),O=()=>{m(""),p(""),N(!1),r(null),j(""),M(Ee),v(!1),C(!1),D(cs),F.current=!1,a()};l.useEffect(()=>{s&&(j(""),M(Ee),r(null))},[t,s]),l.useEffect(()=>{let P=!1;if(!s||t!=="agy"){v(!1),C(!1);return}return(async()=>{try{C(!0);const ae=await d();P||v(ae)}catch{P||v(!1)}finally{P||C(!1)}})(),()=>{P=!0}},[d,s,t]),l.useEffect(()=>{if(!s||t!=="agy"||!y.error||!g)return;const P=y.error.toLowerCase();if(!(P.includes("agy_risk_ack_required")||P.includes("responsibility acknowledgement")||P.includes("responsibility checklist")))return;let ae=!1;return(async()=>{try{C(!0);const we=await d();if(ae)return;v(we),we||r("Power user mode is off. Complete the AGY checklist and retry.")}catch{if(ae)return;v(!1),r("Power user mode is off. Complete the AGY checklist and retry.")}finally{ae||C(!1)}})(),()=>{ae=!0}},[g,y.error,d,s,t]),l.useEffect(()=>{!y.isAuthenticating&&!y.error&&y.provider===null&&s&&F.current&&(F.current=!1,(async()=>{try{const ie=await He(t);ie.success&&ie.presetName&&i&&q.success(`Applied "${ie.presetName}" preset`)}catch{}O()})())},[y.isAuthenticating,y.error,y.provider]);const $=()=>{y.cancelAuth(),O()},de=async()=>{y.authUrl&&(await navigator.clipboard.writeText(y.authUrl),N(!0),setTimeout(()=>N(!1),2e3))},Pe=()=>{o.trim()&&y.submitCallback(o.trim())},De=()=>{if(K){r("Loading Antigravity safety settings. Please wait a moment and retry.");return}if(k&&!G){r("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(S&&!T){r(`Type "${ke}" to acknowledge the account safety warning before authenticating this provider.`);return}if(U&&!X){r(`Nickname is required for ${n} accounts.`);return}r(null),F.current=!0,y.startAuth(t,{nickname:X||void 0,kiroMethod:w?I:void 0,flowType:w?V.flowType:void 0,startEndpoint:w?V.startEndpoint:void 0,riskAcknowledgement:k?{version:Zt,reviewedIssue509:x.reviewedIssue509,understandsBanRisk:x.understandsBanRisk,acceptsFullResponsibility:x.acceptsFullResponsibility,typedPhrase:x.typedPhrase}:void 0})},Me=()=>{F.current=!0,A.mutate(void 0,{onSuccess:async()=>{const P=await He("kiro");P.success&&P.presetName&&i&&q.success(`Applied "${P.presetName}" preset`),O()}})},Te=P=>{P||$()},J=y.isAuthenticating;return e.jsx(Qe,{open:s,onOpenChange:Te,children:e.jsxs(ze,{className:"sm:max-w-md",onInteractOutside:P=>{J&&P.preventDefault()},children:[e.jsxs(Je,{children:[e.jsx(We,{children:h("addAccountDialog.title",{displayName:n})}),e.jsx(Ps,{children:h(w?"addAccountDialog.descKiro":se?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[k&&!J&&e.jsx(xa,{value:x,onChange:P=>{M(P),r(null)},disabled:z}),t==="agy"&&g&&!J&&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(_s,{className:"h-3.5 w-3.5"}),h("addAccountDialog.powerUserEnabled")]}),h("addAccountDialog.powerUserSkipped")]}),S&&!J&&e.jsx(Ks,{showAcknowledgement:!0,acknowledgementPhrase:ke,acknowledgementText:b,onAcknowledgementTextChange:P=>{j(P),r(null)},disabled:z}),w&&!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:h("addAccountDialog.authMethod")}),e.jsxs(Ve,{value:I,onValueChange:P=>{D(P),r(null)},children:[e.jsx(Be,{id:"kiro-auth-method",children:e.jsx(Ge,{placeholder:h("addAccountDialog.selectKiroAuthMethod")})}),e.jsx($e,{children:at.map(P=>e.jsx(je,{value:P.id,children:P.label},P.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V.description})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:h(U?"addAccountDialog.nicknameRequired":"addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ce,{id:"nickname",value:c,onChange:P=>{m(P.target.value),r(null)},placeholder:h("addAccountDialog.nicknamePlaceholder"),disabled:z,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h(U?"addAccountDialog.nicknameRequiredHint":"addAccountDialog.nicknameOptionalHint")})]}),J&&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(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:y.isDeviceCodeFlow?h("addAccountDialog.deviceCodeHint"):h("addAccountDialog.browserHint")})]}),y.authUrl&&!y.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:h("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:y.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(R,{variant:"outline",size:"sm",onClick:de,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Es,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.copy")]})}),e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>{if(!y.authUrl)return;const P=window.open(y.authUrl,"_blank");(!P||P.closed||typeof P.closed>"u")&&q.warning(h("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ge,{className:"w-3 h-3 mr-1"}),h("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:h("addAccountDialog.redirectPasteLabel")}),e.jsx(ce,{id:"callback-url",value:o,onChange:P=>p(P.target.value),placeholder:h("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(R,{variant:"secondary",size:"sm",onClick:Pe,disabled:!o.trim()||y.isSubmittingCallback,children:y.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-3 h-3 mr-1 animate-spin"}),h("addAccountDialog.submitting")]}):h("addAccountDialog.submitCallback")})]})]}),!y.authUrl&&!y.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:h("addAccountDialog.preparingUrl")})]}),te&&e.jsx("p",{className:"text-xs text-center text-destructive",children:te}),A.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(W,{className:"w-4 h-4 inline mr-2 animate-spin"}),h("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(R,{variant:"ghost",onClick:$,children:h("addAccountDialog.cancel")}),w&&!J&&e.jsx(R,{variant:"outline",onClick:Me,disabled:z,children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2 animate-spin"}),h("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Kt,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.importFromIde")]})}),!J&&e.jsxs(R,{onClick:De,disabled:z||K||U&&!X||k&&!G||S&&!T,children:[e.jsx(ge,{className:"w-4 h-4 mr-2"}),h("addAccountDialog.authenticate")]})]})]})]})})}const as="[1m]";function ga(s){return s.toLowerCase().startsWith("gemini-")}function ns(s){return s.toLowerCase().endsWith(as.toLowerCase())}function fa(s){return!s||ns(s)?s:`${s}${as}`}function Vs(s){return s&&(ns(s)?s.slice(0,-as.length):s)}const vs=["ANTHROPIC_MODEL"],ja=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function va(s){const a=s?.env||{};return ja.filter(t=>!a[t]?.trim())}function Na(s){const[a,t]=l.useState(null),[n,i]=l.useState(!1),c=Ke(),{data:m,isLoading:o,refetch:p}=bs({queryKey:["settings",s],queryFn:async()=>{const A=await fetch(`/api/settings/${s}/raw`);return A.ok?A.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),f=m?.settings,N=l.useMemo(()=>a!==null?a:f?JSON.stringify(f,null,2):`{
|
|
2
2
|
"env": {}
|
|
3
3
|
}`,[a,f]),u=l.useCallback(A=>{t(A)},[]),r=l.useMemo(()=>{try{return JSON.parse(N)}catch{return f||{env:{}}}},[N,f]),b=r?.env?.ANTHROPIC_MODEL,j=r?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,x=r?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,M=r?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,g=l.useMemo(()=>{const A=r?.env||{};return vs.some(w=>{const S=A[w];return S&&ns(S)})},[r]),v=l.useCallback((A,w)=>{const S={...r?.env||{},[A]:w},k={...r,env:S};t(JSON.stringify(k,null,2))},[r]),E=l.useCallback(A=>{const w=r?.env||{},S={};for(const G of vs){const T=w[G];T&&(S[G]=A?fa(T):Vs(T))}const k={...w,...S};delete k.CCS_EXTENDED_CONTEXT;const K={...r,env:k};t(JSON.stringify(K,null,2))},[r]),C=l.useCallback(A=>{const w={...r?.env||{},...A},S={...r,env:w};t(JSON.stringify(S,null,2))},[r]),I=l.useMemo(()=>{try{return JSON.parse(N),!0}catch{return!1}},[N]),D=l.useMemo(()=>a===null?!1:a!==JSON.stringify(f,null,2),[a,f]),h=l.useMemo(()=>va(r),[r]),F=zs({mutationFn:async()=>{const A=JSON.parse(N),w=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:A,expectedMtime:m?.mtime})});if(w.status===409)throw new Error("CONFLICT");if(!w.ok)throw new Error("Failed to save");return w.json()},onSuccess:A=>{c.invalidateQueries({queryKey:["settings",s]}),t(null),A?.warning?q.success("Settings saved",{description:A.warning}):q.success("Settings saved")},onError:A=>{A.message==="CONFLICT"?i(!0):q.error(A.message)}}),y=async A=>{i(!1),A?(await p(),F.mutate()):t(null)};return{data:m,isLoading:o,refetch:p,rawJsonContent:N,rawJsonEdits:a,isRawJsonValid:I,hasChanges:D,currentSettings:r,currentModel:b,opusModel:j,sonnetModel:x,haikuModel:M,extendedContextEnabled:g,toggleExtendedContext:E,handleRawJsonChange:u,updateEnvValue:v,updateEnvValues:C,saveMutation:{mutate:()=>F.mutate(),isPending:F.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:y,missingRequiredFields:h}}const ya=/-(medium|high|xhigh)$/i;function wa(s){if(!s)return;const a=s.trim().match(ya);if(a?.[1])return a[1].toLowerCase()}function Le(s){if(!s)return null;const a=wa(s);return a?{label:`Pinned ${a}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function oe({label:s,description:a,value:t,onChange:n,catalog:i,allModels:c,disabled:m}){const{t:o}=ee(),p=new Set(i?.models.map(u=>u.id)||[]),f=i?.provider==="codex",N=f?Le(t):null;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(Ve,{value:t||"",onValueChange:n,disabled:m,children:[e.jsx(Be,{className:"h-9",children:e.jsx(Ge,{placeholder:o("providerModelSelector.selectModel"),children:t&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:t}),N&&e.jsx(H,{variant:N.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:N.label})]})})}),e.jsxs($e,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(ds,{children:[e.jsx(us,{className:"text-xs text-primary",children:o("providerModelSelector.recommended")}),i.models.map(u=>{const r=f?Le(u.id):null;return e.jsx(je,{value:u.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u.id}),u.tier==="paid"&&e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:o("providerModelSelector.paid")}),r&&e.jsx(H,{variant:r.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:r.label}),t===u.id&&e.jsx(ne,{className:"w-3 h-3 text-primary ml-auto"})]})},u.id)})]}),c.length>0&&e.jsxs(ds,{children:[e.jsx(us,{className:"text-xs text-muted-foreground",children:o("providerModelSelector.allModelsCount",{count:c.length})}),c.filter(u=>!p.has(u.id)).map(u=>{const r=f?Le(u.id):null;return e.jsx(je,{value:u.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:u.id}),r&&e.jsx(H,{variant:r.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:r.label}),t===u.id&&e.jsx(ne,{className:"w-3 h-3 text-primary ml-auto"})]})},u.id)})]}),(!i||i.models.length===0)&&c.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:o("providerModelSelector.noModelsAvailable")})]})]})]})}function ba({open:s,onClose:a,currentValues:t,onApply:n,onSave:i,isSaving:c,catalog:m,allModels:o}){const{t:p}=ee(),[f,N]=l.useState(t),[u,r]=l.useState(""),b=j=>{j?(N(t),r("")):a()};return e.jsx(Qe,{open:s,onOpenChange:b,children:e.jsxs(ze,{className:"sm:max-w-md",children:[e.jsx(Je,{children:e.jsxs(We,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),p("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:p("customPresetDialog.presetNameOptional")}),e.jsx(ce,{id:"preset-name",value:u,onChange:j=>r(j.target.value),placeholder:p("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(ts,{}),m?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[p("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",p("customPresetDialog.codexTipSuffix")]}),e.jsx(oe,{label:p("customPresetDialog.defaultModel"),description:p("customPresetDialog.defaultModelDesc"),value:f.default,onChange:j=>N({...f,default:j}),catalog:m,allModels:o}),e.jsx(oe,{label:p("customPresetDialog.opusModel"),description:p("customPresetDialog.opusModelDesc"),value:f.opus,onChange:j=>N({...f,opus:j}),catalog:m,allModels:o}),e.jsx(oe,{label:p("customPresetDialog.sonnetModel"),description:p("customPresetDialog.sonnetModelDesc"),value:f.sonnet,onChange:j=>N({...f,sonnet:j}),catalog:m,allModels:o}),e.jsx(oe,{label:p("customPresetDialog.haikuModel"),description:p("customPresetDialog.haikuModelDesc"),value:f.haiku,onChange:j=>N({...f,haiku:j}),catalog:m,allModels:o})]}),e.jsxs(nt,{className:"gap-2 sm:gap-0",children:[e.jsx(R,{variant:"outline",onClick:a,children:p("customPresetDialog.cancel")}),i&&e.jsxs(R,{variant:"secondary",onClick:()=>i(f,u||void 0),disabled:c||!u.trim(),children:[c?e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Se,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.savePreset")]}),e.jsxs(R,{onClick:()=>n(f,u||void 0),children:[e.jsx(ye,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.applyPreset")]})]})]})})}function he({label:s,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(Ts,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function ka({provider:s,displayName:a,defaultTarget:t,data:n,authStatus:i}){const c=t||"claude",m=c==="droid";return e.jsx(Xe,{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(Rs,{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:a})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Ts,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.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"}),i.authenticated?e.jsxs(H,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Vt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(H,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Default Target"}),e.jsx("span",{className:"font-mono",children:c})]})]})]}),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(he,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(he,{label:m?"Droid alias (explicit)":"Run on Droid",command:m?`ccsd ${s} "your prompt"`:`ccs ${s} --target droid "your prompt"`}),e.jsx(he,{label:m?"Override to Claude":"Override target",command:`ccs ${s} --target claude "your prompt"`}),e.jsx(he,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(he,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(he,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Ca={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function is({provider:s,className:a,size:t="md"}){const n=it(s),i=Ca[t],c=rt(s);return e.jsx("div",{className:B("flex items-center justify-center rounded-md",c&&(ot(s)?"bg-gray-900 p-1":"bg-white p-1"),i.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:B(i.icon,"object-contain")}):e.jsx("span",{className:B("font-semibold",n.textClass,i.text),children:n.letter})})}function Aa({displayName:s,logoProvider:a,provider:t,data:n,isLoading:i,hasChanges:c,isRawJsonValid:m,isSaving:o,isRemoteMode:p,port:f,onRefetch:N,onSave:u}){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(is,{provider:a||t,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}),p&&e.jsxs(H,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(Ls,{className:"w-3 h-3"}),"Remote"]}),f&&e.jsxs(H,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(Bt,{className:"w-3 h-3"}),":",f]}),!p&&n?.path&&e.jsx(H,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),p?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:N,disabled:i,children:e.jsx(Ze,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(R,{size:"sm",onClick:u,disabled:o||!c||!m,children:o?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Sa({model:s,provider:a,enabled:t,onToggle:n,disabled:i,className:c}){if(!s?.extendedContext)return null;const m=ga(s.id);return e.jsxs("div",{className:B("rounded-lg border p-3 space-y-2",t?"border-primary/50 bg-primary/5":"border-border bg-muted/30",c),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:B("w-4 h-4",t?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(H,{variant:t?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Hs,{checked:t,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(Rs,{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:m?e.jsxs("span",{className:"text-primary",children:["Auto-enabled for ",a," Gemini models"]}):e.jsxs("span",{children:["Opt-in for ",a," Claude models via --1m flag"]})}),t&&e.jsx("p",{className:"text-amber-600 dark:text-amber-500",children:"Note: 2x input pricing applies for tokens beyond 200K"})]})]})]})}function Pa({catalog:s,savedPresets:a,currentModel:t,opusModel:n,sonnetModel:i,haikuModel:c,providerModels:m,provider:o,extendedContextEnabled:p,onExtendedContextToggle:f,onApplyPreset:N,onUpdateEnvValue:u,onOpenCustomPreset:r,onDeletePreset:b,isDeletePending:j}){const x=s&&s.models.length>0||a.length>0,M=l.useMemo(()=>{if(!s||!t)return;const g=Vs(t);return s.models.find(v=>v.id===g)},[s,t]);return e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ne,{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:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(g=>e.jsxs(R,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const v=g.presetMapping||{default:g.id,opus:g.id,sonnet:g.id,haiku:g.id};N({ANTHROPIC_MODEL:v.default,ANTHROPIC_DEFAULT_OPUS_MODEL:v.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:v.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:v.haiku})},children:[e.jsx(ye,{className:"w-3 h-3"}),g.name]},g.id)),a.map(g=>e.jsxs("div",{className:"group relative",children:[e.jsxs(R,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{N({ANTHROPIC_MODEL:g.default,ANTHROPIC_DEFAULT_OPUS_MODEL:g.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:g.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:g.haiku})},children:[e.jsx(Se,{className:"w-3 h-3 fill-current"}),g.name]}),e.jsx(R,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:v=>{v.stopPropagation(),b(g.name)},disabled:j,children:e.jsx(ss,{className:"w-3 h-3"})})]},g.name)),e.jsxs(R,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:r,children:[e.jsx(Is,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(ts,{}),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"}),o==="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(oe,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:g=>u("ANTHROPIC_MODEL",g),catalog:s,allModels:m}),M?.extendedContext&&f&&e.jsx(Sa,{model:M,provider:o,enabled:p??!1,onToggle:f}),e.jsx(oe,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:g=>u("ANTHROPIC_DEFAULT_OPUS_MODEL",g),catalog:s,allModels:m}),e.jsx(oe,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:g=>u("ANTHROPIC_DEFAULT_SONNET_MODEL",g),catalog:s,allModels:m}),e.jsx(oe,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:g=>u("ANTHROPIC_DEFAULT_HAIKU_MODEL",g),catalog:s,allModels:m})]})]})]})}function Ns(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function ys(s){if(!s)return"";try{const a=new Date(s),n=new Date().getTime()-a.getTime();if(n<0)return"just now";const i=Math.floor(n/(1e3*60)),c=Math.floor(n/(1e3*60*60)),m=Math.floor(n/(1e3*60*60*24));return m>0?`${m}d ago`:c>0?`${c}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Da(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function Ma({account:s,onSetDefault:a,onRemove:t,onPauseToggle:n,isRemoving:i,isPausingAccount:c,privacyMode:m,showQuota:o,selectable:p,selected:f,onSelectChange:N}){const u=s.provider.toLowerCase(),r=u==="codex",b=u==="claude"||u==="anthropic",{data:j}=lt(o),{data:x,isLoading:M}=ct(u,s.id,o),g=j?.accountStats?.[s.email||s.id]?.lastUsedAt,v=Da(g),E=dt(s.provider,x),C=ut(s.provider,x),I=r&&x&&mt(x)?xt(x.windows):null,D=[{label:"5h",value:I?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:I?.weeklyWindow?.remainingPercent??null}].filter(w=>w.value!==null),h=b&&x&&pt(x)?[{label:"5h",value:x.coreUsage?.fiveHour?.remainingPercent??x.windows.find(w=>w.rateLimitType==="five_hour")?.remainingPercent??null},{label:"Weekly",value:x.coreUsage?.weekly?.remainingPercent??x.windows.find(w=>["seven_day","seven_day_opus","seven_day_sonnet","seven_day_oauth_apps","seven_day_cowork"].includes(w.rateLimitType))?.remainingPercent??null}].filter(w=>w.value!==null):[],F=r?D:b?h:[],y=E!==null?jt(E):null,A=y!==null?Number(y):null;return e.jsxs("div",{className:B("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",f&&"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:[p&&e.jsx("button",{type:"button",onClick:()=>N?.(!f),className:B("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",f?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":f?"Deselect account":"Select account",children:f&&e.jsx(ne,{className:"w-3 h-3"})}),n&&e.jsx(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:c,children:c?e.jsx(W,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(Fs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(qe,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(pe,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:B("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(fe,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:B("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:B("font-medium text-sm truncate",m&&Ae),children:s.email||s.id}),s.isDefault&&e.jsxs(H,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(Se,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(H,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(qe,{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(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx($t,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:B("font-mono max-w-[180px] truncate",m&&Ae),title:s.projectId,children:s.projectId})]})}),e.jsx(pe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(es,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(pe,{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(hs,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(ht,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Qt,{className:"w-4 h-4"})})}),e.jsxs(ft,{align:"end",children:[!s.isDefault&&e.jsxs(ms,{onClick:a,children:[e.jsx(Se,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(ms,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(Us,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),o&&e.jsx("div",{className:"pl-11",children:M?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(W,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):A!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:v?e.jsxs(e.Fragment,{children:[e.jsx(zt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ys(g)]})]}):g?e.jsxs(e.Fragment,{children:[e.jsx(hs,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ys(g)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(gs,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:F.length>0?e.jsx("div",{className:"space-y-1.5",children:F.map(w=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:w.label}),e.jsx(Fe,{value:Math.max(0,Math.min(100,w.value)),className:"h-2 flex-1",indicatorClassName:Ns(w.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[w.value,"%"]})]},w.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{value:Math.max(0,Math.min(100,A)),className:"h-2 flex-1",indicatorClassName:Ns(A)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[y,"%"]})]})}),e.jsx(pe,{side:"bottom",className:"max-w-xs",children:e.jsx(vt,{quota:x,resetTime:C})})]})})]}):x?.success?e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(H,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(gs,{className:"w-3 h-3"}),"No limits"]})}):x?.needsReauth?e.jsx(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(H,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-amber-500/50 text-amber-600 dark:text-amber-400",children:[e.jsx(Jt,{className:"w-3 h-3"}),"Reauth"]})})}),e.jsx(pe,{side:"bottom",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:x.error?.includes("No refresh token")?"No refresh token available. Remove and re-add account to fix.":x.error?.includes("refresh")||x.error?.includes("Invalid")?`Auto-refresh failed: ${x.error}`:`Token issue: ${x.error||"Re-authenticate required"}`})})]})}):x?.error||x&&!x.success?e.jsx(ue,{children:e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(H,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(Wt,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(pe,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:x?.error||"Quota information unavailable"})})]})}):null})]})}function Ta({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:n,isPausing:i,isResuming:c}){if(s<1)return null;const m=i||c;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(R,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:m,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(R,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:m,children:[i?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(qe,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(R,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:m,children:[c?e.jsx(W,{className:"w-3 h-3 animate-spin"}):e.jsx(Fs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Oa({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:n,onPauseToggle:i,onSoloMode:c,onBulkPause:m,onBulkResume:o,isRemovingAccount:p,isPausingAccount:f,isSoloingAccount:N,isBulkPausing:u,isBulkResuming:r,privacyMode:b,showQuota:j,isKiro:x,kiroNoIncognito:M,onKiroNoIncognitoChange:g,kiroSettingsLoading:v}){const[E,C]=l.useState(new Set),I=l.useMemo(()=>new Set(s.map(_=>_.id)),[s]),D=l.useMemo(()=>new Set([...E].filter(_=>I.has(_))),[E,I]),h=!!(m&&o),F=D.size,y=s.length>0&&D.size===s.length,A=D.size>0&&D.size<s.length,w=l.useCallback(_=>{C(U=>{const V=new Set(U);return V.has(_)?V.delete(_):V.add(_),V})},[]),S=l.useCallback(()=>{C(new Set(s.map(_=>_.id)))},[s]),k=l.useCallback(()=>{C(new Set)},[]),K=l.useCallback(()=>{y?k():S()},[y,S,k]),G=l.useCallback(()=>{m&&D.size>0&&(m(Array.from(D)),C(new Set))},[m,D]),T=l.useCallback(()=>{o&&D.size>0&&(o(Array.from(D)),C(new Set))},[o,D]);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:[h&&s.length>0&&e.jsx(Ce,{checked:y,onCheckedChange:K,"aria-label":"Select all accounts",className:A?"data-[state=checked]:bg-primary/50":"",...A?{"data-state":"indeterminate"}:{}}),e.jsx(fe,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(H,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(R,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(Is,{className:"w-3 h-3"}),"Add"]})]}),h&&F>0&&e.jsx(Ta,{selectedCount:F,onPauseSelected:G,onResumeSelected:T,onClearSelection:k,isPausing:!!u,isResuming:!!r}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(_=>e.jsx(Ma,{account:_,onSetDefault:()=>t(_.id),onRemove:()=>n(_.id),onPauseToggle:i?U=>i(_.id,U):void 0,onSoloMode:c?()=>c(_.id):void 0,isRemoving:p,isPausingAccount:f,isSoloingAccount:N,privacyMode:b,showQuota:j,selectable:h,selected:D.has(_.id),onSelectChange:()=>w(_.id)},_.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(fe,{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"})]}),x&&g&&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(Ls,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Hs,{checked:!M,onCheckedChange:_=>g(!_),disabled:v,className:"scale-90"})]})})]})}function Ea({provider:s,catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:m,providerModels:o,extendedContextEnabled:p,onExtendedContextToggle:f,onApplyPreset:N,onUpdateEnvValue:u,onOpenCustomPreset:r,onDeletePreset:b,isDeletePending:j,accounts:x,onAddAccount:M,onSetDefault:g,onRemoveAccount:v,onPauseToggle:E,onSoloMode:C,onBulkPause:I,onBulkResume:D,isRemovingAccount:h,isPausingAccount:F,isSoloingAccount:y,isBulkPausing:A,isBulkResuming:w,privacyMode:S,isRemoteMode:k}){const K=s.toLowerCase(),G=(Nt.includes(K)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(K))&&!k,T=s==="kiro",[_,U]=l.useState(!0),[V,se]=l.useState(!0),[z,X]=l.useState(!1),te=l.useCallback(async()=>{if(T)try{se(!0);const $=(await be.config.get()).cliproxy;U($?.kiro_no_incognito??!0)}catch{U(!0)}finally{se(!1)}},[T]),d=l.useCallback(async O=>{U(O),X(!0);try{const $=await be.config.get(),de=$.cliproxy??{};await be.config.update({...$,cliproxy:{...de,kiro_no_incognito:O}})}catch{U(!O)}finally{X(!1)}},[]);return l.useEffect(()=>{te()},[te]),e.jsx(Xe,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Pa,{catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:m,providerModels:o,provider:s,extendedContextEnabled:p,onExtendedContextToggle:f,onApplyPreset:N,onUpdateEnvValue:u,onOpenCustomPreset:r,onDeletePreset:b,isDeletePending:j}),e.jsx(ts,{}),e.jsx(Oa,{accounts:x,onAddAccount:M,onSetDefault:g,onRemoveAccount:v,onPauseToggle:E,onSoloMode:C,onBulkPause:I,onBulkResume:D,isRemovingAccount:h,isPausingAccount:F,isSoloingAccount:y,isBulkPausing:A,isBulkResuming:w,privacyMode:S,showQuota:G,isKiro:T,kiroNoIncognito:_,onKiroNoIncognitoChange:d,kiroSettingsLoading:V||z})]})})}function ws({provider:s,displayName:a,authStatus:t,catalog:n,logoProvider:i,baseProvider:c,isRemoteMode:m,port:o,defaultTarget:p,onAddAccount:f,onSetDefault:N,onRemoveAccount:u,onPauseToggle:r,onSoloMode:b,onBulkPause:j,onBulkResume:x,isRemovingAccount:M,isPausingAccount:g,isSoloingAccount:v,isBulkPausing:E,isBulkResuming:C}){const[I,D]=l.useState(!1),{privacyMode:h}=Ss(),{data:F}=yt(),{data:y}=wt(s),A=bt(),w=kt(),S=c||s,k=S.toLowerCase()==="agy",K=l.useMemo(()=>{const L=y?.presets||[];return k?L.filter(Q=>!Z(Q.default)&&!Z(Q.opus)&&!Z(Q.sonnet)&&!Z(Q.haiku)):L},[k,y?.presets]),G=l.useMemo(()=>{if(!F?.models)return[];const Q={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[S.toLowerCase()]||[S.toLowerCase()];return F.models.filter(re=>Q.some(Oe=>re.owned_by.toLowerCase().includes(Oe))?k?!Z(re.id):!0:!1)},[k,F,S]),T=(c||s).toLowerCase(),{data:_,isLoading:U,refetch:V,rawJsonContent:se,rawJsonEdits:z,isRawJsonValid:X,hasChanges:te,currentModel:d,opusModel:O,sonnetModel:$,haikuModel:de,extendedContextEnabled:Pe,toggleExtendedContext:De,handleRawJsonChange:Me,updateEnvValue:Te,updateEnvValues:J,saveMutation:P,conflictDialog:ie,handleConflictResolve:ae,missingRequiredFields:rs}=Na(s),we=l.useMemo(()=>(t.accounts||[]).map(L=>({...L,provider:L.provider||c||s})),[t.accounts,c,s]),{data:Bs}=bs({queryKey:["auth-tokens-raw"],queryFn:async()=>{const L=await fetch("/api/settings/auth/tokens/raw");return L.ok?L.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),os=Bs?.apiKey?.value??"ccs-internal-managed",Gs=L=>{if(k&&[L.ANTHROPIC_MODEL,L.ANTHROPIC_DEFAULT_OPUS_MODEL,L.ANTHROPIC_DEFAULT_SONNET_MODEL,L.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(re=>typeof re=="string"&&Z(re))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}J({ANTHROPIC_BASE_URL:`http://127.0.0.1:${o??Ue}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:os,...L}),q.success(`Applied "${L.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},$s=(L,Q)=>{if(k&&[L.default,L.opus,L.sonnet,L.haiku].some(Oe=>Z(Oe))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}J({ANTHROPIC_BASE_URL:`http://127.0.0.1:${o??Ue}/api/provider/${T}`,ANTHROPIC_AUTH_TOKEN:os,ANTHROPIC_MODEL:L.default,ANTHROPIC_DEFAULT_OPUS_MODEL:L.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:L.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:L.haiku}),q.success(`Applied ${Q?`"${Q}"`:"custom"} preset`),D(!1)},Qs=(L,Q)=>{if(!Q){q.error(Ds.t("commonToast.enterPresetName"));return}if(k&&[L.default,L.opus,L.sonnet,L.haiku].some(re=>Z(re))){q.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}A.mutate({profile:s,data:{name:Q,...L}}),D(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Aa,{provider:s,displayName:a,logoProvider:i,data:_,isLoading:U,hasChanges:te,isRawJsonValid:X,isSaving:P.isPending,isRemoteMode:m,port:o,onRefetch:V,onSave:()=>P.mutate()}),U?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(W,{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(Ct,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(At,{className:"w-full",children:[e.jsx(xs,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(xs,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(ps,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(Ea,{provider:s,catalog:n,savedPresets:K,currentModel:d,opusModel:O,sonnetModel:$,haikuModel:de,providerModels:G,extendedContextEnabled:Pe,onExtendedContextToggle:De,onApplyPreset:Gs,onUpdateEnvValue:Te,onOpenCustomPreset:()=>D(!0),onDeletePreset:L=>w.mutate({profile:s,name:L}),isDeletePending:w.isPending,accounts:we,onAddAccount:f,onSetDefault:N,onRemoveAccount:u,onPauseToggle:r,onSoloMode:b,onBulkPause:j,onBulkResume:x,isRemovingAccount:M,isPausingAccount:g,isSoloingAccount:v,isBulkPausing:E,isBulkResuming:C,privacyMode:h,isRemoteMode:m})}),e.jsx(ps,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ka,{provider:s,displayName:a,defaultTarget:p,data:_,authStatus:t})})]})]})}),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(Xt,{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(St,{rawJsonContent:se,isRawJsonValid:X,rawJsonEdits:z,onRawJsonChange:Me,profileEnv:_?.settings?.env,missingRequiredFields:rs})]})]}),e.jsx(sa,{open:ie,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ae(!0),onCancel:()=>ae(!1)}),e.jsx(ba,{open:I,onClose:()=>D(!1),currentValues:{default:d||"",opus:O||"",sonnet:$||"",haiku:de||""},onApply:$s,onSave:Qs,isSaving:A.isPending,catalog:n,allModels:G})]})}function _a({status:s,isSelected:a,onSelect:t}){const{t:n}=ee(),i=s.accounts?.length||0;return e.jsxs("button",{className:B("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(is,{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}),i>0&&e.jsx(H,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:n("cliproxyPage.connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function Ra({variant:s,parentAuth:a,isSelected:t,onSelect:n,onDelete:i,isDeleting:c}){const{t:m}=ee();return e.jsxs("button",{className:B("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsxs("div",{className:"relative",children:[e.jsx(is,{provider:s.provider,size:"sm"}),e.jsx(qs,{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(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:m("cliproxyPage.variant")}),e.jsx(H,{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:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:m("cliproxyPage.viaProvider",{provider:s.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ss,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:m("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:o=>{o.stopPropagation(),i()},disabled:c,children:e.jsx(Us,{className:"w-3 h-3"})})]})}function La({onSetup:s}){const{t:a}=ee();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(ye,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[a("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:a("cliproxyPage.controlPanel")}),"."]}),e.jsxs(R,{onClick:s,className:"gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),a("cliproxyPage.quickSetup")]})]})})}function Za(){const{t:s}=ee(),a=Ke(),{data:t,isLoading:n}=As(),{data:i,isFetching:c}=Pt(),{data:m}=Dt(),o=Mt(),p=Tt(),f=Ot(),N=Et(),u=_t(),r=Rt(),b=Lt(),j=It(),[x,M]=l.useState(()=>{if(typeof window<"u"){const O=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return O&&Ie(O)?O:localStorage.getItem("cliproxy-selected-provider")}return null}),[g,v]=l.useState(null),[E,C]=l.useState(!1),[I,D]=l.useState(()=>{if(typeof window>"u")return null;const d=new URLSearchParams(window.location.search),O=d.get("provider")?.trim().toLowerCase();return d.get("action")!=="auth"||!O||!Ie(O)?null:{provider:O,displayName:Ft(O),isFirstAccount:!1}}),h=l.useMemo(()=>t?.authStatus||[],[t?.authStatus]),F=t?.source==="remote",y=l.useMemo(()=>i?.variants||[],[i?.variants]),A=d=>{M(d),d&&localStorage.setItem("cliproxy-selected-provider",d)},w=l.useMemo(()=>g?null:x&&h.some(d=>d.provider===x)?x:h.length>0&&(h.find(O=>(O.accounts?.length||0)>0)?.provider||h[0]?.provider)||null,[x,g,h]),S=h.find(d=>d.provider===w),k=y.find(d=>d.name===g),K=k?h.find(d=>d.provider===k.provider):void 0,G=(k?.provider||S?.provider||"").toLowerCase().trim(),T=G==="gemini"||G==="agy",_=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]})},U=(d,O,$)=>{f.isPending||N.isPending||($?f.mutate({provider:d,accountId:O}):N.mutate({provider:d,accountId:O}))},V=(d,O)=>{u.isPending||u.mutate({provider:d,accountId:O})},se=(d,O)=>{r.isPending||r.mutate({provider:d,accountIds:O})},z=(d,O)=>{b.isPending||b.mutate({provider:d,accountIds:O})},X=d=>{A(d),v(null)},te=d=>{v(d),A(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(ye,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:m?.backendLabel??"CLIProxy"})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:_,disabled:c,children:e.jsx(Ze,{className:B("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cliproxyPage.accountManagement")}),e.jsxs(R,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>C(!0),children:[e.jsx(Ne,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]}),e.jsx(Xe,{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")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(d=>e.jsx(Ut,{className:"h-14 w-full rounded-lg"},d))}):e.jsx("div",{className:"space-y-1",children:h.map(d=>e.jsx(_a,{status:d,isSelected:w===d.provider,onSelect:()=>X(d.provider)},d.provider))}),y.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(qs,{className:"w-3 h-3"}),s("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:y.map(d=>e.jsx(Ra,{variant:d,parentAuth:h.find(O=>O.provider===d.provider),isSelected:g===d.name,onSelect:()=>te(d.name),onDelete:()=>j.mutate(d.name),isDeleting:j.isPending},d.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(ea,{})}),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:h.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),s("cliproxyPage.connectedCount",{count:h.filter(d=>d.authenticated).length})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:[T&&e.jsx(Ks,{showProxySettingsLink:!0,className:"mx-4 mt-4"}),k&&K?e.jsx(ws,{provider:k.name,displayName:s("cliproxyPage.variantDisplay",{name:k.name,provider:k.provider}),authStatus:K,catalog:ve[k.provider],logoProvider:k.provider,baseProvider:k.provider,defaultTarget:k.target,isRemoteMode:F,port:k.port,onAddAccount:()=>D({provider:k.provider,displayName:K.displayName,isFirstAccount:(K.accounts?.length||0)===0}),onSetDefault:d=>o.mutate({provider:k.provider,accountId:d}),onRemoveAccount:d=>p.mutate({provider:k.provider,accountId:d}),onPauseToggle:(d,O)=>U(k.provider,d,O),onSoloMode:d=>V(k.provider,d),onBulkPause:d=>se(k.provider,d),onBulkResume:d=>z(k.provider,d),isRemovingAccount:p.isPending,isPausingAccount:f.isPending||N.isPending,isSoloingAccount:u.isPending,isBulkPausing:r.isPending,isBulkResuming:b.isPending}):S?e.jsx(ws,{provider:S.provider,displayName:S.displayName,authStatus:S,catalog:ve[S.provider],isRemoteMode:F,onAddAccount:()=>D({provider:S.provider,displayName:S.displayName,isFirstAccount:(S.accounts?.length||0)===0}),onSetDefault:d=>o.mutate({provider:S.provider,accountId:d}),onRemoveAccount:d=>p.mutate({provider:S.provider,accountId:d}),onPauseToggle:(d,O)=>U(S.provider,d,O),onSoloMode:d=>V(S.provider,d),onBulkPause:d=>se(S.provider,d),onBulkResume:d=>z(S.provider,d),isRemovingAccount:p.isPending,isPausingAccount:f.isPending||N.isPending,isSoloingAccount:u.isPending,isBulkPausing:r.isPending,isBulkResuming:b.isPending}):e.jsx(La,{onSetup:()=>C(!0)})]}),e.jsx(ca,{open:E,onClose:()=>C(!1)}),e.jsx(ha,{open:I!==null,onClose:()=>D(null),provider:I?.provider||"",displayName:I?.displayName||"",isFirstAccount:I?.isFirstAccount||!1})]})}export{Za as CliproxyPage};
|