@kaitranntt/ccs 7.74.0-dev.1 → 7.74.0-dev.2

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/cliproxy/codex-plan-compatibility.d.ts.map +1 -1
  2. package/dist/cliproxy/codex-plan-compatibility.js +1 -0
  3. package/dist/cliproxy/codex-plan-compatibility.js.map +1 -1
  4. package/dist/cliproxy/model-catalog.d.ts.map +1 -1
  5. package/dist/cliproxy/model-catalog.js +12 -0
  6. package/dist/cliproxy/model-catalog.js.map +1 -1
  7. package/dist/ui/assets/{accounts-D0Z5AVKW.js → accounts-BGE0yjYy.js} +1 -1
  8. package/dist/ui/assets/{alert-dialog-CzJucE0e.js → alert-dialog-DuiOADsV.js} +1 -1
  9. package/dist/ui/assets/{api-DXAf4i-v.js → api-Guj515aS.js} +1 -1
  10. package/dist/ui/assets/{auth-section-BrnnHBi-.js → auth-section-SAQbhr1I.js} +1 -1
  11. package/dist/ui/assets/{backups-section-DCBcfZ-C.js → backups-section-DDvlWpiu.js} +1 -1
  12. package/dist/ui/assets/{channels-BSapONLx.js → channels-BplAqAOq.js} +1 -1
  13. package/dist/ui/assets/{checkbox-Bd7X5Xud.js → checkbox-BOkFW5T7.js} +1 -1
  14. package/dist/ui/assets/{claude-extension-BYJxm4B5.js → claude-extension-n_MuC68N.js} +1 -1
  15. package/dist/ui/assets/{cliproxy-G5JuFm2j.js → cliproxy-WWj2GyJE.js} +1 -1
  16. package/dist/ui/assets/{cliproxy-ai-providers-D7r2Us_Y.js → cliproxy-ai-providers-B70CiXmm.js} +1 -1
  17. package/dist/ui/assets/{cliproxy-control-panel-Cmo3ArVL.js → cliproxy-control-panel-B7FrWnuW.js} +1 -1
  18. package/dist/ui/assets/{codex-4VNBJ4Nb.js → codex-BoljmCX9.js} +8 -8
  19. package/dist/ui/assets/{confirm-dialog--zJgz4y0.js → confirm-dialog-D73zMOJ7.js} +1 -1
  20. package/dist/ui/assets/{copilot-2ARJ9YVb.js → copilot-CmS0DhuS.js} +1 -1
  21. package/dist/ui/assets/{cursor-CQNCrVt0.js → cursor-btzq1F22.js} +1 -1
  22. package/dist/ui/assets/{droid-Dl5wRjDv.js → droid-Dt-4f5BE.js} +1 -1
  23. package/dist/ui/assets/{globalenv-section-T1imQsSA.js → globalenv-section-DWWZ9ERp.js} +1 -1
  24. package/dist/ui/assets/{health-CNous3WN.js → health-CuzprvVL.js} +1 -1
  25. package/dist/ui/assets/{index-fV5BBuAO.js → index-CA5Km3DW.js} +1 -1
  26. package/dist/ui/assets/{index-BcLnqcxD.js → index-CHCBgQxw.js} +1 -1
  27. package/dist/ui/assets/{index-DH916Tyi.js → index-ClrCKbzh.js} +1 -1
  28. package/dist/ui/assets/{index-Be3dhMW3.js → index-DEqhujvv.js} +1 -1
  29. package/dist/ui/assets/{index-DFgCoUVv.js → index-DPiX3K4c.js} +1 -1
  30. package/dist/ui/assets/{index-CqJFugM4.js → index-DQXr3j8J.js} +1 -1
  31. package/dist/ui/assets/{index-2X8-14xr.js → index-DhAjOd4r.js} +2 -2
  32. package/dist/ui/assets/{logs-CZsWbq7X.js → logs-CabVgAOr.js} +1 -1
  33. package/dist/ui/assets/{masked-input-_EkW1Pzo.js → masked-input-4lwOg03z.js} +1 -1
  34. package/dist/ui/assets/{proxy-status-widget-D82T2X4F.js → proxy-status-widget-C6Ctzus0.js} +1 -1
  35. package/dist/ui/assets/{raw-json-settings-editor-panel-DNmb_vR-.js → raw-json-settings-editor-panel-upVhpuik.js} +1 -1
  36. package/dist/ui/assets/{searchable-select--iFe00dY.js → searchable-select-DkL__exx.js} +1 -1
  37. package/dist/ui/assets/{separator-CaGbNw8E.js → separator-fWUi3UIY.js} +1 -1
  38. package/dist/ui/assets/{shared-Cgk48Wu3.js → shared-I-FRJqTw.js} +1 -1
  39. package/dist/ui/assets/{table-CKuoPAz4.js → table-D3mrbj8H.js} +1 -1
  40. package/dist/ui/assets/{updates-Dr8Yq-Pm.js → updates-2HIhdejN.js} +1 -1
  41. package/dist/ui/index.html +1 -1
  42. package/package.json +1 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b,h as gs}from"./react-vendor-CNOkPC89.js";import{t as i}from"./notifications-B2HqRBj7.js";import{bf as y,bg as xs,a as Oe,B as M,d as h,c as V,n as U,Q as hs,R as fs,U as ue,V as me,L,I as ge,aI as Fe,bl as ps,ah as js,ai as Ps,aj as bs,ak as ys,al as Ns,aD as vs,bh as ws}from"./index-2X8-14xr.js";import{a as Cs,u as B,b as R}from"./tanstack-CrmUhA7Z.js";import{D as Ee}from"./default-ports-1QQSffYX.js";import{S as Ss}from"./separator-CaGbNw8E.js";import{S as ks}from"./searchable-select--iFe00dY.js";import{R as Le,T as _s,K as z,Z as J,ai as As,ae as Ds,ax as xe,aQ as Ie,aP as Ms,L as F,J as Ts,au as Rs,aa as Fs,x as Ls,I as Is}from"./icons-DyorC3Xk.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const N="/legacy/cursor";function Os(s){if(!s||typeof s!="object")return!1;const t=s;return typeof t.message=="string"&&typeof t.stage=="string"&&typeof t.status=="number"&&typeof t.duration_ms=="number"&&typeof t.ok=="boolean"}function Es(s){if(!s||typeof s!="object"||!("error"in s))return null;const t=s;return typeof t.error=="string"?t.error:null}async function zs(){const s=await fetch(y(`${N}/status`));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ks(){const s=await fetch(y(`${N}/settings`));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function qs(){const s=await fetch(y(`${N}/models`));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Gs(){const s=await fetch(y(`${N}/settings/raw`));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Qs(s){const t=await fetch(y(`${N}/settings`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Us(s){const t=await fetch(y(`${N}/settings/raw`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new xs("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Bs(){const s=await fetch(y(`${N}/auth/auto-detect`),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Js(s){const t=await fetch(y(`${N}/auth/import`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const r=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(r.error||"Manual import failed")}return t.json()}async function $s(){const s=await fetch(y(`${N}/daemon/start`),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Hs(){const s=await fetch(y(`${N}/daemon/stop`),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Vs(){const s=await fetch(y(`${N}/probe`),{method:"POST"}),t=await s.json().catch(()=>null);return Os(t)?t:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Es(t)??"Failed to run live probe"}}function Ws(){const s=Cs(),t=B({queryKey:["cursor-status"],queryFn:zs,refetchInterval:5e3}),r=B({queryKey:["cursor-config"],queryFn:Ks}),u=B({queryKey:["cursor-models"],queryFn:qs}),x=B({queryKey:["cursor-raw-settings"],queryFn:Gs}),c=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},f=R({mutationFn:Qs,onSuccess:c}),g=R({mutationFn:Us,onSuccess:c}),p=R({mutationFn:Bs,onSuccess:c}),n=R({mutationFn:Js,onSuccess:c}),l=R({mutationFn:$s,onSuccess:c}),d=R({mutationFn:Hs,onSuccess:c}),m=R({mutationFn:Vs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:r.data,configLoading:r.isLoading,refetchConfig:r.refetch,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:x.data,rawSettingsLoading:x.isLoading,refetchRawSettings:x.refetch,updateConfig:f.mutate,updateConfigAsync:f.mutateAsync,isUpdatingConfig:f.isPending,saveRawSettings:g.mutate,saveRawSettingsAsync:g.mutateAsync,isSavingRawSettings:g.isPending,autoDetectAuth:p.mutate,autoDetectAuthAsync:p.mutateAsync,isAutoDetectingAuth:p.isPending,autoDetectAuthResult:p.data,importManualAuth:n.mutate,importManualAuthAsync:n.mutateAsync,isImportingManualAuth:n.isPending,manualAuthResult:n.data,startDaemon:l.mutate,startDaemonAsync:l.mutateAsync,isStartingDaemon:l.isPending,stopDaemon:d.mutate,stopDaemonAsync:d.mutateAsync,isStoppingDaemon:d.isPending,runProbe:m.mutate,runProbeAsync:m.mutateAsync,isRunningProbe:m.isPending,probeResult:m.data,resetProbe:m.reset}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.refetch,u.data,u.isLoading,x.data,x.isLoading,x.refetch,f.mutate,f.mutateAsync,f.isPending,g.mutate,g.mutateAsync,g.isPending,p.mutate,p.mutateAsync,p.isPending,p.data,n.mutate,n.mutateAsync,n.isPending,n.data,l.mutate,l.mutateAsync,l.isPending,d.mutate,d.mutateAsync,d.isPending,m.mutate,m.mutateAsync,m.isPending,m.data,m.reset])}function he(s,t){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:t?.auto_start??null,model:t?.model??null})}function $(s){return{port:String(s?.port??Ee),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 S(s,t,r){return s.find(x=>t.some(c=>c.test(x.id)))?.id??r}function fe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function k(s,t,r){const u=new Set(t.map(fe)),x=s.find(f=>u.has(fe(f.id)));if(x)return x.id;const c=s.find(f=>u.has(fe(f.name)));return c?c.id:r}function Xs(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function H({label:s,description:t,value:r,models:u,disabled:x,allowDefaultFallback:c=!1,onChange:f}){const{t:g}=Oe(),p=r||(c?"__default":""),n=b.useMemo(()=>{const l=u.map(d=>({value:d.id,groupKey:"models",searchText:`${d.name||d.id} ${d.id}`,keywords:[d.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:d.name||d.id}),d.provider&&e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.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:d.name||d.id}),e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]})}));return c?[{value:"__default",groupKey:"models",searchText:g("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:g("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:g("cursorPage.useDefaultModel")})},...l]:l},[c,u,g]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ks,{value:p||void 0,onChange:l=>{if(c&&l==="__default"){f("");return}f(l)},disabled:x,placeholder:g("cursorPage.selectModel"),searchPlaceholder:g("searchableSelect.searchModels"),emptyText:g("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:g("cursorPage.availableModelCount",{count:u.length})}],options:n})]})}function pe({icon:s,label:t,ok:r,detail:u}){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:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r?e.jsx(Ls,{className:"h-4 w-4 text-green-500"}):e.jsx(Is,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:V("text-xs",r?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function da(){const{t:s}=Oe(),t=gs(),{status:r,statusLoading:u,refetchStatus:x,config:c,refetchConfig:f,updateConfigAsync:g,isUpdatingConfig:p,models:n,modelsLoading:l,currentModel:d,rawSettings:m,rawSettingsLoading:je,refetchRawSettings:ze,saveRawSettingsAsync:Ke,isSavingRawSettings:Pe,autoDetectAuthAsync:qe,isAutoDetectingAuth:be,importManualAuthAsync:Ge,isImportingManualAuth:ye,startDaemonAsync:Qe,isStartingDaemon:Ue,stopDaemonAsync:Be,isStoppingDaemon:Ne,runProbeAsync:Je,isRunningProbe:W,probeResult:X,resetProbe:$e}=Ws(),[T,Z]=b.useState(()=>$()),[v,Y]=b.useState(!1),[ve,He]=b.useState("{}"),[I,ee]=b.useState(!1),[Ve,K]=b.useState(!1),[se,we]=b.useState(""),[ae,Ce]=b.useState(""),[Se,ke]=b.useState(()=>X?he(r,c):null),_=$(c),_e=v?T.port:_.port,te=v?T.auto_start:_.auto_start,re=v?T.ghost_mode:_.ghost_mode,w=v?T.model:_.model,ne=v?T.opus_model:_.opus_model,oe=v?T.sonnet_model:_.sonnet_model,ie=v?T.haiku_model:_.haiku_model,ce=I?ve:JSON.stringify(m?.settings??{},null,2),Ae=!!m,O=b.useMemo(()=>Xs(ce),[ce]),De=O.isValid,q=v||I,We=!I||Ae&&De,Xe=he(r,c),P=X&&!q&&Se!==null&&Se===Xe?X:null,G=b.useMemo(()=>{const a=new Set,o=[...n].sort((D,de)=>D.name.localeCompare(de.name)),j=o.filter(D=>a.has(D.id)?!1:(a.add(D.id),!0));return w&&!o.some(D=>D.id===w)?[{id:w,name:w,provider:"custom"},...j]:j},[n,w]),C=a=>{Z(o=>a(v?o:_)),Y(!0)},A=()=>{$e(),ke(null)},Ze=(a=c)=>{Z($(a)),Y(!1)},Ye=!!(r?.enabled&&r?.authenticated&&!r?.token_expired),es=b.useMemo(()=>r?.enabled?e.jsx(M,{children:s("cursorPage.enabled")}):e.jsx(M,{variant:"secondary",children:s("cursorPage.disabled")}),[r?.enabled,s]),ss=async({suppressSuccessToast:a=!1}={})=>{const o=Number(_e);if(!Number.isInteger(o)||o<1||o>65535)return i.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return i.error(s("cursorPage.defaultModelRequired")),!1;try{return await g({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0}),Y(!1),Z($({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0})),A(),a||i.success(s("cursorPage.savedConfig")),!0}catch(j){return i.error(j.message||s("cursorPage.failedSaveConfig")),!1}},le=a=>{if(l){i.error(s("cursorPage.modelsLoadingWait"));return}if(n.length===0){i.error(s("cursorPage.noModelsAvailable"));return}const o=w||d||n[0]?.id||"gpt-5.3-codex",j=k(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],S(n,[/gpt[-.]?5.*codex/i],o)),D=k(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],S(n,[/gpt[-.]?5.*codex.*max/i],j)),de=k(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],S(n,[/gpt[-.]?5.*fast/i],j)),ds=k(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],S(n,[/gpt[-.]?5.*mini/i],de)),Te=k(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],S(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],j)),Re=k(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],S(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],j)),us=k(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],S(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Re)),Q=k(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],S(n,[/gemini[-.]?3.*pro/i],j)),ms=k(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],S(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],Q));if(a==="codex53"){C(E=>({...E,model:j,opus_model:D,sonnet_model:j,haiku_model:ds})),i.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){C(E=>({...E,model:Te,opus_model:Te,sonnet_model:Re,haiku_model:us})),i.success(s("cursorPage.appliedClaudePreset"));return}C(E=>({...E,model:Q,opus_model:Q,sonnet_model:Q,haiku_model:ms})),i.success(s("cursorPage.appliedGeminiPreset"))},Me=async a=>{try{await g({enabled:a}),A(),i.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(o){i.error(o.message||s("cursorPage.failedUpdateIntegration"))}},as=async()=>{try{await qe(),A(),i.success(s("cursorPage.credentialsImported"))}catch(a){i.error(a.message||s("cursorPage.autoDetectFailed"))}},ts=async()=>{if(!se.trim()||!ae.trim()){i.error(s("cursorPage.manualRequired"));return}try{await Ge({accessToken:se.trim(),machineId:ae.trim()}),A(),i.success(s("cursorPage.credentialsImported")),K(!1),we(""),Ce("")}catch(a){i.error(a.message||s("cursorPage.manualImportFailed"))}},rs=async()=>{try{const a=await Qe();if(!a.success){i.error(a.error||s("cursorPage.failedStartDaemon"));return}A(),i.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){i.error(a.message||s("cursorPage.failedStartDaemon"))}},ns=async()=>{try{const a=await Be();if(!a.success){i.error(a.error||s("cursorPage.failedStopDaemon"));return}A(),i.success(s("cursorPage.daemonStopped"))}catch(a){i.error(a.message||s("cursorPage.failedStopDaemon"))}},os=async()=>{if(q){i.error(s("cursorPage.probeSaveFirst"));return}try{const a=await Je(),o=await x();if(ke(he(o.data??r,c)),a.ok){i.success(s("cursorPage.probeSucceeded"));return}i.error(a.message||s("cursorPage.probeFailed"))}catch(a){i.error(a.message||s("cursorPage.probeFailed"))}},is=async({suppressSuccessToast:a=!1}={})=>{if(!Ae)return i.error(s("cursorPage.rawLoading")),!1;if(!O.isValid||!O.settings)return i.error(O.error||s("cursorPage.invalidJson")),!1;try{return await Ke({settings:O.settings,expectedMtime:m?.mtime}),ee(!1),A(),a||i.success(s("cursorPage.rawSaved")),!0}catch(o){return ws(o)?i.error(s("cursorPage.rawChanged")):i.error(o.message||s("cursorPage.failedSaveRaw")),!1}},cs=async()=>{if(!q)return;const a=v,o=I;a&&!await ss({suppressSuccessToast:o})||o&&!await is({suppressSuccessToast:a})||a&&o&&i.success(s("cursorPage.savedAll"))},ls=async()=>{ee(!1),A();const[,a]=await Promise.all([x(),f(),ze()]);Ze(a.data??c)};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(M,{variant:"outline",className:"h-5 border-red-500/50 bg-red-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300",children:s("cursorPage.deprecated")}),es]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(),disabled:u,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Le,{className:V("w-4 h-4",u&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(U,{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(_s,{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:"rounded-md border border-border/70 bg-background/90 p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.supportedPathTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.supportedPathDesc")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor&action=auth"),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startCliproxyAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.openCliproxyCursor")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{icon:As,label:s("cursorPage.integration"),ok:!!r?.enabled,detail:r?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(pe,{icon:z,label:s("cursorPage.authentication"),ok:!!(r?.authenticated&&!r?.token_expired),detail:r?.authenticated?r?.token_expired?s("cursorPage.expired"):r.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(pe,{icon:Ds,label:s("cursorPage.daemon"),ok:!!r?.daemon_running,detail:r?.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(xe,{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(M,{variant:P?"outline":"secondary",className:V(P?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",P&&!P.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:P?P.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),P?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:P.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:P.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:[P.duration_ms," ms"]})]}),P.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:P.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:P.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")}),r?.enabled?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:p,children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:p,children:[e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:as,disabled:be,children:[be?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>K(!0),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:os,disabled:W,children:[W?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),s(W?"cursorPage.probing":P?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),r?.daemon_running?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:ns,disabled:Ne,children:[Ne?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:rs,disabled:!Ye,children:[Ue?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ts,{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:r?.port??c?.port??Ee})]})})]}),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")}),m&&e.jsx(M,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",m.exists?new Date(m.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:ls,disabled:u||je,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Le,{className:V("w-4 h-4",(u||je)&&"animate-spin")})}),e.jsx(h,{size:"sm",onClick:cs,disabled:p||Pe||!q||!We,children:p||Pe?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Rs,{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(hs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(fs,{className:"w-full",children:[e.jsx(ue,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(ue,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(ue,{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(me,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(Fs,{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(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("codex53"),disabled:l||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(J,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("claude46"),disabled:l||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(J,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("gemini3"),disabled:l||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(J,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(Ss,{}),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(H,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:G,disabled:l,onChange:a=>{C(o=>({...o,model:a}))}}),e.jsx(H,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:ne,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,opus_model:a}))}}),e.jsx(H,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:oe,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,sonnet_model:a}))}}),e.jsx(H,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ie,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,haiku_model:a}))}})]})]})]})})}),e.jsx(me,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(L,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ge,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:_e,onChange:a=>{C(o=>({...o,port:a.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(L,{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(Fe,{id:"cursor-auto-start",checked:te,onCheckedChange:a=>{C(o=>({...o,auto_start:a}))}})]}),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:"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(Fe,{id:"cursor-ghost-mode",checked:re,onCheckedChange:a=>{C(o=>({...o,ghost_mode:a}))}})]})]})})})}),e.jsx(me,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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 (Legacy)"})]}),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:m?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Legacy bridge 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")}),l?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:n.map(a=>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:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===d&&e.jsx(M,{children:s("cursorPage.default")})]},a.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(xe,{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(ps,{rawJsonContent:ce,isRawJsonValid:De,rawJsonEdits:I?ve:null,rawSettingsEnv:m?.settings?.env,onChange:a=>{ee(!0),He(a)}})]})]})]})})]}),e.jsx(js,{open:Ve,onOpenChange:K,children:e.jsxs(Ps,{children:[e.jsxs(bs,{children:[e.jsx(ys,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ge,{id:"cursor-manual-token",value:se,onChange:a=>we(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ge,{id:"cursor-manual-machine-id",value:ae,onChange:a=>Ce(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(vs,{children:[e.jsx(h,{variant:"outline",onClick:()=>K(!1),children:s("cursorPage.cancel")}),e.jsxs(h,{onClick:ts,disabled:ye,children:[ye?e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(z,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{da as CursorPage};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as b,h as gs}from"./react-vendor-CNOkPC89.js";import{t as i}from"./notifications-B2HqRBj7.js";import{bf as y,bg as xs,a as Oe,B as M,d as h,c as V,n as U,Q as hs,R as fs,U as ue,V as me,L,I as ge,aI as Fe,bl as ps,ah as js,ai as Ps,aj as bs,ak as ys,al as Ns,aD as vs,bh as ws}from"./index-DhAjOd4r.js";import{a as Cs,u as B,b as R}from"./tanstack-CrmUhA7Z.js";import{D as Ee}from"./default-ports-1QQSffYX.js";import{S as Ss}from"./separator-fWUi3UIY.js";import{S as ks}from"./searchable-select-DkL__exx.js";import{R as Le,T as _s,K as z,Z as J,ai as As,ae as Ds,ax as xe,aQ as Ie,aP as Ms,L as F,J as Ts,au as Rs,aa as Fs,x as Ls,I as Is}from"./icons-DyorC3Xk.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const N="/legacy/cursor";function Os(s){if(!s||typeof s!="object")return!1;const t=s;return typeof t.message=="string"&&typeof t.stage=="string"&&typeof t.status=="number"&&typeof t.duration_ms=="number"&&typeof t.ok=="boolean"}function Es(s){if(!s||typeof s!="object"||!("error"in s))return null;const t=s;return typeof t.error=="string"?t.error:null}async function zs(){const s=await fetch(y(`${N}/status`));if(!s.ok)throw new Error("Failed to fetch cursor status");return s.json()}async function Ks(){const s=await fetch(y(`${N}/settings`));if(!s.ok)throw new Error("Failed to fetch cursor config");return s.json()}async function qs(){const s=await fetch(y(`${N}/models`));if(!s.ok)throw new Error("Failed to fetch cursor models");return s.json()}async function Gs(){const s=await fetch(y(`${N}/settings/raw`));if(!s.ok)throw new Error("Failed to fetch cursor raw settings");return s.json()}async function Qs(s){const t=await fetch(y(`${N}/settings`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error("Failed to update cursor config");return t.json()}async function Us(s){const t=await fetch(y(`${N}/settings/raw`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(t.status===409)throw new xs("Cursor raw settings changed externally");if(!t.ok)throw new Error("Failed to save cursor raw settings");return t.json()}async function Bs(){const s=await fetch(y(`${N}/auth/auto-detect`),{method:"POST"});if(!s.ok){const t=await s.json().catch(()=>({error:"Auto-detect failed"}));throw new Error(t.error||"Auto-detect failed")}return s.json()}async function Js(s){const t=await fetch(y(`${N}/auth/import`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok){const r=await t.json().catch(()=>({error:"Manual import failed"}));throw new Error(r.error||"Manual import failed")}return t.json()}async function $s(){const s=await fetch(y(`${N}/daemon/start`),{method:"POST"});if(!s.ok)throw new Error("Failed to start cursor daemon");return s.json()}async function Hs(){const s=await fetch(y(`${N}/daemon/stop`),{method:"POST"});if(!s.ok)throw new Error("Failed to stop cursor daemon");return s.json()}async function Vs(){const s=await fetch(y(`${N}/probe`),{method:"POST"}),t=await s.json().catch(()=>null);return Os(t)?t:{ok:!1,stage:"runtime",status:s.status,duration_ms:0,error_type:"runtime_error",message:Es(t)??"Failed to run live probe"}}function Ws(){const s=Cs(),t=B({queryKey:["cursor-status"],queryFn:zs,refetchInterval:5e3}),r=B({queryKey:["cursor-config"],queryFn:Ks}),u=B({queryKey:["cursor-models"],queryFn:qs}),x=B({queryKey:["cursor-raw-settings"],queryFn:Gs}),c=()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-config"]}),s.invalidateQueries({queryKey:["cursor-models"]}),s.invalidateQueries({queryKey:["cursor-raw-settings"]})},f=R({mutationFn:Qs,onSuccess:c}),g=R({mutationFn:Us,onSuccess:c}),p=R({mutationFn:Bs,onSuccess:c}),n=R({mutationFn:Js,onSuccess:c}),l=R({mutationFn:$s,onSuccess:c}),d=R({mutationFn:Hs,onSuccess:c}),m=R({mutationFn:Vs,onSettled:()=>{s.invalidateQueries({queryKey:["cursor-status"]}),s.invalidateQueries({queryKey:["cursor-models"]})}});return b.useMemo(()=>({status:t.data,statusLoading:t.isLoading,statusError:t.error,refetchStatus:t.refetch,config:r.data,configLoading:r.isLoading,refetchConfig:r.refetch,models:u.data?.models??[],currentModel:u.data?.current??null,modelsLoading:u.isLoading,rawSettings:x.data,rawSettingsLoading:x.isLoading,refetchRawSettings:x.refetch,updateConfig:f.mutate,updateConfigAsync:f.mutateAsync,isUpdatingConfig:f.isPending,saveRawSettings:g.mutate,saveRawSettingsAsync:g.mutateAsync,isSavingRawSettings:g.isPending,autoDetectAuth:p.mutate,autoDetectAuthAsync:p.mutateAsync,isAutoDetectingAuth:p.isPending,autoDetectAuthResult:p.data,importManualAuth:n.mutate,importManualAuthAsync:n.mutateAsync,isImportingManualAuth:n.isPending,manualAuthResult:n.data,startDaemon:l.mutate,startDaemonAsync:l.mutateAsync,isStartingDaemon:l.isPending,stopDaemon:d.mutate,stopDaemonAsync:d.mutateAsync,isStoppingDaemon:d.isPending,runProbe:m.mutate,runProbeAsync:m.mutateAsync,isRunningProbe:m.isPending,probeResult:m.data,resetProbe:m.reset}),[t.data,t.isLoading,t.error,t.refetch,r.data,r.isLoading,r.refetch,u.data,u.isLoading,x.data,x.isLoading,x.refetch,f.mutate,f.mutateAsync,f.isPending,g.mutate,g.mutateAsync,g.isPending,p.mutate,p.mutateAsync,p.isPending,p.data,n.mutate,n.mutateAsync,n.isPending,n.data,l.mutate,l.mutateAsync,l.isPending,d.mutate,d.mutateAsync,d.isPending,m.mutate,m.mutateAsync,m.isPending,m.data,m.reset])}function he(s,t){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:t?.auto_start??null,model:t?.model??null})}function $(s){return{port:String(s?.port??Ee),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 S(s,t,r){return s.find(x=>t.some(c=>c.test(x.id)))?.id??r}function fe(s){return s.toLowerCase().replace(/[^a-z0-9]/g,"")}function k(s,t,r){const u=new Set(t.map(fe)),x=s.find(f=>u.has(fe(f.id)));if(x)return x.id;const c=s.find(f=>u.has(fe(f.name)));return c?c.id:r}function Xs(s){try{const t=JSON.parse(s||"{}");return!t||typeof t!="object"||Array.isArray(t)?{isValid:!1,error:"Raw settings must be a JSON object"}:{isValid:!0,settings:t}}catch(t){return{isValid:!1,error:t.message||"Invalid JSON"}}}function H({label:s,description:t,value:r,models:u,disabled:x,allowDefaultFallback:c=!1,onChange:f}){const{t:g}=Oe(),p=r||(c?"__default":""),n=b.useMemo(()=>{const l=u.map(d=>({value:d.id,groupKey:"models",searchText:`${d.name||d.id} ${d.id}`,keywords:[d.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:d.name||d.id}),d.provider&&e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.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:d.name||d.id}),e.jsx(M,{variant:"outline",className:"text-[9px] h-4 px-1 capitalize",children:d.provider})]})}));return c?[{value:"__default",groupKey:"models",searchText:g("cursorPage.useDefaultModel"),triggerContent:e.jsx("span",{className:"truncate font-mono text-xs",children:g("cursorPage.useDefaultModel")}),itemContent:e.jsx("span",{children:g("cursorPage.useDefaultModel")})},...l]:l},[c,u,g]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-xs font-medium",children:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t})]}),e.jsx(ks,{value:p||void 0,onChange:l=>{if(c&&l==="__default"){f("");return}f(l)},disabled:x,placeholder:g("cursorPage.selectModel"),searchPlaceholder:g("searchableSelect.searchModels"),emptyText:g("searchableSelect.noResults"),triggerClassName:"h-9",groups:[{key:"models",label:g("cursorPage.availableModelCount",{count:u.length})}],options:n})]})}function pe({icon:s,label:t,ok:r,detail:u}){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:t})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r?e.jsx(Ls,{className:"h-4 w-4 text-green-500"}):e.jsx(Is,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:V("text-xs",r?"text-green-500":"text-muted-foreground"),title:u,children:u})]})]})}function da(){const{t:s}=Oe(),t=gs(),{status:r,statusLoading:u,refetchStatus:x,config:c,refetchConfig:f,updateConfigAsync:g,isUpdatingConfig:p,models:n,modelsLoading:l,currentModel:d,rawSettings:m,rawSettingsLoading:je,refetchRawSettings:ze,saveRawSettingsAsync:Ke,isSavingRawSettings:Pe,autoDetectAuthAsync:qe,isAutoDetectingAuth:be,importManualAuthAsync:Ge,isImportingManualAuth:ye,startDaemonAsync:Qe,isStartingDaemon:Ue,stopDaemonAsync:Be,isStoppingDaemon:Ne,runProbeAsync:Je,isRunningProbe:W,probeResult:X,resetProbe:$e}=Ws(),[T,Z]=b.useState(()=>$()),[v,Y]=b.useState(!1),[ve,He]=b.useState("{}"),[I,ee]=b.useState(!1),[Ve,K]=b.useState(!1),[se,we]=b.useState(""),[ae,Ce]=b.useState(""),[Se,ke]=b.useState(()=>X?he(r,c):null),_=$(c),_e=v?T.port:_.port,te=v?T.auto_start:_.auto_start,re=v?T.ghost_mode:_.ghost_mode,w=v?T.model:_.model,ne=v?T.opus_model:_.opus_model,oe=v?T.sonnet_model:_.sonnet_model,ie=v?T.haiku_model:_.haiku_model,ce=I?ve:JSON.stringify(m?.settings??{},null,2),Ae=!!m,O=b.useMemo(()=>Xs(ce),[ce]),De=O.isValid,q=v||I,We=!I||Ae&&De,Xe=he(r,c),P=X&&!q&&Se!==null&&Se===Xe?X:null,G=b.useMemo(()=>{const a=new Set,o=[...n].sort((D,de)=>D.name.localeCompare(de.name)),j=o.filter(D=>a.has(D.id)?!1:(a.add(D.id),!0));return w&&!o.some(D=>D.id===w)?[{id:w,name:w,provider:"custom"},...j]:j},[n,w]),C=a=>{Z(o=>a(v?o:_)),Y(!0)},A=()=>{$e(),ke(null)},Ze=(a=c)=>{Z($(a)),Y(!1)},Ye=!!(r?.enabled&&r?.authenticated&&!r?.token_expired),es=b.useMemo(()=>r?.enabled?e.jsx(M,{children:s("cursorPage.enabled")}):e.jsx(M,{variant:"secondary",children:s("cursorPage.disabled")}),[r?.enabled,s]),ss=async({suppressSuccessToast:a=!1}={})=>{const o=Number(_e);if(!Number.isInteger(o)||o<1||o>65535)return i.error(s("cursorPage.invalidPort")),!1;if(!w.trim())return i.error(s("cursorPage.defaultModelRequired")),!1;try{return await g({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0}),Y(!1),Z($({port:o,auto_start:te,ghost_mode:re,model:w,opus_model:ne||void 0,sonnet_model:oe||void 0,haiku_model:ie||void 0})),A(),a||i.success(s("cursorPage.savedConfig")),!0}catch(j){return i.error(j.message||s("cursorPage.failedSaveConfig")),!1}},le=a=>{if(l){i.error(s("cursorPage.modelsLoadingWait"));return}if(n.length===0){i.error(s("cursorPage.noModelsAvailable"));return}const o=w||d||n[0]?.id||"gpt-5.3-codex",j=k(n,["gpt-5.3-codex","gpt53codex","GPT-5.3 Codex"],S(n,[/gpt[-.]?5.*codex/i],o)),D=k(n,["gpt-5.1-codex-max","gpt51codexmax","GPT-5.1 Codex Max"],S(n,[/gpt[-.]?5.*codex.*max/i],j)),de=k(n,["gpt-5-fast","gpt5fast","GPT-5 Fast"],S(n,[/gpt[-.]?5.*fast/i],j)),ds=k(n,["gpt-5-mini","gpt5mini","GPT-5 Mini"],S(n,[/gpt[-.]?5.*mini/i],de)),Te=k(n,["claude-4.6-opus","claude46opus","Claude 4.6 Opus"],S(n,[/claude[-.]?4\.?6.*opus/i,/claude.*opus/i],j)),Re=k(n,["claude-4.5-sonnet","claude45sonnet","Claude 4.5 Sonnet"],S(n,[/claude[-.]?4\.?5.*sonnet/i,/claude.*sonnet/i],j)),us=k(n,["claude-4.5-haiku","claude45haiku","Claude 4.5 Haiku"],S(n,[/claude[-.]?4\.?5.*haiku/i,/haiku/i],Re)),Q=k(n,["gemini-3-pro","gemini3pro","Gemini 3 Pro"],S(n,[/gemini[-.]?3.*pro/i],j)),ms=k(n,["gemini-3-flash","gemini3flash","Gemini 3 Flash"],S(n,[/gemini[-.]?3.*flash/i,/gemini[-.]?2\.?5.*flash/i],Q));if(a==="codex53"){C(E=>({...E,model:j,opus_model:D,sonnet_model:j,haiku_model:ds})),i.success(s("cursorPage.appliedCodexPreset"));return}if(a==="claude46"){C(E=>({...E,model:Te,opus_model:Te,sonnet_model:Re,haiku_model:us})),i.success(s("cursorPage.appliedClaudePreset"));return}C(E=>({...E,model:Q,opus_model:Q,sonnet_model:Q,haiku_model:ms})),i.success(s("cursorPage.appliedGeminiPreset"))},Me=async a=>{try{await g({enabled:a}),A(),i.success(s(a?"cursorPage.integrationEnabled":"cursorPage.integrationDisabled"))}catch(o){i.error(o.message||s("cursorPage.failedUpdateIntegration"))}},as=async()=>{try{await qe(),A(),i.success(s("cursorPage.credentialsImported"))}catch(a){i.error(a.message||s("cursorPage.autoDetectFailed"))}},ts=async()=>{if(!se.trim()||!ae.trim()){i.error(s("cursorPage.manualRequired"));return}try{await Ge({accessToken:se.trim(),machineId:ae.trim()}),A(),i.success(s("cursorPage.credentialsImported")),K(!1),we(""),Ce("")}catch(a){i.error(a.message||s("cursorPage.manualImportFailed"))}},rs=async()=>{try{const a=await Qe();if(!a.success){i.error(a.error||s("cursorPage.failedStartDaemon"));return}A(),i.success(a.pid?s("cursorPage.daemonStartedWithPid",{pid:a.pid}):s("cursorPage.daemonStarted"))}catch(a){i.error(a.message||s("cursorPage.failedStartDaemon"))}},ns=async()=>{try{const a=await Be();if(!a.success){i.error(a.error||s("cursorPage.failedStopDaemon"));return}A(),i.success(s("cursorPage.daemonStopped"))}catch(a){i.error(a.message||s("cursorPage.failedStopDaemon"))}},os=async()=>{if(q){i.error(s("cursorPage.probeSaveFirst"));return}try{const a=await Je(),o=await x();if(ke(he(o.data??r,c)),a.ok){i.success(s("cursorPage.probeSucceeded"));return}i.error(a.message||s("cursorPage.probeFailed"))}catch(a){i.error(a.message||s("cursorPage.probeFailed"))}},is=async({suppressSuccessToast:a=!1}={})=>{if(!Ae)return i.error(s("cursorPage.rawLoading")),!1;if(!O.isValid||!O.settings)return i.error(O.error||s("cursorPage.invalidJson")),!1;try{return await Ke({settings:O.settings,expectedMtime:m?.mtime}),ee(!1),A(),a||i.success(s("cursorPage.rawSaved")),!0}catch(o){return ws(o)?i.error(s("cursorPage.rawChanged")):i.error(o.message||s("cursorPage.failedSaveRaw")),!1}},cs=async()=>{if(!q)return;const a=v,o=I;a&&!await ss({suppressSuccessToast:o})||o&&!await is({suppressSuccessToast:a})||a&&o&&i.success(s("cursorPage.savedAll"))},ls=async()=>{ee(!1),A();const[,a]=await Promise.all([x(),f(),ze()]);Ze(a.data??c)};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(M,{variant:"outline",className:"h-5 border-red-500/50 bg-red-500/10 px-1.5 text-[10px] font-semibold uppercase tracking-wide text-red-700 dark:text-red-300",children:s("cursorPage.deprecated")}),es]}),e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>x(),disabled:u,"aria-label":s("cursorPage.refreshStatus"),title:s("cursorPage.refreshStatus"),children:e.jsx(Le,{className:V("w-4 h-4",u&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.subtitle")})]}),e.jsx(U,{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(_s,{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:"rounded-md border border-border/70 bg-background/90 p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s("cursorPage.supportedPathTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("cursorPage.supportedPathDesc")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor&action=auth"),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.startCliproxyAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/cliproxy?provider=cursor"),children:[e.jsx(J,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.openCliproxyCursor")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{icon:As,label:s("cursorPage.integration"),ok:!!r?.enabled,detail:r?.enabled?s("cursorPage.enabled"):s("cursorPage.disabled")}),e.jsx(pe,{icon:z,label:s("cursorPage.authentication"),ok:!!(r?.authenticated&&!r?.token_expired),detail:r?.authenticated?r?.token_expired?s("cursorPage.expired"):r.auth_method??s("cursorPage.connected"):s("cursorPage.notConnected")}),e.jsx(pe,{icon:Ds,label:s("cursorPage.daemon"),ok:!!r?.daemon_running,detail:r?.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(xe,{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(M,{variant:P?"outline":"secondary",className:V(P?.ok&&"border-green-500/40 text-green-600 dark:text-green-300",P&&!P.ok&&"border-red-500/40 text-red-600 dark:text-red-300"),children:P?P.ok?s("cursorPage.probeSucceeded"):s("cursorPage.probeFailed"):s("cursorPage.probeNotRun")})]}),P?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:P.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:P.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:[P.duration_ms," ms"]})]}),P.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:P.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:P.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")}),r?.enabled?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>Me(!1),disabled:p,children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.disableIntegration")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:()=>Me(!0),disabled:p,children:[e.jsx(Ms,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.enableIntegration")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:as,disabled:be,children:[be?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.autoDetectAuth")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:()=>K(!0),children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.manualAuthImport")]}),e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:os,disabled:W,children:[W?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(xe,{className:"w-3.5 h-3.5 mr-1.5"}),s(W?"cursorPage.probing":P?"cursorPage.rerunLiveProbe":"cursorPage.runLiveProbe")]}),r?.daemon_running?e.jsxs(h,{variant:"outline",size:"sm",className:"w-full",onClick:ns,disabled:Ne,children:[Ne?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),s("cursorPage.stopDaemon")]}):e.jsxs(h,{size:"sm",className:"w-full",onClick:rs,disabled:!Ye,children:[Ue?e.jsx(F,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):e.jsx(Ts,{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:r?.port??c?.port??Ee})]})})]}),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")}),m&&e.jsx(M,{variant:"outline",className:"text-xs",children:"cursor.settings.json"})]}),m&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[s("cursorPage.lastModified")," ",m.exists?new Date(m.mtime).toLocaleString():s("cursorPage.neverSaved")]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:ls,disabled:u||je,"aria-label":s("cursorPage.refreshConfiguration"),title:s("cursorPage.refreshConfiguration"),children:e.jsx(Le,{className:V("w-4 h-4",(u||je)&&"animate-spin")})}),e.jsx(h,{size:"sm",onClick:cs,disabled:p||Pe||!q||!We,children:p||Pe?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-1 animate-spin"}),s("cursorPage.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(Rs,{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(hs,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(fs,{className:"w-full",children:[e.jsx(ue,{value:"config",className:"flex-1",children:s("cursorPage.modelConfig")}),e.jsx(ue,{value:"settings",className:"flex-1",children:s("cursorPage.settings")}),e.jsx(ue,{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(me,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(Fs,{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(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("codex53"),disabled:l||n.length===0,title:"OpenAI-only mapping: GPT-5.3 Codex / Codex Max / GPT-5 Mini",children:[e.jsx(J,{className:"w-3 h-3"}),"GPT-5.3 Codex"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("claude46"),disabled:l||n.length===0,title:"Claude-first mapping: Opus 4.6 / Sonnet 4.5 / Haiku 4.5",children:[e.jsx(J,{className:"w-3 h-3"}),"Claude 4.6"]}),e.jsxs(h,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>le("gemini3"),disabled:l||n.length===0,title:"Gemini-first mapping: Gemini 3 Pro + Gemini 3 Flash",children:[e.jsx(J,{className:"w-3 h-3"}),"Gemini 3 Pro"]})]})]}),e.jsx(Ss,{}),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(H,{label:s("cursorPage.defaultModel"),description:s("cursorPage.defaultModelDesc"),value:w,models:G,disabled:l,onChange:a=>{C(o=>({...o,model:a}))}}),e.jsx(H,{label:s("cursorPage.opusModel"),description:s("cursorPage.opusModelDesc"),value:ne,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,opus_model:a}))}}),e.jsx(H,{label:s("cursorPage.sonnetModel"),description:s("cursorPage.sonnetModelDesc"),value:oe,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,sonnet_model:a}))}}),e.jsx(H,{label:s("cursorPage.haikuModel"),description:s("cursorPage.haikuModelDesc"),value:ie,models:G,disabled:l,allowDefaultFallback:!0,onChange:a=>{C(o=>({...o,haiku_model:a}))}})]})]})]})})}),e.jsx(me,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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(L,{htmlFor:"cursor-port",className:"text-xs",children:s("cursorPage.port")}),e.jsx(ge,{id:"cursor-port",type:"number",min:1,max:65535,className:"max-w-[150px] h-8",value:_e,onChange:a=>{C(o=>({...o,port:a.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(L,{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(Fe,{id:"cursor-auto-start",checked:te,onCheckedChange:a=>{C(o=>({...o,auto_start:a}))}})]}),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:"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(Fe,{id:"cursor-ghost-mode",checked:re,onCheckedChange:a=>{C(o=>({...o,ghost_mode:a}))}})]})]})})})}),e.jsx(me,{value:"info",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(U,{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 (Legacy)"})]}),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:m?.path??"~/.ccs/cursor.settings.json"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Legacy bridge 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")}),l?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),s("cursorPage.loadingModels")]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s("cursorPage.noModels")}):e.jsx("div",{className:"space-y-2",children:n.map(a=>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:a.id}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.name," • ",a.provider]})]}),a.id===d&&e.jsx(M,{children:s("cursorPage.default")})]},a.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(xe,{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(ps,{rawJsonContent:ce,isRawJsonValid:De,rawJsonEdits:I?ve:null,rawSettingsEnv:m?.settings?.env,onChange:a=>{ee(!0),He(a)}})]})]})]})})]}),e.jsx(js,{open:Ve,onOpenChange:K,children:e.jsxs(Ps,{children:[e.jsxs(bs,{children:[e.jsx(ys,{children:s("cursorPage.manualImportTitle")}),e.jsx(Ns,{children:s("cursorPage.manualImportDesc")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-token",children:s("cursorPage.accessToken")}),e.jsx(ge,{id:"cursor-manual-token",value:se,onChange:a=>we(a.target.value),placeholder:s("cursorPage.accessTokenPlaceholder")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(L,{htmlFor:"cursor-manual-machine-id",children:s("cursorPage.machineId")}),e.jsx(ge,{id:"cursor-manual-machine-id",value:ae,onChange:a=>Ce(a.target.value),placeholder:s("cursorPage.machineIdPlaceholder")})]})]}),e.jsxs(vs,{children:[e.jsx(h,{variant:"outline",onClick:()=>K(!1),children:s("cursorPage.cancel")}),e.jsxs(h,{onClick:ts,disabled:ye,children:[ye?e.jsx(F,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(z,{className:"w-4 h-4 mr-2"}),s("cursorPage.import")]})]})]})})]})}export{da as CursorPage};
@@ -1,2 +1,2 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-2X8-14xr.js";import{a as Te,u as ie,b as Ae}from"./tanstack-CrmUhA7Z.js";import{a as Re}from"./raw-json-settings-editor-panel-DNmb_vR-.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-DyorC3Xk.js";import{S as R}from"./separator-CaGbNw8E.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(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 vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!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:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as Q}from"./react-vendor-CNOkPC89.js";import{t as j}from"./notifications-B2HqRBj7.js";import{bf as X,bg as Ne,a as Z,C as y,j as v,k as b,B as C,b as N,r as q,s as H,t as W,v as Y,w as k,I as le,bm as we,bn as ae,bo as ke,Q as Se,R as Pe,U,V,n as A,bh as Ce,c as Ee}from"./index-DhAjOd4r.js";import{a as Te,u as ie,b as Ae}from"./tanstack-CrmUhA7Z.js";import{a as Re}from"./raw-json-settings-editor-panel-upVhpuik.js";import{ay as _e,aC as De,N as Oe,L as Me,S as Be,aY as Fe,x as Le,I as Ie,T as Ke,ae as Ue,ai as Ve,p as oe}from"./icons-DyorC3Xk.js";import{S as R}from"./separator-fWUi3UIY.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function $e(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{settings:null,parseError:"JSON root must be an object."}:{settings:r,parseError:null}}catch(r){return{settings:null,parseError:r.message}}}async function ze(){const s=await fetch(X("/droid/diagnostics"));if(!s.ok)throw new Error("Failed to fetch Droid diagnostics");return s.json()}async function Je(){const s=await fetch(X("/droid/settings/raw"));if(!s.ok)throw new Error("Failed to fetch Droid raw settings");return s.json()}async function Qe(s){const r=await fetch(X("/droid/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(r.status===409)throw new Ne("Droid raw settings changed externally");if(!r.ok){const n=await r.json().catch(()=>null);throw new Error(n?.error||"Failed to save Droid raw settings")}return r.json()}function qe(){const s=Te(),r=ie({queryKey:["droid-diagnostics"],queryFn:ze,refetchInterval:1e4}),n=ie({queryKey:["droid-raw-settings"],queryFn:Je}),i=Ae({mutationFn:Qe,onSuccess:(l,d)=>{s.setQueryData(["droid-raw-settings"],o=>{const t=o?.path??"~/.factory/settings.json",c=o?.resolvedPath??t,m=$e(d.rawText);return{path:t,resolvedPath:c,exists:!0,mtime:l.mtime,rawText:d.rawText,settings:m.settings,parseError:m.parseError}}),s.invalidateQueries({queryKey:["droid-diagnostics"]})}});return Q.useMemo(()=>({diagnostics:r.data,diagnosticsLoading:r.isLoading,diagnosticsError:r.error,refetchDiagnostics:r.refetch,rawSettings:n.data,rawSettingsLoading:n.isLoading,rawSettingsError:n.error,refetchRawSettings:n.refetch,saveRawSettings:i.mutate,saveRawSettingsAsync:i.mutateAsync,isSavingRawSettings:i.isPending}),[r.data,r.isLoading,r.error,r.refetch,n.data,n.isLoading,n.error,n.refetch,i.mutate,i.mutateAsync,i.isPending])}const He=["customModels","custom_models"],We={low:4e3,medium:12e3,high:3e4,max:5e4,xhigh:64e3},Ye=["low","medium","high","max","xhigh"];function p(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function h(s){return typeof s=="string"&&s.trim()?s.trim():null}function D(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function G(s){if(!s)return"unknown";const r=s.toLowerCase();return r==="anthropic"?"anthropic":r==="openai"?"openai":r==="generic-chat-completion-api"?"generic-chat-completion-api":"unknown"}function Ge(s,r,n){return`${s}:${r}:${encodeURIComponent(String(n))}`}function Xe(s){const r=s.indexOf(":"),n=s.indexOf(":",r+1);if(r<=0||n<=r+1)return null;const i=s.slice(0,r),l=s.slice(r+1,n),d=s.slice(n+1);if(i!=="customModels"&&i!=="custom_models"||l!=="array"&&l!=="object")return null;const o=decodeURIComponent(d);if(l==="array"){const t=Number.parseInt(o,10);return!Number.isInteger(t)||t<0?null:{rootKey:i,locationType:l,locationKey:t}}return{rootKey:i,locationType:l,locationKey:o}}function Ze(s){return!s||s<=0?null:s<=4e3?"low":s<=12e3?"medium":s<=3e4?"high":s<=5e4?"max":"xhigh"}function es(s){return Object.prototype.hasOwnProperty.call(s,"extraArgs")?"extraArgs":Object.prototype.hasOwnProperty.call(s,"extra_args")?"extra_args":"extraArgs"}function de(s){return JSON.parse(JSON.stringify(s))}function ss(s){const r=[];for(const n of He){const i=s[n];if(Array.isArray(i)){i.forEach((l,d)=>{p(l)&&r.push({rootKey:n,locationType:"array",locationKey:d,entry:l})});continue}if(p(i))for(const[l,d]of Object.entries(i))p(d)&&r.push({rootKey:n,locationType:"object",locationKey:l,entry:d})}return r}function ce(s,r){const n=Xe(r);if(!n)return null;const i=s[n.rootKey];if(n.locationType==="array"){if(!Array.isArray(i))return null;const o=i[n.locationKey];if(!p(o))return null;const t=h(o.provider);return{entry:o,providerKind:G(t)}}if(!p(i))return null;const l=i[n.locationKey];if(!p(l))return null;const d=h(l.provider);return{entry:l,providerKind:G(d)}}function rs(s,r){const n=r.extraArgs??r.extra_args,i=p(n)?n:null;if(!i)return{effort:null,anthropicBudgetTokens:null};const l=h(i.reasoning_effort)??h(i.reasoningEffort),d=p(i.reasoning)?i.reasoning:null,o=d?h(d.effort):null,t=p(i.thinking)?i.thinking:null,c=t?h(t.type):null,m=t?D(t.budget_tokens)??D(t.budgetTokens):null;return s==="openai"?{effort:o??l,anthropicBudgetTokens:null}:s==="anthropic"?c==="enabled"?{effort:Ze(m)??"high",anthropicBudgetTokens:m}:{effort:o??l,anthropicBudgetTokens:m}:{effort:l??o,anthropicBudgetTokens:null}}function ts(s){if(!s)return null;const r=s.trim().toLowerCase();return!r||r==="default"||r==="unset"||r==="off"||r==="none"||r==="disabled"?null:r}function ue(s){const r=es(s),n=s[r],i=p(n)?{...n}:{};return{extraArgsKey:r,extraArgs:i}}function me(s,r,n){if(Object.keys(n).length===0){delete s[r];return}s[r]=n}function ns(s){return ss(s).map(({rootKey:r,locationType:n,locationKey:i,entry:l})=>{const d=h(l.displayName)??h(l.model_display_name)??"Unnamed model",o=h(l.model)??"",t=h(l.provider)??"unknown",c=G(t),m=rs(c,l);return{id:Ge(r,n,i),rootKey:r,locationType:n,locationKey:i,displayName:d,model:o,provider:t,providerKind:c,effort:m.effort,anthropicBudgetTokens:m.anthropicBudgetTokens}})}function as(s,r,n){const i=de(s),l=ce(i,r);if(!l)return null;const d=ts(n),{extraArgsKey:o,extraArgs:t}=ue(l.entry);if(l.providerKind==="openai")if(delete t.reasoning_effort,delete t.reasoningEffort,!d)delete t.reasoning;else{const c=p(t.reasoning)?t.reasoning:{};t.reasoning={...c,effort:d}}else if(l.providerKind==="anthropic")if(delete t.reasoning_effort,delete t.reasoningEffort,delete t.reasoning,!d)delete t.thinking;else{const c=p(t.thinking)?{...t.thinking}:{},m=D(c.budget_tokens)??D(c.budgetTokens);delete c.budgetTokens,t.thinking={...c,type:"enabled",budget_tokens:m??We[d]??3e4}}else delete t.reasoning,delete t.reasoningEffort,d?t.reasoning_effort=d:delete t.reasoning_effort;return me(l.entry,o,t),i}function is(s,r,n){const i=de(s),l=ce(i,r);if(!l||l.providerKind!=="anthropic")return null;const{extraArgsKey:d,extraArgs:o}=ue(l.entry),t=p(o.thinking)?{...o.thinking}:{};if(t.type="enabled",n===null)delete t.budget_tokens,delete t.budgetTokens;else{const c=Math.max(1024,Math.floor(n));t.budget_tokens=c,delete t.budgetTokens}return o.thinking=t,me(l.entry,d,o),i}const $="__unset__";function os(s){return s.providerKind==="openai"?"Writes: extraArgs.reasoning.effort":s.providerKind==="anthropic"?"Writes: extraArgs.thinking.{type,budget_tokens}":"Writes: extraArgs.reasoning_effort"}function ls({models:s,disabled:r,disabledReason:n,onEffortChange:i,onAnthropicBudgetChange:l}){const{t:d}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),d("droidSettings.reasoningControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"customModels"})]})}),e.jsxs(N,{className:"space-y-3",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No BYOK custom models found in settings.json (`customModels` or `custom_models`)."}):e.jsx("div",{className:"space-y-2",children:s.map(o=>e.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:o.displayName}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground truncate",children:o.model||"(missing model id)"})]}),e.jsx(C,{variant:"outline",className:"font-mono text-[10px] shrink-0",children:o.provider})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.reasoningEffortCapitalized")}),e.jsxs(q,{value:o.effort??$,onValueChange:t=>i(o.id,t===$?null:t),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:"Use provider default"})}),e.jsxs(Y,{children:[e.jsx(k,{value:$,children:"Use provider default"}),Ye.map(t=>e.jsx(k,{value:t,children:t},t))]})]})]}),o.providerKind==="anthropic"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-medium",children:d("codex.thinkingBudgetTokens")}),e.jsx(le,{type:"number",min:1024,step:1024,value:o.anthropicBudgetTokens??"",placeholder:"auto",className:"h-8 text-xs",disabled:r,onChange:t=>{const c=t.target.value.trim();if(!c){l(o.id,null);return}const m=Number.parseInt(c,10);Number.isFinite(m)&&l(o.id,Math.max(1024,m))}})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:os(o)})]},o.id))})]})]})}const T="__unset__",ds=[{key:"reasoningEffort",label:"Reasoning Effort",description:"none | medium | high | max",options:[{value:"none",label:"none"},{value:"medium",label:"medium"},{value:"high",label:"high"},{value:"max",label:"max"}]},{key:"autonomyLevel",label:"Autonomy Level",description:"suggest | aggressive | full",options:[{value:"suggest",label:"suggest"},{value:"aggressive",label:"aggressive"},{value:"full",label:"full"}]},{key:"diffMode",label:"Diff Mode",description:"auto | none | inline | split",options:[{value:"auto",label:"auto"},{value:"none",label:"none"},{value:"inline",label:"inline"},{value:"split",label:"split"}]}],cs=[{key:"todoEnabled",label:"Todo Enabled"},{key:"todoAutoRefresh",label:"Todo Auto Refresh"},{key:"autoCompactEnabled",label:"Auto Compact Enabled"},{key:"soundEnabled",label:"Sound Enabled"}],us=[{key:"maxTurns",label:"Max Turns",min:1,step:1},{key:"maxToolCalls",label:"Max Tool Calls",min:1,step:1},{key:"autoCompactThreshold",label:"Auto Compact Threshold",min:1e3,step:1e3}];function ms(s){return s===!0?"true":s===!1?"false":T}function xs(s){return s==="true"?!0:s==="false"?!1:null}function gs({values:s,disabled:r,disabledReason:n,onEnumSettingChange:i,onBooleanSettingChange:l,onNumberSettingChange:d}){const{t:o}=Z();return e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),o("droidSettings.quickControls"),e.jsx(C,{variant:"outline",className:"text-[10px] font-normal",children:"settings.json"})]})}),e.jsxs(N,{className:"space-y-4",children:[n&&e.jsx("p",{className:"text-xs text-amber-600",children:n}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[ds.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:s[t.key]??T,onValueChange:c=>i(t.key,c===T?null:c),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),t.options.map(c=>e.jsx(k,{value:c.value,children:c.label},c.value))]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.description})]},t.key)),us.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsx(le,{type:"number",min:t.min,step:t.step,value:s[t.key]??"",onChange:c=>{const m=c.target.value.trim();if(!m){d(t.key,null);return}const S=Number.parseInt(m,10);Number.isFinite(S)&&d(t.key,Math.max(t.min,S))},className:"h-8 text-xs",disabled:r})]},t.key)),cs.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:t.label}),e.jsxs(q,{value:ms(s[t.key]),onValueChange:c=>l(t.key,xs(c)),disabled:r,children:[e.jsx(H,{className:"h-8 text-xs",children:e.jsx(W,{placeholder:o("codex.useDefault")})}),e.jsxs(Y,{children:[e.jsx(k,{value:T,children:o("codex.useDefault")}),e.jsx(k,{value:"true",children:"true"}),e.jsx(k,{value:"false",children:"false"})]})]})]},t.key))]})]})]})}const fs=[{id:"droid-cli-overview",label:"Droid CLI Overview",url:"https://docs.factory.ai/cli/",description:"Primary entry docs for setup, auth, and core CLI usage."},{id:"droid-byok-overview",label:"BYOK Overview",url:"https://docs.factory.ai/cli/byok/overview/",description:"BYOK model/provider shape, provider values, and migration notes."},{id:"droid-settings-reference",label:"settings.json Reference",url:"https://docs.factory.ai/cli/configuration/settings/",description:"Supported settings keys, defaults, and allowed values."}],ps=[{provider:"anthropic",label:"Anthropic Messages API",apiFormat:"Messages API",url:"https://docs.anthropic.com/en/api/messages"},{provider:"openai",label:"OpenAI Responses API",apiFormat:"Responses API",url:"https://platform.openai.com/docs/api-reference/responses"},{provider:"generic-chat-completion-api",label:"OpenAI Chat Completions Spec",apiFormat:"Chat Completions API",url:"https://platform.openai.com/docs/api-reference/chat"}];function hs(s){const r=/https?:\/\/[^\s)]+/g,n=[];let i=0,l;for(;(l=r.exec(s))!==null;){const[d]=l,o=l.index;o>i&&n.push(s.slice(i,o)),n.push(e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:d},`${d}-${o}`)),i=o+d.length}return i<s.length&&n.push(s.slice(i)),n.length>0?n:[s]}function js(s){return!s||!Number.isFinite(s)?"N/A":new Date(s).toLocaleString()}function ys(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 vs(s){try{const r=JSON.parse(s);return!r||typeof r!="object"||Array.isArray(r)?{valid:!1,error:"JSON root must be an object."}:{valid:!0,value:r}}catch(r){return{valid:!1,error:r.message}}}function z(s){return typeof s=="string"?s:null}function J(s){return typeof s=="number"&&Number.isFinite(s)?s:null}function _(s){return typeof s=="boolean"?s:null}function g({label:s,value:r,mono:n=!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:Ee("text-right break-all",n&&"font-mono text-xs"),children:r})]})}function _s(){const{t:s}=Z(),{diagnostics:r,diagnosticsLoading:n,diagnosticsError:i,refetchDiagnostics:l,rawSettings:d,rawSettingsLoading:o,refetchRawSettings:t,saveRawSettingsAsync:c,isSavingRawSettings:m}=qe(),[S,O]=Q.useState(null),M=d?.rawText??"{}",B=S??M,ee=S!==null&&S!==M,u=vs(B),F=u.valid?{valid:!0}:{valid:!1,error:u.error},se=x=>{if(x===M){O(null);return}O(x)},L=x=>{se(JSON.stringify(x,null,2)+`
2
2
  `)},I=(x,w)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeQuickSettings"));return}const P={...u.value};w==null?delete P[x]:P[x]=w,L(P)},xe=u.valid?{reasoningEffort:z(u.value.reasoningEffort),autonomyLevel:z(u.value.autonomyLevel),diffMode:z(u.value.diffMode),maxTurns:J(u.value.maxTurns),maxToolCalls:J(u.value.maxToolCalls),autoCompactThreshold:J(u.value.autoCompactThreshold),todoEnabled:_(u.value.todoEnabled),todoAutoRefresh:_(u.value.todoAutoRefresh),autoCompactEnabled:_(u.value.autoCompactEnabled),soundEnabled:_(u.value.soundEnabled)}:{reasoningEffort:null,autonomyLevel:null,diffMode:null,maxTurns:null,maxToolCalls:null,autoCompactThreshold:null,todoEnabled:null,todoAutoRefresh:null,autoCompactEnabled:null,soundEnabled:null},ge=u.valid?ns(u.value):[],fe=async()=>{await Promise.all([l(),t()])},pe=async()=>{if(!F.valid){j.error(s("droidPage.invalidJson",{value:F.error}));return}try{await c({rawText:B,expectedMtime:d?.exists?d.mtime:void 0}),O(null),j.success(s("droidPage.saved"))}catch(x){Ce(x)?j.error(s("droidPage.changedExternally")):j.error(x.message||s("droidPage.failedSave"))}},re=r?.byok.customModels??[],te=Q.useMemo(()=>Object.entries(r?.byok.providerBreakdown??{}).sort((x,w)=>w[1]-x[1]),[r?.byok.providerBreakdown]),he=()=>{if(n)return e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(Me,{className:"h-5 w-5 animate-spin mr-2"}),s("droidPage.loadingDiagnostics")]});if(i||!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-destructive px-6 text-center",children:s("droidPage.failedDiagnostics")});const x=r.docsReference??{notes:[],links:[],providerDocs:[],providerValues:[],settingsHierarchy:[]},w=x.notes??[],P=x.links??[],ne=x.providerDocs??[],je=P.length>0?P:fs,ye=ne.length>0?ne:ps,ve=x.providerValues??[],be=x.settingsHierarchy??[],K="mt-0 h-full border-0 p-0 data-[state=inactive]:hidden";return e.jsxs(Se,{defaultValue:"byok",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Pe,{className:"grid w-full grid-cols-3",children:[e.jsx(U,{value:"overview",children:s("droidPage.overview")}),e.jsx(U,{value:"byok",children:s("droidPage.byok")}),e.jsx(U,{value:"docs",children:s("droidPage.docs")})]})}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden px-4 pb-4 pt-3",children:[e.jsx(V,{value:"overview",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),s("droidPage.runtimeInstall")]})}),e.jsxs(N,{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:s("droidPage.status")}),e.jsx(C,{variant:r.binary.installed?"default":"secondary",children:r.binary.installed?s("droidPage.detected"):s("droidPage.notFound")})]}),e.jsx(g,{label:s("droidPage.detectionSource"),value:r.binary.source,mono:!0}),e.jsx(g,{label:s("droidPage.binaryPath"),value:r.binary.path||s("droidPage.notFound"),mono:!0}),e.jsx(g,{label:s("droidPage.installDirectory"),value:r.binary.installDir||"N/A",mono:!0}),e.jsx(g,{label:s("droidPage.version"),value:r.binary.version||"Unknown",mono:!0}),e.jsx(g,{label:s("droidPage.overridePath"),value:r.binary.overridePath||"Not set",mono:!0})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4"}),s("droidPage.configFiles")]})}),e.jsx(N,{className:"space-y-3",children:[r.files.settings,r.files.legacyConfig].map(a=>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:a.label}),a.exists?e.jsx(Le,{className:"h-4 w-4 text-green-600"}):e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(g,{label:s("droidPage.path"),value:a.path,mono:!0}),e.jsx(g,{label:s("droidPage.resolved"),value:a.resolvedPath,mono:!0}),e.jsx(g,{label:s("droidPage.size"),value:ys(a.sizeBytes)}),e.jsx(g,{label:s("droidPage.lastModified"),value:js(a.mtimeMs)}),a.parseError&&e.jsx("p",{className:"text-xs text-amber-600",children:s("droidPage.parseWarning",{value:a.parseError})}),a.readError&&e.jsx("p",{className:"text-xs text-destructive",children:s("droidPage.readWarning",{value:a.readError})})]},a.label))})]}),r.warnings.length>0&&e.jsxs(y,{className:"border-amber-200 bg-amber-50/50 dark:bg-amber-950/20",children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-amber-600"}),s("droidPage.warnings")]})}),e.jsx(N,{className:"space-y-1.5",children:r.warnings.map(a=>e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:["- ",a]},a))})]})]})})}),e.jsx(V,{value:"byok",className:K,children:e.jsx(A,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pr-1",children:[e.jsx(gs,{values:xe,disabled:o||!u.valid,disabledReason:u.valid?null:`Quick settings disabled: ${u.error}`,onEnumSettingChange:(a,f)=>{I(a,f)},onBooleanSettingChange:(a,f)=>{I(a,f)},onNumberSettingChange:(a,f)=>{I(a,f)}}),e.jsx(ls,{models:ge,disabled:o||!u.valid,disabledReason:u.valid?null:`${s("droidPage.byok")}: ${u.error}`,onEffortChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeReasoning"));return}const E=as(u.value,a,f);if(!E){j.error(s("droidPage.unableUpdateReasoning"));return}L(E)},onAnthropicBudgetChange:(a,f)=>{if(!u.valid){j.error(s("droidPage.fixJsonBeforeBudget"));return}const E=is(u.value,a,f);if(!E){j.error(s("droidPage.anthropicOnlyBudget"));return}L(E)}}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),s("droidPage.byokSummary")]})}),e.jsxs(N,{className:"space-y-2",children:[e.jsx(g,{label:s("droidPage.activeModelSelector"),value:r.byok.activeModelSelector||"Not set",mono:!0}),e.jsx(g,{label:s("droidPage.customModels"),value:String(r.byok.customModelCount)}),e.jsx(g,{label:s("droidPage.ccsManaged"),value:String(r.byok.ccsManagedCount)}),e.jsx(g,{label:s("droidPage.userManaged"),value:String(r.byok.userManagedCount)}),e.jsx(g,{label:s("droidPage.malformedEntries"),value:String(r.byok.invalidModelEntryCount)}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providers")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[te.length===0&&e.jsx(C,{variant:"secondary",className:"font-mono",children:s("droidPage.none")}),te.map(([a,f])=>e.jsxs(C,{variant:"outline",className:"font-mono text-xs",children:[a,": ",f]},a))]})]})]})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsx(b,{className:"text-base",children:s("droidPage.customModelsTitle")})}),e.jsx(N,{children:e.jsxs("div",{className:"rounded-md border overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] bg-muted/40 px-3 py-2 text-xs font-medium",children:[e.jsx("span",{children:s("droidPage.modelName")}),e.jsx("span",{children:s("droidPage.provider")}),e.jsx("span",{children:s("droidPage.baseUrl")})]}),e.jsx(A,{className:"h-52",children:e.jsxs("div",{className:"divide-y",children:[re.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:s("droidPage.noCustomModels")}),re.map(a=>e.jsxs("div",{className:"grid grid-cols-[2fr_1fr_2fr] gap-2 px-3 py-2 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:a.displayName}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.model})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",children:a.provider}),e.jsx("p",{className:"text-muted-foreground",children:a.apiKeyPreview||"no-key"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate",title:a.baseUrl,children:a.host||a.baseUrl}),e.jsx("p",{className:"text-muted-foreground font-mono truncate",children:a.baseUrl})]})]},`${a.displayName}-${a.model}-${a.baseUrl}`))]})})]})})]})]})})}),e.jsx(V,{value:"docs",className:K,children:e.jsx(A,{className:"h-full",children:e.jsx("div",{className:"space-y-4 pr-1",children:e.jsxs(y,{children:[e.jsx(v,{className:"pb-2",children:e.jsxs(b,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),s("droidPage.docsAlignedNotes")]})}),e.jsxs(N,{className:"space-y-2 text-sm",children:[w.map((a,f)=>e.jsxs("p",{className:"text-muted-foreground",children:["- ",hs(a)]},`${f}-${a}`)),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.factoryDocs")}),e.jsx("div",{className:"space-y-1.5",children:je.map(a=>e.jsxs("a",{href:a.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:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:a.description}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},a.id))})]}),e.jsx(R,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:s("droidPage.providerFactCheckDocs")}),e.jsx("div",{className:"space-y-1.5",children:ye.map(a=>e.jsxs("a",{href:a.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:a.label}),e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["provider: ",a.provider," | format: ",a.apiFormat]}),e.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-muted-foreground/90 underline underline-offset-2",children:a.url})]},`${a.provider}-${a.url}`))})]}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.providerValues",{value:ve.join(", ")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("droidPage.settingsHierarchy",{value:be.join(" -> ")})})]})]})})})})]})]})};return e.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:e.jsxs(we,{direction:"horizontal",className:"h-full",children:[e.jsx(ae,{defaultSize:45,minSize:35,children:e.jsx("div",{className:"h-full border-r bg-muted/20",children:he()})}),e.jsx(ke,{className:"w-2 bg-border hover:bg-primary/20 transition-colors cursor-col-resize flex items-center justify-center group",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground group-hover:text-primary"})}),e.jsx(ae,{defaultSize:55,minSize:35,children:e.jsx(Re,{title:s("droidPage.settingsTitle"),pathLabel:d?.path||"~/.factory/settings.json",loading:o,parseWarning:d?.parseError,value:B,dirty:ee,saving:m,saveDisabled:!ee||m||o||!F.valid,onChange:x=>{se(x)},onSave:pe,onRefresh:fe})})]})})}export{_s as DroidPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as g}from"./react-vendor-CNOkPC89.js";import{bt as C,bu as w,a as G,bv as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-2X8-14xr.js";import{R as N,w as D,x as I,at as L,a9 as T}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 _(){const{state:s}=C(),n=w(),[o,r]=g.useState(""),[c,m]=g.useState(""),u=g.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=g.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=g.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),m("")},[o,c,s.globalEnvConfig,i]),b=g.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:m,fetchConfig:u,saveConfig:i,addEnvVar:E,removeEnvVar:b}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:m,newEnvKey:u,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:b,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();g.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?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(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("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 ${c||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),m&&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(I,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:u,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>b(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!u.trim(),className:"h-9",children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),b(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as g}from"./react-vendor-CNOkPC89.js";import{bt as C,bu as w,a as G,bv as y,bi as k,bk as S,n as R,aI as A,d as f,I as j}from"./index-DhAjOd4r.js";import{R as N,w as D,x as I,at as L,a9 as T}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 _(){const{state:s}=C(),n=w(),[o,r]=g.useState(""),[c,m]=g.useState(""),u=g.useCallback(async()=>{try{n.setGlobalEnvLoading(!0),n.setGlobalEnvError(null);const a=await fetch("/api/global-env");if(!a.ok)throw new Error("Failed to load Global Env config");const l=await a.json();n.setGlobalEnvConfig(l)}catch(a){n.setGlobalEnvError(a.message)}finally{n.setGlobalEnvLoading(!1)}},[n]),i=g.useCallback(async a=>{const l=s.globalEnvConfig;if(!l)return;const x={...l,...a};n.setGlobalEnvConfig(x);try{n.setGlobalEnvSaving(!0),n.setGlobalEnvError(null);const d=await fetch("/api/global-env",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!d.ok){const h=await d.json();throw new Error(h.error||"Failed to save")}const v=await d.json();n.setGlobalEnvConfig(v.config),n.setGlobalEnvSuccess(!0),setTimeout(()=>n.setGlobalEnvSuccess(!1),1500)}catch(d){n.setGlobalEnvConfig(l),n.setGlobalEnvError(d.message)}finally{n.setGlobalEnvSaving(!1)}},[s.globalEnvConfig,n]),E=g.useCallback(()=>{if(!o.trim()||!s.globalEnvConfig)return;const a={...s.globalEnvConfig.env,[o.trim()]:c};i({env:a}),r(""),m("")},[o,c,s.globalEnvConfig,i]),b=g.useCallback(a=>{if(!s.globalEnvConfig)return;const l={...s.globalEnvConfig.env};delete l[a],i({env:l})},[s.globalEnvConfig,i]);return{config:s.globalEnvConfig,loading:s.globalEnvLoading,saving:s.globalEnvSaving,error:s.globalEnvError,success:s.globalEnvSuccess,newEnvKey:o,setNewEnvKey:r,newEnvValue:c,setNewEnvValue:m,fetchConfig:u,saveConfig:i,addEnvVar:E,removeEnvVar:b}}function Y(){const{t:s}=G(),{config:n,loading:o,saving:r,error:c,success:m,newEnvKey:u,setNewEnvKey:i,newEnvValue:E,setNewEnvValue:b,fetchConfig:a,saveConfig:l,addEnvVar:x,removeEnvVar:d}=_(),{fetchRawConfig:v}=y();g.useEffect(()=>{a(),v()},[a,v]);const h=()=>{l({enabled:!n?.enabled})};return o?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(N,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("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 ${c||m?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[c&&e.jsxs(k,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(S,{children:c})]}),m&&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(I,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(R,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.description")}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?.enabled?s("settingsGlobalEnv.enabled"):s("settingsGlobalEnv.disabled")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?.enabled?s("settingsGlobalEnv.enabledDesc"):s("settingsGlobalEnv.disabledDesc")})]}),e.jsx(A,{checked:n?.enabled??!0,onCheckedChange:h})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsGlobalEnv.envVars")}),n?.env&&Object.keys(n.env).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(n.env).map(([t,p])=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border bg-background",children:[e.jsx("code",{className:"flex-1 font-mono text-sm truncate",children:t}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("code",{className:"font-mono text-sm px-2 py-1 bg-muted rounded",children:p}),e.jsx(f,{variant:"ghost",size:"sm",onClick:()=>d(t),disabled:r,className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(L,{className:"w-4 h-4"})})]},t))}):e.jsx("div",{className:"p-4 rounded-lg border border-dashed text-center text-muted-foreground",children:e.jsx("p",{children:s("settingsGlobalEnv.noneConfigured")})}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.addNew")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:u,onChange:t=>i(t.target.value.toUpperCase()),placeholder:s("settingsGlobalEnv.keyName"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:"="}),e.jsx(j,{value:E,onChange:t=>b(t.target.value),placeholder:s("settingsGlobalEnv.value"),className:"flex-1 font-mono text-sm h-9",disabled:r}),e.jsxs(f,{size:"sm",onClick:x,disabled:r||!u.trim(),className:"h-9",children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),s("settingsGlobalEnv.add")]})]})]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-muted/30",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:s("settingsGlobalEnv.quickAdd")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[[{key:"DISABLE_BUG_COMMAND",value:"1"},{key:"DISABLE_ERROR_REPORTING",value:"1"},{key:"DISABLE_TELEMETRY",value:"1"}].map(({key:t,value:p})=>!n?.env?.[t]&&e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{i(t),b(p)},className:"text-xs font-mono",children:["+ ",t]},t)),n?.env&&["DISABLE_BUG_COMMAND","DISABLE_ERROR_REPORTING","DISABLE_TELEMETRY"].every(t=>n.env[t])&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("settingsGlobalEnv.allConfigured")})]})]})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>{a(),v()},disabled:o||r,className:"w-full",children:[e.jsx(N,{className:`w-4 h-4 mr-2 ${o?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Y as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{a as N,c as l,d as p,M as k,N as C,O as S,B as R,S as h}from"./index-2X8-14xr.js";import{u as W,a as E,b as O}from"./tanstack-CrmUhA7Z.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{b6 as y,C as P,$ as I,o as M,Z as T,i as $,U as H,e as A,ab as z,s as F,Y as B,R as D}from"./icons-DyorC3Xk.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},G={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function K({passed:s,total:t,status:a,size:r="md"}){const{t:i}=N(),o=q[r],c=G[a],n=t>0?Math.round(s/t*100):0,d=(o.dimension-o.strokeWidth)/2,u=2*Math.PI*d,f=u-n/100*u,x=o.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:o.dimension,height:o.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${c.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:"currentColor",strokeWidth:o.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:c.stroke,strokeWidth:o.strokeWidth,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),n>0&&e.jsx("circle",{cx:x+d*Math.cos(n/100*2*Math.PI-Math.PI/2),cy:x+d*Math.sin(n/100*2*Math.PI-Math.PI/2),r:o.strokeWidth/2,fill:c.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${c.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",o.fontSize),children:n}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",o.labelSize),children:i("health.healthLabel")})]})]})}function b({label:s,value:t,color:a,bgColor:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",r)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:r,info:i}){const{t:o}=N(),c=t/s*100,n=a/s*100,d=r/s*100,u=i/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[d>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${d}%`}}),n>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${n}%`}}),u>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${u}%`}}),c>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${c}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("health.checks")}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:r,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:i,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function Q(){return W({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function U(){const s=E();return O({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),r=await a.json();if(!a.ok)throw new Error(r.message);return r},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Z={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function Y({check:s}){const{t}=N(),a=U(),r=Z[s.status],[i,o]=j.useState(!1),c=s.details||s.fix,n=d=>{navigator.clipboard.writeText(d),g.success(t("health.copied"))};return c?e.jsx(k,{open:i,onOpenChange:o,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",i?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(P,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",i&&"rotate-90")})]})}),e.jsx(S,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(I,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&n(s.fix),className:"h-5 w-5 p-0",children:e.jsx(M,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.fix")]})]})}const J={Monitor:z,Settings:A,Users:H,Shield:$,Zap:T};function V({group:s,defaultOpen:t=!0}){const[a,r]=j.useState(t),i=J[s.icon]||z,o=s.checks.filter(m=>m.status==="ok").length,c=s.checks.length,n=s.checks.some(m=>m.status==="error"),d=s.checks.some(m=>m.status==="warning"),u=Math.round(o/c*100),f=n?"text-red-500":d?"text-yellow-500":"text-green-500",x=n?"bg-red-500":d?"bg-yellow-500":"bg-green-500";return e.jsx(k,{open:a,onOpenChange:r,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",n?"border-red-500/30":d?"border-yellow-500/30":"border-border"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",n?"bg-red-500/10 text-red-500":d?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",x),style:{width:`${u}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",f),children:[o,"/",c]}),e.jsx(F,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(S,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(Y,{check:m},m.id))})})]})})}function X(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function _(s,t){const a=Math.floor((Date.now()-s)/1e3);if(a<5)return t("health.justNow");if(a<60)return t("health.secondsAgo",{count:a});const r=Math.floor(a/60);if(r<60)return t("health.minutesAgo",{count:r});const i=Math.floor(r/60);return t("health.hoursAgo",{count:i})}function ee(s){return[...s].sort((t,a)=>{const r=t.checks.filter(n=>n.status==="error").length,i=a.checks.filter(n=>n.status==="error").length,o=t.checks.filter(n=>n.status==="warning").length,c=a.checks.filter(n=>n.status==="warning").length;return r!==i?i-r:c-o})}function se(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function te(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function xe(){const{t:s}=N(),{data:t,isLoading:a,refetch:r,dataUpdatedAt:i}=Q(),o=i,[c,n]=j.useState(0);j.useEffect(()=>{const m=setInterval(()=>n(v=>v+1),1e3);return()=>clearInterval(m)},[]);const d=()=>{navigator.clipboard.writeText("ccs doctor"),g.success(s("health.copied"))},u=()=>{r(),g.info(s("health.refreshing"))};if(a&&!t)return e.jsx(te,{});const f=t?X(t.summary):"ok",x=t?.groups?ee(t.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[t&&e.jsx("div",{className:"shrink-0",children:e.jsx(K,{passed:t.summary.passed,total:t.summary.total-t.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:s("health.systemHealth")}),t?.version&&e.jsx(R,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:s("health.build",{version:t.version})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.lastScan")}),e.jsx("span",{className:"font-mono",children:o?_(o,s):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.autoRefresh")}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:d,className:"gap-2 font-mono text-xs",children:[e.jsx(I,{className:"w-3 h-3"}),"ccs doctor",e.jsx(M,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:u,disabled:a,className:"gap-2",children:[e.jsx(D,{className:l("w-4 h-4",a&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:s("health.refresh")}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),t&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:t.summary.total,passed:t.summary.passed,warnings:t.summary.warnings,errors:t.summary.errors,info:t.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((m,v)=>e.jsx(V,{group:m,defaultOpen:v<2||m.checks.some(w=>w.status==="error"||w.status==="warning")},m.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:[s("health.version")," ",e.jsx("span",{className:"font-mono",children:t?.version??"--"})]}),e.jsxs("span",{children:[s("health.platform")," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})}export{xe as HealthPage};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{a as N,c as l,d as p,M as k,N as C,O as S,B as R,S as h}from"./index-DhAjOd4r.js";import{u as W,a as E,b as O}from"./tanstack-CrmUhA7Z.js";import{t as g}from"./notifications-B2HqRBj7.js";import{r as j}from"./react-vendor-CNOkPC89.js";import{b6 as y,C as P,$ as I,o as M,Z as T,i as $,U as H,e as A,ab as z,s as F,Y as B,R as D}from"./icons-DyorC3Xk.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q={sm:{dimension:80,strokeWidth:6,fontSize:"text-lg",labelSize:"text-[10px]"},md:{dimension:120,strokeWidth:8,fontSize:"text-3xl",labelSize:"text-xs"},lg:{dimension:160,strokeWidth:10,fontSize:"text-4xl",labelSize:"text-sm"}},G={ok:{stroke:"#22C55E",glow:"rgba(34, 197, 94, 0.4)"},warning:{stroke:"#EAB308",glow:"rgba(234, 179, 8, 0.4)"},error:{stroke:"#EF4444",glow:"rgba(239, 68, 68, 0.4)"}};function K({passed:s,total:t,status:a,size:r="md"}){const{t:i}=N(),o=q[r],c=G[a],n=t>0?Math.round(s/t*100):0,d=(o.dimension-o.strokeWidth)/2,u=2*Math.PI*d,f=u-n/100*u,x=o.dimension/2;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:o.dimension,height:o.dimension,className:"transform -rotate-90",style:{filter:`drop-shadow(0 0 8px ${c.glow})`},children:[e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:"currentColor",strokeWidth:o.strokeWidth,className:"text-muted/30"}),e.jsx("circle",{cx:x,cy:x,r:d,fill:"none",stroke:c.stroke,strokeWidth:o.strokeWidth,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:f,className:"transition-all duration-1000 ease-out"}),n>0&&e.jsx("circle",{cx:x+d*Math.cos(n/100*2*Math.PI-Math.PI/2),cy:x+d*Math.sin(n/100*2*Math.PI-Math.PI/2),r:o.strokeWidth/2,fill:c.stroke,className:"animate-pulse",style:{filter:`drop-shadow(0 0 4px ${c.glow})`}})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("span",{className:l("font-mono font-bold tracking-tight",o.fontSize),children:n}),e.jsx("span",{className:l("font-mono uppercase tracking-widest text-muted-foreground",o.labelSize),children:i("health.healthLabel")})]})]})}function b({label:s,value:t,color:a,bgColor:r}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full animate-pulse",r)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s}),e.jsx("span",{className:l("font-mono font-bold text-sm",a),children:t})]})}function L({total:s,passed:t,warnings:a,errors:r,info:i}){const{t:o}=N(),c=t/s*100,n=a/s*100,d=r/s*100,u=i/s*100;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"h-2 rounded-full overflow-hidden bg-muted/50 flex",children:[d>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all duration-500",style:{width:`${d}%`}}),n>0&&e.jsx("div",{className:"h-full bg-yellow-500 transition-all duration-500",style:{width:`${n}%`}}),u>0&&e.jsx("div",{className:"h-full bg-blue-500 transition-all duration-500",style:{width:`${u}%`}}),c>0&&e.jsx("div",{className:"h-full bg-green-500 transition-all duration-500",style:{width:`${c}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:o("health.checks")}),e.jsx("span",{className:"font-mono font-bold text-lg",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(b,{label:"OK",value:t,color:"text-green-500",bgColor:"bg-green-500"}),e.jsx(b,{label:"WARN",value:a,color:"text-yellow-500",bgColor:"bg-yellow-500"}),e.jsx(b,{label:"ERR",value:r,color:"text-red-500",bgColor:"bg-red-500"}),e.jsx(b,{label:"INFO",value:i,color:"text-blue-500",bgColor:"bg-blue-500"})]})]})]})}function Q(){return W({queryKey:["health"],queryFn:async()=>(await fetch("/api/health")).json(),refetchInterval:3e4})}function U(){const s=E();return O({mutationFn:async t=>{const a=await fetch(`/api/health/fix/${t}`,{method:"POST"}),r=await a.json();if(!a.ok)throw new Error(r.message);return r},onSuccess:t=>{s.invalidateQueries({queryKey:["health"]}),g.success(t.message)},onError:t=>{g.error(t.message)}})}const Z={ok:{dot:"bg-green-500",label:"OK",labelColor:"text-green-500"},warning:{dot:"bg-yellow-500",label:"WARN",labelColor:"text-yellow-500"},error:{dot:"bg-red-500",label:"ERR",labelColor:"text-red-500"},info:{dot:"bg-blue-500",label:"INFO",labelColor:"text-blue-500"}};function Y({check:s}){const{t}=N(),a=U(),r=Z[s.status],[i,o]=j.useState(!1),c=s.details||s.fix,n=d=>{navigator.clipboard.writeText(d),g.success(t("health.copied"))};return c?e.jsx(k,{open:i,onOpenChange:o,children:e.jsxs("div",{className:l("group rounded-lg border transition-all duration-150",i?"border-border bg-muted/30":"border-transparent hover:border-border/50 hover:bg-muted/50"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left",children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),e.jsx(P,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",i&&"rotate-90")})]})}),e.jsx(S,{children:e.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-2 ml-7",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),s.details&&e.jsx("pre",{className:"text-xs font-mono text-muted-foreground bg-background/50 rounded p-2 overflow-x-auto border border-border/50",children:s.details}),s.fix&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-background/50 rounded px-2 py-1.5 border border-border/50",children:[e.jsx(I,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("code",{className:"text-xs font-mono flex-1 truncate",children:s.fix}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>s.fix&&n(s.fix),className:"h-5 w-5 p-0",children:e.jsx(M,{className:"w-3 h-3"})})]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-7 px-3 text-xs",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.applyFix")]})]})]})})]})}):e.jsxs("div",{className:l("group flex items-center gap-3 px-3 py-2 rounded-lg","hover:bg-muted/50 transition-colors duration-150","border border-transparent hover:border-border/50"),children:[e.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[e.jsx("div",{className:l("w-2 h-2 rounded-full",r.dot)}),s.status!=="ok"&&e.jsx("div",{className:l("absolute w-2 h-2 rounded-full animate-ping opacity-75",r.dot)})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:s.name}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",r.labelColor),children:["[",r.label,"]"]}),s.fixable&&s.status!=="ok"&&e.jsxs(p,{size:"sm",variant:"ghost",onClick:()=>a.mutate(s.id),disabled:a.isPending,className:"h-6 px-2 text-xs opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{className:"w-3 h-3 mr-1"}),t("health.fix")]})]})}const J={Monitor:z,Settings:A,Users:H,Shield:$,Zap:T};function V({group:s,defaultOpen:t=!0}){const[a,r]=j.useState(t),i=J[s.icon]||z,o=s.checks.filter(m=>m.status==="ok").length,c=s.checks.length,n=s.checks.some(m=>m.status==="error"),d=s.checks.some(m=>m.status==="warning"),u=Math.round(o/c*100),f=n?"text-red-500":d?"text-yellow-500":"text-green-500",x=n?"bg-red-500":d?"bg-yellow-500":"bg-green-500";return e.jsx(k,{open:a,onOpenChange:r,children:e.jsxs("div",{className:l("rounded-lg border transition-all duration-200",n?"border-red-500/30":d?"border-yellow-500/30":"border-border"),children:[e.jsx(C,{asChild:!0,children:e.jsxs("button",{className:l("w-full flex items-center gap-3 p-3 text-left rounded-lg","hover:bg-muted/50 transition-colors duration-150",a&&"rounded-b-none border-b border-border/50"),children:[e.jsx("div",{className:l("p-1.5 rounded-md",n?"bg-red-500/10 text-red-500":d?"bg-yellow-500/10 text-yellow-500":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-4 h-4"})}),e.jsx("span",{className:"flex-1 text-sm font-semibold",children:s.name}),!a&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:l("h-full transition-all duration-500",x),style:{width:`${u}%`}})})}),e.jsxs("span",{className:l("font-mono text-xs font-semibold",f),children:[o,"/",c]}),e.jsx(F,{className:l("w-4 h-4 text-muted-foreground transition-transform duration-200",a&&"rotate-180")})]})}),e.jsx(S,{children:e.jsx("div",{className:"p-2 space-y-0.5",children:s.checks.map(m=>e.jsx(Y,{check:m},m.id))})})]})})}function X(s){return s.errors>0?"error":s.warnings>0?"warning":"ok"}function _(s,t){const a=Math.floor((Date.now()-s)/1e3);if(a<5)return t("health.justNow");if(a<60)return t("health.secondsAgo",{count:a});const r=Math.floor(a/60);if(r<60)return t("health.minutesAgo",{count:r});const i=Math.floor(r/60);return t("health.hoursAgo",{count:i})}function ee(s){return[...s].sort((t,a)=>{const r=t.checks.filter(n=>n.status==="error").length,i=a.checks.filter(n=>n.status==="error").length,o=t.checks.filter(n=>n.status==="warning").length,c=a.checks.filter(n=>n.status==="warning").length;return r!==i?i-r:c-o})}function se(){return e.jsxs("div",{className:"font-mono text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"$"}),e.jsx("span",{children:"ccs doctor"})]})}function te(){return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsx("div",{className:"rounded-xl border bg-gradient-to-br from-background to-muted/20 p-6",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(h,{className:"w-[120px] h-[120px] rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(h,{className:"h-5 w-48"}),e.jsx(h,{className:"h-8 w-64"}),e.jsx(h,{className:"h-4 w-32"})]})]})}),e.jsx(h,{className:"h-16 w-full rounded-lg"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(h,{className:"h-20 rounded-lg"},s))})]})}function xe(){const{t:s}=N(),{data:t,isLoading:a,refetch:r,dataUpdatedAt:i}=Q(),o=i,[c,n]=j.useState(0);j.useEffect(()=>{const m=setInterval(()=>n(v=>v+1),1e3);return()=>clearInterval(m)},[]);const d=()=>{navigator.clipboard.writeText("ccs doctor"),g.success(s("health.copied"))},u=()=>{r(),g.info(s("health.refreshing"))};if(a&&!t)return e.jsx(te,{});const f=t?X(t.summary):"ok",x=t?.groups?ee(t.groups):[];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:l("relative overflow-hidden rounded-xl border p-6","bg-gradient-to-br from-background via-background to-muted/30"),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)",backgroundSize:"24px 24px"}})}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start md:items-center gap-6",children:[t&&e.jsx("div",{className:"shrink-0",children:e.jsx(K,{passed:t.summary.passed,total:t.summary.total-t.summary.info,status:f,size:"md"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl font-bold font-mono tracking-tight",children:s("health.systemHealth")}),t?.version&&e.jsx(R,{variant:"outline",className:"font-mono text-xs bg-muted/50",children:s("health.build",{version:t.version})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(B,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.lastScan")}),e.jsx("span",{className:"font-mono",children:o?_(o,s):"--"}),e.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsx("span",{className:"text-muted-foreground",children:s("health.autoRefresh")}),e.jsx("span",{className:"font-mono text-green-500",children:"30s"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(p,{variant:"outline",size:"sm",onClick:d,className:"gap-2 font-mono text-xs",children:[e.jsx(I,{className:"w-3 h-3"}),"ccs doctor",e.jsx(M,{className:"w-3 h-3 opacity-50"})]}),e.jsxs(p,{variant:"outline",size:"sm",onClick:u,disabled:a,className:"gap-2",children:[e.jsx(D,{className:l("w-4 h-4",a&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:s("health.refresh")}),e.jsx("kbd",{className:"hidden md:inline-flex h-5 items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground",children:"R"})]})]})]})]}),t&&e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsx(L,{total:t.summary.total,passed:t.summary.passed,warnings:t.summary.warnings,errors:t.summary.errors,info:t.summary.info})}),x.length>0&&e.jsx("div",{className:"space-y-3",children:x.map((m,v)=>e.jsx(V,{group:m,defaultOpen:v<2||m.checks.some(w=>w.status==="error"||w.status==="warning")},m.id))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:[s("health.version")," ",e.jsx("span",{className:"font-mono",children:t?.version??"--"})]}),e.jsxs("span",{children:[s("health.platform")," ",e.jsx("span",{className:"font-mono",children:typeof navigator<"u"?navigator.platform:"linux"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsx("span",{children:s("health.liveMonitoring")})]})]})]})}export{xe as HealthPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Ne,bv as ke,Y as re,bi as se,bk as ne,d as C,n as we,B as m,c as g,aI as Se,I as q,r as ie,s as le,t as de,v as oe,w as z,W as l}from"./index-2X8-14xr.js";import{R as G,w as ce,x as Ae,a8 as me,aC as Ce,A as Me,aa as Pe,at as Be,t as Re,s as _e,a9 as Ve,aL as Te}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 M="__no_backend__";function ue(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(r=>typeof r=="string")}function De(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const r=t;return!!r.config&&typeof r.config.enabled=="boolean"&&typeof r.config.timeout=="number"&&ue(r.config.providerModels)&&(r.config.fallbackBackend===null||typeof r.config.fallbackBackend=="string")&&ue(r.config.profileBackends)&&!!r.summary&&typeof r.summary.state=="string"&&typeof r.summary.title=="string"&&typeof r.summary.detail=="string"&&Array.isArray(r.backends)&&Array.isArray(r.profiles)&&!!r.catalog&&Array.isArray(r.catalog.knownBackends)&&Array.isArray(r.catalog.profileNames)&&typeof r.summary.nativeProfileCount=="number"}function Ie(t){return Object.entries(t).sort(([r],[s])=>r.localeCompare(s)).map(([r,s],x)=>({id:`${r}-${s}-${x}`,profileName:r,backendId:s}))}function Ee(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function $e(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function ge(t){switch(t){case"active":return l.t("imageAnalysisStatus.badgeReady");case"bypassed":return l.t("imageAnalysisStatus.badgeBypassed");case"fallback":return l.t("imageAnalysisStatus.nativeFallback");case"setup":return l.t("imageAnalysisStatus.badgeSetup");case"disabled":return l.t("imageAnalysisStatus.badgeDisabled");case"native":return l.t("imageAnalysisStatus.badgeNative");case"unresolved":return l.t("imageAnalysisStatus.nativeImageReading")}}function xe(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Fe(t){switch(t){case"starts_on_launch":return l.t("imageAnalysisSection.backendStartsOnLaunch",{defaultValue:"Starts on launch"});case"needs_auth":return l.t("imageAnalysisStatus.needsAuth");case"needs_proxy":return l.t("imageAnalysisStatus.needsProxy");case"review":return l.t("imageAnalysisSection.review",{defaultValue:"Review"});case"ready":return l.t("imageAnalysisStatus.badgeReady")}}function Oe(t){if(!t)return l.t("imageAnalysisSection.noModelConfigured",{defaultValue:"No model configured."});switch(t.state){case"needs_auth":return t.authReason||l.t("imageAnalysisSection.authenticateToRoute",{defaultValue:"Authenticate to route here."});case"needs_proxy":return t.proxyReason||l.t("imageAnalysisSection.proxyUnavailable",{defaultValue:"Proxy unavailable."});case"starts_on_launch":return l.t("imageAnalysisSection.authReadyLaunchesLocally",{defaultValue:"Auth ready. Launches locally on demand."});case"review":return l.t("imageAnalysisSection.needsManualReview",{defaultValue:"Needs manual review."});case"ready":return null}}function ze(t){switch(t){case"profile-backend":return l.t("imageAnalysisSection.explicitMapping",{defaultValue:"Explicit mapping"});case"fallback-backend":return l.t("imageAnalysisSection.fallbackBackend",{defaultValue:"Fallback backend"});case"cliproxy-provider":return l.t("imageAnalysisSection.providerMatch",{defaultValue:"Provider match"});case"cliproxy-bridge":return l.t("imageAnalysisSection.bridgeMatch",{defaultValue:"Bridge match"});case"native-compatible":return l.t("imageAnalysisSection.nativePath",{defaultValue:"Native path"});case"copilot-alias":return l.t("imageAnalysisSection.copilotAlias",{defaultValue:"Copilot alias"});default:return t.replace(/-/g," ")}}function k(t){return"border-border/50 bg-background/40"}function Le(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Ke(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ue(t,r){return r.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function He(t){const r=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&r.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),r.join(" · ")}function Je(t){return Object.entries(t).reduce((r,[s,x])=>{const h=x.trim();return r[s]=h||null,r},{})}function W(t){return Object.entries(t).filter(([,r])=>r.trim().length>0).map(([r])=>r)}function qe(t){return t.reduce((r,s)=>{const x=s.profileName.trim();return!x||!s.backendId||(r[x]=s.backendId),r},{})}function pe(t,r){const s=Number.parseInt(t.trim(),10);return Number.isInteger(s)?String(Math.min(600,Math.max(10,s))):r}function T({title:t,description:r,icon:s,meta:x,action:h,children:D,className:c}){return e.jsxs("div",{className:g("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",c),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:s}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),x]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:r})]})]}),h&&e.jsx("div",{className:"shrink-0",children:h})]}),e.jsx("div",{className:"space-y-3",children:D})]})]})}function ra(){const{t}=Ne(),{fetchRawConfig:r}=ke(),[s,x]=o.useState(null),[h,D]=o.useState(!0),[c,Y]=o.useState(!1),[I,N]=o.useState(null),[P,L]=o.useState(null),[E,Q]=o.useState(!1),[B,X]=o.useState(!0),[K,U]=o.useState("60"),[v,R]=o.useState(""),[w,$]=o.useState({}),[p,F]=o.useState([]),S=o.useCallback(a=>{X(a.config.enabled),U(String(a.config.timeout)),R(a.config.fallbackBackend??""),$(a.catalog.knownBackends.reduce((n,i)=>(n[i]=a.config.providerModels[i]??"",n),{})),F(Ie(a.config.profileBackends))},[]),H=o.useCallback(async()=>{try{D(!0),N(null);const a=await re.imageAnalysis.get();if(!De(a))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");x(a),S(a)}catch(a){N(a instanceof Error?a.message:"Failed to load image settings.")}finally{D(!1)}},[S]);o.useEffect(()=>{H(),r()},[H,r]),o.useEffect(()=>{if(!P)return;const a=window.setTimeout(()=>L(null),2500);return()=>window.clearTimeout(a)},[P]),o.useEffect(()=>{s&&Object.keys(s.config.profileBackends).length>0&&Q(!0)},[s]);const u=o.useMemo(()=>W(w),[w]),Z=o.useMemo(()=>{if(!s)return[];const a=s.catalog.knownBackends.filter(i=>u.includes(i)),n=s.catalog.knownBackends.filter(i=>!u.includes(i));return[...a,...n]},[u,s]),O=o.useMemo(()=>s?.profiles.filter(a=>a.nativeReadPreference)??[],[s]);o.useEffect(()=>{if(u.length===0){R("");return}u.includes(v)||R(u[0])},[u,v]);const _=o.useCallback(async a=>{if(!s)return!1;const n=a?.enabled??B,i=a?.providerModels??w,d=W(i),b=pe(a?.timeout??K,String(s.config.timeout)),y=a?.fallbackBackend??v,A=d.length===0?"":d.includes(y)?y:d[0],f=a?.mappingDrafts??p,V={enabled:n,timeout:b,fallbackBackend:A,providerModels:Je(i),profileBackends:qe(f)},je={enabled:s.config.enabled,timeout:String(s.config.timeout),fallbackBackend:s.config.fallbackBackend??"",providerModels:s.catalog.knownBackends.reduce((j,te)=>(j[te]=s.config.providerModels[te]??null,j),{}),profileBackends:s.config.profileBackends};if(JSON.stringify(V)===JSON.stringify(je))return!0;if(n&&d.length===0)return N("Keep at least one provider model configured, or disable Image globally."),S(s),!1;try{Y(!0),N(null);const j=await re.imageAnalysis.update({enabled:n,timeout:Number.parseInt(b,10),fallbackBackend:A||null,providerModels:V.providerModels,profileBackends:V.profileBackends});return x(j),S(j),L(t("commonToast.settingsSaved")),await r(),!0}catch(j){return N(j instanceof Error?j.message:"Failed to save image settings."),S(s),!1}finally{Y(!1)}},[s,B,v,r,S,p,w,t,K]),ee=async()=>{h||c||(L(null),await Promise.all([H(),r()]))},be=async a=>{if(!c){if(a&&u.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}X(a),await _({enabled:a})}},fe=async a=>{if(!s||c)return;const n=pe(a,String(s.config.timeout));U(n),await _({timeout:n})},he=async a=>{c||(R(a),await _({fallbackBackend:a}))},ae=async(a,n)=>{if(!s||c)return;const i=n.trim(),d={...w,[a]:i},b=W(d);if(B&&b.length===0){N("Disable Image first or keep one backend configured."),$(A=>({...A,[a]:s.config.providerModels[a]??""}));return}const y=b.length===0?"":b.includes(v)?v:b[0];$(d),R(y),await _({providerModels:d,fallbackBackend:y})},ve=(a,n)=>{F(i=>i.map(d=>d.id===a?{...d,...n}:d))},J=async a=>{c||(F(a),await _({mappingDrafts:a}))},ye=p.filter(a=>a.profileName.trim()&&a.backendId).length;return h?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(G,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settingsPage.imageAnalysisSection.loading")})]})}):s?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||P?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:P})]})]}),e.jsx(we,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:t("settingsPage.imageAnalysisSection.title")})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(m,{className:g("border",Ee(s.summary.state)),children:s.summary.title}),e.jsx("span",{children:He(s.summary)})]})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:ee,disabled:h||c,"aria-label":"Refresh",title:"Refresh",children:e.jsx(G,{className:`h-4 w-4 ${h?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:t("settingsPage.imageAnalysisSection.description"),icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[u.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:B?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(Se,{checked:B,onCheckedChange:a=>{be(a)},disabled:c})]})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(q,{value:K,onChange:a=>U(a.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:c,onBlur:a=>{fe(a.currentTarget.value)},onKeyDown:a=>{a.key==="Enter"&&a.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(ie,{value:v||M,onValueChange:a=>{he(a===M?"":a)},disabled:c,children:[e.jsx(le,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(a=>e.jsx(z,{value:a,children:a},a))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[ye," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[v||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[Z.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:Z.map((a,n)=>{const i=s.backends.find(f=>f.backendId===a),d=i?.displayName||a,b=w[a]??"",y=Oe(i),A=b?[`${i?.profilesUsing??0} active`,i?.authReadiness==="missing"?"auth missing":i?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:g("relative px-3 py-3 md:px-4",n>0&&"border-t border-cyan-500/10",Le(i?.state)),children:[e.jsx("div",{className:g("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Ke(i?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:d}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a}),i?.profilesUsing?e.jsxs(m,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[i.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:A})]}),e.jsx(m,{className:g("border",i?$e(i.state):"border-border/80 bg-background/85 text-muted-foreground"),children:i?Fe(i.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(q,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:t("imageAnalysisSection.setModel",{defaultValue:"Set model"}),value:b,disabled:c,onChange:f=>$(V=>({...V,[a]:f.target.value})),onBlur:f=>{ae(a,f.currentTarget.value)},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}}),b.trim().length>0&&e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:c,onClick:()=>{ae(a,"")},children:t("common.clear",{defaultValue:"Clear"})})]}),y&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:y})]})]},a)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Pe,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:t("imageAnalysisSection.noProfilesPreferNative",{defaultValue:"No profiles prefer native reading yet."})}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(a=>e.jsx("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.nativeImageCapable?t("imageAnalysisStatus.capabilityVerified"):t("imageAnalysisSection.review",{defaultValue:"Review"})})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[a.profileModel||t("imageAnalysisSection.modelNotDetected",{defaultValue:"Model not detected"})," ","·"," ",a.nativeImageReason||t("imageAnalysisSection.nativeReadPreferred",{defaultValue:"Native read preferred."})]})]}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})},`native-${a.kind}-${a.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Te,{className:"h-4 w-4"}),meta:e.jsx(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(a=>!a),children:[E?e.jsx(Re,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?t("common.hide",{defaultValue:"Hide"}):t("common.show",{defaultValue:"Show"})]}),E&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>F(a=>[...a,{id:`mapping-${Date.now()}`,profileName:"",backendId:u[0]??""}]),disabled:u.length===0||c,children:[e.jsx(Ve,{className:"mr-1 h-4 w-4"}),t("imageAnalysisSection.addMapping",{defaultValue:"Add mapping"})]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:s.catalog.profileNames.map(a=>e.jsx("option",{value:a},a))}),E?e.jsx("div",{className:"space-y-2",children:p.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:p.map(a=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:t("imageAnalysisSection.directOverride",{defaultValue:"Direct override"})}),!(a.profileName.trim()&&a.backendId)&&e.jsx(m,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(C,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>{const n=p.filter(i=>i.id!==a.id);J(n)},children:[e.jsx(Be,{className:"mr-1 h-4 w-4"}),t("common.remove",{defaultValue:"Remove"})]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(q,{value:a.profileName,list:"image-profile-suggestions",disabled:c,placeholder:t("imageAnalysisSection.profileOrVariantName",{defaultValue:"Profile or variant name"}),className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:n=>{ve(a.id,{profileName:n.target.value})},onBlur:n=>{const i=p.map(d=>d.id===a.id?{...d,profileName:n.currentTarget.value.trim()}:d);J(i)},onKeyDown:n=>{n.key==="Enter"&&n.currentTarget.blur()}}),e.jsxs(ie,{value:a.backendId||M,disabled:c,onValueChange:n=>{const i=p.map(d=>d.id===a.id?{...d,backendId:n===M?"":n}:d);J(i)},children:[e.jsx(le,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(n=>e.jsx(z,{value:n,children:n},n))})]})]})]},a.id))})}):e.jsxs("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",k()),children:["Hidden by default.",p.length>0?` ${p.length} override${p.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[s.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:s.profiles.map((a,n)=>e.jsxs("div",{className:g("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",n>0&&"border-t border-slate-400/12",Ue(n,a)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px] uppercase",children:a.target}),a.nativeReadPreference&&e.jsx(m,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[a.backendDisplayName||a.profileModel||"Native file access"," ·"," ",ze(a.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[a.profileModel&&e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a.profileModel}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})]},`${a.kind}-${a.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(se,{variant:"destructive",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I??t("settingsPage.imageAnalysisSection.description")})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:ee,children:[e.jsx(G,{className:"mr-1 h-4 w-4"}),t("sharedPage.retry")]})})]})}export{ra as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as o}from"./react-vendor-CNOkPC89.js";import{a as Ne,bv as ke,Y as re,bi as se,bk as ne,d as C,n as we,B as m,c as g,aI as Se,I as q,r as ie,s as le,t as de,v as oe,w as z,W as l}from"./index-DhAjOd4r.js";import{R as G,w as ce,x as Ae,a8 as me,aC as Ce,A as Me,aa as Pe,at as Be,t as Re,s as _e,a9 as Ve,aL as Te}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 M="__no_backend__";function ue(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(r=>typeof r=="string")}function De(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const r=t;return!!r.config&&typeof r.config.enabled=="boolean"&&typeof r.config.timeout=="number"&&ue(r.config.providerModels)&&(r.config.fallbackBackend===null||typeof r.config.fallbackBackend=="string")&&ue(r.config.profileBackends)&&!!r.summary&&typeof r.summary.state=="string"&&typeof r.summary.title=="string"&&typeof r.summary.detail=="string"&&Array.isArray(r.backends)&&Array.isArray(r.profiles)&&!!r.catalog&&Array.isArray(r.catalog.knownBackends)&&Array.isArray(r.catalog.profileNames)&&typeof r.summary.nativeProfileCount=="number"}function Ie(t){return Object.entries(t).sort(([r],[s])=>r.localeCompare(s)).map(([r,s],x)=>({id:`${r}-${s}-${x}`,profileName:r,backendId:s}))}function Ee(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-900 dark:text-emerald-200";case"partial":return"border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-200";case"needs_setup":return"border-rose-500/25 bg-rose-500/10 text-rose-900 dark:text-rose-200";case"disabled":return"border-border/80 bg-background/85 text-muted-foreground"}}function $e(t){switch(t){case"ready":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"starts_on_launch":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"needs_auth":return"border-rose-500/25 bg-rose-500/10 text-rose-800 dark:text-rose-200";case"needs_proxy":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"review":return"border-border/80 bg-background/85 text-muted-foreground"}}function ge(t){switch(t){case"active":return l.t("imageAnalysisStatus.badgeReady");case"bypassed":return l.t("imageAnalysisStatus.badgeBypassed");case"fallback":return l.t("imageAnalysisStatus.nativeFallback");case"setup":return l.t("imageAnalysisStatus.badgeSetup");case"disabled":return l.t("imageAnalysisStatus.badgeDisabled");case"native":return l.t("imageAnalysisStatus.badgeNative");case"unresolved":return l.t("imageAnalysisStatus.nativeImageReading")}}function xe(t){switch(t){case"active":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"bypassed":return"border-sky-500/25 bg-sky-500/10 text-sky-800 dark:text-sky-200";case"fallback":case"setup":return"border-amber-500/25 bg-amber-500/10 text-amber-800 dark:text-amber-200";case"native":return"border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-200";case"disabled":case"unresolved":return"border-border/80 bg-background/85 text-muted-foreground"}}function Fe(t){switch(t){case"starts_on_launch":return l.t("imageAnalysisSection.backendStartsOnLaunch",{defaultValue:"Starts on launch"});case"needs_auth":return l.t("imageAnalysisStatus.needsAuth");case"needs_proxy":return l.t("imageAnalysisStatus.needsProxy");case"review":return l.t("imageAnalysisSection.review",{defaultValue:"Review"});case"ready":return l.t("imageAnalysisStatus.badgeReady")}}function Oe(t){if(!t)return l.t("imageAnalysisSection.noModelConfigured",{defaultValue:"No model configured."});switch(t.state){case"needs_auth":return t.authReason||l.t("imageAnalysisSection.authenticateToRoute",{defaultValue:"Authenticate to route here."});case"needs_proxy":return t.proxyReason||l.t("imageAnalysisSection.proxyUnavailable",{defaultValue:"Proxy unavailable."});case"starts_on_launch":return l.t("imageAnalysisSection.authReadyLaunchesLocally",{defaultValue:"Auth ready. Launches locally on demand."});case"review":return l.t("imageAnalysisSection.needsManualReview",{defaultValue:"Needs manual review."});case"ready":return null}}function ze(t){switch(t){case"profile-backend":return l.t("imageAnalysisSection.explicitMapping",{defaultValue:"Explicit mapping"});case"fallback-backend":return l.t("imageAnalysisSection.fallbackBackend",{defaultValue:"Fallback backend"});case"cliproxy-provider":return l.t("imageAnalysisSection.providerMatch",{defaultValue:"Provider match"});case"cliproxy-bridge":return l.t("imageAnalysisSection.bridgeMatch",{defaultValue:"Bridge match"});case"native-compatible":return l.t("imageAnalysisSection.nativePath",{defaultValue:"Native path"});case"copilot-alias":return l.t("imageAnalysisSection.copilotAlias",{defaultValue:"Copilot alias"});default:return t.replace(/-/g," ")}}function k(t){return"border-border/50 bg-background/40"}function Le(t){switch(t){case"ready":return"bg-[linear-gradient(90deg,rgba(16,185,129,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(16,185,129,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"starts_on_launch":return"bg-[linear-gradient(90deg,rgba(14,165,233,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(14,165,233,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_auth":return"bg-[linear-gradient(90deg,rgba(244,63,94,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(244,63,94,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"needs_proxy":return"bg-[linear-gradient(90deg,rgba(245,158,11,0.08),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.72),rgba(255,255,255,0.46))] dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12),transparent_18%),linear-gradient(180deg,rgba(15,23,42,0.82),rgba(15,23,42,0.56))]";case"review":default:return"bg-[linear-gradient(180deg,rgba(255,255,255,0.74),rgba(255,255,255,0.5))] dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.8),rgba(15,23,42,0.58))]"}}function Ke(t){switch(t){case"ready":return"from-emerald-500 to-emerald-400/30";case"starts_on_launch":return"from-sky-500 to-sky-400/30";case"needs_auth":return"from-rose-500 to-rose-400/30";case"needs_proxy":return"from-amber-500 to-amber-400/30";case"review":default:return"from-slate-400 to-slate-300/20"}}function Ue(t,r){return r.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function He(t){const r=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&r.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),r.join(" · ")}function Je(t){return Object.entries(t).reduce((r,[s,x])=>{const h=x.trim();return r[s]=h||null,r},{})}function W(t){return Object.entries(t).filter(([,r])=>r.trim().length>0).map(([r])=>r)}function qe(t){return t.reduce((r,s)=>{const x=s.profileName.trim();return!x||!s.backendId||(r[x]=s.backendId),r},{})}function pe(t,r){const s=Number.parseInt(t.trim(),10);return Number.isInteger(s)?String(Math.min(600,Math.max(10,s))):r}function T({title:t,description:r,icon:s,meta:x,action:h,children:D,className:c}){return e.jsxs("div",{className:g("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",c),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/40 via-primary/10 to-transparent"}),e.jsxs("div",{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary",children:s}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold tracking-tight",children:t}),x]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:r})]})]}),h&&e.jsx("div",{className:"shrink-0",children:h})]}),e.jsx("div",{className:"space-y-3",children:D})]})]})}function ra(){const{t}=Ne(),{fetchRawConfig:r}=ke(),[s,x]=o.useState(null),[h,D]=o.useState(!0),[c,Y]=o.useState(!1),[I,N]=o.useState(null),[P,L]=o.useState(null),[E,Q]=o.useState(!1),[B,X]=o.useState(!0),[K,U]=o.useState("60"),[v,R]=o.useState(""),[w,$]=o.useState({}),[p,F]=o.useState([]),S=o.useCallback(a=>{X(a.config.enabled),U(String(a.config.timeout)),R(a.config.fallbackBackend??""),$(a.catalog.knownBackends.reduce((n,i)=>(n[i]=a.config.providerModels[i]??"",n),{})),F(Ie(a.config.profileBackends))},[]),H=o.useCallback(async()=>{try{D(!0),N(null);const a=await re.imageAnalysis.get();if(!De(a))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");x(a),S(a)}catch(a){N(a instanceof Error?a.message:"Failed to load image settings.")}finally{D(!1)}},[S]);o.useEffect(()=>{H(),r()},[H,r]),o.useEffect(()=>{if(!P)return;const a=window.setTimeout(()=>L(null),2500);return()=>window.clearTimeout(a)},[P]),o.useEffect(()=>{s&&Object.keys(s.config.profileBackends).length>0&&Q(!0)},[s]);const u=o.useMemo(()=>W(w),[w]),Z=o.useMemo(()=>{if(!s)return[];const a=s.catalog.knownBackends.filter(i=>u.includes(i)),n=s.catalog.knownBackends.filter(i=>!u.includes(i));return[...a,...n]},[u,s]),O=o.useMemo(()=>s?.profiles.filter(a=>a.nativeReadPreference)??[],[s]);o.useEffect(()=>{if(u.length===0){R("");return}u.includes(v)||R(u[0])},[u,v]);const _=o.useCallback(async a=>{if(!s)return!1;const n=a?.enabled??B,i=a?.providerModels??w,d=W(i),b=pe(a?.timeout??K,String(s.config.timeout)),y=a?.fallbackBackend??v,A=d.length===0?"":d.includes(y)?y:d[0],f=a?.mappingDrafts??p,V={enabled:n,timeout:b,fallbackBackend:A,providerModels:Je(i),profileBackends:qe(f)},je={enabled:s.config.enabled,timeout:String(s.config.timeout),fallbackBackend:s.config.fallbackBackend??"",providerModels:s.catalog.knownBackends.reduce((j,te)=>(j[te]=s.config.providerModels[te]??null,j),{}),profileBackends:s.config.profileBackends};if(JSON.stringify(V)===JSON.stringify(je))return!0;if(n&&d.length===0)return N("Keep at least one provider model configured, or disable Image globally."),S(s),!1;try{Y(!0),N(null);const j=await re.imageAnalysis.update({enabled:n,timeout:Number.parseInt(b,10),fallbackBackend:A||null,providerModels:V.providerModels,profileBackends:V.profileBackends});return x(j),S(j),L(t("commonToast.settingsSaved")),await r(),!0}catch(j){return N(j instanceof Error?j.message:"Failed to save image settings."),S(s),!1}finally{Y(!1)}},[s,B,v,r,S,p,w,t,K]),ee=async()=>{h||c||(L(null),await Promise.all([H(),r()]))},be=async a=>{if(!c){if(a&&u.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}X(a),await _({enabled:a})}},fe=async a=>{if(!s||c)return;const n=pe(a,String(s.config.timeout));U(n),await _({timeout:n})},he=async a=>{c||(R(a),await _({fallbackBackend:a}))},ae=async(a,n)=>{if(!s||c)return;const i=n.trim(),d={...w,[a]:i},b=W(d);if(B&&b.length===0){N("Disable Image first or keep one backend configured."),$(A=>({...A,[a]:s.config.providerModels[a]??""}));return}const y=b.length===0?"":b.includes(v)?v:b[0];$(d),R(y),await _({providerModels:d,fallbackBackend:y})},ve=(a,n)=>{F(i=>i.map(d=>d.id===a?{...d,...n}:d))},J=async a=>{c||(F(a),await _({mappingDrafts:a}))},ye=p.filter(a=>a.profileName.trim()&&a.backendId).length;return h?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(G,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("settingsPage.imageAnalysisSection.loading")})]})}):s?e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${I||P?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:P})]})]}),e.jsx(we,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/30 p-4 shadow-sm",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-primary/70 via-primary/20 to-transparent"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.035]",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, currentColor 2px, currentColor 3px)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"inline-flex h-8 w-8 items-center justify-center rounded-xl border border-primary/20 bg-primary/8 text-primary",children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:t("settingsPage.imageAnalysisSection.title")})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(m,{className:g("border",Ee(s.summary.state)),children:s.summary.title}),e.jsx("span",{children:He(s.summary)})]})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:ee,disabled:h||c,"aria-label":"Refresh",title:"Refresh",children:e.jsx(G,{className:`h-4 w-4 ${h?"animate-spin":""}`})})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Active routes"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.activeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Current target path"})]}),e.jsxs("div",{className:"rounded-[18px] border bg-background/72 px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Native path"}),e.jsx("div",{className:"mt-1.5 text-xl font-semibold text-foreground",children:s.summary.nativeProfileCount}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Skip transformer"})]})]})]})]}),e.jsxs(T,{tone:"amber",eyebrow:"Control deck",title:"Core setup",description:t("settingsPage.imageAnalysisSection.description"),icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[u.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Enabled"}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:B?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(Se,{checked:B,onCheckedChange:a=>{be(a)},disabled:c})]})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Timeout"}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx(q,{value:K,onChange:a=>U(a.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:c,onBlur:a=>{fe(a.currentTarget.value)},onKeyDown:a=>{a.key==="Enter"&&a.currentTarget.blur()}}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"sec"})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Keeps large reads from hanging."})]}),e.jsxs("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.14em] text-amber-700/75 dark:text-amber-300/75",children:"Fallback backend"}),e.jsx("div",{className:"mt-2.5",children:e.jsxs(ie,{value:v||M,onValueChange:a=>{he(a===M?"":a)},disabled:c,children:[e.jsx(le,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(a=>e.jsx(z,{value:a,children:a},a))})]})}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:"Used when no direct route exists."})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[ye," overrides"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[O.length," native"]}),e.jsxs("div",{className:"rounded-full border border-amber-500/15 bg-background/80 px-2.5 py-1 text-[11px] text-muted-foreground",children:[v||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[Z.length," backends"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-cyan-500/12 bg-background/65 shadow-sm backdrop-blur-sm",children:Z.map((a,n)=>{const i=s.backends.find(f=>f.backendId===a),d=i?.displayName||a,b=w[a]??"",y=Oe(i),A=b?[`${i?.profilesUsing??0} active`,i?.authReadiness==="missing"?"auth missing":i?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:g("relative px-3 py-3 md:px-4",n>0&&"border-t border-cyan-500/10",Le(i?.state)),children:[e.jsx("div",{className:g("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Ke(i?.state))}),e.jsxs("div",{className:"pl-2.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground",children:d}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a}),i?.profilesUsing?e.jsxs(m,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[i.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:A})]}),e.jsx(m,{className:g("border",i?$e(i.state):"border-border/80 bg-background/85 text-muted-foreground"),children:i?Fe(i.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(q,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:t("imageAnalysisSection.setModel",{defaultValue:"Set model"}),value:b,disabled:c,onChange:f=>$(V=>({...V,[a]:f.target.value})),onBlur:f=>{ae(a,f.currentTarget.value)},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}}),b.trim().length>0&&e.jsx(C,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:c,onClick:()=>{ae(a,"")},children:t("common.clear",{defaultValue:"Clear"})})]}),y&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:y})]})]},a)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Pe,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[O.length," profiles"]}),children:O.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:t("imageAnalysisSection.noProfilesPreferNative",{defaultValue:"No profiles prefer native reading yet."})}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:O.map(a=>e.jsx("div",{className:g("rounded-[18px] border px-3.5 py-3 shadow-sm",k()),children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.nativeImageCapable?t("imageAnalysisStatus.capabilityVerified"):t("imageAnalysisSection.review",{defaultValue:"Review"})})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[a.profileModel||t("imageAnalysisSection.modelNotDetected",{defaultValue:"Model not detected"})," ","·"," ",a.nativeImageReason||t("imageAnalysisSection.nativeReadPreferred",{defaultValue:"Native read preferred."})]})]}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})},`native-${a.kind}-${a.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Te,{className:"h-4 w-4"}),meta:e.jsx(m,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px] text-amber-800 dark:text-amber-200",children:"Advanced"}),action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>Q(a=>!a),children:[E?e.jsx(Re,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?t("common.hide",{defaultValue:"Hide"}):t("common.show",{defaultValue:"Show"})]}),E&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>F(a=>[...a,{id:`mapping-${Date.now()}`,profileName:"",backendId:u[0]??""}]),disabled:u.length===0||c,children:[e.jsx(Ve,{className:"mr-1 h-4 w-4"}),t("imageAnalysisSection.addMapping",{defaultValue:"Add mapping"})]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:s.catalog.profileNames.map(a=>e.jsx("option",{value:a},a))}),E?e.jsx("div",{className:"space-y-2",children:p.length===0?e.jsx("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",k()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:p.map(a=>e.jsxs("div",{className:"rounded-[18px] border border-slate-400/20 bg-[linear-gradient(180deg,rgba(255,255,255,0.72),rgba(248,250,252,0.52))] p-3 shadow-sm dark:bg-[linear-gradient(180deg,rgba(15,23,42,0.84),rgba(15,23,42,0.56))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:t("imageAnalysisSection.directOverride",{defaultValue:"Direct override"})}),!(a.profileName.trim()&&a.backendId)&&e.jsx(m,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(C,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:()=>{const n=p.filter(i=>i.id!==a.id);J(n)},children:[e.jsx(Be,{className:"mr-1 h-4 w-4"}),t("common.remove",{defaultValue:"Remove"})]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(q,{value:a.profileName,list:"image-profile-suggestions",disabled:c,placeholder:t("imageAnalysisSection.profileOrVariantName",{defaultValue:"Profile or variant name"}),className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:n=>{ve(a.id,{profileName:n.target.value})},onBlur:n=>{const i=p.map(d=>d.id===a.id?{...d,profileName:n.currentTarget.value.trim()}:d);J(i)},onKeyDown:n=>{n.key==="Enter"&&n.currentTarget.blur()}}),e.jsxs(ie,{value:a.backendId||M,disabled:c,onValueChange:n=>{const i=p.map(d=>d.id===a.id?{...d,backendId:n===M?"":n}:d);J(i)},children:[e.jsx(le,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(de,{placeholder:t("settingsPage.thinkingSection.configureModelFirst")})}),e.jsx(oe,{children:u.length===0?e.jsx(z,{value:M,children:t("settingsPage.thinkingSection.configureModelFirst")}):u.map(n=>e.jsx(z,{value:n,children:n},n))})]})]})]},a.id))})}):e.jsxs("div",{className:g("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",k()),children:["Hidden by default.",p.length>0?` ${p.length} override${p.length===1?"":"s"} saved.`:" No overrides saved."]})]}),e.jsx(T,{tone:"slate",eyebrow:"Audit view",title:"Coverage",description:"Read-only routing ledger for the current path.",icon:e.jsx(me,{className:"h-4 w-4"}),meta:e.jsxs(m,{variant:"outline",children:[s.profiles.length," profiles"]}),children:e.jsx("div",{className:"overflow-hidden rounded-[20px] border border-slate-400/15 bg-background/75 shadow-sm backdrop-blur-sm",children:s.profiles.map((a,n)=>e.jsxs("div",{className:g("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",n>0&&"border-t border-slate-400/12",Ue(n,a)),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e.jsx(m,{variant:"outline",className:"text-[10px]",children:a.kind==="variant"?t("cliproxyPage.variant"):t("apiProfiles.title")}),e.jsx(m,{variant:"outline",className:"font-mono text-[10px] uppercase",children:a.target}),a.nativeReadPreference&&e.jsx(m,{variant:"outline",className:"border-emerald-500/20 bg-emerald-500/10 text-[10px]",children:"Native"})]}),e.jsxs("div",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:[a.backendDisplayName||a.profileModel||"Native file access"," ·"," ",ze(a.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[a.profileModel&&e.jsx(m,{variant:"outline",className:"font-mono text-[10px]",children:a.profileModel}),e.jsx(m,{className:g("border",xe(a.currentTargetMode)),children:ge(a.currentTargetMode)})]})]},`${a.kind}-${a.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(se,{variant:"destructive",children:[e.jsx(ce,{className:"h-4 w-4"}),e.jsx(ne,{children:I??t("settingsPage.imageAnalysisSection.description")})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:ee,children:[e.jsx(G,{className:"mr-1 h-4 w-4"}),t("sharedPage.retry")]})})]})}export{ra as default};