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

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 (49) hide show
  1. package/dist/commands/tokens-command.d.ts.map +1 -1
  2. package/dist/commands/tokens-command.js +26 -37
  3. package/dist/commands/tokens-command.js.map +1 -1
  4. package/dist/ui/assets/accounts-DamxGxu1.js +1 -0
  5. package/dist/ui/assets/{alert-dialog-CuN8HTEx.js → alert-dialog-sars2LJq.js} +1 -1
  6. package/dist/ui/assets/{api-CI8RoZ-m.js → api-DHF10LeP.js} +1 -1
  7. package/dist/ui/assets/{auth-section-C49fRTna.js → auth-section-BNmbrWhd.js} +1 -1
  8. package/dist/ui/assets/{backups-section-DeJGo6Co.js → backups-section-DGURGm2o.js} +1 -1
  9. package/dist/ui/assets/channels-B0j9pbpo.js +1 -0
  10. package/dist/ui/assets/{checkbox-DVHcE1RO.js → checkbox-DQIFU7Wu.js} +1 -1
  11. package/dist/ui/assets/claude-extension-qxiVTjYL.js +1 -0
  12. package/dist/ui/assets/{cliproxy-BQuYNZ_b.js → cliproxy-CdvU0y2i.js} +1 -1
  13. package/dist/ui/assets/{cliproxy-ai-providers-Bjx7XtY6.js → cliproxy-ai-providers-zgUBcUcJ.js} +1 -1
  14. package/dist/ui/assets/{cliproxy-control-panel-DoLho1iE.js → cliproxy-control-panel-S6FdJjgh.js} +1 -1
  15. package/dist/ui/assets/codex-B79sHpGl.js +27 -0
  16. package/dist/ui/assets/{confirm-dialog-D_5v8muu.js → confirm-dialog-DwrX5gr_.js} +1 -1
  17. package/dist/ui/assets/{copilot-B4waN1q6.js → copilot-CgE4vyvS.js} +1 -1
  18. package/dist/ui/assets/{cursor-DHHZs05u.js → cursor-rYsOav5G.js} +1 -1
  19. package/dist/ui/assets/{droid-CZePX0Pf.js → droid-CQlRU59Q.js} +1 -1
  20. package/dist/ui/assets/{globalenv-section-nQDFHMda.js → globalenv-section-DSQ3m4Ei.js} +1 -1
  21. package/dist/ui/assets/{health-BfS7V7RZ.js → health-DE-wdzdl.js} +1 -1
  22. package/dist/ui/assets/{index-EboJtDBz.js → index-BcJqrfhu.js} +1 -1
  23. package/dist/ui/assets/{index-C5CFzca_.js → index-BwtPYSbP.js} +1 -1
  24. package/dist/ui/assets/{index-CRiWOwLR.js → index-C5VFMOG4.js} +1 -1
  25. package/dist/ui/assets/index-CqJW-L_1.js +1 -0
  26. package/dist/ui/assets/{index-B9VMppQ3.js → index-D1jFmelj.js} +1 -1
  27. package/dist/ui/assets/index-g2g1k0QS.js +72 -0
  28. package/dist/ui/assets/{logs-GW0Oy6XF.js → logs-CDpci_AI.js} +1 -1
  29. package/dist/ui/assets/{masked-input-D1Ilmeh7.js → masked-input-DXzbXJrE.js} +1 -1
  30. package/dist/ui/assets/{proxy-status-widget-Bdh67BxQ.js → proxy-status-widget-DCQBVSBP.js} +1 -1
  31. package/dist/ui/assets/{raw-json-settings-editor-panel-DwzGE_kH.js → raw-json-settings-editor-panel-Db_WTo0f.js} +1 -1
  32. package/dist/ui/assets/{searchable-select-DbhlbNK0.js → searchable-select-CHzzY0Km.js} +1 -1
  33. package/dist/ui/assets/{separator-DziIoy6O.js → separator-Bd4OFZm5.js} +1 -1
  34. package/dist/ui/assets/{shared-XJ2EhJPB.js → shared-B8K097LC.js} +1 -1
  35. package/dist/ui/assets/{table-D5bWyv-8.js → table-7IypCMku.js} +1 -1
  36. package/dist/ui/assets/updates-4X5hHhUg.js +1 -0
  37. package/dist/ui/index.html +1 -1
  38. package/package.json +1 -1
  39. package/dist/ui/assets/accounts-D7sfwYrK.js +0 -1
  40. package/dist/ui/assets/channels-CEHW5H6N.js +0 -1
  41. package/dist/ui/assets/claude-extension-CLmICnx_.js +0 -1
  42. package/dist/ui/assets/codex-BDfvFO8E.js +0 -27
  43. package/dist/ui/assets/index-BDfXfBTa.js +0 -72
  44. package/dist/ui/assets/index-yt8jgaSK.js +0 -1
  45. package/dist/ui/assets/updates-ClhhaqwU.js +0 -1
  46. package/scripts/github/build-ai-review-packet.mjs +0 -242
  47. package/scripts/github/normalize-ai-review-output.mjs +0 -934
  48. package/scripts/github/prepare-ai-review-scope.mjs +0 -324
  49. package/scripts/github/run-ai-review-direct.mjs +0 -349
