@kaitranntt/ccs 7.68.1-dev.9 → 7.68.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/commands/create-command-env.d.ts +0 -1
- package/dist/auth/commands/create-command-env.d.ts.map +1 -1
- package/dist/ccs.js +2 -55
- package/dist/ccs.js.map +1 -1
- package/dist/channels/official-channels-runtime.d.ts +0 -1
- package/dist/channels/official-channels-runtime.d.ts.map +1 -1
- package/dist/channels/official-channels-store.d.ts +0 -1
- package/dist/channels/official-channels-store.d.ts.map +1 -1
- package/dist/cliproxy/base-config-loader.d.ts +0 -1
- package/dist/cliproxy/base-config-loader.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +0 -1
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/extended-context-config.d.ts +0 -1
- package/dist/cliproxy/config/extended-context-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts +0 -1
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +0 -2
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +1 -2
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +1 -28
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-id-normalizer.d.ts +0 -1
- package/dist/cliproxy/model-id-normalizer.d.ts.map +1 -1
- package/dist/cliproxy/routing-strategy-http.d.ts +0 -1
- package/dist/cliproxy/routing-strategy-http.d.ts.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.d.ts.map +1 -1
- package/dist/cliproxy/tool-sanitization-proxy.js +3 -0
- package/dist/cliproxy/tool-sanitization-proxy.js.map +1 -1
- package/dist/cliproxy/types.d.ts +0 -2
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/commands/cliproxy/catalog-subcommand.d.ts +0 -6
- package/dist/commands/cliproxy/catalog-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/catalog-subcommand.js +1 -39
- package/dist/commands/cliproxy/catalog-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +0 -1
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +0 -6
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/command-catalog.d.ts +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.d.ts +0 -2
- package/dist/commands/cursor-command-display.d.ts.map +1 -1
- package/dist/commands/cursor-command-display.js +3 -24
- package/dist/commands/cursor-command-display.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +1 -31
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/config/migration-manager.d.ts.map +1 -1
- package/dist/config/migration-manager.js +1 -2
- package/dist/config/migration-manager.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +3 -8
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +7 -20
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +2 -15
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +3 -8
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/cursor/constants.d.ts +1 -1
- package/dist/cursor/constants.d.ts.map +1 -1
- package/dist/cursor/constants.js +0 -1
- package/dist/cursor/constants.js.map +1 -1
- package/dist/cursor/cursor-anthropic-response.d.ts +0 -1
- package/dist/cursor/cursor-anthropic-response.d.ts.map +1 -1
- package/dist/cursor/cursor-auth.d.ts +0 -1
- package/dist/cursor/cursor-auth.d.ts.map +1 -1
- package/dist/cursor/cursor-auth.js +32 -154
- package/dist/cursor/cursor-auth.js.map +1 -1
- package/dist/cursor/cursor-executor.d.ts +1 -2
- package/dist/cursor/cursor-executor.d.ts.map +1 -1
- package/dist/cursor/cursor-executor.js +160 -295
- package/dist/cursor/cursor-executor.js.map +1 -1
- package/dist/cursor/cursor-protobuf-decoder.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf-decoder.js +3 -1
- package/dist/cursor/cursor-protobuf-decoder.js.map +1 -1
- package/dist/cursor/cursor-protobuf-schema.d.ts +3 -12
- package/dist/cursor/cursor-protobuf-schema.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf-schema.js +5 -23
- package/dist/cursor/cursor-protobuf-schema.js.map +1 -1
- package/dist/cursor/cursor-protobuf.d.ts +1 -1
- package/dist/cursor/cursor-protobuf.d.ts.map +1 -1
- package/dist/cursor/cursor-protobuf.js +4 -2
- package/dist/cursor/cursor-protobuf.js.map +1 -1
- package/dist/cursor/cursor-stream-parser.d.ts +0 -10
- package/dist/cursor/cursor-stream-parser.d.ts.map +1 -1
- package/dist/cursor/cursor-stream-parser.js +10 -106
- package/dist/cursor/cursor-stream-parser.js.map +1 -1
- package/dist/cursor/index.d.ts +0 -1
- package/dist/cursor/index.d.ts.map +1 -1
- package/dist/cursor/index.js +1 -3
- package/dist/cursor/index.js.map +1 -1
- package/dist/cursor/types.d.ts +0 -6
- package/dist/cursor/types.d.ts.map +1 -1
- package/dist/docker/docker-executor.d.ts +0 -1
- package/dist/docker/docker-executor.d.ts.map +1 -1
- package/dist/management/instance-manager.d.ts.map +1 -1
- package/dist/management/instance-manager.js +2 -5
- package/dist/management/instance-manager.js.map +1 -1
- package/dist/targets/claude-adapter.d.ts +1 -6
- package/dist/targets/claude-adapter.d.ts.map +1 -1
- package/dist/targets/claude-adapter.js +2 -6
- package/dist/targets/claude-adapter.js.map +1 -1
- package/dist/targets/codex-adapter.d.ts +0 -1
- package/dist/targets/codex-adapter.d.ts.map +1 -1
- package/dist/targets/codex-adapter.js +8 -12
- package/dist/targets/codex-adapter.js.map +1 -1
- package/dist/targets/droid-adapter.d.ts +1 -3
- package/dist/targets/droid-adapter.d.ts.map +1 -1
- package/dist/targets/droid-adapter.js +2 -3
- package/dist/targets/droid-adapter.js.map +1 -1
- package/dist/targets/target-adapter.d.ts +0 -5
- package/dist/targets/target-adapter.d.ts.map +1 -1
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/ui/assets/{accounts-D9eEaNx9.js → accounts-DjL3iVZW.js} +1 -1
- package/dist/ui/assets/{alert-dialog-QyEXocpn.js → alert-dialog-Tc_D1a_B.js} +1 -1
- package/dist/ui/assets/{api-7vQe0xOg.js → api-CUtkvXmX.js} +1 -1
- package/dist/ui/assets/{auth-section-BszF77uT.js → auth-section-CuKWQHC7.js} +1 -1
- package/dist/ui/assets/{backups-section-D6RgaOx1.js → backups-section-BKW2pbb9.js} +1 -1
- package/dist/ui/assets/{channels-B1vgnNJX.js → channels-DvWJMdaq.js} +1 -1
- package/dist/ui/assets/{checkbox-Dzwkj_Pg.js → checkbox-B0hZxMK5.js} +1 -1
- package/dist/ui/assets/{claude-extension-CKO4bJ22.js → claude-extension-Dfqu-rev.js} +1 -1
- package/dist/ui/assets/{cliproxy-kHd-oC5W.js → cliproxy-C9RxW-I8.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-CmbFYVoR.js → cliproxy-ai-providers-BXLuuxNf.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-M8ZfUq3C.js → cliproxy-control-panel-aQ7cCc2U.js} +1 -1
- package/dist/ui/assets/{codex-BJ0RdMuh.js → codex-aq4RI6_n.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BlSaX2gK.js → confirm-dialog-CpDk6eu4.js} +1 -1
- package/dist/ui/assets/{copilot-NJKZQXQ_.js → copilot-CQRpGXvY.js} +1 -1
- package/dist/ui/assets/cursor-BpXPf6qi.js +1 -0
- package/dist/ui/assets/{droid-B9u9ZB-a.js → droid-Cgx-yLjy.js} +1 -1
- package/dist/ui/assets/{globalenv-section-DoX37DqB.js → globalenv-section-DsNqG1yB.js} +1 -1
- package/dist/ui/assets/{health-D_gdcxnc.js → health-BY-O-JcA.js} +1 -1
- package/dist/ui/assets/index-BmSzf0T9.js +72 -0
- package/dist/ui/assets/{index-DFEMq3KP.js → index-CLGiPB3A.js} +1 -1
- package/dist/ui/assets/{index-CTGpqIx6.js → index-Cet36v1V.js} +1 -1
- package/dist/ui/assets/index-DH6L6ybH.js +1 -0
- package/dist/ui/assets/{index-BNU4Hhe_.js → index-DsCjnpco.js} +1 -1
- package/dist/ui/assets/{index-DoVPk3vW.js → index-TQFuDZdB.js} +1 -1
- package/dist/ui/assets/index-teLjoh2T.css +1 -0
- package/dist/ui/assets/{logs-DtH4YMt4.js → logs-D5ro-pc7.js} +1 -1
- package/dist/ui/assets/{masked-input-C2H-Ax0Z.js → masked-input-h0XkMSwB.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-BOrsn86w.js → proxy-status-widget-yBdrFeb7.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-WxTn7-hS.js → raw-json-settings-editor-panel-Cb7ZInQV.js} +1 -1
- package/dist/ui/assets/{searchable-select-1zOULoec.js → searchable-select-D4xr5xKS.js} +1 -1
- package/dist/ui/assets/{separator-BCfZ54mZ.js → separator-gw5BjIpP.js} +1 -1
- package/dist/ui/assets/{shared-DlTbnc9n.js → shared-C-VeA1Z9.js} +1 -1
- package/dist/ui/assets/{table-Bx2cnkWN.js → table-Bd4isC18.js} +1 -1
- package/dist/ui/assets/{updates-SiZKOnUD.js → updates-DiK8I67C.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/claude-detector.d.ts +0 -1
- package/dist/utils/claude-detector.d.ts.map +1 -1
- package/dist/utils/claude-spawner.d.ts +0 -1
- package/dist/utils/claude-spawner.d.ts.map +1 -1
- package/dist/utils/hooks/image-analysis-runtime-status.js +5 -5
- package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
- package/dist/utils/image-analysis/claude-tool-args.d.ts +0 -3
- package/dist/utils/image-analysis/claude-tool-args.d.ts.map +1 -1
- package/dist/utils/image-analysis/claude-tool-args.js +47 -21
- package/dist/utils/image-analysis/claude-tool-args.js.map +1 -1
- package/dist/utils/package-manager-detector.d.ts +0 -1
- package/dist/utils/package-manager-detector.d.ts.map +1 -1
- package/dist/utils/shell-executor.d.ts +0 -1
- package/dist/utils/shell-executor.d.ts.map +1 -1
- package/dist/utils/websearch/claude-tool-args.d.ts +0 -7
- package/dist/utils/websearch/claude-tool-args.d.ts.map +1 -1
- package/dist/utils/websearch/claude-tool-args.js +50 -27
- package/dist/utils/websearch/claude-tool-args.js.map +1 -1
- package/dist/utils/websearch/hook-env.d.ts.map +1 -1
- package/dist/utils/websearch/hook-env.js +1 -19
- package/dist/utils/websearch/hook-env.js.map +1 -1
- package/dist/utils/websearch/status.d.ts +1 -1
- package/dist/utils/websearch/status.d.ts.map +1 -1
- package/dist/utils/websearch/status.js +12 -33
- package/dist/utils/websearch/status.js.map +1 -1
- package/dist/utils/websearch/trace.d.ts +0 -1
- package/dist/utils/websearch/trace.d.ts.map +1 -1
- package/dist/utils/websearch/trace.js +5 -20
- package/dist/utils/websearch/trace.js.map +1 -1
- package/dist/utils/websearch/types.d.ts +2 -12
- package/dist/utils/websearch/types.d.ts.map +1 -1
- package/dist/utils/websearch/types.js +0 -38
- package/dist/utils/websearch/types.js.map +1 -1
- package/dist/web-server/health/websearch-checks.js +1 -1
- package/dist/web-server/health/websearch-checks.js.map +1 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +1 -0
- package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-local-proxy.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-local-proxy.js +6 -26
- package/dist/web-server/routes/cliproxy-local-proxy.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +1 -8
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-routes.d.ts +0 -2
- package/dist/web-server/routes/cursor-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cursor-routes.js +2 -44
- package/dist/web-server/routes/cursor-routes.js.map +1 -1
- package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
- package/dist/web-server/routes/websearch-routes.js +0 -37
- package/dist/web-server/routes/websearch-routes.js.map +1 -1
- package/dist/web-server/services/cliproxy-dashboard-install-service.d.ts.map +1 -1
- package/dist/web-server/services/cliproxy-dashboard-install-service.js +0 -14
- package/dist/web-server/services/cliproxy-dashboard-install-service.js.map +1 -1
- package/dist/web-server/services/codex-dashboard-service.d.ts +0 -1
- package/dist/web-server/services/codex-dashboard-service.d.ts.map +1 -1
- package/dist/web-server/services/droid-dashboard-service.d.ts +0 -1
- package/dist/web-server/services/droid-dashboard-service.d.ts.map +1 -1
- package/lib/hooks/websearch-transformer.cjs +0 -136
- package/lib/mcp/ccs-websearch-server.cjs +1 -1
- package/package.json +1 -2
- package/dist/cursor/cursor-runtime-probe.d.ts +0 -12
- package/dist/cursor/cursor-runtime-probe.d.ts.map +0 -1
- package/dist/cursor/cursor-runtime-probe.js +0 -220
- package/dist/cursor/cursor-runtime-probe.js.map +0 -1
- package/dist/docker/supervisord-lifecycle.d.ts +0 -17
- package/dist/docker/supervisord-lifecycle.d.ts.map +0 -1
- package/dist/docker/supervisord-lifecycle.js +0 -58
- package/dist/docker/supervisord-lifecycle.js.map +0 -1
- package/dist/ui/assets/cursor-BrcDgu6X.js +0 -1
- package/dist/ui/assets/index-Cu6e0-ev.css +0 -1
- package/dist/ui/assets/index-DOn6k1jF.js +0 -72
- package/dist/ui/assets/index-h08p9xL5.js +0 -1
- package/dist/utils/browser/chrome-reuse.d.ts +0 -17
- package/dist/utils/browser/chrome-reuse.d.ts.map +0 -1
- package/dist/utils/browser/chrome-reuse.js +0 -205
- package/dist/utils/browser/chrome-reuse.js.map +0 -1
- package/dist/utils/browser/claude-tool-args.d.ts +0 -2
- package/dist/utils/browser/claude-tool-args.d.ts.map +0 -1
- package/dist/utils/browser/claude-tool-args.js +0 -18
- package/dist/utils/browser/claude-tool-args.js.map +0 -1
- package/dist/utils/browser/index.d.ts +0 -8
- package/dist/utils/browser/index.d.ts.map +0 -1
- package/dist/utils/browser/index.js +0 -24
- package/dist/utils/browser/index.js.map +0 -1
- package/dist/utils/browser/mcp-installer.d.ts +0 -14
- package/dist/utils/browser/mcp-installer.d.ts.map +0 -1
- package/dist/utils/browser/mcp-installer.js +0 -356
- package/dist/utils/browser/mcp-installer.js.map +0 -1
- package/dist/utils/browser-codex-overrides.d.ts +0 -3
- package/dist/utils/browser-codex-overrides.d.ts.map +0 -1
- package/dist/utils/browser-codex-overrides.js +0 -29
- package/dist/utils/browser-codex-overrides.js.map +0 -1
- package/dist/utils/claude-tool-args.d.ts +0 -7
- package/dist/utils/claude-tool-args.d.ts.map +0 -1
- package/dist/utils/claude-tool-args.js +0 -43
- package/dist/utils/claude-tool-args.js.map +0 -1
- package/dist/utils/prompt-injection-strategy.d.ts +0 -54
- package/dist/utils/prompt-injection-strategy.d.ts.map +0 -1
- package/dist/utils/prompt-injection-strategy.js +0 -128
- package/dist/utils/prompt-injection-strategy.js.map +0 -1
- package/lib/mcp/ccs-browser-server.cjs +0 -877
|
@@ -1 +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-Bx2cnkWN.js";import{Y as O,a as z,ag as de,ah as ue,ai as xe,aj as me,ak as he,L as T,I as V,x as D,aC as Se,d as b,B as P,C as M,b as R,e as Ge,f as Me,g as Re,n as Oe,j as I,k as q,_ as Q}from"./index-DOn6k1jF.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-QyEXocpn.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-Dzwkj_Pg.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Z(a){return Array.from(a).sort((r,t)=>r.localeCompare(t))}function We(a){const r=new Map;for(const n of a){if(n.context_mode!=="shared")continue;const h=n.context_group||"default",m=r.get(h)??{group:h,sharedCount:0,deeperCount:0,accountNames:[]};m.sharedCount+=1,m.accountNames.push(n.name),n.continuity_mode==="deeper"&&(m.deeperCount+=1),r.set(h,m)}const t=Array.from(r.values()).sort((n,h)=>n.group.localeCompare(h.group)),u=a.map(n=>{if(n.context_mode!=="shared")return{...n,sameGroupPeerCount:0,sameGroupDeeperPeerCount:0};const h=n.context_group||"default",m=r.get(h),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=u.filter(n=>n.context_mode==="shared").length,i=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode==="deeper").length,c=u.filter(n=>n.context_inferred).length,p=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode!=="deeper"&&n.continuity_inferred).length;return{accounts:u,sharedCount:s,sharedStandardCount:Math.max(s-i,0),deeperSharedCount:i,isolatedCount:u.length-s,legacyContextCount:c,legacyContinuityCount:p,sharedAloneCount:u.filter(n=>n.context_mode==="shared"&&n.sameGroupPeerCount===0).length,sharedPeerAccountCount:u.filter(n=>n.sameGroupPeerCount>0).length,deeperReadyAccountCount:u.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:()=>O.accounts.list(),select:a=>{const r=a.accounts.filter(i=>i.type!=="cliproxy"),t=We(r),u=a.accounts.length-r.length,s=t.accounts.some(i=>i.name===a.default)?a.default:null;return{accounts:t.accounts,default:s,cliproxyCount:u,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=$();return F({mutationFn:r=>O.accounts.setDefault(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Default account set to "${t}"`)},onError:r=>{k.error(r.message)}})}function et(){const a=$();return F({mutationFn:()=>O.accounts.resetDefault(),onSuccess:()=>{a.invalidateQueries({queryKey:["accounts"]}),k.success("Default account reset to CCS")},onError:r=>{k.error(r.message)}})}function tt(){const a=$();return F({mutationFn:r=>O.accounts.delete(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Account "${t}" deleted`)},onError:r=>{k.error(r.message)}})}function be(){const a=$();return F({mutationFn:({name:r,context_mode:t,context_group:u,continuity_mode:s})=>O.accounts.updateContext(r,{context_mode:t,context_group:u,continuity_mode:s}),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]});const u=t.context_mode==="shared"?t.continuity_mode==="deeper"?`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, deeper continuity)`:`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, standard)`:"isolated";k.success(`Updated "${t.name}" context to ${u}`)},onError:r=>{k.error(r.message)}})}function st(){const a=$();return F({mutationFn:async r=>{const t=r.filter(i=>i.context_inferred||i.continuity_inferred),s=(await Promise.allSettled(t.map(i=>{const c=i.context_mode==="shared";return O.accounts.updateContext(i.name,{context_mode:c?"shared":"isolated",context_group:c?i.context_group||"default":void 0,continuity_mode:c?i.continuity_mode==="deeper"?"deeper":"standard":void 0})}))).filter(i=>i.status==="rejected").length;return{updatedCount:t.length-s,failedCount:s}},onSuccess:({updatedCount:r,failedCount:t})=>{if(a.invalidateQueries({queryKey:["accounts"]}),t>0&&r>0){k.error(`Confirmed ${r} legacy account${r>1?"s":""}, but ${t} update${t>1?"s":""} failed. Refreshed account state.`);return}if(t>0){k.error(`Failed to confirm ${t} legacy account${t>1?"s":""}. Refreshed account state.`);return}if(r>0){k.success(`Confirmed explicit sync mode for ${r} legacy account${r>1?"s":""}`);return}k.info("No legacy accounts need confirmation")},onError:r=>{a.invalidateQueries({queryKey:["accounts"]}),k.error(r.message)}})}const oe=64,at=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function nt({account:a,groupSummaries:r,plainCcsLane:t,onClose:u}){const{t:s}=z(),i=be(),[c,p]=C.useState(a.context_mode==="shared"?"shared":"isolated"),[n,h]=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]),l=C.useMemo(()=>r.find(g=>g.group===x),[r,x]),N=x.length>0&&x.length<=oe&&at.test(x),o=c==="isolated"||N,d=c==="shared"?Math.max((l?.sharedCount??0)-(a.context_mode==="shared"&&a.context_group===x?1:0),0):0,f=c==="shared"?Math.max((l?.deeperCount??0)-(a.continuity_mode==="deeper"&&a.context_group===x?1:0),0):0,v=t?.account_name===a.name,j=!!t&&!v,S=`ccs auth default ${a.name}`,_=`ccs auth backup ${a.name}`,w=(g,K,G,H)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(g.key))return;g.preventDefault();const je=G.indexOf(K),ye=g.key==="ArrowLeft"||g.key==="ArrowUp"?-1:1,Ne=(je+ye+G.length)%G.length;H(G[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:"",A=()=>{o&&i.mutate({name:a.name,context_mode:c,context_group:c==="shared"?x:void 0,continuity_mode:c==="shared"?m:void 0},{onSuccess:()=>{u()}})},B=g=>{g||u()};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(T,{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":c==="isolated",tabIndex:c==="isolated"?0:-1,onClick:()=>p("isolated"),onKeyDown:g=>w(g,c,["isolated","shared"],p),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 ${c==="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":c==="shared",tabIndex:c==="shared"?0:-1,onClick:()=>p("shared"),onKeyDown:g=>w(g,c,["isolated","shared"],p),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 ${c==="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(c==="isolated"?"editAccountContext.isolatedModeHint":"editAccountContext.sharedModeHint")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"context-group",children:s("editAccountContext.historySyncGroup")}),e.jsx(V,{id:"context-group",value:n,onChange:g=>h(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")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(T,{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(D,{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(D,{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:_}),e.jsx(D,{value:_,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:S}),e.jsx(D,{value:S,size:"icon"})]})]})]})}),e.jsx("div",{className:`rounded-[14px] border p-4 text-xs shadow-sm transition-colors ${c==="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:[c==="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:[c==="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] ${c==="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:u,disabled:i.isPending,children:s("editAccountContext.cancel")}),e.jsx(b,{onClick:A,disabled:!o||i.isPending,children:i.isPending?s("editAccountContext.saving"):s("editAccountContext.save")})]})]})})}function ce({data:a,defaultAccount:r,groupSummaries:t,plainCcsLane:u}){const{t:s}=z(),i=Je(),c=tt(),p=et(),n=be(),[h,m]=C.useState(null),[y,x]=C.useState(null),l=[{accessorKey:"name",header:s("accountsTable.name"),size:200,cell:({row:o})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:o.original.name}),o.original.name===r&&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:o})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:o.original.type||"oauth"})},{accessorKey:"created",header:s("accountsTable.created"),size:150,cell:({row:o})=>{const d=new Date(o.original.created);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{accessorKey:"last_used",header:s("accountsTable.lastUsed"),size:150,cell:({row:o})=>{if(!o.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const d=new Date(o.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{id:"context",header:s("accountsTable.historySync"),size:170,cell:({row:o})=>{if(o.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((o.original.context_mode||"isolated")==="shared"){const f=o.original.context_group||"default",v=o.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(P,{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:o.original.sameGroupPeerCount>0?s("accountsTable.sameGroupPeerCount",{count:o.original.sameGroupPeerCount}):s("accountsTable.noSameGroupPeer")})]})}return o.original.context_inferred?e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx(P,{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(P,{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:o})=>{const d=o.original.name===r,f=i.isPending||c.isPending||n.isPending,v=o.original.type==="cliproxy",j=o.original.context_inferred||o.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(o.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:o.original.name,context_mode:o.original.context_mode==="shared"?"shared":"isolated",context_group:o.original.context_mode==="shared"?o.original.context_group||"default":void 0,continuity_mode:o.original.context_mode==="shared"?o.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:()=>i.mutate(o.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(o.original.name),title:s(d?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Be,{className:"w-4 h-4"})})]})}}],N=ke({data:a,columns:l,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(o=>e.jsx(te,{children:o.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)})},o.id))}),e.jsx(_e,{children:N.getRowModel().rows.map(o=>e.jsx(te,{children:o.getVisibleCells().map(d=>e.jsx(Te,{children:ee(d.column.columnDef.cell,d.getContext())},d.id))},o.id))})]})}),r&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),s("accountsTable.resetToDefault")]})})]}),y&&e.jsx(nt,{account:y,groupSummaries:t,plainCcsLane:u,onClose:()=>x(null)}),e.jsx(ze,{open:!!h,onOpenChange:o=>!o&&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:h??""})})]}),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:()=>{h&&(c.mutate(h),m(null))},children:s("accountsTable.delete")})]})]})})]})}const X=({titleKey:a,descKey:r})=>{const{t}=z();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(Re,{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(r)})]})]})};function ie({totalAccounts:a,primaryAccountName:r,isolatedCount:t,sharedStandardCount:u,deeperSharedCount:s,sharedAloneCount:i,sharedPeerAccountCount:c,deeperReadyAccountCount:p,sharedPeerGroups:n,deeperReadyGroups:h,legacyTargetCount:m,cliproxyCount:y,plainCcsLane:x}){const{t:l}=z(),N=x?x.kind==="native"?l("continuityOverview.lane.native"):x.kind==="account-default"?l("continuityOverview.lane.accountDefault",{name:x.account_name||""}):x.kind==="account-inherited"?l("continuityOverview.lane.accountInherited",{name:x.account_name||""}):x.kind==="profile-default"?l("continuityOverview.lane.profileDefault",{name:x.profile_name||"default"}):x.label:"",o=a<2?"single":n.length===0?t===a?"isolated":"shared-alone":h.length===0?"shared-standard":t>0||i>0||p<c||h.length<n.length?"partial":"ready",d=h[0]||n[0]||"default",f=h.length>0&&(t>0||u>0||n.length>h.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"})}[o],S=!!r&&x?.account_name===r,_=a>0&&!!x&&(!r||!S),w=a>1&&o!=="ready";return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(M,{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:l(`continuityReadiness.messages.${o}.title`,{group:d})}),e.jsx(P,{variant:o==="ready"?"default":"secondary",className:"rounded-full px-2.5 py-0.5 font-medium shadow-sm",children:l(`continuityReadiness.state.${o}`)})]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg leading-relaxed",children:l(`continuityReadiness.messages.${o}.description`,{group:d,count:i})})]})]})}),e.jsxs("div",{className:"mt-auto pt-4 flex flex-wrap items-center gap-2",children:[y>0&&e.jsx(P,{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:l("historySyncLearningMap.cliproxyManaged",{count:y})}),m>0&&e.jsx(P,{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:l("historySyncLearningMap.legacyConfirmation",{count:m})}),n.length>0&&h.length===0&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.recommendBadge",{group:d})}),f&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.partialBadge",{group:d})})]})]})}),(_||w)&&e.jsx(M,{className:"border-dashed",children:e.jsxs(R,{className:"p-5 space-y-4",children:[_&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("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(D,{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(D,{value:"ccs auth backup default",size:"icon"})]}),r?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 ${r}`}),e.jsx(D,{value:`ccs auth default ${r}`,size:"icon"})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:l("continuityOverview.setDefaultHint")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityReadiness.stepsTitle")}),e.jsxs("ol",{className:"space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:l("continuityReadiness.steps.syncBoth")}),e.jsx("li",{children:l("continuityReadiness.steps.sameGroup",{group:d})}),e.jsx("li",{children:l("continuityReadiness.steps.enableDeeper")}),e.jsx("li",{children:l("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:l("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:l("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:u})]}),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:l("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 le=64;function rt({open:a,onClose:r}){const{t}=z(),[u,s]=C.useState(""),[i,c]=C.useState(!1),[p,n]=C.useState(""),[h,m]=C.useState(!1),[y,x]=C.useState(!1),l=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(u),N=p.trim().toLowerCase().replace(/\s+/g,"-"),o=N.length===0||N.length<=le&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(N),d=u&&l?[`ccs auth create ${u}`,i?N.length>0?`--context-group ${N}`:"--share-context":"",i&&h?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),f=async()=>{!l||i&&!o||(await navigator.clipboard.writeText(d),x(!0),setTimeout(()=>x(!1),2e3))},v=()=>{s(""),c(!1),n(""),m(!1),x(!1),r()};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(T,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx(V,{id:"profile-name",value:u,onChange:j=>s(j.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),u&&!l&&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:i,onCheckedChange:j=>c(j===!0)}),e.jsx(T,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),i&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(T,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx(V,{id:"context-group",value:p,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:h,onCheckedChange:j=>m(j===!0)}),e.jsx(T,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),p.trim().length>0&&!o&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:le})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{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:!l||i&&!o,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:!l||i&&!o,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}=z(),r=ve(),{data:t,isLoading:u}=Ye(),s=st(),[i,c]=C.useState(!1),p=t?.accounts||[],n=t?.cliproxyCount||0,h=t?.legacyContextCount||0,m=t?.legacyContinuityCount||0,y=t?.sharedCount||0,x=t?.sharedStandardCount||0,l=t?.deeperSharedCount||0,N=t?.isolatedCount||0,o=t?.sharedAloneCount||0,d=t?.sharedPeerAccountCount||0,f=t?.deeperReadyAccountCount||0,v=t?.sharedPeerGroups||[],j=t?.deeperReadyGroups||[],S=t?.sharedGroups||[],_=t?.groupSummaries||[],w=t?.plainCcsLane||null,L=p.filter(H=>H.context_inferred||H.continuity_inferred),A=L.length,B=A>0,g=()=>r("/cliproxy?provider=claude"),K=()=>r("/cliproxy?provider=claude&action=auth"),G=()=>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(Oe,{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:()=>c(!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:[h>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContextPending",{count:h})}),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:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:a("accountsPage.noLegacyFollowup")}),e.jsxs(M,{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(D,{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(D,{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(P,{variant:"outline",children:a("accountsPage.workspaceBadge")}),e.jsx(P,{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(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{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:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(M,{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:()=>c(!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:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}),e.jsx(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{children:[e.jsx(I,{className:"pb-3",children:e.jsx(q,{className:"text-base",children:a("accountsPage.accountMatrix")})}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]}),e.jsx(rt,{open:i,onClose:()=>c(!1)})]})}export{bt as AccountsPage};
|
|
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-Bd4isC18.js";import{Y as O,a as z,ag as de,ah as ue,ai as xe,aj as me,ak as he,L as T,I as V,x as D,aC as Se,d as b,B as P,C as M,b as R,e as Ge,f as Me,g as Re,n as Oe,j as I,k as q,_ as Q}from"./index-BmSzf0T9.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-Tc_D1a_B.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-B0hZxMK5.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Z(a){return Array.from(a).sort((r,t)=>r.localeCompare(t))}function We(a){const r=new Map;for(const n of a){if(n.context_mode!=="shared")continue;const h=n.context_group||"default",m=r.get(h)??{group:h,sharedCount:0,deeperCount:0,accountNames:[]};m.sharedCount+=1,m.accountNames.push(n.name),n.continuity_mode==="deeper"&&(m.deeperCount+=1),r.set(h,m)}const t=Array.from(r.values()).sort((n,h)=>n.group.localeCompare(h.group)),u=a.map(n=>{if(n.context_mode!=="shared")return{...n,sameGroupPeerCount:0,sameGroupDeeperPeerCount:0};const h=n.context_group||"default",m=r.get(h),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=u.filter(n=>n.context_mode==="shared").length,i=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode==="deeper").length,c=u.filter(n=>n.context_inferred).length,p=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode!=="deeper"&&n.continuity_inferred).length;return{accounts:u,sharedCount:s,sharedStandardCount:Math.max(s-i,0),deeperSharedCount:i,isolatedCount:u.length-s,legacyContextCount:c,legacyContinuityCount:p,sharedAloneCount:u.filter(n=>n.context_mode==="shared"&&n.sameGroupPeerCount===0).length,sharedPeerAccountCount:u.filter(n=>n.sameGroupPeerCount>0).length,deeperReadyAccountCount:u.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:()=>O.accounts.list(),select:a=>{const r=a.accounts.filter(i=>i.type!=="cliproxy"),t=We(r),u=a.accounts.length-r.length,s=t.accounts.some(i=>i.name===a.default)?a.default:null;return{accounts:t.accounts,default:s,cliproxyCount:u,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=$();return F({mutationFn:r=>O.accounts.setDefault(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Default account set to "${t}"`)},onError:r=>{k.error(r.message)}})}function et(){const a=$();return F({mutationFn:()=>O.accounts.resetDefault(),onSuccess:()=>{a.invalidateQueries({queryKey:["accounts"]}),k.success("Default account reset to CCS")},onError:r=>{k.error(r.message)}})}function tt(){const a=$();return F({mutationFn:r=>O.accounts.delete(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Account "${t}" deleted`)},onError:r=>{k.error(r.message)}})}function be(){const a=$();return F({mutationFn:({name:r,context_mode:t,context_group:u,continuity_mode:s})=>O.accounts.updateContext(r,{context_mode:t,context_group:u,continuity_mode:s}),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]});const u=t.context_mode==="shared"?t.continuity_mode==="deeper"?`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, deeper continuity)`:`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, standard)`:"isolated";k.success(`Updated "${t.name}" context to ${u}`)},onError:r=>{k.error(r.message)}})}function st(){const a=$();return F({mutationFn:async r=>{const t=r.filter(i=>i.context_inferred||i.continuity_inferred),s=(await Promise.allSettled(t.map(i=>{const c=i.context_mode==="shared";return O.accounts.updateContext(i.name,{context_mode:c?"shared":"isolated",context_group:c?i.context_group||"default":void 0,continuity_mode:c?i.continuity_mode==="deeper"?"deeper":"standard":void 0})}))).filter(i=>i.status==="rejected").length;return{updatedCount:t.length-s,failedCount:s}},onSuccess:({updatedCount:r,failedCount:t})=>{if(a.invalidateQueries({queryKey:["accounts"]}),t>0&&r>0){k.error(`Confirmed ${r} legacy account${r>1?"s":""}, but ${t} update${t>1?"s":""} failed. Refreshed account state.`);return}if(t>0){k.error(`Failed to confirm ${t} legacy account${t>1?"s":""}. Refreshed account state.`);return}if(r>0){k.success(`Confirmed explicit sync mode for ${r} legacy account${r>1?"s":""}`);return}k.info("No legacy accounts need confirmation")},onError:r=>{a.invalidateQueries({queryKey:["accounts"]}),k.error(r.message)}})}const oe=64,at=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function nt({account:a,groupSummaries:r,plainCcsLane:t,onClose:u}){const{t:s}=z(),i=be(),[c,p]=C.useState(a.context_mode==="shared"?"shared":"isolated"),[n,h]=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]),l=C.useMemo(()=>r.find(g=>g.group===x),[r,x]),N=x.length>0&&x.length<=oe&&at.test(x),o=c==="isolated"||N,d=c==="shared"?Math.max((l?.sharedCount??0)-(a.context_mode==="shared"&&a.context_group===x?1:0),0):0,f=c==="shared"?Math.max((l?.deeperCount??0)-(a.continuity_mode==="deeper"&&a.context_group===x?1:0),0):0,v=t?.account_name===a.name,j=!!t&&!v,S=`ccs auth default ${a.name}`,_=`ccs auth backup ${a.name}`,w=(g,K,G,H)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(g.key))return;g.preventDefault();const je=G.indexOf(K),ye=g.key==="ArrowLeft"||g.key==="ArrowUp"?-1:1,Ne=(je+ye+G.length)%G.length;H(G[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:"",A=()=>{o&&i.mutate({name:a.name,context_mode:c,context_group:c==="shared"?x:void 0,continuity_mode:c==="shared"?m:void 0},{onSuccess:()=>{u()}})},B=g=>{g||u()};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(T,{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":c==="isolated",tabIndex:c==="isolated"?0:-1,onClick:()=>p("isolated"),onKeyDown:g=>w(g,c,["isolated","shared"],p),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 ${c==="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":c==="shared",tabIndex:c==="shared"?0:-1,onClick:()=>p("shared"),onKeyDown:g=>w(g,c,["isolated","shared"],p),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 ${c==="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(c==="isolated"?"editAccountContext.isolatedModeHint":"editAccountContext.sharedModeHint")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"context-group",children:s("editAccountContext.historySyncGroup")}),e.jsx(V,{id:"context-group",value:n,onChange:g=>h(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")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(T,{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(D,{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(D,{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:_}),e.jsx(D,{value:_,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:S}),e.jsx(D,{value:S,size:"icon"})]})]})]})}),e.jsx("div",{className:`rounded-[14px] border p-4 text-xs shadow-sm transition-colors ${c==="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:[c==="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:[c==="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] ${c==="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:u,disabled:i.isPending,children:s("editAccountContext.cancel")}),e.jsx(b,{onClick:A,disabled:!o||i.isPending,children:i.isPending?s("editAccountContext.saving"):s("editAccountContext.save")})]})]})})}function ce({data:a,defaultAccount:r,groupSummaries:t,plainCcsLane:u}){const{t:s}=z(),i=Je(),c=tt(),p=et(),n=be(),[h,m]=C.useState(null),[y,x]=C.useState(null),l=[{accessorKey:"name",header:s("accountsTable.name"),size:200,cell:({row:o})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:o.original.name}),o.original.name===r&&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:o})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:o.original.type||"oauth"})},{accessorKey:"created",header:s("accountsTable.created"),size:150,cell:({row:o})=>{const d=new Date(o.original.created);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{accessorKey:"last_used",header:s("accountsTable.lastUsed"),size:150,cell:({row:o})=>{if(!o.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const d=new Date(o.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{id:"context",header:s("accountsTable.historySync"),size:170,cell:({row:o})=>{if(o.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((o.original.context_mode||"isolated")==="shared"){const f=o.original.context_group||"default",v=o.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(P,{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:o.original.sameGroupPeerCount>0?s("accountsTable.sameGroupPeerCount",{count:o.original.sameGroupPeerCount}):s("accountsTable.noSameGroupPeer")})]})}return o.original.context_inferred?e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx(P,{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(P,{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:o})=>{const d=o.original.name===r,f=i.isPending||c.isPending||n.isPending,v=o.original.type==="cliproxy",j=o.original.context_inferred||o.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(o.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:o.original.name,context_mode:o.original.context_mode==="shared"?"shared":"isolated",context_group:o.original.context_mode==="shared"?o.original.context_group||"default":void 0,continuity_mode:o.original.context_mode==="shared"?o.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:()=>i.mutate(o.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(o.original.name),title:s(d?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Be,{className:"w-4 h-4"})})]})}}],N=ke({data:a,columns:l,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(o=>e.jsx(te,{children:o.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)})},o.id))}),e.jsx(_e,{children:N.getRowModel().rows.map(o=>e.jsx(te,{children:o.getVisibleCells().map(d=>e.jsx(Te,{children:ee(d.column.columnDef.cell,d.getContext())},d.id))},o.id))})]})}),r&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),s("accountsTable.resetToDefault")]})})]}),y&&e.jsx(nt,{account:y,groupSummaries:t,plainCcsLane:u,onClose:()=>x(null)}),e.jsx(ze,{open:!!h,onOpenChange:o=>!o&&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:h??""})})]}),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:()=>{h&&(c.mutate(h),m(null))},children:s("accountsTable.delete")})]})]})})]})}const X=({titleKey:a,descKey:r})=>{const{t}=z();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(Re,{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(r)})]})]})};function ie({totalAccounts:a,primaryAccountName:r,isolatedCount:t,sharedStandardCount:u,deeperSharedCount:s,sharedAloneCount:i,sharedPeerAccountCount:c,deeperReadyAccountCount:p,sharedPeerGroups:n,deeperReadyGroups:h,legacyTargetCount:m,cliproxyCount:y,plainCcsLane:x}){const{t:l}=z(),N=x?x.kind==="native"?l("continuityOverview.lane.native"):x.kind==="account-default"?l("continuityOverview.lane.accountDefault",{name:x.account_name||""}):x.kind==="account-inherited"?l("continuityOverview.lane.accountInherited",{name:x.account_name||""}):x.kind==="profile-default"?l("continuityOverview.lane.profileDefault",{name:x.profile_name||"default"}):x.label:"",o=a<2?"single":n.length===0?t===a?"isolated":"shared-alone":h.length===0?"shared-standard":t>0||i>0||p<c||h.length<n.length?"partial":"ready",d=h[0]||n[0]||"default",f=h.length>0&&(t>0||u>0||n.length>h.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"})}[o],S=!!r&&x?.account_name===r,_=a>0&&!!x&&(!r||!S),w=a>1&&o!=="ready";return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(M,{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:l(`continuityReadiness.messages.${o}.title`,{group:d})}),e.jsx(P,{variant:o==="ready"?"default":"secondary",className:"rounded-full px-2.5 py-0.5 font-medium shadow-sm",children:l(`continuityReadiness.state.${o}`)})]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg leading-relaxed",children:l(`continuityReadiness.messages.${o}.description`,{group:d,count:i})})]})]})}),e.jsxs("div",{className:"mt-auto pt-4 flex flex-wrap items-center gap-2",children:[y>0&&e.jsx(P,{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:l("historySyncLearningMap.cliproxyManaged",{count:y})}),m>0&&e.jsx(P,{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:l("historySyncLearningMap.legacyConfirmation",{count:m})}),n.length>0&&h.length===0&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.recommendBadge",{group:d})}),f&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.partialBadge",{group:d})})]})]})}),(_||w)&&e.jsx(M,{className:"border-dashed",children:e.jsxs(R,{className:"p-5 space-y-4",children:[_&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("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(D,{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(D,{value:"ccs auth backup default",size:"icon"})]}),r?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 ${r}`}),e.jsx(D,{value:`ccs auth default ${r}`,size:"icon"})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:l("continuityOverview.setDefaultHint")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityReadiness.stepsTitle")}),e.jsxs("ol",{className:"space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:l("continuityReadiness.steps.syncBoth")}),e.jsx("li",{children:l("continuityReadiness.steps.sameGroup",{group:d})}),e.jsx("li",{children:l("continuityReadiness.steps.enableDeeper")}),e.jsx("li",{children:l("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:l("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:l("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:u})]}),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:l("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 le=64;function rt({open:a,onClose:r}){const{t}=z(),[u,s]=C.useState(""),[i,c]=C.useState(!1),[p,n]=C.useState(""),[h,m]=C.useState(!1),[y,x]=C.useState(!1),l=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(u),N=p.trim().toLowerCase().replace(/\s+/g,"-"),o=N.length===0||N.length<=le&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(N),d=u&&l?[`ccs auth create ${u}`,i?N.length>0?`--context-group ${N}`:"--share-context":"",i&&h?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),f=async()=>{!l||i&&!o||(await navigator.clipboard.writeText(d),x(!0),setTimeout(()=>x(!1),2e3))},v=()=>{s(""),c(!1),n(""),m(!1),x(!1),r()};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(T,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx(V,{id:"profile-name",value:u,onChange:j=>s(j.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),u&&!l&&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:i,onCheckedChange:j=>c(j===!0)}),e.jsx(T,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),i&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(T,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx(V,{id:"context-group",value:p,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:h,onCheckedChange:j=>m(j===!0)}),e.jsx(T,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),p.trim().length>0&&!o&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:le})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{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:!l||i&&!o,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:!l||i&&!o,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}=z(),r=ve(),{data:t,isLoading:u}=Ye(),s=st(),[i,c]=C.useState(!1),p=t?.accounts||[],n=t?.cliproxyCount||0,h=t?.legacyContextCount||0,m=t?.legacyContinuityCount||0,y=t?.sharedCount||0,x=t?.sharedStandardCount||0,l=t?.deeperSharedCount||0,N=t?.isolatedCount||0,o=t?.sharedAloneCount||0,d=t?.sharedPeerAccountCount||0,f=t?.deeperReadyAccountCount||0,v=t?.sharedPeerGroups||[],j=t?.deeperReadyGroups||[],S=t?.sharedGroups||[],_=t?.groupSummaries||[],w=t?.plainCcsLane||null,L=p.filter(H=>H.context_inferred||H.continuity_inferred),A=L.length,B=A>0,g=()=>r("/cliproxy?provider=claude"),K=()=>r("/cliproxy?provider=claude&action=auth"),G=()=>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(Oe,{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:()=>c(!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:[h>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContextPending",{count:h})}),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:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:a("accountsPage.noLegacyFollowup")}),e.jsxs(M,{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(D,{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(D,{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(P,{variant:"outline",children:a("accountsPage.workspaceBadge")}),e.jsx(P,{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(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{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:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(M,{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:()=>c(!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:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}),e.jsx(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{children:[e.jsx(I,{className:"pb-3",children:e.jsx(q,{className:"text-base",children:a("accountsPage.accountMatrix")})}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]}),e.jsx(rt,{open:i,onClose:()=>c(!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-
|
|
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-BmSzf0T9.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 u,h as qe}from"./react-vendor-CNOkPC89.js";import{B as M,c as Q,T as Ve,p as We,q as Ye,r as Ge,s as Xe,t as Ze,v as es,w as xe,d as w,a as B,n as ne,L as D,I as H,x as J,y as Ee,z as ss,A as ts,D as as,E as rs,S as ve,F as ee,G as pe,H as Re,J as ns,K as is,M as Ae,N as _e,O as Le,Q as ls,R as os,U as be,V as we,W as se,X as cs,Y as De,Z as Ne,C as Me,b as Qe,j as ds,k as ms,_ as us,$ as xs,a0 as hs,a1 as ps,a2 as gs,a3 as fs,a4 as js,a5 as Ns,a6 as vs,a7 as bs}from"./index-DOn6k1jF.js";import{a as ws,u as ge,b as Ce}from"./tanstack-CrmUhA7Z.js";import{C as fe}from"./confirm-dialog-BlSaX2gK.js";import{t as E}from"./notifications-B2HqRBj7.js";import{L as te,R as X,as as Fe,at as Cs,a9 as ae,_ as ys,au as Ie,aa as re,C as He,av as ks,a7 as Ss,aw as Ps,p as je,X as Os,ax as Ts,Z as Ue,ay as $e,n as ye,az as ke,aA as Es,aB as he,a6 as Rs,ad as As,aC as _s,w as ze,aD as Ls,x as Ke,o as Ds,aE as Ms}from"./icons-KVCk4_U8.js";import{M as Je}from"./masked-input-C2H-Ax0Z.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-QyEXocpn.js";function Qs({className:s,showTooltip:r=!0}){const a=e.jsxs(M,{variant:"outline",className:Q("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 r?e.jsxs(Ve,{children:[e.jsx(We,{asChild:!0,children:a}),e.jsx(Ye,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):a}function Se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(a=>a.test(s))}function Be(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Fs(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,r){const a={...s};return r.opus?a.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete a.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?a.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete a.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?a.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete a.ANTHROPIC_DEFAULT_HAIKU_MODEL,a}function Hs({profileName:s,target:r,data:a,settings:d,isLoading:c,isSaving:g,isTargetSaving:h,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:x,onDelete:v,onSave:C}){const y=g||h,j=c||y;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}),a?.path&&e.jsx(M,{variant:"outline",className:"text-xs",children:a.path.replace(/^.*\//,"")}),Be(d)&&e.jsx(Qs,{className:"ml-1"})]}),a&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(a.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ge,{value:r,onValueChange:k=>{j||p(k)},disabled:j,children:[e.jsx(Xe,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(Ze,{})}),e.jsxs(es,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"}),e.jsx(xe,{value:"codex",children:"Codex CLI"})]})]}),h&&e.jsx(te,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:x,disabled:j,children:e.jsx(X,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),v&&e.jsx(w,{variant:"ghost",size:"sm",onClick:v,disabled:y,children:e.jsx(Fe,{className:"w-4 h-4 text-destructive"})}),e.jsx(w,{size:"sm",onClick:C,disabled:y||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Us({currentSettings:s,newEnvKey:r,newEnvValue:a,onNewEnvKeyChange:d,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:h}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{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,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(D,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Se(t)&&e.jsx(M,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Se(t)?e.jsx(Je,{value:p,onChange:x=>g(t,x.target.value),className:"font-mono text-sm h-8"}):e.jsx(H,{value:p,onChange:x=>g(t,x.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:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(D,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>d(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(H,{placeholder:f("envEditor.valuePlaceholder"),value:a,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:h,disabled:!r.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]})}function $s({profileName:s,target:r,data:a}){const{t:d}=B(),c=r==="droid";return e.jsx(ne,{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(ys,{className:"w-4 h-4"}),d("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:a&&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:d("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:a.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:d("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:a.path}),e.jsx(J,{value:a.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:d("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(a.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:d("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:d("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(D,{className:"text-xs text-muted-foreground",children:d("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(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d(c?"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(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d(c?"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 ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d("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(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function zs({value:s,onChange:r,placeholder:a="Search models...",className:d}){const[c,g]=u.useState(""),[h,f]=u.useState(null),{models:t,isLoading:p,isError:x,isFetching:v}=Ee(),C=ss(),y=u.useMemo(()=>ts(t,c,{category:h??void 0}),[t,c,h]),j=u.useMemo(()=>as(t,2),[t]),k=!c.trim()&&!h,R=u.useMemo(()=>{const n={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};y.forEach(m=>{n[m.category].push(m)});for(const m of Object.keys(n))n[m]=rs(n[m]);return n},[y]),N=u.useCallback(()=>{C()},[C]),S=t.find(n=>n.id===s);return p&&t.length===0?e.jsxs("div",{className:Q("space-y-2",d),children:[e.jsx(ve,{className:"h-10 w-full"}),e.jsx(ve,{className:"h-32 w-full"})]}):e.jsxs("div",{className:Q("space-y-2 w-full min-w-0 overflow-hidden",d),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(H,{value:c,onChange:n=>g(n.target.value),placeholder:a,className:"pl-9"})]}),e.jsx(w,{variant:"outline",size:"icon",onClick:N,disabled:v,title:"Refresh models",children:v?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(M,{variant:h===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(ee).map(n=>{const m=R[n].length;return m===0?null:e.jsxs(M,{variant:h===n?"default":"outline",className:"cursor-pointer",onClick:()=>f(n),children:[ee[n]," (",m,")"]},n)})]}),S&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[pe(S.pricing)," |"," ",Re(S.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:x?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(w,{variant:"link",onClick:N,children:"Retry"})]}):y.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[k&&j.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(re,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(n=>e.jsx(Pe,{model:n,isSelected:n.id===s,onClick:()=>r(n.id),showAge:!0},n.id))})]}),Object.keys(ee).map(n=>{const m=R[n];return m.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:ee[n]}),e.jsx("div",{className:"space-y-1",children:m.map(o=>e.jsx(Pe,{model:o,isSelected:o.id===s,onClick:()=>r(o.id)},o.id))})]},n)})]})})]})}function Pe({model:s,isSelected:r,onClick:a,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:a,className:Q("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",r&&"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:Q("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[d&&s.created&&e.jsx(M,{variant:"outline",className:Q("text-[10px] px-1",r?"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:ns(s.created)}),s.isFree?e.jsx(M,{variant:"secondary",className:Q("text-[10px] px-1",r?"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(M,{variant:"outline",className:Q("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"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:pe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:pe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Re(s.context_length)})]})]})}function Ks({selectedModel:s,value:r,onChange:a,className:d}){const{t:c}=B(),{models:g}=Ee(),h=u.useMemo(()=>s?is(s,g):{},[s,g]),f=()=>{a(h)},t=(x,v)=>{a({...r,[x]:v||void 0})},p=s&&Object.keys(h).length>0;return e.jsxs(Ae,{className:Q("group",d),children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(He,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(Le,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ks,{className:"mr-1 h-4 w-4"}),c("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(D,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(H,{id:"tier-opus",value:r.opus??"",onChange:x=>t("opus",x.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(H,{id:"tier-sonnet",value:r.sonnet??"",onChange:x=>t("sonnet",x.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(H,{id:"tier-haiku",value:r.haiku??"",onChange:x=>t("haiku",x.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Js({profileName:s,target:r,data:a,currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:x}){const v=Be(d),C=d?.env,y=u.useMemo(()=>Fs(C??{}),[C]),j=C??{},k=o=>{if(x){const U={...j,ANTHROPIC_MODEL:o,ANTHROPIC_DEFAULT_OPUS_MODEL:o,ANTHROPIC_DEFAULT_SONNET_MODEL:o,ANTHROPIC_DEFAULT_HAIKU_MODEL:o};x(U)}else t("ANTHROPIC_MODEL",o),t("ANTHROPIC_DEFAULT_OPUS_MODEL",o),t("ANTHROPIC_DEFAULT_SONNET_MODEL",o),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o);E.success(se.t("commonToast.appliedModelAllTiers"),{duration:2e3})},R=o=>{if(x){const U=Is(j,o);x(U)}else o.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",o.opus||""),o.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",o.sonnet||""),o.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o.haiku||"")},[N,S]=u.useState(!1),n=new Set(["ANTHROPIC_AUTH_TOKEN"]),m=Object.entries(j).filter(([o])=>!n.has(o));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(os,{className:"w-full",children:[e.jsx(be,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(be,{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(we,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:v?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(D,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(zs,{value:j.ANTHROPIC_MODEL,onChange:k,placeholder:"Search OpenRouter models..."})]}),e.jsx(Ks,{selectedModel:j.ANTHROPIC_MODEL,value:y,onChange:R}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Je,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:o=>t("ANTHROPIC_AUTH_TOKEN",o.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"})]})]}),m.length>0&&e.jsxs(Ae,{open:N,onOpenChange:S,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(He,{className:Q("h-4 w-4 transition-transform",N&&"rotate-90")}),e.jsx(Ss,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",m.length,")"]})]}),e.jsx(Le,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:m.map(([o,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:o}),e.jsx(H,{value:U,onChange:$=>t(o,$.target.value),className:"font-mono text-xs h-8"})]},o))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(D,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:"VARIABLE_NAME",value:c,onChange:o=>h(o.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(H,{placeholder:"value",value:g,onChange:o=>f(o.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]}):e.jsx(Us,{currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(we,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($s,{profileName:s,target:r,data:a})})]})]})})}function Bs({profileName:s,profileTarget:r,onDelete:a,onHasChangesUpdate:d}){const[c,g]=u.useState({}),[h,f]=u.useState(!1),[t,p]=u.useState(null),[x,v]=u.useState(""),[C,y]=u.useState(""),j=ws(),{data:k,isLoading:R,isError:N,refetch:S}=ge({queryKey:["settings",s],queryFn:async()=>{const l=await fetch(`/api/settings/${s}/raw`);if(!l.ok)throw new Error(`Failed to load settings: ${l.status}`);return l.json()}}),n=k?.settings,m=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(n)return{...n,env:{...n.env,...c}}},[n,c,t]),o=u.useMemo(()=>t!==null?t:n?JSON.stringify(n,null,2):"",[t,n]),U=u.useCallback(l=>{p(l)},[]),$=u.useCallback(l=>{const b={...m??{}},_=b.ccs_image&&typeof b.ccs_image=="object"?{...b.ccs_image}:{};l?_.native_read=!0:delete _.native_read,Object.keys(_).length>0?b.ccs_image=_:delete b.ccs_image,p(JSON.stringify(b,null,2))},[m]),q=(l,b)=>{const _={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2))},K=l=>{const b={...m?.env||{},...l};g(_=>({..._,...l})),p(JSON.stringify({...m,env:b},null,2))},Z=()=>{if(!x.trim())return;const l=x.trim(),b=C,_={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2)),v(""),y("")},P=u.useMemo(()=>{try{return JSON.parse(o),!0}catch{return!1}},[o]),F=u.useMemo(()=>t!==null?t!==JSON.stringify(n,null,2):Object.keys(c).length>0,[t,c,n]),T=u.useDeferredValue(o),z=u.useMemo(()=>{if(!F||!P)return null;try{return JSON.parse(T)}catch{return null}},[F,P,T]),{data:V,isFetching:ie,isError:W,isPlaceholderData:le}=ge({queryKey:["settings",s,"image-analysis-status-preview",T],enabled:z!==null,placeholderData:l=>l,queryFn:async()=>{const l=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!l.ok)throw new Error(`Failed to preview image-analysis status: ${l.status}`);return l.json()}}),oe=F&&P&&!W?V?.imageAnalysisStatus??k?.imageAnalysisStatus:k?.imageAnalysisStatus,ce=F&&P&&!W&&V?.imageAnalysisStatus?"editor":"saved",de=F?P?W?"saved":ie&&(!V?.imageAnalysisStatus||le)?"refreshing":"preview":"invalid":"saved",me=m?.ccs_image?.native_read===!0,ue=u.useMemo(()=>{const l=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],b=m?.env||{};return l.filter(_=>!b[_]?.trim())},[m]);u.useEffect(()=>{d?.(F)},[F,d]);const i=Ce({mutationFn:async()=>{let l;try{l=JSON.parse(o)}catch{l={...k?.settings,env:{...k?.settings?.env,...c}}}const b=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:l,expectedMtime:k?.mtime})});if(b.status===409)throw new Error("CONFLICT");if(!b.ok)throw new Error("Failed to save");return b.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),E.success(se.t("commonToast.settingsSaved"))},onError:l=>{l.message==="CONFLICT"?f(!0):E.error(l.message)}}),A=Ce({mutationFn:async l=>(await De.profiles.update(s,{target:l}),l),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),E.success(se.t("commonToast.defaultTargetUpdated"))},onError:(l,b)=>{const _=b==="droid"?"Factory Droid":b==="codex"?"Codex CLI":"Claude Code",Y=l.message.trim()?`: ${l.message}`:"";E.error(se.t("commonToast.failedUpdateDefaultTarget",{target:_,suffix:Y}))}}),O=r||"claude",I=i.isPending||A.isPending,L=async l=>{f(!1),l?(await S(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Hs,{profileName:s,target:O,data:k,settings:m,isLoading:R,isSaving:i.isPending,isTargetSaving:A.isPending,hasChanges:F,isRawJsonValid:P,onTargetChange:l=>{I||l!==O&&A.mutate(l)},onRefresh:()=>{I||S()},onDelete:a,onSave:()=>{I||i.mutate()}}),R?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(te,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):N?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:"Failed to load settings."}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>S(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"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:O,data:k,currentSettings:m,newEnvKey:x,newEnvValue:C,onNewEnvKeyChange:v,onNewEnvValueChange:y,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:Z})}),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(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(cs,{rawJsonContent:o,isRawJsonValid:P,rawJsonEdits:t,settings:n,profileTarget:O,imageAnalysisStatus:oe,imageAnalysisStatusSource:ce,imageAnalysisStatusPreviewState:de,nativeReadPreferenceOverride:me,onToggleNativeRead:$,onChange:U,missingRequiredFields:ue})]})]}),e.jsx(fe,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>L(!0),onCancel:()=>L(!1)})]},s)}const Oe="ccs:openrouter-banner-dismissed";function qs({onCreateClick:s}){const[r,a]=u.useState(!0),{modelCount:d,isLoading:c}=Ne();u.useEffect(()=>{const h=localStorage.getItem(Oe)==="true";a(h)},[]);const g=()=>{localStorage.setItem(Oe,"true"),a(!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(re,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${d}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(w,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),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(je,{className:"w-3 h-3"})]}),e.jsxs(w,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Os,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Vs(){return ge({queryKey:["profiles","local-runtime-readiness"],queryFn:()=>De.profiles.getLocalRuntimeReadiness(),staleTime:15e3,refetchOnWindowFocus:!1})}function G({badge:s,badgeClassName:r,className:a,title:d,description:c,visual:g,highlights:h,actionLabel:f,actionClassName:t,onAction:p,footer:x}){return e.jsxs(Me,{className:Q("flex h-full flex-col border shadow-sm",a),children:[e.jsxs(ds,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(M,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ms,{className:"text-base",children:d}),e.jsx(us,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Qe,{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:h.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(w,{onClick:p,className:t,children:[f,e.jsx(Rs,{className:"ml-2 h-4 w-4"})]}),x?e.jsx("div",{className:"text-xs text-muted-foreground",children:x}):null]})]})}function Te(s,r,a){return s?s.status==="ready"?{badge:a("openrouterQuickStart.localRuntimeReadyBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",actionLabel:a("openrouterQuickStart.localRuntimeUseAction",{label:r}),description:a("openrouterQuickStart.localRuntimeReadyDescription"),footer:a("openrouterQuickStart.localRuntimeReadyFooter",{endpoint:s.endpoint})}:s.status==="missing-model"?{badge:a("openrouterQuickStart.localRuntimeNeedsModelBadge"),badgeClassName:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",actionLabel:a("openrouterQuickStart.localRuntimeFinishAction",{label:r}),description:a("openrouterQuickStart.localRuntimeNeedsModelDescription"),footer:a("openrouterQuickStart.localRuntimeMissingModelFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeOfflineBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeOfflineDescription"),footer:a("openrouterQuickStart.localRuntimeOfflineFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeCheckingBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeCheckingDescription"),footer:a("openrouterQuickStart.localRuntimeCheckingFooter")}}function Ws({hasProfiles:s,profileCount:r,onOpenRouterClick:a,onAlibabaCodingPlanClick:d,onCliproxyClick:c,onCustomClick:g,onOllamaClick:h,onLlamacppClick:f}){const{t}=B(),{modelCount:p,isLoading:x}=Ne(),{data:v}=Vs(),C=x?"300+":`${p}+`,y=s?t("openrouterQuickStart.profileSummaryCount",{count:r}):t("openrouterQuickStart.profileSummaryEmpty"),j=t(s?"openrouterQuickStart.summaryExistingTitle":"openrouterQuickStart.summaryEmptyTitle"),k=s?t("openrouterQuickStart.summaryExistingDescription",{count:r}):t("openrouterQuickStart.summaryEmptyDescription"),R=v?.runtimes.find(m=>m.id==="ollama"),N=v?.runtimes.find(m=>m.id==="llamacpp"),S=Te(R,t("openrouterQuickStart.localOllamaLabel"),t),n=Te(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(Me,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Qe,{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(M,{variant:"secondary",children:y}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeDefaultQuality")}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeLocalLane")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:j}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:k})]})]}),e.jsx(w,{variant:"outline",onClick:g,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(Ts,{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(G,{badge:t("openrouterQuickStart.recommended"),title:t("openrouterQuickStart.title"),description:t("openrouterQuickStart.description",{modelCountLabel:C}),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(Ue,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.featureOneApi")},{icon:e.jsx(re,{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:a,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(je,{className:"h-3 w-3"})]})]})}),e.jsx(G,{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($e,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{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:d,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(je,{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(ke,{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(G,{badge:S.badge,badgeClassName:S.badgeClassName,title:t("openrouterQuickStart.localOllamaTitle"),description:S.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(Es,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.localOllamaHighlight")},{icon:e.jsx(re,{className:"h-3.5 w-3.5 text-emerald-600"}),label:R?.detectedModelCount&&R.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:R.detectedModelCount}):t("openrouterQuickStart.localNoModelsDetected")}],actionLabel:S.actionLabel,actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:h,footer:e.jsx("span",{children:S.footer})}),e.jsx(G,{badge:n.badge,badgeClassName:n.badgeClassName,title:t("openrouterQuickStart.localLlamacppTitle"),description:n.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(he,{className:"h-3.5 w-3.5 text-sky-600"}),label:t("openrouterQuickStart.localLlamacppHighlight")},{icon:e.jsx(ke,{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:n.actionLabel,actionClassName:"w-full bg-sky-600 text-white hover:bg-sky-600/90",onAction:f,footer:e.jsx("span",{children:n.footer})})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:e.jsx(G,{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(he,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(he,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{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:c,footer:e.jsx("span",{children:t("openrouterQuickStart.runtimeProviderFooter")})})})]})})}function Ys({onCreateClick:s}){const{modelCount:r,isLoading:a}=Ne();return 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:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[a?"300+":`${r}+`," models available"]})]}),e.jsxs(w,{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(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Gs({onCreateClick:s}){const{t:r}=B();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:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(w,{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($e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function mt(){const{t:s}=B(),r=qe(),{data:a,isLoading:d,isError:c,refetch:g}=xs(),h=hs(),f=ps(),t=gs(),p=fs(),x=js(),v=Ns(),[C,y]=u.useState(null),[j,k]=u.useState(""),[R,N]=u.useState(!1),[S,n]=u.useState("normal"),[m,o]=u.useState(null),[U,$]=u.useState(!1),[q,K]=u.useState(null),Z=u.useRef(null);vs();const P=u.useMemo(()=>a?.profiles||[],[a?.profiles]),F=u.useMemo(()=>P.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[P,j]),T=C?P.find(i=>i.name===C):null,z=i=>{U&&C!==i?K(i):y(i)},V=i=>{h.mutate(i,{onSuccess:()=>{C===i&&(y(null),$(!1),K(null)),o(null)}})},ie=i=>{N(!1),z(i)},W=i=>{z(i)},le=(i,A)=>{const O=JSON.stringify(A,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as u,h as qe}from"./react-vendor-CNOkPC89.js";import{B as M,c as Q,T as Ve,p as We,q as Ye,r as Ge,s as Xe,t as Ze,v as es,w as xe,d as w,a as B,n as ne,L as D,I as H,x as J,y as Ee,z as ss,A as ts,D as as,E as rs,S as ve,F as ee,G as pe,H as Re,J as ns,K as is,M as Ae,N as _e,O as Le,Q as ls,R as os,U as be,V as we,W as se,X as cs,Y as De,Z as Ne,C as Me,b as Qe,j as ds,k as ms,_ as us,$ as xs,a0 as hs,a1 as ps,a2 as gs,a3 as fs,a4 as js,a5 as Ns,a6 as vs,a7 as bs}from"./index-BmSzf0T9.js";import{a as ws,u as ge,b as Ce}from"./tanstack-CrmUhA7Z.js";import{C as fe}from"./confirm-dialog-CpDk6eu4.js";import{t as E}from"./notifications-B2HqRBj7.js";import{L as te,R as X,as as Fe,at as Cs,a9 as ae,_ as ys,au as Ie,aa as re,C as He,av as ks,a7 as Ss,aw as Ps,p as je,X as Os,ax as Ts,Z as Ue,ay as $e,n as ye,az as ke,aA as Es,aB as he,a6 as Rs,ad as As,aC as _s,w as ze,aD as Ls,x as Ke,o as Ds,aE as Ms}from"./icons-KVCk4_U8.js";import{M as Je}from"./masked-input-h0XkMSwB.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Tc_D1a_B.js";function Qs({className:s,showTooltip:r=!0}){const a=e.jsxs(M,{variant:"outline",className:Q("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 r?e.jsxs(Ve,{children:[e.jsx(We,{asChild:!0,children:a}),e.jsx(Ye,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):a}function Se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(a=>a.test(s))}function Be(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Fs(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,r){const a={...s};return r.opus?a.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete a.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?a.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete a.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?a.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete a.ANTHROPIC_DEFAULT_HAIKU_MODEL,a}function Hs({profileName:s,target:r,data:a,settings:d,isLoading:c,isSaving:g,isTargetSaving:h,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:x,onDelete:v,onSave:C}){const y=g||h,j=c||y;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}),a?.path&&e.jsx(M,{variant:"outline",className:"text-xs",children:a.path.replace(/^.*\//,"")}),Be(d)&&e.jsx(Qs,{className:"ml-1"})]}),a&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(a.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ge,{value:r,onValueChange:k=>{j||p(k)},disabled:j,children:[e.jsx(Xe,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(Ze,{})}),e.jsxs(es,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"}),e.jsx(xe,{value:"codex",children:"Codex CLI"})]})]}),h&&e.jsx(te,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:x,disabled:j,children:e.jsx(X,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),v&&e.jsx(w,{variant:"ghost",size:"sm",onClick:v,disabled:y,children:e.jsx(Fe,{className:"w-4 h-4 text-destructive"})}),e.jsx(w,{size:"sm",onClick:C,disabled:y||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Us({currentSettings:s,newEnvKey:r,newEnvValue:a,onNewEnvKeyChange:d,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:h}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{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,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(D,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Se(t)&&e.jsx(M,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Se(t)?e.jsx(Je,{value:p,onChange:x=>g(t,x.target.value),className:"font-mono text-sm h-8"}):e.jsx(H,{value:p,onChange:x=>g(t,x.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:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(D,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>d(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(H,{placeholder:f("envEditor.valuePlaceholder"),value:a,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:h,disabled:!r.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]})}function $s({profileName:s,target:r,data:a}){const{t:d}=B(),c=r==="droid";return e.jsx(ne,{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(ys,{className:"w-4 h-4"}),d("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:a&&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:d("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:a.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:d("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:a.path}),e.jsx(J,{value:a.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:d("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(a.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:d("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:d("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(D,{className:"text-xs text-muted-foreground",children:d("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(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d(c?"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(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d(c?"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 ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:d("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(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function zs({value:s,onChange:r,placeholder:a="Search models...",className:d}){const[c,g]=u.useState(""),[h,f]=u.useState(null),{models:t,isLoading:p,isError:x,isFetching:v}=Ee(),C=ss(),y=u.useMemo(()=>ts(t,c,{category:h??void 0}),[t,c,h]),j=u.useMemo(()=>as(t,2),[t]),k=!c.trim()&&!h,R=u.useMemo(()=>{const n={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};y.forEach(m=>{n[m.category].push(m)});for(const m of Object.keys(n))n[m]=rs(n[m]);return n},[y]),N=u.useCallback(()=>{C()},[C]),S=t.find(n=>n.id===s);return p&&t.length===0?e.jsxs("div",{className:Q("space-y-2",d),children:[e.jsx(ve,{className:"h-10 w-full"}),e.jsx(ve,{className:"h-32 w-full"})]}):e.jsxs("div",{className:Q("space-y-2 w-full min-w-0 overflow-hidden",d),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(H,{value:c,onChange:n=>g(n.target.value),placeholder:a,className:"pl-9"})]}),e.jsx(w,{variant:"outline",size:"icon",onClick:N,disabled:v,title:"Refresh models",children:v?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(M,{variant:h===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(ee).map(n=>{const m=R[n].length;return m===0?null:e.jsxs(M,{variant:h===n?"default":"outline",className:"cursor-pointer",onClick:()=>f(n),children:[ee[n]," (",m,")"]},n)})]}),S&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[pe(S.pricing)," |"," ",Re(S.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:x?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(w,{variant:"link",onClick:N,children:"Retry"})]}):y.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[k&&j.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(re,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(n=>e.jsx(Pe,{model:n,isSelected:n.id===s,onClick:()=>r(n.id),showAge:!0},n.id))})]}),Object.keys(ee).map(n=>{const m=R[n];return m.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:ee[n]}),e.jsx("div",{className:"space-y-1",children:m.map(o=>e.jsx(Pe,{model:o,isSelected:o.id===s,onClick:()=>r(o.id)},o.id))})]},n)})]})})]})}function Pe({model:s,isSelected:r,onClick:a,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:a,className:Q("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",r&&"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:Q("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[d&&s.created&&e.jsx(M,{variant:"outline",className:Q("text-[10px] px-1",r?"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:ns(s.created)}),s.isFree?e.jsx(M,{variant:"secondary",className:Q("text-[10px] px-1",r?"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(M,{variant:"outline",className:Q("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"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:pe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:pe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Re(s.context_length)})]})]})}function Ks({selectedModel:s,value:r,onChange:a,className:d}){const{t:c}=B(),{models:g}=Ee(),h=u.useMemo(()=>s?is(s,g):{},[s,g]),f=()=>{a(h)},t=(x,v)=>{a({...r,[x]:v||void 0})},p=s&&Object.keys(h).length>0;return e.jsxs(Ae,{className:Q("group",d),children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(He,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(Le,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ks,{className:"mr-1 h-4 w-4"}),c("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(D,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(H,{id:"tier-opus",value:r.opus??"",onChange:x=>t("opus",x.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(H,{id:"tier-sonnet",value:r.sonnet??"",onChange:x=>t("sonnet",x.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(H,{id:"tier-haiku",value:r.haiku??"",onChange:x=>t("haiku",x.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Js({profileName:s,target:r,data:a,currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:x}){const v=Be(d),C=d?.env,y=u.useMemo(()=>Fs(C??{}),[C]),j=C??{},k=o=>{if(x){const U={...j,ANTHROPIC_MODEL:o,ANTHROPIC_DEFAULT_OPUS_MODEL:o,ANTHROPIC_DEFAULT_SONNET_MODEL:o,ANTHROPIC_DEFAULT_HAIKU_MODEL:o};x(U)}else t("ANTHROPIC_MODEL",o),t("ANTHROPIC_DEFAULT_OPUS_MODEL",o),t("ANTHROPIC_DEFAULT_SONNET_MODEL",o),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o);E.success(se.t("commonToast.appliedModelAllTiers"),{duration:2e3})},R=o=>{if(x){const U=Is(j,o);x(U)}else o.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",o.opus||""),o.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",o.sonnet||""),o.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o.haiku||"")},[N,S]=u.useState(!1),n=new Set(["ANTHROPIC_AUTH_TOKEN"]),m=Object.entries(j).filter(([o])=>!n.has(o));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(os,{className:"w-full",children:[e.jsx(be,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(be,{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(we,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:v?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(D,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(zs,{value:j.ANTHROPIC_MODEL,onChange:k,placeholder:"Search OpenRouter models..."})]}),e.jsx(Ks,{selectedModel:j.ANTHROPIC_MODEL,value:y,onChange:R}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Je,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:o=>t("ANTHROPIC_AUTH_TOKEN",o.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"})]})]}),m.length>0&&e.jsxs(Ae,{open:N,onOpenChange:S,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(He,{className:Q("h-4 w-4 transition-transform",N&&"rotate-90")}),e.jsx(Ss,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",m.length,")"]})]}),e.jsx(Le,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:m.map(([o,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:o}),e.jsx(H,{value:U,onChange:$=>t(o,$.target.value),className:"font-mono text-xs h-8"})]},o))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(D,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:"VARIABLE_NAME",value:c,onChange:o=>h(o.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(H,{placeholder:"value",value:g,onChange:o=>f(o.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]}):e.jsx(Us,{currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(we,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($s,{profileName:s,target:r,data:a})})]})]})})}function Bs({profileName:s,profileTarget:r,onDelete:a,onHasChangesUpdate:d}){const[c,g]=u.useState({}),[h,f]=u.useState(!1),[t,p]=u.useState(null),[x,v]=u.useState(""),[C,y]=u.useState(""),j=ws(),{data:k,isLoading:R,isError:N,refetch:S}=ge({queryKey:["settings",s],queryFn:async()=>{const l=await fetch(`/api/settings/${s}/raw`);if(!l.ok)throw new Error(`Failed to load settings: ${l.status}`);return l.json()}}),n=k?.settings,m=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(n)return{...n,env:{...n.env,...c}}},[n,c,t]),o=u.useMemo(()=>t!==null?t:n?JSON.stringify(n,null,2):"",[t,n]),U=u.useCallback(l=>{p(l)},[]),$=u.useCallback(l=>{const b={...m??{}},_=b.ccs_image&&typeof b.ccs_image=="object"?{...b.ccs_image}:{};l?_.native_read=!0:delete _.native_read,Object.keys(_).length>0?b.ccs_image=_:delete b.ccs_image,p(JSON.stringify(b,null,2))},[m]),q=(l,b)=>{const _={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2))},K=l=>{const b={...m?.env||{},...l};g(_=>({..._,...l})),p(JSON.stringify({...m,env:b},null,2))},Z=()=>{if(!x.trim())return;const l=x.trim(),b=C,_={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2)),v(""),y("")},P=u.useMemo(()=>{try{return JSON.parse(o),!0}catch{return!1}},[o]),F=u.useMemo(()=>t!==null?t!==JSON.stringify(n,null,2):Object.keys(c).length>0,[t,c,n]),T=u.useDeferredValue(o),z=u.useMemo(()=>{if(!F||!P)return null;try{return JSON.parse(T)}catch{return null}},[F,P,T]),{data:V,isFetching:ie,isError:W,isPlaceholderData:le}=ge({queryKey:["settings",s,"image-analysis-status-preview",T],enabled:z!==null,placeholderData:l=>l,queryFn:async()=>{const l=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!l.ok)throw new Error(`Failed to preview image-analysis status: ${l.status}`);return l.json()}}),oe=F&&P&&!W?V?.imageAnalysisStatus??k?.imageAnalysisStatus:k?.imageAnalysisStatus,ce=F&&P&&!W&&V?.imageAnalysisStatus?"editor":"saved",de=F?P?W?"saved":ie&&(!V?.imageAnalysisStatus||le)?"refreshing":"preview":"invalid":"saved",me=m?.ccs_image?.native_read===!0,ue=u.useMemo(()=>{const l=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],b=m?.env||{};return l.filter(_=>!b[_]?.trim())},[m]);u.useEffect(()=>{d?.(F)},[F,d]);const i=Ce({mutationFn:async()=>{let l;try{l=JSON.parse(o)}catch{l={...k?.settings,env:{...k?.settings?.env,...c}}}const b=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:l,expectedMtime:k?.mtime})});if(b.status===409)throw new Error("CONFLICT");if(!b.ok)throw new Error("Failed to save");return b.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),E.success(se.t("commonToast.settingsSaved"))},onError:l=>{l.message==="CONFLICT"?f(!0):E.error(l.message)}}),A=Ce({mutationFn:async l=>(await De.profiles.update(s,{target:l}),l),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),E.success(se.t("commonToast.defaultTargetUpdated"))},onError:(l,b)=>{const _=b==="droid"?"Factory Droid":b==="codex"?"Codex CLI":"Claude Code",Y=l.message.trim()?`: ${l.message}`:"";E.error(se.t("commonToast.failedUpdateDefaultTarget",{target:_,suffix:Y}))}}),O=r||"claude",I=i.isPending||A.isPending,L=async l=>{f(!1),l?(await S(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Hs,{profileName:s,target:O,data:k,settings:m,isLoading:R,isSaving:i.isPending,isTargetSaving:A.isPending,hasChanges:F,isRawJsonValid:P,onTargetChange:l=>{I||l!==O&&A.mutate(l)},onRefresh:()=>{I||S()},onDelete:a,onSave:()=>{I||i.mutate()}}),R?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(te,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):N?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:"Failed to load settings."}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>S(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"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:O,data:k,currentSettings:m,newEnvKey:x,newEnvValue:C,onNewEnvKeyChange:v,onNewEnvValueChange:y,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:Z})}),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(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(cs,{rawJsonContent:o,isRawJsonValid:P,rawJsonEdits:t,settings:n,profileTarget:O,imageAnalysisStatus:oe,imageAnalysisStatusSource:ce,imageAnalysisStatusPreviewState:de,nativeReadPreferenceOverride:me,onToggleNativeRead:$,onChange:U,missingRequiredFields:ue})]})]}),e.jsx(fe,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>L(!0),onCancel:()=>L(!1)})]},s)}const Oe="ccs:openrouter-banner-dismissed";function qs({onCreateClick:s}){const[r,a]=u.useState(!0),{modelCount:d,isLoading:c}=Ne();u.useEffect(()=>{const h=localStorage.getItem(Oe)==="true";a(h)},[]);const g=()=>{localStorage.setItem(Oe,"true"),a(!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(re,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${d}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(w,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),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(je,{className:"w-3 h-3"})]}),e.jsxs(w,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Os,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Vs(){return ge({queryKey:["profiles","local-runtime-readiness"],queryFn:()=>De.profiles.getLocalRuntimeReadiness(),staleTime:15e3,refetchOnWindowFocus:!1})}function G({badge:s,badgeClassName:r,className:a,title:d,description:c,visual:g,highlights:h,actionLabel:f,actionClassName:t,onAction:p,footer:x}){return e.jsxs(Me,{className:Q("flex h-full flex-col border shadow-sm",a),children:[e.jsxs(ds,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(M,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ms,{className:"text-base",children:d}),e.jsx(us,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Qe,{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:h.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(w,{onClick:p,className:t,children:[f,e.jsx(Rs,{className:"ml-2 h-4 w-4"})]}),x?e.jsx("div",{className:"text-xs text-muted-foreground",children:x}):null]})]})}function Te(s,r,a){return s?s.status==="ready"?{badge:a("openrouterQuickStart.localRuntimeReadyBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",actionLabel:a("openrouterQuickStart.localRuntimeUseAction",{label:r}),description:a("openrouterQuickStart.localRuntimeReadyDescription"),footer:a("openrouterQuickStart.localRuntimeReadyFooter",{endpoint:s.endpoint})}:s.status==="missing-model"?{badge:a("openrouterQuickStart.localRuntimeNeedsModelBadge"),badgeClassName:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",actionLabel:a("openrouterQuickStart.localRuntimeFinishAction",{label:r}),description:a("openrouterQuickStart.localRuntimeNeedsModelDescription"),footer:a("openrouterQuickStart.localRuntimeMissingModelFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeOfflineBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeOfflineDescription"),footer:a("openrouterQuickStart.localRuntimeOfflineFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeCheckingBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeCheckingDescription"),footer:a("openrouterQuickStart.localRuntimeCheckingFooter")}}function Ws({hasProfiles:s,profileCount:r,onOpenRouterClick:a,onAlibabaCodingPlanClick:d,onCliproxyClick:c,onCustomClick:g,onOllamaClick:h,onLlamacppClick:f}){const{t}=B(),{modelCount:p,isLoading:x}=Ne(),{data:v}=Vs(),C=x?"300+":`${p}+`,y=s?t("openrouterQuickStart.profileSummaryCount",{count:r}):t("openrouterQuickStart.profileSummaryEmpty"),j=t(s?"openrouterQuickStart.summaryExistingTitle":"openrouterQuickStart.summaryEmptyTitle"),k=s?t("openrouterQuickStart.summaryExistingDescription",{count:r}):t("openrouterQuickStart.summaryEmptyDescription"),R=v?.runtimes.find(m=>m.id==="ollama"),N=v?.runtimes.find(m=>m.id==="llamacpp"),S=Te(R,t("openrouterQuickStart.localOllamaLabel"),t),n=Te(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(Me,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Qe,{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(M,{variant:"secondary",children:y}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeDefaultQuality")}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeLocalLane")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:j}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:k})]})]}),e.jsx(w,{variant:"outline",onClick:g,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(Ts,{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(G,{badge:t("openrouterQuickStart.recommended"),title:t("openrouterQuickStart.title"),description:t("openrouterQuickStart.description",{modelCountLabel:C}),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(Ue,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.featureOneApi")},{icon:e.jsx(re,{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:a,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(je,{className:"h-3 w-3"})]})]})}),e.jsx(G,{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($e,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{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:d,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(je,{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(ke,{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(G,{badge:S.badge,badgeClassName:S.badgeClassName,title:t("openrouterQuickStart.localOllamaTitle"),description:S.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(Es,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.localOllamaHighlight")},{icon:e.jsx(re,{className:"h-3.5 w-3.5 text-emerald-600"}),label:R?.detectedModelCount&&R.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:R.detectedModelCount}):t("openrouterQuickStart.localNoModelsDetected")}],actionLabel:S.actionLabel,actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:h,footer:e.jsx("span",{children:S.footer})}),e.jsx(G,{badge:n.badge,badgeClassName:n.badgeClassName,title:t("openrouterQuickStart.localLlamacppTitle"),description:n.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(he,{className:"h-3.5 w-3.5 text-sky-600"}),label:t("openrouterQuickStart.localLlamacppHighlight")},{icon:e.jsx(ke,{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:n.actionLabel,actionClassName:"w-full bg-sky-600 text-white hover:bg-sky-600/90",onAction:f,footer:e.jsx("span",{children:n.footer})})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:e.jsx(G,{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(he,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(he,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{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:c,footer:e.jsx("span",{children:t("openrouterQuickStart.runtimeProviderFooter")})})})]})})}function Ys({onCreateClick:s}){const{modelCount:r,isLoading:a}=Ne();return 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:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[a?"300+":`${r}+`," models available"]})]}),e.jsxs(w,{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(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Gs({onCreateClick:s}){const{t:r}=B();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:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(w,{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($e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function mt(){const{t:s}=B(),r=qe(),{data:a,isLoading:d,isError:c,refetch:g}=xs(),h=hs(),f=ps(),t=gs(),p=fs(),x=js(),v=Ns(),[C,y]=u.useState(null),[j,k]=u.useState(""),[R,N]=u.useState(!1),[S,n]=u.useState("normal"),[m,o]=u.useState(null),[U,$]=u.useState(!1),[q,K]=u.useState(null),Z=u.useRef(null);vs();const P=u.useMemo(()=>a?.profiles||[],[a?.profiles]),F=u.useMemo(()=>P.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[P,j]),T=C?P.find(i=>i.name===C):null,z=i=>{U&&C!==i?K(i):y(i)},V=i=>{h.mutate(i,{onSuccess:()=>{C===i&&(y(null),$(!1),K(null)),o(null)}})},ie=i=>{N(!1),z(i)},W=i=>{z(i)},le=(i,A)=>{const O=JSON.stringify(A,null,2)+`
|
|
2
2
|
`,I=new Blob([O],{type:"application/json"}),L=URL.createObjectURL(I),l=document.createElement("a");l.href=L,l.download=i,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(L)},oe=async()=>{try{const i=await f.mutateAsync();if(i.orphans.length===0){E.success("No orphan profile settings found");return}const A=i.orphans.filter(l=>l.validation.valid).length;if(!window.confirm(`Found ${i.orphans.length} orphan settings file(s). Register ${A} valid profile(s) now?`))return;const I=await t.mutateAsync({}),L=I.skipped.length>0?`, skipped ${I.skipped.length}`:"";E.success(`Registered ${I.registered.length} profile(s)${L}`)}catch(i){E.error(i.message)}},ce=async()=>{if(!T)return;const i=window.prompt(`Copy profile "${T.name}" to new profile name:`,`${T.name}-copy`);if(!i)return;const A=i.trim();if(!A){E.error("Destination profile name cannot be empty");return}try{const O=await p.mutateAsync({name:T.name,data:{destination:A}});z(A),O.warnings&&O.warnings.length>0&&E.info(O.warnings.join(`
|
|
3
3
|
`))}catch(O){E.error(O.message)}},de=async()=>{if(T)try{const i=await x.mutateAsync({name:T.name});le(`${T.name}.ccs-profile.json`,i.bundle),i.redacted?E.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):E.success("Profile export downloaded")}catch(i){E.error(i.message)}},me=()=>{Z.current?.click()},ue=async i=>{const A=i.target.files?.[0];if(i.target.value="",!!A)try{const O=await A.text(),I=JSON.parse(O),L=await v.mutateAsync({bundle:I});L.name&&z(L.name),L.warnings&&L.warnings.length>0&&E.info(L.warnings.join(`
|
|
4
4
|
`))}catch(O){E.error(O.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(qs,{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(As,{className:"w-5 h-5 text-primary"}),e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"font-semibold",children:"Profiles"})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{size:"sm",variant:"outline",onClick:()=>void oe(),disabled:f.isPending||t.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(w,{size:"sm",variant:"outline",onClick:me,disabled:v.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(_s,{className:"w-4 h-4"})}),e.jsxs(w,{size:"sm",onClick:()=>{N(!0)},children:[e.jsx(ae,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsx("p",{className:"mb-3 text-xs leading-4 text-muted-foreground",children:"Premium APIs, local runtimes, custom endpoints"}),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(H,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:j,onChange:i=>k(i.target.value)})]})]}),e.jsx(ne,{className:"flex-1 min-h-0",children:d?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):c?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(ze,{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(w,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):F.length===0?e.jsx("div",{className:"p-4 text-center",children:P.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ls,{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(w,{size:"sm",variant:"outline",onClick:()=>{N(!0)},children:[e.jsx(ae,{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:j})})}):e.jsx("div",{className:"p-2 space-y-1",children:F.map(i=>e.jsx(Xs,{profile:i,isSelected:C===i.name,onSelect:()=>W(i.name),onDelete:()=>o(i.name)},i.name))})}),P.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:P.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ke,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:P.filter(i=>i.configured).length})]})]})}),e.jsx(Ys,{onCreateClick:()=>{n("openrouter"),N(!0)}}),e.jsx(Gs,{onCreateClick:()=>{n("alibaba-coding-plan"),N(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:T?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(w,{size:"sm",variant:"outline",onClick:()=>void ce(),disabled:p.isPending,children:[e.jsx(Ds,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>void de(),disabled:x.isPending,children:[e.jsx(Ms,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(Bs,{profileName:T.name,profileTarget:T.target,onDelete:()=>o(T.name),onHasChangesUpdate:$},T.name)]}):e.jsx(Ws,{hasProfiles:P.length>0,profileCount:P.length,onCliproxyClick:()=>{r("/cliproxy/ai-providers")},onOpenRouterClick:()=>{n("openrouter"),N(!0)},onAlibabaCodingPlanClick:()=>{n("alibaba-coding-plan"),N(!0)},onOllamaClick:()=>{n("ollama"),N(!0)},onLlamacppClick:()=>{n("llamacpp"),N(!0)},onCustomClick:()=>{n("normal"),N(!0)}})})]}),e.jsx("input",{ref:Z,type:"file",accept:".json,application/json",className:"hidden",onChange:i=>void ue(i)}),e.jsx(bs,{open:R,onOpenChange:N,onSuccess:ie,initialMode:S}),e.jsx(fe,{open:!!m,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:m??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>m&&V(m),onCancel:()=>o(null)}),e.jsx(fe,{open:!!q,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:C??"",next:q??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{$(!1),y(q),K(null)},onCancel:()=>K(null)})]})}function Xs({profile:s,isSelected:r,onSelect:a,onDelete:d}){return e.jsxs("div",{className:Q("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",r?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[s.configured?e.jsx(Ke,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(ze,{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(M,{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(J,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),d()},children:e.jsx(Fe,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{mt 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-
|
|
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-BmSzf0T9.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 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bv as E,n as k,S as n,C as g,be as R,bg as D,B as T,d as C}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bv as E,n as k,S as n,C as g,be as R,bg as D,B as T,d as C}from"./index-BmSzf0T9.js";import{A as O,a as _,b as F,c as I,d as P,e as z,f as L,g as U}from"./alert-dialog-Tc_D1a_B.js";import{w as $,x as H,ae as v,v as M,Q as Y,R as J}from"./icons-KVCk4_U8.js";import"./tanstack-CrmUhA7Z.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const Q=3e3,q=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,y]=r.useState([]),[f,N]=r.useState(!0),[u,w]=r.useState(null),[i,l]=r.useState(null),[c,b]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();y(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{w(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}b(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{w(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>b(null),Q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),q);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&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(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(I,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(P,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(z,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
|