@kaitranntt/ccs 7.74.0-dev.6 → 7.74.0-dev.8

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 (51) hide show
  1. package/dist/cliproxy/binary/lifecycle.d.ts.map +1 -1
  2. package/dist/cliproxy/binary/lifecycle.js +2 -1
  3. package/dist/cliproxy/binary/lifecycle.js.map +1 -1
  4. package/dist/cliproxy/service-manager.d.ts +17 -1
  5. package/dist/cliproxy/service-manager.d.ts.map +1 -1
  6. package/dist/cliproxy/service-manager.js +10 -5
  7. package/dist/cliproxy/service-manager.js.map +1 -1
  8. package/dist/cliproxy/types.d.ts +8 -0
  9. package/dist/cliproxy/types.d.ts.map +1 -1
  10. package/dist/cliproxy/types.js.map +1 -1
  11. package/dist/ui/assets/{accounts-Bi9l48Df.js → accounts-BHXLCVr2.js} +1 -1
  12. package/dist/ui/assets/{alert-dialog-BRUwq6tw.js → alert-dialog-_HsPBPYt.js} +1 -1
  13. package/dist/ui/assets/{api-D-U56E4i.js → api-DJfWWXFl.js} +1 -1
  14. package/dist/ui/assets/{auth-section-Ce9qsANj.js → auth-section-BAacZ7AC.js} +1 -1
  15. package/dist/ui/assets/{backups-section-sgFRBpZK.js → backups-section-BZRNv86z.js} +1 -1
  16. package/dist/ui/assets/{channels-N0BJTNsj.js → channels-DP9aCTUd.js} +1 -1
  17. package/dist/ui/assets/{checkbox-C1C1vyVk.js → checkbox-DcZz3WGM.js} +1 -1
  18. package/dist/ui/assets/{claude-extension-DlsLoPw6.js → claude-extension-CENyhVUo.js} +1 -1
  19. package/dist/ui/assets/{cliproxy-DYhugtcp.js → cliproxy-Bxpop7Hy.js} +1 -1
  20. package/dist/ui/assets/{cliproxy-ai-providers-DCpIG9TD.js → cliproxy-ai-providers-CRDA8-Ut.js} +1 -1
  21. package/dist/ui/assets/{cliproxy-control-panel-DCfZjUBO.js → cliproxy-control-panel-mve89_rF.js} +1 -1
  22. package/dist/ui/assets/{codex-ZkG1YspX.js → codex-DxHcxVjR.js} +1 -1
  23. package/dist/ui/assets/{confirm-dialog-DesWFrB5.js → confirm-dialog-CA_kx7yS.js} +1 -1
  24. package/dist/ui/assets/{copilot-BQcghL5h.js → copilot-DS2c7d1T.js} +1 -1
  25. package/dist/ui/assets/{cursor-z9CgZr4F.js → cursor-Bbta1Z_q.js} +1 -1
  26. package/dist/ui/assets/{droid-Du97l2rE.js → droid-bFC5rthA.js} +1 -1
  27. package/dist/ui/assets/{globalenv-section-Dbi199_E.js → globalenv-section-CZNxpuZE.js} +1 -1
  28. package/dist/ui/assets/health-DTrCPTsQ.js +1 -0
  29. package/dist/ui/assets/{index-3YVWpOmW.js → index-B4dFnnun.js} +1 -1
  30. package/dist/ui/assets/index-BXEJ1fT2.css +1 -0
  31. package/dist/ui/assets/index-BzK9qB9a.js +1 -0
  32. package/dist/ui/assets/{index-DTxpIlHx.js → index-CEtMdB2w.js} +1 -1
  33. package/dist/ui/assets/{index-EoKZSZjT.js → index-CEuKLsUj.js} +3 -3
  34. package/dist/ui/assets/{index-CDOC8O90.js → index-DjptczWk.js} +1 -1
  35. package/dist/ui/assets/{index-BD1XO7hd.js → index-DkB98h6I.js} +1 -1
  36. package/dist/ui/assets/{index-YC5YfdvY.js → index-hh65jn6S.js} +1 -1
  37. package/dist/ui/assets/{logs-_wJgNka8.js → logs-CskpzGaG.js} +1 -1
  38. package/dist/ui/assets/{masked-input-Bvitkjfi.js → masked-input-Ck9tgCY7.js} +1 -1
  39. package/dist/ui/assets/proxy-g4_N-fbB.js +9 -0
  40. package/dist/ui/assets/{proxy-status-widget-DKF_u-z_.js → proxy-status-widget-CjDFDoLb.js} +1 -1
  41. package/dist/ui/assets/{raw-json-settings-editor-panel-B-kpXlsF.js → raw-json-settings-editor-panel-DtHR8TT6.js} +1 -1
  42. package/dist/ui/assets/{searchable-select-BIIDffTw.js → searchable-select-DmX9VGp5.js} +1 -1
  43. package/dist/ui/assets/{separator-DuNFfbVb.js → separator-CF37MlTs.js} +1 -1
  44. package/dist/ui/assets/{shared-zxKI7DcS.js → shared-CQDIfxlI.js} +1 -1
  45. package/dist/ui/assets/{table-DeH167eX.js → table-Ce_lz0Ia.js} +1 -1
  46. package/dist/ui/assets/{updates-DeNEfEmm.js → updates-BRRjuRCH.js} +1 -1
  47. package/dist/ui/index.html +2 -2
  48. package/package.json +1 -1
  49. package/dist/ui/assets/health-LEYI6q2O.js +0 -1
  50. package/dist/ui/assets/index-BIHjOqHW.css +0 -1
  51. package/dist/ui/assets/index-Ce4IouO8.js +0 -9
