@kaitranntt/ccs 7.69.1-dev.2 → 7.69.1-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/ui/assets/accounts-DN0lP-yj.js +1 -0
  2. package/dist/ui/assets/{alert-dialog-QyEXocpn.js → alert-dialog-BA39vaYL.js} +1 -1
  3. package/dist/ui/assets/api-D2cjf1H4.js +4 -0
  4. package/dist/ui/assets/{auth-section-BszF77uT.js → auth-section-BNX8_9MJ.js} +1 -1
  5. package/dist/ui/assets/{backups-section-D6RgaOx1.js → backups-section-Bt0FA5zl.js} +1 -1
  6. package/dist/ui/assets/channels-FaDUjf3Y.js +1 -0
  7. package/dist/ui/assets/{checkbox-Dzwkj_Pg.js → checkbox-DHF-UBrH.js} +1 -1
  8. package/dist/ui/assets/claude-extension-D-skBToQ.js +1 -0
  9. package/dist/ui/assets/cliproxy-CD7z-_q8.js +3 -0
  10. package/dist/ui/assets/cliproxy-ai-providers-QSOOqh8F.js +15 -0
  11. package/dist/ui/assets/cliproxy-control-panel-D9dLU28p.js +1 -0
  12. package/dist/ui/assets/codex-CHO5_hku.js +27 -0
  13. package/dist/ui/assets/confirm-dialog-BICDz_zm.js +1 -0
  14. package/dist/ui/assets/copilot-BnQrRCuJ.js +3 -0
  15. package/dist/ui/assets/{cursor-BrcDgu6X.js → cursor-CXopLKfC.js} +1 -1
  16. package/dist/ui/assets/droid-CLFg9ELE.js +2 -0
  17. package/dist/ui/assets/{globalenv-section-DoX37DqB.js → globalenv-section-NPjCcYBN.js} +1 -1
  18. package/dist/ui/assets/{health-D_gdcxnc.js → health-B_3JpCrY.js} +1 -1
  19. package/dist/ui/assets/index-B5Egq7qY.js +1 -0
  20. package/dist/ui/assets/index-BY2j-o67.js +1 -0
  21. package/dist/ui/assets/{index-CTGpqIx6.js → index-BcUkpsGj.js} +1 -1
  22. package/dist/ui/assets/{index-DoVPk3vW.js → index-BgGHTjTd.js} +1 -1
  23. package/dist/ui/assets/index-DNmWbKbN.js +72 -0
  24. package/dist/ui/assets/index-DZddoGfE.js +1 -0
  25. package/dist/ui/assets/logs-Bb1OVYeK.js +1 -0
  26. package/dist/ui/assets/{masked-input-C2H-Ax0Z.js → masked-input-b4-lEKNq.js} +1 -1
  27. package/dist/ui/assets/proxy-status-widget-s89zaj3X.js +1 -0
  28. package/dist/ui/assets/{raw-json-settings-editor-panel-WxTn7-hS.js → raw-json-settings-editor-panel-Dr_BNQwQ.js} +1 -1
  29. package/dist/ui/assets/{searchable-select-1zOULoec.js → searchable-select-FJPe_YWv.js} +1 -1
  30. package/dist/ui/assets/{separator-BCfZ54mZ.js → separator-DJ0ku_ak.js} +1 -1
  31. package/dist/ui/assets/{shared-DlTbnc9n.js → shared-DyQlJnbj.js} +1 -1
  32. package/dist/ui/assets/{table-Bx2cnkWN.js → table-6Yg65ZZH.js} +1 -1
  33. package/dist/ui/assets/{updates-SiZKOnUD.js → updates-DSCXb6Au.js} +1 -1
  34. package/dist/ui/index.html +1 -1
  35. package/package.json +1 -1
  36. package/dist/ui/assets/accounts-D9eEaNx9.js +0 -1
  37. package/dist/ui/assets/api-7vQe0xOg.js +0 -4
  38. package/dist/ui/assets/channels-B1vgnNJX.js +0 -1
  39. package/dist/ui/assets/claude-extension-CKO4bJ22.js +0 -1
  40. package/dist/ui/assets/cliproxy-ai-providers-CmbFYVoR.js +0 -15
  41. package/dist/ui/assets/cliproxy-control-panel-M8ZfUq3C.js +0 -1
  42. package/dist/ui/assets/cliproxy-kHd-oC5W.js +0 -3
  43. package/dist/ui/assets/codex-BJ0RdMuh.js +0 -27
  44. package/dist/ui/assets/confirm-dialog-BlSaX2gK.js +0 -1
  45. package/dist/ui/assets/copilot-NJKZQXQ_.js +0 -3
  46. package/dist/ui/assets/droid-B9u9ZB-a.js +0 -2
  47. package/dist/ui/assets/index-BNU4Hhe_.js +0 -1
  48. package/dist/ui/assets/index-DFEMq3KP.js +0 -1
  49. package/dist/ui/assets/index-DOn6k1jF.js +0 -72
  50. package/dist/ui/assets/index-h08p9xL5.js +0 -1
  51. package/dist/ui/assets/logs-DtH4YMt4.js +0 -1
  52. package/dist/ui/assets/proxy-status-widget-BOrsn86w.js +0 -1
