@kaitranntt/ccs 7.46.0-dev.1 → 7.46.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/account-safety.d.ts +13 -0
- package/dist/cliproxy/account-safety.d.ts.map +1 -1
- package/dist/cliproxy/account-safety.js +54 -1
- package/dist/cliproxy/account-safety.js.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +6 -1
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.d.ts.map +1 -1
- package/dist/cliproxy/codex-reasoning-proxy.js +23 -9
- package/dist/cliproxy/codex-reasoning-proxy.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +37 -0
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +1 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/executor/retry-handler.d.ts.map +1 -1
- package/dist/cliproxy/executor/retry-handler.js +1 -0
- package/dist/cliproxy/executor/retry-handler.js.map +1 -1
- package/dist/ui/assets/{accounts-5ui2q53B.js → accounts-Btv_qewI.js} +1 -1
- package/dist/ui/assets/{alert-dialog-C3jFRTwI.js → alert-dialog-Cx2FWTeI.js} +1 -1
- package/dist/ui/assets/{api-6SoxBYSB.js → api-DuXeaXLm.js} +1 -1
- package/dist/ui/assets/{auth-section-BDHHhE6e.js → auth-section-BmXjgNLb.js} +1 -1
- package/dist/ui/assets/{backups-section-CS06Tg2f.js → backups-section-CtAIIykA.js} +1 -1
- package/dist/ui/assets/cliproxy-DWzW6PBD.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel--ldkVsyK.js → cliproxy-control-panel-k6cxgMYD.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DjChZijF.js → confirm-dialog-j885h5CO.js} +1 -1
- package/dist/ui/assets/{copilot-vgXbgIvI.js → copilot-CooFqvu2.js} +2 -2
- package/dist/ui/assets/{cursor-BajLT9y0.js → cursor-DzsXMwIB.js} +1 -1
- package/dist/ui/assets/{globalenv-section-Dsdb7zOK.js → globalenv-section-Cwcz1pEG.js} +1 -1
- package/dist/ui/assets/{health-BJuP8omT.js → health-PRUrGRyi.js} +1 -1
- package/dist/ui/assets/{index-uj-gfqVW.js → index-BHYMU8Ew.js} +2 -2
- package/dist/ui/assets/{index-Bf5t_D35.js → index-C8n2wLuZ.js} +1 -1
- package/dist/ui/assets/{index-Br-F473I.js → index-CY1I5fO0.js} +1 -1
- package/dist/ui/assets/index-D7Ug8PFN.js +1 -0
- package/dist/ui/assets/{index-DLdcTG-c.js → index-DMltlCdB.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-C9OwEWsC.js → proxy-status-widget-DAaIvG6n.js} +1 -1
- package/dist/ui/assets/{separator-DIHMuj2A.js → separator-xdaLFECx.js} +1 -1
- package/dist/ui/assets/{shared-B9g38Klw.js → shared-9S-1UkAP.js} +1 -1
- package/dist/ui/assets/{switch-Db-uyN1u.js → switch-DLwFVnEA.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-CUrdHMT1.js +0 -3
- package/dist/ui/assets/index-sBSBwu__.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e,$ as Es,a0 as Ds}from"./radix-ui-qEZD5MMp.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{a as we,u as as,b as _s}from"./tanstack-De4wvi8X.js";import{b as O,C as ns,a as is,c as H,P as me,L as Y,I as ie,X as be,Y as Ce,Z as ye,_ as ke,$ as re,a0 as rs,a1 as Rs,a2 as Ls,a3 as Is,u as os,a4 as Se,a5 as Ae,a6 as Pe,a7 as Me,a8 as ls,a9 as Ge,aa as Fs,ab as Us,ac as qs,ad as cs,ae as ue,af as $e,ag as Hs,ah as Ks,ai as Gs,aj as $s,B as K,ak as Be,al as ze,am as Bs,q as ds,m as Te,l as zs,an as Qs,ao as Vs,ap as Js,aq as Ws,ar as Xs,as as ee,T as se,o as te,p as ae,at as Ys,au as Zs,av as et,aw as Qe,ax as Ve,ay as st,az as tt,aA as at,aB as nt,aC as it,aD as rt,H as ot,J as lt,K as Je,M as We,aE as ct,aF as dt,aG as ut,aH as mt,aI as xt,aJ as pt,aK as ht,aL as ft,aM as gt,aN as jt,aO as vt,S as Nt}from"./index-uj-gfqVW.js";import{C as je}from"./default-ports-1QQSffYX.js";import{t as I}from"./notifications-B2HqRBj7.js";import{b as us,L as B,m as xe,y as wt,j as z,l as ms,an as Oe,R as Ee,n as ne,a0 as le,ao as bt,ap as pe,Z as ce,I as xs,f as Ct,a2 as ps,aq as yt,ah as kt,X as De,$ as hs,s as fs,t as ve,ar as St,T as At,p as Xe,as as Pt,ag as gs,q as Mt,at as Tt,k as Ot,a1 as Et,ak as Dt,au as js}from"./icons-DGASzt3M.js";import{C as _t}from"./confirm-dialog-DjChZijF.js";import{S as _e}from"./separator-DIHMuj2A.js";import{S as vs}from"./switch-Db-uyN1u.js";import{P as Rt}from"./proxy-status-widget-C9OwEWsC.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-C3jFRTwI.js";const oe={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-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Previous flagship, extended thinking",presetMapping:{default:"claude-opus-4-5-thinking",opus:"claude-opus-4-5-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"claude-sonnet-4-5-thinking",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5-thinking",haiku:"claude-sonnet-4-5"}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"claude-sonnet-4-5",opus:"claude-opus-4-6-thinking",sonnet:"claude-sonnet-4-5",haiku:"claude-sonnet-4-5"}},{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-xhigh",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5.3-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Previous stable Codex model",presetMapping:{default:"gpt-5.2-codex-xhigh",opus:"gpt-5.2-codex-xhigh",sonnet:"gpt-5.2-codex-high",haiku:"gpt-5-mini-medium"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high effort (no xhigh)",presetMapping:{default:"gpt-5-mini-medium",opus:"gpt-5.3-codex-xhigh",sonnet:"gpt-5-mini-high",haiku:"gpt-5-mini-medium"}},{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-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"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:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow 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"}]}},fe="ccs-internal-managed";async function Lt(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??fe:fe}catch{return fe}}async function Ne(s,a){const t=oe[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},u=await Lt(),m={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${je}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:u,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:m})})).ok,presetName:n?.name||t.defaultModel}}catch{return{success:!1}}}function It({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 Ft({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(us,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function Ut({selectedProvider:s,providers:a,authCommand:t,isRefreshing:n,isPending:i,onBack:u,onStartAuth:c,onRefresh:m}){const[f,h]=d.useState(!1),x=async v=>{await navigator.clipboard.writeText(v),h(!0),setTimeout(()=>h(!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(v=>v.id===s)?.name," to add an account"]}),e.jsx(O,{onClick:c,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{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(ns,{children:e.jsxs(is,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(wt,{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(O,{variant:"outline",size:"icon",onClick:()=>x(t),children:f?e.jsx(z,{className:"w-4 h-4 text-green-500"}):e.jsx(ms,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(O,{variant:"ghost",onClick:u,disabled:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(O,{variant:"outline",onClick:m,disabled:n||i,children:[e.jsx(Ee,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function qt({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(u=>e.jsxs("button",{type:"button",onClick:()=>t(u),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(ne,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:H("font-medium",a&&me),children:u.email||u.id}),u.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(us,{className:"w-4 h-4 text-muted-foreground"})]},u.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(xe,{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(O,{variant:"ghost",onClick:i,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ye="__custom__";function Ht({selectedProvider:s,selectedAccount:a,variantName:t,modelName:n,isPending:i,privacyMode:u,onVariantNameChange:c,onModelChange:m,onBack:f,onSkip:h,onCreate:x}){const v=oe[s]?.models||[],r=n&&!v.some(o=>o.id===n),[g,N]=d.useState(r),C=o=>{o===Ye?(N(!0),m("")):(N(!1),m(o))};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(ne,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:H(u&&me),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ie,{id:"variant-name",value:t,onChange:o=>c(o.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:"Model"}),g?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ie,{value:n,onChange:o=>m(o.target.value),placeholder:"e.g., gemini-2.5-pro, claude-opus-4-5"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>N(!1),children:"Choose from presets instead"})]}):e.jsxs(be,{value:v.some(o=>o.id===n)?n:"",onValueChange:C,children:[e.jsx(Ce,{children:e.jsx(ye,{placeholder:"Select a model"})}),e.jsxs(ke,{children:[v.map(o=>e.jsx(re,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:o.name}),o.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",o.description]})]})},o.id)),e.jsx(re,{value:Ye,children:e.jsx("span",{className:"text-primary",children:"Custom model name..."})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:g?"Enter any model name supported by CLIProxy":`Default: ${oe[s]?.defaultModel||"provider default"}`})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(O,{variant:"ghost",onClick:f,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{variant:"ghost",onClick:h,children:"Skip"}),e.jsx(O,{onClick:x,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Kt({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(z,{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(ns,{children:e.jsxs(is,{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(O,{onClick:a,className:"w-full",children:"Done"})]})}function Gt({open:s,onClose:a}){const[t,n]=d.useState("provider"),[i,u]=d.useState(""),[c,m]=d.useState(null),[f,h]=d.useState(""),[x,v]=d.useState(""),[r,g]=d.useState(!1),[N,C]=d.useState(!1),{data:o,refetch:p}=rs(),T=Rs(),k=Ls(),j=Is(),{privacyMode:E}=os(),S=o?.authStatus.find(P=>P.provider===i),D=d.useMemo(()=>S?.accounts||[],[S?.accounts]);d.useEffect(()=>{if(!s){const P=setTimeout(()=>{n("provider"),u(""),m(null),h(""),v(""),C(!1)},0);return()=>clearTimeout(P)}},[s]),d.useEffect(()=>{if(t==="auth"&&D.length>0&&!N){const P=setTimeout(()=>{n("account")},0);return()=>clearTimeout(P)}},[t,D,N]);const L=async()=>{g(!0),await p(),g(!1)},F=()=>{const P=(S?.accounts?.length||0)===0;k.mutate({provider:i},{onSuccess:async M=>{if(P){const b=await Ne(i);b.success&&b.presetName?I.success(`Applied "${b.presetName}" preset`):b.success||I.warning("Account added, but failed to apply default preset")}M.account&&(m(M.account),n("variant")),p()}})},y=P=>{u(P),(o?.authStatus.find(q=>q.provider===P)?.accounts||[]).length===0?n("auth"):n("account")},A=P=>{m(P),n("variant")},w=async()=>{if(!(!f||!i))try{await T.mutateAsync({name:f,provider:i,model:x||void 0,account:c?.id}),n("success")}catch(P){console.error("Failed to create variant:",P)}},_=`ccs ${i} --auth --add`,U=Us(t),G=P=>{if(!P&&(k.isPending&&i&&j.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(Se,{open:s,onOpenChange:G,children:e.jsxs(Ae,{className:"sm:max-w-lg",onPointerDownOutside:P=>{t!=="success"&&t!=="provider"&&P.preventDefault()},onEscapeKeyDown:P=>{(k.isPending||T.isPending)&&P.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(ls,{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(Ft,{providers:Ge,onSelect:y}),t==="auth"&&e.jsx(Ut,{selectedProvider:i,providers:Ge,authCommand:_,isRefreshing:r,isPending:k.isPending,onBack:()=>n("provider"),onStartAuth:F,onRefresh:L}),t==="account"&&e.jsx(qt,{accounts:D,privacyMode:E,onSelect:A,onAddNew:()=>{C(!0),n("auth")},onBack:()=>n("provider")}),t==="variant"&&e.jsx(Ht,{selectedProvider:i,selectedAccount:c,variantName:f,modelName:x,isPending:T.isPending,privacyMode:E,onVariantNameChange:h,onModelChange:v,onBack:()=>D.length>0?n("account"):n("provider"),onSkip:a,onCreate:w}),t==="success"&&e.jsx(Kt,{variantName:f,onClose:a})]}),e.jsx(It,{currentProgress:U,allSteps:Fs})]})})}const $t=3e3,Bt=300*1e3,X={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function zt(){const[s,a]=d.useState(X),t=d.useRef(null),n=d.useRef(null),i=d.useRef(0),u=d.useRef(!1),c=we(),m=d.useCallback(()=>{n.current&&(clearInterval(n.current),n.current=null)},[]);d.useEffect(()=>()=>{t.current?.abort(),m(),u.current=!1},[m]);const f=d.useCallback(async(r,g)=>{if(Date.now()-i.current>Bt){m(),a(N=>({...N,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const C=await(await fetch(`/api/cliproxy/auth/${r}/status?state=${encodeURIComponent(g)}`)).json();if(C.status==="ok")m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${r} authentication successful`),u.current=!1,a(X);else if(C.status==="auth_url"){const o=C.url||C.auth_url;o&&(a(p=>({...p,authUrl:o})),u.current||(u.current=!0,window.open(o,"_blank")))}else if(C.status==="device_code"){m();const o=C.user_code&&C.verification_url?`Open ${C.verification_url} and enter code: ${C.user_code}`:"Switch to Device Code method and try again.";I.error("Provider returned Device Code flow in callback mode"),a(p=>({...p,isAuthenticating:!1,error:o}))}else if(C.status==="error"){m();const o=C.error||"Authentication failed";I.error(o),a(p=>({...p,isAuthenticating:!1,error:o}))}}catch{}},[c,m]),h=d.useCallback(async(r,g)=>{if(!qs(r)){a({...X,error:`Unknown provider: ${r}`});return}t.current?.abort(),m(),u.current=!1;const N=new AbortController;t.current=N;const o=(g?.flowType||(cs(r)?"device_code":"authorization_code"))==="device_code",p=g?.startEndpoint||(o?"start":"start-url"),T={nickname:g?.nickname,kiroMethod:g?.kiroMethod};a({provider:r,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:o});try{if(p==="start")fetch(`/api/cliproxy/auth/${r}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}).then(async k=>{const j=await k.json();if(k.ok&&j.success)c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),u.current=!1,a(X);else{const E=j.error||"Authentication failed";I.error(E),a(S=>({...S,isAuthenticating:!1,error:E}))}}).catch(k=>{if(k instanceof Error&&k.name==="AbortError")return;const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))});else{const k=await fetch(`/api/cliproxy/auth/${r}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T),signal:N.signal}),j=await k.json();if(!k.ok||!j.success)throw new Error(j.error||"Failed to start OAuth");a(E=>({...E,authUrl:j.authUrl||null,oauthState:j.state})),j.authUrl&&(u.current=!0,window.open(j.authUrl,"_blank")),j.state&&(i.current=Date.now(),n.current=setInterval(()=>{f(r,j.state)},$t))}}catch(k){if(k instanceof Error&&k.name==="AbortError"){u.current=!1,a(X);return}const j=k instanceof Error?k.message:"Authentication failed";I.error(j),a(E=>({...E,isAuthenticating:!1,error:j}))}},[f,m,c]),x=d.useCallback(()=>{const r=s.provider;t.current?.abort(),m(),u.current=!1,a(X),r&&ue.cliproxy.auth.cancel(r).catch(()=>{})},[s.provider,m]),v=d.useCallback(async r=>{if(s.provider){a(g=>({...g,isSubmittingCallback:!0,error:null}));try{const g=await fetch(`/api/cliproxy/auth/${s.provider}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:r})}),N=await g.json();if(g.ok&&N.success)m(),c.invalidateQueries({queryKey:["cliproxy-auth"]}),c.invalidateQueries({queryKey:["account-quota"]}),I.success(`${s.provider} authentication successful`),a(X);else throw new Error(N.error||"Callback submission failed")}catch(g){const N=g instanceof Error?g.message:"Failed to submit callback";I.error(N),a(C=>({...C,isSubmittingCallback:!1,error:N}))}}},[s.provider,c,m]);return d.useMemo(()=>({...s,startAuth:h,cancelAuth:x,submitCallback:v}),[s,h,x,v])}function Qt({open:s,onClose:a,provider:t,displayName:n,isFirstAccount:i=!1}){const[u,c]=d.useState(""),[m,f]=d.useState(""),[h,x]=d.useState(!1),[v,r]=d.useState(null),[g,N]=d.useState($e),C=d.useRef(!1),o=zt(),p=Hs(),T=t==="kiro",k=cs(t),j=$s(t),E=Ks(g),S=T?E.flowType==="device_code":k,D=o.isAuthenticating||p.isPending,L=u.trim(),F=v||o.error,y=()=>{c(""),f(""),x(!1),r(null),N($e),C.current=!1,a()};d.useEffect(()=>{!o.isAuthenticating&&!o.error&&o.provider===null&&s&&C.current&&(C.current=!1,(async()=>{try{const q=await Ne(t);q.success&&q.presetName&&i&&I.success(`Applied "${q.presetName}" preset`)}catch{}y()})())},[o.isAuthenticating,o.error,o.provider]);const A=()=>{o.cancelAuth(),y()},w=async()=>{o.authUrl&&(await navigator.clipboard.writeText(o.authUrl),x(!0),setTimeout(()=>x(!1),2e3))},_=()=>{m.trim()&&o.submitCallback(m.trim())},U=()=>{if(j&&!L){r(`Nickname is required for ${n} accounts.`);return}r(null),C.current=!0,o.startAuth(t,{nickname:L||void 0,kiroMethod:T?g:void 0,flowType:T?E.flowType:void 0,startEndpoint:T?E.startEndpoint:void 0})},G=()=>{C.current=!0,p.mutate(void 0,{onSuccess:async()=>{const b=await Ne("kiro");b.success&&b.presetName&&i&&I.success(`Applied "${b.presetName}" preset`),y()}})},P=b=>{b||A()},M=o.isAuthenticating;return e.jsx(Se,{open:s,onOpenChange:P,children:e.jsxs(Ae,{className:"sm:max-w-md",onInteractOutside:b=>{M&&b.preventDefault()},children:[e.jsxs(Pe,{children:[e.jsxs(Me,{children:["Add ",n," Account"]}),e.jsx(ls,{children:T?"Choose a Kiro auth method, then authenticate via browser or import from Kiro IDE.":S?"Click Authenticate. A verification code will appear for you to enter on the provider website.":"Click Authenticate to get an OAuth URL. Open it in any browser to sign in."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[T&&!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:"Auth Method"}),e.jsxs(be,{value:g,onValueChange:b=>{N(b),r(null)},children:[e.jsx(Ce,{id:"kiro-auth-method",children:e.jsx(ye,{placeholder:"Select Kiro auth method"})}),e.jsx(ke,{children:Gs.map(b=>e.jsx(re,{value:b.id,children:b.label},b.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:E.description})]}),!M&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"nickname",children:j?"Nickname (required)":"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ie,{id:"nickname",value:u,onChange:b=>{c(b.target.value),r(null)},placeholder:"e.g., work, personal",disabled:D,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Required for this provider. Use a unique friendly name (e.g., work, personal).":"A friendly name to identify this account. Auto-generated from email if left empty."})]}),M&&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(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Waiting for authentication..."]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o.isDeviceCodeFlow?"A verification code dialog will appear shortly. Enter the code on the provider website.":"Complete the authentication in your browser. This dialog closes automatically."})]}),o.authUrl&&!o.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:"Open this URL in any browser to sign in:"}),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:o.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(O,{variant:"outline",size:"sm",onClick:w,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ms,{className:"w-3 h-3 mr-1"}),"Copy"]})}),e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{if(!o.authUrl)return;const b=window.open(o.authUrl,"_blank");(!b||b.closed||typeof b.closed>"u")&&I.warning("Popup blocked. Copy the URL above and open it manually in your browser.",{duration:5e3})},children:[e.jsx(xe,{className:"w-3 h-3 mr-1"}),"Open"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:"Redirect didn't work? Paste the callback URL:"}),e.jsx(ie,{id:"callback-url",value:m,onChange:b=>f(b.target.value),placeholder:"Paste the redirect URL here...",className:"font-mono text-xs"}),e.jsx(O,{variant:"secondary",size:"sm",onClick:_,disabled:!m.trim()||o.isSubmittingCallback,children:o.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-3 h-3 mr-1 animate-spin"}),"Submitting..."]}):"Submit Callback"})]})]}),!o.authUrl&&!o.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Preparing sign-in URL..."})]}),F&&e.jsx("p",{className:"text-xs text-center text-destructive",children:F}),p.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(B,{className:"w-4 h-4 inline mr-2 animate-spin"}),"Importing token from Kiro IDE..."]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(O,{variant:"ghost",onClick:A,children:"Cancel"}),T&&!M&&e.jsx(O,{variant:"outline",onClick:G,disabled:D,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),!M&&e.jsxs(O,{onClick:U,disabled:D||j&&!L,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Authenticate"]})]})]})]})})}const Re="[1m]";function Vt(s){return s.toLowerCase().startsWith("gemini-")}function Le(s){return s.toLowerCase().endsWith(Re.toLowerCase())}function Jt(s){return!s||Le(s)?s:`${s}${Re}`}function Ns(s){return s&&(Le(s)?s.slice(0,-Re.length):s)}const Ze=["ANTHROPIC_MODEL"],Wt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Xt(s){const a=s?.env||{};return Wt.filter(t=>!a[t]?.trim())}function Yt(s){const[a,t]=d.useState(null),[n,i]=d.useState(!1),u=we(),{data:c,isLoading:m,refetch:f}=as({queryKey:["settings",s],queryFn:async()=>{const y=await fetch(`/api/settings/${s}/raw`);return y.ok?y.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),h=c?.settings,x=d.useMemo(()=>a!==null?a:h?JSON.stringify(h,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[a,h]),v=d.useCallback(y=>{t(y)},[]),r=d.useMemo(()=>{try{return JSON.parse(x)}catch{return h||{env:{}}}},[x,h]),g=r?.env?.ANTHROPIC_MODEL,N=r?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,C=r?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,o=r?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,p=d.useMemo(()=>{const y=r?.env||{};return Ze.some(A=>{const w=y[A];return w&&Le(w)})},[r]),T=d.useCallback((y,A)=>{const w={...r?.env||{},[y]:A},_={...r,env:w};t(JSON.stringify(_,null,2))},[r]),k=d.useCallback(y=>{const A=r?.env||{},w={};for(const G of Ze){const P=A[G];P&&(w[G]=y?Jt(P):Ns(P))}const _={...A,...w};delete _.CCS_EXTENDED_CONTEXT;const U={...r,env:_};t(JSON.stringify(U,null,2))},[r]),j=d.useCallback(y=>{const A={...r?.env||{},...y},w={...r,env:A};t(JSON.stringify(w,null,2))},[r]),E=d.useMemo(()=>{try{return JSON.parse(x),!0}catch{return!1}},[x]),S=d.useMemo(()=>a===null?!1:a!==JSON.stringify(h,null,2),[a,h]),D=d.useMemo(()=>Xt(r),[r]),L=_s({mutationFn:async()=>{const y=JSON.parse(x),A=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:y,expectedMtime:c?.mtime})});if(A.status===409)throw new Error("CONFLICT");if(!A.ok)throw new Error("Failed to save");return A.json()},onSuccess:y=>{u.invalidateQueries({queryKey:["settings",s]}),t(null),y?.warning?I.success("Settings saved",{description:y.warning}):I.success("Settings saved")},onError:y=>{y.message==="CONFLICT"?i(!0):I.error(y.message)}}),F=async y=>{i(!1),y?(await f(),L.mutate()):t(null)};return{data:c,isLoading:m,refetch:f,rawJsonContent:x,rawJsonEdits:a,isRawJsonValid:E,hasChanges:S,currentSettings:r,currentModel:g,opusModel:N,sonnetModel:C,haikuModel:o,extendedContextEnabled:p,toggleExtendedContext:k,handleRawJsonChange:v,updateEnvValue:T,updateEnvValues:j,saveMutation:{mutate:()=>L.mutate(),isPending:L.isPending},conflictDialog:n,setConflictDialog:i,handleConflictResolve:F,missingRequiredFields:D}}const Zt=/-(medium|high|xhigh)$/i;function ea(s){if(!s)return;const a=s.trim().match(Zt);if(a?.[1])return a[1].toLowerCase()}function ge(s){if(!s)return null;const a=ea(s);return a?{label:`Pinned ${a}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function J({label:s,description:a,value:t,onChange:n,catalog:i,allModels:u,disabled:c}){const m=new Set(i?.models.map(x=>x.id)||[]),f=i?.provider==="codex",h=f?ge(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(be,{value:t||"",onValueChange:n,disabled:c,children:[e.jsx(Ce,{className:"h-9",children:e.jsx(ye,{placeholder:"Select model",children:t&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:t}),h&&e.jsx(K,{variant:h.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:h.label})]})})}),e.jsxs(ke,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(Be,{children:[e.jsx(ze,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(x=>{const v=f?ge(x.id):null;return e.jsx(re,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:x.id}),x.tier==="paid"&&e.jsx(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),v&&e.jsx(K,{variant:v.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:v.label}),t===x.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},x.id)})]}),u.length>0&&e.jsxs(Be,{children:[e.jsxs(ze,{className:"text-xs text-muted-foreground",children:["All Models (",u.length,")"]}),u.filter(x=>!m.has(x.id)).map(x=>{const v=f?ge(x.id):null;return e.jsx(re,{value:x.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:x.id}),v&&e.jsx(K,{variant:v.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:v.label}),t===x.id&&e.jsx(z,{className:"w-3 h-3 text-primary ml-auto"})]})},x.id)})]}),(!i||i.models.length===0)&&u.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function sa({open:s,onClose:a,currentValues:t,onApply:n,onSave:i,isSaving:u,catalog:c,allModels:m}){const[f,h]=d.useState(t),[x,v]=d.useState(""),r=g=>{g?(h(t),v("")):a()};return e.jsx(Se,{open:s,onOpenChange:r,children:e.jsxs(Ae,{className:"sm:max-w-md",children:[e.jsx(Pe,{children:e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4"}),"Custom Preset"]})}),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:"Preset Name (optional)"}),e.jsx(ie,{id:"preset-name",value:x,onChange:g=>v(g.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(_e,{}),c?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground 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 effort. Unsuffixed models use Thinking settings."]}),e.jsx(J,{label:"Default Model",description:"Used when no specific tier is requested",value:f.default,onChange:g=>h({...f,default:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:f.opus,onChange:g=>h({...f,opus:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:f.sonnet,onChange:g=>h({...f,sonnet:g}),catalog:c,allModels:m}),e.jsx(J,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:f.haiku,onChange:g=>h({...f,haiku:g}),catalog:c,allModels:m})]}),e.jsxs(Bs,{className:"gap-2 sm:gap-0",children:[e.jsx(O,{variant:"outline",onClick:a,children:"Cancel"}),i&&e.jsxs(O,{variant:"secondary",onClick:()=>i(f,x||void 0),disabled:u||!x.trim(),children:[u?e.jsx(B,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(pe,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(O,{onClick:()=>n(f,x||void 0),children:[e.jsx(ce,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function de({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(ds,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function ta({provider:s,displayName:a,data:t,authStatus:n}){return e.jsx(Te,{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(xs,{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})]}),t&&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:t.path}),e.jsx(ds,{value:t.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(t.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"}),n.authenticated?e.jsxs(K,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(Ct,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(K,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),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(de,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(de,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(de,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(de,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const aa={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg",claude:"/assets/providers/claude.svg",kimi:"/assets/providers/kimi.svg"},na={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"},kimi:{text:"text-orange-500",letter:"K"}},ia=new Set(["kimi"]),ra={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 Ie({provider:s,className:a,size:t="md"}){const n=s.toLowerCase(),i=na[n]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},u=ra[t],c=aa[n];return e.jsx("div",{className:H("flex items-center justify-center rounded-md",c&&(ia.has(n)?"bg-gray-900 p-1":"bg-white p-1"),u.container,a),children:c?e.jsx("img",{src:c,alt:`${s} logo`,className:H(u.icon,"object-contain")}):e.jsx("span",{className:H("font-semibold",i.text,u.text),children:i.letter})})}function oa({displayName:s,logoProvider:a,provider:t,data:n,isLoading:i,hasChanges:u,isRawJsonValid:c,isSaving:m,isRemoteMode:f,port:h,onRefetch:x,onSave:v}){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(Ie,{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}),f&&e.jsxs(K,{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(ps,{className:"w-3 h-3"}),"Remote"]}),h&&e.jsxs(K,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(yt,{className:"w-3 h-3"}),":",h]}),!f&&n?.path&&e.jsx(K,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),f?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(O,{variant:"ghost",size:"sm",onClick:x,disabled:i,children:e.jsx(Ee,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(O,{size:"sm",onClick:v,disabled:m||!u||!c,children:m?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(kt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function la({model:s,provider:a,enabled:t,onToggle:n,disabled:i,className:u}){if(!s?.extendedContext)return null;const c=Vt(s.id);return e.jsxs("div",{className:H("rounded-lg border p-3 space-y-2",t?"border-primary/50 bg-primary/5":"border-border bg-muted/30",u),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:H("w-4 h-4",t?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(K,{variant:t?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(vs,{checked:t,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(xs,{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:c?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 ca({catalog:s,savedPresets:a,currentModel:t,opusModel:n,sonnetModel:i,haikuModel:u,providerModels:c,provider:m,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N}){const C=s&&s.models.length>0||a.length>0,o=d.useMemo(()=>{if(!s||!t)return;const p=Ns(t);return s.models.find(T=>T.id===p)},[s,t]);return e.jsxs(e.Fragment,{children:[C&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(p=>e.jsxs(O,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const T=p.presetMapping||{default:p.id,opus:p.id,sonnet:p.id,haiku:p.id};x({ANTHROPIC_MODEL:T.default,ANTHROPIC_DEFAULT_OPUS_MODEL:T.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:T.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:T.haiku})},children:[e.jsx(ce,{className:"w-3 h-3"}),p.name]},p.id)),a.map(p=>e.jsxs("div",{className:"group relative",children:[e.jsxs(O,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{x({ANTHROPIC_MODEL:p.default,ANTHROPIC_DEFAULT_OPUS_MODEL:p.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:p.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:p.haiku})},children:[e.jsx(pe,{className:"w-3 h-3 fill-current"}),p.name]}),e.jsx(O,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:T=>{T.stopPropagation(),g(p.name)},disabled:N,children:e.jsx(De,{className:"w-3 h-3"})})]},p.name)),e.jsxs(O,{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(hs,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(_e,{}),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"}),m==="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(J,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:p=>v("ANTHROPIC_MODEL",p),catalog:s,allModels:c}),o?.extendedContext&&h&&e.jsx(la,{model:o,provider:m,enabled:f??!1,onToggle:h}),e.jsx(J,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:p=>v("ANTHROPIC_DEFAULT_OPUS_MODEL",p),catalog:s,allModels:c}),e.jsx(J,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:p=>v("ANTHROPIC_DEFAULT_SONNET_MODEL",p),catalog:s,allModels:c}),e.jsx(J,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:u,onChange:p=>v("ANTHROPIC_DEFAULT_HAIKU_MODEL",p),catalog:s,allModels:c})]})]})]})}function da({className:s,...a}){return e.jsx(Es,{"data-slot":"checkbox",className:H("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",s),...a,children:e.jsx(Ds,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(z,{className:"size-3.5"})})})}function es(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function ss(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)),u=Math.floor(n/(1e3*60*60)),c=Math.floor(n/(1e3*60*60*24));return c>0?`${c}d ago`:u>0?`${u}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function ua(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:u,privacyMode:c,showQuota:m,selectable:f,selected:h,onSelectChange:x}){const{data:v}=zs(m),{data:r,isLoading:g}=Qs(s.provider,s.id,m),N=v?.accountStats?.[s.email||s.id]?.lastUsedAt,C=ua(N),o=Vs(s.provider,r),p=Js(s.provider,r),T=s.provider==="codex"&&r&&Ws(r)?Xs(r.windows):null,k=[{label:"5h",value:T?.fiveHourWindow?.remainingPercent??null},{label:"Weekly",value:T?.weeklyWindow?.remainingPercent??null}].filter(j=>j.value!==null);return e.jsxs("div",{className:H("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",h&&"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:[f&&e.jsx("button",{type:"button",onClick:()=>x?.(!h),className:H("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",h?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":h?"Deselect account":"Select account",children:h&&e.jsx(z,{className:"w-3 h-3"})}),n&&e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!s.paused),disabled:u,children:u?e.jsx(B,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(fs,{className:"w-4 h-4 text-emerald-500"}):e.jsx(ve,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ae,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:H("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(ne,{className:"w-4 h-4"})}),s.tier&&s.tier!=="unknown"&&s.tier!=="free"&&e.jsx("span",{className:H("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:H("font-medium text-sm truncate",c&&me),children:s.email||s.id}),s.isDefault&&e.jsxs(K,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(pe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.paused&&e.jsxs(K,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(ve,{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(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(St,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:H("font-mono max-w-[180px] truncate",c&&me),title:s.projectId,children:s.projectId})]})}),e.jsx(ae,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(At,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(ae,{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(Xe,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Ys,{children:[e.jsx(Zs,{asChild:!0,children:e.jsx(O,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(Pt,{className:"w-4 h-4"})})}),e.jsxs(et,{align:"end",children:[!s.isDefault&&e.jsxs(Qe,{onClick:a,children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Qe,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(gs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),m&&e.jsx("div",{className:"pl-11",children:g?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(B,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):o!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",ss(N)]})]}):N?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",ss(N)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Tt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:s.provider==="codex"&&k.length>0?e.jsx("div",{className:"space-y-1.5",children:k.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-10 text-[10px] text-muted-foreground",children:j.label}),e.jsx(Ve,{value:Math.max(0,Math.min(100,j.value)),className:"h-2 flex-1",indicatorClassName:es(j.value)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[j.value,"%"]})]},j.label))}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{value:Math.max(0,Math.min(100,o)),className:"h-2 flex-1",indicatorClassName:es(o)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[o,"%"]})]})}),e.jsx(ae,{side:"bottom",className:"max-w-xs",children:r&&e.jsx(st,{quota:r,resetTime:p})})]})})]}):r?.needsReauth?e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{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(Ot,{className:"w-3 h-3"}),"Reauth"]})})}),e.jsx(ae,{side:"bottom",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:r.error?.includes("No refresh token")?"No refresh token available. Remove and re-add account to fix.":r.error?.includes("refresh")||r.error?.includes("Invalid")?`Auto-refresh failed: ${r.error}`:`Token issue: ${r.error||"Re-authenticate required"}`})})]})}):r?.error||r&&!r.success?e.jsx(ee,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(Et,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(ae,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:r?.error||"Quota information unavailable"})})]})}):null})]})}function xa({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:n,isPausing:i,isResuming:u}){if(s<1)return null;const c=i||u;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(O,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:c,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(O,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:c,children:[i?e.jsx(B,{className:"w-3 h-3 animate-spin"}):e.jsx(ve,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(O,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:c,children:[u?e.jsx(B,{className:"w-3 h-3 animate-spin"}):e.jsx(fs,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function pa({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:n,onPauseToggle:i,onSoloMode:u,onBulkPause:c,onBulkResume:m,isRemovingAccount:f,isPausingAccount:h,isSoloingAccount:x,isBulkPausing:v,isBulkResuming:r,privacyMode:g,showQuota:N,isKiro:C,kiroNoIncognito:o,onKiroNoIncognitoChange:p,kiroSettingsLoading:T}){const[k,j]=d.useState(new Set),E=d.useMemo(()=>new Set(s.map(M=>M.id)),[s]),S=d.useMemo(()=>new Set([...k].filter(M=>E.has(M))),[k,E]),D=!!(c&&m),L=S.size,F=s.length>0&&S.size===s.length,y=S.size>0&&S.size<s.length,A=d.useCallback(M=>{j(b=>{const q=new Set(b);return q.has(M)?q.delete(M):q.add(M),q})},[]),w=d.useCallback(()=>{j(new Set(s.map(M=>M.id)))},[s]),_=d.useCallback(()=>{j(new Set)},[]),U=d.useCallback(()=>{F?_():w()},[F,w,_]),G=d.useCallback(()=>{c&&S.size>0&&(c(Array.from(S)),j(new Set))},[c,S]),P=d.useCallback(()=>{m&&S.size>0&&(m(Array.from(S)),j(new Set))},[m,S]);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:[D&&s.length>0&&e.jsx(da,{checked:F,onCheckedChange:U,"aria-label":"Select all accounts",className:y?"data-[state=checked]:bg-primary/50":"",...y?{"data-state":"indeterminate"}:{}}),e.jsx(ne,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(K,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(O,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(hs,{className:"w-3 h-3"}),"Add"]})]}),D&&L>0&&e.jsx(xa,{selectedCount:L,onPauseSelected:G,onResumeSelected:P,onClearSelection:_,isPausing:!!v,isResuming:!!r}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(M=>e.jsx(ma,{account:M,onSetDefault:()=>t(M.id),onRemove:()=>n(M.id),onPauseToggle:i?b=>i(M.id,b):void 0,onSoloMode:u?()=>u(M.id):void 0,isRemoving:f,isPausingAccount:h,isSoloingAccount:x,privacyMode:g,showQuota:N,selectable:D,selected:S.has(M.id),onSelectChange:()=>A(M.id)},M.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(ne,{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"})]}),C&&p&&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(ps,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(vs,{checked:!o,onCheckedChange:M=>p(!M),disabled:T,className:"scale-90"})]})})]})}function ha({provider:s,catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:u,haikuModel:c,providerModels:m,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N,accounts:C,onAddAccount:o,onSetDefault:p,onRemoveAccount:T,onPauseToggle:k,onSoloMode:j,onBulkPause:E,onBulkResume:S,isRemovingAccount:D,isPausingAccount:L,isSoloingAccount:F,isBulkPausing:y,isBulkResuming:A,privacyMode:w,isRemoteMode:_}){const U=s==="kiro",[G,P]=d.useState(!0),[M,b]=d.useState(!0),[q,Z]=d.useState(!1),l=d.useCallback(async()=>{if(U)try{b(!0);const W=(await ue.config.get()).cliproxy;P(W?.kiro_no_incognito??!0)}catch{P(!0)}finally{b(!1)}},[U]),R=d.useCallback(async Q=>{P(Q),Z(!0);try{const W=await ue.config.get(),he=W.cliproxy??{};await ue.config.update({...W,cliproxy:{...he,kiro_no_incognito:Q}})}catch{P(!Q)}finally{Z(!1)}},[]);return d.useEffect(()=>{l()},[l]),e.jsx(Te,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(ca,{catalog:a,savedPresets:t,currentModel:n,opusModel:i,sonnetModel:u,haikuModel:c,providerModels:m,provider:s,extendedContextEnabled:f,onExtendedContextToggle:h,onApplyPreset:x,onUpdateEnvValue:v,onOpenCustomPreset:r,onDeletePreset:g,isDeletePending:N}),e.jsx(_e,{}),e.jsx(pa,{accounts:C,onAddAccount:o,onSetDefault:p,onRemoveAccount:T,onPauseToggle:k,onSoloMode:j,onBulkPause:E,onBulkResume:S,isRemovingAccount:D,isPausingAccount:L,isSoloingAccount:F,isBulkPausing:y,isBulkResuming:A,privacyMode:w,showQuota:tt.includes(s)&&!_,isKiro:U,kiroNoIncognito:G,onKiroNoIncognitoChange:R,kiroSettingsLoading:M||q})]})})}function ts({provider:s,displayName:a,authStatus:t,catalog:n,logoProvider:i,baseProvider:u,isRemoteMode:c,port:m,onAddAccount:f,onSetDefault:h,onRemoveAccount:x,onPauseToggle:v,onSoloMode:r,onBulkPause:g,onBulkResume:N,isRemovingAccount:C,isPausingAccount:o,isSoloingAccount:p,isBulkPausing:T,isBulkResuming:k}){const[j,E]=d.useState(!1),{privacyMode:S}=os(),{data:D}=at(),{data:L}=nt(s),F=it(),y=rt(),A=L?.presets||[],w=u||s,_=d.useMemo(()=>{if(!D?.models)return[];const V={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[w.toLowerCase()]||[w.toLowerCase()];return D.models.filter(Ke=>V.some(Os=>Ke.owned_by.toLowerCase().includes(Os)))},[D,w]),{data:U,isLoading:G,refetch:P,rawJsonContent:M,rawJsonEdits:b,isRawJsonValid:q,hasChanges:Z,currentModel:l,opusModel:R,sonnetModel:Q,haikuModel:W,extendedContextEnabled:he,toggleExtendedContext:ws,handleRawJsonChange:bs,updateEnvValue:Cs,updateEnvValues:Fe,saveMutation:Ue,conflictDialog:ys,handleConflictResolve:qe,missingRequiredFields:ks}=Yt(s),Ss=t.accounts||[],{data:As}=as({queryKey:["auth-tokens-raw"],queryFn:async()=>{const $=await fetch("/api/settings/auth/tokens/raw");return $.ok?$.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),He=As?.apiKey?.value??"ccs-internal-managed",Ps=$=>{Fe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${m??je}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:He,...$}),I.success(`Applied "${$.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Ms=($,V)=>{Fe({ANTHROPIC_BASE_URL:`http://127.0.0.1:${m??je}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:He,ANTHROPIC_MODEL:$.default,ANTHROPIC_DEFAULT_OPUS_MODEL:$.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:$.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:$.haiku}),I.success(`Applied ${V?`"${V}"`:"custom"} preset`),E(!1)},Ts=($,V)=>{if(!V){I.error("Please enter a preset name to save");return}F.mutate({profile:s,data:{name:V,...$}}),E(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(oa,{provider:s,displayName:a,logoProvider:i,data:U,isLoading:G,hasChanges:Z,isRawJsonValid:q,isSaving:Ue.isPending,isRemoteMode:c,port:m,onRefetch:P,onSave:()=>Ue.mutate()}),G?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(B,{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(ot,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(lt,{className:"w-full",children:[e.jsx(Je,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Je,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(We,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(ha,{provider:s,catalog:n,savedPresets:A,currentModel:l,opusModel:R,sonnetModel:Q,haikuModel:W,providerModels:_,extendedContextEnabled:he,onExtendedContextToggle:ws,onApplyPreset:Ps,onUpdateEnvValue:Cs,onOpenCustomPreset:()=>E(!0),onDeletePreset:$=>y.mutate({profile:s,name:$}),isDeletePending:y.isPending,accounts:Ss,onAddAccount:f,onSetDefault:h,onRemoveAccount:x,onPauseToggle:v,onSoloMode:r,onBulkPause:g,onBulkResume:N,isRemovingAccount:C,isPausingAccount:o,isSoloingAccount:p,isBulkPausing:T,isBulkResuming:k,privacyMode:S,isRemoteMode:c})}),e.jsx(We,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(ta,{provider:s,displayName:a,data:U,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(Dt,{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(ct,{rawJsonContent:M,isRawJsonValid:q,rawJsonEdits:b,onRawJsonChange:bs,profileEnv:U?.settings?.env,missingRequiredFields:ks})]})]}),e.jsx(_t,{open:ys,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>qe(!0),onCancel:()=>qe(!1)}),e.jsx(sa,{open:j,onClose:()=>E(!1),currentValues:{default:l||"",opus:R||"",sonnet:Q||"",haiku:W||""},onApply:Ms,onSave:Ts,isSaving:F.isPending,catalog:n,allModels:_})]})}function fa({status:s,isSelected:a,onSelect:t}){const n=s.accounts?.length||0;return e.jsxs("button",{className:H("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(Ie,{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}),n>0&&e.jsx(K,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function ga({variant:s,parentAuth:a,isSelected:t,onSelect:n,onDelete:i,isDeleting:u}){return e.jsxs("button",{className:H("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(Ie,{provider:s.provider,size:"sm"}),e.jsx(js,{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(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(O,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:c=>{c.stopPropagation(),i()},disabled:u,children:e.jsx(gs,{className:"w-3 h-3"})})]})}function ja({onSetup:s}){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(ce,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(O,{onClick:s,className:"gap-2",children:[e.jsx(le,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function _a(){const s=we(),{data:a,isLoading:t}=rs(),{data:n,isFetching:i}=dt(),{data:u}=ut(),c=mt(),m=xt(),f=pt(),h=ht(),x=ft(),v=gt(),r=jt(),g=vt(),[N,C]=d.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[o,p]=d.useState(null),[T,k]=d.useState(!1),[j,E]=d.useState(null),S=d.useMemo(()=>a?.authStatus||[],[a?.authStatus]),D=a?.source==="remote",L=d.useMemo(()=>n?.variants||[],[n?.variants]),F=l=>{C(l),l&&localStorage.setItem("cliproxy-selected-provider",l)},y=d.useMemo(()=>o?null:N&&S.some(l=>l.provider===N)?N:S.length>0&&(S.find(R=>(R.accounts?.length||0)>0)?.provider||S[0]?.provider)||null,[N,o,S]),A=S.find(l=>l.provider===y),w=L.find(l=>l.name===o),_=w?S.find(l=>l.provider===w.provider):void 0,U=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},G=(l,R,Q)=>{f.isPending||h.isPending||(Q?f.mutate({provider:l,accountId:R}):h.mutate({provider:l,accountId:R}))},P=(l,R)=>{x.isPending||x.mutate({provider:l,accountId:R})},M=(l,R)=>{v.isPending||v.mutate({provider:l,accountIds:R})},b=(l,R)=>{r.isPending||r.mutate({provider:l,accountIds:R})},q=l=>{F(l),p(null)},Z=l=>{p(l),F(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(O,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U,disabled:i,children:e.jsx(Ee,{className:H("w-4 h-4",i&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(O,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>k(!0),children:[e.jsx(le,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Te,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(l=>e.jsx(Nt,{className:"h-14 w-full rounded-lg"},l))}):e.jsx("div",{className:"space-y-1",children:S.map(l=>e.jsx(fa,{status:l,isSelected:y===l.provider,onSelect:()=>q(l.provider)},l.provider))}),L.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(js,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:L.map(l=>e.jsx(ga,{variant:l,parentAuth:S.find(R=>R.provider===l.provider),isSelected:o===l.name,onSelect:()=>Z(l.name),onDelete:()=>g.mutate(l.name),isDeleting:g.isPending},l.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(Rt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[S.length," provider",S.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3 text-green-600"}),S.filter(l=>l.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:w&&_?e.jsx(ts,{provider:w.name,displayName:`${w.name} (${w.provider} variant)`,authStatus:_,catalog:oe[w.provider],logoProvider:w.provider,baseProvider:w.provider,isRemoteMode:D,port:w.port,onAddAccount:()=>E({provider:w.provider,displayName:_.displayName,isFirstAccount:(_.accounts?.length||0)===0}),onSetDefault:l=>c.mutate({provider:w.provider,accountId:l}),onRemoveAccount:l=>m.mutate({provider:w.provider,accountId:l}),onPauseToggle:(l,R)=>G(w.provider,l,R),onSoloMode:l=>P(w.provider,l),onBulkPause:l=>M(w.provider,l),onBulkResume:l=>b(w.provider,l),isRemovingAccount:m.isPending,isPausingAccount:f.isPending||h.isPending,isSoloingAccount:x.isPending,isBulkPausing:v.isPending,isBulkResuming:r.isPending}):A?e.jsx(ts,{provider:A.provider,displayName:A.displayName,authStatus:A,catalog:oe[A.provider],isRemoteMode:D,onAddAccount:()=>E({provider:A.provider,displayName:A.displayName,isFirstAccount:(A.accounts?.length||0)===0}),onSetDefault:l=>c.mutate({provider:A.provider,accountId:l}),onRemoveAccount:l=>m.mutate({provider:A.provider,accountId:l}),onPauseToggle:(l,R)=>G(A.provider,l,R),onSoloMode:l=>P(A.provider,l),onBulkPause:l=>M(A.provider,l),onBulkResume:l=>b(A.provider,l),isRemovingAccount:m.isPending,isPausingAccount:f.isPending||h.isPending,isSoloingAccount:x.isPending,isBulkPausing:v.isPending,isBulkResuming:r.isPending}):e.jsx(ja,{onSetup:()=>k(!0)})}),e.jsx(Gt,{open:T,onClose:()=>k(!1)}),e.jsx(Qt,{open:j!==null,onClose:()=>E(null),provider:j?.provider||"",displayName:j?.displayName||"",isFirstAccount:j?.isFirstAccount||!1})]})}export{_a as CliproxyPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aY as P,aZ as $,I as F,a_ as U,aV as _,aX as B,m as z,b as O}from"./index-uj-gfqVW.js";import{S as K}from"./switch-Db-uyN1u.js";import{y as Y,j as q,V,Y as D,m as X,R as y,a1 as Z,q as J,aB as Q}from"./icons-DGASzt3M.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function ee(){const{state:s}=P(),a=$(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),g=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,g]),p=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await g({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,g]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:g,saveGeminiModel:x,saveOpencodeModel:p}}function A({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:g,modelPlaceholder:x,showHint:p,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",E=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",I=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(K,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:W=>S(W.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),g&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(q,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!p),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${I}`,children:[p?e.jsx(V,{className:"w-4 h-4"}):e.jsx(D,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),p&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${E}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function me(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:g,fetchConfig:x,fetchStatus:p,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=ee(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[E,I]=i.useState(!1),[M,W]=i.useState(!1);i.useEffect(()=>{x(),p(),n()},[x,p,n]);const N=s?.providers?.gemini?.enabled??!1,G=s?.providers?.grok?.enabled??!1,L=s?.providers?.opencode?.enabled??!1,H=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||G||L,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||L,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||G||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?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(y,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&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(J,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),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:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(O,{variant:"ghost",size:"sm",onClick:p,disabled:l,children:e.jsx(y,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),!a?.geminiCli&&!a?.opencodeCli&&!a?.grokCli&&!l&&e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed rounded-lg text-center bg-muted/30",children:[e.jsx(Q,{className:"w-12 h-12 text-muted-foreground mb-3 opacity-30"}),e.jsx("p",{className:"font-medium text-foreground mb-1",children:"No providers configured"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Install CLI tools to enable web search providers"}),e.jsxs(O,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"w-4 h-4 mr-2"}),"Check for providers"]})]}),e.jsx(A,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(A,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:L,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:g,modelPlaceholder:"opencode/grok-code",showHint:E,setShowHint:I,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(A,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:G,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:M,setShowHint:W,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(O,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(y,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{me as default};
|