@kaitranntt/ccs 7.69.1-dev.4 → 7.69.1-dev.5

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 (42) hide show
  1. package/dist/ui/assets/accounts-DamxGxu1.js +1 -0
  2. package/dist/ui/assets/{alert-dialog-CuN8HTEx.js → alert-dialog-sars2LJq.js} +1 -1
  3. package/dist/ui/assets/{api-CI8RoZ-m.js → api-DHF10LeP.js} +1 -1
  4. package/dist/ui/assets/{auth-section-C49fRTna.js → auth-section-BNmbrWhd.js} +1 -1
  5. package/dist/ui/assets/{backups-section-DeJGo6Co.js → backups-section-DGURGm2o.js} +1 -1
  6. package/dist/ui/assets/channels-B0j9pbpo.js +1 -0
  7. package/dist/ui/assets/{checkbox-DVHcE1RO.js → checkbox-DQIFU7Wu.js} +1 -1
  8. package/dist/ui/assets/claude-extension-qxiVTjYL.js +1 -0
  9. package/dist/ui/assets/{cliproxy-BQuYNZ_b.js → cliproxy-CdvU0y2i.js} +1 -1
  10. package/dist/ui/assets/{cliproxy-ai-providers-Bjx7XtY6.js → cliproxy-ai-providers-zgUBcUcJ.js} +1 -1
  11. package/dist/ui/assets/{cliproxy-control-panel-DoLho1iE.js → cliproxy-control-panel-S6FdJjgh.js} +1 -1
  12. package/dist/ui/assets/codex-B79sHpGl.js +27 -0
  13. package/dist/ui/assets/{confirm-dialog-D_5v8muu.js → confirm-dialog-DwrX5gr_.js} +1 -1
  14. package/dist/ui/assets/{copilot-B4waN1q6.js → copilot-CgE4vyvS.js} +1 -1
  15. package/dist/ui/assets/{cursor-DHHZs05u.js → cursor-rYsOav5G.js} +1 -1
  16. package/dist/ui/assets/{droid-CZePX0Pf.js → droid-CQlRU59Q.js} +1 -1
  17. package/dist/ui/assets/{globalenv-section-nQDFHMda.js → globalenv-section-DSQ3m4Ei.js} +1 -1
  18. package/dist/ui/assets/{health-BfS7V7RZ.js → health-DE-wdzdl.js} +1 -1
  19. package/dist/ui/assets/{index-EboJtDBz.js → index-BcJqrfhu.js} +1 -1
  20. package/dist/ui/assets/{index-C5CFzca_.js → index-BwtPYSbP.js} +1 -1
  21. package/dist/ui/assets/{index-CRiWOwLR.js → index-C5VFMOG4.js} +1 -1
  22. package/dist/ui/assets/index-CqJW-L_1.js +1 -0
  23. package/dist/ui/assets/{index-B9VMppQ3.js → index-D1jFmelj.js} +1 -1
  24. package/dist/ui/assets/index-g2g1k0QS.js +72 -0
  25. package/dist/ui/assets/{logs-GW0Oy6XF.js → logs-CDpci_AI.js} +1 -1
  26. package/dist/ui/assets/{masked-input-D1Ilmeh7.js → masked-input-DXzbXJrE.js} +1 -1
  27. package/dist/ui/assets/{proxy-status-widget-Bdh67BxQ.js → proxy-status-widget-DCQBVSBP.js} +1 -1
  28. package/dist/ui/assets/{raw-json-settings-editor-panel-DwzGE_kH.js → raw-json-settings-editor-panel-Db_WTo0f.js} +1 -1
  29. package/dist/ui/assets/{searchable-select-DbhlbNK0.js → searchable-select-CHzzY0Km.js} +1 -1
  30. package/dist/ui/assets/{separator-DziIoy6O.js → separator-Bd4OFZm5.js} +1 -1
  31. package/dist/ui/assets/{shared-XJ2EhJPB.js → shared-B8K097LC.js} +1 -1
  32. package/dist/ui/assets/{table-D5bWyv-8.js → table-7IypCMku.js} +1 -1
  33. package/dist/ui/assets/updates-4X5hHhUg.js +1 -0
  34. package/dist/ui/index.html +1 -1
  35. package/package.json +1 -1
  36. package/dist/ui/assets/accounts-D7sfwYrK.js +0 -1
  37. package/dist/ui/assets/channels-CEHW5H6N.js +0 -1
  38. package/dist/ui/assets/claude-extension-CLmICnx_.js +0 -1
  39. package/dist/ui/assets/codex-BDfvFO8E.js +0 -27
  40. package/dist/ui/assets/index-BDfXfBTa.js +0 -72
  41. package/dist/ui/assets/index-yt8jgaSK.js +0 -1
  42. package/dist/ui/assets/updates-ClhhaqwU.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as S}from"./tanstack-CrmUhA7Z.js";import{a as D,bb as g,Y as I}from"./index-BDfXfBTa.js";import{C as _}from"./default-ports-1QQSffYX.js";import{G as Q,R as $,w as X}from"./icons-KVCk4_U8.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",O="isLoggedIn",U="apiBase",K="apiUrl",F="managementKey";function A(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function J(a,u){window.localStorage.removeItem(k),window.localStorage.setItem(U,a),window.localStorage.setItem(K,a),window.localStorage.setItem(F,u),window.localStorage.setItem(O,"true")}function T(){window.localStorage.removeItem(k),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(F),window.localStorage.removeItem(O)}function V({port:a=_}){const{t:u}=D(),f=s.useRef(null),[M,N]=s.useState(null),[B,Y]=s.useState(0),[L,v]=s.useState(null),[G,E]=s.useState(!1),{data:l,error:w}=S({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{w&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",w)},[w]);const j=!!(l?.remote?.enabled&&l?.remote?.host),{data:y,error:x}=S({queryKey:["auth-tokens-raw",j?"remote":"local"],enabled:l!==void 0&&!j,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return J(A(g("/cliproxy-local/")),o),n}catch(t){throw T(),t}},staleTime:3e4}),{managementUrl:R,checkUrl:h,authToken:b,isRemote:i,displayHost:c}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",m=t.port||(o==="https"?443:_),p=o==="https"&&m===443||o==="http"&&m===80?"":`:${m}`,r=`${o}://${t.host}${p}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${p}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:y?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,y,a]),C=`${R}:${i?"remote":"local"}:${h}:${b??"missing"}:${B}`,P=l!==void 0&&(i||!!y||!!x);s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",x)},[x]),s.useEffect(()=>{if(!i)return()=>{T()}},[i]);const H=!P||!(M===C),q=()=>{if(!(!i||!f.current?.contentWindow||!b))try{const t=A(h),n=new URL(`${t}/`).origin;if(new URL(f.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}f.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:b},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,d)=>{n||(E(r),v(d))},m=async()=>{try{if(i){const r=l?.remote,d=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});d?.reachable?o(!0,null):o(!1,d?.error?`Remote CLIProxy at ${c}: ${d.error}`:`Remote CLIProxy at ${c} returned an error`)}else(await fetch(h,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${c} is not reachable`:"CLIProxy is not running")}},p=setTimeout(()=>t.abort(),2e3);return m().finally(()=>clearTimeout(p)),()=>{n=!0,t.abort()}},[h,i,c,l]);const W=()=>{N(C),q()},z=()=>{N(null),Y(t=>t+1),v(null),E(!1)};return!G&&L?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:u("cliproxyHeader.cliproxyControlPanel")})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:z,children:[e.jsx($,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(X,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:u("cliproxyHeader.cliproxyNotAvailable")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:L}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[H&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx($,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${c}...`:"Loading Control Panel..."})]})}),P?e.jsx("iframe",{ref:f,src:R,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:W},C):null]})})}function me(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(V,{})})}export{me as CliproxyControlPanelPage};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as S}from"./tanstack-CrmUhA7Z.js";import{a as D,bb as g,Y as I}from"./index-g2g1k0QS.js";import{C as _}from"./default-ports-1QQSffYX.js";import{G as Q,R as $,w as X}from"./icons-KVCk4_U8.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",O="isLoggedIn",U="apiBase",K="apiUrl",F="managementKey";function A(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function J(a,u){window.localStorage.removeItem(k),window.localStorage.setItem(U,a),window.localStorage.setItem(K,a),window.localStorage.setItem(F,u),window.localStorage.setItem(O,"true")}function T(){window.localStorage.removeItem(k),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(F),window.localStorage.removeItem(O)}function V({port:a=_}){const{t:u}=D(),f=s.useRef(null),[M,N]=s.useState(null),[B,Y]=s.useState(0),[L,v]=s.useState(null),[G,E]=s.useState(!1),{data:l,error:w}=S({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{w&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",w)},[w]);const j=!!(l?.remote?.enabled&&l?.remote?.host),{data:y,error:x}=S({queryKey:["auth-tokens-raw",j?"remote":"local"],enabled:l!==void 0&&!j,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return J(A(g("/cliproxy-local/")),o),n}catch(t){throw T(),t}},staleTime:3e4}),{managementUrl:R,checkUrl:h,authToken:b,isRemote:i,displayHost:c}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",m=t.port||(o==="https"?443:_),p=o==="https"&&m===443||o==="http"&&m===80?"":`:${m}`,r=`${o}://${t.host}${p}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${p}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:y?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,y,a]),C=`${R}:${i?"remote":"local"}:${h}:${b??"missing"}:${B}`,P=l!==void 0&&(i||!!y||!!x);s.useEffect(()=>{x&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",x)},[x]),s.useEffect(()=>{if(!i)return()=>{T()}},[i]);const H=!P||!(M===C),q=()=>{if(!(!i||!f.current?.contentWindow||!b))try{const t=A(h),n=new URL(`${t}/`).origin;if(new URL(f.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}f.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:b},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,d)=>{n||(E(r),v(d))},m=async()=>{try{if(i){const r=l?.remote,d=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});d?.reachable?o(!0,null):o(!1,d?.error?`Remote CLIProxy at ${c}: ${d.error}`:`Remote CLIProxy at ${c} returned an error`)}else(await fetch(h,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${c} is not reachable`:"CLIProxy is not running")}},p=setTimeout(()=>t.abort(),2e3);return m().finally(()=>clearTimeout(p)),()=>{n=!0,t.abort()}},[h,i,c,l]);const W=()=>{N(C),q()},z=()=>{N(null),Y(t=>t+1),v(null),E(!1)};return!G&&L?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:u("cliproxyHeader.cliproxyControlPanel")})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:z,children:[e.jsx($,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(X,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:u("cliproxyHeader.cliproxyNotAvailable")}),e.jsx("p",{className:"text-muted-foreground mb-4",children:L}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[H&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx($,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${c}...`:"Loading Control Panel..."})]})}),P?e.jsx("iframe",{ref:f,src:R,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:W},C):null]})})}function me(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(V,{})})}export{me as CliproxyControlPanelPage};
@@ -0,0 +1,27 @@
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{t as U}from"./notifications-B2HqRBj7.js";import{C as I,j as F,k as W,B as _,b as K,a as E,d as C,aF as J,r as P,s as O,t as D,v as L,w as v,I as S,n as fe,W as y,bb as se,bc as Pe,c as Oe,bi as He,bj as ve,bk as Qe,Q as Je,R as Ze,U as ae,V as oe,bd as be}from"./index-g2g1k0QS.js";import{aa as es,aR as ss,as as te,L as $,n as ts,aS as rs,aT as ns,aB as as,w as os,a7 as ls,aU as is,aV as cs,aW as ds,ah as me,p as we,$ as xs,m as us,o as ms,_ as ps,S as hs,aM as Ne,aX as fs,x as js,I as gs,T as vs,N as bs}from"./icons-KVCk4_U8.js";import{S as ee}from"./separator-Bd4OFZm5.js";import{a as ws,u as ye,b as Ce}from"./tanstack-CrmUhA7Z.js";import"./code-highlight-BRUf_pqB.js";import{T as Ns,a as ys,b as Se,c as le,d as Cs,e as ie}from"./table-7IypCMku.js";import{R as Ss}from"./raw-json-settings-editor-panel-Db_WTo0f.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";function Z({title:s,icon:t,badge:r,description:l,disabledReason:o,children:n}){return e.jsxs(I,{children:[e.jsxs(F,{className:"pb-2",children:[e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[t,s,r?e.jsx(_,{variant:"outline",className:"text-[10px] font-normal",children:r}):null]}),l?e.jsx("p",{className:"text-xs text-muted-foreground",children:l}):null]}),e.jsxs(K,{className:"space-y-3",children:[o?e.jsx("p",{className:"text-xs text-amber-600",children:o}):null,n]})]})}function _s({catalog:s,state:t,disabled:r=!1,disabledReason:l,onToggle:o}){const{t:n}=E(),a=new Set(s.map(i=>i.name)),c=Object.entries(t).filter(([i])=>!a.has(i)).sort(([i],[d])=>i.localeCompare(d));return e.jsxs(Z,{title:n("codex.features"),badge:"features",icon:e.jsx(es,{className:"h-4 w-4"}),description:n("codex.featuresDesc"),disabledReason:l,children:[e.jsx("div",{className:"space-y-2",children:s.map(i=>{const d=t[i.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:i.label}),e.jsx(_,{variant:"outline",className:"font-mono text-[10px]",children:i.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d!==null?e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i.name,null),disabled:r,children:n("codex.useDefault")}):null,e.jsx(J,{checked:d===!0,onCheckedChange:x=>o(i.name,x),disabled:r})]})]},i.name)})}),c.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:n("codex.configOnlyFlags")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("codex.configOnlyFlagsDesc")})]}),c.map(([i,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:i}),e.jsx(_,{variant:"secondary",className:"text-[10px]",children:n("codex.existing")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n(d===null?"codex.nonBooleanForm":"codex.discoveredFromFile")})]}),d===null?e.jsx(_,{variant:"outline",children:n("codex.rawOnly")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>o(i,null),disabled:r,children:n("codex.useDefault")}),e.jsx(J,{checked:d===!0,onCheckedChange:x=>o(i,x),disabled:r})]})]},i))]}):null]})}const ks={name:"",transport:"stdio",command:null,args:[],url:null,enabled:!0,required:!1,startupTimeoutSec:null,toolTimeoutSec:null,enabledTools:[],disabledTools:[]};function ce(s){return s.join(", ")}function de(s){return s.split(",").map(t=>t.trim()).filter(Boolean)}function Ts({initialDraft:s,isNew:t,disabled:r,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=w.useState(s);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:x=>d(m=>({...m,name:x.target.value})),placeholder:"playwright",disabled:r||!t}),e.jsxs(P,{value:i.transport,onValueChange:x=>d(m=>({...m,transport:x})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(v,{value:"stdio",children:c("codex.stdio")}),e.jsx(v,{value:"streamable-http",children:c("codex.streamableHttp")})]})]}),i.transport==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(S,{value:i.command??"",onChange:x=>d(m=>({...m,command:x.target.value||null})),placeholder:"npx",disabled:r}),e.jsx(S,{value:ce(i.args),onChange:x=>d(m=>({...m,args:de(x.target.value)})),placeholder:"@playwright/mcp@latest, --flag",disabled:r})]}):e.jsx(S,{className:"sm:col-span-2",value:i.url??"",onChange:x=>d(m=>({...m,url:x.target.value||null})),placeholder:"https://example.test/mcp",disabled:r}),e.jsx(S,{type:"number",min:1,value:i.startupTimeoutSec??"",onChange:x=>d(m=>({...m,startupTimeoutSec:x.target.value?Number(x.target.value):null})),placeholder:"Startup timeout (sec)",disabled:r}),e.jsx(S,{type:"number",min:1,value:i.toolTimeoutSec??"",onChange:x=>d(m=>({...m,toolTimeoutSec:x.target.value?Number(x.target.value):null})),placeholder:"Tool timeout (sec)",disabled:r}),e.jsx(S,{value:ce(i.enabledTools),onChange:x=>d(m=>({...m,enabledTools:de(x.target.value)})),placeholder:"enabled_tools",disabled:r}),e.jsx(S,{value:ce(i.disabledTools),onChange:x=>d(m=>({...m,disabledTools:de(x.target.value)})),placeholder:"disabled_tools",disabled:r})]}),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(J,{checked:i.enabled,onCheckedChange:x=>d(m=>({...m,enabled:x})),disabled:r})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Required",e.jsx(J,{checked:i.required,onCheckedChange:x=>d(m=>({...m,required:x})),disabled:r})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:r||l||!o,children:[e.jsx(te,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{transport:i.transport,command:i.command,args:i.args,url:i.url,enabled:i.enabled,required:i.required,startupTimeoutSec:i.startupTimeoutSec,toolTimeoutSec:i.toolTimeoutSec,enabledTools:i.enabledTools,disabledTools:i.disabledTools}),disabled:r||l||i.name.trim().length===0,children:[l?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save MCP server"]})]})]})}function Es({entries:s,disabled:t=!1,disabledReason:r,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=w.useState("new"),d=w.useMemo(()=>s.find(p=>p.name===c)??null,[s,c]),x=d??ks,m=JSON.stringify(x);return e.jsxs(Z,{title:"MCP servers",badge:"mcp_servers",icon:e.jsx(ss,{className:"h-4 w-4"}),description:"Manage the safe MCP transport fields. Keep auth headers and bearer tokens in raw TOML.",disabledReason:r,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select MCP server"})}),e.jsxs(L,{children:[e.jsx(v,{value:"new",children:a("codex.createNewMcpServer")}),s.map(p=>e.jsx(v,{value:p.name,children:p.name},p.name))]})]}),e.jsx(Ts,{initialDraft:x,isNew:c==="new",disabled:t,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(p,N)=>{await o(p,N),i(p)}},m)]})}const Ps={name:"",displayName:null,baseUrl:null,envKey:null,wireApi:"responses",requiresOpenaiAuth:!1,supportsWebsockets:!1},Os={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 Ds({initialDraft:s,isNew:t,disabled:r,saving:l,canDelete:o,onSave:n,onDelete:a}){const{t:c}=E(),[i,d]=w.useState(s);return e.jsxs(e.Fragment,{children:[t&&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:c("codex.defaultProvider")})," to ",e.jsx("code",{children:"cliproxy"})," in Top-level settings."]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>d(Os),disabled:r,children:"Use CLIProxy Codex preset"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:i.name,onChange:x=>d(m=>({...m,name:x.target.value})),placeholder:"Provider id",disabled:r||!t}),e.jsx(S,{value:i.displayName??"",onChange:x=>d(m=>({...m,displayName:x.target.value||null})),placeholder:"Display name",disabled:r}),e.jsx(S,{value:i.baseUrl??"",onChange:x=>d(m=>({...m,baseUrl:x.target.value||null})),placeholder:"http://127.0.0.1:8317/api/provider/codex",disabled:r}),e.jsx(S,{value:i.envKey??"",onChange:x=>d(m=>({...m,envKey:x.target.value||null})),placeholder:"CLIPROXY_API_KEY",disabled:r})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs(P,{value:i.wireApi??"responses",onValueChange:x=>d(m=>({...m,wireApi:x})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsx(L,{children:e.jsx(v,{value:"responses",children:c("codex.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(J,{checked:i.requiresOpenaiAuth,onCheckedChange:x=>d(m=>({...m,requiresOpenaiAuth:x})),disabled:r})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-md border px-3 py-2 text-sm",children:["Supports websockets",e.jsx(J,{checked:i.supportsWebsockets,onCheckedChange:x=>d(m=>({...m,supportsWebsockets:x})),disabled:r})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs(C,{variant:"outline",onClick:a,disabled:r||l||!o,children:[e.jsx(te,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs(C,{onClick:()=>n(i.name,{displayName:i.displayName,baseUrl:i.baseUrl,envKey:i.envKey,wireApi:i.wireApi,requiresOpenaiAuth:i.requiresOpenaiAuth,supportsWebsockets:i.supportsWebsockets}),disabled:r||l||i.name.trim().length===0,children:[l?e.jsx($,{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:c("codex.defaultProvider")})," control above."]})]})}function Ls({entries:s,disabled:t=!1,disabledReason:r,saving:l=!1,onSave:o,onDelete:n}){const{t:a}=E(),[c,i]=w.useState("new"),d=w.useMemo(()=>s.find(p=>p.name===c)??null,[s,c]),x=d??Ps,m=JSON.stringify(x);return e.jsxs(Z,{title:"Model providers",badge:"model_providers",icon:e.jsx(ts,{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:r,children:[e.jsxs(P,{value:c,onValueChange:i,disabled:t,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select provider"})}),e.jsxs(L,{children:[e.jsx(v,{value:"new",children:a("codex.createNewProvider")}),s.map(p=>e.jsx(v,{value:p.name,children:p.name},p.name))]})]}),e.jsx(Ds,{initialDraft:x,isNew:c==="new",disabled:t,saving:l,canDelete:d!==null,onDelete:async()=>{d&&(await n(d.name),i("new"))},onSave:async(p,N)=>{await o(p,N),i(p)}},m)]})}function As({initialName:s,initialModel:t,initialProvider:r,initialEffort:l,providerNames:o,activeProfile:n,selectedEntryName:a,disabled:c,saving:i,onSave:d,onDelete:x,onSetActive:m}){const{t:p}=E(),[N,h]=w.useState(s),[b,R]=w.useState(t),[q,u]=w.useState(r),[g,z]=w.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(S,{value:N,onChange:j=>h(j.target.value),placeholder:"deep-review",disabled:c||a!==null}),e.jsx(S,{value:b??"",onChange:j=>R(j.target.value||null),placeholder:"gpt-5.4",disabled:c}),e.jsxs(P,{value:q??"__unset__",onValueChange:j=>u(j==="__unset__"?null:j),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:p("codex.useGlobalProvider")})}),e.jsxs(L,{children:[e.jsx(v,{value:"__unset__",children:p("codex.useGlobalProvider")}),o.map(j=>e.jsx(v,{value:j,children:j},j))]})]}),e.jsxs(P,{value:g??"__unset__",onValueChange:j=>z(j==="__unset__"?null:j),disabled:c,children:[e.jsx(O,{children:e.jsx(D,{placeholder:p("codex.useGlobalEffort")})}),e.jsxs(L,{children:[e.jsx(v,{value:"__unset__",children:p("codex.useGlobalEffort")}),["minimal","low","medium","high","xhigh"].map(j=>e.jsx(v,{value:j,children:j},j))]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:x,disabled:c||i||!a,children:[e.jsx(te,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsx(C,{variant:"outline",onClick:m,disabled:c||i||!a||a===n,children:"Set active"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",onClick:()=>d(N,{model:b,modelProvider:q,modelReasoningEffort:g},!1),disabled:c||i||N.trim().length===0,children:[i?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save profile"]}),e.jsxs(C,{onClick:()=>d(N,{model:b,modelProvider:q,modelReasoningEffort:g},!0),disabled:c||i||N.trim().length===0,children:[i?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save + activate"]})]})]})]})}function Rs({activeProfile:s,entries:t,providerNames:r,disabled:l=!1,disabledReason:o,saving:n=!1,onSave:a,onDelete:c,onSetActive:i}){const{t:d}=E(),[x,m]=w.useState("new"),p=w.useMemo(()=>t.find(h=>h.name===x)??null,[t,x]),N=JSON.stringify(p??{name:"",values:{}});return e.jsxs(Z,{title:d("codex.profiles"),badge:"profiles",icon:e.jsx(rs,{className:"h-4 w-4"}),description:"Create reusable Codex overlays and set the active default profile.",disabledReason:o,children:[e.jsxs(P,{value:x,onValueChange:m,disabled:l,children:[e.jsx(O,{children:e.jsx(D,{placeholder:"Select profile"})}),e.jsxs(L,{children:[e.jsx(v,{value:"new",children:d("codex.createNewProfile")}),t.map(h=>e.jsxs(v,{value:h.name,children:[h.name,h.name===s?" (active)":""]},h.name))]})]}),e.jsx(As,{initialName:p?.name??"",initialModel:p?.values.model??null,initialProvider:p?.values.modelProvider??null,initialEffort:p?.values.modelReasoningEffort??null,providerNames:r,activeProfile:s,selectedEntryName:p?.name??null,disabled:l,saving:n,onDelete:async()=>{p&&(await c(p.name),m("new"))},onSetActive:async()=>{p&&await i(p.name)},onSave:async(h,b,R)=>{await a(h,b,R),m(h)}},N)]})}function Ms({workspacePath:s,disabled:t,saving:r,onSave:l}){const{t:o}=E(),[n,a]=w.useState(s),[c,i]=w.useState("trusted");return e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_160px_auto]",children:[e.jsx(S,{value:n,onChange:d=>a(d.target.value),placeholder:"~/repo or /absolute/path",disabled:t}),e.jsxs(P,{value:c,onValueChange:i,disabled:t,children:[e.jsx(O,{children:e.jsx(D,{})}),e.jsxs(L,{children:[e.jsx(v,{value:"trusted",children:o("codex.trusted")}),e.jsx(v,{value:"untrusted",children:o("codex.untrusted")})]})]}),e.jsxs(C,{onClick:()=>l(n,c),disabled:t||r,children:[r?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save trust"]})]})}function Is({workspacePath:s,entries:t,disabled:r=!1,disabledReason:l,saving:o=!1,onSave:n}){const{t:a}=E();return e.jsxs(Z,{title:"Project trust",badge:"projects",icon:e.jsx(ns,{className:"h-4 w-4"}),description:"Trust current workspaces or remove stale trust entries without opening raw TOML.",disabledReason:l,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(Ms,{workspacePath:s,disabled:r,saving:o,onSave:n},s),e.jsx(C,{variant:"outline",className:"w-full justify-start",onClick:()=>n(s,"trusted"),disabled:r||o,children:"Trust current workspace"}),e.jsx("div",{className:"space-y-2",children:t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:a("codex.noProjectTrustEntries")}):t.map(c=>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:c.path}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["trust_level = ",c.trustLevel]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(c.path,c.trustLevel==="trusted"?"untrusted":"trusted"),disabled:r||o,children:"Toggle"}),e.jsx(C,{variant:"ghost",size:"icon",onClick:()=>n(c.path,null),disabled:r||o,children:e.jsx(te,{className:"h-4 w-4"})})]})]},c.path))})]})}const A="__unset__",Fs=105e4,Ws=272e3,_e=8e5,ke=7e5,Ks=new Intl.NumberFormat("en-US");function B(s){return s??A}function Y(s,t){return t&&!s.includes(t)?[t,...s]:s}function xe(s){return Ks.format(s)}function qs(s){return s?.trim().toLowerCase().startsWith("gpt-5.4")??!1}function Us(s,t){const r={};return t.model!==s.model&&(r.model=t.model),t.modelReasoningEffort!==s.modelReasoningEffort&&(r.modelReasoningEffort=t.modelReasoningEffort),t.modelContextWindow!==s.modelContextWindow&&(r.modelContextWindow=t.modelContextWindow),t.modelAutoCompactTokenLimit!==s.modelAutoCompactTokenLimit&&(r.modelAutoCompactTokenLimit=t.modelAutoCompactTokenLimit),t.modelProvider!==s.modelProvider&&(r.modelProvider=t.modelProvider),t.approvalPolicy!==s.approvalPolicy&&(r.approvalPolicy=t.approvalPolicy),t.sandboxMode!==s.sandboxMode&&(r.sandboxMode=t.sandboxMode),t.webSearch!==s.webSearch&&(r.webSearch=t.webSearch),t.toolOutputTokenLimit!==s.toolOutputTokenLimit&&(r.toolOutputTokenLimit=t.toolOutputTokenLimit),t.personality!==s.personality&&(r.personality=t.personality),r}function Vs({initialValues:s,providerNames:t,disabled:r,saving:l,onSave:o}){const{t:n}=E(),[a,c]=w.useState(s),i=Y(["minimal","low","medium","high","xhigh"],a.modelReasoningEffort),d=Y(t,a.modelProvider),x=Y(["on-request","never","untrusted"],a.approvalPolicy),m=Y(["read-only","workspace-write","danger-full-access"],a.sandboxMode),p=Y(["cached","live","disabled"],a.webSearch),N=Y(["none","friendly","pragmatic"],a.personality),h=Us(s,a),b=Object.keys(h).length>0,R=qs(a.model),q=u=>{const g=u.trim();return g.length>0?Number(g):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:n("codex.model")}),e.jsx(S,{value:a.model??"",onChange:u=>c(g=>({...g,model:u.target.value||null})),placeholder:"gpt-5.4",disabled:r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.reasoningEffort")}),e.jsxs(P,{value:B(a.modelReasoningEffort),onValueChange:u=>c(g=>({...g,modelReasoningEffort:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useDefault")}),i.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.defaultProvider")}),e.jsxs(P,{value:B(a.modelProvider),onValueChange:u=>c(g=>({...g,modelProvider:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useCodexDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useCodexDefault")}),d.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.approvalPolicy")}),e.jsxs(P,{value:B(a.approvalPolicy),onValueChange:u=>c(g=>({...g,approvalPolicy:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useDefault")}),x.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.sandboxMode")}),e.jsxs(P,{value:B(a.sandboxMode),onValueChange:u=>c(g=>({...g,sandboxMode:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useDefault")}),m.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.webSearch")}),e.jsxs(P,{value:B(a.webSearch),onValueChange:u=>c(g=>({...g,webSearch:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useDefault")}),p.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.toolOutputTokenLimit")}),e.jsx(S,{type:"number",min:1,value:a.toolOutputTokenLimit??"",onChange:u=>c(g=>({...g,toolOutputTokenLimit:u.target.value?Number(u.target.value):null})),placeholder:"25000",disabled:r})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:n("codex.personality")}),e.jsxs(P,{value:B(a.personality),onValueChange:u=>c(g=>({...g,personality:u===A?null:u})),disabled:r,children:[e.jsx(O,{children:e.jsx(D,{placeholder:n("codex.useDefault")})}),e.jsxs(L,{children:[e.jsx(v,{value:A,children:n("codex.useDefault")}),N.map(u=>e.jsx(v,{value:u,children:u},u))]})]})]})]}),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(os,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"}),e.jsx("p",{className:"text-sm font-semibold",children:n("codex.longContextOverride")}),e.jsx(_,{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(_,{variant:"secondary",className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:R?"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(C,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>c(u=>({...u,modelContextWindow:_e,modelAutoCompactTokenLimit:ke})),children:"Fill cautious pair"}),e.jsx(C,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:()=>c(u=>({...u,modelContextWindow:Fs})),children:"Set official max window"}),e.jsx(C,{type:"button",variant:"ghost",size:"sm",disabled:r,onClick:()=>c(u=>({...u,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:n("codex.gptContextCap")})]}),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:xe(Ws)}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.normalUsageWindow")})]}),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:n("codex.counts2x")}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:n("codex.usageLimitCost")})]})]}),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 ",xe(_e)]}),e.jsxs("div",{className:"rounded-full border bg-background px-2.5 py-1 font-mono text-[11px] font-medium",children:["Auto-compact ",xe(ke)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(_,{variant:"outline",className:"border-border/70 bg-background/80 text-[10px] uppercase tracking-[0.14em] text-muted-foreground",children:"Not official"}),e.jsx(_,{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:n("codex.quickFillWarning")}),!R&&a.model?e.jsxs("span",{children:[e.jsx("code",{children:a.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:n("codex.modelContextWindow")}),e.jsx(S,{"aria-label":n("codex.modelContextWindow"),type:"number",min:1,value:a.modelContextWindow??"",onChange:u=>c(g=>({...g,modelContextWindow:q(u.target.value)})),placeholder:"Unset",disabled:r}),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:n("codex.autoCompactTokenLimit")}),e.jsx(S,{"aria-label":n("codex.autoCompactTokenLimit"),type:"number",min:1,value:a.modelAutoCompactTokenLimit??"",onChange:u=>c(g=>({...g,modelAutoCompactTokenLimit:q(u.target.value)})),placeholder:"Unset",disabled:r}),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(C,{onClick:()=>o(h),disabled:r||l||!b,children:[l?e.jsx($,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save top-level settings"]})})]})}function Gs({values:s,providerNames:t,disabled:r=!1,disabledReason:l,saving:o=!1,onSave:n}){return e.jsx(Z,{title:"Top-level controls",badge:"config.toml",icon:e.jsx(as,{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:l,children:e.jsx(Vs,{initialValues:s,providerNames:t,disabled:r,saving:o,onSave:n},JSON.stringify(s))})}function zs({workspacePath:s,activeProfile:t,topLevelSettings:r,projectTrustEntries:l,profileEntries:o,modelProviderEntries:n,mcpServerEntries:a,featureCatalog:c,featureState:i,disabled:d,disabledReason:x,saving:m,onPatch:p}){const{t:N}=E();return e.jsx(fe,{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(ls,{className:"h-4 w-4"})}),e.jsx("div",{children:e.jsx("h2",{className:"text-base font-semibold tracking-tight text-foreground",children:N("codex.controlCenter")})})]}),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(is,{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(cs,{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(ds,{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(Gs,{values:r,providerNames:n.map(h=>h.name),disabled:d,disabledReason:x,saving:m,onSave:h=>p({kind:"top-level",values:h},N("toasts.codexSaved"))}),e.jsx(Is,{workspacePath:s,entries:l,disabled:d,disabledReason:x,saving:m,onSave:(h,b)=>p({kind:"project-trust",path:h,trustLevel:b},b?"Saved project trust entry.":"Removed project trust entry.")}),e.jsx(Rs,{activeProfile:t,entries:o,providerNames:n.map(h=>h.name),disabled:d,disabledReason:x,saving:m,onSave:(h,b,R)=>p({kind:"profile",action:"upsert",name:h,values:b,setAsActive:R},"Saved profile."),onDelete:h=>p({kind:"profile",action:"delete",name:h},"Deleted profile."),onSetActive:h=>p({kind:"profile",action:"set-active",name:h},"Set active profile.")}),e.jsx(Ls,{entries:n,disabled:d,disabledReason:x,saving:m,onSave:(h,b)=>p({kind:"model-provider",action:"upsert",name:h,values:b},"Saved model provider."),onDelete:h=>p({kind:"model-provider",action:"delete",name:h},"Deleted model provider.")}),e.jsx(Es,{entries:a,disabled:d,disabledReason:x,saving:m,onSave:(h,b)=>p({kind:"mcp-server",action:"upsert",name:h,values:b},"Saved MCP server."),onDelete:h=>p({kind:"mcp-server",action:"delete",name:h},"Deleted MCP server.")}),e.jsx(_s,{catalog:c,state:i,disabled:d,disabledReason:x,onToggle:(h,b)=>p({kind:"feature",feature:h,enabled:b},"Saved feature toggle.")})]})})}const De=`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"`,Xs=["multi_agent","unified_exec","shell_snapshot","apply_patch_freeform","js_repl","runtime_metrics","prevent_idle_sleep","fast_mode","apps","smart_approvals"];function $s(){return[{name:"multi_agent",label:y.t("codex.featureMultiAgentLabel"),description:y.t("codex.featureMultiAgentDesc")},{name:"unified_exec",label:y.t("codex.featureUnifiedExecLabel"),description:y.t("codex.featureUnifiedExecDesc")},{name:"shell_snapshot",label:y.t("codex.featureShellSnapshotLabel"),description:y.t("codex.featureShellSnapshotDesc")},{name:"apply_patch_freeform",label:y.t("codex.featureApplyPatchLabel"),description:y.t("codex.featureApplyPatchDesc")},{name:"js_repl",label:y.t("codex.featureJsReplLabel"),description:y.t("codex.featureJsReplDesc")},{name:"runtime_metrics",label:y.t("codex.featureRuntimeMetricsLabel"),description:y.t("codex.featureRuntimeMetricsDesc")},{name:"prevent_idle_sleep",label:y.t("codex.featurePreventIdleSleepLabel"),description:y.t("codex.featurePreventIdleSleepDesc")},{name:"fast_mode",label:y.t("codex.featureFastModeLabel"),description:y.t("codex.featureFastModeDesc")},{name:"apps",label:y.t("codex.featureAppsLabel"),description:y.t("codex.featureAppsDesc")},{name:"smart_approvals",label:y.t("codex.featureSmartApprovalsLabel"),description:y.t("codex.featureSmartApprovalsDesc")}]}function G(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)?s:null}function T(s){return typeof s=="string"&&s.trim().length>0?s.trim():null}function Q(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function ue(s){return Array.isArray(s)?s.filter(t=>typeof t=="string").map(t=>t.trim()):[]}function Le(s){return{model:T(s?.model),modelReasoningEffort:T(s?.model_reasoning_effort),modelContextWindow:Q(s?.model_context_window),modelAutoCompactTokenLimit:Q(s?.model_auto_compact_token_limit),modelProvider:T(s?.model_provider),approvalPolicy:T(s?.approval_policy),sandboxMode:T(s?.sandbox_mode),webSearch:T(s?.web_search),toolOutputTokenLimit:Q(s?.tool_output_token_limit),personality:T(s?.personality)}}function Bs(s){const t=G(s?.projects);return t?Object.entries(t).map(([r,l])=>{const o=T(G(l)?.trust_level);return o?{path:r,trustLevel:o}:null}).filter(r=>r!==null).sort((r,l)=>r.path.localeCompare(l.path)):[]}function Ys(s){const t=G(s?.profiles);return t?Object.entries(t).map(([r,l])=>({name:r,values:Le(G(l))})).sort((r,l)=>r.name.localeCompare(l.name)):[]}function Hs(s){const t=G(s?.model_providers);return t?Object.entries(t).map(([r,l])=>{const o=G(l);return o?{name:r,displayName:T(o.name),baseUrl:T(o.base_url),envKey:T(o.env_key),wireApi:T(o.wire_api),requiresOpenaiAuth:o.requires_openai_auth===!0,supportsWebsockets:o.supports_websockets===!0}:null}).filter(r=>r!==null).sort((r,l)=>r.name.localeCompare(l.name)):[]}function Qs(s){const t=G(s?.mcp_servers);return t?Object.entries(t).map(([r,l])=>{const o=G(l);if(!o)return null;const n=T(o.command)?"stdio":"streamable-http",a=Q(o.startup_timeout_ms);return{name:r,transport:n,command:T(o.command),args:ue(o.args),url:T(o.url),enabled:o.enabled!==!1,required:o.required===!0,startupTimeoutSec:Q(o.startup_timeout_sec)??(a!==null?a/1e3:null),toolTimeoutSec:Q(o.tool_timeout_sec),enabledTools:ue(o.enabled_tools),disabledTools:ue(o.disabled_tools)}}).filter(r=>r!==null).sort((r,l)=>r.name.localeCompare(l.name)):[]}function Js(s){const t=G(s?.features),r={};for(const l of Xs){const o=t?.[l];r[l]=typeof o=="boolean"?o:null}if(t)for(const[l,o]of Object.entries(t))l in r||(r[l]=typeof o=="boolean"?o:null);return r}const Zs=[{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."}],et=[{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"}];function st(s){const t=/https?:\/\/[^\s)]+/g,r=[];let l=0,o;for(;(o=t.exec(s))!==null;){const[n]=o,a=o.index;a>l&&r.push(s.slice(l,a)),r.push(e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:n},`${n}-${a}`)),l=a+n.length}return l<s.length&&r.push(s.slice(l)),r.length>0?r:[s]}function tt({diagnostics:s}){const{t}=E(),r=s.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},l=r.links.length>0?r.links:Zs,o=r.providerDocs.length>0?r.providerDocs:et;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"CCS bridge recipe"]})}),e.jsxs(K,{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:De}),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(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),"Upstream notes"]})}),e.jsxs(K,{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,a)=>e.jsx("li",{children:st(n)},`${a}-${n}`))}),e.jsx(ee,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:t("codex.codexDocs")}),e.jsx("div",{className:"space-y-1.5",children:l.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(we,{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(ee,{}),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:o.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(we,{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(ee,{}),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 rt(s,t){let r=s.slice(0,t).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function nt(s,t,r){let l=s.split(/\r\n|\n|\r/g),o="",n=(Math.log10(t+1)|0)+1;for(let a=t-1;a<=t+1;a++){let c=l[a-1];c&&(o+=a.toString().padEnd(n," "),o+=": ",o+=c,o+=`
7
+ `,a===t&&(o+=" ".repeat(n+r+2),o+=`^
8
+ `))}return o}class f extends Error{line;column;codeblock;constructor(t,r){const[l,o]=rt(r.toml,r.ptr),n=nt(r.toml,l,o);super(`Invalid TOML document: ${t}
9
+
10
+ ${n}`,r),this.line=l,this.column=o,this.codeblock=n}}function at(s,t){let r=0;for(;s[t-++r]==="\\";);return--r&&r%2}function pe(s,t=0,r=s.length){let l=s.indexOf(`
11
+ `,t);return s[l-1]==="\r"&&l--,l<=r?l:-1}function re(s,t){for(let r=t;r<s.length;r++){let l=s[r];if(l===`
12
+ `)return r;if(l==="\r"&&s[r+1]===`
13
+ `)return r+1;if(l<" "&&l!==" "||l==="")throw new f("control characters are not allowed in comments",{toml:s,ptr:t})}return s.length}function V(s,t,r,l){let o;for(;;){for(;(o=s[t])===" "||o===" "||!r&&(o===`
14
+ `||o==="\r"&&s[t+1]===`
15
+ `);)t++;if(l||o!=="#")break;t=re(s,t)}return t}function ot(s,t,r,l,o=!1){if(!l)return t=pe(s,t),t<0?s.length:t;for(let n=t;n<s.length;n++){let a=s[n];if(a==="#")n=pe(s,n);else{if(a===r)return n+1;if(a===l||o&&(a===`
16
+ `||a==="\r"&&s[n+1]===`
17
+ `))return n}}throw new f("cannot find end of structure",{toml:s,ptr:t})}function Ae(s,t){let r=s[t],l=r===s[t+1]&&s[t+1]===s[t+2]?s.slice(t,t+3):r;t+=l.length-1;do t=s.indexOf(l,++t);while(t>-1&&r!=="'"&&at(s,t));return t>-1&&(t+=l.length,l.length>1&&(s[t]===r&&t++,s[t]===r&&t++)),t}let lt=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class H extends Date{#s=!1;#t=!1;#e=null;constructor(t){let r=!0,l=!0,o="Z";if(typeof t=="string"){let n=t.match(lt);n?(n[1]||(r=!1,t=`0000-01-01T${t}`),l=!!n[2],l&&t[10]===" "&&(t=t.replace(" ","T")),n[2]&&+n[2]>23?t="":(o=n[3]||null,t=t.toUpperCase(),!o&&l&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#s=r,this.#t=l,this.#e=o)}isDateTime(){return this.#s&&this.#t}isLocal(){return!this.#s||!this.#t||!this.#e}isDate(){return this.#s&&!this.#t}isTime(){return this.#t&&!this.#s}isValid(){return this.#s||this.#t}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,r="Z"){let l=new H(t);return l.#e=r,l}static wrapAsLocalDateTime(t){let r=new H(t);return r.#e=null,r}static wrapAsLocalDate(t){let r=new H(t);return r.#t=!1,r.#e=null,r}static wrapAsLocalTime(t){let r=new H(t);return r.#s=!1,r.#e=null,r}}let it=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,ct=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,dt=/^[+-]?0[0-9_]/,xt=/^[0-9a-f]{2,8}$/i,Te={b:"\b",t:" ",n:`
18
+ `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Re(s,t=0,r=s.length){let l=s[t]==="'",o=s[t++]===s[t]&&s[t]===s[t+1];o&&(r-=2,s[t+=2]==="\r"&&t++,s[t]===`
19
+ `&&t++);let n=0,a,c="",i=t;for(;t<r-1;){let d=s[t++];if(d===`
20
+ `||d==="\r"&&s[t]===`
21
+ `){if(!o)throw new f("newlines are not allowed in strings",{toml:s,ptr:t-1})}else if(d<" "&&d!==" "||d==="")throw new f("control characters are not allowed in strings",{toml:s,ptr:t-1});if(a){if(a=!1,d==="x"||d==="u"||d==="U"){let x=s.slice(t,t+=d==="x"?2:d==="u"?4:8);if(!xt.test(x))throw new f("invalid unicode escape",{toml:s,ptr:n});try{c+=String.fromCodePoint(parseInt(x,16))}catch{throw new f("invalid unicode escape",{toml:s,ptr:n})}}else if(o&&(d===`
22
+ `||d===" "||d===" "||d==="\r")){if(t=V(s,t-1,!0),s[t]!==`
23
+ `&&s[t]!=="\r")throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:s,ptr:n});t=V(s,t)}else if(d in Te)c+=Te[d];else throw new f("unrecognized escape sequence",{toml:s,ptr:n});i=t}else!l&&d==="\\"&&(n=t-1,a=!0,c+=s.slice(i,n))}return c+s.slice(i,r-1)}function ut(s,t,r,l){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 l?0n:0;let o=it.test(s);if(o||ct.test(s)){if(dt.test(s))throw new f("leading zeroes are not allowed",{toml:t,ptr:r});s=s.replace(/_/g,"");let a=+s;if(isNaN(a))throw new f("invalid number",{toml:t,ptr:r});if(o){if((o=!Number.isSafeInteger(a))&&!l)throw new f("integer value cannot be represented losslessly",{toml:t,ptr:r});(o||l===!0)&&(a=BigInt(s))}return a}const n=new H(s);if(!n.isValid())throw new f("invalid value",{toml:t,ptr:r});return n}function mt(s,t,r){let l=s.slice(t,r),o=l.indexOf("#");return o>-1&&(re(s,o),l=l.slice(0,o)),[l.trimEnd(),o]}function je(s,t,r,l,o){if(l===0)throw new f("document contains excessively nested structures. aborting.",{toml:s,ptr:t});let n=s[t];if(n==="["||n==="{"){let[i,d]=n==="["?ft(s,t,l,o):ht(s,t,l,o);if(r){if(d=V(s,d),s[d]===",")d++;else if(s[d]!==r)throw new f("expected comma or end of structure",{toml:s,ptr:d})}return[i,d]}let a;if(n==='"'||n==="'"){a=Ae(s,t);let i=Re(s,t,a);if(r){if(a=V(s,a),s[a]&&s[a]!==","&&s[a]!==r&&s[a]!==`
24
+ `&&s[a]!=="\r")throw new f("unexpected character encountered",{toml:s,ptr:a});a+=+(s[a]===",")}return[i,a]}a=ot(s,t,",",r);let c=mt(s,t,a-+(s[a-1]===","));if(!c[0])throw new f("incomplete key-value declaration: no value specified",{toml:s,ptr:t});return r&&c[1]>-1&&(a=V(s,t+c[1]),a+=+(s[a]===",")),[ut(c[0],s,t,o),a]}let pt=/^[a-zA-Z0-9-_]+[ \t]*$/;function he(s,t,r="="){let l=t-1,o=[],n=s.indexOf(r,t);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:t});do{let a=s[t=++l];if(a!==" "&&a!==" ")if(a==='"'||a==="'"){if(a===s[t+1]&&a===s[t+2])throw new f("multiline strings are not allowed in keys",{toml:s,ptr:t});let c=Ae(s,t);if(c<0)throw new f("unfinished string encountered",{toml:s,ptr:t});l=s.indexOf(".",c);let i=s.slice(c,l<0||l>n?n:l),d=pe(i);if(d>-1)throw new f("newlines are not allowed in keys",{toml:s,ptr:t+l+d});if(i.trimStart())throw new f("found extra tokens after the string part",{toml:s,ptr:c});if(n<c&&(n=s.indexOf(r,c),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:s,ptr:t});o.push(Re(s,t,c))}else{l=s.indexOf(".",t);let c=s.slice(t,l<0||l>n?n:l);if(!pt.test(c))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:s,ptr:t});o.push(c.trimEnd())}}while(l+1&&l<n);return[o,V(s,n+1,!0,!0)]}function ht(s,t,r,l){let o={},n=new Set,a;for(t++;(a=s[t++])!=="}"&&a;){if(a===",")throw new f("expected value, found comma",{toml:s,ptr:t-1});if(a==="#")t=re(s,t);else if(a!==" "&&a!==" "&&a!==`
25
+ `&&a!=="\r"){let c,i=o,d=!1,[x,m]=he(s,t-1);for(let h=0;h<x.length;h++){if(h&&(i=d?i[c]:i[c]={}),c=x[h],(d=Object.hasOwn(i,c))&&(typeof i[c]!="object"||n.has(i[c])))throw new f("trying to redefine an already defined value",{toml:s,ptr:t});!d&&c==="__proto__"&&Object.defineProperty(i,c,{enumerable:!0,configurable:!0,writable:!0})}if(d)throw new f("trying to redefine an already defined value",{toml:s,ptr:t});let[p,N]=je(s,m,"}",r-1,l);n.add(p),i[c]=p,t=N}}if(!a)throw new f("unfinished table encountered",{toml:s,ptr:t});return[o,t]}function ft(s,t,r,l){let o=[],n;for(t++;(n=s[t++])!=="]"&&n;){if(n===",")throw new f("expected value, found comma",{toml:s,ptr:t-1});if(n==="#")t=re(s,t);else if(n!==" "&&n!==" "&&n!==`
26
+ `&&n!=="\r"){let a=je(s,t-1,"]",r-1,l);o.push(a[0]),t=a[1]}}if(!n)throw new f("unfinished array encountered",{toml:s,ptr:t});return[o,t]}function Ee(s,t,r,l){let o=t,n=r,a,c=!1,i;for(let d=0;d<s.length;d++){if(d){if(o=c?o[a]:o[a]={},n=(i=n[a]).c,l===0&&(i.t===1||i.t===2))return null;if(i.t===2){let x=o.length-1;o=o[x],n=n[x].c}}if(a=s[d],(c=Object.hasOwn(o,a))&&n[a]?.t===0&&n[a]?.d)return null;c||(a==="__proto__"&&(Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,a,{enumerable:!0,configurable:!0,writable:!0})),n[a]={t:d<s.length-1&&l===2?3:l,d:!1,i:0,c:{}})}if(i=n[a],i.t!==l&&!(l===1&&i.t===3)||(l===2&&(i.d||(i.d=!0,o[a]=[]),o[a].push(o={}),i.c[i.i++]=i={t:1,d:!1,i:0,c:{}}),i.d))return null;if(i.d=!0,l===1)o=c?o[a]:o[a]={};else if(l===0&&c)return null;return[a,o,i.c]}function jt(s,{maxDepth:t=1e3,integersAsBigInt:r}={}){let l={},o={},n=l,a=o;for(let c=V(s,0);c<s.length;){if(s[c]==="["){let i=s[++c]==="[",d=he(s,c+=+i,"]");if(i){if(s[d[1]-1]!=="]")throw new f("expected end of table declaration",{toml:s,ptr:d[1]-1});d[1]++}let x=Ee(d[0],l,o,i?2:1);if(!x)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});a=x[2],n=x[1],c=d[1]}else{let i=he(s,c),d=Ee(i[0],n,a,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:s,ptr:c});let x=je(s,i[1],void 0,t,r);d[1][d[0]]=x[0],c=x[1]}if(c=V(s,c,!0),s[c]&&s[c]!==`
27
+ `&&s[c]!=="\r")throw new f("each key-value declaration must be followed by an end-of-line",{toml:s,ptr:c});c=V(s,c)}return l}function gt(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function vt(s){if(!s.trim())return{};const r=jt(s);if(!gt(r))throw new Error("TOML root must be a table.");return r}function Me(s){try{return{config:vt(s),parseError:null}}catch(t){return{config:null,parseError:t.message}}}async function bt(){const s=await fetch(se("/codex/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Codex diagnostics");return s.json()}async function wt(){const s=await fetch(se("/codex/config/raw"));if(!s.ok)throw new Error("Failed to fetch Codex raw config");return s.json()}async function Nt(s){const t=await fetch(se("/codex/config/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Pe("Codex raw config changed externally");if(!t.ok){const r=await t.json().catch(()=>null);throw new Error(r?.error||"Failed to save Codex raw config")}return t.json()}async function yt(s){const t=await fetch(se("/codex/config/patch"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new Pe("Codex config changed externally");if(!t.ok){const r=await t.json().catch(()=>null);throw new Error(r?.error||"Failed to patch Codex config")}return t.json()}function Ct(){const s=ws(),t=ye({queryKey:["codex-diagnostics"],queryFn:bt,refetchInterval:1e4}),r=ye({queryKey:["codex-raw-config"],queryFn:wt}),l=Ce({mutationFn:Nt,onSuccess:(n,a)=>{s.setQueryData(["codex-raw-config"],c=>{const i=c?.path??"$CODEX_HOME/config.toml",d=c?.resolvedPath??i,x=Me(a.rawText);return{path:i,resolvedPath:d,exists:!0,mtime:n.mtime,rawText:a.rawText,config:x.config,parseError:x.parseError,readError:null}}),s.invalidateQueries({queryKey:["codex-diagnostics"]})}}),o=Ce({mutationFn:yt,onSuccess:n=>{s.setQueryData(["codex-raw-config"],n),s.invalidateQueries({queryKey:["codex-diagnostics"]})}});return w.useMemo(()=>({diagnostics:t.data,diagnosticsLoading:t.isLoading,diagnosticsError:t.error,refetchDiagnostics:t.refetch,rawConfig:r.data,rawConfigLoading:r.isLoading,rawConfigError:r.error,refetchRawConfig:r.refetch,saveRawConfig:l.mutate,saveRawConfigAsync:l.mutateAsync,isSavingRawConfig:l.isPending,patchConfig:o.mutate,patchConfigAsync:o.mutateAsync,isPatchingConfig:o.isPending}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.error,r.refetch,l.mutate,l.mutateAsync,l.isPending,o.mutate,o.mutateAsync,o.isPending])}const St=[{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 _t({snippets:s=St}){const[t,r]=w.useState(null),{t:l}=E(),o=async(n,a)=>{await navigator.clipboard.writeText(n),r(a),setTimeout(()=>r(null),2e3)};return e.jsxs(I,{children:[e.jsx(F,{className:"pb-3",children:e.jsxs(W,{className:"text-lg flex items-center gap-2",children:[e.jsx(xs,{className:"w-5 h-5 text-muted-foreground"}),l("quickCommands.title")]})}),e.jsx(K,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:s.map((n,a)=>e.jsxs("div",{className:Oe("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(C,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(n.command,a),title:n.description,children:t===a?e.jsx(us,{className:"h-4 w-4 text-green-600"}):e.jsx(ms,{className:"h-4 w-4"})})]},a))})})]})}function kt(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function Tt(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 k({label:s,value:t,mono:r=!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:Oe("text-right break-all",r&&"font-mono text-xs"),children:t})]})}function Et({diagnostics:s}){const{t}=E(),r=s.config.activeProfile?`codex --profile ${s.config.activeProfile}`:"codex",l=s.binary.supportsConfigOverrides;return e.jsx(fe,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(ps,{className:"h-4 w-4"}),t("codex.howCodexWorks")]})}),e.jsx(K,{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:t("codex.nativeDesc")}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.nativeConfigLabel")})," ",t("codex.nativeConfigDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.transientOverridesLabel")})," ",t("codex.transientOverridesDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.cliproxyDefaultLabel")})," ",t("codex.cliproxyDefaultDesc")]}),e.jsx("li",{children:t("codex.apiProfilesDefault")})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(hs,{className:"h-4 w-4"}),t("codex.runtimeInstall")]})}),e.jsxs(K,{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:t("codex.status")}),e.jsx(_,{variant:s.binary.installed?"default":"secondary",children:s.binary.installed?t("codex.detected"):t("codex.notFound")})]}),e.jsx(k,{label:t("codex.detectionSource"),value:s.binary.source,mono:!0}),e.jsx(k,{label:t("codex.binaryPath"),value:s.binary.path||t("codex.notFound"),mono:!0}),e.jsx(k,{label:t("codex.installDirectory"),value:s.binary.installDir||"N/A",mono:!0}),e.jsx(k,{label:t("codex.versionLabel"),value:s.binary.version||"Unknown",mono:!0}),e.jsx(k,{label:t("codex.nativeAliases"),value:"ccs-codex, ccsx",mono:!0}),e.jsx(k,{label:t("codex.ccsProviderShortcut"),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:t("codex.configOverrideSupport")}),e.jsx(_,{variant:s.binary.supportsConfigOverrides?"default":"secondary",children:s.binary.supportsConfigOverrides?t("codex.available"):t("codex.missing")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),t("codex.cliproxyNativeCodex")]})}),e.jsx(K,{className:"space-y-3 text-sm text-muted-foreground",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{children:e.jsx("strong",{children:t("codex.twoSupportedPaths")})}),e.jsxs("ul",{className:"ml-4 list-disc space-y-1 [&>li]:pl-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.builtInLabel")})," ",t("codex.builtInCcsxpDesc")]}),e.jsxs("li",{children:[e.jsx("strong",{children:t("codex.nativeRecipeLabel")})," ",t("codex.nativeRecipeDesc")]})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("codex.codexNativeRecipe")}),e.jsx("pre",{className:"mt-2 overflow-x-auto rounded-md bg-background p-3 text-xs text-foreground",children:De})]}),e.jsxs("ol",{className:"ml-4 list-decimal space-y-1.5 [&>li]:pl-1",children:[e.jsx("li",{children:t("codex.saveProviderNamedCliproxy")}),e.jsx("li",{children:t("codex.inTopLevelSetDefault")}),e.jsx("li",{children:t("codex.exportCliproxyApiKey")})]})]}):e.jsx("p",{children:t("codex.noConfigOverrides")})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(fs,{className:"h-4 w-4"}),t("codex.configFile")]})}),e.jsx(K,{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:t("codex.userConfig")}),s.file.exists?e.jsx(js,{className:"h-4 w-4 text-green-600"}):e.jsx(gs,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(k,{label:t("codex.path"),value:s.file.path,mono:!0}),e.jsx(k,{label:t("codex.resolved"),value:s.file.resolvedPath,mono:!0}),e.jsx(k,{label:t("codex.size"),value:Tt(s.file.sizeBytes)}),e.jsx(k,{label:t("codex.lastModified"),value:kt(s.file.mtimeMs)}),s.file.parseError&&e.jsxs("p",{className:"text-xs text-amber-600",children:[t("codex.tomlWarning"),": ",s.file.parseError]}),s.file.readError&&e.jsxs("p",{className:"text-xs text-destructive",children:[t("codex.readWarning"),": ",s.file.readError]})]})})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(me,{className:"h-4 w-4"}),t("codex.currentUserLayerSummary")]})}),e.jsxs(K,{className:"space-y-3",children:[e.jsx(k,{label:t("codex.model"),value:s.config.model||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.defaultProvider"),value:s.config.modelProvider||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.activeProfile"),value:s.config.activeProfile||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.approvalPolicy"),value:s.config.approvalPolicy||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.sandboxMode"),value:s.config.sandboxMode||t("codex.notSet"),mono:!0}),e.jsx(k,{label:t("codex.webSearch"),value:s.config.webSearch||t("codex.notSet"),mono:!0}),e.jsx(ee,{}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(_,{variant:"outline",className:"justify-center",children:t("codex.providersCount",{count:s.config.modelProviderCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:t("codex.profilesCount",{count:s.config.profileCount})}),e.jsx(_,{variant:"outline",className:"justify-center",children:t("codex.enabledFeaturesCount",{count:s.config.enabledFeatures.length})}),e.jsx(_,{variant:"outline",className:"justify-center",children:t("codex.mcpServersCount",{count: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:t("codex.userLayerKeysPresent")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.config.topLevelKeys.map(o=>e.jsx(_,{variant:"secondary",className:"font-mono text-[10px]",children:o},o))})]})]})]}),e.jsx(_t,{snippets:[{label:t("codex.nativeShortAlias"),command:"ccsx",description:"Launch the short native Codex runtime alias."},{label:t("codex.ccsCodexShortcut"),command:'ccsxp "your prompt"',description:l?t("codex.runBuiltInCodex"):"Requires a Codex build that exposes --config overrides."},{label:t("codex.explicitProviderRoute"),command:'ccs codex --target codex "your prompt"',description:l?t("codex.runBuiltInCodexExplicit"):"Requires a Codex build that exposes --config overrides."},{label:s.config.activeProfile?"Inspect active profile":t("codex.openNativeCodex"),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(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ne,{className:"h-4 w-4"}),t("codex.runtimeVsProvider")]})}),e.jsxs(K,{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:t("codex.nativeCodexRuntime")}),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(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:t("codex.honorsSavedNativeConfig")})]}),e.jsxs("div",{className:"flex flex-col rounded-md border p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:t("codex.ccsCodexProvider")}),l?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(_,{variant:"secondary",className:"mt-4 w-fit justify-center font-normal",children:t("codex.usesTransientOverrides")})]}):e.jsx("p",{className:"mt-2 text-muted-foreground",children:t("codex.unavailableNoConfig")})]})]})]}),e.jsxs(I,{children:[e.jsx(F,{className:"pb-2",children:e.jsx(W,{className:"text-base",children:t("codex.supportedFlows")})}),e.jsx(K,{children:e.jsxs(Ns,{children:[e.jsx(ys,{children:e.jsxs(Se,{children:[e.jsx(le,{children:t("codex.flow")}),e.jsx(le,{children:t("codex.status")}),e.jsx(le,{children:t("codex.notes")})]})}),e.jsx(Cs,{children:s.supportMatrix.map(o=>e.jsxs(Se,{children:[e.jsx(ie,{className:"font-mono text-xs",children:o.label}),e.jsx(ie,{children:e.jsx(_,{variant:o.supported?"default":"secondary",children:o.supported?t("codex.yes"):t("codex.no")})}),e.jsx(ie,{className:"text-xs text-muted-foreground",children:o.notes})]},o.id))})]})})]}),s.warnings.length>0&&e.jsxs(I,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(F,{className:"pb-2",children:e.jsxs(W,{className:"flex items-center gap-2 text-base",children:[e.jsx(vs,{className:"h-4 w-4 text-amber-600"}),t("codex.warningsTitle")]})}),e.jsx(K,{className:"space-y-1.5",children:s.warnings.map(o=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",o]},o))})]})]})})}function Ut(){const{t:s}=E(),t=$s(),{diagnostics:r,diagnosticsLoading:l,diagnosticsError:o,refetchDiagnostics:n,rawConfig:a,rawConfigLoading:c,rawConfigError:i,refetchRawConfig:d,saveRawConfigAsync:x,isSavingRawConfig:m,patchConfigAsync:p,isPatchingConfig:N}=Ct(),[h,b]=w.useState(null),R=a?.rawText??"",q=h??R,u=h!==null&&h!==R,g=Me(q),z=g.parseError?{valid:!1,error:g.parseError}:{valid:!0},j=a?.config??null,Ie=c||!a||u||a?.parseError!==null||a?.readError!==null,Fe=i?"Structured controls unavailable: failed to load the current config.toml.":a?.readError?`Structured controls unavailable: ${a.readError}`:u?z.valid?"Save or discard raw TOML edits before using structured controls.":"Fix or discard raw TOML edits before using structured controls.":a?.parseError?`Structured controls disabled: ${a.parseError}`:null,We=w.useMemo(()=>Le(j),[j]),Ke=w.useMemo(()=>Bs(j),[j]),qe=w.useMemo(()=>Ys(j),[j]),Ue=w.useMemo(()=>Hs(j),[j]),Ve=w.useMemo(()=>Qs(j),[j]),Ge=w.useMemo(()=>Js(j),[j]),ze=M=>{if(M===R){b(null);return}b(M)},Xe=async()=>{try{if((await Promise.all([n(),d()])).some(X=>!X||X.status==="error"||X.isError||X.error)){U.error(s("toasts.codexRefreshFailed"));return}b(null)}catch(M){U.error(M.message||s("toasts.codexRefreshError"))}},$e=async()=>{if(!z.valid){U.error(s("toasts.codexFixToml"));return}try{await x({rawText:q,expectedMtime:a?.exists?a.mtime:void 0}),b(null),U.success(s("toasts.codexSaved")),await n()}catch(M){be(M)?U.error(s("toasts.codexChangedExternally")):U.error(M.message||s("toasts.codexSaveFailed"))}},Be=async(M,ge)=>{try{await p({...M,expectedMtime:a?.exists?a.mtime:void 0}),b(null),U.success(ge)}catch(X){be(X)?U.error(s("toasts.codexChangedExternally")):U.error(X.message||s("toasts.codexUpdateFailed"))}},ne="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden",Ye=()=>l?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx($,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading Codex diagnostics..."]}):o||!r?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(Je,{defaultValue:"overview",className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs(Ze,{className:"grid w-full grid-cols-3",children:[e.jsx(ae,{value:"overview",children:s("codexPage.overview")}),e.jsx(ae,{value:"controls",children:s("codexPage.controlCenter")}),e.jsx(ae,{value:"docs",children:s("codexPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(oe,{value:"overview",className:ne,children:e.jsx(Et,{diagnostics:r})}),e.jsx(oe,{value:"controls",className:ne,children:e.jsx(zs,{workspacePath:r.workspacePath,activeProfile:r.config.activeProfile,topLevelSettings:We,projectTrustEntries:Ke,profileEntries:qe,modelProviderEntries:Ue,mcpServerEntries:Ve,featureCatalog:t,featureState:Ge,disabled:Ie,disabledReason:Fe,saving:N,onPatch:Be})}),e.jsx(oe,{value:"docs",className:ne,children:e.jsx(tt,{diagnostics:r})})]})]});return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(He,{direction:"horizontal",className:"h-full",children:[e.jsx(ve,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:Ye()})}),e.jsx(Qe,{className:"group flex w-2 cursor-col-resize items-center justify-center bg-border transition-colors hover:bg-primary/20",children:e.jsx(bs,{className:"h-3 w-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ve,{defaultSize:55,minSize:35,children:e.jsx(Ss,{title:"Codex config.toml",pathLabel:a?.path||r?.file.path||"$CODEX_HOME/config.toml",loading:c,parseWarning:z.valid?a?.parseError:z.error,readWarning:a?.readError,value:q,dirty:u,readOnly:!!a?.readError,saving:m,saveDisabled:!u||m||c||!z.valid||!!a?.readError,onChange:M=>{ze(M)},onSave:$e,onRefresh:Xe,onDiscard:()=>b(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{Ut as CodexPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as g,a as d,b as m,c as x,d as D,e as h,f,g as j}from"./alert-dialog-CuN8HTEx.js";import{a as A}from"./index-BDfXfBTa.js";function b({open:l,onConfirm:o,onCancel:r,title:a,description:s,confirmText:t,variant:n="default"}){const{t:i}=A();return e.jsx(g,{open:l,onOpenChange:c=>!c&&r(),children:e.jsxs(d,{children:[e.jsxs(m,{children:[e.jsx(x,{children:a}),e.jsx(D,{children:s})]}),e.jsxs(h,{children:[e.jsx(f,{onClick:r,children:i("confirmDialog.cancel")}),e.jsx(j,{onClick:o,className:n==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:t??i("confirmDialog.confirm")})]})]})})}export{b as C};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{A as g,a as d,b as m,c as x,d as D,e as h,f,g as j}from"./alert-dialog-sars2LJq.js";import{a as A}from"./index-g2g1k0QS.js";function b({open:l,onConfirm:o,onCancel:r,title:a,description:s,confirmText:t,variant:n="default"}){const{t:i}=A();return e.jsx(g,{open:l,onOpenChange:c=>!c&&r(),children:e.jsxs(d,{children:[e.jsxs(m,{children:[e.jsx(x,{children:a}),e.jsx(D,{children:s})]}),e.jsxs(h,{children:[e.jsx(f,{onClick:r,children:i("confirmDialog.cancel")}),e.jsx(j,{onClick:o,className:n==="destructive"?"bg-red-600 hover:bg-red-700 text-white":"",children:t??i("confirmDialog.confirm")})]})]})})}export{b as C};
@@ -1,3 +1,3 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{bb as N,bc as ke,a as S,B as P,d as b,V as oe,n as V,L,aF as Z,I as de,r as Fe,s as Te,t as Me,v as Le,w as ee,x as ge,bd as Re,S as y,be as Ae,bf as Ee,bg as Oe,Q as _e,R as qe,U as te,bh as De,c as ie}from"./index-BDfXfBTa.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as Ie,u as D,b as R}from"./tanstack-CrmUhA7Z.js";import{C as Ue}from"./confirm-dialog-D_5v8muu.js";import{R as fe,L as je,at as Ke,aa as Qe,Z as me,_ as Je,T as ve,aw as $e,b as ze,ad as Be,aE as Ge,aO as ue,K as He,Y as We,aP as Ve,x as we,I as Ne}from"./icons-KVCk4_U8.js";import{S as ne}from"./separator-DziIoy6O.js";import{S as Ye}from"./searchable-select-DbhlbNK0.js";import{t as I}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CuN8HTEx.js";async function Xe(){const t=await fetch(N("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ze(){const t=await fetch(N("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function et(){const t=await fetch(N("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function tt(){const t=await fetch(N("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function st(t){const s=await fetch(N("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function at(t){const s=await fetch(N("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ke("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function it(){const t=await fetch(N("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function nt(){const t=await fetch(N("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function ot(){const t=await fetch(N("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function lt(){const t=await fetch(N("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function rt(t){const s=await fetch(N("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function be(){const t=Ie(),s=D({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),o=D({queryKey:["copilot-config"],queryFn:Ze}),d=D({queryKey:["copilot-models"],queryFn:et}),r=D({queryKey:["copilot-raw-settings"],queryFn:tt}),i=D({queryKey:["copilot-info"],queryFn:lt}),c=R({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),a=R({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=R({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=R({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),f=R({mutationFn:ot,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),u=R({mutationFn:rt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return w.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:r.data,rawSettingsLoading:r.isLoading,refetchRawSettings:r.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:a.mutate,saveRawSettingsAsync:a.mutateAsync,isSavingRawSettings:a.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:i.data,infoLoading:i.isLoading,refetchInfo:i.refetch,install:u.mutate,installAsync:u.mutateAsync,isInstalling:u.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,r.data,r.isLoading,r.refetch,c.mutate,c.mutateAsync,c.isPending,a.mutate,a.mutateAsync,a.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,h.mutate,h.isPending,f.mutate,f.isPending,i.data,i.isLoading,i.refetch,u.mutate,u.mutateAsync,u.isPending])}function ct({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:r,isRawJsonValid:i,onRefresh:c,onSave:a}){const{t:x}=S();return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:x("copilotConfigForm.copilotConfiguration")}),t&&e.jsx(P,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:c,disabled:s,children:e.jsx(fe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(b,{size:"sm",onClick:a,disabled:o||d||!r||!i,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const dt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],mt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function xe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ut(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function G({label:t,description:s,value:o,onChange:d,models:r,disabled:i}){const{t:c}=S();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(Ye,{value:o||void 0,onChange:d,disabled:i,placeholder:c("componentModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:c("componentModelSelector.availableModelsCount",{count:r.length})}],options:r.map(a=>({value:a.id,groupKey:"models",searchText:`${a.name||a.id} ${a.id}`,keywords:[a.minPlan??"",a.preview?"preview":""],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.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan})]}),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.name||a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan}),a.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ut(a.multiplier)}),a.preview&&e.jsx(P,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:c("componentModelSelector.preview")})]})}))})]})}function se(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function xt(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${se(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${se(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${se(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function pt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:r,modelsLoading:i,onApplyPreset:c,onUpdateModel:a,onUpdateOpusModel:x,onUpdateSonnetModel:h,onUpdateHaikuModel:f}){const{t:u}=S(),n=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:o||t},{label:"Haiku",id:d||t}].map(({label:l,id:p})=>{const C=r.find(F=>F.id===p),k=xt(C);return k?{label:l,id:p,limits:k}:null}).filter(l=>l!==null);return e.jsx(oe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4"}),u("providerEditor.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:u("copilotConfigForm.modelMapping")}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u("copilotConfigForm.noPremiumUsage")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3 text-green-600"}),l.name]},l.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3"}),l.name]},l.name))})]})]}),e.jsx(ne,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:u("copilotConfigForm.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:u("copilotConfigForm.githubCopilotControls")}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),n.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:n.map(l=>e.jsxs("p",{children:[l.label,": ",l.id," (",l.limits,")"]},`${l.label}-${l.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:a,models:r,disabled:i}),e.jsx(G,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:r,disabled:i}),e.jsx(G,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:r,disabled:i}),e.jsx(G,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:f,models:r,disabled:i})]})]})]})})})}function ht({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:r,waitOnLimit:i,onUpdateEnabled:c,onUpdateAutoStart:a,onUpdatePort:x,onUpdateAccountType:h,onUpdateRateLimit:f,onUpdateWaitOnLimit:u}){const{t:n}=S();return e.jsx(oe,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"enabled",className:"text-sm font-medium",children:n("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"port",className:"text-xs",children:n("copilotPage.port")}),e.jsx(de,{id:"port",type:"number",value:o,onChange:l=>x(parseInt(l.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"account-type",className:"text-xs",children:n("copilotSettings.accountType")}),e.jsxs(Fe,{value:d,onValueChange:h,children:[e.jsx(Te,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Me,{})}),e.jsxs(Le,{children:[e.jsx(ee,{value:"individual",children:n("copilotSettings.accountTypeIndividual")}),e.jsx(ee,{value:"business",children:n("copilotSettings.accountTypeBusiness")}),e.jsx(ee,{value:"enterprise",children:n("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"rate-limit",className:"text-xs",children:n("copilotSettings.rateLimitSeconds")}),e.jsx(de,{id:"rate-limit",type:"number",value:r,onChange:l=>f(l.target.value),placeholder:n("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"wait-on-limit",className:"text-xs",children:n("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:i,onCheckedChange:u})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"auto-start",className:"text-xs",children:n("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:a})]})]})]})})})}function H({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(ge,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function gt({rawSettings:t}){const{t:s}=S();return e.jsx(oe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(V,{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(Je,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.provider")}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ge,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.status")}),e.jsx(P,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("copilotConfigForm.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(H,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(H,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(H,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(H,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ft=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function pe(t){const s=t?.env||{};return ft.filter(o=>!s[o]?.trim())}function he(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(o=>{s.set(o.message,o)}),[...s.values()]}function jt(){const{t}=S(),{config:s,configLoading:o,models:d,modelsLoading:r,rawSettings:i,rawSettingsLoading:c,updateConfigAsync:a,isUpdating:x,saveRawSettingsAsync:h,isSavingRawSettings:f,refetchRawSettings:u}=be(),[n,l]=w.useState({}),[p,C]=w.useState(null),[k,F]=w.useState(!1),U=n.enabled??s?.enabled??!1,K=n.autoStart??s?.auto_start??!1,A=n.port??s?.port??4141,Q=n.accountType??s?.account_type??"individual",E=n.model??s?.model??"claude-sonnet-4-6",O=n.rateLimit??s?.rate_limit?.toString()??"",j=n.waitOnLimit??s?.wait_on_limit??!0,J=n.opusModel??s?.opus_model??"",$=n.sonnetModel??s?.sonnet_model??"",z=n.haikuModel??s?.haiku_model??"",B=(g,v)=>{l(_=>({..._,[g]:v}))},Y=g=>{l(v=>({...v,model:g.default,opusModel:g.opus,sonnetModel:g.sonnet,haikuModel:g.haiku})),I.success(t("toasts.presetApplied",{name:g.name}))},T=w.useMemo(()=>p!==null?p:i?.settings?JSON.stringify(i.settings,null,2):`{
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{bb as N,bc as ke,a as S,B as P,d as b,V as oe,n as V,L,aF as Z,I as de,r as Fe,s as Te,t as Me,v as Le,w as ee,x as ge,bd as Re,S as y,be as Ae,bf as Ee,bg as Oe,Q as _e,R as qe,U as te,bh as De,c as ie}from"./index-g2g1k0QS.js";import{r as w}from"./react-vendor-CNOkPC89.js";import{a as Ie,u as D,b as R}from"./tanstack-CrmUhA7Z.js";import{C as Ue}from"./confirm-dialog-DwrX5gr_.js";import{R as fe,L as je,at as Ke,aa as Qe,Z as me,_ as Je,T as ve,aw as $e,b as ze,ad as Be,aE as Ge,aO as ue,K as He,Y as We,aP as Ve,x as we,I as Ne}from"./icons-KVCk4_U8.js";import{S as ne}from"./separator-Bd4OFZm5.js";import{S as Ye}from"./searchable-select-CHzzY0Km.js";import{t as I}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-sars2LJq.js";async function Xe(){const t=await fetch(N("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function Ze(){const t=await fetch(N("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function et(){const t=await fetch(N("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function tt(){const t=await fetch(N("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function st(t){const s=await fetch(N("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function at(t){const s=await fetch(N("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ke("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function it(){const t=await fetch(N("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function nt(){const t=await fetch(N("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function ot(){const t=await fetch(N("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function lt(){const t=await fetch(N("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function rt(t){const s=await fetch(N("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function be(){const t=Ie(),s=D({queryKey:["copilot-status"],queryFn:Xe,refetchInterval:5e3}),o=D({queryKey:["copilot-config"],queryFn:Ze}),d=D({queryKey:["copilot-models"],queryFn:et}),r=D({queryKey:["copilot-raw-settings"],queryFn:tt}),i=D({queryKey:["copilot-info"],queryFn:lt}),c=R({mutationFn:st,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),a=R({mutationFn:at,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),x=R({mutationFn:it,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=R({mutationFn:nt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),f=R({mutationFn:ot,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),u=R({mutationFn:rt,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return w.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:r.data,rawSettingsLoading:r.isLoading,refetchRawSettings:r.refetch,updateConfig:c.mutate,updateConfigAsync:c.mutateAsync,isUpdating:c.isPending,saveRawSettings:a.mutate,saveRawSettingsAsync:a.mutateAsync,isSavingRawSettings:a.isPending,startAuth:x.mutate,startAuthAsync:x.mutateAsync,isAuthenticating:x.isPending,authResult:x.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:f.mutate,isStoppingDaemon:f.isPending,info:i.data,infoLoading:i.isLoading,refetchInfo:i.refetch,install:u.mutate,installAsync:u.mutateAsync,isInstalling:u.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,r.data,r.isLoading,r.refetch,c.mutate,c.mutateAsync,c.isPending,a.mutate,a.mutateAsync,a.isPending,x.mutate,x.mutateAsync,x.isPending,x.data,h.mutate,h.isPending,f.mutate,f.isPending,i.data,i.isLoading,i.refetch,u.mutate,u.mutateAsync,u.isPending])}function ct({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:r,isRawJsonValid:i,onRefresh:c,onSave:a}){const{t:x}=S();return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:x("copilotConfigForm.copilotConfiguration")}),t&&e.jsx(P,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:c,disabled:s,children:e.jsx(fe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(b,{size:"sm",onClick:a,disabled:o||d||!r||!i,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const dt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}],mt=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function xe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function ut(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function G({label:t,description:s,value:o,onChange:d,models:r,disabled:i}){const{t:c}=S();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(Ye,{value:o||void 0,onChange:d,disabled:i,placeholder:c("componentModelSelector.selectModel"),searchPlaceholder:c("searchableSelect.searchModels"),emptyText:c("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:c("componentModelSelector.availableModelsCount",{count:r.length})}],options:r.map(a=>({value:a.id,groupKey:"models",searchText:`${a.name||a.id} ${a.id}`,keywords:[a.minPlan??"",a.preview?"preview":""],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.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan})]}),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.name||a.id}),a.minPlan&&e.jsx(P,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${xe(a.minPlan)}`,children:a.minPlan}),a.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:ut(a.multiplier)}),a.preview&&e.jsx(P,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:c("componentModelSelector.preview")})]})}))})]})}function se(t){if(t>=1e6){const s=t/1e6;return s%1===0?`${s}M`:`${s.toFixed(1)}M`}if(t>=1e3){const s=t/1e3;return s%1===0?`${s}K`:`${s.toFixed(1)}K`}return`${t}`}function xt(t){if(!t?.limits)return null;const s=[];return t.limits.maxPromptTokens&&s.push(`prompt ${se(t.limits.maxPromptTokens)}`),t.limits.maxContextWindowTokens&&s.push(`context ${se(t.limits.maxContextWindowTokens)}`),t.limits.maxOutputTokens&&s.push(`output ${se(t.limits.maxOutputTokens)}`),s.length>0?s.join(" | "):null}function pt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:r,modelsLoading:i,onApplyPreset:c,onUpdateModel:a,onUpdateOpusModel:x,onUpdateSonnetModel:h,onUpdateHaikuModel:f}){const{t:u}=S(),n=[{label:"Default",id:t},{label:"Opus",id:s||t},{label:"Sonnet",id:o||t},{label:"Haiku",id:d||t}].map(({label:l,id:p})=>{const C=r.find(F=>F.id===p),k=xt(C);return k?{label:l,id:p,limits:k}:null}).filter(l=>l!==null);return e.jsx(oe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4"}),u("providerEditor.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:u("copilotConfigForm.modelMapping")}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:u("copilotConfigForm.noPremiumUsage")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3 text-green-600"}),l.name]},l.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(P,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:mt.map(l=>e.jsxs(b,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>c(l),title:l.description,children:[e.jsx(me,{className:"w-3 h-3"}),l.name]},l.name))})]})]}),e.jsx(ne,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:u("copilotConfigForm.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:u("copilotConfigForm.githubCopilotControls")}),e.jsx("p",{className:"mt-1",children:"CCS can switch Copilot models, but it cannot increase the provider's max prompt or context window."}),n.length>0?e.jsx("div",{className:"mt-2 space-y-1 text-[11px] font-mono",children:n.map(l=>e.jsxs("p",{children:[l.label,": ",l.id," (",l.limits,")"]},`${l.label}-${l.id}`))}):e.jsx("p",{className:"mt-2 text-[11px] font-mono",children:"Start the daemon to inspect live model limits from GitHub Copilot metadata."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:a,models:r,disabled:i}),e.jsx(G,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:x,models:r,disabled:i}),e.jsx(G,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:r,disabled:i}),e.jsx(G,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:f,models:r,disabled:i})]})]})]})})})}function ht({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:r,waitOnLimit:i,onUpdateEnabled:c,onUpdateAutoStart:a,onUpdatePort:x,onUpdateAccountType:h,onUpdateRateLimit:f,onUpdateWaitOnLimit:u}){const{t:n}=S();return e.jsx(oe,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(V,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"enabled",className:"text-sm font-medium",children:n("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("copilotSettings.enableCopilotDesc")})]}),e.jsx(Z,{id:"enabled",checked:t,onCheckedChange:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"port",className:"text-xs",children:n("copilotPage.port")}),e.jsx(de,{id:"port",type:"number",value:o,onChange:l=>x(parseInt(l.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"account-type",className:"text-xs",children:n("copilotSettings.accountType")}),e.jsxs(Fe,{value:d,onValueChange:h,children:[e.jsx(Te,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(Me,{})}),e.jsxs(Le,{children:[e.jsx(ee,{value:"individual",children:n("copilotSettings.accountTypeIndividual")}),e.jsx(ee,{value:"business",children:n("copilotSettings.accountTypeBusiness")}),e.jsx(ee,{value:"enterprise",children:n("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"rate-limit",className:"text-xs",children:n("copilotSettings.rateLimitSeconds")}),e.jsx(de,{id:"rate-limit",type:"number",value:r,onChange:l=>f(l.target.value),placeholder:n("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"wait-on-limit",className:"text-xs",children:n("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx(Z,{id:"wait-on-limit",checked:i,onCheckedChange:u})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:n("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(L,{htmlFor:"auto-start",className:"text-xs",children:n("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:n("copilotSettings.autoStartDaemonDesc")})]}),e.jsx(Z,{id:"auto-start",checked:s,onCheckedChange:a})]})]})]})})})}function H({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(ge,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function gt({rawSettings:t}){const{t:s}=S();return e.jsx(oe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(V,{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(Je,{className:"w-4 h-4"}),"Configuration Info"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.provider")}),e.jsx("span",{className:"font-mono",children:"GitHub Copilot"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ge,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("copilotConfigForm.status")}),e.jsx(P,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("copilotConfigForm.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(H,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(H,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(H,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(H,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const ft=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function pe(t){const s=t?.env||{};return ft.filter(o=>!s[o]?.trim())}function he(t){if(!t||t.length===0)return[];const s=new Map;return t.forEach(o=>{s.set(o.message,o)}),[...s.values()]}function jt(){const{t}=S(),{config:s,configLoading:o,models:d,modelsLoading:r,rawSettings:i,rawSettingsLoading:c,updateConfigAsync:a,isUpdating:x,saveRawSettingsAsync:h,isSavingRawSettings:f,refetchRawSettings:u}=be(),[n,l]=w.useState({}),[p,C]=w.useState(null),[k,F]=w.useState(!1),U=n.enabled??s?.enabled??!1,K=n.autoStart??s?.auto_start??!1,A=n.port??s?.port??4141,Q=n.accountType??s?.account_type??"individual",E=n.model??s?.model??"claude-sonnet-4-6",O=n.rateLimit??s?.rate_limit?.toString()??"",j=n.waitOnLimit??s?.wait_on_limit??!0,J=n.opusModel??s?.opus_model??"",$=n.sonnetModel??s?.sonnet_model??"",z=n.haikuModel??s?.haiku_model??"",B=(g,v)=>{l(_=>({..._,[g]:v}))},Y=g=>{l(v=>({...v,model:g.default,opusModel:g.opus,sonnetModel:g.sonnet,haikuModel:g.haiku})),I.success(t("toasts.presetApplied",{name:g.name}))},T=w.useMemo(()=>p!==null?p:i?.settings?JSON.stringify(i.settings,null,2):`{
2
2
  "env": {}
3
3
  }`,[p,i]),m=w.useCallback(g=>{C(g)},[]),le=w.useMemo(()=>{try{return JSON.parse(T),!0}catch{return!1}},[T]),ye=w.useMemo(()=>{const g=Object.keys(n).length>0,v=p!==null&&p!==JSON.stringify(i?.settings,null,2);return g||v},[n,p,i]),re=w.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return i?.settings}return i?.settings},[p,i?.settings]),Se=w.useMemo(()=>pe(re),[re]),Ce=w.useMemo(()=>he([...s?.warnings??[],...i?.warnings??[]]),[s?.warnings,i?.warnings]),ce=async({overwriteRawSettings:g=!1}={})=>{try{const v=[];if(Object.keys(n).length>0){const M=await a({enabled:U,auto_start:K,port:A,account_type:Q,model:E,rate_limit:O?parseInt(O,10):null,wait_on_limit:j,opus_model:J||void 0,sonnet_model:$||void 0,haiku_model:z||void 0});v.push(...M.warnings??[])}let _=[];if(p!==null&&le){const M=JSON.parse(T);_=pe(M);const Pe=await h({settings:M,expectedMtime:g?void 0:i?.mtime});v.push(...Pe.warnings??[])}const X=he(v),q=[];X.length>0&&q.push(X.map(M=>M.message).join(" ")),_.length>0&&q.push(`Missing fields will use defaults: ${_.join(", ")}`),X.length>0?I.warning(t("toasts.settingsSavedWithAdjustments"),{description:q.join(" ")}):q.length>0?I.success(t("toasts.settingsSaved"),{description:q.join(" ")}):I.success(t("toasts.settingsSaved")),l({}),C(null)}catch(v){Re(v)?F(!0):I.error(t("toasts.failedSaveSettings"))}};return{configLoading:o,rawSettingsLoading:c,modelsLoading:r,isUpdating:x,isSavingRawSettings:f,models:d,rawSettings:i,rawJsonContent:T,rawJsonEdits:p,enabled:U,autoStart:K,port:A,accountType:Q,currentModel:E,rateLimit:O,waitOnLimit:j,opusModel:J,sonnetModel:$,haikuModel:z,isRawJsonValid:le,hasChanges:ye,normalizationWarnings:Ce,conflictDialog:k,updateField:B,applyPreset:Y,handleRawJsonChange:m,handleSave:ce,handleConflictResolve:async g=>{F(!1),g?await ce({overwriteRawSettings:!0}):C(null)},refetchRawSettings:u,missingRequiredFields:Se}}function vt(){const{t}=S(),{configLoading:s,rawSettingsLoading:o,modelsLoading:d,isUpdating:r,isSavingRawSettings:i,models:c,rawSettings:a,rawJsonContent:x,rawJsonEdits:h,enabled:f,autoStart:u,port:n,accountType:l,currentModel:p,rateLimit:C,waitOnLimit:k,opusModel:F,sonnetModel:U,haikuModel:K,isRawJsonValid:A,hasChanges:Q,normalizationWarnings:E,conflictDialog:O,updateField:j,applyPreset:J,handleRawJsonChange:$,handleSave:z,handleConflictResolve:B,refetchRawSettings:Y,missingRequiredFields:T}=jt();return s||o?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(ct,{rawSettings:a,rawSettingsLoading:o,isUpdating:r,isSavingRawSettings:i,hasChanges:Q,isRawJsonValid:A,onRefresh:()=>Y(),onSave:z}),E.length>0&&e.jsx("div",{className:"px-6 pt-4 shrink-0",children:e.jsxs(Ae,{variant:"warning",children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsx(Ee,{children:t("copilotConfigForm.deprecatedModels")}),e.jsxs(Oe,{className:"space-y-2",children:[e.jsx("p",{children:"Loading this page did not rewrite your files. Save the Copilot configuration to persist these replacements."}),e.jsx("div",{className:"space-y-1",children:E.map(m=>e.jsx("p",{children:m.message},m.message))})]})]})}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(_e,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(qe,{className:"w-full",children:[e.jsx(te,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(te,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(te,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(pt,{currentModel:p,opusModel:F,sonnetModel:U,haikuModel:K,models:c,modelsLoading:d,onApplyPreset:J,onUpdateModel:m=>j("model",m),onUpdateOpusModel:m=>j("opusModel",m),onUpdateSonnetModel:m=>j("sonnetModel",m),onUpdateHaikuModel:m=>j("haikuModel",m)}),e.jsx(ht,{enabled:f,autoStart:u,port:n,accountType:l,rateLimit:C,waitOnLimit:k,onUpdateEnabled:m=>j("enabled",m),onUpdateAutoStart:m=>j("autoStart",m),onUpdatePort:m=>j("port",m),onUpdateAccountType:m=>j("accountType",m),onUpdateRateLimit:m=>j("rateLimit",m),onUpdateWaitOnLimit:m=>j("waitOnLimit",m)}),e.jsx(gt,{rawSettings:a})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx($e,{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(De,{rawJsonContent:x,isRawJsonValid:A,rawJsonEdits:h,rawSettingsEnv:a?.settings?.env,onChange:$,missingRequiredFields:T})]})]}),e.jsx(Ue,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>B(!0),onCancel:()=>B(!1)})]})}function ae({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function W({icon:t,label:s,status:o,statusText:d,variant:r="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:ie("w-4 h-4",r==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:ie("text-xs",r==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function wt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ot(){const{t}=S(),{status:s,statusLoading:o,refetchStatus:d,startAuth:r,isAuthenticating:i,startDaemon:c,isStartingDaemon:a,stopDaemon:x,isStoppingDaemon:h,install:f,isInstalling:u}=be();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 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(fe,{className:ie("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(V,{className:"flex-1",children:o?e.jsx(wt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(ae,{title:t("copilotPage.setup"),children:[e.jsx(W,{icon:Be,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>f(void 0),disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(W,{icon:ue,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(ae,{title:t("copilotPage.auth"),children:[e.jsx(W,{icon:He,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(b,{size:"sm",className:"w-full mt-2",onClick:()=>r(),disabled:i,children:t(i?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(ae,{title:t("copilotPage.daemon"),children:[e.jsx(W,{icon:We,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>x(),disabled:h,children:[e.jsx(Ve,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(b,{size:"sm",variant:"outline",className:"w-full",onClick:()=>c(),disabled:a,children:[e.jsx(ue,{className:"w-3.5 h-3.5 mr-1.5"}),t(a?"copilotPage.starting":"copilotPage.start")]})})]})]})}),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("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ne,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(vt,{})})]})}export{Ot as CopilotPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bb as w,bc as us,a as Le,B as A,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aF as Te,bh as hs,ag as xs,ah as fs,ai as ps,aj as js,ak as Ps,aC as bs,bd as ws}from"./index-BDfXfBTa.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-DziIoy6O.js";import{S as Ns}from"./searchable-select-DbhlbNK0.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as As,aa as Ds,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[D,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?D.port:k.port,se=y?D.auto_start:k.auto_start,ae=y?D.ghost_mode:k.ghost_mode,v=y?D.model:k.model,te=y?D.opus_model:k.opus_model,re=y?D.sonnet_model:k.sonnet_model,ne=y?D.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),Ae=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),De=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],De)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:Ae,opus_model:Ae,sonnet_model:De,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(A,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:j.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:j.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[j.duration_ms," ms"]})]}),j.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:j.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:j.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:a?.port??l?.port??Ie})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ds,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b}from"./react-vendor-CNOkPC89.js";import{t as o}from"./notifications-B2HqRBj7.js";import{bb as w,bc as us,a as Le,B as A,d as p,c as H,n as G,Q as ms,R as gs,U as le,V as de,L as F,I as ue,aF as Te,bh as hs,ag as xs,ah as fs,ai as ps,aj as js,ak as Ps,aC as bs,bd as ws}from"./index-g2g1k0QS.js";import{a as ys,u as Q,b as T}from"./tanstack-CrmUhA7Z.js";import{D as Ie}from"./default-ports-1QQSffYX.js";import{S as vs}from"./separator-Bd4OFZm5.js";import{S as Ns}from"./searchable-select-CHzzY0Km.js";import{R as Re,T as Cs,ah as Ss,K as J,ad as ks,aw as me,aP as Fe,aO as _s,L as R,J as Ms,at as As,aa as Ds,Z as ge,x as Ts,I as Rs}from"./icons-KVCk4_U8.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Fs(s){if(!s||typeof s!="object")return!1;const a=s;return typeof a.message=="string"&&typeof a.stage=="string"&&typeof a.status=="number"&&typeof a.duration_ms=="number"&&typeof a.ok=="boolean"}function Ls(s){if(!s||typeof s!="object"||!("error"in s))return null;const a=s;return typeof a.error=="string"?a.error:null}async function Is(){const s=await fetch(w("/cursor/status"));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Os(){const s=await fetch(w("/cursor/settings"));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function Es(){const s=await fetch(w("/cursor/models"));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Ks(){const s=await fetch(w("/cursor/settings/raw"));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function zs(s){const a=await fetch(w("/cursor/settings"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to update cursor config");return a.json()}async function qs(s){const a=await fetch(w("/cursor/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(a.status===409)throw new us("Cursor raw settings changed externally");if(!a.ok)throw new Error("Failed to save cursor raw settings");return a.json()}async function Gs(){const s=await fetch(w("/cursor/auth/auto-detect"),{method:"POST"});if(!s.ok){const a=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(a.error||"Auto-detect failed")}return s.json()}async function Qs(s){const a=await fetch(w("/cursor/auth/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!a.ok){const c=await a.json().catch(()=>({error:"Manual import failed"}));throw new Error(c.error||"Manual import failed")}return a.json()}async function Js(){const s=await fetch(w("/cursor/daemon/start"),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Us(){const s=await fetch(w("/cursor/daemon/stop"),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Bs(){const s=await fetch(w("/cursor/probe"),{method:"POST"}),a=await s.json().catch(()=>null);return Fs(a)?a:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Ls(a)??"Failed to run live probe"}}function Hs(){const s=ys(),a=Q({queryKey:["cursor-status"],queryFn:Is,refetchInterval:5e3}),c=Q({queryKey:["cursor-config"],queryFn:Os}),d=Q({queryKey:["cursor-models"],queryFn:Es}),l=Q({queryKey:["cursor-raw-settings"],queryFn:Ks}),g=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},h=T({mutationFn:zs,onSuccess:g}),u=T({mutationFn:qs,onSuccess:g}),r=T({mutationFn:Gs,onSuccess:g}),m=T({mutationFn:Qs,onSuccess:g}),x=T({mutationFn:Js,onSuccess:g}),i=T({mutationFn:Us,onSuccess:g}),P=T({mutationFn:Bs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:a.data,statusLoading:a.isLoading,statusError:a.error,refetchStatus:a.refetch,config:c.data,configLoading:c.isLoading,refetchConfig:c.refetch,models:d.data?.models??[],currentModel:d.data?.current??null,modelsLoading:d.isLoading,rawSettings:l.data,rawSettingsLoading:l.isLoading,refetchRawSettings:l.refetch,updateConfig:h.mutate,updateConfigAsync:h.mutateAsync,isUpdatingConfig:h.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,autoDetectAuth:r.mutate,autoDetectAuthAsync:r.mutateAsync,isAutoDetectingAuth:r.isPending,autoDetectAuthResult:r.data,importManualAuth:m.mutate,importManualAuthAsync:m.mutateAsync,isImportingManualAuth:m.isPending,manualAuthResult:m.data,startDaemon:x.mutate,startDaemonAsync:x.mutateAsync,isStartingDaemon:x.isPending,stopDaemon:i.mutate,stopDaemonAsync:i.mutateAsync,isStoppingDaemon:i.isPending,runProbe:P.mutate,runProbeAsync:P.mutateAsync,isRunningProbe:P.isPending,probeResult:P.data,resetProbe:P.reset}),[a.data,a.isLoading,a.error,a.refetch,c.data,c.isLoading,c.refetch,d.data,d.isLoading,l.data,l.isLoading,l.refetch,h.mutate,h.mutateAsync,h.isPending,u.mutate,u.mutateAsync,u.isPending,r.mutate,r.mutateAsync,r.isPending,r.data,m.mutate,m.mutateAsync,m.isPending,m.data,x.mutate,x.mutateAsync,x.isPending,i.mutate,i.mutateAsync,i.isPending,P.mutate,P.mutateAsync,P.isPending,P.data,P.reset])}function he(s,a){return JSON.stringify({enabled:s?.enabled??null,authenticated:s?.authenticated??null,token_expired:s?.token_expired??null,daemon_running:s?.daemon_running??null,port:s?.port??null,ghost_mode:s?.ghost_mode??null,auto_start:a?.auto_start??null,model:a?.model??null})}function U(s){return{port:String(s?.port??Ie),auto_start:s?.auto_start??!1,ghost_mode:s?.ghost_mode??!0,model:s?.model?.trim()||"gpt-5.3-codex",opus_model:s?.opus_model?.trim()||"",sonnet_model:s?.sonnet_model?.trim()||"",haiku_model:s?.haiku_model?.trim()||""}}function C(s,a,c){return s.find(l=>a.some(g=>g.test(l.id)))?.id??c}function xe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function S(s,a,c){const d=new Set(a.map(xe)),l=s.find(h=>d.has(xe(h.id)));if(l)return l.id;const g=s.find(h=>d.has(xe(h.name)));return g?g.id:c}function Vs(s){try{const a=JSON.parse(s||"{}");return!a||typeof a!="object"||Array.isArray(a)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:a}}catch(a){return{isValid:!1,error:a.message||"Invalid JSON"}}}function B({label:s,description:a,value:c,models:d,disabled:l,allowDefaultFallback:g=!1,onChange:h}){const{t:u}=Le(),r=c||(g?"__default":""),m=b.useMemo(()=>{const x=d.map(i=>({value:i.id,groupKey:"models",searchText:`${i.name||i.id} ${i.id}`,keywords:[i.provider],triggerContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.provider&&e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]}),itemContent:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-xs font-mono",children:i.name||i.id}),e.jsx(A,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:i.provider})]})}));return g?[{value:"__default",groupKey:"models",searchText:u("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:u("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:u("cursorPage.useDefaultModel")})},...x]:x},[g,d,u]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(F,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsx(Ns,{value:r||void 0,onChange:x=>{if(g&&x==="__default"){h("");return}h(x)},disabled:l,placeholder:u("cursorPage.selectModel"),searchPlaceholder:u("searchableSelect.searchModels"),emptyText:u("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:u("cursorPage.availableModelCount",{count:d.length})}],options:m})]})}function fe({icon:s,label:a,ok:c,detail:d}){return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-muted/50 px-3 py-2",children:[e.jsx(s,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm",children:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c?e.jsx(Ts,{className:"h-4 w-4 text-green-500"}):e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:H("text-xs",c?"text-green-500":"text-muted-foreground"),title:d,children:d})]})]})}function ia(){const{t:s}=Le(),{status:a,statusLoading:c,refetchStatus:d,config:l,refetchConfig:g,updateConfigAsync:h,isUpdatingConfig:u,models:r,modelsLoading:m,currentModel:x,rawSettings:i,rawSettingsLoading:P,refetchRawSettings:Oe,saveRawSettingsAsync:Ee,isSavingRawSettings:pe,autoDetectAuthAsync:Ke,isAutoDetectingAuth:je,importManualAuthAsync:ze,isImportingManualAuth:Pe,startDaemonAsync:qe,isStartingDaemon:Ge,stopDaemonAsync:Qe,isStoppingDaemon:be,runProbeAsync:Je,isRunningProbe:V,probeResult:W,resetProbe:Ue}=Hs(),[D,X]=b.useState(()=>U()),[y,Z]=b.useState(!1),[we,Be]=b.useState("{}"),[L,$]=b.useState(!1),[He,E]=b.useState(!1),[Y,ye]=b.useState(""),[ee,ve]=b.useState(""),[Ne,Ce]=b.useState(()=>W?he(a,l):null),k=U(l),Se=y?D.port:k.port,se=y?D.auto_start:k.auto_start,ae=y?D.ghost_mode:k.ghost_mode,v=y?D.model:k.model,te=y?D.opus_model:k.opus_model,re=y?D.sonnet_model:k.sonnet_model,ne=y?D.haiku_model:k.haiku_model,oe=L?we:JSON.stringify(i?.settings??{},null,2),ke=!!i,I=b.useMemo(()=>Vs(oe),[oe]),_e=I.isValid,K=y||L,Ve=!L||ke&&_e,We=he(a,l),j=W&&!K&&Ne!==null&&Ne===We?W:null,z=b.useMemo(()=>{const t=new Set,n=[...r].sort((M,ce)=>M.name.localeCompare(ce.name)),f=n.filter(M=>t.has(M.id)?!1:(t.add(M.id),!0));return v&&!n.some(M=>M.id===v)?[{id:v,name:v,provider:"custom"},...f]:f},[r,v]),N=t=>{X(n=>t(y?n:k)),Z(!0)},_=()=>{Ue(),Ce(null)},Xe=(t=l)=>{X(U(t)),Z(!1)},Ze=!!(a?.enabled&&a?.authenticated&&!a?.token_expired),$e=b.useMemo(()=>a?.enabled?e.jsx(A,{children:s("cursorPage.enabled")}):e.jsx(A,{variant:"secondary",children:s("cursorPage.disabled")}),[a?.enabled,s]),Ye=async({suppressSuccessToast:t=!1}={})=>{const n=Number(Se);if(!Number.isInteger(n)||n<1||n>65535)return o.error(s("cursorPage.invalidPort")),!1;if(!v.trim())return o.error(s("cursorPage.defaultModelRequired")),!1;try{return await h({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0}),Z(!1),X(U({port:n,auto_start:se,ghost_mode:ae,model:v,opus_model:te||void 0,sonnet_model:re||void 0,haiku_model:ne||void 0})),_(),t||o.success(s("cursorPage.savedConfig")),!0}catch(f){return o.error(f.message||s("cursorPage.failedSaveConfig")),!1}},ie=t=>{if(m){o.error(s("cursorPage.modelsLoadingWait"));return}if(r.length===0){o.error(s("cursorPage.noModelsAvailable"));return}const n=v||x||r[0]?.id||"gpt-5.3-codex",f=S(r,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],C(r,[/gpt[-.]?5.*codex/i],n)),M=S(r,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],C(r,[/gpt[-.]?5.*codex.*max/i],f)),ce=S(r,["gpt-5-fast","gpt5fast","GPT-5 Fast"],C(r,[/gpt[-.]?5.*fast/i],f)),cs=S(r,["gpt-5-mini","gpt5mini","GPT-5 Mini"],C(r,[/gpt[-.]?5.*mini/i],ce)),Ae=S(r,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],C(r,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],f)),De=S(r,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],C(r,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],f)),ls=S(r,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],C(r,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],De)),q=S(r,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],C(r,[/gemini[-.]?3.*pro/i],f)),ds=S(r,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],C(r,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],q));if(t==="codex53"){N(O=>({...O,model:f,opus_model:M,sonnet_model:f,haiku_model:cs})),o.success(s("cursorPage.appliedCodexPreset"));return}if(t==="claude46"){N(O=>({...O,model:Ae,opus_model:Ae,sonnet_model:De,haiku_model:ls})),o.success(s("cursorPage.appliedClaudePreset"));return}N(O=>({...O,model:q,opus_model:q,sonnet_model:q,haiku_model:ds})),o.success(s("cursorPage.appliedGeminiPreset"))},Me=async t=>{try{await h({enabled:t}),_(),o.success(s(t?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(n){o.error(n.message||s("cursorPage.failedUpdateIntegration"))}},es=async()=>{try{await Ke(),_(),o.success(s("cursorPage.credentialsImported"))}catch(t){o.error(t.message||s("cursorPage.autoDetectFailed"))}},ss=async()=>{if(!Y.trim()||!ee.trim()){o.error(s("cursorPage.manualRequired"));return}try{await ze({accessToken:Y.trim(),machineId:ee.trim()}),_(),o.success(s("cursorPage.credentialsImported")),E(!1),ye(""),ve("")}catch(t){o.error(t.message||s("cursorPage.manualImportFailed"))}},as=async()=>{try{const t=await qe();if(!t.success){o.error(t.error||s("cursorPage.failedStartDaemon"));return}_(),o.success(t.pid?s("cursorPage.daemonStartedWithPid",{pid:t.pid}):s("cursorPage.daemonStarted"))}catch(t){o.error(t.message||s("cursorPage.failedStartDaemon"))}},ts=async()=>{try{const t=await Qe();if(!t.success){o.error(t.error||s("cursorPage.failedStopDaemon"));return}_(),o.success(s("cursorPage.daemonStopped"))}catch(t){o.error(t.message||s("cursorPage.failedStopDaemon"))}},rs=async()=>{if(K){o.error(s("cursorPage.probeSaveFirst"));return}try{const t=await Je(),n=await d();if(Ce(he(n.data??a,l)),t.ok){o.success(s("cursorPage.probeSucceeded"));return}o.error(t.message||s("cursorPage.probeFailed"))}catch(t){o.error(t.message||s("cursorPage.probeFailed"))}},ns=async({suppressSuccessToast:t=!1}={})=>{if(!ke)return o.error(s("cursorPage.rawLoading")),!1;if(!I.isValid||!I.settings)return o.error(I.error||s("cursorPage.invalidJson")),!1;try{return await Ee({settings:I.settings,expectedMtime:i?.mtime}),$(!1),_(),t||o.success(s("cursorPage.rawSaved")),!0}catch(n){return ws(n)?o.error(s("cursorPage.rawChanged")):o.error(n.message||s("cursorPage.failedSaveRaw")),!1}},os=async()=>{if(!K)return;const t=y,n=L;t&&!await Ye({suppressSuccessToast:n})||n&&!await ns({suppressSuccessToast:t})||t&&n&&o.success(s("cursorPage.savedAll"))},is=async()=>{$(!1),_();const[,t]=await Promise.all([d(),g(),Oe()]);Xe(t.data??l)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/assets/sidebar/cursor.svg",alt:"",className:"w-5 h-5 object-contain shrink-0"}),e.jsx("h1",{className:"font-semibold",children:s("cursorPage.title")}),e.jsx(A,{variant:"outline",className:"h-5 border-amber-500/60 bg-amber-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-300",children:s("cursorPage.beta")}),$e]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:c,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Re,{className:H("w-4 h-4",c&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:s("cursorPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:s("cursorPage.unofficialItem1")}),e.jsx("li",{children:s("cursorPage.unofficialItem2")}),e.jsx("li",{children:s("cursorPage.unofficialItem3")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(fe,{icon:Ss,label:s("cursorPage.integration"),ok:!!a?.enabled,detail:a?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(fe,{icon:J,label:s("cursorPage.authentication"),ok:!!(a?.authenticated&&!a?.token_expired),detail:a?.authenticated?a?.token_expired?s("cursorPage.expired"):a.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(fe,{icon:ks,label:s("cursorPage.daemon"),ok:!!a?.daemon_running,detail:a?.daemon_running?s("cursorPage.running"):s("cursorPage.stopped")})]}),e.jsxs("div",{className:"rounded-md border bg-background/80 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.liveProbe")})]}),e.jsx(A,{variant:j?"outline":"secondary",className:H(j?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",j&&!j.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:j?j.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),j?e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeStage")}),e.jsx("span",{className:"font-mono uppercase",children:j.stage})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeHttpStatus")}),e.jsx("span",{className:"font-mono",children:j.status})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeDuration")}),e.jsxs("span",{className:"font-mono",children:[j.duration_ms," ms"]})]}),j.model?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeModel")}),e.jsx("span",{className:"font-mono text-[11px] text-right break-all",children:j.model})]}):null,e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx("span",{className:"text-muted-foreground",children:s("cursorPage.probeMessage")}),e.jsx("p",{className:"text-[11px] leading-relaxed break-words",children:j.message})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.probeNotRun")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("cursorPage.probeLocalReadinessHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s("cursorPage.actions")}),a?.enabled?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:u,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:u,children:[e.jsx(_s,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:es,disabled:je,children:[je?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:()=>E(!0),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:rs,disabled:V,children:[V?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),s(V?"cursorPage.probing":j?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),a?.daemon_running?e.jsxs(p,{variant:"outline",size:"sm",className:"w-full",onClick:ts,disabled:be,children:[be?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(p,{size:"sm",className:"w-full",onClick:as,disabled:!Ze,children:[Ge?e.jsx(R,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startDaemon")]})]})]})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("cursorPage.port")}),e.jsx("span",{children:a?.port??l?.port??Ie})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s("cursorPage.configuration")}),i&&e.jsx(A,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",i.exists?new Date(i.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:is,disabled:c||P,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Re,{className:H("w-4 h-4",(c||P)&&"animate-spin")})}),e.jsx(p,{size:"sm",onClick:os,disabled:u||pe||!K||!Ve,children:u||pe?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),s("cursorPage.save")]})})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(ms,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(gs,{className:"w-full",children:[e.jsx(le,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(le,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(le,{value:"info",className:"flex-1",children:s("cursorPage.info")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[e.jsx(de,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ds,{className:"w-4 h-4"}),s("cursorPage.presets")]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:s("cursorPage.presetsDesc")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("codex53"),disabled:m||r.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(ge,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("claude46"),disabled:m||r.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(ge,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>ie("gemini3"),disabled:m||r.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(ge,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(vs,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:s("cursorPage.modelMapping")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:s("cursorPage.modelMappingDesc")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(B,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:v,models:z,disabled:m,onChange:t=>{N(n=>({...n,model:t}))}}),e.jsx(B,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:te,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,opus_model:t}))}}),e.jsx(B,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:re,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,sonnet_model:t}))}}),e.jsx(B,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ne,models:z,disabled:m,allowDefaultFallback:!0,onChange:t=>{N(n=>({...n,haiku_model:t}))}})]})]})]})})}),e.jsx(de,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:s("cursorPage.runtimeSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ue,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:Se,onChange:t=>{N(n=>({...n,port:t.target.value}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-auto-start",className:"text-xs",children:s("cursorPage.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.autoStartDesc")})]}),e.jsx(Te,{id:"cursor-auto-start",checked:se,onCheckedChange:t=>{N(n=>({...n,auto_start:t}))}})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(F,{htmlFor:"cursor-ghost-mode",className:"text-xs",children:s("cursorPage.ghostMode")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s("cursorPage.ghostModeDesc")})]}),e.jsx(Te,{id:"cursor-ghost-mode",checked:ae,onCheckedChange:t=>{N(n=>({...n,ghost_mode:t}))}})]})]})})})}),e.jsx(de,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(G,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.provider")}),e.jsx("span",{className:"font-mono",children:"Cursor IDE"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:s("cursorPage.filePath")}),e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:i?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model mapping writes `ANTHROPIC_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in `cursor.settings.json`."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:s("cursorPage.availableModels")}),m?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("div",{className:"rounded-lg border px-3 py-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.name," • ",t.provider]})]}),t.id===x&&e.jsx(A,{children:s("cursorPage.default")})]},t.id))})]})]})})})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:s("cursorPage.rawConfiguration")})]}),e.jsx(hs,{rawJsonContent:oe,isRawJsonValid:_e,rawJsonEdits:L?we:null,rawSettingsEnv:i?.settings?.env,onChange:t=>{$(!0),Be(t)}})]})]})]})})]}),e.jsx(xs,{open:He,onOpenChange:E,children:e.jsxs(fs,{children:[e.jsxs(ps,{children:[e.jsx(js,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ps,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ue,{id:"cursor-manual-token",value:Y,onChange:t=>ye(t.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(F,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ue,{id:"cursor-manual-machine-id",value:ee,onChange:t=>ve(t.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(bs,{children:[e.jsx(p,{variant:"outline",onClick:()=>E(!1),children:s("cursorPage.cancel")}),e.jsxs(p,{onClick:ss,disabled:Pe,children:[Pe?e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(J,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{ia as CursorPage};