@@ -0,0 +1 @@
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{bt as ie,bu as ne,Y as E,a as Y,bv as oe,bi as O,bk as R,d as h,n as le,c as w,L as f,I as T,r as $,s as H,t as F,v as U,w as V,aI as G,M as ce,N as ue,O as xe}from"./index-CEuKLsUj.js";import{m as g,A as me}from"./proxy-g4_N-fbB.js";import{R as N,I as B,x as k,ab as ge,_ as be,ba as pe,w as Q,$ as he,a6 as fe,e as we,s as je}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function ve(r,s){return{claude:{...r.claude,...s.claude},codex:{...r.codex,...s.codex}}}function Ne(){const{state:r}=ie(),s=ne(),i=o.useCallback(async()=>{try{s.setBrowserLoading(!0),s.setBrowserError(null);const d=await E.browser.get();s.setBrowserConfig(d.config),s.setBrowserStatus(d.status)}catch(d){s.setBrowserError(d.message)}finally{s.setBrowserLoading(!1),s.setBrowserStatusLoading(!1)}},[s]),a=o.useCallback(async()=>{try{s.setBrowserStatusLoading(!0),s.setBrowserError(null);const d=await E.browser.getStatus();return s.setBrowserStatus(d),d}catch(d){return s.setBrowserError(d.message),null}finally{s.setBrowserStatusLoading(!1)}},[s]),c=o.useCallback(async d=>{const l=r.browserConfig;if(!l)return!1;const b=ve(l,d);s.setBrowserConfig(b);try{s.setBrowserSaving(!0),s.setBrowserError(null);const x=await E.browser.update(d);return s.setBrowserConfig(x.browser.config),s.setBrowserStatus(x.browser.status),s.setBrowserSuccess(!0),window.setTimeout(()=>s.setBrowserSuccess(!1),1500),!0}catch(x){return s.setBrowserConfig(l),s.setBrowserError(x.message),!1}finally{s.setBrowserSaving(!1)}},[s,r.browserConfig]);return{config:r.browserConfig,status:r.browserStatus,loading:r.browserLoading,statusLoading:r.browserStatusLoading,saving:r.browserSaving,error:r.browserError,success:r.browserSuccess,fetchConfig:i,fetchStatus:a,saveConfig:c}}function ke(r){const s=r.toLowerCase();return s.includes("mac")?"darwin":s.includes("win")?"win32":"linux"}function ye(r=navigator){const s=typeof r.userAgentData?.platform=="string"?r.userAgentData.platform:"",i=typeof r.platform=="string"&&r.platform.trim()?r.platform:r.userAgent;return ke(s||i||"")}function Se(r){if(!/^\d+$/.test(r.trim()))return null;const s=Number.parseInt(r.trim(),10);return s<1||s>65535?null:s}const q=["disabled","readonly","readwrite"];function D(r,s){return r(`settingsPage.browserSection.evalMode.options.${s}`)}function Ce(r,s,i){const a=JSON.stringify(r);return i==="darwin"?`open -na "Google Chrome" --args --remote-debugging-port=${s} --user-data-dir=${a}`:i==="win32"?`chrome.exe --remote-debugging-port=${s} --user-data-dir=${a}`:`google-chrome --remote-debugging-port=${s} --user-data-dir=${a}`}function J({children:r,className:s,title:i,description:a,badge:c,action:d}){return e.jsx("div",{className:w("group relative overflow-hidden rounded-[2.5rem] border border-border/60 bg-muted/20 p-1.5 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] dark:border-white/[0.08] dark:bg-zinc-900/35",s),children:e.jsxs("div",{className:"relative overflow-hidden rounded-[calc(2.5rem-0.375rem)] border border-border/70 bg-card/90 shadow-[0_12px_36px_-18px_rgba(15,23,42,0.18)] dark:border-white/[0.08] dark:bg-zinc-900/70 dark:shadow-[0_18px_44px_-24px_rgba(0,0,0,0.55)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_rgba(255,255,255,0.28)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]"}),(i||d)&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-border/60 px-8 py-6 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight",children:i}),c]}),a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]}),d&&e.jsx("div",{className:"flex items-center gap-2",children:d})]}),e.jsx("div",{className:"px-8 py-8",children:r})]})})}function K({state:r,title:s,detail:i,nextStep:a}){const{t:c}=Y(),d=r==="ready"||r==="enabled",l=!d&&r!=="disabled";return e.jsx("div",{className:w("relative overflow-hidden rounded-2xl border p-4 transition-all duration-500",d?"border-emerald-500/20 bg-emerald-500/[0.03] dark:bg-emerald-500/[0.02]":l?"border-amber-500/20 bg-amber-500/[0.03] dark:bg-amber-500/[0.02]":"border-border/60 bg-muted/30 dark:border-white/[0.06] dark:bg-zinc-900/45"),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:w("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-500 group-hover:scale-110",d?"bg-emerald-500/10 text-emerald-600":l?"bg-amber-500/10 text-amber-600":"bg-slate-500/10 text-slate-500"),children:d?e.jsx(k,{size:24}):l?e.jsx(Q,{size:24}):e.jsx(B,{size:24})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground/60",children:c("settingsPage.browserSection.readiness")}),d&&e.jsx(g.span,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsx("h4",{className:"font-medium text-foreground",children:s}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:i}),a&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-border/50 bg-muted/35 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx(fe,{size:14,className:"mt-0.5 shrink-0 text-primary"}),e.jsxs("p",{className:"text-xs leading-normal",children:[e.jsxs("span",{className:"font-semibold text-primary",children:[c("settingsPage.browserSection.nextStep"),":"]})," ",a]})]})]})]})})}function W({title:r,children:s,defaultOpen:i=!1}){const[a,c]=o.useState(i);return e.jsxs(ce,{open:a,onOpenChange:c,className:"overflow-hidden rounded-2xl border border-border/60 bg-muted/20 dark:border-white/[0.06] dark:bg-zinc-900/30",children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center justify-between px-6 py-4 text-sm font-medium transition-colors hover:bg-muted/40 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),r]}),e.jsx(je,{size:16,className:w("transition-transform duration-300",a&&"rotate-180")})]})}),e.jsx(xe,{children:e.jsx("div",{className:"border-t border-border/60 px-6 py-6 dark:border-white/[0.06]",children:s})})]})}function Oe(){const{t:r}=Y(),{fetchRawConfig:s}=oe(),{config:i,status:a,loading:c,statusLoading:d,saving:l,error:b,success:x,fetchConfig:y,fetchStatus:_,saveConfig:S}=Ne(),[Z,m]=o.useState(null),[ee,C]=o.useState(null),[P,p]=o.useState(null);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!P&&!x)return;const n=window.setTimeout(()=>p(null),2500);return()=>window.clearTimeout(n)},[P,x]);const t=Z??i,j=o.useMemo(()=>t?Ce(t.claude.userDataDir,t.claude.devtoolsPort,ye()):"",[t]),M=ee??String(t?.claude.devtoolsPort??9222),v=Se(M),z=M.trim().length>0&&v===null,A=i!==null&&t!==null&&(i.claude.enabled!==t.claude.enabled||i.claude.userDataDir!==t.claude.userDataDir||i.claude.devtoolsPort!==v||i.claude.evalMode!==t.claude.evalMode),re=i!==null&&t!==null&&(i.codex.enabled!==t.codex.enabled||i.codex.evalMode!==t.codex.evalMode),I=o.useCallback(async()=>{p(null),m(null),C(null),await Promise.all([y(),s()])},[y,s]),se=o.useCallback(async()=>{await _()&&p(r("settingsPage.browserSection.messages.statusRefreshed"))},[_,r]),ae=o.useCallback(async()=>{if(!t||v===null)return;await S({claude:{enabled:t.claude.enabled,userDataDir:t.claude.userDataDir.trim(),devtoolsPort:v,evalMode:t.claude.evalMode}})&&(await s(),p(null),m(null),C(null))},[v,t,s,S]),te=o.useCallback(async()=>{if(!t)return;await S({codex:{enabled:t.codex.enabled,evalMode:t.codex.evalMode}})&&(await s(),p(null),m(null),C(null))},[t,s,S]),de=o.useCallback(async()=>{j&&(await navigator.clipboard.writeText(j),p(r("settingsPage.browserSection.messages.launchCommandCopied")))},[j,r]);return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground",children:[e.jsx(g.div,{animate:{rotate:360},transition:{duration:1.5,repeat:1/0,ease:"linear"},children:e.jsx(N,{size:32})}),e.jsx("span",{className:"text-sm font-medium uppercase tracking-widest opacity-60",children:r("settings.loading")})]})}):!i||!a||!t?e.jsx("div",{className:"p-8",children:e.jsxs(O,{variant:"destructive",className:"rounded-[2rem] p-8 shadow-xl",children:[e.jsx(B,{size:24}),e.jsx(R,{className:"mt-2 text-md leading-relaxed",children:b??r("settingsPage.browserSection.description")}),e.jsx("div",{className:"mt-6",children:e.jsxs(h,{variant:"outline",className:"rounded-full px-6 transition-transform active:scale-95",onClick:I,children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),r("sharedPage.retry")]})})]})}):e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-background",children:[e.jsx(me,{children:(b||x||P)&&e.jsx(g.div,{initial:{opacity:0,y:-20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-20,scale:.95},className:"absolute left-1/2 top-6 z-50 -translate-x-1/2",children:b?e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-rose-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-rose-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(B,{size:18}),b]}):e.jsxs("div",{className:"flex items-center gap-3 rounded-full border border-emerald-500/20 bg-card/95 px-6 py-2.5 text-sm font-medium text-emerald-600 shadow-2xl dark:bg-zinc-900/85",children:[e.jsx(k,{size:18}),P??r("commonToast.settingsSaved")]})})}),e.jsx(le,{className:"flex-1",children:e.jsxs("div",{className:"mx-auto max-w-[1240px] space-y-12 p-8 py-16",children:[e.jsxs(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-wrap items-end justify-between gap-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:e.jsx(ge,{size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:r("settingsPage.browserSection.title")}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:r("settingsPage.browserSection.description")})]})]})}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:I,disabled:l||c,children:[e.jsx(N,{className:w("mr-2 h-4 w-4",d&&"animate-spin")}),r("settings.refresh")]})]}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(O,{className:"items-center rounded-3xl border-primary/10 bg-primary/[0.04] p-6 py-4 dark:border-primary/15 dark:bg-primary/[0.05]",children:[e.jsx(be,{className:"h-5 w-5 text-primary"}),e.jsxs(R,{className:"ml-2 text-sm",children:[e.jsx("span",{className:"font-semibold text-primary/80",children:r("settingsPage.browserSection.primaryTitle")})," ",r("settingsPage.browserSection.primaryDescription")]})]})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:e.jsx(J,{title:r("settingsPage.browserSection.claude.title"),description:r("settingsPage.browserSection.claude.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-claude-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.claude.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-claude-enabled",checked:t.claude.enabled,onCheckedChange:n=>m(u=>L(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:ae,disabled:l||z||!A,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveClaude")]}),e.jsxs(h,{variant:"outline",className:"rounded-full border-border/70 bg-background/85 shadow-sm transition-all hover:bg-muted/50 active:scale-95 dark:border-white/[0.08] dark:bg-zinc-900/70 dark:hover:bg-zinc-900",onClick:se,disabled:l||d||A||z,children:[e.jsx(he,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.testConnection")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.claude.state,title:a.claude.title,detail:a.claude.detail,nextStep:a.claude.nextStep}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-user-data-dir",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.userDataDir")}),e.jsx(T,{id:"browser-claude-user-data-dir",value:t.claude.userDataDir,onChange:n=>m(u=>L(u??t,{userDataDir:n.target.value})),className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",placeholder:a.claude.recommendedUserDataDir}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.userDataDirHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{htmlFor:"browser-claude-devtools-port",className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.claude.devtoolsPort")}),e.jsx(T,{id:"browser-claude-devtools-port",value:M,onChange:n=>C(n.target.value),inputMode:"numeric",className:"max-w-[120px] rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70"}),e.jsx("p",{className:w("text-[11px] leading-relaxed text-muted-foreground/70",z&&"text-rose-500"),children:r(z?"settingsPage.browserSection.claude.devtoolsPortInvalid":"settingsPage.browserSection.claude.devtoolsPortHint")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.claude.evalMode,onValueChange:n=>m(u=>L(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.claude.evalModeHint")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"group/launch relative overflow-hidden rounded-2xl border border-border/60 bg-muted/20 p-5 transition-all hover:bg-muted/35 dark:border-white/[0.06] dark:bg-zinc-900/35 dark:hover:bg-zinc-900/50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.15em] text-primary/70",children:r("settingsPage.browserSection.claude.launchGuidance")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settingsPage.browserSection.claude.launchGuidanceHint")})]}),e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-full p-0 transition-transform active:scale-90",onClick:de,disabled:!j,children:e.jsx(pe,{size:18})})]}),e.jsx("code",{className:"mt-4 block break-all rounded-lg border border-border/50 bg-background/80 p-3 font-mono text-[10px] leading-relaxed dark:border-white/[0.05] dark:bg-zinc-900/60",children:j})]}),a.claude.overrideActive&&e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-amber-500/10 bg-amber-500/[0.05] p-4 text-xs font-medium text-amber-700 dark:text-amber-300",children:[e.jsx(Q,{size:18}),r("settingsPage.browserSection.claude.overrideMessage",{source:a.claude.source})]})]})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.claude.state!=="ready",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.effectivePath")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.claude.effectiveUserDataDir})}),e.jsxs("p",{className:"text-[10px] font-medium text-muted-foreground/60",children:[e.jsxs("span",{className:"font-bold",children:[r("settingsPage.browserSection.claude.recommendedPath"),":"]})," ",a.claude.recommendedUserDataDir]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.claude.managedRuntime")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"font-semibold text-primary/80",children:a.claude.managedMcpServerName}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-relaxed text-muted-foreground/80",children:a.claude.managedMcpServerPath})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.claude.evalMode)})})]})]})})]})})}),e.jsx(g.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:e.jsx(J,{title:r("settingsPage.browserSection.codex.title"),description:r("settingsPage.browserSection.codex.description"),action:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-border/60 bg-muted/30 px-4 py-2 dark:border-white/[0.06] dark:bg-zinc-900/45",children:[e.jsx(f,{htmlFor:"browser-codex-enabled",className:"cursor-pointer text-xs font-semibold leading-none",children:t.codex.enabled?"ENABLED":"DISABLED"}),e.jsx(G,{id:"browser-codex-enabled",checked:t.codex.enabled,onCheckedChange:n=>m(u=>X(u??t,{enabled:n}))})]}),e.jsxs(h,{onClick:te,disabled:l||!re,className:"rounded-full px-6 shadow-md transition-transform active:scale-95",children:[l?e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(k,{size:16,className:"mr-2"}),r("settingsPage.browserSection.actions.saveCodex")]})]}),children:e.jsxs("div",{className:"grid gap-12",children:[e.jsx(K,{state:a.codex.state,title:a.codex.title,detail:a.codex.detail,nextStep:a.codex.nextStep}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsx(f,{className:"text-sm font-semibold tracking-wide text-muted-foreground/80",children:r("settingsPage.browserSection.evalMode.label")}),e.jsxs($,{value:t.codex.evalMode,onValueChange:n=>m(u=>X(u??t,{evalMode:n})),children:[e.jsx(H,{className:"rounded-xl border-border/70 bg-background/85 dark:border-white/[0.08] dark:bg-zinc-900/70",children:e.jsx(F,{})}),e.jsx(U,{children:q.map(n=>e.jsx(V,{value:n,children:D(r,n)},n))})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground/70",children:r("settingsPage.browserSection.codex.evalModeHint")})]}),e.jsx(W,{title:r("settingsPage.browserSection.technicalDetails"),defaultOpen:a.codex.state==="unsupported_build",children:e.jsxs("div",{className:"grid gap-6 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.serverName")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:a.codex.serverName})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.overrideSupport")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-muted/25 p-3 font-medium text-xs dark:border-white/[0.05] dark:bg-zinc-900/45",children:[a.codex.supportsConfigOverrides?e.jsx(k,{className:"text-emerald-500",size:16}):e.jsx(B,{className:"text-rose-500",size:16}),a.codex.supportsConfigOverrides?r("settingsPage.browserSection.codex.overrideSupported"):r("settingsPage.browserSection.codex.overrideUnsupported")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.codex.binary")}),e.jsxs("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:[e.jsx("p",{className:"break-all font-mono text-[11px] leading-relaxed",children:a.codex.binaryPath??r("settingsPage.browserSection.codex.notDetected")}),a.codex.version&&e.jsx("div",{className:"mt-2 inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-bold text-primary",children:a.codex.version})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:r("settingsPage.browserSection.evalMode.label")}),e.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/25 p-3 dark:border-white/[0.05] dark:bg-zinc-900/45",children:e.jsx("p",{className:"font-mono text-[11px] font-semibold",children:D(r,a.codex.evalMode)})})]})]})})]})})})]})})]})}function L(r,s){return{...r,claude:{...r.claude,...s}}}function X(r,s){return{...r,codex:{...r.codex,...s}}}export{Oe as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as q,bi as J,bk as X,d as I,n as Y,L as A,r as R,s as M,t as K,v as B,w as E,I as F,aI as Q}from"./index-EoKZSZjT.js";import{R as $,w as Z,x as ee,ad as se,_ as te,s as re}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const z={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function ie(){const[t,i]=o.useState(null),[b,d]=o.useState(!0),[_,N]=o.useState(!1),[p,g]=o.useState(null),[P,y]=o.useState(!1),f=o.useRef(void 0),w=o.useRef(!1),k=o.useCallback(async()=>{const r=new AbortController,c=setTimeout(()=>r.abort(),U);try{d(!0),g(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(c),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const m=await n.json();i(m.config||z),f.current=m.lastModified,w.current=!0}catch(n){clearTimeout(c),n.name==="AbortError"?g("Request timeout - please try again"):g(n.message)}finally{d(!1)}return()=>r.abort()},[]),l=o.useCallback(async r=>{if(!w.current||t===null){g("Cannot save settings before they load. Click Refresh and try again.");return}const c=t,n={...c,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),i(n);const m=new AbortController,h=setTimeout(()=>m.abort(),U);try{N(!0),g(null);const x={...n,lastModified:f.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:m.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const s=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(s.error||"Failed to save")}const v=await u.json();i(v.config),f.current=v.lastModified,y(!0),setTimeout(()=>y(!1),1500)}catch(x){clearTimeout(h),i(c),x.name==="AbortError"?g("Request timeout - please try again"):(g(x.message),x.message.includes("another session")&&setTimeout(()=>k(),1e3))}finally{N(!1)}},[t,k]),T=o.useCallback(r=>{l({mode:r})},[l]),C=o.useCallback((r,c)=>{const n=t?.tier_defaults||z.tier_defaults;l({tier_defaults:{...n,[r]:c}})},[t,l]),O=o.useCallback(r=>{l({show_warnings:r})},[l]),D=o.useCallback(r=>{if(r===void 0){l({override:null,clear_override:!0});return}l({override:r,clear_override:!1})},[l]),L=o.useCallback((r,c,n)=>{const m=t?.provider_overrides||{},h=m[r]||{};if(n===void 0){const{[c]:x,...u}=h,v=Object.keys(u).length>0?u:void 0,{[r]:S,...s}=m,a=v?{...s,[r]:v}:s;l({provider_overrides:Object.keys(a).length>0?a:null,clear_provider_overrides:Object.keys(a).length===0})}else l({provider_overrides:{...m,[r]:{...h,[c]:n}},clear_provider_overrides:!1})},[t,l]);return{config:t||z,loading:b,saving:_,error:p,success:P,fetchConfig:k,saveConfig:l,setMode:T,setTierDefault:C,setShowWarnings:O,setOverride:D,setProviderOverride:L}}const H=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"max",label:"Max (adaptive ceiling)"},{value:"auto",label:"Auto (dynamic)"}],ne=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ae=["agy","gemini","codex"],G=0,V=1e5;function fe(){const{t}=q(),{config:i,loading:b,saving:d,error:_,success:N,fetchConfig:p,setMode:g,setTierDefault:P,setShowWarnings:y,setOverride:f,setProviderOverride:w}=ie(),[k,l]=o.useState(null),[T,C]=o.useState(""),[O,D]=o.useState([]),[L,r]=o.useState(null),c=o.useMemo(()=>Array.from(new Set([...ae,...Object.keys(i.provider_overrides??{}),...O])),[O,i.provider_overrides]),n=i.override===void 0?"__none__":typeof i.override=="number"||/^\d+$/.test(String(i.override))?"__custom__":String(i.override),m=typeof i.override=="number"||/^\d+$/.test(String(i.override??""))?String(i.override):"",h=L??m,x=Object.keys(i.provider_overrides??{}).length>0,u=k??x;o.useEffect(()=>{p()},[p]);const v=()=>{const s=T.trim().toLowerCase();s&&(c.includes(s)||D(a=>[...a,s]),C(""),l(!0))},S=()=>{const s=h.trim();if(!s){f(void 0);return}const a=Number.parseInt(s,10);Number.isNaN(a)||a<G||a>V||!/^\d+$/.test(s)||f(a)};return b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx($,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${_||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[_&&e.jsx(J,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx(X,{children:_})]}),e.jsxs(I,{variant:"outline",size:"sm",onClick:p,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("sharedPage.retry")]})]})}),N&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:t("settings.saved")})]})]}),e.jsx(Y,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.description")})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(te,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.supportedProviders")}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:[t("settingsThinking.supportLine1Prefix")," ",e.jsx("strong",{children:"agy"}),","," ",e.jsx("strong",{children:"gemini"})," ",t("settingsThinking.supportLine1Suffix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine2Prefix")," ",e.jsx("strong",{children:"codex"})," ",t("settingsThinking.supportLine2SuffixPrefix"),e.jsx("code",{children:"--effort"}),t("settingsThinking.supportLine2SuffixPostfix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine3Prefix")," ",e.jsx("code",{children:"-high"}),t("settingsThinking.supportLine3Suffix")]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.modeTitle")}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${i.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${d?"opacity-70 pointer-events-none":""}`,onClick:()=>{d||g(s)},children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&t("settingsThinking.modeAutoDesc"),s==="off"&&t("settingsThinking.modeOffDesc"),s==="manual"&&t("settingsThinking.modeManualDesc")]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${i.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),i.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.tierDefaults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.tierDefaultsDesc")}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(R,{value:i.tier_defaults[s],onValueChange:a=>P(s,a),disabled:d,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx(B,{children:H.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s))})]}),i.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.persistentOverride")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.persistentOverrideDesc")}),e.jsxs(R,{value:n,onValueChange:s=>{if(s==="__none__"){f(void 0);return}if(s==="__custom__"){h||r("8192");return}r(null),f(s)},disabled:d,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx(B,{children:ne.map(s=>e.jsx(E,{value:s.value,children:s.label},s.value))})]}),n==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:G,max:V,value:h,onChange:s=>r(s.target.value),onBlur:S,disabled:d,placeholder:t("settingsThinking.enterCustomBudget")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:d,children:t("settingsThinking.apply")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",G," to ",V]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>l(s=>!(s??x)),disabled:d,children:[e.jsx(re,{className:`w-4 h-4 transition-transform ${u?"rotate-0":"-rotate-90"}`}),t("settingsThinking.providerOverrides",{count:Object.keys(i.provider_overrides??{}).length})]}),u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.providerOverridesDesc")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:T,onChange:s=>C(s.target.value),disabled:d,placeholder:t("settingsThinking.addProviderPlaceholder")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:v,disabled:d,children:t("settingsGlobalEnv.add")})]}),c.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(a=>{const W=i.provider_overrides?.[s]?.[a]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(A,{className:"text-xs text-muted-foreground capitalize",children:a}),e.jsxs(R,{value:W,onValueChange:j=>w(s,a,j==="__default__"?void 0:j),disabled:d,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs(B,{children:[e.jsx(E,{value:"__default__",children:t("cursorPage.default")}),H.map(j=>e.jsx(E,{value:j.value,children:j.label},j.value))]})]})]},a)})})]},s))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.showWarnings")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.showWarningsDesc")})]}),e.jsx(Q,{checked:i.show_warnings??!0,onCheckedChange:y,disabled:d})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:t("settingsThinking.cliEnvOverride")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:p,disabled:b||d,className:"w-full",children:[e.jsx($,{className:`w-4 h-4 mr-2 ${b?"animate-spin":""}`}),t("settings.refresh")]})})]})}export{fe as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as q,bi as J,bk as X,d as I,n as Y,L as A,r as R,s as M,t as K,v as B,w as E,I as F,aI as Q}from"./index-CEuKLsUj.js";import{R as $,w as Z,x as ee,ad as se,_ as te,s as re}from"./icons-DyorC3Xk.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const z={mode:"auto",tier_defaults:{opus:"high",sonnet:"medium",haiku:"low"},show_warnings:!0},U=1e4;function ie(){const[t,i]=o.useState(null),[b,d]=o.useState(!0),[_,N]=o.useState(!1),[p,g]=o.useState(null),[P,y]=o.useState(!1),f=o.useRef(void 0),w=o.useRef(!1),k=o.useCallback(async()=>{const r=new AbortController,c=setTimeout(()=>r.abort(),U);try{d(!0),g(null);const n=await fetch("/api/thinking",{signal:r.signal});if(clearTimeout(c),!n.ok)throw n.headers.get("content-type")?.includes("text/html")?new Error(`Server error (${n.status})`):new Error("Failed to load Thinking config");const m=await n.json();i(m.config||z),f.current=m.lastModified,w.current=!0}catch(n){clearTimeout(c),n.name==="AbortError"?g("Request timeout - please try again"):g(n.message)}finally{d(!1)}return()=>r.abort()},[]),l=o.useCallback(async r=>{if(!w.current||t===null){g("Cannot save settings before they load. Click Refresh and try again.");return}const c=t,n={...c,...r.mode!==void 0?{mode:r.mode}:{},...r.tier_defaults!==void 0?{tier_defaults:r.tier_defaults}:{},...r.show_warnings!==void 0?{show_warnings:r.show_warnings}:{}};r.clear_override||r.override===null?delete n.override:r.override!==void 0&&(n.override=r.override),r.clear_provider_overrides||r.provider_overrides===null?delete n.provider_overrides:r.provider_overrides!==void 0&&(n.provider_overrides=r.provider_overrides),i(n);const m=new AbortController,h=setTimeout(()=>m.abort(),U);try{N(!0),g(null);const x={...n,lastModified:f.current},u=await fetch("/api/thinking",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:m.signal});if(clearTimeout(h),!u.ok){if(u.headers.get("content-type")?.includes("text/html"))throw new Error(`Server error (${u.status})`);const s=await u.json();throw u.status===409?new Error("Config changed by another session. Refreshing..."):new Error(s.error||"Failed to save")}const v=await u.json();i(v.config),f.current=v.lastModified,y(!0),setTimeout(()=>y(!1),1500)}catch(x){clearTimeout(h),i(c),x.name==="AbortError"?g("Request timeout - please try again"):(g(x.message),x.message.includes("another session")&&setTimeout(()=>k(),1e3))}finally{N(!1)}},[t,k]),T=o.useCallback(r=>{l({mode:r})},[l]),C=o.useCallback((r,c)=>{const n=t?.tier_defaults||z.tier_defaults;l({tier_defaults:{...n,[r]:c}})},[t,l]),O=o.useCallback(r=>{l({show_warnings:r})},[l]),D=o.useCallback(r=>{if(r===void 0){l({override:null,clear_override:!0});return}l({override:r,clear_override:!1})},[l]),L=o.useCallback((r,c,n)=>{const m=t?.provider_overrides||{},h=m[r]||{};if(n===void 0){const{[c]:x,...u}=h,v=Object.keys(u).length>0?u:void 0,{[r]:S,...s}=m,a=v?{...s,[r]:v}:s;l({provider_overrides:Object.keys(a).length>0?a:null,clear_provider_overrides:Object.keys(a).length===0})}else l({provider_overrides:{...m,[r]:{...h,[c]:n}},clear_provider_overrides:!1})},[t,l]);return{config:t||z,loading:b,saving:_,error:p,success:P,fetchConfig:k,saveConfig:l,setMode:T,setTierDefault:C,setShowWarnings:O,setOverride:D,setProviderOverride:L}}const H=[{value:"minimal",label:"Minimal (512 tokens)"},{value:"low",label:"Low (1K tokens)"},{value:"medium",label:"Medium (8K tokens)"},{value:"high",label:"High (24K tokens)"},{value:"xhigh",label:"Extra High (32K tokens)"},{value:"max",label:"Max (adaptive ceiling)"},{value:"auto",label:"Auto (dynamic)"}],ne=[{value:"__none__",label:"None (use CLI flags only)"},...H,{value:"__custom__",label:"Custom budget (number)"},{value:"off",label:"Off (disable thinking)"}],ae=["agy","gemini","codex"],G=0,V=1e5;function fe(){const{t}=q(),{config:i,loading:b,saving:d,error:_,success:N,fetchConfig:p,setMode:g,setTierDefault:P,setShowWarnings:y,setOverride:f,setProviderOverride:w}=ie(),[k,l]=o.useState(null),[T,C]=o.useState(""),[O,D]=o.useState([]),[L,r]=o.useState(null),c=o.useMemo(()=>Array.from(new Set([...ae,...Object.keys(i.provider_overrides??{}),...O])),[O,i.provider_overrides]),n=i.override===void 0?"__none__":typeof i.override=="number"||/^\d+$/.test(String(i.override))?"__custom__":String(i.override),m=typeof i.override=="number"||/^\d+$/.test(String(i.override??""))?String(i.override):"",h=L??m,x=Object.keys(i.provider_overrides??{}).length>0,u=k??x;o.useEffect(()=>{p()},[p]);const v=()=>{const s=T.trim().toLowerCase();s&&(c.includes(s)||D(a=>[...a,s]),C(""),l(!0))},S=()=>{const s=h.trim();if(!s){f(void 0);return}const a=Number.parseInt(s,10);Number.isNaN(a)||a<G||a>V||!/^\d+$/.test(s)||f(a)};return b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx($,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settings.loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${_||N?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[_&&e.jsx(J,{variant:"destructive",className:"py-2 shadow-lg",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx(X,{children:_})]}),e.jsxs(I,{variant:"outline",size:"sm",onClick:p,className:"h-7 px-2 text-xs border-destructive/50 hover:bg-destructive/10",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("sharedPage.retry")]})]})}),N&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:t("settings.saved")})]})]}),e.jsx(Y,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(se,{className:"w-5 h-5 text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.description")})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(te,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.supportedProviders")}),e.jsxs("ul",{className:"mt-1 space-y-0.5 text-blue-600 dark:text-blue-400",children:[e.jsxs("li",{children:[t("settingsThinking.supportLine1Prefix")," ",e.jsx("strong",{children:"agy"}),","," ",e.jsx("strong",{children:"gemini"})," ",t("settingsThinking.supportLine1Suffix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine2Prefix")," ",e.jsx("strong",{children:"codex"})," ",t("settingsThinking.supportLine2SuffixPrefix"),e.jsx("code",{children:"--effort"}),t("settingsThinking.supportLine2SuffixPostfix")]}),e.jsxs("li",{children:[t("settingsThinking.supportLine3Prefix")," ",e.jsx("code",{children:"-high"}),t("settingsThinking.supportLine3Suffix")]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.modeTitle")}),e.jsx("div",{className:"space-y-2",children:["auto","off","manual"].map(s=>e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg cursor-pointer transition-colors ${i.mode===s?"bg-primary/10 border border-primary/30":"bg-muted/50 hover:bg-muted/80"} ${d?"opacity-70 pointer-events-none":""}`,onClick:()=>{d||g(s)},children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium capitalize",children:s}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s==="auto"&&t("settingsThinking.modeAutoDesc"),s==="off"&&t("settingsThinking.modeOffDesc"),s==="manual"&&t("settingsThinking.modeManualDesc")]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 ${i.mode===s?"bg-primary border-primary":"border-muted-foreground/50"}`})]},s))})]}),i.mode==="auto"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.tierDefaults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.tierDefaultsDesc")}),e.jsx("div",{className:"space-y-3",children:["opus","sonnet","haiku"].map(s=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"w-20 capitalize font-medium",children:s}),e.jsxs(R,{value:i.tier_defaults[s],onValueChange:a=>P(s,a),disabled:d,children:[e.jsx(M,{className:"flex-1",children:e.jsx(K,{})}),e.jsx(B,{children:H.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s))})]}),i.mode==="manual"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:t("settingsThinking.persistentOverride")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.persistentOverrideDesc")}),e.jsxs(R,{value:n,onValueChange:s=>{if(s==="__none__"){f(void 0);return}if(s==="__custom__"){h||r("8192");return}r(null),f(s)},disabled:d,children:[e.jsx(M,{children:e.jsx(K,{})}),e.jsx(B,{children:ne.map(s=>e.jsx(E,{value:s.value,children:s.label},s.value))})]}),n==="__custom__"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{type:"number",min:G,max:V,value:h,onChange:s=>r(s.target.value),onBlur:S,disabled:d,placeholder:t("settingsThinking.enterCustomBudget")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:d,children:t("settingsThinking.apply")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Range: ",G," to ",V]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 text-base font-medium w-full text-left",onClick:()=>l(s=>!(s??x)),disabled:d,children:[e.jsx(re,{className:`w-4 h-4 transition-transform ${u?"rotate-0":"-rotate-90"}`}),t("settingsThinking.providerOverrides",{count:Object.keys(i.provider_overrides??{}).length})]}),u&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.providerOverridesDesc")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{value:T,onChange:s=>C(s.target.value),disabled:d,placeholder:t("settingsThinking.addProviderPlaceholder")}),e.jsx(I,{type:"button",size:"sm",variant:"outline",onClick:v,disabled:d,children:t("settingsGlobalEnv.add")})]}),c.map(s=>e.jsxs("div",{className:"space-y-2 p-3 rounded-lg bg-muted/30",children:[e.jsx(A,{className:"capitalize font-medium text-sm",children:s}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["opus","sonnet","haiku"].map(a=>{const W=i.provider_overrides?.[s]?.[a]||"__default__";return e.jsxs("div",{className:"space-y-1",children:[e.jsx(A,{className:"text-xs text-muted-foreground capitalize",children:a}),e.jsxs(R,{value:W,onValueChange:j=>w(s,a,j==="__default__"?void 0:j),disabled:d,children:[e.jsx(M,{className:"h-8 text-xs",children:e.jsx(K,{})}),e.jsxs(B,{children:[e.jsx(E,{value:"__default__",children:t("cursorPage.default")}),H.map(j=>e.jsx(E,{value:j.value,children:j.label},j.value))]})]})]},a)})})]},s))]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t("settingsThinking.showWarnings")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsThinking.showWarningsDesc")})]}),e.jsx(Q,{checked:i.show_warnings??!0,onCheckedChange:y,disabled:d})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:t("settingsThinking.cliEnvOverride")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-2",children:["Override per session with flags or"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-muted",children:"CCS_THINKING"})," env var. Priority: flag > env > config."]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono text-muted-foreground",children:[e.jsx("p",{children:"ccs gemini --thinking high"}),e.jsx("p",{children:"ccs codex --effort xhigh"}),e.jsx("p",{children:'CCS_THINKING=high ccs codex "debug this"'}),e.jsx("p",{children:"ccs config thinking --mode auto"})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(I,{variant:"outline",size:"sm",onClick:p,disabled:b||d,className:"w-full",children:[e.jsx($,{className:`w-4 h-4 mr-2 ${b?"animate-spin":""}`}),t("settings.refresh")]})})]})}export{fe as default};