@kaitranntt/ccs 7.68.1-dev.3 → 7.68.1-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/commands/cliproxy/catalog-subcommand.d.ts +6 -0
  2. package/dist/commands/cliproxy/catalog-subcommand.d.ts.map +1 -1
  3. package/dist/commands/cliproxy/catalog-subcommand.js +39 -1
  4. package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -1
  5. package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
  6. package/dist/commands/cliproxy/help-subcommand.js +1 -0
  7. package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
  8. package/dist/commands/cliproxy/index.d.ts.map +1 -1
  9. package/dist/commands/cliproxy/index.js +6 -0
  10. package/dist/commands/cliproxy/index.js.map +1 -1
  11. package/dist/commands/command-catalog.d.ts +1 -1
  12. package/dist/commands/command-catalog.d.ts.map +1 -1
  13. package/dist/commands/cursor-command-display.d.ts +2 -0
  14. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  15. package/dist/commands/cursor-command-display.js +24 -3
  16. package/dist/commands/cursor-command-display.js.map +1 -1
  17. package/dist/commands/cursor-command.d.ts.map +1 -1
  18. package/dist/commands/cursor-command.js +31 -1
  19. package/dist/commands/cursor-command.js.map +1 -1
  20. package/dist/cursor/constants.d.ts +1 -1
  21. package/dist/cursor/constants.d.ts.map +1 -1
  22. package/dist/cursor/constants.js +1 -0
  23. package/dist/cursor/constants.js.map +1 -1
  24. package/dist/cursor/cursor-auth.d.ts +1 -0
  25. package/dist/cursor/cursor-auth.d.ts.map +1 -1
  26. package/dist/cursor/cursor-auth.js +154 -32
  27. package/dist/cursor/cursor-auth.js.map +1 -1
  28. package/dist/cursor/cursor-executor.d.ts +1 -1
  29. package/dist/cursor/cursor-executor.d.ts.map +1 -1
  30. package/dist/cursor/cursor-executor.js +295 -160
  31. package/dist/cursor/cursor-executor.js.map +1 -1
  32. package/dist/cursor/cursor-protobuf-decoder.d.ts.map +1 -1
  33. package/dist/cursor/cursor-protobuf-decoder.js +1 -3
  34. package/dist/cursor/cursor-protobuf-decoder.js.map +1 -1
  35. package/dist/cursor/cursor-protobuf-schema.d.ts +12 -3
  36. package/dist/cursor/cursor-protobuf-schema.d.ts.map +1 -1
  37. package/dist/cursor/cursor-protobuf-schema.js +23 -5
  38. package/dist/cursor/cursor-protobuf-schema.js.map +1 -1
  39. package/dist/cursor/cursor-protobuf.d.ts +1 -1
  40. package/dist/cursor/cursor-protobuf.d.ts.map +1 -1
  41. package/dist/cursor/cursor-protobuf.js +2 -4
  42. package/dist/cursor/cursor-protobuf.js.map +1 -1
  43. package/dist/cursor/cursor-runtime-probe.d.ts +12 -0
  44. package/dist/cursor/cursor-runtime-probe.d.ts.map +1 -0
  45. package/dist/cursor/cursor-runtime-probe.js +220 -0
  46. package/dist/cursor/cursor-runtime-probe.js.map +1 -0
  47. package/dist/cursor/cursor-stream-parser.d.ts +10 -0
  48. package/dist/cursor/cursor-stream-parser.d.ts.map +1 -1
  49. package/dist/cursor/cursor-stream-parser.js +106 -10
  50. package/dist/cursor/cursor-stream-parser.js.map +1 -1
  51. package/dist/cursor/index.d.ts +1 -0
  52. package/dist/cursor/index.d.ts.map +1 -1
  53. package/dist/cursor/index.js +3 -1
  54. package/dist/cursor/index.js.map +1 -1
  55. package/dist/cursor/types.d.ts +6 -0
  56. package/dist/cursor/types.d.ts.map +1 -1
  57. package/dist/ui/assets/{accounts-4Wxzh1pD.js → accounts-BohTElIQ.js} +1 -1
  58. package/dist/ui/assets/{alert-dialog-DGxGdNKD.js → alert-dialog-DnnexfUF.js} +1 -1
  59. package/dist/ui/assets/{api-DDTb78NK.js → api-DK9aBvwF.js} +1 -1
  60. package/dist/ui/assets/{auth-section-r5XbRAUy.js → auth-section-D1IqH1kL.js} +1 -1
  61. package/dist/ui/assets/{backups-section-CfhkSFYu.js → backups-section-Cizi6jcJ.js} +1 -1
  62. package/dist/ui/assets/{channels-CUNcGH3S.js → channels-1FDViA_G.js} +1 -1
  63. package/dist/ui/assets/{checkbox-Dhabke8C.js → checkbox-BrsI6T5h.js} +1 -1
  64. package/dist/ui/assets/{claude-extension-B7woSTcR.js → claude-extension-B_YasQSe.js} +1 -1
  65. package/dist/ui/assets/{cliproxy-0UypW7So.js → cliproxy-BGV6RvKO.js} +1 -1
  66. package/dist/ui/assets/{cliproxy-ai-providers-n7M1sRek.js → cliproxy-ai-providers-DOg-95GU.js} +1 -1
  67. package/dist/ui/assets/{cliproxy-control-panel-BfElGwOQ.js → cliproxy-control-panel-DrH2SYCZ.js} +1 -1
  68. package/dist/ui/assets/{codex-CP1dPOyh.js → codex-DHCsIPxy.js} +1 -1
  69. package/dist/ui/assets/{confirm-dialog-vhsQSaZ6.js → confirm-dialog-DW9epM6P.js} +1 -1
  70. package/dist/ui/assets/{copilot-DUTtEVYH.js → copilot-CKDZ98ee.js} +1 -1
  71. package/dist/ui/assets/cursor-BHg_ETJF.js +1 -0
  72. package/dist/ui/assets/{droid-mrP_PnYz.js → droid-CWS4dH8h.js} +1 -1
  73. package/dist/ui/assets/{globalenv-section-Gh2BxqVn.js → globalenv-section-DS-1Qpmy.js} +1 -1
  74. package/dist/ui/assets/{health-TGXaQNZq.js → health-DUOeRP2U.js} +1 -1
  75. package/dist/ui/assets/{index-CQIjTCyk.js → index-BFj6rbo3.js} +1 -1
  76. package/dist/ui/assets/{index-DSM3luVm.js → index-BzucrQW1.js} +15 -15
  77. package/dist/ui/assets/{index-DRXqBE1w.js → index-CZ74sbc0.js} +1 -1
  78. package/dist/ui/assets/{index-CaRCgIIp.js → index-CmO-DVIW.js} +1 -1
  79. package/dist/ui/assets/index-Cu6e0-ev.css +1 -0
  80. package/dist/ui/assets/{index-wYHVuydD.js → index-HX0cLD64.js} +1 -1
  81. package/dist/ui/assets/{index-CRAY9dRC.js → index-S2moP4X0.js} +1 -1
  82. package/dist/ui/assets/{logs-5mpClyQ2.js → logs-l8NsPQKy.js} +1 -1
  83. package/dist/ui/assets/{masked-input-DhWU9sNj.js → masked-input-ROSbNEnd.js} +1 -1
  84. package/dist/ui/assets/{proxy-status-widget-C1IFaC6c.js → proxy-status-widget-CXjMNmf4.js} +1 -1
  85. package/dist/ui/assets/{raw-json-settings-editor-panel-tK2P1u12.js → raw-json-settings-editor-panel-Baama5zh.js} +1 -1
  86. package/dist/ui/assets/{searchable-select-CNH0YBur.js → searchable-select-g1nEPDRJ.js} +1 -1
  87. package/dist/ui/assets/{separator-CJd089R0.js → separator-B019oPsV.js} +1 -1
  88. package/dist/ui/assets/{shared-DxH1omaN.js → shared-DNazuV_W.js} +1 -1
  89. package/dist/ui/assets/{table-lWkyktS-.js → table-DBOKGrcQ.js} +1 -1
  90. package/dist/ui/assets/{updates-nm2PIK8k.js → updates-B11W_hg3.js} +1 -1
  91. package/dist/ui/index.html +2 -2
  92. package/dist/web-server/routes/cursor-routes.d.ts +2 -0
  93. package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
  94. package/dist/web-server/routes/cursor-routes.js +44 -2
  95. package/dist/web-server/routes/cursor-routes.js.map +1 -1
  96. package/package.json +1 -1
  97. package/dist/ui/assets/cursor-ThAyj_tQ.js +0 -1
  98. package/dist/ui/assets/index-teLjoh2T.css +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{bt as Oe,bu as He,Y as L,a as ae,I as B,aF as D,r as Ve,s as Ue,t as ze,v as We,w as ue,d as V,bv as Ge,bw as Ye,bx as qe,be as se,bg as te,n as Je}from"./index-DSM3luVm.js";import{C as U}from"./default-ports-1QQSffYX.js";import{ba as he,R as re,h as Xe,x as fe,W as Qe,w as Ze,az as es,bb as ss,T as ye,aG as ts,p as rs,bc as as}from"./icons-KVCk4_U8.js";import{P as os}from"./proxy-status-widget-C1IFaC6c.js";import{R as H}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./tanstack-CrmUhA7Z.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DGxGdNKD.js";function ns(){const{state:s}=Oe(),t=He(),[g,o]=n.useState(null),[u,b]=n.useState(null),[y,j]=n.useState(null),[p,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await L.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await L.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:b,editedAuthToken:y,setEditedAuthToken:j,editedManagementKey:p,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function is({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:b}){const{t:y}=ae(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:y("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:y("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:p=>o(p.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${U}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:y("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y("settingsProxy.localAutoStartDesc")})]}),e.jsx(D,{checked:j.auto_start??!0,onCheckedChange:p=>b({local:{...j,auto_start:p}}),disabled:t})]})]})]})}function ls({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:b,displayAuthToken:y,displayManagementKey:j,setEditedHost:p,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=ae(),c=s.remote,k=l=>l==="https"?443:U;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>p(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:b,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(Ve,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Ue,{children:e.jsx(ze,{})}),e.jsxs(We,{children:[e.jsx(ue,{value:"http",children:a("settingsProxy.http")}),e.jsx(ue,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:y,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(V,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const pe="ccs_debug_mode",cs=["kiro","ghcp"];function ds(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Cs(){const{t:s}=ae(),{config:t,loading:g,saving:o,error:u,success:b,testResult:y,testing:j,editedHost:p,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ns(),{fetchRawConfig:l}=Ge(),[_,be]=n.useState(()=>{try{return localStorage.getItem(pe)==="true"}catch{return!1}}),[je,z]=n.useState(!1),[Pe,oe]=n.useState(!0),[f,ne]=n.useState(!1),[ke,R]=n.useState(!1),[ie,I]=n.useState(""),K=n.useRef(!1),W=ds(ie)===H,ve=r=>{be(r);try{localStorage.setItem(pe,String(r))}catch{}},G=n.useCallback(async()=>{try{oe(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();z(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),z(!1)}finally{oe(!1)}},[s]),F=n.useCallback(async r=>{if(!(K.current||f||o))try{K.current=!0,ne(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),O=await i.json();if(!i.ok)throw new Error(O.error||s("settingsProxy.failedUpdateAgyMode"));const $e=O.antigravityAckBypass===!0,me=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!me.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const ge=(await me.json()).antigravityAckBypass===!0;if(ge!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));z(ge&&$e),R(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ne(!1)}},[f,l,o,s]),Ne=n.useCallback(r=>{if(!(K.current||f||o)){if(r){R(!0);return}R(!1),I(""),F(!1)}},[f,F,o]),Ce=n.useCallback(()=>{if(!W){T.error(s("settingsProxy.typePhraseToContinue",{value:H}));return}F(!0)},[W,F,s]),[v,Y]=n.useState("plus"),[Se,we]=n.useState(!1),q=Ye(),{data:Ae}=qe(),le=Ae?.running??!1,J=n.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();Y(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),X=n.useCallback(async()=>{try{const i=(await L.cliproxy.list()).variants.some(O=>cs.includes(O.provider));we(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),ce=r=>{const i=v;Y(r),q.mutate({backend:r},{onError:()=>{Y(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),G(),l(),J(),X()},[a,G,l,J,X]),g||!t)return 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(re,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,$=!m&&le,N=t.remote,M=t.fallback,Ee=t.remote.host??"",Te=t.remote.port!==void 0?t.remote.port.toString():"",Be=t.remote.auth_token??"",Me=t.remote.management_key??"",De=(t.local.port??U).toString(),Q=p??Ee,Z=S??Te,ee=w??Be,de=E??Me,xe=x??De,Le=()=>{const r=p??Q;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},_e=()=>{const r=(S??Z).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Re=()=>{const r=w??ee;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Ie=()=>{const r=E??de;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},Ke=()=>{const r=(x??xe).trim(),i=r===""?U:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},Fe=()=>{k({host:Q,port:Z,protocol:t.remote.protocol||"http",authToken:ee})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||b?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx(te,{children:u})]}),b&&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(fe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(Je,{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("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(os,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(es,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(he,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&le&&e.jsxs(se,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(ye,{className:"h-4 w-4 text-amber-600"}),e.jsx(te,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>ce("plus"),disabled:q.isPending||$,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${$?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")})]}),e.jsxs("button",{onClick:()=>ce("original"),disabled:q.isPending||$,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${$?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")})]})]}),v==="original"&&Se&&e.jsxs(se,{variant:"destructive",className:"py-2",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx(te,{children:s("settingsProxy.variantsIncompatible")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(D,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:je,disabled:Pe||f||o,onCheckedChange:Ne})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),ke&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(rs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:H})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:ie,onChange:r=>I(r.target.value),placeholder:H,disabled:f||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(V,{variant:"outline",size:"sm",onClick:()=>{R(!1),I("")},disabled:f||o,children:s("settingsBackups.cancel")}),e.jsx(V,{size:"sm",variant:"destructive",onClick:Ce,disabled:!W||f||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(ls,{config:t,saving:o,testing:j,testResult:y,displayHost:Q,displayPort:Z,displayAuthToken:ee,displayManagementKey:de,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Le,onSavePort:_e,onSaveAuthToken:Re,onSaveManagementKey:Ie,onSaveConfig:c,onTestConnection:Fe}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(D,{checked:M.enabled??!0,onCheckedChange:r=>c({fallback:{...M,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(D,{checked:M.auto_start??!1,onCheckedChange:r=>c({fallback:{...M,auto_start:r}}),disabled:o||!m||!M.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(D,{checked:_,onCheckedChange:ve,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(is,{config:t,saving:o,displayLocalPort:xe,setEditedLocalPort:h,onSaveLocalPort:Ke,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>{a(),G(),l(),J(),X()},disabled:g||o||f,className:"w-full",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Cs as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{bt as Oe,bu as He,Y as L,a as ae,I as B,aF as D,r as Ve,s as Ue,t as ze,v as We,w as ue,d as V,bv as Ge,bw as Ye,bx as qe,be as se,bg as te,n as Je}from"./index-BzucrQW1.js";import{C as U}from"./default-ports-1QQSffYX.js";import{ba as he,R as re,h as Xe,x as fe,W as Qe,w as Ze,az as es,bb as ss,T as ye,aG as ts,p as rs,bc as as}from"./icons-KVCk4_U8.js";import{P as os}from"./proxy-status-widget-CXjMNmf4.js";import{R as H}from"./antigravity-responsibility-constants-Bvh4Ybz0.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./tanstack-CrmUhA7Z.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DnnexfUF.js";function ns(){const{state:s}=Oe(),t=He(),[g,o]=n.useState(null),[u,b]=n.useState(null),[y,j]=n.useState(null),[p,C]=n.useState(null),[S,P]=n.useState(null),w=n.useCallback(async()=>{try{t.setProxyLoading(!0),t.setProxyError(null);const d=await L.cliproxyServer.get();t.setProxyConfig(d)}catch(d){t.setProxyError(d.message)}finally{t.setProxyLoading(!1)}},[t]),A=n.useCallback(async d=>{const x=s.proxyConfig;if(!x)return;const h={remote:{...x.remote,...d.remote},fallback:{...x.fallback,...d.fallback},local:{...x.local,...d.local}};t.setProxyConfig(h),t.setProxyTestResult(null);try{t.setProxySaving(!0),t.setProxyError(null);const a=await L.cliproxyServer.update(d);t.setProxyConfig(a),t.setProxySuccess(!0),setTimeout(()=>t.setProxySuccess(!1),1500)}catch(a){t.setProxyConfig(x),t.setProxyError(a.message)}finally{t.setProxySaving(!1)}},[s.proxyConfig,t]),E=n.useCallback(async d=>{const{host:x,port:h,protocol:a,authToken:c}=d;if(!x){t.setProxyError("Host is required");return}try{t.setProxyTesting(!0),t.setProxyError(null),t.setProxyTestResult(null);const k=h?parseInt(h,10):void 0,l=await L.cliproxyServer.test({host:x,port:k||void 0,protocol:a,authToken:c||void 0});t.setProxyTestResult(l)}catch(k){t.setProxyError(k.message)}finally{t.setProxyTesting(!1)}},[t]);return{config:s.proxyConfig,loading:s.proxyLoading,saving:s.proxySaving,error:s.proxyError,success:s.proxySuccess,testResult:s.proxyTestResult,testing:s.proxyTesting,editedHost:g,setEditedHost:o,editedPort:u,setEditedPort:b,editedAuthToken:y,setEditedAuthToken:j,editedManagementKey:p,setEditedManagementKey:C,editedLocalPort:S,setEditedLocalPort:P,fetchConfig:w,saveConfig:A,testConnection:E}}function is({config:s,saving:t,displayLocalPort:g,setEditedLocalPort:o,onSaveLocalPort:u,onSaveConfig:b}){const{t:y}=ae(),j=s.local;return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:y("settingsProxy.localProxy")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:y("settingsProxy.port")}),e.jsx(B,{type:"text",inputMode:"numeric",value:g,onChange:p=>o(p.target.value.replace(/\D/g,"")),onBlur:u,placeholder:`${U}`,className:"font-mono max-w-32",disabled:t})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:y("settingsProxy.autoStart")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:y("settingsProxy.localAutoStartDesc")})]}),e.jsx(D,{checked:j.auto_start??!0,onCheckedChange:p=>b({local:{...j,auto_start:p}}),disabled:t})]})]})]})}function ls({config:s,saving:t,testing:g,testResult:o,displayHost:u,displayPort:b,displayAuthToken:y,displayManagementKey:j,setEditedHost:p,setEditedPort:C,setEditedAuthToken:S,setEditedManagementKey:P,onSaveHost:w,onSavePort:A,onSaveAuthToken:E,onSaveManagementKey:d,onSaveConfig:x,onTestConnection:h}){const{t:a}=ae(),c=s.remote,k=l=>l==="https"?443:U;return e.jsxs("div",{className:"space-y-4 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4"}),a("settingsProxy.remoteConfigTitle")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.host")}),e.jsx(B,{value:u,onChange:l=>p(l.target.value),onBlur:w,placeholder:a("settingsProxy.hostPlaceholder"),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-sm text-muted-foreground",children:[a("settingsProxy.port")," ",e.jsxs("span",{className:"text-xs opacity-70",children:["(",a("settingsProxy.defaultPort",{value:k(s.remote.protocol||"http")}),")"]})]}),e.jsx(B,{type:"text",inputMode:"numeric",value:b,onChange:l=>C(l.target.value.replace(/\D/g,"")),onBlur:A,placeholder:a("settingsProxy.portPlaceholder",{value:k(s.remote.protocol||"http")}),className:"font-mono",disabled:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.protocol")}),e.jsxs(Ve,{value:s.remote.protocol||"http",onValueChange:l=>x({remote:{...c,protocol:l}}),disabled:t,children:[e.jsx(Ue,{children:e.jsx(ze,{})}),e.jsxs(We,{children:[e.jsx(ue,{value:"http",children:a("settingsProxy.http")}),e.jsx(ue,{value:"https",children:a("settingsProxy.https")})]})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.apiKeyOptional")}),e.jsx(B,{type:"password",value:y,onChange:l=>S(l.target.value),onBlur:E,placeholder:a("settingsProxy.apiKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.apiKeyDesc")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:a("settingsProxy.managementKeyOptional")}),e.jsx(B,{type:"password",value:j,onChange:l=>P(l.target.value),onBlur:d,placeholder:a("settingsProxy.managementKeyPlaceholder"),className:"font-mono",disabled:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settingsProxy.managementKeyDesc")})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx(V,{onClick:h,disabled:g||!u,variant:"outline",className:"w-full",children:g?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}),a("settingsProxy.testing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-4 h-4 mr-2"}),a("settingsProxy.testConnection")]})}),o&&e.jsx("div",{className:`p-3 rounded-md ${o.reachable?"bg-green-50 border border-green-200 dark:bg-green-900/20 dark:border-green-900/50":"bg-red-50 border border-red-200 dark:bg-red-900/20 dark:border-red-900/50"}`,children:e.jsx("div",{className:"flex items-center gap-2",children:o.reachable?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("settingsProxy.connectedLatency",{value:o.latencyMs})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:o.error||a("settingsProxy.connectionFailed")})]})})})]})]})}const pe="ccs_debug_mode",cs=["kiro","ghcp"];function ds(s){return s.trim().replace(/\s+/g," ").toUpperCase()}function Cs(){const{t:s}=ae(),{config:t,loading:g,saving:o,error:u,success:b,testResult:y,testing:j,editedHost:p,setEditedHost:C,editedPort:S,setEditedPort:P,editedAuthToken:w,setEditedAuthToken:A,editedManagementKey:E,setEditedManagementKey:d,editedLocalPort:x,setEditedLocalPort:h,fetchConfig:a,saveConfig:c,testConnection:k}=ns(),{fetchRawConfig:l}=Ge(),[_,be]=n.useState(()=>{try{return localStorage.getItem(pe)==="true"}catch{return!1}}),[je,z]=n.useState(!1),[Pe,oe]=n.useState(!0),[f,ne]=n.useState(!1),[ke,R]=n.useState(!1),[ie,I]=n.useState(""),K=n.useRef(!1),W=ds(ie)===H,ve=r=>{be(r);try{localStorage.setItem(pe,String(r))}catch{}},G=n.useCallback(async()=>{try{oe(!0);const r=await fetch("/api/settings/auth/antigravity-risk");if(!r.ok)throw new Error(s("settingsProxy.failedLoadAgyMode"));const i=await r.json();z(i.antigravityAckBypass===!0)}catch(r){T.error(r instanceof Error?r.message:s("settingsProxy.failedLoadAgyMode")),z(!1)}finally{oe(!1)}},[s]),F=n.useCallback(async r=>{if(!(K.current||f||o))try{K.current=!0,ne(!0);const i=await fetch("/api/settings/auth/antigravity-risk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({antigravityAckBypass:r})}),O=await i.json();if(!i.ok)throw new Error(O.error||s("settingsProxy.failedUpdateAgyMode"));const $e=O.antigravityAckBypass===!0,me=await fetch("/api/settings/auth/antigravity-risk",{cache:"no-store"});if(!me.ok)throw new Error(s("settingsProxy.failedVerifyAgyMode"));const ge=(await me.json()).antigravityAckBypass===!0;if(ge!==r)throw new Error(s("settingsProxy.notPersistedAgyMode"));z(ge&&$e),R(!1),I(""),T.success(s(r?"settingsProxy.agyModeEnabled":"settingsProxy.agyModeDisabled")),await l()}catch(i){T.error(i instanceof Error?i.message:s("settingsProxy.failedUpdateAgyMode"))}finally{K.current=!1,ne(!1)}},[f,l,o,s]),Ne=n.useCallback(r=>{if(!(K.current||f||o)){if(r){R(!0);return}R(!1),I(""),F(!1)}},[f,F,o]),Ce=n.useCallback(()=>{if(!W){T.error(s("settingsProxy.typePhraseToContinue",{value:H}));return}F(!0)},[W,F,s]),[v,Y]=n.useState("plus"),[Se,we]=n.useState(!1),q=Ye(),{data:Ae}=qe(),le=Ae?.running??!1,J=n.useCallback(async()=>{try{const r=await L.cliproxyServer.getBackend();Y(r.backend)}catch(r){console.error("[Proxy] Failed to fetch backend:",r)}},[]),X=n.useCallback(async()=>{try{const i=(await L.cliproxy.list()).variants.some(O=>cs.includes(O.provider));we(i)}catch(r){console.error("[Proxy] Failed to check variants:",r)}},[]),ce=r=>{const i=v;Y(r),q.mutate({backend:r},{onError:()=>{Y(i)}})};if(n.useEffect(()=>{if(_&&t){const r={...t,remote:{...t.remote,auth_token:t.remote.auth_token?"[REDACTED]":void 0,management_key:t.remote.management_key?"[REDACTED]":void 0}};console.log("[CCS Debug] Debug mode enabled - proxy config:",r)}},[_,t]),n.useEffect(()=>{a(),G(),l(),J(),X()},[a,G,l,J,X]),g||!t)return 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(re,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const m=t.remote.enabled??!1,$=!m&&le,N=t.remote,M=t.fallback,Ee=t.remote.host??"",Te=t.remote.port!==void 0?t.remote.port.toString():"",Be=t.remote.auth_token??"",Me=t.remote.management_key??"",De=(t.local.port??U).toString(),Q=p??Ee,Z=S??Te,ee=w??Be,de=E??Me,xe=x??De,Le=()=>{const r=p??Q;r!==t.remote.host&&c({remote:{...N,host:r}}),C(null)},_e=()=>{const r=(S??Z).trim();if(r===""){t.remote.port!==void 0&&c({remote:{...N,port:void 0}}),P(null);return}const i=Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidPortOrEmpty")),P(null);return}i!==t.remote.port&&c({remote:{...N,port:i}}),P(null)},Re=()=>{const r=w??ee;r!==t.remote.auth_token&&c({remote:{...N,auth_token:r}}),A(null)},Ie=()=>{const r=E??de;r!==t.remote.management_key&&c({remote:{...N,management_key:r||void 0}}),d(null)},Ke=()=>{const r=(x??xe).trim(),i=r===""?U:Number(r);if(!Number.isInteger(i)||i<1||i>65535){T.error(s("settingsProxy.invalidLocalPort")),h(null);return}i!==t.local.port&&c({local:{...t.local,port:i}}),h(null)},Fe=()=>{k({host:Q,port:Z,protocol:t.remote.protocol||"http",authToken:ee})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${u||b?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[u&&e.jsxs(se,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx(te,{children:u})]}),b&&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(fe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:s("settings.saved")})]})]}),e.jsx(Je,{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("settingsProxy.description",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})}),!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.instanceStatus")}),e.jsx(os,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.connectionMode")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!1}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(es,{className:`w-5 h-5 ${m?"text-muted-foreground":"text-primary"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.local")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.localDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]}),e.jsxs("button",{onClick:()=>c({remote:{...N,enabled:!0}}),disabled:o,className:`p-4 rounded-lg border-2 text-left transition-all ${m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(he,{className:`w-5 h-5 ${m?"text-primary":"text-muted-foreground"}`}),e.jsx("span",{className:"font-medium",children:s("settingsProxy.remote")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.remoteDesc",{backend:s(v==="plus"?"settingsProxy.backendPlus":"settingsProxy.backend")})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ss,{className:"w-4 h-4"}),s("settingsProxy.backendBinary")]}),!m&&le&&e.jsxs(se,{className:"py-2 border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 [&>svg]:top-2.5",children:[e.jsx(ye,{className:"h-4 w-4 text-amber-600"}),e.jsx(te,{className:"text-amber-700 dark:text-amber-400",children:s("settingsProxy.stopProxyToSwitch")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>ce("plus"),disabled:q.isPending||$,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="plus"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${$?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendPlusApi")}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-400",children:s("settingsProxy.default")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.plusDesc")})]}),e.jsxs("button",{onClick:()=>ce("original"),disabled:q.isPending||$,className:`p-4 rounded-lg border-2 text-left transition-all ${v==="original"?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"} ${$?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx("span",{className:"font-medium",children:s("settingsProxy.backendApi")})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.originalDesc")})]})]}),v==="original"&&Se&&e.jsxs(se,{variant:"destructive",className:"py-2",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx(te,{children:s("settingsProxy.variantsIncompatible")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(ts,{className:"w-4 h-4 text-amber-700 dark:text-amber-300"}),s("settingsProxy.safety")]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-400/35 bg-amber-50/70 p-4 dark:border-amber-800/60 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.agyModeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.agyModeDesc")})]}),e.jsx(D,{"aria-labelledby":"agy-power-user-mode-label","aria-describedby":"agy-power-user-mode-description",checked:je,disabled:Pe||f||o,onCheckedChange:Ne})]}),e.jsx("p",{id:"agy-power-user-mode-description",className:"text-xs text-amber-800/90 dark:text-amber-200/90",children:s("settingsProxy.agyWarning")}),ke&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-rose-500/40 bg-rose-500/[0.08] p-3.5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.finalConfirm")}),e.jsx("p",{className:"text-xs leading-relaxed text-rose-800/95 dark:text-rose-200/90",children:s("settingsProxy.finalConfirmDesc")})]}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step1")}),e.jsxs("a",{href:"https://github.com/kaitranntt/ccs/issues/509",target:"_blank",rel:"noreferrer",className:"mt-1 inline-flex items-center gap-1.5 text-xs font-medium text-rose-800 underline decoration-rose-500/60 underline-offset-2 transition-colors hover:text-rose-700 dark:text-rose-200",children:[s("settingsProxy.readIssue"),e.jsx(rs,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"rounded-md border border-rose-400/30 bg-rose-500/10 p-2.5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-rose-900 dark:text-rose-200",children:s("settingsProxy.step2")}),e.jsxs("p",{className:"mt-1 text-xs text-rose-800/95 dark:text-rose-200/90",children:[s("settingsProxy.typePrefix")," ",e.jsx("code",{className:"rounded bg-background/80 px-1 py-0.5 font-mono",children:H})," ",s("settingsProxy.typeSuffix")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{value:ie,onChange:r=>I(r.target.value),placeholder:H,disabled:f||o,className:"font-mono text-xs","aria-label":s("settingsProxy.typePhraseAria")}),e.jsx("p",{className:"text-[11px] text-rose-800/90 dark:text-rose-200/80",children:s("settingsProxy.exactPhrase")})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(V,{variant:"outline",size:"sm",onClick:()=>{R(!1),I("")},disabled:f||o,children:s("settingsBackups.cancel")}),e.jsx(V,{size:"sm",variant:"destructive",onClick:Ce,disabled:!W||f||o,children:s("settingsProxy.enableAgyMode")})]})]}),e.jsx("span",{id:"agy-power-user-mode-label",className:"sr-only",children:s("settingsProxy.toggleAgyMode")})]})]}),m&&e.jsx(ls,{config:t,saving:o,testing:j,testResult:y,displayHost:Q,displayPort:Z,displayAuthToken:ee,displayManagementKey:de,setEditedHost:C,setEditedPort:P,setEditedAuthToken:A,setEditedManagementKey:d,onSaveHost:Le,onSavePort:_e,onSaveAuthToken:Re,onSaveManagementKey:Ie,onSaveConfig:c,onTestConnection:Fe}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:s("settingsProxy.fallbackSettings")}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.enableFallback")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.enableFallbackDesc")})]}),e.jsx(D,{checked:M.enabled??!0,onCheckedChange:r=>c({fallback:{...M,enabled:r}}),disabled:o||!m})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.autoStartLocal")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.autoStartLocalDesc")})]}),e.jsx(D,{checked:M.auto_start??!1,onCheckedChange:r=>c({fallback:{...M,auto_start:r}}),disabled:o||!m||!M.enabled})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-base font-medium flex items-center gap-2",children:[e.jsx(as,{className:"w-4 h-4"}),s("settingsProxy.advanced")]}),e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s("settingsProxy.debugMode")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsProxy.debugModeDesc")})]}),e.jsx(D,{checked:_,onCheckedChange:ve,disabled:o})]}),_&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 pl-0.5",children:s("settingsProxy.debugModeEnabled")})]})]}),!m&&e.jsx(is,{config:t,saving:o,displayLocalPort:xe,setEditedLocalPort:h,onSaveLocalPort:Ke,onSaveConfig:c})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>{a(),G(),l(),J(),X()},disabled:g||o||f,className:"w-full",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),s("settings.refresh")]})})]})}export{Cs as default};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{bv as je,Y as re,be as ae,bg as te,d as B,n as Ne,B as c,c as u,aF as ye,I as G,r as se,s as ne,t as ie,v as de,w as O}from"./index-DSM3luVm.js";import{R as J,w as le,x as ke,a8 as oe,aB as we,A as Ce,aa as Be,as as Me,t as Se,s as _e,a9 as Pe,aK as Re}from"./icons-KVCk4_U8.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 ce(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(a=>typeof a=="string")}function Ae(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const a=t;return!!a.config&&typeof a.config.enabled=="boolean"&&typeof a.config.timeout=="number"&&ce(a.config.providerModels)&&(a.config.fallbackBackend===null||typeof a.config.fallbackBackend=="string")&&ce(a.config.profileBackends)&&!!a.summary&&typeof a.summary.state=="string"&&typeof a.summary.title=="string"&&typeof a.summary.detail=="string"&&Array.isArray(a.backends)&&Array.isArray(a.profiles)&&!!a.catalog&&Array.isArray(a.catalog.knownBackends)&&Array.isArray(a.catalog.profileNames)&&typeof a.summary.nativeProfileCount=="number"}function Te(t){return Object.entries(t).sort(([a],[l])=>a.localeCompare(l)).map(([a,l],g)=>({id:`${a}-${l}-${g}`,profileName:a,backendId:l}))}function De(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 Ie(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 me(t){switch(t){case"active":return"Active";case"bypassed":return"Bypassed";case"fallback":return"Native fallback";case"setup":return"Needs setup";case"disabled":return"Disabled";case"native":return"Native";case"unresolved":return"Native only"}}function ue(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 Ee(t){switch(t){case"starts_on_launch":return"Starts on launch";case"needs_auth":return"Needs auth";case"needs_proxy":return"Needs proxy";case"review":return"Review";case"ready":return"Ready"}}function $e(t){if(!t)return"No model configured.";switch(t.state){case"needs_auth":return t.authReason||"Authenticate to route here.";case"needs_proxy":return t.proxyReason||"Proxy unavailable.";case"starts_on_launch":return"Auth ready. Launches locally on demand.";case"review":return"Needs manual review.";case"ready":return null}}function ze(t){switch(t){case"profile-backend":return"Explicit mapping";case"fallback-backend":return"Fallback backend";case"cliproxy-provider":return"Provider match";case"cliproxy-bridge":return"Bridge match";case"native-compatible":return"Native path";case"copilot-alias":return"Copilot alias";default:return t.replace(/-/g," ")}}function y(t){return"border-border/50 bg-background/40"}function Fe(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 Oe(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 Ke(t,a){return a.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function Le(t){const a=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&a.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),a.join(" · ")}function Ve(t){return Object.entries(t).reduce((a,[l,g])=>{const j=g.trim();return a[l]=j||null,a},{})}function q(t){return Object.entries(t).filter(([,a])=>a.trim().length>0).map(([a])=>a)}function Ue(t){return t.reduce((a,l)=>{const g=l.profileName.trim();return!g||!l.backendId||(a[g]=l.backendId),a},{})}function ge(t,a){const l=Number.parseInt(t.trim(),10);return Number.isInteger(l)?String(Math.min(600,Math.max(10,l))):a}function T({title:t,description:a,icon:l,meta:g,action:j,children:o,className:D}){return e.jsxs("div",{className:u("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",D),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:l}),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}),g]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:a})]})]}),j&&e.jsx("div",{className:"shrink-0",children:j})]}),e.jsx("div",{className:"space-y-3",children:o})]})]})}function er(){const{fetchRawConfig:t}=je(),[a,l]=d.useState(null),[g,j]=d.useState(!0),[o,D]=d.useState(!1),[I,N]=d.useState(null),[S,K]=d.useState(null),[E,Y]=d.useState(!1),[_,Q]=d.useState(!0),[L,V]=d.useState("60"),[f,P]=d.useState(""),[k,$]=d.useState({}),[x,z]=d.useState([]),w=d.useCallback(r=>{Q(r.config.enabled),V(String(r.config.timeout)),P(r.config.fallbackBackend??""),$(r.catalog.knownBackends.reduce((s,n)=>(s[n]=r.config.providerModels[n]??"",s),{})),z(Te(r.config.profileBackends))},[]),U=d.useCallback(async()=>{try{j(!0),N(null);const r=await re.imageAnalysis.get();if(!Ae(r))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");l(r),w(r)}catch(r){N(r instanceof Error?r.message:"Failed to load image settings.")}finally{j(!1)}},[w]);d.useEffect(()=>{U(),t()},[U,t]),d.useEffect(()=>{if(!S)return;const r=window.setTimeout(()=>K(null),2500);return()=>window.clearTimeout(r)},[S]),d.useEffect(()=>{a&&Object.keys(a.config.profileBackends).length>0&&Y(!0)},[a]);const m=d.useMemo(()=>q(k),[k]),W=d.useMemo(()=>{if(!a)return[];const r=a.catalog.knownBackends.filter(n=>m.includes(n)),s=a.catalog.knownBackends.filter(n=>!m.includes(n));return[...r,...s]},[m,a]),F=d.useMemo(()=>a?.profiles.filter(r=>r.nativeReadPreference)??[],[a]);d.useEffect(()=>{if(m.length===0){P("");return}m.includes(f)||P(m[0])},[m,f]);const R=d.useCallback(async r=>{if(!a)return!1;const s=r?.enabled??_,n=r?.providerModels??k,i=q(n),b=ge(r?.timeout??L,String(a.config.timeout)),h=r?.fallbackBackend??f,C=i.length===0?"":i.includes(h)?h:i[0],p=r?.mappingDrafts??x,A={enabled:s,timeout:b,fallbackBackend:C,providerModels:Ve(n),profileBackends:Ue(p)},ve={enabled:a.config.enabled,timeout:String(a.config.timeout),fallbackBackend:a.config.fallbackBackend??"",providerModels:a.catalog.knownBackends.reduce((v,ee)=>(v[ee]=a.config.providerModels[ee]??null,v),{}),profileBackends:a.config.profileBackends};if(JSON.stringify(A)===JSON.stringify(ve))return!0;if(s&&i.length===0)return N("Keep at least one provider model configured, or disable Image globally."),w(a),!1;try{D(!0),N(null);const v=await re.imageAnalysis.update({enabled:s,timeout:Number.parseInt(b,10),fallbackBackend:C||null,providerModels:A.providerModels,profileBackends:A.profileBackends});return l(v),w(v),K("Image settings saved."),await t(),!0}catch(v){return N(v instanceof Error?v.message:"Failed to save image settings."),w(a),!1}finally{D(!1)}},[a,_,f,t,w,x,k,L]),X=async()=>{g||o||(K(null),await Promise.all([U(),t()]))},xe=async r=>{if(!o){if(r&&m.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}Q(r),await R({enabled:r})}},be=async r=>{if(!a||o)return;const s=ge(r,String(a.config.timeout));V(s),await R({timeout:s})},pe=async r=>{o||(P(r),await R({fallbackBackend:r}))},Z=async(r,s)=>{if(!a||o)return;const n=s.trim(),i={...k,[r]:n},b=q(i);if(_&&b.length===0){N("Disable Image first or keep one backend configured."),$(C=>({...C,[r]:a.config.providerModels[r]??""}));return}const h=b.length===0?"":b.includes(f)?f:b[0];$(i),P(h),await R({providerModels:i,fallbackBackend:h})},fe=(r,s)=>{z(n=>n.map(i=>i.id===r?{...i,...s}:i))},H=async r=>{o||(z(r),await R({mappingDrafts:r}))},he=x.filter(r=>r.profileName.trim()&&r.backendId).length;return g?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(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading image settings..."})]})}):a?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||S?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(ae,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I})]}),S&&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(ke,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:S})]})]}),e.jsx(Ne,{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(oe,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Image"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(c,{className:u("border",De(a.summary.state)),children:a.summary.title}),e.jsx("span",{children:Le(a.summary)})]})]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:X,disabled:g||o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(J,{className:`h-4 w-4 ${g?"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:a.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:a.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:"Global toggle, timeout, and fallback.",icon:e.jsx(we,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[m.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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:_?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(ye,{checked:_,onCheckedChange:r=>{xe(r)},disabled:o})]})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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(G,{value:L,onChange:r=>V(r.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:o,onBlur:r=>{be(r.currentTarget.value)},onKeyDown:r=>{r.key==="Enter"&&r.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:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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(se,{value:f||M,onValueChange:r=>{pe(r===M?"":r)},disabled:o,children:[e.jsx(ne,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(O,{value:M,children:"Configure a model first"}):m.map(r=>e.jsx(O,{value:r,children:r},r))})]})}),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:[he," 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:[F.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:[f||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[W.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:W.map((r,s)=>{const n=a.backends.find(p=>p.backendId===r),i=n?.displayName||r,b=k[r]??"",h=$e(n),C=b?[`${n?.profilesUsing??0} active`,n?.authReadiness==="missing"?"auth missing":n?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:u("relative px-3 py-3 md:px-4",s>0&&"border-t border-cyan-500/10",Fe(n?.state)),children:[e.jsx("div",{className:u("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Oe(n?.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:i}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r}),n?.profilesUsing?e.jsxs(c,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[n.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:C})]}),e.jsx(c,{className:u("border",n?Ie(n.state):"border-border/80 bg-background/85 text-muted-foreground"),children:n?Ee(n.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(G,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:"Set model",value:b,disabled:o,onChange:p=>$(A=>({...A,[r]:p.target.value})),onBlur:p=>{Z(r,p.currentTarget.value)},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()}}),b.trim().length>0&&e.jsx(B,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:o,onClick:()=>{Z(r,"")},children:"Clear"})]}),h&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:h})]})]},r)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Be,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[F.length," profiles"]}),children:F.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No profiles prefer native reading yet."}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:F.map(r=>e.jsx("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.nativeImageCapable?"Verified":"Review"})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[r.profileModel||"Model not detected"," ·"," ",r.nativeImageReason||"Native read preferred."]})]}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})},`native-${r.kind}-${r.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Re,{className:"h-4 w-4"}),meta:e.jsx(c,{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(B,{type:"button",variant:"outline",size:"sm",onClick:()=>Y(r=>!r),children:[E?e.jsx(Se,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?"Hide":"Show"]}),E&&e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>z(r=>[...r,{id:`mapping-${Date.now()}`,profileName:"",backendId:m[0]??""}]),disabled:m.length===0||o,children:[e.jsx(Pe,{className:"mr-1 h-4 w-4"}),"Add mapping"]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:a.catalog.profileNames.map(r=>e.jsx("option",{value:r},r))}),E?e.jsx("div",{className:"space-y-2",children:x.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:x.map(r=>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:"Direct override"}),!(r.profileName.trim()&&r.backendId)&&e.jsx(c,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(B,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>{const s=x.filter(n=>n.id!==r.id);H(s)},children:[e.jsx(Me,{className:"mr-1 h-4 w-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(G,{value:r.profileName,list:"image-profile-suggestions",disabled:o,placeholder:"Profile or variant name",className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:s=>{fe(r.id,{profileName:s.target.value})},onBlur:s=>{const n=x.map(i=>i.id===r.id?{...i,profileName:s.currentTarget.value.trim()}:i);H(n)},onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}}),e.jsxs(se,{value:r.backendId||M,disabled:o,onValueChange:s=>{const n=x.map(i=>i.id===r.id?{...i,backendId:s===M?"":s}:i);H(n)},children:[e.jsx(ne,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(O,{value:M,children:"Configure a model first"}):m.map(s=>e.jsx(O,{value:s,children:s},s))})]})]})]},r.id))})}):e.jsxs("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",y()),children:["Hidden by default.",x.length>0?` ${x.length} override${x.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(oe,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[a.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:a.profiles.map((r,s)=>e.jsxs("div",{className:u("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",s>0&&"border-t border-slate-400/12",Ke(s,r)),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:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px] uppercase",children:r.target}),r.nativeReadPreference&&e.jsx(c,{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:[r.backendDisplayName||r.profileModel||"Native file access"," ·"," ",ze(r.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[r.profileModel&&e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r.profileModel}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})]},`${r.kind}-${r.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(ae,{variant:"destructive",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I??"Failed to load image settings."})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(B,{variant:"outline",size:"sm",onClick:X,children:[e.jsx(J,{className:"mr-1 h-4 w-4"}),"Retry"]})})]})}export{er as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as d}from"./react-vendor-CNOkPC89.js";import{bv as je,Y as re,be as ae,bg as te,d as B,n as Ne,B as c,c as u,aF as ye,I as G,r as se,s as ne,t as ie,v as de,w as O}from"./index-BzucrQW1.js";import{R as J,w as le,x as ke,a8 as oe,aB as we,A as Ce,aa as Be,as as Me,t as Se,s as _e,a9 as Pe,aK as Re}from"./icons-KVCk4_U8.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 ce(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(a=>typeof a=="string")}function Ae(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const a=t;return!!a.config&&typeof a.config.enabled=="boolean"&&typeof a.config.timeout=="number"&&ce(a.config.providerModels)&&(a.config.fallbackBackend===null||typeof a.config.fallbackBackend=="string")&&ce(a.config.profileBackends)&&!!a.summary&&typeof a.summary.state=="string"&&typeof a.summary.title=="string"&&typeof a.summary.detail=="string"&&Array.isArray(a.backends)&&Array.isArray(a.profiles)&&!!a.catalog&&Array.isArray(a.catalog.knownBackends)&&Array.isArray(a.catalog.profileNames)&&typeof a.summary.nativeProfileCount=="number"}function Te(t){return Object.entries(t).sort(([a],[l])=>a.localeCompare(l)).map(([a,l],g)=>({id:`${a}-${l}-${g}`,profileName:a,backendId:l}))}function De(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 Ie(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 me(t){switch(t){case"active":return"Active";case"bypassed":return"Bypassed";case"fallback":return"Native fallback";case"setup":return"Needs setup";case"disabled":return"Disabled";case"native":return"Native";case"unresolved":return"Native only"}}function ue(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 Ee(t){switch(t){case"starts_on_launch":return"Starts on launch";case"needs_auth":return"Needs auth";case"needs_proxy":return"Needs proxy";case"review":return"Review";case"ready":return"Ready"}}function $e(t){if(!t)return"No model configured.";switch(t.state){case"needs_auth":return t.authReason||"Authenticate to route here.";case"needs_proxy":return t.proxyReason||"Proxy unavailable.";case"starts_on_launch":return"Auth ready. Launches locally on demand.";case"review":return"Needs manual review.";case"ready":return null}}function ze(t){switch(t){case"profile-backend":return"Explicit mapping";case"fallback-backend":return"Fallback backend";case"cliproxy-provider":return"Provider match";case"cliproxy-bridge":return"Bridge match";case"native-compatible":return"Native path";case"copilot-alias":return"Copilot alias";default:return t.replace(/-/g," ")}}function y(t){return"border-border/50 bg-background/40"}function Fe(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 Oe(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 Ke(t,a){return a.nativeReadPreference?t%2===0?"bg-emerald-500/[0.06]":"bg-emerald-500/[0.08]":t%2===0?"bg-background/75":"bg-muted/18"}function Le(t){const a=[`${t.activeProfileCount} routed`,`${t.nativeProfileCount} native`];return t.mappedProfileCount>0&&a.push(`${t.mappedProfileCount} override${t.mappedProfileCount===1?"":"s"}`),a.join(" · ")}function Ve(t){return Object.entries(t).reduce((a,[l,g])=>{const j=g.trim();return a[l]=j||null,a},{})}function q(t){return Object.entries(t).filter(([,a])=>a.trim().length>0).map(([a])=>a)}function Ue(t){return t.reduce((a,l)=>{const g=l.profileName.trim();return!g||!l.backendId||(a[g]=l.backendId),a},{})}function ge(t,a){const l=Number.parseInt(t.trim(),10);return Number.isInteger(l)?String(Math.min(600,Math.max(10,l))):a}function T({title:t,description:a,icon:l,meta:g,action:j,children:o,className:D}){return e.jsxs("div",{className:u("relative overflow-hidden rounded-2xl border bg-gradient-to-br from-background via-background to-muted/25 p-4 shadow-sm",D),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:l}),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}),g]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-muted-foreground",children:a})]})]}),j&&e.jsx("div",{className:"shrink-0",children:j})]}),e.jsx("div",{className:"space-y-3",children:o})]})]})}function er(){const{fetchRawConfig:t}=je(),[a,l]=d.useState(null),[g,j]=d.useState(!0),[o,D]=d.useState(!1),[I,N]=d.useState(null),[S,K]=d.useState(null),[E,Y]=d.useState(!1),[_,Q]=d.useState(!0),[L,V]=d.useState("60"),[f,P]=d.useState(""),[k,$]=d.useState({}),[x,z]=d.useState([]),w=d.useCallback(r=>{Q(r.config.enabled),V(String(r.config.timeout)),P(r.config.fallbackBackend??""),$(r.catalog.knownBackends.reduce((s,n)=>(s[n]=r.config.providerModels[n]??"",s),{})),z(Te(r.config.profileBackends))},[]),U=d.useCallback(async()=>{try{j(!0),N(null);const r=await re.imageAnalysis.get();if(!Ae(r))throw new Error("Image settings returned an unexpected response. Restart the dashboard server so the new API route is available.");l(r),w(r)}catch(r){N(r instanceof Error?r.message:"Failed to load image settings.")}finally{j(!1)}},[w]);d.useEffect(()=>{U(),t()},[U,t]),d.useEffect(()=>{if(!S)return;const r=window.setTimeout(()=>K(null),2500);return()=>window.clearTimeout(r)},[S]),d.useEffect(()=>{a&&Object.keys(a.config.profileBackends).length>0&&Y(!0)},[a]);const m=d.useMemo(()=>q(k),[k]),W=d.useMemo(()=>{if(!a)return[];const r=a.catalog.knownBackends.filter(n=>m.includes(n)),s=a.catalog.knownBackends.filter(n=>!m.includes(n));return[...r,...s]},[m,a]),F=d.useMemo(()=>a?.profiles.filter(r=>r.nativeReadPreference)??[],[a]);d.useEffect(()=>{if(m.length===0){P("");return}m.includes(f)||P(m[0])},[m,f]);const R=d.useCallback(async r=>{if(!a)return!1;const s=r?.enabled??_,n=r?.providerModels??k,i=q(n),b=ge(r?.timeout??L,String(a.config.timeout)),h=r?.fallbackBackend??f,C=i.length===0?"":i.includes(h)?h:i[0],p=r?.mappingDrafts??x,A={enabled:s,timeout:b,fallbackBackend:C,providerModels:Ve(n),profileBackends:Ue(p)},ve={enabled:a.config.enabled,timeout:String(a.config.timeout),fallbackBackend:a.config.fallbackBackend??"",providerModels:a.catalog.knownBackends.reduce((v,ee)=>(v[ee]=a.config.providerModels[ee]??null,v),{}),profileBackends:a.config.profileBackends};if(JSON.stringify(A)===JSON.stringify(ve))return!0;if(s&&i.length===0)return N("Keep at least one provider model configured, or disable Image globally."),w(a),!1;try{D(!0),N(null);const v=await re.imageAnalysis.update({enabled:s,timeout:Number.parseInt(b,10),fallbackBackend:C||null,providerModels:A.providerModels,profileBackends:A.profileBackends});return l(v),w(v),K("Image settings saved."),await t(),!0}catch(v){return N(v instanceof Error?v.message:"Failed to save image settings."),w(a),!1}finally{D(!1)}},[a,_,f,t,w,x,k,L]),X=async()=>{g||o||(K(null),await Promise.all([U(),t()]))},xe=async r=>{if(!o){if(r&&m.length===0){N("Keep at least one provider model configured, or disable Image globally.");return}Q(r),await R({enabled:r})}},be=async r=>{if(!a||o)return;const s=ge(r,String(a.config.timeout));V(s),await R({timeout:s})},pe=async r=>{o||(P(r),await R({fallbackBackend:r}))},Z=async(r,s)=>{if(!a||o)return;const n=s.trim(),i={...k,[r]:n},b=q(i);if(_&&b.length===0){N("Disable Image first or keep one backend configured."),$(C=>({...C,[r]:a.config.providerModels[r]??""}));return}const h=b.length===0?"":b.includes(f)?f:b[0];$(i),P(h),await R({providerModels:i,fallbackBackend:h})},fe=(r,s)=>{z(n=>n.map(i=>i.id===r?{...i,...s}:i))},H=async r=>{o||(z(r),await R({mappingDrafts:r}))},he=x.filter(r=>r.profileName.trim()&&r.backendId).length;return g?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(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading image settings..."})]})}):a?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||S?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[I&&e.jsxs(ae,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I})]}),S&&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(ke,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:S})]})]}),e.jsx(Ne,{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(oe,{className:"h-4 w-4"})}),e.jsx("p",{className:"text-sm font-semibold tracking-tight",children:"Image"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(c,{className:u("border",De(a.summary.state)),children:a.summary.title}),e.jsx("span",{children:Le(a.summary)})]})]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:X,disabled:g||o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(J,{className:`h-4 w-4 ${g?"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:a.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:a.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:"Global toggle, timeout, and fallback.",icon:e.jsx(we,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-amber-500/25 bg-amber-500/10 text-[10px]",children:[m.length," configured"]}),children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-3",children:[e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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:_?"Transformer on":"Transformer off"}),e.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Profile flags stay untouched."})]}),e.jsx(ye,{checked:_,onCheckedChange:r=>{xe(r)},disabled:o})]})]}),e.jsxs("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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(G,{value:L,onChange:r=>V(r.target.value),inputMode:"numeric",className:"h-10 border-amber-500/15 bg-background/90 text-base",disabled:o,onBlur:r=>{be(r.currentTarget.value)},onKeyDown:r=>{r.key==="Enter"&&r.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:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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(se,{value:f||M,onValueChange:r=>{pe(r===M?"":r)},disabled:o,children:[e.jsx(ne,{className:"h-10 border-amber-500/15 bg-background/90",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(O,{value:M,children:"Configure a model first"}):m.map(r=>e.jsx(O,{value:r,children:r},r))})]})}),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:[he," 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:[F.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:[f||"No fallback"," fallback"]})]})]}),e.jsx(T,{tone:"cyan",eyebrow:"Route inventory",title:"Backend routes",description:"Model entry plus route health.",icon:e.jsx(Ce,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",className:"border-cyan-500/25 bg-cyan-500/10 text-[10px]",children:[W.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:W.map((r,s)=>{const n=a.backends.find(p=>p.backendId===r),i=n?.displayName||r,b=k[r]??"",h=$e(n),C=b?[`${n?.profilesUsing??0} active`,n?.authReadiness==="missing"?"auth missing":n?.proxyReadiness==="stopped"?"starts on launch":null].filter(Boolean).join(" · "):"No model configured.";return e.jsxs("div",{className:u("relative px-3 py-3 md:px-4",s>0&&"border-t border-cyan-500/10",Fe(n?.state)),children:[e.jsx("div",{className:u("absolute bottom-3 left-0 top-3 w-1 rounded-r-full bg-gradient-to-b",Oe(n?.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:i}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r}),n?.profilesUsing?e.jsxs(c,{variant:"outline",className:"border-cyan-500/20 bg-cyan-500/10 text-[10px]",children:[n.profilesUsing," active"]}):null]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-4 text-muted-foreground",children:C})]}),e.jsx(c,{className:u("border",n?Ie(n.state):"border-border/80 bg-background/85 text-muted-foreground"),children:n?Ee(n.state):"Inactive"})]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx(G,{className:"h-10 flex-1 border-cyan-500/15 bg-background/88 text-base",placeholder:"Set model",value:b,disabled:o,onChange:p=>$(A=>({...A,[r]:p.target.value})),onBlur:p=>{Z(r,p.currentTarget.value)},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()}}),b.trim().length>0&&e.jsx(B,{type:"button",variant:"outline",size:"sm",className:"h-10 sm:self-stretch",disabled:o,onClick:()=>{Z(r,"")},children:"Clear"})]}),h&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-4 text-muted-foreground",children:h})]})]},r)})})}),e.jsx(T,{tone:"emerald",eyebrow:"Native path",title:"Native reading",description:"Profiles that skip the transformer.",icon:e.jsx(Be,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[F.length," profiles"]}),children:F.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No profiles prefer native reading yet."}):e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:F.map(r=>e.jsx("div",{className:u("rounded-[18px] border px-3.5 py-3 shadow-sm",y()),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:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.nativeImageCapable?"Verified":"Review"})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:[r.profileModel||"Model not detected"," ·"," ",r.nativeImageReason||"Native read preferred."]})]}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})},`native-${r.kind}-${r.name}`))})}),e.jsxs(T,{tone:"slate",eyebrow:"Override lab",title:"Profile routing",description:"Only for explicit route overrides.",icon:e.jsx(Re,{className:"h-4 w-4"}),meta:e.jsx(c,{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(B,{type:"button",variant:"outline",size:"sm",onClick:()=>Y(r=>!r),children:[E?e.jsx(Se,{className:"mr-1 h-4 w-4"}):e.jsx(_e,{className:"mr-1 h-4 w-4"}),E?"Hide":"Show"]}),E&&e.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>z(r=>[...r,{id:`mapping-${Date.now()}`,profileName:"",backendId:m[0]??""}]),disabled:m.length===0||o,children:[e.jsx(Pe,{className:"mr-1 h-4 w-4"}),"Add mapping"]})]}),className:"border-dashed",children:[e.jsx("datalist",{id:"image-profile-suggestions",children:a.catalog.profileNames.map(r=>e.jsx("option",{value:r},r))}),E?e.jsx("div",{className:"space-y-2",children:x.length===0?e.jsx("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3.5 text-sm text-muted-foreground",y()),children:"No explicit overrides saved."}):e.jsx("div",{className:"space-y-2",children:x.map(r=>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:"Direct override"}),!(r.profileName.trim()&&r.backendId)&&e.jsx(c,{variant:"outline",className:"text-[10px]",children:"Draft"})]}),e.jsxs(B,{type:"button",variant:"ghost",size:"sm",disabled:o,onClick:()=>{const s=x.filter(n=>n.id!==r.id);H(s)},children:[e.jsx(Me,{className:"mr-1 h-4 w-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(G,{value:r.profileName,list:"image-profile-suggestions",disabled:o,placeholder:"Profile or variant name",className:"h-10 border-slate-400/15 bg-background/88 text-base",onChange:s=>{fe(r.id,{profileName:s.target.value})},onBlur:s=>{const n=x.map(i=>i.id===r.id?{...i,profileName:s.currentTarget.value.trim()}:i);H(n)},onKeyDown:s=>{s.key==="Enter"&&s.currentTarget.blur()}}),e.jsxs(se,{value:r.backendId||M,disabled:o,onValueChange:s=>{const n=x.map(i=>i.id===r.id?{...i,backendId:s===M?"":s}:i);H(n)},children:[e.jsx(ne,{className:"h-10 border-slate-400/15 bg-background/88",children:e.jsx(ie,{placeholder:"Choose backend"})}),e.jsx(de,{children:m.length===0?e.jsx(O,{value:M,children:"Configure a model first"}):m.map(s=>e.jsx(O,{value:s,children:s},s))})]})]})]},r.id))})}):e.jsxs("div",{className:u("rounded-[18px] border border-dashed px-3.5 py-3 text-sm text-muted-foreground",y()),children:["Hidden by default.",x.length>0?` ${x.length} override${x.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(oe,{className:"h-4 w-4"}),meta:e.jsxs(c,{variant:"outline",children:[a.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:a.profiles.map((r,s)=>e.jsxs("div",{className:u("grid gap-2 px-3.5 py-2.5 md:grid-cols-[minmax(0,1fr)_auto] md:items-center",s>0&&"border-t border-slate-400/12",Ke(s,r)),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:r.name}),e.jsx(c,{variant:"outline",className:"text-[10px]",children:r.kind==="variant"?"Variant":"Profile"}),e.jsx(c,{variant:"outline",className:"font-mono text-[10px] uppercase",children:r.target}),r.nativeReadPreference&&e.jsx(c,{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:[r.backendDisplayName||r.profileModel||"Native file access"," ·"," ",ze(r.resolutionSource)]})]}),e.jsxs("div",{className:"flex items-center gap-2 md:justify-end",children:[r.profileModel&&e.jsx(c,{variant:"outline",className:"font-mono text-[10px]",children:r.profileModel}),e.jsx(c,{className:u("border",ue(r.currentTargetMode)),children:me(r.currentTargetMode)})]})]},`${r.kind}-${r.name}`))})})]})})]}):e.jsxs("div",{className:"p-5",children:[e.jsxs(ae,{variant:"destructive",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(te,{children:I??"Failed to load image settings."})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(B,{variant:"outline",size:"sm",onClick:X,children:[e.jsx(J,{className:"mr-1 h-4 w-4"}),"Retry"]})})]})}export{er as default};