@@ -1,3 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{a as dt,u as Kt,b as us}from"./tanstack-CrmUhA7Z.js";import{a8 as ms,d as U,C as qt,b as Ht,a9 as Gt,c as Q,P as ut,B as H,a as ce,aa as le,L as Y,I as me,r as Ye,s as Ze,t as et,v as tt,w as Ae,ab as Vt,ac as Bt,ad as ps,ae as xs,af as hs,u as zt,ag as mt,ah as pt,ai as xt,aj as ht,ak as $t,al as kt,am as fs,an as gs,W as Qt,ao as st,ap as Jt,Y as Fe,aq as vs,ar as At,as as St,at as js,au as bs,av as Ns,aw as ys,ax as ws,ay as Cs,az as ks,aA as As,aB as Pt,aC as Ss,x as Wt,n as ft,aD as gt,aE as Mt,aF as Xt,aG as Ps,m as Ms,aH as Ds,aI as Is,aJ as at,T as nt,p as it,q as rt,aK as Ts,aL as Ls,aM as Rs,aN as Dt,aO as Es,aP as Os,aQ as _s,aR as Fs,aS as Us,aT as Ks,Q as qs,R as Hs,U as It,V as Tt,aU as Gs,aV as Vs,aW as Bs,aX as zs,aY as $s,aZ as Qs,a_ as Js,a$ as Ws,b0 as Xs,b1 as Ys,b2 as Zs,b3 as ea,S as ta}from"./index-DOn6k1jF.js";import{C as ot}from"./default-ports-1QQSffYX.js";import{t as G}from"./notifications-B2HqRBj7.js";import{C as Yt,L as ne,p as ve,$ as sa,m as je,o as Zt,aF as vt,R as jt,q as Se,aa as Pe,T as qe,a7 as Lt,aG as es,aE as aa,z as bt,Z as Me,_ as ts,i as na,u as ss,aH as ia,at as ra,X as Nt,a9 as as,J as ns,D as is,aI as oa,as as rs,aJ as la,aw as ca,aK as os}from"./icons-KVCk4_U8.js";import{R as Ue,A as Rt,D as Qe,i as da,a as ua}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{C as Ke}from"./checkbox-Dzwkj_Pg.js";import{C as ma}from"./confirm-dialog-BlSaX2gK.js";import{S as yt}from"./separator-BCfZ54mZ.js";import{S as pa}from"./searchable-select-1zOULoec.js";import{P as xa}from"./proxy-status-widget-BOrsn86w.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-QyEXocpn.js";const X="gemini-3.1-pro-high",ye="gemini-3.1-pro-low",ha=Object.freeze({"gemini-3-pro-high":X,"gemini-3.1-pro-high":X,"gemini-3-pro-low":ye,"gemini-3.1-pro-low":ye,"gemini-3-pro-preview":X,"gemini-3-pro-preview-customtools":X,"gemini-3.1-pro-preview":X,"gemini-3.1-pro-preview-customtools":X,"gemini-3-1-pro-preview":X,"gemini-3-1-pro-preview-customtools":X}),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,ga=["agy/","gcli/"];function z(t){return ms(t).toLowerCase()}function va(t){const s=t.trim(),a=s.toLowerCase();for(const n of ga)if(a.startsWith(n))return s.slice(n.length);return s}function ja(t){return t.replace(/-customtools$/i,"")}function ba(t){return ha[z(t)]}function He(t){const s=z(t),a=s.match(fa);if(!a)return null;const[,n,i,c]=a;return{normalizedId:s,version:n.split(/[.-]/).map(o=>Number(o)),family:i,customtools:!!c,dottedVersion:n.includes(".")}}function cs(t,s){const a=Math.max(t.length,s.length);for(let n=0;n<a;n+=1){const i=t[n]??0,c=s[n]??0;if(i!==c)return i>c?1:-1}return 0}function Na(t,s,a){if(t.customtools!==s.customtools)return t.customtools?1:-1;const n=cs(t.version,s.version);if(n!==0)return n>0?-1:1;const i=+(t.dottedVersion===a.dottedVersion),c=+(s.dottedVersion===a.dottedVersion);return i!==c?c-i:t.normalizedId.localeCompare(s.normalizedId)}function Et(t,s){const a=z(s);return t.find(n=>z(n.id)===a)?.id}function ya(t,s){const a=He(t);return!a||s.length===0?void 0:s.map(i=>{const c=He(i.id);return!c||c.family!==a.family?null:{id:i.id,info:c}}).filter(i=>!!i).sort((i,c)=>Na(i.info,c.info,a))[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:X,name:"Gemini Pro High",description:"Current Antigravity Gemini Pro route with higher reasoning budget",extendedContext:!0,presetMapping:{default:X,opus:X,sonnet:X,haiku:"gemini-3-1-flash-preview"}},{id:ye,name:"Gemini Pro Low",description:"Current Antigravity Gemini Pro route with the lighter quota tier",extendedContext:!0,presetMapping:{default:ye,opus:ye,sonnet:ye,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:X,sonnet:X,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 Ce(t,s){if(!t)return;const a=z(s);if(t.provider==="agy"){const o=ba(a);if(o){const u=t.models.find(r=>r.id===o);if(u)return u}}const n=ls[a.toLowerCase()],i=t.models.find(o=>o.id===a||o.id===n);if(i)return i;const c=He(a);if(c)return t.models.map(o=>({model:o,info:He(o.id)})).filter(o=>!!(o.info&&o.info.family===c.family)).sort((o,u)=>cs(u.info.version,o.info.version))[0]?.model}function wa(t){if(t==="free")return"free";if(typeof t=="string"&&t.trim().length>0)return"paid"}function Ca(t,s){const a=pe[t.toLowerCase()];if(!s||s.models.length===0)return a;const n=s.models.map(u=>({id:u.id,owned_by:s.provider})),i=s.models.map(u=>{const r=Ce(a,u.id);return{...u,name:u.name||r?.name||u.id,tier:r?.tier??wa(u.tier),description:u.description??r?.description,broken:r?.broken,issueUrl:r?.issueUrl,deprecated:r?.deprecated,deprecationReason:r?.deprecationReason,extendedContext:u.extendedContext??r?.extendedContext,presetMapping:r?.presetMapping}}),c=a?.defaultModel?we(a.defaultModel,n):void 0,o=typeof c=="string"&&n.some(u=>z(u.id)===z(c));return{provider:s.provider,displayName:s.displayName||a?.displayName||t,defaultModel:o?c:s.defaultModel,models:i}}function wt(t){const s={},a=new Set([...Object.keys(pe),...Object.keys(t??{})]);for(const n of a){const i=Ca(n,t?.[n]);i&&(s[n]=i)}return s}function ds(t,s,a){const n=Ce(a,s);return n||Ce(pe[t.toLowerCase()],s)}function we(t,s=[]){const a=z(t),n=ya(a,s);if(n)return n;const i=Et(s,a);if(i)return i;const c=ls[a];return(c?Et(s,c):void 0)??a}function ka(t,s=[]){return{default:we(t.default,s),opus:we(t.opus,s),sonnet:we(t.sonnet,s),haiku:we(t.haiku,s)}}function Ct(t,s=[]){if(!t)return[];const a=pe[t.provider.toLowerCase()]??t,n=new Set;return a.models.map(i=>{const c=we(i.id,s),o=i.presetMapping?ka(i.presetMapping,s):void 0,u=t.models.find(r=>z(r.id)===z(c));return{...i,id:c,name:u?.name||i.name,description:u?.description??i.description,presetMapping:o}}).filter(i=>n.has(i.id)?!1:(n.add(i.id),!0))}function Aa(t,s,a=[]){const n=t.trim().toLowerCase();if(!s||!n)return[];const i=pe[n]??s,c=Ct(s,a),o=new Set(c.map(x=>z(x.id))),u=new Set(c.map(x=>Ce(i,x.id)?.id).filter(x=>!!x).map(x=>z(x))),r=new Set,p=new Set(a.map(x=>z(x.id)));return a.filter(x=>{const v=z(x.id),j=va(x.id),m=ja(j),R=Ce(i,j)??Ce(i,m);if(o.has(z(j))||v!==z(j)&&p.has(z(j)))return!1;const k=z(m);if(k!==z(j)&&p.has(k))return!1;const b=R?z(R.id):k;return R&&u.has(b)||r.has(b)||!R&&n==="agy"?!1:(r.add(b),!0)})}function Sa(t,s,a){return ds(t,s,a)?.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 Ma(t,s){if(s)return s;try{const a=await fetch("/api/cliproxy/catalog");if(!a.ok)return pe[t];const n=await a.json();return wt(n.catalogs)[t]??pe[t]}catch{return pe[t]}}async function lt(t,s,a){const n=await Ma(t,a);if(!n)return{success:!1};const i=n.models.find(p=>p.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:${ot}/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 Da({currentProgress:t,allSteps:s}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:s.map((a,n)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${t>=n?"bg-primary":"bg-muted"}`},a))})}function Ia({providers:t,onSelect:s}){return e.jsx("div",{className:"grid gap-2",children:t.map(a=>e.jsxs("button",{onClick:()=>s(a.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.description})]}),e.jsx(Yt,{className:"w-4 h-4 text-muted-foreground"})]},a.id))})}function Ta({selectedProvider:t,providers:s,authCommand:a,isRefreshing:n,isPending:i,onBack:c,onStartAuth:o,onRefresh:u}){const[r,p]=d.useState(!1),x=async v=>{await navigator.clipboard.writeText(v),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.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",s.find(v=>v.id===t)?.name," to add an account"]}),e.jsx(U,{onClick:o,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(qt,{children:e.jsxs(Ht,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(sa,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:a}),e.jsx(U,{variant:"outline",size:"icon",onClick:()=>x(a),children:r?e.jsx(je,{className:"w-4 h-4 text-green-500"}):e.jsx(Zt,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(U,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(vt,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(U,{variant:"outline",onClick:u,disabled:n||i,children:[e.jsx(jt,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),n?"Checking...":"Refresh Status"]})]})]})}function La({accounts:t,privacyMode:s,onSelect:a,onAddNew:n,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",t.length,")"]}),e.jsx("div",{className:"grid gap-2 max-h-[320px] overflow-y-auto pr-1",children:t.map(c=>{const o=Gt(c.id,c.email,c.tokenFile);return e.jsxs("button",{type:"button",onClick:()=>a(c),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Se,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:Q("font-medium",s&&ut),children:o.email}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[o.audienceLabel&&e.jsx(H,{variant:"outline",className:Q("text-[10px] h-4 px-1.5 border-transparent",o.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:o.audienceLabel}),o.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:o.detailLabel}),c.isDefault&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default account"})]})]})]}),e.jsx(Yt,{className:"w-4 h-4 text-muted-foreground"})]},c.id)})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ve,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(U,{variant:"ghost",onClick:i,children:[e.jsx(vt,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}const Ot="__custom__";function Ra({selectedProvider:t,catalog:s,selectedAccount:a,variantName:n,modelName:i,isPending:c,privacyMode:o,onVariantNameChange:u,onModelChange:r,onBack:p,onSkip:x,onCreate:v}){const{t:j}=ce(),m=s||pe[t],R=m?.models||[],k=i&&!R.some(l=>l.id===i),[b,D]=d.useState(k),S=t==="agy"&&i.trim().length>0?le(i):!1,f=a?Gt(a.id,a.email,a.tokenFile):null,C=l=>{l===Ot?(D(!0),r("")):(D(!1),r(l))};return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{children:[j("setupVariant.using")," ",e.jsx("span",{className:Q(o&&ut),children:f?.email})]}),(f?.audienceLabel||f?.detailLabel)&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f?.audienceLabel&&e.jsx(H,{variant:"outline",className:Q("text-[10px] h-4 px-1.5 border-transparent",f.audience==="business"?"bg-sky-500/12 text-sky-700 dark:text-sky-300":"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300"),children:f.audienceLabel}),f?.detailLabel&&e.jsx(H,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:f.detailLabel})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"variant-name",children:j("setupVariant.variantNameRequired")}),e.jsx(me,{id:"variant-name",value:n,onChange:l=>u(l.target.value),placeholder:j("setupVariant.variantNamePlaceholder")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[j("setupVariant.invokeHintPrefix")," ccs ",n||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{children:j("setupVariant.model")}),b?e.jsxs("div",{className:"space-y-2",children:[e.jsx(me,{value:i,onChange:l=>r(l.target.value),placeholder:j("setupVariant.modelPlaceholder")}),S&&e.jsx("p",{className:"text-xs text-destructive",children:"Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated."}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>{D(!1),t==="agy"&&le(i)&&r("")},children:j("setupVariant.choosePresetInstead")})]}):e.jsxs(Ye,{value:R.some(l=>l.id===i)?i:"",onValueChange:C,children:[e.jsx(Ze,{children:e.jsx(et,{placeholder:j("setupVariant.selectModel")})}),e.jsxs(tt,{children:[R.map(l=>e.jsx(Ae,{value:l.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:l.name}),l.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",l.description]})]})},l.id)),e.jsx(Ae,{value:Ot,children:e.jsx("span",{className:"text-primary",children:j("setupVariant.customModelName")})})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b?j("setupVariant.enterAnyModel"):j("setupVariant.defaultModel",{model:m?.defaultModel||j("setupVariant.providerDefault")})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(U,{variant:"ghost",onClick:p,children:[e.jsx(vt,{className:"w-4 h-4 mr-2"}),j("setupVariant.back")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"ghost",onClick:x,children:j("setupVariant.skip")}),e.jsx(U,{onClick:v,disabled:!n||c||S,children:j(c?"setupVariant.creating":"setupVariant.createVariant")})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:j("setupVariant.skipHint")})]})}function Ea({variantName:t,onClose:s}){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:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(qt,{children:e.jsxs(Ht,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",t,' "your prompt here"']})]})}),e.jsx(U,{onClick:s,className:"w-full",children:"Done"})]})}function Oa({open:t,onClose:s}){const[a,n]=d.useState("provider"),[i,c]=d.useState(""),[o,u]=d.useState(null),[r,p]=d.useState(""),[x,v]=d.useState(""),[j,m]=d.useState(!1),[R,k]=d.useState(!1),{data:b,refetch:D}=Vt(),{data:S}=Bt(),f=ps(),C=xs(),l=hs(),{privacyMode:P}=zt(),g=b?.authStatus.find(L=>L.provider===i),N=d.useMemo(()=>g?.accounts||[],[g?.accounts]),w=d.useMemo(()=>wt(S?.catalogs),[S?.catalogs]),q=!!S;d.useEffect(()=>{if(!t){const L=setTimeout(()=>{n("provider"),c(""),u(null),p(""),v(""),k(!1)},0);return()=>clearTimeout(L)}},[t]),d.useEffect(()=>{if(a==="auth"&&N.length>0&&!R){const L=setTimeout(()=>{n("account")},0);return()=>clearTimeout(L)}},[a,N,R]);const V=async()=>{m(!0),await D(),m(!1)},M=()=>{const L=(g?.accounts?.length||0)===0;C.mutate({provider:i},{onSuccess:async B=>{if(L){const $=await lt(i,void 0,q?w[i]:void 0);$.success&&$.presetName?G.success(`Applied "${$.presetName}" preset`):$.success||G.warning(Qt.t("commonToast.accountAddedPresetFailed"))}B.account&&(u(B.account),n("variant")),D()}})},E=L=>{c(L),(b?.authStatus.find(Z=>Z.provider===L)?.accounts||[]).length===0?n("auth"):n("account")},y=L=>{u(L),n("variant")},K=async()=>{if(!(!r||!i))try{await f.mutateAsync({name:r,provider:i,model:x||void 0,account:o?.id}),n("success")}catch(L){console.error("Failed to create variant:",L)}},O=`ccs ${i} --auth --add`,A=gs(a),I=L=>{if(!L&&(C.isPending&&i&&l.mutate(i),a==="success"||a==="provider")){s();return}};return e.jsx(mt,{open:t,onOpenChange:I,children:e.jsxs(pt,{className:"sm:max-w-lg",onPointerDownOutside:L=>{a!=="success"&&a!=="provider"&&L.preventDefault()},onEscapeKeyDown:L=>{(C.isPending||f.isPending)&&L.preventDefault()},children:[e.jsxs(xt,{children:[e.jsxs(ht,{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs($t,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx(Ia,{providers:kt,onSelect:E}),a==="auth"&&e.jsx(Ta,{selectedProvider:i,providers:kt,authCommand:O,isRefreshing:j,isPending:C.isPending,onBack:()=>n("provider"),onStartAuth:M,onRefresh:V}),a==="account"&&e.jsx(La,{accounts:N,privacyMode:P,onSelect:y,onAddNew:()=>{k(!0),n("auth")},onBack:()=>n("provider")}),a==="variant"&&e.jsx(Ra,{selectedProvider:i,catalog:w[i],selectedAccount:o,variantName:r,modelName:x,isPending:f.isPending,privacyMode:P,onVariantNameChange:p,onModelChange:v,onBack:()=>N.length>0?n("account"):n("provider"),onSkip:s,onCreate:K}),a==="success"&&e.jsx(Ea,{variantName:r,onClose:s})]}),e.jsx(Da,{currentProgress:A,allSteps:fs})]})})}const _a=3e3,Fa=300*1e3,Ua=3;function We(t){t.invalidateQueries({queryKey:["cliproxy-catalog"]}),t.invalidateQueries({queryKey:["cliproxy-models"]})}async function Xe(t){const s=await t.text();if(!s)return{};try{return JSON.parse(s)}catch{const a=t.status>=400?`Request failed with status ${t.status}`:void 0;return a?{error:a}:{}}}const xe={provider:null,isAuthenticating:!1,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:!1};function Ka(){const[t,s]=d.useState(xe),a=d.useRef(xe),n=d.useRef(0),i=d.useRef(null),c=d.useRef(null),o=d.useRef(0),u=d.useRef(0),r=d.useRef(!1),p=dt(),x=d.useCallback(b=>b===n.current,[]),v=d.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=null),u.current=0},[]);d.useEffect(()=>()=>{i.current?.abort(),v(),r.current=!1},[v]),d.useEffect(()=>{a.current=t},[t]);const j=d.useCallback(async(b,D,S)=>{if(x(S)){if(Date.now()-o.current>Fa){v(),x(S)&&s(f=>({...f,isAuthenticating:!1,error:"Authentication timed out. Please try again."}));return}try{const f=await fetch(`/api/cliproxy/auth/${b}/status?state=${encodeURIComponent(D)}`);if(!x(S))return;const C=await f.json();if(u.current=0,C.status==="ok"){if(!(typeof C.account=="object"&&C.account!==null)){v();const P="Authenticated account could not be registered";G.error(P),s(g=>({...g,isAuthenticating:!1,error:P}));return}v(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),We(p),G.success(`${b} authentication successful`),r.current=!1,s(xe)}else if(C.status==="auth_url"){const l=C.url||C.auth_url;l&&(s(P=>({...P,authUrl:l})),r.current||(r.current=!0,window.open(l,"_blank")))}else if(C.status==="device_code"){v();const l=C.user_code&&C.verification_url?`Open ${C.verification_url} and enter code: ${C.user_code}`:"Switch to Device Code method and try again.";G.error("Provider returned Device Code flow in callback mode"),s(P=>({...P,isAuthenticating:!1,error:l}))}else if(C.status==="error"){v();const l=C.error||"Authentication failed";G.error(l),s(P=>({...P,isAuthenticating:!1,error:l}))}}catch(f){if(!x(S)||(u.current+=1,u.current<Ua))return;v();const C=f instanceof Error&&f.message.trim().length>0?f.message:"Lost contact with the auth status endpoint";G.error(C),s(l=>({...l,isAuthenticating:!1,error:C}))}}},[x,p,v]),m=d.useCallback(async(b,D)=>{if(!st(b)){s({...xe,error:`Unknown provider: ${b}`});return}i.current?.abort(),v(),r.current=!1,u.current=0;const S=new AbortController,f=n.current+1;n.current=f,i.current=S;const l=(D?.flowType||(Jt(b)?"device_code":"authorization_code"))==="device_code",P=D?.startEndpoint||(l?"start":"start-url"),g={nickname:D?.nickname,kiroMethod:D?.kiroMethod,kiroIDCStartUrl:D?.kiroIDCStartUrl,kiroIDCRegion:D?.kiroIDCRegion,kiroIDCFlow:D?.kiroIDCFlow,riskAcknowledgement:D?.riskAcknowledgement};s({provider:b,isAuthenticating:!0,error:null,authUrl:null,oauthState:null,isSubmittingCallback:!1,isDeviceCodeFlow:l});try{if(P==="start")fetch(`/api/cliproxy/auth/${b}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g),signal:S.signal}).then(async N=>{if(!x(f))return;const w=await Xe(N);if(!x(f))return;const q=w.success===!0,V=typeof w.account=="object"&&w.account!==null;if(N.ok&&q&&V)p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),We(p),r.current=!1,s(xe);else{const M=typeof w.error=="string"?w.error:q?"Authenticated account could not be registered":"Authentication failed";G.error(M),s(E=>({...E,isAuthenticating:!1,error:M}))}}).catch(N=>{if(!x(f)||N instanceof Error&&N.name==="AbortError")return;const w=N instanceof Error?N.message:"Authentication failed";G.error(w),s(q=>({...q,isAuthenticating:!1,error:w}))});else{const N=await fetch(`/api/cliproxy/auth/${b}/start-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g),signal:S.signal});if(!x(f))return;const w=await Xe(N);if(!x(f))return;const q=w.success===!0;if(!N.ok||!q){const E=typeof w.error=="string"?w.error:"Failed to start OAuth";throw new Error(E)}const V=typeof w.authUrl=="string"?w.authUrl:null,M=typeof w.state=="string"?w.state:null;if(s(E=>({...E,authUrl:V,oauthState:M})),V&&(r.current=!0,window.open(V,"_blank")),M){if(o.current=Date.now(),!V){if(await j(b,M,f),!x(f))return;const E=a.current;if(!E.isAuthenticating||E.provider!==b)return}c.current=setInterval(()=>{j(b,M,f)},_a)}}}catch(N){if(!x(f))return;if(N instanceof Error&&N.name==="AbortError"){r.current=!1,s(xe);return}const w=N instanceof Error?N.message:"Authentication failed";G.error(w),s(q=>({...q,isAuthenticating:!1,error:w}))}},[x,j,v,p]),R=d.useCallback(()=>{const b=t.provider;n.current+=1,i.current?.abort(),v(),r.current=!1,s(xe),b&&Fe.cliproxy.auth.cancel(b).catch(()=>{})},[t.provider,v]),k=d.useCallback(async b=>{if(!t.provider)return;const D=n.current,S=t.provider;s(f=>({...f,isSubmittingCallback:!0,error:null}));try{const f=await fetch(`/api/cliproxy/auth/${S}/submit-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({redirectUrl:b})});if(!x(D))return;const C=await Xe(f);if(!x(D))return;const l=C.success===!0,P=C.status==="wait",g=typeof C.account=="object"&&C.account!==null;if(f.ok&&P)s(N=>({...N,isSubmittingCallback:!1,error:null}));else if(f.ok&&l&&g)v(),p.invalidateQueries({queryKey:["cliproxy-auth"]}),p.invalidateQueries({queryKey:["cliproxy-accounts"]}),p.invalidateQueries({queryKey:["account-quota"]}),We(p),G.success(`${S} authentication successful`),s(xe);else{const N=typeof C.error=="string"?C.error:l?"Authenticated account could not be registered":"Callback submission failed";throw new Error(N)}}catch(f){if(!x(D))return;const C=f instanceof Error?f.message:"Failed to submit callback";G.error(C),s(l=>({...l,isSubmittingCallback:!1,error:C}))}},[x,t.provider,p,v]);return d.useMemo(()=>({...t,startAuth:m,cancelAuth:R,submitCallback:k}),[t,m,R,k])}function ct({className:t,compact:s=!1,showAcknowledgement:a=!1,acknowledgementPhrase:n=Ue,acknowledgementText:i="",onAcknowledgementTextChange:c,disabled:o=!1,showProxySettingsLink:u=!1}){const{t:r}=ce(),p=r("accountSafetyWarning.title"),x=r("accountSafetyWarning.subtitle"),v=r("accountSafetyWarning.firstLine"),j=r("accountSafetyWarning.secondLine"),m="https://github.com/kaitranntt/ccs/issues/509",R=r("accountSafetyWarning.issueLabel"),k=r("accountSafetyWarning.proxySettingsLabel");return s?e.jsx("section",{role:"alert",className:Q("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:p}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:x})]}),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:j})]})]}),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:[R,e.jsx(ve,{className:"h-3 w-3"})]}),u?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(H,{variant:"outline",className:"border-amber-500/40 text-[10px] text-amber-700 dark:text-amber-300",children:"High Risk"})]})]})}):e.jsxs("section",{role:"alert",className:Q("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:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x})]})]}),e.jsx(H,{variant:"outline",className:"border-amber-500/40 text-amber-700 dark:text-amber-300",children:"High Risk"})]}),e.jsxs("div",{className:"space-y-2 text-sm leading-relaxed",children:[e.jsx("p",{children:v}),e.jsx("p",{className:"font-medium text-amber-900 dark:text-amber-200",children:j}),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:[R,e.jsx(ve,{className:"h-3.5 w-3.5"})]}),u&&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"})]}),a&&c&&e.jsxs("div",{className:"rounded-lg border border-amber-500/25 bg-amber-500/5 p-2.5",children:[e.jsxs(Y,{htmlFor:"account-risk-ack-text",className:"text-xs leading-5",children:["Type exact phrase to continue:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono",children:n})]}),e.jsx(me,{id:"account-risk-ack-text",value:i,onChange:b=>c(b.target.value),placeholder:n,disabled:o,className:"mt-2 font-mono text-xs"})]})]})]})}function qa({className:t,value:s,onChange:a,disabled:n=!1}){const{t:i}=ce(),c=[s.reviewedIssue509,s.understandsBanRisk,s.acceptsFullResponsibility,s.typedPhrase.trim().replace(/\s+/g," ").toUpperCase()===Rt].filter(Boolean).length,o=c/4*100,u=r=>{a({...s,...r})};return e.jsxs("section",{role:"alert",className:Q("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(H,{variant:"outline",className:"border-rose-500/40 text-rose-700 dark:text-rose-300",children:i("antigravityChecklist.mandatory")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:i("antigravityChecklist.completion")}),e.jsx("span",{children:i("antigravityChecklist.stepsCount",{current:c})})]}),e.jsx(vs,{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:s.reviewedIssue509,onCheckedChange:r=>u({reviewedIssue509:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-reviewed-issue",className:"text-xs leading-5",children:"Step 1: I reviewed issue #509 and understand AGY OAuth can trigger account bans/suspensions."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ke,{id:"agy-step-understands-risk",checked:s.understandsBanRisk,onCheckedChange:r=>u({understandsBanRisk:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-understands-risk",className:"text-xs leading-5",children:"Step 2: I understand this OAuth action is my own decision and I accept the upstream risk."})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ke,{id:"agy-step-accept-responsibility",checked:s.acceptsFullResponsibility,onCheckedChange:r=>u({acceptsFullResponsibility:!!r}),disabled:n}),e.jsx(Y,{htmlFor:"agy-step-accept-responsibility",className:"text-xs leading-5",children:"Step 3: I accept full responsibility. CCS is not liable for suspension, bans, or access loss."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-amber-500/25 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-amber-800 dark:text-amber-200",children:[e.jsx(es,{className:"h-3.5 w-3.5"}),"Step 4: Type exact phrase to continue"]}),e.jsx(me,{value:s.typedPhrase,onChange:r=>u({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 Ha(t){return t.trim().replace(/\s+/g," ").toUpperCase()}function Ga({open:t,onClose:s,provider:a,displayName:n,catalog:i,isFirstAccount:c=!1}){const[o,u]=d.useState(""),[r,p]=d.useState(""),[x,v]=d.useState(!1),[j,m]=d.useState(null),[R,k]=d.useState(""),[b,D]=d.useState(Qe),[S,f]=d.useState(!1),[C,l]=d.useState(!1),[P,g]=d.useState(At),[N,w]=d.useState(""),[q,V]=d.useState(""),[M,E]=d.useState(St),{t:y}=ce(),K=d.useRef(!1),O=d.useRef(0),A=d.useRef(!1),I=Ka(),L=js(),B=a==="kiro",$=a==="agy"||a==="gemini",Z=a==="gemini"&&!S,ee=a==="agy"&&!S,se=$&&C,de=da(b),te=Ha(R)===Ue,ae=Jt(a),h=bs(P),F=B&&P==="idc",ie=B&&ys(P),De=B?Ns(P,M):void 0,Ge=B?Cs(P):void 0,Ve=B?De==="device_code":ae,re=I.isAuthenticating||L.isPending,Ie=o.trim(),Te=N.trim(),ke=q.trim(),Le=j||I.error,Re=d.useCallback(async()=>{const T=await fetch("/api/settings/auth/antigravity-risk");if(!T.ok)throw new Error("Failed to load power user mode setting");return(await T.json()).antigravityAckBypass===!0},[]),be=d.useCallback(async({pendingMessage:T=null,disabledMessage:ue=null}={})=>{const $e=++O.current;l(!0),T!==null&&m(T);try{const Oe=await Re();return O.current!==$e||(f(Oe),ue?m(Oe?null:ue):T!==null&&m(null)),Oe}catch{return O.current!==$e||(f(!1),m(ue??y("addAccountDialog.powerUserLoadFailed")),A.current||(A.current=!0,G.error(y("addAccountDialog.powerUserLoadFailed")))),!1}finally{O.current===$e&&l(!1)}},[Re,y]),Ne=()=>{u(""),p(""),v(!1),m(null),k(""),D(Qe),f(!1),l(!1),g(At),w(""),V(""),E(St),O.current+=1,A.current=!1,K.current=!1,s()};d.useEffect(()=>{t&&(k(""),D(Qe),m(null))},[a,t]),d.useEffect(()=>()=>{O.current+=1},[]),d.useEffect(()=>{if(!t||!$){O.current+=1,f(!1),l(!1);return}be()},[t,a,$,be]),d.useEffect(()=>{if(!t||a!=="agy"||!I.error||!S)return;const T=I.error.toLowerCase();(T.includes("agy_risk_ack_required")||T.includes("responsibility acknowledgement")||T.includes("responsibility checklist"))&&be({pendingMessage:y("addAccountDialog.powerUserLoading"),disabledMessage:y("addAccountDialog.powerUserUnavailableRetry")})},[I.error,t,S,a,be,y]),d.useEffect(()=>{!I.isAuthenticating&&!I.error&&I.provider===null&&t&&K.current&&(K.current=!1,(async()=>{try{const ue=await lt(a,void 0,i);ue.success&&ue.presetName&&c&&G.success(`Applied "${ue.presetName}" preset`)}catch{}Ne()})())},[I.isAuthenticating,I.error,I.provider]);const Ee=()=>{I.cancelAuth(),Ne()},Be=async()=>{I.authUrl&&(await navigator.clipboard.writeText(I.authUrl),v(!0),setTimeout(()=>v(!1),2e3))},ze=()=>{r.trim()&&I.submitCallback(r.trim())},_=()=>{if(se){m(y("addAccountDialog.powerUserLoading"));return}if(ee&&!de){m("Complete all Antigravity responsibility steps before authenticating this provider.");return}if(Z&&!te){m(`Type "${Ue}" to acknowledge the account safety warning before authenticating this provider.`);return}if(m(null),F&&!Te){m("IDC Start URL is required for Kiro IAM Identity Center login.");return}K.current=!0,I.startAuth(a,{nickname:Ie||void 0,kiroMethod:B?P:void 0,kiroIDCStartUrl:F?Te:void 0,kiroIDCRegion:F&&ke?ke:void 0,kiroIDCFlow:F?M:void 0,flowType:B?De:void 0,startEndpoint:B?Ge:void 0,riskAcknowledgement:ee?{version:ua,reviewedIssue509:b.reviewedIssue509,understandsBanRisk:b.understandsBanRisk,acceptsFullResponsibility:b.acceptsFullResponsibility,typedPhrase:b.typedPhrase}:void 0})},J=()=>{K.current=!0,L.mutate(void 0,{onSuccess:async()=>{const T=await lt("kiro",void 0,i);T.success&&T.presetName&&c&&G.success(`Applied "${T.presetName}" preset`),Ne()}})},oe=T=>{T||Ee()},W=I.isAuthenticating;return e.jsx(mt,{open:t,onOpenChange:oe,children:e.jsxs(pt,{className:"sm:max-w-md",onInteractOutside:T=>{W&&T.preventDefault()},children:[e.jsxs(xt,{children:[e.jsx(ht,{children:y("addAccountDialog.title",{displayName:n})}),e.jsx($t,{children:y(B?"addAccountDialog.descKiro":Ve?"addAccountDialog.descDeviceCode":"addAccountDialog.descOauth")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[ee&&!W&&e.jsx(qa,{value:b,onChange:T=>{D(T),m(null)},disabled:re}),$&&S&&!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(es,{className:"h-3.5 w-3.5"}),y("addAccountDialog.powerUserEnabled")]}),y("addAccountDialog.powerUserSkipped")]}),Z&&!W&&e.jsx(ct,{showAcknowledgement:!0,acknowledgementPhrase:Ue,acknowledgementText:R,onAcknowledgementTextChange:T=>{k(T),m(null)},disabled:re}),B&&!W&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-auth-method",children:y("addAccountDialog.authMethod")}),e.jsxs(Ye,{value:P,onValueChange:T=>{g(T),m(null)},children:[e.jsx(Ze,{id:"kiro-auth-method",children:e.jsx(et,{placeholder:y("addAccountDialog.selectKiroAuthMethod")})}),e.jsx(tt,{children:ws.map(T=>e.jsx(Ae,{value:T.id,children:T.label},T.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h.description}),ie&&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."]})]}),F&&!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(Y,{htmlFor:"kiro-idc-start-url",children:"IDC Start URL"}),e.jsx(me,{id:"kiro-idc-start-url",value:N,onChange:T=>{w(T.target.value),m(null)},placeholder:"https://d-xxx.awsapps.com/start",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Required for organization IAM Identity Center login."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-region",children:"IDC Region"}),e.jsx(me,{id:"kiro-idc-region",value:q,onChange:T=>{V(T.target.value),m(null)},placeholder:"us-east-1",disabled:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Leave blank to use the upstream default region."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"kiro-idc-flow",children:"IDC Flow"}),e.jsxs(Ye,{value:M,onValueChange:T=>{E(T),m(null)},children:[e.jsx(Ze,{id:"kiro-idc-flow",children:e.jsx(et,{placeholder:"Select IDC flow"})}),e.jsxs(tt,{children:[e.jsx(Ae,{value:"authcode",children:"Authorization Code"}),e.jsx(Ae,{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(Y,{htmlFor:"nickname",children:y("addAccountDialog.nicknameOptional")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(me,{id:"nickname",value:o,onChange:T=>{u(T.target.value),m(null)},placeholder:y("addAccountDialog.nicknamePlaceholder"),disabled:re,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y("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(ne,{className:"w-4 h-4 inline mr-2 animate-spin"}),y("addAccountDialog.waitingForAuth")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:I.isDeviceCodeFlow?y("addAccountDialog.deviceCodeHint"):ie?"Complete sign-in in your browser. If it does not return automatically, paste the final kiro:// callback URL below.":y("addAccountDialog.browserHint")})]}),I.authUrl&&!I.isDeviceCodeFlow&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{className:"text-xs",children:y("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:I.authUrl}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:Be,children:x?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3 h-3 mr-1"}),y("addAccountDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(Zt,{className:"w-3 h-3 mr-1"}),y("addAccountDialog.copy")]})}),e.jsxs(U,{variant:"outline",size:"sm",onClick:()=>{if(!I.authUrl)return;const T=window.open(I.authUrl,"_blank");(!T||T.closed||typeof T.closed>"u")&&G.warning(y("addAccountDialog.popupBlocked"),{duration:5e3})},children:[e.jsx(ve,{className:"w-3 h-3 mr-1"}),y("addAccountDialog.open")]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"callback-url",className:"text-xs",children:ie?"Browser did not return? Paste the final kiro:// callback URL:":y("addAccountDialog.redirectPasteLabel")}),e.jsx(me,{id:"callback-url",value:r,onChange:T=>p(T.target.value),placeholder:ie?"kiro://kiro.kiroAgent/authenticate-success?code=...&state=...":y("addAccountDialog.callbackPlaceholder"),className:"font-mono text-xs"}),e.jsx(U,{variant:"secondary",size:"sm",onClick:ze,disabled:!r.trim()||I.isSubmittingCallback,children:I.isSubmittingCallback?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-3 h-3 mr-1 animate-spin"}),y("addAccountDialog.submitting")]}):y("addAccountDialog.submitCallback")})]})]}),!I.authUrl&&!I.isDeviceCodeFlow&&e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:ie?"Preparing the Kiro sign-in URL. If it does not open automatically, it will appear here shortly.":y("addAccountDialog.preparingUrl")})]}),Le&&e.jsx("p",{className:"text-xs text-center text-destructive",children:Le}),L.isPending&&e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:[e.jsx(ne,{className:"w-4 h-4 inline mr-2 animate-spin"}),y("addAccountDialog.importingToken")]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(U,{variant:"ghost",onClick:Ee,children:y("addAccountDialog.cancel")}),B&&!W&&e.jsx(U,{variant:"outline",onClick:J,disabled:re,children:L.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),y("addAccountDialog.importing")]}):e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"w-4 h-4 mr-2"}),y("addAccountDialog.importFromIde")]})}),!W&&e.jsxs(U,{onClick:_,disabled:re||se||ee&&!de||Z&&!te,children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),y("addAccountDialog.authenticate")]})]})]})]})})}const Va=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Ba(t){const s=t?.env||{};return Va.filter(a=>!s[a]?.trim())}function za(t,s){const[a,n]=d.useState(null),[i,c]=d.useState(!1),o=dt(),{data:u,isLoading:r,refetch:p}=Kt({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`}}}),x=u?.settings,v=d.useMemo(()=>a!==null?a:x?JSON.stringify(x,null,2):`{
2
- "env": {}
3
- }`,[a,x]),j=d.useCallback(M=>{n(M)},[]),m=d.useMemo(()=>{try{return JSON.parse(v)}catch{return x||{env:{}}}},[v,x]),R=m?.env?.ANTHROPIC_MODEL,k=m?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,b=m?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,D=m?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,S=d.useMemo(()=>ks(m?.env||{}),[m]),f=d.useCallback((M,E)=>As(M,E,{supportsExtendedContext:y=>Sa(t,y,s)}),[s,t]),C=d.useCallback((M,E)=>{const y={...m?.env||{},[M]:E},K=Pt(M)?f(y,S):y;delete K.CCS_EXTENDED_CONTEXT;const O={...m,env:K};n(JSON.stringify(O,null,2))},[f,m,S]),l=d.useCallback(M=>{const E=m?.env||{},y=f(E,M);delete y.CCS_EXTENDED_CONTEXT;const K={...m,env:y};n(JSON.stringify(K,null,2))},[f,m]),P=d.useCallback(M=>{const E={...m?.env||{},...M},K=Object.keys(M).some(Pt)?f(E,S):E;delete K.CCS_EXTENDED_CONTEXT;const O={...m,env:K};n(JSON.stringify(O,null,2))},[f,m,S]),g=d.useMemo(()=>{try{return JSON.parse(v),!0}catch{return!1}},[v]),N=d.useMemo(()=>a===null?!1:a!==JSON.stringify(x,null,2),[a,x]),w=d.useMemo(()=>Ba(m),[m]),q=us({mutationFn:async()=>{const M=JSON.parse(v),E=await fetch(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:M,expectedMtime:u?.mtime})});if(E.status===409)throw new Error("CONFLICT");if(!E.ok)throw new Error("Failed to save");return E.json()},onSuccess:M=>{o.invalidateQueries({queryKey:["settings",t]}),n(null),M?.warning?G.success("Settings saved",{description:M.warning}):G.success("Settings saved")},onError:M=>{M.message==="CONFLICT"?c(!0):G.error(M.message)}}),V=async M=>{c(!1),M?(await p(),q.mutate()):n(null)};return{data:u,isLoading:r,refetch:p,rawJsonContent:v,rawJsonEdits:a,isRawJsonValid:g,hasChanges:N,currentSettings:m,currentModel:R,opusModel:k,sonnetModel:b,haikuModel:D,extendedContextEnabled:S,toggleExtendedContext:l,handleRawJsonChange:j,updateEnvValue:C,updateEnvValues:P,saveMutation:{mutate:()=>q.mutate(),isPending:q.isPending},conflictDialog:i,setConflictDialog:c,handleConflictResolve:V,missingRequiredFields:w}}const $a=/-(medium|high|xhigh)$/i;function Qa(t){if(!t)return;const s=t.trim().match($a);if(s?.[1])return s[1].toLowerCase()}function Ja(t){if(!t)return null;const s=Qa(t);return s?{label:`Pinned ${s}`,explicit:!0}:{label:"Auto effort",explicit:!1}}function Wa({label:t}){return e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:t})}function _e({modelId:t}){const s=Ja(t);return s?e.jsx(H,{variant:s.explicit?"secondary":"outline",className:"text-[9px] h-4 px-1 uppercase",children:s.label}):null}function _t(t,s){if(!t)return"";if(!s?.prefix)return t;const a=`${s.prefix}/`;return t.startsWith(a)?t.slice(a.length):t}function he(t,s){return s?.recommendedModelId??t}function ge({label:t,description:s,value:a,onChange:n,catalog:i,allModels:c,routing:o,disabled:u}){const{t:r}=ce(),p=i?.provider==="codex",x=d.useMemo(()=>Ct(i,c),[c,i]),v=d.useMemo(()=>Aa(i?.provider??"",i,c),[c,i]),j=new Set(x.map(l=>l.id)),m=d.useMemo(()=>new Map((o?.models??[]).map(l=>[l.modelId.toLowerCase(),l])),[o]),R=d.useMemo(()=>new Set(x.map(l=>he(l.id,m.get(l.id.toLowerCase())))),[x,m]),k=d.useMemo(()=>m.get(_t(a,o).toLowerCase()),[o,m,a]),b=x.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(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:m.get(l.id.toLowerCase())?.prefix}):null,p&&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(Wa,{label:r("providerModelSelector.paid")}),m.get(l.id.toLowerCase())?.unprefixedStatus==="shadowed"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"Shadowed"}):null,m.get(l.id.toLowerCase())?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"Prefix only"}):null,p&&e.jsx(_e,{modelId:l.id})]})})),D=v.filter(l=>!j.has(l.id)).filter(l=>!R.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(H,{variant:"secondary",className:"text-[9px] h-4 px-1 uppercase",children:m.get(l.id.toLowerCase())?.prefix}):null,p&&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(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"Shadowed"}):null,m.get(l.id.toLowerCase())?.unprefixedStatus==="prefix-only"?e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"Prefix only"}):null,p&&e.jsx(_e,{modelId:l.id})]})})),S=!!a&&!b.some(l=>l.value===a)&&!D.some(l=>l.value===a),f=a?{value:a,groupKey:"current",searchText:a,triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:a}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"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:a}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:"Current"})]})}:null,C=b.length+D.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}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx(pa,{value:a||void 0,onChange:n,disabled:u,placeholder:r("providerModelSelector.selectModel"),searchPlaceholder:r("searchableSelect.searchModels"),emptyText:r(C?"searchableSelect.noResults":"providerModelSelector.noModelsAvailable"),triggerClassName:"h-9",groups:[...S&&f?[{key:"current",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Current value"})}]:[],{key:"recommended",label:e.jsx("span",{className:"text-xs text-primary",children:r("providerModelSelector.recommended")})},...D.length>0?[{key:"all",label:e.jsx("span",{className:"text-xs text-muted-foreground",children:r("providerModelSelector.allModelsCount",{count:D.length})})}]:[]],options:[...S&&f?[f]:[],...b,...D]}),k?e.jsxs("div",{className:Q("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?"Preferred pinned model:":"Pinned route status:"," ",e.jsx("code",{children:k.pinnedAvailable?k.recommendedModelId:k.pinnedModelId})]}),e.jsx("p",{className:"mt-1 leading-5",children:k.summary})]}):null,a&&!k&&_t(a,o)!==a?e.jsxs("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:["Pinned model is not currently advertised by the proxy: ",e.jsx("code",{children:a})]}):null]})}function Ft(t,s){const a=n=>s?.models.find(c=>c.modelId.toLowerCase()===n.toLowerCase())?.recommendedModelId??n;return{default:a(t.default),opus:a(t.opus),sonnet:a(t.sonnet),haiku:a(t.haiku)}}function Xa({open:t,onClose:s,currentValues:a,onApply:n,onSave:i,isSaving:c,catalog:o,allModels:u,routing:r}){const{t:p}=ce(),[x,v]=d.useState(Ft(a,r)),[j,m]=d.useState(""),R=k=>{k?(v(Ft(a,r)),m("")):s()};return e.jsx(mt,{open:t,onOpenChange:R,children:e.jsxs(pt,{className:"sm:max-w-md",children:[e.jsx(xt,{children:e.jsxs(ht,{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),p("customPresetDialog.title")]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Y,{htmlFor:"preset-name",children:p("customPresetDialog.presetNameOptional")}),e.jsx(me,{id:"preset-name",value:j,onChange:k=>m(k.target.value),placeholder:p("customPresetDialog.presetNamePlaceholder"),className:"text-sm"})]}),e.jsx(yt,{}),o?.provider==="codex"&&e.jsxs("p",{className:"text-[11px] text-muted-foreground rounded-md border bg-muted/30 px-2.5 py-2",children:[p("customPresetDialog.codexTipPrefix")," ",e.jsx("code",{children:"-medium"}),", ",e.jsx("code",{children:"-high"}),", and"," ",e.jsx("code",{children:"-xhigh"})," ",p("customPresetDialog.codexTipSuffix")]}),e.jsx(ge,{label:p("customPresetDialog.defaultModel"),description:p("customPresetDialog.defaultModelDesc"),value:x.default,onChange:k=>v({...x,default:k}),catalog:o,allModels:u,routing:r}),e.jsx(ge,{label:p("customPresetDialog.opusModel"),description:p("customPresetDialog.opusModelDesc"),value:x.opus,onChange:k=>v({...x,opus:k}),catalog:o,allModels:u,routing:r}),e.jsx(ge,{label:p("customPresetDialog.sonnetModel"),description:p("customPresetDialog.sonnetModelDesc"),value:x.sonnet,onChange:k=>v({...x,sonnet:k}),catalog:o,allModels:u,routing:r}),e.jsx(ge,{label:p("customPresetDialog.haikuModel"),description:p("customPresetDialog.haikuModelDesc"),value:x.haiku,onChange:k=>v({...x,haiku:k}),catalog:o,allModels:u,routing:r})]}),e.jsxs(Ss,{className:"gap-2 sm:gap-0",children:[e.jsx(U,{variant:"outline",onClick:s,children:p("customPresetDialog.cancel")}),i&&e.jsxs(U,{variant:"secondary",onClick:()=>i(x,j||void 0),disabled:c||!j.trim(),children:[c?e.jsx(ne,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(bt,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.savePreset")]}),e.jsxs(U,{onClick:()=>n(x,j||void 0),children:[e.jsx(Me,{className:"w-4 h-4 mr-1"}),p("customPresetDialog.applyPreset")]})]})]})})}function fe({label:t,command:s}){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:s}),e.jsx(Wt,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function Ya({provider:t,displayName:s,defaultTarget:a,data:n,authStatus:i,supportsModelConfig:c=!1}){const o=a||"claude",u=o==="droid",r=t==="codex",p=o==="claude"?`ccs ${t}`:`ccs ${t} --target claude`,x=`${p} --config`,v=`${p} --auth --add`,j=`${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(ts,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:s})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(Wt,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),i.authenticated?e.jsxs(H,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(na,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(H,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Default Target"}),e.jsx("span",{className:"font-mono",children:o})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(fe,{label:"Run with prompt",command:`ccs ${t} "your prompt"`}),r&&e.jsxs(e.Fragment,{children:[e.jsx(fe,{label:"Run on native Codex (shortcut)",command:'ccsxp "your prompt"'}),e.jsx(fe,{label:"Run on native Codex (--target)",command:`ccs ${t} --target codex "your prompt"`})]}),e.jsx(fe,{label:u?"Droid alias (explicit)":"Run on Droid",command:`ccs-droid ${t} "your prompt"`}),e.jsx(fe,{label:u?"Override to Claude":"Run on Droid (--target)",command:`ccs ${t} --target ${u?"claude":"droid"} "your prompt"`}),c&&e.jsx(fe,{label:o==="claude"?"Change model":"Change model (Claude target)",command:x}),e.jsx(fe,{label:o==="claude"?"Add account":"Add account (Claude target)",command:v}),e.jsx(fe,{label:o==="claude"?"List accounts":"List accounts (Claude target)",command:j}),o!=="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 Za({displayName:t,logoProvider:s,provider:a,data:n,isLoading:i,hasChanges:c,isRawJsonValid:o,isSaving:u,isRemoteMode:r,port:p,onRefetch:x,onSave:v}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(gt,{provider:s||a,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:t}),r&&e.jsxs(H,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(ss,{className:"w-3 h-3"}),"Remote"]}),p&&e.jsxs(H,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(ia,{className:"w-3 h-3"}),":",p]}),!r&&n?.path&&e.jsx(H,{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:["Last modified: ",new Date(n.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:x,disabled:i,children:e.jsx(jt,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(U,{size:"sm",onClick:v,disabled:u||!c||!o,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function en({models:t,provider:s,enabled:a,onToggle:n,disabled:i,className:c}){if(t.length===0)return null;const o=t.some(p=>Mt(p.id)),u=t.some(p=>!Mt(p.id));let r="Compatible mappings stay on standard context unless you turn this on.";return o&&u?r="Gemini-compatible mappings can use 1M automatically. Claude mappings stay plain unless you turn this on.":o&&(r="Gemini-compatible mappings can use 1M by default. Turn this off to keep standard context."),e.jsxs("div",{className:Q("rounded-lg border p-3 space-y-2",a?"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(Me,{className:Q("w-4 h-4",a?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"text-sm font-medium",children:"Extended Context"}),e.jsx(H,{variant:a?"default":"secondary",className:"text-[10px] h-5 px-1.5",children:"1M tokens"})]}),e.jsx(Xt,{checked:a,onCheckedChange:n,disabled:i})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[e.jsx(ts,{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:r}),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 tn(t,s){const a=t.presetMapping||{default:t.id,opus:t.id,sonnet:t.id,haiku:t.id};return{ANTHROPIC_MODEL:s(a.default),ANTHROPIC_DEFAULT_OPUS_MODEL:s(a.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:s(a.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:s(a.haiku)}}function sn({catalog:t,savedPresets:s,currentModel:a,opusModel:n,sonnetModel:i,haikuModel:c,providerModels:o,routing:u,provider:r,extendedContextEnabled:p,onExtendedContextToggle:x,onApplyPreset:v,onUpdateEnvValue:j,onOpenCustomPreset:m,onDeletePreset:R,isDeletePending:k}){const b=(u?.models??[]).some(g=>g.pinnedAvailable),D=d.useMemo(()=>new Map((u?.models??[]).map(g=>[g.modelId.toLowerCase(),g])),[u]),S=g=>D.get(g.toLowerCase())?.recommendedModelId??g,f=d.useMemo(()=>{if(!t)return[];const g=[a,n,i,c].filter(w=>!!w).map(w=>Ps(w));return[...new Set(g)].map(w=>ds(t.provider,w,t)).filter(w=>!!w?.extendedContext)},[t,a,n,i,c]),C=d.useMemo(()=>Ct(t,o),[t,o]),l=d.useMemo(()=>{const g=C.filter(w=>w.presetMapping);return g.length===0?[]:g.some(w=>w.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(w=>w.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(w=>w.tier==="paid")}].filter(w=>w.models.length>0):[{key:"default",models:g.slice(0,4)}]},[C]),P=l.length>0||s.length>0;return e.jsxs(e.Fragment,{children:[P&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"space-y-4",children:[l.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(H,{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(N=>e.jsxs(U,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>v(tn(N,S)),children:[e.jsx(Me,{className:`w-3 h-3 ${"iconClassName"in g?g.iconClassName:""}`}),N.name]},N.id))})]},g.key)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.map(g=>e.jsxs("div",{className:"group relative",children:[e.jsxs(U,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{v({ANTHROPIC_MODEL:S(g.default),ANTHROPIC_DEFAULT_OPUS_MODEL:S(g.opus),ANTHROPIC_DEFAULT_SONNET_MODEL:S(g.sonnet),ANTHROPIC_DEFAULT_HAIKU_MODEL:S(g.haiku)})},children:[e.jsx(bt,{className:"w-3 h-3 fill-current"}),g.name]}),e.jsx(U,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:N=>{N.stopPropagation(),R(g.name)},disabled:k,children:e.jsx(Nt,{className:"w-3 h-3"})})]},g.name)),e.jsxs(U,{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(as,{className:"w-3 h-3"}),"Custom"]})]})]})]}),e.jsx(yt,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),u?e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3 rounded-md border bg-muted/30 px-2.5 py-2",children:b?e.jsxs(e.Fragment,{children:["Preferred pinned model names use the ",e.jsxs("code",{children:[u.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:[u.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(ge,{label:"Default Model",description:"Used when no specific tier is requested",value:a,onChange:g=>j("ANTHROPIC_MODEL",g),catalog:t,allModels:o,routing:u}),f.length>0&&x&&e.jsx(en,{models:f,provider:r,enabled:p??!1,onToggle:x}),e.jsx(ge,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:n,onChange:g=>j("ANTHROPIC_DEFAULT_OPUS_MODEL",g),catalog:t,allModels:o,routing:u}),e.jsx(ge,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:g=>j("ANTHROPIC_DEFAULT_SONNET_MODEL",g),catalog:t,allModels:o,routing:u}),e.jsx(ge,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:g=>j("ANTHROPIC_DEFAULT_HAIKU_MODEL",g),catalog:t,allModels:o,routing:u})]})]})]})}function an(t,s){return t?e.jsx(at,{children:e.jsxs(nt,{children:[e.jsx(it,{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:Q("font-mono max-w-[180px] truncate",s&&ut),title:t,children:t})]})}),e.jsx(rt,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(at,{children:e.jsxs(nt,{children:[e.jsx(it,{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:"Project ID: N/A"})]})}),e.jsx(rt,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}function nn({account:t,onSetDefault:s,onRemove:a,onPauseToggle:n,isRemoving:i,isPausingAccount:c,privacyMode:o,showQuota:u,selectable:r,selected:p,onSelectChange:x}){const v=t.provider.toLowerCase(),{data:j}=Ms(u),{data:m,isLoading:R}=Ds(v,t.id,u),k=Is(j,t)?.lastUsedAt,b=r||n?e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r&&e.jsx("button",{type:"button",onClick:()=>x?.(!p),className:Q("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",p?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":p?"Deselect account":"Select account",children:p&&e.jsx(je,{className:"w-3 h-3"})}),n&&e.jsx(at,{children:e.jsxs(nt,{children:[e.jsx(it,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>n(!t.paused),disabled:c,children:c?e.jsx(ne,{className:"w-4 h-4 animate-spin"}):t.paused?e.jsx(ns,{className:"w-4 h-4 text-emerald-500"}):e.jsx(is,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(rt,{side:"top",children:t.paused?"Resume account":"Pause account"})]})})]}):void 0,D=e.jsxs(Ts,{children:[e.jsx(Ls,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(oa,{className:"w-4 h-4"})})}),e.jsxs(Rs,{align:"end",children:[!t.isDefault&&e.jsxs(Dt,{onClick:s,children:[e.jsx(bt,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Dt,{className:"text-destructive focus:text-destructive",onClick:a,disabled:i,children:[e.jsx(rs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]});return e.jsx("div",{className:Q("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",p&&"ring-2 ring-primary/50 bg-primary/5"),children:e.jsx(Es,{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:u,quota:m,quotaLoading:R,runtimeLastUsed:k,beforeIdentity:b,headerEnd:D,bodySlot:t.provider==="agy"?an(t.projectId,o):null,quotaInsetClassName:"pl-11"})})}function rn({selectedCount:t,onPauseSelected:s,onResumeSelected:a,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(U,{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(U,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:s,disabled:o,children:[i?e.jsx(ne,{className:"w-3 h-3 animate-spin"}):e.jsx(is,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(U,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:o,children:[c?e.jsx(ne,{className:"w-3 h-3 animate-spin"}):e.jsx(ns,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function on({accounts:t,onAddAccount:s,onSetDefault:a,onRemoveAccount:n,onPauseToggle:i,onSoloMode:c,onBulkPause:o,onBulkResume:u,isRemovingAccount:r,isPausingAccount:p,isSoloingAccount:x,isBulkPausing:v,isBulkResuming:j,privacyMode:m,showQuota:R,isKiro:k,kiroNoIncognito:b,onKiroNoIncognitoChange:D,kiroSettingsLoading:S}){const[f,C]=d.useState(new Set),l=d.useMemo(()=>new Set(t.map(A=>A.id)),[t]),P=d.useMemo(()=>new Set([...f].filter(A=>l.has(A))),[f,l]),g=!!(o&&u),N=P.size,w=t.length>0&&P.size===t.length,q=P.size>0&&P.size<t.length,V=d.useCallback(A=>{C(I=>{const L=new Set(I);return L.has(A)?L.delete(A):L.add(A),L})},[]),M=d.useCallback(()=>{C(new Set(t.map(A=>A.id)))},[t]),E=d.useCallback(()=>{C(new Set)},[]),y=d.useCallback(()=>{w?E():M()},[w,M,E]),K=d.useCallback(()=>{o&&P.size>0&&(o(Array.from(P)),C(new Set))},[o,P]),O=d.useCallback(()=>{u&&P.size>0&&(u(Array.from(P)),C(new Set))},[u,P]);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:w,onCheckedChange:y,"aria-label":"Select all accounts",className:q?"data-[state=checked]:bg-primary/50":"",...q?{"data-state":"indeterminate"}:{}}),e.jsx(Se,{className:"w-4 h-4"}),"Accounts",t.length>0&&e.jsx(H,{variant:"secondary",className:"text-xs",children:t.length})]}),e.jsxs(U,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:s,children:[e.jsx(as,{className:"w-3 h-3"}),"Add"]})]}),g&&N>0&&e.jsx(rn,{selectedCount:N,onPauseSelected:K,onResumeSelected:O,onClearSelection:E,isPausing:!!v,isResuming:!!j}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(A=>e.jsx(nn,{account:A,onSetDefault:()=>a(A.id),onRemove:()=>n(A.id),onPauseToggle:i?I=>i(A.id,I):void 0,onSoloMode:c?()=>c(A.id):void 0,isRemoving:r,isPausingAccount:p,isSoloingAccount:x,privacyMode:m,showQuota:R,selectable:g,selected:P.has(A.id),onSelectChange:()=>V(A.id)},A.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(Se,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),k&&D&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ss,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(Xt,{checked:!b,onCheckedChange:A=>D(!A),disabled:S,className:"scale-90"})]})})]})}function ln({provider:t,catalog:s,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:o,providerModels:u,routing:r,extendedContextEnabled:p,onExtendedContextToggle:x,onApplyPreset:v,onUpdateEnvValue:j,onOpenCustomPreset:m,onDeletePreset:R,isDeletePending:k,accounts:b,onAddAccount:D,onSetDefault:S,onRemoveAccount:f,onPauseToggle:C,onSoloMode:l,onBulkPause:P,onBulkResume:g,isRemovingAccount:N,isPausingAccount:w,isSoloingAccount:q,isBulkPausing:V,isBulkResuming:M,privacyMode:E,isRemoteMode:y}){const K=t.toLowerCase(),O=(Os.includes(K)||["anthropic","antigravity","gemini-cli","copilot","github-copilot"].includes(K))&&!y,A=t==="kiro",[I,L]=d.useState(!0),[B,$]=d.useState(!0),[Z,ee]=d.useState(!1),se=d.useCallback(async()=>{if(A)try{$(!0);const ae=(await Fe.config.get()).cliproxy;L(ae?.kiro_no_incognito??!0)}catch{L(!0)}finally{$(!1)}},[A]),de=d.useCallback(async te=>{L(te),ee(!0);try{const ae=await Fe.config.get(),h=ae.cliproxy??{};await Fe.config.update({...ae,cliproxy:{...h,kiro_no_incognito:te}})}catch{L(!te)}finally{ee(!1)}},[]);return d.useEffect(()=>{se()},[se]),e.jsx(ft,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(sn,{catalog:s,savedPresets:a,currentModel:n,opusModel:i,sonnetModel:c,haikuModel:o,providerModels:u,routing:r,provider:t,extendedContextEnabled:p,onExtendedContextToggle:x,onApplyPreset:v,onUpdateEnvValue:j,onOpenCustomPreset:m,onDeletePreset:R,isDeletePending:k}),e.jsx(yt,{}),e.jsx(on,{accounts:b,onAddAccount:D,onSetDefault:S,onRemoveAccount:f,onPauseToggle:C,onSoloMode:l,onBulkPause:P,onBulkResume:g,isRemovingAccount:N,isPausingAccount:w,isSoloingAccount:q,isBulkPausing:V,isBulkResuming:M,privacyMode:E,showQuota:O,isKiro:A,kiroNoIncognito:I,onKiroNoIncognitoChange:de,kiroSettingsLoading:B||Z})]})})}function Ut({provider:t,displayName:s,authStatus:a,catalog:n,routing:i,logoProvider:c,baseProvider:o,isRemoteMode:u,port:r,defaultTarget:p,topNotice:x,onAddAccount:v,onSetDefault:j,onRemoveAccount:m,onPauseToggle:R,onSoloMode:k,onBulkPause:b,onBulkResume:D,isRemovingAccount:S,isPausingAccount:f,isSoloingAccount:C,isBulkPausing:l,isBulkResuming:P}){const[g,N]=d.useState(!1),{privacyMode:w}=zt(),{data:q}=_s(),{data:V}=Fs(t),M=Us(),E=Ks(),y=o||t,K=y.toLowerCase()==="agy",O=d.useMemo(()=>{const _=V?.presets||[];return K?_.filter(J=>!le(J.default)&&!le(J.opus)&&!le(J.sonnet)&&!le(J.haiku)):_},[K,V?.presets]),A=d.useMemo(()=>{if(!q?.models)return[];const J={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"],kimi:["kimi","moonshot"]}[y.toLowerCase()]||[y.toLowerCase()];return q.models.filter(oe=>J.some(W=>oe.owned_by.toLowerCase().includes(W))?K?!le(oe.id):!0:!1)},[K,q,y]),I=(o||t).toLowerCase(),{data:L,isLoading:B,refetch:$,rawJsonContent:Z,rawJsonEdits:ee,isRawJsonValid:se,hasChanges:de,currentModel:te,opusModel:ae,sonnetModel:h,haikuModel:F,extendedContextEnabled:ie,toggleExtendedContext:De,handleRawJsonChange:Ge,updateEnvValue:Ve,updateEnvValues:re,saveMutation:Ie,conflictDialog:Te,handleConflictResolve:ke,missingRequiredFields:Le}=za(t,n),Re=d.useMemo(()=>(a.accounts||[]).map(_=>({..._,provider:_.provider||o||t})),[a.accounts,o,t]),{data:be}=Kt({queryKey:["auth-tokens-raw"],queryFn:async()=>{const _=await fetch("/api/settings/auth/tokens/raw");return _.ok?_.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),Ne=be?.apiKey?.value??"ccs-internal-managed",Ee=_=>{if(K&&[_.ANTHROPIC_MODEL,_.ANTHROPIC_DEFAULT_OPUS_MODEL,_.ANTHROPIC_DEFAULT_SONNET_MODEL,_.ANTHROPIC_DEFAULT_HAIKU_MODEL].some(oe=>typeof oe=="string"&&le(oe))){G.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??ot}/api/provider/${I}`,ANTHROPIC_AUTH_TOKEN:Ne,..._}),G.success(`Applied "${_.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},Be=(_,J)=>{if(K&&[_.default,_.opus,_.sonnet,_.haiku].some(W=>le(W))){G.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}re({ANTHROPIC_BASE_URL:`http://127.0.0.1:${r??ot}/api/provider/${I}`,ANTHROPIC_AUTH_TOKEN:Ne,ANTHROPIC_MODEL:_.default,ANTHROPIC_DEFAULT_OPUS_MODEL:_.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:_.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:_.haiku}),G.success(`Applied ${J?`"${J}"`:"custom"} preset`),N(!1)},ze=(_,J)=>{if(!J){G.error(Qt.t("commonToast.enterPresetName"));return}if(K&&[_.default,_.opus,_.sonnet,_.haiku].some(oe=>le(oe))){G.error("Antigravity denylist: Claude Opus 4.5 and Claude Sonnet 4.5 are deprecated.");return}M.mutate({profile:t,data:{name:J,..._}}),N(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Za,{provider:t,displayName:s,logoProvider:c,data:L,isLoading:B,hasChanges:de,isRawJsonValid:se,isSaving:Ie.isPending,isRemoteMode:u,port:r,onRefetch:$,onSave:()=>Ie.mutate()}),x?e.jsx("div",{className:"border-b bg-muted/10 px-4 py-3",children:x}):null,B?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ne,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"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(qs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Hs,{className:"w-full",children:[e.jsx(It,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(It,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Tt,{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:O,currentModel:te,opusModel:ae,sonnetModel:h,haikuModel:F,providerModels:A,routing:i,extendedContextEnabled:ie,onExtendedContextToggle:De,onApplyPreset:Ee,onUpdateEnvValue:Ve,onOpenCustomPreset:()=>N(!0),onDeletePreset:_=>E.mutate({profile:t,name:_}),isDeletePending:E.isPending,accounts:Re,onAddAccount:v,onSetDefault:j,onRemoveAccount:m,onPauseToggle:R,onSoloMode:k,onBulkPause:b,onBulkResume:D,isRemovingAccount:S,isPausingAccount:f,isSoloingAccount:C,isBulkPausing:l,isBulkResuming:P,privacyMode:w,isRemoteMode:u})}),e.jsx(Tt,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Ya,{provider:t,displayName:s,defaultTarget:p,data:L,authStatus:a,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.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Gs,{rawJsonContent:Z,isRawJsonValid:se,rawJsonEdits:ee,onRawJsonChange:Ge,profileEnv:L?.settings?.env,missingRequiredFields:Le})]})]}),e.jsx(ma,{open:Te,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(Xa,{open:g,onClose:()=>N(!1),currentValues:{default:te||"",opus:ae||"",sonnet:h||"",haiku:F||""},onApply:Be,onSave:ze,isSaving:M.isPending,catalog:n,allModels:A,routing:i})]})}function cn({status:t,isSelected:s,onSelect:a}){const{t:n}=ce(),i=t.accounts?.length||0;return e.jsxs("button",{className:Q("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",s?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(gt,{provider:t.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.displayName}),i>0&&e.jsx(H,{variant:"secondary",className:"text-[10px] h-4 px-1",children:i})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:t.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(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(Nt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("cliproxyPage.notConnected")})]})})]})]})}function dn({variant:t,parentAuth:s,isSelected:a,onSelect:n,onDelete:i,isDeleting:c}){const{t:o}=ce(),u=()=>{n()};return e.jsxs("div",{role:"button",tabIndex:0,className:Q("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:u,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),u())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(gt,{provider:t.provider,size:"sm"}),e.jsx(os,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1",children:o("cliproxyPage.variant")}),e.jsx(H,{variant:"outline",className:"text-[9px] h-4 px-1 uppercase",children:t.target||"claude"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s?.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(Nt,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o("cliproxyPage.parentNotConnected")})]})})]}),e.jsx(U,{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(rs,{className:"w-3 h-3"})})]})}function un({onSetup:t}){const{t:s}=ce();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(Me,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:s("cliproxyPage.emptyTitle")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:s("cliproxyPage.emptyDesc")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:[s("cliproxyPage.emptyControlPanelPrefix")," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:s("cliproxyPage.controlPanel")}),"."]}),e.jsxs(U,{onClick:t,className:"gap-2",children:[e.jsx(Pe,{className:"w-4 h-4"}),s("cliproxyPage.quickSetup")]})]})})}function Mn(){const{t}=ce(),s=dt(),{data:a,isLoading:n}=Vt(),{data:i,isFetching:c}=Vs(),{data:o}=Bt(),{data:u}=Bs(),r=zs(),p=$s(),x=Qs(),v=Js(),j=Ws(),m=Xs(),R=Ys(),k=Zs(),[b,D]=d.useState(()=>{if(typeof window<"u"){const F=new URLSearchParams(window.location.search).get("provider")?.trim().toLowerCase();return F&&st(F)?F:localStorage.getItem("cliproxy-selected-provider")}return null}),[S,f]=d.useState(null),[C,l]=d.useState(!1),[P,g]=d.useState(()=>{if(typeof window>"u")return null;const h=new URLSearchParams(window.location.search),F=h.get("provider")?.trim().toLowerCase();return h.get("action")!=="auth"||!F||!st(F)?null:{provider:F,displayName:ea(F),isFirstAccount:!1}}),N=d.useMemo(()=>a?.authStatus||[],[a?.authStatus]),w=a?.source==="remote",q=d.useMemo(()=>i?.variants||[],[i?.variants]),V=d.useMemo(()=>wt(o?.catalogs),[o?.catalogs]),M=o?.routing??{},E=!!o,y=h=>{D(h),h&&localStorage.setItem("cliproxy-selected-provider",h)},K=d.useMemo(()=>S?null:b&&N.some(h=>h.provider===b)?b:N.length>0&&(N.find(F=>(F.accounts?.length||0)>0)?.provider||N[0]?.provider)||null,[b,S,N]),O=N.find(h=>h.provider===K),A=q.find(h=>h.name===S),I=A?N.find(h=>h.provider===A.provider):void 0,L=(A?.provider||O?.provider||"").toLowerCase().trim(),B=L==="gemini"||L==="agy",$=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]}),s.invalidateQueries({queryKey:["cliproxy-catalog"]}),s.invalidateQueries({queryKey:["cliproxy-models"]})},Z=(h,F,ie)=>{x.isPending||v.isPending||(ie?x.mutate({provider:h,accountId:F}):v.mutate({provider:h,accountId:F}))},ee=(h,F)=>{j.isPending||j.mutate({provider:h,accountId:F})},se=(h,F)=>{m.isPending||m.mutate({provider:h,accountIds:F})},de=(h,F)=>{R.isPending||R.mutate({provider:h,accountIds:F})},te=h=>{y(h),f(null)},ae=h=>{f(h),y(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(Me,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:u?.backendLabel??"CLIProxy"})]}),e.jsx(U,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:$,disabled:c,children:e.jsx(jt,{className:Q("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t("cliproxyPage.accountManagement")}),e.jsxs(U,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>l(!0),children:[e.jsx(Pe,{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(h=>e.jsx(ta,{className:"h-14 w-full rounded-lg"},h))}):e.jsx("div",{className:"space-y-1",children:N.map(h=>e.jsx(cn,{status:h,isSelected:K===h.provider,onSelect:()=>te(h.provider)},h.provider))}),q.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(os,{className:"w-3 h-3"}),t("cliproxyPage.variants")]}),e.jsx("div",{className:"space-y-1",children:q.map(h=>e.jsx(dn,{variant:h,parentAuth:N.find(F=>F.provider===h.provider),isSelected:S===h.name,onSelect:()=>ae(h.name),onDelete:()=>k.mutate(h.name),isDeleting:k.isPending},h.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(xa,{})}),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:N.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:N.filter(h=>h.authenticated).length})]})]})})]}),e.jsx("div",{className:"flex-1 flex min-w-0 flex-col overflow-hidden bg-background",children:A&&I?e.jsx(e.Fragment,{children:e.jsx(Ut,{provider:A.name,displayName:t("cliproxyPage.variantDisplay",{name:A.name,provider:A.provider}),authStatus:I,catalog:V[A.provider],routing:M[A.provider],logoProvider:A.provider,baseProvider:A.provider,defaultTarget:A.target,isRemoteMode:w,port:A.port,topNotice:B?e.jsx(ct,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>g({provider:A.provider,displayName:I.displayName,isFirstAccount:(I.accounts?.length||0)===0}),onSetDefault:h=>r.mutate({provider:A.provider,accountId:h}),onRemoveAccount:h=>p.mutate({provider:A.provider,accountId:h}),onPauseToggle:(h,F)=>Z(A.provider,h,F),onSoloMode:h=>ee(A.provider,h),onBulkPause:h=>se(A.provider,h),onBulkResume:h=>de(A.provider,h),isRemovingAccount:p.isPending,isPausingAccount:x.isPending||v.isPending,isSoloingAccount:j.isPending,isBulkPausing:m.isPending,isBulkResuming:R.isPending})}):O?e.jsx(e.Fragment,{children:e.jsx(Ut,{provider:O.provider,displayName:O.displayName,authStatus:O,catalog:V[O.provider],routing:M[O.provider],isRemoteMode:w,topNotice:B?e.jsx(ct,{compact:!0,showProxySettingsLink:!0}):void 0,onAddAccount:()=>g({provider:O.provider,displayName:O.displayName,isFirstAccount:(O.accounts?.length||0)===0}),onSetDefault:h=>r.mutate({provider:O.provider,accountId:h}),onRemoveAccount:h=>p.mutate({provider:O.provider,accountId:h}),onPauseToggle:(h,F)=>Z(O.provider,h,F),onSoloMode:h=>ee(O.provider,h),onBulkPause:h=>se(O.provider,h),onBulkResume:h=>de(O.provider,h),isRemovingAccount:p.isPending,isPausingAccount:x.isPending||v.isPending,isSoloingAccount:j.isPending,isBulkPausing:m.isPending,isBulkResuming:R.isPending})}):e.jsx(un,{onSetup:()=>l(!0)})}),e.jsx(Oa,{open:C,onClose:()=>l(!1)}),e.jsx(Ga,{open:P!==null,onClose:()=>g(null),provider:P?.provider||"",displayName:P?.displayName||"",catalog:E&&P?.provider?V[P.provider]:void 0,isFirstAccount:P?.isFirstAccount||!1})]})}export{Mn as CliproxyPage};
@@ -1,27 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as W}from"./notifications-B2HqRBj7.js";import{C as D,j as M,k as I,B as y,b as F,d as w,aF as B,r as _,s as E,t as P,v as O,w as v,I as C,n as xe,bb as J,bc as Te,c as _e,bi as Ge,bj as fe,bk as Ye,Q as Be,R as He,U as re,V as te,bd as je}from"./index-DOn6k1jF.js";import{aa as Qe,aR as Je,as as Z,L as X,n as Ze,aS as es,aT as ss,aB as rs,w as ts,a7 as ns,aU as as,aV as ls,aW as os,ah as de,p as ge,$ as is,m as cs,o as ds,_ as us,S as ms,aM as ve,aX as xs,x as hs,I as ps,T as fs,N as js}from"./icons-KVCk4_U8.js";import{S as Q}from"./separator-BCfZ54mZ.js";import{a as gs,u as be,b as we}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as vs,a as bs,b as Ne,c as ne,d as ws,e as ae}from"./table-Bx2cnkWN.js";import{R as Ns}from"./raw-json-settings-editor-panel-WxTn7-hS.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function H({title:s,icon:r,badge:t,description:a,disabledReason:n,children:l}){return e.jsxs(D,{children:[e.jsxs(M,{className:"pb-2",children:[e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[r,s,t?e.jsx(y,{variant:"outline",className:"text-[10px] font-normal",children:t}):null]}),a?e.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null]}),e.jsxs(F,{className:"space-y-3",children:[n?e.jsx("p",{className:"text-xs text-amber-600",children:n}):null,l]})]})}function Cs({catalog:s,state:r,disabled:t=!1,disabledReason:a,onToggle:n}){const l=new Set(s.map(o=>o.name)),i=Object.entries(r).filter(([o])=>!l.has(o)).sort(([o],[d])=>o.localeCompare(d));return e.jsxs(H,{title:"Features",badge:"features",icon:e.jsx(Qe,{className:"h-4 w-4"}),description:"Toggle the supported Codex feature flags CCS can safely manage.",disabledReason:a,children:[e.jsx("div",{className:"space-y-2",children:s.map(o=>{const d=r[o.name]??null;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o.label}),e.jsx(y,{variant:"outline",className:"font-mono text-[10px]",children:o.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o.name,null),disabled:t,children:"Use default"}):null,e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o.name,c),disabled:t})]})]},o.name)})}),i.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Existing config-only flags"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These feature keys already exist in your `config.toml`, so CCS can surface them without claiming full catalog coverage."})]}),i.map(([o,d])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-dashed px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:o}),e.jsx(y,{variant:"secondary",className:"text-[10px]",children:"existing"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d===null?"Stored in a non-boolean form. Use raw TOML if you need to edit it.":"Discovered from the current file instead of CCS's built-in catalog."})]}),d===null?e.jsx(y,{variant:"outline",children:"Raw only"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(o,null),disabled:t,children:"Use default"}),e.jsx(B,{checked:d===!0,onCheckedChange:c=>n(o,c),disabled:t})]})]},o))]}):null]})}const ys={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function le(s){return s.join(", ")}function oe(s){return s.split(",").map(r=>r.trim()).filter(Boolean)}function Ss({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"playwright",disabled:t||!r}),e.jsxs(_,{value:o.transport,onValueChange:c=>d(u=>({...u,transport:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"stdio",children:"stdio"}),e.jsx(v,{value:"streamable-http",children:"streamable-http"})]})]}),o.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(C,{value:o.command??"",onChange:c=>d(u=>({...u,command:c.target.value||null})),placeholder:"npx",disabled:t}),e.jsx(C,{value:le(o.args),onChange:c=>d(u=>({...u,args:oe(c.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:t})]}):e.jsx(C,{className:"sm:col-span-2",value:o.url??"",onChange:c=>d(u=>({...u,url:c.target.value||null})),placeholder:"https://example.test/mcp",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.startupTimeoutSec??"",onChange:c=>d(u=>({...u,startupTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Startup timeout (sec)",disabled:t}),e.jsx(C,{type:"number",min:1,value:o.toolTimeoutSec??"",onChange:c=>d(u=>({...u,toolTimeoutSec:c.target.value?Number(c.target.value):null})),placeholder:"Tool timeout (sec)",disabled:t}),e.jsx(C,{value:le(o.enabledTools),onChange:c=>d(u=>({...u,enabledTools:oe(c.target.value)})),placeholder:"enabled_tools",disabled:t}),e.jsx(C,{value:le(o.disabledTools),onChange:c=>d(u=>({...u,disabledTools:oe(c.target.value)})),placeholder:"disabled_tools",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Enabled",e.jsx(B,{checked:o.enabled,onCheckedChange:c=>d(u=>({...u,enabled:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(B,{checked:o.required,onCheckedChange:c=>d(u=>({...u,required:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{transport:o.transport,command:o.command,args:o.args,url:o.url,enabled:o.enabled,required:o.required,startupTimeoutSec:o.startupTimeoutSec,toolTimeoutSec:o.toolTimeoutSec,enabledTools:o.enabledTools,disabledTools:o.disabledTools}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function ks({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??ys,u=JSON.stringify(c);return e.jsxs(H,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(Je,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select MCP server"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new MCP server"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Ss,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}const Ts={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},_s={name:"cliproxy",displayName:"CLIProxy Codex",baseUrl:"http://127.0.0.1:8317/api/provider/codex",envKey:"CLIPROXY_API_KEY",wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1};function Es({initialDraft:s,isNew:r,disabled:t,saving:a,canDelete:n,onSave:l,onDelete:i}){const[o,d]=b.useState(s);return e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Quick start: apply the CLIProxy Codex preset here, then set"," ",e.jsx("strong",{children:"Default provider"})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>d(_s),disabled:t,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:o.name,onChange:c=>d(u=>({...u,name:c.target.value})),placeholder:"Provider id",disabled:t||!r}),e.jsx(C,{value:o.displayName??"",onChange:c=>d(u=>({...u,displayName:c.target.value||null})),placeholder:"Display name",disabled:t}),e.jsx(C,{value:o.baseUrl??"",onChange:c=>d(u=>({...u,baseUrl:c.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:t}),e.jsx(C,{value:o.envKey??"",onChange:c=>d(u=>({...u,envKey:c.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:t})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(_,{value:o.wireApi??"responses",onValueChange:c=>d(u=>({...u,wireApi:c})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsx(O,{children:e.jsx(v,{value:"responses",children:"responses"})})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Requires OpenAI auth",e.jsx(B,{checked:o.requiresOpenaiAuth,onCheckedChange:c=>d(u=>({...u,requiresOpenaiAuth:c})),disabled:t})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(B,{checked:o.supportsWebsockets,onCheckedChange:c=>d(u=>({...u,supportsWebsockets:c})),disabled:t})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(w,{variant:"outline",onClick:i,disabled:t||a||!n,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(w,{onClick:()=>l(o.name,{displayName:o.displayName,baseUrl:o.baseUrl,envKey:o.envKey,wireApi:o.wireApi,requiresOpenaiAuth:o.requiresOpenaiAuth,supportsWebsockets:o.supportsWebsockets}),disabled:t||a||o.name.trim().length===0,children:[a?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save provider"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["If you want plain native ",e.jsx("code",{children:"codex"})," to default to CLIProxy, save a provider named"," ",e.jsx("code",{children:"cliproxy"})," with ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," here, then pick"," ",e.jsx("code",{children:"cliproxy"})," in the ",e.jsx("strong",{children:"Default provider"})," control above."]})]})}function Ps({entries:s,disabled:r=!1,disabledReason:t,saving:a=!1,onSave:n,onDelete:l}){const[i,o]=b.useState("new"),d=b.useMemo(()=>s.find(h=>h.name===i)??null,[s,i]),c=d??Ts,u=JSON.stringify(c);return e.jsxs(H,{title:"Model providers",badge:"model_providers",icon:e.jsx(Ze,{className:"h-4 w-4"}),description:"Edit the common provider fields CCS can support safely. Keep secret migration and inline bearer tokens in raw TOML.",disabledReason:t,children:[e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new provider"}),s.map(h=>e.jsx(v,{value:h.name,children:h.name},h.name))]})]}),e.jsx(Es,{initialDraft:c,isNew:i==="new",disabled:r,saving:a,canDelete:d!==null,onDelete:async()=>{d&&(await l(d.name),o("new"))},onSave:async(h,j)=>{await n(h,j),o(h)}},u)]})}function Os({initialName:s,initialModel:r,initialProvider:t,initialEffort:a,providerNames:n,activeProfile:l,selectedEntryName:i,disabled:o,saving:d,onSave:c,onDelete:u,onSetActive:h}){const[j,x]=b.useState(s),[g,A]=b.useState(r),[U,m]=b.useState(t),[f,T]=b.useState(a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(C,{value:j,onChange:N=>x(N.target.value),placeholder:"deep-review",disabled:o||i!==null}),e.jsx(C,{value:g??"",onChange:N=>A(N.target.value||null),placeholder:"gpt-5.4",disabled:o}),e.jsxs(_,{value:U??"__unset__",onValueChange:N=>m(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global provider"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global provider"}),n.map(N=>e.jsx(v,{value:N,children:N},N))]})]}),e.jsxs(_,{value:f??"__unset__",onValueChange:N=>T(N==="__unset__"?null:N),disabled:o,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use global effort"})}),e.jsxs(O,{children:[e.jsx(v,{value:"__unset__",children:"Use global effort"}),["minimal","low","medium","high","xhigh"].map(N=>e.jsx(v,{value:N,children:N},N))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:u,disabled:o||d||!i,children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(w,{variant:"outline",onClick:h,disabled:o||d||!i||i===l,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!1),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(w,{onClick:()=>c(j,{model:g,modelProvider:U,modelReasoningEffort:f},!0),disabled:o||d||j.trim().length===0,children:[d?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Ls({activeProfile:s,entries:r,providerNames:t,disabled:a=!1,disabledReason:n,saving:l=!1,onSave:i,onDelete:o,onSetActive:d}){const[c,u]=b.useState("new"),h=b.useMemo(()=>r.find(x=>x.name===c)??null,[r,c]),j=JSON.stringify(h??{name:"",values:{}});return e.jsxs(H,{title:"Profiles",badge:"profiles",icon:e.jsx(es,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:n,children:[e.jsxs(_,{value:c,onValueChange:u,disabled:a,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Select profile"})}),e.jsxs(O,{children:[e.jsx(v,{value:"new",children:"Create new profile"}),r.map(x=>e.jsxs(v,{value:x.name,children:[x.name,x.name===s?" (active)":""]},x.name))]})]}),e.jsx(Os,{initialName:h?.name??"",initialModel:h?.values.model??null,initialProvider:h?.values.modelProvider??null,initialEffort:h?.values.modelReasoningEffort??null,providerNames:t,activeProfile:s,selectedEntryName:h?.name??null,disabled:a,saving:l,onDelete:async()=>{h&&(await o(h.name),u("new"))},onSetActive:async()=>{h&&await d(h.name)},onSave:async(x,g,A)=>{await i(x,g,A),u(x)}},j)]})}function As({workspacePath:s,disabled:r,saving:t,onSave:a}){const[n,l]=b.useState(s),[i,o]=b.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(C,{value:n,onChange:d=>l(d.target.value),placeholder:"~/repo or /absolute/path",disabled:r}),e.jsxs(_,{value:i,onValueChange:o,disabled:r,children:[e.jsx(E,{children:e.jsx(P,{})}),e.jsxs(O,{children:[e.jsx(v,{value:"trusted",children:"trusted"}),e.jsx(v,{value:"untrusted",children:"untrusted"})]})]}),e.jsxs(w,{onClick:()=>a(n,i),disabled:r||t,children:[t?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Rs({workspacePath:s,entries:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsxs(H,{title:"Project trust",badge:"projects",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:a,children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths must be absolute or start with ",e.jsx("code",{children:"~/"}),". Relative paths are rejected so CCS does not trust the wrong folder."]}),e.jsx(As,{workspacePath:s,disabled:t,saving:n,onSave:l},s),e.jsx(w,{variant:"outline",className:"w-full justify-start",onClick:()=>l(s,"trusted"),disabled:t||n,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No explicit project trust entries saved."}):r.map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:i.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",i.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>l(i.path,i.trustLevel==="trusted"?"untrusted":"trusted"),disabled:t||n,children:"Toggle"}),e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>l(i.path,null),disabled:t||n,children:e.jsx(Z,{className:"h-4 w-4"})})]})]},i.path))})]})}const L="__unset__",Ds=105e4,Ms=272e3,Ce=8e5,ye=7e5,Is=new Intl.NumberFormat("en-US");function z(s){return s??L}function $(s,r){return r&&!s.includes(r)?[r,...s]:s}function ie(s){return Is.format(s)}function Fs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,r){const t={};return r.model!==s.model&&(t.model=r.model),r.modelReasoningEffort!==s.modelReasoningEffort&&(t.modelReasoningEffort=r.modelReasoningEffort),r.modelContextWindow!==s.modelContextWindow&&(t.modelContextWindow=r.modelContextWindow),r.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(t.modelAutoCompactTokenLimit=r.modelAutoCompactTokenLimit),r.modelProvider!==s.modelProvider&&(t.modelProvider=r.modelProvider),r.approvalPolicy!==s.approvalPolicy&&(t.approvalPolicy=r.approvalPolicy),r.sandboxMode!==s.sandboxMode&&(t.sandboxMode=r.sandboxMode),r.webSearch!==s.webSearch&&(t.webSearch=r.webSearch),r.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(t.toolOutputTokenLimit=r.toolOutputTokenLimit),r.personality!==s.personality&&(t.personality=r.personality),t}function Ws({initialValues:s,providerNames:r,disabled:t,saving:a,onSave:n}){const[l,i]=b.useState(s),o=$(["minimal","low","medium","high","xhigh"],l.modelReasoningEffort),d=$(r,l.modelProvider),c=$(["on-request","never","untrusted"],l.approvalPolicy),u=$(["read-only","workspace-write","danger-full-access"],l.sandboxMode),h=$(["cached","live","disabled"],l.webSearch),j=$(["none","friendly","pragmatic"],l.personality),x=Us(s,l),g=Object.keys(x).length>0,A=Fs(l.model),U=m=>{const f=m.trim();return f.length>0?Number(f):null};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model"}),e.jsx(C,{value:l.model??"",onChange:m=>i(f=>({...f,model:m.target.value||null})),placeholder:"gpt-5.4",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Reasoning effort"}),e.jsxs(_,{value:z(l.modelReasoningEffort),onValueChange:m=>i(f=>({...f,modelReasoningEffort:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),o.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Default provider"}),e.jsxs(_,{value:z(l.modelProvider),onValueChange:m=>i(f=>({...f,modelProvider:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use Codex default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use Codex default"}),d.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Approval policy"}),e.jsxs(_,{value:z(l.approvalPolicy),onValueChange:m=>i(f=>({...f,approvalPolicy:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),c.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Sandbox mode"}),e.jsxs(_,{value:z(l.sandboxMode),onValueChange:m=>i(f=>({...f,sandboxMode:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),u.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Web search"}),e.jsxs(_,{value:z(l.webSearch),onValueChange:m=>i(f=>({...f,webSearch:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),h.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Tool output token limit"}),e.jsx(C,{type:"number",min:1,value:l.toolOutputTokenLimit??"",onChange:m=>i(f=>({...f,toolOutputTokenLimit:m.target.value?Number(m.target.value):null})),placeholder:"25000",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Personality"}),e.jsxs(_,{value:z(l.personality),onValueChange:m=>i(f=>({...f,personality:m===L?null:m})),disabled:t,children:[e.jsx(E,{children:e.jsx(P,{placeholder:"Use default"})}),e.jsxs(O,{children:[e.jsx(v,{value:L,children:"Use default"}),j.map(m=>e.jsx(v,{value:m,children:m},m))]})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 shadow-sm dark:bg-amber-400/5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ts,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"Long context override"}),e.jsx(y,{variant:"outline",className:"border-amber-500/40 bg-background/80 text-[10px] uppercase tracking-[0.16em] text-amber-700 dark:text-amber-300",children:"Manual opt-in only"}),e.jsx(y,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:A?"GPT-5.4 selected":"GPT-5.4 reference"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Draft values only. Nothing applies until Save."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ce,modelAutoCompactTokenLimit:ye})),children:"Fill cautious pair"}),e.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:Ds})),children:"Set official max window"}),e.jsx(w,{type:"button",variant:"ghost",size:"sm",disabled:t,onClick:()=>i(m=>({...m,modelContextWindow:null,modelAutoCompactTokenLimit:null})),children:"Clear"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Official max"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"1.05M / 1M"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"GPT-5.4 context cap"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Standard window"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:ie(Ms)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Normal usage window"})]}),e.jsxs("div",{className:"rounded-lg border bg-background/85 px-3 py-3 shadow-sm shadow-black/5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Above 272K"}),e.jsx("p",{className:"mt-1 font-mono text-base font-semibold text-foreground",children:"Counts 2x"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Usage-limit cost above 272K"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border bg-background/75 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"One cautious pair"}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Context ",ie(Ce)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",ie(ye)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(y,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Draft only"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:"Quick-fill only. Review before saving."}),!A&&l.model?e.jsxs("span",{children:[e.jsx("code",{children:l.model})," should be checked separately."]}):null]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Model context window"}),e.jsx(C,{"aria-label":"Model context window",type:"number",min:1,value:l.modelContextWindow??"",onChange:m=>i(f=>({...f,modelContextWindow:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_context_window"}),". Leave unset to keep Codex defaults."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:"Auto-compact token limit"}),e.jsx(C,{"aria-label":"Auto-compact token limit",type:"number",min:1,value:l.modelAutoCompactTokenLimit??"",onChange:m=>i(f=>({...f,modelAutoCompactTokenLimit:U(m.target.value)})),placeholder:"Unset",disabled:t}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Writes ",e.jsx("code",{children:"model_auto_compact_token_limit"}),". Leave unset to keep model defaults."]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em]",children:"Docs"}),e.jsx("a",{href:"https://developers.openai.com/api/docs/models/gpt-5.4",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"GPT-5.4 model page"}),e.jsx("a",{href:"https://openai.com/index/introducing-gpt-5-4/",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Release notes"}),e.jsx("a",{href:"https://developers.openai.com/codex/config-reference",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Config reference"})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{onClick:()=>n(x),disabled:t||a||!g,children:[a?e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Ks({values:s,providerNames:r,disabled:t=!1,disabledReason:a,saving:n=!1,onSave:l}){return e.jsx(H,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Structured controls for the stable top-level Codex settings users touch most often. Unsupported upstream shapes stay untouched and should be edited in raw TOML.",disabledReason:a,children:e.jsx(Ws,{initialValues:s,providerNames:r,disabled:t,saving:n,onSave:l},JSON.stringify(s))})}function qs({workspacePath:s,activeProfile:r,topLevelSettings:t,projectTrustEntries:a,profileEntries:n,modelProviderEntries:l,mcpServerEntries:i,featureCatalog:o,featureState:d,disabled:c,disabledReason:u,saving:h,onPatch:j}){return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 pr-1 pb-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-xl border border-border/80 bg-background/50 p-5 shadow-sm transition-all hover:bg-background hover:shadow-md dark:border-border/60",children:[e.jsx("div",{className:"absolute inset-x-0 -top-px h-px bg-gradient-to-r from-transparent via-foreground/15 to-transparent transition-opacity group-hover:via-foreground/30"}),e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary transition-colors group-hover:border-primary/30",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:"Structured controls boundary"})})]}),e.jsxs("ul",{className:"grid gap-3 sm:grid-cols-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(as,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsxs("span",{className:"leading-relaxed",children:["Writes exclusively to user-layer"," ",e.jsx("code",{className:"text-[11px] bg-muted/70 px-1.5 py-0.5 rounded border border-border/50",children:"config.toml"})]})]}),e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx(ls,{className:"h-4 w-4 shrink-0 text-muted-foreground/60 mt-0.5"}),e.jsx("span",{className:"leading-relaxed",children:"Does not reflect repo trust layers or CLI overrides"})]})]})]}),e.jsx("div",{className:"shrink-0 lg:w-[280px]",children:e.jsx("div",{className:"relative overflow-hidden rounded-lg border border-amber-500/20 bg-amber-500/5 p-4 transition-colors group-hover:border-amber-500/30 group-hover:bg-amber-500/10 dark:border-amber-400/10 dark:bg-amber-400/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-300 uppercase tracking-wider",children:"Formatting Note"}),e.jsx("p",{className:"text-[13px] leading-relaxed text-amber-800/80 dark:text-amber-200/70",children:"Saves normalize TOML formatting and strip comments. Switch to the raw editor if exact layout matters."})]})]})})})]})]}),e.jsx(Ks,{values:t,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:x=>j({kind:"top-level",values:x},"Saved top-level Codex settings.")}),e.jsx(Rs,{workspacePath:s,entries:a,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"project-trust",path:x,trustLevel:g},g?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Ls,{activeProfile:r,entries:n,providerNames:l.map(x=>x.name),disabled:c,disabledReason:u,saving:h,onSave:(x,g,A)=>j({kind:"profile",action:"upsert",name:x,values:g,setAsActive:A},"Saved profile."),onDelete:x=>j({kind:"profile",action:"delete",name:x},"Deleted profile."),onSetActive:x=>j({kind:"profile",action:"set-active",name:x},"Set active profile.")}),e.jsx(Ps,{entries:l,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"model-provider",action:"upsert",name:x,values:g},"Saved model provider."),onDelete:x=>j({kind:"model-provider",action:"delete",name:x},"Deleted model provider.")}),e.jsx(ks,{entries:i,disabled:c,disabledReason:u,saving:h,onSave:(x,g)=>j({kind:"mcp-server",action:"upsert",name:x,values:g},"Saved MCP server."),onDelete:x=>j({kind:"mcp-server",action:"delete",name:x},"Deleted MCP server.")}),e.jsx(Cs,{catalog:o,state:d,disabled:c,disabledReason:u,onToggle:(x,g)=>j({kind:"feature",feature:x,enabled:g},"Saved feature toggle.")})]})})}const Ee=`model_provider = "cliproxy"
2
-
3
- [model_providers.cliproxy]
4
- base_url = "http://127.0.0.1:8317/api/provider/codex"
5
- env_key = "CLIPROXY_API_KEY"
6
- wire_api = "responses"`,Pe=[{name:"multi_agent",label:"Multi-agent",description:"Enable subagent collaboration tools."},{name:"unified_exec",label:"Unified exec",description:"Use the PTY-backed unified exec tool."},{name:"shell_snapshot",label:"Shell snapshot",description:"Reuse shell environment snapshots."},{name:"apply_patch_freeform",label:"Apply patch",description:"Enable freeform apply_patch edits."},{name:"js_repl",label:"JS REPL",description:"Enable the Node-backed JavaScript REPL."},{name:"runtime_metrics",label:"Runtime metrics",description:"Collect Codex runtime metrics."},{name:"prevent_idle_sleep",label:"Prevent idle sleep",description:"Keep the machine awake while active."},{name:"fast_mode",label:"Fast mode",description:"Allow the fast service tier path."},{name:"apps",label:"Apps",description:"Enable ChatGPT Apps and connectors support."},{name:"smart_approvals",label:"Smart approvals",description:"Route eligible approvals through the guardian flow."}];function q(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function k(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function Y(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ce(s){return Array.isArray(s)?s.filter(r=>typeof r=="string").map(r=>r.trim()):[]}function Oe(s){return{model:k(s?.model),modelReasoningEffort:k(s?.model_reasoning_effort),modelContextWindow:Y(s?.model_context_window),modelAutoCompactTokenLimit:Y(s?.model_auto_compact_token_limit),modelProvider:k(s?.model_provider),approvalPolicy:k(s?.approval_policy),sandboxMode:k(s?.sandbox_mode),webSearch:k(s?.web_search),toolOutputTokenLimit:Y(s?.tool_output_token_limit),personality:k(s?.personality)}}function Vs(s){const r=q(s?.projects);return r?Object.entries(r).map(([t,a])=>{const n=k(q(a)?.trust_level);return n?{path:t,trustLevel:n}:null}).filter(t=>t!==null).sort((t,a)=>t.path.localeCompare(a.path)):[]}function Xs(s){const r=q(s?.profiles);return r?Object.entries(r).map(([t,a])=>({name:t,values:Oe(q(a))})).sort((t,a)=>t.name.localeCompare(a.name)):[]}function zs(s){const r=q(s?.model_providers);return r?Object.entries(r).map(([t,a])=>{const n=q(a);return n?{name:t,displayName:k(n.name),baseUrl:k(n.base_url),envKey:k(n.env_key),wireApi:k(n.wire_api),requiresOpenaiAuth:n.requires_openai_auth===!0,supportsWebsockets:n.supports_websockets===!0}:null}).filter(t=>t!==null).sort((t,a)=>t.name.localeCompare(a.name)):[]}function $s(s){const r=q(s?.mcp_servers);return r?Object.entries(r).map(([t,a])=>{const n=q(a);if(!n)return null;const l=k(n.command)?"stdio":"streamable-http",i=Y(n.startup_timeout_ms);return{name:t,transport:l,command:k(n.command),args:ce(n.args),url:k(n.url),enabled:n.enabled!==!1,required:n.required===!0,startupTimeoutSec:Y(n.startup_timeout_sec)??(i!==null?i/1e3:null),toolTimeoutSec:Y(n.tool_timeout_sec),enabledTools:ce(n.enabled_tools),disabledTools:ce(n.disabled_tools)}}).filter(t=>t!==null).sort((t,a)=>t.name.localeCompare(a.name)):[]}function Gs(s){const r=q(s?.features),t={};for(const a of Pe){const n=r?.[a.name];t[a.name]=typeof n=="boolean"?n:null}if(r)for(const[a,n]of Object.entries(r))a in t||(t[a]=typeof n=="boolean"?n:null);return t}const Ys=[{id:"codex-config-basic",label:"Codex Config Basics",url:"https://developers.openai.com/codex/config-basic",description:"Official user-layer setup, config location, and baseline configuration behavior."},{id:"codex-config-advanced",label:"Codex Config Advanced",url:"https://developers.openai.com/codex/config-advanced",description:"Layering, trust, profiles, and advanced config behavior."},{id:"codex-config-reference",label:"Codex Config Reference",url:"https://developers.openai.com/codex/config-reference",description:"Canonical upstream config surface for providers, MCP, features, and trust."},{id:"codex-releases",label:"Codex GitHub Releases",url:"https://github.com/openai/codex/releases",description:"Track upstream release notes and fast-moving CLI changes."}],Bs=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function Hs(s){const r=/https?:\/\/[^\s)]+/g,t=[];let a=0,n;for(;(n=r.exec(s))!==null;){const[l]=n,i=n.index;i>a&&t.push(s.slice(a,i)),t.push(e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:l},`${l}-${i}`)),a=i+l.length}return a<s.length&&t.push(s.slice(a)),t.length>0?t:[s]}function Qs({diagnostics:s}){const r=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},t=r.links.length>0?r.links:Ys,a=r.providerDocs.length>0?r.providerDocs:Bs;return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(F,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with"," ",e.jsx("code",{children:"codex"}),"."]})]}),e.jsx("pre",{className:"overflow-x-auto rounded-md border bg-muted/20 p-3 text-xs text-foreground",children:Ee}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save the ",e.jsx("code",{children:"cliproxy"})," provider in your user config."]}),e.jsxs("li",{children:["Set top-level ",e.jsx("code",{children:"model_provider"})," to ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," before launching native Codex."]})]})]})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(F,{className:"space-y-2 text-sm",children:[r.notes.length>0&&e.jsx("ul",{className:"ml-4 list-disc space-y-1.5 text-muted-foreground [&>li]:pl-1",children:r.notes.map((n,l)=>e.jsx("li",{children:Hs(n)},`${l}-${n}`))}),e.jsx(Q,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Codex docs"}),e.jsx("div",{className:"space-y-1.5",children:t.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(ge,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:n.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},n.id))})]}),e.jsx(Q,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Provider / bridge reference"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"block rounded-md border px-2.5 py-2 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-medium",children:n.label}),e.jsx(ge,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",n.provider," | format: ",n.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:n.url})]},`${n.provider}-${n.url}`))})]}),r.providerValues.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider values: ",r.providerValues.join(", ")]})]}),r.settingsHierarchy.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Settings hierarchy: ",r.settingsHierarchy.join(" -> ")]})]})]})]})})}function Js(s,r){let t=s.slice(0,r).split(/\r\n|\n|\r/g);return[t.length,t.pop().length+1]}function Zs(s,r,t){let a=s.split(/\r\n|\n|\r/g),n="",l=(Math.log10(r+1)|0)+1;for(let i=r-1;i<=r+1;i++){let o=a[i-1];o&&(n+=i.toString().padEnd(l," "),n+=": ",n+=o,n+=`
7
- `,i===r&&(n+=" ".repeat(l+t+2),n+=`^
8
- `))}return n}class p extends Error{line;column;codeblock;constructor(r,t){const[a,n]=Js(t.toml,t.ptr),l=Zs(t.toml,a,n);super(`Invalid TOML document: ${r}
9
-
10
- ${l}`,t),this.line=a,this.column=n,this.codeblock=l}}function er(s,r){let t=0;for(;s[r-++t]==="\\";);return--t&&t%2}function ue(s,r=0,t=s.length){let a=s.indexOf(`
11
- `,r);return s[a-1]==="\r"&&a--,a<=t?a:-1}function ee(s,r){for(let t=r;t<s.length;t++){let a=s[t];if(a===`
12
- `)return t;if(a==="\r"&&s[t+1]===`
13
- `)return t+1;if(a<" "&&a!==" "||a==="")throw new p("control characters are not allowed in comments",{toml:s,ptr:r})}return s.length}function K(s,r,t,a){let n;for(;;){for(;(n=s[r])===" "||n===" "||!t&&(n===`
14
- `||n==="\r"&&s[r+1]===`
15
- `);)r++;if(a||n!=="#")break;r=ee(s,r)}return r}function sr(s,r,t,a,n=!1){if(!a)return r=ue(s,r),r<0?s.length:r;for(let l=r;l<s.length;l++){let i=s[l];if(i==="#")l=ue(s,l);else{if(i===t)return l+1;if(i===a||n&&(i===`
16
- `||i==="\r"&&s[l+1]===`
17
- `))return l}}throw new p("cannot find end of structure",{toml:s,ptr:r})}function Le(s,r){let t=s[r],a=t===s[r+1]&&s[r+1]===s[r+2]?s.slice(r,r+3):t;r+=a.length-1;do r=s.indexOf(a,++r);while(r>-1&&t!=="'"&&er(s,r));return r>-1&&(r+=a.length,a.length>1&&(s[r]===t&&r++,s[r]===t&&r++)),r}let rr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class G extends Date{#s=!1;#r=!1;#e=null;constructor(r){let t=!0,a=!0,n="Z";if(typeof r=="string"){let l=r.match(rr);l?(l[1]||(t=!1,r=`0000-01-01T${r}`),a=!!l[2],a&&r[10]===" "&&(r=r.replace(" ","T")),l[2]&&+l[2]>23?r="":(n=l[3]||null,r=r.toUpperCase(),!n&&a&&(r+="Z"))):r=""}super(r),isNaN(this.getTime())||(this.#s=t,this.#r=a,this.#e=n)}isDateTime(){return this.#s&&this.#r}isLocal(){return!this.#s||!this.#r||!this.#e}isDate(){return this.#s&&!this.#r}isTime(){return this.#r&&!this.#s}isValid(){return this.#s||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let a=new G(r);return a.#e=t,a}static wrapAsLocalDateTime(r){let t=new G(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new G(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new G(r);return t.#s=!1,t.#e=null,t}}let tr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,nr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ar=/^[+-]?0[0-9_]/,lr=/^[0-9a-f]{2,8}$/i,Se={b:"\b",t:" ",n:`
18
- `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Ae(s,r=0,t=s.length){let a=s[r]==="'",n=s[r++]===s[r]&&s[r]===s[r+1];n&&(t-=2,s[r+=2]==="\r"&&r++,s[r]===`
19
- `&&r++);let l=0,i,o="",d=r;for(;r<t-1;){let c=s[r++];if(c===`
20
- `||c==="\r"&&s[r]===`
21
- `){if(!n)throw new p("newlines are not allowed in strings",{toml:s,ptr:r-1})}else if(c<" "&&c!==" "||c==="")throw new p("control characters are not allowed in strings",{toml:s,ptr:r-1});if(i){if(i=!1,c==="x"||c==="u"||c==="U"){let u=s.slice(r,r+=c==="x"?2:c==="u"?4:8);if(!lr.test(u))throw new p("invalid unicode escape",{toml:s,ptr:l});try{o+=String.fromCodePoint(parseInt(u,16))}catch{throw new p("invalid unicode escape",{toml:s,ptr:l})}}else if(n&&(c===`
22
- `||c===" "||c===" "||c==="\r")){if(r=K(s,r-1,!0),s[r]!==`
23
- `&&s[r]!=="\r")throw new p("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:l});r=K(s,r)}else if(c in Se)o+=Se[c];else throw new p("unrecognized escape sequence",{toml:s,ptr:l});d=r}else!a&&c==="\\"&&(l=r-1,i=!0,o+=s.slice(d,l))}return o+s.slice(d,t-1)}function or(s,r,t,a){if(s==="true")return!0;if(s==="false")return!1;if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return a?0n:0;let n=tr.test(s);if(n||nr.test(s)){if(ar.test(s))throw new p("leading zeroes are not allowed",{toml:r,ptr:t});s=s.replace(/_/g,"");let i=+s;if(isNaN(i))throw new p("invalid number",{toml:r,ptr:t});if(n){if((n=!Number.isSafeInteger(i))&&!a)throw new p("integer value cannot be represented losslessly",{toml:r,ptr:t});(n||a===!0)&&(i=BigInt(s))}return i}const l=new G(s);if(!l.isValid())throw new p("invalid value",{toml:r,ptr:t});return l}function ir(s,r,t){let a=s.slice(r,t),n=a.indexOf("#");return n>-1&&(ee(s,n),a=a.slice(0,n)),[a.trimEnd(),n]}function he(s,r,t,a,n){if(a===0)throw new p("document contains excessively nested structures. aborting.",{toml:s,ptr:r});let l=s[r];if(l==="["||l==="{"){let[d,c]=l==="["?ur(s,r,a,n):dr(s,r,a,n);if(t){if(c=K(s,c),s[c]===",")c++;else if(s[c]!==t)throw new p("expected comma or end of structure",{toml:s,ptr:c})}return[d,c]}let i;if(l==='"'||l==="'"){i=Le(s,r);let d=Ae(s,r,i);if(t){if(i=K(s,i),s[i]&&s[i]!==","&&s[i]!==t&&s[i]!==`
24
- `&&s[i]!=="\r")throw new p("unexpected character encountered",{toml:s,ptr:i});i+=+(s[i]===",")}return[d,i]}i=sr(s,r,",",t);let o=ir(s,r,i-+(s[i-1]===","));if(!o[0])throw new p("incomplete key-value declaration: no value specified",{toml:s,ptr:r});return t&&o[1]>-1&&(i=K(s,r+o[1]),i+=+(s[i]===",")),[or(o[0],s,r,n),i]}let cr=/^[a-zA-Z0-9-_]+[ \t]*$/;function me(s,r,t="="){let a=r-1,n=[],l=s.indexOf(t,r);if(l<0)throw new p("incomplete key-value: cannot find end of key",{toml:s,ptr:r});do{let i=s[r=++a];if(i!==" "&&i!==" ")if(i==='"'||i==="'"){if(i===s[r+1]&&i===s[r+2])throw new p("multiline strings are not allowed in keys",{toml:s,ptr:r});let o=Le(s,r);if(o<0)throw new p("unfinished string encountered",{toml:s,ptr:r});a=s.indexOf(".",o);let d=s.slice(o,a<0||a>l?l:a),c=ue(d);if(c>-1)throw new p("newlines are not allowed in keys",{toml:s,ptr:r+a+c});if(d.trimStart())throw new p("found extra tokens after the string part",{toml:s,ptr:o});if(l<o&&(l=s.indexOf(t,o),l<0))throw new p("incomplete key-value: cannot find end of key",{toml:s,ptr:r});n.push(Ae(s,r,o))}else{a=s.indexOf(".",r);let o=s.slice(r,a<0||a>l?l:a);if(!cr.test(o))throw new p("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:r});n.push(o.trimEnd())}}while(a+1&&a<l);return[n,K(s,l+1,!0,!0)]}function dr(s,r,t,a){let n={},l=new Set,i;for(r++;(i=s[r++])!=="}"&&i;){if(i===",")throw new p("expected value, found comma",{toml:s,ptr:r-1});if(i==="#")r=ee(s,r);else if(i!==" "&&i!==" "&&i!==`
25
- `&&i!=="\r"){let o,d=n,c=!1,[u,h]=me(s,r-1);for(let g=0;g<u.length;g++){if(g&&(d=c?d[o]:d[o]={}),o=u[g],(c=Object.hasOwn(d,o))&&(typeof d[o]!="object"||l.has(d[o])))throw new p("trying to redefine an already defined value",{toml:s,ptr:r});!c&&o==="__proto__"&&Object.defineProperty(d,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new p("trying to redefine an already defined value",{toml:s,ptr:r});let[j,x]=he(s,h,"}",t-1,a);l.add(j),d[o]=j,r=x}}if(!i)throw new p("unfinished table encountered",{toml:s,ptr:r});return[n,r]}function ur(s,r,t,a){let n=[],l;for(r++;(l=s[r++])!=="]"&&l;){if(l===",")throw new p("expected value, found comma",{toml:s,ptr:r-1});if(l==="#")r=ee(s,r);else if(l!==" "&&l!==" "&&l!==`
26
- `&&l!=="\r"){let i=he(s,r-1,"]",t-1,a);n.push(i[0]),r=i[1]}}if(!l)throw new p("unfinished array encountered",{toml:s,ptr:r});return[n,r]}function ke(s,r,t,a){let n=r,l=t,i,o=!1,d;for(let c=0;c<s.length;c++){if(c){if(n=o?n[i]:n[i]={},l=(d=l[i]).c,a===0&&(d.t===1||d.t===2))return null;if(d.t===2){let u=n.length-1;n=n[u],l=l[u].c}}if(i=s[c],(o=Object.hasOwn(n,i))&&l[i]?.t===0&&l[i]?.d)return null;o||(i==="__proto__"&&(Object.defineProperty(n,i,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(l,i,{enumerable:!0,configurable:!0,writable:!0})),l[i]={t:c<s.length-1&&a===2?3:a,d:!1,i:0,c:{}})}if(d=l[i],d.t!==a&&!(a===1&&d.t===3)||(a===2&&(d.d||(d.d=!0,n[i]=[]),n[i].push(n={}),d.c[d.i++]=d={t:1,d:!1,i:0,c:{}}),d.d))return null;if(d.d=!0,a===1)n=o?n[i]:n[i]={};else if(a===0&&o)return null;return[i,n,d.c]}function mr(s,{maxDepth:r=1e3,integersAsBigInt:t}={}){let a={},n={},l=a,i=n;for(let o=K(s,0);o<s.length;){if(s[o]==="["){let d=s[++o]==="[",c=me(s,o+=+d,"]");if(d){if(s[c[1]-1]!=="]")throw new p("expected end of table declaration",{toml:s,ptr:c[1]-1});c[1]++}let u=ke(c[0],a,n,d?2:1);if(!u)throw new p("trying to redefine an already defined table or value",{toml:s,ptr:o});i=u[2],l=u[1],o=c[1]}else{let d=me(s,o),c=ke(d[0],l,i,0);if(!c)throw new p("trying to redefine an already defined table or value",{toml:s,ptr:o});let u=he(s,d[1],void 0,r,t);c[1][c[0]]=u[0],o=u[1]}if(o=K(s,o,!0),s[o]&&s[o]!==`
27
- `&&s[o]!=="\r")throw new p("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:o});o=K(s,o)}return a}function xr(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function hr(s){if(!s.trim())return{};const t=mr(s);if(!xr(t))throw new Error("TOML root must be a table.");return t}function Re(s){try{return{config:hr(s),parseError:null}}catch(r){return{config:null,parseError:r.message}}}async function pr(){const s=await fetch(J("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function fr(){const s=await fetch(J("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function jr(s){const r=await fetch(J("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Te("Codex raw config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to save Codex raw config")}return r.json()}async function gr(s){const r=await fetch(J("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Te("Codex config changed externally");if(!r.ok){const t=await r.json().catch(()=>null);throw new Error(t?.error||"Failed to patch Codex config")}return r.json()}function vr(){const s=gs(),r=be({queryKey:["codex-diagnostics"],queryFn:pr,refetchInterval:1e4}),t=be({queryKey:["codex-raw-config"],queryFn:fr}),a=we({mutationFn:jr,onSuccess:(l,i)=>{s.setQueryData(["codex-raw-config"],o=>{const d=o?.path??"$CODEX_HOME/config.toml",c=o?.resolvedPath??d,u=Re(i.rawText);return{path:d,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:i.rawText,config:u.config,parseError:u.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),n=we({mutationFn:gr,onSuccess:l=>{s.setQueryData(["codex-raw-config"],l),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return b.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawConfig:t.data,rawConfigLoading:t.isLoading,rawConfigError:t.error,refetchRawConfig:t.refetch,saveRawConfig:a.mutate,saveRawConfigAsync:a.mutateAsync,isSavingRawConfig:a.isPending,patchConfig:n.mutate,patchConfigAsync:n.mutateAsync,isPatchingConfig:n.isPending}),[r.data,r.isLoading,r.error,r.refetch,t.data,t.isLoading,t.error,t.refetch,a.mutate,a.mutateAsync,a.isPending,n.mutate,n.mutateAsync,n.isPending])}const br=[{label:"Start Default",command:"ccs",description:"Launch Claude with default profile"},{label:"GLM Profile",command:"ccs glm",description:"Switch to GLM model"},{label:"Health Check",command:"ccs doctor",description:"Run system diagnostics"},{label:"Delegate Task",command:'ccs glm -p "your task"',description:"Delegate to GLM profile"}];function wr({snippets:s=br}){const[r,t]=b.useState(null),a=async(n,l)=>{await navigator.clipboard.writeText(n),t(l),setTimeout(()=>t(null),2e3)};return e.jsxs(D,{children:[e.jsx(M,{className:"pb-3",children:e.jsxs(I,{className:"text-lg flex items-center gap-2",children:[e.jsx(is,{className:"w-5 h-5 text-muted-foreground"}),"Quick Commands"]})}),e.jsx(F,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,l)=>e.jsxs("div",{className:_e("group flex items-center justify-between gap-2 px-3 py-2","rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors"),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:n.label}),e.jsx("code",{className:"text-sm font-mono font-medium truncate block",children:n.command})]}),e.jsx(w,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>a(n.command,l),title:n.description,children:r===l?e.jsx(cs,{className:"h-4 w-4 text-green-600"}):e.jsx(ds,{className:"h-4 w-4"})})]},l))})})]})}function Nr(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Cr(s){return!s||s<=0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(2)} MB`}function S({label:s,value:r,mono:t=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-muted-foreground shrink-0",children:s}),e.jsx("span",{className:_e("text-right break-all",t&&"font-mono text-xs"),children:r})]})}function yr({diagnostics:s}){const r=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",t=s.binary.supportsConfigOverrides;return e.jsx(xe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(us,{className:"h-4 w-4"}),"How Codex works in CCS"]})}),e.jsx(F,{className:"text-sm text-muted-foreground",children:e.jsxs("ul",{className:"ml-4 list-disc space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:"Codex is a first-class, runtime-only target in CCS v1."}),e.jsxs("li",{children:[e.jsx("strong",{children:"Native config:"})," ",e.jsx("code",{children:"ccs-codex"})," and ",e.jsx("code",{children:"ccsx"})," launch native Codex using your saved defaults."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Transient overrides:"})," ",e.jsx("code",{children:"ccsxp"})," (or"," ",e.jsx("code",{children:"ccs codex --target codex"}),") uses the CCS provider shortcut."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"CLIProxy default:"})," To make plain ",e.jsx("code",{children:"codex"})," use CLIProxy, set ",e.jsx("code",{children:'model_provider = "cliproxy"'})," and add the recipe below."]}),e.jsx("li",{children:"API profiles continue to default to Claude or Droid."})]})})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(ms,{className:"h-4 w-4"}),"Runtime install"]})}),e.jsxs(F,{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(y,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?"Detected":"Not found"})]}),e.jsx(S,{label:"Detection source",value:s.binary.source,mono:!0}),e.jsx(S,{label:"Binary path",value:s.binary.path||"Not found",mono:!0}),e.jsx(S,{label:"Install directory",value:s.binary.installDir||"N/A",mono:!0}),e.jsx(S,{label:"Version",value:s.binary.version||"Unknown",mono:!0}),e.jsx(S,{label:"Native aliases",value:"ccs-codex, ccsx",mono:!0}),e.jsx(S,{label:"CCS provider shortcut",value:"ccsxp",mono:!0}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"--config override support"}),e.jsx(y,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?"Available":"Missing"})]})]})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(ve,{className:"h-4 w-4"}),"CLIProxy-backed native Codex"]})}),e.jsx(F,{className:"space-y-3 text-sm text-muted-foreground",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:"Two supported paths:"})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Built-in:"})," Use ",e.jsx("code",{children:"ccsxp"})," for the CCS provider shortcut."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Native:"})," Configure the recipe below to use CLIProxy directly with ",e.jsx("code",{children:"codex"}),"."]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Saved native Codex recipe"}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:Ee})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsxs("li",{children:["Save a provider named ",e.jsx("code",{children:"cliproxy"})," with the base URL and env key above."]}),e.jsxs("li",{children:["In ",e.jsx("strong",{children:"Top-level settings"}),", set ",e.jsx("strong",{children:"Default provider"})," to"," ",e.jsx("code",{children:"cliproxy"}),"."]}),e.jsxs("li",{children:["Export ",e.jsx("code",{children:"CLIPROXY_API_KEY"})," in your shell before launching native Codex."]})]})]}):e.jsxs("p",{children:["This Codex build can still use the native path, but CCS-backed Codex routing via"," ",e.jsx("code",{children:"ccsxp"})," or ",e.jsx("code",{children:"ccs codex --target codex"})," stays unavailable until the detected Codex binary exposes ",e.jsx("code",{children:"--config"})," overrides."]})})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(xs,{className:"h-4 w-4"}),"Config file"]})}),e.jsx(F,{className:"space-y-3",children:e.jsxs("div",{className:"rounded-md border p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:"User config"}),s.file.exists?e.jsx(hs,{className:"h-4 w-4 text-green-600"}):e.jsx(ps,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(S,{label:"Path",value:s.file.path,mono:!0}),e.jsx(S,{label:"Resolved",value:s.file.resolvedPath,mono:!0}),e.jsx(S,{label:"Size",value:Cr(s.file.sizeBytes)}),e.jsx(S,{label:"Last modified",value:Nr(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:["TOML warning: ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:["Read warning: ",s.file.readError]})]})})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(de,{className:"h-4 w-4"}),"Current user-layer summary"]})}),e.jsxs(F,{className:"space-y-3",children:[e.jsx(S,{label:"Model",value:s.config.model||"Not set",mono:!0}),e.jsx(S,{label:"Model provider",value:s.config.modelProvider||"Not set",mono:!0}),e.jsx(S,{label:"Active profile",value:s.config.activeProfile||"Not set",mono:!0}),e.jsx(S,{label:"Approval policy",value:s.config.approvalPolicy||"Not set",mono:!0}),e.jsx(S,{label:"Sandbox mode",value:s.config.sandboxMode||"Not set",mono:!0}),e.jsx(S,{label:"Web search",value:s.config.webSearch||"Not set",mono:!0}),e.jsx(Q,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs(y,{variant:"outline",className:"justify-center",children:["providers: ",s.config.modelProviderCount]}),e.jsxs(y,{variant:"outline",className:"justify-center",children:["profiles: ",s.config.profileCount]}),e.jsxs(y,{variant:"outline",className:"justify-center",children:["enabled features: ",s.config.enabledFeatures.length]}),e.jsxs(y,{variant:"outline",className:"justify-center",children:["MCP servers: ",s.config.mcpServerCount]})]}),s.config.topLevelKeys.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"User-layer keys present"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(a=>e.jsx(y,{variant:"secondary",className:"font-mono text-[10px]",children:a},a))})]})]})]}),e.jsx(wr,{snippets:[{label:"Native short alias",command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:"CCS Codex shortcut",command:'ccsxp "your prompt"',description:t?"Run the built-in CCS Codex provider on native Codex.":"Requires a Codex build that exposes --config overrides."},{label:"Explicit provider route",command:'ccs codex --target codex "your prompt"',description:t?"Use the explicit built-in Codex provider route.":"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":"Open native Codex",command:r,description:s.config.activeProfile?"Inspect the active named profile directly in native Codex.":"Open native Codex without forcing a named profile overlay."}]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(ve,{className:"h-4 w-4"}),"Runtime vs provider"]})}),e.jsxs(F,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Native Codex runtime"}),e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccs-codex"})}),e.jsx("li",{children:e.jsx("code",{children:"ccsx"})}),e.jsx("li",{children:e.jsx("code",{children:"--target codex"})})]}),e.jsx(y,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:"Honors saved native user config"})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:"CCS Codex provider / bridge"}),t?e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"mt-2 flex-grow list-disc space-y-1.5 pl-4 text-muted-foreground [&>li]:pl-1",children:[e.jsx("li",{children:e.jsx("code",{children:"ccsxp"})}),e.jsx("li",{children:e.jsx("code",{children:"ccs codex --target codex"})})]}),e.jsx(y,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:"Uses transient overrides"})]}):e.jsxs("p",{className:"mt-2 text-muted-foreground",children:["Unavailable (Codex build lacks ",e.jsx("code",{children:"--config"})," support)."]})]})]})]}),e.jsxs(D,{children:[e.jsx(M,{className:"pb-2",children:e.jsx(I,{className:"text-base",children:"Supported flows"})}),e.jsx(F,{children:e.jsxs(vs,{children:[e.jsx(bs,{children:e.jsxs(Ne,{children:[e.jsx(ne,{children:"Flow"}),e.jsx(ne,{children:"Status"}),e.jsx(ne,{children:"Notes"})]})}),e.jsx(ws,{children:s.supportMatrix.map(a=>e.jsxs(Ne,{children:[e.jsx(ae,{className:"font-mono text-xs",children:a.label}),e.jsx(ae,{children:e.jsx(y,{variant:a.supported?"default":"secondary",children:a.supported?"Yes":"No"})}),e.jsx(ae,{className:"text-xs text-muted-foreground",children:a.notes})]},a.id))})]})})]}),s.warnings.length>0&&e.jsxs(D,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(M,{className:"pb-2",children:e.jsxs(I,{className:"flex items-center gap-2 text-base",children:[e.jsx(fs,{className:"h-4 w-4 text-amber-600"}),"Warnings"]})}),e.jsx(F,{className:"space-y-1.5",children:s.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}function Ir(){const{diagnostics:s,diagnosticsLoading:r,diagnosticsError:t,refetchDiagnostics:a,rawConfig:n,rawConfigLoading:l,rawConfigError:i,refetchRawConfig:o,saveRawConfigAsync:d,isSavingRawConfig:c,patchConfigAsync:u,isPatchingConfig:h}=vr(),[j,x]=b.useState(null),g=n?.rawText??"",A=j??g,U=j!==null&&j!==g,m=Re(A),f=m.parseError?{valid:!1,error:m.parseError}:{valid:!0},T=n?.config??null,N=l||!n||U||n?.parseError!==null||n?.readError!==null,De=i?"Structured controls unavailable: failed to load the current config.toml.":n?.readError?`Structured controls unavailable: ${n.readError}`:U?f.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":n?.parseError?`Structured controls disabled: ${n.parseError}`:null,Me=b.useMemo(()=>Oe(T),[T]),Ie=b.useMemo(()=>Vs(T),[T]),Fe=b.useMemo(()=>Xs(T),[T]),Ue=b.useMemo(()=>zs(T),[T]),We=b.useMemo(()=>$s(T),[T]),Ke=b.useMemo(()=>Gs(T),[T]),qe=R=>{if(R===g){x(null);return}x(R)},Ve=async()=>{try{if((await Promise.all([a(),o()])).some(V=>!V||V.status==="error"||V.isError||V.error)){W.error("Failed to refresh Codex snapshot. Raw edits were kept.");return}x(null)}catch(R){W.error(R.message||"Failed to refresh Codex snapshot.")}},Xe=async()=>{if(!f.valid){W.error("Fix TOML before saving.");return}try{await d({rawText:A,expectedMtime:n?.exists?n.mtime:void 0}),x(null),W.success("Saved Codex config.toml."),await a()}catch(R){je(R)?W.error("config.toml changed externally. Refresh and retry."):W.error(R.message||"Failed to save Codex config.toml.")}},ze=async(R,pe)=>{try{await u({...R,expectedMtime:n?.exists?n.mtime:void 0}),x(null),W.success(pe)}catch(V){je(V)?W.error("config.toml changed externally. Refresh and retry."):W.error(V.message||"Failed to update Codex config.")}},se="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",$e=()=>r?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(X,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):t||!s?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-destructive",children:"Failed to load Codex diagnostics."}):e.jsxs(Be,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(He,{className:"grid w-full grid-cols-3",children:[e.jsx(re,{value:"overview",children:"Overview"}),e.jsx(re,{value:"controls",children:"Control Center"}),e.jsx(re,{value:"docs",children:"Docs"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(te,{value:"overview",className:se,children:e.jsx(yr,{diagnostics:s})}),e.jsx(te,{value:"controls",className:se,children:e.jsx(qs,{workspacePath:s.workspacePath,activeProfile:s.config.activeProfile,topLevelSettings:Me,projectTrustEntries:Ie,profileEntries:Fe,modelProviderEntries:Ue,mcpServerEntries:We,featureCatalog:Pe,featureState:Ke,disabled:N,disabledReason:De,saving:h,onPatch:ze})}),e.jsx(te,{value:"docs",className:se,children:e.jsx(Qs,{diagnostics:s})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(Ge,{direction:"horizontal",className:"h-full",children:[e.jsx(fe,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:$e()})}),e.jsx(Ye,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(js,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(fe,{defaultSize:55,minSize:35,children:e.jsx(Ns,{title:"Codex config.toml",pathLabel:n?.path||s?.file.path||"$CODEX_HOME/config.toml",loading:l,parseWarning:f.valid?n?.parseError:f.error,readWarning:n?.readError,value:A,dirty:U,readOnly:!!n?.readError,saving:c,saveDisabled:!U||c||l||!f.valid||!!n?.readError,onChange:R=>{qe(R)},onSave:Xe,onRefresh:Ve,onDiscard:()=>x(null),language:"toml",loadingLabel:"Loading config.toml...",parseWarningLabel:"TOML warning",ownershipNotice:e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/60 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium",children:"This file is upstream-owned by Codex CLI."}),e.jsxs("p",{children:["CCS does not keep ",e.jsx("code",{children:"~/.codex/config.toml"})," in sync for you."]}),e.jsxs("p",{children:["CCS-backed Codex launches may apply transient ",e.jsx("code",{children:"-c"})," overrides and",e.jsx("code",{children:" CCS_CODEX_API_KEY"}),"; those effective values may not appear here."]})]})})})]})})}export{Ir as CodexPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as c,a as d,b as g,c as x,d as h,e as j,f as A,g as D}from"./alert-dialog-QyEXocpn.js";function f({open:i,onConfirm:l,onCancel:r,title:s,description:t,confirmText:a="Confirm",variant:o="default"}){return e.jsx(c,{open:i,onOpenChange:n=>!n&&r(),children:e.jsxs(d,{children:[e.jsxs(g,{children:[e.jsx(x,{children:s}),e.jsx(h,{children:t})]}),e.jsxs(j,{children:[e.jsx(A,{onClick:r,children:"Cancel"}),e.jsx(D,{onClick:l,className:o==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:a})]})]})})}export{f as C};