@kaitranntt/ccs 7.71.0-dev.5 → 7.71.0-dev.7
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/config/base-codebuddy.settings.json +10 -0
- package/config/base-cursor.settings.json +10 -0
- package/config/base-gitlab.settings.json +10 -0
- package/config/base-kilo.settings.json +10 -0
- package/dist/auth/profile-detector.d.ts +2 -3
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +19 -19
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/ccs.js +35 -4
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/auth/auth-types.d.ts +10 -0
- package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
- package/dist/cliproxy/auth/auth-types.js +32 -0
- package/dist/cliproxy/auth/auth-types.js.map +1 -1
- package/dist/cliproxy/auth/gitlab-pat-response.d.ts +9 -0
- package/dist/cliproxy/auth/gitlab-pat-response.d.ts.map +1 -0
- package/dist/cliproxy/auth/gitlab-pat-response.js +64 -0
- package/dist/cliproxy/auth/gitlab-pat-response.js.map +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts +3 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +119 -3
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +5 -0
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +56 -4
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/path-resolver.d.ts +21 -0
- package/dist/cliproxy/config/path-resolver.d.ts.map +1 -1
- package/dist/cliproxy/config/path-resolver.js +42 -2
- package/dist/cliproxy/config/path-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts +1 -0
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +31 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-config.js +4 -4
- package/dist/cliproxy/model-config.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -1
- package/dist/cliproxy/provider-capabilities.js +48 -0
- package/dist/cliproxy/provider-capabilities.js.map +1 -1
- package/dist/cliproxy/types.d.ts +7 -3
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/cliproxy/types.js +8 -1
- package/dist/cliproxy/types.js.map +1 -1
- package/dist/commands/command-catalog.d.ts +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/command-catalog.js +13 -3
- package/dist/commands/command-catalog.js.map +1 -1
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +43 -30
- package/dist/commands/cursor-command-display.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +30 -13
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/help-command.d.ts +2 -0
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +53 -2
- package/dist/commands/help-command.js.map +1 -1
- package/dist/config/reserved-names.d.ts +1 -1
- package/dist/config/reserved-names.d.ts.map +1 -1
- package/dist/config/reserved-names.js +9 -0
- package/dist/config/reserved-names.js.map +1 -1
- package/dist/cursor/constants.d.ts +3 -0
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +26 -1
- package/dist/cursor/constants.js.map +1 -1
- package/dist/cursor/cursor-daemon-entry.js +2 -2
- package/dist/cursor/cursor-daemon-entry.js.map +1 -1
- package/dist/cursor/cursor-profile-executor.js +4 -4
- package/dist/cursor/cursor-profile-executor.js.map +1 -1
- package/dist/cursor/cursor-runtime-probe.js +3 -3
- package/dist/cursor/cursor-runtime-probe.js.map +1 -1
- package/dist/management/shared-manager.d.ts +2 -0
- package/dist/management/shared-manager.d.ts.map +1 -1
- package/dist/management/shared-manager.js +25 -10
- package/dist/management/shared-manager.js.map +1 -1
- package/dist/shared/claude-extension-setup.js +1 -1
- package/dist/shared/claude-extension-setup.js.map +1 -1
- package/dist/ui/assets/{accounts-BlNCxQDI.js → accounts-Crgc0yWM.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CfV8437M.js → alert-dialog-yKKRht-n.js} +1 -1
- package/dist/ui/assets/{api-B7lj0Dc2.js → api-D5r7ashl.js} +1 -1
- package/dist/ui/assets/{auth-section-CHVVS7rI.js → auth-section--1iqnu6V.js} +1 -1
- package/dist/ui/assets/{backups-section-CpFIwU4j.js → backups-section-BlDjCL-e.js} +1 -1
- package/dist/ui/assets/{channels-BydspWYC.js → channels-B5SdP3Pl.js} +1 -1
- package/dist/ui/assets/{checkbox-DYmBWybh.js → checkbox-DiS_kxMz.js} +1 -1
- package/dist/ui/assets/{claude-extension-CzJ87It9.js → claude-extension-CRhdIR9s.js} +1 -1
- package/dist/ui/assets/cliproxy-BCpKbC4I.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-UO-T4Fqd.js → cliproxy-ai-providers-B4SRf2vw.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-0R9jNjr0.js → cliproxy-control-panel-J_oQ5Xh4.js} +1 -1
- package/dist/ui/assets/{codex-BVqCgVqO.js → codex-DQ990C8B.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DRRk4zKh.js → confirm-dialog-yn3c0i1R.js} +1 -1
- package/dist/ui/assets/{copilot-nS3mAmR9.js → copilot-Cjvb_YyS.js} +1 -1
- package/dist/ui/assets/cursor-D3Ju4OTj.js +1 -0
- package/dist/ui/assets/{droid-BB0GtApF.js → droid-Cq9QnAxR.js} +1 -1
- package/dist/ui/assets/{globalenv-section-BjJLRo6F.js → globalenv-section-BBpljTzA.js} +1 -1
- package/dist/ui/assets/{health-znxFFIkw.js → health-Ddh2qy77.js} +1 -1
- package/dist/ui/assets/{index-Dysy3B2b.js → index-BzP7CRDd.js} +1 -1
- package/dist/ui/assets/{index-pwN04MoG.js → index-CEJ85H4U.js} +1 -1
- package/dist/ui/assets/{index-BLYSBsul.js → index-CMLw3FK3.js} +1 -1
- package/dist/ui/assets/{index-BVIpZbhs.js → index-DWbTolkF.js} +1 -1
- package/dist/ui/assets/index-DzJi9m-K.css +1 -0
- package/dist/ui/assets/{index-DNc1KeSH.js → index-qOjmNZz3.js} +1 -1
- package/dist/ui/assets/index-qkjZYMsM.js +72 -0
- package/dist/ui/assets/{logs-CRtMBq6_.js → logs-D-21cOBh.js} +1 -1
- package/dist/ui/assets/{masked-input-CJpWyl5d.js → masked-input-DwcTX5yf.js} +1 -1
- package/dist/ui/assets/providers/codebuddy.png +0 -0
- package/dist/ui/assets/providers/cursor.svg +5 -0
- package/dist/ui/assets/providers/gitlab.svg +22 -0
- package/dist/ui/assets/providers/kilo.png +0 -0
- package/dist/ui/assets/{proxy-status-widget-D2p87v3u.js → proxy-status-widget-Cp9lTM10.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-COHp3_mV.js → raw-json-settings-editor-panel-CddILtTW.js} +1 -1
- package/dist/ui/assets/{searchable-select-pmhYtZtB.js → searchable-select-CGGBqyNo.js} +1 -1
- package/dist/ui/assets/{separator-BvMmPLuD.js → separator-CjkNFHb0.js} +1 -1
- package/dist/ui/assets/{shared-BEX5VpRF.js → shared-BYzMWzKk.js} +1 -1
- package/dist/ui/assets/{table-BubU4ogA.js → table-DR11LpZ-.js} +1 -1
- package/dist/ui/assets/{updates-BZiDw0db.js → updates-Bi3BBori.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/hooks/image-analysis-backend-resolver.js +1 -1
- package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +117 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/index.js +1 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +8 -0
- package/dist/web-server/routes/settings-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-CDQmxSTd.js +0 -3
- package/dist/ui/assets/cursor-eTkTzDnb.js +0 -1
- package/dist/ui/assets/index-BVvZE8GV.css +0 -1
- package/dist/ui/assets/index-rrT-79_v.js +0 -72
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as u}from"./react-vendor-CNOkPC89.js";import{a as ut,u as qt,b as ms}from"./tanstack-CrmUhA7Z.js";import{a8 as ps,a as B,d as K,C as Ht,b as zt,a9 as Gt,aa as Vt,c as J,P as mt,B as q,ab as de,L as Z,I as me,r as Ze,s as et,t as tt,v as st,w as Me,ac as Bt,ad as $t,ae as xs,af as hs,ag as gs,u as Wt,ah as pt,ai as xt,aj as ht,ak as gt,W as le,al as Qt,am as St,an as fs,ao as vs,ap as at,aq as Jt,Y as Fe,ar as js,as as At,at as Mt,au as bs,av as Ns,aw as ys,ax as ws,ay as Cs,az as ks,aA as Ss,aB as As,aC as Pt,aD as Ms,x as Xt,n as ft,aE as vt,aF as Dt,aG as Yt,aH as Ps,m as Ds,aI as Is,aJ as Ts,aK as nt,T as it,p as rt,q as ot,aL as Es,aM as Ls,aN as Rs,aO as It,aP as Os,aQ as _s,aR as Fs,aS as Us,aT as Ks,aU as qs,Q as Hs,R as zs,U as Tt,V as Et,aV as Gs,aW as Vs,aX as Bs,aY as $s,aZ as Ws,a_ as Qs,a$ as Js,b0 as Xs,b1 as Ys,b2 as Zs,b3 as ea,b4 as ta,S as sa}from"./index-rrT-79_v.js";import{C as dt}from"./default-ports-1QQSffYX.js";import{t as V}from"./notifications-B2HqRBj7.js";import{C as Zt,L as ie,p as ve,$ as aa,m as je,o as es,aF as jt,R as bt,q as Pe,aa as De,T as qe,a7 as Lt,aG as ts,aE as na,z as Nt,Z as Ie,_ as ss,i as ia,u as as,aH as ra,at as oa,X as yt,a9 as ns,J as is,D as rs,aI as da,as as os,aJ as la,aw as ca,aK as ds}from"./icons-KVCk4_U8.js";import{R as Ue,A as Rt,D as Qe,i as ua,a as ma}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ke}from"./checkbox-DYmBWybh.js";import{C as pa}from"./confirm-dialog-DRRk4zKh.js";import{S as wt}from"./separator-BvMmPLuD.js";import{S as xa}from"./searchable-select-pmhYtZtB.js";import{P as ha}from"./proxy-status-widget-D2p87v3u.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CfV8437M.js";const Y="gemini-3.1-pro-high",Ne="gemini-3.1-pro-low",ga=Object.freeze({"gemini-3-pro-high":Y,"gemini-3.1-pro-high":Y,"gemini-3-pro-low":Ne,"gemini-3.1-pro-low":Ne,"gemini-3-pro-preview":Y,"gemini-3-pro-preview-customtools":Y,"gemini-3.1-pro-preview":Y,"gemini-3.1-pro-preview-customtools":Y,"gemini-3-1-pro-preview":Y,"gemini-3-1-pro-preview-customtools":Y}),ls=Object.freeze({"gemini-3-pro-preview":"gemini-3.1-pro-preview","gemini-3.1-pro-preview":"gemini-3-pro-preview","gemini-3-flash-preview":"gemini-3.1-flash-preview","gemini-3.1-flash-preview":"gemini-3-flash-preview"}),fa=/^gemini-(\d+(?:[.-]\d+)*)-(pro|flash)-preview(-customtools)?$/i,va=["agy/","gcli/"];function $(t){return ps(t).toLowerCase()}function ja(t){const a=t.trim(),s=a.toLowerCase();for(const n of va)if(s.startsWith(n))return a.slice(n.length);return a}function ba(t){return t.replace(/-customtools$/i,"")}function Na(t){return ga[$(t)]}function He(t){const a=$(t),s=a.match(fa);if(!s)return null;const[,n,i,c]=s;return{normalizedId:a,version:n.split(/[.-]/).map(o=>Number(o)),family:i,customtools:!!c,dottedVersion:n.includes(".")}}function cs(t,a){const s=Math.max(t.length,a.length);for(let n=0;n<s;n+=1){const i=t[n]??0,c=a[n]??0;if(i!==c)return i>c?1:-1}return 0}function ya(t,a,s){if(t.customtools!==a.customtools)return t.customtools?1:-1;const n=cs(t.version,a.version);if(n!==0)return n>0?-1:1;const i=+(t.dottedVersion===s.dottedVersion),c=+(a.dottedVersion===s.dottedVersion);return i!==c?c-i:t.normalizedId.localeCompare(a.normalizedId)}function Ot(t,a){const s=$(a);return t.find(n=>$(n.id)===s)?.id}function wa(t,a){const s=He(t);return!s||a.length===0?void 0:a.map(i=>{const c=He(i.id);return!c||c.family!==s.family?null:{id:i.id,info:c}}).filter(i=>!!i).sort((i,c)=>ya(i.info,c.info,s))[0]?.id}const pe={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:Y,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:Y,opus:Y,sonnet:Y,haiku:"gemini-3-1-flash-preview"}},{id:Ne,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:Ne,opus:Ne,sonnet:Ne,haiku:"gemini-3-1-flash-preview"}},{id:"gemini-3-1-flash-preview",name:"Gemini Flash",description:"Resolves to the best advertised Gemini Flash preview via Antigravity",extendedContext:!0,presetMapping:{default:"gemini-3-1-flash-preview",opus:Y,sonnet:Y,haiku:"gemini-3-1-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3.1-pro-preview",name:"Gemini Pro",tier:"paid",description:"Uses the best advertised Gemini Pro preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3.1-pro-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini Flash",tier:"paid",description:"Uses the best advertised Gemini Flash preview when Google exposes one",extendedContext:!0,presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3.1-pro-preview",sonnet:"gemini-3.1-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",extendedContext:!0,presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5-codex",models:[{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Cross-plan safe Codex default",presetMapping:{default:"gpt-5-codex",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-codex-mini",name:"GPT-5 Codex Mini",description:"Faster and cheaper Codex option",presetMapping:{default:"gpt-5-codex-mini",opus:"gpt-5-codex",sonnet:"gpt-5-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Legacy mini model ID kept for backwards compatibility",presetMapping:{default:"gpt-5-mini",opus:"gpt-5-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",description:"Legacy fast Codex mini model",presetMapping:{default:"gpt-5.1-codex-mini",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",description:"Higher-effort Codex model with xhigh support",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini"}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Cross-plan Codex model with xhigh support",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",tier:"paid",description:"Paid Codex plans only",presetMapping:{default:"gpt-5.3-codex",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",tier:"paid",description:"Paid Codex plans only, ultra-fast coding model",presetMapping:{default:"gpt-5.3-codex-spark",opus:"gpt-5.3-codex",sonnet:"gpt-5.3-codex",haiku:"gpt-5-codex-mini"}},{id:"gpt-5.4",name:"GPT-5.4",tier:"paid",description:"Paid Codex plans only, latest GPT-5 family model",presetMapping:{default:"gpt-5.4",opus:"gpt-5.4",sonnet:"gpt-5.4",haiku:"gpt-5-codex-mini"}}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Code-focused model (1M context)",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship model (256K context)",presetMapping:{default:"qwen3-max",opus:"qwen3-max",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-flash"}},{id:"qwen3-max-preview",name:"Qwen3 Max Preview",description:"Preview with thinking support (256K)",presetMapping:{default:"qwen3-max-preview",opus:"qwen3-max-preview",sonnet:"qwen3-max",haiku:"qwen3-coder-flash"}},{id:"qwen3-235b",name:"Qwen3 235B",description:"Large 235B A22B model",presetMapping:{default:"qwen3-235b",opus:"qwen3-max",sonnet:"qwen3-235b",haiku:"qwen3-coder-flash"}},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language multimodal"},{id:"qwen3-coder-flash",name:"Qwen3 Coder Flash",description:"Fast code generation"},{id:"qwen3-32b",name:"Qwen3 32B",description:"Qwen3 32B model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"qwen3-coder-plus",models:[{id:"qwen3-coder-plus",name:"Qwen3 Coder Plus",description:"Recommended default for iFlow accounts",presetMapping:{default:"qwen3-coder-plus",opus:"qwen3-coder-plus",sonnet:"qwen3-coder-plus",haiku:"qwen3-coder-plus"}},{id:"qwen3-max",name:"Qwen3 Max",description:"Flagship Qwen model via iFlow"},{id:"kimi-k2",name:"Kimi K2",description:"Kimi model currently available via iFlow"},{id:"deepseek-v3.2",name:"DeepSeek V3.2",description:"Current DeepSeek V3.2 model via iFlow"},{id:"deepseek-r1",name:"DeepSeek R1",description:"Reasoning-focused DeepSeek model"},{id:"glm-4.6",name:"GLM 4.6",description:"Zhipu GLM 4.6 via iFlow"},{id:"qwen3-vl-plus",name:"Qwen3 VL Plus",description:"Vision-language model"}]},kimi:{provider:"kimi",displayName:"Kimi (Moonshot)",defaultModel:"kimi-k2.5",models:[{id:"kimi-k2.5",name:"Kimi K2.5",description:"Latest multimodal model (262K context)",presetMapping:{default:"kimi-k2.5",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",description:"Extended reasoning model",presetMapping:{default:"kimi-k2-thinking",opus:"kimi-k2.5",sonnet:"kimi-k2-thinking",haiku:"kimi-k2"}},{id:"kimi-k2",name:"Kimi K2",description:"Flagship coding model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-6",models:[{id:"kiro-claude-opus-4-6",name:"Kiro Claude Opus 4.6",description:"Claude Opus 4.6 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-6",name:"Kiro Claude Sonnet 4.6",description:"Claude Sonnet 4.6 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-6",opus:"kiro-claude-opus-4-6",sonnet:"kiro-claude-sonnet-4-6",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-6",models:[{id:"claude-opus-4-6",name:"Claude Opus 4.6",description:"Latest flagship model",extendedContext:!0,presetMapping:{default:"claude-opus-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-6",opus:"claude-opus-4-6",sonnet:"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",description:"Most capable Claude model",extendedContext:!0,presetMapping:{default:"claude-opus-4-5-20251101",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-5-20250929",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-5-20250929",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",extendedContext:!0,presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20251101",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20251001"}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}};function we(t,a){if(!t)return;const s=$(a);if(t.provider==="agy"){const o=Na(s);if(o){const d=t.models.find(r=>r.id===o);if(d)return d}}const n=ls[s.toLowerCase()],i=t.models.find(o=>o.id===s||o.id===n);if(i)return i;const c=He(s);if(c)return t.models.map(o=>({model:o,info:He(o.id)})).filter(o=>!!(o.info&&o.info.family===c.family)).sort((o,d)=>cs(d.info.version,o.info.version))[0]?.model}function Ca(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function ka(t,a){const s=pe[t.toLowerCase()];if(!a||a.models.length===0)return s;const n=a.models.map(d=>({id:d.id,owned_by:a.provider})),i=a.models.map(d=>{const r=we(s,d.id);return{...d,name:d.name||r?.name||d.id,tier:r?.tier??Ca(d.tier),description:d.description??r?.description,broken:r?.broken,issueUrl:r?.issueUrl,deprecated:r?.deprecated,deprecationReason:r?.deprecationReason,extendedContext:d.extendedContext??r?.extendedContext,presetMapping:r?.presetMapping}}),c=s?.defaultModel?ye(s.defaultModel,n):void 0,o=typeof c=="string"&&n.some(d=>$(d.id)===$(c));return{provider:a.provider,displayName:a.displayName||s?.displayName||t,defaultModel:o?c:a.defaultModel,models:i}}function Ct(t){const a={},s=new Set([...Object.keys(pe),...Object.keys(t??{})]);for(const n of s){const i=ka(n,t?.[n]);i&&(a[n]=i)}return a}function us(t,a,s){const n=we(s,a);return n||we(pe[t.toLowerCase()],a)}function ye(t,a=[]){const s=$(t),n=wa(s,a);if(n)return n;const i=Ot(a,s);if(i)return i;const c=ls[s];return(c?Ot(a,c):void 0)??s}function Sa(t,a=[]){return{default:ye(t.default,a),opus:ye(t.opus,a),sonnet:ye(t.sonnet,a),haiku:ye(t.haiku,a)}}function kt(t,a=[]){if(!t)return[];const s=pe[t.provider.toLowerCase()]??t,n=new Set;return s.models.map(i=>{const c=ye(i.id,a),o=i.presetMapping?Sa(i.presetMapping,a):void 0,d=t.models.find(r=>$(r.id)===$(c));return{...i,id:c,name:d?.name||i.name,description:d?.description??i.description,presetMapping:o}}).filter(i=>n.has(i.id)?!1:(n.add(i.id),!0))}function Aa(t,a,s=[]){const n=t.trim().toLowerCase();if(!a||!n)return[];const i=pe[n]??a,c=kt(a,s),o=new Set(c.map(p=>$(p.id))),d=new Set(c.map(p=>we(i,p.id)?.id).filter(p=>!!p).map(p=>$(p))),r=new Set,h=new Set(s.map(p=>$(p.id)));return s.filter(p=>{const v=$(p.id),x=ja(p.id),m=ba(x),L=we(i,x)??we(i,m);if(o.has($(x))||v!==$(x)&&h.has($(x)))return!1;const k=$(m);if(k!==$(x)&&h.has(k))return!1;const I=L?$(L.id):k;return L&&d.has(I)||r.has(I)||!L&&n==="agy"?!1:(r.add(I),!0)})}function Ma(t,a,s){return us(t,a,s)?.extendedContext===!0}const Je="ccs-internal-managed";async function Pa(){try{const t=await fetch("/api/settings/auth/tokens/raw");return t.ok?(await t.json())?.apiKey?.value??Je:Je}catch{return Je}}async function Da(t,a){if(a)return a;try{const s=await fetch("/api/cliproxy/catalog");if(!s.ok)return pe[t];const n=await s.json();return Ct(n.catalogs)[t]??pe[t]}catch{return pe[t]}}async function lt(t,a,s){const n=await Da(t,s);if(!n)return{success:!1};const i=n.models.find(h=>h.id===n.defaultModel)||n.models[0],c=i?.presetMapping||{default:n.defaultModel,opus:n.defaultModel,sonnet:n.defaultModel,haiku:n.defaultModel},o=await Pa(),r={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${dt}/api/provider/${t}`,ANTHROPIC_AUTH_TOKEN:o,ANTHROPIC_MODEL:c.default,ANTHROPIC_DEFAULT_OPUS_MODEL:c.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:c.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:c.haiku}};try{return{success:(await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:r})})).ok,presetName:i?.name||n.defaultModel}}catch{return{success:!1}}}function Ia({currentProgress:t,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((s,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=n?"bg-primary":"bg-muted"}`},s))})}function Ta({providers:t,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:t.map(s=>e.jsxs("button",{onClick:()=>a(s.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(Zt,{className:"w-4 h-4 text-muted-foreground"})]},s.id))})}function Ea({selectedProvider:t,providers:a,authCommand:s,isRefreshing:n,isPending:i,onBack:c,onStartAuth:o,onRefresh:d}){const{t:r}=B(),[h,p]=u.useState(!1),v=async x=>{await navigator.clipboard.writeText(x),p(!0),setTimeout(()=>p(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:r("setupWizard.authStep.authenticateWith",{provider:a.find(x=>x.id===t)?.name})}),e.jsx(K,{onClick:o,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 animate-spin"}),r("setupWizard.authStep.authenticating")]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4"}),r("setupWizard.authStep.authenticateInBrowser")]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("setupWizard.authStep.completeOAuth")})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:r("setupWizard.authStep.orUseTerminal")})})]}),e.jsx(Ht,{children:e.jsxs(zt,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(aa,{className:"w-4 h-4"}),r("setupWizard.authStep.runCommandHint")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:s}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>v(s),children:h?e.jsx(je,{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(K,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),r("setupWizard.authStep.back")]}),e.jsxs(K,{variant:"outline",onClick:d,disabled:n||i,children:[e.jsx(bt,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),r(n?"setupWizard.authStep.checking":"setupWizard.authStep.refreshStatus")]})]})]})}function La({accounts:t,privacyMode:a,onSelect:s,onAddNew:n,onBack:i}){const{t:c}=B();return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:c("setupWizard.accountStep.selectAccount",{count:t.length})}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(o=>{const d=Gt(o.id,o.email,o.tokenFile),r=o.provider?.toLowerCase()==="codex"?Vt(d):null;return e.jsxs("button",{type:"button",onClick:()=>s(o),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:J("font-medium",a&&mt),children:d.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r?.label?e.jsx(q,{variant:"outline",className:J("text-[10px] h-4 px-1.5 border-transparent",r.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":r.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:r.label}):d.audienceLabel?e.jsx(q,{variant:"outline",className:J("text-[10px] h-4 px-1.5 border-transparent",d.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":d.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:d.audienceLabel}):null,!r?.label&&d.detailLabel&&e.jsx(q,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:d.detailLabel}),o.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.defaultAccount")})]})]})]}),e.jsx(Zt,{className:"w-4 h-4 text-muted-foreground"})]},o.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:c("setupWizard.accountStep.or")})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ve,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:c("setupWizard.accountStep.addNewAccount")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:c("setupWizard.accountStep.addNewAccountDesc")})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(K,{variant:"ghost",onClick:i,children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),c("setupWizard.accountStep.back")]})})]})}const _t="__custom__";function Ra({selectedProvider:t,catalog:a,selectedAccount:s,variantName:n,modelName:i,isPending:c,privacyMode:o,onVariantNameChange:d,onModelChange:r,onBack:h,onSkip:p,onCreate:v}){const{t:x}=B(),m=a||pe[t],L=m?.models||[],k=i&&!L.some(b=>b.id===i),[I,S]=u.useState(k),A=t==="agy"&&i.trim().length>0?de(i):!1,y=s?Gt(s.id,s.email,s.tokenFile):null,C=t==="codex"&&y?Vt(y):null,l=b=>{b===_t?(S(!0),r("")):(S(!1),r(b))};return e.jsxs("div",{className:"space-y-4",children:[s&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(Pe,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[x("setupVariant.using")," ",e.jsx("span",{className:J(o&&mt),children:y?.email})]}),(y?.audienceLabel||y?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[C?.label?e.jsx(q,{variant:"outline",className:J("text-[10px] h-4 px-1.5 border-transparent",C.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":C.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:C.label}):y?.audienceLabel?e.jsx(q,{variant:"outline",className:J("text-[10px] h-4 px-1.5 border-transparent",y.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":y.audience==="free"?"bg-slate-200/70 text-slate-700 dark:bg-slate-700/40 dark:text-slate-200":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:y.audienceLabel}):null,!C?.label&&y?.detailLabel&&e.jsx(q,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:y.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"variant-name",children:x("setupVariant.variantNameRequired")}),e.jsx(me,{id:"variant-name",value:n,onChange:b=>d(b.target.value),placeholder:x("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[x("setupVariant.invokeHintPrefix")," ccs ",n||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:x("setupVariant.model")}),I?e.jsxs("div",{className:"space-y-2",children:[e.jsx(me,{value:i,onChange:b=>r(b.target.value),placeholder:x("setupVariant.modelPlaceholder")}),A&&e.jsx("p",{className:"text-xs text-destructive",children:x("providerEditor.agyDenylist")}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{S(!1),t==="agy"&&de(i)&&r("")},children:x("setupVariant.choosePresetInstead")})]}):e.jsxs(Ze,{value:L.some(b=>b.id===i)?i:"",onValueChange:l,children:[e.jsx(et,{children:e.jsx(tt,{placeholder:x("setupVariant.selectModel")})}),e.jsxs(st,{children:[L.map(b=>e.jsx(Me,{value:b.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:b.name}),b.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",b.description]})]})},b.id)),e.jsx(Me,{value:_t,children:e.jsx("span",{className:"text-primary",children:x("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:I?x("setupVariant.enterAnyModel"):x("setupVariant.defaultModel",{model:m?.defaultModel||x("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(K,{variant:"ghost",onClick:h,children:[e.jsx(jt,{className:"w-4 h-4 mr-2"}),x("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",onClick:p,children:x("setupVariant.skip")}),e.jsx(K,{onClick:v,disabled:!n||c||A,children:x(c?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:x("setupVariant.skipHint")})]})}function Oa({variantName:t,onClose:a}){const{t:s}=B();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(je,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:s("setupWizard.successStep.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.subtitle")})]}),e.jsx(Ht,{children:e.jsxs(zt,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:s("setupWizard.successStep.usage")}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",t,' "your prompt here"']})]})}),e.jsx(K,{onClick:a,className:"w-full",children:s("setupWizard.successStep.done")})]})}function _a({open:t,onClose:a}){const[s,n]=u.useState("provider"),[i,c]=u.useState(""),[o,d]=u.useState(null),[r,h]=u.useState(""),[p,v]=u.useState(""),[x,m]=u.useState(!1),[L,k]=u.useState(!1),{data:I,refetch:S}=Bt(),{data:A}=$t(),y=xs(),C=hs(),l=gs(),{privacyMode:b}=Wt(),T=I?.authStatus.find(R=>R.provider===i),g=u.useMemo(()=>T?.accounts||[],[T?.accounts]),D=u.useMemo(()=>Ct(A?.catalogs),[A?.catalogs]),N=!!A;u.useEffect(()=>{if(!t){const R=setTimeout(()=>{n("provider"),c(""),d(null),h(""),v(""),k(!1)},0);return()=>clearTimeout(R)}},[t]),u.useEffect(()=>{if(s==="auth"&&g.length>0&&!L){const R=setTimeout(()=>{n("account")},0);return()=>clearTimeout(R)}},[s,g,L]);const z=async()=>{m(!0),await S(),m(!1)},M=()=>{const R=(T?.accounts?.length||0)===0;C.mutate({provider:i},{onSuccess:async H=>{if(R){const Q=await lt(i,void 0,N?D[i]:void 0);Q.success&&Q.presetName?V.success(`Applied "${Q.presetName}" preset`):Q.success||V.warning(le.t("commonToast.accountAddedPresetFailed"))}H.account&&(d(H.account),n("variant")),S()}})},O=R=>{c(R),(I?.authStatus.find(ee=>ee.provider===R)?.accounts||[]).length===0?n("auth"):n("account")},j=R=>{d(R),n("variant")},G=async()=>{if(!(!r||!i))try{await y.mutateAsync({name:r,provider:i,model:p||void 0,account:o?.id}),n("success")}catch(R){console.error("Failed to create variant:",R)}},E=`ccs ${i} --auth --add`,F=vs(s),w=R=>{if(!R&&(C.isPending&&i&&l.mutate(i),s==="success"||s==="provider")){a();return}};return e.jsx(pt,{open:t,onOpenChange:w,children:e.jsxs(xt,{className:"sm:max-w-lg",onPointerDownOutside:R=>{s!=="success"&&s!=="provider"&&R.preventDefault()},onEscapeKeyDown:R=>{(C.isPending||y.isPending)&&R.preventDefault()},children:[e.jsxs(ht,{children:[e.jsxs(gt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-5 h-5 text-primary"}),le.t("setupWizard.title")]}),e.jsxs(Qt,{children:[s==="provider"&&le.t("setupWizard.stepProviderDesc"),s==="auth"&&le.t("setupWizard.stepAuthDesc"),s==="account"&&le.t("setupWizard.stepAccountDesc"),s==="variant"&&le.t("setupWizard.stepVariantDesc"),s==="success"&&le.t("setupWizard.stepSuccessDesc")]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[s==="provider"&&e.jsx(Ta,{providers:St,onSelect:O}),s==="auth"&&e.jsx(Ea,{selectedProvider:i,providers:St,authCommand:E,isRefreshing:x,isPending:C.isPending,onBack:()=>n("provider"),onStartAuth:M,onRefresh:z}),s==="account"&&e.jsx(La,{accounts:g,privacyMode:b,onSelect:j,onAddNew:()=>{k(!0),n("auth")},onBack:()=>n("provider")}),s==="variant"&&e.jsx(Ra,{selectedProvider:i,catalog:D[i],selectedAccount:o,variantName:r,modelName:p,isPending:y.isPending,privacyMode:b,onVariantNameChange:h,onModelChange:v,onBack:()=>g.length>0?n("account"):n("provider"),onSkip:a,onCreate:G}),s==="success"&&e.jsx(Oa,{variantName:r,onClose:a})]}),e.jsx(Ia,{currentProgress:F,allSteps:fs})]})})}const Fa=3e3,Ua=300*1e3,Ka=3;function Xe(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function Ye(t){const a=await t.text();if(!a)return{};try{return JSON.parse(a)}catch{const s=t.status>=400?`Request failed with status ${t.status}`:void 0;return s?{error:s}:{}}}const xe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function qa(){const{t}=B(),[a,s]=u.useState(xe),n=u.useRef(xe),i=u.useRef(0),c=u.useRef(null),o=u.useRef(null),d=u.useRef(0),r=u.useRef(0),h=u.useRef(!1),p=ut(),v=u.useCallback(S=>S===i.current,[]),x=u.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),r.current=0},[]);u.useEffect(()=>()=>{c.current?.abort(),x(),h.current=!1},[x]),u.useEffect(()=>{n.current=a},[a]);const m=u.useCallback(async(S,A,y)=>{if(v(y)){if(Date.now()-d.current>Ua){x(),v(y)&&s(C=>({...C,isAuthenticating:!1,error:t("toasts.providerAuthTimeout")}));return}try{const C=await fetch(`/api/cliproxy/auth/${S}/status?state=${encodeURIComponent(A)}`);if(!v(y))return;const l=await C.json();if(r.current=0,l.status==="ok"){if(!(typeof l.account=="object"&&l.account!==null)){x();const T=t("toasts.providerAccountRegistrationFailed");V.error(T),s(g=>({...g,isAuthenticating:!1,error:T}));return}x(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),Xe(p),V.success(t("toasts.providerAuthSuccess",{provider:S})),h.current=!1,s(xe)}else if(l.status==="auth_url"){const b=l.url||l.auth_url;b&&(s(T=>({...T,authUrl:b})),h.current||(h.current=!0,window.open(b,"_blank")))}else if(l.status==="device_code"){x();const b=l.user_code&&l.verification_url?`Open ${l.verification_url} and enter code: ${l.user_code}`:"Switch to Device Code method and try again.";V.error(t("toasts.providerDeviceCodeInCallback")),s(T=>({...T,isAuthenticating:!1,error:b}))}else if(l.status==="error"){x();const b=l.error||"Authentication failed";V.error(b),s(T=>({...T,isAuthenticating:!1,error:b}))}}catch(C){if(!v(y)||(r.current+=1,r.current<Ka))return;x();const l=C instanceof Error&&C.message.trim().length>0?C.message:t("toasts.providerLostStatusEndpoint");V.error(l),s(b=>({...b,isAuthenticating:!1,error:l}))}}},[v,p,x,t]),L=u.useCallback(async(S,A)=>{if(!at(S)){s({...xe,error:t("toasts.providerUnknown",{provider:S})});return}c.current?.abort(),x(),h.current=!1,r.current=0;const y=new AbortController,C=i.current+1;i.current=C,c.current=y;const b=(A?.flowType||(Jt(S)?"device_code":"authorization_code"))==="device_code",T=A?.startEndpoint||(b?"start":"start-url"),g={nickname:A?.nickname,kiroMethod:A?.kiroMethod,kiroIDCStartUrl:A?.kiroIDCStartUrl,kiroIDCRegion:A?.kiroIDCRegion,kiroIDCFlow:A?.kiroIDCFlow,riskAcknowledgement:A?.riskAcknowledgement};s({provider:S,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:b});try{if(T==="start")fetch(`/api/cliproxy/auth/${S}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g),signal:y.signal}).then(async D=>{if(!v(C))return;const N=await Ye(D);if(!v(C))return;const z=N.success===!0,M=typeof N.account=="object"&&N.account!==null;if(D.ok&&z&&M)p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),Xe(p),h.current=!1,s(xe);else{const O=typeof N.error=="string"?N.error:t(z?"toasts.providerAccountRegistrationFailed":"auth.loginFailed");V.error(O),s(j=>({...j,isAuthenticating:!1,error:O}))}}).catch(D=>{if(!v(C)||D instanceof Error&&D.name==="AbortError")return;const N=D instanceof Error?D.message:"Authentication failed";V.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))});else{const D=await fetch(`/api/cliproxy/auth/${S}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g),signal:y.signal});if(!v(C))return;const N=await Ye(D);if(!v(C))return;const z=N.success===!0;if(!D.ok||!z){const j=typeof N.error=="string"?N.error:t("toasts.providerStartOAuthFailed");throw new Error(j)}const M=typeof N.authUrl=="string"?N.authUrl:null,O=typeof N.state=="string"?N.state:null;if(s(j=>({...j,authUrl:M,oauthState:O})),M&&(h.current=!0,window.open(M,"_blank")),O){if(d.current=Date.now(),!M){if(await m(S,O,C),!v(C))return;const j=n.current;if(!j.isAuthenticating||j.provider!==S)return}o.current=setInterval(()=>{m(S,O,C)},Fa)}}}catch(D){if(!v(C))return;if(D instanceof Error&&D.name==="AbortError"){h.current=!1,s(xe);return}const N=D instanceof Error?D.message:t("auth.loginFailed");V.error(N),s(z=>({...z,isAuthenticating:!1,error:N}))}},[v,m,x,p,t]),k=u.useCallback(()=>{const S=a.provider;i.current+=1,c.current?.abort(),x(),h.current=!1,s(xe),S&&Fe.cliproxy.auth.cancel(S).catch(()=>{})},[a.provider,x]),I=u.useCallback(async S=>{if(!a.provider)return;const A=i.current,y=a.provider;s(C=>({...C,isSubmittingCallback:!0,error:null}));try{const C=await fetch(`/api/cliproxy/auth/${y}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:S})});if(!v(A))return;const l=await Ye(C);if(!v(A))return;const b=l.success===!0,T=l.status==="wait",g=typeof l.account=="object"&&l.account!==null;if(C.ok&&T)s(D=>({...D,isSubmittingCallback:!1,error:null}));else if(C.ok&&b&&g)x(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),Xe(p),V.success(t("toasts.providerAuthSuccess",{provider:y})),s(xe);else{const D=typeof l.error=="string"?l.error:t(b?"toasts.providerAccountRegistrationFailed":"toasts.providerCallbackFailed");throw new Error(D)}}catch(C){if(!v(A))return;const l=C instanceof Error?C.message:t("toasts.providerSubmitCallbackFailed");V.error(l),s(b=>({...b,isSubmittingCallback:!1,error:l}))}},[v,a.provider,p,x,t]);return u.useMemo(()=>({...a,startAuth:L,cancelAuth:k,submitCallback:I}),[a,L,k,I])}function ct({className:t,compact:a=!1,showAcknowledgement:s=!1,acknowledgementPhrase:n=Ue,acknowledgementText:i="",onAcknowledgementTextChange:c,disabled:o=!1,showProxySettingsLink:d=!1}){const{t:r}=B(),h=r("accountSafetyWarning.title"),p=r("accountSafetyWarning.subtitle"),v=r("accountSafetyWarning.firstLine"),x=r("accountSafetyWarning.secondLine"),m="https://github.com/kaitranntt/ccs/issues/509",L=r("accountSafetyWarning.issueLabel"),k=r("accountSafetyWarning.proxySettingsLabel");return a?e.jsx("section",{role:"alert",className:J("border-b border-amber-200/70 bg-amber-50/45 dark:bg-amber-950/5",t),children:e.jsxs("div",{className:"flex flex-col gap-3 px-6 py-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-6 w-6 items-center justify-center rounded-md bg-amber-500/12 text-amber-700 dark:text-amber-300",children:e.jsx(qe,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold leading-5",children:h}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:p})]}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:v}),e.jsx("p",{className:"text-xs font-medium leading-5 text-amber-900 dark:text-amber-200",children:x})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:justify-end",children:[e.jsxs("a",{href:m,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[L,e.jsx(ve,{className:"h-3 w-3"})]}),d?e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1 rounded-md border border-amber-500/25 bg-background/90 px-2 py-1 text-[11px] font-medium text-amber-800 transition-colors hover:bg-amber-500/10 dark:text-amber-200",children:[e.jsx(Lt,{className:"h-3 w-3"}),k]}):null,e.jsx(q,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:J("relative overflow-hidden rounded-xl border border-amber-500/30 bg-gradient-to-br from-amber-50 via-background to-rose-50/70 shadow-sm dark:from-amber-950/20 dark:to-rose-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500"}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-amber-500/15 text-amber-700 dark:text-amber-400",children:e.jsx(qe,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold leading-5",children:h}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]})]}),e.jsx(q,{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:v}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:x}),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:m,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:[L,e.jsx(ve,{className:"h-3.5 w-3.5"})]}),d&&e.jsxs("a",{href:"/settings?tab=proxy",className:"inline-flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-800 transition-colors hover:bg-amber-500/15 dark:text-amber-200",children:[e.jsx(Lt,{className:"h-3.5 w-3.5"}),k]}),e.jsx("span",{className:"rounded-md border border-border/70 bg-muted/60 px-2.5 py-1 text-xs text-muted-foreground",children:"Applies to CLI and dashboard auth"})]}),s&&c&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Z,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:n})]}),e.jsx(me,{id:"account-risk-ack-text",value:i,onChange:I=>c(I.target.value),placeholder:n,disabled:o,className:"mt-2 font-mono text-xs"})]})]})]})}function Ha({className:t,value:a,onChange:s,disabled:n=!1}){const{t:i}=B(),c=[a.reviewedIssue509,a.understandsBanRisk,a.acceptsFullResponsibility,a.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Rt].filter(Boolean).length,o=c/4*100,d=r=>{s({...a,...r})};return e.jsxs("section",{role:"alert",className:J("relative overflow-hidden rounded-xl border border-rose-500/35 bg-gradient-to-br from-rose-50 via-background to-amber-50/70 p-4 shadow-sm dark:from-rose-950/20 dark:to-amber-950/20",t),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:"mt-0.5 inline-flex h-7 w-7 items-center justify-center rounded-md bg-rose-500/15 text-rose-700 dark:text-rose-300",children:e.jsx(qe,{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(q,{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(js,{value:o,className:"h-2"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/20 bg-rose-500/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ke,{id:"agy-step-reviewed-issue",checked:a.reviewedIssue509,onCheckedChange:r=>d({reviewedIssue509:!!r}),disabled:n}),e.jsx(Z,{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(Ke,{id:"agy-step-understands-risk",checked:a.understandsBanRisk,onCheckedChange:r=>d({understandsBanRisk:!!r}),disabled:n}),e.jsx(Z,{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(Ke,{id:"agy-step-accept-responsibility",checked:a.acceptsFullResponsibility,onCheckedChange:r=>d({acceptsFullResponsibility:!!r}),disabled:n}),e.jsx(Z,{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(ts,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(me,{value:a.typedPhrase,onChange:r=>d({typedPhrase:r.target.value}),placeholder:Rt,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(ve,{className:"h-3.5 w-3.5"})]})})]})]})}function za(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function Ga({open:t,onClose:a,provider:s,displayName:n,catalog:i,isFirstAccount:c=!1}){const[o,d]=u.useState(""),[r,h]=u.useState(""),[p,v]=u.useState(!1),[x,m]=u.useState(null),[L,k]=u.useState(""),[I,S]=u.useState(Qe),[A,y]=u.useState(!1),[C,l]=u.useState(!1),[b,T]=u.useState(At),[g,D]=u.useState(""),[N,z]=u.useState(""),[M,O]=u.useState(Mt),{t:j}=B(),G=u.useRef(!1),E=u.useRef(0),F=u.useRef(!1),w=qa(),R=bs(),H=s==="kiro",Q=s==="agy"||s==="gemini",ee=s==="gemini"&&!A,te=s==="agy"&&!A,re=Q&&C,oe=ua(I),se=za(L)===Ue,ae=Jt(s),f=Ns(b),U=H&&b==="idc",ne=H&&ws(b),Te=H?ys(b,M):void 0,ze=H?ks(b):void 0,Ge=H?Te==="device_code":ae,ce=w.isAuthenticating||R.isPending,Ee=o.trim(),Ce=g.trim(),Le=N.trim(),ke=x||w.error,Re=u.useCallback(async()=>{const P=await fetch("/api/settings/auth/antigravity-risk");if(!P.ok)throw new Error("Failed to load power user mode setting");return(await P.json()).antigravityAckBypass===!0},[]),be=u.useCallback(async({pendingMessage:P=null,disabledMessage:ue=null}={})=>{const We=++E.current;l(!0),P!==null&&m(P);try{const Oe=await Re();return E.current!==We||(y(Oe),ue?m(Oe?null:ue):P!==null&&m(null)),Oe}catch{return E.current!==We||(y(!1),m(ue??j("addAccountDialog.powerUserLoadFailed")),F.current||(F.current=!0,V.error(j("addAccountDialog.powerUserLoadFailed")))),!1}finally{E.current===We&&l(!1)}},[Re,j]),Se=()=>{d(""),h(""),v(!1),m(null),k(""),S(Qe),y(!1),l(!1),T(At),D(""),z(""),O(Mt),E.current+=1,F.current=!1,G.current=!1,a()};u.useEffect(()=>{t&&(k(""),S(Qe),m(null))},[s,t]),u.useEffect(()=>()=>{E.current+=1},[]),u.useEffect(()=>{if(!t||!Q){E.current+=1,y(!1),l(!1);return}be()},[t,s,Q,be]),u.useEffect(()=>{if(!t||s!=="agy"||!w.error||!A)return;const P=w.error.toLowerCase();(P.includes("agy_risk_ack_required")||P.includes("responsibility acknowledgement")||P.includes("responsibility checklist"))&&be({pendingMessage:j("addAccountDialog.powerUserLoading"),disabledMessage:j("addAccountDialog.powerUserUnavailableRetry")})},[w.error,t,A,s,be,j]),u.useEffect(()=>{!w.isAuthenticating&&!w.error&&w.provider===null&&t&&G.current&&(G.current=!1,(async()=>{try{const ue=await lt(s,void 0,i);ue.success&&ue.presetName&&c&&V.success(`Applied "${ue.presetName}" preset`)}catch{}Se()})())},[w.isAuthenticating,w.error,w.provider]);const Ae=()=>{w.cancelAuth(),Se()},Ve=async()=>{w.authUrl&&(await navigator.clipboard.writeText(w.authUrl),v(!0),setTimeout(()=>v(!1),2e3))},Be=()=>{r.trim()&&w.submitCallback(r.trim())},$e=()=>{if(re){m(j("addAccountDialog.powerUserLoading"));return}if(te&&!oe){m("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(ee&&!se){m(`Type "${Ue}" to acknowledge the account safety warning before authenticating this provider.`);return}if(m(null),U&&!Ce){m("IDC Start URL is required for Kiro IAM Identity Center login.");return}G.current=!0,w.startAuth(s,{nickname:Ee||void 0,kiroMethod:H?b:void 0,kiroIDCStartUrl:U?Ce:void 0,kiroIDCRegion:U&&Le?Le:void 0,kiroIDCFlow:U?M:void 0,flowType:H?Te:void 0,startEndpoint:H?ze:void 0,riskAcknowledgement:te?{version:ma,reviewedIssue509:I.reviewedIssue509,understandsBanRisk:I.understandsBanRisk,acceptsFullResponsibility:I.acceptsFullResponsibility,typedPhrase:I.typedPhrase}:void 0})},_=()=>{G.current=!0,R.mutate(void 0,{onSuccess:async()=>{const P=await lt("kiro",void 0,i);P.success&&P.presetName&&c&&V.success(`Applied "${P.presetName}" preset`),Se()}})},X=P=>{P||Ae()},W=w.isAuthenticating;return e.jsx(pt,{open:t,onOpenChange:X,children:e.jsxs(xt,{className:"sm:max-w-md",onInteractOutside:P=>{W&&P.preventDefault()},children:[e.jsxs(ht,{children:[e.jsx(gt,{children:j("addAccountDialog.title",{displayName:n})}),e.jsx(Qt,{children:j(H?"addAccountDialog.descKiro":Ge?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[te&&!W&&e.jsx(Ha,{value:I,onChange:P=>{S(P),m(null)},disabled:ce}),Q&&A&&!W&&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(ts,{className:"h-3.5 w-3.5"}),j("addAccountDialog.powerUserEnabled")]}),j("addAccountDialog.powerUserSkipped")]}),ee&&!W&&e.jsx(ct,{showAcknowledgement:!0,acknowledgementPhrase:Ue,acknowledgementText:L,onAcknowledgementTextChange:P=>{k(P),m(null)},disabled:ce}),H&&!W&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-auth-method",children:j("addAccountDialog.authMethod")}),e.jsxs(Ze,{value:b,onValueChange:P=>{T(P),m(null)},children:[e.jsx(et,{id:"kiro-auth-method",children:e.jsx(tt,{placeholder:j("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(st,{children:Cs.map(P=>e.jsx(Me,{value:P.id,children:P.label},P.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.description}),ne&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If your browser does not return automatically after login, CCS can accept the final",e.jsx("span",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"kiro://..."}),"callback URL in the next step."]})]}),U&&!W&&e.jsxs("div",{className:"space-y-4 rounded-lg border border-border/60 bg-muted/20 p-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(me,{id:"kiro-idc-start-url",value:g,onChange:P=>{D(P.target.value),m(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:ce}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(me,{id:"kiro-idc-region",value:N,onChange:P=>{z(P.target.value),m(null)},placeholder:"us-east-1",disabled:ce}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(Ze,{value:M,onValueChange:P=>{O(P),m(null)},children:[e.jsx(et,{id:"kiro-idc-flow",children:e.jsx(tt,{placeholder:"{/* TODO i18n: missing key */}Select IDC flow"})}),e.jsxs(st,{children:[e.jsx(Me,{value:"authcode",children:"Authorization Code"}),e.jsx(Me,{value:"device",children:"Device Code"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auth Code opens a browser and may need the final callback URL pasted back. Device Code shows a verification code instead."})]})]}),!W&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"nickname",children:j("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(me,{id:"nickname",value:o,onChange:P=>{d(P.target.value),m(null)},placeholder:j("addAccountDialog.nicknamePlaceholder"),disabled:ce,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:j("addAccountDialog.nicknameOptionalHint")})]}),W&&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(ie,{className:"w-4 h-4 inline mr-2 animate-spin"}),j("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:w.isDeviceCodeFlow?j("addAccountDialog.deviceCodeHint"):ne?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":j("addAccountDialog.browserHint")})]}),w.authUrl&&!w.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{className:"text-xs",children:j("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:w.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:Ve,children:p?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.copy")]})}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{if(!w.authUrl)return;const P=window.open(w.authUrl,"_blank");(!P||P.closed||typeof P.closed>"u")&&V.warning(j("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ve,{className:"w-3 h-3 mr-1"}),j("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"callback-url",className:"text-xs",children:ne?"Browser did not return? Paste the final kiro:// callback URL:":j("addAccountDialog.redirectPasteLabel")}),e.jsx(me,{id:"callback-url",value:r,onChange:P=>h(P.target.value),placeholder:ne?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":j("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(K,{variant:"secondary",size:"sm",onClick:Be,disabled:!r.trim()||w.isSubmittingCallback,children:w.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-3 h-3 mr-1 animate-spin"}),j("addAccountDialog.submitting")]}):j("addAccountDialog.submitCallback")})]})]}),!w.authUrl&&!w.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:ne?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":j("addAccountDialog.preparingUrl")})]}),ke&&e.jsx("p",{className:"text-xs text-center text-destructive",children:ke}),R.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ie,{className:"w-4 h-4 inline mr-2 animate-spin"}),j("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:Ae,children:j("addAccountDialog.cancel")}),H&&!W&&e.jsx(K,{variant:"outline",onClick:_,disabled:ce,children:R.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),j("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(na,{className:"w-4 h-4 mr-2"}),j("addAccountDialog.importFromIde")]})}),!W&&e.jsxs(K,{onClick:$e,disabled:ce||re||te&&!oe||ee&&!se,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),j("addAccountDialog.authenticate")]})]})]})]})})}const Va=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Ba(t){const a=t?.env||{};return Va.filter(s=>!a[s]?.trim())}function $a(t,a){const[s,n]=u.useState(null),[i,c]=u.useState(!1),o=ut(),{data:d,isLoading:r,refetch:h}=qt({queryKey:["settings",t],queryFn:async()=>{const M=await fetch(`/api/settings/${t}/raw`);return M.ok?M.json():{profile:t,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${t}/settings.json`}}}),p=d?.settings,v=u.useMemo(()=>s!==null?s:p?JSON.stringify(p,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[s,p]),x=u.useCallback(M=>{n(M)},[]),m=u.useMemo(()=>{try{return JSON.parse(v)}catch{return p||{env:{}}}},[v,p]),L=m?.env?.ANTHROPIC_MODEL,k=m?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,I=m?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,S=m?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,A=u.useMemo(()=>Ss(m?.env||{}),[m]),y=u.useCallback((M,O)=>As(M,O,{supportsExtendedContext:j=>Ma(t,j,a)}),[a,t]),C=u.useCallback((M,O)=>{const j={...m?.env||{},[M]:O},G=Pt(M)?y(j,A):j;delete G.CCS_EXTENDED_CONTEXT;const E={...m,env:G};n(JSON.stringify(E,null,2))},[y,m,A]),l=u.useCallback(M=>{const O=m?.env||{},j=y(O,M);delete j.CCS_EXTENDED_CONTEXT;const G={...m,env:j};n(JSON.stringify(G,null,2))},[y,m]),b=u.useCallback(M=>{const O={...m?.env||{},...M},G=Object.keys(M).some(Pt)?y(O,A):O;delete G.CCS_EXTENDED_CONTEXT;const E={...m,env:G};n(JSON.stringify(E,null,2))},[y,m,A]),T=u.useMemo(()=>{try{return JSON.parse(v),!0}catch{return!1}},[v]),g=u.useMemo(()=>s===null?!1:s!==JSON.stringify(p,null,2),[s,p]),D=u.useMemo(()=>Ba(m),[m]),N=ms({mutationFn:async()=>{const M=JSON.parse(v),O=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:M,expectedMtime:d?.mtime})});if(O.status===409)throw new Error("CONFLICT");if(!O.ok)throw new Error("Failed to save");return O.json()},onSuccess:M=>{o.invalidateQueries({queryKey:["settings",t]}),n(null),M?.warning?V.success(le.t("settings.saved"),{description:M.warning}):V.success(le.t("settings.saved"))},onError:M=>{M.message==="CONFLICT"?c(!0):V.error(M.message)}}),z=async M=>{c(!1),M?(await h(),N.mutate()):n(null)};return{data:d,isLoading:r,refetch:h,rawJsonContent:v,rawJsonEdits:s,isRawJsonValid:T,hasChanges:g,currentSettings:m,currentModel:L,opusModel:k,sonnetModel:I,haikuModel:S,extendedContextEnabled:A,toggleExtendedContext:l,handleRawJsonChange:x,updateEnvValue:C,updateEnvValues:b,saveMutation:{mutate:()=>N.mutate(),isPending:N.isPending},conflictDialog:i,setConflictDialog:c,handleConflictResolve:z,missingRequiredFields:D}}const Wa=/-(medium|high|xhigh)$/i;function Qa(t){if(!t)return;const a=t.trim().match(Wa);if(a?.[1])return a[1].toLowerCase()}function Ja(t,a){if(!t)return null;const s=Qa(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function Xa({label:t}){return e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function _e({modelId:t}){const a=Ja(t);return a?e.jsx(q,{variant:a.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:a.label}):null}function Ft(t,a){if(!t)return"";if(!a?.prefix)return t;const s=`${a.prefix}/`;return t.startsWith(s)?t.slice(s.length):t}function he(t,a){return a?.recommendedModelId??t}function fe({label:t,description:a,value:s,onChange:n,catalog:i,allModels:c,routing:o,disabled:d}){const{t:r}=B(),h=i?.provider==="codex",p=u.useMemo(()=>kt(i,c),[c,i]),v=u.useMemo(()=>Aa(i?.provider??"",i,c),[c,i]),x=new Set(p.map(l=>l.id)),m=u.useMemo(()=>new Map((o?.models??[]).map(l=>[l.modelId.toLowerCase(),l])),[o]),L=u.useMemo(()=>new Set(p.map(l=>he(l.id,m.get(l.id.toLowerCase())))),[p,m]),k=u.useMemo(()=>m.get(Ft(s,o).toLowerCase()),[o,m,s]),I=p.map(l=>({value:he(l.id,m.get(l.id.toLowerCase())),groupKey:"recommended",searchText:`${l.id} ${l.name} ${m.get(l.id.toLowerCase())?.recommendedModelId??""}`,keywords:[l.tier??"",i?.provider??""],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:he(l.id,m.get(l.id.toLowerCase()))}),m.get(l.id.toLowerCase())?.pinnedAvailable?e.jsx(q,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:m.get(l.id.toLowerCase())?.prefix}):null,h&&e.jsx(_e,{modelId:l.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:he(l.id,m.get(l.id.toLowerCase()))}),l.tier==="paid"&&e.jsx(Xa,{label:r("providerModelSelector.paid")}),m.get(l.id.toLowerCase())?.unprefixedStatus==="shadowed"?e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,m.get(l.id.toLowerCase())?.unprefixedStatus==="prefix-only"?e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,h&&e.jsx(_e,{modelId:l.id})]})})),S=v.filter(l=>!x.has(l.id)).filter(l=>!L.has(he(l.id,m.get(l.id.toLowerCase())))).map(l=>({value:he(l.id,m.get(l.id.toLowerCase())),groupKey:"all",searchText:`${l.id} ${m.get(l.id.toLowerCase())?.recommendedModelId??""}`,keywords:[l.owned_by],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:he(l.id,m.get(l.id.toLowerCase()))}),m.get(l.id.toLowerCase())?.pinnedAvailable?e.jsx(q,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:m.get(l.id.toLowerCase())?.prefix}):null,h&&e.jsx(_e,{modelId:l.id})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:he(l.id,m.get(l.id.toLowerCase()))}),m.get(l.id.toLowerCase())?.unprefixedStatus==="shadowed"?e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.shadowed")}):null,m.get(l.id.toLowerCase())?.unprefixedStatus==="prefix-only"?e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.prefixOnly")}):null,h&&e.jsx(_e,{modelId:l.id})]})})),A=!!s&&!I.some(l=>l.value===s)&&!S.some(l=>l.value===s),y=s?{value:s,groupKey:"current",searchText:s,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s}),e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:r("providerModelSelector.current")})]})}:null,C=I.length+S.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(xa,{value:s||void 0,onChange:n,disabled:d,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(C?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...A&&y?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.currentValue")})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},...S.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:S.length})})}]:[]],options:[...A&&y?[y]:[],...I,...S]}),k?e.jsxs("div",{className:J("rounded-md border px-2.5 py-2 text-[11px]",k.unprefixedStatus==="safe"?"border-border/70 bg-muted/25 text-muted-foreground":"border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100"),children:[e.jsxs("div",{className:"font-medium",children:[k.pinnedAvailable?r("providerModelSelector.preferredPinnedModel"):r("providerModelSelector.pinnedRouteStatus")," ",e.jsx("code",{children:k.pinnedAvailable?k.recommendedModelId:k.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:k.summary})]}):null,s&&!k&&Ft(s,o)!==s?e.jsx("div",{className:"rounded-md border border-amber-300/60 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-950/25 dark:text-amber-100",children:r("providerModelSelector.pinnedModelNotAdvertised",{model:s})}):null]})}function Ut(t,a){const s=n=>a?.models.find(c=>c.modelId.toLowerCase()===n.toLowerCase())?.recommendedModelId??n;return{default:s(t.default),opus:s(t.opus),sonnet:s(t.sonnet),haiku:s(t.haiku)}}function Ya({open:t,onClose:a,currentValues:s,onApply:n,onSave:i,isSaving:c,catalog:o,allModels:d,routing:r}){const{t:h}=B(),[p,v]=u.useState(Ut(s,r)),[x,m]=u.useState(""),L=k=>{k?(v(Ut(s,r)),m("")):a()};return e.jsx(pt,{open:t,onOpenChange:L,children:e.jsxs(xt,{className:"sm:max-w-md",children:[e.jsx(ht,{children:e.jsxs(gt,{className:"flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),h("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"preset-name",children:h("customPresetDialog.presetNameOptional")}),e.jsx(me,{id:"preset-name",value:x,onChange:k=>m(k.target.value),placeholder:h("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(wt,{}),o?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[h("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",h("customPresetDialog.codexTipSuffix")]}),e.jsx(fe,{label:h("customPresetDialog.defaultModel"),description:h("customPresetDialog.defaultModelDesc"),value:p.default,onChange:k=>v({...p,default:k}),catalog:o,allModels:d,routing:r}),e.jsx(fe,{label:h("customPresetDialog.opusModel"),description:h("customPresetDialog.opusModelDesc"),value:p.opus,onChange:k=>v({...p,opus:k}),catalog:o,allModels:d,routing:r}),e.jsx(fe,{label:h("customPresetDialog.sonnetModel"),description:h("customPresetDialog.sonnetModelDesc"),value:p.sonnet,onChange:k=>v({...p,sonnet:k}),catalog:o,allModels:d,routing:r}),e.jsx(fe,{label:h("customPresetDialog.haikuModel"),description:h("customPresetDialog.haikuModelDesc"),value:p.haiku,onChange:k=>v({...p,haiku:k}),catalog:o,allModels:d,routing:r})]}),e.jsxs(Ms,{className:"gap-2 sm:gap-0",children:[e.jsx(K,{variant:"outline",onClick:a,children:h("customPresetDialog.cancel")}),i&&e.jsxs(K,{variant:"secondary",onClick:()=>i(p,x||void 0),disabled:c||!x.trim(),children:[c?e.jsx(ie,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(Nt,{className:"w-4 h-4 mr-1"}),h("customPresetDialog.savePreset")]}),e.jsxs(K,{onClick:()=>n(p,x||void 0),children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"}),h("customPresetDialog.applyPreset")]})]})]})})}function ge({label:t,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(Xt,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Za({provider:t,displayName:a,defaultTarget:s,data:n,authStatus:i,supportsModelConfig:c=!1}){const{t:o}=B(),d=s||"claude",r=d==="droid",h=t==="codex",p=d==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,v=`${p} --config`,x=`${p} --auth --add`,m=`${p} --accounts`;return e.jsx(ft,{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(ss,{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:o("providerEditor.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:o("providerEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Xt,{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:o("providerEditor.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:o("providerEditor.status")}),i.authenticated?e.jsxs(q,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(ia,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(q,{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:o("providerEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:d})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:o("providerEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ge,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),h&&e.jsxs(e.Fragment,{children:[e.jsx(ge,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(ge,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(ge,{label:r?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(ge,{label:r?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${r?"claude":"droid"} "your prompt"`}),c&&e.jsx(ge,{label:d==="claude"?"Change model":"Change model (Claude target)",command:v}),e.jsx(ge,{label:d==="claude"?"Add account":"Add account (Claude target)",command:x}),e.jsx(ge,{label:d==="claude"?"List accounts":"List accounts (Claude target)",command:m}),d!=="claude"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account and model-management flags stay on Claude target. Codex and Droid runtime launches reject those CLIProxy management commands."})]})]})]})})}function en({displayName:t,logoProvider:a,provider:s,data:n,isLoading:i,hasChanges:c,isRawJsonValid:o,isSaving:d,isRemoteMode:r,port:h,onRefetch:p,onSave:v}){const{t:x}=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",{className:"flex items-center gap-3",children:[e.jsx(vt,{provider:a||s,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t}),r&&e.jsxs(q,{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(as,{className:"w-3 h-3"}),"Remote"]}),h&&e.jsxs(q,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(ra,{className:"w-3 h-3"}),":",h]}),!r&&n?.path&&e.jsx(q,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*[\\/]/,"")})]}),r?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[x("providerEditor.lastModified"),": ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:p,disabled:i,children:e.jsx(bt,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(K,{size:"sm",onClick:v,disabled:d||!c||!o,children:d?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function tn({models:t,provider:a,enabled:s,onToggle:n,disabled:i,className:c}){const{t:o}=B();if(t.length===0)return null;const d=t.some(p=>Dt(p.id)),r=t.some(p=>!Dt(p.id));let h="Compatible mappings stay on standard context unless you turn this on.";return d&&r?h="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":d&&(h="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:J("rounded-lg border p-3 space-y-2",s?"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(Ie,{className:J("w-4 h-4",s?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:o("extendedContext.extendedContext")}),e.jsx(q,{variant:s?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Yt,{checked:s,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(ss,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{children:["Applies the explicit ",e.jsx("code",{children:"[1m]"})," long-context suffix to compatible saved mappings."]}),e.jsx("p",{className:"text-[10px]",children:h}),e.jsxs("p",{className:"text-amber-600 dark:text-amber-500",children:["CCS only saves ",e.jsx("code",{children:"[1m]"}),". Provider pricing and entitlement are separate, and some accounts can still return 429 extra-usage errors for long-context requests."]})]})]})]})}function sn(t,a){const s=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:a(s.default),ANTHROPIC_DEFAULT_OPUS_MODEL:a(s.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:a(s.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:a(s.haiku)}}function an({catalog:t,savedPresets:a,currentModel:s,opusModel:n,sonnetModel:i,haikuModel:c,providerModels:o,routing:d,provider:r,extendedContextEnabled:h,onExtendedContextToggle:p,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:m,onDeletePreset:L,isDeletePending:k}){const{t:I}=B(),S=(d?.models??[]).some(g=>g.pinnedAvailable),A=u.useMemo(()=>new Map((d?.models??[]).map(g=>[g.modelId.toLowerCase(),g])),[d]),y=g=>A.get(g.toLowerCase())?.recommendedModelId??g,C=u.useMemo(()=>{if(!t)return[];const g=[s,n,i,c].filter(N=>!!N).map(N=>Ps(N));return[...new Set(g)].map(N=>us(t.provider,N,t)).filter(N=>!!N?.extendedContext)},[t,s,n,i,c]),l=u.useMemo(()=>kt(t,o),[t,o]),b=u.useMemo(()=>{const g=l.filter(N=>N.presetMapping);return g.length===0?[]:g.some(N=>N.tier==="paid")?[{key:"free",label:"Free Tier",description:"Available on free or paid plans",badgeClassName:"text-[10px] bg-green-100 text-green-700 border-green-200",iconClassName:"text-green-600",models:g.filter(N=>N.tier!=="paid")},{key:"paid",label:"Paid Tier",description:"Requires paid access",badgeClassName:"text-[10px] bg-amber-100 text-amber-700 border-amber-200",iconClassName:"text-amber-700",models:g.filter(N=>N.tier==="paid")}].filter(N=>N.models.length>0):[{key:"default",models:g.slice(0,4)}]},[l]),T=b.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[T&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:I("providerEditor.presets")}),e.jsxs("div",{className:"space-y-4",children:[b.map(g=>e.jsxs("div",{children:["label"in g&&g.label&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(q,{variant:"outline",className:g.badgeClassName,children:g.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:g.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:g.models.map(D=>e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>v(sn(D,y)),children:[e.jsx(Ie,{className:`w-3 h-3 ${"iconClassName"in g?g.iconClassName:""}`}),D.name]},D.id))})]},g.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.map(g=>e.jsxs("div",{className:"group relative",children:[e.jsxs(K,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{v({ANTHROPIC_MODEL:y(g.default),ANTHROPIC_DEFAULT_OPUS_MODEL:y(g.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:y(g.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:y(g.haiku)})},children:[e.jsx(Nt,{className:"w-3 h-3 fill-current"}),g.name]}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:D=>{D.stopPropagation(),L(g.name)},disabled:k,children:e.jsx(yt,{className:"w-3 h-3"})})]},g.name)),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:m,children:[e.jsx(ns,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(wt,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:I("providerEditor.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),d?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:S?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[d.prefix,"/"]})," prefix. Unprefixed names can still resolve to a different backend when providers overlap."]}):e.jsxs(e.Fragment,{children:["Managed pinning for ",e.jsxs("code",{children:[d.prefix,"/"]})," is not currently advertised by the proxy. Unprefixed names may still be ambiguous until prefix repair completes."]})}):null,r==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:["Codex tip: suffixes ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and ",e.jsx("code",{children:"-xhigh"})," ","pin reasoning effort. Unsuffixed models use Thinking settings."]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(fe,{label:"Default Model",description:"Used when no specific tier is requested",value:s,onChange:g=>x("ANTHROPIC_MODEL",g),catalog:t,allModels:o,routing:d}),C.length>0&&p&&e.jsx(tn,{models:C,provider:r,enabled:h??!1,onToggle:p}),e.jsx(fe,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:g=>x("ANTHROPIC_DEFAULT_OPUS_MODEL",g),catalog:t,allModels:o,routing:d}),e.jsx(fe,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:g=>x("ANTHROPIC_DEFAULT_SONNET_MODEL",g),catalog:t,allModels:o,routing:d}),e.jsx(fe,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:g=>x("ANTHROPIC_DEFAULT_HAIKU_MODEL",g),catalog:t,allModels:o,routing:d})]})]})]})}function nn(t,a,s){return t?e.jsx(nt,{children:e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(la,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:J("font-mono max-w-[180px] truncate",a&&mt),title:t,children:t})]})}),e.jsx(ot,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:s("providerEditor.gcpProjectIdReadonly")})})]})}):e.jsx(nt,{children:e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(qe,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:s("providerEditor.projectIdNA")})]})}),e.jsx(ot,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:s("providerEditor.missingProjectId")}),e.jsx("p",{children:s("providerEditor.missingProjectIdHint")})]})})]})})}function rn({account:t,onSetDefault:a,onRemove:s,onPauseToggle:n,isRemoving:i,isPausingAccount:c,privacyMode:o,showQuota:d,selectable:r,selected:h,onSelectChange:p}){const{t:v}=B(),x=t.provider.toLowerCase(),{data:m}=Ds(d),{data:L,isLoading:k}=Is(x,t.id,d),I=Ts(m,t)?.lastUsedAt,S=r||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r&&e.jsx("button",{type:"button",onClick:()=>p?.(!h),className:J("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(je,{className:"w-3 h-3"})}),n&&e.jsx(nt,{children:e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!t.paused),disabled:c,children:c?e.jsx(ie,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(is,{className:"w-4 h-4 text-emerald-500"}):e.jsx(rs,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ot,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,A=e.jsxs(Es,{children:[e.jsx(Ls,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(da,{className:"w-4 h-4"})})}),e.jsxs(Rs,{align:"end",children:[!t.isDefault&&e.jsxs(It,{onClick:a,children:[e.jsx(Nt,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(It,{className:"text-destructive focus:text-destructive",onClick:s,disabled:i,children:[e.jsx(os,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:J("rounded-lg border p-3 transition-colors overflow-hidden",t.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",t.paused&&"opacity-75",h&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(Os,{mode:"detailed",provider:t.provider,accountId:t.id,email:t.email,displayEmail:t.email||t.id,tokenFile:t.tokenFile,tier:t.tier,isDefault:t.isDefault,paused:t.paused,privacyMode:o,showQuota:d,quota:L,quotaLoading:k,runtimeLastUsed:I,beforeIdentity:S,headerEnd:A,bodySlot:t.provider==="agy"?nn(t.projectId,o,v):null,quotaInsetClassName:"pl-11"})})}function on({selectedCount:t,onPauseSelected:a,onResumeSelected:s,onClearSelection:n,isPausing:i,isResuming:c}){if(t<1)return null;const o=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:[t," selected"]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n,disabled:o,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:o,children:[i?e.jsx(ie,{className:"w-3 h-3 animate-spin"}):e.jsx(rs,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:o,children:[c?e.jsx(ie,{className:"w-3 h-3 animate-spin"}):e.jsx(is,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function dn({accounts:t,onAddAccount:a,onSetDefault:s,onRemoveAccount:n,onPauseToggle:i,onSoloMode:c,onBulkPause:o,onBulkResume:d,isRemovingAccount:r,isPausingAccount:h,isSoloingAccount:p,isBulkPausing:v,isBulkResuming:x,privacyMode:m,showQuota:L,isKiro:k,kiroNoIncognito:I,onKiroNoIncognitoChange:S,kiroSettingsLoading:A}){const{t:y}=B(),[C,l]=u.useState(new Set),b=u.useMemo(()=>new Set(t.map(w=>w.id)),[t]),T=u.useMemo(()=>new Set([...C].filter(w=>b.has(w))),[C,b]),g=!!(o&&d),D=T.size,N=t.length>0&&T.size===t.length,z=T.size>0&&T.size<t.length,M=u.useCallback(w=>{l(R=>{const H=new Set(R);return H.has(w)?H.delete(w):H.add(w),H})},[]),O=u.useCallback(()=>{l(new Set(t.map(w=>w.id)))},[t]),j=u.useCallback(()=>{l(new Set)},[]),G=u.useCallback(()=>{N?j():O()},[N,O,j]),E=u.useCallback(()=>{o&&T.size>0&&(o(Array.from(T)),l(new Set))},[o,T]),F=u.useCallback(()=>{d&&T.size>0&&(d(Array.from(T)),l(new Set))},[d,T]);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:[g&&t.length>0&&e.jsx(Ke,{checked:N,onCheckedChange:G,"aria-label":"Select all accounts",className:z?"data-[state=checked]:bg-primary/50":"",...z?{"data-state":"indeterminate"}:{}}),e.jsx(Pe,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(q,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(ns,{className:"w-3 h-3"}),"Add"]})]}),g&&D>0&&e.jsx(on,{selectedCount:D,onPauseSelected:E,onResumeSelected:F,onClearSelection:j,isPausing:!!v,isResuming:!!x}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(w=>e.jsx(rn,{account:w,onSetDefault:()=>s(w.id),onRemove:()=>n(w.id),onPauseToggle:i?R=>i(w.id,R):void 0,onSoloMode:c?()=>c(w.id):void 0,isRemoving:r,isPausingAccount:h,isSoloingAccount:p,privacyMode:m,showQuota:L,selectable:g,selected:T.has(w.id),onSelectChange:()=>M(w.id)},w.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Pe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:y("providerEditor.noAccountsConnected")}),e.jsx("p",{className:"text-xs opacity-70",children:y("providerEditor.addAccountToStart")})]}),k&&S&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(as,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:y("providerEditor.useIncognito")})]}),e.jsx(Yt,{checked:!I,onCheckedChange:w=>S(!w),disabled:A,className:"scale-90"})]})})]})}function ln({provider:t,catalog:a,savedPresets:s,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:o,providerModels:d,routing:r,extendedContextEnabled:h,onExtendedContextToggle:p,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:m,onDeletePreset:L,isDeletePending:k,accounts:I,onAddAccount:S,onSetDefault:A,onRemoveAccount:y,onPauseToggle:C,onSoloMode:l,onBulkPause:b,onBulkResume:T,isRemovingAccount:g,isPausingAccount:D,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:M,privacyMode:O,isRemoteMode:j}){const G=t.toLowerCase(),E=(_s.includes(G)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(G))&&!j,F=t==="kiro",[w,R]=u.useState(!0),[H,Q]=u.useState(!0),[ee,te]=u.useState(!1),re=u.useCallback(async()=>{if(F)try{Q(!0);const ae=(await Fe.config.get()).cliproxy;R(ae?.kiro_no_incognito??!0)}catch{R(!0)}finally{Q(!1)}},[F]),oe=u.useCallback(async se=>{R(se),te(!0);try{const ae=await Fe.config.get(),f=ae.cliproxy??{};await Fe.config.update({...ae,cliproxy:{...f,kiro_no_incognito:se}})}catch{R(!se)}finally{te(!1)}},[]);return u.useEffect(()=>{re()},[re]),e.jsx(ft,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(an,{catalog:a,savedPresets:s,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:o,providerModels:d,routing:r,provider:t,extendedContextEnabled:h,onExtendedContextToggle:p,onApplyPreset:v,onUpdateEnvValue:x,onOpenCustomPreset:m,onDeletePreset:L,isDeletePending:k}),e.jsx(wt,{}),e.jsx(dn,{accounts:I,onAddAccount:S,onSetDefault:A,onRemoveAccount:y,onPauseToggle:C,onSoloMode:l,onBulkPause:b,onBulkResume:T,isRemovingAccount:g,isPausingAccount:D,isSoloingAccount:N,isBulkPausing:z,isBulkResuming:M,privacyMode:O,showQuota:E,isKiro:F,kiroNoIncognito:w,onKiroNoIncognitoChange:oe,kiroSettingsLoading:H||ee})]})})}function Kt({provider:t,displayName:a,authStatus:s,catalog:n,routing:i,logoProvider:c,baseProvider:o,isRemoteMode:d,port:r,defaultTarget:h,topNotice:p,onAddAccount:v,onSetDefault:x,onRemoveAccount:m,onPauseToggle:L,onSoloMode:k,onBulkPause:I,onBulkResume:S,isRemovingAccount:A,isPausingAccount:y,isSoloingAccount:C,isBulkPausing:l,isBulkResuming:b}){const[T,g]=u.useState(!1),{privacyMode:D}=Wt(),{t:N}=B(),{data:z}=Fs(),{data:M}=Us(t),O=Ks(),j=qs(),G=o||t,E=G.toLowerCase()==="agy",F=u.useMemo(()=>{const _=M?.presets||[];return E?_.filter(X=>!de(X.default)&&!de(X.opus)&&!de(X.sonnet)&&!de(X.haiku)):_},[E,M?.presets]),w=u.useMemo(()=>{if(!z?.models)return[];const X={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[G.toLowerCase()]||[G.toLowerCase()];return z.models.filter(W=>X.some(P=>W.owned_by.toLowerCase().includes(P))?E?!de(W.id):!0:!1)},[E,z,G]),R=(o||t).toLowerCase(),{data:H,isLoading:Q,refetch:ee,rawJsonContent:te,rawJsonEdits:re,isRawJsonValid:oe,hasChanges:se,currentModel:ae,opusModel:f,sonnetModel:U,haikuModel:ne,extendedContextEnabled:Te,toggleExtendedContext:ze,handleRawJsonChange:Ge,updateEnvValue:ce,updateEnvValues:Ee,saveMutation:Ce,conflictDialog:Le,handleConflictResolve:ke,missingRequiredFields:Re}=$a(t,n),be=u.useMemo(()=>(s.accounts||[]).map(_=>({..._,provider:_.provider||o||t})),[s.accounts,o,t]),{data:Se}=qt({queryKey:["auth-tokens-raw"],queryFn:async()=>{const _=await fetch("/api/settings/auth/tokens/raw");return _.ok?_.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Ae=Se?.apiKey?.value??"ccs-internal-managed",Ve=_=>{if(E&&[_.ANTHROPIC_MODEL,_.ANTHROPIC_DEFAULT_OPUS_MODEL,_.ANTHROPIC_DEFAULT_SONNET_MODEL,_.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(W=>typeof W=="string"&&de(W))){V.error(N("providerEditor.agyDenylist"));return}Ee({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??dt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Ae,..._}),V.success(`Applied "${_.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Be=(_,X)=>{if(E&&[_.default,_.opus,_.sonnet,_.haiku].some(P=>de(P))){V.error(N("providerEditor.agyDenylist"));return}Ee({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??dt}/api/provider/${R}`,ANTHROPIC_AUTH_TOKEN:Ae,ANTHROPIC_MODEL:_.default,ANTHROPIC_DEFAULT_OPUS_MODEL:_.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:_.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:_.haiku}),V.success(`Applied ${X?`"${X}"`:"custom"} preset`),g(!1)},$e=(_,X)=>{if(!X){V.error(le.t("commonToast.enterPresetName"));return}if(E&&[_.default,_.opus,_.sonnet,_.haiku].some(W=>de(W))){V.error(N("providerEditor.agyDenylist"));return}O.mutate({profile:t,data:{name:X,..._}}),g(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(en,{provider:t,displayName:a,logoProvider:c,data:H,isLoading:Q,hasChanges:se,isRawJsonValid:oe,isSaving:Ce.isPending,isRemoteMode:d,port:r,onRefetch:ee,onSave:()=>Ce.mutate()}),p?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:p}):null,Q?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ie,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:N("providerEditor.loadingSettings")})]}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsxs(Hs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(zs,{className:"w-full",children:[e.jsx(Tt,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Tt,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Et,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(ln,{provider:t,catalog:n,savedPresets:F,currentModel:ae,opusModel:f,sonnetModel:U,haikuModel:ne,providerModels:w,routing:i,extendedContextEnabled:Te,onExtendedContextToggle:ze,onApplyPreset:Ve,onUpdateEnvValue:ce,onOpenCustomPreset:()=>g(!0),onDeletePreset:_=>j.mutate({profile:t,name:_}),isDeletePending:j.isPending,accounts:be,onAddAccount:v,onSetDefault:x,onRemoveAccount:m,onPauseToggle:L,onSoloMode:k,onBulkPause:I,onBulkResume:S,isRemovingAccount:A,isPausingAccount:y,isSoloingAccount:C,isBulkPausing:l,isBulkResuming:b,privacyMode:D,isRemoteMode:d})}),e.jsx(Et,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Za,{provider:t,displayName:a,defaultTarget:h,data:H,authStatus:s,supportsModelConfig:!!n})})]})]})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(ca,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:[N("rawEditorSection.rawConfig")," (JSON)"]})]}),e.jsx(Gs,{rawJsonContent:te,isRawJsonValid:oe,rawJsonEdits:re,onRawJsonChange:Ge,profileEnv:H?.settings?.env,missingRequiredFields:Re})]})]}),e.jsx(pa,{open:Le,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ke(!0),onCancel:()=>ke(!1)}),e.jsx(Ya,{open:T,onClose:()=>g(!1),currentValues:{default:ae||"",opus:f||"",sonnet:U||"",haiku:ne||""},onApply:Be,onSave:$e,isSaving:O.isPending,catalog:n,allModels:w,routing:i})]})}function cn({status:t,isSelected:a,onSelect:s}){const{t:n}=B(),i=t.accounts?.length||0;return e.jsxs("button",{className:J("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:s,children:[e.jsx(vt,{provider:t.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.displayName}),i>0&&e.jsx(q,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(je,{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(yt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function un({variant:t,parentAuth:a,isSelected:s,onSelect:n,onDelete:i,isDeleting:c}){const{t:o}=B(),d=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:J("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:d,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),d())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(vt,{provider:t.provider,size:"sm"}),e.jsx(ds,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1",children:o("cliproxyPage.variant")}),e.jsx(q,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:o("cliproxyPage.viaProvider",{provider:t.provider})})]}):e.jsxs(e.Fragment,{children:[e.jsx(yt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),i()},disabled:c,children:e.jsx(os,{className:"w-3 h-3"})})]})}function mn({onSetup:t}){const{t:a}=B();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(Ie,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:a("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[a("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:a("cliproxyPage.controlPanel")}),"."]}),e.jsxs(K,{onClick:t,className:"gap-2",children:[e.jsx(De,{className:"w-4 h-4"}),a("cliproxyPage.quickSetup")]})]})})}function Dn(){const{t}=B(),a=ut(),{data:s,isLoading:n}=Bt(),{data:i,isFetching:c}=Vs(),{data:o}=$t(),{data:d}=Bs(),r=$s(),h=Ws(),p=Qs(),v=Js(),x=Xs(),m=Ys(),L=Zs(),k=ea(),[I,S]=u.useState(()=>{if(typeof window<"u"){const U=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return U&&at(U)?U:localStorage.getItem("cliproxy-selected-provider")}return null}),[A,y]=u.useState(null),[C,l]=u.useState(!1),[b,T]=u.useState(()=>{if(typeof window>"u")return null;const f=new URLSearchParams(window.location.search),U=f.get("provider")?.trim().toLowerCase();return f.get("action")!=="auth"||!U||!at(U)?null:{provider:U,displayName:ta(U),isFirstAccount:!1}}),g=u.useMemo(()=>s?.authStatus||[],[s?.authStatus]),D=s?.source==="remote",N=u.useMemo(()=>i?.variants||[],[i?.variants]),z=u.useMemo(()=>Ct(o?.catalogs),[o?.catalogs]),M=o?.routing??{},O=!!o,j=f=>{S(f),f&&localStorage.setItem("cliproxy-selected-provider",f)},G=u.useMemo(()=>A?null:I&&g.some(f=>f.provider===I)?I:g.length>0&&(g.find(U=>(U.accounts?.length||0)>0)?.provider||g[0]?.provider)||null,[I,A,g]),E=g.find(f=>f.provider===G),F=N.find(f=>f.name===A),w=F?g.find(f=>f.provider===F.provider):void 0,R=(F?.provider||E?.provider||"").toLowerCase().trim(),H=R==="gemini"||R==="agy",Q=()=>{a.invalidateQueries({queryKey:["cliproxy"]}),a.invalidateQueries({queryKey:["cliproxy-auth"]}),a.invalidateQueries({queryKey:["cliproxy-catalog"]}),a.invalidateQueries({queryKey:["cliproxy-models"]})},ee=(f,U,ne)=>{p.isPending||v.isPending||(ne?p.mutate({provider:f,accountId:U}):v.mutate({provider:f,accountId:U}))},te=(f,U)=>{x.isPending||x.mutate({provider:f,accountId:U})},re=(f,U)=>{m.isPending||m.mutate({provider:f,accountIds:U})},oe=(f,U)=>{L.isPending||L.mutate({provider:f,accountIds:U})},se=f=>{j(f),y(null)},ae=f=>{y(f),j(null)};return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:d?.backendLabel??"CLIProxy"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Q,disabled:c,children:e.jsx(bt,{className:J("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(K,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>l(!0),children:[e.jsx(De,{className:"w-4 h-4"}),t("cliproxyPage.quickSetup")]})]}),e.jsx(ft,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:t("cliproxyPage.providers")}),n?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(f=>e.jsx(sa,{className:"h-14 w-full rounded-lg"},f))}):e.jsx("div",{className:"space-y-1",children:g.map(f=>e.jsx(cn,{status:f,isSelected:G===f.provider,onSelect:()=>se(f.provider)},f.provider))}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(ds,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:N.map(f=>e.jsx(un,{variant:f,parentAuth:g.find(U=>U.provider===f.provider),isSelected:A===f.name,onSelect:()=>ae(f.name),onDelete:()=>k.mutate(f.name),isDeleting:k.isPending},f.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(ha,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:t("cliproxyPage.providerCount",{count:g.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3 text-green-600"}),t("cliproxyPage.connectedCount",{count:g.filter(f=>f.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:F&&w?e.jsx(e.Fragment,{children:e.jsx(Kt,{provider:F.name,displayName:t("cliproxyPage.variantDisplay",{name:F.name,provider:F.provider}),authStatus:w,catalog:z[F.provider],routing:M[F.provider],logoProvider:F.provider,baseProvider:F.provider,defaultTarget:F.target,isRemoteMode:D,port:F.port,topNotice:H?e.jsx(ct,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>T({provider:F.provider,displayName:w.displayName,isFirstAccount:(w.accounts?.length||0)===0}),onSetDefault:f=>r.mutate({provider:F.provider,accountId:f}),onRemoveAccount:f=>h.mutate({provider:F.provider,accountId:f}),onPauseToggle:(f,U)=>ee(F.provider,f,U),onSoloMode:f=>te(F.provider,f),onBulkPause:f=>re(F.provider,f),onBulkResume:f=>oe(F.provider,f),isRemovingAccount:h.isPending,isPausingAccount:p.isPending||v.isPending,isSoloingAccount:x.isPending,isBulkPausing:m.isPending,isBulkResuming:L.isPending})}):E?e.jsx(e.Fragment,{children:e.jsx(Kt,{provider:E.provider,displayName:E.displayName,authStatus:E,catalog:z[E.provider],routing:M[E.provider],isRemoteMode:D,topNotice:H?e.jsx(ct,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>T({provider:E.provider,displayName:E.displayName,isFirstAccount:(E.accounts?.length||0)===0}),onSetDefault:f=>r.mutate({provider:E.provider,accountId:f}),onRemoveAccount:f=>h.mutate({provider:E.provider,accountId:f}),onPauseToggle:(f,U)=>ee(E.provider,f,U),onSoloMode:f=>te(E.provider,f),onBulkPause:f=>re(E.provider,f),onBulkResume:f=>oe(E.provider,f),isRemovingAccount:h.isPending,isPausingAccount:p.isPending||v.isPending,isSoloingAccount:x.isPending,isBulkPausing:m.isPending,isBulkResuming:L.isPending})}):e.jsx(mn,{onSetup:()=>l(!0)})}),e.jsx(_a,{open:C,onClose:()=>l(!1)}),e.jsx(Ga,{open:b!==null,onClose:()=>T(null),provider:b?.provider||"",displayName:b?.displayName||"",catalog:O&&b?.provider?z[b.provider]:void 0,isFirstAccount:b?.isFirstAccount||!1})]})}export{Dn as CliproxyPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bc as w,bd as us,a as Le,B as D,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aG as Te,bi as hs,ah as xs,ai as fs,aj as ps,ak as js,al as Ps,aD as bs,be as ws}from"./index-rrT-79_v.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-BvMmPLuD.js";import{S as Ns}from"./searchable-select-pmhYtZtB.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as Ds,aa as As,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.provider&&e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(D,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[A,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?A.port:k.port,se=y?A.auto_start:k.auto_start,ae=y?A.ghost_mode:k.ghost_mode,v=y?A.model:k.model,te=y?A.opus_model:k.opus_model,re=y?A.sonnet_model:k.sonnet_model,ne=y?A.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(D,{children:s("cursorPage.enabled")}):e.jsx(D,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),De=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),Ae=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Ae)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:De,opus_model:De,sonnet_model:Ae,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(D,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(D,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:j.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:j.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[j.duration_ms," ms"]})]}),j.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:j.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:j.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),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("cursorPage.port")}),e.jsx("span",{children:a?.port??l?.port??Ie})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(D,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ds,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(As,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),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:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(D,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};
|