@@ -1 +1 @@
1
- {"version":3,"file":"tokens-command.d.ts","sourceRoot":"","sources":["../../src/commands/tokens-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsDH;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAgIzE"}
1
+ {"version":3,"file":"tokens-command.d.ts","sourceRoot":"","sources":["../../src/commands/tokens-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsDH;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqHzE"}
@@ -55,21 +55,18 @@ async function showAuthStatus(showUnmasked) {
55
55
  */
56
56
  async function handleTokensCommand(args) {
57
57
  await (0, ui_1.initUI)();
58
- // Parse flags
59
58
  const showFlag = args.includes('--show');
60
59
  const resetFlag = args.includes('--reset');
61
60
  const regenerateSecretFlag = args.includes('--regenerate-secret');
62
61
  const helpFlag = args.includes('--help') || args.includes('-h');
63
- // Find --api-key value
64
62
  const apiKeyIndex = args.indexOf('--api-key');
63
+ const hasApiKeyFlag = apiKeyIndex !== -1;
65
64
  const apiKeyValue = apiKeyIndex !== -1 ? args[apiKeyIndex + 1] : undefined;
66
- // Find --secret value
67
65
  const secretIndex = args.indexOf('--secret');
66
+ const hasSecretFlag = secretIndex !== -1;
68
67
  const secretValue = secretIndex !== -1 ? args[secretIndex + 1] : undefined;
69
- // Find --variant value
70
68
  const variantIndex = args.indexOf('--variant');
71
69
  const variantValue = variantIndex !== -1 ? args[variantIndex + 1] : undefined;
72
- // Help
73
70
  if (helpFlag) {
74
71
  console.log((0, ui_1.header)('CCS Tokens Management'));
75
72
  console.log('');
@@ -101,37 +98,38 @@ async function handleTokensCommand(args) {
101
98
  console.log('');
102
99
  return 0;
103
100
  }
104
- // Reset to defaults
105
101
  if (resetFlag) {
106
102
  (0, cliproxy_1.resetAuthToDefaults)();
107
- // Regenerate CLIProxy config to apply changes
108
103
  (0, config_generator_1.regenerateConfig)();
109
104
  console.log((0, ui_1.ok)('Auth tokens reset to defaults'));
110
105
  console.log((0, ui_1.info)('CLIProxy config regenerated'));
111
106
  return 0;
112
107
  }
113
- // Regenerate management secret
108
+ if (regenerateSecretFlag && hasSecretFlag) {
109
+ console.error((0, ui_1.fail)('Cannot combine --secret with --regenerate-secret'));
110
+ return 1;
111
+ }
112
+ if (hasApiKeyFlag && (!apiKeyValue || apiKeyValue.startsWith('-'))) {
113
+ console.error((0, ui_1.fail)('Missing value for --api-key'));
114
+ return 1;
115
+ }
116
+ if (hasSecretFlag && (!secretValue || secretValue.startsWith('-'))) {
117
+ console.error((0, ui_1.fail)('Missing value for --secret'));
118
+ return 1;
119
+ }
120
+ let updated = false;
114
121
  if (regenerateSecretFlag) {
115
122
  const newSecret = (0, cliproxy_1.generateSecureToken)(32);
116
123
  (0, cliproxy_1.setGlobalManagementSecret)(newSecret);
117
- // Regenerate CLIProxy config to apply changes
118
- (0, config_generator_1.regenerateConfig)();
119
124
  console.log((0, ui_1.ok)('New management secret generated'));
120
125
  console.log(` Secret: ${(0, cliproxy_1.maskToken)(newSecret)}`);
121
- console.log((0, ui_1.info)('CLIProxy config regenerated'));
122
- console.log((0, ui_1.warn)('Restart CLIProxy to apply: ccs cliproxy restart'));
123
- return 0;
126
+ updated = true;
124
127
  }
125
- // Set API key
126
- if (apiKeyValue !== undefined) {
127
- if (!apiKeyValue || apiKeyValue.startsWith('-')) {
128
- console.error((0, ui_1.fail)('Missing value for --api-key'));
129
- return 1;
130
- }
128
+ if (hasApiKeyFlag) {
129
+ const resolvedApiKey = apiKeyValue;
131
130
  if (variantValue) {
132
- // Per-variant API key
133
131
  try {
134
- (0, cliproxy_1.setVariantApiKey)(variantValue, apiKeyValue);
132
+ (0, cliproxy_1.setVariantApiKey)(variantValue, resolvedApiKey);
135
133
  console.log((0, ui_1.ok)(`API key set for variant '${variantValue}'`));
136
134
  }
137
135
  catch (err) {
@@ -141,31 +139,22 @@ async function handleTokensCommand(args) {
141
139
  }
142
140
  }
143
141
  else {
144
- // Global API key
145
- (0, cliproxy_1.setGlobalApiKey)(apiKeyValue);
142
+ (0, cliproxy_1.setGlobalApiKey)(resolvedApiKey);
146
143
  console.log((0, ui_1.ok)('Global API key updated'));
147
144
  }
148
- // Regenerate CLIProxy config to apply changes
149
- (0, config_generator_1.regenerateConfig)();
150
- console.log((0, ui_1.info)('CLIProxy config regenerated'));
151
- console.log((0, ui_1.warn)('Restart CLIProxy to apply: ccs cliproxy restart'));
152
- return 0;
145
+ updated = true;
153
146
  }
154
- // Set management secret
155
- if (secretValue !== undefined) {
156
- if (!secretValue || secretValue.startsWith('-')) {
157
- console.error((0, ui_1.fail)('Missing value for --secret'));
158
- return 1;
159
- }
147
+ if (hasSecretFlag) {
160
148
  (0, cliproxy_1.setGlobalManagementSecret)(secretValue);
161
- // Regenerate CLIProxy config to apply changes
162
- (0, config_generator_1.regenerateConfig)();
163
149
  console.log((0, ui_1.ok)('Management secret updated'));
150
+ updated = true;
151
+ }
152
+ if (updated) {
153
+ (0, config_generator_1.regenerateConfig)();
164
154
  console.log((0, ui_1.info)('CLIProxy config regenerated'));
165
155
  console.log((0, ui_1.warn)('Restart CLIProxy to apply: ccs cliproxy restart'));
166
156
  return 0;
167
157
  }
168
- // Default: show status
169
158
  await showAuthStatus(showFlag);
170
159
  return 0;
171
160
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tokens-command.js","sourceRoot":"","sources":["../../src/commands/tokens-command.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,oCAA0F;AAC1F,0CAQqB;AACrB,mEA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,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,IAAA,oCAAyB,EAAC,WAAW,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,IAAA,OAAE,EAAC,2BAA2B,CAAC,CAAC,CAAC;QAC7C,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,IAAA,mCAAgB,GAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,IAAA,SAAI,EAAC,6BAA6B,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,IAAA,SAAI,EAAC,iDAAiD,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,CAAC;AACX,CAAC;AArHD,kDAqHC"}
@@ -0,0 +1 @@
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as C,h as ve}from"./react-vendor-CNOkPC89.js";import{u as Ce,a as $,b as F,e as ke,f as ee,g as we}from"./tanstack-CrmUhA7Z.js";import{T as Pe,a as Ae,b as te,c as De,d as _e,e as Te}from"./table-7IypCMku.js";import{a as P,Y as z,ag as de,ah as ue,ai as xe,aj as me,ak as he,L as S,I as V,x as _,aC as Se,d as b,B as A,C as O,b as R,e as Ge,f as Me,g as Oe,n as Re,j as I,k as q,_ as Q}from"./index-g2g1k0QS.js";import{A as ze,a as $e,b as Fe,c as Le,d as Ke,e as He,f as Ie,g as qe}from"./alert-dialog-sars2LJq.js";import{t as k}from"./notifications-B2HqRBj7.js";import{b0 as W,b1 as E,b2 as pe,aG as ge,_ as fe,b3 as Ee,b4 as Ue,m as Y,as as Be,Q as Qe,a6 as U,T as J,x as Ze,$ as Xe,o as se,U as Ve,a9 as ae,Z as ne}from"./icons-KVCk4_U8.js";import{C as re}from"./checkbox-DQIFU7Wu.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Z(a){return Array.from(a).sort((c,t)=>c.localeCompare(t))}function We(a){const c=new Map;for(const n of a){if(n.context_mode!=="shared")continue;const p=n.context_group||"default",m=c.get(p)??{group:p,sharedCount:0,deeperCount:0,accountNames:[]};m.sharedCount+=1,m.accountNames.push(n.name),n.continuity_mode==="deeper"&&(m.deeperCount+=1),c.set(p,m)}const t=Array.from(c.values()).sort((n,p)=>n.group.localeCompare(p.group)),o=a.map(n=>{if(n.context_mode!=="shared")return{...n,sameGroupPeerCount:0,sameGroupDeeperPeerCount:0};const p=n.context_group||"default",m=c.get(p),y=Math.max((m?.sharedCount??1)-1,0),x=Math.max((m?.deeperCount??0)-(n.continuity_mode==="deeper"?1:0),0);return{...n,sameGroupPeerCount:y,sameGroupDeeperPeerCount:x}}),s=o.filter(n=>n.context_mode==="shared").length,u=o.filter(n=>n.context_mode==="shared"&&n.continuity_mode==="deeper").length,l=o.filter(n=>n.context_inferred).length,h=o.filter(n=>n.context_mode==="shared"&&n.continuity_mode!=="deeper"&&n.continuity_inferred).length;return{accounts:o,sharedCount:s,sharedStandardCount:Math.max(s-u,0),deeperSharedCount:u,isolatedCount:o.length-s,legacyContextCount:l,legacyContinuityCount:h,sharedAloneCount:o.filter(n=>n.context_mode==="shared"&&n.sameGroupPeerCount===0).length,sharedPeerAccountCount:o.filter(n=>n.sameGroupPeerCount>0).length,deeperReadyAccountCount:o.filter(n=>n.continuity_mode==="deeper"&&n.sameGroupDeeperPeerCount>0).length,sharedPeerGroups:Z(t.filter(n=>n.sharedCount>=2).map(n=>n.group)),deeperReadyGroups:Z(t.filter(n=>n.deeperCount>=2).map(n=>n.group)),sharedGroups:Z(t.map(n=>n.group)),groupSummaries:t}}function Ye(){return Ce({queryKey:["accounts"],queryFn:()=>z.accounts.list(),select:a=>{const c=a.accounts.filter(u=>u.type!=="cliproxy"),t=We(c),o=a.accounts.length-c.length,s=t.accounts.some(u=>u.name===a.default)?a.default:null;return{accounts:t.accounts,default:s,cliproxyCount:o,legacyContextCount:t.legacyContextCount,legacyContinuityCount:t.legacyContinuityCount,sharedCount:t.sharedCount,sharedStandardCount:t.sharedStandardCount,deeperSharedCount:t.deeperSharedCount,isolatedCount:t.isolatedCount,sharedAloneCount:t.sharedAloneCount,sharedPeerAccountCount:t.sharedPeerAccountCount,deeperReadyAccountCount:t.deeperReadyAccountCount,sharedPeerGroups:t.sharedPeerGroups,deeperReadyGroups:t.deeperReadyGroups,sharedGroups:t.sharedGroups,groupSummaries:t.groupSummaries,plainCcsLane:a.plain_ccs_lane??null}}})}function Je(){const a=$(),{t:c}=P();return F({mutationFn:t=>z.accounts.setDefault(t),onSuccess:(t,o)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(c("toasts.defaultAccountSet",{name:o}))},onError:t=>{k.error(t.message)}})}function et(){const a=$(),{t:c}=P();return F({mutationFn:()=>z.accounts.resetDefault(),onSuccess:()=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(c("toasts.defaultAccountReset"))},onError:t=>{k.error(t.message)}})}function tt(){const a=$(),{t:c}=P();return F({mutationFn:t=>z.accounts.delete(t),onSuccess:(t,o)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(c("toasts.accountDeleted",{name:o}))},onError:t=>{k.error(t.message)}})}function be(){const a=$(),{t:c}=P();return F({mutationFn:({name:t,context_mode:o,context_group:s,continuity_mode:u})=>z.accounts.updateContext(t,{context_mode:o,context_group:s,continuity_mode:u}),onSuccess:(t,o)=>{a.invalidateQueries({queryKey:["accounts"]});const s=(o.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-"),u=o.context_mode==="shared"?o.continuity_mode==="deeper"?`${c("accountsPage.sharedDeeper")} (${s})`:`${c("accountsPage.sharedStandard")} (${s})`:c("accountsPage.isolated");k.success(c("toasts.contextUpdated",{name:o.name,summary:u}))},onError:t=>{k.error(t.message)}})}function st(){const a=$(),{t:c}=P();return F({mutationFn:async t=>{const o=t.filter(l=>l.context_inferred||l.continuity_inferred),u=(await Promise.allSettled(o.map(l=>{const h=l.context_mode==="shared";return z.accounts.updateContext(l.name,{context_mode:h?"shared":"isolated",context_group:h?l.context_group||"default":void 0,continuity_mode:h?l.continuity_mode==="deeper"?"deeper":"standard":void 0})}))).filter(l=>l.status==="rejected").length;return{updatedCount:o.length-u,failedCount:u}},onSuccess:({updatedCount:t,failedCount:o})=>{if(a.invalidateQueries({queryKey:["accounts"]}),o>0&&t>0){k.error(c("toasts.legacyConfirmPartial",{updated:t,failed:o}));return}if(o>0){k.error(c("toasts.legacyConfirmAllFailed",{failed:o}));return}if(t>0){k.success(c("toasts.legacyConfirmSuccess",{count:t}));return}k.info(c("toasts.noLegacyAccounts"))},onError:t=>{a.invalidateQueries({queryKey:["accounts"]}),k.error(t.message)}})}const oe=64,at=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function nt({account:a,groupSummaries:c,plainCcsLane:t,onClose:o}){const{t:s}=P(),u=be(),[l,h]=C.useState(a.context_mode==="shared"?"shared":"isolated"),[n,p]=C.useState(a.context_group||"default"),[m,y]=C.useState(a.continuity_mode==="deeper"?"deeper":"standard"),x=C.useMemo(()=>n.trim().toLowerCase().replace(/\s+/g,"-"),[n]),i=C.useMemo(()=>c.find(g=>g.group===x),[c,x]),N=x.length>0&&x.length<=oe&&at.test(x),r=l==="isolated"||N,d=l==="shared"?Math.max((i?.sharedCount??0)-(a.context_mode==="shared"&&a.context_group===x?1:0),0):0,f=l==="shared"?Math.max((i?.deeperCount??0)-(a.continuity_mode==="deeper"&&a.context_group===x?1:0),0):0,v=t?.account_name===a.name,j=!!t&&!v,G=`ccs auth default ${a.name}`,T=`ccs auth backup ${a.name}`,w=(g,K,M,H)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(g.key))return;g.preventDefault();const je=M.indexOf(K),ye=g.key==="ArrowLeft"||g.key==="ArrowUp"?-1:1,Ne=(je+ye+M.length)%M.length;H(M[Ne])},L=t?t.kind==="native"?s("continuityOverview.lane.native"):t.kind==="account-default"?s("continuityOverview.lane.accountDefault",{name:t.account_name||""}):t.kind==="account-inherited"?s("continuityOverview.lane.accountInherited",{name:t.account_name||""}):t.kind==="profile-default"?s("continuityOverview.lane.profileDefault",{name:t.profile_name||"default"}):t.label:"",D=()=>{r&&u.mutate({name:a.name,context_mode:l,context_group:l==="shared"?x:void 0,continuity_mode:l==="shared"?m:void 0},{onSuccess:()=>{o()}})},B=g=>{g||o()};return e.jsx(de,{open:!0,onOpenChange:B,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(xe,{children:[e.jsx(me,{children:s("editAccountContext.title")}),e.jsx(he,{children:s("editAccountContext.description",{name:a.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(S,{className:"text-sm font-semibold",children:s("editAccountContext.syncMode")})}),e.jsxs("div",{className:"flex p-0.5 bg-muted/60 hover:bg-muted/80 transition-colors rounded-xl border border-border/40 w-full",role:"radiogroup","aria-label":s("editAccountContext.syncMode"),children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":l==="isolated",tabIndex:l==="isolated"?0:-1,onClick:()=>h("isolated"),onKeyDown:g=>w(g,l,["isolated","shared"],h),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${l==="isolated"?"bg-background text-blue-600 dark:text-blue-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(W,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.isolatedOption")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":l==="shared",tabIndex:l==="shared"?0:-1,onClick:()=>h("shared"),onKeyDown:g=>w(g,l,["isolated","shared"],h),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${l==="shared"?"bg-background text-emerald-600 dark:text-emerald-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:s(l==="isolated"?"editAccountContext.isolatedModeHint":"editAccountContext.sharedModeHint")})]}),l==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"context-group",children:s("editAccountContext.historySyncGroup")}),e.jsx(V,{id:"context-group",value:n,onChange:g=>p(g.target.value),placeholder:s("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("editAccountContext.groupHint",{max:oe})}),!N&&e.jsx("p",{className:"text-xs text-destructive",children:s("editAccountContext.invalidGroup")})]}),l==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(S,{className:"text-sm font-semibold",children:s("editAccountContext.continuityDepth")})}),e.jsxs("div",{className:"flex p-0.5 bg-muted/60 hover:bg-muted/80 transition-colors rounded-xl border border-border/40 w-full",role:"radiogroup","aria-label":s("editAccountContext.continuityDepth"),children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":m==="standard",tabIndex:m==="standard"?0:-1,onClick:()=>y("standard"),onKeyDown:g=>w(g,m,["standard","deeper"],y),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${m==="standard"?"bg-background text-emerald-600 dark:text-emerald-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.standardOption")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":m==="deeper",tabIndex:m==="deeper"?0:-1,onClick:()=>y("deeper"),onKeyDown:g=>w(g,m,["standard","deeper"],y),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${m==="deeper"?"bg-background text-indigo-600 dark:text-indigo-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(pe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:s(m==="standard"?"editAccountContext.standardHint":"editAccountContext.deeperHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("editAccountContext.credentialsIsolated")}),j&&e.jsx("div",{className:"rounded-[14px] border border-amber-200 bg-amber-50/50 p-4 text-xs shadow-sm dark:border-amber-900/40 dark:bg-amber-900/10",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:s("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:s("continuityOverview.plainLaneDescription",{lane:L||"plain ccs",name:a.name})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs -r"}),e.jsx(_,{value:"ccs -r",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth backup default"}),e.jsx(_,{value:"ccs auth backup default",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:T}),e.jsx(_,{value:T,size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:G}),e.jsx(_,{value:G,size:"icon"})]})]})]})}),e.jsx("div",{className:`rounded-[14px] border p-4 text-xs shadow-sm transition-colors ${l==="isolated"?"bg-blue-50/50 border-blue-200 dark:bg-blue-900/10 dark:border-blue-800/40":"bg-muted/40 border-border/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[l==="isolated"?e.jsx(ge,{className:"h-4 w-4 text-blue-500 mt-0.5 shrink-0"}):e.jsx(fe,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1.5 flex-1 text-muted-foreground leading-relaxed",children:[l==="isolated"?e.jsx("p",{className:"text-foreground font-medium selection:bg-blue-200",children:s("editAccountContext.isolatedImplication")}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-foreground font-medium",children:s("editAccountContext.sameGroupRule",{group:x})})," ",d>0?s("editAccountContext.sameGroupPeerCount",{count:d}):s("editAccountContext.noSameGroupPeer")]}),m==="deeper"&&e.jsx("p",{children:f>0?s("editAccountContext.deeperReady",{count:f}):e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:s("editAccountContext.deeperNeedsPeers")})})]}),e.jsx("p",{className:`pt-1.5 text-[11px] ${l==="isolated"?"text-blue-700/70 dark:text-blue-300/60":"text-muted-foreground/70"}`,children:s("editAccountContext.resumeOriginalWarning")})]})]})})]}),e.jsxs(Se,{children:[e.jsx(b,{variant:"outline",onClick:o,disabled:u.isPending,children:s("editAccountContext.cancel")}),e.jsx(b,{onClick:D,disabled:!r||u.isPending,children:u.isPending?s("editAccountContext.saving"):s("editAccountContext.save")})]})]})})}function ce({data:a,defaultAccount:c,groupSummaries:t,plainCcsLane:o}){const{t:s}=P(),u=Je(),l=tt(),h=et(),n=be(),[p,m]=C.useState(null),[y,x]=C.useState(null),i=[{accessorKey:"name",header:s("accountsTable.name"),size:200,cell:({row:r})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:r.original.name}),r.original.name===c&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:s("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:s("accountsTable.type"),size:100,cell:({row:r})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:r.original.type||"oauth"})},{accessorKey:"created",header:s("accountsTable.created"),size:150,cell:({row:r})=>{const d=new Date(r.original.created);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{accessorKey:"last_used",header:s("accountsTable.lastUsed"),size:150,cell:({row:r})=>{if(!r.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const d=new Date(r.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{id:"context",header:s("accountsTable.historySync"),size:170,cell:({row:r})=>{if(r.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((r.original.context_mode||"isolated")==="shared"){const f=r.original.context_group||"default",v=r.original.continuity_mode==="deeper";return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(A,{variant:"outline",className:`font-mono text-[10px] uppercase px-1.5 py-0 border ${v?"text-indigo-700 border-indigo-300/60 bg-indigo-50/50 dark:text-indigo-300 dark:border-indigo-900/40 dark:bg-indigo-900/20":"text-emerald-700 border-emerald-300/60 bg-emerald-50/50 dark:text-emerald-300 dark:border-emerald-900/40 dark:bg-emerald-900/20"}`,children:s(v?"accountsTable.badges.deeper":"accountsTable.badges.shared")}),e.jsx("span",{className:"text-xs font-semibold text-foreground/80",children:f})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:r.original.sameGroupPeerCount>0?s("accountsTable.sameGroupPeerCount",{count:r.original.sameGroupPeerCount}):s("accountsTable.noSameGroupPeer")})]})}return r.original.context_inferred?e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx(A,{variant:"outline",className:"text-amber-700 border-amber-300/60 bg-amber-50/50 dark:text-amber-400 dark:border-amber-900/40 dark:bg-amber-900/20 font-mono text-[10px] uppercase px-1.5 py-0",children:s("accountsTable.badges.legacy")}),e.jsx("p",{className:"text-[10px] text-amber-700/80 dark:text-amber-400/80 whitespace-nowrap",children:s("accountsTable.legacyReview")})]}):e.jsx("div",{className:"flex flex-col items-start gap-1.5",children:e.jsx(A,{variant:"secondary",className:"font-mono text-[10px] uppercase px-1.5 py-0 text-muted-foreground bg-muted/60 border-transparent shadow-none",children:s("accountsTable.badges.isolated")})})}},{id:"actions",header:s("accountsTable.actions"),size:220,cell:({row:r})=>{const d=r.original.name===c,f=u.isPending||l.isPending||n.isPending,v=r.original.type==="cliproxy",j=r.original.context_inferred||r.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!v&&e.jsxs(b,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:f,onClick:()=>x(r.original),title:s("accountsTable.syncTitle"),children:[e.jsx(Ee,{className:"w-3.5 h-3.5 mr-1"}),s("accountsTable.sync")]}),!v&&j&&e.jsxs(b,{variant:"ghost",size:"sm",className:"h-8 px-2 text-amber-700 hover:text-amber-700 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:text-amber-400",disabled:f,onClick:()=>n.mutate({name:r.original.name,context_mode:r.original.context_mode==="shared"?"shared":"isolated",context_group:r.original.context_mode==="shared"?r.original.context_group||"default":void 0,continuity_mode:r.original.context_mode==="shared"?r.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:s("accountsTable.confirmLegacyTitle"),children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),s("accountsTable.confirm")]}),e.jsxs(b,{variant:d?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:d||f,onClick:()=>u.mutate(r.original.name),children:[e.jsx(Y,{className:`w-3 h-3 mr-1 ${d?"opacity-50":""}`}),s(d?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(b,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:d||f,onClick:()=>m(r.original.name),title:s(d?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Be,{className:"w-4 h-4"})})]})}}],N=ke({data:a,columns:i,getCoreRowModel:we()});return a.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:s("accountsTable.noAccounts")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border rounded-md",children:e.jsxs(Pe,{children:[e.jsx(Ae,{children:N.getHeaderGroups().map(r=>e.jsx(te,{children:r.headers.map(d=>{const f={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[d.id]||"w-auto";return e.jsx(De,{className:f,children:d.isPlaceholder?null:ee(d.column.columnDef.header,d.getContext())},d.id)})},r.id))}),e.jsx(_e,{children:N.getRowModel().rows.map(r=>e.jsx(te,{children:r.getVisibleCells().map(d=>e.jsx(Te,{children:ee(d.column.columnDef.cell,d.getContext())},d.id))},r.id))})]})}),c&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>h.mutate(),disabled:h.isPending,children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),s("accountsTable.resetToDefault")]})})]}),y&&e.jsx(nt,{account:y,groupSummaries:t,plainCcsLane:o,onClose:()=>x(null)}),e.jsx(ze,{open:!!p,onOpenChange:r=>!r&&m(null),children:e.jsxs($e,{children:[e.jsxs(Fe,{children:[e.jsx(Le,{children:s("accountsTable.deleteDialogTitle")}),e.jsx(Ke,{children:s("accountsTable.deleteDialogDesc",{name:p??""})})]}),e.jsxs(He,{children:[e.jsx(Ie,{children:s("accountsTable.cancel")}),e.jsx(qe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{p&&(l.mutate(p),m(null))},children:s("accountsTable.delete")})]})]})})]})}const X=({titleKey:a,descKey:c})=>{const{t}=P();return e.jsxs(Ge,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"icon","aria-label":t(a),className:"h-5 w-5 rounded-full hover:bg-muted text-muted-foreground/70 transition-colors",children:e.jsx(fe,{className:"h-3 w-3"})})}),e.jsxs(Oe,{className:"w-72 p-4 rounded-xl shadow-lg border-border/50 text-sm",side:"top",align:"center",children:[e.jsx("p",{className:"font-semibold tracking-tight",children:t(a)}),e.jsx("p",{className:"mt-1.5 text-muted-foreground leading-relaxed",children:t(c)})]})]})};function le({totalAccounts:a,primaryAccountName:c,isolatedCount:t,sharedStandardCount:o,deeperSharedCount:s,sharedAloneCount:u,sharedPeerAccountCount:l,deeperReadyAccountCount:h,sharedPeerGroups:n,deeperReadyGroups:p,legacyTargetCount:m,cliproxyCount:y,plainCcsLane:x}){const{t:i}=P(),N=x?x.kind==="native"?i("continuityOverview.lane.native"):x.kind==="account-default"?i("continuityOverview.lane.accountDefault",{name:x.account_name||""}):x.kind==="account-inherited"?i("continuityOverview.lane.accountInherited",{name:x.account_name||""}):x.kind==="profile-default"?i("continuityOverview.lane.profileDefault",{name:x.profile_name||"default"}):x.label:"",r=a<2?"single":n.length===0?t===a?"isolated":"shared-alone":p.length===0?"shared-standard":t>0||u>0||h<l||p.length<n.length?"partial":"ready",d=p[0]||n[0]||"default",f=p.length>0&&(t>0||o>0||n.length>p.length),j={ready:e.jsx(Ze,{className:"h-6 w-6 text-emerald-600 dark:text-emerald-400"}),"shared-standard":e.jsx(E,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"}),single:e.jsx(ge,{className:"h-6 w-6 text-stone-400"}),isolated:e.jsx(W,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"}),"shared-alone":e.jsx(J,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"}),partial:e.jsx(J,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"})}[r],G=!!c&&x?.account_name===c,T=a>0&&!!x&&(!c||!G),w=a>1&&r!=="ready";return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(O,{className:"flex flex-col justify-between overflow-hidden relative group p-0 border-border bg-card shadow-sm hover:shadow-md transition-shadow duration-300",children:e.jsxs(R,{className:"p-6 flex flex-col h-full bg-gradient-to-br from-card to-muted/20 space-y-4",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-4",children:[e.jsx("div",{className:"rounded-2xl bg-background p-3 shadow-sm ring-1 ring-border/50 self-start shrink-0",children:j}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold tracking-tight",children:i(`continuityReadiness.messages.${r}.title`,{group:d})}),e.jsx(A,{variant:r==="ready"?"default":"secondary",className:"rounded-full px-2.5 py-0.5 font-medium shadow-sm",children:i(`continuityReadiness.state.${r}`)})]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg leading-relaxed",children:i(`continuityReadiness.messages.${r}.description`,{group:d,count:u})})]})]})}),e.jsxs("div",{className:"mt-auto pt-4 flex flex-wrap items-center gap-2",children:[y>0&&e.jsx(A,{variant:"outline",className:"text-blue-700 bg-blue-50/50 border-blue-200/60 dark:border-blue-900/40 dark:bg-blue-900/20 dark:text-blue-300",children:i("historySyncLearningMap.cliproxyManaged",{count:y})}),m>0&&e.jsx(A,{variant:"outline",className:"text-amber-700 bg-amber-50/50 border-amber-200/60 dark:border-amber-900/40 dark:bg-amber-900/20 dark:text-amber-300",children:i("historySyncLearningMap.legacyConfirmation",{count:m})}),n.length>0&&p.length===0&&e.jsx(A,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:i("continuityOverview.recommendBadge",{group:d})}),f&&e.jsx(A,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:i("continuityOverview.partialBadge",{group:d})})]})]})}),(T||w)&&e.jsx(O,{className:"border-dashed",children:e.jsxs(R,{className:"p-5 space-y-4",children:[T&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:i("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i("continuityOverview.plainLaneDescription",{lane:N||"plain ccs"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs -r"}),e.jsx(_,{value:"ccs -r",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth backup default"}),e.jsx(_,{value:"ccs auth backup default",size:"icon"})]}),c?e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:`ccs auth default ${c}`}),e.jsx(_,{value:`ccs auth default ${c}`,size:"icon"})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:i("continuityOverview.setDefaultHint")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:i("continuityReadiness.stepsTitle")}),e.jsxs("ol",{className:"space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:i("continuityReadiness.steps.syncBoth")}),e.jsx("li",{children:i("continuityReadiness.steps.sameGroup",{group:d})}),e.jsx("li",{children:i("continuityReadiness.steps.enableDeeper")}),e.jsx("li",{children:i("continuityReadiness.steps.resumeOriginal")})]})]})]})}),e.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3",children:[e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-blue-300/40 bg-blue-50/50 dark:border-blue-900/30 dark:bg-blue-900/10 shadow-sm transition-colors hover:bg-blue-100/40 dark:hover:bg-blue-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4 text-blue-700/80 dark:text-blue-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-blue-900 dark:text-blue-200",children:i("historySyncLearningMap.isolated")}),e.jsx(X,{titleKey:"accountsPage.isolated",descKey:"accountsPage.isolatedDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-blue-900 dark:text-blue-200",children:t})]}),e.jsx(U,{className:"hidden md:block h-4 w-4 text-muted-foreground/40 shrink-0"}),e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-emerald-300/40 bg-emerald-50/50 dark:border-emerald-900/30 dark:bg-emerald-900/10 shadow-sm transition-colors hover:bg-emerald-100/40 dark:hover:bg-emerald-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-4 w-4 text-emerald-700/80 dark:text-emerald-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-emerald-900 dark:text-emerald-200",children:i("historySyncLearningMap.shared")}),e.jsx(X,{titleKey:"accountsPage.sharedStandard",descKey:"accountsPage.sharedStandardDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-emerald-900 dark:text-emerald-200",children:o})]}),e.jsx(U,{className:"hidden md:block h-4 w-4 text-muted-foreground/40 shrink-0"}),e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-indigo-300/40 bg-indigo-50/50 dark:border-indigo-900/30 dark:bg-indigo-900/10 shadow-sm transition-colors hover:bg-indigo-100/40 dark:hover:bg-indigo-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"h-4 w-4 text-indigo-700/80 dark:text-indigo-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-indigo-900 dark:text-indigo-200",children:i("historySyncLearningMap.deeper")}),e.jsx(X,{titleKey:"accountsPage.sharedDeeper",descKey:"accountsPage.sharedDeeperDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-indigo-900 dark:text-indigo-200",children:s})]})]})]})}const ie=64;function rt({open:a,onClose:c}){const{t}=P(),[o,s]=C.useState(""),[u,l]=C.useState(!1),[h,n]=C.useState(""),[p,m]=C.useState(!1),[y,x]=C.useState(!1),i=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(o),N=h.trim().toLowerCase().replace(/\s+/g,"-"),r=N.length===0||N.length<=ie&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(N),d=o&&i?[`ccs auth create ${o}`,u?N.length>0?`--context-group ${N}`:"--share-context":"",u&&p?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),f=async()=>{!i||u&&!r||(await navigator.clipboard.writeText(d),x(!0),setTimeout(()=>x(!1),2e3))},v=()=>{s(""),l(!1),n(""),m(!1),x(!1),c()};return e.jsx(de,{open:a,onOpenChange:j=>!j&&v(),children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(xe,{children:[e.jsx(me,{children:t("createAuthProfileDialog.title")}),e.jsx(he,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx(V,{id:"profile-name",value:o,onChange:j=>s(j.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),o&&!i&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidProfileName")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{id:"share-context",checked:u,onCheckedChange:j=>l(j===!0)}),e.jsx(S,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),u&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(S,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx(V,{id:"context-group",value:h,onChange:j=>n(j.target.value),placeholder:t("createAuthProfileDialog.historySyncGroupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.historySyncGroupHint")}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(re,{id:"deeper-continuity",checked:p,onCheckedChange:j=>m(j===!0)}),e.jsx(S,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),h.trim().length>0&&!r&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:ie})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:t("createAuthProfileDialog.command")}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md font-mono text-sm",children:[e.jsx(Xe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:d}),e.jsx(b,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:f,disabled:!i||u&&!r,children:y?e.jsx(Y,{className:"w-4 h-4 text-green-500"}):e.jsx(se,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:t("createAuthProfileDialog.afterRunPrefix")}),e.jsxs("ol",{className:"list-decimal list-inside pl-2 space-y-0.5",children:[e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep1")}),e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep2")})]}),e.jsx("p",{className:"pt-1",children:t("createAuthProfileDialog.poolingHint")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{variant:"ghost",onClick:v,children:t("createAuthProfileDialog.close")}),e.jsx(b,{onClick:f,disabled:!i||u&&!r,children:y?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function bt(){const{t:a}=P(),c=ve(),{data:t,isLoading:o}=Ye(),s=st(),[u,l]=C.useState(!1),h=t?.accounts||[],n=t?.cliproxyCount||0,p=t?.legacyContextCount||0,m=t?.legacyContinuityCount||0,y=t?.sharedCount||0,x=t?.sharedStandardCount||0,i=t?.deeperSharedCount||0,N=t?.isolatedCount||0,r=t?.sharedAloneCount||0,d=t?.sharedPeerAccountCount||0,f=t?.deeperReadyAccountCount||0,v=t?.sharedPeerGroups||[],j=t?.deeperReadyGroups||[],G=t?.sharedGroups||[],T=t?.groupSummaries||[],w=t?.plainCcsLane||null,L=h.filter(H=>H.context_inferred||H.continuity_inferred),D=L.length,B=D>0,g=()=>c("/cliproxy?provider=claude"),K=()=>c("/cliproxy?provider=claude&action=auth"),M=()=>s.mutate(L);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden h-full min-h-0 lg:flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/20 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:a("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.manageSuffix")]})]}),e.jsx(Re,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:a("accountsPage.primaryActions")}),e.jsxs(b,{size:"sm",className:"w-full justify-start",onClick:()=>l(!0),children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),a("accountsPage.createAccount")]}),e.jsxs(b,{size:"sm",className:"w-full justify-start",onClick:K,children:[e.jsx(ne,{className:"w-4 h-4 mr-2"}),a("accountsPage.authClaudeInPool")]}),e.jsxs(b,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:g,children:[a("accountsPage.openClaudePoolSettings"),e.jsx(U,{className:"w-4 h-4 ml-auto"})]})]}),B?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:a("accountsPage.migrationFollowup")}),e.jsxs("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/10 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(J,{className:"h-4 w-4 mt-0.5 text-amber-700 dark:text-amber-400 shrink-0"}),e.jsxs("div",{className:"space-y-1 text-xs",children:[p>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContextPending",{count:p})}),m>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContinuityPending",{count:m})})]})]}),e.jsx(b,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:M,disabled:s.isPending||D===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:D})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:a("accountsPage.noLegacyFollowup")}),e.jsxs(O,{children:[e.jsxs(I,{className:"pb-2",children:[e.jsx(q,{className:"text-sm",children:a("accountsPage.quickCommands")}),e.jsx(Q,{children:a("accountsPage.quickCommandsDesc")})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth create work --context-group sprint-a --deeper-continuity"}),e.jsx(_,{value:"ccs auth create work --context-group sprint-a --deeper-continuity",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs cliproxy auth claude"}),e.jsx(_,{value:"ccs cliproxy auth claude",size:"icon"})]})]})]})]})})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"px-5 py-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{variant:"outline",children:a("accountsPage.workspaceBadge")}),e.jsx(A,{variant:"secondary",children:a("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:a("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[a("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:a("accountsTable.sync")}),a("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(le,{totalAccounts:h.length,primaryAccountName:h.length===1?h[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:i,sharedAloneCount:r,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:G,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:D,cliproxyCount:n,plainCcsLane:w}),e.jsxs(O,{className:"flex flex-col",children:[e.jsxs(I,{className:"pb-3",children:[e.jsx(q,{className:"text-lg",children:a("accountsPage.accountMatrix")}),e.jsx(Q,{children:a("accountsPage.sharedTotalDesc",{count:y})})]}),e.jsx(R,{children:o?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:h,defaultAccount:t?.default??null,groupSummaries:T,plainCcsLane:w})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(O,{children:[e.jsxs(I,{children:[e.jsx(q,{className:"text-lg",children:a("accountsPage.title")}),e.jsxs(Q,{children:[a("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.mobileManageSuffix")]})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs(b,{className:"w-full",onClick:()=>l(!0),children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),a("accountsPage.createAccount")]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:g,children:[a("accountsPage.openCliProxyClaudePool"),e.jsx(U,{className:"w-4 h-4 ml-2"})]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:K,children:[a("accountsPage.authClaudeInPool"),e.jsx(ne,{className:"w-4 h-4 ml-2"})]}),e.jsx(b,{variant:"outline",className:"w-full",onClick:M,disabled:s.isPending||D===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:D})})]})]}),e.jsx(le,{totalAccounts:h.length,primaryAccountName:h.length===1?h[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:i,sharedAloneCount:r,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:G,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:D,cliproxyCount:n,plainCcsLane:w}),e.jsxs(O,{children:[e.jsx(I,{className:"pb-3",children:e.jsx(q,{className:"text-base",children:a("accountsPage.accountMatrix")})}),e.jsx(R,{children:o?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:h,defaultAccount:t?.default??null,groupSummaries:T,plainCcsLane:w})})]})]}),e.jsx(rt,{open:u,onClose:()=>l(!1)})]})}export{bt as AccountsPage};
@@ -1 +1 @@
1
- import{j as e,a3 as s,a4 as r,a5 as n,a6 as i,a7 as d,a8 as c,a9 as u,aa as f}from"./radix-ui-Zb8sVEtn.js";import"./react-vendor-CNOkPC89.js";import{c as o,bO as l}from"./index-BDfXfBTa.js";function A({...a}){return e.jsx(s,{"data-slot":"alert-dialog",...a})}function g({...a}){return e.jsx(u,{"data-slot":"alert-dialog-portal",...a})}function m({className:a,...t}){return e.jsx(f,{"data-slot":"alert-dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...t})}function D({className:a,...t}){return e.jsxs(g,{children:[e.jsx(m,{}),e.jsx(r,{"data-slot":"alert-dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...t})]})}function b({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...t})}function N({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...t})}function v({className:a,...t}){return e.jsx(n,{"data-slot":"alert-dialog-title",className:o("text-lg font-semibold",a),...t})}function w({className:a,...t}){return e.jsx(i,{"data-slot":"alert-dialog-description",className:o("text-muted-foreground text-sm",a),...t})}function y({className:a,...t}){return e.jsx(c,{className:o(l(),a),...t})}function z({className:a,...t}){return e.jsx(d,{className:o(l({variant:"outline"}),a),...t})}export{A,D as a,b,v as c,w as d,N as e,z as f,y as g};
1
+ import{j as e,a3 as s,a4 as r,a5 as n,a6 as i,a7 as d,a8 as c,a9 as u,aa as f}from"./radix-ui-Zb8sVEtn.js";import"./react-vendor-CNOkPC89.js";import{c as o,bK as l}from"./index-g2g1k0QS.js";function A({...a}){return e.jsx(s,{"data-slot":"alert-dialog",...a})}function g({...a}){return e.jsx(u,{"data-slot":"alert-dialog-portal",...a})}function m({className:a,...t}){return e.jsx(f,{"data-slot":"alert-dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...t})}function D({className:a,...t}){return e.jsxs(g,{children:[e.jsx(m,{}),e.jsx(r,{"data-slot":"alert-dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...t})]})}function b({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...t})}function N({className:a,...t}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...t})}function v({className:a,...t}){return e.jsx(n,{"data-slot":"alert-dialog-title",className:o("text-lg font-semibold",a),...t})}function w({className:a,...t}){return e.jsx(i,{"data-slot":"alert-dialog-description",className:o("text-muted-foreground text-sm",a),...t})}function y({className:a,...t}){return e.jsx(c,{className:o(l(),a),...t})}function z({className:a,...t}){return e.jsx(d,{className:o(l({variant:"outline"}),a),...t})}export{A,D as a,b,v as c,w as d,N as e,z as f,y as g};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as x,h as We}from"./react-vendor-CNOkPC89.js";import{a as Q,B as L,c as H,T as Ye,p as Ve,q as Ge,r as Xe,s as Ze,t as es,v as ss,w as he,d as C,n as oe,L as M,I as z,x as W,y as Re,z as ts,A as as,D as rs,E as ns,S as be,F as te,G as ge,H as Ae,J as is,K as os,M as De,N as _e,O as Me,Q as ls,R as cs,U as we,V as Ce,W as ae,X as ds,Y as Le,Z as ve,C as Qe,b as Fe,j as ms,k as us,_ as xs,$ as hs,a0 as ps,a1 as gs,a2 as fs,a3 as js,a4 as Ns,a5 as vs,a6 as bs,a7 as ws}from"./index-BDfXfBTa.js";import{a as Cs,u as fe,b as ye}from"./tanstack-CrmUhA7Z.js";import{C as je}from"./confirm-dialog-D_5v8muu.js";import{t as E}from"./notifications-B2HqRBj7.js";import{L as re,R as Z,as as He,at as ys,a9 as ne,_ as ks,au as Ie,aa as ie,C as Ue,av as Ss,a7 as Ps,aw as Os,p as Ne,X as Ts,ax as Es,Z as ze,ay as Be,n as ke,az as Se,aA as Rs,aB as pe,a6 as As,ad as Ds,aC as _s,w as Ke,aD as Ms,x as $e,o as Ls,aE as Qs}from"./icons-KVCk4_U8.js";import{M as Je}from"./masked-input-D1Ilmeh7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-CuN8HTEx.js";function Fs({className:s,showTooltip:a=!0}){const{t:r}=Q(),c=e.jsxs(L,{variant:"outline",className:H("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return a?e.jsxs(Ye,{children:[e.jsx(Ve,{asChild:!0,children:c}),e.jsx(Ge,{children:e.jsx("p",{children:r("openrouterBadge.integration")})})]}):c}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(r=>r.test(s))}function qe(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Hs(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Is(s,a){const r={...s};return a.opus?r.ANTHROPIC_DEFAULT_OPUS_MODEL=a.opus:delete r.ANTHROPIC_DEFAULT_OPUS_MODEL,a.sonnet?r.ANTHROPIC_DEFAULT_SONNET_MODEL=a.sonnet:delete r.ANTHROPIC_DEFAULT_SONNET_MODEL,a.haiku?r.ANTHROPIC_DEFAULT_HAIKU_MODEL=a.haiku:delete r.ANTHROPIC_DEFAULT_HAIKU_MODEL,r}function Us({profileName:s,target:a,data:r,settings:c,isLoading:o,isSaving:p,isTargetSaving:f,hasChanges:g,isRawJsonValid:t,onTargetChange:m,onRefresh:u,onDelete:j,onSave:P}){const{t:b}=Q(),O=p||f,y=o||O;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),r?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:r.path.replace(/^.*\//,"")}),qe(c)&&e.jsx(Fs,{className:"ml-1"})]}),r&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[b("profileEditor.lastModified"),": ",new Date(r.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b("profileEditor.defaultTarget"),":"]}),e.jsxs(Xe,{value:a,onValueChange:k=>{y||m(k)},disabled:y,children:[e.jsx(Ze,{className:"h-7 w-[170px] text-xs",disabled:y,children:e.jsx(es,{})}),e.jsxs(ss,{children:[e.jsx(he,{value:"claude",children:b("profileEditor.targetClaude")}),e.jsx(he,{value:"droid",children:b("profileEditor.targetDroid")}),e.jsx(he,{value:"codex",children:b("profileEditor.targetCodex")})]})]}),f&&e.jsx(re,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:u,disabled:y,children:e.jsx(Z,{className:`w-4 h-4 ${o?"animate-spin":""}`})}),j&&e.jsx(C,{variant:"ghost",size:"sm",onClick:j,disabled:O,children:e.jsx(He,{className:"w-4 h-4 text-destructive"})}),e.jsx(C,{size:"sm",onClick:P,disabled:O||!g||!t,children:p?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-1 animate-spin"}),b("profileEditor.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 mr-1"}),b("settingsAuth.save")]})})]})]})}function zs({currentSettings:s,newEnvKey:a,newEnvValue:r,onNewEnvKeyChange:c,onNewEnvValueChange:o,onEnvValueChange:p,onAddEnvVar:f}){const{t:g}=Q();return e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,m])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(M,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:g("envEditor.sensitive")})]}),Pe(t)?e.jsx(Je,{value:m,onChange:u=>p(t,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(z,{value:m,onChange:u=>p(t,u.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:g("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:g("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(M,{className:"text-xs font-medium text-muted-foreground",children:g("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(z,{placeholder:g("envEditor.keyPlaceholder"),value:a,onChange:t=>c(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&a.trim()&&f()}),e.jsx(z,{placeholder:g("envEditor.valuePlaceholder"),value:r,onChange:t=>o(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&a.trim()&&f()}),e.jsx(C,{variant:"outline",size:"sm",className:"h-8",onClick:f,disabled:!a.trim(),children:e.jsx(ne,{className:"w-4 h-4"})})]})]})]})}function Bs({profileName:s,target:a,data:r}){const{t:c}=Q(),o=a==="droid";return e.jsx(oe,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ks,{className:"w-4 h-4"}),c("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:r.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:r.path}),e.jsx(W,{value:r.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(r.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:a})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:c("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(W,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c(o?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(W,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c(o?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",o?"claude":"droid",' "prompt"']}),e.jsx(W,{value:`ccs ${s} --target ${o?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(W,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Ks({value:s,onChange:a,placeholder:r,className:c}){const{t:o}=Q(),[p,f]=x.useState(""),[g,t]=x.useState(null),{models:m,isLoading:u,isError:j,isFetching:P}=Re(),b=ts(),O=x.useMemo(()=>as(m,p,{category:g??void 0}),[m,p,g]),y=x.useMemo(()=>rs(m,2),[m]),k=!p.trim()&&!g,N=x.useMemo(()=>{const i={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};O.forEach(h=>{i[h.category].push(h)});for(const h of Object.keys(i))i[h]=ns(i[h]);return i},[O]),R=x.useCallback(()=>{b()},[b]),v=m.find(i=>i.id===s);return u&&m.length===0?e.jsxs("div",{className:H("space-y-2",c),children:[e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-32 w-full"})]}):e.jsxs("div",{className:H("space-y-2 w-full min-w-0 overflow-hidden",c),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ie,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(z,{value:p,onChange:i=>f(i.target.value),placeholder:r??o("openrouterModelPicker.searchModels"),className:"pl-9"})]}),e.jsx(C,{variant:"outline",size:"icon",onClick:R,disabled:P,title:"Refresh models",children:P?e.jsx(re,{className:"h-4 w-4 animate-spin"}):e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:g===null?"default":"outline",className:"cursor-pointer",onClick:()=>t(null),children:["All (",m.length,")"]}),Object.keys(te).map(i=>{const h=N[i].length;return h===0?null:e.jsxs(L,{variant:g===i?"default":"outline",className:"cursor-pointer",onClick:()=>t(i),children:[te[i]," (",h,")"]},i)})]}),v&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:v.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[ge(v.pricing)," |"," ",Ae(v.context_length)]})]}),e.jsx(oe,{className:"h-72 w-full rounded-md border",children:j?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(C,{variant:"link",onClick:R,children:"Retry"})]}):O.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',p,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[k&&y.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(ie,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:o("openrouterModelPicker.newestModels")})]}),e.jsx("div",{className:"space-y-1",children:y.map(i=>e.jsx(Oe,{model:i,isSelected:i.id===s,onClick:()=>a(i.id),showAge:!0},i.id))})]}),Object.keys(te).map(i=>{const h=N[i];return h.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:te[i]}),e.jsx("div",{className:"space-y-1",children:h.map(l=>e.jsx(Oe,{model:l,isSelected:l.id===s,onClick:()=>a(l.id)},l.id))})]},i)})]})})]})}function Oe({model:s,isSelected:a,onClick:r,showAge:c=!1}){return e.jsxs("button",{type:"button",onClick:r,className:H("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",a&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:H("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",a?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[c&&s.created&&e.jsx(L,{variant:"outline",className:H("text-[10px] px-1",a?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:is(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:H("text-[10px] px-1",a?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:H("text-[10px] px-1 border-emerald-500/50 text-emerald-600",a?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:ge(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:ge(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Ae(s.context_length)})]})]})}function $s({selectedModel:s,value:a,onChange:r,className:c}){const{t:o}=Q(),{models:p}=Re(),f=x.useMemo(()=>s?os(s,p):{},[s,p]),g=()=>{r(f)},t=(u,j)=>{r({...a,[u]:j||void 0})},m=s&&Object.keys(f).length>0;return e.jsxs(De,{className:H("group",c),children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ue,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),o("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",o("modelTierMapping.advanced"),")"]})]}),e.jsxs(Me,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:o("modelTierMapping.description")}),m&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(Ss,{className:"mr-1 h-4 w-4"}),o("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(z,{id:"tier-opus",value:a.opus??"",onChange:u=>t("opus",u.target.value),placeholder:o("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(z,{id:"tier-sonnet",value:a.sonnet??"",onChange:u=>t("sonnet",u.target.value),placeholder:o("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(z,{id:"tier-haiku",value:a.haiku??"",onChange:u=>t("haiku",u.target.value),placeholder:o("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:o("modelTierMapping.footer")})]})]})}function Js({profileName:s,target:a,data:r,currentSettings:c,newEnvKey:o,newEnvValue:p,onNewEnvKeyChange:f,onNewEnvValueChange:g,onEnvValueChange:t,onAddEnvVar:m,onEnvBulkChange:u}){const{t:j}=Q(),P=qe(c),b=c?.env,O=x.useMemo(()=>Hs(b??{}),[b]),y=b??{},k=l=>{if(u){const I={...y,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};u(I)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);E.success(ae.t("commonToast.appliedModelAllTiers"),{duration:2e3})},N=l=>{if(u){const I=Is(y,l);u(I)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[R,v]=x.useState(!1),i=new Set(["ANTHROPIC_AUTH_TOKEN"]),h=Object.entries(y).filter(([l])=>!i.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(ls,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(cs,{className:"w-full",children:[e.jsx(we,{value:"env",className:"flex-1",children:P?"Configuration":j("settingsDialog.envTab")}),e.jsx(we,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(Ce,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:P?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Ks,{value:y.ANTHROPIC_MODEL,onChange:k,placeholder:"Search OpenRouter models..."})]}),e.jsx($s,{selectedModel:y.ANTHROPIC_MODEL,value:O,onChange:N}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{className:"text-sm font-medium",children:j("profileDialog.apiKey")}),e.jsx(Je,{value:y.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),h.length>0&&e.jsxs(De,{open:R,onOpenChange:v,children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ue,{className:H("h-4 w-4 transition-transform",R&&"rotate-90")}),e.jsx(Ps,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",h.length,")"]})]}),e.jsx(Me,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:h.map(([l,I])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:l}),e.jsx(z,{value:I,onChange:J=>t(l,J.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(M,{className:"text-xs font-medium text-muted-foreground",children:j("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(z,{placeholder:j("envEditor.keyPlaceholder"),value:o,onChange:l=>f(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&o.trim()&&m()}),e.jsx(z,{placeholder:j("envEditor.valuePlaceholder"),value:p,onChange:l=>g(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&o.trim()&&m()}),e.jsx(C,{variant:"outline",size:"sm",className:"h-8",onClick:m,disabled:!o.trim(),children:e.jsx(ne,{className:"w-4 h-4"})})]})]})]}):e.jsx(zs,{currentSettings:c,newEnvKey:o,newEnvValue:p,onNewEnvKeyChange:f,onNewEnvValueChange:g,onEnvValueChange:t,onAddEnvVar:m})}),e.jsx(Ce,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Bs,{profileName:s,target:a,data:r})})]})]})})}function qs({profileName:s,profileTarget:a,onDelete:r,onHasChangesUpdate:c}){const{t:o}=Q(),[p,f]=x.useState({}),[g,t]=x.useState(!1),[m,u]=x.useState(null),[j,P]=x.useState(""),[b,O]=x.useState(""),y=Cs(),{data:k,isLoading:N,isError:R,refetch:v}=fe({queryKey:["settings",s],queryFn:async()=>{const d=await fetch(`/api/settings/${s}/raw`);if(!d.ok)throw new Error(`Failed to load settings: ${d.status}`);return d.json()}}),i=k?.settings,h=x.useMemo(()=>{if(m!==null)try{return JSON.parse(m)}catch{}if(i)return{...i,env:{...i.env,...p}}},[i,p,m]),l=x.useMemo(()=>m!==null?m:i?JSON.stringify(i,null,2):"",[m,i]),I=x.useCallback(d=>{u(d)},[]),J=x.useCallback(d=>{const w={...h??{}},_=w.ccs_image&&typeof w.ccs_image=="object"?{...w.ccs_image}:{};d?_.native_read=!0:delete _.native_read,Object.keys(_).length>0?w.ccs_image=_:delete w.ccs_image,u(JSON.stringify(w,null,2))},[h]),q=(d,w)=>{const _={...h?.env||{},[d]:w};f(G=>({...G,[d]:w})),u(JSON.stringify({...h,env:_},null,2))},ee=d=>{const w={...h?.env||{},...d};f(_=>({..._,...d})),u(JSON.stringify({...h,env:w},null,2))},U=()=>{if(!j.trim())return;const d=j.trim(),w=b,_={...h?.env||{},[d]:w};f(G=>({...G,[d]:w})),u(JSON.stringify({...h,env:_},null,2)),P(""),O("")},B=x.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),S=x.useMemo(()=>m!==null?m!==JSON.stringify(i,null,2):Object.keys(p).length>0,[m,p,i]),$=x.useDeferredValue(l),se=x.useMemo(()=>{if(!S||!B)return null;try{return JSON.parse($)}catch{return null}},[S,B,$]),{data:Y,isFetching:le,isError:V,isPlaceholderData:ce}=fe({queryKey:["settings",s,"image-analysis-status-preview",$],enabled:se!==null,placeholderData:d=>d,queryFn:async()=>{const d=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:se})});if(!d.ok)throw new Error(`Failed to preview image-analysis status: ${d.status}`);return d.json()}}),de=S&&B&&!V?Y?.imageAnalysisStatus??k?.imageAnalysisStatus:k?.imageAnalysisStatus,me=S&&B&&!V&&Y?.imageAnalysisStatus?"editor":"saved",ue=S?B?V?"saved":le&&(!Y?.imageAnalysisStatus||ce)?"refreshing":"preview":"invalid":"saved",xe=h?.ccs_image?.native_read===!0,n=x.useMemo(()=>{const d=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],w=h?.env||{};return d.filter(_=>!w[_]?.trim())},[h]);x.useEffect(()=>{c?.(S)},[S,c]);const A=ye({mutationFn:async()=>{let d;try{d=JSON.parse(l)}catch{d={...k?.settings,env:{...k?.settings?.env,...p}}}const w=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:d,expectedMtime:k?.mtime})});if(w.status===409)throw new Error("CONFLICT");if(!w.ok)throw new Error("Failed to save");return w.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["settings",s]}),y.invalidateQueries({queryKey:["profiles"]}),f({}),u(null),E.success(ae.t("commonToast.settingsSaved"))},onError:d=>{d.message==="CONFLICT"?t(!0):E.error(d.message)}}),T=ye({mutationFn:async d=>(await Le.profiles.update(s,{target:d}),d),onSuccess:()=>{y.invalidateQueries({queryKey:["profiles"]}),E.success(ae.t("commonToast.defaultTargetUpdated"))},onError:(d,w)=>{const _=w==="droid"?"Factory Droid":w==="codex"?"Codex CLI":"Claude Code",G=d.message.trim()?`: ${d.message}`:"";E.error(ae.t("commonToast.failedUpdateDefaultTarget",{target:_,suffix:G}))}}),F=a||"claude",D=A.isPending||T.isPending,K=async d=>{t(!1),d?(await v(),A.mutate()):(f({}),u(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Us,{profileName:s,target:F,data:k,settings:h,isLoading:N,isSaving:A.isPending,isTargetSaving:T.isPending,hasChanges:S,isRawJsonValid:B,onTargetChange:d=>{D||d!==F&&T.mutate(d)},onRefresh:()=>{D||v()},onDelete:r,onSave:()=>{D||A.mutate()}}),N?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(re,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:o("settingsDialog.loadingSettings")})]}):R?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("settingsPage.failedLoad")}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>v(),children:[e.jsx(Z,{className:"w-4 h-4 mr-1"}),o("apiProfiles.retry")]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Js,{profileName:s,target:F,data:k,currentSettings:h,newEnvKey:j,newEnvValue:b,onNewEnvKeyChange:P,onNewEnvValueChange:O,onEnvValueChange:q,onEnvBulkChange:ee,onAddEnvVar:U})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:o("rawEditorSection.rawConfig")})]}),e.jsx(ds,{rawJsonContent:l,isRawJsonValid:B,rawJsonEdits:m,settings:i,profileTarget:F,imageAnalysisStatus:de,imageAnalysisStatusSource:me,imageAnalysisStatusPreviewState:ue,nativeReadPreferenceOverride:xe,onToggleNativeRead:J,onChange:I,missingRequiredFields:n})]})]}),e.jsx(je,{open:g,title:o("settingsDialog.conflictTitle"),description:o("settingsDialog.conflictDesc"),confirmText:o("settingsDialog.overwrite"),variant:"destructive",onConfirm:()=>K(!0),onCancel:()=>K(!1)})]},s)}const Te="ccs:openrouter-banner-dismissed";function Ws({onCreateClick:s}){const{t:a}=Q(),[r,c]=x.useState(!0),{modelCount:o,isLoading:p}=ve();x.useEffect(()=>{const g=localStorage.getItem(Te)==="true";c(g)},[]);const f=()=>{localStorage.setItem(Te,"true"),c(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[a("openrouterBadge.new"),": ",a("openrouterBadge.integration")]}),e.jsx("p",{className:"text-xs text-white/80 truncate",children:a("openrouterBanner.accessModels",{count:p?300:o})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(C,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:a("openrouterBanner.add")}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(Ne,{className:"w-3 h-3"})]}),e.jsxs(C,{size:"icon",variant:"ghost",onClick:f,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Ts,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Ys(){return fe({queryKey:["profiles","local-runtime-readiness"],queryFn:()=>Le.profiles.getLocalRuntimeReadiness(),staleTime:15e3,refetchOnWindowFocus:!1})}function X({badge:s,badgeClassName:a,className:r,title:c,description:o,visual:p,highlights:f,actionLabel:g,actionClassName:t,onAction:m,footer:u}){return e.jsxs(Qe,{className:H("flex h-full flex-col border shadow-sm",r),children:[e.jsxs(ms,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p,e.jsx(L,{variant:"secondary",className:a,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(us,{className:"text-base",children:c}),e.jsx(xs,{className:"text-sm leading-6",children:o})]})]}),e.jsxs(Fe,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:f.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[j.icon,e.jsx("span",{children:j.label})]},j.label))}),e.jsxs(C,{onClick:m,className:t,children:[g,e.jsx(As,{className:"ml-2 h-4 w-4"})]}),u?e.jsx("div",{className:"text-xs text-muted-foreground",children:u}):null]})]})}function Ee(s,a,r){return s?s.status==="ready"?{badge:r("openrouterQuickStart.localRuntimeReadyBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",actionLabel:r("openrouterQuickStart.localRuntimeUseAction",{label:a}),description:r("openrouterQuickStart.localRuntimeReadyDescription"),footer:r("openrouterQuickStart.localRuntimeReadyFooter",{endpoint:s.endpoint})}:s.status==="missing-model"?{badge:r("openrouterQuickStart.localRuntimeNeedsModelBadge"),badgeClassName:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",actionLabel:r("openrouterQuickStart.localRuntimeFinishAction",{label:a}),description:r("openrouterQuickStart.localRuntimeNeedsModelDescription"),footer:r("openrouterQuickStart.localRuntimeMissingModelFooter",{command:s.commandHint})}:{badge:r("openrouterQuickStart.localRuntimeOfflineBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:r("openrouterQuickStart.localRuntimeSetupAction",{label:a}),description:r("openrouterQuickStart.localRuntimeOfflineDescription"),footer:r("openrouterQuickStart.localRuntimeOfflineFooter",{command:s.commandHint})}:{badge:r("openrouterQuickStart.localRuntimeCheckingBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:r("openrouterQuickStart.localRuntimeSetupAction",{label:a}),description:r("openrouterQuickStart.localRuntimeCheckingDescription"),footer:r("openrouterQuickStart.localRuntimeCheckingFooter")}}function Vs({hasProfiles:s,profileCount:a,onOpenRouterClick:r,onAlibabaCodingPlanClick:c,onCliproxyClick:o,onCustomClick:p,onOllamaClick:f,onLlamacppClick:g}){const{t}=Q(),{modelCount:m,isLoading:u}=ve(),{data:j}=Ys(),P=u?"300+":`${m}+`,b=s?t("openrouterQuickStart.profileSummaryCount",{count:a}):t("openrouterQuickStart.profileSummaryEmpty"),O=t(s?"openrouterQuickStart.summaryExistingTitle":"openrouterQuickStart.summaryEmptyTitle"),y=s?t("openrouterQuickStart.summaryExistingDescription",{count:a}):t("openrouterQuickStart.summaryEmptyDescription"),k=j?.runtimes.find(i=>i.id==="ollama"),N=j?.runtimes.find(i=>i.id==="llamacpp"),R=Ee(k,t("openrouterQuickStart.localOllamaLabel"),t),v=Ee(N,t("openrouterQuickStart.localLlamacppLabel"),t);return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-5",children:[e.jsx(Qe,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Fe,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:b}),e.jsx(L,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeDefaultQuality")}),e.jsx(L,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeLocalLane")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:O}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:y})]})]}),e.jsx(C,{variant:"outline",onClick:p,className:"shrink-0",children:t("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"h-4 w-4 text-accent"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.qualityLanesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(X,{badge:t("openrouterQuickStart.recommended"),title:t("openrouterQuickStart.title"),description:t("openrouterQuickStart.description",{modelCountLabel:P}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(ze,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.featureOneApi")},{icon:e.jsx(ie,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.qualityLaneHighlightDefaultQuality")}],actionLabel:t("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:r,footer:e.jsxs(e.Fragment,{children:[t("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(Ne,{className:"h-3 w-3"})]})]})}),e.jsx(X,{badge:t("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",title:t("alibabaCodingPlanQuickStart.title"),description:t("openrouterQuickStart.alibabaLaneDescription"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Be,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ke,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("openrouterQuickStart.alibabaLaneHighlightQuality")}],actionLabel:t("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:c,footer:e.jsxs(e.Fragment,{children:[t("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(Ne,{className:"h-3 w-3"})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-emerald-600"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.localRuntimesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(X,{badge:R.badge,badgeClassName:R.badgeClassName,title:t("openrouterQuickStart.localOllamaTitle"),description:R.description,visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx("img",{src:"/icons/ollama.svg",alt:"Ollama",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Rs,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.localOllamaHighlight")},{icon:e.jsx(ie,{className:"h-3.5 w-3.5 text-emerald-600"}),label:k?.detectedModelCount&&k.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:k.detectedModelCount}):t("openrouterQuickStart.localNoModelsDetected")}],actionLabel:R.actionLabel,actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:f,footer:e.jsx("span",{children:R.footer})}),e.jsx(X,{badge:v.badge,badgeClassName:v.badgeClassName,title:t("openrouterQuickStart.localLlamacppTitle"),description:v.description,visual:e.jsx("div",{className:"rounded-lg bg-sky-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/llama-cpp.svg",alt:"llama.cpp",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(pe,{className:"h-3.5 w-3.5 text-sky-600"}),label:t("openrouterQuickStart.localLlamacppHighlight")},{icon:e.jsx(Se,{className:"h-3.5 w-3.5 text-sky-600"}),label:N?.detectedModelCount&&N.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:N.detectedModelCount}):t("openrouterQuickStart.localWaitingServer")}],actionLabel:v.actionLabel,actionClassName:"w-full bg-sky-600 text-white hover:bg-sky-600/90",onAction:g,footer:e.jsx("span",{children:v.footer})})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:e.jsx(X,{badge:t("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:t("openrouterQuickStart.runtimeProviderTitle"),description:t("openrouterQuickStart.runtimeProviderManagedDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(pe,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(pe,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ke,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:t("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:o,footer:e.jsx("span",{children:t("openrouterQuickStart.runtimeProviderFooter")})})})]})})}function Gs({onCreateClick:s}){const{t:a}=Q();return ve(),e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:a("openrouterPromoCard.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a("openrouterPromoCard.description")})]}),e.jsxs(C,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(ze,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:a("openrouterBanner.add")})]})]})})}function Xs({onCreateClick:s}){const{t:a}=Q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:a("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(C,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Be,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:a("alibabaCodingPlanPromo.add")})]})]})})}function ut(){const{t:s}=Q(),a=We(),{data:r,isLoading:c,isError:o,refetch:p}=hs(),f=ps(),g=gs(),t=fs(),m=js(),u=Ns(),j=vs(),[P,b]=x.useState(null),[O,y]=x.useState(""),[k,N]=x.useState(!1),[R,v]=x.useState("normal"),[i,h]=x.useState(null),[l,I]=x.useState(!1),[J,q]=x.useState(null),ee=x.useRef(null);bs();const U=x.useMemo(()=>r?.profiles||[],[r?.profiles]),B=x.useMemo(()=>U.filter(n=>n.name.toLowerCase().includes(O.toLowerCase())),[U,O]),S=P?U.find(n=>n.name===P):null,$=n=>{l&&P!==n?q(n):b(n)},se=n=>{f.mutate(n,{onSuccess:()=>{P===n&&(b(null),I(!1),q(null)),h(null)}})},Y=n=>{N(!1),$(n)},le=n=>{$(n)},V=(n,A)=>{const T=JSON.stringify(A,null,2)+`
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as x,h as We}from"./react-vendor-CNOkPC89.js";import{a as Q,B as L,c as H,T as Ye,p as Ve,q as Ge,r as Xe,s as Ze,t as es,v as ss,w as he,d as C,n as oe,L as M,I as z,x as W,y as Re,z as ts,A as as,D as rs,E as ns,S as be,F as te,G as ge,H as Ae,J as is,K as os,M as De,N as _e,O as Me,Q as ls,R as cs,U as we,V as Ce,W as ae,X as ds,Y as Le,Z as ve,C as Qe,b as Fe,j as ms,k as us,_ as xs,$ as hs,a0 as ps,a1 as gs,a2 as fs,a3 as js,a4 as Ns,a5 as vs,a6 as bs,a7 as ws}from"./index-g2g1k0QS.js";import{a as Cs,u as fe,b as ye}from"./tanstack-CrmUhA7Z.js";import{C as je}from"./confirm-dialog-DwrX5gr_.js";import{t as E}from"./notifications-B2HqRBj7.js";import{L as re,R as Z,as as He,at as ys,a9 as ne,_ as ks,au as Ie,aa as ie,C as Ue,av as Ss,a7 as Ps,aw as Os,p as Ne,X as Ts,ax as Es,Z as ze,ay as Be,n as ke,az as Se,aA as Rs,aB as pe,a6 as As,ad as Ds,aC as _s,w as Ke,aD as Ms,x as $e,o as Ls,aE as Qs}from"./icons-KVCk4_U8.js";import{M as Je}from"./masked-input-DXzbXJrE.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-sars2LJq.js";function Fs({className:s,showTooltip:a=!0}){const{t:r}=Q(),c=e.jsxs(L,{variant:"outline",className:H("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return a?e.jsxs(Ye,{children:[e.jsx(Ve,{asChild:!0,children:c}),e.jsx(Ge,{children:e.jsx("p",{children:r("openrouterBadge.integration")})})]}):c}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(r=>r.test(s))}function qe(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Hs(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Is(s,a){const r={...s};return a.opus?r.ANTHROPIC_DEFAULT_OPUS_MODEL=a.opus:delete r.ANTHROPIC_DEFAULT_OPUS_MODEL,a.sonnet?r.ANTHROPIC_DEFAULT_SONNET_MODEL=a.sonnet:delete r.ANTHROPIC_DEFAULT_SONNET_MODEL,a.haiku?r.ANTHROPIC_DEFAULT_HAIKU_MODEL=a.haiku:delete r.ANTHROPIC_DEFAULT_HAIKU_MODEL,r}function Us({profileName:s,target:a,data:r,settings:c,isLoading:o,isSaving:p,isTargetSaving:f,hasChanges:g,isRawJsonValid:t,onTargetChange:m,onRefresh:u,onDelete:j,onSave:P}){const{t:b}=Q(),O=p||f,y=o||O;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),r?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:r.path.replace(/^.*\//,"")}),qe(c)&&e.jsx(Fs,{className:"ml-1"})]}),r&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[b("profileEditor.lastModified"),": ",new Date(r.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b("profileEditor.defaultTarget"),":"]}),e.jsxs(Xe,{value:a,onValueChange:k=>{y||m(k)},disabled:y,children:[e.jsx(Ze,{className:"h-7 w-[170px] text-xs",disabled:y,children:e.jsx(es,{})}),e.jsxs(ss,{children:[e.jsx(he,{value:"claude",children:b("profileEditor.targetClaude")}),e.jsx(he,{value:"droid",children:b("profileEditor.targetDroid")}),e.jsx(he,{value:"codex",children:b("profileEditor.targetCodex")})]})]}),f&&e.jsx(re,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:u,disabled:y,children:e.jsx(Z,{className:`w-4 h-4 ${o?"animate-spin":""}`})}),j&&e.jsx(C,{variant:"ghost",size:"sm",onClick:j,disabled:O,children:e.jsx(He,{className:"w-4 h-4 text-destructive"})}),e.jsx(C,{size:"sm",onClick:P,disabled:O||!g||!t,children:p?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-4 h-4 mr-1 animate-spin"}),b("profileEditor.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4 mr-1"}),b("settingsAuth.save")]})})]})]})}function zs({currentSettings:s,newEnvKey:a,newEnvValue:r,onNewEnvKeyChange:c,onNewEnvValueChange:o,onEnvValueChange:p,onAddEnvVar:f}){const{t:g}=Q();return e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,m])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(M,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:g("envEditor.sensitive")})]}),Pe(t)?e.jsx(Je,{value:m,onChange:u=>p(t,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(z,{value:m,onChange:u=>p(t,u.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:g("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:g("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(M,{className:"text-xs font-medium text-muted-foreground",children:g("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(z,{placeholder:g("envEditor.keyPlaceholder"),value:a,onChange:t=>c(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&a.trim()&&f()}),e.jsx(z,{placeholder:g("envEditor.valuePlaceholder"),value:r,onChange:t=>o(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&a.trim()&&f()}),e.jsx(C,{variant:"outline",size:"sm",className:"h-8",onClick:f,disabled:!a.trim(),children:e.jsx(ne,{className:"w-4 h-4"})})]})]})]})}function Bs({profileName:s,target:a,data:r}){const{t:c}=Q(),o=a==="droid";return e.jsx(oe,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ks,{className:"w-4 h-4"}),c("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:r&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:r.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:r.path}),e.jsx(W,{value:r.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(r.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:a})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:c("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(W,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c(o?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(W,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c(o?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",o?"claude":"droid",' "prompt"']}),e.jsx(W,{value:`ccs ${s} --target ${o?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:c("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(W,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Ks({value:s,onChange:a,placeholder:r,className:c}){const{t:o}=Q(),[p,f]=x.useState(""),[g,t]=x.useState(null),{models:m,isLoading:u,isError:j,isFetching:P}=Re(),b=ts(),O=x.useMemo(()=>as(m,p,{category:g??void 0}),[m,p,g]),y=x.useMemo(()=>rs(m,2),[m]),k=!p.trim()&&!g,N=x.useMemo(()=>{const i={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};O.forEach(h=>{i[h.category].push(h)});for(const h of Object.keys(i))i[h]=ns(i[h]);return i},[O]),R=x.useCallback(()=>{b()},[b]),v=m.find(i=>i.id===s);return u&&m.length===0?e.jsxs("div",{className:H("space-y-2",c),children:[e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-32 w-full"})]}):e.jsxs("div",{className:H("space-y-2 w-full min-w-0 overflow-hidden",c),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ie,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(z,{value:p,onChange:i=>f(i.target.value),placeholder:r??o("openrouterModelPicker.searchModels"),className:"pl-9"})]}),e.jsx(C,{variant:"outline",size:"icon",onClick:R,disabled:P,title:"Refresh models",children:P?e.jsx(re,{className:"h-4 w-4 animate-spin"}):e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:g===null?"default":"outline",className:"cursor-pointer",onClick:()=>t(null),children:["All (",m.length,")"]}),Object.keys(te).map(i=>{const h=N[i].length;return h===0?null:e.jsxs(L,{variant:g===i?"default":"outline",className:"cursor-pointer",onClick:()=>t(i),children:[te[i]," (",h,")"]},i)})]}),v&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:v.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[ge(v.pricing)," |"," ",Ae(v.context_length)]})]}),e.jsx(oe,{className:"h-72 w-full rounded-md border",children:j?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(C,{variant:"link",onClick:R,children:"Retry"})]}):O.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',p,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[k&&y.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(ie,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:o("openrouterModelPicker.newestModels")})]}),e.jsx("div",{className:"space-y-1",children:y.map(i=>e.jsx(Oe,{model:i,isSelected:i.id===s,onClick:()=>a(i.id),showAge:!0},i.id))})]}),Object.keys(te).map(i=>{const h=N[i];return h.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:te[i]}),e.jsx("div",{className:"space-y-1",children:h.map(l=>e.jsx(Oe,{model:l,isSelected:l.id===s,onClick:()=>a(l.id)},l.id))})]},i)})]})})]})}function Oe({model:s,isSelected:a,onClick:r,showAge:c=!1}){return e.jsxs("button",{type:"button",onClick:r,className:H("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",a&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:H("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",a?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[c&&s.created&&e.jsx(L,{variant:"outline",className:H("text-[10px] px-1",a?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:is(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:H("text-[10px] px-1",a?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:H("text-[10px] px-1 border-emerald-500/50 text-emerald-600",a?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:ge(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:ge(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Ae(s.context_length)})]})]})}function $s({selectedModel:s,value:a,onChange:r,className:c}){const{t:o}=Q(),{models:p}=Re(),f=x.useMemo(()=>s?os(s,p):{},[s,p]),g=()=>{r(f)},t=(u,j)=>{r({...a,[u]:j||void 0})},m=s&&Object.keys(f).length>0;return e.jsxs(De,{className:H("group",c),children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ue,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),o("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",o("modelTierMapping.advanced"),")"]})]}),e.jsxs(Me,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:o("modelTierMapping.description")}),m&&e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(Ss,{className:"mr-1 h-4 w-4"}),o("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(z,{id:"tier-opus",value:a.opus??"",onChange:u=>t("opus",u.target.value),placeholder:o("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(z,{id:"tier-sonnet",value:a.sonnet??"",onChange:u=>t("sonnet",u.target.value),placeholder:o("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(M,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(z,{id:"tier-haiku",value:a.haiku??"",onChange:u=>t("haiku",u.target.value),placeholder:o("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:o("modelTierMapping.footer")})]})]})}function Js({profileName:s,target:a,data:r,currentSettings:c,newEnvKey:o,newEnvValue:p,onNewEnvKeyChange:f,onNewEnvValueChange:g,onEnvValueChange:t,onAddEnvVar:m,onEnvBulkChange:u}){const{t:j}=Q(),P=qe(c),b=c?.env,O=x.useMemo(()=>Hs(b??{}),[b]),y=b??{},k=l=>{if(u){const I={...y,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};u(I)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);E.success(ae.t("commonToast.appliedModelAllTiers"),{duration:2e3})},N=l=>{if(u){const I=Is(y,l);u(I)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[R,v]=x.useState(!1),i=new Set(["ANTHROPIC_AUTH_TOKEN"]),h=Object.entries(y).filter(([l])=>!i.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(ls,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(cs,{className:"w-full",children:[e.jsx(we,{value:"env",className:"flex-1",children:P?"Configuration":j("settingsDialog.envTab")}),e.jsx(we,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(Ce,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:P?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Ks,{value:y.ANTHROPIC_MODEL,onChange:k,placeholder:"Search OpenRouter models..."})]}),e.jsx($s,{selectedModel:y.ANTHROPIC_MODEL,value:O,onChange:N}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{className:"text-sm font-medium",children:j("profileDialog.apiKey")}),e.jsx(Je,{value:y.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),h.length>0&&e.jsxs(De,{open:R,onOpenChange:v,children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ue,{className:H("h-4 w-4 transition-transform",R&&"rotate-90")}),e.jsx(Ps,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",h.length,")"]})]}),e.jsx(Me,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:h.map(([l,I])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{className:"text-xs text-muted-foreground",children:l}),e.jsx(z,{value:I,onChange:J=>t(l,J.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(M,{className:"text-xs font-medium text-muted-foreground",children:j("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(z,{placeholder:j("envEditor.keyPlaceholder"),value:o,onChange:l=>f(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&o.trim()&&m()}),e.jsx(z,{placeholder:j("envEditor.valuePlaceholder"),value:p,onChange:l=>g(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&o.trim()&&m()}),e.jsx(C,{variant:"outline",size:"sm",className:"h-8",onClick:m,disabled:!o.trim(),children:e.jsx(ne,{className:"w-4 h-4"})})]})]})]}):e.jsx(zs,{currentSettings:c,newEnvKey:o,newEnvValue:p,onNewEnvKeyChange:f,onNewEnvValueChange:g,onEnvValueChange:t,onAddEnvVar:m})}),e.jsx(Ce,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Bs,{profileName:s,target:a,data:r})})]})]})})}function qs({profileName:s,profileTarget:a,onDelete:r,onHasChangesUpdate:c}){const{t:o}=Q(),[p,f]=x.useState({}),[g,t]=x.useState(!1),[m,u]=x.useState(null),[j,P]=x.useState(""),[b,O]=x.useState(""),y=Cs(),{data:k,isLoading:N,isError:R,refetch:v}=fe({queryKey:["settings",s],queryFn:async()=>{const d=await fetch(`/api/settings/${s}/raw`);if(!d.ok)throw new Error(`Failed to load settings: ${d.status}`);return d.json()}}),i=k?.settings,h=x.useMemo(()=>{if(m!==null)try{return JSON.parse(m)}catch{}if(i)return{...i,env:{...i.env,...p}}},[i,p,m]),l=x.useMemo(()=>m!==null?m:i?JSON.stringify(i,null,2):"",[m,i]),I=x.useCallback(d=>{u(d)},[]),J=x.useCallback(d=>{const w={...h??{}},_=w.ccs_image&&typeof w.ccs_image=="object"?{...w.ccs_image}:{};d?_.native_read=!0:delete _.native_read,Object.keys(_).length>0?w.ccs_image=_:delete w.ccs_image,u(JSON.stringify(w,null,2))},[h]),q=(d,w)=>{const _={...h?.env||{},[d]:w};f(G=>({...G,[d]:w})),u(JSON.stringify({...h,env:_},null,2))},ee=d=>{const w={...h?.env||{},...d};f(_=>({..._,...d})),u(JSON.stringify({...h,env:w},null,2))},U=()=>{if(!j.trim())return;const d=j.trim(),w=b,_={...h?.env||{},[d]:w};f(G=>({...G,[d]:w})),u(JSON.stringify({...h,env:_},null,2)),P(""),O("")},B=x.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),S=x.useMemo(()=>m!==null?m!==JSON.stringify(i,null,2):Object.keys(p).length>0,[m,p,i]),$=x.useDeferredValue(l),se=x.useMemo(()=>{if(!S||!B)return null;try{return JSON.parse($)}catch{return null}},[S,B,$]),{data:Y,isFetching:le,isError:V,isPlaceholderData:ce}=fe({queryKey:["settings",s,"image-analysis-status-preview",$],enabled:se!==null,placeholderData:d=>d,queryFn:async()=>{const d=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:se})});if(!d.ok)throw new Error(`Failed to preview image-analysis status: ${d.status}`);return d.json()}}),de=S&&B&&!V?Y?.imageAnalysisStatus??k?.imageAnalysisStatus:k?.imageAnalysisStatus,me=S&&B&&!V&&Y?.imageAnalysisStatus?"editor":"saved",ue=S?B?V?"saved":le&&(!Y?.imageAnalysisStatus||ce)?"refreshing":"preview":"invalid":"saved",xe=h?.ccs_image?.native_read===!0,n=x.useMemo(()=>{const d=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],w=h?.env||{};return d.filter(_=>!w[_]?.trim())},[h]);x.useEffect(()=>{c?.(S)},[S,c]);const A=ye({mutationFn:async()=>{let d;try{d=JSON.parse(l)}catch{d={...k?.settings,env:{...k?.settings?.env,...p}}}const w=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:d,expectedMtime:k?.mtime})});if(w.status===409)throw new Error("CONFLICT");if(!w.ok)throw new Error("Failed to save");return w.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["settings",s]}),y.invalidateQueries({queryKey:["profiles"]}),f({}),u(null),E.success(ae.t("commonToast.settingsSaved"))},onError:d=>{d.message==="CONFLICT"?t(!0):E.error(d.message)}}),T=ye({mutationFn:async d=>(await Le.profiles.update(s,{target:d}),d),onSuccess:()=>{y.invalidateQueries({queryKey:["profiles"]}),E.success(ae.t("commonToast.defaultTargetUpdated"))},onError:(d,w)=>{const _=w==="droid"?"Factory Droid":w==="codex"?"Codex CLI":"Claude Code",G=d.message.trim()?`: ${d.message}`:"";E.error(ae.t("commonToast.failedUpdateDefaultTarget",{target:_,suffix:G}))}}),F=a||"claude",D=A.isPending||T.isPending,K=async d=>{t(!1),d?(await v(),A.mutate()):(f({}),u(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Us,{profileName:s,target:F,data:k,settings:h,isLoading:N,isSaving:A.isPending,isTargetSaving:T.isPending,hasChanges:S,isRawJsonValid:B,onTargetChange:d=>{D||d!==F&&T.mutate(d)},onRefresh:()=>{D||v()},onDelete:r,onSave:()=>{D||A.mutate()}}),N?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(re,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:o("settingsDialog.loadingSettings")})]}):R?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o("settingsPage.failedLoad")}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>v(),children:[e.jsx(Z,{className:"w-4 h-4 mr-1"}),o("apiProfiles.retry")]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Js,{profileName:s,target:F,data:k,currentSettings:h,newEnvKey:j,newEnvValue:b,onNewEnvKeyChange:P,onNewEnvValueChange:O,onEnvValueChange:q,onEnvBulkChange:ee,onAddEnvVar:U})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Os,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:o("rawEditorSection.rawConfig")})]}),e.jsx(ds,{rawJsonContent:l,isRawJsonValid:B,rawJsonEdits:m,settings:i,profileTarget:F,imageAnalysisStatus:de,imageAnalysisStatusSource:me,imageAnalysisStatusPreviewState:ue,nativeReadPreferenceOverride:xe,onToggleNativeRead:J,onChange:I,missingRequiredFields:n})]})]}),e.jsx(je,{open:g,title:o("settingsDialog.conflictTitle"),description:o("settingsDialog.conflictDesc"),confirmText:o("settingsDialog.overwrite"),variant:"destructive",onConfirm:()=>K(!0),onCancel:()=>K(!1)})]},s)}const Te="ccs:openrouter-banner-dismissed";function Ws({onCreateClick:s}){const{t:a}=Q(),[r,c]=x.useState(!0),{modelCount:o,isLoading:p}=ve();x.useEffect(()=>{const g=localStorage.getItem(Te)==="true";c(g)},[]);const f=()=>{localStorage.setItem(Te,"true"),c(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[a("openrouterBadge.new"),": ",a("openrouterBadge.integration")]}),e.jsx("p",{className:"text-xs text-white/80 truncate",children:a("openrouterBanner.accessModels",{count:p?300:o})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(C,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:a("openrouterBanner.add")}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(Ne,{className:"w-3 h-3"})]}),e.jsxs(C,{size:"icon",variant:"ghost",onClick:f,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Ts,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Ys(){return fe({queryKey:["profiles","local-runtime-readiness"],queryFn:()=>Le.profiles.getLocalRuntimeReadiness(),staleTime:15e3,refetchOnWindowFocus:!1})}function X({badge:s,badgeClassName:a,className:r,title:c,description:o,visual:p,highlights:f,actionLabel:g,actionClassName:t,onAction:m,footer:u}){return e.jsxs(Qe,{className:H("flex h-full flex-col border shadow-sm",r),children:[e.jsxs(ms,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[p,e.jsx(L,{variant:"secondary",className:a,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(us,{className:"text-base",children:c}),e.jsx(xs,{className:"text-sm leading-6",children:o})]})]}),e.jsxs(Fe,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:f.map(j=>e.jsxs("div",{className:"flex items-center gap-2",children:[j.icon,e.jsx("span",{children:j.label})]},j.label))}),e.jsxs(C,{onClick:m,className:t,children:[g,e.jsx(As,{className:"ml-2 h-4 w-4"})]}),u?e.jsx("div",{className:"text-xs text-muted-foreground",children:u}):null]})]})}function Ee(s,a,r){return s?s.status==="ready"?{badge:r("openrouterQuickStart.localRuntimeReadyBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",actionLabel:r("openrouterQuickStart.localRuntimeUseAction",{label:a}),description:r("openrouterQuickStart.localRuntimeReadyDescription"),footer:r("openrouterQuickStart.localRuntimeReadyFooter",{endpoint:s.endpoint})}:s.status==="missing-model"?{badge:r("openrouterQuickStart.localRuntimeNeedsModelBadge"),badgeClassName:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",actionLabel:r("openrouterQuickStart.localRuntimeFinishAction",{label:a}),description:r("openrouterQuickStart.localRuntimeNeedsModelDescription"),footer:r("openrouterQuickStart.localRuntimeMissingModelFooter",{command:s.commandHint})}:{badge:r("openrouterQuickStart.localRuntimeOfflineBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:r("openrouterQuickStart.localRuntimeSetupAction",{label:a}),description:r("openrouterQuickStart.localRuntimeOfflineDescription"),footer:r("openrouterQuickStart.localRuntimeOfflineFooter",{command:s.commandHint})}:{badge:r("openrouterQuickStart.localRuntimeCheckingBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:r("openrouterQuickStart.localRuntimeSetupAction",{label:a}),description:r("openrouterQuickStart.localRuntimeCheckingDescription"),footer:r("openrouterQuickStart.localRuntimeCheckingFooter")}}function Vs({hasProfiles:s,profileCount:a,onOpenRouterClick:r,onAlibabaCodingPlanClick:c,onCliproxyClick:o,onCustomClick:p,onOllamaClick:f,onLlamacppClick:g}){const{t}=Q(),{modelCount:m,isLoading:u}=ve(),{data:j}=Ys(),P=u?"300+":`${m}+`,b=s?t("openrouterQuickStart.profileSummaryCount",{count:a}):t("openrouterQuickStart.profileSummaryEmpty"),O=t(s?"openrouterQuickStart.summaryExistingTitle":"openrouterQuickStart.summaryEmptyTitle"),y=s?t("openrouterQuickStart.summaryExistingDescription",{count:a}):t("openrouterQuickStart.summaryEmptyDescription"),k=j?.runtimes.find(i=>i.id==="ollama"),N=j?.runtimes.find(i=>i.id==="llamacpp"),R=Ee(k,t("openrouterQuickStart.localOllamaLabel"),t),v=Ee(N,t("openrouterQuickStart.localLlamacppLabel"),t);return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-5",children:[e.jsx(Qe,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Fe,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:b}),e.jsx(L,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeDefaultQuality")}),e.jsx(L,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeLocalLane")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:O}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:y})]})]}),e.jsx(C,{variant:"outline",onClick:p,className:"shrink-0",children:t("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"h-4 w-4 text-accent"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.qualityLanesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(X,{badge:t("openrouterQuickStart.recommended"),title:t("openrouterQuickStart.title"),description:t("openrouterQuickStart.description",{modelCountLabel:P}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(ze,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.featureOneApi")},{icon:e.jsx(ie,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.qualityLaneHighlightDefaultQuality")}],actionLabel:t("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:r,footer:e.jsxs(e.Fragment,{children:[t("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(Ne,{className:"h-3 w-3"})]})]})}),e.jsx(X,{badge:t("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",title:t("alibabaCodingPlanQuickStart.title"),description:t("openrouterQuickStart.alibabaLaneDescription"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Be,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ke,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("openrouterQuickStart.alibabaLaneHighlightQuality")}],actionLabel:t("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:c,footer:e.jsxs(e.Fragment,{children:[t("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(Ne,{className:"h-3 w-3"})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-emerald-600"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.localRuntimesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(X,{badge:R.badge,badgeClassName:R.badgeClassName,title:t("openrouterQuickStart.localOllamaTitle"),description:R.description,visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx("img",{src:"/icons/ollama.svg",alt:"Ollama",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Rs,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.localOllamaHighlight")},{icon:e.jsx(ie,{className:"h-3.5 w-3.5 text-emerald-600"}),label:k?.detectedModelCount&&k.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:k.detectedModelCount}):t("openrouterQuickStart.localNoModelsDetected")}],actionLabel:R.actionLabel,actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:f,footer:e.jsx("span",{children:R.footer})}),e.jsx(X,{badge:v.badge,badgeClassName:v.badgeClassName,title:t("openrouterQuickStart.localLlamacppTitle"),description:v.description,visual:e.jsx("div",{className:"rounded-lg bg-sky-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/llama-cpp.svg",alt:"llama.cpp",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(pe,{className:"h-3.5 w-3.5 text-sky-600"}),label:t("openrouterQuickStart.localLlamacppHighlight")},{icon:e.jsx(Se,{className:"h-3.5 w-3.5 text-sky-600"}),label:N?.detectedModelCount&&N.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:N.detectedModelCount}):t("openrouterQuickStart.localWaitingServer")}],actionLabel:v.actionLabel,actionClassName:"w-full bg-sky-600 text-white hover:bg-sky-600/90",onAction:g,footer:e.jsx("span",{children:v.footer})})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:e.jsx(X,{badge:t("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:t("openrouterQuickStart.runtimeProviderTitle"),description:t("openrouterQuickStart.runtimeProviderManagedDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(pe,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(pe,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ke,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:t("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:o,footer:e.jsx("span",{children:t("openrouterQuickStart.runtimeProviderFooter")})})})]})})}function Gs({onCreateClick:s}){const{t:a}=Q();return ve(),e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:a("openrouterPromoCard.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a("openrouterPromoCard.description")})]}),e.jsxs(C,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(ze,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:a("openrouterBanner.add")})]})]})})}function Xs({onCreateClick:s}){const{t:a}=Q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:a("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(C,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Be,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:a("alibabaCodingPlanPromo.add")})]})]})})}function ut(){const{t:s}=Q(),a=We(),{data:r,isLoading:c,isError:o,refetch:p}=hs(),f=ps(),g=gs(),t=fs(),m=js(),u=Ns(),j=vs(),[P,b]=x.useState(null),[O,y]=x.useState(""),[k,N]=x.useState(!1),[R,v]=x.useState("normal"),[i,h]=x.useState(null),[l,I]=x.useState(!1),[J,q]=x.useState(null),ee=x.useRef(null);bs();const U=x.useMemo(()=>r?.profiles||[],[r?.profiles]),B=x.useMemo(()=>U.filter(n=>n.name.toLowerCase().includes(O.toLowerCase())),[U,O]),S=P?U.find(n=>n.name===P):null,$=n=>{l&&P!==n?q(n):b(n)},se=n=>{f.mutate(n,{onSuccess:()=>{P===n&&(b(null),I(!1),q(null)),h(null)}})},Y=n=>{N(!1),$(n)},le=n=>{$(n)},V=(n,A)=>{const T=JSON.stringify(A,null,2)+`
2
2
  `,F=new Blob([T],{type:"application/json"}),D=URL.createObjectURL(F),K=document.createElement("a");K.href=D,K.download=n,document.body.appendChild(K),K.click(),K.remove(),URL.revokeObjectURL(D)},ce=async()=>{try{const n=await g.mutateAsync();if(n.orphans.length===0){E.success(s("apiProfiles.noOrphansFound"));return}const A=n.orphans.filter(K=>K.validation.valid).length;if(!window.confirm(s("apiProfiles.confirmRegisterOrphans",{total:n.orphans.length,valid:A})))return;const F=await t.mutateAsync({}),D=F.skipped.length>0?s("apiProfiles.registeredWithSkipped",{count:F.skipped.length}):"";E.success(s("apiProfiles.registeredProfiles",{count:F.registered.length})+D)}catch(n){E.error(n.message)}},de=async()=>{if(!S)return;const n=window.prompt(s("apiProfiles.copyPrompt",{name:S.name}),`${S.name}-copy`);if(!n)return;const A=n.trim();if(!A){E.error(s("apiProfiles.destinationEmpty"));return}try{const T=await m.mutateAsync({name:S.name,data:{destination:A}});$(A),T.warnings&&T.warnings.length>0&&E.info(T.warnings.join(`
3
3
  `))}catch(T){E.error(T.message)}},me=async()=>{if(S)try{const n=await u.mutateAsync({name:S.name});V(`${S.name}.ccs-profile.json`,n.bundle),n.redacted?E.info(s("apiProfiles.exportRedacted")):E.success(s("apiProfiles.exportDownloaded"))}catch(n){E.error(n.message)}},ue=()=>{ee.current?.click()},xe=async n=>{const A=n.target.files?.[0];if(n.target.value="",!!A)try{const T=await A.text(),F=JSON.parse(T),D=await j.mutateAsync({bundle:F});D.name&&$(D.name),D.warnings&&D.warnings.length>0&&E.info(D.warnings.join(`
4
4
  `))}catch(T){E.error(T.message||s("apiProfiles.importFailed"))}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(Ws,{onCreateClick:()=>N(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ds,{className:"w-5 h-5 text-primary"}),e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.sidebarTitle")})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(C,{size:"sm",variant:"outline",onClick:()=>void ce(),disabled:g.isPending||t.isPending,"aria-label":s("apiProfiles.discoverOrphans"),title:s("apiProfiles.discoverOrphans"),children:e.jsx(Z,{className:`w-4 h-4 ${g.isPending?"animate-spin":""}`})}),e.jsx(C,{size:"sm",variant:"outline",onClick:ue,disabled:j.isPending,"aria-label":s("apiProfiles.importProfileBundle"),title:s("apiProfiles.importProfileBundle"),children:e.jsx(_s,{className:"w-4 h-4"})}),e.jsxs(C,{size:"sm",onClick:()=>{N(!0)},children:[e.jsx(ne,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsx("p",{className:"mb-3 text-xs leading-4 text-muted-foreground",children:s("apiProfiles.sidebarSubtitle")}),e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(z,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:O,onChange:n=>y(n.target.value)})]})]}),e.jsx(oe,{className:"flex-1 min-h-0",children:c?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):o?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ke,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>p(),children:[e.jsx(Z,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):B.length===0?e.jsx("div",{className:"p-4 text-center",children:U.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ms,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{N(!0)},children:[e.jsx(ne,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:O})})}):e.jsx("div",{className:"p-2 space-y-1",children:B.map(n=>e.jsx(Zs,{profile:n,isSelected:P===n.name,onSelect:()=>le(n.name),onDelete:()=>h(n.name)},n.name))})}),U.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:U.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($e,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:U.filter(n=>n.configured).length})]})]})}),e.jsx(Gs,{onCreateClick:()=>{v("openrouter"),N(!0)}}),e.jsx(Xs,{onCreateClick:()=>{v("alibaba-coding-plan"),N(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:S?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>void de(),disabled:m.isPending,children:[e.jsx(Ls,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>void me(),disabled:u.isPending,children:[e.jsx(Qs,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(qs,{profileName:S.name,profileTarget:S.target,onDelete:()=>h(S.name),onHasChangesUpdate:I},S.name)]}):e.jsx(Vs,{hasProfiles:U.length>0,profileCount:U.length,onCliproxyClick:()=>{a("/cliproxy/ai-providers")},onOpenRouterClick:()=>{v("openrouter"),N(!0)},onAlibabaCodingPlanClick:()=>{v("alibaba-coding-plan"),N(!0)},onOllamaClick:()=>{v("ollama"),N(!0)},onLlamacppClick:()=>{v("llamacpp"),N(!0)},onCustomClick:()=>{v("normal"),N(!0)}})})]}),e.jsx("input",{ref:ee,type:"file",accept:".json,application/json",className:"hidden",onChange:n=>void xe(n)}),e.jsx(ws,{open:k,onOpenChange:N,onSuccess:Y,initialMode:R}),e.jsx(je,{open:!!i,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:i??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>i&&se(i),onCancel:()=>h(null)}),e.jsx(je,{open:!!J,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:P??"",next:J??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{I(!1),b(J),q(null)},onCancel:()=>q(null)})]})}function Zs({profile:s,isSelected:a,onSelect:r,onDelete:c}){return e.jsxs("div",{className:H("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:r,children:[s.configured?e.jsx($e,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Ke,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(L,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(W,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:o=>{o.stopPropagation(),c()},children:e.jsx(He,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{ut as ApiPage};
@@ -1 +1 @@
1
- import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bv as W,be as X,bg as Y,n as Z,I as C,d as c}from"./index-BDfXfBTa.js";import{R as E,w as _,x as ee,n as se,E as K,g as T,m as R,o as z,ah as te,aa as ae,Q as ne,at 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";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,b]=n.useState(!1),[F,k]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const M=await A.json();throw new Error(M.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},J=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),b(!0),setTimeout(()=>b(!1),2e3))},L=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))},Q=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)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(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const q=d??a.apiKey.value,G=u??a.managementSecret.value,H=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;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 ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{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("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:q,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:G,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:L,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:B,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:Q,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!H||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};
1
+ import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,br as W,be as X,bg as Y,n as Z,I as C,d as c}from"./index-g2g1k0QS.js";import{R as E,w as _,x as ee,n as se,E as K,g as T,m as R,o as z,ah as te,aa as ae,Q as ne,at 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";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,b]=n.useState(!1),[F,k]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const M=await A.json();throw new Error(M.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},J=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),b(!0),setTimeout(()=>b(!1),2e3))},L=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))},Q=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)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(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const q=d??a.apiKey.value,G=u??a.managementSecret.value,H=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;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 ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{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("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:q,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:G,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:L,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:B,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:Q,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!H||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};